@naturalcycles/db-lib 10.0.1 → 10.0.2

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 (86) hide show
  1. package/dist/adapter/cachedb/cache.db.d.ts +6 -6
  2. package/dist/adapter/cachedb/cache.db.js +6 -5
  3. package/dist/adapter/cachedb/cache.db.model.d.ts +3 -3
  4. package/dist/adapter/cachedb/index.d.ts +1 -1
  5. package/dist/adapter/file/file.db.d.ts +8 -7
  6. package/dist/adapter/file/file.db.js +11 -10
  7. package/dist/adapter/file/file.db.model.d.ts +2 -2
  8. package/dist/adapter/file/inMemory.persistence.plugin.d.ts +3 -3
  9. package/dist/adapter/file/inMemory.persistence.plugin.js +1 -3
  10. package/dist/adapter/file/index.d.ts +1 -1
  11. package/dist/adapter/file/localFile.persistence.plugin.d.ts +3 -3
  12. package/dist/adapter/file/localFile.persistence.plugin.js +1 -0
  13. package/dist/adapter/file/noop.persistence.plugin.d.ts +3 -3
  14. package/dist/adapter/inmemory/inMemory.db.d.ts +6 -5
  15. package/dist/adapter/inmemory/inMemory.db.js +13 -10
  16. package/dist/adapter/inmemory/inMemoryKeyValueDB.d.ts +4 -4
  17. package/dist/adapter/inmemory/inMemoryKeyValueDB.js +6 -5
  18. package/dist/adapter/inmemory/queryInMemory.d.ts +2 -2
  19. package/dist/base.common.db.d.ts +6 -5
  20. package/dist/base.common.db.js +2 -4
  21. package/dist/common.db.d.ts +3 -3
  22. package/dist/commondao/common.dao.d.ts +9 -6
  23. package/dist/commondao/common.dao.js +6 -2
  24. package/dist/commondao/common.dao.model.d.ts +5 -4
  25. package/dist/db.model.d.ts +2 -2
  26. package/dist/kv/commonKeyValueDB.d.ts +3 -3
  27. package/dist/kv/commonKeyValueDao.d.ts +5 -5
  28. package/dist/kv/commonKeyValueDao.js +1 -0
  29. package/dist/kv/commonKeyValueDaoMemoCache.d.ts +3 -2
  30. package/dist/kv/commonKeyValueDaoMemoCache.js +1 -0
  31. package/dist/model.util.d.ts +1 -1
  32. package/dist/pipeline/dbPipelineBackup.d.ts +5 -3
  33. package/dist/pipeline/dbPipelineCopy.d.ts +6 -4
  34. package/dist/pipeline/dbPipelineRestore.d.ts +6 -4
  35. package/dist/query/dbQuery.d.ts +5 -5
  36. package/dist/query/dbQuery.js +15 -5
  37. package/dist/testing/daoTest.d.ts +2 -2
  38. package/dist/testing/dbTest.d.ts +1 -1
  39. package/dist/testing/index.d.ts +4 -2
  40. package/dist/testing/keyValueDBTest.d.ts +1 -1
  41. package/dist/testing/keyValueDaoTest.d.ts +1 -1
  42. package/dist/testing/test.model.d.ts +1 -1
  43. package/dist/testing/timeSeriesTest.util.d.ts +1 -1
  44. package/dist/timeseries/commonTimeSeriesDao.d.ts +1 -1
  45. package/dist/timeseries/commonTimeSeriesDao.js +1 -0
  46. package/dist/timeseries/timeSeries.model.d.ts +1 -1
  47. package/dist/transaction/dbTransaction.util.d.ts +2 -2
  48. package/dist/transaction/dbTransaction.util.js +1 -0
  49. package/dist/validation/index.d.ts +2 -2
  50. package/package.json +3 -2
  51. package/src/adapter/cachedb/cache.db.model.ts +3 -3
  52. package/src/adapter/cachedb/cache.db.ts +8 -7
  53. package/src/adapter/cachedb/index.ts +1 -1
  54. package/src/adapter/file/file.db.model.ts +2 -2
  55. package/src/adapter/file/file.db.ts +9 -15
  56. package/src/adapter/file/inMemory.persistence.plugin.ts +4 -3
  57. package/src/adapter/file/index.ts +1 -1
  58. package/src/adapter/file/localFile.persistence.plugin.ts +4 -3
  59. package/src/adapter/file/noop.persistence.plugin.ts +3 -3
  60. package/src/adapter/inmemory/inMemory.db.ts +14 -20
  61. package/src/adapter/inmemory/inMemoryKeyValueDB.ts +5 -9
  62. package/src/adapter/inmemory/queryInMemory.ts +3 -2
  63. package/src/base.common.db.ts +6 -5
  64. package/src/common.db.ts +3 -3
  65. package/src/commondao/common.dao.model.ts +5 -6
  66. package/src/commondao/common.dao.ts +25 -21
  67. package/src/db.model.ts +2 -2
  68. package/src/kv/commonKeyValueDB.ts +3 -3
  69. package/src/kv/commonKeyValueDao.ts +7 -5
  70. package/src/kv/commonKeyValueDaoMemoCache.ts +3 -8
  71. package/src/model.util.ts +2 -1
  72. package/src/pipeline/dbPipelineBackup.ts +4 -13
  73. package/src/pipeline/dbPipelineCopy.ts +5 -13
  74. package/src/pipeline/dbPipelineRestore.ts +9 -8
  75. package/src/query/dbQuery.ts +6 -11
  76. package/src/testing/daoTest.ts +3 -3
  77. package/src/testing/dbTest.ts +3 -2
  78. package/src/testing/index.ts +3 -4
  79. package/src/testing/keyValueDBTest.ts +3 -2
  80. package/src/testing/keyValueDaoTest.ts +1 -1
  81. package/src/testing/test.model.ts +2 -7
  82. package/src/testing/timeSeriesTest.util.ts +1 -1
  83. package/src/timeseries/commonTimeSeriesDao.ts +3 -2
  84. package/src/timeseries/timeSeries.model.ts +1 -1
  85. package/src/transaction/dbTransaction.util.ts +2 -2
  86. package/src/validation/index.ts +3 -8
