diff --git a/api/package.json b/api/package.json index 7fc9f1d4..9f46b97a 100644 --- a/api/package.json +++ b/api/package.json @@ -21,8 +21,8 @@ "body-parser": "^1.20.2", "cookie-parser": "^1.4.6", "cors": "^2.8.5", - "document-drive": "0.0.28", - "document-model": "1.0.29", + "document-drive": "^0.0.29", + "document-model": "^1.0.29", "document-model-libs": "1.1.43", "dotenv": "^16.0.3", "ethers": "^5.7.2", diff --git a/api/src/modules/document-drive/drive-resolver.ts b/api/src/modules/document-drive/drive-resolver.ts index 7cd182aa..ff1b265a 100644 --- a/api/src/modules/document-drive/drive-resolver.ts +++ b/api/src/modules/document-drive/drive-resolver.ts @@ -14,6 +14,9 @@ import { } from 'document-drive'; import { OperationScope } from 'document-model/document'; import stringify from 'json-stringify-deterministic'; +import { getChildLogger } from '../../logger'; + +const logger = getChildLogger({ msgPrefix: 'Drive' }); export const Node = objectType({ name: 'Node', @@ -199,7 +202,7 @@ export const syncType = objectType({ })), })); } catch (e) { - console.error(e) + logger.error(e); throw new Error('Failed to fetch strands'); } }, @@ -290,13 +293,16 @@ export const pushUpdates = mutationField('pushUpdates', { s.documentId ?? undefined, ); + if (result.status !== "SUCCESS") logger.error(result.error); + + const revision = result.document.operations[s.scope].slice().pop()?.index ?? -1; return { + revision, branch: s.branch, documentId: s.documentId ?? '', driveId: s.driveId, - revision: result.operations.pop()?.index ?? -1, scope: s.scope as OperationScope, - status: (result.success ? "SUCCESS" : "ERROR") as IUpdateStatus, + status: result.status, }; })); @@ -332,6 +338,7 @@ export const acknowledge = mutationField('acknowledge', { return result; } catch (e) { + logger.error(e) return false; } },