UNPKG

@ic-wallet-kit/hpl

Version:
89 lines (88 loc) 4.9 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.HplReplicationManager = void 0; const storage_1 = require("../storage"); const common_1 = require("@ic-wallet-kit/common"); require("reflect-metadata"); const typedi_1 = require("typedi"); const hplRxSyncStateService_1 = require("./hplRxSyncStateService"); let HplReplicationManager = class HplReplicationManager { hplAccountDataStorage; hplAssetDataStorage; hplVirtualAccountDataStorage; hplContactDataStorage; replicationProcessor; constructor(logger, replicationConfiguration, identifierService, hplRxSyncStateService, hplDbContext, createCanisterFunc, hplAccountDataStorage, hplAssetDataStorage, hplVirtualAccountDataStorage, hplContactDataStorage) { this.hplAccountDataStorage = hplAccountDataStorage; this.hplAssetDataStorage = hplAssetDataStorage; this.hplVirtualAccountDataStorage = hplVirtualAccountDataStorage; this.hplContactDataStorage = hplContactDataStorage; this.replicationProcessor = new common_1.ReplicationProcessor(logger, replicationConfiguration, identifierService, hplRxSyncStateService, hplDbContext, createCanisterFunc); } async init() { const replicationCollectionList = []; replicationCollectionList.push({ collectionName: this.hplAssetDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullHplAssets(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushHplAssets(items); } }); replicationCollectionList.push({ collectionName: this.hplAccountDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullHplAccounts(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushHplAccounts(items); } }); replicationCollectionList.push({ collectionName: this.hplVirtualAccountDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullHplVirtualAccounts(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushHplVirtualAccounts(items); } }); replicationCollectionList.push({ collectionName: this.hplContactDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullHplContacts(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushHplContacts(items); } }); await this.replicationProcessor.initReplication(replicationCollectionList); } }; exports.HplReplicationManager = HplReplicationManager; exports.HplReplicationManager = HplReplicationManager = __decorate([ (0, typedi_1.Service)(), __param(0, (0, typedi_1.Inject)("ILogger")), __param(1, (0, typedi_1.Inject)("HplReplicationConfiguration")), __param(5, (0, typedi_1.Inject)("createHplCanisterFunc")), __param(6, (0, typedi_1.Inject)("IHplAccountDataStorage")), __param(7, (0, typedi_1.Inject)("IHplAssetDataStorage")), __param(8, (0, typedi_1.Inject)("IHplVirtualAccountDataStorage")), __param(9, (0, typedi_1.Inject)("IHplContactDataStorage")), __metadata("design:paramtypes", [Object, Object, common_1.IdentifierService, hplRxSyncStateService_1.HplRxSyncStateService, storage_1.HplDbContext, Function, Object, Object, Object, Object]) ], HplReplicationManager);