@naturalcycles/db-lib 9.14.0 → 9.14.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.
- package/dist/adapter/inmemory/inMemory.db.d.ts +15 -15
- package/dist/adapter/inmemory/inMemoryKeyValueDB.d.ts +0 -1
- package/dist/adapter/inmemory/queryInMemory.js +1 -2
- package/dist/commondao/common.dao.d.ts +0 -1
- package/dist/kv/commonKeyValueDB.d.ts +0 -1
- package/dist/kv/commonKeyValueDao.d.ts +0 -1
- package/dist/model.util.js +4 -5
- package/dist/pipeline/dbPipelineBackup.js +1 -2
- package/dist/pipeline/dbPipelineCopy.js +1 -2
- package/dist/pipeline/dbPipelineRestore.js +1 -2
- package/dist/testing/daoTest.js +2 -3
- package/dist/testing/dbTest.js +2 -3
- package/dist/testing/keyValueDBTest.js +1 -2
- package/dist/testing/keyValueDaoTest.d.ts +0 -1
- package/dist/testing/keyValueDaoTest.js +1 -2
- package/dist/testing/test.model.d.ts +0 -1
- package/dist/testing/test.model.js +5 -5
- package/dist/testing/test.util.js +1 -2
- package/dist/testing/timeSeriesTest.util.js +1 -2
- package/package.json +2 -2
- package/src/adapter/inmemory/inMemory.db.ts +1 -1
- package/src/adapter/inmemory/inMemoryKeyValueDB.ts +1 -1
- package/src/testing/daoTest.ts +2 -2
|
@@ -48,21 +48,21 @@ export interface InMemoryDBCfg {
|
|
|
48
48
|
export declare class InMemoryDB implements CommonDB {
|
|
49
49
|
dbType: CommonDBType;
|
|
50
50
|
support: {
|
|
51
|
-
queries?: boolean
|
|
52
|
-
dbQueryFilter?: boolean
|
|
53
|
-
dbQueryFilterIn?: boolean
|
|
54
|
-
dbQueryOrder?: boolean
|
|
55
|
-
dbQuerySelectFields?: boolean
|
|
56
|
-
insertSaveMethod?: boolean
|
|
57
|
-
updateSaveMethod?: boolean
|
|
58
|
-
updateByQuery?: boolean
|
|
59
|
-
dbIncrement?: boolean
|
|
60
|
-
createTable?: boolean
|
|
61
|
-
tableSchemas?: boolean
|
|
62
|
-
streaming?: boolean
|
|
63
|
-
bufferValues?: boolean
|
|
64
|
-
nullValues?: boolean
|
|
65
|
-
transactions?: boolean
|
|
51
|
+
queries?: boolean;
|
|
52
|
+
dbQueryFilter?: boolean;
|
|
53
|
+
dbQueryFilterIn?: boolean;
|
|
54
|
+
dbQueryOrder?: boolean;
|
|
55
|
+
dbQuerySelectFields?: boolean;
|
|
56
|
+
insertSaveMethod?: boolean;
|
|
57
|
+
updateSaveMethod?: boolean;
|
|
58
|
+
updateByQuery?: boolean;
|
|
59
|
+
dbIncrement?: boolean;
|
|
60
|
+
createTable?: boolean;
|
|
61
|
+
tableSchemas?: boolean;
|
|
62
|
+
streaming?: boolean;
|
|
63
|
+
bufferValues?: boolean;
|
|
64
|
+
nullValues?: boolean;
|
|
65
|
+
transactions?: boolean;
|
|
66
66
|
};
|
|
67
67
|
constructor(cfg?: Partial<InMemoryDBCfg>);
|
|
68
68
|
cfg: InMemoryDBCfg;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queryInMemory =
|
|
3
|
+
exports.queryInMemory = queryInMemory;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const FILTER_FNS = {
|
|
6
6
|
'==': (v, val) => v === val,
|
|
@@ -49,4 +49,3 @@ function queryInMemory(q, rows = []) {
|
|
|
49
49
|
}
|
|
50
50
|
return rows;
|
|
51
51
|
}
|
|
52
|
-
exports.queryInMemory = queryInMemory;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Transform } from 'node:stream';
|
|
3
2
|
import { AsyncMapper, BaseDBEntity, CommonLogger, JsonSchemaObject, JsonSchemaRootObject, UnixTimestampMillisNumber, Unsaved, ZodSchema } from '@naturalcycles/js-lib';
|
|
4
3
|
import { AjvSchema, ObjectSchema, ReadableTyped } from '@naturalcycles/nodejs-lib';
|
package/dist/model.util.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createdUpdatedFields = createdUpdatedFields;
|
|
4
|
+
exports.createdUpdatedIdFields = createdUpdatedIdFields;
|
|
5
|
+
exports.deserializeJsonField = deserializeJsonField;
|
|
6
|
+
exports.serializeJsonField = serializeJsonField;
|
|
4
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
8
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
9
|
function createdUpdatedFields(existingObject) {
|
|
@@ -10,7 +13,6 @@ function createdUpdatedFields(existingObject) {
|
|
|
10
13
|
updated: now,
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
|
-
exports.createdUpdatedFields = createdUpdatedFields;
|
|
14
16
|
function createdUpdatedIdFields(existingObject) {
|
|
15
17
|
const now = (0, js_lib_1.nowUnix)();
|
|
16
18
|
return {
|
|
@@ -19,14 +21,11 @@ function createdUpdatedIdFields(existingObject) {
|
|
|
19
21
|
updated: now,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
|
-
exports.createdUpdatedIdFields = createdUpdatedIdFields;
|
|
23
24
|
function deserializeJsonField(f) {
|
|
24
25
|
return JSON.parse(f || '{}');
|
|
25
26
|
}
|
|
26
|
-
exports.deserializeJsonField = deserializeJsonField;
|
|
27
27
|
function serializeJsonField(f) {
|
|
28
28
|
if (f === undefined)
|
|
29
29
|
return;
|
|
30
30
|
return JSON.stringify(f);
|
|
31
31
|
}
|
|
32
|
-
exports.serializeJsonField = serializeJsonField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dbPipelineBackup =
|
|
3
|
+
exports.dbPipelineBackup = dbPipelineBackup;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
6
|
const index_1 = require("../index");
|
|
@@ -84,4 +84,3 @@ async function dbPipelineBackup(opt) {
|
|
|
84
84
|
console.log(statsTotal.toPretty('total'));
|
|
85
85
|
return statsTotal;
|
|
86
86
|
}
|
|
87
|
-
exports.dbPipelineBackup = dbPipelineBackup;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dbPipelineCopy =
|
|
3
|
+
exports.dbPipelineCopy = dbPipelineCopy;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
6
|
const dbQuery_1 = require("../query/dbQuery");
|
|
@@ -59,4 +59,3 @@ async function dbPipelineCopy(opt) {
|
|
|
59
59
|
console.log(statsTotal.toPretty('total'));
|
|
60
60
|
return statsTotal;
|
|
61
61
|
}
|
|
62
|
-
exports.dbPipelineCopy = dbPipelineCopy;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dbPipelineRestore =
|
|
3
|
+
exports.dbPipelineRestore = dbPipelineRestore;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
6
|
/**
|
|
@@ -96,4 +96,3 @@ async function dbPipelineRestore(opt) {
|
|
|
96
96
|
console.log(statsTotal.toPretty('total'));
|
|
97
97
|
return statsTotal;
|
|
98
98
|
}
|
|
99
|
-
exports.dbPipelineRestore = dbPipelineRestore;
|
package/dist/testing/daoTest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCommonDaoTest =
|
|
3
|
+
exports.runCommonDaoTest = runCommonDaoTest;
|
|
4
4
|
const node_stream_1 = require("node:stream");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
@@ -186,7 +186,7 @@ function runCommonDaoTest(db, quirks = {}) {
|
|
|
186
186
|
// cleanup
|
|
187
187
|
await dao.query().deleteByQuery();
|
|
188
188
|
// Test that id, created, updated are created
|
|
189
|
-
const now = (0, js_lib_1.
|
|
189
|
+
const now = (0, js_lib_1.nowUnix)();
|
|
190
190
|
await dao.runInTransaction(async (tx) => {
|
|
191
191
|
const row = (0, js_lib_1._omit)(item1, ['id', 'created', 'updated']);
|
|
192
192
|
await tx.save(dao, row);
|
|
@@ -228,4 +228,3 @@ function runCommonDaoTest(db, quirks = {}) {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
exports.runCommonDaoTest = runCommonDaoTest;
|
package/dist/testing/dbTest.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runCommonDBTest = runCommonDBTest;
|
|
4
|
+
exports.expectMatch = expectMatch;
|
|
4
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
6
|
const common_db_1 = require("../common.db");
|
|
6
7
|
const db_model_1 = require("../db.model");
|
|
@@ -283,7 +284,6 @@ function runCommonDBTest(db, quirks = {}) {
|
|
|
283
284
|
});
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
|
-
exports.runCommonDBTest = runCommonDBTest;
|
|
287
287
|
function expectMatch(expected, actual, quirks) {
|
|
288
288
|
// const expectedSorted = sortObjectDeep(expected)
|
|
289
289
|
// const actualSorted = sortObjectDeep(actual)
|
|
@@ -299,4 +299,3 @@ function expectMatch(expected, actual, quirks) {
|
|
|
299
299
|
expect(actual).toEqual(expected);
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
exports.expectMatch = expectMatch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCommonKeyValueDBTest =
|
|
3
|
+
exports.runCommonKeyValueDBTest = runCommonKeyValueDBTest;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const test_model_1 = require("./test.model");
|
|
6
6
|
const testIds = (0, js_lib_1._range)(1, 4).map(n => `id${n}`);
|
|
@@ -71,4 +71,3 @@ function runCommonKeyValueDBTest(db) {
|
|
|
71
71
|
expect(results).toEqual([]);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
exports.runCommonKeyValueDBTest = runCommonKeyValueDBTest;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCommonKeyValueDaoTest =
|
|
3
|
+
exports.runCommonKeyValueDaoTest = runCommonKeyValueDaoTest;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const testIds = (0, js_lib_1._range)(1, 4).map(n => `id${n}`);
|
|
6
6
|
const testEntries = testIds.map(id => [id, Buffer.from(`${id}value`)]);
|
|
@@ -64,4 +64,3 @@ function runCommonKeyValueDaoTest(dao) {
|
|
|
64
64
|
expect(results).toEqual([]);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
exports.runCommonKeyValueDaoTest = runCommonKeyValueDaoTest;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.testItemBMJsonSchema = exports.testItemTMSchema = exports.testItemBMSchema = exports.TEST_TABLE = void 0;
|
|
4
|
+
exports.createTestItemDBM = createTestItemDBM;
|
|
5
|
+
exports.createTestItemBM = createTestItemBM;
|
|
6
|
+
exports.createTestItemsDBM = createTestItemsDBM;
|
|
7
|
+
exports.createTestItemsBM = createTestItemsBM;
|
|
4
8
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
9
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
10
|
const MOCK_TS_2018_06_21 = 1529539200;
|
|
@@ -41,16 +45,12 @@ function createTestItemDBM(num = 1) {
|
|
|
41
45
|
updated: MOCK_TS_2018_06_21,
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
|
-
exports.createTestItemDBM = createTestItemDBM;
|
|
45
48
|
function createTestItemBM(num = 1) {
|
|
46
49
|
return createTestItemDBM(num);
|
|
47
50
|
}
|
|
48
|
-
exports.createTestItemBM = createTestItemBM;
|
|
49
51
|
function createTestItemsDBM(count = 1) {
|
|
50
52
|
return (0, js_lib_1._range)(1, count + 1).map(num => createTestItemDBM(num));
|
|
51
53
|
}
|
|
52
|
-
exports.createTestItemsDBM = createTestItemsDBM;
|
|
53
54
|
function createTestItemsBM(count = 1) {
|
|
54
55
|
return (0, js_lib_1._range)(1, count + 1).map(num => createTestItemBM(num));
|
|
55
56
|
}
|
|
56
|
-
exports.createTestItemsBM = createTestItemsBM;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// copy-pasted from test-lib to be able to not include devDependecies there
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.deepFreeze =
|
|
4
|
+
exports.deepFreeze = deepFreeze;
|
|
5
5
|
/**
|
|
6
6
|
* Does Object.freeze recursively for given object.
|
|
7
7
|
*
|
|
@@ -21,4 +21,3 @@ function deepFreeze(o) {
|
|
|
21
21
|
});
|
|
22
22
|
return o;
|
|
23
23
|
}
|
|
24
|
-
exports.deepFreeze = deepFreeze;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTestTimeSeries =
|
|
3
|
+
exports.createTestTimeSeries = createTestTimeSeries;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
function createTestTimeSeries(count = 10) {
|
|
6
6
|
const ts = Date.now();
|
|
7
7
|
return (0, js_lib_1._range)(1, count + 1).map(i => [ts - i * 60_000, (0, js_lib_1._randomInt)(10, 20)]);
|
|
8
8
|
}
|
|
9
|
-
exports.createTestTimeSeries = createTestTimeSeries;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@naturalcycles/nodejs-lib": "^13.1.1"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@naturalcycles/bench-lib": "^
|
|
11
|
+
"@naturalcycles/bench-lib": "^3.0.0",
|
|
12
12
|
"@naturalcycles/dev-lib": "^13.0.0",
|
|
13
13
|
"@types/node": "^20.2.1",
|
|
14
14
|
"jest": "^29.0.0"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=18.12"
|
|
42
42
|
},
|
|
43
|
-
"version": "9.14.
|
|
43
|
+
"version": "9.14.2",
|
|
44
44
|
"description": "Lowest Common Denominator API to supported Databases",
|
|
45
45
|
"keywords": [
|
|
46
46
|
"db",
|
|
@@ -215,7 +215,7 @@ export class InMemoryDB implements CommonDB {
|
|
|
215
215
|
): Promise<number> {
|
|
216
216
|
const table = this.cfg.tablesPrefix + q.table
|
|
217
217
|
if (!this.data[table]) return 0
|
|
218
|
-
const ids = queryInMemory(q, Object.values(this.data[table]
|
|
218
|
+
const ids = queryInMemory(q, Object.values(this.data[table]) as ROW[]).map(r => r.id)
|
|
219
219
|
return await this.deleteByIds(q.table, ids)
|
|
220
220
|
}
|
|
221
221
|
|
package/src/testing/daoTest.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
|
-
import { _deepCopy, _pick, _sortBy, _omit,
|
|
2
|
+
import { _deepCopy, _pick, _sortBy, _omit, nowUnix } from '@naturalcycles/js-lib'
|
|
3
3
|
import { _pipeline } from '@naturalcycles/nodejs-lib'
|
|
4
4
|
import { CommonDaoLogLevel, DBQuery } from '..'
|
|
5
5
|
import { CommonDB } from '../common.db'
|
|
@@ -255,7 +255,7 @@ export function runCommonDaoTest(db: CommonDB, quirks: CommonDBImplementationQui
|
|
|
255
255
|
await dao.query().deleteByQuery()
|
|
256
256
|
|
|
257
257
|
// Test that id, created, updated are created
|
|
258
|
-
const now =
|
|
258
|
+
const now = nowUnix()
|
|
259
259
|
|
|
260
260
|
await dao.runInTransaction(async tx => {
|
|
261
261
|
const row = _omit(item1, ['id', 'created', 'updated'])
|