Skip to content

Commit

Permalink
Merge pull request #41 from treegex/dev
Browse files Browse the repository at this point in the history
added typeScript definitions
  • Loading branch information
aliazmoodehvaldi authored Sep 19, 2022
2 parents 465fd5b + 5106d26 commit 907345f
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 3 deletions.
50 changes: 50 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as dataType from './type/DataType';
import * as fieldHelper from './type/FieldHelper';
import * as queryHelper from './type/QueryHelper';
import * as keywordHelper from './type/KeywordHelper';
import * as variableDataType from './type/VariableDataType';


declare module 'opensql' {

let fieldHelper: fieldHelper.FieldHelper;

let dataType: dataType.DataType;

let keywordHelper: keywordHelper.KeywordHelper;

let variableDataType: variableDataType.VariableDataType;

let queryHelper: queryHelper.QueryHelper;

export function connect(jsonObject: object): any;

export function createDatabase(name?: string): any;

export function createTable(jsonObject: object): any;

export function dropTable(data: string[] | string): any;

export function addForeignKey(jsonObject: object): any;

export function remove(jsonObject: object): any;

export function update(jsonObject: object): any;

export function addMultiValue(jsonObject: object): any;

export function addOne(jsonObject: object): any;

export function addWithFind(jsonObject: object): any;

export function customQuery(sqlQuery: string, inject?: object | any[]): any;

export function dropDatabase(databaseName?: string): any;

export function find(jsonObject: object): any;

export function findTable(tableName: string, databaseName?: string): any;

export function result(fn: Function): any;

}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensql",
"version": "1.2.46",
"version": "1.2.47",
"description": "OpenSql is a promise-based Node.js ORM tool for MySql",
"main": "index.js",
"scripts": {
Expand All @@ -12,6 +12,7 @@
"**/test/**/*.test.js"
]
},
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/treegex/opensql.git"
Expand Down
73 changes: 73 additions & 0 deletions type/DataType.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
declare module dataType {

interface DataType {

VARCHAR(data: number | any[]): string;

INT(data?: number | any[]): string;

CHAR(data: number | any[]): string;

DATE(data?: any[]): string;

TIME(data?: any[]): string;

DATETIME(data?: any[]): string;

ENUM(data: any[]): string;

BOOLEAN(data?: number | any[]): string;

POINT(data?: number | any[]): string;

TINYINT(data?: number | any[]): string;

SMALLINT(data?: number | any[]): string;

MEDIUMINT(data?: number | any[]): string;

BIGINT(data?: number | any[]): string;

DECIMAL(data?: number | any[]): string;

FLOAT(data?: number | any[]): string;

DOUBLE(data?: number | any[]): string;

REAL(data?: number | any[]): string;

BIT(data?: number | any[]): string;

SERIAL(data?: number | any[]): string;

TIMESTAMP(data?: any[]): string;

YEAR(data?: any[]): string;

TINYTEXT(data?: number | any[]): string;

TEXT(data?: number | any[]): string;

MEDIUMTEXT(data?: number | any[]): string;

LONGTEXT(data?: number | any[]): string;

BINARY(data?: number | any[]): string;

VARBINARY(data: number | any[]): string;

TINYBLOB(data?: any[]): string;

BLOB(data?: any[]): string;

MEDIUMBLOB(data?: any[]): string;

LONGBLOB(data?: any[]): string;

SET(data: any[]): string;

}

}

export = dataType;
15 changes: 15 additions & 0 deletions type/FieldHelper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
declare module fieldHelper {

interface FieldHelper {

POINT(Lat: number, Lon: number): string;

fieldPoint(field: string): string;

DEFAULT(value: string): string;

}

}

export = fieldHelper;
38 changes: 38 additions & 0 deletions type/KeywordHelper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
declare module keywordHelper {

interface KeywordHelper {

OR: string;
IN: string;
AND: string;
ASC: string;
STAR: string;
DESC: string;
LIKE: string;
CAST: string;
COMMA: string;
UNION: string;
LIMIT: string;
COUNT: string;
NOT_IN: string;
OFFSET: string;
BETWEEN: string;
CASCADE: string;
DISTINCT: string;
SET_NULL: string;
GROUP_BY: string;
RESTRICT: string;
ORDER_BY: string;
UNION_ALL: string;
NO_ACTION: string;
NOT_BETWEEN: string;
IF_NOT_EXISTS: string;
QUESTION_MARK: string;
AUTO_INCREMENT: string;
DOUBLE_QUESTION_MARK: string;

}

}

export = keywordHelper;
64 changes: 64 additions & 0 deletions type/QueryHelper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
declare module queryHelper {

interface QueryHelper {

NULL: string;
IS_NULL: string;
NOT_NULL: string;
EQUAL_TO: string;
LESS_THAN: string;
IS_NOT_NULL: string;
GREATER_THAN: string;
NOT_EQUAL_TO: string;
LESS_THAN_OR_EQUAL_TO: string;
GREATER_THAN_OR_EQUAL_TO: string;

setOperator(operator: string, value: string, op?: string): string;

OR(jsonObject: object, operator?: any): string[];

AND(jsonObject: object, operator?: any): string[];

IN(arr: any[], op?: string): string;

NOT_IN(arr: any[], op?: string): string;

BETWEEN(first: number, second: number, op?: string): string;

NOT_BETWEEN(first: number, second: number, op?: string): string;

LIKE(str: string, op?: string): string;

CAST(data: string | number, type: string): string;

COUNT(column?: string | string[]): string;

AS(first: string, second: String): string;

SOURCE(name: string, typeName?: string): string;

ATTACH(array: string[], op?: string): object;

UNION(jsonObject: object): object;

NOT(str: string, op?: string): string;

UNION_ALL(jsonObject: object): object;

MIN(column: string): string;

MAX(column: string): string;

SUM(column: string): string;

AVG(column: string): string;

CONCAT_WS(str: string, array: string[], column: string): string;

GROUP(data: string | string[]): string;

}

}

export = queryHelper;
42 changes: 42 additions & 0 deletions type/VariableDataType.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
declare module variableDataType {

interface VariableDataType {

int: string;
bit: string;
text: string;
Enum: string;
set: string;
real: string;
year: string;
blob: string;
char: string;
date: string;
time: string;
point: string;
float: string;
bigint: string;
binary: string;
serial: string;
double: string;
decimal: string;
boolean: string;
varchar: string;
tinyint: string;
tinyblob: string;
longblob: string;
longtext: string;
tinytext: string;
smallint: string;
datetime: string;
timestamp: string;
mediumint: string;
varbinary: string;
mediumblob: string;
mediumtext: string;

}

}

export = variableDataType;

0 comments on commit 907345f

Please sign in to comment.