mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-30 11:14:27 +08:00
Merge branch 'master' into node-config
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/// <reference path="./amazon-product-api.d.ts" />
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
import amazon = require('amazon-product-api');
|
||||
|
||||
var client = amazon.createClient({
|
||||
awsId: process.env.AWS_ACCESS_KEY_ID,
|
||||
awsSecret: process.env.AWS_SECRET,
|
||||
awsTag: process.env.AWS_ASSOCIATE_TAG
|
||||
});
|
||||
|
||||
|
||||
// Item Search
|
||||
|
||||
var searchQuery = {
|
||||
director: 'Quentin Tarantino',
|
||||
actor: 'Samuel L. Jackson',
|
||||
searchIndex: 'DVD',
|
||||
audienceRating: 'R',
|
||||
responseGroup: 'ItemAttributes,Offers,Images'
|
||||
};
|
||||
|
||||
client.itemSearch(searchQuery).then((results) => {
|
||||
console.log(getResultCount(results) + " search results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.itemSearch(searchQuery, (err, results) => {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
console.log(getResultCount(results) + " search results");
|
||||
});
|
||||
|
||||
|
||||
// Item Lookup
|
||||
|
||||
var lookupQuery = {
|
||||
itemId: 'B00008OE6I',
|
||||
idType: 'ASIN',
|
||||
responseGroup: 'OfferFull',
|
||||
Condition: 'All'
|
||||
};
|
||||
|
||||
client.itemLookup(lookupQuery).then((results) => {
|
||||
console.log(getResultCount(results) + " lookup results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.itemLookup(lookupQuery, (err, results) => {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
console.log(getResultCount(results) + " lookup results");
|
||||
});
|
||||
|
||||
// Browse Node Lookup
|
||||
|
||||
var nodeLookupQuery = {
|
||||
browseNodeId: '2625373011'
|
||||
};
|
||||
|
||||
client.browseNodeLookup(nodeLookupQuery).then((results) => {
|
||||
console.log(getResultCount(results) + " node lookup results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.browseNodeLookup(nodeLookupQuery, (err, results) => {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(getResultCount(results) + " node lookup results");
|
||||
});
|
||||
|
||||
function getResultCount(results: Object[]) {
|
||||
return results != undefined ? results.length : 0;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for amazon-product-api
|
||||
// Project: https://github.com/t3chnoboy/amazon-product-api
|
||||
// Definitions by: Matti Lehtinen <https://github.com/MattiLehtinen/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts"/>
|
||||
|
||||
declare module "amazon-product-api" {
|
||||
|
||||
interface ICredentials {
|
||||
awsId: string,
|
||||
awsSecret: string,
|
||||
awsTag: string
|
||||
}
|
||||
|
||||
interface IAmazonProductQueryCallback {
|
||||
(err: string, results: Object[]): void;
|
||||
}
|
||||
|
||||
interface IAmazonProductClient {
|
||||
itemSearch(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
|
||||
itemLookup(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
|
||||
browseNodeLookup(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
|
||||
}
|
||||
|
||||
export function createClient(credentials:ICredentials) : IAmazonProductClient;
|
||||
}
|
||||
Vendored
+6
@@ -106,6 +106,8 @@ declare module "express" {
|
||||
use(handler: ErrorRequestHandler): T;
|
||||
use(path: string, ...handler: RequestHandler[]): T;
|
||||
use(path: string, handler: ErrorRequestHandler): T;
|
||||
use(path: string[], ...handler: RequestHandler[]): T;
|
||||
use(path: string[], handler: ErrorRequestHandler[]): T;
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
@@ -410,6 +412,10 @@ declare module "express" {
|
||||
originalUrl: string;
|
||||
|
||||
url: string;
|
||||
|
||||
baseUrl: string;
|
||||
|
||||
app: Application;
|
||||
}
|
||||
|
||||
interface MediaType {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path="level-sublevel.d.ts" />
|
||||
|
||||
import levelup = require('levelup');
|
||||
import sublevel = require('level-sublevel');
|
||||
|
||||
var db = sublevel(levelup('./tmp/sublevel-example'));
|
||||
var sub = db.sublevel('stuff');
|
||||
|
||||
db.put('foo', 'bar', err => {});
|
||||
|
||||
sub.put('foo', 'bar', err => {});
|
||||
|
||||
db.pre((ch, add) => {
|
||||
add({
|
||||
key: ''+Date.now(),
|
||||
value: ch.key,
|
||||
type: 'put',
|
||||
prefix: sub
|
||||
})
|
||||
});
|
||||
|
||||
var sub1 = db.sublevel('SUB_1');
|
||||
var sub2 = db.sublevel('SUM_2');
|
||||
|
||||
sub1.batch([
|
||||
{ key: 'key', value: 'Value', type: 'put' },
|
||||
{ key: 'key', value: 'Value', type: 'put', prefix: sub2 }
|
||||
], err => { if (err) throw err; });
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for level-sublevel
|
||||
// Project: https://github.com/dominictarr/level-sublevel
|
||||
// Definitions by: Bas Pennings <https://github.com/basp/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../levelup/levelup.d.ts" />
|
||||
|
||||
interface Hook {
|
||||
(ch: any, add: (op: Batch|boolean) => void): void;
|
||||
}
|
||||
|
||||
interface Batch {
|
||||
prefix?: Sublevel;
|
||||
}
|
||||
|
||||
interface Sublevel extends LevelUp {
|
||||
sublevel(key: string): Sublevel;
|
||||
pre(hook: Hook): Function;
|
||||
}
|
||||
|
||||
declare module "level-sublevel" {
|
||||
function sublevel(levelup: LevelUp): Sublevel;
|
||||
export = sublevel;
|
||||
}
|
||||
Vendored
+2
-2
@@ -22,8 +22,8 @@ interface LevelUp {
|
||||
del(key: any, options ?: { keyEncoding?: string; sync?: boolean }, callback ?: (error: any) => any): void;
|
||||
|
||||
|
||||
batch(array: Batch[], options?: { keyEncoding?: string; valueEncoding?: string; sync?: boolean }, callback?: (error?: any)=>any);
|
||||
batch(array: Batch[], callback?: (error?: any)=>any);
|
||||
batch(array: Batch[], options?: { keyEncoding?: string; valueEncoding?: string; sync?: boolean }, callback?: (error?: any)=>any): void;
|
||||
batch(array: Batch[], callback?: (error?: any)=>any): void;
|
||||
batch():LevelUpChain;
|
||||
isOpen():boolean;
|
||||
isClosed():boolean;
|
||||
|
||||
+67
-1
@@ -71,8 +71,74 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
|
||||
console.error('Error happened calling Query: ' + err.name + " " + err.message);
|
||||
}
|
||||
else {
|
||||
console.info(requestStoredProcedureWithOutput.parameters.output.value);
|
||||
console.info(requestStoredProcedureWithOutput.parameters['output'].value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function test_table() {
|
||||
var table = new sql.Table('#temp_table');
|
||||
|
||||
table.create = true;
|
||||
|
||||
table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
|
||||
table.columns.add('type', sql.Int, { nullable: false });
|
||||
table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });
|
||||
|
||||
table.rows.add('name', 42, 3.50);
|
||||
table.rows.add('name2', 7, 3.14);
|
||||
}
|
||||
|
||||
|
||||
function test_promise_returns() {
|
||||
// Methods return a promises if the callback is omitted.
|
||||
var connection: sql.Connection = new sql.Connection(config);
|
||||
connection.connect().then(() => { });
|
||||
connection.close().then(() => { });
|
||||
|
||||
var preparedStatment = new sql.PreparedStatement(connection);
|
||||
preparedStatment.prepare("SELECT @myValue").then(() => { });
|
||||
preparedStatment.execute({ myValue: 1 }).then((recordSet) => { });
|
||||
preparedStatment.unprepare().then(() => { });
|
||||
|
||||
var transaction = new sql.Transaction(connection);
|
||||
transaction.begin().then(() => { });
|
||||
transaction.commit().then(() => { });
|
||||
transaction.rollback().then(() => { });
|
||||
|
||||
var request = new sql.Request();
|
||||
request.batch('create procedure #temporary as select * from table').then((recordset) => { });
|
||||
request.bulk(new sql.Table("table_name")).then(() => { });
|
||||
request.query('SELECT 1').then((recordset) => { });
|
||||
request.execute('procedure_name').then((recordset) => { });
|
||||
}
|
||||
|
||||
|
||||
function test_request_constructor() {
|
||||
// Request can be constructed with a connection, preparedStatment, transaction or no arguments
|
||||
var connection: sql.Connection = new sql.Connection(config);
|
||||
var preparedStatment = new sql.PreparedStatement(connection);
|
||||
var transaction = new sql.Transaction(connection);
|
||||
|
||||
var request1 = new sql.Request(connection);
|
||||
var request2 = new sql.Request(preparedStatment);
|
||||
var request3 = new sql.Request(transaction);
|
||||
var request4 = new sql.Request();
|
||||
}
|
||||
|
||||
function test_classes_extend_eventemitter() {
|
||||
var connection: sql.Connection = new sql.Connection(config);
|
||||
var transaction = new sql.Transaction();
|
||||
var request = new sql.Request();
|
||||
var preparedStatment = new sql.PreparedStatement();
|
||||
|
||||
connection.on('connect', () => { });
|
||||
transaction.on('begin', () => { });
|
||||
transaction.on('commit', () => { });
|
||||
transaction.on('rollback', () => { });
|
||||
request.on('done', () => { });
|
||||
request.on('error', () => { });
|
||||
|
||||
preparedStatment.on('error', () => { })
|
||||
}
|
||||
Vendored
+208
-62
@@ -1,53 +1,131 @@
|
||||
// Type definitions for mssql
|
||||
// Type definitions for mssql v2.2.0
|
||||
// Project: https://www.npmjs.com/package/mssql
|
||||
// Definitions by: COLSA Corporation <http://www.colsa.com/>
|
||||
// Definitions by: COLSA Corporation <http://www.colsa.com/>, Ben Farr <https://github.com/jaminfarr>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
declare module "mssql" {
|
||||
import events = require('events');
|
||||
|
||||
export var Date: any;
|
||||
export var DateTime: any;
|
||||
export var DateTime2: any;
|
||||
export var DateTimeOffset: any;
|
||||
export var SmallDateTime: any;
|
||||
export var Time: any;
|
||||
export var Char: any;
|
||||
export var VarChar:any;
|
||||
export var NChar: any;
|
||||
export var NVarChar: any;
|
||||
export var Text:any;
|
||||
export var NText:any;
|
||||
export var Xml: any;
|
||||
export var TinyInt:any;
|
||||
export var SmallInt:any;
|
||||
export var Int: any;
|
||||
export var BigInt:any;
|
||||
export var Decimal:any;
|
||||
export var Float:any;
|
||||
export var Real:any;
|
||||
export var SmallMoney:any;
|
||||
export var Money:any;
|
||||
export var Numeric:any;
|
||||
export var Bit: any;
|
||||
export var Binary: any;
|
||||
export var VarBinary: any;
|
||||
export var TVP: any;
|
||||
export var UniqueIdentifier: any;
|
||||
export var Image: any;
|
||||
export var UDT: any;
|
||||
export var Geography: any;
|
||||
export var Geometry: any;
|
||||
type sqlTypeWithNoParams = { type: sqlTypeFactoryWithNoParams }
|
||||
type sqlTypeWithLength = { type: sqlTypeFactoryWithLength, length: number }
|
||||
type sqlTypeWithScale = { type: sqlTypeFactoryWithScale, scale: number }
|
||||
type sqlTypeWithPrecisionScale = { type: sqlTypeFactoryWithPrecisionScale, precision: number, scale: number }
|
||||
type sqlTypeWithTvpType = { type: sqlTypeFactoryWithTvpType, tvpType: any }
|
||||
|
||||
export interface options {
|
||||
type sqlTypeFactoryWithNoParams = () => sqlTypeWithNoParams;
|
||||
type sqlTypeFactoryWithLength = (length?: number) => sqlTypeWithLength;
|
||||
type sqlTypeFactoryWithScale = (scale?: number) => sqlTypeWithScale;
|
||||
type sqlTypeFactoryWithPrecisionScale = (precision?: number, scale?: number) => sqlTypeWithPrecisionScale;
|
||||
type sqlTypeFactoryWithTvpType = (tvpType: any) => sqlTypeWithTvpType;
|
||||
|
||||
export var VarChar: sqlTypeFactoryWithLength;
|
||||
export var NVarChar: sqlTypeFactoryWithLength;
|
||||
export var Text: sqlTypeFactoryWithNoParams;
|
||||
export var Int: sqlTypeFactoryWithNoParams;
|
||||
export var BigInt: sqlTypeFactoryWithNoParams;
|
||||
export var TinyInt: sqlTypeFactoryWithNoParams;
|
||||
export var SmallInt: sqlTypeFactoryWithNoParams;
|
||||
export var Bit: sqlTypeFactoryWithNoParams;
|
||||
export var Float: sqlTypeFactoryWithNoParams;
|
||||
export var Numeric: sqlTypeFactoryWithPrecisionScale;
|
||||
export var Decimal: sqlTypeFactoryWithPrecisionScale;
|
||||
export var Real: sqlTypeFactoryWithNoParams;
|
||||
export var Date: sqlTypeFactoryWithNoParams;
|
||||
export var DateTime: sqlTypeFactoryWithNoParams;
|
||||
export var DateTime2: sqlTypeFactoryWithScale;
|
||||
export var DateTimeOffset: sqlTypeFactoryWithScale;
|
||||
export var SmallDateTime: sqlTypeFactoryWithNoParams;
|
||||
export var Time: sqlTypeFactoryWithScale;
|
||||
export var UniqueIdentifier: sqlTypeFactoryWithNoParams;
|
||||
export var SmallMoney: sqlTypeFactoryWithNoParams;
|
||||
export var Money: sqlTypeFactoryWithNoParams;
|
||||
export var Binary: sqlTypeFactoryWithNoParams;
|
||||
export var VarBinary: sqlTypeFactoryWithLength;
|
||||
export var Image: sqlTypeFactoryWithNoParams;
|
||||
export var Xml: sqlTypeFactoryWithNoParams;
|
||||
export var Char: sqlTypeFactoryWithLength;
|
||||
export var NChar: sqlTypeFactoryWithLength;
|
||||
export var NText: sqlTypeFactoryWithNoParams;
|
||||
export var TVP: sqlTypeFactoryWithTvpType;
|
||||
export var UDT: sqlTypeFactoryWithNoParams;
|
||||
export var Geography: sqlTypeFactoryWithNoParams;
|
||||
export var Geometry: sqlTypeFactoryWithNoParams;
|
||||
|
||||
export var TYPES: {
|
||||
VarChar: sqlTypeFactoryWithLength;
|
||||
NVarChar: sqlTypeFactoryWithLength;
|
||||
Text: sqlTypeFactoryWithNoParams;
|
||||
Int: sqlTypeFactoryWithNoParams;
|
||||
BigInt: sqlTypeFactoryWithNoParams;
|
||||
TinyInt: sqlTypeFactoryWithNoParams;
|
||||
SmallInt: sqlTypeFactoryWithNoParams;
|
||||
Bit: sqlTypeFactoryWithNoParams;
|
||||
Float: sqlTypeFactoryWithNoParams;
|
||||
Numeric: sqlTypeFactoryWithPrecisionScale;
|
||||
Decimal: sqlTypeFactoryWithPrecisionScale;
|
||||
Real: sqlTypeFactoryWithNoParams;
|
||||
Date: sqlTypeFactoryWithNoParams;
|
||||
DateTime: sqlTypeFactoryWithNoParams;
|
||||
DateTime2: sqlTypeFactoryWithScale;
|
||||
DateTimeOffset: sqlTypeFactoryWithScale;
|
||||
SmallDateTime: sqlTypeFactoryWithNoParams;
|
||||
Time: sqlTypeFactoryWithScale;
|
||||
UniqueIdentifier: sqlTypeFactoryWithNoParams;
|
||||
SmallMoney: sqlTypeFactoryWithNoParams;
|
||||
Money: sqlTypeFactoryWithNoParams;
|
||||
Binary: sqlTypeFactoryWithNoParams;
|
||||
VarBinary: sqlTypeFactoryWithLength;
|
||||
Image: sqlTypeFactoryWithNoParams;
|
||||
Xml: sqlTypeFactoryWithNoParams;
|
||||
Char: sqlTypeFactoryWithLength;
|
||||
NChar: sqlTypeFactoryWithLength;
|
||||
NText: sqlTypeFactoryWithNoParams;
|
||||
TVP: sqlTypeFactoryWithTvpType;
|
||||
UDT: sqlTypeFactoryWithNoParams;
|
||||
Geography: sqlTypeFactoryWithNoParams;
|
||||
Geometry: sqlTypeFactoryWithNoParams;
|
||||
};
|
||||
|
||||
export var MAX: number;
|
||||
export var fix: boolean;
|
||||
export var Promise: any;
|
||||
|
||||
|
||||
interface IMap extends Array<{js: any, sql: any }> {
|
||||
register(jstype: any, sql: any): void;
|
||||
}
|
||||
|
||||
export var map: IMap;
|
||||
|
||||
export var DRIVERS: string[];
|
||||
|
||||
type recordSet = any;
|
||||
type IIsolationLevel = number;
|
||||
|
||||
export var ISOLATION_LEVEL: {
|
||||
READ_UNCOMMITTED: IIsolationLevel
|
||||
READ_COMMITTED: IIsolationLevel
|
||||
REPEATABLE_READ: IIsolationLevel
|
||||
SERIALIZABLE: IIsolationLevel
|
||||
SNAPSHOT: IIsolationLevel
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
encrypt: boolean;
|
||||
}
|
||||
|
||||
export interface pool {
|
||||
|
||||
export interface IPool {
|
||||
min: number;
|
||||
max: number;
|
||||
idleTimeoutMillis: number;
|
||||
}
|
||||
|
||||
export var pool: IPool;
|
||||
|
||||
export interface config {
|
||||
driver?: string;
|
||||
user?: string;
|
||||
@@ -59,18 +137,26 @@ declare module "mssql" {
|
||||
connectionTimeout?: number;
|
||||
requestTimeout?: number;
|
||||
stream?: boolean;
|
||||
options?: options;
|
||||
pool?: pool;
|
||||
|
||||
options?: IOptions;
|
||||
pool?: IPool;
|
||||
}
|
||||
|
||||
export class Connection {
|
||||
|
||||
export class Connection extends events.EventEmitter {
|
||||
public connected: boolean;
|
||||
public connecting: boolean;
|
||||
public driver: string;
|
||||
public constructor(config: config, callback?: (err?: any) => void);
|
||||
public connect(): Promise<void>;
|
||||
public connect(callback: (err: any) => void): void;
|
||||
public close(): Promise<void>;
|
||||
public close(callback: (err: any) => void): void;
|
||||
}
|
||||
|
||||
public connect(callback?: (err?: any) => void): void;
|
||||
|
||||
public close(): void;
|
||||
export class ConnectionError implements Error {
|
||||
constructor(message: string, code?: any)
|
||||
public name: string;
|
||||
public message: string;
|
||||
public code: string;
|
||||
}
|
||||
|
||||
class columns {
|
||||
@@ -78,7 +164,7 @@ declare module "mssql" {
|
||||
}
|
||||
|
||||
class rows {
|
||||
public add(row: any): void;
|
||||
public add(...row: any[]): void;
|
||||
}
|
||||
|
||||
export class Table {
|
||||
@@ -86,37 +172,97 @@ declare module "mssql" {
|
||||
public columns: columns;
|
||||
public rows: rows;
|
||||
public constructor(tableName: string);
|
||||
|
||||
}
|
||||
|
||||
export class Request {
|
||||
interface IRequestParameters {
|
||||
[name: string]: {
|
||||
name: string;
|
||||
type: any;
|
||||
io: number;
|
||||
value: any;
|
||||
length: number;
|
||||
scale: number;
|
||||
precision: number;
|
||||
tvpType: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class Request extends events.EventEmitter {
|
||||
public connection: Connection;
|
||||
public transaction: Transaction;
|
||||
public pstatement: PreparedStatement;
|
||||
public parameters: IRequestParameters;
|
||||
public verbose: boolean;
|
||||
public multiple: boolean;
|
||||
public canceled: boolean;
|
||||
public stream: any;
|
||||
public constructor(connection?: Connection);
|
||||
public execute(procedure: string, callback?: (err?: any, recordsets?: any, returnValue?: any) => void): void;
|
||||
public constructor(transaction: Transaction);
|
||||
public constructor(preparedStatement: PreparedStatement);
|
||||
public execute(procedure: string): Promise<recordSet>;
|
||||
public execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
|
||||
public input(name: string, value: any): void;
|
||||
public input(name: string, type: any, value: any): void;
|
||||
public output(name: string, type: any, value?: any): void;
|
||||
public pipe(stream: any): void;
|
||||
public query(command: string, callback?: (err?: any, recordset?: any) => void): void;
|
||||
public batch(batch: string, callback?: (err?: any, recordset?: any) => void): void;
|
||||
public bulk(table: Table, callback?: (err?: any, rowCount?: any) => void): void;
|
||||
public pipe(stream: NodeJS.WritableStream): void;
|
||||
public query(command: string): Promise<void>;
|
||||
public query(command: string, callback: (err?: any, recordset?: any) => void): void;
|
||||
public batch(batch: string): Promise<recordSet>;
|
||||
public batch(batch: string, callback: (err?: any, recordset?: any) => void): void;
|
||||
public bulk(table: Table): Promise<void>;
|
||||
public bulk(table: Table, callback: (err: any, rowCount: any) => void): void;
|
||||
public cancel(): void;
|
||||
public parameters: any;
|
||||
}
|
||||
|
||||
export class Transaction {
|
||||
export class RequestError implements Error {
|
||||
constructor(message: string, code?: any)
|
||||
public name: string;
|
||||
public message: string;
|
||||
public code: string;
|
||||
}
|
||||
|
||||
export class Transaction extends events.EventEmitter {
|
||||
public connection: Connection;
|
||||
public isolationLevel: IIsolationLevel;
|
||||
public constructor(connection?: Connection);
|
||||
public begin(isolationLevel?: any, callback?: (err?: any) => void): void;
|
||||
public begin(callback?: (err?: any) => void): void;
|
||||
public commit(callback?: (err?: any) => void): void;
|
||||
public rollback(callback?: (err?: any) => void): void;
|
||||
public begin(isolationLevel?: IIsolationLevel): Promise<void>;
|
||||
public begin(isolationLevel?: IIsolationLevel, callback?: (err?: any) => void): void;
|
||||
public commit(): Promise<void>;
|
||||
public commit(callback: (err?: any) => void): void;
|
||||
public rollback(): Promise<void>;
|
||||
public rollback(callback: (err?: any) => void): void;
|
||||
}
|
||||
|
||||
export class PreparedStatement {
|
||||
export class TransactionError implements Error {
|
||||
constructor(message: string, code?: any)
|
||||
public name: string;
|
||||
public message: string;
|
||||
public code: string;
|
||||
}
|
||||
|
||||
export class PreparedStatement extends events.EventEmitter {
|
||||
public connection: Connection;
|
||||
public transaction: Transaction;
|
||||
public prepared: boolean;
|
||||
public statement: string;
|
||||
public parameters: IRequestParameters;
|
||||
public multiple: boolean;
|
||||
public stream: any;
|
||||
public constructor(connection?: Connection);
|
||||
public input(name: string, type: any): void;
|
||||
public output(name: string, type: any): void;
|
||||
public prepare(statement: string, callback?: (err?: any) => void): void;
|
||||
public execute(values: any, callback?: (err?: any) => void): void;
|
||||
public unprepare(callback?: (err?: any) => void): void;
|
||||
public prepare(statement?: string): Promise<void>;
|
||||
public prepare(statement?: string, callback?: (err?: any) => void): void;
|
||||
public execute(values: Object): Promise<recordSet>;
|
||||
public execute(values: Object, callback: (err: any, recordSet: recordSet) => void): void;
|
||||
public unprepare(): Promise<void>;
|
||||
public unprepare(callback: (err?: any) => void): void;
|
||||
}
|
||||
|
||||
export class PreparedStatementError implements Error {
|
||||
constructor(message: string, code?: any)
|
||||
public name: string;
|
||||
public message: string;
|
||||
public code: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/// <reference path="./qs.d.ts" />
|
||||
|
||||
import qs = require('qs');
|
||||
|
||||
qs.stringify({ a: 'b' });
|
||||
qs.stringify({ a: 'b', c: 'd' }, { delimiter: '&' });
|
||||
|
||||
qs.parse('a=b');
|
||||
qs.parse('a=b&c=d', { delimiter: '&' });
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for qs
|
||||
// Project: https://github.com/hapijs/qs
|
||||
// Definitions by: Roman Korneev <https://github.com/RWander>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module QueryString {
|
||||
interface IStringifyOptions {
|
||||
delimiter?: string;
|
||||
strictNullHandling?: boolean;
|
||||
skipNulls?: boolean;
|
||||
encode?: boolean;
|
||||
filter?: any;
|
||||
arrayFormat?: any;
|
||||
indices?: string;
|
||||
}
|
||||
|
||||
interface IParseOptions {
|
||||
delimiter?: string;
|
||||
depth?: number;
|
||||
arrayLimit?: number;
|
||||
parseArrays?: boolean;
|
||||
allowDots?: boolean;
|
||||
plainObjects?: boolean;
|
||||
allowPrototypes?: boolean;
|
||||
parameterLimit?: number;
|
||||
strictNullHandling?: boolean;
|
||||
}
|
||||
|
||||
function stringify(obj: any, options?: IStringifyOptions): string;
|
||||
function parse(str: string, options?: IParseOptions): any;
|
||||
}
|
||||
|
||||
declare module "qs" {
|
||||
export = QueryString;
|
||||
}
|
||||
Vendored
-1
@@ -39,7 +39,6 @@ declare module RedlockTypes {
|
||||
servers: any[]; // array of redis.RedisClient
|
||||
|
||||
constructor(clients: any[], options?: RedlockOptions);
|
||||
//new (clients: any[], options?: IRedlockOptions);
|
||||
|
||||
acquire(resource: string, ttl: number, callback?: NodeifyCallback<Lock>): Promise<Lock>;
|
||||
lock(resource: string, ttl: number, callback?: NodeifyCallback<Lock>): Promise<Lock>;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/// <reference path="../socket.io/socket.io.d.ts"/>
|
||||
/// <reference path="socket.io.users.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
var httpServer = require('http').createServer(app);
|
||||
var io = require('socket.io')(httpServer);
|
||||
import ioUsers = require("socket.io.users");
|
||||
|
||||
|
||||
|
||||
ioUsers.Session(app, {
|
||||
"secret": "socket.io.users secret test",
|
||||
"resave": true,
|
||||
"saveUninitialized": true
|
||||
});
|
||||
|
||||
io.use(ioUsers.Middleware());
|
||||
|
||||
var users = ioUsers.Users.of("/");
|
||||
|
||||
|
||||
var userDisconnected = (user: ioUsers.User) => {
|
||||
console.log(user.get("username") + " has disconnected from all web browser windows or/and tabs");
|
||||
}
|
||||
|
||||
var setUsername = (user: ioUsers.User, data: any) => {
|
||||
console.log(user.ip + ' is for first time visiting our site. He/she wants ' + data.username + ' for username');
|
||||
user.set("username", data.username);
|
||||
}
|
||||
|
||||
var joinRoom = (user: ioUsers.User, roomToJoin: string) => {
|
||||
console.log(user.get("username") + ' joined to ' + roomToJoin);
|
||||
}
|
||||
|
||||
var leaveRoom = (user: ioUsers.User, roomToJoin: string) => {
|
||||
console.log(user.get("username") + ' joined to ' + roomToJoin);
|
||||
}
|
||||
|
||||
var sendMessage = (user: ioUsers.User, data: any) => {
|
||||
console.log(user.get("username") + 'send ' + data.content + ' to room: ' + data.room);
|
||||
}
|
||||
|
||||
users.on('disconnected', userDisconnected);
|
||||
users.on('set username', setUsername);
|
||||
users.on('join room', joinRoom); //notify other = user joined room or (GLOBAL) room created.
|
||||
users.on('leave room', leaveRoom); //notify other = user left room or (GLOBAL) room removed.
|
||||
users.on("send message", sendMessage); //notify other = receive message.
|
||||
|
||||
httpServer.on('uncaughtException', function(err: any) {
|
||||
console.log(err);
|
||||
})
|
||||
|
||||
var httpPort = 80;
|
||||
httpServer.listen(httpPort, function() {
|
||||
console.log("Server is running on " + httpPort);
|
||||
});
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
// Type definitions for socket.io.users
|
||||
// Project: https://github.com/nodets/socket.io.users
|
||||
// Definitions by: Makis Maropoulos <https://github.com/kataras>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../express-session/express-session.d.ts" />
|
||||
/// <reference path="../socket.io/socket.io.d.ts" />
|
||||
|
||||
declare module "socket.io.users" {
|
||||
import { EventEmitter } from 'events';
|
||||
import { Application } from "express";
|
||||
import { SessionOptions } from "express-session";
|
||||
|
||||
var CONNECTION_EVENTS: string[];
|
||||
var Middleware: () => (socket: SocketIO.Socket, next: () => any) => void;
|
||||
var Session: (app: Application, options?: SessionOptions) => void;
|
||||
|
||||
type SocketUserList = {
|
||||
[namespace: string]: Users;
|
||||
};
|
||||
|
||||
class Namespaces {
|
||||
private static socketUsersList: any;
|
||||
static attach(namespace: string, socketUsersObj: Users): void;
|
||||
static get(namespace: string): Users;
|
||||
}
|
||||
|
||||
class User {
|
||||
id: string | number;
|
||||
socket: SocketIO.Socket;
|
||||
sockets: SocketIO.Socket[];
|
||||
rooms: string[];
|
||||
ip: string;
|
||||
remoteAddresses: string[];
|
||||
store: any;
|
||||
attach(socket: SocketIO.Socket): void;
|
||||
detachSocket(socket: SocketIO.Socket): void;
|
||||
detach(): void;
|
||||
join(room: string): boolean;
|
||||
leave(room: string): void;
|
||||
leaveAll(): void;
|
||||
/** same as in, checks if this user is inside a room */
|
||||
belong(room: string): boolean;
|
||||
/** same as belong, checks if this user is inside a room */
|
||||
in(room: string): boolean;
|
||||
set(key: string, value: any, callback?: () => void): void;
|
||||
get: (key: string) => any;
|
||||
toString(): string;
|
||||
emit(...args: any[]): void;
|
||||
to(room: string): SocketIO.Socket;
|
||||
}
|
||||
|
||||
|
||||
class Users extends EventEmitter {
|
||||
namespace: string;
|
||||
users: User[];
|
||||
constructor(namespace?: string);
|
||||
static of(namespace?: string): Users;
|
||||
takeId: (request: any) => string | number;
|
||||
create(socket: SocketIO.Socket): User;
|
||||
getById(id: string | number): User;
|
||||
get(socket: SocketIO.Socket): User;
|
||||
list(): User[];
|
||||
size(): number;
|
||||
push(_user: User): void;
|
||||
add(socket: SocketIO.Socket): User;
|
||||
indexOf(user: User): number;
|
||||
remove(user: User): void;
|
||||
room(room: string): User[];
|
||||
in(room: string): User[];
|
||||
from(room: string): User[];
|
||||
update(user: User): void;
|
||||
emitAll(...args: any[]): void;
|
||||
registerSocketEvents(currentUser: User): void;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user