@naturalcycles/db-lib 10.5.0 → 10.7.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.
Files changed (94) hide show
  1. package/dist/adapter/cachedb/cache.db.d.ts +4 -3
  2. package/dist/adapter/cachedb/cache.db.js +2 -2
  3. package/dist/adapter/cachedb/cache.db.model.d.ts +3 -2
  4. package/dist/adapter/file/file.db.d.ts +4 -3
  5. package/dist/adapter/file/file.db.js +10 -5
  6. package/dist/adapter/file/file.db.model.d.ts +2 -1
  7. package/dist/adapter/file/inMemory.persistence.plugin.d.ts +1 -1
  8. package/dist/adapter/file/localFile.persistence.plugin.d.ts +1 -1
  9. package/dist/adapter/file/localFile.persistence.plugin.js +5 -5
  10. package/dist/adapter/file/noop.persistence.plugin.d.ts +1 -1
  11. package/dist/commondao/common.dao.d.ts +3 -1
  12. package/dist/commondao/common.dao.js +7 -1
  13. package/dist/commondao/common.dao.model.d.ts +4 -2
  14. package/dist/commondao/index.d.ts +2 -0
  15. package/dist/commondao/index.js +2 -0
  16. package/dist/{base.common.db.d.ts → commondb/base.common.db.d.ts} +4 -3
  17. package/dist/{base.common.db.js → commondb/base.common.db.js} +1 -1
  18. package/dist/{common.db.d.ts → commondb/common.db.d.ts} +4 -3
  19. package/dist/db.model.d.ts +2 -2
  20. package/dist/index.d.ts +2 -13
  21. package/dist/index.js +2 -13
  22. package/dist/{adapter/inmemory → inmemory}/inMemory.db.d.ts +7 -5
  23. package/dist/{adapter/inmemory → inmemory}/inMemory.db.js +13 -7
  24. package/dist/{adapter/inmemory → inmemory}/inMemoryKeyValueDB.d.ts +3 -3
  25. package/dist/{adapter/inmemory → inmemory}/inMemoryKeyValueDB.js +1 -1
  26. package/dist/inmemory/index.d.ts +3 -0
  27. package/dist/inmemory/index.js +3 -0
  28. package/dist/inmemory/queryInMemory.d.ts +3 -0
  29. package/dist/{adapter/inmemory → inmemory}/queryInMemory.js +1 -1
  30. package/dist/kv/commonKeyValueDB.d.ts +1 -1
  31. package/dist/kv/commonKeyValueDao.d.ts +2 -1
  32. package/dist/kv/commonKeyValueDao.js +3 -2
  33. package/dist/kv/commonKeyValueDaoMemoCache.d.ts +3 -2
  34. package/dist/kv/commonKeyValueDaoMemoCache.js +2 -1
  35. package/dist/kv/index.d.ts +3 -0
  36. package/dist/kv/index.js +3 -0
  37. package/dist/model.util.d.ts +1 -1
  38. package/dist/model.util.js +1 -1
  39. package/dist/pipeline/dbPipelineBackup.d.ts +4 -4
  40. package/dist/pipeline/dbPipelineBackup.js +8 -4
  41. package/dist/pipeline/dbPipelineCopy.d.ts +3 -3
  42. package/dist/pipeline/dbPipelineCopy.js +5 -2
  43. package/dist/pipeline/dbPipelineRestore.d.ts +4 -4
  44. package/dist/pipeline/dbPipelineRestore.js +10 -4
  45. package/dist/pipeline/index.d.ts +3 -0
  46. package/dist/pipeline/index.js +3 -0
  47. package/dist/query/dbQuery.d.ts +1 -1
  48. package/dist/query/dbQuery.js +2 -1
  49. package/dist/testing/commonDBTest.d.ts +1 -1
  50. package/dist/testing/commonDBTest.js +5 -2
  51. package/dist/testing/commonDaoTest.d.ts +1 -1
  52. package/dist/testing/commonDaoTest.js +3 -1
  53. package/dist/testing/test.model.d.ts +2 -1
  54. package/dist/testing/test.model.js +2 -1
  55. package/dist/timeseries/timeSeries.model.d.ts +1 -1
  56. package/dist/transaction/dbTransaction.util.d.ts +2 -2
  57. package/package.json +8 -4
  58. package/src/adapter/cachedb/cache.db.model.ts +3 -2
  59. package/src/adapter/cachedb/cache.db.ts +5 -9
  60. package/src/adapter/file/file.db.model.ts +2 -1
  61. package/src/adapter/file/file.db.ts +14 -16
  62. package/src/adapter/file/inMemory.persistence.plugin.ts +1 -1
  63. package/src/adapter/file/localFile.persistence.plugin.ts +10 -6
  64. package/src/adapter/file/noop.persistence.plugin.ts +1 -1
  65. package/src/commondao/common.dao.model.ts +4 -4
  66. package/src/commondao/common.dao.ts +15 -22
  67. package/src/commondao/index.ts +2 -0
  68. package/src/{base.common.db.ts → commondb/base.common.db.ts} +7 -11
  69. package/src/{common.db.ts → commondb/common.db.ts} +4 -8
  70. package/src/db.model.ts +2 -2
  71. package/src/index.ts +2 -13
  72. package/src/{adapter/inmemory → inmemory}/inMemory.db.ts +30 -27
  73. package/src/{adapter/inmemory → inmemory}/inMemoryKeyValueDB.ts +4 -8
  74. package/src/inmemory/index.ts +3 -0
  75. package/src/{adapter/inmemory → inmemory}/queryInMemory.ts +3 -3
  76. package/src/kv/commonKeyValueDB.ts +1 -1
  77. package/src/kv/commonKeyValueDao.ts +5 -3
  78. package/src/kv/commonKeyValueDaoMemoCache.ts +4 -2
  79. package/src/kv/index.ts +3 -0
  80. package/src/model.util.ts +2 -2
  81. package/src/pipeline/dbPipelineBackup.ts +13 -9
  82. package/src/pipeline/dbPipelineCopy.ts +7 -4
  83. package/src/pipeline/dbPipelineRestore.ts +15 -20
  84. package/src/pipeline/index.ts +3 -0
  85. package/src/query/dbQuery.ts +3 -2
  86. package/src/testing/commonDBTest.ts +6 -3
  87. package/src/testing/commonDaoTest.ts +4 -2
  88. package/src/testing/keyValueDBTest.ts +1 -1
  89. package/src/testing/test.model.ts +4 -2
  90. package/src/timeseries/commonTimeSeriesDao.ts +1 -1
  91. package/src/timeseries/timeSeries.model.ts +1 -1
  92. package/src/transaction/dbTransaction.util.ts +2 -2
  93. package/dist/adapter/inmemory/queryInMemory.d.ts +0 -3
  94. /package/dist/{common.db.js → commondb/common.db.js} +0 -0
