mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path='../node/node.d.ts'/>
|
||||
|
||||
/// <reference path='../redis/redis.d.ts'/>
|
||||
|
||||
Vendored
+6
@@ -961,6 +961,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
@Default 150
|
||||
*/
|
||||
hideBalloonTime: number;
|
||||
/** Allows changing language easily.
|
||||
* Note, you should include the language.js file from amcharts/lang or ammap/lang folder and then use variable name used in this file, like chart.language = "de";
|
||||
* Note, for maps this works differently - you use language only for country names, as there are no other strings in the maps application. */
|
||||
language: string;
|
||||
/** Legend of a chart. */
|
||||
legend: AmLegend;
|
||||
/** Reference to the div of the legend. */
|
||||
@@ -989,6 +993,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
prefixesOfBigNumbers: any[];
|
||||
/** Prefixes which are used to make small numbers shorter: 2μ instead of 0.000002, etc. Prefixes are used on value axes and in the legend. To enable prefixes, set usePrefixes property to true. [{number:1e-24, prefix:"y"},{number:1e-21, prefix:"z"},{number:1e-18, prefix:"a"},{number:1e-15, prefix:"f"},{number:1e-12, prefix:"p"},{number:1e-9, prefix:"n"},{number:1e-6, prefix:"μ"},{number:1e-3, prefix:"m"}] */
|
||||
prefixesOfSmallNumbers: any[];
|
||||
/** A config object for Responsive plugin. */
|
||||
responsive: any;
|
||||
/** Theme of a chart. Config files of themes can be found in amcharts/themes/ folder. More info about using themes. */
|
||||
theme: string;
|
||||
/** Thousands separator.
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// Tests for Amplitude SDK TypeScript definitions
|
||||
|
||||
/// <reference path="amplitude-js.d.ts" />
|
||||
|
||||
module Amplitude.Tests {
|
||||
function all() {
|
||||
amplitude.init('YOUR_API_KEY_HERE', null, {
|
||||
// optional configuration options
|
||||
saveEvents: true,
|
||||
includeUtm: true,
|
||||
includeReferrer: true,
|
||||
batchEvents: true,
|
||||
eventUploadThreshold: 50
|
||||
});
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {});
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE');
|
||||
amplitude.setUserId('USER_ID_HERE');
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE');
|
||||
amplitude.setUserId(null); // not string 'null'
|
||||
amplitude.setVersionName('VERSION_NAME_HERE');
|
||||
|
||||
amplitude.regenerateDeviceId();
|
||||
amplitude.setDeviceId('CUSTOM_DEVICE_ID');
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE', {
|
||||
'color': 'blue',
|
||||
'age': 20,
|
||||
'key': 'value'
|
||||
});
|
||||
amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
|
||||
|
||||
let identify = new amplitude.Identify().set('gender', 'female').set('age', 20);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().unset('gender').unset('age');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('karma', 10)
|
||||
.add('karma', 1)
|
||||
.unset('karma');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('colors', ['rose', 'gold'])
|
||||
.append('ab-tests', 'campaign_a')
|
||||
.append('existing_list', [4, 5]);
|
||||
amplitude.identify(identify);
|
||||
|
||||
amplitude.setUserProperties({
|
||||
gender: 'female',
|
||||
age: 20
|
||||
});
|
||||
|
||||
amplitude.clearUserProperties();
|
||||
|
||||
amplitude.setOptOut(true);
|
||||
amplitude.setOptOut(false);
|
||||
|
||||
amplitude.setGroup('orgId', '15');
|
||||
amplitude.setGroup('sport', ['soccer', 'tennis']);
|
||||
|
||||
// TODO: Implement those.
|
||||
/*
|
||||
var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
|
||||
amplitude.logRevenueV2(revenue);
|
||||
|
||||
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
|
||||
*/
|
||||
}
|
||||
}
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
// Type definitions for Amplitude SDK 2.12.1
|
||||
// Project: https://github.com/amplitude/Amplitude-Javascript
|
||||
// Definitions by: Arvydas Sidorenko <https://github.com/Asido>
|
||||
// Definitions: https://github.com/Asido/DefinitelyTyped
|
||||
|
||||
declare module amplitude {
|
||||
interface Config {
|
||||
batchEvents?: boolean;
|
||||
cookieExpiration?: number;
|
||||
cookieName?: string;
|
||||
deviceId?: string;
|
||||
domain?: string;
|
||||
eventUploadPeriodMillis?: number;
|
||||
eventUploadThreshold?: number;
|
||||
includeReferrer?: boolean;
|
||||
includeUtm?: boolean;
|
||||
language?: string;
|
||||
optOut?: boolean;
|
||||
platform?: string;
|
||||
saveEvents?: boolean;
|
||||
savedMaxCount?: number;
|
||||
sessionTimeout?: number;
|
||||
uploadBatchSize?: number;
|
||||
}
|
||||
|
||||
export class Identify {
|
||||
set(key: string, value: any): Identify;
|
||||
setOnce(key: string, value: any): Identify;
|
||||
add(key: string, value: number): Identify;
|
||||
append(key: string, value: any): Identify;
|
||||
prepend(key: string, value: any): Identify;
|
||||
|
||||
unset(key: string): Identify;
|
||||
}
|
||||
|
||||
export function init(apiKey: string): void;
|
||||
export function init(apiKey: string, userId: string): void;
|
||||
export function init(apiKey: string, userId: string, options: Config): void;
|
||||
export function init(apiKey: string, userId: string, options: Config, callback: () => void): void;
|
||||
|
||||
export function setVersionName(version: string): void;
|
||||
export function setUserId(userId: string): void;
|
||||
|
||||
export function setDeviceId(id: string): void;
|
||||
export function regenerateDeviceId(): void;
|
||||
|
||||
export function identify(identify: Identify): void;
|
||||
|
||||
export function setUserProperties(properties: Object): void;
|
||||
export function clearUserProperties(): void;
|
||||
|
||||
export function setOptOut(optOut: boolean): void;
|
||||
|
||||
export function setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
export function logEvent(event: string): void;
|
||||
export function logEvent(event: string, data: Object): void;
|
||||
export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void;
|
||||
|
||||
export var options: Config;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/// <reference path="./angular-es.d.ts" />
|
||||
|
||||
//
|
||||
// @Component
|
||||
//
|
||||
import { Component } from 'angular-es';
|
||||
@Component({
|
||||
selector: '',
|
||||
template: ''
|
||||
})
|
||||
class MyComponentController {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Config
|
||||
//
|
||||
import { Config } from 'angular-es';
|
||||
|
||||
@Config()
|
||||
class MyConfig {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Constant
|
||||
//
|
||||
import { Constant } from 'angular-es';
|
||||
|
||||
@Constant('MyConstant')
|
||||
class MyConstant {
|
||||
foo = 'foo';
|
||||
bar = 'bar';
|
||||
}
|
||||
|
||||
//
|
||||
// @Controller
|
||||
//
|
||||
import { Controller } from 'angular-es';
|
||||
|
||||
@Controller('MyController')
|
||||
class MyController {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Decorator
|
||||
//
|
||||
import { Decorator } from 'angular-es';
|
||||
|
||||
@Decorator('MyServiceDecorator')
|
||||
class MyServiceDecorator {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Directive
|
||||
//
|
||||
import { Directive } from 'angular-es';
|
||||
|
||||
@Directive('MyDirective')
|
||||
class MyDirective {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Factory
|
||||
//
|
||||
import { Factory } from 'angular-es';
|
||||
|
||||
@Factory('MyFactory')
|
||||
class MyFactory {
|
||||
}
|
||||
|
||||
//
|
||||
// @Filter
|
||||
//
|
||||
import { Filter } from 'angular-es';
|
||||
|
||||
@Filter('MyFilter')
|
||||
class MyFilter {
|
||||
}
|
||||
|
||||
//
|
||||
// @Inject
|
||||
//
|
||||
import { Inject } from 'angular-es';
|
||||
|
||||
@Inject('fooBar')
|
||||
class MyFooService {
|
||||
|
||||
@Inject('bazBar')
|
||||
myMethod(bazBar: Object) {
|
||||
}
|
||||
|
||||
constructor(fooBar: Object) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @InjectAsProperty
|
||||
//
|
||||
import { InjectAsProperty } from 'angular-es';
|
||||
|
||||
@InjectAsProperty('fooBar')
|
||||
class MyFooBarService {
|
||||
fooBar: Object;
|
||||
|
||||
myMethod() {
|
||||
this.fooBar !== undefined;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @Module
|
||||
//
|
||||
import { Module } from 'angular-es';
|
||||
|
||||
@Module('my.module')
|
||||
@Service('MyModuleService')
|
||||
class MyModuleService {
|
||||
}
|
||||
|
||||
//
|
||||
// @Provider
|
||||
//
|
||||
import { Provider } from 'angular-es';
|
||||
|
||||
@Provider('MyProvider')
|
||||
class MyProvider {
|
||||
}
|
||||
|
||||
//
|
||||
// @Run
|
||||
//
|
||||
import { Run } from 'angular-es';
|
||||
|
||||
@Run()
|
||||
class MyRunBlock {
|
||||
}
|
||||
|
||||
//
|
||||
// @Service
|
||||
//
|
||||
import { Service } from 'angular-es';
|
||||
|
||||
@Service('MyService')
|
||||
class MyService {
|
||||
}
|
||||
//
|
||||
// @Value
|
||||
//
|
||||
import { Value } from 'angular-es';
|
||||
|
||||
@Value('MyValue')
|
||||
class MyValue {
|
||||
}
|
||||
Vendored
+187
@@ -0,0 +1,187 @@
|
||||
// Type definitions for angular-es v0.0.3
|
||||
// Project: https://github.com/mbutsykin/angular-es
|
||||
// Definitions by: mbutsykin <https://github.com/mbutsykin/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'angular-es' {
|
||||
|
||||
interface ClassDecorator {
|
||||
<TFunction extends Function>(target: TFunction): TFunction|void;
|
||||
}
|
||||
|
||||
interface MethodDecorator {
|
||||
<T>(target: Object, propertyKey: string|symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>|void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorated target
|
||||
*/
|
||||
interface ngESDecorator extends ClassDecorator, MethodDecorator {
|
||||
(target: Object|Function,
|
||||
ngName?: string,
|
||||
ngArguments?: Array<any>,
|
||||
ngType?: string,
|
||||
injectAsProperty?: Array<string>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Component interface
|
||||
* @see https://docs.angularjs.org/guide/component
|
||||
*/
|
||||
interface iComponent {
|
||||
template: string,
|
||||
selector: string,
|
||||
controllerAs?: string,
|
||||
require?: string,
|
||||
templateUrl?: string,
|
||||
transclude?: string,
|
||||
bindings?: Object
|
||||
}
|
||||
|
||||
/**
|
||||
* Register component
|
||||
*
|
||||
* @param {Object<iComponent>} component - component config
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Component: (component: iComponent) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register config block
|
||||
*/
|
||||
var Config: () => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register constant
|
||||
*
|
||||
* @param {string} name - constant name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Constant: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register controller
|
||||
*
|
||||
* @param {string} name - controller name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Controller: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register decorator
|
||||
*
|
||||
* @param {string} name - provider name to decorate
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Decorator: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register directive
|
||||
*
|
||||
* @param {string} name - directive selector, can be in hyphen-case
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Directive: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register factory
|
||||
*
|
||||
* @param {string} name - factory name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Factory: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register filter
|
||||
*
|
||||
* @param {string} name - filter name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Filter: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Add $inject property to target
|
||||
*
|
||||
* @param {Array<string>} dependencies - dependencies to inject
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Inject: (...dependencies: Array<string>) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Inject dependencies as properties to target
|
||||
*
|
||||
* @param {Array<string>} dependencies - dependencies to inject
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var InjectAsProperty: (...dependencies: Array<string>) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Attach target to the specified module
|
||||
*
|
||||
* @param {string} name - module name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Module: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register provider
|
||||
*
|
||||
* @param {string} name - provider name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Provider: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register run block
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Run: () => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register service
|
||||
*
|
||||
* @param {string} name - service name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Service: (name: string) => ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register value
|
||||
*
|
||||
* @param {string} name - value name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
var Value: (name: string) => ngESDecorator;
|
||||
|
||||
export {
|
||||
Component,
|
||||
Config,
|
||||
Constant,
|
||||
Controller,
|
||||
Decorator,
|
||||
Directive,
|
||||
Factory,
|
||||
Filter,
|
||||
Inject,
|
||||
InjectAsProperty,
|
||||
Module,
|
||||
Provider,
|
||||
Run,
|
||||
Service,
|
||||
Value,
|
||||
}
|
||||
}
|
||||
Vendored
+3
-3
@@ -51,12 +51,12 @@ declare namespace angular.gettext {
|
||||
/** Get the correct pluralized (but untranslated) string for the value of n. */
|
||||
getStringForm(string: string, n: number): string;
|
||||
|
||||
/** Translate a string with the given context. Uses Angular.JS interpolation, so something like this will do what you expect:
|
||||
/** Translate a string with the given scope. Uses Angular.JS interpolation, so something like this will do what you expect:
|
||||
* var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
|
||||
* // var hello will be "Hallo Ruben!" in Dutch.
|
||||
* The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
|
||||
* The scope parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
|
||||
*/
|
||||
getString(string: string, context?: any): string;
|
||||
getString(string: string, scope?: any, context?: string): string;
|
||||
|
||||
/** Translate a plural string with the given context. */
|
||||
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/// <reference path="angular-ui-notification.d.ts" />
|
||||
|
||||
function TestNotifications(NotificationProvider: angular.uiNotification.INotificationProvider, Notification: angular.uiNotification.INotificationService) {
|
||||
NotificationProvider.setOptions({
|
||||
delay: 10000,
|
||||
startTop: 20,
|
||||
startRight: 10,
|
||||
verticalSpacing: 20,
|
||||
horizontalSpacing: 20,
|
||||
positionX: 'left',
|
||||
positionY: 'bottom'
|
||||
});
|
||||
|
||||
Notification.primary('Primary notification');
|
||||
Notification('Primary notification');
|
||||
|
||||
Notification.success('Success notification');
|
||||
|
||||
Notification({message: 'Warning notification'}, 'warning');
|
||||
|
||||
Notification({message: 'Primary notification', title: 'Primary notification'});
|
||||
|
||||
Notification.error({message: 'Error notification 1s', delay: 1000});
|
||||
|
||||
Notification.success({message: 'Success notification<br>Some other <b>content</b><br><a href="https://github.com/alexcrack/angular-ui-notification">This is a link</a><br><img src="https://angularjs.org/img/AngularJS-small.png">', title: 'Html content'});
|
||||
|
||||
Notification.error({message: 'Error Bottom Right', positionY: 'bottom', positionX: 'right'});
|
||||
|
||||
Notification.error({message: 'Error notification 1s', replaceMessage: true});
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// Type definitions for angular-ui-notification
|
||||
// Project: https://github.com/alexcrack/angular-ui-notification
|
||||
// Definitions by: Kamil Rojewski <https://github.com/krojew/DefinitelyTyped>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace angular.uiNotification {
|
||||
// Taken from angular to avoid dependency
|
||||
interface IPromise<T> {
|
||||
/**
|
||||
* Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected.
|
||||
* The successCallBack may return IPromise<void> for when a $q.reject() needs to be returned
|
||||
* This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
|
||||
*/
|
||||
then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
|
||||
|
||||
/**
|
||||
* Shorthand for promise.then(null, errorCallback)
|
||||
*/
|
||||
catch<TResult>(onRejected: (reason: any) => IPromise<TResult>|TResult): IPromise<TResult>;
|
||||
|
||||
/**
|
||||
* Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information.
|
||||
*
|
||||
* Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible.
|
||||
*/
|
||||
finally(finallyCallback: () => any): IPromise<T>;
|
||||
}
|
||||
|
||||
type XPosition = 'right'|'left'|'center';
|
||||
type YPosition = 'top'|'bottom';
|
||||
|
||||
type MessageType = 'primary'|'info'|'success'|'warning'|'error';
|
||||
|
||||
interface IGlobalMessageOptions {
|
||||
delay?: number;
|
||||
startTop?: number;
|
||||
startRight?: number;
|
||||
verticalSpacing?: number;
|
||||
horizontalSpacing?: number;
|
||||
positionX?: XPosition;
|
||||
positionY?: YPosition;
|
||||
replaceMessage?: boolean;
|
||||
templateUrl?: string;
|
||||
onClose?: (element: any) => any;
|
||||
closeOnClick?: boolean;
|
||||
maxCount?: number;
|
||||
}
|
||||
|
||||
interface IMessageOptions {
|
||||
title?: string;
|
||||
message?: string;
|
||||
templateUrl?: string;
|
||||
delay?: number;
|
||||
type?: MessageType;
|
||||
positionX?: XPosition;
|
||||
positionY?: YPosition;
|
||||
replaceMessage?: boolean;
|
||||
closeOnClick?: boolean;
|
||||
}
|
||||
|
||||
interface INotificationScope {
|
||||
kill(isHard: boolean): void;
|
||||
}
|
||||
|
||||
interface INotificationProvider {
|
||||
setOptions(options: IGlobalMessageOptions): void;
|
||||
}
|
||||
|
||||
type Message = string|IMessageOptions;
|
||||
|
||||
interface INotificationService {
|
||||
primary(message: Message): IPromise<INotificationScope>;
|
||||
info(message: Message): IPromise<INotificationScope>;
|
||||
success(message: Message): IPromise<INotificationScope>;
|
||||
warning(message: Message): IPromise<INotificationScope>;
|
||||
error(message: Message): IPromise<INotificationScope>;
|
||||
|
||||
clearAll(): void;
|
||||
|
||||
(message: Message, type?: MessageType): IPromise<INotificationScope>;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -476,7 +476,7 @@ declare namespace angular {
|
||||
// Supplement IComponentOptions from angular.d.ts with router-specific
|
||||
// fields.
|
||||
interface IComponentOptions {
|
||||
$canActivate?: () => boolean;
|
||||
$canActivate?: (...args: any[]) => boolean | angular.IPromise<boolean>;
|
||||
$routeConfig?: RouteDefinition[];
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+9
-4
@@ -238,6 +238,7 @@ declare namespace angular {
|
||||
* @param directiveFactory An injectable directive factory function.
|
||||
*/
|
||||
directive(name: string, inlineAnnotatedFunction: any[]): IModule;
|
||||
directive(name: string, injectionFunction: Function): IModule;
|
||||
directive(object: Object): IModule;
|
||||
/**
|
||||
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
|
||||
@@ -1745,12 +1746,12 @@ declare namespace angular {
|
||||
*/
|
||||
$onInit?(): void;
|
||||
/**
|
||||
* Called whenever one-way bindings are updated. The changesObj is a hash whose keys are the names of the bound
|
||||
* properties that have changed, and the values are an {@link IChangesObject} object of the form
|
||||
* Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
|
||||
* properties that have changed, and the values are an {@link IChangesObject} object of the form
|
||||
* { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
|
||||
* cloning the bound value to prevent accidental mutation of the outer value.
|
||||
*/
|
||||
$onChanges?(changesObj: {[property:string]: IChangesObject}): void;
|
||||
$onChanges?(onChangesObj: IOnChangesObject): void;
|
||||
/**
|
||||
* Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
|
||||
* watches and event handlers.
|
||||
@@ -1766,6 +1767,10 @@ declare namespace angular {
|
||||
*/
|
||||
$postLink?(): void;
|
||||
}
|
||||
|
||||
interface IOnChangesObject {
|
||||
[property: string]: IChangesObject;
|
||||
}
|
||||
|
||||
interface IChangesObject {
|
||||
currentValue: any;
|
||||
@@ -1825,7 +1830,7 @@ declare namespace angular {
|
||||
bindToController?: boolean | Object;
|
||||
link?: IDirectiveLinkFn | IDirectivePrePost;
|
||||
multiElement?: boolean;
|
||||
name?: string;
|
||||
directiveName?: string;
|
||||
priority?: number;
|
||||
/**
|
||||
* @deprecated
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Gorgi Kosev <https://github.com/spion>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path="../anydb-sql/anydb-sql.d.ts" />
|
||||
|
||||
declare module "anydb-sql-migrations" {
|
||||
@@ -31,4 +31,4 @@ declare module "anydb-sql-migrations" {
|
||||
items: MigrationTask[];
|
||||
}) => any) => Promise<any>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path="../request/request.d.ts" />
|
||||
|
||||
declare module "asana" {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="auth0-js.d.ts" />
|
||||
|
||||
var auth0 = new Auth0({
|
||||
domain: 'mine.auth0.com',
|
||||
clientID: 'dsa7d77dsa7d7',
|
||||
callbackURL: 'http://my-app.com/callback',
|
||||
callbackOnLocationHash: true
|
||||
});
|
||||
|
||||
auth0.login({
|
||||
connection: 'google-oauth2',
|
||||
popup: true,
|
||||
popupOptions: {
|
||||
width: 450,
|
||||
height: 800
|
||||
}
|
||||
}, (err, profile, idToken, accessToken, state) => {
|
||||
if (err) {
|
||||
alert("something went wrong: " + err.message);
|
||||
return;
|
||||
}
|
||||
alert('hello ' + profile.name);
|
||||
});
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
// Type definitions for Auth0.js
|
||||
// Project: https://github.com/auth0/auth0.js
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/** Extensions to the browser Window object. */
|
||||
interface Window {
|
||||
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
|
||||
token: string;
|
||||
}
|
||||
|
||||
/** This is the interface for the main Auth0 client. */
|
||||
interface Auth0Static {
|
||||
|
||||
new(options: Auth0ClientOptions): Auth0Static;
|
||||
changePassword(options: any, callback?: Function): void;
|
||||
decodeJwt(jwt: string): any;
|
||||
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
|
||||
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
logout(query: string): void;
|
||||
getConnections(callback?: Function): void;
|
||||
refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
|
||||
getSSOData(withActiveDirectories: any, callback?: Function): void;
|
||||
parseHash(hash: string): Auth0DecodedHash;
|
||||
signup(options: Auth0SignupOptions, callback: Function): void;
|
||||
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
|
||||
}
|
||||
|
||||
/** Represents constructor options for the Auth0 client. */
|
||||
interface Auth0ClientOptions {
|
||||
clientID: string;
|
||||
callbackURL: string;
|
||||
callbackOnLocationHash?: boolean;
|
||||
domain: string;
|
||||
forceJSONP?: boolean;
|
||||
}
|
||||
|
||||
/** Represents a normalized UserProfile. */
|
||||
interface Auth0UserProfile {
|
||||
email: string;
|
||||
email_verified: boolean;
|
||||
family_name: string;
|
||||
gender: string;
|
||||
given_name: string;
|
||||
locale: string;
|
||||
name: string;
|
||||
nickname: string;
|
||||
picture: string;
|
||||
user_id: string;
|
||||
/** Represents one or more Identities that may be associated with the User. */
|
||||
identities: Auth0Identity[];
|
||||
user_metadata?: any;
|
||||
app_metadata?: any;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
|
||||
interface MicrosoftUserProfile extends Auth0UserProfile {
|
||||
emails: string[];
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
|
||||
interface Office365UserProfile extends Auth0UserProfile {
|
||||
tenantid: string;
|
||||
upn: string;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
|
||||
interface AdfsUserProfile extends Auth0UserProfile {
|
||||
issuer: string;
|
||||
}
|
||||
|
||||
/** Represents multiple identities assigned to a user. */
|
||||
interface Auth0Identity {
|
||||
access_token: string;
|
||||
connection: string;
|
||||
isSocial: boolean;
|
||||
provider: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
interface Auth0DecodedHash {
|
||||
access_token: string;
|
||||
id_token: string;
|
||||
profile: Auth0UserProfile;
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface Auth0PopupOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface Auth0LoginOptions {
|
||||
auto_login?: boolean;
|
||||
connection?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
popup?: boolean;
|
||||
popupOptions?: Auth0PopupOptions;
|
||||
}
|
||||
|
||||
interface Auth0SignupOptions extends Auth0LoginOptions {
|
||||
auto_login: boolean;
|
||||
}
|
||||
|
||||
interface Auth0Error {
|
||||
code: any;
|
||||
details: any;
|
||||
name: string;
|
||||
message: string;
|
||||
status: any;
|
||||
}
|
||||
|
||||
/** Represents the response from an API Token Delegation request. */
|
||||
interface Auth0DelegationToken {
|
||||
/** The length of time in seconds the token is valid for. */
|
||||
expires_in: string;
|
||||
/** The JWT for delegated access. */
|
||||
id_token: string;
|
||||
/** The type of token being returned. Possible values: "Bearer" */
|
||||
token_type: string;
|
||||
}
|
||||
|
||||
declare var Auth0: Auth0Static;
|
||||
|
||||
declare module "auth0-js" {
|
||||
export = Auth0
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
/// <reference path="auth0.lock.d.ts" />
|
||||
|
||||
const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Brian Caruso <https://github.com/carusology>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
|
||||
interface Auth0LockAdditionalSignUpFieldOption {
|
||||
value: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
/// <reference path="auth0.widget.d.ts" />
|
||||
|
||||
var widget: Auth0WidgetStatic = new Auth0Widget({
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
|
||||
|
||||
interface Auth0WidgetStatic {
|
||||
|
||||
+48
-20
@@ -1,23 +1,51 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="auth0.d.ts" />
|
||||
|
||||
var auth0 = new Auth0({
|
||||
domain: 'mine.auth0.com',
|
||||
clientID: 'dsa7d77dsa7d7',
|
||||
callbackURL: 'http://my-app.com/callback',
|
||||
callbackOnLocationHash: true
|
||||
import * as auth0 from 'auth0';
|
||||
|
||||
const management = new auth0.ManagementClient({
|
||||
token: '{YOUR_API_V2_TOKEN}',
|
||||
domain: '{YOUR_ACCOUNT}.auth0.com'
|
||||
});
|
||||
|
||||
auth0.login({
|
||||
connection: 'google-oauth2',
|
||||
popup: true,
|
||||
popupOptions: {
|
||||
width: 450,
|
||||
height: 800
|
||||
}
|
||||
}, (err, profile, idToken, accessToken, state) => {
|
||||
if (err) {
|
||||
alert("something went wrong: " + err.message);
|
||||
return;
|
||||
}
|
||||
alert('hello ' + profile.name);
|
||||
});
|
||||
const auth = new auth0.AuthenticationClient({
|
||||
domain: '{YOUR_ACCOUNT}.auth0.com',
|
||||
clientId: '{OPTIONAL_CLIENT_ID}'
|
||||
});
|
||||
|
||||
// Using a callback.
|
||||
management.getUsers((err: Error, users: auth0.User[]) => {
|
||||
if (err) {
|
||||
// Handle error.
|
||||
}
|
||||
console.log(users);
|
||||
});
|
||||
|
||||
// Using a Promise.
|
||||
management
|
||||
.getUsers()
|
||||
.then((users) => {
|
||||
console.log(users);
|
||||
})
|
||||
.catch((err) => {
|
||||
// Handle the error.
|
||||
});
|
||||
|
||||
management
|
||||
.createUser({
|
||||
connection: 'My-Connection',
|
||||
email: 'hi@me.co',
|
||||
}).then((user) => {
|
||||
console.log(user);
|
||||
}).catch((err) => {
|
||||
// Handle the error.
|
||||
});
|
||||
|
||||
auth
|
||||
.requestChangePasswordEmail({
|
||||
connection: 'My-Connection',
|
||||
email: 'hi@me.co',
|
||||
}).then((response) => {
|
||||
console.log(response);
|
||||
}).catch((err) => {
|
||||
// Handle the error.
|
||||
});
|
||||
|
||||
Vendored
+81
-117
@@ -1,131 +1,95 @@
|
||||
// Type definitions for Auth0.js
|
||||
// Project: http://auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Type definitions for auth0 v2.3.1
|
||||
// Project: https://github.com/auth0/node-auth0
|
||||
// Definitions by: Seth Westphal <https://github.com/westy92>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/** Extensions to the browser Window object. */
|
||||
interface Window {
|
||||
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
|
||||
declare module "auth0" {
|
||||
|
||||
import * as Promise from 'bluebird';
|
||||
|
||||
export interface ManagementClientOptions {
|
||||
token: string;
|
||||
}
|
||||
domain?: string;
|
||||
}
|
||||
|
||||
/** This is the interface for the main Auth0 client. */
|
||||
interface Auth0Static {
|
||||
|
||||
new(options: Auth0ClientOptions): Auth0Static;
|
||||
changePassword(options: any, callback?: Function): void;
|
||||
decodeJwt(jwt: string): any;
|
||||
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
|
||||
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
logout(query: string): void;
|
||||
getConnections(callback?: Function): void;
|
||||
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
|
||||
getSSOData(withActiveDirectories: any, callback?: Function): void;
|
||||
parseHash(hash: string): Auth0DecodedHash;
|
||||
signup(options: Auth0SignupOptions, callback: Function): void;
|
||||
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
|
||||
}
|
||||
|
||||
/** Represents constructor options for the Auth0 client. */
|
||||
interface Auth0ClientOptions {
|
||||
clientID: string;
|
||||
callbackURL: string;
|
||||
callbackOnLocationHash?: boolean;
|
||||
domain: string;
|
||||
forceJSONP?: boolean;
|
||||
}
|
||||
|
||||
/** Represents a normalized UserProfile. */
|
||||
interface Auth0UserProfile {
|
||||
email: string;
|
||||
family_name: string;
|
||||
gender: string;
|
||||
given_name: string;
|
||||
locale: string;
|
||||
name: string;
|
||||
nickname: string;
|
||||
picture: string;
|
||||
user_id: string;
|
||||
/** Represents one or more Identities that may be associated with the User. */
|
||||
identities: Auth0Identity[];
|
||||
user_metadata?: any;
|
||||
app_metadata?: any;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
|
||||
interface MicrosoftUserProfile extends Auth0UserProfile {
|
||||
emails: string[];
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
|
||||
interface Office365UserProfile extends Auth0UserProfile {
|
||||
tenantid: string;
|
||||
upn: string;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
|
||||
interface AdfsUserProfile extends Auth0UserProfile {
|
||||
issuer: string;
|
||||
}
|
||||
|
||||
/** Represents multiple identities assigned to a user. */
|
||||
interface Auth0Identity {
|
||||
access_token: string;
|
||||
export interface UserData {
|
||||
connection: string;
|
||||
isSocial: boolean;
|
||||
provider: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
interface Auth0DecodedHash {
|
||||
access_token: string;
|
||||
id_token: string;
|
||||
profile: Auth0UserProfile;
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface Auth0PopupOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface Auth0LoginOptions {
|
||||
auto_login?: boolean;
|
||||
connection?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
popup?: boolean;
|
||||
popupOptions?: Auth0PopupOptions;
|
||||
}
|
||||
phone_number?: string;
|
||||
user_metadata?: {};
|
||||
email_verified?: boolean;
|
||||
app_metadata?: {};
|
||||
}
|
||||
|
||||
interface Auth0SignupOptions extends Auth0LoginOptions {
|
||||
auto_login: boolean;
|
||||
}
|
||||
export interface GetUsersData {
|
||||
per_page?: number;
|
||||
page?: number;
|
||||
include_totals?: boolean;
|
||||
sort?: string;
|
||||
connection?: string;
|
||||
fields?: string;
|
||||
include_fields?: boolean;
|
||||
q?: string;
|
||||
search_engine?: string;
|
||||
}
|
||||
|
||||
interface Auth0Error {
|
||||
code: any;
|
||||
details: any;
|
||||
name: string;
|
||||
message: string;
|
||||
status: any;
|
||||
}
|
||||
export interface User {
|
||||
email?: string;
|
||||
email_verified?: boolean;
|
||||
username?: string;
|
||||
phone_number?: string;
|
||||
phone_verified?: boolean;
|
||||
user_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
identities?: Identity[];
|
||||
app_metadata?: {};
|
||||
user_metadata?: {};
|
||||
picture?: string;
|
||||
name?: string;
|
||||
nickname?: string;
|
||||
multifactor?: string[];
|
||||
last_ip?: string;
|
||||
last_login?: string;
|
||||
logins_count?: number;
|
||||
blocked?: boolean;
|
||||
}
|
||||
|
||||
/** Represents the response from an API Token Delegation request. */
|
||||
interface Auth0DelegationToken {
|
||||
/** The length of time in seconds the token is valid for. */
|
||||
expires_in: string;
|
||||
/** The JWT for delegated access. */
|
||||
id_token: string;
|
||||
/** The type of token being returned. Possible values: "Bearer" */
|
||||
token_type: string;
|
||||
}
|
||||
export interface Identity {
|
||||
connection: string;
|
||||
user_id: string;
|
||||
provider: string;
|
||||
isSocial: boolean;
|
||||
}
|
||||
|
||||
declare var Auth0: Auth0Static;
|
||||
export class ManagementClient {
|
||||
constructor(options: ManagementClientOptions);
|
||||
|
||||
getUsers(params?: GetUsersData): Promise<User[]>;
|
||||
getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void;
|
||||
createUser(data: UserData): Promise<User>;
|
||||
createUser(data: UserData, cb: (err: Error, data: User) => void): void;
|
||||
}
|
||||
|
||||
export interface AuthenticationClientOptions {
|
||||
clientId?: string;
|
||||
domain: string;
|
||||
}
|
||||
|
||||
export interface RequestChangePasswordEmailData {
|
||||
connection: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export class AuthenticationClient {
|
||||
constructor(options: AuthenticationClientOptions);
|
||||
|
||||
requestChangePasswordEmail(data: RequestChangePasswordEmailData): Promise<string>;
|
||||
requestChangePasswordEmail(data: RequestChangePasswordEmailData, cb: (err: Error, message: string) => void): void;
|
||||
}
|
||||
|
||||
declare module "auth0" {
|
||||
export = Auth0
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ var kinesis: lambda.Kinesis;
|
||||
var recordsList: lambda.Record[];
|
||||
var anyObj: any;
|
||||
var num: number;
|
||||
var identity: lambda.Identity;
|
||||
var error: Error;
|
||||
|
||||
/* Records */
|
||||
var records: lambda.Records;
|
||||
@@ -46,4 +48,19 @@ context.succeed(str);
|
||||
context.succeed(anyObj);
|
||||
context.succeed(str, anyObj);
|
||||
str = context.awsRequestId;
|
||||
num = context.getRemainingTimeInMillis();
|
||||
num = context.getRemainingTimeInMillis();
|
||||
identity = context.identity;
|
||||
|
||||
/* Identity */
|
||||
var identity: lambda.Identity;
|
||||
|
||||
str = identity.cognitoIdentityId;
|
||||
str = identity.cognitoIdentityPoolId;
|
||||
|
||||
/* Callback */
|
||||
function callback(cb: lambda.Callback) {
|
||||
cb();
|
||||
cb(null);
|
||||
cb(error);
|
||||
cb(null, anyObj);
|
||||
}
|
||||
Vendored
+13
-1
@@ -36,8 +36,20 @@ declare module "aws-lambda" {
|
||||
succeed(message: string, object: any): void;
|
||||
awsRequestId: string;
|
||||
getRemainingTimeInMillis(): number;
|
||||
/** Information about the Amazon Cognito identity provider when invoked through the AWS Mobile SDK. It can be null. */
|
||||
identity?: Identity;
|
||||
}
|
||||
|
||||
interface Identity {
|
||||
cognitoIdentityId: string;
|
||||
cognitoIdentityPoolId: string;
|
||||
}
|
||||
|
||||
export type Callback = (error?: Error, message?: string) => void;
|
||||
/**
|
||||
* Optional callback parameter.
|
||||
*
|
||||
* @param error – an optional parameter that you can use to provide results of the failed Lambda function execution.
|
||||
* @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible.
|
||||
*/
|
||||
export type Callback = (error?: Error, result?: any) => void;
|
||||
}
|
||||
Vendored
+74
@@ -0,0 +1,74 @@
|
||||
// Type definitions for base64url v2.0.0
|
||||
// Project: https://github.com/brianloveswords/base64url
|
||||
// Definitions by: Stepan Miroshin <https://github.com/microshine>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
/**
|
||||
* For encoding and decoding base64url!
|
||||
* v2.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Encoding type
|
||||
*/
|
||||
declare type Encoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "utf16le" | "base64" | "binary" | "hex"
|
||||
|
||||
interface IBase64Url {
|
||||
/**
|
||||
* Encode input to base64url
|
||||
* @param {string} input Incoming input
|
||||
* @param {Encoding} encoding Default 'utf8'
|
||||
* @return {string}
|
||||
*/
|
||||
(input: string, encoding?: Encoding): string;
|
||||
/**
|
||||
* Encode input to base64url
|
||||
* @param {Buffer} input Incoming value
|
||||
*/
|
||||
(inout: Buffer): string;
|
||||
/**
|
||||
* Encode input to base64url
|
||||
*
|
||||
* @param {string} input Incoming input
|
||||
* @param {Encoding} encoding Default 'utf8'
|
||||
* @returns {string}
|
||||
*/
|
||||
encode(input: string, encoding?: Encoding): string;
|
||||
/**
|
||||
* Encode input to base64url
|
||||
* @param {Buffer} input Incoming value
|
||||
*/
|
||||
encode(input: Buffer): string;
|
||||
/**
|
||||
* Convert a base64url encoded string into a raw string.
|
||||
* @param {string} base64url base64url encoded string
|
||||
* @param {Encoding} encoding Encoding defaults to 'utf8'
|
||||
* @returns {string}
|
||||
*/
|
||||
decode(base64url: string, encoding?: string): string;
|
||||
/**
|
||||
* Convert a base64url encoded string to a base64 encoded string
|
||||
* @param {string | Buffer} base64url base64url encoded value
|
||||
* @returns {string}
|
||||
*/
|
||||
toBase64(base64url: string | Buffer): string;
|
||||
/**
|
||||
* Convert a base64 encoded string to a base64url encoded string
|
||||
* @param {string} base64 encoded string
|
||||
* @returns {string}
|
||||
*/
|
||||
fromBase64(base64: string): string;
|
||||
/**
|
||||
* Convert a base64url encoded string to a Buffer
|
||||
* @param {string} base64url encoded string
|
||||
* @returns {Buffer}
|
||||
*/
|
||||
toBuffer(base64url: string): Buffer;
|
||||
}
|
||||
|
||||
declare module "base64url" {
|
||||
const base64url: IBase64Url;
|
||||
export = base64url;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="./base64url.d.ts" />
|
||||
|
||||
import * as base64url from "base64url";
|
||||
|
||||
// default
|
||||
let str = base64url("some value");
|
||||
str = base64url("some value", "hex");
|
||||
str = base64url(new Buffer("some value"));
|
||||
|
||||
// encode
|
||||
str = base64url.encode("some value");
|
||||
str = base64url.encode("some value", "hex");
|
||||
str = base64url.encode(new Buffer("some value"));
|
||||
|
||||
// decode
|
||||
str = base64url.decode("ADA=");
|
||||
str = base64url.decode("ADA=", "binary");
|
||||
|
||||
// toBase64
|
||||
str = base64url.toBase64("ADA=");
|
||||
str = base64url.toBase64(new Buffer("ADA=", "base64"));
|
||||
|
||||
// fromBase64
|
||||
str = base64url.fromBase64("ADA=");
|
||||
|
||||
let buf = base64url.toBase64("ADA=");
|
||||
+17
-1
@@ -12,6 +12,7 @@
|
||||
|
||||
*/
|
||||
|
||||
import BigJS = BigJsLibrary.BigJS;
|
||||
function constructorTests() {
|
||||
var x = new Big(9) // '9'
|
||||
var y = new Big(x) // '9'
|
||||
@@ -247,4 +248,19 @@ function testMultipleConstructors() {
|
||||
|
||||
x.div(3) // 1.667
|
||||
y.div(3) // 1.6666666667
|
||||
}
|
||||
}
|
||||
|
||||
function multipleTypesAccepted(n: number | BigJS | string) {
|
||||
var y = Big(n)
|
||||
.minus(n)
|
||||
.mod(n)
|
||||
.plus(n)
|
||||
.times(n);
|
||||
y.cmp(n);
|
||||
y.eq(n);
|
||||
y.gt(n);
|
||||
y.gte(n);
|
||||
y.lt(n);
|
||||
y.lte(n);
|
||||
y.div(n)
|
||||
}
|
||||
|
||||
Vendored
+16
-82
@@ -25,23 +25,11 @@ declare namespace BigJsLibrary {
|
||||
RM: RoundingMode;
|
||||
}
|
||||
|
||||
type BigNumberInputType = number | string | BigJS;
|
||||
|
||||
interface BigJS_Constructors {
|
||||
/** A decimal value. */
|
||||
new (value: number): BigJS;
|
||||
/** A decimal value.
|
||||
String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
|
||||
String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
|
||||
new (value: string): BigJS;
|
||||
/** A decimal value. */
|
||||
new (value: BigJS): BigJS;
|
||||
/** A decimal value. */
|
||||
(value: number): BigJS;
|
||||
/** A decimal value.
|
||||
String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
|
||||
String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
|
||||
(value: string): BigJS;
|
||||
/** A decimal value. */
|
||||
(value: BigJS): BigJS;
|
||||
new (value: BigNumberInputType): BigJS;
|
||||
(value: BigNumberInputType): BigJS;
|
||||
|
||||
/** A decimal value. */
|
||||
(): BigJS;
|
||||
@@ -57,85 +45,35 @@ declare namespace BigJsLibrary {
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: number): number;
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: string): number;
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: BigJS): number;
|
||||
cmp(n: BigNumberInputType): number;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: BigJS): BigJS;
|
||||
div(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: number): boolean;
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: string): boolean;
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: BigJS): boolean;
|
||||
eq(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: number): boolean;
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: string): boolean;
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: BigJS): boolean;
|
||||
gt(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: number): boolean;
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: string): boolean;
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: BigJS): boolean;
|
||||
gte(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: number): boolean;
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: string): boolean;
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: BigJS): boolean;
|
||||
lt(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: number): boolean;
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: string): boolean;
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: BigJS): boolean;
|
||||
lte(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: BigJS): BigJS;
|
||||
minus(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: BigJS): BigJS;
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: BigJS): BigJS;
|
||||
plus(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number raised to the power exp.
|
||||
If exp is negative and the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM.
|
||||
@@ -156,11 +94,7 @@ declare namespace BigJsLibrary {
|
||||
sqrt(): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: BigJS): BigJS;
|
||||
times(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp. */
|
||||
toExponential(): string;
|
||||
|
||||
@@ -0,0 +1,773 @@
|
||||
///<reference path="blessed.d.ts" />
|
||||
|
||||
import * as blessed from 'blessed';
|
||||
|
||||
let screen: blessed.Widgets.Screen = null;
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-autopad.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/autopad.log',
|
||||
smartCSR: true,
|
||||
autoPadding: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var box1 = blessed.box({
|
||||
parent: screen,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line'
|
||||
});
|
||||
|
||||
var box2 = blessed.box({
|
||||
parent: box1,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line'
|
||||
});
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-bigtext.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/bigtext.log',
|
||||
smartCSR: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var box = blessed.bigtext({
|
||||
parent: screen,
|
||||
content: 'Hello',
|
||||
shrink: true,
|
||||
width: '80%',
|
||||
// height: '80%',
|
||||
height: 'shrink',
|
||||
// width: 'shrink',
|
||||
border: 'line',
|
||||
fch: ' ',
|
||||
ch: '\u2592',
|
||||
style: {
|
||||
fg: 'red',
|
||||
bg: 'blue',
|
||||
bold: false
|
||||
}
|
||||
});
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-csr.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/csr.log',
|
||||
smartCSR: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var lorem = require('fs').readFileSync(__dirname + '/git.diff', 'utf8');
|
||||
|
||||
var cleanSides = screen.cleanSides;
|
||||
function expectClean(value: any) {
|
||||
screen.cleanSides = function(el: blessed.widget.Element) {
|
||||
var ret = cleanSides.apply(this, arguments);
|
||||
if (ret !== value) {
|
||||
throw new Error('Failed. Expected '
|
||||
+ value + ' from cleanSides. Got '
|
||||
+ ret + '.');
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
var btext = blessed.box({
|
||||
parent: screen,
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
width: '80%',
|
||||
height: '80%',
|
||||
style: {
|
||||
bg: 'green'
|
||||
},
|
||||
border: 'line',
|
||||
content: 'CSR should still work.'
|
||||
});
|
||||
let _oscroll = btext.scroll;
|
||||
btext.scroll = function(offset, always) {
|
||||
expectClean(true);
|
||||
return _oscroll(offset, always);
|
||||
};
|
||||
|
||||
var text = blessed.scrollabletext({
|
||||
parent: screen,
|
||||
content: lorem,
|
||||
border: 'line',
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
draggable: true,
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
mouse: true,
|
||||
keys: true,
|
||||
vi: true
|
||||
});
|
||||
|
||||
_oscroll = text.scroll;
|
||||
text.scroll = function(offset, always) {
|
||||
var el = this;
|
||||
var value = true;
|
||||
if (el.left < 0) value = true;
|
||||
if (el.top < 0) value = false;
|
||||
if (el.left + el.width > screen.width) value = true;
|
||||
if (el.top + el.height > screen.height) value = false;
|
||||
expectClean(value);
|
||||
return _oscroll(offset, always);
|
||||
};
|
||||
|
||||
text.focus();
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-dock-noborder.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/dock.log',
|
||||
smartCSR: true,
|
||||
dockBorders: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
blessed.box({
|
||||
parent: screen,
|
||||
left: -1,
|
||||
top: -1,
|
||||
width: '50%+1',
|
||||
height: '50%+1',
|
||||
border: 'line',
|
||||
content: 'Foo'
|
||||
});
|
||||
|
||||
blessed.box({
|
||||
parent: screen,
|
||||
left: '50%-1',
|
||||
top: -1,
|
||||
width: '50%+3',
|
||||
height: '50%+1',
|
||||
content: 'Bar',
|
||||
border: 'line'
|
||||
});
|
||||
|
||||
blessed.box({
|
||||
parent: screen,
|
||||
left: -1,
|
||||
top: '50%-1',
|
||||
width: '50%+1',
|
||||
height: '50%+3',
|
||||
border: 'line',
|
||||
content: 'Foo'
|
||||
});
|
||||
|
||||
blessed.listtable({
|
||||
parent: screen,
|
||||
left: '50%-1',
|
||||
top: '50%-1',
|
||||
width: '50%+3',
|
||||
height: '50%+3',
|
||||
border: 'line',
|
||||
align: 'center',
|
||||
tags: true,
|
||||
keys: true,
|
||||
vi: true,
|
||||
mouse: true,
|
||||
style: {
|
||||
header: {
|
||||
fg: 'blue',
|
||||
bold: true
|
||||
},
|
||||
cell: {
|
||||
fg: 'magenta',
|
||||
selected: {
|
||||
bg: 'blue'
|
||||
}
|
||||
}
|
||||
},
|
||||
data: [
|
||||
[ 'Animals', 'Foods', 'Times', 'Numbers' ],
|
||||
[ 'Elephant', 'Apple', '1:00am', 'One' ],
|
||||
[ 'Bird', 'Orange', '2:15pm', 'Two' ],
|
||||
[ 'T-Rex', 'Taco', '8:45am', 'Three' ],
|
||||
[ 'Mouse', 'Cheese', '9:05am', 'Four' ]
|
||||
]
|
||||
}).focus();
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://raw.githubusercontent.com/chjj/blessed/master/example/simple-form.js
|
||||
|
||||
var form = blessed.form({
|
||||
parent: screen,
|
||||
keys: true,
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 30,
|
||||
height: 4,
|
||||
bg: 'green',
|
||||
content: 'Submit or cancel?'
|
||||
});
|
||||
|
||||
var submit = blessed.button({
|
||||
parent: form,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
right: 1
|
||||
},
|
||||
left: 10,
|
||||
top: 2,
|
||||
shrink: true,
|
||||
name: 'submit',
|
||||
content: 'submit',
|
||||
style: {
|
||||
bg: 'blue',
|
||||
focus: {
|
||||
bg: 'red'
|
||||
},
|
||||
hover: {
|
||||
bg: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var cancel = blessed.button({
|
||||
parent: form,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
right: 1
|
||||
},
|
||||
left: 20,
|
||||
top: 2,
|
||||
shrink: true,
|
||||
name: 'cancel',
|
||||
content: 'cancel',
|
||||
style: {
|
||||
bg: 'blue',
|
||||
focus: {
|
||||
bg: 'red'
|
||||
},
|
||||
hover: {
|
||||
bg: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-layout.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/layout.log',
|
||||
smartCSR: true,
|
||||
autoPadding: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var layout = blessed.layout({
|
||||
parent: screen,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
border: 'line',
|
||||
layout: process.argv[2] === 'grid' ? 'grid' : 'inline',
|
||||
style: {
|
||||
bg: 'red',
|
||||
border: {
|
||||
fg: 'blue'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var box1 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '1'
|
||||
});
|
||||
|
||||
var box2 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '2'
|
||||
});
|
||||
|
||||
var box3 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '3'
|
||||
});
|
||||
|
||||
var box4 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '4'
|
||||
});
|
||||
|
||||
var box5 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '5'
|
||||
});
|
||||
|
||||
var box6 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '6'
|
||||
});
|
||||
|
||||
var box7 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '7'
|
||||
});
|
||||
|
||||
var box8 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '8'
|
||||
});
|
||||
|
||||
var box9 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '9'
|
||||
});
|
||||
|
||||
var box10 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '10'
|
||||
});
|
||||
|
||||
var box11 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '11'
|
||||
});
|
||||
|
||||
var box12 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '12'
|
||||
});
|
||||
|
||||
if (process.argv[2] !== 'grid') {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
blessed.box({
|
||||
parent: layout,
|
||||
// width: i % 2 === 0 ? 10 : 20,
|
||||
// height: i % 2 === 0 ? 5 : 10,
|
||||
width: Math.random() > 0.5 ? 10 : 20,
|
||||
height: Math.random() > 0.5 ? 5 : 10,
|
||||
border: 'line',
|
||||
content: (i + 1 + 12) + ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-form.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/form.log',
|
||||
warnings: true
|
||||
});
|
||||
|
||||
type FormData = {
|
||||
radio1: boolean;
|
||||
radio2: boolean;
|
||||
text: string;
|
||||
check: boolean;
|
||||
};
|
||||
|
||||
var form2 = blessed.form<FormData>({
|
||||
parent: screen,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
vi: true,
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: '100%',
|
||||
//height: 12,
|
||||
style: {
|
||||
bg: 'green',
|
||||
border: {
|
||||
inverse: true
|
||||
},
|
||||
scrollbar: {
|
||||
inverse: true
|
||||
}
|
||||
},
|
||||
content: 'foobar',
|
||||
scrollable: true,
|
||||
scrollbar: {
|
||||
ch: ' '
|
||||
}
|
||||
//alwaysScroll: true
|
||||
});
|
||||
|
||||
form2.on('submit', (data) => {
|
||||
output.setContent(JSON.stringify(data, null, 2));
|
||||
screen.render();
|
||||
});
|
||||
|
||||
form2.key('d', function() {
|
||||
form2.scroll(1, true);
|
||||
screen.render();
|
||||
});
|
||||
|
||||
form2.key('u', function() {
|
||||
form2.scroll(-1, true);
|
||||
screen.render();
|
||||
});
|
||||
|
||||
var set = blessed.radioset({
|
||||
parent: form2,
|
||||
left: 1,
|
||||
top: 1,
|
||||
shrink: true,
|
||||
//padding: 1,
|
||||
//content: 'f',
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
}
|
||||
});
|
||||
|
||||
var radio1 = blessed.radiobutton({
|
||||
parent: set,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 0,
|
||||
top: 0,
|
||||
name: 'radio1',
|
||||
content: 'radio1'
|
||||
});
|
||||
|
||||
var radio2 = blessed.radiobutton({
|
||||
parent: set,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 15,
|
||||
top: 0,
|
||||
name: 'radio2',
|
||||
content: 'radio2'
|
||||
});
|
||||
|
||||
var text2 = blessed.textbox({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
style: {
|
||||
bg: 'blue'
|
||||
},
|
||||
height: 1,
|
||||
width: 20,
|
||||
left: 1,
|
||||
top: 3,
|
||||
name: 'text'
|
||||
});
|
||||
|
||||
text2.on('focus', function() {
|
||||
text2.readInput();
|
||||
});
|
||||
|
||||
var check = blessed.checkbox({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 28,
|
||||
top: 1,
|
||||
name: 'check',
|
||||
content: 'check'
|
||||
});
|
||||
|
||||
var check2 = blessed.checkbox({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 28,
|
||||
top: 14,
|
||||
name: 'foooooooo2',
|
||||
content: 'foooooooo2'
|
||||
});
|
||||
|
||||
var submit = blessed.button({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
right: 1
|
||||
},
|
||||
left: 29,
|
||||
top: 3,
|
||||
name: 'submit',
|
||||
content: 'submit',
|
||||
style: {
|
||||
bg: 'blue',
|
||||
focus: {
|
||||
bg: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submit.on('press', function() {
|
||||
form2.submit();
|
||||
});
|
||||
|
||||
var box1 = blessed.box({
|
||||
parent: form2,
|
||||
left: 1,
|
||||
top: 10,
|
||||
height: 10,
|
||||
width: 10,
|
||||
content: 'one',
|
||||
style: {
|
||||
bg: 'cyan'
|
||||
}
|
||||
});
|
||||
|
||||
var box2 = blessed.box({
|
||||
parent: box1,
|
||||
left: 1,
|
||||
top: 2,
|
||||
height: 8,
|
||||
width: 9,
|
||||
content: 'two',
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
}
|
||||
});
|
||||
|
||||
var box3 = blessed.box({
|
||||
parent: box2,
|
||||
left: 1,
|
||||
top: 2,
|
||||
height: 6,
|
||||
width: 8,
|
||||
content: 'three',
|
||||
style: {
|
||||
bg: 'yellow'
|
||||
}
|
||||
});
|
||||
|
||||
var box4 = blessed.box({
|
||||
parent: box3,
|
||||
left: 1,
|
||||
top: 2,
|
||||
height: 4,
|
||||
width: 7,
|
||||
content: 'four',
|
||||
style: {
|
||||
bg: 'blue'
|
||||
}
|
||||
});
|
||||
|
||||
var output = blessed.scrollabletext({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
left: 0,
|
||||
top: 20,
|
||||
height: 5,
|
||||
right: 0,
|
||||
style: {
|
||||
bg: 'red'
|
||||
},
|
||||
content: 'foobar'
|
||||
});
|
||||
|
||||
var bottom = blessed.line({
|
||||
parent: form2,
|
||||
type: 'line',
|
||||
orientation: 'horizontal',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 50,
|
||||
style: {
|
||||
fg: 'blue'
|
||||
}
|
||||
});
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
form2.focus();
|
||||
|
||||
form2.submit();
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-table.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/table.log',
|
||||
autoPadding: false,
|
||||
fullUnicode: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var DU = '杜';
|
||||
var JUAN = '鹃';
|
||||
|
||||
var table = blessed.table({
|
||||
//parent: screen,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
data: null,
|
||||
border: 'line',
|
||||
align: 'center',
|
||||
tags: true,
|
||||
//width: '80%',
|
||||
width: 'shrink',
|
||||
style: {
|
||||
border: {
|
||||
fg: 'red'
|
||||
},
|
||||
header: {
|
||||
fg: 'blue',
|
||||
bold: true
|
||||
},
|
||||
cell: {
|
||||
fg: 'magenta'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var data1 = [
|
||||
[ 'Animals', 'Foods', 'Times' ],
|
||||
[ 'Elephant', 'Apple', '1:00am' ],
|
||||
[ 'Bird', 'Orange', '2:15pm' ],
|
||||
[ 'T-Rex', 'Taco', '8:45am' ],
|
||||
[ 'Mouse', 'Cheese', '9:05am' ]
|
||||
];
|
||||
|
||||
data1[1][0] = '{red-fg}' + data1[1][0] + '{/red-fg}';
|
||||
data1[2][0] += ' (' + DU + JUAN + ')';
|
||||
|
||||
var data2 = [
|
||||
[ 'Animals', 'Foods', 'Times', 'Numbers' ],
|
||||
[ 'Elephant', 'Apple', '1:00am', 'One' ],
|
||||
[ 'Bird', 'Orange', '2:15pm', 'Two' ],
|
||||
[ 'T-Rex', 'Taco', '8:45am', 'Three' ],
|
||||
[ 'Mouse', 'Cheese', '9:05am', 'Four' ]
|
||||
];
|
||||
|
||||
data2[1][0] = '{red-fg}' + data2[1][0] + '{/red-fg}';
|
||||
data2[2][0] += ' (' + DU + JUAN + ')';
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
table.setData(data2);
|
||||
screen.append(table);
|
||||
screen.render();
|
||||
|
||||
setTimeout(function() {
|
||||
table.setData(data1);
|
||||
screen.render();
|
||||
}, 3000);
|
||||
Vendored
+2812
-1247
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path="blue-tape.d.ts" />
|
||||
|
||||
import tape = require('blue-tape');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="bluebird-retry.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
import Promise = require('bluebird');
|
||||
import retry = require('bluebird-retry');
|
||||
|
||||
@@ -32,4 +32,4 @@ var options:retry.Options = {
|
||||
interval: 500
|
||||
};
|
||||
|
||||
retry(logFail, options);
|
||||
retry(logFail, options);
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Pascal Vomhoff <https://github.com/pvomhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
declare module "bluebird-retry" {
|
||||
import Promise = require('bluebird');
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+773
@@ -0,0 +1,773 @@
|
||||
// Type definitions for bluebird 2.0.0
|
||||
// Project: https://github.com/petkaantonov/bluebird
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, falsandtru <https://github.com/falsandtru>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
|
||||
// By: Campredon <https://github.com/fdecampredon/>
|
||||
|
||||
// Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code):
|
||||
// - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/1563
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// TODO fix remaining TODO annotations in both definition and test
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
|
||||
interface PromiseCancelHandlerSetter {
|
||||
(handler: () => void): void;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions
|
||||
* `resolve` and `reject` as its arguments which can be called to seal the
|
||||
* fate of the created promise.
|
||||
*
|
||||
* If configured appropriately, it will also receive an `onCancel`
|
||||
* function that can be used to configure a promise cancellation handler.
|
||||
*/
|
||||
new <T>(callback: (
|
||||
resolve: (thenableOrResult?: T | PromiseLike<T>) => void,
|
||||
reject: (error: any) => void,
|
||||
onCancel?: PromiseCancelHandlerSetter
|
||||
) => void): Promise<T>;
|
||||
|
||||
config(options: {
|
||||
warnings?: boolean | {wForgottenReturn?: boolean};
|
||||
longStackTraces?: boolean;
|
||||
cancellation?: boolean;
|
||||
monitoring?: boolean;
|
||||
}): void;
|
||||
|
||||
// Ideally, we'd define e.g. "export class RangeError extends Error {}",
|
||||
// but as Error is defined as an interface (not a class), TypeScript doesn't
|
||||
// allow extending Error, only implementing it.
|
||||
// However, if we want to catch() only a specific error type, we need to pass
|
||||
// a constructor function to it. So, as a workaround, we define them here as such.
|
||||
RangeError(): RangeError;
|
||||
CancellationError(): Promise.CancellationError;
|
||||
TimeoutError(): Promise.TimeoutError;
|
||||
TypeError(): Promise.TypeError;
|
||||
RejectionError(): Promise.RejectionError;
|
||||
OperationalError(): Promise.OperationalError;
|
||||
|
||||
/**
|
||||
* Changes how bluebird schedules calls a-synchronously.
|
||||
*
|
||||
* @param scheduler Should be a function that asynchronously schedules
|
||||
* the calling of the passed in function
|
||||
*/
|
||||
setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
|
||||
|
||||
/**
|
||||
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
|
||||
*
|
||||
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
|
||||
*
|
||||
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
try<T>(fn: () => T | PromiseLike<T>, args?: any[], ctx?: any): Promise<T>;
|
||||
|
||||
attempt<T>(fn: () => T | PromiseLike<T>, args?: any[], ctx?: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
|
||||
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
|
||||
*/
|
||||
method(fn: Function): Function;
|
||||
|
||||
/**
|
||||
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
resolve(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Create a promise that is rejected with the given `reason`.
|
||||
*/
|
||||
reject(reason: any): Promise<any>;
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
|
||||
*/
|
||||
defer<T>(): Promise.Resolver<T>;
|
||||
|
||||
/**
|
||||
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
|
||||
*/
|
||||
cast<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
|
||||
*/
|
||||
bind(thisArg: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* See if `value` is a trusted Promise.
|
||||
*/
|
||||
is(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
|
||||
*/
|
||||
longStackTraces(): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
delay<T>(ms: number, value: T | PromiseLike<T>): Promise<T>;
|
||||
delay(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
|
||||
*
|
||||
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
|
||||
*
|
||||
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
|
||||
*/
|
||||
promisify<T>(func: (callback: (err: any, result: T) => void) => void, receiver?: any): () => Promise<T>;
|
||||
promisify<T, A1>(func: (arg1: A1, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1) => Promise<T>;
|
||||
promisify<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2) => Promise<T>;
|
||||
promisify<T, A1, A2, A3>(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3) => Promise<T>;
|
||||
promisify<T, A1, A2, A3, A4>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Promise<T>;
|
||||
promisify<T, A1, A2, A3, A4, A5>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Promise<T>;
|
||||
promisify(nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
/**
|
||||
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
|
||||
*
|
||||
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
|
||||
*/
|
||||
// TODO how to model promisifyAll?
|
||||
promisifyAll(target: Object, options?: Promise.PromisifyAllOptions): any;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a promise that is resolved by a node style callback function.
|
||||
*/
|
||||
fromNode(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise<any>;
|
||||
fromCallback(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise<any>;
|
||||
|
||||
/**
|
||||
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix coroutine GeneratorFunction
|
||||
coroutine<T>(generatorFunction: Function): Function;
|
||||
|
||||
/**
|
||||
* Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix spawn GeneratorFunction
|
||||
spawn<T>(generatorFunction: Function): Promise<T>;
|
||||
|
||||
/**
|
||||
* This is relevant to browser environments with no module loader.
|
||||
*
|
||||
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
|
||||
*/
|
||||
noConflict(): typeof Promise;
|
||||
|
||||
/**
|
||||
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
|
||||
*
|
||||
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
|
||||
*/
|
||||
onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
// promise of array with promises of value
|
||||
all<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<T[]>;
|
||||
// promise of array with values
|
||||
all<T>(values: PromiseLike<T[]>): Promise<T[]>;
|
||||
// array with promises of value
|
||||
all<T>(values: PromiseLike<T>[]): Promise<T[]>;
|
||||
// array with promises of different types
|
||||
all<T1, T2, T3, T4, T5>(values: [PromiseLike<T1>, PromiseLike<T2>, PromiseLike<T3>, PromiseLike<T4>, PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
all<T1, T2, T3, T4>(values: [PromiseLike<T1>, PromiseLike<T2>, PromiseLike<T3>, PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
all<T1, T2, T3>(values: [PromiseLike<T1>, PromiseLike<T2>, PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
all<T1, T2>(values: [PromiseLike<T1>, PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
// array with values
|
||||
all<T>(values: T[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
|
||||
*
|
||||
* *The original object is not modified.*
|
||||
*/
|
||||
// TODO verify this is correct
|
||||
// trusted promise for object
|
||||
props(object: Promise<Object>): Promise<Object>;
|
||||
// object
|
||||
props(object: Object): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
|
||||
*
|
||||
* *original: The array is not modified. The input array sparsity is retained in the resulting array.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
settle<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<Promise.Inspection<T>[]>;
|
||||
// promise of array with values
|
||||
settle<T>(values: PromiseLike<T[]>): Promise<Promise.Inspection<T>[]>;
|
||||
// array with promises of value
|
||||
settle<T>(values: PromiseLike<T>[]): Promise<Promise.Inspection<T>[]>;
|
||||
// array with values
|
||||
settle<T>(values: T[]): Promise<Promise.Inspection<T>[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
any<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<T>;
|
||||
// promise of array with values
|
||||
any<T>(values: PromiseLike<T[]>): Promise<T>;
|
||||
// array with promises of value
|
||||
any<T>(values: PromiseLike<T>[]): Promise<T>;
|
||||
// array with values
|
||||
any<T>(values: T[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
|
||||
*
|
||||
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
race<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<T>;
|
||||
// promise of array with values
|
||||
race<T>(values: PromiseLike<T[]>): Promise<T>;
|
||||
// array with promises of value
|
||||
race<T>(values: PromiseLike<T>[]): Promise<T>;
|
||||
// array with values
|
||||
race<T>(values: T[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
|
||||
*
|
||||
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
some<T>(values: PromiseLike<PromiseLike<T>[]>, count: number): Promise<T[]>;
|
||||
// promise of array with values
|
||||
some<T>(values: PromiseLike<T[]>, count: number): Promise<T[]>;
|
||||
// array with promises of value
|
||||
some<T>(values: PromiseLike<T>[], count: number): Promise<T[]>;
|
||||
// array with values
|
||||
some<T>(values: T[], count: number): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
|
||||
*/
|
||||
// variadic array with promises of value
|
||||
join<T>(...values: PromiseLike<T>[]): Promise<T[]>;
|
||||
// variadic array with values
|
||||
join<T>(...values: T[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
map<T, U>(values: PromiseLike<PromiseLike<T>[]>, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
map<T, U>(values: PromiseLike<T[]>, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
map<T, U>(values: PromiseLike<T>[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
map<T, U>(values: T[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Similar to `map` with concurrency set to 1 but guaranteed to execute in sequential order
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
mapSeries<R, U>(values: PromiseLike<PromiseLike<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
mapSeries<R, U>(values: PromiseLike<R[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
mapSeries<R, U>(values: PromiseLike<R>[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
mapSeries<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
|
||||
/**
|
||||
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*
|
||||
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
reduce<T, U>(values: PromiseLike<PromiseLike<T>[]>, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
// promise of array with values
|
||||
reduce<T, U>(values: PromiseLike<T[]>, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with promises of value
|
||||
reduce<T, U>(values: PromiseLike<T>[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with values
|
||||
reduce<T, U>(values: T[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
|
||||
*
|
||||
* *The original array is not modified.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
filter<T>(values: PromiseLike<PromiseLike<T>[]>, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
// promise of array with values
|
||||
filter<T>(values: PromiseLike<T[]>, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
// array with promises of value
|
||||
filter<T>(values: PromiseLike<T>[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
// array with values
|
||||
filter<T>(values: T[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
each<T, U>(values: PromiseLike<PromiseLike<T>[]>, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
// array with promises of value
|
||||
each<T, U>(values: PromiseLike<T>[], iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
// array with values OR promise of array with values
|
||||
each<T, U>(values: T[] | PromiseLike<T[]>, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
}
|
||||
|
||||
interface Promise<T> extends PromiseLike<T>, Promise.Inspection<T> {
|
||||
/**
|
||||
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
|
||||
*/
|
||||
then<U>(onFulfill: (value: T) => U | PromiseLike<U>, onReject?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: T) => U | PromiseLike<U>, onReject?: (error: any) => void | PromiseLike<void>, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch(onReject?: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
caught(onReject?: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
|
||||
catch<U>(onReject?: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
caught<U>(onReject?: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
|
||||
/**
|
||||
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
|
||||
*
|
||||
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
caught(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
|
||||
catch(ErrorClass: Function, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
caught(ErrorClass: Function, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
|
||||
|
||||
/**
|
||||
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
|
||||
*/
|
||||
error<U>(onReject: (reason: any) => PromiseLike<U>): Promise<U>;
|
||||
error<U>(onReject: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally<U>(handler: () => U | PromiseLike<U>): Promise<T>;
|
||||
|
||||
lastly<U>(handler: () => U | PromiseLike<U>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
*/
|
||||
bind(thisArg: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled?: (value: T) => PromiseLike<U>, onRejected?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled?: (value: T) => U, onRejected?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): void;
|
||||
|
||||
/**
|
||||
* Like `.finally()`, but not called for rejections.
|
||||
*/
|
||||
tap<U>(onFulFill: (value: T) => U | PromiseLike<U>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
*/
|
||||
progressed(handler: (note: any) => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
delay(ms: number): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
|
||||
*
|
||||
* You may specify a custom error message with the `message` parameter.
|
||||
*/
|
||||
timeout(ms: number, message?: string): Promise<T>;
|
||||
|
||||
/**
|
||||
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
|
||||
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
|
||||
*/
|
||||
nodeify(callback: (err: any, value?: T) => void, options?: Promise.SpreadOption): Promise<T>;
|
||||
nodeify(...sink: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
|
||||
*/
|
||||
cancellable(): Promise<T>;
|
||||
|
||||
/**
|
||||
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
|
||||
*
|
||||
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
|
||||
*
|
||||
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
|
||||
*
|
||||
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
|
||||
*/
|
||||
// TODO what to do with this?
|
||||
cancel<U>(reason?: any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
|
||||
*/
|
||||
fork<U>(onFulfilled?: (value: T) => U | PromiseLike<U>, onRejected?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Create an uncancellable promise based on this promise.
|
||||
*/
|
||||
uncancellable(): Promise<T>;
|
||||
|
||||
/**
|
||||
* See if this promise can be cancelled.
|
||||
*/
|
||||
isCancellable(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been fulfilled.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been rejected.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is still defer.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is resolved -> either fulfilled or rejected.
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): T;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
reason(): any;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
inspect(): Promise.Inspection<T>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName].call(obj, arg...);
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
call(propertyName: string, ...args: any[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName];
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
// TODO find way to fix get()
|
||||
// get<U>(propertyName: string): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* return value;
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
|
||||
*
|
||||
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
return(): Promise<any>;
|
||||
thenReturn(): Promise<any>;
|
||||
return<U>(value: U): Promise<U>;
|
||||
thenReturn<U>(value: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* throw reason;
|
||||
* });
|
||||
* </code>
|
||||
* Same limitations apply as with `.return()`.
|
||||
*
|
||||
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
throw(reason: Error): Promise<T>;
|
||||
thenThrow(reason: Error): Promise<T>;
|
||||
|
||||
/**
|
||||
* Convert to String.
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
|
||||
*/
|
||||
toJSON(): Object;
|
||||
|
||||
/**
|
||||
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
|
||||
*/
|
||||
// TODO how to model instance.spread()? like Q?
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => U | PromiseLike<U>): Promise<U>;
|
||||
/*
|
||||
// TODO or something like this?
|
||||
spread<U, W>(onFulfill: (...values: W[]) => PromiseLike<U>, onReject?: (reason: any) => PromiseLike<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => PromiseLike<U>, onReject?: (reason: any) => U): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => PromiseLike<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise<U>;
|
||||
*/
|
||||
/**
|
||||
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
all<U>(): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO how to model instance.props()?
|
||||
props(): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
settle<U>(): Promise<Promise.Inspection<U>[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
any<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
some<U>(count: number): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
race<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as `Promise.mapSeries(thisPromise, mapper)`.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
mapSeries<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
each<T, U>(iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use variable namespace such as variables, functions, and classes.
|
||||
* If you use this namespace, it will conflict in es6.
|
||||
*/
|
||||
declare namespace Promise {
|
||||
export interface RangeError extends Error {
|
||||
}
|
||||
export interface CancellationError extends Error {
|
||||
}
|
||||
export interface TimeoutError extends Error {
|
||||
}
|
||||
export interface TypeError extends Error {
|
||||
}
|
||||
export interface RejectionError extends Error {
|
||||
}
|
||||
export interface OperationalError extends Error {
|
||||
}
|
||||
|
||||
export interface ConcurrencyOption {
|
||||
concurrency: number;
|
||||
}
|
||||
export interface SpreadOption {
|
||||
spread: boolean;
|
||||
}
|
||||
export interface PromisifyAllOptions {
|
||||
suffix?: string;
|
||||
filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean;
|
||||
// The promisifier gets a reference to the original method and should return a function which returns a promise
|
||||
promisifier?: (originalMethod: Function) => () => PromiseLike<any>;
|
||||
}
|
||||
|
||||
export interface Resolver<T> {
|
||||
/**
|
||||
* Returns a reference to the controlled promise that can be passed to clients.
|
||||
*/
|
||||
promise: Promise<T>;
|
||||
|
||||
/**
|
||||
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
|
||||
*/
|
||||
resolve(value: T): void;
|
||||
resolve(): void;
|
||||
|
||||
/**
|
||||
* Reject the underlying promise with `reason` as the rejection reason.
|
||||
*/
|
||||
reject(reason: any): void;
|
||||
|
||||
/**
|
||||
* Progress the underlying promise with `value` as the progression value.
|
||||
*/
|
||||
progress(value: any): void;
|
||||
|
||||
/**
|
||||
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
|
||||
*
|
||||
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
|
||||
*/
|
||||
// TODO specify resolver callback
|
||||
callback: (err: any, value: T, ...values: T[]) => void;
|
||||
}
|
||||
|
||||
export interface Inspection<T> {
|
||||
/**
|
||||
* See if the underlying promise was fulfilled at the creation time of this inspection object.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was rejected at the creation time of this inspection object.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was defer at the creation time of this inspection object.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): T;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
reason(): any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
+7
-126
@@ -7,6 +7,8 @@
|
||||
|
||||
// Note: try to maintain the ordering and separators, and keep to the pattern
|
||||
|
||||
import Promise = require("bluebird");
|
||||
|
||||
var obj: Object;
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
@@ -141,7 +143,7 @@ var fooResolver: Promise.Resolver<Foo>;
|
||||
var barResolver: Promise.Resolver<Bar>;
|
||||
|
||||
var fooInspection: Promise.Inspection<Foo>;
|
||||
var barInspection: Promise.Inspection<Bar>;
|
||||
var fooInspectionPromise: Promise<Promise.Inspection<Foo>>;
|
||||
|
||||
var fooInspectionArrProm: Promise<Promise.Inspection<Foo>[]>;
|
||||
var barInspectionArrProm: Promise<Promise.Inspection<Bar>[]>;
|
||||
@@ -195,8 +197,6 @@ fooResolver.resolve(foo);
|
||||
|
||||
fooResolver.reject(err);
|
||||
|
||||
fooResolver.progress(bar);
|
||||
|
||||
fooResolver.callback = (err: any, value: Foo) => {
|
||||
|
||||
};
|
||||
@@ -204,24 +204,13 @@ fooResolver.callback = (err: any, value: Foo) => {
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooInspection.isFulfilled();
|
||||
|
||||
bool = fooInspection.isRejected();
|
||||
|
||||
bool = fooInspection.isPending();
|
||||
|
||||
foo = fooInspection.value();
|
||||
|
||||
x = fooInspection.reason();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
@@ -384,13 +373,6 @@ fooProm = fooProm.bind(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
@@ -402,13 +384,6 @@ voidVar = fooProm.done((value: Foo) => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
@@ -436,11 +411,6 @@ fooProm = fooProm.tap(() => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.progressed((note: any) => {
|
||||
return foo;
|
||||
});
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.delay(num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -460,52 +430,11 @@ fooProm = fooProm.nodeify((err: any, foo?: Foo) => { }, { spread: true });
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
voidVar = fooProm.cancel();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.cancel<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.cancellable();
|
||||
fooProm = fooProm.uncancellable();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooProm.isCancellable();
|
||||
bool = fooProm.isCancelled();
|
||||
bool = fooProm.isFulfilled();
|
||||
bool = fooProm.isRejected();
|
||||
bool = fooProm.isPending();
|
||||
@@ -513,8 +442,6 @@ bool = fooProm.isResolved();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooInspection = fooProm.inspect();
|
||||
|
||||
anyProm = fooProm.call(str);
|
||||
anyProm = fooProm.call(str, 1, 2, 3);
|
||||
|
||||
@@ -543,22 +470,12 @@ obj = fooProm.toJSON();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
@@ -568,15 +485,10 @@ barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
//TODO fix collection inference
|
||||
|
||||
barArrProm = fooProm.all<Bar>();
|
||||
|
||||
objProm = fooProm.props();
|
||||
|
||||
barInspectionArrProm = fooProm.settle<Bar>();
|
||||
|
||||
fooInspectionPromise = fooProm.reflect();
|
||||
barProm = fooProm.any<Bar>();
|
||||
|
||||
barArrProm = fooProm.some<Bar>(num);
|
||||
|
||||
barProm = fooProm.race<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -686,24 +598,12 @@ fooProm = Promise.try<Foo>(() => {
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -725,12 +625,6 @@ fooProm = Promise.attempt<Foo>(() => {
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -746,12 +640,6 @@ fooProm = Promise.attempt(() => {
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -847,6 +735,7 @@ obj = Promise.promisifyAll(obj, {
|
||||
*/
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
BlueBird = Promise.getNewLibraryCopy();
|
||||
BlueBird = Promise.noConflict();
|
||||
|
||||
Promise.onPossiblyUnhandledRejection((reason: any) => {
|
||||
@@ -868,14 +757,6 @@ objProm = Promise.props(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooInspectionArrProm = Promise.settle(fooThenArrThen);
|
||||
fooInspectionArrProm = Promise.settle(fooArrProm);
|
||||
fooInspectionArrProm = Promise.settle(fooThenArr);
|
||||
fooInspectionArrProm = Promise.settle(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooProm = Promise.any(fooThenArrThen);
|
||||
fooProm = Promise.any(fooArrProm);
|
||||
|
||||
Vendored
+730
-730
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Andrew Schurman <http://github.com/arcticwaters>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path='../lodash/lodash-3.10.d.ts' />
|
||||
/// <reference path="../knex/knex.d.ts" />
|
||||
/// <reference path="../create-error/create-error.d.ts" />
|
||||
|
||||
Vendored
+1
-1
@@ -9,7 +9,7 @@
|
||||
interface BootboxBaseOptions {
|
||||
title?: string | Element;
|
||||
callback?: (result: boolean | string) => any;
|
||||
onEscape?: () => any | boolean;
|
||||
onEscape?: (() => any) | boolean;
|
||||
show?: boolean;
|
||||
backdrop?: boolean;
|
||||
closeButton?: boolean;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/// <reference path="bootstrap.datepicker.d.ts"/>
|
||||
/// <reference path="bootstrap-datepicker.d.ts"/>
|
||||
|
||||
function tests_simple() {
|
||||
$('#datepicker').datepicker();
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bootstrap.datepicker
|
||||
// Type definitions for bootstrap-datepicker
|
||||
// Project: https://github.com/eternicode/bootstrap-datepicker
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -7,3 +7,13 @@ Bowser.test(['msie']) === true;
|
||||
Bowser.a === Bowser.c;
|
||||
Bowser.osversion > 10;
|
||||
Bowser.osversion === '10.1A';
|
||||
|
||||
bowser.msedge === true;
|
||||
bowser.test(['msie']) === true;
|
||||
bowser.a === bowser.c;
|
||||
bowser.osversion > 10;
|
||||
bowser.osversion === '10.1A';
|
||||
bowser.compareVersions(['9.0', '10']);
|
||||
bowser() === <BowserModule.IBowserDetection>{android: true, x: true};
|
||||
bowser.check({msie: "11"}, window.navigator.userAgent);
|
||||
bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent);
|
||||
Vendored
+71
-19
@@ -3,52 +3,104 @@
|
||||
// Definitions by: Paulo Cesar <https://github.com/pocesar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var bowser: BowserModule.IBowser;
|
||||
|
||||
declare module 'bowser' {
|
||||
var def: BowserModule.IBowser;
|
||||
export = def;
|
||||
export = bowser;
|
||||
}
|
||||
|
||||
declare namespace BowserModule {
|
||||
|
||||
export interface IBowserUA {
|
||||
msie: boolean;
|
||||
export interface IBowserOS {
|
||||
mac: boolean;
|
||||
/**other than Windows Phone */
|
||||
windows: boolean;
|
||||
windowsphone: boolean;
|
||||
/**other than android, chromeos, webos, tizen, and sailfish */
|
||||
linux: boolean;
|
||||
chromeos: boolean;
|
||||
android: boolean;
|
||||
/** also sets one of iphone/ipad/ipod */
|
||||
ios: boolean;
|
||||
blackberry: boolean;
|
||||
firefoxos: boolean;
|
||||
/** may also set touchpad */
|
||||
webos: boolean;
|
||||
bada: boolean;
|
||||
tizen: boolean;
|
||||
sailfish: boolean;
|
||||
}
|
||||
|
||||
export interface IBowserVersions {
|
||||
chrome: boolean;
|
||||
webkit: boolean;
|
||||
phantom: boolean;
|
||||
opera: boolean;
|
||||
firefox: boolean;
|
||||
msie: boolean;
|
||||
msedge: boolean;
|
||||
safari: boolean;
|
||||
android: boolean;
|
||||
ios: boolean;
|
||||
webos: boolean;
|
||||
msedge: boolean;
|
||||
seamonkey: boolean;
|
||||
firefox: boolean;
|
||||
yandexbrowser: boolean;
|
||||
opera: boolean;
|
||||
phantom: boolean;
|
||||
blackberry: boolean;
|
||||
tablet: boolean;
|
||||
mobile: boolean;
|
||||
webos: boolean;
|
||||
silk: boolean;
|
||||
bada: boolean;
|
||||
tizen: boolean;
|
||||
windowsphone: boolean;
|
||||
firefoxos: boolean;
|
||||
gecko: boolean;
|
||||
seamonkey: boolean;
|
||||
sailfish: boolean;
|
||||
chromeBook: boolean;
|
||||
ucbrowser: boolean;
|
||||
qupzilla: boolean;
|
||||
vivaldi: boolean;
|
||||
sleipnir: boolean;
|
||||
kMeleon: boolean;
|
||||
}
|
||||
|
||||
export interface IBowserEngines {
|
||||
/** IE <= 11 */
|
||||
msie: boolean;
|
||||
/**Chrome 0-27, Android <4.4, iOs, BB, etc. */
|
||||
webkit: boolean;
|
||||
/**Chrome >=28, Android >=4.4, Opera, etc. */
|
||||
blink: boolean;
|
||||
/**Firefox, etc. */
|
||||
gecko: boolean;
|
||||
/** IE > 11 */
|
||||
msedge: boolean;
|
||||
/** If a tablet device is detected, the flag tablet is set instead of mobile. */
|
||||
tablet: boolean;
|
||||
/** All detected mobile OSes are additionally flagged mobile, unless it's a tablet */
|
||||
mobile: boolean;
|
||||
|
||||
}
|
||||
|
||||
export interface IBowserGrade {
|
||||
/** Grade A browser */
|
||||
a: boolean;
|
||||
/** Grade C browser */
|
||||
c: boolean;
|
||||
/** Grade X browser */
|
||||
x: boolean;
|
||||
/**A human readable name for this browser. E.g. 'Chrome', '' */
|
||||
name: string;
|
||||
/**Version number for the browser. E.g. '32.0' */
|
||||
version: string|number;
|
||||
osversion: string|number;
|
||||
}
|
||||
|
||||
export interface IBowser extends IBowserUA {
|
||||
export interface IBowserDetection extends IBowserGrade, IBowserEngines, IBowserOS, IBowserVersions { }
|
||||
|
||||
export interface IBowserMinVersions {
|
||||
// { msie: "11", "firefox": "4" }
|
||||
[index: string]: string;
|
||||
}
|
||||
|
||||
export interface IBowser extends IBowserDetection {
|
||||
(): IBowserDetection;
|
||||
test(browserList: string[]): boolean;
|
||||
_detect(ua: string): IBowser;
|
||||
compareVersions(versions: string[]): number;
|
||||
check(minVersions: IBowserMinVersions, strictMode?: boolean|string, ua?: string): Boolean;
|
||||
isUnsupportedBrowser(minVersions: IBowserMinVersions, strictMode?: boolean|string, ua?: string): boolean;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/// <reference path="chroma-js.d.ts" />
|
||||
|
||||
import * as myChroma from "chroma-js";
|
||||
|
||||
function test_chroma() {
|
||||
chroma('hotpink');
|
||||
chroma('#ff3399');
|
||||
@@ -41,6 +43,9 @@ function test_chroma() {
|
||||
chroma.limits(data, 'e', 5);
|
||||
chroma.limits(data, 'q', 5);
|
||||
chroma.limits(data, 'k', 5);
|
||||
|
||||
myChroma(0xff3399);
|
||||
myChroma.limits(data, 'k', 5);
|
||||
}
|
||||
|
||||
function test_color() {
|
||||
@@ -99,6 +104,10 @@ function test_color() {
|
||||
chroma('#cbdbff').temperature();
|
||||
chroma('#b3ccff').temperature();
|
||||
chroma('33cc00').gl();
|
||||
|
||||
myChroma('teal').alpha(0.5).css();
|
||||
myChroma('teal').css('hsl');
|
||||
myChroma('orange').rgb();
|
||||
}
|
||||
|
||||
function test_scale() {
|
||||
@@ -163,4 +172,17 @@ function test_scale() {
|
||||
|
||||
chroma.scale('OrRd').classes(5);
|
||||
chroma.scale('OrRd').classes(8);
|
||||
}
|
||||
|
||||
myChroma.cubehelix()
|
||||
.start(200)
|
||||
.rotations(-0.35)
|
||||
.gamma(0.7)
|
||||
.lightness([0.3, 0.8])
|
||||
.scale() // convert to chroma.scale
|
||||
|
||||
.correctLightness()
|
||||
.colors(5);
|
||||
|
||||
myChroma.scale('RdYlBu');
|
||||
myChroma.scale('RdYlBu').padding(0.15);
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -263,3 +263,7 @@ declare namespace Chroma {
|
||||
}
|
||||
|
||||
declare var chroma: Chroma.ChromaStatic;
|
||||
|
||||
declare module "chroma-js" {
|
||||
export = chroma;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/consolidate.d.ts
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
|
||||
declare module "consolidate" {
|
||||
var cons: Consolidate;
|
||||
|
||||
@@ -126,12 +126,27 @@ function fsaccessor(fs: FileSystem) {
|
||||
(err: FileError)=> { alert('Error: ' + err.code); });
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// FileSystem plugin
|
||||
//
|
||||
//cordova states that the enums for requestFileSystem live on LocalFileSystem
|
||||
//
|
||||
window.requestFileSystem(
|
||||
window.TEMPORARY,
|
||||
LocalFileSystem.TEMPORARY,
|
||||
1024 * 1024 * 5,
|
||||
fsaccessor,
|
||||
(err: FileError) => { alert('Error: ' + err.code); }
|
||||
);
|
||||
window.requestFileSystem(
|
||||
LocalFileSystem.PERSISTENT,
|
||||
1024 * 1024 * 5,
|
||||
fsaccessor,
|
||||
(err: FileError) => { alert('Error: ' + err.code); }
|
||||
);
|
||||
// FileSystem plugin
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
window.resolveLocalFileSystemURI(cordova.file.applicationDirectory,
|
||||
(entry: Entry)=> {
|
||||
|
||||
Vendored
+74
-10
@@ -42,6 +42,40 @@ interface Contacts {
|
||||
*/
|
||||
pickContact(onSuccess: (contact: Contact) => void,
|
||||
onError: (error: ContactError) => void): void
|
||||
|
||||
/**
|
||||
* This allows us to use an enumeration when setting the desired fields for the ContactFindOptions.
|
||||
* The values will correspond to the type of string literals in ContactFieldType.
|
||||
*/
|
||||
fieldType: {
|
||||
addresses: "addresses",
|
||||
birthday: "birthday",
|
||||
categories: "categories",
|
||||
country: "country",
|
||||
department: "department",
|
||||
displayName: "displayName",
|
||||
emails: "emails",
|
||||
familyName: "familyName",
|
||||
formatted: "formatted",
|
||||
givenName: "givenName",
|
||||
honorificPrefix: "honorificPrefix",
|
||||
honorificSuffix: "honorificSuffix",
|
||||
id: "id",
|
||||
ims: "ims",
|
||||
locality: "locality",
|
||||
middleName: "middleName",
|
||||
name: "name",
|
||||
nickname: "nickname",
|
||||
note: "note",
|
||||
organizations: "organizations",
|
||||
phoneNumbers: "phoneNumbers",
|
||||
photos: "photos",
|
||||
postalCode: "postalCode",
|
||||
region: "region",
|
||||
streetAddress: "streetAddress",
|
||||
title: "title",
|
||||
urls: "urls"
|
||||
}
|
||||
}
|
||||
|
||||
interface ContactProperties {
|
||||
@@ -105,7 +139,7 @@ interface Contact extends ContactProperties {
|
||||
|
||||
declare var Contact: {
|
||||
/** Constructor of Contact object */
|
||||
new(id?: string,
|
||||
new (id?: string,
|
||||
displayName?: string,
|
||||
name?: ContactName,
|
||||
nickname?: string,
|
||||
@@ -130,7 +164,7 @@ interface ContactError {
|
||||
}
|
||||
|
||||
declare var ContactError: {
|
||||
new(code: number): ContactError;
|
||||
new (code: number): ContactError;
|
||||
UNKNOWN_ERROR: number;
|
||||
INVALID_ARGUMENT_ERROR: number;
|
||||
TIMEOUT_ERROR: number;
|
||||
@@ -158,7 +192,7 @@ interface ContactName {
|
||||
|
||||
declare var ContactName: {
|
||||
/** Constructor for ContactName object */
|
||||
new(formatted?: string,
|
||||
new (formatted?: string,
|
||||
familyName?: string,
|
||||
givenName?: string,
|
||||
middleName?: string,
|
||||
@@ -189,7 +223,7 @@ interface ContactField {
|
||||
|
||||
declare var ContactField: {
|
||||
/** Constructor for ContactField object */
|
||||
new(type?: string,
|
||||
new (type?: string,
|
||||
value?: string,
|
||||
pref?: boolean): ContactField
|
||||
};
|
||||
@@ -219,7 +253,7 @@ interface ContactAddress {
|
||||
|
||||
declare var ContactAddress: {
|
||||
/** Constructor of ContactAddress object */
|
||||
new(pref?: boolean,
|
||||
new (pref?: boolean,
|
||||
type?: string,
|
||||
formatted?: string,
|
||||
streetAddress?: string,
|
||||
@@ -248,7 +282,7 @@ interface ContactOrganization {
|
||||
|
||||
declare var ContactOrganization: {
|
||||
/** Constructor for ContactOrganization object */
|
||||
new(pref?: boolean,
|
||||
new (pref?: boolean,
|
||||
type?: string,
|
||||
name?: string,
|
||||
department?: string,
|
||||
@@ -262,12 +296,42 @@ interface ContactFindOptions {
|
||||
/** Determines if the find operation returns multiple navigator.contacts. */
|
||||
multiple?: boolean;
|
||||
/* Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. */
|
||||
desiredFields?: string[];
|
||||
desiredFields?: ContactFieldType[];
|
||||
}
|
||||
|
||||
/** these are the string values that are valid for the desired fields in ContactFindOptions */
|
||||
declare type ContactFieldType =
|
||||
"addresses"
|
||||
| "birthday"
|
||||
| "categories"
|
||||
| "country"
|
||||
| "department"
|
||||
| "displayName"
|
||||
| "emails"
|
||||
| "familyName"
|
||||
| "formatted"
|
||||
| "givenName"
|
||||
| "honorificPrefix"
|
||||
| "honorificSuffix"
|
||||
| "id"
|
||||
| "ims"
|
||||
| "locality"
|
||||
| "middleName"
|
||||
| "name"
|
||||
| "nickname"
|
||||
| "note"
|
||||
| "organizations"
|
||||
| "phoneNumbers"
|
||||
| "photos"
|
||||
| "postalCode"
|
||||
| "region"
|
||||
| "streetAddress"
|
||||
| "title"
|
||||
| "urls";
|
||||
|
||||
declare var ContactFindOptions: {
|
||||
/** Constructor for ContactFindOptions object */
|
||||
new(filter?: string,
|
||||
new (filter?: string,
|
||||
multiple?: boolean,
|
||||
desiredFields?: string[]): ContactFindOptions
|
||||
};
|
||||
desiredFields?: ContactFieldType[]): ContactFindOptions
|
||||
};
|
||||
|
||||
Vendored
+6
-1
@@ -15,7 +15,7 @@ interface Window {
|
||||
* @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied.
|
||||
*/
|
||||
requestFileSystem(
|
||||
type: number,
|
||||
type: LocalFileSystem,
|
||||
size: number,
|
||||
successCallback: (fileSystem: FileSystem) => void,
|
||||
errorCallback?: (fileError: FileError) => void): void;
|
||||
@@ -371,3 +371,8 @@ interface Cordova {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declare enum LocalFileSystem {
|
||||
PERSISTENT=0,
|
||||
TEMPORARY=1
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/// <reference path="countdown.d.ts" />
|
||||
|
||||
import { countdown, Timespan, CountdownStatic, Format } from 'countdown';
|
||||
import * as countdown from 'countdown';
|
||||
|
||||
let ts: Timespan;
|
||||
let ts: countdown.Timespan;
|
||||
let interval: number;
|
||||
|
||||
ts = <Timespan>countdown(new Date());
|
||||
ts = <Timespan>countdown(150);
|
||||
ts = <countdown.Timespan>countdown(new Date());
|
||||
ts = <countdown.Timespan>countdown(150);
|
||||
|
||||
interval = <number>countdown(new Date(),
|
||||
function (ts: Timespan) {
|
||||
function (ts: countdown.Timespan) {
|
||||
document.getElementById('pageTimer').innerHTML = ts.toHTML('strong');
|
||||
},
|
||||
countdown.HOURS | countdown.MINUTES | countdown.SECONDS,
|
||||
|
||||
Vendored
+10
-7
@@ -3,11 +3,11 @@
|
||||
// Definitions by: Gabriel Juchault <https://github.com/gjuchault>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'countdown' {
|
||||
export type DateFunction = (timespan: Timespan) => void;
|
||||
export type DateTime = number | Date | DateFunction;
|
||||
declare namespace countdown {
|
||||
type DateFunction = (timespan: Timespan) => void;
|
||||
type DateTime = number | Date | DateFunction;
|
||||
|
||||
export interface Timespan {
|
||||
interface Timespan {
|
||||
start?: Date;
|
||||
end?: Date;
|
||||
units?: number;
|
||||
@@ -26,7 +26,7 @@ declare module 'countdown' {
|
||||
toHTML(tagName?: string, label?: string): string;
|
||||
}
|
||||
|
||||
export interface Format {
|
||||
interface Format {
|
||||
singular?: string | Array<string>;
|
||||
plural?: string | Array<string>;
|
||||
last?: string;
|
||||
@@ -36,7 +36,7 @@ declare module 'countdown' {
|
||||
formatter?(value: number, unit: number): string;
|
||||
}
|
||||
|
||||
export interface CountdownStatic {
|
||||
interface CountdownStatic {
|
||||
(start: DateTime, end?: DateTime, units?: number, max?: number, digits?: number): Timespan | number;
|
||||
MILLENNIA: number;
|
||||
CENTURIES: number;
|
||||
@@ -64,6 +64,9 @@ declare module 'countdown' {
|
||||
resetFormat(): void;
|
||||
setFormat(format: Format): void;
|
||||
}
|
||||
}
|
||||
|
||||
export let countdown: CountdownStatic;
|
||||
declare module 'countdown' {
|
||||
let countdown: countdown.CountdownStatic;
|
||||
export = countdown;
|
||||
}
|
||||
|
||||
Vendored
+5
-1
@@ -11,7 +11,7 @@ interface JQuery {
|
||||
daterangepicker(settings?: daterangepicker.Settings, callback?: (start?: string | Date | moment.Moment, end?: string | Date | moment.Moment, label?: string) => any): JQuery;
|
||||
}
|
||||
|
||||
declare module daterangepicker {
|
||||
declare namespace daterangepicker {
|
||||
|
||||
interface DatepickerEventObject extends JQueryEventObject {
|
||||
date: Date;
|
||||
@@ -164,3 +164,7 @@ declare module daterangepicker {
|
||||
monthNames?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
declare module "daterangepicker" {
|
||||
export = daterangepicker;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
// Test file for db-migrate-base Definition file
|
||||
/// <reference path="db-migrate-base.d.ts" />
|
||||
|
||||
import * as DbMigrateBase from "db-migrate-base";
|
||||
|
||||
// Throw together a dummy driver
|
||||
let db = <DbMigrateBase.Base>{};
|
||||
|
||||
let callback = (err: any, response: any) => {
|
||||
// Do nothing.
|
||||
};
|
||||
|
||||
/// createTable(tableName, columnSpec, callback)
|
||||
db.createTable('pets', {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
}, callback);
|
||||
|
||||
db.createTable('pets', {
|
||||
columns: {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
},
|
||||
ifNotExists: true
|
||||
}, callback);
|
||||
|
||||
db.createTable('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: 'id'
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
|
||||
db.createTable('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
product_id: 'id'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
|
||||
/// dropTable(tableName, [options,] callback)
|
||||
db.dropTable('pets', callback);
|
||||
|
||||
db.dropTable('pets', { ifExists: true }, callback);
|
||||
|
||||
/// renameTable(tableName, newTableName, callback)
|
||||
db.renameTable('pets', 'pets_OLD', callback);
|
||||
|
||||
/// addColumn(tableName, columnName, columnSpec, callback)
|
||||
db.addColumn('pets', 'eyeColor', {
|
||||
type: 'string',
|
||||
length: 25,
|
||||
notNull: true,
|
||||
}, callback);
|
||||
|
||||
db.addColumn('pets', 'id', {
|
||||
type: 'int',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
notNull: true,
|
||||
unique: true
|
||||
}, callback);
|
||||
|
||||
/// renameColumn(tableName, oldColumnName, newColumnName, callback)
|
||||
db.renameColumn('pets', 'id', 'pet_id', callback);
|
||||
|
||||
/// changeColumn(tableName, columnName, columnSpec, callback)
|
||||
db.changeColumn('pets', 'eye_color', {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'pets_eye_color_id_fk',
|
||||
table: 'eye_color',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
eye_color: 'id'
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
|
||||
/// addIndex(tableName, indexName, columns, [unique,] callback)
|
||||
db.addIndex('pets', 'pets_eye_color_idx', ['eye_color'], callback);
|
||||
db.addIndex('pets', 'pets_registration_code_idx', ['registration_code'], true, callback);
|
||||
|
||||
/// addForeignKey(tableName, referencedTableName, keyName, fieldMapping, rules, callback)
|
||||
db.addForeignKey('module_user', 'modules', 'module_user_module_id_fk',
|
||||
{
|
||||
'module_id': 'id'
|
||||
},
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
}, callback);
|
||||
|
||||
/// removeForeignKey(tableName, keyName, options, callback)
|
||||
db.removeForeignKey('module_user', 'module_uer_module_id_foreign', callback);
|
||||
db.removeForeignKey('module_user', 'module_user_module_id_foreign', {
|
||||
dropIndex: true,
|
||||
}, callback);
|
||||
|
||||
/// insert(tableName, [columnNameArray,] valueArray, callback)
|
||||
db.insert('module_user', ['first_name', 'last_name'], ['Test', 'Testerson'], callback);
|
||||
db.insert('module_user', ['Test', 'Testerson'], callback);
|
||||
|
||||
/// removeIndex([tableName,] indexName, callback)
|
||||
db.removeIndex('pets', 'pets_eye_color_idx', callback);
|
||||
db.removeIndex('pets_eye_color_idx', callback);
|
||||
|
||||
/// runSql(sql, [params,] callback)
|
||||
db.runSql('INSERT INTO `module_user` (`?`,`?`) VALUES (\'?\',\'?\')', [
|
||||
'first_name', 'last_name',
|
||||
'Test', 'Testerson'
|
||||
], callback);
|
||||
db.runSql('DROP TABLE `pets`', callback);
|
||||
|
||||
/// all(sql, [params,] callback)
|
||||
db.all('SELECT * FROM `module_user` WHERE `?` = \'?\'', ['first_name', 'Test'], callback);
|
||||
db.all('SELECT * FROM `module_user`', callback);
|
||||
|
||||
/// =========
|
||||
/// Async
|
||||
/// =========
|
||||
|
||||
let onResolve = (result: any) => {};
|
||||
|
||||
/// createTableAsync(tableName, columnSpec)
|
||||
db.createTableAsync('pets', {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
}).then(onResolve);
|
||||
|
||||
db.createTableAsync('pets', {
|
||||
columns: {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
},
|
||||
ifNotExists: true
|
||||
}).then(onResolve);
|
||||
|
||||
db.createTableAsync('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: 'id'
|
||||
}
|
||||
}
|
||||
}).then(onResolve);
|
||||
|
||||
db.createTableAsync('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
product_id: 'id'
|
||||
}
|
||||
}
|
||||
}
|
||||
}).then(onResolve);
|
||||
|
||||
/// dropTableAsync(tableName, [options])
|
||||
db.dropTableAsync('pets').then(onResolve);
|
||||
db.dropTableAsync('pets', { ifExists: true }).then(onResolve);
|
||||
|
||||
/// renameTableAsync(tableName, newTableName)
|
||||
db.renameTableAsync('pets', 'pets_OLD').then(onResolve);
|
||||
|
||||
/// addColumnAsync(tableName, columnName, columnSpec)
|
||||
db.addColumnAsync('pets', 'eyeColor', {
|
||||
type: 'string',
|
||||
length: 25,
|
||||
notNull: true,
|
||||
}).then(onResolve);
|
||||
|
||||
db.addColumnAsync('pets', 'id', {
|
||||
type: 'int',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
notNull: true,
|
||||
unique: true
|
||||
}).then(onResolve);
|
||||
|
||||
/// renameColumnAsync(tableName, oldColumnName, newColumnName)
|
||||
db.renameColumnAsync('pets', 'id', 'pet_id').then(onResolve);
|
||||
|
||||
/// changeColumnAsync(tableName, columnName, columnSpec)
|
||||
db.changeColumnAsync('pets', 'eye_color', {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'pets_eye_color_id_fk',
|
||||
table: 'eye_color',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
eye_color: 'id'
|
||||
}
|
||||
}
|
||||
}).then(onResolve);
|
||||
|
||||
/// addIndexAsync(tableName, indexName, columns, [unique])
|
||||
db.addIndexAsync('pets', 'pets_eye_color_idx', ['eye_color']).then(onResolve);
|
||||
db.addIndexAsync('pets', 'pets_registration_code_idx', ['registration_code'], true).then(onResolve);
|
||||
|
||||
/// addForeignKeyAsync(tableName, referencedTableName, keyName, fieldMapping, rules)
|
||||
db.addForeignKeyAsync('module_user', 'modules', 'module_user_module_id_fk',
|
||||
{
|
||||
'module_id': 'id'
|
||||
},
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
}).then(onResolve);
|
||||
|
||||
/// removeForeignKeyAsync(tableName, keyName, options)
|
||||
db.removeForeignKeyAsync('module_user', 'module_uer_module_id_foreign').then(onResolve);
|
||||
db.removeForeignKeyAsync('module_user', 'module_user_module_id_foreign', {
|
||||
dropIndex: true,
|
||||
}).then(onResolve);
|
||||
|
||||
/// insertAsync(tableName, [columnNameArray,] valueArray)
|
||||
db.insertAsync('module_user', ['first_name', 'last_name'], ['Test', 'Testerson']).then(onResolve);
|
||||
db.insertAsync('module_user', ['Test', 'Testerson']).then(onResolve);
|
||||
|
||||
/// removeIndexAsync([tableName,] indexName)
|
||||
db.removeIndexAsync('pets', 'pets_eye_color_idx').then(onResolve);
|
||||
db.removeIndexAsync('pets_eye_color_idx').then(onResolve);
|
||||
|
||||
/// runSqlAsync(sql, [params])
|
||||
db.runSqlAsync('INSERT INTO `module_user` (`?`,`?`) VALUES (\'?\',\'?\')', [
|
||||
'first_name', 'last_name',
|
||||
'Test', 'Testerson'
|
||||
]).then(onResolve);
|
||||
db.runSqlAsync('DROP TABLE `pets`').then(onResolve);
|
||||
|
||||
/// allAsync(sql, [params])
|
||||
db.allAsync('SELECT * FROM `module_user` WHERE `?` = \'?\'', ['first_name', 'Test']).then(onResolve);
|
||||
db.allAsync('SELECT * FROM `module_user`').then(onResolve);
|
||||
Vendored
+152
@@ -0,0 +1,152 @@
|
||||
// Type definitions for db-migrate-base
|
||||
// Project: https://github.com/db-migrate/db-migrate-base
|
||||
// Definitions by: nickiannone <https://github.com/nickiannone>
|
||||
// Definitions: https://github.com/nickiannone/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts"/>
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
declare module "db-migrate-base" {
|
||||
|
||||
import * as Promise from "bluebird";
|
||||
|
||||
export interface CallbackFunction { (err: any, response: any): void; }
|
||||
|
||||
export interface InternalModule {
|
||||
log: any;
|
||||
type: any;
|
||||
}
|
||||
|
||||
export interface InternalOptions {
|
||||
mod: InternalModule;
|
||||
}
|
||||
|
||||
export interface ColumnSpec {
|
||||
length?: number;
|
||||
type: string;
|
||||
unsigned?: boolean;
|
||||
primaryKey?: boolean;
|
||||
autoIncrement?: boolean;
|
||||
notNull?: boolean;
|
||||
unique?: boolean;
|
||||
defaultValue?: any;
|
||||
foreignKey?: ForeignKeySpec;
|
||||
}
|
||||
|
||||
export interface ForeignKeySpec {
|
||||
name: string;
|
||||
table: string;
|
||||
rules?: ForeignKeyRules;
|
||||
mapping: string | any;
|
||||
}
|
||||
|
||||
export interface ForeignKeyRules {
|
||||
onDelete: string;
|
||||
onUpdate: string;
|
||||
}
|
||||
|
||||
export interface RemoveForeignKeyOptions {
|
||||
dropIndex?: boolean;
|
||||
}
|
||||
|
||||
export interface ColumnDef {
|
||||
foreignKey?: any; // TODO Figure this out!
|
||||
constraints: string;
|
||||
}
|
||||
|
||||
export interface CreateTableOptions {
|
||||
columns?: Array<ColumnSpec>;
|
||||
ifNotExists?: boolean;
|
||||
}
|
||||
|
||||
export interface DropTableOptions {
|
||||
ifExists?: boolean;
|
||||
}
|
||||
|
||||
export class Base {
|
||||
constructor(intern: InternalOptions);
|
||||
|
||||
close(callback?: CallbackFunction): void;
|
||||
mapDataType(str: string): string;
|
||||
truncate(tableName: string, callback: CallbackFunction): void;
|
||||
checkDBMS(dbms: any, callback: CallbackFunction): void;
|
||||
createDatabase(...options: any[]): void;
|
||||
switchDatabase(...options: any[]): void;
|
||||
dropDatabase(...options: any[]): void;
|
||||
recurseCallbackArray(foreignKeys: Array<string>, callback: CallbackFunction): void;
|
||||
bindForeignKey(tableName: string, columnName: string, fkOptions: ForeignKeySpec): (callback: CallbackFunction) => void;
|
||||
createColumnDef(name: string, spec: ColumnSpec, options?: any): ColumnDef; // TODO Figure out a type for `options`!
|
||||
//createColumnConstraint(spec: ColumnSpec, options?: any, ...implementationDefinedOptions: any[]): string;
|
||||
createMigrationsTable(callback: CallbackFunction): void;
|
||||
createSeedsTable(callback: CallbackFunction): void;
|
||||
createTable(tableName: string, options: any | CreateTableOptions, callback: CallbackFunction): void;
|
||||
dropTable(tableName: string, optionsOrCb?: DropTableOptions | CallbackFunction, callback?: CallbackFunction): void;
|
||||
renameTable(tableName: string, newTableName: string, callback: CallbackFunction): void;
|
||||
addColumn(tableName: string, columnName: string, columnSpec: ColumnSpec, callback: CallbackFunction): void;
|
||||
removeColumn(tableName: string, columnName: string, callback: CallbackFunction): void;
|
||||
renameColumn(tableName: string, oldColumnName: string, newColumnName: string, callback: CallbackFunction): void;
|
||||
changeColumn(tableName: string, columnName: string, columnSpec: ColumnSpec, callback: CallbackFunction): void;
|
||||
quoteDDLArr(arr: Array<string>): Array<string>;
|
||||
quoteArr(arr: Array<string>): Array<string>;
|
||||
addIndex(tableName: string, indexName: string, columns: string | Array<string>, uniqueOrCb?: boolean | CallbackFunction, callback?: CallbackFunction): void;
|
||||
insert(tableName: string, columnNameOrValueArray: any, valueArrayOrCb?: any | CallbackFunction, callback?: CallbackFunction): void;
|
||||
update(tableName: string, columnNameOrValueArray: any, valueArrayOrIds?: any, idsOrCb?: any | CallbackFunction, callback?: CallbackFunction): void;
|
||||
lookup(tableName: string, column: string, id?: any, callback?: CallbackFunction): void;
|
||||
removeIndex(tableNameOrIndexName: string, indexNameOrCb?: string | CallbackFunction, callback?: CallbackFunction): void;
|
||||
addForeignKey(tableName: string, referencedTableName: string, keyName: string, fieldMapping: any, rules: ForeignKeyRules, callback: CallbackFunction): void;
|
||||
removeForeignKey(tableName: string, keyName: string, optionsOrCb?: RemoveForeignKeyOptions | CallbackFunction, callback?: CallbackFunction): void;
|
||||
normalizeColumnSpec(spec: string | ColumnSpec): ColumnSpec;
|
||||
addMigrationRecord(name: string, callback: CallbackFunction): void;
|
||||
addSeedRecord(name: string, callback: CallbackFunction): void;
|
||||
startMigration(callback: CallbackFunction): void;
|
||||
endMigration(callback: CallbackFunction): void;
|
||||
runSql(sql?: string, paramsOrCb?: Array<any> | CallbackFunction, callback?: CallbackFunction): void;
|
||||
allLoadedMigrations(callback: CallbackFunction): void;
|
||||
allLoadedSeeds(callback: CallbackFunction): void;
|
||||
deleteMigration(migrationName: string, callback: CallbackFunction): void;
|
||||
remove(table: string, ids: any, callback: CallbackFunction): void; // TODO Make ids match the type of ids in buildWhereClause(ids);
|
||||
buildWhereClause(ids: any): string;
|
||||
deleteSeed(seedName: string, callback: CallbackFunction): void;
|
||||
all(sql: string, paramsOrCb?: Array<any> | CallbackFunction, callback?: CallbackFunction): void;
|
||||
escape(str: string): string;
|
||||
escapeString(str: string): string;
|
||||
escapeDDL(str: string): string;
|
||||
|
||||
// Promisified methods
|
||||
closeAsync(): Promise<any>;
|
||||
truncateAsync(tableName: string): Promise<any>;
|
||||
checkDBMSAsync(dbms: any): Promise<any>;
|
||||
createDatabaseAsync(...options: any[]): Promise<any>;
|
||||
switchDatabaseAsync(...options: any[]): Promise<any>;
|
||||
dropDatabaseAsync(...options: any[]): Promise<any>;
|
||||
recurseCallbackArrayAsync(foreignKeys: Array<string>): Promise<any>;
|
||||
createMigrationsTableAsync(): Promise<any>;
|
||||
createSeedsTableAsync(): Promise<any>;
|
||||
createTableAsync(tableName: string, options: any | CreateTableOptions): Promise<any>;
|
||||
dropTableAsync(tableName: string, options?: DropTableOptions): Promise<any>;
|
||||
renameTableAsync(tableName: string, newTableName: string): Promise<any>;
|
||||
addColumnAsync(tableName: string, columnName: string, columnSpec: ColumnSpec): Promise<any>;
|
||||
removeColumnAsync(tableName: string, columnName: string): Promise<any>;
|
||||
renameColumnAsync(tableName: string, oldColumnName: string, newColumnName: string): Promise<any>;
|
||||
changeColumnAsync(tableName: string, columnName: string, columnSpec: ColumnSpec): Promise<any>;
|
||||
addIndexAsync(tableName: string, indexName: string, columns: string | Array<string>, unique?: boolean): Promise<any>;
|
||||
insertAsync(tableName: string, columnNameOrValueArray: any, valueArrayOrCb?: any | CallbackFunction, callback?: CallbackFunction): Promise<any>;
|
||||
updateAsync(tableName: string, columnNameOrValueArray: any, valueArrayOrIds?: any, idsOrCb?: any | CallbackFunction, callback?: CallbackFunction): Promise<any>;
|
||||
lookupAsync(tableName: string, column: string, id?: any, callback?: CallbackFunction): Promise<any>;
|
||||
removeIndexAsync(tableNameOrIndexName: string, indexName?: string): Promise<any>;
|
||||
addForeignKeyAsync(tableName: string, referencedTableName: string, keyName: string, fieldMapping: any, rules: ForeignKeyRules): Promise<any>;
|
||||
removeForeignKeyAsync(tableName: string, keyName: string, options?: RemoveForeignKeyOptions): Promise<any>;
|
||||
addMigrationRecordAsync(name: string): Promise<any>;
|
||||
addSeedRecordAsync(name: string): Promise<any>;
|
||||
startMigrationAsync(): Promise<any>;
|
||||
endMigrationAsync(callback: CallbackFunction): Promise<any>;
|
||||
runSqlAsync(sql?: string, params?: Array<any>): Promise<any>;
|
||||
allLoadedMigrationsAsync(): Promise<any>;
|
||||
allLoadedSeedsAsync(): Promise<any>;
|
||||
deleteMigrationAsync(migrationName: string): Promise<any>;
|
||||
removeAsync(table: string, ids: any): Promise<any>;
|
||||
deleteSeedAsync(seedName: string): Promise<any>;
|
||||
allAsync(sql: string, params?: Array<any>): Promise<any>;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
// Test file for db-migrate-pg Definition file
|
||||
/// <reference path="db-migrate-pg.d.ts" />
|
||||
|
||||
import * as DbMigratePg from "db-migrate-pg";
|
||||
|
||||
// Throw together a dummy driver
|
||||
let db = <DbMigratePg.PgDriver>{};
|
||||
|
||||
let callback = (err: any, response: any) => {
|
||||
// Do nothing.
|
||||
};
|
||||
|
||||
/// createTable(tableName, columnSpec, callback)
|
||||
db.createTable('pets', {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
}, callback);
|
||||
|
||||
db.createTable('pets', {
|
||||
columns: {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
},
|
||||
ifNotExists: true
|
||||
}, callback);
|
||||
|
||||
db.createTable('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: 'id'
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
|
||||
db.createTable('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
product_id: 'id'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
|
||||
/// dropTable(tableName, [options,] callback)
|
||||
db.dropTable('pets', callback);
|
||||
|
||||
db.dropTable('pets', { ifExists: true }, callback);
|
||||
|
||||
/// renameTable(tableName, newTableName, callback)
|
||||
db.renameTable('pets', 'pets_OLD', callback);
|
||||
|
||||
/// addColumn(tableName, columnName, columnSpec, callback)
|
||||
db.addColumn('pets', 'eyeColor', {
|
||||
type: 'string',
|
||||
length: 25,
|
||||
notNull: true,
|
||||
}, callback);
|
||||
|
||||
db.addColumn('pets', 'id', {
|
||||
type: 'int',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
notNull: true,
|
||||
unique: true
|
||||
}, callback);
|
||||
|
||||
/// renameColumn(tableName, oldColumnName, newColumnName, callback)
|
||||
db.renameColumn('pets', 'id', 'pet_id', callback);
|
||||
|
||||
/// changeColumn(tableName, columnName, columnSpec, callback)
|
||||
db.changeColumn('pets', 'eye_color', {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'pets_eye_color_id_fk',
|
||||
table: 'eye_color',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
eye_color: 'id'
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
|
||||
/// addIndex(tableName, indexName, columns, [unique,] callback)
|
||||
db.addIndex('pets', 'pets_eye_color_idx', ['eye_color'], callback);
|
||||
db.addIndex('pets', 'pets_registration_code_idx', ['registration_code'], true, callback);
|
||||
|
||||
/// addForeignKey(tableName, referencedTableName, keyName, fieldMapping, rules, callback)
|
||||
db.addForeignKey('module_user', 'modules', 'module_user_module_id_fk',
|
||||
{
|
||||
'module_id': 'id'
|
||||
},
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
}, callback);
|
||||
|
||||
/// removeForeignKey(tableName, keyName, options, callback)
|
||||
db.removeForeignKey('module_user', 'module_uer_module_id_foreign', callback);
|
||||
db.removeForeignKey('module_user', 'module_user_module_id_foreign', {
|
||||
dropIndex: true,
|
||||
}, callback);
|
||||
|
||||
/// insert(tableName, [columnNameArray,] valueArray, callback)
|
||||
db.insert('module_user', ['first_name', 'last_name'], ['Test', 'Testerson'], callback);
|
||||
db.insert('module_user', ['Test', 'Testerson'], callback);
|
||||
|
||||
/// removeIndex([tableName,] indexName, callback)
|
||||
db.removeIndex('pets', 'pets_eye_color_idx', callback);
|
||||
db.removeIndex('pets_eye_color_idx', callback);
|
||||
|
||||
/// runSql(sql, [params,] callback)
|
||||
db.runSql('INSERT INTO `module_user` (`?`,`?`) VALUES (\'?\',\'?\')', [
|
||||
'first_name', 'last_name',
|
||||
'Test', 'Testerson'
|
||||
], callback);
|
||||
db.runSql('DROP TABLE `pets`', callback);
|
||||
|
||||
/// all(sql, [params,] callback)
|
||||
db.all('SELECT * FROM `module_user` WHERE `?` = \'?\'', ['first_name', 'Test'], callback);
|
||||
db.all('SELECT * FROM `module_user`', callback);
|
||||
|
||||
/// =========
|
||||
/// Async
|
||||
/// =========
|
||||
|
||||
let onResolve = (result: any) => {};
|
||||
|
||||
/// createTableAsync(tableName, columnSpec)
|
||||
db.createTableAsync('pets', {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
}).then(onResolve);
|
||||
|
||||
db.createTableAsync('pets', {
|
||||
columns: {
|
||||
id: { type: 'int', primaryKey: true, autoIncrement: true },
|
||||
name: 'string'
|
||||
},
|
||||
ifNotExists: true
|
||||
}).then(onResolve);
|
||||
|
||||
db.createTableAsync('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: 'id'
|
||||
}
|
||||
}
|
||||
}).then(onResolve);
|
||||
|
||||
db.createTableAsync('product_variant',
|
||||
{
|
||||
id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
length: 10
|
||||
},
|
||||
product_id: {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
length: 10,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'product_variant_product_id_fk',
|
||||
table: 'product',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
product_id: 'id'
|
||||
}
|
||||
}
|
||||
}
|
||||
}).then(onResolve);
|
||||
|
||||
/// dropTableAsync(tableName, [options])
|
||||
db.dropTableAsync('pets').then(onResolve);
|
||||
db.dropTableAsync('pets', { ifExists: true }).then(onResolve);
|
||||
|
||||
/// renameTableAsync(tableName, newTableName)
|
||||
db.renameTableAsync('pets', 'pets_OLD').then(onResolve);
|
||||
|
||||
/// addColumnAsync(tableName, columnName, columnSpec)
|
||||
db.addColumnAsync('pets', 'eyeColor', {
|
||||
type: 'string',
|
||||
length: 25,
|
||||
notNull: true,
|
||||
}).then(onResolve);
|
||||
|
||||
db.addColumnAsync('pets', 'id', {
|
||||
type: 'int',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
notNull: true,
|
||||
unique: true
|
||||
}).then(onResolve);
|
||||
|
||||
/// renameColumnAsync(tableName, oldColumnName, newColumnName)
|
||||
db.renameColumnAsync('pets', 'id', 'pet_id').then(onResolve);
|
||||
|
||||
/// changeColumnAsync(tableName, columnName, columnSpec)
|
||||
db.changeColumnAsync('pets', 'eye_color', {
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
notNull: true,
|
||||
foreignKey: {
|
||||
name: 'pets_eye_color_id_fk',
|
||||
table: 'eye_color',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
eye_color: 'id'
|
||||
}
|
||||
}
|
||||
}).then(onResolve);
|
||||
|
||||
/// addIndexAsync(tableName, indexName, columns, [unique])
|
||||
db.addIndexAsync('pets', 'pets_eye_color_idx', ['eye_color']).then(onResolve);
|
||||
db.addIndexAsync('pets', 'pets_registration_code_idx', ['registration_code'], true).then(onResolve);
|
||||
|
||||
/// addForeignKeyAsync(tableName, referencedTableName, keyName, fieldMapping, rules)
|
||||
db.addForeignKeyAsync('module_user', 'modules', 'module_user_module_id_fk',
|
||||
{
|
||||
'module_id': 'id'
|
||||
},
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
}).then(onResolve);
|
||||
|
||||
/// removeForeignKeyAsync(tableName, keyName, options)
|
||||
db.removeForeignKeyAsync('module_user', 'module_uer_module_id_foreign').then(onResolve);
|
||||
db.removeForeignKeyAsync('module_user', 'module_user_module_id_foreign', {
|
||||
dropIndex: true,
|
||||
}).then(onResolve);
|
||||
|
||||
/// insertAsync(tableName, [columnNameArray,] valueArray)
|
||||
db.insertAsync('module_user', ['first_name', 'last_name'], ['Test', 'Testerson']).then(onResolve);
|
||||
db.insertAsync('module_user', ['Test', 'Testerson']).then(onResolve);
|
||||
|
||||
/// removeIndexAsync([tableName,] indexName)
|
||||
db.removeIndexAsync('pets', 'pets_eye_color_idx').then(onResolve);
|
||||
db.removeIndexAsync('pets_eye_color_idx').then(onResolve);
|
||||
|
||||
/// runSqlAsync(sql, [params])
|
||||
db.runSqlAsync('INSERT INTO `module_user` (`?`,`?`) VALUES (\'?\',\'?\')', [
|
||||
'first_name', 'last_name',
|
||||
'Test', 'Testerson'
|
||||
]).then(onResolve);
|
||||
db.runSqlAsync('DROP TABLE `pets`').then(onResolve);
|
||||
|
||||
/// allAsync(sql, [params])
|
||||
db.allAsync('SELECT * FROM `module_user` WHERE `?` = \'?\'', ['first_name', 'Test']).then(onResolve);
|
||||
db.allAsync('SELECT * FROM `module_user`').then(onResolve);
|
||||
|
||||
/// ====================
|
||||
/// PG-specific tests
|
||||
/// ====================
|
||||
|
||||
/// createColumnConstraint(spec, options, tableName, columnName) (INTERNAL USE ONLY)
|
||||
let constraint: DbMigratePg.ColumnConstraint;
|
||||
|
||||
constraint = db.createColumnConstraint({
|
||||
type: 'int',
|
||||
length: 10,
|
||||
unsigned: true,
|
||||
primaryKey: false,
|
||||
autoIncrement: false,
|
||||
notNull: true,
|
||||
unique: false,
|
||||
defaultValue: 0,
|
||||
foreignKey: {
|
||||
name: 'pets_eye_color_id_fk',
|
||||
table: 'eye_color',
|
||||
rules: {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'RESTRICT'
|
||||
},
|
||||
mapping: {
|
||||
'eye_color': 'id'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
emitPrimaryKey: false
|
||||
}, 'pets', 'eye_color');
|
||||
|
||||
// Print the SQL constraints
|
||||
console.log(constraint.constraints);
|
||||
|
||||
// Invoke the foreign key builder
|
||||
constraint.foreignKey(callback);
|
||||
|
||||
/// Public Callback Methods:
|
||||
|
||||
/// createDatabase(dbName, [options,] callback)
|
||||
db.createDatabase('petstore', callback);
|
||||
db.createDatabase('petstore', {}, callback);
|
||||
|
||||
/// dropDatabase(dbName, [options,] callback)
|
||||
db.dropDatabase('petstore', callback);
|
||||
db.dropDatabase('petstore', { ifExists: true }, callback);
|
||||
|
||||
/// createSequence(sqName, [options,] callback)
|
||||
db.createSequence('pets_id_sq', callback);
|
||||
db.createSequence('pets_id_sq', { temp: true }, callback);
|
||||
|
||||
/// switchDatabase(options, callback)
|
||||
db.switchDatabase('petstore', callback);
|
||||
db.switchDatabase({ database: 'petstore' }, callback);
|
||||
|
||||
/// dropSequence(sqName, [options,] callback)
|
||||
db.dropSequence('pets_id_sq', callback);
|
||||
db.dropSequence('pets_id_sq', {
|
||||
ifExists: true,
|
||||
cascade: true,
|
||||
restrict: true,
|
||||
}, callback);
|
||||
|
||||
/// Public Promisified Methods:
|
||||
|
||||
/// createDatabaseAsync(dbName, [options])
|
||||
db.createDatabaseAsync('petstore').then(onResolve);
|
||||
db.createDatabaseAsync('petstore', {}).then(onResolve);
|
||||
|
||||
/// dropDatabaseAsync(dbName, [options])
|
||||
db.dropDatabaseAsync('petstore').then(onResolve);
|
||||
db.dropDatabaseAsync('petstore', { ifExists: true }).then(onResolve);
|
||||
|
||||
/// createSequenceAsync(sqName, [options])
|
||||
db.createSequenceAsync('pets_id_sq').then(onResolve);
|
||||
db.createSequenceAsync('pets_id_sq', { temp: true }).then(onResolve);
|
||||
|
||||
/// switchDatabaseAsync(options)
|
||||
db.switchDatabaseAsync('petstore').then(onResolve);
|
||||
db.switchDatabaseAsync({ database: 'petstore' }).then(onResolve);
|
||||
|
||||
/// dropSequenceAsync(sqName, [options])
|
||||
db.dropSequenceAsync('pets_id_sq').then(onResolve);
|
||||
db.dropSequenceAsync('pets_id_sq', {
|
||||
ifExists: true,
|
||||
cascade: true,
|
||||
restrict: true,
|
||||
}).then(onResolve);
|
||||
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
// Type definitions for db-migrate-pg
|
||||
// Project: https://github.com/db-migrate/pg
|
||||
// Definitions by: nickiannone <http://github.com/nickiannone>
|
||||
// Definitions: https://github.com/nickiannone/DefinitelyTyped
|
||||
|
||||
/// <reference path="../db-migrate-base/db-migrate-base.d.ts"/>
|
||||
/// <reference path="../pg/pg.d.ts" />
|
||||
|
||||
declare module "db-migrate-pg" {
|
||||
|
||||
import * as pg from "pg";
|
||||
import * as DbMigrateBase from "db-migrate-base";
|
||||
import * as Promise from "bluebird";
|
||||
|
||||
// Yes, this is a dummy interface for now; the current implementation of the pg driver doesn't need any options.
|
||||
export interface CreateDatabaseOptions {}
|
||||
|
||||
export interface DropDatabaseOptions {
|
||||
ifExists?: boolean;
|
||||
}
|
||||
|
||||
export interface CreateSequenceOptions {
|
||||
temp?: boolean;
|
||||
}
|
||||
|
||||
export interface SwitchDatabaseOptions {
|
||||
database?: string;
|
||||
}
|
||||
|
||||
export interface DropSequenceOptions {
|
||||
ifExists?: boolean;
|
||||
cascade?: boolean;
|
||||
restrict?: boolean;
|
||||
}
|
||||
|
||||
export interface ColumnConstraint {
|
||||
foreignKey: (callback: DbMigrateBase.CallbackFunction) => void;
|
||||
constraints: string;
|
||||
}
|
||||
|
||||
export interface ColumnConstraintOptions {
|
||||
emitPrimaryKey?: boolean;
|
||||
}
|
||||
|
||||
export class PgDriver extends DbMigrateBase.Base {
|
||||
constructor(connection: pg.Client, schema: string, intern: DbMigrateBase.InternalOptions);
|
||||
createDatabase(dbName: string, optionsOrCb: CreateDatabaseOptions | DbMigrateBase.CallbackFunction, callback?: DbMigrateBase.CallbackFunction): void;
|
||||
dropDatabase(dbName: string, optionsOrCb: DropDatabaseOptions | DbMigrateBase.CallbackFunction, callback?: DbMigrateBase.CallbackFunction): void;
|
||||
createSequence(sqName: string, optionsOrCb: CreateSequenceOptions | DbMigrateBase.CallbackFunction, callback?: DbMigrateBase.CallbackFunction): void;
|
||||
switchDatabase(options: string | SwitchDatabaseOptions, callback: DbMigrateBase.CallbackFunction): void;
|
||||
dropSequence(dbName: string, optionsOrCb: DropSequenceOptions | DbMigrateBase.CallbackFunction, callback?: DbMigrateBase.CallbackFunction): void;
|
||||
createColumnConstraint(spec: DbMigrateBase.ColumnSpec, options: ColumnConstraintOptions, tableName: string, columnName: string): ColumnConstraint;
|
||||
|
||||
createDatabaseAsync(dbName: string, options?: CreateDatabaseOptions): Promise<any>;
|
||||
dropDatabaseAsync(dbName: string, options?: DropDatabaseOptions): Promise<any>;
|
||||
createSequenceAsync(sqName: string, options?: CreateSequenceOptions): Promise<any>;
|
||||
switchDatabaseAsync(options: string | SwitchDatabaseOptions): Promise<any>;
|
||||
dropSequenceAsync(dbName: string, options?: DropSequenceOptions): Promise<any>;
|
||||
}
|
||||
}
|
||||
Vendored
+549
-298
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
/// <reference path="devtools-detect.d.ts" />
|
||||
|
||||
// check if it's open
|
||||
console.log('is DevTools open?', window.devtools.open);
|
||||
// check it's orientation, null if not open
|
||||
console.log('and DevTools orientation?', window.devtools.orientation);
|
||||
|
||||
// get notified when it's opened/closed or orientation changes
|
||||
window.addEventListener('devtoolschange', function (e) {
|
||||
console.log('is DevTools open?', e.detail.open);
|
||||
console.log('and DevTools orientation?', e.detail.orientation);
|
||||
});
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for ajv
|
||||
// Project: https://github.com/sindresorhus/devtools-detect
|
||||
// Definitions by: York Yao <https://github.com/plantain-00/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type DevTools = {
|
||||
open: boolean;
|
||||
orientation: "vertical" | "horizontal";
|
||||
}
|
||||
interface DevToolsEvent extends Event {
|
||||
detail: DevTools;
|
||||
}
|
||||
interface Window {
|
||||
devtools: DevTools;
|
||||
addEventListener(type: "devtoolschange", listener: (ev: DevToolsEvent) => any, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="./diff2html.d.ts" />
|
||||
|
||||
import Diff2Html = require('diff2html');
|
||||
|
||||
let d2h = Diff2Html.Diff2Html;
|
||||
|
||||
class Diff2HtmlOptionsImpl implements Diff2Html.Options {
|
||||
constructor (public inputFormat: string) {
|
||||
}
|
||||
}
|
||||
|
||||
let strInput =
|
||||
'diff --git a/sample b/sample\n' +
|
||||
'index 0000001..0ddf2ba\n' +
|
||||
'--- a/sample\n' +
|
||||
'+++ b/sample\n' +
|
||||
'@@ -1 +1 @@\n' +
|
||||
'-test\n' +
|
||||
'+test1r\n';
|
||||
|
||||
let strConfiguration = new Diff2HtmlOptionsImpl('diff');
|
||||
let diffInput = d2h.getJsonFromDiff(strInput, strConfiguration);
|
||||
|
||||
let diffConfiguration = new Diff2HtmlOptionsImpl('json');
|
||||
let htmlString = d2h.getPrettyHtml(diffInput, diffConfiguration);
|
||||
console.log(htmlString);
|
||||
Vendored
+66
@@ -0,0 +1,66 @@
|
||||
// Type definitions for diff2html
|
||||
// Project: https://github.com/rtfpessoa/diff2html
|
||||
// Definitions by: rtfpessoa <https://github.com/rtfpessoa/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Diff2Html {
|
||||
|
||||
export interface Options {
|
||||
inputFormat?: string;
|
||||
outputFormat?: string;
|
||||
showFiles?: boolean;
|
||||
matching?: string;
|
||||
synchronisedScroll?: boolean;
|
||||
matchWordsThreshold?: number;
|
||||
matchingMaxComparisons?: number;
|
||||
}
|
||||
|
||||
export interface Line {
|
||||
content: string;
|
||||
type: string;
|
||||
oldNumber: number;
|
||||
newNumber: number;
|
||||
}
|
||||
|
||||
export interface Block {
|
||||
oldStartLine: number;
|
||||
oldStartLine2?: number;
|
||||
newStartLine: number;
|
||||
header: string;
|
||||
lines: Line[];
|
||||
}
|
||||
|
||||
export interface Result {
|
||||
addedLines: number;
|
||||
deletedLines: number;
|
||||
isCombined: boolean;
|
||||
isGitDiff: boolean;
|
||||
oldName: string;
|
||||
newName: string;
|
||||
language: string;
|
||||
blocks: Block[];
|
||||
oldMode?: string;
|
||||
newMode?: string;
|
||||
deletedFileMode?: string;
|
||||
newFileMode?: string;
|
||||
isDeleted?: boolean;
|
||||
isNew?: boolean;
|
||||
isCopy?: boolean;
|
||||
isRename?: boolean;
|
||||
unchangedPercentage?: number;
|
||||
changedPercentage?: number;
|
||||
checksumBefore?: string;
|
||||
checksumAfter?: string;
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
export interface Diff2Html {
|
||||
getJsonFromDiff(input: string, configuration?: Options): Result;
|
||||
getPrettyHtml(input: any, configuration?: Options): string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "diff2html" {
|
||||
var d2h: { "Diff2Html": Diff2Html.Diff2Html };
|
||||
export = d2h;
|
||||
}
|
||||
Vendored
+7
-2
@@ -93,8 +93,13 @@ declare module 'documentdb' {
|
||||
|
||||
/** Represents the result returned from a query. */
|
||||
interface QueryIterator<TResultRow> {
|
||||
|
||||
toArray(callback: (error: QueryError, result: TResultRow[]) => void): void;
|
||||
current(): TResultRow;
|
||||
executeNext(callback: (error: QueryError, result: TResultRow[], responseHeaders? : any) => void): void;
|
||||
forEach(iteratorFunction : (error: QueryError, element: TResultRow, responseHeaders? : any) => void): void;
|
||||
hasMoreResults(): boolean;
|
||||
nextItem(callback: (error : QueryError, item : TResultRow, responseHeaders? : any) => void): void;
|
||||
reset() : void;
|
||||
toArray(callback: (error: QueryError, result: TResultRow[], responseHeaders? : any) => void): void;
|
||||
}
|
||||
|
||||
/** Reprents an object with a unique identifier. */
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/// <reference path="domurl.d.ts" />
|
||||
|
||||
interface UModel extends QueryString {
|
||||
a: any;
|
||||
b: string;
|
||||
}
|
||||
|
||||
interface U2Model extends QueryString {
|
||||
a: any;
|
||||
}
|
||||
|
||||
interface U3Model extends QueryString {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
var u = new Url<UModel>(); // current document URL will be used
|
||||
// or we can instantiate as
|
||||
var u2 = new Url<U2Model>("http://example.com/some/path?a=b&c=d#someAnchor");
|
||||
// it should support relative URLs also
|
||||
var u3 = new Url<U3Model>("/my/site/doc/path?foo=bar#baz");
|
||||
|
||||
// get the value of some query string parameter
|
||||
console.log(u2.query.a);
|
||||
// or
|
||||
console.log(u3.query["foo"]);
|
||||
|
||||
// Manipulating query string parameters
|
||||
u.query.a = [1, 2, 3]; // adds/replaces in query string params a=1&a=2&a=3
|
||||
u.query.b = 'woohoo'; // adds/replaces in query string param b=woohoo
|
||||
|
||||
if (u.query.a instanceof Array) { // the way to add a parameter
|
||||
u.query.a.push(4); // now it's "a=1&a=2&a=3&a=4&b=woohoo"
|
||||
}
|
||||
|
||||
else { // if not an array but scalar value here is a way how to convert to array
|
||||
u.query.a = [u.query.a];
|
||||
u.query.a.push(8)
|
||||
}
|
||||
|
||||
|
||||
// The way to remove the parameter:
|
||||
delete u.query.a;
|
||||
// or:
|
||||
delete u.query["a"];
|
||||
|
||||
// If you need to remove all query string params:
|
||||
console.log(u.clearQuery());
|
||||
console.log(u.queryLength());
|
||||
console.log(u.isEmptyQuery());
|
||||
|
||||
// Lookup URL parts:
|
||||
console.log(
|
||||
'protocol = ' + u.protocol + '\n' +
|
||||
'user = ' + u.user + '\n' +
|
||||
'pass = ' + u.pass + '\n' +
|
||||
'host = ' + u.host + '\n' +
|
||||
'port = ' + u.port + '\n' +
|
||||
'path = ' + u.path + '\n' +
|
||||
'query = ' + u.query + '\n' +
|
||||
'hash = ' + u.hash
|
||||
);
|
||||
|
||||
// Manipulating URL parts
|
||||
u.path = '/some/new/path'; // the way to change URL path
|
||||
u.protocol = 'https'; // the way to force https protocol on the source URL
|
||||
|
||||
// inject into string
|
||||
var str = '<a href="' + u + '">My Cool Link</a>';
|
||||
|
||||
// or use in DOM context
|
||||
var a = document.createElement('a');
|
||||
a.href = u.toString();
|
||||
a.innerHTML = 'test';
|
||||
document.body.appendChild(a);
|
||||
|
||||
// Stringify
|
||||
var su1 = u + '';
|
||||
var su2 = String(u);
|
||||
var su3 = u.toString();
|
||||
// NOTE, that usually it will be done automatically, so only in special
|
||||
// cases direct stringify is required
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// Type definitions for domurl
|
||||
// Project: https://github.com/Mikhus/domurl
|
||||
// Definitions by: Mikhus <ttps://github.com/Mikhus>
|
||||
// Definitions: https://github.com/Mikhus/DefinitelyTyped
|
||||
|
||||
declare class QueryString {
|
||||
constructor(qs?: string);
|
||||
toString: () => string;
|
||||
}
|
||||
|
||||
declare class Url<T> {
|
||||
constructor(url?: string);
|
||||
query: T;
|
||||
protocol: string;
|
||||
user: string;
|
||||
pass: string;
|
||||
host: string;
|
||||
port: string;
|
||||
path: string;
|
||||
hash: string;
|
||||
href: string;
|
||||
toString: () => string;
|
||||
encode: (s: string) => string;
|
||||
decode: (s: string) => string;
|
||||
isAbsolute: () => boolean;
|
||||
paths: (paths?: [string]) => [string];
|
||||
isEmptyQuery: () => boolean;
|
||||
queryLength: () => number;
|
||||
clearQuery: () => Url<T>;
|
||||
}
|
||||
Vendored
+3
-3
@@ -89,7 +89,7 @@ declare module "dustjs-linkedin" {
|
||||
* Registers an event listener. Streams accept a single listener for a given event.
|
||||
* @param evt the event. Possible values are data, end, error (maybe more, look in the source).
|
||||
*/
|
||||
on(evt: string, callback: (data?: any) => any);
|
||||
on(evt: string, callback: (data?: any) => any): this;
|
||||
|
||||
pipe(stream: Stream): Stream;
|
||||
}
|
||||
@@ -126,8 +126,8 @@ declare module "dustjs-linkedin" {
|
||||
* @param name the template name.
|
||||
* @param context a plain object or an instance of dust.Context.
|
||||
*/
|
||||
export function render(name: string, context: any, callback: (err: any, out: string) => any);
|
||||
export function render(name: string, context: Context, callback: (err: any, out: string) => any);
|
||||
export function render(name: string, context: any, callback: (err: any, out: string) => any): void;
|
||||
export function render(name: string, context: Context, callback: (err: any, out: string) => any): void;
|
||||
|
||||
/**
|
||||
* Compiles and renders source, invoking callback on completion. If no callback is supplied this function returns a Stream object. Use this function when precompilation is not required.
|
||||
|
||||
@@ -32,4 +32,17 @@ client.indices.delete({
|
||||
ignore: [404]
|
||||
}).then(function (body) {
|
||||
}, function (error) {
|
||||
});
|
||||
|
||||
client.create({
|
||||
id: '123',
|
||||
index: 'index',
|
||||
type: 'type'
|
||||
});
|
||||
|
||||
client.create({
|
||||
id: '123',
|
||||
index: 'index',
|
||||
type: 'type'
|
||||
}, (err, repsonse, status) => {
|
||||
});
|
||||
Vendored
+17
@@ -9,6 +9,8 @@ declare module Elasticsearch {
|
||||
indices: Indices;
|
||||
bulk(params: BulkIndexDocumentsParams): PromiseLike<any>;
|
||||
bulk(params: BulkIndexDocumentsParams, callback: (error: any, response: any) => void): void;
|
||||
create(params: CreateDocumentParams): PromiseLike<any>;
|
||||
create(params: CreateDocumentParams, callback: (err: any, response: any, status: any) => void): void;
|
||||
delete(params: DeleteDocumentParams): PromiseLike<any>;
|
||||
delete(params: DeleteDocumentParams, callback: (error: any, response: any) => void): void;
|
||||
get(params: GetParams, callback: (error: any, response: any) => void): void;
|
||||
@@ -102,6 +104,21 @@ declare module Elasticsearch {
|
||||
index?: string;
|
||||
}
|
||||
|
||||
export interface CreateDocumentParams extends GenericParams {
|
||||
consistency?: "one" | "quorum" | "all";
|
||||
parent?: string;
|
||||
refressh?: boolean;
|
||||
routing?: string;
|
||||
timeout?: number | Date;
|
||||
timestamp?: number | Date;
|
||||
ttl?: number;
|
||||
version?: number;
|
||||
versionType?: "internal" | "external" | "external_gte" | "force";
|
||||
id: string;
|
||||
index: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface IndicesGetParams extends GenericParams {
|
||||
ignoreUnavailable?: boolean;
|
||||
index: string | string[] | boolean;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path="./electron-notifications.d.ts" />
|
||||
|
||||
import * as notifier from 'electron-notifications';
|
||||
|
||||
const data: ElectronNotifications.NotifierOptions = {
|
||||
message: 'message',
|
||||
icon: 'icon',
|
||||
buttons: ['ok', 'cancel']
|
||||
};
|
||||
const notification = notifier.notify('title', data);
|
||||
notification.on('clicked', () => { console.log('clicked') });
|
||||
notification.on('swipedRight', () => { console.log('swipedRight') });
|
||||
notification.on('buttonClicked', (text) => { console.log(`buttonClicked: ${text}`) });
|
||||
@@ -0,0 +1,41 @@
|
||||
// Type definitions for electron-notifications v0.0.3
|
||||
// Project: https://github.com/blainesch/electron-notifications
|
||||
// Definitions by: Daniel Pereira <https://github.com/djpereira>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../github-electron/github-electron.d.ts" />
|
||||
|
||||
declare namespace ElectronNotifications {
|
||||
|
||||
interface NotifierOptions {
|
||||
|
||||
/** A message to display under the title. */
|
||||
message?: string,
|
||||
|
||||
/** The absolute URL of a icon displayed to the left of the text. */
|
||||
icon?: string,
|
||||
|
||||
/** One or two buttons to display on the right of the notification. */
|
||||
buttons?: string[]
|
||||
}
|
||||
|
||||
class NotificationWindow extends Electron.BrowserWindow {
|
||||
|
||||
/** When the notification was clicked, but not dragged. This usually does the default action, or closes the notification. */
|
||||
on(event: 'clicked', listener: Function): this;
|
||||
|
||||
/** When the notification has been swiped to the right. This usually indiciated the user wants to dismiss the notification. */
|
||||
on(event: 'swipedRight', listener: Function): this;
|
||||
|
||||
/** When any one of the buttons are clicked, it will trigger a buttonClicked event, and pass the text that was clicked to the handler. */
|
||||
on(event: 'buttonClicked', listener: (text: string) => void): this;
|
||||
|
||||
on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** A node module for sending notifications in electron applications */
|
||||
declare module 'electron-notifications' {
|
||||
export function notify(title: string, data?: ElectronNotifications.NotifierOptions): ElectronNotifications.NotificationWindow;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="./electron-notify.d.ts" />
|
||||
|
||||
import * as eNotify from 'electron-notify';
|
||||
|
||||
eNotify.setConfig({
|
||||
appIcon: 'images/otherIcon.png',
|
||||
displayTime: 6000,
|
||||
defaultStyleText: {
|
||||
color: '#FF0000',
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
});
|
||||
|
||||
eNotify.notify({
|
||||
title: 'Title',
|
||||
text: 'Some text',
|
||||
image: 'path/to/image.png',
|
||||
url: 'http://google.de',
|
||||
sound: 'notification.wav',
|
||||
onClickFunc: (event) => {
|
||||
console.log('onClick ' + event.id);
|
||||
event.closeNotification('onClick');
|
||||
},
|
||||
onShowFunc: (event) => { console.log('onShow ' + event.id) },
|
||||
onCloseFunc: (event) => { console.log('onClose ' + event.id) }
|
||||
});
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
// Type definitions for electron-notify v0.1.0
|
||||
// Project: https://github.com/hankbao/electron-notify
|
||||
// Definitions by: Daniel Pereira <https://github.com/djpereira>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../github-electron/github-electron.d.ts" />
|
||||
|
||||
/** Nice and simple notifications for electron apps */
|
||||
declare module 'electron-notify' {
|
||||
|
||||
export interface ICustomConfig {
|
||||
width?: number,
|
||||
height?: number,
|
||||
padding?: number,
|
||||
borderRadius?: number,
|
||||
displayTime?: number,
|
||||
animationSteps?: number,
|
||||
animationStepMs?: number,
|
||||
animateInParallel?: boolean,
|
||||
appIcon?: string,
|
||||
pathToModule?: string,
|
||||
logging?: boolean,
|
||||
defaultWindow?: Electron.BrowserWindowOptions,
|
||||
defaultStyleContainer?: any,
|
||||
defaultStyleAppIcon?: any,
|
||||
defaultStyleImage?: any,
|
||||
defaultStyleClose?: any,
|
||||
defaultStyleText?: any
|
||||
}
|
||||
|
||||
export interface ICloseNotificationEvent {
|
||||
event: 'close' | 'show' | 'click',
|
||||
id: number
|
||||
}
|
||||
|
||||
export interface INotificationEvent extends ICloseNotificationEvent {
|
||||
closeNotification: (reason: any) => void,
|
||||
}
|
||||
|
||||
export interface INotification {
|
||||
title: string,
|
||||
text?: string,
|
||||
image?: string,
|
||||
url?: string,
|
||||
sound?: string,
|
||||
onClickFunc?: (event: INotificationEvent) => void,
|
||||
onShowFunc?: (event: INotificationEvent) => void,
|
||||
onCloseFunc?: (event: ICloseNotificationEvent) => void
|
||||
}
|
||||
|
||||
/** Change some config options. Can be run multiple times, also between notify()-calls to change electron-notifys behaviour. */
|
||||
export function setConfig(customConfig: ICustomConfig): void;
|
||||
|
||||
/** Displays new notification. */
|
||||
export function notify(notification: INotification): void;
|
||||
|
||||
/** Clears the animation queue and closes all windows opened by electron-notify. Call this to clean up before quiting your app. */
|
||||
export function closeAll(): void;
|
||||
|
||||
export function getTemplatePath(): string;
|
||||
|
||||
export function setTemplatePath(path: string): void;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/// <reference path="epub.d.ts" />
|
||||
import EPub = require("epub");
|
||||
|
||||
var epub = new EPub("./file.epub");
|
||||
epub.on("end", function(){
|
||||
epub.getChapter("chapter_id", function(err: Error, text: string) {});
|
||||
});
|
||||
|
||||
epub.parse();
|
||||
Vendored
+66
@@ -0,0 +1,66 @@
|
||||
// Type definitions for epub
|
||||
// Project: https://github.com/julien-c/epub
|
||||
// Definitions by: Julien Chaumond <https://github.com/julien-c>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
/**
|
||||
* new EPub(fname[, imageroot][, linkroot])
|
||||
* - fname (String): filename for the ebook
|
||||
* - imageroot (String): URL prefix for images
|
||||
* - linkroot (String): URL prefix for links
|
||||
*
|
||||
* Creates an Event Emitter type object for parsing epub files
|
||||
*
|
||||
* var epub = new EPub("book.epub");
|
||||
* epub.on("end", function () {
|
||||
* console.log(epub.spine);
|
||||
* });
|
||||
* epub.on("error", function (error) { ... });
|
||||
* epub.parse();
|
||||
*
|
||||
* Image and link URL format is:
|
||||
*
|
||||
* imageroot + img_id + img_zip_path
|
||||
*
|
||||
* So an image "logo.jpg" which resides in "OPT/" in the zip archive
|
||||
* and is listed in the manifest with id "logo_img" will have the
|
||||
* following url (providing that imageroot is "/images/"):
|
||||
*
|
||||
* /images/logo_img/OPT/logo.jpg
|
||||
**/
|
||||
declare module "epub" {
|
||||
|
||||
import {EventEmitter} from "events";
|
||||
|
||||
interface TocElement {
|
||||
level: number;
|
||||
order: number;
|
||||
title: string;
|
||||
id: string;
|
||||
href?: string;
|
||||
}
|
||||
|
||||
class EPub extends EventEmitter {
|
||||
constructor(epubfile: string, imagewebroot?: string, chapterwebroot?: string);
|
||||
|
||||
metadata: Object;
|
||||
manifest: Object;
|
||||
spine: Object;
|
||||
flow: Array<Object>;
|
||||
toc: Array<TocElement>;
|
||||
|
||||
parse(): void;
|
||||
|
||||
getChapter(chapterId: string, callback: (error: Error, text: string) => void): void;
|
||||
|
||||
getChapterRaw(chapterId: string, callback: (error: Error, text: string) => void): void;
|
||||
|
||||
getImage(id: string, callback: (error: Error, data: Buffer, mimeType: string) => void): void;
|
||||
|
||||
getFile(id: string, callback: (error: Error, data: Buffer, mimeType: string) => void): void;
|
||||
}
|
||||
|
||||
export = EPub;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="../estree/estree.d.ts" />
|
||||
/// <reference path="esprima-walk.d.ts" />
|
||||
|
||||
import * as walk from 'esprima-walk'
|
||||
|
||||
var program: ESTree.Program
|
||||
var string: string
|
||||
var node: ESTree.Node
|
||||
|
||||
walk(program, _node => {
|
||||
string = node.type
|
||||
node = _node
|
||||
})
|
||||
|
||||
walk.walk(program, _node => {
|
||||
string = node.type
|
||||
node = _node
|
||||
})
|
||||
|
||||
walk.walkAddParent(program, _node => {
|
||||
node = _node
|
||||
node = _node.parent
|
||||
string = node.type
|
||||
})
|
||||
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// Type definitions for esprima-walk v0.1.0
|
||||
// Project: https://github.com/jrajav/esprima-walk
|
||||
// Definitions by: tswaters <https://github.com/tswaters>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../estree/estree.d.ts" />
|
||||
|
||||
declare module "esprima-walk" {
|
||||
|
||||
interface NodeWithParent extends ESTree.Node {
|
||||
parent?: ESTree.Node
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk the provided AST; fn is called once for each node with a `type`
|
||||
* @param {ESTree.Program} ast program to walk
|
||||
* @param {function} fn function invoked for each node with type
|
||||
*/
|
||||
function walk (ast: ESTree.Program, fn:(node: ESTree.Node)=>void) :void
|
||||
|
||||
namespace walk {
|
||||
/**
|
||||
* Walk the provided AST; fn is called once for each node with a `type`
|
||||
* @param {ESTree.Program} ast program to walk
|
||||
* @param {function} fn function invoked for each node
|
||||
*/
|
||||
export function walk (ast: ESTree.Program, fn:(node: ESTree.Node)=>void) :void
|
||||
|
||||
/**
|
||||
* Walk the provided AST; fn is called once for each node with a `type`.
|
||||
* Adds a parent property prior to invoking fn when applicable
|
||||
* @param {ESTree.Program} ast program to walk
|
||||
* @param {function} fn function invoked for each node
|
||||
*/
|
||||
export function walkAddParent (ast: ESTree.Program, fn:(node: NodeWithParent)=>void) :void
|
||||
}
|
||||
|
||||
export = walk
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ var string: string;
|
||||
string = esprima.version;
|
||||
program = esprima.parse('code');
|
||||
program = esprima.parse('code', {range: true});
|
||||
program = esprima.parse('import * as code from "code"', {sourceType: 'module'})
|
||||
token = esprima.tokenize('code')[0];
|
||||
token = esprima.tokenize('code', {range: true})[0];
|
||||
|
||||
|
||||
Vendored
+1
@@ -30,6 +30,7 @@ declare namespace esprima {
|
||||
attachComment?: boolean;
|
||||
tolerant?: boolean;
|
||||
source?: boolean;
|
||||
sourceType?: 'script' | 'module';
|
||||
}
|
||||
|
||||
const Syntax: {
|
||||
|
||||
Vendored
+4
-4
@@ -43,7 +43,7 @@ declare class EventEmitter2 {
|
||||
* @param event
|
||||
* @param listener
|
||||
*/
|
||||
on(event: string, listener: Function): EventEmitter2;
|
||||
on(event: string | string[], listener: Function): EventEmitter2;
|
||||
|
||||
/**
|
||||
* Adds a listener that will be fired when any event is emitted.
|
||||
@@ -128,7 +128,7 @@ declare class EventEmitter2 {
|
||||
* @param event
|
||||
* @param args
|
||||
*/
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: string | string[], ...args: any[]): boolean;
|
||||
|
||||
/**
|
||||
* Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.
|
||||
@@ -156,7 +156,7 @@ declare module "eventemitter2" {
|
||||
* @param event
|
||||
* @param listener
|
||||
*/
|
||||
on(event: string, listener: Function): EventEmitter2;
|
||||
on(event: string | string[], listener: Function): EventEmitter2;
|
||||
|
||||
/**
|
||||
* Adds a listener that will be fired when any event is emitted.
|
||||
@@ -241,7 +241,7 @@ declare module "eventemitter2" {
|
||||
* @param event
|
||||
* @param args
|
||||
*/
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: string | string[], ...args: any[]): boolean;
|
||||
|
||||
/**
|
||||
* Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.
|
||||
|
||||
@@ -22,7 +22,7 @@ declare module "express-serve-static-core" {
|
||||
}
|
||||
|
||||
interface RequestHandler {
|
||||
(req: Request, res: Response, next: NextFunction): any;
|
||||
(req: Request, res: Response, next?: NextFunction): any;
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
@@ -117,11 +117,11 @@ declare module "express-serve-static-core" {
|
||||
interface CookieOptions {
|
||||
maxAge?: number;
|
||||
signed?: boolean;
|
||||
expires?: Date;
|
||||
expires?: Date | boolean;
|
||||
httpOnly?: boolean;
|
||||
path?: string;
|
||||
domain?: string;
|
||||
secure?: boolean;
|
||||
secure?: boolean | 'auto';
|
||||
}
|
||||
|
||||
interface Errback { (err: Error): void; }
|
||||
@@ -199,7 +199,7 @@ declare module "express-serve-static-core" {
|
||||
|
||||
/**
|
||||
* Returns the first accepted charset of the specified character sets,
|
||||
* based on the request’s Accept-Charset HTTP header field.
|
||||
* based on the request's Accept-Charset HTTP header field.
|
||||
* If none of the specified charsets is accepted, returns false.
|
||||
*
|
||||
* For more information, or if you have issues or concerns, see accepts.
|
||||
@@ -212,7 +212,7 @@ declare module "express-serve-static-core" {
|
||||
|
||||
/**
|
||||
* Returns the first accepted encoding of the specified encodings,
|
||||
* based on the request’s Accept-Encoding HTTP header field.
|
||||
* based on the request's Accept-Encoding HTTP header field.
|
||||
* If none of the specified encodings is accepted, returns false.
|
||||
*
|
||||
* For more information, or if you have issues or concerns, see accepts.
|
||||
@@ -225,7 +225,7 @@ declare module "express-serve-static-core" {
|
||||
|
||||
/**
|
||||
* Returns the first accepted language of the specified languages,
|
||||
* based on the request’s Accept-Language HTTP header field.
|
||||
* based on the request's Accept-Language HTTP header field.
|
||||
* If none of the specified languages is accepted, returns false.
|
||||
*
|
||||
* For more information, or if you have issues or concerns, see accepts.
|
||||
|
||||
@@ -6,7 +6,8 @@ import session = require('express-session');
|
||||
var app = express();
|
||||
|
||||
app.use(session({
|
||||
secret: 'keyboard cat'
|
||||
secret: 'keyboard cat',
|
||||
cookie: { secure: 'auto' }
|
||||
}));
|
||||
app.use(session({
|
||||
secret: 'keyboard cat',
|
||||
|
||||
Vendored
+1
-1
@@ -30,7 +30,7 @@ declare namespace Express {
|
||||
secure?: boolean;
|
||||
httpOnly: boolean;
|
||||
domain?: string;
|
||||
expires: Date;
|
||||
expires: Date | boolean;
|
||||
serialize: (name: string, value: string) => string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,19 +15,23 @@ app.post('/:urlparam', function(req: express.Request, res: express.Response) {
|
||||
// Similarly checkParams only checks in req.params (URL params) and
|
||||
// checkQuery only checks req.query (GET params).
|
||||
req.checkBody('postparam', 'Invalid postparam').notEmpty().isInt();
|
||||
req.checkParams('urlparam', 'Invalid urlparam').isAlpha();
|
||||
req.checkParams('urlparam', 'Invalid urlparam').isAlpha().matches(/test?/i).matches('test?', 'i');
|
||||
req.checkQuery('getparam', 'Invalid getparam').isInt();
|
||||
req.checkHeader('testHeader', 'Invalid testHeader').isLowercase().isUppercase();
|
||||
req.checkFiles('testFiles', 'Invalid testFiles').isUrl();
|
||||
|
||||
req.checkHeaders('testHeader', 'Invalid testHeader').isLowercase().isUppercase();
|
||||
req.checkFiles('testFiles', 'Invalid testFiles').isURL();
|
||||
|
||||
// OR assert can be used to check on all 3 types of params.
|
||||
// req.assert('postparam', 'Invalid postparam').notEmpty().isInt();
|
||||
// req.assert('urlparam', 'Invalid urlparam').isAlpha();
|
||||
// req.assert('getparam', 'Invalid getparam').isInt();
|
||||
|
||||
req.sanitize('postparam').toBoolean();
|
||||
req.filter('postparam').toBoolean();
|
||||
req.sanitize('postparam').blacklist('t').blacklist(['<script', '</script>']).whitelist('hello').whitelist(['h', 'e', 'l']);
|
||||
req.sanitizeBody('postvar').trim().stripLow().escape();
|
||||
req.sanitizeQuery('queryvar').toDate();
|
||||
req.sanitizeParams('urlparam').toFloat().toInt().toInt(10);
|
||||
req.sanitizeHeaders('header').normalizeEmail();
|
||||
|
||||
|
||||
var errors = req.validationErrors();
|
||||
var mappedErrors = req.validationErrors(true);
|
||||
|
||||
+88
-47
@@ -1,9 +1,10 @@
|
||||
// Type definitions for express-validator 2.9.0
|
||||
// Type definitions for express-validator 2.20.4
|
||||
// Project: https://github.com/ctavan/express-validator
|
||||
// Definitions by: Nathan Ridley <https://github.com/axefrog/>, Jonathan Häberle <http://dreampulse.de>
|
||||
// Definitions by: Nathan Ridley <https://github.com/axefrog/>, Jonathan Häberle <http://dreampulse.de>, Peter Harris <https://github.com/codeanimal/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
|
||||
// Add RequestValidation Interface on to Express's Request Interface.
|
||||
declare namespace Express {
|
||||
@@ -31,25 +32,33 @@ declare namespace ExpressValidator {
|
||||
param: string;
|
||||
}
|
||||
|
||||
interface ValidatorFunction { (item: string, message: string): Validator; }
|
||||
interface ValidatorFunction { (item: string | {}, message?: string): Validator; }
|
||||
interface ValidatorExtraFunction extends ValidatorFunction { (matchIndex: number, message?: string): Validator; }
|
||||
interface SanitizerFunction { (item: string): Sanitizer; }
|
||||
interface Dictionary<T> { [key: string]: T; }
|
||||
|
||||
export interface RequestValidation {
|
||||
assert: ValidatorFunction;
|
||||
check: ValidatorFunction;
|
||||
assert: ValidatorExtraFunction;
|
||||
validate: ValidatorExtraFunction;
|
||||
check: ValidatorExtraFunction;
|
||||
checkBody: ValidatorFunction;
|
||||
checkFiles: ValidatorFunction;
|
||||
checkHeader: ValidatorFunction;
|
||||
checkHeaders: ValidatorFunction;
|
||||
checkParams: ValidatorFunction;
|
||||
checkQuery: ValidatorFunction;
|
||||
validate: ValidatorFunction;
|
||||
|
||||
|
||||
filter: SanitizerFunction;
|
||||
sanitize: SanitizerFunction;
|
||||
|
||||
sanitizeBody: SanitizerFunction;
|
||||
sanitizeQuery: SanitizerFunction;
|
||||
sanitizeParams: SanitizerFunction;
|
||||
sanitizeHeaders: SanitizerFunction;
|
||||
|
||||
onValidationError(errback: (msg: string) => void): void;
|
||||
validationErrors(mapped?: boolean): Dictionary<any> | any[];
|
||||
validationErrors(mapped?: boolean): Dictionary<MappedError> | MappedError[];
|
||||
validationErrors<T>(mapped?: boolean): Dictionary<T> | T[];
|
||||
asyncValidationErrors(mapped?: boolean): Promise<MappedError[] | Dictionary<MappedError>>;
|
||||
asyncValidationErrors<T>(mapped?: boolean): Promise<T[] | Dictionary<T>>;
|
||||
}
|
||||
|
||||
export interface Validator {
|
||||
@@ -61,12 +70,13 @@ declare namespace ExpressValidator {
|
||||
* Alias for notRegex()
|
||||
*/
|
||||
not(): Validator;
|
||||
isEmail(): Validator;
|
||||
isEmail(options?:{}): Validator;
|
||||
/**
|
||||
* Accepts http, https, ftp
|
||||
*/
|
||||
isUrl(): Validator;
|
||||
|
||||
isURL(): Validator;
|
||||
isFQDN(options?: MinMaxOptions): Validator;
|
||||
|
||||
/**
|
||||
* Combines isIPv4 and isIPv6
|
||||
*/
|
||||
@@ -74,8 +84,21 @@ declare namespace ExpressValidator {
|
||||
isIPv4(): Validator;
|
||||
isIPv6(): Validator;
|
||||
isMACAddress(): Validator;
|
||||
isAlpha(): Validator;
|
||||
isAlphanumeric(): Validator;
|
||||
isISBN(version?: number): Validator;
|
||||
isISIN(): Validator;
|
||||
isISO8601(): Validator;
|
||||
isMobilePhone(locale: string): Validator;
|
||||
isMongoId(): Validator;
|
||||
isMultibyte(): Validator;
|
||||
isAlpha(locale?: string): Validator;
|
||||
isAlphanumeric(locale?: string): Validator;
|
||||
isAscii(): Validator;
|
||||
isBase64(): Validator;
|
||||
isBoolean(): Validator;
|
||||
isByteLength(options: MinMaxOptions): Validator;
|
||||
isCurrency(options: {}): Validator;
|
||||
isDataURI(): Validator;
|
||||
isDivisibleBy(num: number): Validator;
|
||||
isNumeric(): Validator;
|
||||
isHexadecimal(): Validator;
|
||||
/**
|
||||
@@ -85,7 +108,7 @@ declare namespace ExpressValidator {
|
||||
/**
|
||||
* isNumeric accepts zero padded numbers, e.g. '001', isInt doesn't
|
||||
*/
|
||||
isInt(): Validator;
|
||||
isInt(options?: MinMaxOptions): Validator;
|
||||
isLowercase(): Validator;
|
||||
isUppercase(): Validator;
|
||||
isDecimal(): Validator;
|
||||
@@ -93,10 +116,12 @@ declare namespace ExpressValidator {
|
||||
* Alias for isDecimal
|
||||
*/
|
||||
isFloat(): Validator;
|
||||
isFullWidth(): Validator;
|
||||
isHalfWidth(): Validator;
|
||||
isVariableWidth(): Validator;
|
||||
/**
|
||||
* Check if length is 0
|
||||
*/
|
||||
notNull(): Validator;
|
||||
isNull(): Validator;
|
||||
/**
|
||||
* Not just whitespace (input.trim().length !== 0)
|
||||
@@ -104,12 +129,13 @@ declare namespace ExpressValidator {
|
||||
notEmpty(): Validator;
|
||||
equals(equals:any): Validator;
|
||||
contains(str:string): Validator;
|
||||
notContains(str:string): Validator;
|
||||
|
||||
/**
|
||||
* Usage: regex(/[a-z]/i) or regex('[a-z]','i')
|
||||
* Usage: matches(/[a-z]/i) or matches('[a-z]','i')
|
||||
*/
|
||||
regex(pattern:string, modifiers:string): Validator;
|
||||
notRegex(pattern:string, modifiers:string): Validator;
|
||||
matches(pattern:string, modifiers?:string): Validator;
|
||||
matches(pattern: RegExp): Validator;
|
||||
|
||||
/**
|
||||
* max is optional
|
||||
*/
|
||||
@@ -117,7 +143,7 @@ declare namespace ExpressValidator {
|
||||
/**
|
||||
* Version can be 3, 4 or 5 or empty, see http://en.wikipedia.org/wiki/Universally_unique_identifier
|
||||
*/
|
||||
isUUID(version:number): Validator;
|
||||
isUUID(version?:number): Validator;
|
||||
/**
|
||||
* Alias for isUUID(3)
|
||||
*/
|
||||
@@ -137,17 +163,20 @@ declare namespace ExpressValidator {
|
||||
/**
|
||||
* Argument is optional and defaults to today. Comparison is non-inclusive
|
||||
*/
|
||||
isAfter(date:Date): Validator;
|
||||
isAfter(date?:Date): Validator;
|
||||
/**
|
||||
* Argument is optional and defaults to today. Comparison is non-inclusive
|
||||
*/
|
||||
isBefore(date:Date): Validator;
|
||||
isBefore(date?:Date): Validator;
|
||||
isIn(options:string): Validator;
|
||||
isIn(options:string[]): Validator;
|
||||
notIn(options:string): Validator;
|
||||
notIn(options:string[]): Validator;
|
||||
max(val:string): Validator;
|
||||
min(val:string): Validator;
|
||||
isJSON(): Validator;
|
||||
isLength(options: MinMaxOptions): Validator;
|
||||
isWhitelisted(chars: string): Validator;
|
||||
/**
|
||||
* Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats
|
||||
*/
|
||||
@@ -155,7 +184,10 @@ declare namespace ExpressValidator {
|
||||
/**
|
||||
* Check an input only when the input exists
|
||||
*/
|
||||
optional(): Validator;
|
||||
isSurrogatePar(): Validator;
|
||||
|
||||
optional(options?: { checkFalsy?: boolean }): Validator;
|
||||
withMessage(message: string): Validator;
|
||||
}
|
||||
|
||||
interface Sanitizer {
|
||||
@@ -165,40 +197,49 @@ declare namespace ExpressValidator {
|
||||
trim(...chars:string[]): Sanitizer;
|
||||
ltrim(...chars:string[]): Sanitizer;
|
||||
rtrim(...chars:string[]): Sanitizer;
|
||||
ifNull(replace:any): Sanitizer;
|
||||
stripLow(keep_new_lines?: boolean): Sanitizer;
|
||||
toFloat(): Sanitizer;
|
||||
toInt(): Sanitizer;
|
||||
toInt(radix?: number): Sanitizer;
|
||||
/**
|
||||
* True unless str = '0', 'false', or str.length == 0
|
||||
*/
|
||||
toBoolean(): Sanitizer;
|
||||
/**
|
||||
* False unless str = '1' or 'true'
|
||||
*/
|
||||
toBooleanStrict(): Sanitizer;
|
||||
/**
|
||||
* Decode HTML entities
|
||||
* True unless str = '0', 'false', or str.length == 0. In strict mode only '1' and 'true' return true.
|
||||
*/
|
||||
toBoolean(strict?: boolean): Sanitizer;
|
||||
|
||||
/**
|
||||
* Convert the input string to a date, or null if the input is not a date.
|
||||
*/
|
||||
toDate(): Sanitizer;
|
||||
|
||||
entityDecode(): Sanitizer;
|
||||
entityEncode(): Sanitizer;
|
||||
* Convert the input string to a date, or null if the input is not a date.
|
||||
*/
|
||||
toDate(): Sanitizer;
|
||||
|
||||
/**
|
||||
* Escape &, <, >, and "
|
||||
*/
|
||||
escape(): Sanitizer;
|
||||
|
||||
/**
|
||||
* Remove common XSS attack vectors from user-supplied HTML
|
||||
* Replaces HTML encoded entities with <, >, &, ', " and /.
|
||||
*/
|
||||
xss(): Sanitizer;
|
||||
unescape(): Sanitizer;
|
||||
|
||||
blacklist(chars: string): Sanitizer;
|
||||
blacklist(chars: string[]): Sanitizer;
|
||||
whitelist(chars: string): Sanitizer;
|
||||
whitelist(chars: string[]): Sanitizer;
|
||||
|
||||
normalizeEmail(options?: { lowercase?: boolean; remove_dots?: boolean; remove_extensions?: boolean }): Sanitizer;
|
||||
|
||||
/**
|
||||
* Remove common XSS attack vectors from images
|
||||
* !!! XSS sanitization was removed from the library (see: https://github.com/chriso/validator.js#xss-sanitization)
|
||||
*/
|
||||
xss(fromImages:boolean): Sanitizer;
|
||||
}
|
||||
|
||||
|
||||
interface MappedError {
|
||||
param: string;
|
||||
msg: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface MinMaxOptions {
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/// <reference path="express.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import * as express from 'express';
|
||||
var app = express();
|
||||
@@ -91,3 +92,10 @@ app.listen(3000);
|
||||
|
||||
const next: express.NextFunction = () => {};
|
||||
const nextWithArgument: express.NextFunction = (err: any) => {};
|
||||
|
||||
/**
|
||||
* The express.Application is compatible with http.createServer
|
||||
*/
|
||||
|
||||
import * as http from 'http';
|
||||
http.createServer(app);
|
||||
|
||||
@@ -30,3 +30,15 @@ fetchMock.called("http://test.com");
|
||||
(fetchMock.lastCall()[1] as RequestInit).body;
|
||||
fetchMock.lastUrl();
|
||||
fetchMock.lastOptions();
|
||||
|
||||
fetchMock.get("http://test.com", 200)
|
||||
fetchMock.post("http://test.com", 200)
|
||||
fetchMock.put("http://test.com", 200)
|
||||
fetchMock.delete("http://test.com", 200)
|
||||
fetchMock.head("http://test.com", 200)
|
||||
|
||||
fetchMock.get("http://test.com", 200, {method: "GET"})
|
||||
fetchMock.post("http://test.com", 200, {method: "POST"})
|
||||
fetchMock.put("http://test.com", 200, {method: "PUT"})
|
||||
fetchMock.delete("http://test.com", 200, {method: "DELETE"})
|
||||
fetchMock.head("http://test.com", 200, {method: "HEAD"})
|
||||
|
||||
Vendored
+70
@@ -114,6 +114,26 @@ declare module "fetch-mock" {
|
||||
unmatched: Array<MockCall>;
|
||||
}
|
||||
|
||||
interface MockOptionsMethodGet extends MockOptions {
|
||||
method: 'GET'
|
||||
}
|
||||
|
||||
interface MockOptionsMethodPost extends MockOptions {
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
interface MockOptionsMethodPut extends MockOptions {
|
||||
method: 'PUT'
|
||||
}
|
||||
|
||||
interface MockOptionsMethodDelete extends MockOptions {
|
||||
method: 'DELETE'
|
||||
}
|
||||
|
||||
interface MockOptionsMethodHead extends MockOptions {
|
||||
method: 'HEAD'
|
||||
}
|
||||
|
||||
interface FetchMockStatic {
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
@@ -139,6 +159,56 @@ declare module "fetch-mock" {
|
||||
* @param options The route to mock
|
||||
*/
|
||||
mock(options: MockOptions): this;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Shorthand for mock() restricted to the GET
|
||||
method. Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param response Configures the http response returned by the mock
|
||||
* @param [options] Additional properties defining the route to mock
|
||||
*/
|
||||
get(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodGet): this;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Shorthand for mock() restricted to the POST
|
||||
method. Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param response Configures the http response returned by the mock
|
||||
* @param [options] Additional properties defining the route to mock
|
||||
*/
|
||||
post(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodPost): this;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Shorthand for mock() restricted to the PUT
|
||||
method. Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param response Configures the http response returned by the mock
|
||||
* @param [options] Additional properties defining the route to mock
|
||||
*/
|
||||
put(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodPut): this;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Shorthand for mock() restricted to the
|
||||
DELETE method. Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param response Configures the http response returned by the mock
|
||||
* @param [options] Additional properties defining the route to mock
|
||||
*/
|
||||
delete(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodDelete): this;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Shorthand for mock() restricted to the HEAD
|
||||
method. Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param response Configures the http response returned by the mock
|
||||
* @param [options] Additional properties defining the route to mock
|
||||
*/
|
||||
head(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodHead): this;
|
||||
/**
|
||||
* Chainable method that restores fetch() to its unstubbed state and
|
||||
clears all data recorded for its calls.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference path="file-type.d.ts" />
|
||||
|
||||
"use strict";
|
||||
|
||||
import fileType = require("file-type")
|
||||
|
||||
fileType(new Buffer([0xFF, 0xD8, 0xFF]))
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// Type definitions for file-type
|
||||
// Project: https://github.com/sindresorhus/file-type
|
||||
// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk <http://github.com/tcaesvk/>
|
||||
// Definitions: https://github.com/DefinitelyType/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "file-type" {
|
||||
interface FileTypeResult {
|
||||
ext: string
|
||||
mime: string
|
||||
}
|
||||
|
||||
function FileType(buf: Buffer): FileTypeResult
|
||||
|
||||
export = FileType
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fill-pdf.d.ts' />
|
||||
|
||||
import * as fillPdf from 'fill-pdf';
|
||||
|
||||
var formData: fillPdf.FormData = { FieldName: 'Text to put into form field' };
|
||||
var pdfTemplatePath = 'templates.pdf';
|
||||
var extendArgs: string[] = [];
|
||||
|
||||
fillPdf.generatePdf(formData, pdfTemplatePath, extendArgs, (err: Error, output: Buffer) => {
|
||||
if ( !err ) {
|
||||
console.log('Success!');
|
||||
// output is a buffer
|
||||
}
|
||||
});
|
||||
|
||||
var result = fillPdf.generateFdf(formData);
|
||||
// result is a buffer
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for fill-pdf v0.5.0
|
||||
// Project: https://github.com/dommmel/fill-pdf
|
||||
// Definitions by: Seth Westphal <https://github.com/westy92>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'fill-pdf' {
|
||||
|
||||
export interface FormData {
|
||||
[name: string]: string;
|
||||
}
|
||||
|
||||
export function generatePdf(data: FormData, templatePath: string, extendArgs: string[], callback?: (err: Error, output: Buffer) => void): void;
|
||||
export function generateFdf(data: FormData): Buffer;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference path="./fluent-ffmpeg.d.ts" />
|
||||
|
||||
import ffmpeg = require("fluent-ffmpeg")
|
||||
|
||||
let source: string, format: string, output: string
|
||||
|
||||
ffmpeg({ source: source }).format(format).save(output)
|
||||
Vendored
+315
@@ -0,0 +1,315 @@
|
||||
// Type definitions for node-fluent-ffmpeg
|
||||
// Project: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg
|
||||
// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk <http://github.com/tcaesvk/>
|
||||
// Definitions: https://github.com/DefinitelyType/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "fluent-ffmpeg" {
|
||||
import * as events from "events"
|
||||
import * as stream from "stream"
|
||||
|
||||
interface FfmpegCommandLogger {
|
||||
error(...data: any[]): void
|
||||
warning(...data: any[]): void
|
||||
info(...data: any[]): void
|
||||
debug(...data: any[]): void
|
||||
}
|
||||
|
||||
interface FfmpegCommandOptions {
|
||||
logger?: FfmpegCommandLogger
|
||||
niceness?: number
|
||||
priority?: number
|
||||
presets?: string
|
||||
preset?: string
|
||||
stdoutLines?: number
|
||||
timeout?: number
|
||||
source?: string | stream.Readable
|
||||
}
|
||||
|
||||
interface FilterSpecification {
|
||||
filter: string
|
||||
inputs: string | string[]
|
||||
outputs: string | string[]
|
||||
options?: Object | string | any[]
|
||||
}
|
||||
|
||||
interface GetPreset {
|
||||
(command: FfmpegCommand): string
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
description: string
|
||||
input: string
|
||||
multipleInputs: boolean
|
||||
output: string
|
||||
multipleOutputs: boolean
|
||||
}
|
||||
interface Filters {
|
||||
[key: string]: Filter
|
||||
}
|
||||
interface FiltersCallback {
|
||||
(err: Error, filters: Filters): void
|
||||
}
|
||||
|
||||
interface Codec {
|
||||
type: string
|
||||
description: string
|
||||
canDecode: boolean
|
||||
canEncode: boolean
|
||||
drawHorizBand?: boolean
|
||||
directRendering?: boolean
|
||||
weirdFrameTruncation?: boolean
|
||||
intraFrameOnly?: boolean
|
||||
isLossy?: boolean
|
||||
isLossless?: boolean
|
||||
}
|
||||
interface Codecs {
|
||||
[key: string]: Codec
|
||||
}
|
||||
interface CodecsCallback {
|
||||
(err: Error, codecs: Codecs): void
|
||||
}
|
||||
|
||||
interface Encoder {
|
||||
type: string
|
||||
description: string
|
||||
frameMT: boolean
|
||||
sliceMT: boolean
|
||||
experimental: boolean
|
||||
drawHorizBand: boolean
|
||||
directRendering: boolean
|
||||
}
|
||||
interface Encoders {
|
||||
[key: string]: Encoder
|
||||
}
|
||||
interface EncodersCallback {
|
||||
(err: Error, encoders: Encoders): void
|
||||
}
|
||||
|
||||
interface Format {
|
||||
description: string
|
||||
canDemux: boolean
|
||||
canMux: boolean
|
||||
}
|
||||
interface Formats {
|
||||
[key: string]: Format
|
||||
}
|
||||
interface FormatsCallback {
|
||||
(err: Error, formats: Formats): void
|
||||
}
|
||||
|
||||
interface FfprobeData {
|
||||
stream: any[]
|
||||
format: any
|
||||
chapters: any[]
|
||||
}
|
||||
|
||||
interface ScreenshotsConfig {
|
||||
count?: number
|
||||
folder?: string
|
||||
filename?: string
|
||||
timemarks?: number[] | string[]
|
||||
timestamps?: number[] | string[]
|
||||
fastSeek?: boolean
|
||||
size?: string
|
||||
}
|
||||
|
||||
interface FfmpegCommand extends events.EventEmitter {
|
||||
constructor(): FfmpegCommand
|
||||
constructor(options: FfmpegCommandOptions): FfmpegCommand
|
||||
constructor(input: string | stream.Readable, options: FfmpegCommandOptions): FfmpegCommand
|
||||
|
||||
// options/inputs
|
||||
mergeAdd(source: string | stream.Readable): FfmpegCommand
|
||||
addInput(source: string | stream.Readable): FfmpegCommand
|
||||
input(source: string | stream.Readable): FfmpegCommand
|
||||
withInputFormat(format: string): FfmpegCommand
|
||||
inputFormat(format: string): FfmpegCommand
|
||||
fromFormat(format: string): FfmpegCommand
|
||||
withInputFps(fps: number): FfmpegCommand
|
||||
withInputFPS(fps: number): FfmpegCommand
|
||||
withFpsInput(fps: number): FfmpegCommand
|
||||
withFPSInput(fps: number): FfmpegCommand
|
||||
inputFPS(fps: number): FfmpegCommand
|
||||
inputFps(fps: number): FfmpegCommand
|
||||
fpsInput(fps: number): FfmpegCommand
|
||||
FPSInput(fps: number): FfmpegCommand
|
||||
nativeFramerate(): FfmpegCommand
|
||||
withNativeFramerate(): FfmpegCommand
|
||||
native(): FfmpegCommand
|
||||
setStartTime(seek: string | number): FfmpegCommand
|
||||
seekInput(seek: string | number): FfmpegCommand
|
||||
loop(duration: string | number): FfmpegCommand
|
||||
|
||||
// options/audio
|
||||
withNoAudio(): FfmpegCommand
|
||||
noAudio(): FfmpegCommand
|
||||
withAudioCodec(codec: string): FfmpegCommand
|
||||
audioCodec(codec: string): FfmpegCommand
|
||||
withAudioBitrate(bitrate: string | number): FfmpegCommand
|
||||
audioBitrate(bitrate: string | number): FfmpegCommand
|
||||
withAudioChannels(channels: number): FfmpegCommand
|
||||
audioChannels(channels: number): FfmpegCommand
|
||||
withAudioFrequency(freq: number): FfmpegCommand
|
||||
audioFrequency(freq: number): FfmpegCommand
|
||||
withAudioQuality(quality: number): FfmpegCommand
|
||||
audioQuality(quality: number): FfmpegCommand
|
||||
withAudioFilter(filters: { filter: string, options: any }): FfmpegCommand
|
||||
withAudioFilters(filters: { filter: string, options: any }): FfmpegCommand
|
||||
audioFilter(filters: { filter: string, options: any }): FfmpegCommand
|
||||
audioFilters(filters: { filter: string, options: any }): FfmpegCommand
|
||||
|
||||
// options/video
|
||||
withNoVideo(): FfmpegCommand
|
||||
noVideo(): FfmpegCommand
|
||||
withVideoCodec(codec: string): FfmpegCommand
|
||||
videoCodec(codec: string): FfmpegCommand
|
||||
withVideoBitrate(bitrate: string | number): FfmpegCommand
|
||||
videoBitrate(bitrate: string | number): FfmpegCommand
|
||||
withVideoFilter(filters: { filter: string, options: any }): FfmpegCommand
|
||||
withVideoFilters(filters: { filter: string, options: any }): FfmpegCommand
|
||||
videoFilter(filters: { filter: string, options: any }): FfmpegCommand
|
||||
videoFilters(filters: { filter: string, options: any }): FfmpegCommand
|
||||
withOutputFps(fps: number): FfmpegCommand
|
||||
withOutputFPS(fps: number): FfmpegCommand
|
||||
withFpsOutput(fps: number): FfmpegCommand
|
||||
withFPSOutput(fps: number): FfmpegCommand
|
||||
withFps(fps: number): FfmpegCommand
|
||||
withFPS(fps: number): FfmpegCommand
|
||||
outputFPS(fps: number): FfmpegCommand
|
||||
outputFps(fps: number): FfmpegCommand
|
||||
fpsOutput(fps: number): FfmpegCommand
|
||||
FPSOutput(fps: number): FfmpegCommand
|
||||
fps(fps: number): FfmpegCommand
|
||||
FPS(fps: number): FfmpegCommand
|
||||
takeFrames(frames: number): FfmpegCommand
|
||||
withFrames(frames: number): FfmpegCommand
|
||||
frames(frames: number): FfmpegCommand
|
||||
|
||||
// options/videosize
|
||||
keepPixelAspect(): FfmpegCommand
|
||||
keepDisplayAspect(): FfmpegCommand
|
||||
keepDisplayAspectRatio(): FfmpegCommand
|
||||
keepDAR(): FfmpegCommand
|
||||
withSize(size: string): FfmpegCommand
|
||||
setSize(size: string): FfmpegCommand
|
||||
size(size: string): FfmpegCommand
|
||||
withAspect(aspect: string | number): FfmpegCommand
|
||||
withAspectRatio(aspect: string | number): FfmpegCommand
|
||||
setAspect(aspect: string | number): FfmpegCommand
|
||||
setAspectRatio(aspect: string | number): FfmpegCommand
|
||||
aspect(aspect: string | number): FfmpegCommand
|
||||
aspectRatio(aspect: string | number): FfmpegCommand
|
||||
applyAutopadding(pad: boolean, color: string): FfmpegCommand
|
||||
applyAutoPadding(pad: boolean, color: string): FfmpegCommand
|
||||
applyAutopad(pad: boolean, color: string): FfmpegCommand
|
||||
applyAutoPad(pad: boolean, color: string): FfmpegCommand
|
||||
withAutopadding(pad: boolean, color: string): FfmpegCommand
|
||||
withAutoPadding(pad: boolean, color: string): FfmpegCommand
|
||||
withAutopad(pad: boolean, color: string): FfmpegCommand
|
||||
withAutoPad(pad: boolean, color: string): FfmpegCommand
|
||||
autoPad(pad: boolean, color: string): FfmpegCommand
|
||||
autopad(pad: boolean, color: string): FfmpegCommand
|
||||
|
||||
// options/output
|
||||
addOutput(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand
|
||||
output(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand
|
||||
seekOutput(seek: string | number): FfmpegCommand
|
||||
seek(seek: string | number): FfmpegCommand
|
||||
withDuration(duration: string | number): FfmpegCommand
|
||||
setDuration(duration: string | number): FfmpegCommand
|
||||
duration(duration: string | number): FfmpegCommand
|
||||
toFormat(format: string): FfmpegCommand
|
||||
withOutputFormat(format: string): FfmpegCommand
|
||||
outputFormat(format: string): FfmpegCommand
|
||||
format(format: string): FfmpegCommand
|
||||
map(spec: string): FfmpegCommand
|
||||
updateFlvMetadata(): FfmpegCommand
|
||||
flvmeta(): FfmpegCommand
|
||||
|
||||
// options/custom
|
||||
addInputOption(options: string[]): FfmpegCommand
|
||||
addInputOption(...options: string[]): FfmpegCommand
|
||||
addInputOptions(options: string[]): FfmpegCommand
|
||||
addInputOptions(...options: string[]): FfmpegCommand
|
||||
withInputOption(options: string[]): FfmpegCommand
|
||||
withInputOption(...options: string[]): FfmpegCommand
|
||||
withInputOptions(options: string[]): FfmpegCommand
|
||||
withInputOptions(...options: string[]): FfmpegCommand
|
||||
inputOption(options: string[]): FfmpegCommand
|
||||
inputOption(...options: string[]): FfmpegCommand
|
||||
inputOptions(options: string[]): FfmpegCommand
|
||||
inputOptions(...options: string[]): FfmpegCommand
|
||||
addOutputOption(options: string[]): FfmpegCommand
|
||||
addOutputOption(...options: string[]): FfmpegCommand
|
||||
addOutputOptions(options: string[]): FfmpegCommand
|
||||
addOutputOptions(...options: string[]): FfmpegCommand
|
||||
addOption(options: string[]): FfmpegCommand
|
||||
addOption(...options: string[]): FfmpegCommand
|
||||
addOptions(options: string[]): FfmpegCommand
|
||||
addOptions(...options: string[]): FfmpegCommand
|
||||
withOutputOption(options: string[]): FfmpegCommand
|
||||
withOutputOption(...options: string[]): FfmpegCommand
|
||||
withOutputOptions(options: string[]): FfmpegCommand
|
||||
withOutputOptions(...options: string[]): FfmpegCommand
|
||||
withOption(options: string[]): FfmpegCommand
|
||||
withOption(...options: string[]): FfmpegCommand
|
||||
withOptions(options: string[]): FfmpegCommand
|
||||
withOptions(...options: string[]): FfmpegCommand
|
||||
outputOption(options: string[]): FfmpegCommand
|
||||
outputOption(...options: string[]): FfmpegCommand
|
||||
outputOptions(options: string[]): FfmpegCommand
|
||||
outputOptions(...options: string[]): FfmpegCommand
|
||||
filterGraph(spec: string | FilterSpecification[], map: string[]): FfmpegCommand
|
||||
complexFilter(spec: string | FilterSpecification[], map: string[]): FfmpegCommand
|
||||
|
||||
// options/misc
|
||||
usingPreset(proset: string | GetPreset): FfmpegCommand
|
||||
pnreset(proset: string | GetPreset): FfmpegCommand
|
||||
|
||||
// processor
|
||||
renice(niceness: number): FfmpegCommand
|
||||
kill(signal: string): FfmpegCommand
|
||||
|
||||
// capabilities
|
||||
setFfmpegPath(path: string): FfmpegCommand
|
||||
setFfprobePath(path: string): FfmpegCommand
|
||||
setFlvtoolPath(path: string): FfmpegCommand
|
||||
availableFilters(callback: FiltersCallback): void
|
||||
getAvailableFilters(callback: FiltersCallback): void
|
||||
availableCodecs(callback: CodecsCallback): void
|
||||
getAvailableCodecs(callback: CodecsCallback): void
|
||||
availableEncoders(callback: EncodersCallback): void
|
||||
getAvailableEncoders(callback: EncodersCallback): void
|
||||
availableFormats(callback: FormatsCallback): void
|
||||
getAvailableFormats(callback: FormatsCallback): void
|
||||
|
||||
// ffprobe
|
||||
ffprobe(callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void
|
||||
ffprobe(index: number, callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void
|
||||
ffprobe(options: string[], callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void
|
||||
ffprobe(index: number, options: string[], callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void
|
||||
|
||||
// recipes
|
||||
saveToFile(output: string): FfmpegCommand
|
||||
save(output: string): FfmpegCommand
|
||||
writeToStream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable
|
||||
pipe(stream: stream.Writable, options?: { end?: boolean }): stream.Writable
|
||||
stream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable
|
||||
takeScreenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand
|
||||
thumbnail(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand
|
||||
thumbnails(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand
|
||||
screenshot(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand
|
||||
screenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand
|
||||
mergeToFile(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand
|
||||
concatenate(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand
|
||||
concat(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand
|
||||
}
|
||||
|
||||
function Ffmpeg(): FfmpegCommand
|
||||
function Ffmpeg(options: FfmpegCommandOptions): FfmpegCommand
|
||||
function Ffmpeg(input: string | stream.Readable, options: FfmpegCommandOptions): FfmpegCommand
|
||||
|
||||
export = Ffmpeg
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/fs-extra.d.ts via TSD fs-extra definition
|
||||
|
||||
///<reference path="../node/node.d.ts"/>
|
||||
///<reference path="../bluebird/bluebird.d.ts"/>
|
||||
///<reference path="../bluebird/bluebird-2.0.d.ts"/>
|
||||
|
||||
declare module "fs-extra-promise" {
|
||||
import stream = require("stream");
|
||||
|
||||
Vendored
+2
-2
@@ -318,7 +318,7 @@ interface JQuery {
|
||||
/**
|
||||
* Moves the calendar to an arbitrary date.
|
||||
*/
|
||||
fullCalendar(method: 'gotoDate', date: Date | string): void;
|
||||
fullCalendar(method: 'gotoDate', date: moment.Moment | Date | string): void;
|
||||
|
||||
/**
|
||||
* Moves the calendar forward/backward an arbitrary amount of time.
|
||||
@@ -403,4 +403,4 @@ interface JQuery {
|
||||
|
||||
interface JQueryStatic {
|
||||
fullCalendar: FullCalendar.Calendar;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="electron-prebuilt.d.ts" />
|
||||
/// <reference path="electron.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import electron = require('electron-prebuilt');
|
||||
import electron = require('electron');
|
||||
import child_process = require('child_process');
|
||||
|
||||
child_process.spawn(electron);
|
||||
@@ -1,9 +1,9 @@
|
||||
// Type definitions for electron-prebuilt 0.30.1
|
||||
// Project: https://github.com/mafintosh/electron-prebuilt
|
||||
// Type definitions for electron 1.3.3
|
||||
// Project: https://github.com/electron-userland/electron-prebuilt
|
||||
// Definitions by: rhysd <https://github.com/rhysd>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'electron-prebuilt' {
|
||||
declare module 'electron' {
|
||||
var electron: string;
|
||||
export = electron;
|
||||
}
|
||||
Vendored
+44
-12
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Electron v1.3.3
|
||||
// Type definitions for Electron v1.3.4
|
||||
// Project: http://electron.atom.io/
|
||||
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
declare namespace Electron {
|
||||
|
||||
class EventEmitter implements NodeJS.EventEmitter {
|
||||
class EventEmitter extends NodeJS.EventEmitter {
|
||||
addListener(event: string, listener: Function): this;
|
||||
on(event: string, listener: Function): this;
|
||||
once(event: string, listener: Function): this;
|
||||
@@ -296,22 +296,37 @@ declare namespace Electron {
|
||||
* Once registered, all links with your-protocol:// will be opened with the current executable.
|
||||
* The whole link, including protocol, will be passed to your application as a parameter.
|
||||
*
|
||||
* On Windows you can provide optional parameters path, the path to your executable,
|
||||
* and args, an array of arguments to be passed to your executable when it launches.
|
||||
*
|
||||
* @param protocol The name of your protocol, without ://.
|
||||
* @param path Defaults to process.execPath.
|
||||
* @param args Defaults to an empty array.
|
||||
*
|
||||
* Note: This is only implemented on macOS and Windows.
|
||||
* On macOS, you can only register protocols that have been added to your app's info.plist.
|
||||
*/
|
||||
setAsDefaultProtocolClient(protocol: string): boolean;
|
||||
setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
|
||||
/**
|
||||
* Removes the current executable as the default handler for a protocol (aka URI scheme).
|
||||
*
|
||||
* @param protocol The name of your protocol, without ://.
|
||||
* @param path Defaults to process.execPath.
|
||||
* @param args Defaults to an empty array.
|
||||
*
|
||||
* Note: This is only implemented on macOS and Windows.
|
||||
*/
|
||||
removeAsDefaultProtocolClient(protocol: string): boolean;
|
||||
removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
|
||||
/**
|
||||
* @param protocol The name of your protocol, without ://.
|
||||
* @param path Defaults to process.execPath.
|
||||
* @param args Defaults to an empty array.
|
||||
*
|
||||
* @returns Whether the current executable is the default handler for a protocol (aka URI scheme).
|
||||
*
|
||||
* Note: This is only implemented on macOS and Windows.
|
||||
*/
|
||||
isDefaultProtocolClient(protocol: string): boolean;
|
||||
isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
|
||||
/**
|
||||
* Adds tasks to the Tasks category of JumpList on Windows.
|
||||
*
|
||||
@@ -630,7 +645,7 @@ declare namespace Electron {
|
||||
* Emitted when the document changed its title,
|
||||
* calling event.preventDefault() would prevent the native window’s title to change.
|
||||
*/
|
||||
on(event: 'page-title-updated', listener: (event: Event) => void): this;
|
||||
on(event: 'page-title-updated', listener: (event: Event, title: string) => void): this;
|
||||
/**
|
||||
* Emitted when the window is going to be closed. It’s emitted before the beforeunload
|
||||
* and unload event of the DOM. Calling event.preventDefault() will cancel the close.
|
||||
@@ -2947,18 +2962,22 @@ declare namespace Electron {
|
||||
interface NetworkEmulationOptions {
|
||||
/**
|
||||
* Whether to emulate network outage.
|
||||
* Default: false.
|
||||
*/
|
||||
offline?: boolean;
|
||||
/**
|
||||
* RTT in ms.
|
||||
* Default: 0, which will disable latency throttling.
|
||||
*/
|
||||
latency?: number;
|
||||
/**
|
||||
* Download rate in Bps.
|
||||
* Default: 0, which will disable download throttling.
|
||||
*/
|
||||
downloadThroughput?: number;
|
||||
/**
|
||||
* Upload rate in Bps.
|
||||
* Default: 0, which will disable upload throttling.
|
||||
*/
|
||||
uploadThroughput?: number;
|
||||
}
|
||||
@@ -3687,7 +3706,7 @@ declare namespace Electron {
|
||||
* navigation outside of the page. Examples of this occurring are when anchor links
|
||||
* are clicked or when the DOM hashchange event is triggered.
|
||||
*/
|
||||
on(event: 'did-navigate-in-page', listener: (event: Event, url: string) => void): this;
|
||||
on(event: 'did-navigate-in-page', listener: (event: Event, url: string, isMainFrame: boolean) => void): this;
|
||||
/**
|
||||
* Emitted when the renderer process has crashed.
|
||||
*/
|
||||
@@ -4382,7 +4401,7 @@ declare namespace Electron {
|
||||
/**
|
||||
* PEM encoded data.
|
||||
*/
|
||||
data: Buffer;
|
||||
data: string;
|
||||
/**
|
||||
* Issuer's Common Name.
|
||||
*/
|
||||
@@ -4766,6 +4785,10 @@ declare namespace Electron {
|
||||
* @returns Whether the web page is destroyed.
|
||||
*/
|
||||
isDestroyed(): boolean;
|
||||
/**
|
||||
* @returns Whether the web page is focused.
|
||||
*/
|
||||
isFocused(): boolean;
|
||||
/**
|
||||
* @returns Whether guest page is still loading resources.
|
||||
*/
|
||||
@@ -5043,14 +5066,14 @@ declare namespace Electron {
|
||||
*
|
||||
* Calling event.preventDefault() does NOT have any effect.
|
||||
*/
|
||||
addEventListener(type: 'will-navigate', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void;
|
||||
addEventListener(type: 'will-navigate', listener: (event: WebViewElement.WillNavigateEvent) => void, useCapture?: boolean): void;
|
||||
/**
|
||||
* Emitted when a navigation is done.
|
||||
*
|
||||
* This event is not emitted for in-page navigations, such as clicking anchor links
|
||||
* or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
|
||||
*/
|
||||
addEventListener(type: 'did-navigate', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void;
|
||||
addEventListener(type: 'did-navigate', listener: (event: WebViewElement.DidNavigateEvent) => void, useCapture?: boolean): void;
|
||||
/**
|
||||
* Emitted when an in-page navigation happened.
|
||||
*
|
||||
@@ -5058,7 +5081,7 @@ declare namespace Electron {
|
||||
* navigation outside of the page. Examples of this occurring are when anchor links
|
||||
* are clicked or when the DOM hashchange event is triggered.
|
||||
*/
|
||||
addEventListener(type: 'did-navigate-in-page', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void;
|
||||
addEventListener(type: 'did-navigate-in-page', listener: (event: WebViewElement.DidNavigateInPageEvent) => void, useCapture?: boolean): void;
|
||||
/**
|
||||
* Fired when the guest page attempts to close itself.
|
||||
*/
|
||||
@@ -5182,10 +5205,19 @@ declare namespace Electron {
|
||||
options: BrowserWindowOptions;
|
||||
}
|
||||
|
||||
interface NavigateEvent extends Event {
|
||||
interface WillNavigateEvent extends Event {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface DidNavigateEvent extends Event {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface DidNavigateInPageEvent extends Event {
|
||||
url: string;
|
||||
isMainFrame: boolean;
|
||||
}
|
||||
|
||||
interface IpcMessageEvent extends Event {
|
||||
channel: string;
|
||||
args: any[];
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/// <reference path="google-earth.d.ts" />
|
||||
|
||||
google.load("earth", "1", {"other_params":"sensor=true_or_false"});
|
||||
|
||||
google.earth.createInstance("map3d", initCB, failureCB);
|
||||
|
||||
function failureCB(error: any) {}
|
||||
|
||||
function initCB(ge: google.earth.GEPlugin) {
|
||||
|
||||
ge.getWindow().setVisibility(true);
|
||||
|
||||
|
||||
// Create the placemark.
|
||||
var placemark = ge.createPlacemark('');
|
||||
placemark.setName("placemark");
|
||||
|
||||
// Set the placemark's location.
|
||||
var point = ge.createPoint('');
|
||||
point.setLatitude(12.345);
|
||||
point.setLongitude(54.321);
|
||||
placemark.setGeometry(point);
|
||||
|
||||
// Create a style map.
|
||||
var styleMap = ge.createStyleMap('');
|
||||
|
||||
// Create normal style for style map.
|
||||
var normalStyle = ge.createStyle('');
|
||||
var normalIcon = ge.createIcon('');
|
||||
normalIcon.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
|
||||
normalStyle.getIconStyle().setIcon(normalIcon);
|
||||
|
||||
// Create highlight style for style map.
|
||||
var highlightStyle = ge.createStyle('');
|
||||
var highlightIcon = ge.createIcon('');
|
||||
highlightIcon.setHref('http://google-maps-icons.googlecode.com/files/girlfriend.png');
|
||||
highlightStyle.getIconStyle().setIcon(highlightIcon);
|
||||
highlightStyle.getIconStyle().setScale(5.0);
|
||||
|
||||
styleMap.setNormalStyle(normalStyle);
|
||||
styleMap.setHighlightStyle(highlightStyle);
|
||||
|
||||
// Apply stylemap to a placemark.
|
||||
placemark.setStyleSelector(styleMap);
|
||||
|
||||
//Add the placemark to Earth.
|
||||
ge.getFeatures().appendChild(placemark);
|
||||
|
||||
|
||||
// balloons
|
||||
var balloon = ge.createHtmlDivBalloon('');
|
||||
balloon.setFeature(placemark);
|
||||
var div = document.createElement('DIV');
|
||||
div.innerHTML = 'Any <em>HTML</em>, CSS, or JavaScript goes here.';
|
||||
balloon.setContentDiv(div);
|
||||
ge.setBalloon(balloon);
|
||||
|
||||
// Create the ScreenOverlay
|
||||
var screenOverlay = ge.createScreenOverlay('');
|
||||
|
||||
// Specify a path to the image and set as the icon
|
||||
var icon = ge.createIcon('');
|
||||
icon.setHref('http://www.google.com/intl/en_ALL/images/logo.gif');
|
||||
screenOverlay.setIcon(icon);
|
||||
|
||||
// Set the ScreenOverlay's position in the window
|
||||
screenOverlay.getOverlayXY().setXUnits(ge.UNITS_PIXELS);
|
||||
screenOverlay.getOverlayXY().setYUnits(ge.UNITS_PIXELS);
|
||||
screenOverlay.getOverlayXY().setX(200);
|
||||
screenOverlay.getOverlayXY().setY(200);
|
||||
|
||||
// Set the overlay's size in pixels
|
||||
screenOverlay.getSize().setXUnits(ge.UNITS_PIXELS);
|
||||
screenOverlay.getSize().setYUnits(ge.UNITS_PIXELS);
|
||||
screenOverlay.getSize().setX(250);
|
||||
screenOverlay.getSize().setY(75);
|
||||
|
||||
// Specify the point in the image around which to rotate
|
||||
screenOverlay.getRotationXY().setXUnits(ge.UNITS_FRACTION);
|
||||
screenOverlay.getRotationXY().setYUnits(ge.UNITS_FRACTION);
|
||||
screenOverlay.getRotationXY().setX(0.5);
|
||||
screenOverlay.getRotationXY().setY(0.5);
|
||||
|
||||
// Rotate the overlay
|
||||
screenOverlay.setRotation(25);
|
||||
|
||||
// Add the ScreenOverlay to Earth
|
||||
ge.getFeatures().appendChild(screenOverlay);
|
||||
|
||||
|
||||
// network link
|
||||
var link = ge.createLink('');
|
||||
var href = 'http://code.google.com/'
|
||||
+ 'apis/earth/documentation/samples/kml_example.kml'
|
||||
link.setHref(href);
|
||||
|
||||
var networkLink = ge.createNetworkLink('');
|
||||
networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView
|
||||
|
||||
ge.getFeatures().appendChild(networkLink);
|
||||
|
||||
// Get the current view.
|
||||
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
|
||||
|
||||
// Set new latitude and longitude values.
|
||||
lookAt.setLatitude(36.584207);
|
||||
lookAt.setLongitude(-121.754322);
|
||||
|
||||
// Update the view in Google Earth.
|
||||
ge.getView().setAbstractView(lookAt);
|
||||
|
||||
// time
|
||||
ge.getTime().getControl().setVisibility(ge.VISIBILITY_SHOW);
|
||||
ge.getTime().setHistoricalImageryEnabled(true);
|
||||
var extents = ge.getTime().getControl().getExtents();
|
||||
var begin = extents.getBegin().get();
|
||||
var end = extents.getEnd().get();
|
||||
|
||||
// tour
|
||||
ge.getTourPlayer().play();
|
||||
|
||||
|
||||
// controls
|
||||
ge.getNavigationControl().getScreenXY().setXUnits(ge.UNITS_INSET_PIXELS);
|
||||
ge.getNavigationControl().getScreenXY().setYUnits(ge.UNITS_PIXELS);
|
||||
|
||||
|
||||
// sky
|
||||
ge.getOptions().setMapType(ge.MAP_TYPE_SKY);
|
||||
ge.getOptions().setMapType(ge.MAP_TYPE_EARTH);
|
||||
}
|
||||
Vendored
+3978
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -427,7 +427,7 @@ declare namespace google.maps {
|
||||
/**
|
||||
* Marker position. Required.
|
||||
*/
|
||||
position: LatLng;
|
||||
position: LatLng|LatLngLiteral;
|
||||
/** Image map region definition used for drag/click. */
|
||||
shape?: MarkerShape;
|
||||
/** Rollover text. */
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/// <reference path="./graphene-pk11.d.ts" />
|
||||
|
||||
import * as graphene from "graphene-pk11";
|
||||
|
||||
// Example of Hashing from README.MD <https://github.com/PeculiarVentures/graphene#hashing>
|
||||
let Module = graphene.Module;
|
||||
|
||||
let lib = "/usr/local/lib/softhsm/libsofthsm2.so";
|
||||
@@ -13,13 +11,44 @@ mod.initialize();
|
||||
let slot = mod.getSlots(0);
|
||||
if (slot.flags & graphene.SlotFlag.TOKEN_PRESENT) {
|
||||
let session = slot.open();
|
||||
session.login("12345");
|
||||
|
||||
let digest = session.createDigest("sha1");
|
||||
digest.update("simple text 1");
|
||||
digest.update("simple text 2");
|
||||
let hash = digest.final();
|
||||
// generate EC key
|
||||
let keys = session.generateKeyPair(graphene.KeyGenMechanism.ECDSA, {
|
||||
keyType: graphene.KeyType.ECDSA,
|
||||
token: false,
|
||||
derive: true,
|
||||
paramsECDSA: graphene.NamedCurve.getByName("secp192r1").value
|
||||
}, {
|
||||
keyType: graphene.KeyType.ECDSA,
|
||||
token: false,
|
||||
derive: true
|
||||
});
|
||||
|
||||
console.log("Hash SHA1:", hash.toString("hex")); // Hash SHA1: e1dc1e52e9779cd69679b3e0af87d2e288190d34
|
||||
// derive algorithm
|
||||
let alg = {
|
||||
name: "ECDH1_DERIVE",
|
||||
params: new graphene.EcdhParams(
|
||||
graphene.EcKdf.SHA1,
|
||||
null,
|
||||
keys.publicKey.getAttribute({ pointEC: null }).pointEC)
|
||||
};
|
||||
|
||||
// Template for derived key
|
||||
let template = {
|
||||
"class": graphene.ObjectClass.SECRET_KEY,
|
||||
"token": false,
|
||||
"keyType": graphene.KeyType.AES,
|
||||
"valueLen": 256 / 8,
|
||||
"encrypt": true,
|
||||
"decrypt": true
|
||||
};
|
||||
|
||||
// Key derivation
|
||||
let dKey = session.deriveKey(alg, keys.privateKey, template);
|
||||
console.log("Derived key handle:", dKey.handle);
|
||||
|
||||
session.logout();
|
||||
session.close();
|
||||
}
|
||||
else {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user