@naturalcycles/datastore-lib 3.25.0 → 3.25.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.
@@ -33,13 +33,12 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
33
33
  }
34
34
  // @memo() // not used to be able to connect to many DBs in the same server instance
35
35
  ds() {
36
- var _a;
37
36
  if (!this.cachedDatastore) {
38
37
  (0, js_lib_1._assert)(process.env['APP_ENV'] !== 'test', 'DatastoreDB cannot be used in Test env, please use InMemoryDB');
39
38
  // Lazy-loading
40
39
  const datastoreLib = require('@google-cloud/datastore');
41
40
  const DS = datastoreLib.Datastore;
42
- (_a = this.cfg).projectId || (_a.projectId = this.cfg.credentials?.project_id || process.env['GOOGLE_CLOUD_PROJECT']);
41
+ this.cfg.projectId ||= this.cfg.credentials?.project_id || process.env['GOOGLE_CLOUD_PROJECT'];
43
42
  if (this.cfg.projectId) {
44
43
  this.cfg.logger.log(`DatastoreDB connected to ${(0, colors_1.boldWhite)(this.cfg.projectId)}`);
45
44
  }
@@ -68,7 +67,7 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
68
67
  if (this.cfg.timeout) {
69
68
  // First try
70
69
  try {
71
- const r = await (0, js_lib_1.pTimeout)(this.ds().get(keys), {
70
+ const r = await (0, js_lib_1.pTimeout)(() => this.ds().get(keys), {
72
71
  timeout: this.cfg.timeout,
73
72
  name: `datastore.getByIds(${table})`,
74
73
  });
@@ -81,7 +80,7 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
81
80
  const DS = datastoreLib.Datastore;
82
81
  this.cachedDatastore = new DS(this.cfg);
83
82
  // Second try (will throw)
84
- const r = await (0, js_lib_1.pTimeout)(this.ds().get(keys), {
83
+ const r = await (0, js_lib_1.pTimeout)(() => this.ds().get(keys), {
85
84
  timeout: this.cfg.timeout,
86
85
  name: `datastore.getByIds(${table}) second try`,
87
86
  errorData: {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@naturalcycles/datastore-lib",
3
- "version": "3.25.0",
3
+ "version": "3.25.1",
4
4
  "description": "Opinionated library to work with Google Datastore",
5
5
  "scripts": {
6
6
  "prepare": "husky install"
7
7
  },
8
8
  "dependencies": {
9
9
  "@google-cloud/datastore": "^7.0.0",
10
- "@naturalcycles/db-lib": "^8.0.0",
11
- "@naturalcycles/js-lib": "^14.0.0",
10
+ "@naturalcycles/db-lib": "^8.46.1",
11
+ "@naturalcycles/js-lib": "^14.116.0",
12
12
  "@naturalcycles/nodejs-lib": "^12.0.0",
13
13
  "grpc": "^1.24.2"
14
14
  },
@@ -31,7 +31,7 @@
31
31
  "main": "dist/index.js",
32
32
  "types": "dist/index.d.ts",
33
33
  "engines": {
34
- "node": ">=14.15.0"
34
+ "node": ">=16.10.0"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
@@ -130,7 +130,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
130
130
  if (this.cfg.timeout) {
131
131
  // First try
132
132
  try {
133
- const r = await pTimeout(this.ds().get(keys), {
133
+ const r = await pTimeout(() => this.ds().get(keys), {
134
134
  timeout: this.cfg.timeout,
135
135
  name: `datastore.getByIds(${table})`,
136
136
  })
@@ -144,7 +144,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
144
144
  this.cachedDatastore = new DS(this.cfg)
145
145
 
146
146
  // Second try (will throw)
147
- const r = await pTimeout(this.ds().get(keys), {
147
+ const r = await pTimeout(() => this.ds().get(keys), {
148
148
  timeout: this.cfg.timeout,
149
149
  name: `datastore.getByIds(${table}) second try`,
150
150
  errorData: {