From f489a978e2c4ea41b94eecc68930ca94f1acbfda Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:37:15 +0200 Subject: [PATCH 1/8] fix: Export types directly from sqlstring dependency Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- package-lock.json | 14 ++++++++++++++ package.json | 1 + typings/mysql/index.d.ts | 25 ++----------------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index ddd049ce4e..8a1d27b735 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ }, "devDependencies": { "@types/node": "^22.0.0", + "@types/sqlstring": "^2.3.2", "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.42.1", "assert-diff": "^3.0.2", @@ -366,6 +367,13 @@ "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, + "node_modules/@types/sqlstring": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/sqlstring/-/sqlstring-2.3.2.tgz", + "integrity": "sha512-lVRe4Iz9UNgiHelKVo8QlC8fb5nfY8+p+jNQNE+UVsuuVlQnWhyWmQ/wF5pE8Ys6TdjfVpqTG9O9i2vi6E0+Sg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", @@ -3692,6 +3700,12 @@ "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, + "@types/sqlstring": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/sqlstring/-/sqlstring-2.3.2.tgz", + "integrity": "sha512-lVRe4Iz9UNgiHelKVo8QlC8fb5nfY8+p+jNQNE+UVsuuVlQnWhyWmQ/wF5pE8Ys6TdjfVpqTG9O9i2vi6E0+Sg==", + "dev": true + }, "@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", diff --git a/package.json b/package.json index af271ff824..68e198879e 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ }, "devDependencies": { "@types/node": "^22.0.0", + "@types/sqlstring": "^2.3.2", "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.42.1", "assert-diff": "^3.0.2", diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index 7dafa9cbf3..52bfd6d63c 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -21,6 +21,8 @@ import { } from './lib/protocol/sequences/Prepare.js'; import { Server } from './lib/Server.js'; +export type * from "sqlstring"; + export { ConnectionOptions, SslOptions, @@ -53,29 +55,6 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; -export function escape(value: any): string; - -export function escapeId(value: any): string; - -export function format(sql: string): string; -export function format( - sql: string, - values: any[], - stringifyObjects?: boolean, - timeZone?: string, -): string; - -export function format( - sql: string, - values: any, - stringifyObjects?: boolean, - timeZone?: string, -): string; - -export function raw(sql: string): { - toSqlString: () => string; -}; - export interface ConnectionConfig extends ConnectionOptions { mergeFlags(defaultFlags: string[], userFlags: string[] | string): number; getDefaultFlags(options?: ConnectionOptions): string[]; From fe0f1efe826aa8d16c6eabcedfdd822c39aaaab1 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:13:53 +0200 Subject: [PATCH 2/8] Revert "fix: Export types directly from sqlstring dependency" This reverts commit f489a978e2c4ea41b94eecc68930ca94f1acbfda. --- package-lock.json | 14 -------------- package.json | 1 - typings/mysql/index.d.ts | 25 +++++++++++++++++++++++-- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8a1d27b735..ddd049ce4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,6 @@ }, "devDependencies": { "@types/node": "^22.0.0", - "@types/sqlstring": "^2.3.2", "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.42.1", "assert-diff": "^3.0.2", @@ -367,13 +366,6 @@ "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, - "node_modules/@types/sqlstring": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@types/sqlstring/-/sqlstring-2.3.2.tgz", - "integrity": "sha512-lVRe4Iz9UNgiHelKVo8QlC8fb5nfY8+p+jNQNE+UVsuuVlQnWhyWmQ/wF5pE8Ys6TdjfVpqTG9O9i2vi6E0+Sg==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", @@ -3700,12 +3692,6 @@ "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, - "@types/sqlstring": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@types/sqlstring/-/sqlstring-2.3.2.tgz", - "integrity": "sha512-lVRe4Iz9UNgiHelKVo8QlC8fb5nfY8+p+jNQNE+UVsuuVlQnWhyWmQ/wF5pE8Ys6TdjfVpqTG9O9i2vi6E0+Sg==", - "dev": true - }, "@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", diff --git a/package.json b/package.json index 68e198879e..af271ff824 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,6 @@ }, "devDependencies": { "@types/node": "^22.0.0", - "@types/sqlstring": "^2.3.2", "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.42.1", "assert-diff": "^3.0.2", diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index 52bfd6d63c..7dafa9cbf3 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -21,8 +21,6 @@ import { } from './lib/protocol/sequences/Prepare.js'; import { Server } from './lib/Server.js'; -export type * from "sqlstring"; - export { ConnectionOptions, SslOptions, @@ -55,6 +53,29 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; +export function escape(value: any): string; + +export function escapeId(value: any): string; + +export function format(sql: string): string; +export function format( + sql: string, + values: any[], + stringifyObjects?: boolean, + timeZone?: string, +): string; + +export function format( + sql: string, + values: any, + stringifyObjects?: boolean, + timeZone?: string, +): string; + +export function raw(sql: string): { + toSqlString: () => string; +}; + export interface ConnectionConfig extends ConnectionOptions { mergeFlags(defaultFlags: string[], userFlags: string[] | string): number; getDefaultFlags(options?: ConnectionOptions): string[]; From 69452a39472dd822fd298a47b5156ccbbbe5ef03 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:25:45 +0200 Subject: [PATCH 3/8] refactor: Merged similarly shaped format overloads Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- typings/mysql/index.d.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index 7dafa9cbf3..2a3db83006 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -60,16 +60,9 @@ export function escapeId(value: any): string; export function format(sql: string): string; export function format( sql: string, - values: any[], + values: any | any[], stringifyObjects?: boolean, - timeZone?: string, -): string; - -export function format( - sql: string, - values: any, - stringifyObjects?: boolean, - timeZone?: string, + timeZone?: 'local' | NonNullable, ): string; export function raw(sql: string): { From b63f9e7913346c8cadebb101a1b2f4a2c1e1a3f0 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:26:24 +0200 Subject: [PATCH 4/8] fix: Added "hidden" type definitions provided by sqlstring package Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- typings/mysql/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index 2a3db83006..b636133e59 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -53,9 +53,9 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; -export function escape(value: any): string; +export function escape(value: any, stringifyObjects?: boolean, timeZone?: 'local' | NonNullable): string; -export function escapeId(value: any): string; +export function escapeId(value: any, forbidQualified?: boolean): string; export function format(sql: string): string; export function format( From 18bc151a7addc3b2d8236171d25a75a1dd8cb635 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:42:44 +0200 Subject: [PATCH 5/8] Added header comments Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- typings/mysql/index.d.ts | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index b636133e59..db5cc82bd6 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -53,10 +53,35 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; +/** + * @file index.d.ts + * + * @author marvinhagemeister + * @date 11 July 2017 + * + * @dependency \@types/sqlstring + * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information + */ export function escape(value: any, stringifyObjects?: boolean, timeZone?: 'local' | NonNullable): string; - +/** + * @file index.d.ts + * + * @author marvinhagemeister + * @date 11 July 2017 + * + * @dependency \@types/sqlstring + * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information + */ export function escapeId(value: any, forbidQualified?: boolean): string; - +/** + * @file index.d.ts + * + * @author marvinhagemeister + * @date 11 July 2017 + * + * @dependency \@types/sqlstring + * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information + */ export function format(sql: string): string; export function format( sql: string, @@ -64,7 +89,15 @@ export function format( stringifyObjects?: boolean, timeZone?: 'local' | NonNullable, ): string; - +/** + * @file index.d.ts + * + * @author David Gomes + * @date 3 January 2019 + * + * @dependency \@types/sqlstring + * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information + */ export function raw(sql: string): { toSqlString: () => string; }; From 27e225d9ec9a54df92dcaad79b8b4ad4cb82db74 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:08:27 +0200 Subject: [PATCH 6/8] refactor: moved header comment Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- typings/mysql/index.d.ts | 42 ++++++---------------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index db5cc82bd6..7acb501207 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -1,3 +1,6 @@ +/** + * sqlstring types are based on https://www.npmjs.com/package/@types/sqlstring, version 2.3.2 + */ import { Pool as BasePool, PoolOptions } from './lib/Pool.js'; import { Connection as BaseConnection, @@ -53,35 +56,10 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; -/** - * @file index.d.ts - * - * @author marvinhagemeister - * @date 11 July 2017 - * - * @dependency \@types/sqlstring - * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information - */ export function escape(value: any, stringifyObjects?: boolean, timeZone?: 'local' | NonNullable): string; -/** - * @file index.d.ts - * - * @author marvinhagemeister - * @date 11 July 2017 - * - * @dependency \@types/sqlstring - * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information - */ + export function escapeId(value: any, forbidQualified?: boolean): string; -/** - * @file index.d.ts - * - * @author marvinhagemeister - * @date 11 July 2017 - * - * @dependency \@types/sqlstring - * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information - */ + export function format(sql: string): string; export function format( sql: string, @@ -89,15 +67,7 @@ export function format( stringifyObjects?: boolean, timeZone?: 'local' | NonNullable, ): string; -/** - * @file index.d.ts - * - * @author David Gomes - * @date 3 January 2019 - * - * @dependency \@types/sqlstring - * @see {@link https://www.npmjs.com/package/@types/sqlstring} for more information - */ + export function raw(sql: string): { toSqlString: () => string; }; From bb59081cad3249514f193bb4bbffe5b62c507642 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:09:28 +0200 Subject: [PATCH 7/8] refactor: typing corrections Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- typings/mysql/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index 7acb501207..1b3521308c 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -56,7 +56,8 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; -export function escape(value: any, stringifyObjects?: boolean, timeZone?: 'local' | NonNullable): string; +type TimeZone = 'local' | 'Z' | string & NonNullable; +export function escape(value: any, stringifyObjects?: boolean, timeZone?: TimeZone): string; export function escapeId(value: any, forbidQualified?: boolean): string; @@ -65,7 +66,7 @@ export function format( sql: string, values: any | any[], stringifyObjects?: boolean, - timeZone?: 'local' | NonNullable, + timeZone?: TimeZone, ): string; export function raw(sql: string): { From b66b054483c9d8e25504387ccca7c3e1c54a9ff2 Mon Sep 17 00:00:00 2001 From: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:46:39 +0200 Subject: [PATCH 8/8] fix: Ran prettier Signed-off-by: Scraps <123112608+ScrapsPrograms@users.noreply.github.com> --- typings/mysql/index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index 1b3521308c..3ef9b6b464 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -56,8 +56,12 @@ export function createPool(config: PoolOptions): BasePool; export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; -type TimeZone = 'local' | 'Z' | string & NonNullable; -export function escape(value: any, stringifyObjects?: boolean, timeZone?: TimeZone): string; +type TimeZone = 'local' | 'Z' | (string & NonNullable); +export function escape( + value: any, + stringifyObjects?: boolean, + timeZone?: TimeZone, +): string; export function escapeId(value: any, forbidQualified?: boolean): string;