@rebasepro/server-postgres 0.29.1 → 0.29.3
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/{BranchService-BIIBF5ZL.js → BranchService-CrXvcES2.js} +3 -3
- package/dist/{BranchService-BIIBF5ZL.js.map → BranchService-CrXvcES2.js.map} +1 -1
- package/dist/PostgresBackendDriver.d.ts +64 -4
- package/dist/PostgresBootstrapper.d.ts +27 -0
- package/dist/auth/ensure-tables.d.ts +2 -2
- package/dist/auth/schema-version.d.ts +5 -5
- package/dist/auth/services.d.ts +9 -9
- package/dist/{backup-cli-QcOpmRpQ.js → backup-cli-CTKCOLpX.js} +3 -3
- package/dist/{backup-cli-QcOpmRpQ.js.map → backup-cli-CTKCOLpX.js.map} +1 -1
- package/dist/{boot-ddl-BSNpEUOS.js → boot-ddl-CqGIwSYx.js} +2 -2
- package/dist/{boot-ddl-BSNpEUOS.js.map → boot-ddl-CqGIwSYx.js.map} +1 -1
- package/dist/{cli-console-DTsm96lW.js → cli-console-DBPw-oAz.js} +6 -6
- package/dist/{cli-console-DTsm96lW.js.map → cli-console-DBPw-oAz.js.map} +1 -1
- package/dist/{cli-errors-DwqFRIWz.js → cli-errors-DYTxnLbW.js} +5 -5
- package/dist/{cli-errors-DwqFRIWz.js.map → cli-errors-DYTxnLbW.js.map} +1 -1
- package/dist/cli.js +185 -49
- package/dist/cli.js.map +1 -1
- package/dist/{connection-COuS5Fm-.js → connection-C1zXTPJq.js} +7 -3
- package/dist/{connection-COuS5Fm-.js.map → connection-C1zXTPJq.js.map} +1 -1
- package/dist/data-transformer.d.ts +2 -2
- package/dist/database-health.d.ts +2 -1
- package/dist/{database-preflight-D5JtPt8i.js → database-preflight-iBpT7-vv.js} +36 -3
- package/dist/database-preflight-iBpT7-vv.js.map +1 -0
- package/dist/{databasePoolManager-7hXVurmG.js → databasePoolManager-DIjzlTK4.js} +2 -2
- package/dist/{databasePoolManager-7hXVurmG.js.map → databasePoolManager-DIjzlTK4.js.map} +1 -1
- package/dist/{deferred-index-build-B8feKnUj.js → deferred-index-build-BCU9RoHK.js} +18 -6
- package/dist/deferred-index-build-BCU9RoHK.js.map +1 -0
- package/dist/{doctor-BaR11xUe.js → doctor-Kg1oUK0Q.js} +11 -11
- package/dist/doctor-Kg1oUK0Q.js.map +1 -0
- package/dist/{ensure-collection-policies-85HiG-k1.js → ensure-collection-policies-Bo-_fDAy.js} +25 -15
- package/dist/ensure-collection-policies-Bo-_fDAy.js.map +1 -0
- package/dist/{ensure-collection-tables-DR_WcxLA.js → ensure-collection-tables-DCJINkT_.js} +11 -8
- package/dist/ensure-collection-tables-DCJINkT_.js.map +1 -0
- package/dist/{ensure-tables-Dh5UP_Zs.js → ensure-tables-BPGaGh0y.js} +4 -4
- package/dist/ensure-tables-BPGaGh0y.js.map +1 -0
- package/dist/{enum-labels-kept-DSU8lAnd.js → enum-labels-kept-YAgOZS4I.js} +3 -3
- package/dist/{enum-labels-kept-DSU8lAnd.js.map → enum-labels-kept-YAgOZS4I.js.map} +1 -1
- package/dist/{generate-drizzle-schema-5spbTyQ6.js → generate-drizzle-schema-DcrFr7YX.js} +2 -2
- package/dist/{generate-drizzle-schema-5spbTyQ6.js.map → generate-drizzle-schema-DcrFr7YX.js.map} +1 -1
- package/dist/{generate-drizzle-schema-logic-C5FB7Fpo.js → generate-drizzle-schema-logic-LTLZvt6r.js} +3 -3
- package/dist/{generate-drizzle-schema-logic-C5FB7Fpo.js.map → generate-drizzle-schema-logic-LTLZvt6r.js.map} +1 -1
- package/dist/{generate-files-Bl3_D_oP.js → generate-files-CsaVzatS.js} +3 -3
- package/dist/{generate-files-Bl3_D_oP.js.map → generate-files-CsaVzatS.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-BC3JA93M.js → generate-postgres-ddl-logic-Dg0bcENZ.js} +45 -7
- package/dist/generate-postgres-ddl-logic-Dg0bcENZ.js.map +1 -0
- package/dist/{generated-schema-diff-Jm93vyJB.js → generated-schema-diff-By4dxyTH.js} +8 -5
- package/dist/generated-schema-diff-By4dxyTH.js.map +1 -0
- package/dist/history/HistoryService.d.ts +2 -3
- package/dist/history/ensure-history-table.d.ts +8 -3
- package/dist/index.es.js +15 -15
- package/dist/interfaces.d.ts +24 -2
- package/dist/{introspect-db-logic-DgQVzccW.js → introspect-db-logic-DWqAEURB.js} +7 -5
- package/dist/introspect-db-logic-DWqAEURB.js.map +1 -0
- package/dist/{migrate-baseline-BfHmq3vN.js → migrate-baseline-CmWXL7qx.js} +163 -502
- package/dist/migrate-baseline-CmWXL7qx.js.map +1 -0
- package/dist/{migrate-policy-stamps-B4k1ggma.js → migrate-policy-stamps-BN_Qad6c.js} +42 -13
- package/dist/migrate-policy-stamps-BN_Qad6c.js.map +1 -0
- package/dist/{open-rebase-CiO_sjMT.js → open-rebase-40paQfVW.js} +1401 -655
- package/dist/open-rebase-40paQfVW.js.map +1 -0
- package/dist/open-rebase.d.ts +1 -1
- package/dist/{pg-error-utils-D1Nc0UML.js → pg-error-utils-DJHjCF7-.js} +2 -2
- package/dist/{pg-error-utils-D1Nc0UML.js.map → pg-error-utils-DJHjCF7-.js.map} +1 -1
- package/dist/pipelined-transaction.d.ts +24 -37
- package/dist/{plan-schema-BYxOzflz.js → plan-schema-vJd3UEmT.js} +41 -11
- package/dist/plan-schema-vJd3UEmT.js.map +1 -0
- package/dist/{policy-drift-DKuTJHfc.js → policy-drift-C-m0uWHH.js} +78 -10
- package/dist/policy-drift-C-m0uWHH.js.map +1 -0
- package/dist/push-index-adoption-Cp7oZxSl.js +22 -0
- package/dist/push-index-adoption-Cp7oZxSl.js.map +1 -0
- package/dist/{push-index-prebuild-bqXimSZz.js → push-index-prebuild-DbwKGtQT.js} +4 -4
- package/dist/{push-index-prebuild-bqXimSZz.js.map → push-index-prebuild-DbwKGtQT.js.map} +1 -1
- package/dist/{push-kept-defaults-CN9R8cHf.js → push-kept-defaults-CLcgsEPt.js} +2 -2
- package/dist/{push-kept-defaults-CN9R8cHf.js.map → push-kept-defaults-CLcgsEPt.js.map} +1 -1
- package/dist/{push-legacy-renames-CU_UYPbz.js → push-legacy-renames-BthD0E9W.js} +4 -4
- package/dist/{push-legacy-renames-CU_UYPbz.js.map → push-legacy-renames-BthD0E9W.js.map} +1 -1
- package/dist/{push-policy-plan-JcyK94bc.js → push-policy-plan-BgcrroxQ.js} +14 -8
- package/dist/push-policy-plan-BgcrroxQ.js.map +1 -0
- package/dist/read-routing.d.ts +10 -30
- package/dist/{render-ddl-DCdVP-pQ.js → render-ddl-Ci3S_SoI.js} +34 -3
- package/dist/render-ddl-Ci3S_SoI.js.map +1 -0
- package/dist/{request-role-cli-DSdRtvgH.js → request-role-cli-Dy1EgJU9.js} +10 -10
- package/dist/{request-role-cli-DSdRtvgH.js.map → request-role-cli-Dy1EgJU9.js.map} +1 -1
- package/dist/{request-role-migration-D9BZ5Uba.js → request-role-migration-GHTJnPMV.js} +2 -2
- package/dist/{request-role-migration-D9BZ5Uba.js.map → request-role-migration-GHTJnPMV.js.map} +1 -1
- package/dist/rls-bootstrap-sql-kPX4-MB1.js +549 -0
- package/dist/rls-bootstrap-sql-kPX4-MB1.js.map +1 -0
- package/dist/{rls-enforcement-BO618rnr.js → rls-enforcement-Cc_UhOxb.js} +316 -10
- package/dist/rls-enforcement-Cc_UhOxb.js.map +1 -0
- package/dist/{rls-settings-De5NoHHy.js → rls-settings-BCGMIig3.js} +23 -3
- package/dist/rls-settings-BCGMIig3.js.map +1 -0
- package/dist/schema/doctor-cli.js +9 -9
- package/dist/schema/doctor-cli.js.map +1 -1
- package/dist/schema/drizzle-ddl.d.ts +2 -2
- package/dist/schema/ensure-collection-policies.d.ts +23 -3
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +14 -1
- package/dist/schema/generate-postgres-ddl.js +1 -1
- package/dist/schema/index-adoption.d.ts +99 -0
- package/dist/schema/introspect-db-logic.d.ts +2 -1
- package/dist/schema/introspect-db.js +3 -3
- package/dist/schema/migrate-policy-stamps.d.ts +19 -1
- package/dist/schema/plan/diff-plan.d.ts +8 -1
- package/dist/schema/plan/render-ddl.d.ts +7 -0
- package/dist/schema/plan/types.d.ts +15 -0
- package/dist/schema/push-index-adoption.d.ts +10 -0
- package/dist/schema/push-policy-plan.d.ts +5 -1
- package/dist/schema/rls-bootstrap-sql.d.ts +19 -2
- package/dist/schema/search-column.d.ts +2 -2
- package/dist/search-column-BM-GV6vH.js.map +1 -1
- package/dist/security/policy-drift.d.ts +31 -1
- package/dist/security/rls-enforcement.d.ts +118 -1
- package/dist/security/rls-settings.d.ts +33 -0
- package/dist/services/FetchService.d.ts +33 -8
- package/dist/services/PersistService.d.ts +75 -4
- package/dist/services/RelationService.d.ts +1 -1
- package/dist/services/channel-bus/PostgresChannelBus.d.ts +2 -2
- package/dist/services/channel-bus/index.d.ts +2 -2
- package/dist/services/channel-history.d.ts +2 -2
- package/dist/services/channel-presence.d.ts +3 -3
- package/dist/services/dataService.d.ts +6 -2
- package/dist/services/realtimeService.d.ts +18 -5
- package/dist/services/socket-liveness.d.ts +6 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/drizzle-conditions.d.ts +12 -0
- package/dist/utils/positional-params.d.ts +40 -0
- package/dist/{websocket-B33YjKhs.js → websocket-B7ex6AQM.js} +3 -3
- package/dist/websocket-B7ex6AQM.js.map +1 -0
- package/dist/websocket.d.ts +14 -3
- package/package.json +7 -7
- package/dist/database-preflight-D5JtPt8i.js.map +0 -1
- package/dist/deferred-index-build-B8feKnUj.js.map +0 -1
- package/dist/doctor-BaR11xUe.js.map +0 -1
- package/dist/ensure-collection-policies-85HiG-k1.js.map +0 -1
- package/dist/ensure-collection-tables-DR_WcxLA.js.map +0 -1
- package/dist/ensure-tables-Dh5UP_Zs.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-BC3JA93M.js.map +0 -1
- package/dist/generated-schema-diff-Jm93vyJB.js.map +0 -1
- package/dist/introspect-db-logic-DgQVzccW.js.map +0 -1
- package/dist/migrate-baseline-BfHmq3vN.js.map +0 -1
- package/dist/migrate-policy-stamps-B4k1ggma.js.map +0 -1
- package/dist/open-rebase-CiO_sjMT.js.map +0 -1
- package/dist/plan-schema-BYxOzflz.js.map +0 -1
- package/dist/policy-drift-DKuTJHfc.js.map +0 -1
- package/dist/push-policy-plan-JcyK94bc.js.map +0 -1
- package/dist/render-ddl-DCdVP-pQ.js.map +0 -1
- package/dist/rls-enforcement-BO618rnr.js.map +0 -1
- package/dist/rls-settings-De5NoHHy.js.map +0 -1
- package/dist/websocket-B33YjKhs.js.map +0 -1
|
@@ -13,7 +13,7 @@ import { type ReadCallContextProvider } from "./read-scope.js";
|
|
|
13
13
|
* the gap with a single confined cast.
|
|
14
14
|
*
|
|
15
15
|
* Exported so `data-transformer` uses this one rather than restating the same
|
|
16
|
-
* fact — it
|
|
16
|
+
* fact — it double-cast `query.innerJoin(...)` to `typeof query`, which is
|
|
17
17
|
* the same claim about the same drizzle behaviour in a second spelling.
|
|
18
18
|
*/
|
|
19
19
|
export declare function applyDynamicJoin<T>(query: T, joinTable: PgTable, condition: SQL): T;
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
* the client's history replay, so a lost frame costs a live update rather
|
|
28
28
|
* than correctness. That is what makes coalescing safe.
|
|
29
29
|
*/
|
|
30
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
31
30
|
import { type PgNotifyListenerStatus } from "../pg-notify-listener.js";
|
|
32
31
|
import { ChannelBus, ChannelBusFrame, ChannelBusHandler } from "./ChannelBus.js";
|
|
32
|
+
import type { PgSqlDatabase } from "../../interfaces.js";
|
|
33
33
|
/** NOTIFY channel carrying channel-bus frames. */
|
|
34
34
|
export declare const CHANNEL_BUS_NOTIFY_CHANNEL = "rebase_channel_bus";
|
|
35
35
|
/**
|
|
@@ -64,7 +64,7 @@ export declare class PostgresChannelBus implements ChannelBus {
|
|
|
64
64
|
private pendingBytes;
|
|
65
65
|
private windowTimer?;
|
|
66
66
|
private stopped;
|
|
67
|
-
constructor(db:
|
|
67
|
+
constructor(db: PgSqlDatabase<Record<string, unknown>>, connectionString: string, options?: {
|
|
68
68
|
batchWindowMs?: number;
|
|
69
69
|
});
|
|
70
70
|
start(handler: ChannelBusHandler): Promise<void>;
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* without this file learning about it. See `@rebasepro/types` →
|
|
15
15
|
* `types/channel_bus.ts` for the contract such a package implements.
|
|
16
16
|
*/
|
|
17
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
18
17
|
import { type ChannelBus, type ChannelBusSetting } from "@rebasepro/types";
|
|
18
|
+
import type { PgSqlDatabase } from "../../interfaces.js";
|
|
19
19
|
export * from "./ChannelBus.js";
|
|
20
20
|
export { PostgresChannelBus, CHANNEL_BUS_NOTIFY_CHANNEL, PG_NOTIFY_MAX_PAYLOAD_BYTES, DEFAULT_BATCH_WINDOW_MS, parseChannelBusFrame, parseChannelBusPayload } from "./PostgresChannelBus.js";
|
|
21
21
|
export interface ChannelBusDeps {
|
|
22
|
-
db:
|
|
22
|
+
db: PgSqlDatabase<Record<string, unknown>>;
|
|
23
23
|
/**
|
|
24
24
|
* Direct (non-pooled) Postgres URL for the LISTEN client. `LISTEN` is
|
|
25
25
|
* session state, so behind PgBouncer in transaction mode this must be the
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
* return rows and they would look plausible. Cursors are tiny and are kept
|
|
30
30
|
* forever; see {@link prune}, which touches only `channel_messages`.
|
|
31
31
|
*/
|
|
32
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
33
32
|
import type { ChannelHistoryEntry, ChannelRetentionRule } from "@rebasepro/types";
|
|
33
|
+
import type { PgSqlDatabase } from "../interfaces.js";
|
|
34
34
|
/**
|
|
35
35
|
* Parse a retention TTL into milliseconds.
|
|
36
36
|
*
|
|
@@ -95,7 +95,7 @@ export declare class ChannelHistoryStore {
|
|
|
95
95
|
private lastPruned;
|
|
96
96
|
private nextPruneSweepAt;
|
|
97
97
|
private tablesReady;
|
|
98
|
-
constructor(db:
|
|
98
|
+
constructor(db: PgSqlDatabase<Record<string, unknown>>, rules?: ChannelRetentionRule[]);
|
|
99
99
|
/** Whether any channel retains anything at all. */
|
|
100
100
|
get enabled(): boolean;
|
|
101
101
|
/**
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
* is the one that announces the departures, so a stale client produces one
|
|
26
26
|
* `presence_diff` for the cluster rather than one per replica.
|
|
27
27
|
*/
|
|
28
|
-
import {
|
|
29
|
-
/** A tracked client, as
|
|
28
|
+
import type { PgSqlDatabase } from "../interfaces.js";
|
|
29
|
+
/** A tracked client, as every instance sees it. */
|
|
30
30
|
export interface PresenceRow {
|
|
31
31
|
channel: string;
|
|
32
32
|
clientId: string;
|
|
@@ -36,7 +36,7 @@ export declare class ChannelPresenceStore {
|
|
|
36
36
|
private readonly db;
|
|
37
37
|
private readonly instanceId;
|
|
38
38
|
private tablesReady;
|
|
39
|
-
constructor(db:
|
|
39
|
+
constructor(db: PgSqlDatabase<Record<string, unknown>>, instanceId: string);
|
|
40
40
|
/**
|
|
41
41
|
* Create the roster table. Idempotent, and safe to run on every instance at
|
|
42
42
|
* once.
|
|
@@ -3,7 +3,7 @@ import type { VectorSearchParams } from "@rebasepro/types";
|
|
|
3
3
|
import { FetchService } from "./FetchService.js";
|
|
4
4
|
import type { ReadCallContextProvider } from "./read-scope.js";
|
|
5
5
|
import type { WithDeleted } from "./soft-delete.js";
|
|
6
|
-
import { PersistService, type PersistSaveOptions } from "./PersistService.js";
|
|
6
|
+
import { PersistService, type ConflictRule, type PersistSaveOptions } from "./PersistService.js";
|
|
7
7
|
import { RelationService } from "./RelationService.js";
|
|
8
8
|
import { DataRepository, DrizzleClient } from "../interfaces.js";
|
|
9
9
|
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
@@ -119,10 +119,14 @@ export declare class DataService implements DataRepository {
|
|
|
119
119
|
* Save an row (create or update)
|
|
120
120
|
*/
|
|
121
121
|
save<M extends Record<string, unknown>>(collectionPath: string, values: Partial<M>, id?: string | number, databaseId?: string, options?: PersistSaveOptions): Promise<Record<string, unknown>>;
|
|
122
|
+
/** See {@link PersistService.saveUnlessKept}. */
|
|
123
|
+
saveUnlessKept<M extends Record<string, unknown>>(collectionPath: string, values: Partial<M>, id?: string | number, databaseId?: string, options?: PersistSaveOptions & ConflictRule): Promise<Record<string, unknown> | undefined>;
|
|
122
124
|
/**
|
|
123
125
|
* Delete an row by ID
|
|
124
126
|
*/
|
|
125
|
-
delete(collectionPath: string, id: string | number, databaseId?: string
|
|
127
|
+
delete(collectionPath: string, id: string | number, databaseId?: string, options?: {
|
|
128
|
+
commitsTransaction?: boolean;
|
|
129
|
+
}): Promise<void>;
|
|
126
130
|
/**
|
|
127
131
|
* Delete all rows from a collection
|
|
128
132
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { WebSocket } from "ws";
|
|
2
1
|
import { EventEmitter } from "events";
|
|
3
2
|
import { DataDriver, IncludeSpec, WebSocketMessage, LogicalCondition, OrderByTuple } from "@rebasepro/types";
|
|
4
|
-
import {
|
|
5
|
-
import { RealtimeProvider, CollectionSubscriptionConfig, SingleSubscriptionConfig } from "../interfaces.js";
|
|
3
|
+
import { RealtimeProvider, CollectionSubscriptionConfig, SingleSubscriptionConfig, type PgSqlDatabase } from "../interfaces.js";
|
|
6
4
|
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
7
5
|
import type { RequestIdentity } from "../security/rls-settings.js";
|
|
8
6
|
import type { CdcTableRef } from "./cdc/trigger-cdc.js";
|
|
@@ -229,6 +227,21 @@ export declare function parseRealtimeTuning(value: unknown, source: string, unit
|
|
|
229
227
|
* than quietly becoming no ceiling.
|
|
230
228
|
*/
|
|
231
229
|
export declare function parseMaxSocketsPerUser(value: unknown, source: string): number;
|
|
230
|
+
/**
|
|
231
|
+
* What the service uses of a client socket: its state, sending a frame, the
|
|
232
|
+
* close and error events, and the two ways of ending it. `ws`'s `WebSocket`
|
|
233
|
+
* satisfies it; so does any socket-shaped stand-in a caller hands over.
|
|
234
|
+
*/
|
|
235
|
+
export interface RealtimeClientSocket {
|
|
236
|
+
readonly readyState: number;
|
|
237
|
+
/** Bytes sent and not yet read: see `terminateIfBacklogged`. */
|
|
238
|
+
readonly bufferedAmount: number;
|
|
239
|
+
send(data: string): void;
|
|
240
|
+
on(event: "close", listener: () => void): unknown;
|
|
241
|
+
on(event: "error", listener: (error: Error) => void): unknown;
|
|
242
|
+
close(code?: number, reason?: string): void;
|
|
243
|
+
terminate(): void;
|
|
244
|
+
}
|
|
232
245
|
/**
|
|
233
246
|
* PostgreSQL-specific realtime service.
|
|
234
247
|
* Handles WebSocket connections and subscriptions for real-time row updates.
|
|
@@ -503,7 +516,7 @@ export declare class RealtimeService extends EventEmitter implements RealtimePro
|
|
|
503
516
|
* already arrived. An echo later than that costs one more refetch.
|
|
504
517
|
*/
|
|
505
518
|
private static readonly CDC_DEDUP_WINDOW_MS;
|
|
506
|
-
constructor(db:
|
|
519
|
+
constructor(db: PgSqlDatabase<any>, registry: PostgresCollectionRegistry);
|
|
507
520
|
/**
|
|
508
521
|
* Restricted role that auth-scoped refetches run as (via `SET LOCAL ROLE`)
|
|
509
522
|
* so RLS `select` policies bind. Set by the bootstrapper alongside
|
|
@@ -653,7 +666,7 @@ export declare class RealtimeService extends EventEmitter implements RealtimePro
|
|
|
653
666
|
* alone. A socket ends its own through the `unsubscribe` frame.
|
|
654
667
|
*/
|
|
655
668
|
unsubscribe(subscriptionId: string): void;
|
|
656
|
-
addClient(clientId: string, ws:
|
|
669
|
+
addClient(clientId: string, ws: RealtimeClientSocket): void;
|
|
657
670
|
handleClientMessage(clientId: string, message: WebSocketMessage, authContext?: SubscriptionAuthContext): Promise<void>;
|
|
658
671
|
/** Record what a socket opted into when it opened. See `socket-opt-ins.ts`. */
|
|
659
672
|
setClientOptIns(clientId: string, optIns: ReadonlySet<string>): void;
|
|
@@ -74,6 +74,11 @@ export declare function enforceProcessSendBudget(budget?: number): WebSocket[];
|
|
|
74
74
|
* not answer the previous ping. Returns the function that stops it.
|
|
75
75
|
*/
|
|
76
76
|
export declare function reapSilentSockets(wss: WebSocketServer, intervalMs?: number): () => void;
|
|
77
|
+
/** What {@link terminateIfBacklogged} reads of a socket; `ws`'s `WebSocket` satisfies it. */
|
|
78
|
+
export interface BackloggableSocket {
|
|
79
|
+
readonly bufferedAmount: number;
|
|
80
|
+
terminate(): void;
|
|
81
|
+
}
|
|
77
82
|
/**
|
|
78
83
|
* Terminate `ws` if its unsent backlog has passed {@link MAX_SOCKET_BUFFERED_BYTES}.
|
|
79
84
|
* Returns whether it did; the caller then sends nothing.
|
|
@@ -82,4 +87,4 @@ export declare function reapSilentSockets(wss: WebSocketServer, intervalMs?: num
|
|
|
82
87
|
* the process-wide budget is kept, summed at most every
|
|
83
88
|
* {@link PROCESS_BUDGET_CHECK_MS} — see {@link enforceProcessSendBudget}.
|
|
84
89
|
*/
|
|
85
|
-
export declare function terminateIfBacklogged(ws:
|
|
90
|
+
export declare function terminateIfBacklogged(ws: BackloggableSocket, clientId: string): boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type RebasePgTable = PgTable & Record<string, AnyPgColumn>;
|
|
|
14
14
|
* A concrete table does not satisfy it: its columns have specific types and it
|
|
15
15
|
* carries methods and symbols besides, so `Record<string, AnyPgColumn>` is not
|
|
16
16
|
* a supertype and a direct `as` is refused. Written out, that refusal was
|
|
17
|
-
* answered six times with
|
|
17
|
+
* answered six times with a double cast to `RebasePgTable`, which also discarded
|
|
18
18
|
* the check that the thing being converted is a table at all — the parameter
|
|
19
19
|
* below is what restores it.
|
|
20
20
|
*/
|
|
@@ -117,6 +117,11 @@ export interface FilterCompilationOptions {
|
|
|
117
117
|
type FilterTarget = {
|
|
118
118
|
kind: "column";
|
|
119
119
|
column: AnyPgColumn;
|
|
120
|
+
} | {
|
|
121
|
+
/** A text column folded to one case — `lower(artist)`. */
|
|
122
|
+
kind: "text";
|
|
123
|
+
/** The folded expression every operator compares. */
|
|
124
|
+
expression: SQL;
|
|
120
125
|
} | {
|
|
121
126
|
/** A path *inside* a json/jsonb column — `metadata->>country`. */
|
|
122
127
|
kind: "json";
|
|
@@ -305,6 +310,13 @@ export declare class DrizzleConditionBuilder {
|
|
|
305
310
|
* from a query string, and `->>` takes a text parameter perfectly well.
|
|
306
311
|
*/
|
|
307
312
|
private static buildJsonPathCondition;
|
|
313
|
+
/**
|
|
314
|
+
* A comparison against a text expression: a JSON path's leaf, or a column
|
|
315
|
+
* folded to one case. Values compare as text — booleans as `->>` renders
|
|
316
|
+
* them — and the membership operators compile to `= ANY` / `<> ALL` over
|
|
317
|
+
* one array parameter, so a list of any length is one bound value.
|
|
318
|
+
*/
|
|
319
|
+
private static buildTextCondition;
|
|
308
320
|
/**
|
|
309
321
|
* A filter on a relation that owns no column on this row — `EXISTS` over
|
|
310
322
|
* the rows it reaches.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw SQL with `$n` placeholders, as one drizzle statement that binds each
|
|
3
|
+
* parameter once.
|
|
4
|
+
*
|
|
5
|
+
* `rebase.sql(text, { params })` takes the text and parameters `pg` takes, and
|
|
6
|
+
* has to mean what `pg` means by them. It used to split the text on every
|
|
7
|
+
* `/\$(\d+)/` and bind each occurrence as a new parameter, which broke three
|
|
8
|
+
* ways:
|
|
9
|
+
*
|
|
10
|
+
* - A `$1` written N times became N bind parameters. Postgres infers each
|
|
11
|
+
* one's type alone, so an uncast reuse failed with `could not determine data
|
|
12
|
+
* type of parameter $7` where `pg` ran the same text, and the value was sent
|
|
13
|
+
* N times.
|
|
14
|
+
* - A `$1` inside a string literal, a quoted identifier, a comment or a
|
|
15
|
+
* dollar-quoted body was bound as a parameter, changing the statement.
|
|
16
|
+
* - `a$1`, an identifier Postgres allows, was split in two.
|
|
17
|
+
*
|
|
18
|
+
* So the text is scanned the way Postgres's lexer reads it, and only a
|
|
19
|
+
* placeholder outside those spans is a parameter. The first occurrence of
|
|
20
|
+
* each `$n` becomes a `sql.param`; drizzle numbers params in the order they
|
|
21
|
+
* appear, so a later occurrence is written as the number drizzle gave the
|
|
22
|
+
* first. Each value is sent once, and every occurrence is the same parameter.
|
|
23
|
+
*/
|
|
24
|
+
import { type SQL } from "drizzle-orm";
|
|
25
|
+
/** One piece of the statement: SQL text, or a reference to parameter `n` (1-based). */
|
|
26
|
+
export type SqlPiece = {
|
|
27
|
+
text: string;
|
|
28
|
+
} | {
|
|
29
|
+
param: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Split `text` into SQL text and `$n` placeholders, leaving string literals,
|
|
33
|
+
* quoted identifiers, comments and dollar-quoted bodies whole.
|
|
34
|
+
*/
|
|
35
|
+
export declare function splitPlaceholders(text: string): SqlPiece[];
|
|
36
|
+
/**
|
|
37
|
+
* `text` and `params` as one drizzle statement: each `$n` bound once, however
|
|
38
|
+
* often it appears, and nothing inside a literal, identifier or comment bound.
|
|
39
|
+
*/
|
|
40
|
+
export declare function positionalStatement(text: string, params?: readonly unknown[]): SQL;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { i as __exportAll } from "./cli-prompt-DXG0yk-h.js";
|
|
4
|
-
import { A as budgetSendBuffers, M as terminateIfBacklogged, N as assertReadRequestReadable, ct as SqlResultTooLargeError, it as effectiveSqlRole, j as reapSilentSockets, lt as isNestedPath, ot as sqlRoleRanAs, st as SQL_RESULT_BYTE_BUDGET, ut as resolveNestedPath } from "./open-rebase-
|
|
5
|
-
import { r as BranchingUnsupportedError } from "./BranchService-
|
|
4
|
+
import { A as budgetSendBuffers, M as terminateIfBacklogged, N as assertReadRequestReadable, ct as SqlResultTooLargeError, it as effectiveSqlRole, j as reapSilentSockets, lt as isNestedPath, ot as sqlRoleRanAs, st as SQL_RESULT_BYTE_BUDGET, ut as resolveNestedPath } from "./open-rebase-40paQfVW.js";
|
|
5
|
+
import { r as BranchingUnsupportedError } from "./BranchService-CrXvcES2.js";
|
|
6
6
|
import { ApiError, DATABASE_UNAVAILABLE_MESSAGE, RUNTIME_DEFAULT_MAX_BODY_SIZE, assertFieldOpsValid, assertNestedWriteAllowed, assertNoFieldOpsOnCreate, assertNoUserUpsert, assertUserCreationBodyValid, assertWriteRequestValid, createUserThroughAuthCollection, decideImpersonation, declaredErrorAnswer, extractUserFromToken, getAccessModel, isDatabaseUnreachable, logger, resolveConflictTarget, resolveRequireAuth, safeCompare } from "@rebasepro/server";
|
|
7
7
|
import { ANONYMOUS_USER_ID, ListLimitError, hasAdminRole, isSQLAdmin, isSchemaAdmin, resolveClientListLimit, scopeGrants, scopesForRoles } from "@rebasepro/types";
|
|
8
8
|
import { UnknownFilterOperatorError, deserializeFilter, redactSqlLiterals } from "@rebasepro/common";
|
|
@@ -1698,4 +1698,4 @@ function createPostgresWebSocket(server, realtimeService, driver, authConfig, au
|
|
|
1698
1698
|
//#endregion
|
|
1699
1699
|
export { createPostgresWebSocket as a, websocket_exports as c, TOO_MANY_SOCKETS_CLOSE_CODE as i, PUBLIC_TYPES as n, isSocketRealtimeService as o, SESSION_ENDED_CLOSE_CODE as r, socketRealtimeMissing as s, ADMIN_PLANE_TYPES as t };
|
|
1700
1700
|
|
|
1701
|
-
//# sourceMappingURL=websocket-
|
|
1701
|
+
//# sourceMappingURL=websocket-B7ex6AQM.js.map
|