@@ -1,2 +1,2 @@
1
- import { CommonKeyValueDB } from '../kv/commonKeyValueDB';
1
+ import type { CommonKeyValueDB } from '../kv/commonKeyValueDB';
2
2
  export declare function runCommonKeyValueDaoTest(db: CommonKeyValueDB): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { BaseDBEntity, JsonSchemaObject } from '@naturalcycles/js-lib';
1
+ import type { BaseDBEntity, JsonSchemaObject } from '@naturalcycles/js-lib';
2
2
  export declare const TEST_TABLE = "TEST_TABLE";
3
3
  export interface TestItemBM extends BaseDBEntity {
4
4
  k1: string;
@@ -1,2 +1,2 @@
1
- import { TimeSeriesDataPoint } from '../timeseries/timeSeries.model';
1
+ import type { TimeSeriesDataPoint } from '../timeseries/timeSeries.model';
2
2
  export declare function createTestTimeSeries(count?: number): TimeSeriesDataPoint[];
@@ -1,4 +1,4 @@
1
- import { CommonTimeSeriesDaoCfg, TimeSeriesDataPoint, TimeSeriesQuery, TimeSeriesSaveBatchOp } from './timeSeries.model';
1
+ import type { CommonTimeSeriesDaoCfg, TimeSeriesDataPoint, TimeSeriesQuery, TimeSeriesSaveBatchOp } from './timeSeries.model';
2
2
  /**
3
3
  * TimeSeries DB implementation based on provided CommonDB database.
4
4
  * Turns any CommonDB database into TimeSeries DB. Kind of.
@@ -11,6 +11,7 @@ const _TIMESERIES_RAW = '_TIMESERIES_RAW';
11
11
  * @experimental
12
12
  */
13
13
  class CommonTimeSeriesDao {
14
+ cfg;
14
15
  constructor(cfg) {
15
16
  this.cfg = cfg;
16
17
  }
@@ -1,4 +1,4 @@
1
- import { CommonDB } from '../common.db';
1
+ import type { CommonDB } from '../common.db';
2
2
  export interface CommonTimeSeriesDaoCfg {
3
3
  db: CommonDB;
4
4
  }
@@ -1,6 +1,6 @@
1
- import { ObjectWithId } from '@naturalcycles/js-lib';
1
+ import type { ObjectWithId } from '@naturalcycles/js-lib';
2
2
  import type { CommonDB } from '../common.db';
3
- import { CommonDBOptions, CommonDBSaveOptions, DBTransaction } from '../db.model';
3
+ import type { CommonDBOptions, CommonDBSaveOptions, DBTransaction } from '../db.model';
4
4
  /**
5
5
  * Optimizes the Transaction (list of DBOperations) to do less operations.
6
6
  * E.g if you save id1 first and then delete it - this function will turn it into a no-op (self-eliminate).
@@ -91,6 +91,7 @@ export function mergeDBOperations(ops: DBOperation[]): DBOperation[] {
91
91
  * which executes all operations instantly, without any Transaction involved.
92
92
  */
93
93
  class FakeDBTransaction {
94
+ db;
94
95
  constructor(db) {
95
96
  this.db = db;
96
97
  }
@@ -1,5 +1,5 @@
1
- import { CommonDBOptions, CommonDBSaveOptions } from '../db.model';
2
- import { DBQuery, DBQueryFilter, DBQueryFilterOperator, DBQueryOrder } from '../query/dbQuery';
1
+ import type { CommonDBOptions, CommonDBSaveOptions } from '../db.model';
2
+ import type { DBQuery, DBQueryFilter, DBQueryFilterOperator, DBQueryOrder } from '../query/dbQuery';
3
3
  export declare const commonDBOptionsSchema: import("joi").ObjectSchema<CommonDBOptions>;
4
4
  export declare const commonDBSaveOptionsSchema: import("joi").ObjectSchema<CommonDBSaveOptions<any>>;
5
5
  export declare const dbQueryFilterOperatorSchema: import("@naturalcycles/nodejs-lib").StringSchema<DBQueryFilterOperator>;
package/package.json CHANGED
@@ -14,9 +14,10 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@naturalcycles/bench-lib": "^3",
17
- "@naturalcycles/dev-lib": "^16",
17
+ "@naturalcycles/dev-lib": "^17",
18
18
  "@types/node": "^22",
19
19
  "@vitest/coverage-v8": "^3",
20
+ "tsx": "^4",
20
21
  "vitest": "^3"
21
22
  },
22
23
  "files": [
@@ -46,7 +47,7 @@
46
47
  "engines": {
47
48
  "node": ">=22.12.0"
48
49
  },
49
- "version": "10.0.1",
50
+ "version": "10.0.2",
50
51
  "description": "Lowest Common Denominator API to supported Databases",
51
52
  "keywords": [
52
53
  "db",
@@ -1,6 +1,6 @@
1
- import { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2
- import { CommonDB } from '../../common.db'
3
- import {
1
+ import type { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2
+ import type { CommonDB } from '../../common.db'
3
+ import type {
4
4
  CommonDBCreateOptions,
5
5
  CommonDBOptions,
6
6
  CommonDBSaveOptions,
@@ -1,17 +1,18 @@
1
1
  import { Readable } from 'node:stream'
2
- import {
3
- _isTruthy,
2
+ import type {
4
3
  JsonSchemaObject,
5
4
  JsonSchemaRootObject,
6
5
  ObjectWithId,
7
6
  StringMap,
8
7
  } from '@naturalcycles/js-lib'
9
- import { ReadableTyped } from '@naturalcycles/nodejs-lib'
8
+ import { _isTruthy } from '@naturalcycles/js-lib'
9
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
10
10
  import { BaseCommonDB } from '../../base.common.db'
11
- import { CommonDB, commonDBFullSupport, CommonDBSupport } from '../../common.db'
12
- import { RunQueryResult } from '../../db.model'
13
- import { DBQuery } from '../../query/dbQuery'
14
- import {
11
+ import type { CommonDB, CommonDBSupport } from '../../common.db'
12
+ import { commonDBFullSupport } from '../../common.db'
13
+ import type { RunQueryResult } from '../../db.model'
14
+ import type { DBQuery } from '../../query/dbQuery'
15
+ import type {
15
16
  CacheDBCfg,
16
17
  CacheDBCreateOptions,
17
18
  CacheDBOptions,
@@ -1,5 +1,5 @@
1
1
  import { CacheDB } from './cache.db'
2
- import {
2
+ import type {
3
3
  CacheDBCfg,
4
4
  CacheDBCreateOptions,
5
5
  CacheDBOptions,
@@ -1,5 +1,5 @@
1
- import { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2
- import { DBSaveBatchOperation } from '../../db.model'
1
+ import type { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2
+ import type { DBSaveBatchOperation } from '../../db.model'
3
3
  import type { DBQueryOrder } from '../../query/dbQuery'
4
4
 
5
5
  export interface FileDBPersistencePlugin {
@@ -1,3 +1,4 @@
1
+ import type { JsonSchemaRootObject, ObjectWithId, UnixTimestampMillis } from '@naturalcycles/js-lib'
1
2
  import {
2
3
  _assert,
3
4
  _by,
@@ -8,28 +9,21 @@ import {
8
9
  _sortObjectDeep,
9
10
  _stringMapValues,
10
11
  generateJsonSchemaFromData,
11
- JsonSchemaRootObject,
12
12
  localTime,
13
- ObjectWithId,
14
- UnixTimestampMillis,
15
13
  } from '@naturalcycles/js-lib'
16
- import { dimGrey, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
17
- import {
18
- BaseCommonDB,
19
- commonDBFullSupport,
20
- CommonDBSupport,
21
- DBSaveBatchOperation,
22
- queryInMemory,
23
- } from '../..'
24
- import { CommonDB } from '../../common.db'
25
- import {
14
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
15
+ import { dimGrey, readableCreate } from '@naturalcycles/nodejs-lib'
16
+ import type { CommonDBSupport, DBSaveBatchOperation } from '../..'
17
+ import { BaseCommonDB, commonDBFullSupport, queryInMemory } from '../..'
18
+ import type { CommonDB } from '../../common.db'
19
+ import type {
26
20
  CommonDBOptions,
27
21
  CommonDBSaveOptions,
28
22
  CommonDBStreamOptions,
29
23
  RunQueryResult,
30
24
  } from '../../db.model'
31
- import { DBQuery } from '../../query/dbQuery'
32
- import { FileDBCfg } from './file.db.model'
25
+ import type { DBQuery } from '../../query/dbQuery'
26
+ import type { FileDBCfg } from './file.db.model'
33
27
 
34
28
  /**
35
29
  * Provides barebone implementation for "whole file" based CommonDB.
@@ -1,6 +1,7 @@
1
- import { _by, ObjectWithId, StringMap } from '@naturalcycles/js-lib'
2
- import { DBSaveBatchOperation } from '../../db.model'
3
- import { FileDBPersistencePlugin } from './file.db.model'
1
+ import type { ObjectWithId, StringMap } from '@naturalcycles/js-lib'
2
+ import { _by } from '@naturalcycles/js-lib'
3
+ import type { DBSaveBatchOperation } from '../../db.model'
4
+ import type { FileDBPersistencePlugin } from './file.db.model'
4
5
 
5
6
  /**
6
7
  * Mostly useful for testing.
@@ -1,5 +1,5 @@
1
1
  import { FileDB } from './file.db'
2
- import { FileDBCfg, FileDBPersistencePlugin } from './file.db.model'
2
+ import type { FileDBCfg, FileDBPersistencePlugin } from './file.db.model'
3
3
  import { LocalFilePersistencePlugin } from './localFile.persistence.plugin'
4
4
 
5
5
  export type { FileDBCfg, FileDBPersistencePlugin }
@@ -1,8 +1,9 @@
1
1
  import { Readable } from 'node:stream'
2
- import { ObjectWithId, pMap } from '@naturalcycles/js-lib'
2
+ import type { ObjectWithId } from '@naturalcycles/js-lib'
3
+ import { pMap } from '@naturalcycles/js-lib'
3
4
  import { _pipeline, fs2 } from '@naturalcycles/nodejs-lib'
4
- import { DBSaveBatchOperation } from '../../db.model'
5
- import { FileDBPersistencePlugin } from './file.db.model'
5
+ import type { DBSaveBatchOperation } from '../../db.model'
6
+ import type { FileDBPersistencePlugin } from './file.db.model'
6
7
 
7
8
  export interface LocalFilePersistencePluginCfg {
8
9
  /**
@@ -1,6 +1,6 @@
1
- import { ObjectWithId } from '@naturalcycles/js-lib'
2
- import { DBSaveBatchOperation } from '../../db.model'
3
- import { FileDBPersistencePlugin } from './file.db.model'
1
+ import type { ObjectWithId } from '@naturalcycles/js-lib'
2
+ import type { DBSaveBatchOperation } from '../../db.model'
3
+ import type { FileDBPersistencePlugin } from './file.db.model'
4
4
 
5
5
  export class NoopPersistencePlugin implements FileDBPersistencePlugin {
6
6
  async ping(): Promise<void> {}
@@ -1,4 +1,12 @@
1
1
  import { Readable } from 'node:stream'
2
+ import type {
3
+ AnyObjectWithId,
4
+ CommonLogger,
5
+ JsonSchemaObject,
6
+ JsonSchemaRootObject,
7
+ ObjectWithId,
8
+ StringMap,
9
+ } from '@naturalcycles/js-lib'
2
10
  import {
3
11
  _assert,
4
12
  _by,
@@ -8,42 +16,28 @@ import {
8
16
  _sortObjectDeep,
9
17
  _stringMapEntries,
10
18
  _stringMapValues,
11
- AnyObjectWithId,
12
- CommonLogger,
13
19
  generateJsonSchemaFromData,
14
- JsonSchemaObject,
15
- JsonSchemaRootObject,
16
20
  localTime,
17
- ObjectWithId,
18
21
  pMap,
19
- StringMap,
20
22
  } from '@naturalcycles/js-lib'
21
- import {
22
- _pipeline,
23
- bufferReviver,
24
- dimGrey,
25
- fs2,
26
- ReadableTyped,
27
- yellow,
28
- } from '@naturalcycles/nodejs-lib'
29
- import {
23
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
24
+ import { _pipeline, bufferReviver, dimGrey, fs2, yellow } from '@naturalcycles/nodejs-lib'
25
+ import type {
30
26
  CommonDB,
31
- commonDBFullSupport,
32
27
  CommonDBSupport,
33
28
  CommonDBTransactionOptions,
34
- CommonDBType,
35
29
  DBOperation,
36
30
  DBTransactionFn,
37
- queryInMemory,
38
31
  } from '../..'
39
- import {
32
+ import { commonDBFullSupport, CommonDBType, queryInMemory } from '../..'
33
+ import type {
40
34
  CommonDBCreateOptions,
41
35
  CommonDBOptions,
42
36
  CommonDBSaveOptions,
43
37
  DBTransaction,
44
38
  RunQueryResult,
45
39
  } from '../../db.model'
46
- import { DBQuery } from '../../query/dbQuery'
40
+ import type { DBQuery } from '../../query/dbQuery'
47
41
 
48
42
  export interface InMemoryDBCfg {
49
43
  /**
@@ -1,13 +1,9 @@
1
1
  import { Readable } from 'node:stream'
2
- import { StringMap } from '@naturalcycles/js-lib'
3
- import { ReadableTyped } from '@naturalcycles/nodejs-lib'
4
- import { CommonDBCreateOptions } from '../../db.model'
5
- import {
6
- CommonKeyValueDB,
7
- commonKeyValueDBFullSupport,
8
- IncrementTuple,
9
- KeyValueDBTuple,
10
- } from '../../kv/commonKeyValueDB'
2
+ import type { StringMap } from '@naturalcycles/js-lib'
3
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
4
+ import type { CommonDBCreateOptions } from '../../db.model'
5
+ import type { CommonKeyValueDB, IncrementTuple, KeyValueDBTuple } from '../../kv/commonKeyValueDB'
6
+ import { commonKeyValueDBFullSupport } from '../../kv/commonKeyValueDB'
11
7
 
12
8
  export interface InMemoryKeyValueDBCfg {}
13
9
 
@@ -1,5 +1,6 @@
1
- import { _get, _pick, ObjectWithId } from '@naturalcycles/js-lib'
2
- import { DBQuery, DBQueryFilterOperator } from '../../query/dbQuery'
1
+ import type { ObjectWithId } from '@naturalcycles/js-lib'
2
+ import { _get, _pick } from '@naturalcycles/js-lib'
3
+ import type { DBQuery, DBQueryFilterOperator } from '../../query/dbQuery'
3
4
 
4
5
  type FilterFn = (v: any, val: any) => boolean
5
6
  const FILTER_FNS: Record<DBQueryFilterOperator, FilterFn> = {
@@ -1,19 +1,20 @@
1
- import {
1
+ import type {
2
2
  JsonSchemaObject,
3
3
  JsonSchemaRootObject,
4
4
  ObjectWithId,
5
5
  StringMap,
6
6
  } from '@naturalcycles/js-lib'
7
- import { ReadableTyped } from '@naturalcycles/nodejs-lib'
8
- import { CommonDB, CommonDBSupport, CommonDBType } from './common.db'
9
- import {
7
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
8
+ import type { CommonDB, CommonDBSupport } from './common.db'
9
+ import { CommonDBType } from './common.db'
10
+ import type {
10
11
  CommonDBOptions,
11
12
  CommonDBSaveOptions,
12
13
  CommonDBTransactionOptions,
13
14
  DBTransactionFn,
14
15
  RunQueryResult,
15
16
  } from './db.model'
16
- import { DBQuery } from './query/dbQuery'
17
+ import type { DBQuery } from './query/dbQuery'
17
18
  import { FakeDBTransaction } from './transaction/dbTransaction.util'
18
19
 
19
20
  /**
package/src/common.db.ts CHANGED
@@ -1,11 +1,11 @@
1
- import {
1
+ import type {
2
2
  JsonSchemaObject,
3
3
  JsonSchemaRootObject,
4
4
  ObjectWithId,
5
5
  StringMap,
6
6
  } from '@naturalcycles/js-lib'
7
7
  import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
8
- import {
8
+ import type {
9
9
  CommonDBCreateOptions,
10
10
  CommonDBOptions,
11
11
  CommonDBReadOptions,
@@ -15,7 +15,7 @@ import {
15
15
  DBTransactionFn,
16
16
  RunQueryResult,
17
17
  } from './db.model'
18
- import { DBQuery } from './query/dbQuery'
18
+ import type { DBQuery } from './query/dbQuery'
19
19
 
20
20
  export enum CommonDBType {
21
21
  'document' = 'document',
@@ -1,14 +1,13 @@
1
- import {
1
+ import type {
2
2
  BaseDBEntity,
3
3
  CommonLogger,
4
4
  ErrorMode,
5
5
  NumberOfMilliseconds,
6
6
  Promisable,
7
7
  UnixTimestamp,
8
- ZodError,
9
- ZodSchema,
10
8
  } from '@naturalcycles/js-lib'
11
- import {
9
+ import type { ZodError, ZodSchema } from '@naturalcycles/js-lib/dist/zod/index.js'
10
+ import type {
12
11
  AjvSchema,
13
12
  AjvValidationError,
14
13
  JoiValidationError,
@@ -16,8 +15,8 @@ import {
16
15
  TransformLogProgressOptions,
17
16
  TransformMapOptions,
18
17
  } from '@naturalcycles/nodejs-lib'
19
- import { CommonDB } from '../common.db'
20
- import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'
18
+ import type { CommonDB } from '../common.db'
19
+ import type { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'
21
20
 
22
21
  export interface CommonDaoHooks<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID = BM['id']> {
23
22
  /**
@@ -1,4 +1,15 @@
1
- import { Transform } from 'node:stream'
1
+ import type { Transform } from 'node:stream'
2
+ import type {
3
+ AsyncMapper,
4
+ BaseDBEntity,
5
+ CommonLogger,
6
+ JsonSchemaObject,
7
+ JsonSchemaRootObject,
8
+ ObjectWithId,
9
+ StringMap,
10
+ UnixTimestampMillis,
11
+ Unsaved,
12
+ } from '@naturalcycles/js-lib'
2
13
  import {
3
14
  _assert,
4
15
  _deepCopy,
@@ -12,31 +23,23 @@ import {
12
23
  _typeCast,
13
24
  _uniqBy,
14
25
  AppError,
15
- AsyncMapper,
16
- BaseDBEntity,
17
- CommonLogger,
18
26
  ErrorMode,
19
- JsonSchemaObject,
20
- JsonSchemaRootObject,
21
27
  localTime,
22
- ObjectWithId,
23
28
  pMap,
24
29
  SKIP,
25
- StringMap,
26
- UnixTimestampMillis,
27
- Unsaved,
28
- ZodSchema,
29
- ZodValidationError,
30
- zSafeValidate,
31
30
  } from '@naturalcycles/js-lib'
32
- import {
33
- _pipeline,
34
- AjvSchema,
31
+ import type { ZodValidationError } from '@naturalcycles/js-lib/dist/zod/index.js'
32
+ import { ZodSchema, zSafeValidate } from '@naturalcycles/js-lib/dist/zod/index.js'
33
+ import type {
35
34
  AjvValidationError,
36
- getValidationResult,
37
35
  JoiValidationError,
38
36
  ObjectSchema,
39
37
  ReadableTyped,
38
+ } from '@naturalcycles/nodejs-lib'
39
+ import {
40
+ _pipeline,
41
+ AjvSchema,
42
+ getValidationResult,
40
43
  stringId,
41
44
  transformChunk,
42
45
  transformLogProgress,
@@ -45,13 +48,13 @@ import {
45
48
  writableVoid,
46
49
  } from '@naturalcycles/nodejs-lib'
47
50
  import { DBLibError } from '../cnst'
48
- import { CommonDBTransactionOptions, DBTransaction, RunQueryResult } from '../db.model'
49
- import { DBQuery, RunnableDBQuery } from '../query/dbQuery'
50
- import {
51
+ import type { CommonDBTransactionOptions, DBTransaction, RunQueryResult } from '../db.model'
52
+ import type { DBQuery } from '../query/dbQuery'
53
+ import { RunnableDBQuery } from '../query/dbQuery'
54
+ import type {
51
55
  CommonDaoCfg,
52
56
  CommonDaoCreateOptions,
53
57
  CommonDaoHooks,
54
- CommonDaoLogLevel,
55
58
  CommonDaoOptions,
56
59
  CommonDaoPatchByIdOptions,
57
60
  CommonDaoPatchOptions,
@@ -63,6 +66,7 @@ import {
63
66
  CommonDaoStreamOptions,
64
67
  CommonDaoStreamSaveOptions,
65
68
  } from './common.dao.model'
69
+ import { CommonDaoLogLevel } from './common.dao.model'
66
70
 
67
71
  const isGAE = !!process.env['GAE_INSTANCE']
68
72
  const isCI = !!process.env['CI']
package/src/db.model.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ObjectWithId, UnixTimestamp } from '@naturalcycles/js-lib'
2
- import { CommonDB } from './common.db'
1
+ import type { ObjectWithId, UnixTimestamp } from '@naturalcycles/js-lib'
2
+ import type { CommonDB } from './common.db'
3
3
 
4
4
  /**
5
5
  * Similar to SQL INSERT, UPDATE.
@@ -1,6 +1,6 @@
1
- import { Integer, UnixTimestamp } from '@naturalcycles/js-lib'
2
- import { ReadableTyped } from '@naturalcycles/nodejs-lib'
3
- import { CommonDBCreateOptions } from '../db.model'
1
+ import type { Integer, UnixTimestamp } from '@naturalcycles/js-lib'
2
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
3
+ import type { CommonDBCreateOptions } from '../db.model'
4
4
 
5
5
  /**
6
6
  * Common interface for Key-Value database implementations.
@@ -1,8 +1,10 @@
1
- import { AppError, CommonLogger, KeyValueTuple, pMap } from '@naturalcycles/js-lib'
2
- import { deflateString, inflateToString, ReadableTyped } from '@naturalcycles/nodejs-lib'
3
- import { CommonDaoLogLevel } from '../commondao/common.dao.model'
4
- import { CommonDBCreateOptions } from '../db.model'
5
- import {
1
+ import type { CommonLogger, KeyValueTuple } from '@naturalcycles/js-lib'
2
+ import { AppError, pMap } from '@naturalcycles/js-lib'
3
+ import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
4
+ import { deflateString, inflateToString } from '@naturalcycles/nodejs-lib'
5
+ import type { CommonDaoLogLevel } from '../commondao/common.dao.model'
6
+ import type { CommonDBCreateOptions } from '../db.model'
7
+ import type {
6
8
  CommonKeyValueDB,
7
9
  CommonKeyValueDBSaveBatchOptions,
8
10
  IncrementTuple,
@@ -1,11 +1,6 @@
1
- import {
2
- AsyncMemoCache,
3
- localTime,
4
- MISS,
5
- NumberOfSeconds,
6
- UnixTimestamp,
7
- } from '@naturalcycles/js-lib'
8
- import { CommonKeyValueDao } from './commonKeyValueDao'
1
+ import type { AsyncMemoCache, NumberOfSeconds, UnixTimestamp } from '@naturalcycles/js-lib'
2
+ import { localTime, MISS } from '@naturalcycles/js-lib'
3
+ import type { CommonKeyValueDao } from './commonKeyValueDao'
9
4
 
10
5
  export interface CommonKeyValueDaoMemoCacheCfg<VALUE> {
11
6
  dao: CommonKeyValueDao<string, VALUE>
package/src/model.util.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { CreatedUpdated, CreatedUpdatedId, localTime } from '@naturalcycles/js-lib'
1
+ import type { CreatedUpdated, CreatedUpdatedId } from '@naturalcycles/js-lib'
2
+ import { localTime } from '@naturalcycles/js-lib'
2
3
  import { stringId } from '@naturalcycles/nodejs-lib'
3
4
 
4
5
  export function createdUpdatedFields(
@@ -1,13 +1,6 @@
1
- import {
2
- _passthroughMapper,
3
- AppError,
4
- AsyncMapper,
5
- ErrorMode,
6
- localTime,
7
- pMap,
8
- StringMap,
9
- UnixTimestamp,
10
- } from '@naturalcycles/js-lib'
1
+ import type { AsyncMapper, StringMap, UnixTimestamp } from '@naturalcycles/js-lib'
2
+ import { _passthroughMapper, AppError, ErrorMode, localTime, pMap } from '@naturalcycles/js-lib'
3
+ import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib'
11
4
  import {
12
5
  _pipeline,
13
6
  boldWhite,
@@ -16,13 +9,11 @@ import {
16
9
  grey,
17
10
  NDJsonStats,
18
11
  transformLogProgress,
19
- TransformLogProgressOptions,
20
12
  transformMap,
21
- TransformMapOptions,
22
13
  transformTap,
23
14
  yellow,
24
15
  } from '@naturalcycles/nodejs-lib'
25
- import { CommonDB } from '../common.db'
16
+ import type { CommonDB } from '../common.db'
26
17
  import { DBQuery } from '../index'
27
18
 
28
19
  export interface DBPipelineBackupOptions extends TransformLogProgressOptions {
@@ -1,12 +1,6 @@
1
- import {
2
- _passthroughMapper,
3
- AsyncMapper,
4
- BaseDBEntity,
5
- ErrorMode,
6
- localTime,
7
- pMap,
8
- UnixTimestamp,
9
- } from '@naturalcycles/js-lib'
1
+ import type { AsyncMapper, BaseDBEntity, UnixTimestamp } from '@naturalcycles/js-lib'
2
+ import { _passthroughMapper, ErrorMode, localTime, pMap } from '@naturalcycles/js-lib'
3
+ import type { TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib'
10
4
  import {
11
5
  _pipeline,
12
6
  boldWhite,
@@ -15,15 +9,13 @@ import {
15
9
  NDJsonStats,
16
10
  transformChunk,
17
11
  transformLogProgress,
18
- TransformLogProgressOptions,
19
12
  transformMap,
20
- TransformMapOptions,
21
13
  transformTap,
22
14
  writableForEach,
23
15
  yellow,
24
16
  } from '@naturalcycles/nodejs-lib'
25
- import { CommonDB } from '../common.db'
26
- import { CommonDBSaveOptions } from '../db.model'
17
+ import type { CommonDB } from '../common.db'
18
+ import type { CommonDBSaveOptions } from '../db.model'
27
19
  import { DBQuery } from '../query/dbQuery'
28
20
 
29
21
  export interface DBPipelineCopyOptions extends TransformLogProgressOptions {