@naturalcycles/datastore-lib 4.7.0 → 4.8.1
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,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
-
import { _ms } from '@naturalcycles/js-lib/datetime';
|
|
3
|
-
import { pRetry } from '@naturalcycles/js-lib/promise';
|
|
2
|
+
import { _ms } from '@naturalcycles/js-lib/datetime/time.util.js';
|
|
3
|
+
import { pRetry } from '@naturalcycles/js-lib/promise/pRetry.js';
|
|
4
4
|
export class DatastoreStreamReadable extends Readable {
|
|
5
5
|
q;
|
|
6
6
|
logger;
|
package/dist/datastore.db.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Transform } from 'node:stream';
|
|
2
2
|
import { BaseCommonDB, commonDBFullSupport } from '@naturalcycles/db-lib';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { _round } from '@naturalcycles/js-lib';
|
|
4
|
+
import { _chunk } from '@naturalcycles/js-lib/array/array.util.js';
|
|
5
|
+
import { _assert } from '@naturalcycles/js-lib/error/assert.js';
|
|
6
|
+
import { _errorDataAppend, TimeoutError } from '@naturalcycles/js-lib/error/error.util.js';
|
|
5
7
|
import { commonLoggerMinLevel } from '@naturalcycles/js-lib/log';
|
|
6
|
-
import { _omit } from '@naturalcycles/js-lib/object';
|
|
7
|
-
import { pMap
|
|
8
|
+
import { _omit } from '@naturalcycles/js-lib/object/object.util.js';
|
|
9
|
+
import { pMap } from '@naturalcycles/js-lib/promise/pMap.js';
|
|
10
|
+
import { pRetry, pRetryFn } from '@naturalcycles/js-lib/promise/pRetry.js';
|
|
11
|
+
import { pTimeout } from '@naturalcycles/js-lib/promise/pTimeout.js';
|
|
8
12
|
import { boldWhite } from '@naturalcycles/nodejs-lib/colors';
|
|
9
13
|
import { DatastoreType } from './datastore.model.js';
|
|
10
14
|
import { DatastoreStreamReadable } from './DatastoreStreamReadable.js';
|
|
@@ -468,7 +472,8 @@ export class DatastoreDB extends BaseCommonDB {
|
|
|
468
472
|
return {};
|
|
469
473
|
return {
|
|
470
474
|
// Datastore expects UnixTimestamp in milliseconds
|
|
471
|
-
|
|
475
|
+
// Datastore requires the timestamp to be rounded to the whole minutes
|
|
476
|
+
readTime: _round(opt.readAt, 60) * 1000,
|
|
472
477
|
};
|
|
473
478
|
}
|
|
474
479
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DBQuery } from '@naturalcycles/db-lib';
|
|
2
2
|
import { commonKeyValueDBFullSupport } from '@naturalcycles/db-lib/kv';
|
|
3
|
-
import { AppError } from '@naturalcycles/js-lib/error';
|
|
3
|
+
import { AppError } from '@naturalcycles/js-lib/error/error.util.js';
|
|
4
4
|
import { DatastoreDB } from './datastore.db.js';
|
|
5
5
|
const excludeFromIndexes = ['v'];
|
|
6
6
|
export class DatastoreKeyValueDB {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/datastore-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.8.1",
|
|
5
5
|
"description": "Opinionated library to work with Google Datastore, implements CommonDB",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@google-cloud/datastore": "^10",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"@naturalcycles/nodejs-lib": "^15"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@
|
|
14
|
-
"@
|
|
13
|
+
"@types/node": "^24",
|
|
14
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./dist/index.js"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import type { Query } from '@google-cloud/datastore'
|
|
3
3
|
import type { RunQueryInfo, RunQueryOptions } from '@google-cloud/datastore/build/src/query.js'
|
|
4
|
-
import { _ms } from '@naturalcycles/js-lib/datetime'
|
|
4
|
+
import { _ms } from '@naturalcycles/js-lib/datetime/time.util.js'
|
|
5
5
|
import type { CommonLogger } from '@naturalcycles/js-lib/log'
|
|
6
|
-
import { pRetry } from '@naturalcycles/js-lib/promise'
|
|
6
|
+
import { pRetry } from '@naturalcycles/js-lib/promise/pRetry.js'
|
|
7
7
|
import type { UnixTimestampMillis } from '@naturalcycles/js-lib/types'
|
|
8
8
|
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
9
9
|
import type { DatastoreDBStreamOptions } from './datastore.model.js'
|
package/src/datastore.db.ts
CHANGED
|
@@ -15,8 +15,10 @@ import type {
|
|
|
15
15
|
RunQueryResult,
|
|
16
16
|
} from '@naturalcycles/db-lib'
|
|
17
17
|
import { BaseCommonDB, commonDBFullSupport } from '@naturalcycles/db-lib'
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { _round } from '@naturalcycles/js-lib'
|
|
19
|
+
import { _chunk } from '@naturalcycles/js-lib/array/array.util.js'
|
|
20
|
+
import { _assert } from '@naturalcycles/js-lib/error/assert.js'
|
|
21
|
+
import { _errorDataAppend, TimeoutError } from '@naturalcycles/js-lib/error/error.util.js'
|
|
20
22
|
import type {
|
|
21
23
|
JsonSchemaAny,
|
|
22
24
|
JsonSchemaBoolean,
|
|
@@ -28,9 +30,11 @@ import type {
|
|
|
28
30
|
} from '@naturalcycles/js-lib/json-schema'
|
|
29
31
|
import type { CommonLogger } from '@naturalcycles/js-lib/log'
|
|
30
32
|
import { commonLoggerMinLevel } from '@naturalcycles/js-lib/log'
|
|
31
|
-
import { _omit } from '@naturalcycles/js-lib/object'
|
|
33
|
+
import { _omit } from '@naturalcycles/js-lib/object/object.util.js'
|
|
32
34
|
import type { PRetryOptions } from '@naturalcycles/js-lib/promise'
|
|
33
|
-
import { pMap
|
|
35
|
+
import { pMap } from '@naturalcycles/js-lib/promise/pMap.js'
|
|
36
|
+
import { pRetry, pRetryFn } from '@naturalcycles/js-lib/promise/pRetry.js'
|
|
37
|
+
import { pTimeout } from '@naturalcycles/js-lib/promise/pTimeout.js'
|
|
34
38
|
import type { ObjectWithId } from '@naturalcycles/js-lib/types'
|
|
35
39
|
import { boldWhite } from '@naturalcycles/nodejs-lib/colors'
|
|
36
40
|
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
@@ -657,7 +661,8 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
657
661
|
|
|
658
662
|
return {
|
|
659
663
|
// Datastore expects UnixTimestamp in milliseconds
|
|
660
|
-
|
|
664
|
+
// Datastore requires the timestamp to be rounded to the whole minutes
|
|
665
|
+
readTime: _round(opt.readAt, 60) * 1000,
|
|
661
666
|
}
|
|
662
667
|
}
|
|
663
668
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DBQuery } from '@naturalcycles/db-lib'
|
|
2
2
|
import type { CommonKeyValueDB, IncrementTuple, KeyValueDBTuple } from '@naturalcycles/db-lib/kv'
|
|
3
3
|
import { commonKeyValueDBFullSupport } from '@naturalcycles/db-lib/kv'
|
|
4
|
-
import { AppError } from '@naturalcycles/js-lib/error'
|
|
4
|
+
import { AppError } from '@naturalcycles/js-lib/error/error.util.js'
|
|
5
5
|
import type { ObjectWithId } from '@naturalcycles/js-lib/types'
|
|
6
6
|
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
7
7
|
import { DatastoreDB } from './datastore.db.js'
|