@rebasepro/server-postgres 0.13.1-canary.g18cfeb7 → 0.13.1-canary.g1bf9303
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/PostgresBootstrapper.d.ts +26 -0
- package/dist/auth/services.d.ts +21 -0
- package/dist/{auth-users-columns-Do9mw5Y5.js → auth-users-columns-BxT6FRyu.js} +819 -68
- package/dist/auth-users-columns-BxT6FRyu.js.map +1 -0
- package/dist/{backup-service-Bww-Lg0s.js → backup-service-BH0Dzo_h.js} +2 -3
- package/dist/{backup-service-Bww-Lg0s.js.map → backup-service-BH0Dzo_h.js.map} +1 -1
- package/dist/cli-helpers.d.ts +56 -0
- package/dist/cli-output.d.ts +34 -0
- package/dist/data-transformer.d.ts +7 -2
- package/dist/data_driver-ULAyJEi9.js +193 -0
- package/dist/data_driver-ULAyJEi9.js.map +1 -0
- package/dist/ensure-collection-policies-CP5_YttS.js +124 -0
- package/dist/ensure-collection-policies-CP5_YttS.js.map +1 -0
- package/dist/{ensure-collection-tables-DSIxvLLD.js → ensure-collection-tables-DWVISfcC.js} +119 -13
- package/dist/ensure-collection-tables-DWVISfcC.js.map +1 -0
- package/dist/index.es.js +998 -600
- package/dist/index.es.js.map +1 -1
- package/dist/{rls-bootstrap-sql-Bpv3nUZo.js → rls-bootstrap-sql-69hYT8nr.js} +2 -2
- package/dist/{rls-bootstrap-sql-Bpv3nUZo.js.map → rls-bootstrap-sql-69hYT8nr.js.map} +1 -1
- package/dist/rls-enforcement-Ct9ab42o.js +425 -0
- package/dist/rls-enforcement-Ct9ab42o.js.map +1 -0
- package/dist/schema/auth-schema.d.ts +102 -0
- package/dist/schema/doctor-policy-checks.d.ts +28 -0
- package/dist/schema/doctor.d.ts +41 -25
- package/dist/schema/ensure-collection-policies.d.ts +33 -9
- package/dist/schema/ensure-collection-tables.d.ts +60 -6
- package/dist/schema/generate-drizzle-schema-logic.d.ts +9 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +48 -0
- package/dist/schema/search-column.d.ts +248 -0
- package/dist/security/rls-enforcement.d.ts +8 -3
- package/dist/services/FetchService.d.ts +24 -0
- package/dist/services/RelationService.d.ts +30 -0
- package/dist/services/collection-helpers.d.ts +26 -0
- package/dist/services/dataService.d.ts +3 -0
- package/dist/services/realtimeService.d.ts +139 -2
- package/dist/{src-C_wvdMnl.js → src-DCdn3Val.js} +35 -3
- package/dist/src-DCdn3Val.js.map +1 -0
- package/dist/utils/drizzle-conditions.d.ts +124 -2
- package/dist/{websocket-D0TBU3ia.js → websocket-C8ZqVBiV.js} +75 -18
- package/dist/websocket-C8ZqVBiV.js.map +1 -0
- package/package.json +6 -6
- package/src/PostgresBackendDriver.ts +7 -3
- package/src/PostgresBootstrapper.ts +95 -9
- package/src/auth/ensure-tables.ts +27 -5
- package/src/auth/services.ts +82 -5
- package/src/backup/backup-cli.ts +59 -57
- package/src/cli-errors.ts +6 -6
- package/src/cli-helpers.ts +110 -4
- package/src/cli-output.ts +43 -0
- package/src/cli.ts +210 -145
- package/src/collections/buildRegistry.ts +3 -1
- package/src/data-transformer.ts +107 -14
- package/src/history/ensure-history-table.ts +2 -2
- package/src/schema/auth-schema.ts +17 -1
- package/src/schema/doctor-cli.ts +14 -65
- package/src/schema/doctor-policy-checks.ts +105 -0
- package/src/schema/doctor.ts +149 -72
- package/src/schema/ensure-collection-policies.ts +99 -6
- package/src/schema/ensure-collection-tables.ts +286 -13
- package/src/schema/generate-drizzle-schema-logic.ts +126 -42
- package/src/schema/generate-drizzle-schema.ts +11 -10
- package/src/schema/generate-postgres-ddl-logic.ts +204 -10
- package/src/schema/generate-postgres-ddl.ts +38 -14
- package/src/schema/introspect-db-logic.ts +65 -33
- package/src/schema/introspect-db.ts +24 -24
- package/src/schema/search-column.ts +643 -0
- package/src/security/rls-enforcement.ts +9 -4
- package/src/services/FetchService.ts +229 -15
- package/src/services/PersistService.ts +24 -1
- package/src/services/RelationService.ts +119 -69
- package/src/services/cdc/trigger-cdc.ts +5 -1
- package/src/services/channel-history.ts +9 -3
- package/src/services/channel-presence.ts +10 -3
- package/src/services/collection-helpers.ts +54 -1
- package/src/services/dataService.ts +3 -0
- package/src/services/pg-notify-listener.ts +1 -1
- package/src/services/realtimeService.ts +347 -86
- package/src/utils/drizzle-conditions.ts +365 -23
- package/src/utils/pg-error-utils.ts +8 -3
- package/src/websocket.ts +113 -16
- package/dist/auth-users-columns-Do9mw5Y5.js.map +0 -1
- package/dist/ensure-collection-policies-DMUdRQdM.js +0 -57
- package/dist/ensure-collection-policies-DMUdRQdM.js.map +0 -1
- package/dist/ensure-collection-tables-DSIxvLLD.js.map +0 -1
- package/dist/policy-CPkCqVTz.js +0 -105
- package/dist/policy-CPkCqVTz.js.map +0 -1
- package/dist/src-C_wvdMnl.js.map +0 -1
- package/dist/websocket-D0TBU3ia.js.map +0 -1
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { countRowsUpTo, readSchemaMetadata } from "./introspect-db-queries";
|
|
18
18
|
import { classifyTables, lookupCandidates, LOOKUP_MAX_ROWS } from "./introspect-db-structure";
|
|
19
19
|
import { parseCheckConstraints } from "./introspect-db-constraints";
|
|
20
|
-
import {
|
|
20
|
+
import { out, outWarn, outError } from "../cli-output";
|
|
21
21
|
|
|
22
22
|
async function main() {
|
|
23
23
|
const args = arg(
|
|
@@ -59,14 +59,14 @@ async function main() {
|
|
|
59
59
|
|
|
60
60
|
for (const p of envPaths) {
|
|
61
61
|
if (fs.existsSync(p)) {
|
|
62
|
-
dotenv.config({ path: p });
|
|
62
|
+
dotenv.config({ path: p, quiet: true });
|
|
63
63
|
break;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const databaseUrl = process.env.DATABASE_URL || process.env.ADMIN_CONNECTION_STRING;
|
|
68
68
|
if (!databaseUrl) {
|
|
69
|
-
|
|
69
|
+
outError(chalk.red("✗ DATABASE_URL is not set. Make sure your .env file is configured."));
|
|
70
70
|
process.exit(1);
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -75,15 +75,15 @@ async function main() {
|
|
|
75
75
|
try {
|
|
76
76
|
await client.connect();
|
|
77
77
|
} catch (err) {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
outError(chalk.red(`✗ Failed to connect to database: ${err instanceof Error ? err.message : String(err)}`));
|
|
79
|
+
outError(chalk.gray(" Check your DATABASE_URL and ensure the database is reachable."));
|
|
80
80
|
process.exit(1);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// Log the host portion safely — handle URLs without "@"
|
|
84
84
|
const hostPart = safeHostFromUrl(databaseUrl);
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
out(chalk.gray(`Connected to database: ${hostPart}`));
|
|
86
|
+
out(chalk.gray(`Introspecting schema '${pgSchema}'...`));
|
|
87
87
|
|
|
88
88
|
try {
|
|
89
89
|
const metadata = await readSchemaMetadata(client, pgSchema);
|
|
@@ -101,7 +101,7 @@ async function main() {
|
|
|
101
101
|
} catch (err) {
|
|
102
102
|
// A table this run cannot read is simply not classified as a code
|
|
103
103
|
// list; everything else about it still generates.
|
|
104
|
-
|
|
104
|
+
out(chalk.gray(` (skipped row count for ${table}: ${err instanceof Error ? err.message : String(err)})`));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -116,8 +116,8 @@ async function main() {
|
|
|
116
116
|
const roleCount = (role: string) =>
|
|
117
117
|
Array.from(classifications.values()).filter((c) => c.role === role).length;
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
out(chalk.blue(`Found ${tablesMap.size} tables.`));
|
|
120
|
+
out(chalk.gray(
|
|
121
121
|
` ${roleCount("entity")} entities, ${joinTables.size} join tables (folded into relations), ` +
|
|
122
122
|
`${roleCount("lookup")} code lists, ${roleCount("owned-child")} owned by another table (hidden from navigation).`
|
|
123
123
|
));
|
|
@@ -130,7 +130,7 @@ async function main() {
|
|
|
130
130
|
} else if (!process.stdin.isTTY) {
|
|
131
131
|
// No terminal to answer the question below (scaffolding scripts, CI,
|
|
132
132
|
// `rebase init --introspect`) — asking would hang forever.
|
|
133
|
-
|
|
133
|
+
out(chalk.gray("Skipping data inference (non-interactive run; pass --data-inference to enable)."));
|
|
134
134
|
} else {
|
|
135
135
|
const rl = readline.createInterface({
|
|
136
136
|
input: process.stdin,
|
|
@@ -142,7 +142,7 @@ async function main() {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
if (runDataInference) {
|
|
145
|
-
|
|
145
|
+
out(chalk.gray("Sampling database rows for data inference..."));
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// Generate Collections
|
|
@@ -169,7 +169,7 @@ async function main() {
|
|
|
169
169
|
const { rows } = await client.query(`SELECT * FROM "${pgSchema}"."${tableName}" LIMIT 100`);
|
|
170
170
|
sampleData = rows;
|
|
171
171
|
} catch (err) {
|
|
172
|
-
|
|
172
|
+
outError(chalk.yellow(`⚠ Failed to sample data for table ${tableName}: ${err instanceof Error ? err.message : String(err)}`));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -186,7 +186,7 @@ async function main() {
|
|
|
186
186
|
|
|
187
187
|
fs.writeFileSync(filePath, fileContent, "utf-8");
|
|
188
188
|
generatedFiles.push(tableName);
|
|
189
|
-
|
|
189
|
+
out(chalk.green(` ✓ ${filePath}`));
|
|
190
190
|
}));
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -213,21 +213,21 @@ async function main() {
|
|
|
213
213
|
const indexContent = generateIndexContent(allFiles);
|
|
214
214
|
fs.writeFileSync(indexPath, indexContent, "utf-8");
|
|
215
215
|
}
|
|
216
|
-
|
|
216
|
+
out(chalk.green(` ✓ ${indexPath}`));
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
out("");
|
|
220
220
|
if (skippedFiles.length > 0) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
out(chalk.yellow(`⚠ Skipped ${skippedFiles.length} existing file(s): ${skippedFiles.join(", ")}`));
|
|
222
|
+
out(chalk.gray(" Use --force to overwrite existing files."));
|
|
223
|
+
out("");
|
|
224
224
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
out(chalk.bold.green(`✓ Introspected ${tablesMap.size} tables — generated ${generatedFiles.length} collection(s).`));
|
|
226
|
+
out(chalk.gray(` Review the generated files in ${outDir} and customize properties as needed.`));
|
|
227
|
+
out("");
|
|
228
228
|
|
|
229
229
|
} catch (e) {
|
|
230
|
-
|
|
230
|
+
outError(chalk.red(`✗ Error introspecting database: ${e instanceof Error ? e.message : String(e)}`));
|
|
231
231
|
process.exit(1);
|
|
232
232
|
} finally {
|
|
233
233
|
await client.end();
|
|
@@ -235,6 +235,6 @@ async function main() {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
main().catch((err) => {
|
|
238
|
-
|
|
238
|
+
outError(String(err));
|
|
239
239
|
process.exit(1);
|
|
240
240
|
});
|