From 015be46f9ec39406e33a323eb23f28ed9c606511 Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Fri, 19 Jan 2024 13:05:15 +0100 Subject: [PATCH] fix: deps --- src/airtableDB.ts | 43 ++++++++++++++++++++++++------------------- src/query.util.ts | 4 ++-- yarn.lock | 30 +++++++++++++++--------------- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/airtableDB.ts b/src/airtableDB.ts index b6a8149..0108063 100644 --- a/src/airtableDB.ts +++ b/src/airtableDB.ts @@ -17,10 +17,12 @@ import { pMap, _by, _omit, - AnyObjectWithId, - ObjectWithId, _mapValues, AnyObject, + PartialObjectWithId, + AnyPartialObjectWithId, + Saved, + ObjectWithId, } from '@naturalcycles/js-lib' import { _inspect, ReadableTyped } from '@naturalcycles/nodejs-lib' import { @@ -71,7 +73,7 @@ export interface AirtableDBOptions extends CommonDBOptions { idField?: string } export type AirtableDBStreamOptions = CommonDBStreamOptions -export interface AirtableDBSaveOptions = AnyObjectWithId> +export interface AirtableDBSaveOptions extends AirtableDBOptions, CommonDBSaveOptions {} @@ -112,11 +114,11 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { // impossible to implement without having a baseId and a known Table name there } - override async getByIds( + override async getByIds( table: string, ids: string[], opt: AirtableDBOptions = {}, - ): Promise { + ): Promise[]> { if (!ids.length) return [] const { idField = 'id' } = opt @@ -175,7 +177,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { /** * Does "upsert" always */ - override async saveBatch>( + override async saveBatch( table: string, rows: ROW[], opt?: AirtableDBSaveOptions, @@ -205,10 +207,10 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { ) } - override async runQuery( + override async runQuery( q: DBQuery, opt: AirtableDBOptions = {}, - ): Promise> { + ): Promise>> { const selectOpts = dbQueryToAirtableSelectOptions(q, opt) // console.log({selectOpts}) @@ -225,20 +227,20 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { } } - override async runQueryCount( + override async runQueryCount( q: DBQuery, opt?: AirtableDBOptions, ): Promise { return (await this.runQuery(q.select([]), opt)).rows.length } - override async deleteByQuery( + override async deleteByQuery( q: DBQuery, opt?: AirtableDBOptions, ): Promise { const { rows } = await this.runQuery(q.select([]), opt) - const tableApi = this.tableApi(q.table) + const tableApi = this.tableApi(q.table) await pMap( rows.map(r => r.airtableId), @@ -256,10 +258,10 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { /** * Streaming is emulated by just returning the results of the query as a stream. */ - override streamQuery( + override streamQuery( q: DBQuery, opt?: AirtableDBStreamOptions, - ): ReadableTyped { + ): ReadableTyped> { const readable = new Readable({ objectMode: true, read() {}, @@ -273,7 +275,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { return readable } - private tableApi(table: string): AirtableApiTable { + private tableApi(table: string): AirtableApiTable { let { baseId } = this.cfg if (!baseId) { @@ -289,13 +291,13 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { return this.api.base(baseId)(table) } - private async queryAirtableRecords( + private async queryAirtableRecords( table: string, selectOpts: AirtableApiSelectOpts, opt: AirtableDBOptions, q?: DBQuery, - ): Promise { - const records = await this.tableApi(table) + ): Promise[]> { + const records = await this.tableApi>(table) .select({ // defaults pageSize: 100, @@ -332,7 +334,10 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { return rows } - async createRecord(table: string, record: Partial): Promise { + async createRecord( + table: string, + record: Partial, + ): Promise { // pre-save validation is skipped, cause we'll need to "omit" the `airtableId` from schema const raw = await this.tableApi(table) .create(_omit(record, ['airtableId'] as any)) @@ -341,7 +346,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB { return this.mapToAirtableRecord(raw) } - private async updateRecord( + private async updateRecord( table: string, airtableId: string, patch: Partial, diff --git a/src/query.util.ts b/src/query.util.ts index 5703be4..c6de0d0 100644 --- a/src/query.util.ts +++ b/src/query.util.ts @@ -1,5 +1,5 @@ import { DBQuery, DBQueryFilterOperator } from '@naturalcycles/db-lib' -import { _uniq, ObjectWithId } from '@naturalcycles/js-lib' +import { _uniq, PartialObjectWithId } from '@naturalcycles/js-lib' import { AirtableApiSelectOpts } from './airtable.api' import { AirtableDBOptions } from './airtableDB' @@ -10,7 +10,7 @@ const OP_MAP: Partial> = { /** * https://support.airtable.com/hc/en-us/articles/203255215-Formula-Field-Reference */ -export function dbQueryToAirtableSelectOptions( +export function dbQueryToAirtableSelectOptions( q: DBQuery, opt: AirtableDBOptions, ): AirtableApiSelectOpts { diff --git a/yarn.lock b/yarn.lock index 4647b4c..4565996 100644 --- a/yarn.lock +++ b/yarn.lock @@ -799,9 +799,9 @@ typescript "^5.0.2" "@naturalcycles/db-lib@^9.1.0": - version "9.1.0" - resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.1.0.tgz#4c2d206301caeb67381713566d1945df91435a1f" - integrity sha512-qAJai7bRWY37+Wo/p8KyxaJ+d1UE2XIgIZoc8dcdYtB3XyEUjz3ZNNA4GeurgtxOBqeD5U0UxcOHbijJaHyzCg== + 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== dependencies: "@naturalcycles/js-lib" "^14.116.0" "@naturalcycles/nodejs-lib" "^13.1.1" @@ -842,9 +842,9 @@ yargs "^17.0.0" "@naturalcycles/js-lib@^14.0.0", "@naturalcycles/js-lib@^14.116.0": - version "14.201.1" - resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.201.1.tgz#67d7b74be557385736b489c4ab6f318cf8d093cf" - integrity sha512-NAxPDWxNiFs8Eidj4vt0jcRyvLJ2MuHmPuryIETvKRLfdQ3j14XfZbvCtNMfmX1Yfl0an0xE5fKN2yzKKJk0LQ== + 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== dependencies: tslib "^2.0.0" zod "^3.20.2" @@ -1658,9 +1658,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001565: - version "1.0.30001578" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001578.tgz#11741580434ce60aae4b4a9abee9f9f8d7bf5be5" - integrity sha512-J/jkFgsQ3NEl4w2lCoM9ZPxrD+FoBNJ7uJUpGVjIg/j0OwJosWM36EPDv+Yyi0V4twBk9pPmlFS+PLykgEvUmg== + version "1.0.30001579" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz#45c065216110f46d6274311a4b3fcf6278e0852a" + integrity sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA== chalk@5.3.0: version "5.3.0" @@ -2008,9 +2008,9 @@ ecdsa-sig-formatter@1.0.11: safe-buffer "^5.0.1" electron-to-chromium@^1.4.601: - version "1.4.636" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.636.tgz#302cf4c3016d9d714ba246243a7c97b528e22fe7" - integrity sha512-NLE0GIy1OL9wRiKL20h9TkctBEYZuc99tquSS9MVdTahnuHputoETHeqDzgqGqyOY9NUH0g9wjfEuw5OD+wRcQ== + version "1.4.639" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.639.tgz#c6f9cc685f9efb2980d2cfc95a27f8142c9adf28" + integrity sha512-CkKf3ZUVZchr+zDpAlNLEEy2NJJ9T64ULWaDgy3THXXlPVPkLu3VOs9Bac44nebVtdwl2geSj6AxTtGDOxoXhg== emittery@^0.13.1: version "0.13.1" @@ -3431,9 +3431,9 @@ jiti@^1.19.1: integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q== joi@^17.9.2: - version "17.11.1" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.11.1.tgz#f42951137d25c27f61807502b0af71f7abb885ba" - integrity sha512-671acnrx+w96PCcQOzvm0VYQVwNL2PVgZmDRaFuSsx8sIUmGzYElPw5lU8F3Cr0jOuPs1oM56p7W2a1cdDOwcw== + version "17.12.0" + resolved "https://registry.yarnpkg.com/joi/-/joi-17.12.0.tgz#a3fb5715f198beb0471cd551dd26792089c308d5" + integrity sha512-HSLsmSmXz+PV9PYoi3p7cgIbj06WnEBNT28n+bbBNcPZXZFqCzzvGqpTBPujx/Z0nh1+KNQPDrNgdmQ8dq0qYw== dependencies: "@hapi/hoek" "^9.3.0" "@hapi/topo" "^5.1.0"