@naturalcycles/datastore-lib 3.20.0 → 3.22.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.
@@ -10,7 +10,7 @@ const DatastoreStreamReadable_1 = require("./DatastoreStreamReadable");
10
10
  const query_util_1 = require("./query.util");
11
11
  // Datastore (also Firestore and other Google APIs) supports max 500 of items when saving/deleting, etc.
12
12
  const MAX_ITEMS = 500;
13
- const RETRY_ON = ['GOAWAY', 'UNAVAILABLE', 'UNKNOWN'];
13
+ const RETRY_ON = ['GOAWAY', 'UNAVAILABLE', 'UNKNOWN', 'much contention'];
14
14
  // Examples of errors:
15
15
  // UNKNOWN: Stream removed
16
16
  const methodMap = {
@@ -303,7 +303,8 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
303
303
  stats
304
304
  .filter(s => !s.property_name.includes('.') && s.property_name !== 'id') // filter out objectify's "virtual properties"
305
305
  .forEach(stats => {
306
- const { property_name: name, property_type: dtype } = stats;
306
+ const { property_type: dtype } = stats;
307
+ const name = stats.property_name;
307
308
  if (dtype === datastore_model_1.DatastoreType.Blob) {
308
309
  s.properties[name] = {
309
310
  instanceof: 'Buffer',
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dbQueryToDatastoreQuery = void 0;
4
- // import Operator = google.datastore.v1.CompositeFilter.Operator
5
4
  const FNAME_MAP = {
6
5
  id: '__key__',
7
6
  };
8
7
  const OP_MAP = {
9
8
  '==': '=',
9
+ in: 'IN',
10
+ 'not-in': 'NOT_IN',
10
11
  };
11
12
  function dbQueryToDatastoreQuery(dbQuery, emptyQuery) {
12
13
  let q = emptyQuery;
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@naturalcycles/datastore-lib",
3
- "version": "3.20.0",
3
+ "version": "3.22.0",
4
4
  "description": "Opinionated library to work with Google Datastore",
5
5
  "scripts": {
6
6
  "prepare": "husky install"
7
7
  },
8
- "peerDependencies": {
9
- "@google-cloud/datastore": ">=6.0.0"
10
- },
11
8
  "dependencies": {
9
+ "@google-cloud/datastore": "^7.0.0",
12
10
  "@naturalcycles/db-lib": "^8.0.0",
13
11
  "@naturalcycles/js-lib": "^14.0.0",
14
12
  "@naturalcycles/nodejs-lib": "^12.0.0",
15
13
  "grpc": "^1.24.2"
16
14
  },
17
15
  "devDependencies": {
18
- "@google-cloud/datastore": "^6.0.0",
19
- "@naturalcycles/dev-lib": "^12.0.1",
20
- "@types/node": "^17.0.8",
21
- "jest": "^27.0.4"
16
+ "@naturalcycles/dev-lib": "^13.0.0",
17
+ "@types/node": "^18.7.2",
18
+ "jest": "^28.1.0"
19
+ },
20
+ "resolutions": {
21
+ "long": "^4.0.0"
22
22
  },
23
23
  "files": [
24
24
  "dist",
@@ -45,7 +45,7 @@ import { dbQueryToDatastoreQuery } from './query.util'
45
45
  // Datastore (also Firestore and other Google APIs) supports max 500 of items when saving/deleting, etc.
46
46
  const MAX_ITEMS = 500
47
47
 
48
- const RETRY_ON = ['GOAWAY', 'UNAVAILABLE', 'UNKNOWN']
48
+ const RETRY_ON = ['GOAWAY', 'UNAVAILABLE', 'UNKNOWN', 'much contention']
49
49
  // Examples of errors:
50
50
  // UNKNOWN: Stream removed
51
51
 
@@ -448,7 +448,8 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
448
448
  stats
449
449
  .filter(s => !s.property_name.includes('.') && s.property_name !== 'id') // filter out objectify's "virtual properties"
450
450
  .forEach(stats => {
451
- const { property_name: name, property_type: dtype } = stats
451
+ const { property_type: dtype } = stats
452
+ const name = stats.property_name as keyof ROW
452
453
 
453
454
  if (dtype === DatastoreType.Blob) {
454
455
  s.properties[name] = {
@@ -488,7 +489,9 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
488
489
  } as JsonSchemaNull
489
490
  }
490
491
  } else {
491
- throw new Error(`Unknown Datastore Type '${stats.property_type}' for ${table}.${name}`)
492
+ throw new Error(
493
+ `Unknown Datastore Type '${stats.property_type}' for ${table}.${name as string}`,
494
+ )
492
495
  }
493
496
  })
494
497
 
package/src/query.util.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Query } from '@google-cloud/datastore'
2
2
  import { DBQuery, DBQueryFilterOperator } from '@naturalcycles/db-lib'
3
3
  import { ObjectWithId, StringMap } from '@naturalcycles/js-lib'
4
- // import Operator = google.datastore.v1.CompositeFilter.Operator
5
4
 
6
5
  const FNAME_MAP: StringMap = {
7
6
  id: '__key__',
@@ -9,6 +8,8 @@ const FNAME_MAP: StringMap = {
9
8
 
10
9
  const OP_MAP: Partial<Record<DBQueryFilterOperator, string>> = {
11
10
  '==': '=',
11
+ in: 'IN',
12
+ 'not-in': 'NOT_IN',
12
13
  }
13
14
 
14
15
  export function dbQueryToDatastoreQuery<ROW extends ObjectWithId>(