@naturalcycles/firestore-lib 2.18.0 → 2.19.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.
@@ -52,7 +52,7 @@ export interface FirestoreDBCfg {
52
52
  */
53
53
  streamOptions?: FirestoreDBStreamOptions;
54
54
  /**
55
- * Default to `console`
55
+ * Default to `consoleLogger`
56
56
  */
57
57
  logger?: CommonLogger;
58
58
  logLevel?: CommonLogLevel;
@@ -3,6 +3,7 @@ import { BaseCommonDB, commonDBFullSupport } from '@naturalcycles/db-lib';
3
3
  import { _isTruthy } from '@naturalcycles/js-lib';
4
4
  import { _chunk } from '@naturalcycles/js-lib/array/array.util.js';
5
5
  import { _assert } from '@naturalcycles/js-lib/error/assert.js';
6
+ import { consoleLogger } from '@naturalcycles/js-lib/log';
6
7
  import { _filterUndefinedValues, _omit } from '@naturalcycles/js-lib/object/object.util.js';
7
8
  import { pMap } from '@naturalcycles/js-lib/promise/pMap.js';
8
9
  import { _stringMapEntries } from '@naturalcycles/js-lib/types';
@@ -15,7 +16,7 @@ export class FirestoreDB extends BaseCommonDB {
15
16
  constructor(cfg) {
16
17
  super();
17
18
  this.cfg = {
18
- logger: console,
19
+ logger: consoleLogger,
19
20
  ...cfg,
20
21
  };
21
22
  }
@@ -67,7 +67,7 @@ export class FirestoreShardedReadable extends Readable {
67
67
  return;
68
68
  }
69
69
  void this.runNextQuery(shard).catch(err => {
70
- this.logger.error('error in runNextQuery', err);
70
+ this.logger.error({ msg: 'error in runNextQuery', err });
71
71
  this.destroy(err);
72
72
  });
73
73
  }
@@ -85,7 +85,8 @@ export class FirestoreShardedReadable extends Readable {
85
85
  if (this.cursorByShard[shard]) {
86
86
  q = q.startAfter(this.cursorByShard[shard]);
87
87
  }
88
- logger.debug(`runNextQuery[${shard}]`, {
88
+ logger.debug({
89
+ msg: `runNextQuery[${shard}]`,
89
90
  retrieved: this.rowsRetrieved,
90
91
  });
91
92
  const qs = await this.runQuery(q);
@@ -154,10 +155,12 @@ export class FirestoreShardedReadable extends Readable {
154
155
  });
155
156
  }
156
157
  catch (err) {
157
- logger.error(`FirestoreStreamReadable error!\n`, {
158
+ logger.error({
159
+ msg: `FirestoreStreamReadable error!`,
158
160
  table,
159
161
  rowsRetrieved: this.rowsRetrieved,
160
- }, err);
162
+ err,
163
+ });
161
164
  this.destroy(err);
162
165
  }
163
166
  }
@@ -41,7 +41,8 @@ export class FirestoreStreamReadable extends Readable {
41
41
  this.table = dbQuery.table;
42
42
  const logger = createCommonLoggerAtLevel(opt.logger, opt.logLevel);
43
43
  this.logger = logger;
44
- logger.log(`!!! using experimentalCursorStream`, {
44
+ logger.log({
45
+ msg: `!!! using experimentalCursorStream`,
45
46
  table: this.table,
46
47
  batchSize,
47
48
  highWaterMark,
@@ -64,7 +65,7 @@ export class FirestoreStreamReadable extends Readable {
64
65
  return;
65
66
  }
66
67
  void this.runNextQuery().catch(err => {
67
- this.logger.error('error in runNextQuery', err);
68
+ this.logger.error({ msg: 'error in runNextQuery', err });
68
69
  this.destroy(err);
69
70
  });
70
71
  }
@@ -159,10 +160,12 @@ export class FirestoreStreamReadable extends Readable {
159
160
  }
160
161
  catch (err) {
161
162
  // console.log((q as any)._queryOptions)
162
- logger.error(`FirestoreStreamReadable error!\n`, {
163
+ logger.error({
164
+ msg: `FirestoreStreamReadable error!`,
163
165
  table,
164
166
  rowsRetrieved: this.rowsRetrieved,
165
- }, err);
167
+ err,
168
+ });
166
169
  this.destroy(err);
167
170
  }
168
171
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "tslib": "^2"
10
10
  },
11
11
  "devDependencies": {
12
- "@naturalcycles/dev-lib": "0.0.0",
12
+ "@naturalcycles/dev-lib": "20.64.0",
13
13
  "@types/node": "^26",
14
14
  "typescript": "^7",
15
15
  "firebase-admin": "^14"
@@ -38,7 +38,7 @@
38
38
  "engines": {
39
39
  "node": ">=24.10.0"
40
40
  },
41
- "version": "2.18.0",
41
+ "version": "2.19.0",
42
42
  "description": "Firestore implementation of CommonDB interface",
43
43
  "author": "Natural Cycles Team",
44
44
  "license": "MIT",
@@ -25,6 +25,7 @@ import { BaseCommonDB, commonDBFullSupport } from '@naturalcycles/db-lib'
25
25
  import { _isTruthy } from '@naturalcycles/js-lib'
26
26
  import { _chunk } from '@naturalcycles/js-lib/array/array.util.js'
27
27
  import { _assert } from '@naturalcycles/js-lib/error/assert.js'
28
+ import { consoleLogger } from '@naturalcycles/js-lib/log'
28
29
  import type { CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib/log'
29
30
  import { _filterUndefinedValues, _omit } from '@naturalcycles/js-lib/object/object.util.js'
30
31
  import { pMap } from '@naturalcycles/js-lib/promise/pMap.js'
@@ -41,7 +42,7 @@ export class FirestoreDB extends BaseCommonDB implements CommonDB {
41
42
  constructor(cfg: FirestoreDBCfg) {
42
43
  super()
43
44
  this.cfg = {
44
- logger: console,
45
+ logger: consoleLogger,
45
46
  ...cfg,
46
47
  }
47
48
  }
@@ -559,7 +560,7 @@ export interface FirestoreDBCfg {
559
560
  streamOptions?: FirestoreDBStreamOptions
560
561
 
561
562
  /**
562
- * Default to `console`
563
+ * Default to `consoleLogger`
563
564
  */
564
565
  logger?: CommonLogger
565
566
 
@@ -97,7 +97,7 @@ export class FirestoreShardedReadable<T extends ObjectWithId = any>
97
97
  return
98
98
  }
99
99
  void this.runNextQuery(shard).catch(err => {
100
- this.logger.error('error in runNextQuery', err)
100
+ this.logger.error({ msg: 'error in runNextQuery', err })
101
101
  this.destroy(err)
102
102
  })
103
103
  }
@@ -121,7 +121,8 @@ export class FirestoreShardedReadable<T extends ObjectWithId = any>
121
121
  q = q.startAfter(this.cursorByShard[shard])
122
122
  }
123
123
 
124
- logger.debug(`runNextQuery[${shard}]`, {
124
+ logger.debug({
125
+ msg: `runNextQuery[${shard}]`,
125
126
  retrieved: this.rowsRetrieved,
126
127
  })
127
128
  const qs = await this.runQuery(q)
@@ -212,14 +213,12 @@ export class FirestoreShardedReadable<T extends ObjectWithId = any>
212
213
  },
213
214
  )
214
215
  } catch (err) {
215
- logger.error(
216
- `FirestoreStreamReadable error!\n`,
217
- {
218
- table,
219
- rowsRetrieved: this.rowsRetrieved,
220
- },
216
+ logger.error({
217
+ msg: `FirestoreStreamReadable error!`,
218
+ table,
219
+ rowsRetrieved: this.rowsRetrieved,
221
220
  err,
222
- )
221
+ })
223
222
  this.destroy(err as Error)
224
223
  }
225
224
  }
@@ -63,7 +63,8 @@ export class FirestoreStreamReadable<T extends ObjectWithId = any>
63
63
  const logger = createCommonLoggerAtLevel(opt.logger, opt.logLevel)
64
64
  this.logger = logger
65
65
 
66
- logger.log(`!!! using experimentalCursorStream`, {
66
+ logger.log({
67
+ msg: `!!! using experimentalCursorStream`,
67
68
  table: this.table,
68
69
  batchSize,
69
70
  highWaterMark,
@@ -94,7 +95,7 @@ export class FirestoreStreamReadable<T extends ObjectWithId = any>
94
95
  }
95
96
 
96
97
  void this.runNextQuery().catch(err => {
97
- this.logger.error('error in runNextQuery', err)
98
+ this.logger.error({ msg: 'error in runNextQuery', err })
98
99
  this.destroy(err)
99
100
  })
100
101
  }
@@ -207,14 +208,12 @@ export class FirestoreStreamReadable<T extends ObjectWithId = any>
207
208
  )
208
209
  } catch (err) {
209
210
  // console.log((q as any)._queryOptions)
210
- logger.error(
211
- `FirestoreStreamReadable error!\n`,
212
- {
213
- table,
214
- rowsRetrieved: this.rowsRetrieved,
215
- },
211
+ logger.error({
212
+ msg: `FirestoreStreamReadable error!`,
213
+ table,
214
+ rowsRetrieved: this.rowsRetrieved,
216
215
  err,
217
- )
216
+ })
218
217
  this.destroy(err as Error)
219
218
  }
220
219
  }