@lifeready/core 1.1.8 → 1.1.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.
@@ -6204,6 +6204,9 @@
6204
6204
  this.assemblyController = assemblyController;
6205
6205
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6206
6206
  this.hubSubject = new rxjs.ReplaySubject(1);
6207
+ // Could use rxjs observables here. But trying to have kc-client use as little angular
6208
+ // features as possible. Rxjs is not used anywhere else in kc-client.
6209
+ this.logoutListeners = new Set();
6207
6210
  }
6208
6211
  LifeReadyAuthService.prototype.initialise = function () {
6209
6212
  return __awaiter(this, void 0, void 0, function () {
@@ -6214,6 +6217,12 @@
6214
6217
  });
6215
6218
  });
6216
6219
  };
6220
+ LifeReadyAuthService.prototype.addLogoutListener = function (callback) {
6221
+ this.logoutListeners.add(callback);
6222
+ };
6223
+ LifeReadyAuthService.prototype.removeLogoutListener = function (callback) {
6224
+ this.logoutListeners.delete(callback);
6225
+ };
6217
6226
  LifeReadyAuthService.prototype.loginIdpImpl = function (emailOrPhone, password, passIdpParams, recoveryStatus) {
6218
6227
  return __awaiter(this, void 0, void 0, function () {
6219
6228
  var passIdpResult, user;
@@ -6595,12 +6604,17 @@
6595
6604
  return __awaiter(this, void 0, void 0, function () {
6596
6605
  return __generator(this, function (_b) {
6597
6606
  switch (_b.label) {
6598
- case 0:
6607
+ case 0:
6608
+ // Notify all listeners to clean up.
6609
+ return [4 /*yield*/, Promise.all(__spread(this.logoutListeners).map(function (callback) { return callback(); }))];
6610
+ case 1:
6611
+ // Notify all listeners to clean up.
6612
+ _b.sent();
6599
6613
  this.currentUser = null;
6600
6614
  this.keyService.purgeKeys();
6601
6615
  this.keyGraphService.purgeKeys();
6602
6616
  return [4 /*yield*/, Promise.all([this.auth.signOut(), this.profileService.signOut()])];
6603
- case 1:
6617
+ case 2:
6604
6618
  _b.sent();
6605
6619
  return [2 /*return*/];
6606
6620
  }
@@ -7938,7 +7952,7 @@
7938
7952
  var CreateDirectoryMutation = gqlTyped(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"], ["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"])));
7939
7953
  var UpdateDirectoryMutation = gqlTyped(templateObject_2$d || (templateObject_2$d = __makeTemplateObject(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"], ["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"])));
7940
7954
  var DeleteDirectoryMutation = gqlTyped(templateObject_3$b || (templateObject_3$b = __makeTemplateObject(["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"])));
7941
- var CreateFileMutation$1 = gqlTyped(templateObject_4$8 || (templateObject_4$8 = __makeTemplateObject(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"])));
7955
+ var CreateFileMutation$1 = gqlTyped(templateObject_4$8 || (templateObject_4$8 = __makeTemplateObject(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"], ["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"])));
7942
7956
  var UpdateFileMutation = gqlTyped(templateObject_5$7 || (templateObject_5$7 = __makeTemplateObject(["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"])));
7943
7957
  var RevertFileMutation = gqlTyped(templateObject_6$6 || (templateObject_6$6 = __makeTemplateObject(["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"])));
7944
7958
  var DeleteFileMutation$1 = gqlTyped(templateObject_7$5 || (templateObject_7$5 = __makeTemplateObject(["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"])));
@@ -7960,7 +7974,7 @@
7960
7974
  var Item2Service_1;
7961
7975
  exports.Item2Service = Item2Service_1 = /** @class */ (function (_super) {
7962
7976
  __extends(Item2Service, _super);
7963
- function Item2Service(ngZone, injector, fileUploadService, keyService, keyFactory, keyGraph, lockService) {
7977
+ function Item2Service(ngZone, injector, fileUploadService, keyService, keyFactory, keyGraph, lockService, authService) {
7964
7978
  var _this = _super.call(this, injector) || this;
7965
7979
  _this.ngZone = ngZone;
7966
7980
  _this.injector = injector;
@@ -7969,6 +7983,10 @@
7969
7983
  _this.keyFactory = keyFactory;
7970
7984
  _this.keyGraph = keyGraph;
7971
7985
  _this.lockService = lockService;
7986
+ _this.authService = authService;
7987
+ // Caching the temp directory.
7988
+ _this.tempDirectory = null;
7989
+ _this.authService.addLogoutListener(function () { return _this.onLogout(); });
7972
7990
  return _this;
7973
7991
  }
7974
7992
  Item2Service.prototype.downloadFileContent = function (options) {
@@ -8310,12 +8328,16 @@
8310
8328
  var existing, createDirectory, updateLock, _c, createDirectoryResult, _d, id, keyId, _e, id, keyId;
8311
8329
  return __generator(this, function (_f) {
8312
8330
  switch (_f.label) {
8313
- case 0: return [4 /*yield*/, this.query({
8314
- query: TempDirectoryQuery,
8315
- variables: {
8316
- plainMeta: Item2Service_1.TEMP_DIRECTORY_PLAIN_META_FILTER,
8317
- },
8318
- })];
8331
+ case 0:
8332
+ if (this.tempDirectory) {
8333
+ return [2 /*return*/, this.tempDirectory];
8334
+ }
8335
+ return [4 /*yield*/, this.query({
8336
+ query: TempDirectoryQuery,
8337
+ variables: {
8338
+ plainMeta: Item2Service_1.TEMP_DIRECTORY_PLAIN_META_FILTER,
8339
+ },
8340
+ })];
8319
8341
  case 1:
8320
8342
  existing = _f.sent();
8321
8343
  if (existing.rootDirectories.edges.length > 1) {
@@ -8338,16 +8360,19 @@
8338
8360
  case 3:
8339
8361
  _c = __read.apply(void 0, [_f.sent(), 1]), createDirectoryResult = _c[0];
8340
8362
  _d = createDirectoryResult.createDirectory.directory, id = _d.id, keyId = _d.keyId;
8341
- return [2 /*return*/, {
8342
- id: id,
8343
- keyId: keyId,
8344
- }];
8363
+ this.tempDirectory = {
8364
+ id: id,
8365
+ keyId: keyId,
8366
+ };
8367
+ return [3 /*break*/, 5];
8345
8368
  case 4:
8346
8369
  _e = existing.rootDirectories.edges[0].node, id = _e.id, keyId = _e.keyId;
8347
- return [2 /*return*/, {
8348
- id: id,
8349
- keyId: keyId,
8350
- }];
8370
+ this.tempDirectory = {
8371
+ id: id,
8372
+ keyId: keyId,
8373
+ };
8374
+ _f.label = 5;
8375
+ case 5: return [2 /*return*/, this.tempDirectory];
8351
8376
  }
8352
8377
  });
8353
8378
  });
@@ -8366,7 +8391,7 @@
8366
8391
  */
8367
8392
  Item2Service.prototype.createDirectoryTreeMutation = function (options) {
8368
8393
  return __awaiter(this, void 0, void 0, function () {
8369
- var tempDir, dirId;
8394
+ var tempDir, directory;
8370
8395
  return __generator(this, function (_c) {
8371
8396
  switch (_c.label) {
8372
8397
  case 0: return [4 /*yield*/, this.ensureTempDirectory()];
@@ -8391,9 +8416,12 @@
8391
8416
  plainMetaJson: options.plainMetaJson,
8392
8417
  })];
8393
8418
  case 3:
8394
- dirId = (_c.sent()).createDirectory.directory.id;
8419
+ directory = (_c.sent()).createDirectory.directory;
8395
8420
  // Create the contents
8396
- return [4 /*yield*/, options.createContent(dirId)];
8421
+ return [4 /*yield*/, options.createContent({
8422
+ id: directory.id,
8423
+ keyId: directory.keyId,
8424
+ })];
8397
8425
  case 4:
8398
8426
  // Create the contents
8399
8427
  _c.sent();
@@ -8401,7 +8429,8 @@
8401
8429
  // TODO return the server time where delete is scheduled. Expirable mutation
8402
8430
  // Return the mutation that moves the directory into the dst directories
8403
8431
  return [2 /*return*/, this.changeDirectoryParentsMutation({
8404
- directoryId: dirId,
8432
+ directoryId: directory.id,
8433
+ directoryKeyId: directory.keyId,
8405
8434
  parentsToRemove: [tempDir.id],
8406
8435
  parentsToAdd: options.parentDirectories,
8407
8436
  })];
@@ -8540,15 +8569,23 @@
8540
8569
  };
8541
8570
  Item2Service.prototype.prepareChangeItemParents = function (options, itemKey) {
8542
8571
  return __awaiter(this, void 0, void 0, function () {
8543
- var parentsToAdd;
8572
+ var parentsToAdd, _c;
8544
8573
  var _this = this;
8545
- return __generator(this, function (_c) {
8546
- switch (_c.label) {
8547
- case 0: return [4 /*yield*/, Promise.all(options.parentsToAdd.map(function (t) { return _this.prepareParentDirectory(t, itemKey); }))];
8574
+ return __generator(this, function (_d) {
8575
+ switch (_d.label) {
8576
+ case 0:
8577
+ if (!options.parentsToAdd) return [3 /*break*/, 2];
8578
+ return [4 /*yield*/, Promise.all(options.parentsToAdd.map(function (t) { return _this.prepareParentDirectory(t, itemKey); }))];
8548
8579
  case 1:
8549
- parentsToAdd = _c.sent();
8580
+ _c = _d.sent();
8581
+ return [3 /*break*/, 3];
8582
+ case 2:
8583
+ _c = [];
8584
+ _d.label = 3;
8585
+ case 3:
8586
+ parentsToAdd = _c;
8550
8587
  return [2 /*return*/, {
8551
- directoriesToRemove: options.parentsToRemove,
8588
+ directoriesToRemove: options.parentsToRemove || [],
8552
8589
  directoriesToAdd: parentsToAdd,
8553
8590
  }];
8554
8591
  }
@@ -8713,6 +8750,10 @@
8713
8750
  });
8714
8751
  });
8715
8752
  };
8753
+ Item2Service.prototype.onLogout = function () {
8754
+ // Clear all cached data.
8755
+ this.tempDirectory = null;
8756
+ };
8716
8757
  return Item2Service;
8717
8758
  }(LrService));
8718
8759
  exports.Item2Service.TEMP_DIRECTORY_PLAIN_META = { kcType: 'temp' };
@@ -8723,7 +8764,7 @@
8723
8764
  },
8724
8765
  ],
8725
8766
  });
8726
- exports.Item2Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function Item2Service_Factory() { return new exports.Item2Service(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(FileUploadService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(exports.LockService)); }, token: exports.Item2Service, providedIn: "root" });
8767
+ exports.Item2Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function Item2Service_Factory() { return new exports.Item2Service(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(FileUploadService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(exports.LockService), i0.ɵɵinject(LifeReadyAuthService)); }, token: exports.Item2Service, providedIn: "root" });
8727
8768
  exports.Item2Service.decorators = [
8728
8769
  { type: i0.Injectable, args: [{
8729
8770
  providedIn: 'root',
@@ -8736,7 +8777,8 @@
8736
8777
  { type: KeyService },
8737
8778
  { type: KeyFactoryService },
8738
8779
  { type: KeyGraphService },
8739
- { type: exports.LockService }
8780
+ { type: exports.LockService },
8781
+ { type: LifeReadyAuthService }
8740
8782
  ]; };
8741
8783
  exports.Item2Service = Item2Service_1 = __decorate([
8742
8784
  RunOutsideAngular({