@naturalcycles/db-lib 10.1.6 → 10.3.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Transform } from 'node:stream';
|
|
2
2
|
import type { AsyncMapper, BaseDBEntity, CommonLogger, JsonSchemaObject, JsonSchemaRootObject, StringMap, UnixTimestampMillis, Unsaved } from '@naturalcycles/js-lib';
|
|
3
|
-
import { ZodSchema } from '@naturalcycles/js-lib/
|
|
3
|
+
import { ZodSchema } from '@naturalcycles/js-lib/zod';
|
|
4
4
|
import type { ObjectSchema, ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
5
5
|
import { AjvSchema } from '@naturalcycles/nodejs-lib';
|
|
6
6
|
import type { CommonDBTransactionOptions, DBTransaction, RunQueryResult } from '../db.model.js';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { _assert, _deepCopy, _deepJsonEquals, _filterUndefinedValues, _isTruthy, _objectAssignExact, _passthroughPredicate, _since, _truncate, _typeCast, _uniqBy, AppError, ErrorMode, localTime, pMap, SKIP, } from '@naturalcycles/js-lib';
|
|
2
|
-
import { ZodSchema, zSafeValidate } from '@naturalcycles/js-lib/
|
|
2
|
+
import { ZodSchema, zSafeValidate } from '@naturalcycles/js-lib/zod';
|
|
3
3
|
import { _pipeline, AjvSchema, getValidationResult, stringId, transformChunk, transformLogProgress, transformMap, transformNoOp, writableVoid, } from '@naturalcycles/nodejs-lib';
|
|
4
4
|
import { DBLibError } from '../cnst.js';
|
|
5
5
|
import { RunnableDBQuery } from '../query/dbQuery.js';
|
|
6
6
|
import { CommonDaoLogLevel } from './common.dao.model.js';
|
|
7
|
-
const isGAE = !!process.env['GAE_INSTANCE'];
|
|
8
|
-
const isCI = !!process.env['CI'];
|
|
9
7
|
/**
|
|
10
8
|
* Lowest common denominator API between supported Databases.
|
|
11
9
|
*
|
|
@@ -18,10 +16,7 @@ export class CommonDao {
|
|
|
18
16
|
constructor(cfg) {
|
|
19
17
|
this.cfg = cfg;
|
|
20
18
|
this.cfg = {
|
|
21
|
-
|
|
22
|
-
// otherwise to log Operations
|
|
23
|
-
// e.g in Dev (local machine), Test - it will log operations (useful for debugging)
|
|
24
|
-
logLevel: isGAE || isCI ? CommonDaoLogLevel.NONE : CommonDaoLogLevel.OPERATIONS,
|
|
19
|
+
logLevel: CommonDaoLogLevel.NONE,
|
|
25
20
|
generateId: true,
|
|
26
21
|
assignGeneratedIds: false,
|
|
27
22
|
useCreatedProperty: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseDBEntity, CommonLogger, ErrorMode, NumberOfMilliseconds, Promisable, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ZodError, ZodSchema } from '@naturalcycles/js-lib/
|
|
2
|
+
import type { ZodError, ZodSchema } from '@naturalcycles/js-lib/zod';
|
|
3
3
|
import type { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchema, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
4
4
|
import type { CommonDB } from '../common.db.js';
|
|
5
5
|
import type { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model.js';
|
|
@@ -138,7 +138,7 @@ export interface CommonDaoCfg<BM extends BaseDBEntity, DBM extends BaseDBEntity
|
|
|
138
138
|
*/
|
|
139
139
|
logger?: CommonLogger;
|
|
140
140
|
/**
|
|
141
|
-
* @default
|
|
141
|
+
* @default NONE
|
|
142
142
|
*/
|
|
143
143
|
logLevel?: CommonDaoLogLevel;
|
|
144
144
|
/**
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/db-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.3.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@naturalcycles/nodejs-lib": "^14"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@naturalcycles/dev-lib": "
|
|
10
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
],
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"./testing": "dist/testing/index.js",
|
|
25
|
-
"./validation": "dist/validation/index.js",
|
|
26
|
-
"./adapter/cachedb": "dist/adapter/cachedb/index.js",
|
|
27
|
-
"./adapter/
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./testing": "./dist/testing/index.js",
|
|
25
|
+
"./validation": "./dist/validation/index.js",
|
|
26
|
+
"./adapter/cachedb": "./dist/adapter/cachedb/index.js",
|
|
27
|
+
"./adapter/file": "./dist/adapter/file/index.js"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
@@ -57,6 +57,8 @@
|
|
|
57
57
|
"test": "dev-lib test",
|
|
58
58
|
"lint": "dev-lib lint",
|
|
59
59
|
"bt": "dev-lib bt",
|
|
60
|
-
"
|
|
60
|
+
"clean": "dev-lib clean",
|
|
61
|
+
"typecheck": "dev-lib typecheck",
|
|
62
|
+
"check": "dev-lib check"
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
Promisable,
|
|
7
7
|
UnixTimestamp,
|
|
8
8
|
} from '@naturalcycles/js-lib'
|
|
9
|
-
import type { ZodError, ZodSchema } from '@naturalcycles/js-lib/
|
|
9
|
+
import type { ZodError, ZodSchema } from '@naturalcycles/js-lib/zod'
|
|
10
10
|
import type {
|
|
11
11
|
AjvSchema,
|
|
12
12
|
AjvValidationError,
|
|
@@ -176,7 +176,7 @@ export interface CommonDaoCfg<
|
|
|
176
176
|
logger?: CommonLogger
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
|
-
* @default
|
|
179
|
+
* @default NONE
|
|
180
180
|
*/
|
|
181
181
|
logLevel?: CommonDaoLogLevel
|
|
182
182
|
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
pMap,
|
|
29
29
|
SKIP,
|
|
30
30
|
} from '@naturalcycles/js-lib'
|
|
31
|
-
import type { ZodValidationError } from '@naturalcycles/js-lib/
|
|
32
|
-
import { ZodSchema, zSafeValidate } from '@naturalcycles/js-lib/
|
|
31
|
+
import type { ZodValidationError } from '@naturalcycles/js-lib/zod'
|
|
32
|
+
import { ZodSchema, zSafeValidate } from '@naturalcycles/js-lib/zod'
|
|
33
33
|
import type {
|
|
34
34
|
AjvValidationError,
|
|
35
35
|
JoiValidationError,
|
|
@@ -68,9 +68,6 @@ import type {
|
|
|
68
68
|
} from './common.dao.model.js'
|
|
69
69
|
import { CommonDaoLogLevel } from './common.dao.model.js'
|
|
70
70
|
|
|
71
|
-
const isGAE = !!process.env['GAE_INSTANCE']
|
|
72
|
-
const isCI = !!process.env['CI']
|
|
73
|
-
|
|
74
71
|
/**
|
|
75
72
|
* Lowest common denominator API between supported Databases.
|
|
76
73
|
*
|
|
@@ -81,10 +78,7 @@ const isCI = !!process.env['CI']
|
|
|
81
78
|
export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM, ID = BM['id']> {
|
|
82
79
|
constructor(public cfg: CommonDaoCfg<BM, DBM, ID>) {
|
|
83
80
|
this.cfg = {
|
|
84
|
-
|
|
85
|
-
// otherwise to log Operations
|
|
86
|
-
// e.g in Dev (local machine), Test - it will log operations (useful for debugging)
|
|
87
|
-
logLevel: isGAE || isCI ? CommonDaoLogLevel.NONE : CommonDaoLogLevel.OPERATIONS,
|
|
81
|
+
logLevel: CommonDaoLogLevel.NONE,
|
|
88
82
|
generateId: true,
|
|
89
83
|
assignGeneratedIds: false,
|
|
90
84
|
useCreatedProperty: true,
|