@pol-studios/db 1.0.18 → 1.0.19

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.
Files changed (45) hide show
  1. package/dist/{chunk-ZFM6AGWV.js → chunk-2T6WTCP4.js} +56 -27
  2. package/dist/chunk-2T6WTCP4.js.map +1 -0
  3. package/dist/{chunk-XOPORVJG.js → chunk-R5B2XMN5.js} +6 -8
  4. package/dist/chunk-R5B2XMN5.js.map +1 -0
  5. package/dist/index.js +2 -2
  6. package/dist/index.native.js +2 -2
  7. package/dist/index.web.js +1 -1
  8. package/package.json +1 -1
  9. package/dist/DataLayerContext-ZmLPYR_s.d.ts +0 -825
  10. package/dist/EntityPermissions-DwFt4tUd.d.ts +0 -35
  11. package/dist/FilterConfig-Bt2Ek74z.d.ts +0 -99
  12. package/dist/UserMetadataContext-B8gVWGMl.d.ts +0 -35
  13. package/dist/UserMetadataContext-DntmpK41.d.ts +0 -33
  14. package/dist/auth/context.d.ts +0 -48
  15. package/dist/auth/guards.d.ts +0 -180
  16. package/dist/auth/hooks.d.ts +0 -312
  17. package/dist/auth/index.d.ts +0 -11
  18. package/dist/chunk-XOPORVJG.js.map +0 -1
  19. package/dist/chunk-ZFM6AGWV.js.map +0 -1
  20. package/dist/client/index.d.ts +0 -16
  21. package/dist/core/index.d.ts +0 -539
  22. package/dist/database.types-ChFCG-4M.d.ts +0 -8604
  23. package/dist/executor-CB4KHyYG.d.ts +0 -507
  24. package/dist/gen/index.d.ts +0 -1099
  25. package/dist/hooks/index.d.ts +0 -100
  26. package/dist/index-BNKhgDdC.d.ts +0 -433
  27. package/dist/index.d.ts +0 -33
  28. package/dist/index.native.d.ts +0 -773
  29. package/dist/index.web.d.ts +0 -321
  30. package/dist/mutation/index.d.ts +0 -58
  31. package/dist/parser/index.d.ts +0 -366
  32. package/dist/powersync-bridge/index.d.ts +0 -284
  33. package/dist/query/index.d.ts +0 -723
  34. package/dist/realtime/index.d.ts +0 -44
  35. package/dist/select-query-parser-BwyHum1L.d.ts +0 -352
  36. package/dist/setupAuthContext-Kv-THH-h.d.ts +0 -61
  37. package/dist/types/index.d.ts +0 -10
  38. package/dist/types-CYr9JiUE.d.ts +0 -62
  39. package/dist/useBatchUpsert-9OYjibLh.d.ts +0 -24
  40. package/dist/useDbCount-Id14x_1P.d.ts +0 -1082
  41. package/dist/useDbQuery-C-TL8jY1.d.ts +0 -19
  42. package/dist/useReceiptAI-6HkRpRml.d.ts +0 -58
  43. package/dist/useResolveFeedback-Ca2rh_Bs.d.ts +0 -997
  44. package/dist/useSupabase-DvWVuHHE.d.ts +0 -28
  45. package/dist/with-auth/index.d.ts +0 -704
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  createAdapterAutoDetector,
3
3
  createAdapterRegistry,
