@pisell/pisellos 2.2.96 → 2.2.98
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.
- package/dist/model/strategy/adapter/walletPass/type.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +70 -57
- package/dist/server/modules/resource/index.d.ts +0 -5
- package/dist/server/modules/resource/index.js +186 -269
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/walletPass/type.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/utils.js +58 -51
- package/lib/server/modules/resource/index.d.ts +0 -5
- package/lib/server/modules/resource/index.js +60 -73
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ import { ResourceHooks } from "./types";
|
|
|
34
34
|
* SQLite 存储名称
|
|
35
35
|
*/
|
|
36
36
|
var RESOURCE_STORE_NAME = 'resources';
|
|
37
|
-
|
|
37
|
+
// const BOOKING_STORE_NAME = 'resource_bookings'
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* 默认分页大小
|
|
@@ -145,7 +145,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
145
145
|
value: function () {
|
|
146
146
|
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
147
147
|
var _this3 = this;
|
|
148
|
-
var cachedResources, resources
|
|
148
|
+
var cachedResources, resources;
|
|
149
149
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
150
150
|
while (1) switch (_context2.prev = _context2.next) {
|
|
151
151
|
case 0:
|
|
@@ -182,15 +182,6 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
182
182
|
_context2.next = 18;
|
|
183
183
|
return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
|
|
184
184
|
case 18:
|
|
185
|
-
_context2.next = 20;
|
|
186
|
-
return this.loadBookingsFromSQLite();
|
|
187
|
-
case 20:
|
|
188
|
-
cachedBookings = _context2.sent;
|
|
189
|
-
if (cachedBookings.length > 0) {
|
|
190
|
-
this.store.bookings = cloneDeep(cachedBookings);
|
|
191
|
-
this.syncBookingsIndex();
|
|
192
|
-
}
|
|
193
|
-
case 22:
|
|
194
185
|
case "end":
|
|
195
186
|
return _context2.stop();
|
|
196
187
|
}
|
|
@@ -329,65 +320,57 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
320
|
/**
|
|
330
321
|
* 创建预订
|
|
331
322
|
*/
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
323
|
+
// createBooking(booking: Partial<ResourceBooking>): ResourceBooking {
|
|
324
|
+
// const id = booking?.id ?? Date.now()
|
|
325
|
+
// const normalized: ResourceBooking = {
|
|
326
|
+
// id,
|
|
327
|
+
// ...booking,
|
|
328
|
+
// } as ResourceBooking
|
|
329
|
+
|
|
330
|
+
// this.store.bookings.push(normalized)
|
|
331
|
+
|
|
332
|
+
// const rid = normalized.resource_id ?? normalized.resourceId
|
|
333
|
+
// if (rid !== undefined) {
|
|
334
|
+
// const existing = this.resourceIdIndex.get(rid) || []
|
|
335
|
+
// existing.push(normalized)
|
|
336
|
+
// this.resourceIdIndex.set(rid, existing)
|
|
337
|
+
// }
|
|
338
|
+
|
|
339
|
+
// this.saveBookingsToSQLite(this.store.bookings).catch(() => {})
|
|
340
|
+
// this.safeEmit(ResourceHooks.onBookingsChanged, this.store.bookings)
|
|
341
|
+
// return normalized
|
|
342
|
+
// }
|
|
351
343
|
|
|
352
344
|
/**
|
|
353
345
|
* 更新预订
|
|
354
346
|
*/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.rebuildBookingsIndex();
|
|
369
|
-
this.saveBookingsToSQLite(this.store.bookings).catch(function () {});
|
|
370
|
-
this.safeEmit(ResourceHooks.onBookingsChanged, this.store.bookings);
|
|
371
|
-
return updated;
|
|
372
|
-
}
|
|
347
|
+
// updateBooking(id: ResourceId, data: Partial<ResourceBooking>): ResourceBooking | undefined {
|
|
348
|
+
// const index = this.store.bookings.findIndex(b => this.getIdKey(b.id) === this.getIdKey(id))
|
|
349
|
+
// if (index === -1) return undefined
|
|
350
|
+
|
|
351
|
+
// const old = this.store.bookings[index]
|
|
352
|
+
// const updated: ResourceBooking = { ...old, ...data, id: old.id } as ResourceBooking
|
|
353
|
+
// this.store.bookings[index] = updated
|
|
354
|
+
|
|
355
|
+
// this.rebuildBookingsIndex()
|
|
356
|
+
// this.saveBookingsToSQLite(this.store.bookings).catch(() => {})
|
|
357
|
+
// this.safeEmit(ResourceHooks.onBookingsChanged, this.store.bookings)
|
|
358
|
+
// return updated
|
|
359
|
+
// }
|
|
373
360
|
|
|
374
361
|
/**
|
|
375
362
|
* 删除预订
|
|
376
363
|
*/
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
this.saveBookingsToSQLite(this.store.bookings).catch(function () {});
|
|
388
|
-
this.safeEmit(ResourceHooks.onBookingsChanged, this.store.bookings);
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
364
|
+
// deleteBooking(id: ResourceId): boolean {
|
|
365
|
+
// const index = this.store.bookings.findIndex(b => this.getIdKey(b.id) === this.getIdKey(id))
|
|
366
|
+
// if (index === -1) return false
|
|
367
|
+
|
|
368
|
+
// this.store.bookings.splice(index, 1)
|
|
369
|
+
// this.rebuildBookingsIndex()
|
|
370
|
+
// this.saveBookingsToSQLite(this.store.bookings).catch(() => {})
|
|
371
|
+
// this.safeEmit(ResourceHooks.onBookingsChanged, this.store.bookings)
|
|
372
|
+
// return true
|
|
373
|
+
// }
|
|
391
374
|
|
|
392
375
|
/**
|
|
393
376
|
* 清空缓存
|
|
@@ -448,7 +431,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
448
431
|
value: function normalizeResource(resource) {
|
|
449
432
|
var _ref2,
|
|
450
433
|
_resource$id,
|
|
451
|
-
|
|
434
|
+
_this7 = this;
|
|
452
435
|
var normalized = _objectSpread(_objectSpread({}, resource), {}, {
|
|
453
436
|
id: (_ref2 = (_resource$id = resource === null || resource === void 0 ? void 0 : resource.id) !== null && _resource$id !== void 0 ? _resource$id : resource === null || resource === void 0 ? void 0 : resource.form_record_id) !== null && _ref2 !== void 0 ? _ref2 : ''
|
|
454
437
|
});
|
|
@@ -477,7 +460,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
477
460
|
}
|
|
478
461
|
if (Array.isArray(normalized.children)) {
|
|
479
462
|
normalized.children = normalized.children.map(function (child) {
|
|
480
|
-
return
|
|
463
|
+
return _this7.normalizeResource(child);
|
|
481
464
|
});
|
|
482
465
|
}
|
|
483
466
|
return normalized;
|
|
@@ -568,7 +551,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
568
551
|
key: "loadResourcesByServer",
|
|
569
552
|
value: function () {
|
|
570
553
|
var _loadResourcesByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
571
|
-
var
|
|
554
|
+
var _this8 = this;
|
|
572
555
|
var response, resourceList, normalizedList;
|
|
573
556
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
574
557
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -589,7 +572,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
589
572
|
response = _context5.sent;
|
|
590
573
|
resourceList = Array.isArray(response === null || response === void 0 ? void 0 : response.list) ? response.list : [];
|
|
591
574
|
normalizedList = resourceList.map(function (item) {
|
|
592
|
-
return
|
|
575
|
+
return _this8.normalizeResource(item);
|
|
593
576
|
});
|
|
594
577
|
_context5.next = 10;
|
|
595
578
|
return this.saveResourcesToSQLite(normalizedList);
|
|
@@ -654,7 +637,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
654
637
|
key: "saveResourcesToSQLite",
|
|
655
638
|
value: function () {
|
|
656
639
|
var _saveResourcesToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(resourceList) {
|
|
657
|
-
var
|
|
640
|
+
var _this9 = this;
|
|
658
641
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
659
642
|
while (1) switch (_context7.prev = _context7.next) {
|
|
660
643
|
case 0:
|
|
@@ -685,7 +668,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
685
668
|
case 11:
|
|
686
669
|
_context7.next = 13;
|
|
687
670
|
return Promise.all(resourceList.map(function (r) {
|
|
688
|
-
return
|
|
671
|
+
return _this9.dbManager.add(RESOURCE_STORE_NAME, r);
|
|
689
672
|
}));
|
|
690
673
|
case 13:
|
|
691
674
|
_context7.next = 19;
|
|
@@ -708,96 +691,30 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
708
691
|
return _saveResourcesToSQLite.apply(this, arguments);
|
|
709
692
|
}
|
|
710
693
|
return saveResourcesToSQLite;
|
|
711
|
-
}()
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
return _context8.abrupt("return", []);
|
|
736
|
-
case 12:
|
|
737
|
-
case "end":
|
|
738
|
-
return _context8.stop();
|
|
739
|
-
}
|
|
740
|
-
}, _callee8, this, [[2, 9]]);
|
|
741
|
-
}));
|
|
742
|
-
function loadBookingsFromSQLite() {
|
|
743
|
-
return _loadBookingsFromSQLite.apply(this, arguments);
|
|
744
|
-
}
|
|
745
|
-
return loadBookingsFromSQLite;
|
|
746
|
-
}()
|
|
747
|
-
}, {
|
|
748
|
-
key: "saveBookingsToSQLite",
|
|
749
|
-
value: function () {
|
|
750
|
-
var _saveBookingsToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(bookings) {
|
|
751
|
-
var _this12 = this;
|
|
752
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
753
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
754
|
-
case 0:
|
|
755
|
-
if (this.dbManager) {
|
|
756
|
-
_context9.next = 2;
|
|
757
|
-
break;
|
|
758
|
-
}
|
|
759
|
-
return _context9.abrupt("return");
|
|
760
|
-
case 2:
|
|
761
|
-
_context9.prev = 2;
|
|
762
|
-
_context9.next = 5;
|
|
763
|
-
return this.dbManager.clear(BOOKING_STORE_NAME);
|
|
764
|
-
case 5:
|
|
765
|
-
if (!(bookings.length === 0)) {
|
|
766
|
-
_context9.next = 7;
|
|
767
|
-
break;
|
|
768
|
-
}
|
|
769
|
-
return _context9.abrupt("return");
|
|
770
|
-
case 7:
|
|
771
|
-
if (!this.dbManager.bulkAdd) {
|
|
772
|
-
_context9.next = 11;
|
|
773
|
-
break;
|
|
774
|
-
}
|
|
775
|
-
_context9.next = 10;
|
|
776
|
-
return this.dbManager.bulkAdd(BOOKING_STORE_NAME, bookings);
|
|
777
|
-
case 10:
|
|
778
|
-
return _context9.abrupt("return");
|
|
779
|
-
case 11:
|
|
780
|
-
_context9.next = 13;
|
|
781
|
-
return Promise.all(bookings.map(function (b) {
|
|
782
|
-
return _this12.dbManager.add(BOOKING_STORE_NAME, b);
|
|
783
|
-
}));
|
|
784
|
-
case 13:
|
|
785
|
-
_context9.next = 17;
|
|
786
|
-
break;
|
|
787
|
-
case 15:
|
|
788
|
-
_context9.prev = 15;
|
|
789
|
-
_context9.t0 = _context9["catch"](2);
|
|
790
|
-
case 17:
|
|
791
|
-
case "end":
|
|
792
|
-
return _context9.stop();
|
|
793
|
-
}
|
|
794
|
-
}, _callee9, this, [[2, 15]]);
|
|
795
|
-
}));
|
|
796
|
-
function saveBookingsToSQLite(_x6) {
|
|
797
|
-
return _saveBookingsToSQLite.apply(this, arguments);
|
|
798
|
-
}
|
|
799
|
-
return saveBookingsToSQLite;
|
|
800
|
-
}() // ─────────────────────────────────────────────────────────────────
|
|
694
|
+
}() // private async loadBookingsFromSQLite(): Promise<ResourceBooking[]> {
|
|
695
|
+
// if (!this.dbManager) return []
|
|
696
|
+
// try {
|
|
697
|
+
// const bookings = await this.dbManager.getAll(BOOKING_STORE_NAME)
|
|
698
|
+
// return bookings || []
|
|
699
|
+
// } catch {
|
|
700
|
+
// return []
|
|
701
|
+
// }
|
|
702
|
+
// }
|
|
703
|
+
// private async saveBookingsToSQLite(bookings: ResourceBooking[]): Promise<void> {
|
|
704
|
+
// if (!this.dbManager) return
|
|
705
|
+
// try {
|
|
706
|
+
// await this.dbManager.clear(BOOKING_STORE_NAME)
|
|
707
|
+
// if (bookings.length === 0) return
|
|
708
|
+
// if (this.dbManager.bulkAdd) {
|
|
709
|
+
// await this.dbManager.bulkAdd(BOOKING_STORE_NAME, bookings)
|
|
710
|
+
// return
|
|
711
|
+
// }
|
|
712
|
+
// await Promise.all(bookings.map(b => this.dbManager.add(BOOKING_STORE_NAME, b)))
|
|
713
|
+
// } catch {
|
|
714
|
+
// // 忽略 SQLite 异常
|
|
715
|
+
// }
|
|
716
|
+
// }
|
|
717
|
+
// ─────────────────────────────────────────────────────────────────
|
|
801
718
|
// pubsub 同步
|
|
802
719
|
// ─────────────────────────────────────────────────────────────────
|
|
803
720
|
}, {
|
|
@@ -811,32 +728,32 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
811
728
|
}, {
|
|
812
729
|
key: "setupResourceSync",
|
|
813
730
|
value: function () {
|
|
814
|
-
var _setupResourceSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
815
|
-
var
|
|
731
|
+
var _setupResourceSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
732
|
+
var _this10 = this,
|
|
816
733
|
_result$data;
|
|
817
734
|
var result, _result$data2;
|
|
818
|
-
return _regeneratorRuntime().wrap(function
|
|
819
|
-
while (1) switch (
|
|
735
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
736
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
820
737
|
case 0:
|
|
821
738
|
if (this.resourceDataSource) {
|
|
822
|
-
|
|
739
|
+
_context8.next = 2;
|
|
823
740
|
break;
|
|
824
741
|
}
|
|
825
|
-
return
|
|
742
|
+
return _context8.abrupt("return");
|
|
826
743
|
case 2:
|
|
827
|
-
|
|
744
|
+
_context8.next = 4;
|
|
828
745
|
return this.resourceDataSource.run({
|
|
829
746
|
pubsub: {
|
|
830
747
|
callback: function callback(res) {
|
|
831
748
|
var data = (res === null || res === void 0 ? void 0 : res.data) || res;
|
|
832
749
|
if (!data) return;
|
|
833
750
|
var channelKey = data.module || 'resource';
|
|
834
|
-
|
|
751
|
+
_this10.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
|
|
835
752
|
_channelKey: channelKey
|
|
836
753
|
}));
|
|
837
|
-
if (
|
|
838
|
-
|
|
839
|
-
|
|
754
|
+
if (_this10.syncTimer) clearTimeout(_this10.syncTimer);
|
|
755
|
+
_this10.syncTimer = setTimeout(function () {
|
|
756
|
+
_this10.processSyncMessages();
|
|
840
757
|
}, RESOURCE_SYNC_DEBOUNCE_MS);
|
|
841
758
|
}
|
|
842
759
|
}
|
|
@@ -844,19 +761,19 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
844
761
|
// 忽略同步初始化异常
|
|
845
762
|
});
|
|
846
763
|
case 4:
|
|
847
|
-
result =
|
|
764
|
+
result = _context8.sent;
|
|
848
765
|
console.log('result', result);
|
|
849
766
|
if (!(result !== null && result !== void 0 && (_result$data = result.data) !== null && _result$data !== void 0 && (_result$data = _result$data.list) !== null && _result$data !== void 0 && _result$data.length)) {
|
|
850
|
-
|
|
767
|
+
_context8.next = 9;
|
|
851
768
|
break;
|
|
852
769
|
}
|
|
853
|
-
|
|
770
|
+
_context8.next = 9;
|
|
854
771
|
return this.mergeResourcesToStore(result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.list);
|
|
855
772
|
case 9:
|
|
856
773
|
case "end":
|
|
857
|
-
return
|
|
774
|
+
return _context8.stop();
|
|
858
775
|
}
|
|
859
|
-
},
|
|
776
|
+
}, _callee8, this);
|
|
860
777
|
}));
|
|
861
778
|
function setupResourceSync() {
|
|
862
779
|
return _setupResourceSync.apply(this, arguments);
|
|
@@ -866,53 +783,53 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
866
783
|
}, {
|
|
867
784
|
key: "processSyncMessages",
|
|
868
785
|
value: function () {
|
|
869
|
-
var _processSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
786
|
+
var _processSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
870
787
|
var messages, deleteIds, bodyUpdates, sseRefreshIds, _iterator3, _step3, _msg$ids2, _msg$relation_resourc, msg, _msg$ids, _msg$body$id, bodyId, uniqueDeleteIds, uniqueSSEIds, bodyList, freshResources;
|
|
871
|
-
return _regeneratorRuntime().wrap(function
|
|
872
|
-
while (1) switch (
|
|
788
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
789
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
873
790
|
case 0:
|
|
874
791
|
messages = _toConsumableArray(this.pendingSyncMessages);
|
|
875
792
|
this.pendingSyncMessages = [];
|
|
876
793
|
if (!(messages.length === 0)) {
|
|
877
|
-
|
|
794
|
+
_context9.next = 4;
|
|
878
795
|
break;
|
|
879
796
|
}
|
|
880
|
-
return
|
|
797
|
+
return _context9.abrupt("return");
|
|
881
798
|
case 4:
|
|
882
799
|
deleteIds = [];
|
|
883
800
|
bodyUpdates = new Map();
|
|
884
801
|
sseRefreshIds = [];
|
|
885
802
|
_iterator3 = _createForOfIteratorHelper(messages);
|
|
886
|
-
|
|
803
|
+
_context9.prev = 8;
|
|
887
804
|
_iterator3.s();
|
|
888
805
|
case 10:
|
|
889
806
|
if ((_step3 = _iterator3.n()).done) {
|
|
890
|
-
|
|
807
|
+
_context9.next = 24;
|
|
891
808
|
break;
|
|
892
809
|
}
|
|
893
810
|
msg = _step3.value;
|
|
894
811
|
if (!(msg.operation === 'delete' || msg.action === 'delete')) {
|
|
895
|
-
|
|
812
|
+
_context9.next = 15;
|
|
896
813
|
break;
|
|
897
814
|
}
|
|
898
815
|
if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));else if (msg.id !== undefined) deleteIds.push(msg.id);
|
|
899
|
-
return
|
|
816
|
+
return _context9.abrupt("continue", 22);
|
|
900
817
|
case 15:
|
|
901
818
|
if (!msg.body) {
|
|
902
|
-
|
|
819
|
+
_context9.next = 21;
|
|
903
820
|
break;
|
|
904
821
|
}
|
|
905
822
|
bodyId = (_msg$body$id = msg.body.id) !== null && _msg$body$id !== void 0 ? _msg$body$id : msg.id;
|
|
906
823
|
if (!(bodyId === undefined)) {
|
|
907
|
-
|
|
824
|
+
_context9.next = 19;
|
|
908
825
|
break;
|
|
909
826
|
}
|
|
910
|
-
return
|
|
827
|
+
return _context9.abrupt("continue", 22);
|
|
911
828
|
case 19:
|
|
912
829
|
bodyUpdates.set(this.getIdKey(bodyId), _objectSpread(_objectSpread({}, msg.body), {}, {
|
|
913
830
|
id: bodyId
|
|
914
831
|
}));
|
|
915
|
-
return
|
|
832
|
+
return _context9.abrupt("continue", 22);
|
|
916
833
|
case 21:
|
|
917
834
|
if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
|
|
918
835
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.ids));
|
|
@@ -922,65 +839,65 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
922
839
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_resource_ids));
|
|
923
840
|
}
|
|
924
841
|
case 22:
|
|
925
|
-
|
|
842
|
+
_context9.next = 10;
|
|
926
843
|
break;
|
|
927
844
|
case 24:
|
|
928
|
-
|
|
845
|
+
_context9.next = 29;
|
|
929
846
|
break;
|
|
930
847
|
case 26:
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
_iterator3.e(
|
|
848
|
+
_context9.prev = 26;
|
|
849
|
+
_context9.t0 = _context9["catch"](8);
|
|
850
|
+
_iterator3.e(_context9.t0);
|
|
934
851
|
case 29:
|
|
935
|
-
|
|
852
|
+
_context9.prev = 29;
|
|
936
853
|
_iterator3.f();
|
|
937
|
-
return
|
|
854
|
+
return _context9.finish(29);
|
|
938
855
|
case 32:
|
|
939
856
|
uniqueDeleteIds = this.uniqueResourceIds(deleteIds);
|
|
940
857
|
uniqueSSEIds = this.uniqueResourceIds(sseRefreshIds);
|
|
941
858
|
bodyList = _toConsumableArray(bodyUpdates.values());
|
|
942
859
|
if (!(uniqueDeleteIds.length > 0)) {
|
|
943
|
-
|
|
860
|
+
_context9.next = 38;
|
|
944
861
|
break;
|
|
945
862
|
}
|
|
946
|
-
|
|
863
|
+
_context9.next = 38;
|
|
947
864
|
return this.removeResourcesByIds(uniqueDeleteIds);
|
|
948
865
|
case 38:
|
|
949
866
|
if (!(bodyList.length > 0)) {
|
|
950
|
-
|
|
867
|
+
_context9.next = 41;
|
|
951
868
|
break;
|
|
952
869
|
}
|
|
953
|
-
|
|
870
|
+
_context9.next = 41;
|
|
954
871
|
return this.mergeResourcesToStore(bodyList);
|
|
955
872
|
case 41:
|
|
956
873
|
if (!(uniqueSSEIds.length > 0)) {
|
|
957
|
-
|
|
874
|
+
_context9.next = 48;
|
|
958
875
|
break;
|
|
959
876
|
}
|
|
960
|
-
|
|
877
|
+
_context9.next = 44;
|
|
961
878
|
return this.fetchResourcesBySSE(uniqueSSEIds);
|
|
962
879
|
case 44:
|
|
963
|
-
freshResources =
|
|
880
|
+
freshResources = _context9.sent;
|
|
964
881
|
if (!(freshResources.length > 0)) {
|
|
965
|
-
|
|
882
|
+
_context9.next = 48;
|
|
966
883
|
break;
|
|
967
884
|
}
|
|
968
|
-
|
|
885
|
+
_context9.next = 48;
|
|
969
886
|
return this.mergeResourcesToStore(freshResources);
|
|
970
887
|
case 48:
|
|
971
888
|
if (!(uniqueDeleteIds.length === 0 && bodyList.length === 0 && uniqueSSEIds.length === 0)) {
|
|
972
|
-
|
|
889
|
+
_context9.next = 50;
|
|
973
890
|
break;
|
|
974
891
|
}
|
|
975
|
-
return
|
|
892
|
+
return _context9.abrupt("return");
|
|
976
893
|
case 50:
|
|
977
|
-
|
|
894
|
+
_context9.next = 52;
|
|
978
895
|
return this.core.effects.emit(ResourceHooks.onResourcesSyncCompleted, null);
|
|
979
896
|
case 52:
|
|
980
897
|
case "end":
|
|
981
|
-
return
|
|
898
|
+
return _context9.stop();
|
|
982
899
|
}
|
|
983
|
-
},
|
|
900
|
+
}, _callee9, this, [[8, 26, 29, 32]]);
|
|
984
901
|
}));
|
|
985
902
|
function processSyncMessages() {
|
|
986
903
|
return _processSyncMessages.apply(this, arguments);
|
|
@@ -990,19 +907,19 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
990
907
|
}, {
|
|
991
908
|
key: "fetchResourcesBySSE",
|
|
992
909
|
value: function () {
|
|
993
|
-
var _fetchResourcesBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
910
|
+
var _fetchResourcesBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(ids) {
|
|
994
911
|
var list;
|
|
995
|
-
return _regeneratorRuntime().wrap(function
|
|
996
|
-
while (1) switch (
|
|
912
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
913
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
997
914
|
case 0:
|
|
998
915
|
if (this.resourceDataSource) {
|
|
999
|
-
|
|
916
|
+
_context10.next = 2;
|
|
1000
917
|
break;
|
|
1001
918
|
}
|
|
1002
|
-
return
|
|
919
|
+
return _context10.abrupt("return", []);
|
|
1003
920
|
case 2:
|
|
1004
|
-
|
|
1005
|
-
|
|
921
|
+
_context10.prev = 2;
|
|
922
|
+
_context10.next = 5;
|
|
1006
923
|
return this.resourceDataSource.run({
|
|
1007
924
|
sse: {
|
|
1008
925
|
query: {
|
|
@@ -1012,19 +929,19 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1012
929
|
}
|
|
1013
930
|
});
|
|
1014
931
|
case 5:
|
|
1015
|
-
list =
|
|
1016
|
-
return
|
|
932
|
+
list = _context10.sent;
|
|
933
|
+
return _context10.abrupt("return", list || []);
|
|
1017
934
|
case 9:
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
return
|
|
935
|
+
_context10.prev = 9;
|
|
936
|
+
_context10.t0 = _context10["catch"](2);
|
|
937
|
+
return _context10.abrupt("return", []);
|
|
1021
938
|
case 12:
|
|
1022
939
|
case "end":
|
|
1023
|
-
return
|
|
940
|
+
return _context10.stop();
|
|
1024
941
|
}
|
|
1025
|
-
},
|
|
942
|
+
}, _callee10, this, [[2, 9]]);
|
|
1026
943
|
}));
|
|
1027
|
-
function fetchResourcesBySSE(
|
|
944
|
+
function fetchResourcesBySSE(_x6) {
|
|
1028
945
|
return _fetchResourcesBySSE.apply(this, arguments);
|
|
1029
946
|
}
|
|
1030
947
|
return fetchResourcesBySSE;
|
|
@@ -1032,65 +949,65 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1032
949
|
}, {
|
|
1033
950
|
key: "removeResourcesByIds",
|
|
1034
951
|
value: function () {
|
|
1035
|
-
var _removeResourcesByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1036
|
-
var
|
|
952
|
+
var _removeResourcesByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
|
|
953
|
+
var _this11 = this;
|
|
1037
954
|
var keySet, _iterator4, _step4, id;
|
|
1038
|
-
return _regeneratorRuntime().wrap(function
|
|
1039
|
-
while (1) switch (
|
|
955
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
956
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1040
957
|
case 0:
|
|
1041
958
|
keySet = new Set(ids.map(function (id) {
|
|
1042
|
-
return
|
|
959
|
+
return _this11.getIdKey(id);
|
|
1043
960
|
}));
|
|
1044
961
|
this.store.list = this.store.list.filter(function (r) {
|
|
1045
|
-
return !keySet.has(
|
|
962
|
+
return !keySet.has(_this11.getIdKey(r.id));
|
|
1046
963
|
});
|
|
1047
964
|
this.syncResourcesMap();
|
|
1048
965
|
if (!this.dbManager) {
|
|
1049
|
-
|
|
966
|
+
_context11.next = 26;
|
|
1050
967
|
break;
|
|
1051
968
|
}
|
|
1052
|
-
|
|
969
|
+
_context11.prev = 4;
|
|
1053
970
|
_iterator4 = _createForOfIteratorHelper(ids);
|
|
1054
|
-
|
|
971
|
+
_context11.prev = 6;
|
|
1055
972
|
_iterator4.s();
|
|
1056
973
|
case 8:
|
|
1057
974
|
if ((_step4 = _iterator4.n()).done) {
|
|
1058
|
-
|
|
975
|
+
_context11.next = 14;
|
|
1059
976
|
break;
|
|
1060
977
|
}
|
|
1061
978
|
id = _step4.value;
|
|
1062
|
-
|
|
979
|
+
_context11.next = 12;
|
|
1063
980
|
return this.dbManager.delete(RESOURCE_STORE_NAME, id);
|
|
1064
981
|
case 12:
|
|
1065
|
-
|
|
982
|
+
_context11.next = 8;
|
|
1066
983
|
break;
|
|
1067
984
|
case 14:
|
|
1068
|
-
|
|
985
|
+
_context11.next = 19;
|
|
1069
986
|
break;
|
|
1070
987
|
case 16:
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
_iterator4.e(
|
|
988
|
+
_context11.prev = 16;
|
|
989
|
+
_context11.t0 = _context11["catch"](6);
|
|
990
|
+
_iterator4.e(_context11.t0);
|
|
1074
991
|
case 19:
|
|
1075
|
-
|
|
992
|
+
_context11.prev = 19;
|
|
1076
993
|
_iterator4.f();
|
|
1077
|
-
return
|
|
994
|
+
return _context11.finish(19);
|
|
1078
995
|
case 22:
|
|
1079
|
-
|
|
996
|
+
_context11.next = 26;
|
|
1080
997
|
break;
|
|
1081
998
|
case 24:
|
|
1082
|
-
|
|
1083
|
-
|
|
999
|
+
_context11.prev = 24;
|
|
1000
|
+
_context11.t1 = _context11["catch"](4);
|
|
1084
1001
|
case 26:
|
|
1085
|
-
|
|
1002
|
+
_context11.next = 28;
|
|
1086
1003
|
return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
|
|
1087
1004
|
case 28:
|
|
1088
1005
|
case "end":
|
|
1089
|
-
return
|
|
1006
|
+
return _context11.stop();
|
|
1090
1007
|
}
|
|
1091
|
-
},
|
|
1008
|
+
}, _callee11, this, [[4, 24], [6, 16, 19, 22]]);
|
|
1092
1009
|
}));
|
|
1093
|
-
function removeResourcesByIds(
|
|
1010
|
+
function removeResourcesByIds(_x7) {
|
|
1094
1011
|
return _removeResourcesByIds.apply(this, arguments);
|
|
1095
1012
|
}
|
|
1096
1013
|
return removeResourcesByIds;
|
|
@@ -1098,46 +1015,46 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1098
1015
|
}, {
|
|
1099
1016
|
key: "mergeResourcesToStore",
|
|
1100
1017
|
value: function () {
|
|
1101
|
-
var _mergeResourcesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1102
|
-
var
|
|
1018
|
+
var _mergeResourcesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(freshResources) {
|
|
1019
|
+
var _this12 = this;
|
|
1103
1020
|
var freshMap, _iterator5, _step5, r, updatedList, _iterator6, _step6, _r;
|
|
1104
|
-
return _regeneratorRuntime().wrap(function
|
|
1105
|
-
while (1) switch (
|
|
1021
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1022
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1106
1023
|
case 0:
|
|
1107
1024
|
freshMap = new Map();
|
|
1108
1025
|
_iterator5 = _createForOfIteratorHelper(freshResources);
|
|
1109
|
-
|
|
1026
|
+
_context12.prev = 2;
|
|
1110
1027
|
_iterator5.s();
|
|
1111
1028
|
case 4:
|
|
1112
1029
|
if ((_step5 = _iterator5.n()).done) {
|
|
1113
|
-
|
|
1030
|
+
_context12.next = 11;
|
|
1114
1031
|
break;
|
|
1115
1032
|
}
|
|
1116
1033
|
r = _step5.value;
|
|
1117
1034
|
if (!((r === null || r === void 0 ? void 0 : r.id) === undefined)) {
|
|
1118
|
-
|
|
1035
|
+
_context12.next = 8;
|
|
1119
1036
|
break;
|
|
1120
1037
|
}
|
|
1121
|
-
return
|
|
1038
|
+
return _context12.abrupt("continue", 9);
|
|
1122
1039
|
case 8:
|
|
1123
1040
|
freshMap.set(this.getIdKey(r.id), this.normalizeResource(r));
|
|
1124
1041
|
case 9:
|
|
1125
|
-
|
|
1042
|
+
_context12.next = 4;
|
|
1126
1043
|
break;
|
|
1127
1044
|
case 11:
|
|
1128
|
-
|
|
1045
|
+
_context12.next = 16;
|
|
1129
1046
|
break;
|
|
1130
1047
|
case 13:
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
_iterator5.e(
|
|
1048
|
+
_context12.prev = 13;
|
|
1049
|
+
_context12.t0 = _context12["catch"](2);
|
|
1050
|
+
_iterator5.e(_context12.t0);
|
|
1134
1051
|
case 16:
|
|
1135
|
-
|
|
1052
|
+
_context12.prev = 16;
|
|
1136
1053
|
_iterator5.f();
|
|
1137
|
-
return
|
|
1054
|
+
return _context12.finish(16);
|
|
1138
1055
|
case 19:
|
|
1139
1056
|
updatedList = this.store.list.map(function (r) {
|
|
1140
|
-
var key =
|
|
1057
|
+
var key = _this12.getIdKey(r.id);
|
|
1141
1058
|
if (!freshMap.has(key)) return r;
|
|
1142
1059
|
var fresh = freshMap.get(key);
|
|
1143
1060
|
freshMap.delete(key);
|
|
@@ -1156,18 +1073,18 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1156
1073
|
}
|
|
1157
1074
|
this.store.list = updatedList;
|
|
1158
1075
|
this.syncResourcesMap();
|
|
1159
|
-
|
|
1076
|
+
_context12.next = 26;
|
|
1160
1077
|
return this.saveResourcesToSQLite(this.store.list);
|
|
1161
1078
|
case 26:
|
|
1162
|
-
|
|
1079
|
+
_context12.next = 28;
|
|
1163
1080
|
return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
|
|
1164
1081
|
case 28:
|
|
1165
1082
|
case "end":
|
|
1166
|
-
return
|
|
1083
|
+
return _context12.stop();
|
|
1167
1084
|
}
|
|
1168
|
-
},
|
|
1085
|
+
}, _callee12, this, [[2, 13, 16, 19]]);
|
|
1169
1086
|
}));
|
|
1170
|
-
function mergeResourcesToStore(
|
|
1087
|
+
function mergeResourcesToStore(_x8) {
|
|
1171
1088
|
return _mergeResourcesToStore.apply(this, arguments);
|
|
1172
1089
|
}
|
|
1173
1090
|
return mergeResourcesToStore;
|