@naturalcycles/db-lib 10.0.0 → 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 (90) 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 +3 -3
  38. package/dist/testing/daoTest.js +89 -74
  39. package/dist/testing/dbTest.d.ts +2 -3
  40. package/dist/testing/dbTest.js +68 -68
  41. package/dist/testing/index.d.ts +4 -2
  42. package/dist/testing/keyValueDBTest.d.ts +2 -2
  43. package/dist/testing/keyValueDBTest.js +37 -37
  44. package/dist/testing/keyValueDaoTest.d.ts +2 -2
  45. package/dist/testing/keyValueDaoTest.js +33 -33
  46. package/dist/testing/test.model.d.ts +1 -1
  47. package/dist/testing/timeSeriesTest.util.d.ts +1 -1
  48. package/dist/timeseries/commonTimeSeriesDao.d.ts +1 -1
  49. package/dist/timeseries/commonTimeSeriesDao.js +1 -0
  50. package/dist/timeseries/timeSeries.model.d.ts +1 -1
  51. package/dist/transaction/dbTransaction.util.d.ts +2 -2
  52. package/dist/transaction/dbTransaction.util.js +1 -0
  53. package/dist/validation/index.d.ts +2 -2
  54. package/package.json +3 -2
  55. package/src/adapter/cachedb/cache.db.model.ts +3 -3
  56. package/src/adapter/cachedb/cache.db.ts +8 -7
  57. package/src/adapter/cachedb/index.ts +1 -1
  58. package/src/adapter/file/file.db.model.ts +2 -2
  59. package/src/adapter/file/file.db.ts +9 -15
  60. package/src/adapter/file/inMemory.persistence.plugin.ts +4 -3
  61. package/src/adapter/file/index.ts +1 -1
  62. package/src/adapter/file/localFile.persistence.plugin.ts +4 -3
  63. package/src/adapter/file/noop.persistence.plugin.ts +3 -3
  64. package/src/adapter/inmemory/inMemory.db.ts +14 -20
  65. package/src/adapter/inmemory/inMemoryKeyValueDB.ts +5 -9
  66. package/src/adapter/inmemory/queryInMemory.ts +3 -2
  67. package/src/base.common.db.ts +6 -5
  68. package/src/common.db.ts +3 -3
  69. package/src/commondao/common.dao.model.ts +5 -6
  70. package/src/commondao/common.dao.ts +25 -21
  71. package/src/db.model.ts +2 -2
  72. package/src/kv/commonKeyValueDB.ts +3 -3
  73. package/src/kv/commonKeyValueDao.ts +7 -5
  74. package/src/kv/commonKeyValueDaoMemoCache.ts +3 -8
  75. package/src/model.util.ts +2 -1
  76. package/src/pipeline/dbPipelineBackup.ts +4 -13
  77. package/src/pipeline/dbPipelineCopy.ts +5 -13
  78. package/src/pipeline/dbPipelineRestore.ts +9 -8
  79. package/src/query/dbQuery.ts +6 -11
  80. package/src/testing/daoTest.ts +28 -6
  81. package/src/testing/dbTest.ts +24 -22
  82. package/src/testing/index.ts +3 -4
  83. package/src/testing/keyValueDBTest.ts +6 -4
  84. package/src/testing/keyValueDaoTest.ts +4 -3
  85. package/src/testing/test.model.ts +2 -7
  86. package/src/testing/timeSeriesTest.util.ts +1 -1
  87. package/src/timeseries/commonTimeSeriesDao.ts +3 -2
  88. package/src/timeseries/timeSeries.model.ts +1 -1
  89. package/src/transaction/dbTransaction.util.ts +2 -2
  90. package/src/validation/index.ts +3 -8
@@ -2,20 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCommonKeyValueDaoTest = runCommonKeyValueDaoTest;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
- const vitest_1 = require("vitest");
6
5
  const commonKeyValueDao_1 = require("../kv/commonKeyValueDao");