4
- createSupabaseAdapter
5
- } from "./chunk-XOPORVJG.js";
4
+ createSupabaseAdapter,
5
+ stripSchemaPrefix
6
+ } from "./chunk-R5B2XMN5.js";
6
7
  import {
7
8
  DataLayerCoreContext,
8
9
  DataLayerStatusContext
@@ -1343,11 +1344,13 @@ var PowerSyncAdapter = class {
1343
1344
  *
1344
1345
  * @param db - PowerSync database instance
1345
1346
  * @param schema - Database schema for relationship resolution
1347
+ * @param tableNameResolver - Optional custom resolver for table names to PowerSync aliases
1346
1348
  */
1347
- constructor(db, schema) {
1349
+ constructor(db, schema, tableNameResolver) {
1348
1350
  this.db = db;
1349
1351
  this.schema = schema;
1350
1352
  this.executor = new QueryExecutor(db, schema);
1353
+ this.tableNameResolver = tableNameResolver;
1351
1354
  }
1352
1355
  /**
1353
1356
  * Unique identifier for this adapter type
@@ -1366,6 +1369,25 @@ var PowerSyncAdapter = class {
1366
1369
  * The underlying query executor
1367
1370
  */
1368
1371
  executor;
1372
+ /**
1373
+ * Optional custom table name resolver.
1374
+ * If not provided, uses default auto-alias generation.
1375
+ */
1376
+ tableNameResolver;
1377
+ /**
1378
+ * Resolve a table name to its PowerSync alias.
1379
+ * Schema-qualified names like "chat.Conversation" become "Conversation" (schema stripped).
1380
+ * Unqualified names pass through unchanged.
1381
+ *
1382
+ * @param table - Original table name (may be schema-qualified)
1383
+ * @returns The PowerSync alias to use in SQLite queries
1384
+ */
1385
+ resolveTableName(table) {
1386
+ if (this.tableNameResolver) {
1387
+ return this.tableNameResolver(table);
1388
+ }
1389
+ return stripSchemaPrefix(table);
1390
+ }
1369
1391
  // ===========================================================================
1370
1392
  // Query Operations
1371
1393
  // ===========================================================================
@@ -1377,10 +1399,11 @@ var PowerSyncAdapter = class {
1377
1399
  * @returns Promise resolving to query results with optional count
1378
1400
  */
1379
1401
  async query(table, options = {}) {
1380
- const rawData = await this.executor.execute(table, options);
1402
+ const resolvedTable = this.resolveTableName(table);
1403
+ const rawData = await this.executor.execute(resolvedTable, options);
1381
1404
  const hasRelations = options.select && options.select.includes("(") && options.select !== "*";
1382
1405
  const data = hasRelations ? rawData.map((row) => transformWithRelations(row, this.schema, table)) : transformResultsFromStorage(rawData, this.schema, table);
1383
- const count = options.limit !== void 0 ? await this.executor.count(table, {
1406
+ const count = options.limit !== void 0 ? await this.executor.count(resolvedTable, {
1384
1407
  where: options.where
1385
1408
  }) : void 0;
1386
1409
  return {
@@ -1397,7 +1420,8 @@ var PowerSyncAdapter = class {
1397
1420
  * @returns Promise resolving to the record or null if not found
1398
1421
  */
1399
1422
  async queryById(table, id, options) {
1400
- const rawResult = await this.executor.executeById(table, id, options);
1423
+ const resolvedTable = this.resolveTableName(table);
1424
+ const rawResult = await this.executor.executeById(resolvedTable, id, options);
1401
1425
  if (!rawResult) {
1402
1426
  return null;
1403
1427
  }
@@ -1417,6 +1441,7 @@ var PowerSyncAdapter = class {
1417
1441
  * @returns Unsubscribe function
1418
1442
  */
1419
1443
  subscribe(table, options, callback) {
1444
+ const resolvedTable = this.resolveTableName(table);
1420
1445
  if (!this.db.watch) {
1421
1446
  return this.subscribeWithPolling(table, options, callback);
1422
1447
  }
@@ -1425,17 +1450,17 @@ var PowerSyncAdapter = class {
1425
1450
  const {
1426
1451
  sql,
1427
1452
  params
1428
- } = builder.build(table, "*", {
1453
+ } = builder.build(resolvedTable, "*", {
1429
1454
  where: options.where,
1430
1455
  orderBy: options.orderBy,
1431
1456
  limit: options.limit,
1432
1457
  offset: options.offset
1433
1458
  });
1434
- let watchTables = [table];
1459
+ let watchTables = [resolvedTable];
1435
1460
  if (options.select && options.select !== "*") {
1436
1461
  const parsed = parseSelect(options.select);
1437
1462
  const relationNames = extractRelationNames(parsed);
1438
- watchTables = [table, ...relationNames];
1463
+ watchTables = [resolvedTable, ...relationNames.map((r) => this.resolveTableName(r))];
1439
1464
  }
1440
1465
  const schema = this.schema;
1441
1466
  this.db.watch(sql, params, {
@@ -1445,7 +1470,7 @@ var PowerSyncAdapter = class {
1445
1470
  callback(data);
1446
1471
  },
1447
1472
  onError: (error) => {
1448
- console.error(`PowerSync subscription error for ${table}:`, error);
1473
+ console.error(`PowerSync subscription error for ${resolvedTable}:`, error);
1449
1474
  }
1450
1475
  }, {
1451
1476
  signal: abortController.signal,
@@ -1493,17 +1518,18 @@ var PowerSyncAdapter = class {
1493
1518
  * @returns Promise resolving to the inserted record
1494
1519
  */
1495
1520
  async insert(table, data) {
1496
- if (__DEV__) {
1521
+ const resolvedTable = this.resolveTableName(table);
1522
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1497
1523
  console.log(`[PowerSyncAdapter] insert called:`, {
1498
- table,
1524
+ table: resolvedTable,
1499
1525
  dataKeys: Object.keys(data),
1500
1526
  hasId: "id" in data
1501
1527
  });
1502
1528
  }
1503
- const result = await this.executor.insert(table, data);
1504
- if (__DEV__) {
1529
+ const result = await this.executor.insert(resolvedTable, data);
1530
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1505
1531
  console.log(`[PowerSyncAdapter] insert completed:`, {
1506
- table,
1532
+ table: resolvedTable,
1507
1533
  resultId: result?.id ?? "unknown"
1508
1534
  });
1509
1535
  }
@@ -1518,17 +1544,18 @@ var PowerSyncAdapter = class {
1518
1544
  * @returns Promise resolving to the updated record
1519
1545
  */
1520
1546
  async update(table, id, data) {
1521
- if (__DEV__) {
1547
+ const resolvedTable = this.resolveTableName(table);
1548
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1522
1549
  console.log(`[PowerSyncAdapter] update called:`, {
1523
- table,
1550
+ table: resolvedTable,
1524
1551
  id,
1525
1552
  dataKeys: Object.keys(data)
1526
1553
  });
1527
1554
  }
1528
- const result = await this.executor.update(table, id, data);
1529
- if (__DEV__) {
1555
+ const result = await this.executor.update(resolvedTable, id, data);
1556
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1530
1557
  console.log(`[PowerSyncAdapter] update completed:`, {
1531
- table,
1558
+ table: resolvedTable,
1532
1559
  id,
1533
1560
  resultId: result?.id ?? "unknown"
1534
1561
  });
@@ -1545,18 +1572,19 @@ var PowerSyncAdapter = class {
1545
1572
  * @returns Promise resolving to the upserted record
1546
1573
  */
1547
1574
  async upsert(table, data) {
1548
- if (__DEV__) {
1575
+ const resolvedTable = this.resolveTableName(table);
1576
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1549
1577
  console.log(`[PowerSyncAdapter] upsert called:`, {
1550
- table,
1578
+ table: resolvedTable,
1551
1579
  dataKeys: Object.keys(data),
1552
1580
  hasId: "id" in data,
1553
1581
  idValue: data?.id ?? "none"
1554
1582
  });
1555
1583
  }
1556
- const result = await this.executor.upsert(table, data);
1557
- if (__DEV__) {
1584
+ const result = await this.executor.upsert(resolvedTable, data);
1585
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1558
1586
  console.log(`[PowerSyncAdapter] upsert completed:`, {
1559
- table,
1587
+ table: resolvedTable,
1560
1588
  resultId: result?.id ?? "unknown"
1561
1589
  });
1562
1590
  }
@@ -1570,7 +1598,8 @@ var PowerSyncAdapter = class {
1570
1598
  * @returns Promise that resolves when deletion is complete
1571
1599
  */
1572
1600
  async delete(table, id) {
1573
- await this.executor.delete(table, id);
1601
+ const resolvedTable = this.resolveTableName(table);
1602
+ await this.executor.delete(resolvedTable, id);
1574
1603
  }
1575
1604
  // ===========================================================================
1576
1605
  // Advanced Access Methods
@@ -5234,4 +5263,4 @@ object-assign/index.js:
5234
5263
  @license MIT
5235
5264
  *)
5236
5265
  */
5237
- //# sourceMappingURL=chunk-ZFM6AGWV.js.map
5266
+ //# sourceMappingURL=chunk-2T6WTCP4.js.map