@@ -1,22 +1,17 @@
1
- import type {
2
- AsyncMapper,
3
- BaseDBEntity,
4
- JsonSchemaObject,
5
- UnixTimestamp,
6
- } from '@naturalcycles/js-lib'
1
+ import { _hb } from '@naturalcycles/js-lib'
2
+ import { localTime } from '@naturalcycles/js-lib/datetime'
3
+ import { ErrorMode } from '@naturalcycles/js-lib/error'
4
+ import type { JsonSchemaObject } from '@naturalcycles/js-lib/json-schema'
5
+ import { _mapValues } from '@naturalcycles/js-lib/object'
6
+ import { pMap } from '@naturalcycles/js-lib/promise'
7
+ import type { AsyncMapper, BaseDBEntity, UnixTimestamp } from '@naturalcycles/js-lib/types'
8
+ import { _passthroughMapper } from '@naturalcycles/js-lib/types'
9
+ import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib/colors'
10
+ import { fs2 } from '@naturalcycles/nodejs-lib/fs2'
7
11
  import {
8
- _hb,
9
- _mapValues,
10
- _passthroughMapper,
11
- ErrorMode,
12
- localTime,
13
- pMap,
14
- } from '@naturalcycles/js-lib'
15
- import { boldWhite, dimWhite, grey, yellow } from '@naturalcycles/nodejs-lib'
16
- import { fs2 } from '@naturalcycles/nodejs-lib/fs'
17
- import type {
18
- TransformLogProgressOptions,
19
- TransformMapOptions,
12
+ createReadStreamAsNDJSON,
13
+ type TransformLogProgressOptions,
14
+ type TransformMapOptions,
20
15
  } from '@naturalcycles/nodejs-lib/stream'
