@rebasepro/server-postgres 0.13.1-canary.gf57a27e → 0.14.1-canary.g7e666eb
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/PostgresBackendDriver.d.ts +1 -1
- package/dist/PostgresBootstrapper.d.ts +26 -0
- package/dist/auth/services.d.ts +31 -0
- package/dist/{auth-users-columns-Dt9g712t.js → auth-users-columns-C-FDnL_e.js} +768 -76
- package/dist/auth-users-columns-C-FDnL_e.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-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-BedO2aNX.js +124 -0
- package/dist/ensure-collection-policies-BedO2aNX.js.map +1 -0
- package/dist/{ensure-collection-tables-DRxaUG96.js → ensure-collection-tables-B1qKdXA4.js} +89 -10
- package/dist/ensure-collection-tables-B1qKdXA4.js.map +1 -0
- package/dist/index.es.js +1615 -1210
- 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-gUNDfm7l.js +425 -0
- package/dist/rls-enforcement-gUNDfm7l.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/introspect-db-inference.d.ts +8 -1
- package/dist/schema/introspect-db-logic.d.ts +49 -0
- package/dist/schema/introspect-db-project.d.ts +21 -0
- package/dist/schema/search-column.d.ts +49 -0
- package/dist/security/policy-drift.d.ts +34 -0
- package/dist/security/rls-enforcement.d.ts +8 -3
- package/dist/services/FetchService.d.ts +63 -5
- package/dist/services/PersistService.d.ts +21 -17
- package/dist/services/RelationService.d.ts +11 -59
- package/dist/services/RelationWriteService.d.ts +82 -0
- package/dist/services/collection-helpers.d.ts +42 -0
- package/dist/services/dataService.d.ts +8 -4
- package/dist/services/junction-writes.d.ts +82 -0
- package/dist/services/realtimeService.d.ts +191 -12
- package/dist/services/write-denial.d.ts +36 -0
- 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 +54 -1
- package/dist/{websocket-D0TBU3ia.js → websocket-D2jXv0Ds.js} +103 -19
- package/dist/websocket-D2jXv0Ds.js.map +1 -0
- package/package.json +6 -6
- package/src/PostgresBackendDriver.ts +14 -6
- package/src/PostgresBootstrapper.ts +95 -9
- package/src/auth/ensure-tables.ts +27 -5
- package/src/auth/services.ts +108 -10
- package/src/backup/backup-cli.ts +59 -57
- package/src/cli-errors.ts +6 -6
- package/src/cli-helpers.ts +4 -4
- package/src/cli-output.ts +43 -0
- package/src/cli.ts +155 -147
- package/src/collections/buildRegistry.ts +3 -1
- package/src/data-transformer.ts +111 -25
- 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 +214 -17
- package/src/schema/generate-drizzle-schema-logic.ts +140 -66
- package/src/schema/generate-drizzle-schema.ts +11 -10
- package/src/schema/generate-postgres-ddl-logic.ts +28 -1
- package/src/schema/generate-postgres-ddl.ts +14 -13
- package/src/schema/generated-schema-staleness.ts +7 -5
- package/src/schema/introspect-db-inference.ts +9 -2
- package/src/schema/introspect-db-logic.ts +251 -75
- package/src/schema/introspect-db-project.ts +78 -0
- package/src/schema/introspect-db.ts +42 -25
- package/src/schema/introspect-runtime.ts +14 -2
- package/src/schema/search-column.ts +85 -0
- package/src/security/policy-drift.test.ts +104 -3
- package/src/security/policy-drift.ts +129 -7
- package/src/security/rls-enforcement.ts +9 -4
- package/src/services/FetchService.ts +289 -69
- package/src/services/PersistService.ts +68 -42
- package/src/services/RelationService.ts +38 -698
- package/src/services/RelationWriteService.ts +653 -0
- 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 +89 -4
- package/src/services/dataService.ts +8 -4
- package/src/services/junction-writes.ts +295 -0
- package/src/services/pg-notify-listener.ts +15 -1
- package/src/services/realtimeService.ts +496 -121
- package/src/services/write-denial.ts +55 -0
- package/src/utils/drizzle-conditions.ts +211 -34
- package/src/utils/pg-error-utils.ts +8 -3
- package/src/websocket.ts +157 -17
- package/dist/auth-users-columns-Dt9g712t.js.map +0 -1
- package/dist/ensure-collection-policies-CwYUliAa.js +0 -57
- package/dist/ensure-collection-policies-CwYUliAa.js.map +0 -1
- package/dist/ensure-collection-tables-DRxaUG96.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
|
@@ -152,7 +152,7 @@ export declare class PostgresBackendDriver implements DataDriver {
|
|
|
152
152
|
delete<M extends Record<string, unknown>>({ row, collection }: DeleteProps<M>): Promise<void>;
|
|
153
153
|
deleteAll(path: string): Promise<void>;
|
|
154
154
|
checkUniqueField(path: string, name: string, value: unknown, id?: string, collection?: CollectionConfig): Promise<boolean>;
|
|
155
|
-
count<M extends Record<string, unknown>>({ path, collection, filter, logical, searchString }: FetchCollectionProps<M>): Promise<number>;
|
|
155
|
+
count<M extends Record<string, unknown>>({ path, collection, filter, logical, searchString, vectorSearch }: FetchCollectionProps<M>): Promise<number>;
|
|
156
156
|
private getTargetDb;
|
|
157
157
|
executeSql(sqlText: string, options?: {
|
|
158
158
|
database?: string;
|
|
@@ -89,6 +89,32 @@ export interface PostgresDriverInternals {
|
|
|
89
89
|
* and this is the part that was wrong.
|
|
90
90
|
*/
|
|
91
91
|
export declare function resolveDriftCheckName(col: CollectionConfig, registeredTableNames: string[]): string;
|
|
92
|
+
/**
|
|
93
|
+
* Is this the local database `rebase init` scaffolds — i.e. the one case where
|
|
94
|
+
* "you are connected as a superuser" is not news?
|
|
95
|
+
*
|
|
96
|
+
* The scaffold's own `docker-compose.yml` sets `POSTGRES_USER: rebase_app`,
|
|
97
|
+
* which makes that role the cluster superuser, so the superuser advisory below
|
|
98
|
+
* was the only WARN a brand-new project ever saw and it was about a decision
|
|
99
|
+
* the tool had made for the developer.
|
|
100
|
+
*
|
|
101
|
+
* Of the two available fixes — provision a non-superuser table-owner role in
|
|
102
|
+
* the scaffold, or recognise the local shape and stay quiet — this is the
|
|
103
|
+
* second, because the first breaks the scaffold it is meant to improve: a
|
|
104
|
+
* non-superuser owner cannot `CREATE EXTENSION` (search collections need
|
|
105
|
+
* `pg_trgm`/`unaccent`, applied by `rebase db push` and again by the boot
|
|
106
|
+
* schema-ensure), so the very first `pnpm run db:push` on a scaffolded project
|
|
107
|
+
* with a search block would fail. Trading a working first run for a quieter log
|
|
108
|
+
* line is the wrong trade.
|
|
109
|
+
*
|
|
110
|
+
* The condition is deliberately narrow — a *non-production* process talking to
|
|
111
|
+
* a database on the loopback interface. A genuine production superuser
|
|
112
|
+
* connection still warns, and so does a non-production process pointed at a
|
|
113
|
+
* remote database (the usual "my dev machine writes to staging" mistake, where
|
|
114
|
+
* the advisory is exactly right). NODE_ENV alone would not do: the scaffold
|
|
115
|
+
* ships `NODE_ENV=development` and some deployments inherit it.
|
|
116
|
+
*/
|
|
117
|
+
export declare function isScaffoldedLocalDatabase(connectionString: string | undefined): boolean;
|
|
92
118
|
/**
|
|
93
119
|
* Default PostgreSQL bootstrapper.
|
|
94
120
|
*
|
package/dist/auth/services.d.ts
CHANGED
|
@@ -58,6 +58,16 @@ export declare class UserService implements UserRepository {
|
|
|
58
58
|
private withServerContext;
|
|
59
59
|
private mapRowToUser;
|
|
60
60
|
private mapPayload;
|
|
61
|
+
/**
|
|
62
|
+
* @see UserRepository.createUser — an email already in use is a 409.
|
|
63
|
+
*
|
|
64
|
+
* The route checks first and answers 409; this is the same answer for the
|
|
65
|
+
* requests that get past the check, which two clicks on a signup button
|
|
66
|
+
* are enough to produce. `PersistService` has mapped `23505` to a conflict
|
|
67
|
+
* for collection writes since the layer that holds the SQLSTATE was made
|
|
68
|
+
* responsible for saying whose fault a failure is; the auth writes never
|
|
69
|
+
* got the same treatment and reached the client as "Internal Server Error".
|
|
70
|
+
*/
|
|
61
71
|
createUser(data: CreateUserData): Promise<UserData>;
|
|
62
72
|
getUserById(id: string): Promise<UserData | null>;
|
|
63
73
|
getUserByEmail(email: string): Promise<UserData | null>;
|
|
@@ -287,6 +297,7 @@ export declare class PostgresAuthRepository implements AuthRepository {
|
|
|
287
297
|
secretEncrypted: string;
|
|
288
298
|
}) | null>;
|
|
289
299
|
verifyMfaFactor(factorId: string): Promise<void>;
|
|
300
|
+
updateMfaFactorSecret(factorId: string, secretEncrypted: string): Promise<void>;
|
|
290
301
|
deleteMfaFactor(factorId: string, uid: string): Promise<void>;
|
|
291
302
|
createMfaChallenge(factorId: string, ipAddress?: string): Promise<MfaChallengeInfo>;
|
|
292
303
|
getMfaChallengeById(challengeId: string): Promise<MfaChallengeInfo | null>;
|
|
@@ -296,6 +307,8 @@ export declare class PostgresAuthRepository implements AuthRepository {
|
|
|
296
307
|
getUnusedRecoveryCodeCount(uid: string): Promise<number>;
|
|
297
308
|
deleteAllRecoveryCodes(uid: string): Promise<void>;
|
|
298
309
|
hasVerifiedMfaFactors(uid: string): Promise<boolean>;
|
|
310
|
+
claimMfaFactorCounter(factorId: string, counter: number): Promise<boolean>;
|
|
311
|
+
recordMfaChallengeAttempt(challengeId: string): Promise<number>;
|
|
299
312
|
}
|
|
300
313
|
/**
|
|
301
314
|
* PostgreSQL implementation of MfaRepository.
|
|
@@ -311,10 +324,28 @@ export declare class MfaService implements MfaRepository {
|
|
|
311
324
|
getMfaFactorById(factorId: string): Promise<(MfaFactor & {
|
|
312
325
|
secretEncrypted: string;
|
|
313
326
|
}) | null>;
|
|
327
|
+
/**
|
|
328
|
+
* Spend a TOTP time step, once and only once.
|
|
329
|
+
*
|
|
330
|
+
* One statement: the `WHERE` is the check, the `UPDATE` is the act, and
|
|
331
|
+
* `RETURNING` reports which of two concurrent requests carrying the same
|
|
332
|
+
* six digits won. Reading the counter and then writing it would let both
|
|
333
|
+
* pass — the exact replay this closes.
|
|
334
|
+
*/
|
|
335
|
+
claimMfaFactorCounter(factorId: string, counter: number): Promise<boolean>;
|
|
314
336
|
verifyMfaFactor(factorId: string): Promise<void>;
|
|
337
|
+
updateMfaFactorSecret(factorId: string, secretEncrypted: string): Promise<void>;
|
|
315
338
|
deleteMfaFactor(factorId: string, uid: string): Promise<void>;
|
|
316
339
|
createMfaChallenge(factorId: string, ipAddress?: string): Promise<MfaChallengeInfo>;
|
|
317
340
|
getMfaChallengeById(challengeId: string): Promise<MfaChallengeInfo | null>;
|
|
341
|
+
/**
|
|
342
|
+
* Count one failed guess against a challenge and report the new total.
|
|
343
|
+
*
|
|
344
|
+
* Incremented in the database rather than in the route so that guesses
|
|
345
|
+
* arriving in parallel — the shape any real brute-force takes — cannot
|
|
346
|
+
* share a single increment.
|
|
347
|
+
*/
|
|
348
|
+
recordMfaChallengeAttempt(challengeId: string): Promise<number>;
|
|
318
349
|
verifyMfaChallenge(challengeId: string): Promise<void>;
|
|
319
350
|
createRecoveryCodes(uid: string, codeHashes: string[]): Promise<void>;
|
|
320
351
|
useRecoveryCode(uid: string, codeHash: string): Promise<boolean>;
|