@naturalcycles/datastore-lib 4.18.6 → 4.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.
@@ -3,7 +3,7 @@ import { Datastore } from '@google-cloud/datastore';
3
3
  import type { CommonDB, CommonDBOptions, CommonDBReadOptions, CommonDBSaveOptions, CommonDBSupport, CommonDBTransactionOptions, DBQuery, DBTransaction, DBTransactionFn, RunQueryResult } from '@naturalcycles/db-lib';
4
4
  import { BaseCommonDB } from '@naturalcycles/db-lib';
5
5
  import type { CommonLogger } from '@naturalcycles/js-lib/log';
6
- import { type ObjectWithId, type StringMap } from '@naturalcycles/js-lib/types';
6
+ import type { ObjectWithId, StringMap } from '@naturalcycles/js-lib/types';
7
7
  import type { JsonSchema } from '@naturalcycles/nodejs-lib/ajv';
8
8
  import { Pipeline } from '@naturalcycles/nodejs-lib/stream';
9
9
  import type { DatastoreDBCfg, DatastoreDBOptions, DatastoreDBReadOptions, DatastoreDBSaveOptions, DatastoreDBStreamOptions, DatastorePropertyStats, DatastoreStats } from './datastore.model.js';
@@ -61,10 +61,6 @@ export declare class DatastoreDB extends BaseCommonDB implements CommonDB {
61
61
  getTables(): Promise<string[]>;
62
62
  getTableSchema<ROW extends ObjectWithId>(table: string): Promise<JsonSchema<ROW>>;
63
63
  private getPRetryOptions;
64
- /**
65
- * Silently rollback the transaction.
66
- * It may happen that transaction is already committed/rolled back, so we don't want to throw an error here.
67
- */
68
64
  private rollback;
69
65
  }
