@fileverse/api 0.0.19 → 0.0.20

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.
@@ -3038,44 +3038,38 @@ var init_eventProcessor = __esm({
3038
3038
  if (!file2) throw new Error(`File ${fileId} not found`);
3039
3039
  if (file2.isDeleted === 1) {
3040
3040
  logger.info(`File ${fileId} is deleted, skipping create submit`);
3041
- return;
3041
+ return null;
3042
3042
  }
3043
3043
  console.log("Submitting new file op");
3044
3044
  const result = await handleNewFileOp(fileId);
3045
3045
  console.log("New file op submitted");
3046
- await EventsModel.setEventPendingOp(event._id, result.userOpHash, {
3047
- metadata: result.metadata
3048
- });
3049
3046
  logger.info(`File ${file2.ddocId} create op submitted (hash: ${result.userOpHash})`);
3050
- break;
3047
+ return { userOpHash: result.userOpHash, pendingPayload: { metadata: result.metadata } };
3051
3048
  }
3052
3049
  case "update": {
3053
3050
  const file2 = await FilesModel.findByIdExcludingDeleted(fileId);
3054
- if (!file2) return;
3055
- if (file2.localVersion <= file2.onchainVersion) return;
3051
+ if (!file2) return null;
3052
+ if (file2.localVersion <= file2.onchainVersion) return null;
3056
3053
  const result = await submitUpdateFileOp(fileId);
3057
- await EventsModel.setEventPendingOp(event._id, result.userOpHash, {
3058
- metadata: result.metadata,
3059
- localVersion: file2.localVersion
3060
- });
3061
3054
  logger.info(`File ${file2.ddocId} update op submitted (hash: ${result.userOpHash})`);
3062
- break;
3055
+ return {
3056
+ userOpHash: result.userOpHash,
3057
+ pendingPayload: { metadata: result.metadata, localVersion: file2.localVersion }
3058
+ };
3063
3059
  }
3064
3060
  case "delete": {
3065
3061
  const file2 = await FilesModel.findByIdIncludingDeleted(fileId);
3066
- if (!file2) return;
3062
+ if (!file2) return null;
3067
3063
  if (file2.isDeleted === 1 && file2.syncStatus === "synced") {
3068
3064
  logger.info(`File ${fileId} deletion already synced, skipping`);
3069
- return;
3065
+ return null;
3070
3066
  }
3071
3067
  if (file2.onChainFileId === null || file2.onChainFileId === void 0) {
3072
- await FilesModel.update(fileId, { syncStatus: "synced", isDeleted: 1 }, file2.portalAddress);
3073
- return;
3068
+ return { noOp: true, fileId, portalAddress: file2.portalAddress };
3074
3069
  }
3075
3070
  const result = await submitDeleteFileOp(fileId);
3076
- await EventsModel.setEventPendingOp(event._id, result.userOpHash, {});
3077
3071
  logger.info(`File ${file2.ddocId} delete op submitted (hash: ${result.userOpHash})`);
3078
- break;
3072
+ return { userOpHash: result.userOpHash, pendingPayload: {} };
3079
3073
  }
3080
3074
  default:
3081
3075
  throw new Error(`Unknown event type: ${type}`);