document-drive 1.0.0-alpha.43 → 1.0.0-alpha.45

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/server/index.ts +16 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-drive",
3
- "version": "1.0.0-alpha.43",
3
+ "version": "1.0.0-alpha.45",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "module": "./src/index.ts",
@@ -32,8 +32,8 @@
32
32
  "test:watch": "vitest watch"
33
33
  },
34
34
  "peerDependencies": {
35
- "document-model": "^1.0.45",
36
- "document-model-libs": "^1.34.0"
35
+ "document-model": "^1.0.52",
36
+ "document-model-libs": "^1.36.0"
37
37
  },
38
38
  "optionalDependencies": {
39
39
  "@prisma/client": "5.11.0",
@@ -60,8 +60,8 @@
60
60
  "@typescript-eslint/eslint-plugin": "^6.21.0",
61
61
  "@typescript-eslint/parser": "^6.21.0",
62
62
  "@vitest/coverage-v8": "^1.4.0",
63
- "document-model": "^1.0.45",
64
- "document-model-libs": "^1.34.0",
63
+ "document-model": "^1.0.52",
64
+ "document-model-libs": "^1.36.0",
65
65
  "eslint": "^8.57.0",
66
66
  "eslint-config-prettier": "^9.1.0",
67
67
  "fake-indexeddb": "^5.0.2",
@@ -219,9 +219,16 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
219
219
  }
220
220
 
221
221
  async initialize() {
222
+ const errors: Error[] = [];
222
223
  const drives = await this.getDrives();
223
224
  for (const drive of drives) {
224
- await this._initializeDrive(drive);
225
+ await this._initializeDrive(drive).catch(error => {
226
+ logger.error(
227
+ `Error initializing drive ${drive}`,
228
+ error
229
+ );
230
+ errors.push(error as Error);
231
+ });
225
232
  }
226
233
 
227
234
  // if network connect comes online then
@@ -238,6 +245,8 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
238
245
 
239
246
  });
240
247
  }
248
+
249
+ return errors.length === 0 ? null : errors;
241
250
  }
242
251
 
243
252
  private async _initializeDrive(driveId: string) {
@@ -855,6 +864,10 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
855
864
  };
856
865
  });
857
866
 
867
+ if (document) {
868
+ this.cache.setDocument(drive, id, document).catch(logger.error);
869
+ }
870
+
858
871
  // gets all the different scopes and branches combinations from the operations
859
872
  const { scopes, branches } = [
860
873
  ...operationsApplied,
@@ -903,12 +916,6 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
903
916
  throw error;
904
917
  }
905
918
 
906
- if (document) {
907
- this.cache.setDocument(drive, id, document).catch(logger.error);
908
- } else {
909
- logger.warn("Successfully applied operations but no document returned");
910
- }
911
-
912
919
  return {
913
920
  status: 'SUCCESS',
914
921
  document,
@@ -1013,6 +1020,8 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
1013
1020
  throw error ?? new Error('Invalid Document Drive document');
1014
1021
  }
1015
1022
 
1023
+ this.cache.setDocument("drives", drive, document).catch(logger.error);
1024
+
1016
1025
  for (const operation of operationsApplied) {
1017
1026
  switch (operation.type) {
1018
1027
  case 'ADD_LISTENER': {
@@ -1077,12 +1086,6 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
1077
1086
  throw error;
1078
1087
  }
1079
1088
 
1080
- if (document) {
1081
- this.cache.setDocument("drives", drive, document).catch(logger.error);;
1082
- } else {
1083
- logger.warn("Successfully applied operations but no drive returned");
1084
- }
1085
-
1086
1089
  return {
1087
1090
  status: 'SUCCESS',
1088
1091
  document,