From 6215c46d66c09777a66bdcdc323ca6577d98e8a6 Mon Sep 17 00:00:00 2001 From: victormarquess11 Date: Mon, 20 May 2024 13:45:39 -0300 Subject: [PATCH 1/2] [ADD] typescript support --- index.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..dfa578c --- /dev/null +++ b/index.d.ts @@ -0,0 +1,39 @@ +declare module 'sqlutils/pg' { + type Transformation = { + key: string | [string, string], + columns?: Array, + children?: Array + } + + type ChildTransformation = { + rename: string, + single?: boolean, + flat?: boolean + } + + export function format(statement: string, obj: object|object[]): string + export function escape(value: any): string + export function buildWhereFromQuery(query: object): string + export function groupColumnsToObjects(rows: object[], primary_key: string, groups: object[]): object[] + export function transformer(rows: any[], transformation: Transformation): object[] +}; + +declare module 'sqlutils/mysql' { + type Transformation = { + key: string | [string, string], + columns?: Array, + children?: Array + } + + type ChildTransformation = { + rename: string, + single?: boolean, + flat?: boolean + } + + export function format(statement: string, obj: object|object[]): string + export function escape(value: any): string + export function buildWhereFromQuery(query: object): string + export function groupColumnsToObjects(rows: object[], primary_key: string, groups: object[]): object[] + export function transformer(rows: any[], transformation: Transformation): object[] +}; \ No newline at end of file From e6902bcf52628f5d30ce1f8f49a0599e8ce502e0 Mon Sep 17 00:00:00 2001 From: victormarquess11 Date: Mon, 20 May 2024 17:22:04 -0300 Subject: [PATCH 2/2] [FIX] path to type files --- index.d.ts => mysql/index.d.ts | 20 -------------------- pg/index.d.ts | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) rename index.d.ts => mysql/index.d.ts (50%) create mode 100644 pg/index.d.ts diff --git a/index.d.ts b/mysql/index.d.ts similarity index 50% rename from index.d.ts rename to mysql/index.d.ts index dfa578c..cbfd75d 100644 --- a/index.d.ts +++ b/mysql/index.d.ts @@ -1,23 +1,3 @@ -declare module 'sqlutils/pg' { - type Transformation = { - key: string | [string, string], - columns?: Array, - children?: Array - } - - type ChildTransformation = { - rename: string, - single?: boolean, - flat?: boolean - } - - export function format(statement: string, obj: object|object[]): string - export function escape(value: any): string - export function buildWhereFromQuery(query: object): string - export function groupColumnsToObjects(rows: object[], primary_key: string, groups: object[]): object[] - export function transformer(rows: any[], transformation: Transformation): object[] -}; - declare module 'sqlutils/mysql' { type Transformation = { key: string | [string, string], diff --git a/pg/index.d.ts b/pg/index.d.ts new file mode 100644 index 0000000..d47edb3 --- /dev/null +++ b/pg/index.d.ts @@ -0,0 +1,19 @@ +declare module 'sqlutils/pg' { + type Transformation = { + key: string | [string, string], + columns?: Array, + children?: Array + } + + type ChildTransformation = { + rename: string, + single?: boolean, + flat?: boolean + } + + export function format(statement: string, obj: object|object[]): string + export function escape(value: any): string + export function buildWhereFromQuery(query: object): string + export function groupColumnsToObjects(rows: object[], primary_key: string, groups: object[]): object[] + export function transformer(rows: any[], transformation: Transformation): object[] +}; \ No newline at end of file