@fileverse/api 0.0.4 → 0.0.6

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.
package/dist/worker.js CHANGED
@@ -277,6 +277,58 @@ var init_sql_compat = __esm({
277
277
  }
278
278
  });
279
279
 
280
+ // src/infra/database/adapters/pg-column-map.ts
281
+ function remapRow(row) {
282
+ const out = {};
283
+ for (const key in row) {
284
+ out[COLUMN_MAP[key] ?? key] = row[key];
285
+ }
286
+ return out;
287
+ }
288
+ function remapRows(rows) {
289
+ return rows.map((row) => remapRow(row));
290
+ }
291
+ var COLUMN_MAP;
292
+ var init_pg_column_map = __esm({
293
+ "src/infra/database/adapters/pg-column-map.ts"() {
294
+ "use strict";
295
+ init_esm_shims();
296
+ COLUMN_MAP = {
297
+ ddocid: "ddocId",
298
+ localversion: "localVersion",
299
+ onchainversion: "onchainVersion",
300
+ syncstatus: "syncStatus",
301
+ createdat: "createdAt",
302
+ updatedat: "updatedAt",
303
+ isdeleted: "isDeleted",
304
+ portaladdress: "portalAddress",
305
+ onchainfileid: "onChainFileId",
306
+ commentkey: "commentKey",
307
+ linkkey: "linkKey",
308
+ linkkeynonce: "linkKeyNonce",
309
+ portalseed: "portalSeed",
310
+ owneraddress: "ownerAddress",
311
+ apikeyseed: "apiKeySeed",
312
+ collaboratoraddress: "collaboratorAddress",
313
+ fileid: "fileId",
314
+ retrycount: "retryCount",
315
+ lasterror: "lastError",
316
+ lockedat: "lockedAt",
317
+ nextretryat: "nextRetryAt",
318
+ userophash: "userOpHash",
319
+ pendingpayload: "pendingPayload",
320
+ folderid: "folderId",
321
+ folderref: "folderRef",
322
+ foldername: "folderName",
323
+ metadataipfshash: "metadataIPFSHash",
324
+ contentipfshash: "contentIPFSHash",
325
+ lasttransactionhash: "lastTransactionHash",
326
+ lasttransactionblocknumber: "lastTransactionBlockNumber",
327
+ lasttransactionblocktimestamp: "lastTransactionBlockTimestamp"
328
+ };
329
+ }
330
+ });
331
+
280
332
  // src/infra/database/adapters/postgres-adapter.ts
281
333
  var postgres_adapter_exports = {};
282
334
  __export(postgres_adapter_exports, {
@@ -294,6 +346,7 @@ var init_postgres_adapter = __esm({
294
346
  "use strict";
295
347
  init_esm_shims();
296
348
  init_sql_compat();
349
+ init_pg_column_map();
297
350
  init_infra();
298
351
  pgModule = null;
299
352
  PostgresAdapter = class {
@@ -323,13 +376,13 @@ var init_postgres_adapter = __esm({
323
376
  const pool = await this.getPool();
324
377
  const pgSql = sqliteToPostgres(sql);
325
378
  const result = await pool.query(pgSql, params);
326
- return result.rows;
379
+ return remapRows(result.rows);
327
380
  }
328
381
  async selectOne(sql, params = []) {
329
382
  const pool = await this.getPool();
330
383
  const pgSql = sqliteToPostgres(sql);
331
384
  const result = await pool.query(pgSql, params);
332
- return result.rows[0] ?? void 0;
385
+ return result.rows[0] ? remapRow(result.rows[0]) : void 0;
333
386
  }
334
387
  async execute(sql, params = []) {
335
388
  const pool = await this.getPool();
@@ -3361,13 +3414,13 @@ CREATE TABLE IF NOT EXISTS api_keys (
3361
3414
  CREATE TABLE IF NOT EXISTS events (
3362
3415
  _id TEXT PRIMARY KEY,
3363
3416
  type TEXT NOT NULL CHECK (type IN ('create', 'update', 'delete')),
3364
- timestamp INTEGER NOT NULL,
3417
+ timestamp BIGINT NOT NULL,
3365
3418
  fileId TEXT NOT NULL,
3366
3419
  status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'processing', 'processed', 'failed')),
3367
3420
  retryCount INTEGER NOT NULL DEFAULT 0,
3368
3421
  lastError TEXT,
3369
- lockedAt INTEGER,
3370
- nextRetryAt INTEGER,
3422
+ lockedAt BIGINT,
3423
+ nextRetryAt BIGINT,
3371
3424
  userOpHash TEXT,
3372
3425
  pendingPayload TEXT,
3373
3426
  portalAddress TEXT
@@ -3388,8 +3441,8 @@ CREATE TABLE IF NOT EXISTS folders (
3388
3441
  contentIPFSHash TEXT NOT NULL,
3389
3442
  isDeleted INTEGER NOT NULL DEFAULT 0,
3390
3443
  lastTransactionHash TEXT,
3391
- lastTransactionBlockNumber INTEGER NOT NULL,
3392
- lastTransactionBlockTimestamp INTEGER NOT NULL,
3444
+ lastTransactionBlockNumber BIGINT NOT NULL,
3445
+ lastTransactionBlockTimestamp BIGINT NOT NULL,
3393
3446
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
3394
3447
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
3395
3448
  );