@naturalcycles/db-lib 10.42.2 → 10.43.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.
- package/dist/commondao/common.dao.d.ts +2 -2
- package/dist/commondao/common.dao.model.d.ts +1 -1
- package/dist/testing/test.model.d.ts +1 -1
- package/dist/validation/index.d.ts +1 -1
- package/package.json +1 -1
- package/readme.md +3 -11
- package/src/commondao/common.dao.model.ts +1 -1
- package/src/commondao/common.dao.ts +2 -2
- package/src/testing/test.model.ts +1 -1
- package/src/validation/index.ts +2 -5
|
@@ -173,8 +173,8 @@ export declare class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity
|
|
|
173
173
|
* Validates (unless `skipValidation=true` passed).
|
|
174
174
|
*/
|
|
175
175
|
private validateAndConvert;
|
|
176
|
-
getTableSchema(): Promise<JsonSchema<
|
|
177
|
-
createTable(schema: JsonSchema<
|
|
176
|
+
getTableSchema(): Promise<JsonSchema<DBM>>;
|
|
177
|
+
createTable(schema: JsonSchema<DBM>, opt?: CommonDaoCreateOptions): Promise<void>;
|
|
178
178
|
/**
|
|
179
179
|
* Proxy to this.cfg.db.ping
|
|
180
180
|
*/
|
|
@@ -89,7 +89,7 @@ export interface CommonDaoCfg<BM extends BaseDBEntity, DBM extends BaseDBEntity
|
|
|
89
89
|
* It removes the knowledge from CommonDao about the validation library used
|
|
90
90
|
* and abstracts it away.
|
|
91
91
|
*/
|
|
92
|
-
validateBM?: ValidationFunction<BM,
|
|
92
|
+
validateBM?: ValidationFunction<BM, any>;
|
|
93
93
|
/**
|
|
94
94
|
* Used by e.g Datastore.
|
|
95
95
|
*/
|
|
@@ -19,7 +19,7 @@ export interface TestItemTM {
|
|
|
19
19
|
even?: boolean;
|
|
20
20
|
}
|
|
21
21
|
export declare const testItemTMSchema: any;
|
|
22
|
-
export declare const testItemBMSchema: JsonSchemaObjectBuilder<TestItemBM,
|
|
22
|
+
export declare const testItemBMSchema: JsonSchemaObjectBuilder<TestItemBM, false>;
|
|
23
23
|
export declare function createTestItemDBM(num?: number): TestItemDBM;
|
|
24
24
|
export declare function createTestItemBM(num?: number): TestItemBM;
|
|
25
25
|
export declare function createTestItemsDBM(count?: number): TestItemDBM[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonDBOptions } from '../db.model.js';
|
|
2
|
-
export declare const commonDBOptionsSchema: () => JsonSchemaObjectBuilder<CommonDBOptions,
|
|
2
|
+
export declare const commonDBOptionsSchema: () => JsonSchemaObjectBuilder<CommonDBOptions, false>;
|
|
3
3
|
export declare const commonDBSaveOptionsSchema: <ROW extends ObjectWithId>() => any;
|
|
4
4
|
export declare const dbQueryFilterOperatorSchema: any;
|
|
5
5
|
export declare const dbQueryFilterSchema: <ROW extends ObjectWithId>() => any;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -303,14 +303,6 @@ Passing empty array will actually return an array of empty objects (documented e
|
|
|
303
303
|
.select(['id']) //=> [ { id: 'id1' }, { id: 'id2' }, ... ]
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
- `/adapter/file`
|
|
310
|
-
- `/adapter/cachedb`
|
|
311
|
-
- `/testing`
|
|
312
|
-
- dbTest
|
|
313
|
-
- daoTest
|
|
314
|
-
- Test models, utils, etc
|
|
315
|
-
- `/validation`
|
|
316
|
-
- Joi validation schemas for DBQuery, CommonDBOptions, CommonSchema, etc
|
|
306
|
+
## chore-counter
|
|
307
|
+
|
|
308
|
+
1
|
|
@@ -109,7 +109,7 @@ export interface CommonDaoCfg<
|
|
|
109
109
|
* It removes the knowledge from CommonDao about the validation library used
|
|
110
110
|
* and abstracts it away.
|
|
111
111
|
*/
|
|
112
|
-
validateBM?: ValidationFunction<BM,
|
|
112
|
+
validateBM?: ValidationFunction<BM, any>
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Used by e.g Datastore.
|
|
@@ -926,11 +926,11 @@ export class CommonDao<
|
|
|
926
926
|
return convertedValue
|
|
927
927
|
}
|
|
928
928
|
|
|
929
|
-
async getTableSchema(): Promise<JsonSchema<
|
|
929
|
+
async getTableSchema(): Promise<JsonSchema<DBM>> {
|
|
930
930
|
return await this.cfg.db.getTableSchema<DBM>(this.cfg.table)
|
|
931
931
|
}
|
|
932
932
|
|
|
933
|
-
async createTable(schema: JsonSchema<
|
|
933
|
+
async createTable(schema: JsonSchema<DBM>, opt?: CommonDaoCreateOptions): Promise<void> {
|
|
934
934
|
this.requireWriteAccess()
|
|
935
935
|
await this.cfg.db.createTable(this.cfg.table, schema, opt)
|
|
936
936
|
}
|
|
@@ -31,7 +31,7 @@ export const testItemTMSchema = j.object<TestItemTM>({
|
|
|
31
31
|
even: j.boolean().optional(),
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
export const testItemBMSchema: JsonSchemaObjectBuilder<TestItemBM,
|
|
34
|
+
export const testItemBMSchema: JsonSchemaObjectBuilder<TestItemBM, false> =
|
|
35
35
|
j.object.dbEntity<TestItemBM>({
|
|
36
36
|
// todo: figure out how to not copy-paste these 3 fields
|
|
37
37
|
id: j.string(), // todo: not strictly needed here
|
package/src/validation/index.ts
CHANGED
|
@@ -11,12 +11,9 @@ import type { DBQueryFilter, DBQueryOrder } from '../query/dbQuery.js'
|
|
|
11
11
|
const dbTransactionSchema = j.object.any().castAs<DBTransaction>()
|
|
12
12
|
|
|
13
13
|
// Schema that accepts any value (string, number, boolean, object, array, null)
|
|
14
|
-
const anyValueSchema = new JsonSchemaAnyBuilder<any,
|
|
14
|
+
const anyValueSchema = new JsonSchemaAnyBuilder<any, false>({})
|
|
15
15
|
|
|
16
|
-
export const commonDBOptionsSchema = (): JsonSchemaObjectBuilder<
|
|
17
|
-
CommonDBOptions,
|
|
18
|
-
CommonDBOptions
|
|
19
|
-
> =>
|
|
16
|
+
export const commonDBOptionsSchema = (): JsonSchemaObjectBuilder<CommonDBOptions, false> =>
|
|
20
17
|
j.object<CommonDBOptions>({
|
|
21
18
|
tx: dbTransactionSchema.optional(),
|
|
22
19
|
})
|