@rebasepro/server-postgres 0.13.0 → 0.13.1-canary.g599dae0

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.
@@ -226,13 +226,6 @@ export declare class FetchService {
226
226
  * Note: Primary path now uses inline `getQueryBuilder()` checks.
227
227
  */
228
228
  private hasDrizzleQueryAPI;
229
- /**
230
- * Attempt to use Drizzle's relational query API (db.query.<table>.findMany)
231
- * for efficient JOIN-based relation loading.
232
- * Returns null if the API is not available or the query fails.
233
- * Note: Primary path now uses `buildWithConfig` + `buildDrizzleQueryOptions`.
234
- */
235
- private fetchWithDrizzleQuery;
236
229
  /**
237
230
  * Fallback path used when db.query is unavailable.
238
231
  * The primary path uses db.query.findMany with `with` config, which
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/server-postgres",
3
3
  "type": "module",
4
- "version": "0.13.0",
4
+ "version": "0.13.1-canary.g599dae0",
5
5
  "description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -47,11 +47,11 @@
47
47
  "execa": "^9.6.1",
48
48
  "pg": "^8.22.0",
49
49
  "ws": "^8.21.1",
50
- "@rebasepro/codegen": "0.13.0",
51
- "@rebasepro/common": "0.13.0",
52
- "@rebasepro/types": "0.13.0",
53
- "@rebasepro/server": "0.13.0",
54
- "@rebasepro/utils": "0.13.0"
50
+ "@rebasepro/codegen": "0.13.1-canary.g599dae0",
51
+ "@rebasepro/types": "0.13.1-canary.g599dae0",
52
+ "@rebasepro/utils": "0.13.1-canary.g599dae0",
53
+ "@rebasepro/server": "0.13.1-canary.g599dae0",
54
+ "@rebasepro/common": "0.13.1-canary.g599dae0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@hono/node-server": "^2.0.12",
@@ -1454,99 +1454,6 @@ _distance: vectorMeta.distanceSelect }).from(table).$dynamic()
1454
1454
  return !!this.getQueryBuilder(tableName);
1455
1455
  }
1456
1456
 
1457
- /**
1458
- * Attempt to use Drizzle's relational query API (db.query.<table>.findMany)
1459
- * for efficient JOIN-based relation loading.
1460
- * Returns null if the API is not available or the query fails.
1461
- * Note: Primary path now uses `buildWithConfig` + `buildDrizzleQueryOptions`.
1462
- */
1463
- private async fetchWithDrizzleQuery<M extends Record<string, unknown>>(
1464
- collectionPath: string,
1465
- collection: CollectionConfig,
1466
- options: {
1467
- filter?: FilterValues<Extract<keyof M, string>>;
1468
- orderBy?: string;
1469
- order?: "desc" | "asc";
1470
- limit?: number;
1471
- },
1472
- include: string[],
1473
- idInfo: { fieldName: string; type: "string" | "number" },
1474
- idInfoArray?: { fieldName: string; type: "string" | "number" }[]
1475
- ): Promise<Record<string, unknown>[] | null> {
1476
- try {
1477
-
1478
- const table = getTableForCollection(collection, this.registry);
1479
- const tableName = getTableName(table);
1480
- const queryTarget = this.getQueryBuilder(tableName);
1481
-
1482
- if (!queryTarget?.findMany) return null;
1483
-
1484
- // Build the `with` config from include array
1485
- const resolvedRelations = resolveCollectionRelations(collection);
1486
- const withConfig: Record<string, boolean> = {};
1487
- for (const [key, relation] of Object.entries(resolvedRelations)) {
1488
- if (include[0] === "*" || include.includes(key)) {
1489
- // Use the Drizzle relation name (from the schema)
1490
- const drizzleRelName = relation.relationName || key;
1491
- withConfig[drizzleRelName] = true;
1492
- }
1493
- }
1494
-
1495
- // Build query options
1496
- const queryOpts: Record<string, unknown> = { with: withConfig };
1497
- if (options.limit) queryOpts.limit = options.limit;
1498
-
1499
- // Build where clause
1500
- if (options.filter) {
1501
- const filterConditions = this.buildFilterConditions(
1502
- options.filter, table, collectionPath
1503
- );
1504
- if (filterConditions.length > 0) {
1505
- queryOpts.where = and(...filterConditions);
1506
- }
1507
- }
1508
-
1509
- // Build orderBy
1510
- if (options.orderBy) {
1511
- const orderByField = this.resolveOrderByField(table, options.orderBy, collection);
1512
- if (orderByField) {
1513
- queryOpts.orderBy = options.order === "asc" ? asc(orderByField) : desc(orderByField);
1514
- }
1515
- }
1516
-
1517
-
1518
- const results = await queryTarget.findMany(queryOpts as Parameters<NonNullable<typeof queryTarget>["findMany"]>[0]);
1519
-
1520
- // Inline the nested Drizzle results, columns only — no synthesized id.
1521
- return results.map((row: Record<string, unknown>) => {
1522
- const flat: Record<string, unknown> = {};
1523
- for (const [k, v] of Object.entries(row)) {
1524
- if (Array.isArray(v)) {
1525
- // Many relation — inline each nested row
1526
- flat[k] = v.map((item: Record<string, unknown>) => {
1527
- // Junction table rows may have the target nested, unwrap those
1528
- const keys = Object.keys(item);
1529
- const nestedObj = keys.find(nk => typeof item[nk] === "object" && item[nk] !== null && !Array.isArray(item[nk]));
1530
- if (nestedObj && keys.length <= 3) {
1531
- return { ...(item[nestedObj] as Record<string, unknown>) };
1532
- }
1533
- return { ...item };
1534
- });
1535
- } else if (typeof v === "object" && v !== null) {
1536
- // One-to-one relation — inline the target's columns
1537
- flat[k] = { ...(v as Record<string, unknown>) };
1538
- } else {
1539
- flat[k] = v;
1540
- }
1541
- }
1542
- return flat;
1543
- });
1544
- } catch (e) {
1545
- logger.warn(`[include] Drizzle relational query failed for '${collectionPath}', falling back`, { error: e });
1546
- return null;
1547
- }
1548
- }
1549
-
1550
1457
  /**
1551
1458
  * Fallback path used when db.query is unavailable.
1552
1459
  * The primary path uses db.query.findMany with `with` config, which