@naturalcycles/db-lib 10.1.1 → 10.1.3

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,4 +1,5 @@
1
1
  import type { BaseDBEntity, JsonSchemaObject } from '@naturalcycles/js-lib';
2
+ import { type ObjectSchema } from '@naturalcycles/nodejs-lib';
2
3
  export declare const TEST_TABLE = "TEST_TABLE";
3
4
  export interface TestItemBM extends BaseDBEntity {
4
5
  k1: string;
@@ -16,8 +17,8 @@ export interface TestItemTM {
16
17
  k1: string;
17
18
  even?: boolean;
18
19
  }
19
- export declare const testItemBMSchema: import("joi").ObjectSchema<TestItemBM>;
20
- export declare const testItemTMSchema: import("joi").ObjectSchema<TestItemTM>;
20
+ export declare const testItemBMSchema: ObjectSchema<TestItemBM>;
21
+ export declare const testItemTMSchema: ObjectSchema<TestItemTM>;
21
22
  export declare const testItemBMJsonSchema: JsonSchemaObject<TestItemBM>;
22
23
  export declare function createTestItemDBM(num?: number): TestItemDBM;
23
24
  export declare function createTestItemBM(num?: number): TestItemBM;
@@ -1,8 +1,9 @@
1
+ import { type ObjectSchema, type StringSchema } from '@naturalcycles/nodejs-lib';
1
2
  import type { CommonDBOptions, CommonDBSaveOptions } from '../db.model.js';
2
3
  import type { DBQuery, DBQueryFilter, DBQueryFilterOperator, DBQueryOrder } from '../query/dbQuery.js';
3
- export declare const commonDBOptionsSchema: import("joi").ObjectSchema<CommonDBOptions>;
4
- export declare const commonDBSaveOptionsSchema: import("joi").ObjectSchema<CommonDBSaveOptions<any>>;
5
- export declare const dbQueryFilterOperatorSchema: import("@naturalcycles/nodejs-lib").StringSchema<DBQueryFilterOperator>;
6
- export declare const dbQueryFilterSchema: import("joi").ObjectSchema<DBQueryFilter<any>>;
7
- export declare const dbQueryOrderSchema: import("joi").ObjectSchema<DBQueryOrder<any>>;
8
- export declare const dbQuerySchema: import("joi").ObjectSchema<DBQuery<any>>;
4
+ export declare const commonDBOptionsSchema: ObjectSchema<CommonDBOptions>;
5
+ export declare const commonDBSaveOptionsSchema: ObjectSchema<CommonDBSaveOptions<any>>;
6
+ export declare const dbQueryFilterOperatorSchema: StringSchema<DBQueryFilterOperator>;
7
+ export declare const dbQueryFilterSchema: ObjectSchema<DBQueryFilter<any>>;
8
+ export declare const dbQueryOrderSchema: ObjectSchema<DBQueryOrder<any>>;
9
+ export declare const dbQuerySchema: ObjectSchema<DBQuery<any>>;
package/package.json CHANGED
@@ -1,26 +1,12 @@
1
1
  {
2
2
  "name": "@naturalcycles/db-lib",
3
3
  "type": "module",
4
- "scripts": {
5
- "prepare": "husky",
6
- "build": "dev-lib build",
7
- "test": "dev-lib test",
8
- "lint": "dev-lib lint",
9
- "bt": "dev-lib bt",
10
- "lbt": "dev-lib lbt"
11
- },
4
+ "version": "10.1.3",
12
5
  "dependencies": {
13
- "@naturalcycles/js-lib": "^14",
14
- "@naturalcycles/nodejs-lib": "^13"
15
- },
16
- "devDependencies": {
17
- "@naturalcycles/bench-lib": "^4",
18
- "@naturalcycles/dev-lib": "^17",
19
- "@types/node": "^22",
20
- "@vitest/coverage-v8": "^3",
21
- "tsx": "^4",
22
- "vitest": "^3"
6
+ "@naturalcycles/nodejs-lib": "^14.3.1",
7
+ "@naturalcycles/js-lib": "^15.0.0"
23
8
  },
9
+ "devDependencies": {},
24
10
  "files": [
25
11
  "dist",
26
12
  "src",
@@ -43,12 +29,12 @@
43
29
  },
44
30
  "repository": {
45
31
  "type": "git",
46
- "url": "https://github.com/NaturalCycles/db-lib"
32
+ "url": "git@github.com:NaturalCycles/js-lib.git",
33
+ "directory": "packages/db-lib"
47
34
  },
48
35
  "engines": {
49
36
  "node": ">=22.12.0"
50
37
  },
51
- "version": "10.1.1",
52
38
  "description": "Lowest Common Denominator API to supported Databases",
53
39
  "keywords": [
54
40
  "db",
@@ -63,5 +49,12 @@
63
49
  "mysql"
64
50
  ],
65
51
  "author": "Natural Cycles Team",
66
- "license": "MIT"
67
- }
52
+ "license": "MIT",
53
+ "scripts": {
54
+ "build": "dev-lib build",
55
+ "test": "dev-lib test",
56
+ "lint": "dev-lib lint",
57
+ "bt": "dev-lib bt",
58
+ "lbt": "dev-lib lbt"
59
+ }
60
+ }
@@ -5,6 +5,7 @@ import {
5
5
  binarySchema,
6
6
  booleanSchema,
7
7
  numberSchema,
8
+ type ObjectSchema,
8
9
  objectSchema,
9
10
  stringSchema,
10
11
  } from '@naturalcycles/nodejs-lib'
