@rebasepro/server-postgres 0.23.0 → 0.24.1-canary.g56af4a4
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-DGPL6G_C.js → BranchService-Bsn2wfaj.js} +36 -18
- package/dist/BranchService-Bsn2wfaj.js.map +1 -0
- package/dist/PostgresBackendDriver.d.ts +166 -13
- package/dist/auth/ensure-tables.d.ts +12 -0
- package/dist/auth/services.d.ts +78 -14
- package/dist/{auth-users-columns-D2LBFrMH.js → auth-users-columns-C72EMoDJ.js} +17 -1
- package/dist/{auth-users-columns-D2LBFrMH.js.map → auth-users-columns-C72EMoDJ.js.map} +1 -1
- package/dist/backup/backup-cli.d.ts +14 -0
- package/dist/backup/backup-service.d.ts +2 -2
- package/dist/backup/pg-binary.d.ts +5 -0
- package/dist/{backup-cli-24v4OlSp.js → backup-cli-aUfRv16h.js} +37 -29
- package/dist/backup-cli-aUfRv16h.js.map +1 -0
- package/dist/{backup-service-HQ9GC4tN.js → backup-service-BTBB7RXn.js} +60 -28
- package/dist/backup-service-BTBB7RXn.js.map +1 -0
- package/dist/boot-ddl-DVpsFN6r.js +105 -0
- package/dist/boot-ddl-DVpsFN6r.js.map +1 -0
- package/dist/cli-errors-CaI4ntyD.js +1919 -0
- package/dist/cli-errors-CaI4ntyD.js.map +1 -0
- package/dist/cli-errors.d.ts +93 -5
- package/dist/{cli-flags-BglvpjHv.js → cli-flags-B-Dawocl.js} +5 -2
- package/dist/cli-flags-B-Dawocl.js.map +1 -0
- package/dist/cli-helpers.d.ts +52 -12
- package/dist/cli-output.d.ts +16 -28
- package/dist/cli-push.d.ts +87 -0
- package/dist/cli.js +625 -190
- package/dist/cli.js.map +1 -1
- package/dist/{column-plan-helpers-DF-8dTVa.js → column-plan-helpers-drZIsSNf.js} +42 -26
- package/dist/column-plan-helpers-drZIsSNf.js.map +1 -0
- package/dist/{databasePoolManager-Bj5FbeAs.js → connection-BPoNILnD.js} +19 -110
- package/dist/connection-BPoNILnD.js.map +1 -0
- package/dist/connection.d.ts +9 -1
- package/dist/data-transformer.d.ts +0 -8
- package/dist/databasePoolManager-BkEy2w18.js +119 -0
- package/dist/databasePoolManager-BkEy2w18.js.map +1 -0
- package/dist/deferred-index-build-DP1_SNFo.js +1051 -0
- package/dist/deferred-index-build-DP1_SNFo.js.map +1 -0
- package/dist/{doctor-Cb2thZ8s.js → doctor-C4WiftHm.js} +279 -87
- package/dist/doctor-C4WiftHm.js.map +1 -0
- package/dist/ensure-collection-policies-CXpbeNag.js +541 -0
- package/dist/ensure-collection-policies-CXpbeNag.js.map +1 -0
- package/dist/ensure-collection-tables-BhsU6qUE.js +532 -0
- package/dist/ensure-collection-tables-BhsU6qUE.js.map +1 -0
- package/dist/{ensure-tables-Dhn9KM3B.js → ensure-tables-CHsgyLqg.js} +178 -75
- package/dist/ensure-tables-CHsgyLqg.js.map +1 -0
- package/dist/enum-labels-kept-D8fI1MoX.js +56 -0
- package/dist/enum-labels-kept-D8fI1MoX.js.map +1 -0
- package/dist/generate-drizzle-schema-Bz52jH2h.js +57 -0
- package/dist/generate-drizzle-schema-Bz52jH2h.js.map +1 -0
- package/dist/{generate-drizzle-schema-logic-BfzK7UQd.js → generate-drizzle-schema-logic-B74WN37S.js} +28 -10
- package/dist/generate-drizzle-schema-logic-B74WN37S.js.map +1 -0
- package/dist/generate-files-CdEckX6c.js +199 -0
- package/dist/generate-files-CdEckX6c.js.map +1 -0
- package/dist/generate-postgres-ddl-logic-B64O2oZF.js +152 -0
- package/dist/generate-postgres-ddl-logic-B64O2oZF.js.map +1 -0
- package/dist/generated-sql.d.ts +34 -0
- package/dist/history/HistoryService.d.ts +38 -6
- package/dist/history/ensure-history-table.d.ts +42 -4
- package/dist/index.es.js +5557 -7612
- package/dist/index.es.js.map +1 -1
- package/dist/{introspect-db-logic-WMuAfxvw.js → introspect-db-logic-C-Di8dA9.js} +562 -350
- package/dist/introspect-db-logic-C-Di8dA9.js.map +1 -0
- package/dist/introspect-db-queries-D6kAqReI.js +339 -0
- package/dist/introspect-db-queries-D6kAqReI.js.map +1 -0
- package/dist/pg-error-utils-vJezlXdI.js +388 -0
- package/dist/pg-error-utils-vJezlXdI.js.map +1 -0
- package/dist/{plan-schema-C0fxM8dY.js → plan-schema-B1YF_tYq.js} +278 -533
- package/dist/plan-schema-B1YF_tYq.js.map +1 -0
- package/dist/{policy-drift-DljYdrpW.js → policy-drift-Dm8i-s1J.js} +24 -7
- package/dist/policy-drift-Dm8i-s1J.js.map +1 -0
- package/dist/push-index-prebuild-Db4AQF4i.js +45 -0
- package/dist/push-index-prebuild-Db4AQF4i.js.map +1 -0
- package/dist/push-legacy-renames-BK6ilQq2.js +34 -0
- package/dist/push-legacy-renames-BK6ilQq2.js.map +1 -0
- package/dist/{generate-postgres-ddl-logic-Bt2d2mRH.js → render-ddl-CtC3y9Ol.js} +17 -151
- package/dist/render-ddl-CtC3y9Ol.js.map +1 -0
- package/dist/{rls-bootstrap-sql-B8EclDyM.js → rls-bootstrap-sql-RQUljnJ1.js} +125 -1046
- package/dist/rls-bootstrap-sql-RQUljnJ1.js.map +1 -0
- package/dist/{rls-enforcement-C6Xk0lA6.js → rls-enforcement-DvzqlaL1.js} +137 -17
- package/dist/rls-enforcement-DvzqlaL1.js.map +1 -0
- package/dist/schema/auth-schema.d.ts +172 -2
- package/dist/schema/boot-ddl.d.ts +47 -0
- package/dist/schema/classify-change.d.ts +29 -1
- package/dist/schema/collection-index.d.ts +45 -0
- package/dist/schema/column-plan-helpers.d.ts +38 -21
- package/dist/schema/deferred-index-build.d.ts +131 -0
- package/dist/schema/destructive-sql.d.ts +27 -1
- package/dist/schema/doctor-cli.js +110 -6
- package/dist/schema/doctor-cli.js.map +1 -1
- package/dist/schema/doctor-search-scale.d.ts +45 -0
- package/dist/schema/doctor.d.ts +53 -1
- package/dist/schema/ensure-collection-policies.d.ts +95 -35
- package/dist/schema/ensure-collection-tables.d.ts +56 -3
- package/dist/schema/enum-labels-kept.d.ts +26 -0
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-files.d.ts +44 -0
- package/dist/schema/generate-next-step.d.ts +0 -13
- package/dist/schema/generate-postgres-ddl-logic.d.ts +5 -5
- package/dist/schema/generate-postgres-ddl.js +10 -81
- package/dist/schema/generate-postgres-ddl.js.map +1 -1
- package/dist/schema/generate-schema-commit.d.ts +12 -0
- package/dist/schema/introspect-db-logic.d.ts +43 -0
- package/dist/schema/introspect-db-queries.d.ts +12 -2
- package/dist/schema/introspect-db-search.d.ts +22 -0
- package/dist/schema/introspect-db-storage.d.ts +83 -0
- package/dist/schema/introspect-db-structure.d.ts +10 -0
- package/dist/schema/introspect-db.js +17 -6
- package/dist/schema/introspect-db.js.map +1 -1
- package/dist/schema/migration-post-process.d.ts +34 -0
- package/dist/schema/plan/diff-plan.d.ts +127 -1
- package/dist/schema/plan/plan-schema.d.ts +16 -8
- package/dist/schema/plan/render-ddl.d.ts +6 -0
- package/dist/schema/plan/types.d.ts +45 -11
- package/dist/schema/push-index-prebuild.d.ts +25 -0
- package/dist/schema/push-legacy-renames.d.ts +20 -0
- package/dist/schema/rls-bootstrap-sql.d.ts +15 -0
- package/dist/search-column-BM-GV6vH.js +442 -0
- package/dist/search-column-BM-GV6vH.js.map +1 -0
- package/dist/security/policy-drift.d.ts +1 -1
- package/dist/security/rls-enforcement.d.ts +39 -4
- package/dist/services/BranchService.d.ts +22 -1
- package/dist/services/FetchService.d.ts +63 -12
- package/dist/services/PersistService.d.ts +15 -0
- package/dist/services/RelationService.d.ts +106 -3
- package/dist/services/cdc/CdcListener.d.ts +26 -10
- package/dist/services/cdc/identity-columns.d.ts +19 -0
- package/dist/services/cdc/trigger-cdc.d.ts +180 -18
- package/dist/services/channel-bus/PostgresChannelBus.d.ts +12 -7
- package/dist/services/channel-history.d.ts +32 -5
- package/dist/services/collection-helpers.d.ts +26 -1
- package/dist/services/field-viewer.d.ts +15 -1
- package/dist/services/pg-notify-listener.d.ts +95 -6
- package/dist/services/realtimeService.d.ts +467 -53
- package/dist/services/row-pipeline.d.ts +16 -9
- package/dist/services/socket-liveness.d.ts +85 -0
- package/dist/services/soft-delete.d.ts +12 -0
- package/dist/services/sql-script.d.ts +275 -0
- package/dist/services/vector-iterative-scan.d.ts +40 -0
- package/dist/services/write-depth.d.ts +22 -0
- package/dist/services/write-transaction-scope.d.ts +15 -3
- package/dist/socket-liveness-D3UD5_BW.js +7570 -0
- package/dist/socket-liveness-D3UD5_BW.js.map +1 -0
- package/dist/socket-opt-ins.d.ts +64 -0
- package/dist/source-DBDbBTL4.js +811 -0
- package/dist/source-DBDbBTL4.js.map +1 -0
- package/dist/tsx-loader.d.ts +14 -0
- package/dist/utils/drizzle-conditions.d.ts +63 -3
- package/dist/utils/error-cause.d.ts +7 -0
- package/dist/utils/pg-error-utils.d.ts +2 -4
- package/dist/utils/result-rows.d.ts +10 -0
- package/dist/websocket.d.ts +63 -18
- package/package.json +7 -7
- package/dist/BranchService-DGPL6G_C.js.map +0 -1
- package/dist/backup-cli-24v4OlSp.js.map +0 -1
- package/dist/backup-service-HQ9GC4tN.js.map +0 -1
- package/dist/cli-errors-B8qHg02P.js +0 -798
- package/dist/cli-errors-B8qHg02P.js.map +0 -1
- package/dist/cli-flags-BglvpjHv.js.map +0 -1
- package/dist/cli-output-CNdMql-L.js +0 -47
- package/dist/cli-output-CNdMql-L.js.map +0 -1
- package/dist/collection-index-DdnsxiJ_.js +0 -286
- package/dist/collection-index-DdnsxiJ_.js.map +0 -1
- package/dist/column-plan-helpers-DF-8dTVa.js.map +0 -1
- package/dist/databasePoolManager-Bj5FbeAs.js.map +0 -1
- package/dist/doctor-Cb2thZ8s.js.map +0 -1
- package/dist/ensure-collection-policies-RHUcEp4v.js +0 -105
- package/dist/ensure-collection-policies-RHUcEp4v.js.map +0 -1
- package/dist/ensure-collection-tables-BEEjn5cn.js +0 -857
- package/dist/ensure-collection-tables-BEEjn5cn.js.map +0 -1
- package/dist/ensure-tables-Dhn9KM3B.js.map +0 -1
- package/dist/generate-drizzle-schema-logic-BfzK7UQd.js.map +0 -1
- package/dist/generate-drizzle-schema-yzY_BLhr.js +0 -123
- package/dist/generate-drizzle-schema-yzY_BLhr.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-Bt2d2mRH.js.map +0 -1
- package/dist/introspect-db-logic-WMuAfxvw.js.map +0 -1
- package/dist/plan-schema-C0fxM8dY.js.map +0 -1
- package/dist/policy-drift-DljYdrpW.js.map +0 -1
- package/dist/rls-bootstrap-sql-B8EclDyM.js.map +0 -1
- package/dist/rls-enforcement-C6Xk0lA6.js.map +0 -1
- package/dist/source-Br7L7GOI.js +0 -410
- package/dist/source-Br7L7GOI.js.map +0 -1
package/dist/cli-helpers.d.ts
CHANGED
|
@@ -84,6 +84,45 @@ export declare function resolveLocalBin(binName: string): string | null;
|
|
|
84
84
|
export declare function getTableIncludesFromCollections(allCollections: CollectionConfig[]): Promise<string[]>;
|
|
85
85
|
export declare function getTableIncludes(collectionsPath: string): Promise<string[]>;
|
|
86
86
|
export declare function loadCollectionsForCli(collectionsPath: string): Promise<CollectionConfig[]>;
|
|
87
|
+
type PgClient = import("pg").Client;
|
|
88
|
+
/**
|
|
89
|
+
* Run one step on this process's connection to the app database.
|
|
90
|
+
*
|
|
91
|
+
* Every step leaves the session as it found it, which is what a connection of
|
|
92
|
+
* its own used to guarantee by being closed. None of them sets anything for
|
|
93
|
+
* the session — `SET LOCAL` inside their own transaction, or `RESET` — and one
|
|
94
|
+
* that fails part-way through a transaction it opened is rolled back here, so
|
|
95
|
+
* the next step does not meet `current transaction is aborted`.
|
|
96
|
+
*
|
|
97
|
+
* @param options.connectionTimeoutMillis applies only when this call is the one
|
|
98
|
+
* that connects.
|
|
99
|
+
*/
|
|
100
|
+
export declare function withAppClient<T>(databaseUrl: string, step: (client: PgClient) => Promise<T>, options?: {
|
|
101
|
+
connectionTimeoutMillis?: number;
|
|
102
|
+
}): Promise<T>;
|
|
103
|
+
/** Close every connection {@link withAppClient} opened. Called once, as the command ends. */
|
|
104
|
+
export declare function closeAppClients(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Names the empty database Atlas plans against, instead of `<db>_dev_diff`.
|
|
107
|
+
*
|
|
108
|
+
* The derived one is made with `CREATE DATABASE` beside the real database,
|
|
109
|
+
* which assumes a server that holds more than one. PGlite — the managed
|
|
110
|
+
* development database — serves exactly one: the CREATE succeeds and creates
|
|
111
|
+
* nothing, so Atlas connected straight back to the database it was comparing
|
|
112
|
+
* and refused it as "not clean". `rebase db push` on the managed database now
|
|
113
|
+
* starts a second, throwaway PGlite and names it here. Anyone can name their
|
|
114
|
+
* own the same way; a named database is neither created nor dropped.
|
|
115
|
+
*/
|
|
116
|
+
export declare const ATLAS_DEV_URL_ENV = "REBASE_ATLAS_DEV_URL";
|
|
117
|
+
/**
|
|
118
|
+
* The database Atlas replays the desired schema into: the one
|
|
119
|
+
* {@link ATLAS_DEV_URL_ENV} names (`named: true` — not ours to create or
|
|
120
|
+
* drop), else `<db>_dev_diff`.
|
|
121
|
+
*/
|
|
122
|
+
export declare function atlasDevDatabaseUrl(databaseUrl: string, env: Readonly<Record<string, string | undefined>>): {
|
|
123
|
+
url: string;
|
|
124
|
+
named: boolean;
|
|
125
|
+
};
|
|
87
126
|
export declare function getDevDatabaseUrl(databaseUrl: string): string;
|
|
88
127
|
/**
|
|
89
128
|
* Create the scratch database Atlas plans against, and say so when we cannot.
|
|
@@ -127,10 +166,10 @@ export declare function dropDevDatabase(databaseUrl: string, devDatabaseUrl: str
|
|
|
127
166
|
/**
|
|
128
167
|
* The generated SQL for the project's `search` blocks, if it has any.
|
|
129
168
|
*
|
|
130
|
-
* @param
|
|
131
|
-
* under the working directory.
|
|
169
|
+
* @param sqlDir directory holding the generated SQL. Defaults to
|
|
170
|
+
* `.rebase/sql` under the working directory.
|
|
132
171
|
*/
|
|
133
|
-
export declare function readSearchDdl(
|
|
172
|
+
export declare function readSearchDdl(sqlDir?: string): string;
|
|
134
173
|
/**
|
|
135
174
|
* Bring the search column, its index and their helpers up to date.
|
|
136
175
|
*
|
|
@@ -144,7 +183,7 @@ export declare function readSearchDdl(drizzleDir?: string): string;
|
|
|
144
183
|
* silently pushing a schema whose search column never appeared is how a
|
|
145
184
|
* collection ends up with search configured, no error anywhere, and no results.
|
|
146
185
|
*/
|
|
147
|
-
export declare function applySearchDdl(databaseUrl: string,
|
|
186
|
+
export declare function applySearchDdl(databaseUrl: string, sqlDir?: string): Promise<void>;
|
|
148
187
|
/**
|
|
149
188
|
* Glob patterns keeping Atlas away from the search objects.
|
|
150
189
|
*
|
|
@@ -181,10 +220,10 @@ export declare function dropGeneratedColumns(databaseUrl: string, statements: st
|
|
|
181
220
|
/**
|
|
182
221
|
* The generated SQL for the project's `vector` properties, if it has any.
|
|
183
222
|
*
|
|
184
|
-
* @param
|
|
185
|
-
* under the working directory.
|
|
223
|
+
* @param sqlDir directory holding the generated SQL. Defaults to
|
|
224
|
+
* `.rebase/sql` under the working directory.
|
|
186
225
|
*/
|
|
187
|
-
export declare function readVectorDdl(
|
|
226
|
+
export declare function readVectorDdl(sqlDir?: string): string;
|
|
188
227
|
/**
|
|
189
228
|
* Install pgvector and bring the vector columns and their ANN indexes up to
|
|
190
229
|
* date.
|
|
@@ -200,7 +239,7 @@ export declare function readVectorDdl(drizzleDir?: string): string;
|
|
|
200
239
|
* appeared is how a project ends up with vector search configured, no error
|
|
201
240
|
* anywhere, and no results.
|
|
202
241
|
*/
|
|
203
|
-
export declare function applyVectorDdl(databaseUrl: string,
|
|
242
|
+
export declare function applyVectorDdl(databaseUrl: string, sqlDir?: string): Promise<void>;
|
|
204
243
|
/**
|
|
205
244
|
* Glob patterns keeping Atlas away from the vector objects.
|
|
206
245
|
*
|
|
@@ -212,10 +251,10 @@ export declare function getVectorExcludes(collectionsPath: string): Promise<stri
|
|
|
212
251
|
* The generated SQL for the project's `autoValue: "on_update"` properties, if
|
|
213
252
|
* it has any.
|
|
214
253
|
*
|
|
215
|
-
* @param
|
|
216
|
-
* under the working directory.
|
|
254
|
+
* @param sqlDir directory holding the generated SQL. Defaults to
|
|
255
|
+
* `.rebase/sql` under the working directory.
|
|
217
256
|
*/
|
|
218
|
-
export declare function readTriggersDdl(
|
|
257
|
+
export declare function readTriggersDdl(sqlDir?: string): string;
|
|
219
258
|
/**
|
|
220
259
|
* Install the `updated_at` trigger function and bind it to every column that
|
|
221
260
|
* asked for one.
|
|
@@ -230,7 +269,7 @@ export declare function readTriggersDdl(drizzleDir?: string): string;
|
|
|
230
269
|
* appeared is how `updated_at` ends up silently stale for every writer that is
|
|
231
270
|
* not the driver, which is the whole reason the trigger exists.
|
|
232
271
|
*/
|
|
233
|
-
export declare function applyTriggersDdl(databaseUrl: string,
|
|
272
|
+
export declare function applyTriggersDdl(databaseUrl: string, sqlDir?: string): Promise<void>;
|
|
234
273
|
/** @see getSearchExcludes */
|
|
235
274
|
export declare function getTriggerExcludes(collectionsPath: string): Promise<string[]>;
|
|
236
275
|
/**
|
|
@@ -322,3 +361,4 @@ export declare function getTableExcludes(databaseUrl: string, collectionsPath: s
|
|
|
322
361
|
* `import.meta` and cannot be imported by the jest runner.
|
|
323
362
|
*/
|
|
324
363
|
export declare function promptConfirm(question: string): Promise<boolean>;
|
|
364
|
+
export {};
|
package/dist/cli-output.d.ts
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal output for the `rebase db|schema|doctor` commands.
|
|
3
|
-
*
|
|
4
|
-
* These commands used to write every line through `logger`, and that is a
|
|
5
|
-
* category error with three separate consequences:
|
|
6
|
-
*
|
|
7
|
-
* - `logger` prefixes each line with its own level, so a box-drawn report
|
|
8
|
-
* arrived as `ℹ️ [INFO] ┌─ ✗ Missing Column ───` and the frame no longer
|
|
9
|
-
* lined up with anything;
|
|
10
|
-
* - `logger` is gated by `LOG_LEVEL`, which ships in the scaffold's own
|
|
11
|
-
* `.env.example` — a developer who quietened their dev server with
|
|
12
|
-
* `LOG_LEVEL=warn` got a `rebase db push` that printed almost nothing and
|
|
13
|
-
* still exited non-zero, indistinguishable from a crash;
|
|
14
|
-
* - under `NODE_ENV=production` `logger` emits JSON, so the whole report
|
|
15
|
-
* became log records with the chalk escape codes embedded in them.
|
|
16
|
-
*
|
|
17
|
-
* A CLI's report *is* its return value. It goes to the terminal unconditionally
|
|
18
|
-
* and unadorned. `packages/cli` has always written its output this way; this is
|
|
19
|
-
* the same three functions for the plugin CLI that `rebase` delegates to.
|
|
20
|
-
*
|
|
21
|
-
* `logger` still belongs in this package's *runtime* — a request handler has no
|
|
22
|
-
* terminal and its lines want levels, timestamps and redaction. The rule is the
|
|
23
|
-
* caller, not the severity: anything a developer reads because they typed a
|
|
24
|
-
* command goes here, anything a server emits while running goes to `logger`.
|
|
25
|
-
*
|
|
26
|
-
* Errors and warnings go to stderr so `rebase db push > plan.txt` keeps the
|
|
27
|
-
* diagnosis on the terminal where it is readable.
|
|
28
|
-
*/
|
|
29
1
|
/** One line of human-facing output on stdout. */
|
|
30
2
|
export declare const out: (line?: string) => void;
|
|
31
3
|
/** One line of human-facing warning output on stderr. */
|
|
32
4
|
export declare const outWarn: (line?: string) => void;
|
|
33
5
|
/** One line of human-facing error output on stderr. */
|
|
34
6
|
export declare const outError: (line?: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a failure should be printed with its stack — `rebase --debug`, which
|
|
9
|
+
* the launcher passes down as `REBASE_DEBUG`, or `REBASE_DEBUG` set by hand.
|
|
10
|
+
*/
|
|
11
|
+
export declare const wantsStack: () => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* An error as a person reads it: its message, and its stack only under
|
|
14
|
+
* `--debug`.
|
|
15
|
+
*
|
|
16
|
+
* The rule `rebase` itself follows (`bin/rebase.js`). These commands run in a
|
|
17
|
+
* child process the launcher's handler never sees, so a syntax error in a
|
|
18
|
+
* collection file reached the terminal as `Doctor failed CollectionConfigError:`
|
|
19
|
+
* followed by twenty frames of loader internals, under a sentence that already
|
|
20
|
+
* said which file and which line.
|
|
21
|
+
*/
|
|
22
|
+
export declare const describeFailure: (error: unknown) => string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The steps `rebase db push` takes once the dry-run has been read and gated.
|
|
3
|
+
*
|
|
4
|
+
* Callbacks rather than calls, so the order is testable without a database or
|
|
5
|
+
* an Atlas binary: `cli.ts` itself cannot be loaded by the jest suite.
|
|
6
|
+
*/
|
|
7
|
+
export interface PushApplySteps {
|
|
8
|
+
/** Drop the generated columns that read a column the plan retypes. */
|
|
9
|
+
dropRebuildable: () => Promise<void>;
|
|
10
|
+
/** `atlas schema apply --auto-approve`: Atlas plans again, then applies. */
|
|
11
|
+
atlasApply: () => Promise<void>;
|
|
12
|
+
/** Say what the skipped apply would have printed. */
|
|
13
|
+
reportSynced: () => void;
|
|
14
|
+
/** Put those generated columns back after a failed apply. */
|
|
15
|
+
rebuildAfterFailure: () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Everything Atlas cannot see: RLS locks, auth tables, vector, search,
|
|
18
|
+
* triggers, policies, the user role. Runs whether or not Atlas had work.
|
|
19
|
+
*/
|
|
20
|
+
afterApply: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Apply a planned push.
|
|
24
|
+
*
|
|
25
|
+
* A dry-run that answered "Schema is synced" skips the second Atlas run: that
|
|
26
|
+
* run would plan the same diff again (≈0.9 s at 111 tables, 5.5 s at 411 —
|
|
27
|
+
* Atlas's cost grows faster than the table count) and then apply nothing. The
|
|
28
|
+
* steps after it still run, because Atlas cannot see what they own. A plan with
|
|
29
|
+
* anything in it keeps the old flow, including Atlas re-planning at apply time.
|
|
30
|
+
*
|
|
31
|
+
* @returns `"synced"` when Atlas was not run again, `"applied"` otherwise.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyPushPlan(plan: {
|
|
34
|
+
dryRun: string;
|
|
35
|
+
rebuildable: number;
|
|
36
|
+
}, steps: PushApplySteps): Promise<"applied" | "synced">;
|
|
37
|
+
/** The one call {@link applyPoliciesFile} needs from a connection. */
|
|
38
|
+
export interface PolicyConnection {
|
|
39
|
+
query(text: string): Promise<unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** What {@link applyPoliciesFile} stamps, and how to read the definitions back. */
|
|
42
|
+
export interface PolicyStamping {
|
|
43
|
+
/**
|
|
44
|
+
* `policyStampSql` of every table whose policies `policies.sql` creates
|
|
45
|
+
* exactly as the boot would — see {@link stampableTables}.
|
|
46
|
+
*/
|
|
47
|
+
statements: string[];
|
|
48
|
+
/**
|
|
49
|
+
* The `search_path` a boot reads policies under, when the connection's own
|
|
50
|
+
* differs. A stamp hashes `pg_get_expr`, which spells a function on the
|
|
51
|
+
* path unqualified: read under `"$user", public` with a `rebase` role, the
|
|
52
|
+
* boot's `rebase.uid()` prints as `uid()` and no stamp would ever match.
|
|
53
|
+
*/
|
|
54
|
+
searchPath?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The tables whose stamp `db push` may write: those every one of whose planned
|
|
58
|
+
* statements `policies.sql` carries, verbatim.
|
|
59
|
+
*
|
|
60
|
+
* A stamp says "this stored definition is what the plan's statement made". It
|
|
61
|
+
* is only true of a policy the statement *did* make — and since both are
|
|
62
|
+
* rendered by the same function from the same collections, a table whose
|
|
63
|
+
* statements are all in the file is one whose policies the file just created.
|
|
64
|
+
* Anything else (a hand-edited file, a file generated elsewhere) is not
|
|
65
|
+
* stamped, and the next boot re-applies that table, as before.
|
|
66
|
+
*/
|
|
67
|
+
export declare function stampableTables<T extends {
|
|
68
|
+
policyStatements: string[];
|
|
69
|
+
}>(plans: readonly T[], policiesSql: string): T[];
|
|
70
|
+
/**
|
|
71
|
+
* Run `policies.sql`, then stamp the policies it created the way a boot does,
|
|
72
|
+
* in the same transaction.
|
|
73
|
+
*
|
|
74
|
+
* Before stamps the push's policies carried none, so the first boot after
|
|
75
|
+
* every push re-applied them all — a DROP and a CREATE per policy, an ACCESS
|
|
76
|
+
* EXCLUSIVE lock per table. Stamped here, that boot finds them current.
|
|
77
|
+
*
|
|
78
|
+
* The file runs in one transaction, as it did as one implicit one: a policy
|
|
79
|
+
* that fails leaves the previous ones in place. The stamps run after it, under
|
|
80
|
+
* a savepoint: a stamp that cannot be written costs the next boot a re-apply,
|
|
81
|
+
* which is what it did before, so it is reported and the policies are kept.
|
|
82
|
+
* Nothing is left set on the connection: `SET LOCAL` ends with the transaction.
|
|
83
|
+
*/
|
|
84
|
+
export declare function applyPoliciesFile(client: PolicyConnection, policiesSql: string, stamping: PolicyStamping): Promise<{
|
|
85
|
+
stamped: number;
|
|
86
|
+
stampError?: string;
|
|
87
|
+
}>;
|