remult 3.3.8 → 3.3.9

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.
@@ -2,6 +2,8 @@ import { dbNamesOf, shouldCreateEntity, shouldNotCreateField, } from '../src/fil
2
2
  import { isAutoIncrement } from '../src/remult3/RepositoryImplementation.js';
3
3
  import { ValueConverters } from '../src/valueConverters.js';
4
4
  export function postgresColumnSyntax(x, dbName) {
5
+ if (isAutoIncrement(x))
6
+ return dbName + ' serial';
5
7
  let result = dbName;
6
8
  if (x.valueType == Number) {
7
9
  if (!x.valueConverter.fieldTypeInDb)
@@ -129,11 +131,7 @@ export class PostgresSchemaBuilder {
129
131
  if (result.length != 0)
130
132
  result += ',';
131
133
  result += '\r\n ';
132
- if (isAutoIncrement(x))
133
- result += e.$dbNameOf(x) + ' serial';
134
- else {
135
- result += postgresColumnSyntax(x, e.$dbNameOf(x));
136
- }
134
+ result += postgresColumnSyntax(x, e.$dbNameOf(x));
137
135
  }
138
136
  }
139
137
  result += `,\r\n primary key (${entity.idMetadata.fields
@@ -1,3 +1,8 @@
1
+ const connectionLostNames = new Set([
2
+ 'InvalidStateError',
3
+ 'UnknownError',
4
+ 'AbortError',
5
+ ]);
1
6
  export class JsonEntityIndexedDbStorage {
2
7
  dbName;
3
8
  storeName;
@@ -25,7 +30,9 @@ export class JsonEntityIndexedDbStorage {
25
30
  const attempt = async () => {
26
31
  const db = await this.init();
27
32
  return new Promise((resolve, reject) => {
28
- const request = op(db.transaction([this.storeName], mode).objectStore(this.storeName));
33
+ const tx = db.transaction([this.storeName], mode);
34
+ tx.onabort = () => reject(tx.error);
35
+ const request = op(tx.objectStore(this.storeName));
29
36
  request.onerror = () => reject(request.error);
30
37
  request.onsuccess = () => resolve(request.result ?? null);
31
38
  });
@@ -34,7 +41,7 @@ export class JsonEntityIndexedDbStorage {
34
41
  return await attempt();
35
42
  }
36
43
  catch (err) {
37
- if (err?.name !== 'InvalidStateError')
44
+ if (!connectionLostNames.has(err?.name))
38
45
  throw err;
39
46
  this.db = undefined;
40
47
  return await attempt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "3.3.8",
3
+ "version": "3.3.9",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -7,6 +7,8 @@ var filter_consumer_bridge_to_sql_request_js_1 = require("../src/filter/filter-c
7
7
  var RepositoryImplementation_js_1 = require("../src/remult3/RepositoryImplementation.js");
8
8
  var valueConverters_js_1 = require("../src/valueConverters.js");
9
9
  function postgresColumnSyntax(x, dbName) {
10
+ if ((0, RepositoryImplementation_js_1.isAutoIncrement)(x))
11
+ return dbName + ' serial';
10
12
  var result = dbName;
11
13
  if (x.valueType == Number) {
12
14
  if (!x.valueConverter.fieldTypeInDb)
@@ -218,11 +220,7 @@ var PostgresSchemaBuilder = /** @class */ (function () {
218
220
  if (result.length != 0)
219
221
  result += ',';
220
222
  result += '\r\n ';
221
- if ((0, RepositoryImplementation_js_1.isAutoIncrement)(x))
222
- result += e.$dbNameOf(x) + ' serial';
223
- else {
224
- result += postgresColumnSyntax(x, e.$dbNameOf(x));
225
- }
223
+ result += postgresColumnSyntax(x, e.$dbNameOf(x));
226
224
  }
227
225
  }
228
226
  }
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsonEntityIndexedDbStorage = void 0;
4
4
  var tslib_1 = require("tslib");
5
+ var connectionLostNames = new Set([
6
+ 'InvalidStateError',
7
+ 'UnknownError',
8
+ 'AbortError',
9
+ ]);
5
10
  var JsonEntityIndexedDbStorage = /** @class */ (function () {
6
11
  function JsonEntityIndexedDbStorage(dbName, storeName) {
7
12
  if (dbName === void 0) { dbName = 'db'; }
@@ -41,7 +46,9 @@ var JsonEntityIndexedDbStorage = /** @class */ (function () {
41
46
  case 1:
42
47
  db = _a.sent();
43
48
  return [2 /*return*/, new Promise(function (resolve, reject) {
44
- var request = op(db.transaction([_this.storeName], mode).objectStore(_this.storeName));
49
+ var tx = db.transaction([_this.storeName], mode);
50
+ tx.onabort = function () { return reject(tx.error); };
51
+ var request = op(tx.objectStore(_this.storeName));
45
52
  request.onerror = function () { return reject(request.error); };
46
53
  request.onsuccess = function () { var _a; return resolve((_a = request.result) !== null && _a !== void 0 ? _a : null); };
47
54
  })];
@@ -55,7 +62,7 @@ var JsonEntityIndexedDbStorage = /** @class */ (function () {
55
62
  case 2: return [2 /*return*/, _a.sent()];
56
63
  case 3:
57
64
  err_1 = _a.sent();
58
- if ((err_1 === null || err_1 === void 0 ? void 0 : err_1.name) !== 'InvalidStateError')
65
+ if (!connectionLostNames.has(err_1 === null || err_1 === void 0 ? void 0 : err_1.name))
59
66
  throw err_1;
60
67
  this.db = undefined;
61
68
  return [4 /*yield*/, attempt()];