@rebasepro/server-postgres 0.9.1-canary.0fce67c → 0.9.1-canary.16c42e9

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.
@@ -2,7 +2,7 @@ import { CollectionConfig, Property } from "@rebasepro/types";
2
2
  export type IssueSeverity = "error" | "warning" | "info";
3
3
  export interface DoctorIssue {
4
4
  severity: IssueSeverity;
5
- category: "missing_table" | "missing_column" | "type_mismatch" | "missing_constraint" | "schema_stale" | "missing_enum" | "enum_value_mismatch" | "missing_foreign_key" | "sdk_stale" | "sdk_not_generated";
5
+ category: "missing_table" | "missing_column" | "type_mismatch" | "missing_constraint" | "schema_stale" | "missing_enum" | "enum_value_mismatch" | "missing_foreign_key" | "sdk_stale";
6
6
  table?: string;
7
7
  column?: string;
8
8
  expected?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/server-postgres",
3
3
  "type": "module",
4
- "version": "0.9.1-canary.0fce67c",
4
+ "version": "0.9.1-canary.16c42e9",
5
5
  "description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -71,11 +71,11 @@
71
71
  "execa": "^9.6.1",
72
72
  "pg": "^8.21.0",
73
73
  "ws": "^8.21.0",
74
- "@rebasepro/codegen": "0.9.1-canary.0fce67c",
75
- "@rebasepro/utils": "0.9.1-canary.0fce67c",
76
- "@rebasepro/types": "0.9.1-canary.0fce67c",
77
- "@rebasepro/server": "0.9.1-canary.0fce67c",
78
- "@rebasepro/common": "0.9.1-canary.0fce67c"
74
+ "@rebasepro/codegen": "0.9.1-canary.16c42e9",
75
+ "@rebasepro/server": "0.9.1-canary.16c42e9",
76
+ "@rebasepro/types": "0.9.1-canary.16c42e9",
77
+ "@rebasepro/utils": "0.9.1-canary.16c42e9",
78
+ "@rebasepro/common": "0.9.1-canary.16c42e9"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@hono/node-server": "^2.0.9",
@@ -37,7 +37,7 @@ export type IssueSeverity = "error" | "warning" | "info";
37
37
 
38
38
  export interface DoctorIssue {
39
39
  severity: IssueSeverity;
40
- category: "missing_table" | "missing_column" | "type_mismatch" | "missing_constraint" | "schema_stale" | "missing_enum" | "enum_value_mismatch" | "missing_foreign_key" | "sdk_stale" | "sdk_not_generated";
40
+ category: "missing_table" | "missing_column" | "type_mismatch" | "missing_constraint" | "schema_stale" | "missing_enum" | "enum_value_mismatch" | "missing_foreign_key" | "sdk_stale";
41
41
  table?: string;
42
42
  column?: string;
43
43
  expected?: string;
@@ -61,29 +61,19 @@ export function getExpectedColumnType(prop: Property): string | null {
61
61
  const sp = prop as StringProperty;
62
62
  if (sp.enum) return "USER-DEFINED"; // pgEnum → USER-DEFINED in information_schema
63
63
  if ("isId" in sp && sp.isId === "uuid") return "uuid";
64
- if (sp.columnType === "uuid") return "uuid";
65
- // A markdown/multiline string compiles to `text`, not varchar — the
66
- // generator treats those UI hints as column-type signals, so the
67
- // expectation here must too or every such column reads as drift.
68
- if (sp.columnType === "text" || sp.ui?.markdown || sp.ui?.multiline) return "text";
64
+ if (sp.columnType === "text") return "text";
69
65
  if (sp.columnType === "char") return "character";
70
66
  return "character varying";
71
67
  }
72
68
  case "number": {
73
69
  const np = prop as NumberProperty;
74
- if (np.columnType) {
75
- // The generator passes any columnType straight through to drizzle,
76
- // so mirror that rather than enumerating a subset (which reported
77
- // drift for anything unlisted, e.g. smallint). Serial types are
78
- // integers with a sequence default; information_schema reports the
79
- // underlying width.
80
- const serialWidths: Record<string, string> = {
81
- serial: "integer",
82
- bigserial: "bigint",
83
- smallserial: "smallint"
84
- };
85
- return serialWidths[np.columnType] ?? np.columnType;
86
- }
70
+ if (np.columnType === "double precision") return "double precision";
71
+ if (np.columnType === "real") return "real";
72
+ if (np.columnType === "bigint") return "bigint";
73
+ if (np.columnType === "serial") return "integer"; // serial is integer under the hood
74
+ if (np.columnType === "bigserial") return "bigint";
75
+ if (np.columnType === "integer") return "integer";
76
+ if (np.columnType === "numeric") return "numeric";
87
77
  if (np.validation?.integer || ("isId" in np && np.isId)) return "integer";
88
78
  return "numeric";
89
79
  }
@@ -211,18 +201,15 @@ export async function checkCollectionsVsSdk(
211
201
  ): Promise<{ passed: boolean; issues: DoctorIssue[] }> {
212
202
  const issues: DoctorIssue[] = [];
213
203
 
214
- // The typed SDK is opt-in — nothing in a scaffolded project imports it until
215
- // you choose to. A project that never generated one isn't drifting, so report
216
- // it as information rather than a warning; otherwise `doctor` can never come
217
- // back clean on a fresh project and users learn to ignore its output.
204
+ // Check if SDK file exists
218
205
  if (!fs.existsSync(sdkFilePath)) {
219
206
  issues.push({
220
- severity: "info",
221
- category: "sdk_not_generated",
222
- message: "Typed SDK not generated (optional).",
223
- fix: "Run `rebase generate-sdk` if you want typed collection access"
207
+ severity: "warning",
208
+ category: "sdk_stale",
209
+ message: `Generated SDK typedefs file does not exist at "${sdkFilePath}".`,
210
+ fix: "Run `rebase generate-sdk`"
224
211
  });
225
- return { passed: true,
212
+ return { passed: false,
226
213
  issues };
227
214
  }
228
215
 
@@ -644,15 +631,11 @@ export function renderReport(report: DoctorReport): void {
644
631
  }
645
632
 
646
633
  function renderPhase(label: string, passed: boolean, issues: DoctorIssue[]): void {
647
- const errorCount = issues.filter((i) => i.severity === "error").length;
648
- const warnCount = issues.filter((i) => i.severity === "warning").length;
649
- const infoIssues = issues.filter((i) => i.severity === "info");
650
-
651
- // Informational notes don't make a phase unhealthy, so key the header off
652
- // real problems rather than `passed` alone.
653
- if (errorCount === 0 && warnCount === 0) {
634
+ if (passed) {
654
635
  logger.info(` ${chalk.green("✅")} ${label}: ${chalk.green("In sync")}`);
655
636
  } else {
637
+ const errorCount = issues.filter((i) => i.severity === "error").length;
638
+ const warnCount = issues.filter((i) => i.severity === "warning").length;
656
639
  const parts: string[] = [];
657
640
  if (errorCount > 0) parts.push(`${errorCount} error${errorCount > 1 ? "s" : ""}`);
658
641
  if (warnCount > 0) parts.push(`${warnCount} warning${warnCount > 1 ? "s" : ""}`);
@@ -660,14 +643,7 @@ function renderPhase(label: string, passed: boolean, issues: DoctorIssue[]): voi
660
643
  }
661
644
  logger.info("");
662
645
 
663
- // Notes render as a quiet one-liner, not a full drift box.
664
- for (const issue of infoIssues) {
665
- const fixPart = issue.fix ? chalk.gray(` — ${issue.fix}`) : "";
666
- logger.info(` ${chalk.gray("ℹ")} ${chalk.gray(issue.message)}${fixPart}`);
667
- logger.info("");
668
- }
669
-
670
- for (const issue of issues.filter((i) => i.severity !== "info")) {
646
+ for (const issue of issues) {
671
647
  const severityIcon = issue.severity === "error" ? chalk.red("✗") : chalk.yellow("⚠");
672
648
  const categoryLabel = formatCategory(issue.category);
673
649
  logger.info(` ${chalk.gray("┌─")} ${severityIcon} ${chalk.bold(categoryLabel)} ${chalk.gray("─".repeat(Math.max(0, 42 - categoryLabel.length)))}`);
@@ -698,8 +674,7 @@ function formatCategory(cat: DoctorIssue["category"]): string {
698
674
  missing_enum: "Missing Enum",
699
675
  enum_value_mismatch: "Enum Value Mismatch",
700
676
  missing_foreign_key: "Missing Foreign Key",
701
- sdk_stale: "Stale SDK Types",
702
- sdk_not_generated: "SDK Types Not Generated"
677
+ sdk_stale: "Stale SDK Types"
703
678
  };
704
679
  return labels[cat];
705
680
  }
@@ -91,30 +91,6 @@ function coerceDeclaredNumbers(
91
91
  }
92
92
 
93
93
  /** Render one target row in the requested style. */
94
- /**
95
- * Drop every column the collection marked `excludeFromApi`.
96
- *
97
- * Password hashes and verification tokens have to be readable server-side but
98
- * must never reach a client — and "never" has to mean every exit from this
99
- * pipeline, including relation targets, or a secret leaks through whichever
100
- * path was overlooked. Keyed by both the property name and its column name,
101
- * since a row can arrive keyed either way depending on the caller.
102
- */
103
- function stripExcluded(
104
- row: Record<string, unknown>,
105
- collection: CollectionConfig
106
- ): Record<string, unknown> {
107
- const properties = collection.properties as Record<string, Property> | undefined;
108
- if (!properties) return row;
109
-
110
- for (const [key, property] of Object.entries(properties)) {
111
- if (!property?.excludeFromApi) continue;
112
- delete row[key];
113
- if (property.columnName) delete row[property.columnName];
114
- }
115
- return row;
116
- }
117
-
118
94
  function renderTarget(
119
95
  targetRow: Record<string, unknown>,
120
96
  targetCollection: CollectionConfig,
@@ -124,7 +100,7 @@ function renderTarget(
124
100
  if (style === "inline") {
125
101
  // The target's columns, and only those: its address is the consumer's
126
102
  // to derive, and merging one in overwrites a real `id` column.
127
- return stripExcluded(coerceDeclaredNumbers({ ...targetRow }, targetCollection), targetCollection);
103
+ return coerceDeclaredNumbers({ ...targetRow }, targetCollection);
128
104
  }
129
105
 
130
106
  const address = relationTargetAddress(targetRow, targetCollection, registry);
@@ -192,7 +168,7 @@ export function toCmsRow(
192
168
  }
193
169
  }
194
170
 
195
- return stripExcluded(normalized, collection);
171
+ return normalized;
196
172
  }
197
173
 
198
174
  /**
@@ -235,5 +211,5 @@ export function toRestRow(
235
211
  }
236
212
  }
237
213
 
238
- return stripExcluded(flat, collection);
214
+ return flat;
239
215
  }