7
6
  const test_model_1 = require("./test.model");
8
7
  const testItems = (0, test_model_1.createTestItemsBM)(4);
9
8
  const testIds = testItems.map(e => e.id);
10
9
  const testEntries = testItems.map(e => [e.id, Buffer.from(`${e.id}value`)]);
11
- function runCommonKeyValueDaoTest(db) {
10
+ async function runCommonKeyValueDaoTest(db) {
11
+ const { afterAll, beforeAll, expect, test } = await import('vitest');
12
12
  const dao = new commonKeyValueDao_1.CommonKeyValueDao({
13
13
  db,
14
14
  table: test_model_1.TEST_TABLE,
15
15
  // todo: make this test support "deflatedJson" transformer
16
16
  });
17
17
  const { support } = db;
18
- (0, vitest_1.beforeAll)(async () => {
18
+ beforeAll(async () => {
19
19
  // Tests in this suite are not isolated,
20
20
  // and failing tests can leave the DB in an unexpected state for other tests,
21
21
  // including the following test run.
@@ -23,92 +23,92 @@ function runCommonKeyValueDaoTest(db) {
23
23
  const ids = await dao.streamIds().toArray();
24
24
  await dao.deleteByIds(ids);
25
25
  });
26
- (0, vitest_1.afterAll)(async () => {
26
+ afterAll(async () => {
27
27
  const ids = await dao.streamIds().toArray();
28
28
  await dao.deleteByIds(ids);
29
29
  });
30
- (0, vitest_1.test)('ping', async () => {
30
+ test('ping', async () => {
31
31
  await dao.ping();
32
32
  });
33
- (0, vitest_1.test)('createTable', async () => {
33
+ test('createTable', async () => {
34
34
  await dao.createTable({ dropIfExists: true });
35
35
  });
36
- (0, vitest_1.test)('deleteByIds non existing', async () => {
36
+ test('deleteByIds non existing', async () => {
37
37
  await dao.deleteByIds(testIds);
38
38
  });
39
- (0, vitest_1.test)('getByIds should return empty', async () => {
39
+ test('getByIds should return empty', async () => {
40
40
  const results = await dao.getByIds(testIds);
41
- (0, vitest_1.expect)(results).toEqual([]);
41
+ expect(results).toEqual([]);
42
42
  });
43
- (0, vitest_1.test)('saveBatch, then getByIds', async () => {
43
+ test('saveBatch, then getByIds', async () => {
44
44
  await dao.saveBatch(testEntries);
45
45
  const entries = await dao.getByIds(testIds);
46
46
  // console.log(typeof entries[0]![1], entries[0]![1])
47
47
  (0, js_lib_1._sortBy)(entries, e => e[0], true);
48
- (0, vitest_1.expect)(entries).toEqual(testEntries); // Jest doesn't allow to compare Buffers directly
48
+ expect(entries).toEqual(testEntries); // Jest doesn't allow to compare Buffers directly
49
49
  // expect(entries.map(e => e[0])).toEqual(testEntries.map(e => e[0]))
50
50
  // expect(entries.map(e => e[1].toString())).toEqual(testEntries.map(e => e[1].toString()))
51
51
  });
52
- (0, vitest_1.test)('streamIds', async () => {
52
+ test('streamIds', async () => {
53
53
  const ids = await dao.streamIds().toArray();
54
54
  ids.sort();
55
- (0, vitest_1.expect)(ids).toEqual(testIds);
55
+ expect(ids).toEqual(testIds);
56
56
  });
57
- (0, vitest_1.test)('streamIds limited', async () => {
57
+ test('streamIds limited', async () => {
58
58
  const idsLimited = await dao.streamIds(2).toArray();
59
59
  // Order is non-deterministic, so, cannot compare values
60
60
  // idsLimited.sort()
61
61
  // expect(idsLimited).toEqual(testIds.slice(0, 2))
62
- (0, vitest_1.expect)(idsLimited.length).toBe(2);
62
+ expect(idsLimited.length).toBe(2);
63
63
  });
64
- (0, vitest_1.test)('streamValues', async () => {
64
+ test('streamValues', async () => {
65
65
  const values = await dao.streamValues().toArray();
66
66
  values.sort();
67
- (0, vitest_1.expect)(values).toEqual(testEntries.map(e => e[1]));
67
+ expect(values).toEqual(testEntries.map(e => e[1]));
68
68
  });
69
- (0, vitest_1.test)('streamValues limited', async () => {
69
+ test('streamValues limited', async () => {
70
70
  const valuesLimited = await dao.streamValues(2).toArray();
71
71
  // valuesLimited.sort()
72
72
  // expect(valuesLimited).toEqual(testEntries.map(e => e[1]).slice(0, 2))
73
- (0, vitest_1.expect)(valuesLimited.length).toBe(2);
73
+ expect(valuesLimited.length).toBe(2);
74
74
  });
75
- (0, vitest_1.test)('streamEntries', async () => {
75
+ test('streamEntries', async () => {
76
76
  const entries = await dao.streamEntries().toArray();
77
77
  entries.sort();
78
- (0, vitest_1.expect)(entries).toEqual(testEntries);
78
+ expect(entries).toEqual(testEntries);
79
79
  });
80
- (0, vitest_1.test)('streamEntries limited', async () => {
80
+ test('streamEntries limited', async () => {
81
81
  const entriesLimited = await dao.streamEntries(2).toArray();
82
82
  // entriesLimited.sort()
83
83
  // expect(entriesLimited).toEqual(testEntries.slice(0, 2))
84
- (0, vitest_1.expect)(entriesLimited.length).toBe(2);
84
+ expect(entriesLimited.length).toBe(2);
85
85
  });
86
- (0, vitest_1.test)('deleteByIds should clear', async () => {
86
+ test('deleteByIds should clear', async () => {
87
87
  await dao.deleteByIds(testIds);
88
88
  const results = await dao.getByIds(testIds);
89
- (0, vitest_1.expect)(results).toEqual([]);
89
+ expect(results).toEqual([]);
90
90
  });
91
91
  if (support.increment) {
92
92
  const id = 'nonExistingField';
93
93
  const id2 = 'nonExistingField2';
94
- (0, vitest_1.test)('increment on a non-existing field should set the value to 1', async () => {
94
+ test('increment on a non-existing field should set the value to 1', async () => {
95
95
  const result = await dao.increment(id);
96
- (0, vitest_1.expect)(result).toBe(1);
96
+ expect(result).toBe(1);
97
97
  });
98
- (0, vitest_1.test)('increment on a existing field should increase the value by one', async () => {
98
+ test('increment on a existing field should increase the value by one', async () => {
99
99
  const result = await dao.increment(id);
100
- (0, vitest_1.expect)(result).toBe(2);
100
+ expect(result).toBe(2);
101
101
  });
102
- (0, vitest_1.test)('increment should increase the value by the specified amount', async () => {
102
+ test('increment should increase the value by the specified amount', async () => {
103
103
  const result = await dao.increment(id, 2);
104
- (0, vitest_1.expect)(result).toBe(4);
104
+ expect(result).toBe(4);
105
105
  });
106
- (0, vitest_1.test)('increment 2 ids at the same time', async () => {
106
+ test('increment 2 ids at the same time', async () => {
107
107
  const result = await dao.incrementBatch([
108
108
  [id, 1],
109
109
  [id2, 2],
110
110
  ]);
111
- (0, vitest_1.expect)(Object.fromEntries(result)).toEqual({
111
+ expect(Object.fromEntries(result)).toEqual({
112
112
  [id]: 5,
113
113
  [id2]: 2,
114
114
  });
@@ -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.0",
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.