21
16
  import {
22
17
  _pipeline,
@@ -28,7 +23,7 @@ import {
28
23
  transformTap,
29
24
  writableForEach,
30
25
  } from '@naturalcycles/nodejs-lib/stream'
31
- import type { CommonDB } from '../common.db.js'
26
+ import type { CommonDB } from '../commondb/common.db.js'
32
27
  import type { CommonDBSaveOptions } from '../db.model.js'
33
28
 
34
29
  export interface DBPipelineRestoreOptions extends TransformLogProgressOptions {
@@ -200,7 +195,7 @@ export async function dbPipelineRestore(opt: DBPipelineRestoreOptions): Promise<
200
195
  console.log(`<< ${grey(filePath)} ${dimWhite(_hb(sizeBytes))} started...`)
201
196
 
202
197
  await _pipeline([
203
- fs2.createReadStreamAsNDJSON(filePath).take(limit || Number.POSITIVE_INFINITY),
198
+ createReadStreamAsNDJSON(filePath).take(limit || Number.POSITIVE_INFINITY),
204
199
  transformTap(() => rows++),
205
200
  transformLogProgress({
206
201
  logEvery: 1000,
@@ -0,0 +1,3 @@
1
+ export * from './dbPipelineBackup.js'
2
+ export * from './dbPipelineCopy.js'
3
+ export * from './dbPipelineRestore.js'
@@ -1,5 +1,6 @@
1
- import type { AsyncIndexedMapper, BaseDBEntity, ObjectWithId } from '@naturalcycles/js-lib'
2
- import { _objectAssign, _truncate } from '@naturalcycles/js-lib'
1
+ import { _truncate } from '@naturalcycles/js-lib/string'
2
+ import type { AsyncIndexedMapper, BaseDBEntity, ObjectWithId } from '@naturalcycles/js-lib/types'
3
+ import { _objectAssign } from '@naturalcycles/js-lib/types'
3
4
  import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
4
5
  import type { CommonDao } from '../commondao/common.dao.js'
5
6
  import type {
@@ -1,6 +1,9 @@
1
- import { _deepFreeze, _filterObject, _pick, _sortBy, localTime, pMap } from '@naturalcycles/js-lib'
2
- import type { CommonDB } from '../common.db.js'
3
- import { CommonDBType } from '../common.db.js'
1
+ import { _sortBy } from '@naturalcycles/js-lib'
2
+ import { localTime } from '@naturalcycles/js-lib/datetime'
3
+ import { _deepFreeze, _filterObject, _pick } from '@naturalcycles/js-lib/object'
4
+ import { pMap } from '@naturalcycles/js-lib/promise'
5
+ import type { CommonDB } from '../commondb/common.db.js'
6
+ import { CommonDBType } from '../commondb/common.db.js'
4
7
  import { DBQuery } from '../query/dbQuery.js'
5
8
  import type { TestItemDBM } from './test.model.js'
6
9
  import {
@@ -1,9 +1,11 @@
1
1
  import { Readable } from 'node:stream'
2
- import { _deepCopy, _filterObject, _omit, _pick, _sortBy, localTime } from '@naturalcycles/js-lib'
2
+ import { _sortBy } from '@naturalcycles/js-lib'
3
+ import { localTime } from '@naturalcycles/js-lib/datetime'
4
+ import { _deepCopy, _filterObject, _omit, _pick } from '@naturalcycles/js-lib/object'
3
5
  import { _pipeline } from '@naturalcycles/nodejs-lib/stream'
4
- import type { CommonDB } from '../common.db.js'
5
6
  import { CommonDao } from '../commondao/common.dao.js'
6
7
  import { CommonDaoLogLevel } from '../commondao/common.dao.model.js'
8
+ import type { CommonDB } from '../commondb/common.db.js'
7
9
  import { DBQuery } from '../query/dbQuery.js'
8
10
  import type { CommonDBImplementationQuirks } from './commonDBTest.js'
9
11
  import type { TestItemBM } from './test.model.js'
@@ -1,5 +1,5 @@
1
- import type { KeyValueTuple } from '@naturalcycles/js-lib'
2
1
  import { _range, _sortBy } from '@naturalcycles/js-lib'
2
+ import type { KeyValueTuple } from '@naturalcycles/js-lib/types'
3
3
  import type { CommonKeyValueDB } from '../kv/commonKeyValueDB.js'
4
4
  import { TEST_TABLE } from './test.model.js'
5
5
 
@@ -1,5 +1,7 @@
1
- import type { BaseDBEntity, JsonSchemaObject, UnixTimestamp } from '@naturalcycles/js-lib'
2
- import { _range, jsonSchema } from '@naturalcycles/js-lib'
1
+ import { _range } from '@naturalcycles/js-lib'
2
+ import type { JsonSchemaObject } from '@naturalcycles/js-lib/json-schema'
3
+ import { jsonSchema } from '@naturalcycles/js-lib/json-schema'
4
+ import type { BaseDBEntity, UnixTimestamp } from '@naturalcycles/js-lib/types'
3
5
  import {
4
6
  baseDBEntitySchema,
5
7
  binarySchema,
@@ -1,5 +1,5 @@
1
- import type { ObjectWithId } from '@naturalcycles/js-lib'
2
1
  import { _isTruthy } from '@naturalcycles/js-lib'
2
+ import type { ObjectWithId } from '@naturalcycles/js-lib/types'
3
3
  import { DBQuery } from '../query/dbQuery.js'
4
4
  import type {
5
5
  CommonTimeSeriesDaoCfg,
@@ -1,4 +1,4 @@
1
- import type { CommonDB } from '../common.db.js'
1
+ import type { CommonDB } from '../commondb/common.db.js'
2
2
 
3
3
  export interface CommonTimeSeriesDaoCfg {
4
4
  db: CommonDB
@@ -1,5 +1,5 @@
1
- import type { ObjectWithId } from '@naturalcycles/js-lib'
2
- import type { CommonDB } from '../common.db.js'
1
+ import type { ObjectWithId } from '@naturalcycles/js-lib/types'
2
+ import type { CommonDB } from '../commondb/common.db.js'
3
3
  import type { CommonDBOptions, CommonDBSaveOptions, DBTransaction } from '../db.model.js'
4
4
 
5
5
  /**
@@ -1,3 +0,0 @@
1
- import type { ObjectWithId } from '@naturalcycles/js-lib';
2
- import type { DBQuery } from '../../query/dbQuery.js';
3
- export declare function queryInMemory<ROW extends ObjectWithId>(q: DBQuery<ROW>, rows?: ROW[]): ROW[];
File without changes