@naturalcycles/backend-lib 4.23.2 → 4.23.4

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/cfg/tsconfig.json CHANGED
@@ -59,8 +59,8 @@
59
59
  // Other
60
60
  "pretty": true,
61
61
  "newLine": "lf",
62
- "experimentalDecorators": true
63
- }
62
+ "experimentalDecorators": true,
63
+ },
64
64
  // Need to be specified in the project tsconfig
65
65
  // "include": ["src"],
66
66
  // "exclude": ["**/__exclude"]
@@ -1,4 +1,4 @@
1
- import { BaseCommonDB, CommonDB, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, DBQuery, RunQueryResult } from '@naturalcycles/db-lib';
1
+ import { BaseCommonDB, CommonDB, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, CommonDBSupport, DBQuery, RunQueryResult } from '@naturalcycles/db-lib';
2
2
  import { FetcherOptions, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib';
3
3
  import { ReadableTyped } from '@naturalcycles/nodejs-lib';
4
4
  export interface HttpDBCfg extends FetcherOptions {
@@ -9,6 +9,7 @@ export interface HttpDBCfg extends FetcherOptions {
9
9
  */
10
10
  export declare class HttpDB extends BaseCommonDB implements CommonDB {
11
11
  cfg: HttpDBCfg;
12
+ support: CommonDBSupport;
12
13
  constructor(cfg: HttpDBCfg);
13
14
  setCfg(cfg: HttpDBCfg): void;
14
15
  private fetcher;
@@ -19,7 +20,7 @@ export declare class HttpDB extends BaseCommonDB implements CommonDB {
19
20
  getByIds<ROW extends ObjectWithId>(table: string, ids: ROW['id'][], opt?: CommonDBOptions): Promise<ROW[]>;
20
21
  runQuery<ROW extends ObjectWithId>(query: DBQuery<ROW>, opt?: CommonDBOptions): Promise<RunQueryResult<ROW>>;
21
22
  runQueryCount<ROW extends ObjectWithId>(query: DBQuery<ROW>, opt?: CommonDBOptions): Promise<number>;
22
- saveBatch<ROW extends Partial<ObjectWithId>>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
23
+ saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
23
24
  deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number>;
24
25
  deleteByQuery<ROW extends ObjectWithId>(query: DBQuery<ROW>, opt?: CommonDBOptions): Promise<number>;
25
26
  streamQuery<ROW extends ObjectWithId>(_q: DBQuery<ROW>, _opt?: CommonDBStreamOptions): ReadableTyped<ROW>;
package/dist/db/httpDB.js CHANGED
@@ -11,6 +11,16 @@ class HttpDB extends db_lib_1.BaseCommonDB {
11
11
  constructor(cfg) {
12
12
  super();
13
13
  this.cfg = cfg;
14
+ this.support = {
15
+ ...db_lib_1.commonDBFullSupport,
16
+ streaming: false,
17
+ createTable: false,
18
+ bufferValues: false,
19
+ updateSaveMethod: false,
20
+ insertSaveMethod: false,
21
+ transactions: false,
22
+ updateByQuery: false,
23
+ };
14
24
  this.setCfg(cfg);
15
25
  }
16
26
  setCfg(cfg) {
@@ -15,7 +15,7 @@ export interface RunQueryInput {
15
15
  export interface SaveBatchInput {
16
16
  table: string;
17
17
  rows: ObjectWithId[];
18
- opt?: CommonDBSaveOptions;
18
+ opt?: CommonDBSaveOptions<any>;
19
19
  }
20
20
  /**
21
21
  * Exposes CommonDB interface from provided CommonDB as HTTP endpoint (Express RequestHandler).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.23.2",
3
+ "version": "4.23.4",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -16,7 +16,7 @@
16
16
  "@sentry/node": "^7.0.0"
17
17
  },
18
18
  "dependencies": {
19
- "@naturalcycles/db-lib": "^8.0.2",
19
+ "@naturalcycles/db-lib": "^9.1.0",
20
20
  "@naturalcycles/js-lib": "^14.27.0",
21
21
  "@naturalcycles/nodejs-lib": "^13.1.0",
22
22
  "@types/cookie-parser": "^1.4.1",
package/src/db/httpDB.ts CHANGED
@@ -2,9 +2,11 @@ import { Readable } from 'node:stream'
2
2
  import {
3
3
  BaseCommonDB,
4
4
  CommonDB,
5
+ commonDBFullSupport,
5
6
  CommonDBOptions,
6
7
  CommonDBSaveOptions,
7
8
  CommonDBStreamOptions,
9
+ CommonDBSupport,
8
10
  DBQuery,
9
11
  RunQueryResult,
10
12
  } from '@naturalcycles/db-lib'
@@ -25,6 +27,17 @@ export interface HttpDBCfg extends FetcherOptions {
25
27
  * Implementation of CommonDB that proxies all requests via HTTP to "httpDBRequestHandler".
26
28
  */
27
29
  export class HttpDB extends BaseCommonDB implements CommonDB {
30
+ override support: CommonDBSupport = {
31
+ ...commonDBFullSupport,
32
+ streaming: false,
33
+ createTable: false,
34
+ bufferValues: false,
35
+ updateSaveMethod: false,
36
+ insertSaveMethod: false,
37
+ transactions: false,
38
+ updateByQuery: false,
39
+ }
40
+
28
41
  constructor(public cfg: HttpDBCfg) {
29
42
  super()
30
43
  this.setCfg(cfg)
@@ -92,7 +105,7 @@ export class HttpDB extends BaseCommonDB implements CommonDB {
92
105
  })
93
106
  }
94
107
 
95
- override async saveBatch<ROW extends Partial<ObjectWithId>>(
108
+ override async saveBatch<ROW extends ObjectWithId>(
96
109
  table: string,
97
110
  rows: ROW[],
98
111
  opt?: CommonDBSaveOptions<ROW>,
@@ -106,7 +119,7 @@ export class HttpDB extends BaseCommonDB implements CommonDB {
106
119
  })
107
120
  }
108
121
 
109
- async deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number> {
122
+ override async deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number> {
110
123
  return await this.fetcher.put(`deleteByIds`, {
111
124
  json: {
112
125
  table,
@@ -39,7 +39,7 @@ const runQueryInputSchema = objectSchema<RunQueryInput>({
39
39
  export interface SaveBatchInput {
40
40
  table: string
41
41
  rows: ObjectWithId[]
42
- opt?: CommonDBSaveOptions
42
+ opt?: CommonDBSaveOptions<any>
43
43
  }
44
44
 
45
45
  const saveBatchInputSchema = objectSchema<SaveBatchInput>({