Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jason Tremper
2014-12-18 17:22:57 -05:00
47 changed files with 7364 additions and 94 deletions
+39 -1
View File
@@ -39,4 +39,42 @@ rpc.call<any>('withoutCB', {}, function (msg) {
console.log('withoutCB results:', msg); //output: please run function without cb parameter
});
rpc.call<any>('withoutCB', {}); //output message on server side console
rpc.call<any>('withoutCB', {}); //output message on server side console
import os = require('os');
interface State {
type: string;
}
var counter = 0;
rpc.onBroadcast<State>('getWorkerStat', function (params, cb) {
if (params && params.type == 'fullStat') {
cb(null, {
pid: process.pid,
hostname: os.hostname(),
uptime: process.uptime(),
counter: counter++
});
}
else {
cb(null, { counter: counter++ })
}
});
var all_stats: any = {};
rpc.callBroadcast<State>(
'getWorkerStat',
{ type: 'fullStat' }, //request parameters
{ //call options
ttl: 1000, //wait response time (1 seconds), after run onComplete
onResponse: function (err: any, stat: any) { //callback on each worker response
all_stats[stat.hostname + ':' + stat.pid] = stat;
},
onComplete: function () { //callback on ttl expired
console.log('----------------------- WORKER STATISTICS ----------------------------------------');
for (var worker in all_stats) {
var s: any = all_stats[worker];
console.log(worker, '\tuptime=', s.uptime.toFixed(2) + ' seconds', '\tcounter=', s.counter);
}
}
});
+8 -4
View File
@@ -35,7 +35,7 @@ declare module "amqp-rpc" {
}
export interface BroadcastOptions {
ttl?: boolean;
ttl?: number;
onResponse?: any;
context?: any;
onComplete?: any;
@@ -52,6 +52,10 @@ declare module "amqp-rpc" {
(...args: any[]): void;
}
export interface CallbackWithError {
(err: any, ...args: any[]): void;
}
export function factory(opt?: Options): amqpRPC;
export class amqpRPC {
@@ -61,8 +65,8 @@ declare module "amqp-rpc" {
call<T>(cmd: string, params: T, cb?: Callback, context?: any, options?: CallOptions): string;
on<T>(cmd: string, cb: (param?: T, cb?: Callback, info?: CommandInfo) => void, context?: any, options?: HandlerOptions): boolean;
off(cmd: string): boolean;
callBroadcast(cmd: string, params: any, options: BroadcastOptions): void;
onBroadcast(cmd: string, cb: (err: any) => void, context: any, options?: any): boolean;
callBroadcast<T>(cmd: string, params: T, options?: BroadcastOptions): void;
onBroadcast<T>(cmd: string, cb?: (params?: T, cb?: CallbackWithError) => void, context?: any, options?: any): boolean;
offBroadcast(cmd: string): boolean;
}
}
}
+2
View File
@@ -297,6 +297,8 @@ declare module breeze {
getValidationErrors(property: IProperty): ValidationError[];
hasValidationErrors: boolean;
isNavigationPropertyLoaded(navigationProperty: string): boolean;
isNavigationPropertyLoaded(navigationProperty: NavigationProperty): boolean;
loadNavigationProperty(navigationProperty: string, callback?: Function, errorCallback?: Function): Q.Promise<QueryResult>;
loadNavigationProperty(navigationProperty: NavigationProperty, callback?: Function, errorCallback?: Function): Q.Promise<QueryResult>;
+58
View File
@@ -0,0 +1,58 @@
/// <reference path='convict.d.ts' />
/// <reference path='../validator/validator.d.ts' />
import convict = require('convict');
import validator = require('validator');
// define a schema
var conf = convict({
env: {
doc: 'The applicaton environment.',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV',
arg: 'node-env',
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS',
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 0,
env: 'PORT',
arg: 'port',
},
key: {
doc: "API key",
format: (val: string) => validator.isUUID(val),
default: '01527E56-8431-11E4-AF91-47B661C210CA'
},
});
// load environment dependent configuration
var env = conf.get('env');
conf.loadFile('./config/' + env + '.json');
conf.loadFile(['./configs/always.json', './configs/sometimes.json']);
// perform validation
conf.validate();
var port: number = conf.default('port');
if (conf.has('key')) {
conf.set('the.awesome', true);
conf.load({
thing: {
a: 'b'
}
});
}
// vim:et:sw=2:ts=2
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for node-convict v0.6.0
// Project: https://github.com/mozilla/node-convict
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "convict" {
function convict(schema: convict.Schema): convict.Config;
module convict {
interface Schema {
[name: string]: {
default: any;
doc?: string;
format?: any;
env?: string;
arg?: string;
};
}
interface Config {
get(name: string): any;
default(name: string): any;
has(name: string): boolean;
set(name: string, value: any): void;
load(conf: Object): void;
loadFile(file: string): void;
loadFile(files: string[]): void;
validate(): void;
}
}
export = convict;
}
@@ -1,4 +1,4 @@
/// <reference path="dx.chartjs.d.ts" />
/// <reference path="dx.chartjs-14.1.d.ts" />
module Test {
$("<div/>").appendTo(document.body).dxChart({
@@ -1,9 +1,9 @@
// Type definitions for ChartJS
// Type definitions for ChartJS 14.1.+
// Project: http://js.devexpress.com/WebDevelopment/Charts/
// Definitions by: DevExpress Inc. <http://devexpress.com/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
///<reference path="../../jquery/jquery.d.ts" />
declare module DevExpress {
export function abstract(): void;
@@ -1,4 +1,4 @@
/// <reference path="dx.phonejs.d.ts" />
/// <reference path="dx.phonejs-14.1.d.ts" />
module Test {
var url = "http://some-json-service.net/data.json";
@@ -1,9 +1,9 @@
// Type definitions for PhoneJS
// Type definitions for PhoneJS 14.1.+
// Project: http://js.devexpress.com/MobileDevelopment/
// Definitions by: DevExpress Inc. <http://devexpress.com/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
///<reference path="../../jquery/jquery.d.ts" />
declare module DevExpress {
export function abstract(): void;
@@ -1,4 +1,4 @@
/// <reference path="dx.webappjs.d.ts" />
/// <reference path="dx.webappjs-14.1.d.ts" />
module Test {
$('<div/>').appendTo(document.body)
@@ -1,9 +1,9 @@
// Type definitions for WebAppJS
// Type definitions for WebAppJS 14.1.+
// Project: http://js.devexpress.com/WebDevelopment/
// Definitions by: DevExpress Inc. <http://devexpress.com/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
///<reference path="../../jquery/jquery.d.ts" />
declare module DevExpress {
export function abstract(): void;
+9
View File
@@ -0,0 +1,9 @@
# DevExtreme TypeScript definitions #
You can use DevExtreme TypeScript definitions to add DevExtreme widgets ([UI widgets](http://js.devexpress.com/Documentation/ApiReference/UI_Widgets) and [Data Visualization widgets](http://js.devexpress.com/Documentation/ApiReference/Data_Visualization_Widgets)) to your TypeScript apps, as well as build [DevExtreme single-page applications](http://js.devexpress.com/Documentation/Howto/SPA_Framework/Application_Design) using TypeScript. To do that, simply add <reference path="TypeScript/dx.devextreme.d.ts" /> at the top of your code.
The API enclosed into the DevExtreme TypeScript definition file fully corresponds to the API described in the DevExtreme JavaScript [Reference](http://js.devexpress.com/Documentation/ApiReference) documentation.
To build applications based on the DevExtreme SPA framework in Visual Studio, use TypeScript [application templates](http://js.devexpress.com/Documentation/Howto/VS_Integration/Project_Templates) integrated into Visual Studio.
If you have any issues while using the DevExtreme TypeScript definitions, please refer to our [Support Center](https://www.devexpress.com/Support/Center/Question/List/1).
+335
View File
@@ -0,0 +1,335 @@
/// <reference path="dx.devextreme.d.ts" />
module Tests.ui {
var dataGridOptions: DevExpress.ui.dxDataGridOptions = {
activeStateEnabled: true,
allowColumnReordering: true,
allowColumnResizing: true,
onCellClick: function () { },
cellHintEnabled: true,
columnAutoWidth: true,
columnChooser: {
emptyPanelText: "Nothing is here",
enabled: true,
height: 400,
width: 200,
title: "Column chooser"
},
columns: [
{
text: '5 columns with custom css class', value: [
{ dataField: 'Processed', dataType: 'boolean', allowSorting: false },
{ dataField: 'CustomerID', cssClass: 'customCssClass' },
'OrderDate',
{ dataField: 'Freight', validationRules: [{ type: "range", min: 1, max: 100 }] },
{ dataField: 'ShipName', validationRules: [{ type: 'required' }] },
'ShipCity']
},
{
text: 'with show editor always', value: [
{ dataField: 'Processed', dataType: 'boolean', allowSorting: false, showEditorAlways: true },
{ dataField: 'OrderDate', dataType: 'date', showEditorAlways: true },
{ dataField: 'CustomerID', showEditorAlways: true },
{ dataField: 'Freight', showEditorAlways: true },
{ dataField: 'ShipName', showEditorAlways: true }]
},
{
text: 'custom template/edit/header template', value: [
'CustomerID',
'OrderDate',
'Freight',
{
dataField: 'ShipVia',
editCellTemplate: function (container: JQuery, options: { value: number }) {
container.addClass('dx-editor-cell');
container.append($('<div />').dxSelectBox({
value: options.value,
dataSource: [
{ ShipperID: 1, CompanyName: 'Speedy Express' },
{ ShipperID: 2, CompanyName: 'United Package' },
{ ShipperID: 3, CompanyName: 'Federal Shipping' }
],
valueExpr: 'ShipperID',
displayExpr: 'CompanyName'
}));
},
cellTemplate: function (container: JQuery, options: { value: number }) {
container.text(String(options.value));
},
headerCellTemplate: function (container: JQuery, options: { headerCaption: string }) {
container.append($('<div/>').css({ border: '1px solid red' }).text(options.headerCaption));
}
},
'ShipName',
'ShipCity']
},
{ text: 'none', value: '' },
{
text: 'custom template/header hogan template', value: [
'CustomerID',
'OrderDate',
'Freight',
{
dataField: 'ShipVia',
cellTemplate: '#hoganColumnTemplate',
headerCellTemplate: $('#hoganHeaderColumnTemplate')
},
'ShipName',
'ShipCity']
}],
customizeColumns: function (columns) {
var i: number;
for (i = 0; i < columns.length; i++) {
if (columns[i].dataField.indexOf('Date') > 0) {
columns[i].dataType = 'date';
}
if (columns[i].dataField === 'Freight') {
columns[i].dataType = 'number';
}
if (columns[i].dataField === 'CustomerID') {
columns[i].lookup = {
dataSource: { store: [], sort: 'ContactName' },
valueExpr: 'CustomerID',
displayExpr: 'ContactName'
}
}
if (columns[i].dataField === 'EmployeeID') {
columns[i].lookup = {
dataSource: { store: [], sort: 'LastName' },
valueExpr: 'EmployeeID',
displayExpr: function (data: any) {
return data.LastName + ' ' + data.FirstName;
}
}
}
if (columns[i].dataField === 'ShipVia') {
columns[i].lookup = {
dataSource: [
{ ShipperID: 1, CompanyName: 'Speedy Express' },
{ ShipperID: 2, CompanyName: 'United Package' },
{ ShipperID: 3, CompanyName: 'Federal Shipping' }
],
valueExpr: 'ShipperID',
displayExpr: 'CompanyName'
}
}
if (columns[i].dataField === 'ShipCity') {
columns[i].editCellTemplate = function (container: JQuery, options: { value: string; setValue: Function }) {
$('<div/>').dxAutocomplete({
items: ["Bern", "Lyon", "Lander"],
value: options.value,
onValueChange: function (e:{ value: string }) {
options.setValue(e.value);
}
}).appendTo(container);
}
}
}
},
summary: {
totalItems: [{
column: 'CustomerID',
summaryType: 'count'
}, {
column: 'Freight',
summaryType: 'min',
valueFormat: "percent",
showInColumn: "CustomerID"
},
{
column: 'OrderDate',
summaryType: 'min',
valueFormat: "shortDate"
},
{
column: 'Freight',
summaryType: 'avg',
valueFormat: "fixedPoint",
precision: 2
}],
groupItems: [{
column: 'CustomerID',
summaryType: 'count',
showInGroupFooter: true
}, {
column: 'Freight',
summaryType: 'min'
}, {
column: 'Freight',
summaryType: 'max'
},
{
column: 'ShipName',
summaryType: 'count',
showInGroupFooter: true
},
{
column: 'OrderDate',
summaryType: 'min',
valueFormat: "shortDate",
showInColumn: "CustomerID",
showInGroupFooter: true
}]
},
sortByGroupSummaryInfo: [{ summaryItem: 'count' }],
groupPanel: {
visible: true
},
filterRow: {
visible: true
},
pager: {
visible: true,
showInfo: true,
showNavigationButtons: true,
showPageSizeSelector: true
},
stateStoring: {
enabled: false
},
rowAlternationEnabled: true,
editing: {
editMode: 'batch',
insertEnabled: true,
editEnabled: true,
removeEnabled: true
},
searchPanel: {
visible: true
},
sorting: {
mode: 'multiple'
}
};
new DevExpress.ui.dxDataGrid($("#data-grid"), dataGridOptions);
new DevExpress.ui.dxDataGrid($("#data-grid").get(0), dataGridOptions);
$("#data-grid").dxDataGrid(dataGridOptions);
}
module Tests.viz {
var chartOptions: DevExpress.viz.charts.dxChartOptions = {
dataSource: [
{ arg: "Illinois", s1: 100, s2: 50, s3: 75, s4: 25, s5: 50, s6: 100, s7: 25, s8: 75 },
{ arg: "Indiana", s1: 100, s2: 50, s3: 75, s4: 25, s5: 50, s6: 100, s7: 25, s8: 75 },
{ arg: "Michigan", s1: 100, s2: 50, s3: 75, s4: 25, s5: 50, s6: 100, s7: 25, s8: 75 }
],
valueAxis: [{ title: 'Value Axis Title' }],
argumentAxis: { title: 'Argument Axis Title', grid: { visible: true } },
legend: { border: { visible: true } },
tooltip: { enabled: true },
commonPaneSettings: { border: { visible: true } },
commonSeriesSettings: {
type: 'bar',
hoverMode: 'allArgumentPoints',
selectionMode: 'allArgumentPoints',
label: {
visible: true,
format: 'fixedPoint',
precision: 2
}
},
series: [
{ valueField: 's1' },
{ valueField: 's2' },
{ valueField: 's3' },
{ valueField: 's4' },
{ valueField: 's5' },
{ valueField: 's6' },
{ valueField: 's7' },
{ valueField: 's8' }
],
title: 'Long Chart\'s Title',
onPointClick: function (arg: any) {
arg.target.isSelected() ? arg.target.clearSelection() : arg.target.select();
},
onSeriesClick: function (arg: any) {
arg.target.isVisible() ? arg.target.hide() : arg.target.show();
}
};
var pieChartOptions: DevExpress.viz.charts.dxPieChartOptions = {
dataSource: [{ arg: "Index1", arg1: 1, val: 100 },
{ arg: "Index2", arg1: 2, val: 50 },
{ arg: "Index3", arg1: 3, val: 75 },
{ arg: "Index4", arg1: 4, val: 25 },
{ arg: "Index5", arg1: 5, val: 50 },
{ arg: "Index6", arg1: 6, val: 100 },
{ arg: "Index7", arg1: 7, val: 25 },
{ arg: "Index8", arg1: 8, val: 75 }],
tooltip: {
enabled: true
},
series: [{
type: 'doughnut',
label: {
visible: true,
format: 'fixedPoint',
precision: 2
}
}],
title: 'Long PieChart\'s Title'
};
new DevExpress.viz.charts.dxChart($("chart"), chartOptions);
new DevExpress.viz.charts.dxChart($("#chart").get(0), chartOptions);
$("#chart").dxChart(chartOptions);
new DevExpress.viz.charts.dxPieChart($("#pie-chart"), pieChartOptions);
new DevExpress.viz.charts.dxPieChart($("#pie-chart").get(0), pieChartOptions);
$("#pie-chart").dxPieChart(pieChartOptions);
}
module Tests.framework {
var app = new DevExpress.framework.html.HtmlApplication(<DevExpress.framework.html.HtmlApplicationOptions>{
namespace: "Application",
navigation: [
{
title: "Home",
action: "#home",
icon: "home"
},
{
title: "About",
action: "#about",
icon: "info"
}
]
});
app.router.register(":view/:id", { view: "home", id: undefined });
app.navigate();
}
module Tests.data {
new DevExpress.data.DataSource(<DevExpress.data.DataSourceOptions>{
sort: ["value", true],
group: ["id", false],
select: ["value"],
filter: ["value", "startswith", "first"],
pageSize: 25,
paginate: true,
map: function (item) { return item; },
postProcess: function (data) { return data; },
searchExpr: "expr",
searchOperation: "contains",
searchValue: "somevalue",
store: [1, 2, 3]
});
new DevExpress.data.ArrayStore();
new DevExpress.data.ArrayStore(<DevExpress.data.ArrayStoreOptions>{
data: [{ id: 1, value: "First one" }, { id: 2, value: "Second one" }],
key: "id"
});
new DevExpress.data.CustomStore(<DevExpress.data.CustomStoreOptions>{
load: function () {
return $.Deferred().promise();
}
});
}
+5670
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -24,7 +24,7 @@ interface DropzoneOptions {
headers?: any;
addRemoveLinks?: boolean;
previewsContainer?: string;
clickable?: boolean;
clickable?: any;
createImageThumbnails?: boolean;
maxThumbnailFilesize?: number;
thumbnailWidth?: number;
@@ -39,7 +39,7 @@ interface DropzoneOptions {
forceFallback?: boolean;
fallback?: () => void;
// dictionary options
// dictionary options
dictDefaultMessage?: string;
dictFallbackMessage?: string;
dictFallbackText?: string;
@@ -66,13 +66,13 @@ declare class Dropzone {
off(eventName): void;
removeFile(file: DropzoneFile): void;
removeAllFiles(): void;
removeAllFiles(cancelIfNecessary?: boolean): void;
processQueue(): void;
getAcceptedFiles(): DropzoneFile[];
getRejectedFiles(): DropzoneFile[];
getQueuedFiles(): DropzoneFile[];
getUploadingFiles(): DropzoneFile[];
emit(eventName: string, file: DropzoneFile, str?: string);
emit(eventName: "thumbnail", file: DropzoneFile, path: string);
emit(eventName: "addedfile", file: DropzoneFile);
+7 -1
View File
@@ -1056,4 +1056,10 @@ function sample8() {
obj.setCoords();
});
};
}
}
function sample9() {
var canvas = new fabric.Canvas('c');
canvas.setBackgroundImage('yolo.jpg', () => {"a"}, {opacity: 45});
canvas.setBackgroundImage('yolo.jpg', () => {"a"});
}
+10 -10
View File
@@ -274,13 +274,13 @@ declare module fabric {
hasControls: boolean;
hasRotatingPoint: boolean;
height: number;
getHeight(): number;
setHeight(value: number): IObject;
includeDefaultValues: boolean;
left: number;
getLeft(): number;
setLeft(value: number): IObject;
@@ -296,7 +296,7 @@ declare module fabric {
padding: number;
perPixelTargetFind: boolean;
rotatingPointOffset: number;
scaleX: number;
getScaleX(): number;
setScaleX(value: number): IObject;
@@ -310,7 +310,7 @@ declare module fabric {
stroke: string;
strokeDashArray: any[];
strokeWidth: number;
top: number;
getTop(): number;
setTop(value: number): IObject;
@@ -318,7 +318,7 @@ declare module fabric {
transformMatrix: any[];
transparentCorners: boolean;
type: string;
width: number;
getWidth(): number;
setWidth(value: number): IObject;
@@ -453,7 +453,7 @@ declare module fabric {
toSVG(): string;
}
export interface IPath extends IObject {
complexity(): number;
@@ -511,7 +511,7 @@ declare module fabric {
renderOnAddition: boolean;
stateful: boolean;
// static
// static
EMPTY_JSON: string;
supports(methodName: string): boolean;
@@ -546,7 +546,7 @@ declare module fabric {
sendBackwards(object: IObject): ICanvas;
sendToBack(object: IObject): ICanvas;
setBackgroundImage(object: IObject): ICanvas;
setBackgroundImage(image: any, callback: () => any, options?): ICanvas;
setDimensions(object: { width: number; height: number; }): ICanvas;
setHeight(height: number): ICanvas;
setOverlayImage(url: string, callback: () => any, options): ICanvas;
@@ -681,7 +681,7 @@ declare module fabric {
}
export interface IRectOptions extends IObjectOptions {
x?: number;
x?: number;
y?: number;
rx?: number;
ry?: number;
@@ -798,7 +798,7 @@ declare module fabric {
new (element: HTMLImageElement, objObjects: IObjectOptions): IImage;
prototype: any;
filters:
filters:
{
Grayscale: {
new (): IGrayscaleFilter;
+1 -2
View File
@@ -122,8 +122,7 @@ declare module grunt {
* {@link http://gruntjs.com/sample-gruntfile}
*/
interface IProjectConfig{
[plugin: string]: any
pkg: any; // unfortunate. It is actually a string
[plugin: string]: any;
}
/**
+162
View File
@@ -0,0 +1,162 @@
/// <reference path='imap.d.ts' />
/*
* This code contains all of the example code that was on https://www.npmjs.com/package/imap as of Sat Dec 13, 2014.
*/
import Imap = require('imap');
import util = require('util');
import inspect = util.inspect;
var imap = new Imap({
user: 'mygmailname@gmail.com',
password: 'mygmailpassword',
host: 'imap.gmail.com',
port: 993,
tls: true
});
function openInbox(cb : (error : Error, box: IMAP.Box) => void) {
imap.openBox('INBOX', true, cb);
}
imap.once('ready', function() {
openInbox(function(err, box) {
if (err) throw err;
var f = imap.seq.fetch('1:3', {
bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)',
struct: true
});
f.on('message', function(msg : IMAP.ImapMessage, seqno : number) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream : NodeJS.ReadableStream, info : Object) {
var buffer = '';
stream.on('data', function(chunk : Buffer) {
buffer += chunk.toString('utf8');
});
stream.once('end', function() {
console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer)));
});
});
msg.once('attributes', function(attrs : Object) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err : Error) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages!');
imap.end();
});
});
});
imap.once('error', function(err : Error) {
console.log(err);
});
imap.once('end', function() {
console.log('Connection ended');
});
imap.connect();
// using the functions and variables already defined in the first example ...
openInbox(function(err : Error, box : IMAP.Box) {
if (err) throw err;
var f = imap.seq.fetch(box.messages.total + ':*', { bodies: ['HEADER.FIELDS (FROM)','TEXT'] });
f.on('message', function(msg : IMAP.ImapMessage, seqno : number) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream : NodeJS.ReadableStream, info : any) {
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] found, %d total bytes', inspect(info.which), info.size);
var buffer = '', count = 0;
stream.on('data', function(chunk : Buffer) {
count += chunk.length;
buffer += chunk.toString('utf8');
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), count, info.size);
});
stream.once('end', function() {
if (info.which !== 'TEXT')
console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer)));
else
console.log(prefix + 'Body [%s] Finished', inspect(info.which));
});
});
msg.once('attributes', function(attrs : Object) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err : Error) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages!');
imap.end();
});
});
// using the functions and variables already defined in the first example ...
var fs = require('fs');
openInbox(function(err : Error, box : IMAP.Box) {
if (err) throw err;
imap.search([ 'UNSEEN', ['SINCE', 'May 20, 2010'] ], function(err : Error, results : string[]) {
if (err) throw err;
var f = imap.fetch(results, { bodies: '' });
f.on('message', function(msg : IMAP.ImapMessage, seqno : number) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream : NodeJS.ReadableStream, info : any) {
console.log(prefix + 'Body');
stream.pipe(fs.createWriteStream('msg-' + seqno + '-body.txt'));
});
msg.once('attributes', function(attrs : Object) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err : Error) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages!');
imap.end();
});
});
});
var rawHeader : string = '';
var headers = Imap.parseHeader(rawHeader);
headers = Imap.parseHeader(rawHeader, true);
var f : IMAP.ImapFetch;
f = imap.fetch('1:3', { bodies: '' });
f = imap.seq.fetch('1:3', { bodies: '' });
+272
View File
@@ -0,0 +1,272 @@
// Type definitions for imap v0.8.14
// Project: https://www.npmjs.com/package/imap
// Definitions by: Peter Snider <https://github.com/psnider/>
// Definitions: https://github.com/psnider/DefinitelyTyped/imap
/// <reference path='../node/node.d.ts' />
declare module IMAP {
// The property names of these interfaces match the documentation (where type names were given).
export interface Config {
user: string; // Username for plain-text authentication.
password: string; // Password for plain-text authentication.
xoauth?: string; // Base64-encoded OAuth token for OAuth authentication for servers that support it (See Andris Reinman's xoauth.js module to help generate this string).
xoauth2?: string; // Base64-encoded OAuth2 token for The SASL XOAUTH2 Mechanism for servers that support it (See Andris Reinman's xoauth2 module to help generate this string).
host?: string; // Hostname or IP address of the IMAP server. Default: "localhost"
port?: number; // Port number of the IMAP server. Default: 143
tls?: boolean; // Perform implicit TLS connection? Default: false
tlsOptions?: Object; // Options object to pass to tls.connect() Default: (none)
autotls?: string; // Set to 'always' to always attempt connection upgrades via STARTTLS, 'required' only if upgrading is required, or 'never' to never attempt upgrading. Default: 'never'
connTimeout?: number; // Number of milliseconds to wait for a connection to be established. Default: 10000
authTimeout?: number; // Number of milliseconds to wait to be authenticated after a connection has been established. Default: 5000
keepalive?: any; /* boolean|KeepAlive */ // Configures the keepalive mechanism. Set to true to enable keepalive with defaults or set to object to enable and configure keepalive behavior: Default: true
debug?: Function; // If set, the function will be called with one argument, a string containing some debug info Default: (no debug output)
}
export interface KeepAlive {
interval?: number; // This is the interval (in milliseconds) at which NOOPs are sent and the interval at which idleInterval is checked. Default: 10000
idleInterval?: number; // This is the interval (in milliseconds) at which an IDLE command (for servers that support IDLE) is re-sent. Default: 300000 (5 mins)
forceNoop?: boolean; // Set to true to force use of NOOP keepalive on servers also support IDLE. Default: false
}
// One of:
// - a single message identifier
// - a message identifier range (e.g. '2504:2507' or '*' or '2504:*')
// - an array of message identifiers
// - an array of message identifier ranges.
// type MessageSource = string | string[]
export interface Box {
name: string; // The name of this mailbox.
readOnly?: boolean; // True if this mailbox was opened in read-only mode. (Only available with openBox() calls)
newKeywords: boolean; //True if new keywords can be added to messages in this mailbox.
uidvalidity: number; // A 32-bit number that can be used to determine if UIDs in this mailbox have changed since the last time this mailbox was opened.
uidnext: number; // The uid that will be assigned to the next message that arrives at this mailbox.
flags: string[]; // array - A list of system-defined flags applicable for this mailbox. Flags in this list but not in permFlags may be stored for the current session only. Additional server implementation-specific flags may also be available.
permFlags: string[]; // A list of flags that can be permanently added/removed to/from messages in this mailbox.
persistentUIDs: boolean; // Whether or not this mailbox has persistent UIDs. This should almost always be true for modern mailboxes and should only be false for legacy mail stores where supporting persistent UIDs was not technically feasible.
messages: { //Contains various message counts for this mailbox:
total: number; // Total number of messages in this mailbox.
new: number; // Number of messages in this mailbox having the Recent flag (this IMAP session is the first to see these messages).
unseen: number; // (Only available with status() calls) Number of messages in this mailbox not having the Seen flag (marked as not having been read).
};
}
// Given in a 'message' event from ImapFetch
export interface ImapMessage extends NodeJS.EventEmitter {
}
export interface FetchOptions {
markSeen?: boolean; // Mark message(s) as read when fetched. Default: false
struct?: boolean; // Fetch the message structure. Default: false
envelope?: boolean; // Fetch the message envelope. Default: false
size?: boolean; // Fetch the RFC822 size. Default: false
modifiers?: Object; // Fetch modifiers defined by IMAP extensions. Default: (none)
bodies?: any; /* string|string[] */ // A string or Array of strings containing the body part section to fetch. Default: (none) Example sections:
}
// Returned from fetch()
export interface ImapFetch extends NodeJS.EventEmitter {
}
export interface Folder {
attribs: string[];
delimiter: string;
children: Folder[];
parent: Folder;
}
export interface MailBoxes {
[name: string] : Folder;
}
export interface AppendOptions {
mailbox?: string; // The name of the mailbox to append the message to. Default: the currently open mailbox
flags?: any; /* string|string[] */ // A single flag (e.g. 'Seen') or an array of flags (e.g. ['Seen', 'Flagged']) to append to the message. Default: (no flags)
date?: Date; // What to use for message arrival date/time. Default: (current date/time)
}
// search() criteria
/**
// The following message flags are valid types that do not have arguments:
ALL: void; // All messages.
ANSWERED: void; // Messages with the Answered flag set.
DELETED: void; // Messages with the Deleted flag set.
DRAFT: void; // Messages with the Draft flag set.
FLAGGED: void; // Messages with the Flagged flag set.
NEW: void; // Messages that have the Recent flag set but not the Seen flag.
SEEN: void; // Messages that have the Seen flag set.
RECENT: void; // Messages that have the Recent flag set.
OLD: void; // Messages that do not have the Recent flag set. This is functionally equivalent to "!RECENT" (as opposed to "!NEW").
UNANSWERED: void; // Messages that do not have the Answered flag set.
UNDELETED: void; // Messages that do not have the Deleted flag set.
UNDRAFT: void; // Messages that do not have the Draft flag set.
UNFLAGGED: void; // Messages that do not have the Flagged flag set.
UNSEEN: void; // Messages that do not have the Seen flag set.
// The following are valid types that require string value(s):
BCC: any; // Messages that contain the specified string in the BCC field.
CC: any; // Messages that contain the specified string in the CC field.
FROM: any; // Messages that contain the specified string in the FROM field.
SUBJECT: any; // Messages that contain the specified string in the SUBJECT field.
TO: any; // Messages that contain the specified string in the TO field.
BODY: any; // Messages that contain the specified string in the message body.
TEXT: any; // Messages that contain the specified string in the header OR the message body.
KEYWORD: any; // Messages with the specified keyword set.
HEADER: any; // Requires two string values, with the first being the header name and the second being the value to search for. If this second string is empty, all messages that contain the given header name will be returned.
// The following are valid types that require a string parseable by JavaScripts Date object OR a Date instance:
BEFORE: any; // Messages whose internal date (disregarding time and timezone) is earlier than the specified date.
ON: any; // Messages whose internal date (disregarding time and timezone) is within the specified date.
SINCE: any; // Messages whose internal date (disregarding time and timezone) is within or later than the specified date.
SENTBEFORE: any; // Messages whose Date header (disregarding time and timezone) is earlier than the specified date.
SENTON: any; // Messages whose Date header (disregarding time and timezone) is within the specified date.
SENTSINCE: any; // Messages whose Date header (disregarding time and timezone) is within or later than the specified date.
//The following are valid types that require one Integer value:
LARGER: number; // Messages with a size larger than the specified number of bytes.
SMALLER: number; // Messages with a size smaller than the specified number of bytes.
// The following are valid criterion that require one or more Integer values:
UID: any; // Messages with UIDs corresponding to the specified UID set. Ranges are permitted (e.g. '2504:2507' or '*' or '2504:*').
*/
export interface MessageFunctions {
// Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate.
search(criteria : any[], callback : (error : Error, uids : string[]) => void) : void;
// Fetches message(s) in the currently open mailbox.
fetch(source : any /* MessageSource */, options : FetchOptions) : ImapFetch;
// Copies message(s) in the currently open mailbox to another mailbox.
copy(source : any /* MessageSource */, mailboxName : string, callback : (error : Error) => void) : void;
// Moves message(s) in the currently open mailbox to another mailbox. Note: The message(s) in the destination mailbox will have a new message UID.
move(source : any /* MessageSource */, mailboxName : string, callback : (error : Error) => void) : void;
// Adds flag(s) to message(s).
addFlags(source : any /* MessageSource */, flags : any, callback : (error : Error) => void) : void;
// Removes flag(s) from message(s).
delFlags(source : any /* MessageSource */, flags : any, callback : (error : Error) => void) : void;
// Sets the flag(s) for message(s).
setFlags(source : any /* MessageSource */, flags : any, callback : (error : Error) => void) : void;
// Adds keyword(s) to message(s). keywords is either a single keyword or an array of keywords.
addKeywords(source : any /* MessageSource */, keywords : any /* string|string[] */, callback : (error : Error) => void) : void;
//Removes keyword(s) from message(s). keywords is either a single keyword or an array of keywords.
delKeywords(source : any /* MessageSource */, keywords : any /* string|string[] */, callback : (error : Error) => void) : void;
// Sets keyword(s) for message(s). keywords is either a single keyword or an array of keywords.
setKeywords(source : any /* MessageSource */, keywords : any /* string|string[] */, callback : (error : Error) => void) : void;
// Checks if the server supports the specified capability.
serverSupports(capability : string) : boolean;
}
export class Connection implements NodeJS.EventEmitter, MessageFunctions {
/** @constructor */
constructor(config : Config);
// from NodeJS.EventEmitter
addListener(event: string, listener: Function): NodeJS.EventEmitter;
on(event: string, listener: Function): NodeJS.EventEmitter;
once(event: string, listener: Function): NodeJS.EventEmitter;
removeListener(event: string, listener: Function): NodeJS.EventEmitter;
removeAllListeners(event?: string): NodeJS.EventEmitter;
setMaxListeners(n: number): void;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
// from MessageFunctions
// Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate.
search(criteria : any[], callback : (error : Error, uids : string[]) => void) : void;
// Fetches message(s) in the currently open mailbox.
fetch(source : any /* MessageSource */, options : FetchOptions) : ImapFetch;
// Copies message(s) in the currently open mailbox to another mailbox.
copy(source : any /* MessageSource */, mailboxName : string, callback : (error : Error) => void) : void;
// Moves message(s) in the currently open mailbox to another mailbox. Note: The message(s) in the destination mailbox will have a new message UID.
move(source : any /* MessageSource */, mailboxName : string, callback : (error : Error) => void) : void;
// Adds flag(s) to message(s).
addFlags(source : any /* MessageSource */, flags : any, callback : (error : Error) => void) : void;
// Removes flag(s) from message(s).
delFlags(source : any /* MessageSource */, flags : any, callback : (error : Error) => void) : void;
// Sets the flag(s) for message(s).
setFlags(source : any /* MessageSource */, flags : any, callback : (error : Error) => void) : void;
// Adds keyword(s) to message(s). keywords is either a single keyword or an array of keywords.
addKeywords(source : any /* MessageSource */, keywords : any /* string|string[] */, callback : (error : Error) => void) : void;
//Removes keyword(s) from message(s). keywords is either a single keyword or an array of keywords.
delKeywords(source : any /* MessageSource */, keywords : any /* string|string[] */, callback : (error : Error) => void) : void;
// Sets keyword(s) for message(s). keywords is either a single keyword or an array of keywords.
setKeywords(source : any /* MessageSource */, keywords : any /* string|string[] */, callback : (error : Error) => void) : void;
// Checks if the server supports the specified capability.
serverSupports(capability : string) : boolean;
// Parses a raw header and returns an object keyed on header fields and the values are Arrays of header field values. Set disableAutoDecode to true to disable automatic decoding of MIME encoded-words that may exist in header field values.
static parseHeader(rawHeader: string, disableAutoDecode? : boolean) : any;
state: string; // The current state of the connection (e.g. 'disconnected', 'connected', 'authenticated').
delimiter: string; // The (top-level) mailbox hierarchy delimiter. If the server does not support mailbox hierarchies and only a flat list, this value will be falsey.
namespaces: { // Contains information about each namespace type (if supported by the server) with the following properties:
personal: any[]; // Mailboxes that belong to the logged in user.
other: any[]; // Mailboxes that belong to other users that the logged in user has access to.
shared: any[]; // Mailboxes that are accessible by any logged in user.
};
seq: MessageFunctions;
/** Attempts to connect and authenticate with the IMAP server. */
connect() : void;
/** Closes the connection to the server after all requests in the queue have been sent. */
end() : void;
/** Immediately destroys the connection to the server. */
destroy() : void;
/** Opens a specific mailbox that exists on the server. mailboxName should include any necessary prefix/path. modifiers is used by IMAP extensions. */
openBox(mailboxName : string, callback : (error : Error, mailbox: Box) => void) : void;
openBox(mailboxName : string, openReadOnly : boolean, callback : (error : Error, mailbox: Box) => void) : void;
openBox(mailboxName : string, openReadOnly : boolean, modifiers : Object, callback : (error : Error, mailbox: Box) => void) : void;
/** Closes the currently open mailbox. If autoExpunge is true, any messages marked as Deleted in the currently open mailbox will be removed if the mailbox was NOT opened in read-only mode. If autoExpunge is false, you disconnect, or you open another mailbox, messages marked as Deleted will NOT be removed from the currently open mailbox. */
closeBox(callback : (error : Error) => void) : void;
closeBox(autoExpunge : boolean, callback : (error : Error) => void) : void;
/** Creates a new mailbox on the server. mailboxName should include any necessary prefix/path. */
addBox(mailboxName : string, callback : (error : Error) => void) : void;
/** Removes a specific mailbox that exists on the server. mailboxName should including any necessary prefix/path. */
delBox(mailboxName : string, callback : (error : Error, uids : string[]) => void) : void;
/** Renames a specific mailbox that exists on the server. Both oldMailboxName and newMailboxName should include any necessary prefix/path. Note: Renaming the 'INBOX' mailbox will instead cause all messages in 'INBOX' to be moved to the new mailbox. */
renameBox(oldMailboxName : string, newMailboxName : string, callback : (error : Error, mailbox: Box) => void) : void;
/** Subscribes to a specific mailbox that exists on the server. mailboxName should include any necessary prefix/path. */
subscribeBox(mailboxName : string, callback : (error : Error) => void) : void;
/** Unsubscribes from a specific mailbox that exists on the server. mailboxName should include any necessary prefix/path. */
unsubscribeBox(mailboxName : string, callback : (error : Error) => void) : void;
/** Fetches information about a mailbox other than the one currently open. Note: There is no guarantee that this will be a fast operation on the server. Also, do not call this on the currently open mailbox. */
status(mailboxName : string, callback : (error : Error, mailbox: Box) => void) : void;
/** Obtains the full list of mailboxes. If nsPrefix is not specified, the main personal namespace is used. */
getBoxes(callback : (error : Error, mailboxes: MailBoxes) => void) : void;
getBoxes(nsPrefix : string, callback : (error : Error, mailboxes: MailBoxes) => void) : void;
/** Obtains the full list of subscribed mailboxes. If nsPrefix is not specified, the main personal namespace is used. */
getSubscribedBoxes(callback : (error : Error, mailboxes: MailBoxes) => void) : void;
getSubscribedBoxes(nsPrefix : string, callback : (error : Error, mailboxes: MailBoxes) => void) : void;
/** Permanently removes all messages flagged as Deleted in the currently open mailbox. If the server supports the 'UIDPLUS' capability, uids can be supplied to only remove messages that both have their uid in uids and have the \Deleted flag set. Note: At least on Gmail, performing this operation with any currently open mailbox that is not the Spam or Trash mailbox will merely archive any messages marked as Deleted (by moving them to the 'All Mail' mailbox). */
expunge(callback : (error : Error) => void) : void;
expunge(uids : any /* MessageSource */, callback : (error : Error) => void) : void;
// Appends a message to selected mailbox. msgData is a string or Buffer containing an RFC-822 compatible MIME message. Valid options properties are:
append(msgData : any, callback : (error : Error) => void) : void;
append(msgData : any, options : AppendOptions, callback : (error : Error) => void) : void;
}
}
declare module "imap" {
var out: typeof IMAP.Connection;
export = out;
}
+69
View File
@@ -0,0 +1,69 @@
/// <reference path="jjv.d.ts" />
import jjv = require('jjv');
// create new JJV environment
var env = jjv();
var errors: jjv.Errors;
// Register a `user` schema
env.addSchema('user', {
type: 'object',
properties: {
firstname: {
type: 'string',
minLength: 2,
maxLength: 15,
},
lastname: {
type: 'string',
minLength: 2,
maxLength: 25,
},
gender: {
type: 'string',
enum: ['male', 'female'],
},
email: {
type: 'string',
format: 'email',
},
password: {
type: 'string',
minLength: 8,
},
},
required: ['firstname', 'lastname', 'email', 'password'],
});
// Perform validation against an incomplete user object (errors will be reported)
errors = env.validate('user', { firstname: 'John', lastname: 'Smith' });
errors = env.validate({
type: 'object',
properties: {
x: { type: 'number' },
y: { type: 'number' },
},
required: ['x', 'y'],
}, { x: 'a' });
if (errors.validation['x'].type === 'string') {
console.log('x is wrong type');
}
if (errors.validation['y'].required) {
console.log('y is required');
}
env.defaultOptions.checkRequired = false;
env.validate('schemaName', {}, { checkRequired: false });
env.addType('date', (v: any) => !isNaN(Date.parse(v)));
env.addFormat('hexadecimal', (v: any) => (/^[a-fA-F0-9]+$/).test(v));
env.addCheck('exactLength', (v: any, p: any) => v.length === p);
env.addTypeCoercion('integer', (x: any) => parseInt(x, 10));
+42
View File
@@ -0,0 +1,42 @@
// Type definitions for JJV v1.0.2
// Project: https://github.com/acornejo/jjv
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "jjv" {
function jjv(): jjv.Env;
module jjv {
interface Errors {
validation: {
[property: string]: {
required?: boolean;
type?: string;
}
};
}
interface Options {
checkRequired?: boolean;
useDefault?: boolean;
useCoerce?: boolean;
removeAdditional?: boolean;
}
interface Env {
defaultOptions: Options;
addSchema(name: string, schema: Object): void;
addType(name: string, parse: (input: any) => any): void;
addFormat(name: string, parse: (input: any) => any): void;
addCheck(name: string, check: (input: any, comparator: any) => any): void;
addTypeCoercion(name: string, coerce: (input: any) => any): void;
validate(name: string, object: any, options?: Options): Errors;
validate(schema: Object, object: any, options?: Options): Errors;
}
}
export = jjv;
}
+34
View File
@@ -0,0 +1,34 @@
/// <reference path="../jjv/jjv.d.ts" />
/// <reference path="jjve.d.ts" />
import jjv = require('jjv');
import jjve = require('jjve');
var env: jjv.Env = jjv();
var je: jjve.Env = jjve(env);
var schema = {
type: 'object',
properties: {
ok: {
type: 'boolean',
},
},
};
var data = { ok: 1 };
var result = env.validate(schema, data);
if (result) {
var errors = je(schema, data, result);
console.log(JSON.stringify(errors, null, 4));
}
errors.forEach(error =>
console.log(
'code: %s, message: %s, data: %s, path: %s',
error.code,
error.message,
error.data,
error.path));
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for JJVE v0.4.0
// Project: https://github.com/silas/jjve
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jjv/jjv.d.ts" />
declare module 'jjve' {
import jjv = require('jjv');
function jjve(jjv: jjv.Env): jjve.Env;
module jjve {
interface Issue {
code: string;
message: string;
data: any;
path: string;
}
interface Env {
(schema: Object, data: any, errors: jjv.Errors): Issue[];
}
}
export = jjve;
}
+1 -1
View File
@@ -6,7 +6,7 @@
/// <reference path="../jquery/jquery.d.ts" />
interface JQueryAddressStatic {
();
(): any;
/**
* Binds any supported event type to a function with support for an optional map of data.
*/
+5 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: AndrewGaspar <https://github.com/AndrewGaspar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "less" {
declare module less {
class LessError {
constructor(e: Error, env);
@@ -550,3 +550,7 @@ declare module "less" {
export var version: number[];
}
declare module "less" {
export = less;
}
+2 -1
View File
@@ -7,7 +7,7 @@ var num: string;
var str: string;
var strArr: string[];
var args: string[];
var obj: Object;
var obj: minimist.ParsedArgs;
var opts: Opts;
opts.string = strArr;
@@ -25,3 +25,4 @@ opts.default = {
obj = minimist();
obj = minimist(strArr);
obj = minimist(strArr, opts);
var remainingArgCount = obj._.length;
+5 -1
View File
@@ -4,7 +4,7 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'minimist' {
function minimist(args?: string[], opts?: minimist.Opts):Object;
function minimist(args?: string[], opts?: minimist.Opts): minimist.ParsedArgs;
module minimist {
export interface Opts {
@@ -20,6 +20,10 @@ declare module 'minimist' {
// an object mapping string argument names to default values
default?: {[key:string]: any};
}
export interface ParsedArgs {
_: string[];
}
}
export = minimist;
+2
View File
@@ -124,6 +124,8 @@ moment().isoWeek();
moment().isoWeek(45);
moment().isoWeeks();
moment().isoWeeks(45);
moment().dayOfYear();
moment().dayOfYear(45);
var getMilliseconds: number = moment().milliseconds();
var getSeconds: number = moment().seconds();
+2
View File
@@ -210,6 +210,8 @@ interface Moment {
isoWeeks(d: number): Moment;
weeksInYear(): number;
isoWeeksInYear(): number;
dayOfYear(): number;
dayOfYear(d: number): Moment;
from(f: Moment): string;
from(f: Moment, suffix: boolean): string;
+2
View File
@@ -364,3 +364,5 @@ schema.virtual('display_name')
.get(function(): string { return this.name; })
.set((value: string): void => {});
var id : mongoose.Types.ObjectId;
var s = id.toHexString();
+3 -1
View File
@@ -78,7 +78,9 @@ declare module "mongoose" {
set(fn: Function): VirtualType;
}
export module Types {
export class ObjectId {}
export class ObjectId {
toHexString(): string;
}
}
export class Schema {
+72
View File
@@ -0,0 +1,72 @@
/// <reference path='multiparty.d.ts' />
/// <reference path='../node/node.d.ts' />
import multiparty = require('multiparty');
import http = require('http');
import util = require('util');
http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) {
if (req.url === '/upload' && req.method === 'POST') {
var count = 0;
var form = new multiparty.Form();
// Errors may be emitted
// Note that if you are listening to 'part' events, the same error may be
// emitted from the `form` and the `part`.
form.on('error', function (err: Error) {
console.log('Error parsing form: ' + err);
});
// Parts are emitted when parsing the form
form.on('part', function (part: multiparty.Part) {
// You *must* act on the part by reading it
// NOTE: if you want to ignore it, just call "part.resume()"
if (!!part.filename) {
// filename is exists when this is a file
count++;
console.log('got field named ' + part.name + ' and got file named ' + part.filename);
// ignore file's content here
part.resume();
} else {
// filename doesn't exist when this is a field and not a file
console.log('got field named ' + part.name);
// ignore field's content
part.resume();
}
part.on('error', function (err: Error) {
// decide what to do
console.log('Error on part event: ' + err);
});
});
form.on('progress', function (bytesReceived: number, bytesExpected: number) {
// decide what to do
console.log('BytesReceived: ' + bytesReceived, 'BytesExpected: ', bytesExpected);
});
form.on('field', function (name: string, value: string) {
// decide what to do
console.log('Field Name: ' + name + ', Field Value: ' + value);
});
// Close emitted after form parsed
form.on('close', function () {
console.log('Upload completed!');
res.end('Received ' + count + ' files');
});
// Parse req
form.parse(req);
}
// show a file upload form
res.writeHead(200, {'content-type': 'text/html'});
res.end(
'<form action="/upload" enctype="multipart/form-data" method="post">' +
'<input type="text" name="title"><br>' +
'<input type="file" name="upload" multiple="multiple"><br>' +
'<input type="submit" value="Upload">' +
'</form>'
);
}).listen(8080);
+111
View File
@@ -0,0 +1,111 @@
// Type definitions for node-multiparty
// Project: https://github.com/andrewrk/node-multiparty
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../node/node.d.ts' />
declare module "multiparty" {
import http = require('http');
import events = require('events');
import stream = require('stream');
export class Form extends events.EventEmitter {
constructor(options?: FormOptions);
/**
* Parses an incoming node.js request containing form data.
* This will cause form to emit events based off the incoming request
* @param request
* @param callback
*/
parse(request: http.ServerRequest, callback?: (error: Error, fields: any, files: any) => any): void;
}
export interface File {
/**
* same as name - the field name for this file
*/
fieldName: string;
/**
* the filename that the user reports for the file
*/
originalFileName: string;
/**
* the absolute path of the uploaded file on disk
*/
path: string;
/**
* the HTTP headers that were sent along with this file
*/
headers: any;
/**
* size of the file in bytes
*/
size: number;
}
interface Part extends stream.Readable {
/**
* the headers for this part. For example, you may be interested in content-type
*/
headers: any;
/**
* the field name for this part
*/
name: string;
/**
* only if the part is an incoming file
*/
filename: string;
/**
* the byte offset of this part in the request body
*/
byteOffset: number;
/**
* assuming that this is the last part in the request, this is the size of this part in bytes.
* You could use this, for example, to set the Content-Length header if uploading to S3.
* If the part had a Content-Length header then that value is used here instead.
*/
byteCount: number;
}
export interface FormOptions {
/**
* sets encoding for the incoming form fields. Defaults to utf8.
*/
encoding?:string;
/**
* Limits the amount of memory all fields (not files) can allocate in bytes.
* If this value is exceeded, an error event is emitted. The default size is 2MB.
*/
maxFieldsSize?:number;
/**
* Limits the number of fields that will be parsed before emitting an error event.
* A file counts as a field in this case. Defaults to 1000.
*/
maxFields?:number;
/**
* Only relevant when autoFiles is true.
* Limits the total bytes accepted for all files combined.
* If this value is exceeded, an error event is emitted.
* The default is Infinity.
*/
maxFilesSize?:number;
/**
* Enables field events and disables part events for fields.
* This is automatically set to true if you add a field listener.
*/
autoFields?:boolean;
/**
* Enables file events and disables part events for files.
* This is automatically set to true if you add a file listener.
*/
autoFiles?:boolean;
/**
* Only relevant when autoFiles is true.
* The directory for placing file uploads in.
* You can move them later using fs.rename(). Defaults to os.tmpDir().
*/
uploadDir?:string;
}
}
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="./ngprogress.d.ts" />
var ngProgress: NgProgress.INgProgress = <any> {};
ngProgress.start();
ngProgress.height('10px');
ngProgress.color('red');
var statusResult: number = ngProgress.status();
ngProgress.stop();
ngProgress.set(50);
ngProgress.reset();
ngProgress.complete();
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for ngProgress 1.0.7
// Project: http://victorbjelkholm.github.io/ngProgress/
// Definitions by: Martin McWhorter <https://github.com/martinmcwhorter>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module NgProgress {
export interface INgProgress {
start(): void;
height(height: string): void;
color(color: string): void;
status(): number;
stop(): void;
set(value: number): void;
reset(): void;
complete(): void;
}
}
-1
View File
@@ -1 +0,0 @@
-6
View File
@@ -1,6 +0,0 @@
// Type definitions for PhoneJS
// Project: http://js.devexpress.com/MobileDevelopment/
// Definitions by: DevExpress Inc. <http://devexpress.com/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../devextreme/dx.phonejs.d.ts" />
+40 -14
View File
@@ -1,7 +1,36 @@
/// <reference path="react.d.ts" />
import React = require("react/addons");
// TestUtils
var isImportant: boolean;
var isRead: boolean;
var classSet: React.ClassSet = {
"message": true,
"message-important": isImportant,
"message-read": isRead
};
var cx = React.addons.classSet;
var classes: string = cx(classSet);
//
// React.addons (Transitions)
// --------------------------------------------------------------------------
React.createFactory(React.addons.TransitionGroup)({ component: "div" });
React.createFactory(React.addons.CSSTransitionGroup)({
component: React.createClass({
render: (): React.ReactElement<any> => null
}),
childFactory: (c) => c,
transitionName: "transition",
transitionAppear: false,
transitionEnter: true,
transitionLeave: true
});
//
// React.addons.TestUtils
// --------------------------------------------------------------------------
var that: React.CompositeComponent<any, any>;
var node = that.refs["input"].getDOMNode();
React.addons.TestUtils.Simulate.click(node);
@@ -16,27 +45,24 @@ interface GreetingState {
}
interface Greeting extends React.CompositeComponent<GreetingProps, GreetingState> {
}
var Greeting = React.createClass({displayName: "Greeting",
var Greeting = React.createClass({
displayName: "Greeting",
getInitialState: function() {
return {morning: true};
},
render: function() {
var me = <Greeting>this;
return React.DOM.div(null, (me.state.morning ? "Hello" : "Goodbye "), me.props.name);
return React.DOM.div(
null,
me.state.morning ? "Hello " : "Goodbye ",
me.props.name);
}
});
var root = React.addons.TestUtils.renderIntoDocument(React.createElement(Greeting, {name: "John"}));
var greeting = <Greeting>React.addons.TestUtils.findRenderedComponentWithType(root, Greeting);
var root = React.addons.TestUtils.renderIntoDocument(
React.createElement(Greeting, {name: "John"}));
var greeting = <Greeting>React.addons.TestUtils
.findRenderedComponentWithType(root, Greeting);
greeting.setState({
morning: false
});
var isImportant: boolean;
var isRead: boolean;
var cx = React.addons.classSet;
var classes: string = cx({
"message": true,
"message-important": isImportant,
"message-read": isRead
});
+43 -2
View File
@@ -18,6 +18,8 @@ interface MyComponent extends React.CompositeComponent<Props, State> {
}
var props: Props = {
key: 42,
ref: "myComponent42",
hello: "world",
foo: 42,
bar: true
@@ -60,7 +62,7 @@ var reactClass: React.ComponentClass<Props> = React.createClass<Props>({
var reactElement: React.ReactElement<Props> =
React.createElement<Props>(reactClass, props);
var reactFactory: React.Factory<Props> =
var reactFactory: React.ComponentFactory<Props> =
React.createFactory<Props>(reactClass);
var component: React.Component<Props> =
@@ -116,7 +118,34 @@ var myComponent = <MyComponent>compComponent;
myComponent.reset();
//
// PropTypes
// Attributes
// --------------------------------------------------------------------------
var children = ["Hello world", [null], React.DOM.span(null)];
var divStyle = { // CSSProperties
flex: "1 1 main-size",
backgroundImage: "url('hello.png')"
};
var htmlAttr: React.HTMLAttributes = {
key: 36,
ref: "htmlComponent",
children: children,
className: "test-attr",
style: divStyle,
onClick: (event: React.MouseEvent) => {
event.preventDefault();
event.stopPropagation();
},
dangerouslySetInnerHTML: {
__html: "<strong>STRONG</strong>"
}
};
React.DOM.div(htmlAttr);
React.DOM.span(htmlAttr);
React.DOM.input(htmlAttr);
//
// React.PropTypes
// --------------------------------------------------------------------------
var PropTypesSpecification: React.ComponentSpec<any, any> = {
@@ -156,6 +185,18 @@ var PropTypesSpecification: React.ComponentSpec<any, any> = {
}
};
//
// React.Children
// --------------------------------------------------------------------------
var childMap: { [key: string]: number } =
React.Children.map<number>(children, (child) => { return 42; });
React.Children.forEach(children, (child) => {});
var nChildren: number = React.Children.count(children);
var onlyChild = React.Children.only([null, [[["Hallo"], true]], false, {
test: null
}]);
//
// Example from http://facebook.github.io/react/
// --------------------------------------------------------------------------
+39 -30
View File
@@ -19,7 +19,6 @@ declare module React {
interface ReactHTMLElement extends ReactElement<HTMLAttributes> {}
interface ReactSVGElement extends ReactElement<SVGAttributes> {}
interface ComponentElement<P> extends ReactElement<P> {}
//
// React Nodes
@@ -27,7 +26,10 @@ declare module React {
// type ReactText = string | number;
// type Fragment = ReactNode[];
// type ReactNode = ReactElement<any, any> | Fragment | ReactText;
// type ReactNode = ReactElement<any> | Fragment | ReactText | KeyMap;
// interface KeyMap {
// [key: string]: ReactNode;
// }
//
// React Components
@@ -49,13 +51,12 @@ declare module React {
// ReactElement Factories
// ----------------------------------------------------------------------
interface Factory<P> {
interface ComponentFactory<P> {
(props?: P, ...children: any/*ReactNode*/[]): ReactElement<P>;
}
interface HTMLFactory extends Factory<HTMLAttributes> {}
interface SVGFactory extends Factory<SVGAttributes> {}
interface ComponentFactory<P> extends Factory<P> {}
interface HTMLFactory extends ComponentFactory<HTMLAttributes> {}
interface SVGFactory extends ComponentFactory<SVGAttributes> {}
//
// Top-Level API
@@ -64,8 +65,8 @@ declare module React {
interface TopLevelAPI {
createClass<P>(spec: ComponentSpec<P, any>): ComponentClass<P>;
createElement<P>(type: any/*ReactType*/, props: P, ...children: any/*ReactNode*/[]): ReactElement<P>;
createFactory<P>(componentClass: ComponentClass<P>): Factory<P>;
render<P>(element: ReactElement<P>, container: Element, callback?: () => void): Component<P>;
createFactory<P>(componentClass: ComponentClass<P>): ComponentFactory<P>;
render<P>(element: ReactElement<P>, container: Element, callback?: () => any): Component<P>;
unmountComponentAtNode(container: Element): boolean;
renderToString(element: ReactElement<any>): string;
renderToStaticMarkup(element: ReactElement<any>): string;
@@ -85,8 +86,8 @@ declare module React {
isMounted(): boolean;
props: P;
setProps(nextProps: P, callback?: () => void): void;
replaceProps(nextProps: P, callback?: () => void): void;
setProps(nextProps: P, callback?: () => any): void;
replaceProps(nextProps: P, callback?: () => any): void;
}
interface DOMComponent<P> extends Component<P> {
@@ -98,9 +99,9 @@ declare module React {
interface CompositeComponent<P, S> extends Component<P>, ComponentSpec<P, S> {
state: S;
setState(nextState: S, callback?: () => void): void;
replaceState(nextState: S, callback?: () => void): void;
forceUpdate(callback?: () => void): void;
setState(nextState: S, callback?: () => any): void;
replaceState(nextState: S, callback?: () => any): void;
forceUpdate(callback?: () => any): void;
refs: {
[key: string]: Component<any>
};
@@ -241,7 +242,7 @@ declare module React {
export interface ReactAttributes {
children?: any; // ReactNode
key?: string;
key?: any; // number | string
ref?: string;
// Event Attributes
@@ -287,7 +288,7 @@ declare module React {
interface CSSProperties {
columnCount?: number;
flex?: number;
flex?: any; // number | string
flexGrow?: number;
flexShrink?: number;
fontWeight?: number;
@@ -303,8 +304,6 @@ declare module React {
// SVG-related properties
fillOpacity?: number;
strokeOpacity?: number;
[key: string]: any; // number | string
}
interface HTMLAttributes extends ReactAttributes {
@@ -638,29 +637,39 @@ declare module React {
// React.Children
// ----------------------------------------------------------------------
// type Child = ReactElement<any> | ReactText;
interface ReactChildren {
map<T>(children: any/*ReactNode*/, fn: (child: any/*ReactNode*/) => T): { [key:string]: T };
forEach(children: any/*ReactNode*/, fn: (child: any/*ReactNode*/) => any): void;
map<T>(children: any/*ReactNode*/, fn: (child: any/*Child*/) => T): { [key:string]: T };
forEach(children: any/*ReactNode*/, fn: (child: any/*Child*/) => any): void;
count(children: any/*ReactNode*/): number;
only(children: any/*ReactNode*/): any;
only(children: any/*ReactNode*/): any/*Child*/;
}
//
// React.addons
// ----------------------------------------------------------------------
interface ClassSet {
[key: string]: boolean;
}
//
// React.addons (Transitions)
// ----------------------------------------------------------------------
interface CSSTransitionGroupProps {
interface TransitionGroupProps {
component?: any; // ReactType
childFactory?: (child: ReactElement<any>) => ReactElement<any>;
}
interface CSSTransitionGroupProps extends TransitionGroupProps {
transitionName: string;
transitionAppear?: boolean;
transitionEnter?: boolean;
transitionLeave?: boolean;
}
interface TransitionGroupProps {
component?: any; // ReactType
childFactory?: (child: ReactElement<any>) => ReactElement<any>;
}
interface CSSTransitionGroup extends ComponentClass<CSSTransitionGroupProps> {}
interface TransitionGroup extends ComponentClass<TransitionGroupProps> {}
@@ -869,11 +878,11 @@ declare module React {
PureRenderMixin: PureRenderMixin;
TransitionGroup: TransitionGroup;
batchedUpdates<A, B>(callback: (a: A, b: B) => void, a: A, b: B): void;
batchedUpdates<A>(callback: (a: A) => void, a: A): void;
batchedUpdates(callback: () => void): void;
batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
batchedUpdates<A>(callback: (a: A) => any, a: A): void;
batchedUpdates(callback: () => any): void;
classSet(cx: { [key: string]: boolean }): string;
classSet(cx: ClassSet): string;
cloneWithProps<P>(element: ReactElement<P>, props: P): ReactElement<P>;
update(value: any[], spec: UpdateArraySpec): any[];
+1 -1
View File
@@ -15,7 +15,7 @@ client({ path: '/data.json' }).then(function(response) {
console.log('response: ', response);
});
client = rest.wrap(mime).wrap(errorCode, { code: 500 });
client = rest.wrap(mime, { mime: 'application/json' }).wrap(errorCode, { code: 500 });
client({ path: '/data.json' }).then(
function(response) {
console.log('response: ', response);
+1 -1
View File
@@ -14,7 +14,7 @@ declare module "rest" {
function rest(request: rest.Request): rest.ResponsePromise;
module rest {
export function wrap(interceptor: Interceptor): Client;
export function wrap(interceptor: Interceptor, config?: any): Client;
export interface Request {
method?: string;
+5 -3
View File
@@ -1,16 +1,16 @@
// Type definitions for stripe
// Type definitions for stripe
// Project: https://stripe.com/
// Definitions by: Eric J. Smith <https://github.com/ejsmith/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface StripeStatic {
setPublishableKey(key: string);
createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void);
validateCardNumber(cardNumber: string): boolean;
validateExpiry(month: string, year: string): boolean;
validateCVC(cardCVC: string): boolean;
cardType(cardNumber: string): string;
getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void);
card: StripeCardData;
}
interface StripeTokenData {
@@ -57,6 +57,8 @@ interface StripeCardData {
address_state?: string;
address_zip?: string;
address_country?: string;
createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void);
}
declare var Stripe: StripeStatic;
declare var Stripe: StripeStatic;
+153
View File
@@ -1,5 +1,9 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="when.d.ts" />
import fs = require('fs');
import dns = require('dns');
import when = require("when");
class ForeignPromise<T> {
@@ -12,6 +16,7 @@ class ForeignPromise<T> {
var promise: when.Promise<number>;
var foreign = new ForeignPromise<number>(1);
var error = new Error("boom!");
var example: () => void;
// TODO: with TypeScript 1.4 a lot of these functions should change to use PromiseOrValue<T>
// type PromiseOrValue<T> = Promise<T> | T;
@@ -182,3 +187,151 @@ status = when(1).inspect()
promise = when(1).with(2);
promise = when(1).withThis(2);
/* * * * * * * * *
* when/node *
* * * * * * * * */
import nodefn = require('when/node');
/* node.lift */
// TODO: Again it's not possible to represent the return type of node.lift without union types.
var nodeFn0 = (callback: (err: any, result: number) => void) => callback(null, 0);
var nodeFn1 = (a: number, callback: (err: any, result: number) => void) => callback(null, a);
var nodeFn2 = (a: number, b: number, callback: (err: any, result: number) => void) => callback(null, a + b);
var nodeFn3 = (a: number, b: number, c: number, callback: (err: any, result: number) => void) => callback(null, a + b + c);
var promiseFunc0: () => when.Promise<number> = nodefn.lift(nodeFn0);
var promiseFunc1: (a: when.Promise<number>) => when.Promise<number> = nodefn.lift(nodeFn1);
var promiseFunc2: (a: when.Promise<number>, b: when.Promise<number>) => when.Promise<number> = nodefn.lift(nodeFn2);
var promiseFunc3: (a: when.Promise<number>, b: when.Promise<number>, c: when.Promise<number>) => when.Promise<number> = nodefn.lift(nodeFn3);
example = function() {
var resolveAddress = nodefn.lift(dns.resolve);
when.join(
resolveAddress(when('twitter.com')),
resolveAddress(when('facebook.com')),
resolveAddress(when('google.com'))
).then((addresses) => {
// All addresses resolved
}).catch((reason) => {
// At least one of the lookups failed
});
}
/* node.liftAll */
// Cannot be represented?
example = function() {
// Lift the entire dns API
var promisedDns = nodefn.liftAll(dns);
when.join(
promisedDns.resolve("twitter.com"),
promisedDns.resolveNs("facebook.com"),
promisedDns.resolveMx("google.com")
).then((addresses) => {
// All addresses resolved
}).catch((reason) => {
// At least one of the lookups failed
});
}
example = function() {
// Lift all of the fs methods, but name them with an 'Async' suffix
var promisedFs = nodefn.liftAll(fs, (promisedFs: any, liftedFunc: Function, name: string) => {
promisedFs[name + 'Async'] = liftedFunc;
return promisedFs;
});
promisedFs.readFileAsync('file.txt').done(console.log.bind(console));
}
example = function() {
// Lift all of the fs methods, but name them with an 'Async' suffix
// and add them back onto fs!
var promisedFs = nodefn.liftAll(fs, (promisedFs: any, liftedFunc: Function, name: string) => {
promisedFs[name + 'Async'] = liftedFunc;
return promisedFs;
}, fs);
if (promisedFs === fs) {
promisedFs.readFileAsync('file.txt').done(console.log.bind(console));
}
}
/* node.call */
promise = nodefn.call(nodeFn0);
promise = nodefn.call(nodeFn1, 1);
promise = nodefn.call(nodeFn1, when(1));
promise = nodefn.call(nodeFn2, 1, 2);
promise = nodefn.call(nodeFn2, 1, when(2));
promise = nodefn.call(nodeFn2, when(1), 2);
promise = nodefn.call(nodeFn2, when(1), when(2));
promise = nodefn.call(nodeFn3, 1, 2, 3);
promise = nodefn.call(nodeFn3, 1, when(2), 3);
promise = nodefn.call(nodeFn3, when(1), 2, 3);
promise = nodefn.call(nodeFn3, when(1), when(2), 3);
promise = nodefn.call(nodeFn3, 1, 2, when(3));
promise = nodefn.call(nodeFn3, 1, when(2), when(3));
promise = nodefn.call(nodeFn3, when(1), 2, when(3));
promise = nodefn.call(nodeFn3, when(1), when(2), when(3));
example = function () {
var loadPasswd = nodefn.call(fs.readFile, '/etc/passwd');
loadPasswd.done(
(passwd: Buffer) => console.log('Contents of /etc/passwd:\n' + passwd),
(error: any) => console.log('Something wrong happened: ' + error));
};
/* node.apply */
promise = nodefn.apply(nodeFn2, [1, 2]);
example = function () {
var loadPasswd = nodefn.apply(fs.readFile, ['/etc/passwd']);
loadPasswd.done(
(passwd: Buffer) => console.log('Contents of /etc/passwd:\n' + passwd),
(error: any) => console.log('Something wrong happened: ' + error));
};
/* node.liftCallback */
example = function () {
var fetchData: (key: string) => when.Promise<number>;
var handleData: (err: any, result: number) => void;
var handlePromisedData: (result: when.Promise<number>) => when.Promise<number>;
handlePromisedData = nodefn.liftCallback(handleData);
handlePromisedData(fetchData('thing'));
};
/* node.bindCallback */
example = function () {
var fetchData: (key: string) => when.Promise<number>;
var handleData: (err: any, result: number) => void;
nodefn.bindCallback(fetchData('thing'), handleData);
};
/* node.createCallback */
example = function () {
when.promise((resolve, reject) =>
nodeFn2(1, 2, nodefn.createCallback({ resolve: resolve, reject: reject })))
.then(
(value: number) => console.log(value),
(err: any) => console.error(err));
};
+53
View File
@@ -163,3 +163,56 @@ declare module When {
declare module "when" {
export = When;
}
declare module "when/node" {
import when = require('when');
function lift<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): () => when.Promise<TResult>;
function lift<TArg1, TResult>(fn: (arg1: TArg1, callback: (err: any, result: TResult) => void) => void): (arg1: when.Promise<TArg1>) => when.Promise<TResult>;
function lift<TArg1, TArg2, TResult>(fn: (arg1: TArg1, arg2: TArg2, callback: (err: any, result: TResult) => void) => void): (arg1: when.Promise<TArg1>, arg2: when.Promise<TArg2>) => when.Promise<TResult>;
function lift<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void): (arg1: when.Promise<TArg1>, arg2: when.Promise<TArg2>, arg3: when.Promise<TArg3>) => when.Promise<TResult>;
function liftAll(srcApi: any, transform?: (destApi: any, liftedFunc: Function, name: string) => any, destApi?: any): any;
function call<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): when.Promise<TResult>;
function call<TArg1, TResult>(fn: (arg1: TArg1, callback: (err: any, result: TResult) => void) => void, arg1: TArg1): when.Promise<TResult>;
function call<TArg1, TResult>(fn: (arg1: TArg1, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>): when.Promise<TResult>;
function call<TArg1, TArg2, TResult>(fn: (arg1: TArg1, arg2: TArg2, callback: (err: any, result: TResult) => void) => void, arg1: TArg1, arg2: TArg2): when.Promise<TResult>;
function call<TArg1, TArg2, TResult>(fn: (arg1: TArg1, arg2: TArg2, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>, arg2: TArg2): when.Promise<TResult>;
function call<TArg1, TArg2, TResult>(fn: (arg1: TArg1, arg2: TArg2, callback: (err: any, result: TResult) => void) => void, arg1: TArg1, arg2: when.Promise<TArg2>): when.Promise<TResult>;
function call<TArg1, TArg2, TResult>(fn: (arg1: TArg1, arg2: TArg2, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>, arg2: when.Promise<TArg2>): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: TArg1, arg2: TArg2, arg3: TArg3): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: TArg1, arg2: TArg2, arg3: when.Promise<TArg3>): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: TArg1, arg2: when.Promise<TArg2>, arg3: TArg3): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: TArg1, arg2: when.Promise<TArg2>, arg3: when.Promise<TArg3>): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>, arg2: TArg2, arg3: TArg3): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>, arg2: TArg2, arg3: when.Promise<TArg3>): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>, arg2: when.Promise<TArg2>, arg3: TArg3): when.Promise<TResult>;
function call<TArg1, TArg2, TArg3, TResult>(fn: (arg1: TArg1, arg2: TArg2, arg3: TArg3, callback: (err: any, result: TResult) => void) => void, arg1: when.Promise<TArg1>, arg2: when.Promise<TArg2>, arg3: when.Promise<TArg3>): when.Promise<TResult>;
function apply<TResult>(fn: (callback: (err: any, result: TResult) => void) => void, args: any[]): when.Promise<TResult>;
function apply<TResult>(fn: (arg1: any, callback: (err: any, result: TResult) => void) => void, args: any[]): when.Promise<TResult>;
function apply<TResult>(fn: (arg1: any, arg2: any, callback: (err: any, result: TResult) => void) => void, args: any[]): when.Promise<TResult>;
function apply<TResult>(fn: (arg1: any, arg2: any, arg3: any, callback: (err: any, result: TResult) => void) => void, args: any[]): when.Promise<TResult>;
function liftCallback<TArg>(callback: (err: any, arg: TArg) => void): (value: when.Promise<TArg>) => when.Promise<TArg>;
function bindCallback<TArg>(arg: when.Promise<TArg>, callback: (err: any, arg: TArg) => void): when.Promise<TArg>;
interface Resolver<T> {
reject(reason: any): void;
resolve(value?: T): void;
resolve(value?: when.Promise<T>): void;
}
function createCallback<TArg>(resolver: Resolver<TArg>): (err: any, arg: TArg) => void;
}