@fileverse/api 0.0.9 → 0.0.10

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.
@@ -651,6 +651,29 @@ var init_events_model = __esm({
651
651
  `;
652
652
  await QueryBuilder.execute(sql, [Date.now(), _id]);
653
653
  }
654
+ static async markSubmitted(_id) {
655
+ const sql = `
656
+ UPDATE ${this.TABLE}
657
+ SET status = 'submitted',
658
+ lockedAt = NULL
659
+ WHERE _id = ?
660
+ `;
661
+ await QueryBuilder.execute(sql, [_id]);
662
+ }
663
+ static async findNextSubmitted(lockedFileIds) {
664
+ const exclusionClause = lockedFileIds.length > 0 ? `AND fileId NOT IN (${lockedFileIds.map(() => "?").join(", ")})` : "";
665
+ const sql = `
666
+ SELECT * FROM ${this.TABLE}
667
+ WHERE status = 'submitted'
668
+ AND userOpHash IS NOT NULL
669
+ ${exclusionClause}
670
+ ORDER BY timestamp ASC
671
+ LIMIT 1
672
+ `;
673
+ const params = [...lockedFileIds];
674
+ const row = await QueryBuilder.selectOne(sql, params);
675
+ return row ? this.parseEvent(row) : void 0;
676
+ }
654
677
  static async markProcessed(_id) {
655
678
  const sql = `
656
679
  UPDATE ${this.TABLE}
@@ -956,6 +979,7 @@ var init_publish = __esm({
956
979
  init_smart_agent();
957
980
  init_file_manager();
958
981
  init_config();
982
+ init_pimlico_utils();
959
983
  }
960
984
  });
961
985
 
@@ -1456,7 +1480,7 @@ CREATE TABLE IF NOT EXISTS events (
1456
1480
  type TEXT NOT NULL CHECK (type IN ('create', 'update', 'delete')),
1457
1481
  timestamp BIGINT NOT NULL,
1458
1482
  fileId TEXT NOT NULL,
1459
- status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'processing', 'processed', 'failed')),
1483
+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'processing', 'submitted', 'processed', 'failed')),
1460
1484
  retryCount INTEGER NOT NULL DEFAULT 0,
1461
1485
  lastError TEXT,
1462
1486
  lockedAt BIGINT,