oak-backend-base 4.1.12 → 4.1.14

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.
@@ -38,6 +38,9 @@ function verify(publicKey, body, ts, nonce, signature) {
38
38
  return verify2.verify(publicKey, signature, 'hex');
39
39
  }
40
40
  async function fetchWithTimeout(url, options, timeout = 5000) {
41
+ if (typeof AbortController === 'undefined' || timeout === 0) {
42
+ return fetch(url, options);
43
+ }
41
44
  const controller = new AbortController();
42
45
  const signal = controller.signal;
43
46
  // 设置超时
@@ -141,7 +144,7 @@ class Synchronizer {
141
144
  }
142
145
  }, {});
143
146
  const entityIds = operEntityArr.map(ele => ele.entityId);
144
- return onSynchronized({
147
+ await onSynchronized({
145
148
  action: oper.action,
146
149
  data: oper.data,
147
150
  rowIds: entityIds,
@@ -150,10 +153,8 @@ class Synchronizer {
150
153
  }, context);
151
154
  }
152
155
  }
153
- /**
154
- * 自主将triggerData属性清零
155
- */
156
156
  const operIds = queue.map(ele => ele.oper.id);
157
+ // 在内部清理相应的triggerData
157
158
  await context.operate('oper', {
158
159
  id: await (0, uuid_1.generateNewIdAsync)(),
159
160
  action: 'update',
@@ -356,6 +357,7 @@ class Synchronizer {
356
357
  }
357
358
  }));
358
359
  if (unPushedIds.length > 0) {
360
+ // 在内部清理相应的triggerData
359
361
  await context.operate('oper', {
360
362
  id: await (0, uuid_1.generateNewIdAsync)(),
361
363
  action: 'update',
@@ -376,9 +378,15 @@ class Synchronizer {
376
378
  }
377
379
  }
378
380
  if (result) {
379
- const exception = result.find(ele => ele instanceof Error);
380
- if (exception) {
381
- throw exception;
381
+ const exceptions = result.filter(ele => ele instanceof Error);
382
+ if (exceptions.length > 0) {
383
+ const notPartialSuccess = exceptions.find(ele => !(ele instanceof types_1.OakPartialSuccess));
384
+ if (notPartialSuccess) {
385
+ throw notPartialSuccess;
386
+ }
387
+ else {
388
+ console.warn('出现了PartialSuccess,部分Oper同步失败,事务仍然提交');
389
+ }
382
390
  }
383
391
  }
384
392
  }
@@ -485,6 +493,7 @@ class Synchronizer {
485
493
  strict: 'makeSure',
486
494
  singleton: true,
487
495
  grouped: true,
496
+ cleanTriggerDataBySelf: true,
488
497
  check: (operation) => {
489
498
  const { data } = operation;
490
499
  const { targetEntity, action } = data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-backend-base",
3
- "version": "4.1.12",
3
+ "version": "4.1.14",
4
4
  "description": "oak-backend-base",
5
5
  "main": "lib/index",
6
6
  "author": {
@@ -20,10 +20,10 @@
20
20
  "mysql": "^2.18.1",
21
21
  "mysql2": "^2.3.3",
22
22
  "node-schedule": "^2.1.0",
23
- "oak-common-aspect": "^3.0.4",
24
- "oak-db": "^3.3.4",
25
- "oak-domain": "^5.1.13",
26
- "oak-frontend-base": "^5.3.20",
23
+ "oak-common-aspect": "^3.0.5",
24
+ "oak-db": "^3.3.5",
25
+ "oak-domain": "^5.1.15",
26
+ "oak-frontend-base": "^5.3.22",
27
27
  "socket.io": "^4.7.2",
28
28
  "socket.io-client": "^4.7.2",
29
29
  "uuid": "^8.3.2"