From ad9d856bff4b0a0c9ad37cb4930c529be30ca032 Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Sun, 21 Jan 2024 17:03:37 +0100 Subject: [PATCH] fix: deps --- src/mysql.db.ts | 31 +++++++++----------- src/query.util.test.ts | 12 ++++---- src/query.util.ts | 8 +++--- src/test/mysql.manual.test.ts | 2 +- yarn.lock | 54 +++++++++++++++++------------------ 5 files changed, 52 insertions(+), 55 deletions(-) diff --git a/src/mysql.db.ts b/src/mysql.db.ts index d105d5a..f5d089c 100644 --- a/src/mysql.db.ts +++ b/src/mysql.db.ts @@ -20,13 +20,11 @@ import { _mapValues, _Memo, _omit, - AnyPartialObjectWithId, CommonLogger, commonLoggerPrefix, JsonSchemaObject, JsonSchemaRootObject, - PartialObjectWithId, - Saved, + ObjectWithId, } from '@naturalcycles/js-lib' import { ReadableTyped, white } from '@naturalcycles/nodejs-lib' import { @@ -48,8 +46,7 @@ import { } from './schema/mysql.schema.util' export interface MysqlDBOptions extends CommonDBOptions {} -export interface MysqlDBSaveOptions - extends CommonDBSaveOptions {} +export interface MysqlDBSaveOptions extends CommonDBSaveOptions {} /** * @default false / undefined @@ -196,11 +193,11 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { } // GET - override async getByIds( + override async getByIds( table: string, ids: string[], opt: MysqlDBOptions = {}, - ): Promise[]> { + ): Promise { if (!ids.length) return [] const q = new DBQuery(table).filterEq('id', ids) const { rows } = await this.runQuery(q, opt) @@ -208,10 +205,10 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { } // QUERY - override async runQuery( + override async runQuery( q: DBQuery, _opt: MysqlDBOptions = {}, - ): Promise>> { + ): Promise> { const sql = dbQueryToSQLSelect(q) if (!sql) { return { @@ -261,7 +258,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { } } - override async runQueryCount( + override async runQueryCount( q: DBQuery, _opt?: CommonDBOptions, ): Promise { @@ -269,10 +266,10 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { return (rows[0] as any)._count } - override streamQuery( + override streamQuery( q: DBQuery, _opt: MysqlDBOptions = {}, - ): ReadableTyped> { + ): ReadableTyped { const sql = dbQueryToSQLSelect(q) if (!sql) { return Readable.from([]) @@ -295,7 +292,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { } // SAVE - override async saveBatch( + override async saveBatch( table: string, rowsInput: ROW[], opt: MysqlDBSaveOptions = {}, @@ -373,7 +370,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { return affectedRows } - override async deleteByQuery( + override async deleteByQuery( q: DBQuery, _opt?: CommonDBOptions, ): Promise { @@ -393,7 +390,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { /** * dropIfExists=true needed as a safety check */ - override async createTable( + override async createTable( table: string, schema: JsonSchemaObject, opt: CommonDBCreateOptions = {}, @@ -410,7 +407,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { .filter(Boolean) } - override async getTableSchema( + override async getTableSchema( table: string, ): Promise> { const stats = await this.runSQL({ @@ -420,7 +417,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB { return mysqlTableStatsToJsonSchemaField(table, stats, this.cfg.logger) } - override async updateByQuery( + override async updateByQuery( q: DBQuery, patch: DBPatch, ): Promise { diff --git a/src/query.util.test.ts b/src/query.util.test.ts index 60af04d..5e0f9d0 100644 --- a/src/query.util.test.ts +++ b/src/query.util.test.ts @@ -11,7 +11,7 @@ test('dbQueryToSQLSelect', () => { expect(sql).toMatchSnapshot() sql = dbQueryToSQLSelect( - new DBQuery('TBL1') + new DBQuery('TBL1') .filterEq('a', 'b') .filter('c', '>', '2019') .order('aaa') @@ -21,19 +21,19 @@ test('dbQueryToSQLSelect', () => { // console.log(sql) expect(sql).toMatchSnapshot() - sql = dbQueryToSQLSelect(new DBQuery('TBL1').filter('num', '>', 15)) + sql = dbQueryToSQLSelect(new DBQuery('TBL1').filter('num', '>', 15)) // console.log(sql) expect(sql).toMatchSnapshot() // NULL cases sql = dbQueryToSQLSelect( - new DBQuery('TBL1').filterEq('a', undefined).filterEq('a2', null).filter('a3', '>', null), + new DBQuery('TBL1').filterEq('a', undefined).filterEq('a2', null).filter('a3', '>', null), ) // console.log(sql) expect(sql).toMatchSnapshot() // ARRAY CASES - sql = dbQueryToSQLSelect(new DBQuery('TBL1').filterEq('a', ['a1', 'a2', 'a3'])) + sql = dbQueryToSQLSelect(new DBQuery('TBL1').filterEq('a', ['a1', 'a2', 'a3'])) // console.log(sql) expect(sql).toMatchSnapshot() }) @@ -42,7 +42,7 @@ test('dbQueryToSQLDelete', () => { let sql = dbQueryToSQLDelete(new DBQuery('TBL1')) expect(sql).toMatchSnapshot() - sql = dbQueryToSQLDelete(new DBQuery('TBL1').filter('a', '>', null)) + sql = dbQueryToSQLDelete(new DBQuery('TBL1').filter('a', '>', null)) expect(sql).toMatchSnapshot() }) @@ -60,7 +60,7 @@ test('dbQueryToSQLUpdate', () => { // console.log(sql) expect(sql).toMatchSnapshot() - sql = dbQueryToSQLUpdate(new DBQuery(TEST_TABLE).filter('a', '>', 5), item) + sql = dbQueryToSQLUpdate(new DBQuery(TEST_TABLE).filter('a', '>', 5), item) // console.log(sql) expect(sql).toMatchSnapshot() }) diff --git a/src/query.util.ts b/src/query.util.ts index 7e1d458..163d5f4 100644 --- a/src/query.util.ts +++ b/src/query.util.ts @@ -1,5 +1,5 @@ import { DBQuery, DBQueryFilterOperator } from '@naturalcycles/db-lib' -import { _hb, CommonLogger } from '@naturalcycles/js-lib' +import { _hb, AnyObjectWithId, CommonLogger } from '@naturalcycles/js-lib' import { white, yellow } from '@naturalcycles/nodejs-lib' import { QueryOptions } from 'mysql' import * as mysql from 'mysql' @@ -160,7 +160,7 @@ export function dbQueryToSQLUpdate(q: DBQuery, record: Record): s return mysql.format(tokens.join(' '), Object.values(record)) } -function selectTokens(q: DBQuery): string[] { +function selectTokens(q: DBQuery): string[] { let fields = ['*'] if (q._selectedFieldNames) { @@ -192,7 +192,7 @@ function offsetLimitTokens(q: DBQuery): string[] { return tokens } -function groupOrderTokens(q: DBQuery): string[] { +function groupOrderTokens(q: DBQuery): string[] { const t: string[] = [] if (q._groupByFieldNames?.length) { @@ -216,7 +216,7 @@ const OP_MAP: Partial> = { /** * Returns `null` for "guaranteed 0 rows" cases. */ -function getWhereTokens(q: DBQuery): string[] | null { +function getWhereTokens(q: DBQuery): string[] | null { if (!q._filters.length) return [] let returnNull = false diff --git a/src/test/mysql.manual.test.ts b/src/test/mysql.manual.test.ts index b5fcf03..aec44eb 100644 --- a/src/test/mysql.manual.test.ts +++ b/src/test/mysql.manual.test.ts @@ -104,7 +104,7 @@ test('buffer', async () => { await db.createTable(table, schema, { dropIfExists: true }) await db.saveBatch(table, items) - const { rows } = await db.runQuery(new DBQuery(table)) + const { rows } = await db.runQuery(new DBQuery(table)) // console.log(items2) console.log(await inflateToString(rows[0]!['extra'])) expect(rows).toEqual(items) diff --git a/yarn.lock b/yarn.lock index d5d4c1d..565446d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -779,9 +779,9 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.9": - version "0.3.21" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz#5dc1df7b3dc4a6209e503a924e1ca56097a2bb15" - integrity sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g== + version "0.3.22" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz#72a621e5de59f5f1ef792d0793a82ee20f645e4c" + integrity sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw== dependencies: "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" @@ -799,9 +799,9 @@ typescript "^5.0.2" "@naturalcycles/db-lib@^9.1.0": - version "9.3.0" - resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.3.0.tgz#d6727ff62b4150f26e83e3b68e5ca975229f154d" - integrity sha512-wcPFWmQ+jXtdXrSqPuXHnkzw4UjwvJUhtIIWFxLdsaoEFnA8peSsdpH+E5QIU7EDjXfQmYQ6nhcacmWQ6NvM+Q== + version "9.4.1" + resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.4.1.tgz#e4ff4eaa571e3e78cf7a5b6d1cb0f08866a12b92" + integrity sha512-sb5p/T+da8/6BLPr5NRCX405JkZtKluCNkC+WY72L6MyPK0fEgOkXCyzpzs03b621SRIlH4lSqzLj+PwWsQJyw== dependencies: "@naturalcycles/js-lib" "^14.116.0" "@naturalcycles/nodejs-lib" "^13.1.1" @@ -842,17 +842,17 @@ yargs "^17.0.0" "@naturalcycles/js-lib@^14.0.0", "@naturalcycles/js-lib@^14.116.0", "@naturalcycles/js-lib@^14.47.0": - version "14.204.1" - resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.204.1.tgz#d81838e4a8cd889b734637c2b26a750d5758ef10" - integrity sha512-+2E30+MKFdlxnkbsBHBcbi8aTTPl3AZRe+NUzgimJoJw+7wJS0k6v2DVbrmQ1MCcEyQ4gV5jhOQT8iHEtDDSDw== + version "14.206.0" + resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.206.0.tgz#529be8c590f31cd7dd432032387cca239b860c8f" + integrity sha512-PAoaYwrViznvASPixkaXCvonbaLEHs3yb4maQm5b1SXkiQq6viR8NLzaI+8/Rt3iWveP4BScluYYqfbuPJCtgg== dependencies: tslib "^2.0.0" zod "^3.20.2" "@naturalcycles/nodejs-lib@^13.0.1", "@naturalcycles/nodejs-lib@^13.1.0", "@naturalcycles/nodejs-lib@^13.1.1": - version "13.7.0" - resolved "https://registry.yarnpkg.com/@naturalcycles/nodejs-lib/-/nodejs-lib-13.7.0.tgz#8d49d85d9c3165f20a9bbc08024bc213f5318cae" - integrity sha512-mPGMLS5pBP8U9ToVwM91+7ydir+fCUqYE3NVDotvfQW6jYf+LExKqnyMDGCEnwkGZhkafvGHbHBh5eqluyXsWA== + version "13.7.1" + resolved "https://registry.yarnpkg.com/@naturalcycles/nodejs-lib/-/nodejs-lib-13.7.1.tgz#2369c0a1b28de70bdf87fff067a2e6b2a651c2df" + integrity sha512-y0hVINujeLSVtggnfJEfavZMqLu32/ERIG+EcSgPHK4+MpnKMmpOkh3b59LjaVPs8JDvnCDWRTIPCOOllm1oLw== dependencies: "@naturalcycles/js-lib" "^14.0.0" "@types/js-yaml" "^4.0.9" @@ -918,9 +918,9 @@ integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== "@sinonjs/commons@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.0.tgz#beb434fe875d965265e04722ccfc21df7f755d72" - integrity sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA== + version "3.0.1" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.1.tgz#1029357e44ca901a615585f6d27738dbc89084cd" + integrity sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ== dependencies: type-detect "4.0.8" @@ -1811,9 +1811,9 @@ convert-source-map@^2.0.0: integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== core-js-compat@^3.34.0: - version "3.35.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.35.0.tgz#c149a3d1ab51e743bc1da61e39cb51f461a41873" - integrity sha512-5blwFAddknKeNgsjBzilkdQ0+YK8L1PfqPYq40NOYMYFSS38qj+hpTcLLWwpIwA2A5bje/x5jmVn2tzUMg9IVw== + version "3.35.1" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.35.1.tgz#215247d7edb9e830efa4218ff719beb2803555e2" + integrity sha512-sftHa5qUJY3rs9Zht1WEnmkvXputCyDBczPnr7QDgL8n3qrF3CMXY4VPSYtOLLiOUJcah2WNXREd48iOl6mQIw== dependencies: browserslist "^4.22.2" @@ -1980,9 +1980,9 @@ dot-prop@^5.1.0: is-obj "^2.0.0" dotenv@^16.0.0: - version "16.3.1" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" - integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== + version "16.3.2" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.2.tgz#3cb611ce5a63002dbabf7c281bc331f69d28f03f" + integrity sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ== ecdsa-sig-formatter@1.0.11: version "1.0.11" @@ -1992,9 +1992,9 @@ ecdsa-sig-formatter@1.0.11: safe-buffer "^5.0.1" electron-to-chromium@^1.4.601: - version "1.4.639" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.639.tgz#c6f9cc685f9efb2980d2cfc95a27f8142c9adf28" - integrity sha512-CkKf3ZUVZchr+zDpAlNLEEy2NJJ9T64ULWaDgy3THXXlPVPkLu3VOs9Bac44nebVtdwl2geSj6AxTtGDOxoXhg== + version "1.4.640" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.640.tgz#76290a36fa4b5f1f4cadaf1fc582478ebb3ac246" + integrity sha512-z/6oZ/Muqk4BaE7P69bXhUhpJbUM9ZJeka43ZwxsDshKtePns4mhBlh8bU5+yrnOnz3fhG82XLzGUXazOmsWnA== emittery@^0.13.1: version "0.13.1" @@ -4346,9 +4346,9 @@ reusify@^1.0.4: integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== rfdc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" - integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== + version "1.3.1" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.1.tgz#2b6d4df52dffe8bb346992a10ea9451f24373a8f" + integrity sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg== rimraf@^3.0.2: version "3.0.2"