Skip to content

Commit

Permalink
fix: deps
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jan 21, 2024
1 parent 015be46 commit f2e69c5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 55 deletions.
46 changes: 20 additions & 26 deletions src/airtableDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import {
_omit,
_mapValues,
AnyObject,
PartialObjectWithId,
AnyPartialObjectWithId,
Saved,
ObjectWithId,
} from '@naturalcycles/js-lib'
import { _inspect, ReadableTyped } from '@naturalcycles/nodejs-lib'
Expand Down Expand Up @@ -73,7 +70,7 @@ export interface AirtableDBOptions extends CommonDBOptions {
idField?: string
}
export type AirtableDBStreamOptions = CommonDBStreamOptions
export interface AirtableDBSaveOptions<ROW extends PartialObjectWithId = AnyPartialObjectWithId>
export interface AirtableDBSaveOptions<ROW extends ObjectWithId>
extends AirtableDBOptions,
CommonDBSaveOptions<ROW> {}

Expand Down Expand Up @@ -114,11 +111,11 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
// impossible to implement without having a baseId and a known Table name there
}

override async getByIds<ROW extends PartialObjectWithId>(
override async getByIds<ROW extends ObjectWithId>(
table: string,
ids: string[],
opt: AirtableDBOptions = {},
): Promise<Saved<ROW>[]> {
): Promise<ROW[]> {
if (!ids.length) return []

const { idField = 'id' } = opt
Expand Down Expand Up @@ -177,7 +174,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
/**
* Does "upsert" always
*/
override async saveBatch<ROW extends PartialObjectWithId>(
override async saveBatch<ROW extends ObjectWithId>(
table: string,
rows: ROW[],
opt?: AirtableDBSaveOptions<ROW>,
Expand All @@ -187,7 +184,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {

const existingRows = await this.getByIds<ROW & ObjectWithId & AirtableRecord>(
table,
rows.map(r => r.id!),
rows.map(r => r.id),
opt,
)
const existingRowById = _by(existingRows, r => r.id)
Expand All @@ -196,9 +193,9 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
await pMap(
rows,
async r => {
if (existingRowById[r.id!]) {
if (existingRowById[r.id]) {
// console.log(`will update ${r.id} to ${existingRowById[r.id]!.airtableId}`)
await this.updateRecord(table, existingRowById[r.id!]!.airtableId, r)
await this.updateRecord(table, existingRowById[r.id]!.airtableId, r)
} else {
await this.createRecord(table, r)
}
Expand All @@ -207,10 +204,10 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
)
}

override async runQuery<ROW extends PartialObjectWithId>(
override async runQuery<ROW extends ObjectWithId>(
q: DBQuery<ROW>,
opt: AirtableDBOptions = {},
): Promise<RunQueryResult<Saved<ROW>>> {
): Promise<RunQueryResult<ROW>> {
const selectOpts = dbQueryToAirtableSelectOptions<ROW>(q, opt)
// console.log({selectOpts})

Expand All @@ -227,20 +224,20 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
}
}

override async runQueryCount<ROW extends PartialObjectWithId>(
override async runQueryCount<ROW extends ObjectWithId>(
q: DBQuery<ROW>,
opt?: AirtableDBOptions,
): Promise<number> {
return (await this.runQuery(q.select([]), opt)).rows.length
}

override async deleteByQuery<ROW extends PartialObjectWithId>(
override async deleteByQuery<ROW extends ObjectWithId>(
q: DBQuery<ROW>,
opt?: AirtableDBOptions,
): Promise<number> {
const { rows } = await this.runQuery<ROW & AirtableRecord>(q.select([]), opt)

const tableApi = this.tableApi<PartialObjectWithId>(q.table)
const tableApi = this.tableApi<ObjectWithId>(q.table)

await pMap(
rows.map(r => r.airtableId),
Expand All @@ -258,10 +255,10 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
/**
* Streaming is emulated by just returning the results of the query as a stream.
*/
override streamQuery<ROW extends PartialObjectWithId>(
override streamQuery<ROW extends ObjectWithId>(
q: DBQuery<ROW>,
opt?: AirtableDBStreamOptions,
): ReadableTyped<Saved<ROW>> {
): ReadableTyped<ROW> {
const readable = new Readable({
objectMode: true,
read() {},
Expand All @@ -275,7 +272,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
return readable
}

private tableApi<ROW extends PartialObjectWithId>(table: string): AirtableApiTable<ROW> {
private tableApi<ROW extends ObjectWithId>(table: string): AirtableApiTable<ROW> {
let { baseId } = this.cfg

if (!baseId) {
Expand All @@ -291,13 +288,13 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
return this.api.base(baseId)<ROW>(table)
}

private async queryAirtableRecords<ROW extends PartialObjectWithId>(
private async queryAirtableRecords<ROW extends ObjectWithId>(
table: string,
selectOpts: AirtableApiSelectOpts<ROW>,
opt: AirtableDBOptions,
q?: DBQuery<ROW>,
): Promise<Saved<ROW>[]> {
const records = await this.tableApi<Saved<ROW>>(table)
): Promise<ROW[]> {
const records = await this.tableApi<ROW>(table)
.select({
// defaults
pageSize: 100,
Expand Down Expand Up @@ -334,10 +331,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
return rows
}

async createRecord<ROW extends PartialObjectWithId>(
table: string,
record: Partial<ROW>,
): Promise<ROW> {
async createRecord<ROW extends ObjectWithId>(table: string, record: Partial<ROW>): Promise<ROW> {
// pre-save validation is skipped, cause we'll need to "omit" the `airtableId` from schema
const raw = await this.tableApi<ROW>(table)
.create(_omit(record, ['airtableId'] as any))
Expand All @@ -346,7 +340,7 @@ export class AirtableDB extends BaseCommonDB implements CommonDB {
return this.mapToAirtableRecord(raw)
}

private async updateRecord<ROW extends PartialObjectWithId>(
private async updateRecord<ROW extends ObjectWithId>(
table: string,
airtableId: string,
patch: Partial<ROW>,
Expand Down
4 changes: 2 additions & 2 deletions src/query.util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DBQuery, DBQueryFilterOperator } from '@naturalcycles/db-lib'
import { _uniq, PartialObjectWithId } from '@naturalcycles/js-lib'
import { _uniq, ObjectWithId } from '@naturalcycles/js-lib'
import { AirtableApiSelectOpts } from './airtable.api'
import { AirtableDBOptions } from './airtableDB'

Expand All @@ -10,7 +10,7 @@ const OP_MAP: Partial<Record<DBQueryFilterOperator, string>> = {
/**
* https://support.airtable.com/hc/en-us/articles/203255215-Formula-Field-Reference
*/
export function dbQueryToAirtableSelectOptions<ROW extends PartialObjectWithId>(
export function dbQueryToAirtableSelectOptions<ROW extends ObjectWithId>(
q: DBQuery<ROW>,
opt: AirtableDBOptions,
): AirtableApiSelectOpts<ROW> {
Expand Down
54 changes: 27 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -842,17 +842,17 @@
yargs "^17.0.0"

"@naturalcycles/js-lib@^14.0.0", "@naturalcycles/js-lib@^14.116.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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -1827,9 +1827,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"

Expand Down Expand Up @@ -1996,9 +1996,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==

[email protected]:
version "1.0.11"
Expand All @@ -2008,9 +2008,9 @@ [email protected]:
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"
Expand Down Expand Up @@ -4351,9 +4351,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"
Expand Down

0 comments on commit f2e69c5

Please sign in to comment.