@@ -31,7 +32,7 @@ export interface TestItemTM {
31
32
  even?: boolean
32
33
  }
33
34
 
34
- export const testItemBMSchema = objectSchema<TestItemBM>({
35
+ export const testItemBMSchema: ObjectSchema<TestItemBM> = objectSchema<TestItemBM>({
35
36
  k1: stringSchema,
36
37
  k2: stringSchema.allow(null).optional(),
37
38
  k3: numberSchema.optional(),
@@ -42,7 +43,7 @@ export const testItemBMSchema = objectSchema<TestItemBM>({
42
43
  }).optional(),
43
44
  }).concat(baseDBEntitySchema as any)
44
45
 
45
- export const testItemTMSchema = objectSchema<TestItemTM>({
46
+ export const testItemTMSchema: ObjectSchema<TestItemTM> = objectSchema<TestItemTM>({
46
47
  k1: stringSchema,
47
48
  even: booleanSchema.optional(),
48
49
  })
@@ -4,7 +4,9 @@ import {
4
4
  booleanSchema,
5
5
  integerSchema,
6
6
  Joi,
7
+ type ObjectSchema,
7
8
  objectSchema,
9
+ type StringSchema,
8
10
  stringSchema,
9
11
  } from '@naturalcycles/nodejs-lib'
10
12
  import type { CommonDBOptions, CommonDBSaveOptions } from '../db.model.js'
@@ -16,31 +18,34 @@ import type {
16
18
  } from '../query/dbQuery.js'
17
19
  import { dbQueryFilterOperatorValues } from '../query/dbQuery.js'
18
20
 
19
- export const commonDBOptionsSchema = objectSchema<CommonDBOptions>({
21
+ export const commonDBOptionsSchema: ObjectSchema<CommonDBOptions> = objectSchema<CommonDBOptions>({
20
22
  ['onlyCache' as any]: booleanSchema.optional(),
21
23
  ['skipCache' as any]: booleanSchema.optional(),
22
24
  })
23
25
 
24
- export const commonDBSaveOptionsSchema = objectSchema<CommonDBSaveOptions<any>>({
26
+ export const commonDBSaveOptionsSchema: ObjectSchema<CommonDBSaveOptions<any>> = objectSchema<
27
+ CommonDBSaveOptions<any>
28
+ >({
25
29
  excludeFromIndexes: arraySchema(stringSchema).optional(),
26
30
  }).concat(commonDBOptionsSchema)
27
31
 
28
- export const dbQueryFilterOperatorSchema = Joi.string<DBQueryFilterOperator>().valid(
29
- ...dbQueryFilterOperatorValues,
30
- )
32
+ export const dbQueryFilterOperatorSchema: StringSchema<DBQueryFilterOperator> =
33
+ Joi.string<DBQueryFilterOperator>().valid(...dbQueryFilterOperatorValues)
31
34
 
32
- export const dbQueryFilterSchema = objectSchema<DBQueryFilter<any>>({
35
+ export const dbQueryFilterSchema: ObjectSchema<DBQueryFilter<any>> = objectSchema<
36
+ DBQueryFilter<any>
37
+ >({
33
38
  name: stringSchema,
34
39
  op: dbQueryFilterOperatorSchema,
35
40
  val: anySchema,
36
41
  })
37
42
 
38
- export const dbQueryOrderSchema = objectSchema<DBQueryOrder<any>>({
43
+ export const dbQueryOrderSchema: ObjectSchema<DBQueryOrder<any>> = objectSchema<DBQueryOrder<any>>({
39
44
  name: stringSchema,
40
45
  descending: booleanSchema.optional(),
41
46
  })
42
47
 
43
- export const dbQuerySchema = objectSchema<DBQuery<any>>({
48
+ export const dbQuerySchema: ObjectSchema<DBQuery<any>> = objectSchema<DBQuery<any>>({
44
49
  table: stringSchema,
45
50
  _filters: arraySchema(dbQueryFilterSchema).optional(),
46
51
  _limitValue: integerSchema.min(0).optional(),