@naturalcycles/datastore-lib 4.8.0 → 4.9.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.
@@ -107,7 +107,9 @@ export class DatastoreStreamReadable extends Readable {
107
107
  this.endCursor = info.endCursor;
108
108
  this.running = false; // ready to take more _reads
109
109
  this.lastQueryDone = Date.now();
110
- rows.forEach(row => this.push(row));
110
+ for (const row of rows) {
111
+ this.push(row);
112
+ }
111
113
  if (!info.endCursor ||
112
114
  info.moreResults === 'NO_MORE_RESULTS' ||
113
115
  (this.originalLimit && this.rowsRetrieved >= this.originalLimit)) {
@@ -1,5 +1,6 @@
1
1
  import { Transform } from 'node:stream';
2
2
  import { BaseCommonDB, commonDBFullSupport } from '@naturalcycles/db-lib';
3
+ import { _round } from '@naturalcycles/js-lib';
3
4
  import { _chunk } from '@naturalcycles/js-lib/array/array.util.js';
4
5
  import { _assert } from '@naturalcycles/js-lib/error/assert.js';
5
6
  import { _errorDataAppend, TimeoutError } from '@naturalcycles/js-lib/error/error.util.js';
@@ -471,7 +472,8 @@ export class DatastoreDB extends BaseCommonDB {
471
472
  return {};
472
473
  return {
473
474
  // Datastore expects UnixTimestamp in milliseconds
474
- readTime: opt.readAt * 1000,
475
+ // Datastore requires the timestamp to be rounded to the whole minutes
476
+ readTime: _round(opt.readAt, 60) * 1000,
475
477
  };
476
478
  }
477
479
  }
@@ -8,10 +8,7 @@ export declare class DatastoreKeyValueDB implements CommonKeyValueDB {
8
8
  cfg: DatastoreKeyValueDBCfg;
9
9
  constructor(cfg: DatastoreKeyValueDBCfg);
10
10
  db: DatastoreDB;
11
- support: {
12
- increment: boolean;
13
- count?: boolean;
14
- };
11
+ support: any;
15
12
  ping(): Promise<void>;
16
13
  createTable(): Promise<void>;
17
14
  getByIds(table: string, ids: string[]): Promise<KeyValueDBTuple[]>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/datastore-lib",
3
3
  "type": "module",
4
- "version": "4.8.0",
4
+ "version": "4.9.0",
5
5
  "description": "Opinionated library to work with Google Datastore, implements CommonDB",
6
6
  "dependencies": {
7
7
  "@google-cloud/datastore": "^10",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^24",
14
- "@naturalcycles/dev-lib": "19.11.0"
14
+ "@naturalcycles/dev-lib": "18.4.2"
15
15
  },
16
16
  "exports": {
17
17
  ".": "./dist/index.js"
@@ -154,7 +154,9 @@ export class DatastoreStreamReadable<T = any> extends Readable implements Readab
154
154
  this.running = false // ready to take more _reads
155
155
  this.lastQueryDone = Date.now()
156
156
 
157
- rows.forEach(row => this.push(row))
157
+ for (const row of rows) {
158
+ this.push(row)
159
+ }
158
160
 
159
161
  if (
160
162
  !info.endCursor ||
@@ -15,6 +15,7 @@ import type {
15
15
  RunQueryResult,
16
16
  } from '@naturalcycles/db-lib'
17
17
  import { BaseCommonDB, commonDBFullSupport } from '@naturalcycles/db-lib'
18
+ import { _round } from '@naturalcycles/js-lib'
18
19
  import { _chunk } from '@naturalcycles/js-lib/array/array.util.js'
19
20
  import { _assert } from '@naturalcycles/js-lib/error/assert.js'
20
21
  import { _errorDataAppend, TimeoutError } from '@naturalcycles/js-lib/error/error.util.js'
@@ -660,7 +661,8 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
660
661
 
661
662
  return {
662
663
  // Datastore expects UnixTimestamp in milliseconds
663
- readTime: opt.readAt * 1000,
664
+ // Datastore requires the timestamp to be rounded to the whole minutes
665
+ readTime: _round(opt.readAt, 60) * 1000,
664
666
  }
665
667
  }
666
668
  }