@naturalcycles/db-lib 10.0.2 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/cachedb/cache.db.d.ts +5 -5
- package/dist/adapter/cachedb/cache.db.js +8 -12
- package/dist/adapter/cachedb/cache.db.model.d.ts +2 -2
- package/dist/adapter/cachedb/cache.db.model.js +1 -2
- package/dist/adapter/cachedb/index.d.ts +2 -2
- package/dist/adapter/cachedb/index.js +2 -5
- package/dist/adapter/file/file.db.d.ts +5 -6
- package/dist/adapter/file/file.db.js +25 -27
- package/dist/adapter/file/file.db.model.d.ts +2 -2
- package/dist/adapter/file/file.db.model.js +1 -2
- package/dist/adapter/file/inMemory.persistence.plugin.d.ts +2 -2
- package/dist/adapter/file/inMemory.persistence.plugin.js +3 -7
- package/dist/adapter/file/index.d.ts +3 -3
- package/dist/adapter/file/index.js +3 -7
- package/dist/adapter/file/localFile.persistence.plugin.d.ts +2 -2
- package/dist/adapter/file/localFile.persistence.plugin.js +11 -15
- package/dist/adapter/file/noop.persistence.plugin.d.ts +2 -2
- package/dist/adapter/file/noop.persistence.plugin.js +1 -5
- package/dist/adapter/inmemory/inMemory.db.d.ts +5 -4
- package/dist/adapter/inmemory/inMemory.db.js +43 -41
- package/dist/adapter/inmemory/inMemoryKeyValueDB.d.ts +2 -2
- package/dist/adapter/inmemory/inMemoryKeyValueDB.js +7 -11
- package/dist/adapter/inmemory/queryInMemory.d.ts +1 -1
- package/dist/adapter/inmemory/queryInMemory.js +4 -7
- package/dist/base.common.db.d.ts +6 -4
- package/dist/base.common.db.js +8 -9
- package/dist/cnst.js +2 -5
- package/dist/common.db.d.ts +8 -2
- package/dist/common.db.js +3 -6
- package/dist/commondao/common.dao.d.ts +11 -4
- package/dist/commondao/common.dao.js +120 -113
- package/dist/commondao/common.dao.model.d.ts +2 -2
- package/dist/commondao/common.dao.model.js +2 -5
- package/dist/db.model.d.ts +6 -1
- package/dist/db.model.js +4 -7
- package/dist/index.d.ts +17 -17
- package/dist/index.js +17 -20
- package/dist/kv/commonKeyValueDB.d.ts +1 -1
- package/dist/kv/commonKeyValueDB.js +1 -4
- package/dist/kv/commonKeyValueDao.d.ts +3 -3
- package/dist/kv/commonKeyValueDao.js +10 -14
- package/dist/kv/commonKeyValueDaoMemoCache.d.ts +1 -1
- package/dist/kv/commonKeyValueDaoMemoCache.js +4 -8
- package/dist/model.util.js +9 -15
- package/dist/pipeline/dbPipelineBackup.d.ts +2 -2
- package/dist/pipeline/dbPipelineBackup.js +27 -30
- package/dist/pipeline/dbPipelineCopy.d.ts +2 -2
- package/dist/pipeline/dbPipelineCopy.js +20 -23
- package/dist/pipeline/dbPipelineRestore.d.ts +2 -2
- package/dist/pipeline/dbPipelineRestore.js +27 -30
- package/dist/query/dbQuery.d.ts +3 -3
- package/dist/query/dbQuery.js +7 -12
- package/dist/testing/{dbTest.d.ts → commonDBTest.d.ts} +1 -1
- package/dist/testing/{dbTest.js → commonDBTest.js} +81 -62
- package/dist/testing/commonDaoTest.d.ts +3 -0
- package/dist/testing/{daoTest.js → commonDaoTest.js} +101 -38
- package/dist/testing/index.d.ts +7 -7
- package/dist/testing/index.js +6 -20
- package/dist/testing/keyValueDBTest.d.ts +1 -1
- package/dist/testing/keyValueDBTest.js +28 -31
- package/dist/testing/keyValueDaoTest.d.ts +1 -1
- package/dist/testing/keyValueDaoTest.js +8 -11
- package/dist/testing/test.model.js +30 -37
- package/dist/testing/timeSeriesTest.util.d.ts +1 -1
- package/dist/testing/timeSeriesTest.util.js +3 -6
- package/dist/timeseries/commonTimeSeriesDao.d.ts +1 -1
- package/dist/timeseries/commonTimeSeriesDao.js +5 -9
- package/dist/timeseries/timeSeries.model.d.ts +1 -1
- package/dist/timeseries/timeSeries.model.js +1 -2
- package/dist/transaction/dbTransaction.util.d.ts +3 -2
- package/dist/transaction/dbTransaction.util.js +2 -5
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +25 -28
- package/package.json +3 -3
- package/src/adapter/cachedb/cache.db.model.ts +2 -2
- package/src/adapter/cachedb/cache.db.ts +6 -6
- package/src/adapter/cachedb/index.ts +2 -2
- package/src/adapter/file/file.db.model.ts +2 -2
- package/src/adapter/file/file.db.ts +8 -6
- package/src/adapter/file/inMemory.persistence.plugin.ts +2 -2
- package/src/adapter/file/index.ts +3 -3
- package/src/adapter/file/localFile.persistence.plugin.ts +2 -2
- package/src/adapter/file/noop.persistence.plugin.ts +2 -2
- package/src/adapter/inmemory/inMemory.db.ts +15 -10
- package/src/adapter/inmemory/inMemoryKeyValueDB.ts +7 -3
- package/src/adapter/inmemory/queryInMemory.ts +1 -1
- package/src/base.common.db.ts +9 -5
- package/src/common.db.ts +10 -2
- package/src/commondao/common.dao.model.ts +2 -2
- package/src/commondao/common.dao.ts +20 -6
- package/src/db.model.ts +7 -1
- package/src/index.ts +17 -17
- package/src/kv/commonKeyValueDB.ts +1 -1
- package/src/kv/commonKeyValueDao.ts +3 -3
- package/src/kv/commonKeyValueDaoMemoCache.ts +1 -1
- package/src/pipeline/dbPipelineBackup.ts +2 -2
- package/src/pipeline/dbPipelineCopy.ts +3 -3
- package/src/pipeline/dbPipelineRestore.ts +2 -2
- package/src/query/dbQuery.ts +3 -3
- package/src/testing/{dbTest.ts → commonDBTest.ts} +34 -6
- package/src/testing/{daoTest.ts → commonDaoTest.ts} +89 -11
- package/src/testing/index.ts +7 -7
- package/src/testing/keyValueDBTest.ts +2 -2
- package/src/testing/keyValueDaoTest.ts +3 -3
- package/src/testing/timeSeriesTest.util.ts +1 -1
- package/src/timeseries/commonTimeSeriesDao.ts +2 -2
- package/src/timeseries/timeSeries.model.ts +1 -1
- package/src/transaction/dbTransaction.util.ts +3 -2
- package/src/validation/index.ts +8 -3
- package/dist/testing/daoTest.d.ts +0 -3
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
transformTap,
|
|
14
14
|
yellow,
|
|
15
15
|
} from '@naturalcycles/nodejs-lib'
|
|
16
|
-
import type { CommonDB } from '../common.db'
|
|
17
|
-
import { DBQuery } from '../
|
|
16
|
+
import type { CommonDB } from '../common.db.js'
|
|
17
|
+
import { DBQuery } from '../query/dbQuery.js'
|
|
18
18
|
|
|
19
19
|
export interface DBPipelineBackupOptions extends TransformLogProgressOptions {
|
|
20
20
|
/**
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
writableForEach,
|
|
15
15
|
yellow,
|
|
16
16
|
} from '@naturalcycles/nodejs-lib'
|
|
17
|
-
import type { CommonDB } from '../common.db'
|
|
18
|
-
import type { CommonDBSaveOptions } from '../db.model'
|
|
19
|
-
import { DBQuery } from '../query/dbQuery'
|
|
17
|
+
import type { CommonDB } from '../common.db.js'
|
|
18
|
+
import type { CommonDBSaveOptions } from '../db.model.js'
|
|
19
|
+
import { DBQuery } from '../query/dbQuery.js'
|
|
20
20
|
|
|
21
21
|
export interface DBPipelineCopyOptions extends TransformLogProgressOptions {
|
|
22
22
|
dbInput: CommonDB
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
writableForEach,
|
|
29
29
|
yellow,
|
|
30
30
|
} from '@naturalcycles/nodejs-lib'
|
|
31
|
-
import type { CommonDB } from '../common.db'
|
|
32
|
-
import type { CommonDBSaveOptions } from '../
|
|
31
|
+
import type { CommonDB } from '../common.db.js'
|
|
32
|
+
import type { CommonDBSaveOptions } from '../db.model.js'
|
|
33
33
|
|
|
34
34
|
export interface DBPipelineRestoreOptions extends TransformLogProgressOptions {
|
|
35
35
|
/**
|
package/src/query/dbQuery.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { AsyncMapper, BaseDBEntity, ObjectWithId } from '@naturalcycles/js-lib'
|
|
2
2
|
import { _objectAssign, _truncate } from '@naturalcycles/js-lib'
|
|
3
3
|
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
4
|
+
import type { CommonDao } from '../commondao/common.dao.js'
|
|
4
5
|
import type {
|
|
5
6
|
CommonDaoOptions,
|
|
6
7
|
CommonDaoReadOptions,
|
|
7
8
|
CommonDaoStreamDeleteOptions,
|
|
8
9
|
CommonDaoStreamForEachOptions,
|
|
9
10
|
CommonDaoStreamOptions,
|
|
10
|
-
} from '
|
|
11
|
-
import type {
|
|
12
|
-
import type { RunQueryResult } from '../db.model'
|
|
11
|
+
} from '../commondao/common.dao.model.js'
|
|
12
|
+
import type { RunQueryResult } from '../db.model.js'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Modeled after Firestore operators (WhereFilterOp type)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { _deepFreeze, _filterObject, _pick, _sortBy, localTime, pMap } from '@naturalcycles/js-lib'
|
|
2
|
-
import type { CommonDB } from '../common.db'
|
|
3
|
-
import { CommonDBType } from '../common.db'
|
|
4
|
-
import { DBQuery } from '../query/dbQuery'
|
|
5
|
-
import type { TestItemDBM } from './test.model'
|
|
2
|
+
import type { CommonDB } from '../common.db.js'
|
|
3
|
+
import { CommonDBType } from '../common.db.js'
|
|
4
|
+
import { DBQuery } from '../query/dbQuery.js'
|
|
5
|
+
import type { TestItemDBM } from './test.model.js'
|
|
6
6
|
import {
|
|
7
7
|
createTestItemDBM,
|
|
8
8
|
createTestItemsDBM,
|
|
9
9
|
TEST_TABLE,
|
|
10
10
|
testItemBMJsonSchema,
|
|
11
|
-
} from './test.model'
|
|
11
|
+
} from './test.model.js'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* All options default to `false`.
|
|
@@ -294,6 +294,18 @@ export async function runCommonDBTest(
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
if (support.transactions) {
|
|
297
|
+
/**
|
|
298
|
+
* Returns expected items in the DB after the preparation.
|
|
299
|
+
*/
|
|
300
|
+
async function prepare(): Promise<TestItemDBM[]> {
|
|
301
|
+
// cleanup
|
|
302
|
+
await db.deleteByQuery(queryAll())
|
|
303
|
+
|
|
304
|
+
const itemsToSave: TestItemDBM[] = [items[0]!, { ...items[2]!, k1: 'k1_mod' }]
|
|
305
|
+
await db.saveBatch(TEST_TABLE, itemsToSave)
|
|
306
|
+
return itemsToSave
|
|
307
|
+
}
|
|
308
|
+
|
|
297
309
|
test('transaction happy path', async () => {
|
|
298
310
|
// cleanup
|
|
299
311
|
await db.deleteByQuery(queryAll())
|
|
@@ -313,7 +325,24 @@ export async function runCommonDBTest(
|
|
|
313
325
|
expectMatch(expected, rows, quirks)
|
|
314
326
|
})
|
|
315
327
|
|
|
328
|
+
test('createTransaction happy path', async () => {
|
|
329
|
+
// cleanup
|
|
330
|
+
await db.deleteByQuery(queryAll())
|
|
331
|
+
|
|
332
|
+
const tx = await db.createTransaction()
|
|
333
|
+
await tx.saveBatch(TEST_TABLE, items)
|
|
334
|
+
await tx.saveBatch(TEST_TABLE, [{ ...items[2]!, k1: 'k1_mod' }])
|
|
335
|
+
await tx.deleteByIds(TEST_TABLE, [items[1]!.id])
|
|
336
|
+
await tx.commit()
|
|
337
|
+
|
|
338
|
+
const { rows } = await db.runQuery(queryAll())
|
|
339
|
+
const expected = [items[0], { ...items[2]!, k1: 'k1_mod' }]
|
|
340
|
+
expectMatch(expected, rows, quirks)
|
|
341
|
+
})
|
|
342
|
+
|
|
316
343
|
test('transaction rollback', async () => {
|
|
344
|
+
const expected = await prepare()
|
|
345
|
+
|
|
317
346
|
let err: any
|
|
318
347
|
|
|
319
348
|
try {
|
|
@@ -329,7 +358,6 @@ export async function runCommonDBTest(
|
|
|
329
358
|
expect(err).toBeDefined()
|
|
330
359
|
|
|
331
360
|
const { rows } = await db.runQuery(queryAll())
|
|
332
|
-
const expected = [items[0], { ...items[2]!, k1: 'k1_mod' }]
|
|
333
361
|
expectMatch(expected, rows, quirks)
|
|
334
362
|
})
|
|
335
363
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import { _deepCopy, _filterObject, _omit, _pick, _sortBy, localTime } from '@naturalcycles/js-lib'
|
|
3
3
|
import { _pipeline } from '@naturalcycles/nodejs-lib'
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import type { CommonDBImplementationQuirks } from './
|
|
4
|
+
import type { CommonDB } from '../common.db.js'
|
|
5
|
+
import { CommonDao } from '../commondao/common.dao.js'
|
|
6
|
+
import { CommonDaoLogLevel } from '../commondao/common.dao.model.js'
|
|
7
|
+
import { DBQuery } from '../query/dbQuery.js'
|
|
8
|
+
import type { CommonDBImplementationQuirks } from './commonDBTest.js'
|
|
9
|
+
import type { TestItemBM } from './test.model.js'
|
|
9
10
|
import {
|
|
10
11
|
createTestItemBM,
|
|
11
12
|
createTestItemsBM,
|
|
12
13
|
TEST_TABLE,
|
|
13
14
|
testItemBMJsonSchema,
|
|
14
15
|
testItemBMSchema,
|
|
15
|
-
} from './test.model'
|
|
16
|
+
} from './test.model.js'
|
|
16
17
|
|
|
17
18
|
export async function runCommonDaoTest(
|
|
18
19
|
db: CommonDB,
|
|
@@ -308,6 +309,18 @@ export async function runCommonDaoTest(
|
|
|
308
309
|
}
|
|
309
310
|
|
|
310
311
|
if (support.transactions) {
|
|
312
|
+
/**
|
|
313
|
+
* Returns expected items in the DB after the preparation.
|
|
314
|
+
*/
|
|
315
|
+
async function prepare(): Promise<TestItemBM[]> {
|
|
316
|
+
// cleanup
|
|
317
|
+
await dao.query().deleteByQuery()
|
|
318
|
+
|
|
319
|
+
const itemsToSave: TestItemBM[] = [items[0]!, { ...items[2]!, k1: 'k1_mod' }]
|
|
320
|
+
await dao.saveBatch(itemsToSave)
|
|
321
|
+
return itemsToSave
|
|
322
|
+
}
|
|
323
|
+
|
|
311
324
|
test('transaction happy path', async () => {
|
|
312
325
|
// cleanup
|
|
313
326
|
await dao.query().deleteByQuery()
|
|
@@ -345,16 +358,81 @@ export async function runCommonDaoTest(
|
|
|
345
358
|
expectMatch(expected, rows, quirks)
|
|
346
359
|
})
|
|
347
360
|
|
|
361
|
+
test('createTransaction happy path', async () => {
|
|
362
|
+
// cleanup
|
|
363
|
+
await dao.query().deleteByQuery()
|
|
364
|
+
|
|
365
|
+
// Test that id, created, updated are created
|
|
366
|
+
const now = localTime.nowUnix()
|
|
367
|
+
|
|
368
|
+
const row = _omit(item1, ['id', 'created', 'updated'])
|
|
369
|
+
let tx = await dao.createTransaction()
|
|
370
|
+
await tx.save(dao, row)
|
|
371
|
+
await tx.commit()
|
|
372
|
+
|
|
373
|
+
const loaded = await dao.query().runQuery()
|
|
374
|
+
expect(loaded.length).toBe(1)
|
|
375
|
+
expect(loaded[0]!.id).toBeDefined()
|
|
376
|
+
expect(loaded[0]!.created).toBeGreaterThanOrEqual(now)
|
|
377
|
+
expect(loaded[0]!.updated).toBe(loaded[0]!.created)
|
|
378
|
+
|
|
379
|
+
tx = await dao.createTransaction()
|
|
380
|
+
await tx.deleteById(dao, loaded[0]!.id)
|
|
381
|
+
await tx.commit()
|
|
382
|
+
|
|
383
|
+
// saveBatch [item1, 2, 3]
|
|
384
|
+
// save item3 with k1: k1_mod
|
|
385
|
+
// delete item2
|
|
386
|
+
// remaining: item1, item3_with_k1_mod
|
|
387
|
+
tx = await dao.createTransaction()
|
|
388
|
+
await tx.saveBatch(dao, items)
|
|
389
|
+
await tx.save(dao, { ...items[2]!, k1: 'k1_mod' })
|
|
390
|
+
await tx.deleteById(dao, items[1]!.id)
|
|
391
|
+
await tx.commit()
|
|
392
|
+
|
|
393
|
+
const rows = await dao.query().runQuery()
|
|
394
|
+
const expected = [items[0], { ...items[2]!, k1: 'k1_mod' }]
|
|
395
|
+
expectMatch(expected, rows, quirks)
|
|
396
|
+
})
|
|
397
|
+
|
|
348
398
|
test('transaction rollback', async () => {
|
|
349
|
-
await
|
|
350
|
-
|
|
399
|
+
const expected = await prepare()
|
|
400
|
+
|
|
401
|
+
let err: any
|
|
402
|
+
|
|
403
|
+
try {
|
|
404
|
+
await dao.runInTransaction(async tx => {
|
|
351
405
|
await tx.deleteById(dao, items[2]!.id)
|
|
352
406
|
await tx.save(dao, { ...items[0]!, k1: 5 as any }) // it should fail here
|
|
353
|
-
})
|
|
354
|
-
|
|
407
|
+
})
|
|
408
|
+
} catch (err_) {
|
|
409
|
+
err = err_
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
expect(err).toBeDefined()
|
|
413
|
+
expect(err).toBeInstanceOf(Error)
|
|
414
|
+
|
|
415
|
+
const rows = await dao.query().runQuery()
|
|
416
|
+
expectMatch(expected, rows, quirks)
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
test('createTransaction rollback', async () => {
|
|
420
|
+
const expected = await prepare()
|
|
421
|
+
|
|
422
|
+
let err: any
|
|
423
|
+
try {
|
|
424
|
+
const tx = await dao.createTransaction()
|
|
425
|
+
await tx.deleteById(dao, items[2]!.id)
|
|
426
|
+
await tx.save(dao, { ...items[0]!, k1: 5 as any }) // it should fail here
|
|
427
|
+
await tx.commit()
|
|
428
|
+
} catch (err_) {
|
|
429
|
+
err = err_
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
expect(err).toBeDefined()
|
|
433
|
+
expect(err).toBeInstanceOf(Error)
|
|
355
434
|
|
|
356
435
|
const rows = await dao.query().runQuery()
|
|
357
|
-
const expected = [items[0], { ...items[2]!, k1: 'k1_mod' }]
|
|
358
436
|
expectMatch(expected, rows, quirks)
|
|
359
437
|
})
|
|
360
438
|
|
package/src/testing/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { runCommonDaoTest } from './
|
|
2
|
-
import type { CommonDBImplementationQuirks } from './
|
|
3
|
-
import { runCommonDBTest } from './
|
|
4
|
-
import { runCommonKeyValueDaoTest } from './keyValueDaoTest'
|
|
5
|
-
import { runCommonKeyValueDBTest } from './keyValueDBTest'
|
|
6
|
-
import type { TestItemBM, TestItemDBM, TestItemTM } from './test.model'
|
|
1
|
+
import { runCommonDaoTest } from './commonDaoTest.js'
|
|
2
|
+
import type { CommonDBImplementationQuirks } from './commonDBTest.js'
|
|
3
|
+
import { runCommonDBTest } from './commonDBTest.js'
|
|
4
|
+
import { runCommonKeyValueDaoTest } from './keyValueDaoTest.js'
|
|
5
|
+
import { runCommonKeyValueDBTest } from './keyValueDBTest.js'
|
|
6
|
+
import type { TestItemBM, TestItemDBM, TestItemTM } from './test.model.js'
|
|
7
7
|
import {
|
|
8
8
|
createTestItemBM,
|
|
9
9
|
createTestItemDBM,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
testItemBMJsonSchema,
|
|
14
14
|
testItemBMSchema,
|
|
15
15
|
testItemTMSchema,
|
|
16
|
-
} from './test.model'
|
|
16
|
+
} from './test.model.js'
|
|
17
17
|
|
|
18
18
|
export type { CommonDBImplementationQuirks, TestItemBM, TestItemDBM, TestItemTM }
|
|
19
19
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { KeyValueTuple } from '@naturalcycles/js-lib'
|
|
2
2
|
import { _range, _sortBy } from '@naturalcycles/js-lib'
|
|
3
|
-
import type { CommonKeyValueDB } from '../kv/commonKeyValueDB'
|
|
4
|
-
import { TEST_TABLE } from './test.model'
|
|
3
|
+
import type { CommonKeyValueDB } from '../kv/commonKeyValueDB.js'
|
|
4
|
+
import { TEST_TABLE } from './test.model.js'
|
|
5
5
|
|
|
6
6
|
const testIds = _range(1, 4).map(n => `id${n}`)
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _sortBy } from '@naturalcycles/js-lib'
|
|
2
|
-
import { CommonKeyValueDao } from '../kv/commonKeyValueDao'
|
|
3
|
-
import type { CommonKeyValueDB, KeyValueDBTuple } from '../kv/commonKeyValueDB'
|
|
4
|
-
import { createTestItemsBM, TEST_TABLE } from './test.model'
|
|
2
|
+
import { CommonKeyValueDao } from '../kv/commonKeyValueDao.js'
|
|
3
|
+
import type { CommonKeyValueDB, KeyValueDBTuple } from '../kv/commonKeyValueDB.js'
|
|
4
|
+
import { createTestItemsBM, TEST_TABLE } from './test.model.js'
|
|
5
5
|
|
|
6
6
|
const testItems = createTestItemsBM(4)
|
|
7
7
|
const testIds = testItems.map(e => e.id)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _randomInt, _range } from '@naturalcycles/js-lib'
|
|
2
|
-
import type { TimeSeriesDataPoint } from '../timeseries/timeSeries.model'
|
|
2
|
+
import type { TimeSeriesDataPoint } from '../timeseries/timeSeries.model.js'
|
|
3
3
|
|
|
4
4
|
export function createTestTimeSeries(count = 10): TimeSeriesDataPoint[] {
|
|
5
5
|
const ts = Date.now()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ObjectWithId } from '@naturalcycles/js-lib'
|
|
2
2
|
import { _isTruthy } from '@naturalcycles/js-lib'
|
|
3
|
-
import { DBQuery } from '../query/dbQuery'
|
|
3
|
+
import { DBQuery } from '../query/dbQuery.js'
|
|
4
4
|
import type {
|
|
5
5
|
CommonTimeSeriesDaoCfg,
|
|
6
6
|
TimeSeriesDataPoint,
|
|
7
7
|
TimeSeriesQuery,
|
|
8
8
|
TimeSeriesRow,
|
|
9
9
|
TimeSeriesSaveBatchOp,
|
|
10
|
-
} from './timeSeries.model'
|
|
10
|
+
} from './timeSeries.model.js'
|
|
11
11
|
|
|
12
12
|
const _TIMESERIES_RAW = '_TIMESERIES_RAW'
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ObjectWithId } from '@naturalcycles/js-lib'
|
|
2
|
-
import type { CommonDB } from '../common.db'
|
|
3
|
-
import type { CommonDBOptions, CommonDBSaveOptions, DBTransaction } from '../db.model'
|
|
2
|
+
import type { CommonDB } from '../common.db.js'
|
|
3
|
+
import type { CommonDBOptions, CommonDBSaveOptions, DBTransaction } from '../db.model.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Optimizes the Transaction (list of DBOperations) to do less operations.
|
|
@@ -98,6 +98,7 @@ export class FakeDBTransaction implements DBTransaction {
|
|
|
98
98
|
constructor(protected db: CommonDB) {}
|
|
99
99
|
|
|
100
100
|
// no-op
|
|
101
|
+
async commit(): Promise<void> {}
|
|
101
102
|
async rollback(): Promise<void> {}
|
|
102
103
|
|
|
103
104
|
async getByIds<ROW extends ObjectWithId>(
|
package/src/validation/index.ts
CHANGED
|
@@ -7,9 +7,14 @@ import {
|
|
|
7
7
|
objectSchema,
|
|
8
8
|
stringSchema,
|
|
9
9
|
} from '@naturalcycles/nodejs-lib'
|
|
10
|
-
import type { CommonDBOptions, CommonDBSaveOptions } from '../db.model'
|
|
11
|
-
import type {
|
|
12
|
-
|
|
10
|
+
import type { CommonDBOptions, CommonDBSaveOptions } from '../db.model.js'
|
|
11
|
+
import type {
|
|
12
|
+
DBQuery,
|
|
13
|
+
DBQueryFilter,
|
|
14
|
+
DBQueryFilterOperator,
|
|
15
|
+
DBQueryOrder,
|
|
16
|
+
} from '../query/dbQuery.js'
|
|
17
|
+
import { dbQueryFilterOperatorValues } from '../query/dbQuery.js'
|
|
13
18
|
|
|
14
19
|
export const commonDBOptionsSchema = objectSchema<CommonDBOptions>({
|
|
15
20
|
['onlyCache' as any]: booleanSchema.optional(),
|