@naturalcycles/db-lib 8.43.0 → 8.43.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/commondao/common.dao.d.ts +1 -1
- package/dist/commondao/common.dao.model.d.ts +3 -3
- package/dist/db.model.d.ts +1 -1
- package/dist/query/dbQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/commondao/common.dao.model.ts +4 -4
- package/src/commondao/common.dao.ts +4 -4
- package/src/db.model.ts +1 -1
- package/src/query/dbQuery.ts +2 -2
|
@@ -10,7 +10,7 @@ import { CommonDaoCfg, CommonDaoCreateOptions, CommonDaoOptions, CommonDaoSaveOp
|
|
|
10
10
|
* BM = Backend model (optimized for API access)
|
|
11
11
|
* TM = Transport model (optimized to be sent over the wire)
|
|
12
12
|
*/
|
|
13
|
-
export declare class CommonDao<BM extends ObjectWithId<ID
|
|
13
|
+
export declare class CommonDao<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID> = Saved<BM>, TM extends AnyObject = BM, ID extends string | number = string> {
|
|
14
14
|
cfg: CommonDaoCfg<BM, DBM, TM, ID>;
|
|
15
15
|
constructor(cfg: CommonDaoCfg<BM, DBM, TM, ID>);
|
|
16
16
|
create(part?: Partial<BM>, opt?: CommonDaoOptions): Saved<BM>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CommonLogger, ErrorMode, ObjectWithId } from '@naturalcycles/js-lib';
|
|
1
|
+
import { CommonLogger, ErrorMode, ObjectWithId, Saved } from '@naturalcycles/js-lib';
|
|
2
2
|
import { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchemaTyped, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
3
3
|
import { CommonDB } from '../common.db';
|
|
4
4
|
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model';
|
|
5
|
-
export interface CommonDaoHooks<BM extends ObjectWithId<ID
|
|
5
|
+
export interface CommonDaoHooks<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID>, TM, ID extends string | number> {
|
|
6
6
|
createId: (obj: DBM | BM) => ID;
|
|
7
7
|
parseNaturalId: (id: ID) => Partial<DBM>;
|
|
8
8
|
beforeCreate: (bm: Partial<BM>) => Partial<BM>;
|
|
@@ -38,7 +38,7 @@ export declare enum CommonDaoLogLevel {
|
|
|
38
38
|
*/
|
|
39
39
|
DATA_FULL = 30
|
|
40
40
|
}
|
|
41
|
-
export interface CommonDaoCfg<BM extends ObjectWithId<ID
|
|
41
|
+
export interface CommonDaoCfg<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID> = Saved<BM>, TM = BM, ID extends string | number = string> {
|
|
42
42
|
db: CommonDB;
|
|
43
43
|
table: string;
|
|
44
44
|
/**
|
package/dist/db.model.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface RunQueryResult<T> {
|
|
|
41
41
|
endCursor?: string;
|
|
42
42
|
}
|
|
43
43
|
export declare type DBOperation = DBSaveBatchOperation | DBDeleteByIdsOperation;
|
|
44
|
-
export interface DBSaveBatchOperation<ROW extends ObjectWithId =
|
|
44
|
+
export interface DBSaveBatchOperation<ROW extends ObjectWithId = any> {
|
|
45
45
|
type: 'saveBatch';
|
|
46
46
|
table: string;
|
|
47
47
|
rows: ROW[];
|
package/dist/query/dbQuery.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare class DBQuery<ROW extends ObjectWithId = AnyObjectWithId> {
|
|
|
83
83
|
/**
|
|
84
84
|
* DBQuery that has additional method to support Fluent API style.
|
|
85
85
|
*/
|
|
86
|
-
export declare class RunnableDBQuery<BM extends ObjectWithId<ID
|
|
86
|
+
export declare class RunnableDBQuery<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID> = Saved<BM>, TM extends AnyObject = BM, ID extends string | number = string> extends DBQuery<DBM> {
|
|
87
87
|
dao: CommonDao<BM, DBM, TM, ID>;
|
|
88
88
|
/**
|
|
89
89
|
* Pass `table` to override table.
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonLogger, ErrorMode, ObjectWithId } from '@naturalcycles/js-lib'
|
|
1
|
+
import { CommonLogger, ErrorMode, ObjectWithId, Saved } from '@naturalcycles/js-lib'
|
|
2
2
|
import {
|
|
3
3
|
AjvSchema,
|
|
4
4
|
AjvValidationError,
|
|
@@ -11,7 +11,7 @@ import { CommonDB } from '../common.db'
|
|
|
11
11
|
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'
|
|
12
12
|
|
|
13
13
|
export interface CommonDaoHooks<
|
|
14
|
-
BM extends ObjectWithId<ID
|
|
14
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
15
15
|
DBM extends ObjectWithId<ID>,
|
|
16
16
|
TM,
|
|
17
17
|
ID extends string | number,
|
|
@@ -55,8 +55,8 @@ export enum CommonDaoLogLevel {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export interface CommonDaoCfg<
|
|
58
|
-
BM extends ObjectWithId<ID
|
|
59
|
-
DBM extends ObjectWithId<ID> = BM
|
|
58
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
59
|
+
DBM extends ObjectWithId<ID> = Saved<BM>,
|
|
60
60
|
TM = BM,
|
|
61
61
|
ID extends string | number = string,
|
|
62
62
|
> {
|
|
@@ -68,8 +68,8 @@ const isCI = !!process.env['CI']
|
|
|
68
68
|
* TM = Transport model (optimized to be sent over the wire)
|
|
69
69
|
*/
|
|
70
70
|
export class CommonDao<
|
|
71
|
-
BM extends ObjectWithId<ID
|
|
72
|
-
DBM extends ObjectWithId<ID> = BM
|
|
71
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
72
|
+
DBM extends ObjectWithId<ID> = Saved<BM>,
|
|
73
73
|
TM extends AnyObject = BM,
|
|
74
74
|
ID extends string | number = string,
|
|
75
75
|
> {
|
|
@@ -626,7 +626,7 @@ export class CommonDao<
|
|
|
626
626
|
table: this.cfg.table,
|
|
627
627
|
rows: [row],
|
|
628
628
|
opt: {
|
|
629
|
-
excludeFromIndexes: this.cfg.excludeFromIndexes
|
|
629
|
+
excludeFromIndexes: this.cfg.excludeFromIndexes,
|
|
630
630
|
...opt,
|
|
631
631
|
},
|
|
632
632
|
}
|
|
@@ -642,7 +642,7 @@ export class CommonDao<
|
|
|
642
642
|
table: this.cfg.table,
|
|
643
643
|
rows,
|
|
644
644
|
opt: {
|
|
645
|
-
excludeFromIndexes: this.cfg.excludeFromIndexes
|
|
645
|
+
excludeFromIndexes: this.cfg.excludeFromIndexes,
|
|
646
646
|
...opt,
|
|
647
647
|
},
|
|
648
648
|
}
|
package/src/db.model.ts
CHANGED
|
@@ -52,7 +52,7 @@ export interface RunQueryResult<T> {
|
|
|
52
52
|
|
|
53
53
|
export type DBOperation = DBSaveBatchOperation | DBDeleteByIdsOperation
|
|
54
54
|
|
|
55
|
-
export interface DBSaveBatchOperation<ROW extends ObjectWithId =
|
|
55
|
+
export interface DBSaveBatchOperation<ROW extends ObjectWithId = any> {
|
|
56
56
|
type: 'saveBatch'
|
|
57
57
|
table: string
|
|
58
58
|
rows: ROW[]
|
package/src/query/dbQuery.ts
CHANGED
|
@@ -225,8 +225,8 @@ export class DBQuery<ROW extends ObjectWithId = AnyObjectWithId> {
|
|
|
225
225
|
* DBQuery that has additional method to support Fluent API style.
|
|
226
226
|
*/
|
|
227
227
|
export class RunnableDBQuery<
|
|
228
|
-
BM extends ObjectWithId<ID
|
|
229
|
-
DBM extends ObjectWithId<ID> = BM
|
|
228
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
229
|
+
DBM extends ObjectWithId<ID> = Saved<BM>,
|
|
230
230
|
TM extends AnyObject = BM,
|
|
231
231
|
ID extends string | number = string,
|
|
232
232
|
> extends DBQuery<DBM> {
|