@rebasepro/server-postgres 0.19.2-canary.gef769df → 0.20.0

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.
@@ -11,6 +11,31 @@ import { type WithDeleted } from "./soft-delete.js";
11
11
  * Service for handling all row read operations.
12
12
  * Handles fetching, searching, counting, and filtering rows.
13
13
  */
14
+ /**
15
+ * Which aggregate aliases hold a number that Postgres handed back as a string.
16
+ *
17
+ * `count`, `sum` and `avg` always do: bigint and numeric are returned as text
18
+ * because they do not fit a JS number in general. `min` and `max` are uncast,
19
+ * so they do it too — but only over a numeric column, and those are the two
20
+ * functions that also apply to text and dates.
21
+ *
22
+ * Decided by the column's DECLARED type, not by trying `Number()` on the value.
23
+ * `?select=avg(price),max(price)` used to answer `{avg_price: 5,
24
+ * max_price: "8.5"}` — one column, two functions, two JSON types, and
25
+ * arithmetic on the second one silently concatenates. Parsing whatever looks
26
+ * numeric would fix that and break something worse: a `min(sku)` of `"00123"`
27
+ * would come back as `123`, a different value, and no NaN check would catch it.
28
+ *
29
+ * Exported to be tested: the parsing itself needs a database, this decision
30
+ * does not.
31
+ */
32
+ export declare function numericAggregateAliases(aggregates: {
33
+ fn: "count" | "sum" | "avg" | "min" | "max";
34
+ field?: string;
35
+ alias: string;
36
+ }[], properties: Record<string, {
37
+ type?: string;
38
+ }>): Set<string>;
14
39
  export declare class FetchService {
15
40
  private db;
16
41
  private registry;
@@ -29,6 +29,15 @@ export type RelationStyle = "ref" | "inline";
29
29
  * to unwrap that same level back out.
30
30
  */
31
31
  export declare function isJunctionRelation(relation: ResolvedRelation): boolean;
32
+ /**
33
+ * Apply {@link toRestScalar} across a row, leaving undeclared columns alone.
34
+ *
35
+ * Exported because the include loader attaches related rows itself, and a
36
+ * target rendered differently from its parent is the shape bug this whole file
37
+ * exists to prevent — a date was a string at the top level and a
38
+ * `{ __type: "date" }` envelope one level down, in the same response.
39
+ */
40
+ export declare function toRestValues(row: Record<string, unknown>, collection: CollectionConfig): Record<string, unknown>;
32
41
  /** Render one target row in the requested style. */
33
42
  /**
34
43
  * Drop every column this caller may not read.
@@ -80,9 +89,9 @@ export declare function toFlatRow(row: Record<string, unknown>, collection: Coll
80
89
  *
81
90
  * Values are the ones the database returned, except where that contradicts the
82
91
  * declared type: a `number` property is served as a number (see
83
- * {@link coerceDeclaredNumber}). Dates stay as the database returned them
84
- * JSON has its own opinions about dates that the admin's view-model does not
85
- * share.
92
+ * {@link coerceDeclaredNumber}) and a `date` as RFC 3339, which is what this
93
+ * server's own OpenAPI document says a date column is (see
94
+ * {@link toRestDate}).
86
95
  *
87
96
  * Keyed by the row rather than by the relation list — a REST fetch only loads
88
97
  * the relations `include` asked for, so the row is the authority on which are
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/server-postgres",
3
- "version": "0.19.2-canary.gef769df",
3
+ "version": "0.20.0",
4
4
  "description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
5
5
  "keywords": [
6
6
  "cms",
@@ -50,11 +50,11 @@
50
50
  "execa": "^9.6.1",
51
51
  "pg": "^8.22.0",
52
52
  "ws": "^8.21.1",
53
- "@rebasepro/codegen": "0.19.2-canary.gef769df",
54
- "@rebasepro/types": "0.19.2-canary.gef769df",
55
- "@rebasepro/utils": "0.19.2-canary.gef769df",
56
- "@rebasepro/server": "0.19.2-canary.gef769df",
57
- "@rebasepro/common": "0.19.2-canary.gef769df"
53
+ "@rebasepro/codegen": "0.20.0",
54
+ "@rebasepro/common": "0.20.0",
55
+ "@rebasepro/server": "0.20.0",
56
+ "@rebasepro/types": "0.20.0",
57
+ "@rebasepro/utils": "0.20.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@electric-sql/pglite": "0.5.6",
@@ -70,7 +70,7 @@
70
70
  "typescript": "^6.0.3",
71
71
  "vite": "^8.1.5",
72
72
  "vitest": "^4.1.10",
73
- "@rebasepro/client": "0.19.2-canary.gef769df"
73
+ "@rebasepro/client": "0.20.0"
74
74
  },
75
75
  "gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
76
76
  "publishConfig": {