70
66
  /**
@@ -8,7 +8,7 @@ import { _omit } from '@naturalcycles/js-lib/object/object.util.js';
8
8
  import { pMap } from '@naturalcycles/js-lib/promise/pMap.js';
9
9
  import { pRetry, pRetryFn } from '@naturalcycles/js-lib/promise/pRetry.js';
10
10
  import { pTimeout } from '@naturalcycles/js-lib/promise/pTimeout.js';
11
- import { _stringMapEntries, _stringMapValues, } from '@naturalcycles/js-lib/types';
11
+ import { _stringMapEntries, _stringMapValues } from '@naturalcycles/js-lib/types';
12
12
  import { boldWhite } from '@naturalcycles/nodejs-lib/colors';
13
13
  import { Pipeline } from '@naturalcycles/nodejs-lib/stream';
14
14
  import { DatastoreType } from './datastore.model.js';
@@ -229,7 +229,7 @@ export class DatastoreDB extends BaseCommonDB {
229
229
  await save(chunks[0]);
230
230
  }
231
231
  else {
232
- await pMap(chunks, async (batch) => await save(batch), {
232
+ await pMap(chunks, async batch => await save(batch), {
233
233
  concurrency: DATASTORE_RECOMMENDED_CONCURRENCY,
234
234
  });
235
235
  }
@@ -268,7 +268,7 @@ export class DatastoreDB extends BaseCommonDB {
268
268
  const retryOptions = this.getPRetryOptions(`DatastoreLib.deleteByIds(${table})`);
269
269
  await pMap(_chunk(keys, MAX_ITEMS),
270
270
  // async batch => await doDelete(batch),
271
- async (batchOfKeys) => {
271
+ async batchOfKeys => {
272
272
  await pRetry(async () => {
273
273
  await (opt.tx?.tx || ds).delete(batchOfKeys);
274
274
  }, retryOptions);
@@ -286,7 +286,7 @@ export class DatastoreDB extends BaseCommonDB {
286
286
  const retryOptions = this.getPRetryOptions(`DatastoreLib.multiDeleteByIds`);
287
287
  await pMap(_chunk(keys, MAX_ITEMS),
288
288
  // async batch => await doDelete(batch),
289
- async (batchOfKeys) => {
289
+ async batchOfKeys => {
290
290
  await pRetry(async () => {
291
291
  await (opt.tx?.tx || ds).delete(batchOfKeys);
292
292
  }, retryOptions);
@@ -106,12 +106,12 @@ export interface DatastoreStats {
106
106
  export declare enum DatastoreType {
107
107
  Blob = "Blob",
108
108
  Text = "Text",
109
- String = "String",// eslint-disable-line id-denylist
109
+ String = "String",
110
110
  EmbeddedEntity = "EmbeddedEntity",
111
111
  Float = "Float",
112
112
  Integer = "Integer",
113
113
  DATE_TIME = "Date/Time",
114
- Boolean = "Boolean",// eslint-disable-line id-denylist
114
+ Boolean = "Boolean",
115
115
  NULL = "NULL"
116
116
  }
117
117
  export interface DatastorePropertyStats {
@@ -1,4 +1,5 @@
1
- export var DatastoreType;
1
+ export { DatastoreType };
2
+ var DatastoreType;
2
3
  (function (DatastoreType) {
3
4
  DatastoreType["Blob"] = "Blob";
4
5
  DatastoreType["Text"] = "Text";
@@ -1,4 +1,4 @@
1
- import { type Query } from '@google-cloud/datastore';
1
+ import type { Query } from '@google-cloud/datastore';
2
2
  import type { RunQueryOptions } from '@google-cloud/datastore/build/src/query.js';
3
3
  import type { DBQuery } from '@naturalcycles/db-lib';
4
4
  import type { ObjectWithId } from '@naturalcycles/js-lib/types';
@@ -3,6 +3,7 @@ import { _round } from '@naturalcycles/js-lib';
3
3
  const FNAME_MAP = {
4
4
  id: '__key__',
5
5
  };
6
+ // export type Operator = '=' | '<' | '>' | '<=' | '>=' | 'HAS_ANCESTOR' | '!=' | 'IN' | 'NOT_IN'
6
7
  const OP_MAP = {
7
8
  '==': '=',
8
9
  in: 'IN',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/datastore-lib",
3
3
  "type": "module",
4
- "version": "4.18.6",
4
+ "version": "4.19.0",
5
5
  "description": "Opinionated library to work with Google Datastore, implements CommonDB",
6
6
  "dependencies": {
7
7
  "@google-cloud/datastore": "^10",
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^25",
14
+ "@typescript/native-preview": "7.0.0-dev.20260201.1",
14
15
  "@naturalcycles/dev-lib": "18.4.2"
15
16
  },
16
17
  "exports": {
package/readme.md CHANGED
@@ -16,3 +16,7 @@
16
16
  - Streaming with RxJS Observable interface
17
17
  - Anonymization hook to be able to plug your implementation (privacy by design)
18
18
  - ...
19
+
20
+ ## chore-counter
21
+
22
+ 1
@@ -25,12 +25,8 @@ import type { PRetryOptions } from '@naturalcycles/js-lib/promise'
25
25
  import { pMap } from '@naturalcycles/js-lib/promise/pMap.js'
26
26
  import { pRetry, pRetryFn } from '@naturalcycles/js-lib/promise/pRetry.js'
27
27
  import { pTimeout } from '@naturalcycles/js-lib/promise/pTimeout.js'
28
- import {
29
- _stringMapEntries,
30
- _stringMapValues,
31
- type ObjectWithId,
32
- type StringMap,
33
- } from '@naturalcycles/js-lib/types'
28
+ import { _stringMapEntries, _stringMapValues } from '@naturalcycles/js-lib/types'
29
+ import type { ObjectWithId, StringMap } from '@naturalcycles/js-lib/types'
34
30
  import type { JsonSchema } from '@naturalcycles/nodejs-lib/ajv'
35
31
  import { boldWhite } from '@naturalcycles/nodejs-lib/colors'
36
32
  import { Pipeline } from '@naturalcycles/nodejs-lib/stream'
@@ -606,7 +602,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
606
602
  if (dtype === DatastoreType.Blob) {
607
603
  s.properties![name] = {
608
604
  instanceof: 'Buffer',
609
- } as JsonSchema<any, ROW[typeof name]>
605
+ } as JsonSchema<ROW[typeof name]>
610
606
  } else if (dtype === DatastoreType.Text || dtype === DatastoreType.String) {
611
607
  s.properties![name] = {
612
608
  type: 'string',
@@ -7,7 +7,8 @@ import type {
7
7
  } from '@google-cloud/datastore/build/src/query.js'
8
8
  import { localTime } from '@naturalcycles/js-lib/datetime/localTime.js'
9
9
  import { _ms } from '@naturalcycles/js-lib/datetime/time.util.js'
10
- import { type CommonLogger, createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
10
+ import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
11
+ import type { CommonLogger } from '@naturalcycles/js-lib/log'
11
12
  import { pRetry } from '@naturalcycles/js-lib/promise/pRetry.js'
12
13
  import type { UnixTimestampMillis } from '@naturalcycles/js-lib/types'
13
14
  import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
package/src/query.util.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { PropertyFilter, type Query } from '@google-cloud/datastore'
2
- import type { RunQueryOptions } from '@google-cloud/datastore/build/src/query.js'
1
+ import { PropertyFilter } from '@google-cloud/datastore'
2
+ import type { Query } from '@google-cloud/datastore'
3
+ import type { Operator, RunQueryOptions } from '@google-cloud/datastore/build/src/query.js'
3
4
  import type { DBQuery, DBQueryFilterOperator } from '@naturalcycles/db-lib'
4
5
  import { _round } from '@naturalcycles/js-lib'
5
6
  import type { ObjectWithId, StringMap } from '@naturalcycles/js-lib/types'
@@ -9,7 +10,8 @@ const FNAME_MAP: StringMap = {
9
10
  id: '__key__',
10
11
  }
11
12
 
12
- const OP_MAP: Partial<Record<DBQueryFilterOperator, string>> = {
13
+ // export type Operator = '=' | '<' | '>' | '<=' | '>=' | 'HAS_ANCESTOR' | '!=' | 'IN' | 'NOT_IN'
14
+ const OP_MAP: Partial<Record<DBQueryFilterOperator, Operator>> = {
13
15
  '==': '=',
14
16
  in: 'IN',
15
17
  'not-in': 'NOT_IN',