From 20a7a9419ac98fd782e2ad6abb763f6ac6ba0aa9 Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Wed, 18 Mar 2015 22:56:48 -0500 Subject: [PATCH 01/10] Create mssql.d.ts Initial creation of MSSQL database connector for Node.js defintion --- mssql/mssql.d.ts | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 mssql/mssql.d.ts diff --git a/mssql/mssql.d.ts b/mssql/mssql.d.ts new file mode 100644 index 000000000..dcdd0f700 --- /dev/null +++ b/mssql/mssql.d.ts @@ -0,0 +1,96 @@ +// Type definitions for mssql +// Project: https://www.npmjs.com/package/mssql +// Definitions by: COLSA Corporation +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "mssql" { + + export var DateTime: any; + export var NVarChar: any; + export var Int: any; + export var Bit: any; + export var VarBinary: any; + export var TVP: any; + + export interface options { + encrypt: boolean; + } + + export interface pool { + min: number; + max: number; + idleTimeoutMillis: number; + } + + export interface config { + driver?: string; + user?: string; + password?: string; + server: string; + port?: number; + domain?: string; + database: string; + connectionTimeout?: number; + requestTimeout?: number; + stream?: boolean; + options?: options; + pool?: pool; + + } + + export class Connection { + + public constructor(config: config, callback?: (err?: any) => void); + + public connect(callback?: (err?: any) => void); + + public close(); + } + + class columns { + public add(name: string, type: any, options: any); + } + + class rows { + public add(any); + } + + export class Table { + public create: boolean; + public columns: columns; + public rows: rows; + public constructor(tableName: string); + + } + + export class Request { + public constructor(connection?: Connection); + public execute(procedure: string, callback?: (err?: any, recordsets?: any, returnValue?: any) => void); + public input(name: string, value: any); + public input(name: string, type: any, value: any); + public output(name: string, type: any, value?: any); + public pipe(stream: any); + public query(command: string, callback?: (err?: any, recordset?: any) => void); + public batch(batch: string, callback?: (err?: any, recordset?: any) => void); + public bulk(table: Table, callback?: (err?: any, rowCount?: any) => void); + public cancel(); + public parameters: any; + } + + export class Transaction { + public constructor(connection?: Connection); + public begin(isolationLevel?: any, callback?: (err?: any) => void); + public begin(callback?: (err?: any) => void); + public commit(callback?: (err?: any) => void); + public rollback(callback?: (err?: any) => void); + } + + export class PreparedStatement { + public constructor(connection?: Connection); + public input(name: string, type: any); + public output(name: string, type: any); + public prepare(statement: string, callback?: (err?: any) => void); + public execute(values: any, callback?: (err?: any) => void); + public unprepare(callback?: (err?: any) => void); + } +} From d0087d3ab84b49c80cc4770117526774403b889c Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Wed, 18 Mar 2015 22:57:36 -0500 Subject: [PATCH 02/10] Create mssql-tests.ts Tests for MSSQL database connector for Node.js --- mssql/mssql-tests.ts | 70 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 mssql/mssql-tests.ts diff --git a/mssql/mssql-tests.ts b/mssql/mssql-tests.ts new file mode 100644 index 000000000..5a7e3e305 --- /dev/null +++ b/mssql/mssql-tests.ts @@ -0,0 +1,70 @@ +/// +/// + +import sql = require('mssql'); + +var config: sql.config = { + user: 'user', + password: 'password', + server: 'ip', + database: 'database', + connectionTimeout: 10000, + options: { + encrypt: true + } +} + +var connection: sql.Connection = new sql.Connection(config, function (err: any) { + if (err != null) { + console.warn("Issue with connecting to SQL Server!"); + } + else { + var requestQuery = new sql.Request(connection); + + var getArticlesQuery = "SELECT * FROM TABLE"; + + requestQuery.query(getArticlesQuery, function (err, recordSet) { + if (err) { + console.error('Error happened calling Query: ' + err.name + " " + err.message); + + } + // checking to see if the articles returned as at least one. + else if (recordSet.length > 0) { + } + }); + + var requestStoredProcedure = new sql.Request(connection); + var testId: number = 0; + var testString: string = 'test'; + + requestStoredProcedure.input('pId', testId); + requestStoredProcedure.input('pString', testString); + + + requestStoredProcedure.execute('StoredProcedureName', function (err, recordsets, returnValue) { + if (err != null) { + console.error('Error happened calling Query: ' + err.name + " " + err.message); + } + else { + console.info(returnValue); + } + }); + + var requestStoredProcedureWithOutput = new sql.Request(connection); + var testId: number = 0; + var testString: string = 'test'; + + requestStoredProcedure.input('pId', testId); + requestStoredProcedure.input('pString', testString); + requestStoredProcedure.output('output', sql.Int); + + requestStoredProcedure.execute('StoredProcedureName', function (err, recordsets, returnValue) { + if (err != null) { + console.error('Error happened calling Query: ' + err.name + " " + err.message); + } + else { + console.info(requestStoredProcedureWithOutput.parameters.output.value); + } + }); + } +}); From 1276cc4c1b6fee7ca3b11e960c5eccaff9f0d424 Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Wed, 18 Mar 2015 22:59:17 -0500 Subject: [PATCH 03/10] Create s3-uploader.d.ts Very simple definition of s3-uploader. --- s3-uploader.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 s3-uploader.d.ts diff --git a/s3-uploader.d.ts b/s3-uploader.d.ts new file mode 100644 index 000000000..215cb7df6 --- /dev/null +++ b/s3-uploader.d.ts @@ -0,0 +1,39 @@ +// Type definitions for s3-uploader +// Project: https://www.npmjs.com/package/s3-uploader +// Definitions by: COLSA Corporation +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//NOTE: Does require GM (https://github.com/aheckmann/gm) thus requires GraphicsMagick (http://www.graphicsmagick.org/) or ImageMagick (http://www.imagemagick.org/) + +declare module "s3-uploader" { + export = Upload; +} +interface S3UploaderVersion { + original?: boolean; + suffix?: string; + quality?: number; + maxWidth?: number; + maxHeight?: number; +} + +interface S3UploaderOptions { + awsAccessKeyId?: string; + awsSecretAccessKey?: string; + awsBucketRegion?: string; + awsBucketPath?: string; + awsBucketAcl?: string; + awsMaxRetries?: number; + awsHttpTimeout?: number; + resizeQuality?: number; + returnExif?: boolean; + tmpDir?: string; + workers?: number; + url?: string; + versions?: S3UploaderVersion; +} + +declare class Upload { + public constructor(awsBucketName: string, opts: S3UploaderOptions); + + public upload(src: string, opts?: S3UploaderOptions, cb?: (err, images, meta) => void); +} From 69f007ab58e73567b00a7062a57a404d1dac94f7 Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Wed, 18 Mar 2015 22:59:53 -0500 Subject: [PATCH 04/10] Create s3-uploader-tests.ts Tests for s3-uploader --- s3-uploader/s3-uploader-tests.ts | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 s3-uploader/s3-uploader-tests.ts diff --git a/s3-uploader/s3-uploader-tests.ts b/s3-uploader/s3-uploader-tests.ts new file mode 100644 index 000000000..6fa065866 --- /dev/null +++ b/s3-uploader/s3-uploader-tests.ts @@ -0,0 +1,44 @@ +/// +/// + +//NOTE: Does require GM (https://github.com/aheckmann/gm) thus requires GraphicsMagick (http://www.graphicsmagick.org/) or ImageMagick (http://www.imagemagick.org/) + +import Upload = require('s3-uploader'); + +var s3VersionOriginal: S3UploaderVersion = { + original: true +}; + +var s3VersionHeader: S3UploaderVersion = { + suffix: '-header', + quality: 100, + maxHeight: 300, + maxWidth: 600 +} + +var s3Config: S3UploaderOptions = { + awsAccessKeyId: 'awsKeyId', + awsSecretAccessKey: 'awsSecretAccessKey', + awsBucketPath: '', + awsBucketRegion: 'us-east-1' /*Whatever region s3 is located*/, + awsBucketAcl: 'public-read', + awsHttpTimeout: 60000, + versions: [s3VersionOriginal, s3VersionHeader] +} + +var client = new Upload('bucketName', s3Config); + +client.upload('/images/File.png', s3Config, function (err, images, meta) { + var returnVal: boolean = false; + if (err) { + console.log(err); + } + else { + if (images.length >= 2) { + var originalImageUrl = images[0].url; + var headerImageUrl = images[1].url; + + console.log('Original: ' + originalImageUrl + ' headerImageUrl: ' + headerImageUrl); + } + } +}); From 048feee7490233d846f6c6fb6f6d3ad235fae8fb Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Thu, 19 Mar 2015 08:37:02 -0500 Subject: [PATCH 05/10] Create s3-uploader --- s3-uploader/s3-uploader | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 s3-uploader/s3-uploader diff --git a/s3-uploader/s3-uploader b/s3-uploader/s3-uploader new file mode 100644 index 000000000..215cb7df6 --- /dev/null +++ b/s3-uploader/s3-uploader @@ -0,0 +1,39 @@ +// Type definitions for s3-uploader +// Project: https://www.npmjs.com/package/s3-uploader +// Definitions by: COLSA Corporation +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//NOTE: Does require GM (https://github.com/aheckmann/gm) thus requires GraphicsMagick (http://www.graphicsmagick.org/) or ImageMagick (http://www.imagemagick.org/) + +declare module "s3-uploader" { + export = Upload; +} +interface S3UploaderVersion { + original?: boolean; + suffix?: string; + quality?: number; + maxWidth?: number; + maxHeight?: number; +} + +interface S3UploaderOptions { + awsAccessKeyId?: string; + awsSecretAccessKey?: string; + awsBucketRegion?: string; + awsBucketPath?: string; + awsBucketAcl?: string; + awsMaxRetries?: number; + awsHttpTimeout?: number; + resizeQuality?: number; + returnExif?: boolean; + tmpDir?: string; + workers?: number; + url?: string; + versions?: S3UploaderVersion; +} + +declare class Upload { + public constructor(awsBucketName: string, opts: S3UploaderOptions); + + public upload(src: string, opts?: S3UploaderOptions, cb?: (err, images, meta) => void); +} From 0df80e23991a9891239f4c7b6e6879cbc7241e91 Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Thu, 19 Mar 2015 08:37:59 -0500 Subject: [PATCH 06/10] Rename s3-uploader to s3-uploader.d.ts --- s3-uploader/{s3-uploader => s3-uploader.d.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename s3-uploader/{s3-uploader => s3-uploader.d.ts} (100%) diff --git a/s3-uploader/s3-uploader b/s3-uploader/s3-uploader.d.ts similarity index 100% rename from s3-uploader/s3-uploader rename to s3-uploader/s3-uploader.d.ts From 8f8c018e24000f582570e8d61cdd0b26d9a670ec Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Thu, 19 Mar 2015 22:07:38 -0500 Subject: [PATCH 07/10] Delete s3-uploader.d.ts --- s3-uploader.d.ts | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 s3-uploader.d.ts diff --git a/s3-uploader.d.ts b/s3-uploader.d.ts deleted file mode 100644 index 215cb7df6..000000000 --- a/s3-uploader.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Type definitions for s3-uploader -// Project: https://www.npmjs.com/package/s3-uploader -// Definitions by: COLSA Corporation -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -//NOTE: Does require GM (https://github.com/aheckmann/gm) thus requires GraphicsMagick (http://www.graphicsmagick.org/) or ImageMagick (http://www.imagemagick.org/) - -declare module "s3-uploader" { - export = Upload; -} -interface S3UploaderVersion { - original?: boolean; - suffix?: string; - quality?: number; - maxWidth?: number; - maxHeight?: number; -} - -interface S3UploaderOptions { - awsAccessKeyId?: string; - awsSecretAccessKey?: string; - awsBucketRegion?: string; - awsBucketPath?: string; - awsBucketAcl?: string; - awsMaxRetries?: number; - awsHttpTimeout?: number; - resizeQuality?: number; - returnExif?: boolean; - tmpDir?: string; - workers?: number; - url?: string; - versions?: S3UploaderVersion; -} - -declare class Upload { - public constructor(awsBucketName: string, opts: S3UploaderOptions); - - public upload(src: string, opts?: S3UploaderOptions, cb?: (err, images, meta) => void); -} From 4260bec48a07f49bc47f87e3984ceea6270cc044 Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Mon, 23 Mar 2015 13:46:51 -0500 Subject: [PATCH 08/10] Update s3-uploader.d.ts --- s3-uploader/s3-uploader.d.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/s3-uploader/s3-uploader.d.ts b/s3-uploader/s3-uploader.d.ts index 215cb7df6..b7c093c3f 100644 --- a/s3-uploader/s3-uploader.d.ts +++ b/s3-uploader/s3-uploader.d.ts @@ -32,8 +32,35 @@ interface S3UploaderOptions { versions?: S3UploaderVersion; } +declare class Meta { + public format: string; + public fileSize: string; + public imageSize: imageSize; + public orientation: string; + public colorSpace: string; + public compression: string; + public quallity: string; +} + +declare class imageSize { + public height: number; + public width: number; +} + +declare class image { + public etag: string; + public format: string; + public height: number; + public original: boolean; + public path: string; + public size: string; + public src: string; + public url: string; + public width: number; +} + declare class Upload { public constructor(awsBucketName: string, opts: S3UploaderOptions); - public upload(src: string, opts?: S3UploaderOptions, cb?: (err, images, meta) => void); + public upload(src: string, opts?: S3UploaderOptions, cb?: (err: string, images: image[], meta: Meta) => void): void; } From fe8fabf5f71b11a68f078781e563749bc51edd86 Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Mon, 23 Mar 2015 14:01:16 -0500 Subject: [PATCH 09/10] Update mssql.d.ts --- mssql/mssql.d.ts | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/mssql/mssql.d.ts b/mssql/mssql.d.ts index dcdd0f700..fdcad2642 100644 --- a/mssql/mssql.d.ts +++ b/mssql/mssql.d.ts @@ -42,17 +42,17 @@ declare module "mssql" { public constructor(config: config, callback?: (err?: any) => void); - public connect(callback?: (err?: any) => void); + public connect(callback?: (err?: any) => void): void; - public close(); + public close(): void; } class columns { - public add(name: string, type: any, options: any); + public add(name: string, type: any, options: any): void; } class rows { - public add(any); + public add(any): void; } export class Table { @@ -65,32 +65,32 @@ declare module "mssql" { export class Request { public constructor(connection?: Connection); - public execute(procedure: string, callback?: (err?: any, recordsets?: any, returnValue?: any) => void); - public input(name: string, value: any); - public input(name: string, type: any, value: any); - public output(name: string, type: any, value?: any); - public pipe(stream: any); - public query(command: string, callback?: (err?: any, recordset?: any) => void); - public batch(batch: string, callback?: (err?: any, recordset?: any) => void); - public bulk(table: Table, callback?: (err?: any, rowCount?: any) => void); - public cancel(); + 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 cancel(): void; public parameters: any; } export class Transaction { public constructor(connection?: Connection); - public begin(isolationLevel?: any, callback?: (err?: any) => void); - public begin(callback?: (err?: any) => void); - public commit(callback?: (err?: any) => void); - public rollback(callback?: (err?: any) => void); + 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; } export class PreparedStatement { public constructor(connection?: Connection); - public input(name: string, type: any); - public output(name: string, type: any); - public prepare(statement: string, callback?: (err?: any) => void); - public execute(values: any, callback?: (err?: any) => void); - public unprepare(callback?: (err?: any) => void); + 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; } } From e889118f0e741c5c1e659fb732ccd68354fc8e3d Mon Sep 17 00:00:00 2001 From: ColsaCorp Date: Mon, 23 Mar 2015 14:15:30 -0500 Subject: [PATCH 10/10] Update mssql.d.ts --- mssql/mssql.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mssql/mssql.d.ts b/mssql/mssql.d.ts index fdcad2642..5a6e6a00c 100644 --- a/mssql/mssql.d.ts +++ b/mssql/mssql.d.ts @@ -52,7 +52,7 @@ declare module "mssql" { } class rows { - public add(any): void; + public add(row: any): void; } export class Table {