@fileverse/api 0.0.8 → 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.
@@ -96,7 +96,12 @@ var init_config = __esm({
96
96
  init_constants();
97
97
  projectEnvPath = path2.join(process.cwd(), "config", ".env");
98
98
  userEnvPath = path2.join(os.homedir(), ".fileverse", ".env");
99
- loadConfig(false);
99
+ if (typeof globalThis.process !== "undefined" && typeof globalThis.process.cwd === "function") {
100
+ try {
101
+ loadConfig(false);
102
+ } catch {
103
+ }
104
+ }
100
105
  config = {
101
106
  ...STATIC_CONFIG,
102
107
  get SERVICE_NAME() {
@@ -646,6 +651,29 @@ var init_events_model = __esm({
646
651
  `;
647
652
  await QueryBuilder.execute(sql, [Date.now(), _id]);
648
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
+ }
649
677
  static async markProcessed(_id) {
650
678
  const sql = `
651
679
  UPDATE ${this.TABLE}
@@ -951,6 +979,7 @@ var init_publish = __esm({
951
979
  init_smart_agent();
952
980
  init_file_manager();
953
981
  init_config();
982
+ init_pimlico_utils();
954
983
  }
955
984
  });
956
985
 
@@ -1451,7 +1480,7 @@ CREATE TABLE IF NOT EXISTS events (
1451
1480
  type TEXT NOT NULL CHECK (type IN ('create', 'update', 'delete')),
1452
1481
  timestamp BIGINT NOT NULL,
1453
1482
  fileId TEXT NOT NULL,
1454
- 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')),
1455
1484
  retryCount INTEGER NOT NULL DEFAULT 0,
1456
1485
  lastError TEXT,
1457
1486
  lockedAt BIGINT,