@rebasepro/server-postgres 0.25.0 → 0.25.1
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-iXXZeVYD.js → BranchService-ClklxyAQ.js} +66 -6
- package/dist/BranchService-ClklxyAQ.js.map +1 -0
- package/dist/backup/backup-cli.d.ts +40 -3
- package/dist/backup/backup-service.d.ts +11 -0
- package/dist/{backup-service-Bb39plam.js → backup-cli-gijeXe0u.js} +777 -10
- package/dist/backup-cli-gijeXe0u.js.map +1 -0
- package/dist/{boot-ddl-s_3Hkz94.js → boot-ddl-DYH95Qeg.js} +3 -3
- package/dist/{boot-ddl-s_3Hkz94.js.map → boot-ddl-DYH95Qeg.js.map} +1 -1
- package/dist/branch-argv.d.ts +15 -0
- package/dist/{cli-console-DQ_K-sdM.js → cli-console-CQrQ0lAY.js} +8 -9
- package/dist/{cli-console-DQ_K-sdM.js.map → cli-console-CQrQ0lAY.js.map} +1 -1
- package/dist/{cli-errors-DwQnNATs.js → cli-errors-DiA0XFIS.js} +38 -10
- package/dist/{cli-errors-DwQnNATs.js.map → cli-errors-DiA0XFIS.js.map} +1 -1
- package/dist/cli-errors.d.ts +14 -0
- package/dist/cli-flags.d.ts +51 -0
- package/dist/{cli-prompt-egtNKkZl.js → cli-prompt-DXG0yk-h.js} +39 -4
- package/dist/{cli-prompt-egtNKkZl.js.map → cli-prompt-DXG0yk-h.js.map} +1 -1
- package/dist/cli.js +44 -174
- package/dist/cli.js.map +1 -1
- package/dist/{column-plan-helpers-D_V4oaZh.js → column-plan-helpers-IG6uFb1s.js} +2 -2
- package/dist/{column-plan-helpers-D_V4oaZh.js.map → column-plan-helpers-IG6uFb1s.js.map} +1 -1
- package/dist/{connection-C938nR3E.js → connection-czvI7TZL.js} +57 -10
- package/dist/connection-czvI7TZL.js.map +1 -0
- package/dist/{databasePoolManager-Yqdw14wY.js → databasePoolManager-3stMNFL-.js} +4 -6
- package/dist/databasePoolManager-3stMNFL-.js.map +1 -0
- package/dist/db-command-line.d.ts +14 -0
- package/dist/{rls-bootstrap-sql-Bd-hJk08.js → db-subcommands-BPoHCxJR.js} +455 -3
- package/dist/db-subcommands-BPoHCxJR.js.map +1 -0
- package/dist/db-subcommands.d.ts +11 -0
- package/dist/{deferred-index-build-Cis_HoGn.js → deferred-index-build-BE0I6sYU.js} +8 -8
- package/dist/{deferred-index-build-Cis_HoGn.js.map → deferred-index-build-BE0I6sYU.js.map} +1 -1
- package/dist/{doctor-DvJH-IQG.js → doctor-BT--1kq3.js} +107 -11
- package/dist/doctor-BT--1kq3.js.map +1 -0
- package/dist/{ensure-collection-policies-CCqayoUz.js → ensure-collection-policies-BnGOURpG.js} +13 -10
- package/dist/ensure-collection-policies-BnGOURpG.js.map +1 -0
- package/dist/{ensure-collection-tables-DvvImXDe.js → ensure-collection-tables-Cet4650m.js} +9 -9
- package/dist/{ensure-collection-tables-DvvImXDe.js.map → ensure-collection-tables-Cet4650m.js.map} +1 -1
- package/dist/{ensure-tables-Dpgwx5sy.js → ensure-tables-l_OgFQjN.js} +5 -5
- package/dist/{ensure-tables-Dpgwx5sy.js.map → ensure-tables-l_OgFQjN.js.map} +1 -1
- package/dist/{enum-labels-kept-CUlUlRkO.js → enum-labels-kept-nheku1pB.js} +3 -3
- package/dist/{enum-labels-kept-CUlUlRkO.js.map → enum-labels-kept-nheku1pB.js.map} +1 -1
- package/dist/{generate-drizzle-schema-C3EAP9HE.js → generate-drizzle-schema-DC0BOUpn.js} +3 -3
- package/dist/{generate-drizzle-schema-C3EAP9HE.js.map → generate-drizzle-schema-DC0BOUpn.js.map} +1 -1
- package/dist/{generate-drizzle-schema-logic-DA3zM8zc.js → generate-drizzle-schema-logic-CPzCRD-8.js} +4 -4
- package/dist/{generate-drizzle-schema-logic-DA3zM8zc.js.map → generate-drizzle-schema-logic-CPzCRD-8.js.map} +1 -1
- package/dist/{generate-files-ClmOUHXj.js → generate-files-BP-4W_gm.js} +6 -6
- package/dist/{generate-files-ClmOUHXj.js.map → generate-files-BP-4W_gm.js.map} +1 -1
- package/dist/{generate-next-step-DCeS4LrJ.js → generate-next-step-DgK5BlBn.js} +2 -2
- package/dist/{generate-next-step-DCeS4LrJ.js.map → generate-next-step-DgK5BlBn.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-4eUP4t8w.js → generate-postgres-ddl-logic-DPl1oH_z.js} +4 -4
- package/dist/{generate-postgres-ddl-logic-4eUP4t8w.js.map → generate-postgres-ddl-logic-DPl1oH_z.js.map} +1 -1
- package/dist/generated-schema-diff-eZCklRZQ.js +1025 -0
- package/dist/generated-schema-diff-eZCklRZQ.js.map +1 -0
- package/dist/{generated-schema-staleness-FlxM2i4i.js → generated-schema-staleness-BvNF3i-s.js} +2 -2
- package/dist/{generated-schema-staleness-FlxM2i4i.js.map → generated-schema-staleness-BvNF3i-s.js.map} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +70 -11
- package/dist/index.es.js.map +1 -1
- package/dist/{introspect-db-logic-CI5CU_n0.js → introspect-db-logic-DgQVzccW.js} +2 -2
- package/dist/{introspect-db-logic-CI5CU_n0.js.map → introspect-db-logic-DgQVzccW.js.map} +1 -1
- package/dist/migrate-policy-stamps-3eqfhes6.js +89 -0
- package/dist/migrate-policy-stamps-3eqfhes6.js.map +1 -0
- package/dist/{open-rebase-BKA7Nyoe.js → open-rebase-EmqVmS14.js} +51 -1020
- package/dist/open-rebase-EmqVmS14.js.map +1 -0
- package/dist/{pg-error-utils-Bv5n2PLn.js → pg-error-utils-CFEnm2m9.js} +2 -2
- package/dist/{pg-error-utils-Bv5n2PLn.js.map → pg-error-utils-CFEnm2m9.js.map} +1 -1
- package/dist/{plan-schema-CXOucCw-.js → plan-schema-Czf3q4-Q.js} +4 -4
- package/dist/{plan-schema-CXOucCw-.js.map → plan-schema-Czf3q4-Q.js.map} +1 -1
- package/dist/{policy-drift-vm0BcvcE.js → policy-drift-X4A-xAzv.js} +3 -3
- package/dist/{policy-drift-vm0BcvcE.js.map → policy-drift-X4A-xAzv.js.map} +1 -1
- package/dist/pool-disconnects.d.ts +28 -0
- package/dist/{push-index-prebuild-DIequ4bV.js → push-index-prebuild-COd7i6wm.js} +4 -4
- package/dist/{push-index-prebuild-DIequ4bV.js.map → push-index-prebuild-COd7i6wm.js.map} +1 -1
- package/dist/{push-legacy-renames-BqJut4F3.js → push-legacy-renames-CLgYYwPE.js} +4 -4
- package/dist/{push-legacy-renames-BqJut4F3.js.map → push-legacy-renames-CLgYYwPE.js.map} +1 -1
- package/dist/{push-policy-plan-CvX8hiPb.js → push-policy-plan-D2gpQsdv.js} +5 -5
- package/dist/{push-policy-plan-CvX8hiPb.js.map → push-policy-plan-D2gpQsdv.js.map} +1 -1
- package/dist/{render-ddl-CQNwZdse.js → render-ddl-4v88y-Gv.js} +4 -4
- package/dist/{render-ddl-CQNwZdse.js.map → render-ddl-4v88y-Gv.js.map} +1 -1
- package/dist/{rls-enforcement-D7P4-ZYX.js → rls-enforcement-DDyNoOSy.js} +2 -2
- package/dist/{rls-enforcement-D7P4-ZYX.js.map → rls-enforcement-DDyNoOSy.js.map} +1 -1
- package/dist/schema/doctor-cli.js +5 -5
- package/dist/schema/doctor.d.ts +20 -2
- package/dist/schema/ensure-collection-policies.d.ts +4 -1
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl.js +2 -2
- package/dist/schema/generated-schema-diff.d.ts +21 -0
- package/dist/schema/introspect-db.js +5 -6
- package/dist/schema/introspect-db.js.map +1 -1
- package/dist/schema/migrate-policy-stamps.d.ts +23 -0
- package/dist/schema/push-policy-plan.d.ts +5 -0
- package/dist/services/BranchService.d.ts +20 -2
- package/dist/services/pg-notify-listener.d.ts +2 -0
- package/dist/{source-Bv5KPeIx.js → source-fZb92pN8.js} +2 -2
- package/dist/{source-Bv5KPeIx.js.map → source-fZb92pN8.js.map} +1 -1
- package/dist/{vector-index-BFhyEaiz.js → vector-index-DsQ3V2d2.js} +2 -2
- package/dist/{vector-index-BFhyEaiz.js.map → vector-index-DsQ3V2d2.js.map} +1 -1
- package/dist/{websocket-MC0zTBar.js → websocket-BKZwsjmf.js} +18 -5
- package/dist/websocket-BKZwsjmf.js.map +1 -0
- package/package.json +7 -7
- package/dist/BranchService-iXXZeVYD.js.map +0 -1
- package/dist/backup-cli-B2CAn9fR.js +0 -647
- package/dist/backup-cli-B2CAn9fR.js.map +0 -1
- package/dist/backup-service-Bb39plam.js.map +0 -1
- package/dist/cli-flags-D-b0qL9T.js +0 -206
- package/dist/cli-flags-D-b0qL9T.js.map +0 -1
- package/dist/connection-C938nR3E.js.map +0 -1
- package/dist/databasePoolManager-Yqdw14wY.js.map +0 -1
- package/dist/doctor-DvJH-IQG.js.map +0 -1
- package/dist/ensure-collection-policies-CCqayoUz.js.map +0 -1
- package/dist/open-rebase-BKA7Nyoe.js.map +0 -1
- package/dist/rls-bootstrap-sql-Bd-hJk08.js.map +0 -1
- package/dist/rolldown-runtime-V7rFbMRe.js +0 -39
- package/dist/websocket-MC0zTBar.js.map +0 -1
package/dist/cli-errors.d.ts
CHANGED
|
@@ -170,6 +170,20 @@ export declare function parseNotNullViolation(text: string): {
|
|
|
170
170
|
* NULL`), `null` when the error carried no statement.
|
|
171
171
|
*/
|
|
172
172
|
export declare function notNullColumnIsNew(stderr: string, column: string): boolean | null;
|
|
173
|
+
/**
|
|
174
|
+
* The backfill for a column that refused NOT NULL, as one line a POSIX shell
|
|
175
|
+
* runs once the value is typed between its single quotes.
|
|
176
|
+
*
|
|
177
|
+
* The SQL is the shell's double-quoted word, so the value's own quotes are
|
|
178
|
+
* SQL's: `'tbd'`, or `'O''Brien'` for a value with a quote in it, as SQL
|
|
179
|
+
* writes one. It was the SQL in shell single quotes, and the first quote a
|
|
180
|
+
* value was typed with ended the shell's: `= 'tbd'` reached psql as `= tbd`,
|
|
181
|
+
* `column "tbd" does not exist`.
|
|
182
|
+
*
|
|
183
|
+
* `rebase db url`, not `$DATABASE_URL`: on the managed development database
|
|
184
|
+
* `.env` leaves DATABASE_URL unset, and the shell has none.
|
|
185
|
+
*/
|
|
186
|
+
export declare function backfillCommand(table: string, column: string, manager: ProjectPackageManager): string;
|
|
173
187
|
/**
|
|
174
188
|
* The ways out, and only the ones that work for this column.
|
|
175
189
|
*
|
package/dist/cli-flags.d.ts
CHANGED
|
@@ -127,6 +127,57 @@ export declare function assertSpecMatchesUsage(specs: Record<string, arg.Spec>,
|
|
|
127
127
|
* tests can see.
|
|
128
128
|
*/
|
|
129
129
|
export declare function assertKnownFlags(domain: string, subcommand: string | undefined, args: string[]): void;
|
|
130
|
+
/**
|
|
131
|
+
* The sentence an undeclared flag is refused with, in the words the CLI's own
|
|
132
|
+
* parser uses: "`rebase db push` has no option --dry-rn — did you mean
|
|
133
|
+
* --dry-run? Nothing was run."
|
|
134
|
+
*
|
|
135
|
+
* `token` is the whole argument `arg` refused, which is not always a flag: one
|
|
136
|
+
* argument holding a flag and its value, quoted together
|
|
137
|
+
* (`"--from postgres://u:pw@h/db"`), is refused whole. That one is named as
|
|
138
|
+
* what it is, and what it quotes is password-masked; no other part of an
|
|
139
|
+
* argument is quoted at all.
|
|
140
|
+
*
|
|
141
|
+
* @param command the command as typed: `"db push"`.
|
|
142
|
+
* @param help the command whose `--help` the sentence names.
|
|
143
|
+
* @param spec the command's own flags; the relayed ones are offered too.
|
|
144
|
+
*/
|
|
145
|
+
export declare function unknownOptionSentence(command: string, help: string, token: string, spec: arg.Spec): string;
|
|
146
|
+
/**
|
|
147
|
+
* A line with every `--switch=value` resolved, before `arg` reads it: `=true`
|
|
148
|
+
* or `=1` is the switch alone, `=false` or `=0` drops it, and any other value
|
|
149
|
+
* is refused.
|
|
150
|
+
*
|
|
151
|
+
* `arg` drops the value of a flag that takes none and turns the flag on, so
|
|
152
|
+
* `db push --dry-run=false` was a dry run and `--allow-destructive=false`
|
|
153
|
+
* allowed the destructive statements it was typed to forbid. `=true` kept
|
|
154
|
+
* working by the same accident, and scripts write it, so both readings a value
|
|
155
|
+
* can have are honoured and nothing else is guessed at. Past `--` every word
|
|
156
|
+
* is a positional, so nothing there is read.
|
|
157
|
+
*
|
|
158
|
+
* @param command the command as typed, for the message: `"db push"`.
|
|
159
|
+
* @param help the command whose `--help` the message names.
|
|
160
|
+
*/
|
|
161
|
+
export declare function resolveSwitchValues(spec: arg.Spec, argv: readonly string[], command: string, help?: string): string[];
|
|
162
|
+
/**
|
|
163
|
+
* A driver command's line, `["<domain>", "<subcommand>", …]`, with its
|
|
164
|
+
* switches' values resolved by {@link resolveSwitchValues} against the
|
|
165
|
+
* command's spec: what `runPluginCommand` hands every parser after it, so a
|
|
166
|
+
* permissive one never reads `--allow-destructive=false` as on. A command with
|
|
167
|
+
* no spec here comes back as it was.
|
|
168
|
+
*/
|
|
169
|
+
export declare function resolveDriverSwitches(domain: string, subcommand: string | undefined, args: readonly string[]): string[];
|
|
170
|
+
/**
|
|
171
|
+
* The argument `arg` refused as undeclared, whole, or `null` for any other
|
|
172
|
+
* failure.
|
|
173
|
+
*
|
|
174
|
+
* arg's wording is `unknown or unexpected option: --targt-db`, naming the
|
|
175
|
+
* argument up to its first `=`. An argument with a space in it is named past
|
|
176
|
+
* the space too, so the match runs to the end of the message; and the word
|
|
177
|
+
* in `argv` it came from is returned, `=` and all, so a refusal that quotes it
|
|
178
|
+
* quotes what was typed.
|
|
179
|
+
*/
|
|
180
|
+
export declare function unknownFlagIn(err: unknown, argv: readonly string[]): string | null;
|
|
130
181
|
/**
|
|
131
182
|
* The word in `known` that `typed` was probably meant to be: one edit away
|
|
132
183
|
* (`--targt-db`), or two neighbouring letters swapped (`--clena`, `--froce`),
|
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
|
-
__createRequire(import.meta.url);
|
|
3
|
-
import { t as __commonJSMin } from "./rolldown-runtime-V7rFbMRe.js";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
4
3
|
import readline from "readline";
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
12
|
+
var __exportAll = (all, no_symbols) => {
|
|
13
|
+
let target = {};
|
|
14
|
+
for (var name in all) __defProp(target, name, {
|
|
15
|
+
get: all[name],
|
|
16
|
+
enumerable: true
|
|
17
|
+
});
|
|
18
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
23
|
+
key = keys[i];
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
25
|
+
get: ((k) => from[k]).bind(null, key),
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
32
|
+
value: mod,
|
|
33
|
+
enumerable: true
|
|
34
|
+
}) : target, mod));
|
|
35
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
36
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
37
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
5
40
|
//#region ../../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js
|
|
6
41
|
var require_arg = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7
42
|
var flagSymbol = Symbol("arg flag");
|
|
@@ -128,6 +163,6 @@ async function promptConfirm(question) {
|
|
|
128
163
|
}
|
|
129
164
|
}
|
|
130
165
|
//#endregion
|
|
131
|
-
export { require_arg as n, promptConfirm as t };
|
|
166
|
+
export { __require as a, __exportAll as i, require_arg as n, __toESM as o, __commonJSMin as r, promptConfirm as t };
|
|
132
167
|
|
|
133
|
-
//# sourceMappingURL=cli-prompt-
|
|
168
|
+
//# sourceMappingURL=cli-prompt-DXG0yk-h.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-prompt-egtNKkZl.js","names":[],"sources":["../../../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js","../src/cli-prompt.ts"],"sourcesContent":["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n","/**\n * The one yes/no question the driver CLI asks: before a destructive `db push`,\n * before a `db restore` without `--yes`, before `db branch prune` removes\n * anything, and before `schema introspect` samples rows.\n */\nimport readline from \"readline\";\n\n/**\n * Ask a yes/no question on an interactive terminal; `true` only for \"y\" or\n * \"yes\".\n *\n * The `isTTY` guard is the contract, not an optimisation: non-interactive\n * shells (CI, pipes, agents) can never answer, and `readline` on a non-TTY\n * stdin resolves with whatever the pipe happens to contain, or never resolves\n * at all. Returning false there is what makes an unattended `db push` abort\n * instead of auto-confirming a destructive change. Callers decide first\n * whether interactive confirmation is possible (`decidePushSafety` for a\n * push); this is the backstop.\n *\n * Ctrl-C and Ctrl-D answer no. On a terminal readline reads Ctrl-C as a key,\n * not as a signal, and with nothing listening it only pauses the input: the\n * question never resolves, and the open database connections behind it keep\n * the process alive, so the command hung instead of stopping. Answering no\n * sends it down the path that says \"Aborted\" and cleans up.\n */\nexport async function promptConfirm(question: string): Promise<boolean> {\n if (!process.stdin.isTTY) return false;\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n try {\n const answer = await new Promise<string>((resolve) => {\n rl.once(\"SIGINT\", () => {\n process.stdout.write(\"\\n\");\n resolve(\"\");\n });\n rl.once(\"close\", () => resolve(\"\"));\n rl.question(question, resolve);\n });\n return /^y(es)?$/i.test(answer.trim());\n } finally {\n rl.close();\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;CAAA,IAAM,aAAa,OAAO,UAAU;CAEpC,IAAM,WAAN,MAAM,iBAAiB,MAAM;EAC5B,YAAY,KAAK,MAAM;GACtB,MAAM,GAAG;GACT,KAAK,OAAO;GACZ,KAAK,OAAO;GAEZ,OAAO,eAAe,MAAM,SAAS,SAAS;EAC/C;CACD;CAEA,SAAS,IACR,MACA,EACC,OAAO,QAAQ,KAAK,MAAM,CAAC,GAC3B,aAAa,OACb,mBAAmB,UAChB,CAAC,GACJ;EACD,IAAI,CAAC,MACJ,MAAM,IAAI,SACT,6CACA,oBACD;EAGD,MAAM,SAAS,EAAE,GAAG,CAAC,EAAE;EAEvB,MAAM,UAAU,CAAC;EACjB,MAAM,WAAW,CAAC;EAElB,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;GACpC,IAAI,CAAC,KACJ,MAAM,IAAI,SACT,0CACA,sBACD;GAGD,IAAI,IAAI,OAAO,KACd,MAAM,IAAI,SACT,gDAAgD,IAAI,IACpD,uBACD;GAGD,IAAI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sB,cAAc,UAAoC;CACpE,IAAI,CAAC,QAAQ,MAAM,OAAO,OAAO;CACjC,MAAM,KAAK,SAAS,gBAAgB;EAAE,OAAO,QAAQ;EAAO,QAAQ,QAAQ;CAAO,CAAC;CACpF,IAAI;EACA,MAAM,SAAS,MAAM,IAAI,SAAiB,YAAY;GAClD,GAAG,KAAK,gBAAgB;IACpB,QAAQ,OAAO,MAAM,IAAI;IACzB,QAAQ,EAAE;GACd,CAAC;GACD,GAAG,KAAK,eAAe,QAAQ,EAAE,CAAC;GAClC,GAAG,SAAS,UAAU,OAAO;EACjC,CAAC;EACD,OAAO,YAAY,KAAK,OAAO,KAAK,CAAC;CACzC,UAAU;EACN,GAAG,MAAM;CACb;AACJ"}
|
|
1
|
+
{"version":3,"file":"cli-prompt-DXG0yk-h.js","names":[],"sources":["../../../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js","../src/cli-prompt.ts"],"sourcesContent":["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n","/**\n * The one yes/no question the driver CLI asks: before a destructive `db push`,\n * before a `db restore` without `--yes`, before `db branch prune` removes\n * anything, and before `schema introspect` samples rows.\n */\nimport readline from \"readline\";\n\n/**\n * Ask a yes/no question on an interactive terminal; `true` only for \"y\" or\n * \"yes\".\n *\n * The `isTTY` guard is the contract, not an optimisation: non-interactive\n * shells (CI, pipes, agents) can never answer, and `readline` on a non-TTY\n * stdin resolves with whatever the pipe happens to contain, or never resolves\n * at all. Returning false there is what makes an unattended `db push` abort\n * instead of auto-confirming a destructive change. Callers decide first\n * whether interactive confirmation is possible (`decidePushSafety` for a\n * push); this is the backstop.\n *\n * Ctrl-C and Ctrl-D answer no. On a terminal readline reads Ctrl-C as a key,\n * not as a signal, and with nothing listening it only pauses the input: the\n * question never resolves, and the open database connections behind it keep\n * the process alive, so the command hung instead of stopping. Answering no\n * sends it down the path that says \"Aborted\" and cleans up.\n */\nexport async function promptConfirm(question: string): Promise<boolean> {\n if (!process.stdin.isTTY) return false;\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n try {\n const answer = await new Promise<string>((resolve) => {\n rl.once(\"SIGINT\", () => {\n process.stdout.write(\"\\n\");\n resolve(\"\");\n });\n rl.once(\"close\", () => resolve(\"\"));\n rl.question(question, resolve);\n });\n return /^y(es)?$/i.test(answer.trim());\n } finally {\n rl.close();\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAA,IAAM,aAAa,OAAO,UAAU;CAEpC,IAAM,WAAN,MAAM,iBAAiB,MAAM;EAC5B,YAAY,KAAK,MAAM;GACtB,MAAM,GAAG;GACT,KAAK,OAAO;GACZ,KAAK,OAAO;GAEZ,OAAO,eAAe,MAAM,SAAS,SAAS;EAC/C;CACD;CAEA,SAAS,IACR,MACA,EACC,OAAO,QAAQ,KAAK,MAAM,CAAC,GAC3B,aAAa,OACb,mBAAmB,UAChB,CAAC,GACJ;EACD,IAAI,CAAC,MACJ,MAAM,IAAI,SACT,6CACA,oBACD;EAGD,MAAM,SAAS,EAAE,GAAG,CAAC,EAAE;EAEvB,MAAM,UAAU,CAAC;EACjB,MAAM,WAAW,CAAC;EAElB,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;GACpC,IAAI,CAAC,KACJ,MAAM,IAAI,SACT,0CACA,sBACD;GAGD,IAAI,IAAI,OAAO,KACd,MAAM,IAAI,SACT,gDAAgD,IAAI,IACpD,uBACD;GAGD,IAAI,IAAI,WAAW,GAClB,MAAM,IAAI,SACT,qEAAqE,OACrE,uBACD;GAGD,IAAI,OAAO,KAAK,SAAS,UAAU;IAClC,QAAQ,OAAO,KAAK;IACpB;GACD;GA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;CAAO,CAAC;CACpF,IAAI;EACA,MAAM,SAAS,MAAM,IAAI,SAAiB,YAAY;GAClD,GAAG,KAAK,gBAAgB;IACpB,QAAQ,OAAO,MAAM,IAAI;IACzB,QAAQ,EAAE;GACd,CAAC;GACD,GAAG,KAAK,eAAe,QAAQ,EAAE,CAAC;GAClC,GAAG,SAAS,UAAU,OAAO;EACjC,CAAC;EACD,OAAO,YAAY,KAAK,OAAO,KAAK,CAAC;CACzC,UAAU;EACN,GAAG,MAAM;CACb;AACJ"}
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
import { A as getUndeclaredConstraintExcludes, B as withAppClient, C as dropDevDatabase, D as getSearchExcludes, E as getForeignIndexExcludes, F as queryUndeclarableConstraints, G as prepareGeneratedSqlDir, H as DESIRED_STATE_URL, I as readSearchDdl, J as detectDestructiveStatements, K as decidePushSafety, L as readTriggersDdl, M as loadCollectionsForCli, N as queryColumnTypes, O as getTableExcludes, P as queryGeneratedColumnDependencies, Q as forAtlas, R as readVectorDdl, S as diagnoseMissingBin, T as ensureDevDatabaseExists, U as GENERATED_SQL_DIR, V as workspaceMemberDir, W as generatedSqlDir, X as fromAlterTable, Y as extractPlanStatements, Z as isSyncedPlan, _ as closeAppClients, a as diagnoseDbError, b as describeReinstallCommand, c as isEconnrefused, d as reportCommandFailure, et as redactConnectionPasswords, f as ExcludeIntrospectionError, g as atlasDevDatabaseUrl, h as applyVectorDdl, i as diagnoseAtlasFailure, j as getVectorExcludes, k as getTriggerExcludes, l as isSslNotEnabled, m as applyTriggersDdl, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as destructiveOptInFlag, s as isAuthFailure, t as checkDatabaseConnectivity, v as describeBuildScriptRemedy, w as dropGeneratedColumns, x as detectProjectPackageManager, y as describeDevAddCommand, z as resolveLocalBin } from "./cli-errors-
|
|
5
|
-
import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-
|
|
6
|
-
import { t as nextStepAfterDbGenerate } from "./generate-next-step-
|
|
7
|
-
import { o as
|
|
8
|
-
import { n as require_arg, t as promptConfirm } from "./cli-prompt-egtNKkZl.js";
|
|
9
|
-
import { i as collectionsPathIn, n as assertKnownFlags, o as parseDriverLine, r as closestWord, t as RELAYED_FLAGS } from "./cli-flags-D-b0qL9T.js";
|
|
3
|
+
import { n as require_arg, o as __toESM, t as promptConfirm } from "./cli-prompt-DXG0yk-h.js";
|
|
4
|
+
import { A as getUndeclaredConstraintExcludes, B as withAppClient, C as dropDevDatabase, D as getSearchExcludes, E as getForeignIndexExcludes, F as queryUndeclarableConstraints, G as prepareGeneratedSqlDir, H as DESIRED_STATE_URL, I as readSearchDdl, J as detectDestructiveStatements, K as decidePushSafety, L as readTriggersDdl, M as loadCollectionsForCli, N as queryColumnTypes, O as getTableExcludes, P as queryGeneratedColumnDependencies, Q as forAtlas, R as readVectorDdl, S as diagnoseMissingBin, T as ensureDevDatabaseExists, U as GENERATED_SQL_DIR, V as workspaceMemberDir, W as generatedSqlDir, X as fromAlterTable, Y as extractPlanStatements, Z as isSyncedPlan, _ as closeAppClients, a as diagnoseDbError, b as describeReinstallCommand, c as isEconnrefused, d as reportCommandFailure, et as redactConnectionPasswords, f as ExcludeIntrospectionError, g as atlasDevDatabaseUrl, h as applyVectorDdl, i as diagnoseAtlasFailure, j as getVectorExcludes, k as getTriggerExcludes, l as isSslNotEnabled, m as applyTriggersDdl, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as destructiveOptInFlag, s as isAuthFailure, t as checkDatabaseConnectivity, v as describeBuildScriptRemedy, w as dropGeneratedColumns, x as detectProjectPackageManager, y as describeDevAddCommand, z as resolveLocalBin } from "./cli-errors-DiA0XFIS.js";
|
|
5
|
+
import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-fZb92pN8.js";
|
|
6
|
+
import { t as nextStepAfterDbGenerate } from "./generate-next-step-DgK5BlBn.js";
|
|
7
|
+
import { a as resolveBranchSwitches, c as assertKnownFlags, f as parseDriverLine, g as dropLegacyAuthSchema, m as RLS_BOOTSTRAP_SQL, n as isDriverDbSubcommand, o as unexpectedBranchArgs, p as resolveDriverSwitches, r as backupActionOf, t as DRIVER_DB_SUBCOMMANDS, u as collectionsPathIn, y as execa } from "./db-subcommands-BPoHCxJR.js";
|
|
10
8
|
import { formatRelativeTime } from "@rebasepro/utils";
|
|
11
9
|
import path from "path";
|
|
12
10
|
import fs from "fs";
|
|
@@ -1072,121 +1070,6 @@ async function applyPoliciesFile(client, policiesSql, stamping) {
|
|
|
1072
1070
|
};
|
|
1073
1071
|
}
|
|
1074
1072
|
//#endregion
|
|
1075
|
-
//#region src/branch-argv.ts
|
|
1076
|
-
/**
|
|
1077
|
-
* Argument shapes for `rebase db branch`, with no runtime dependencies.
|
|
1078
|
-
*
|
|
1079
|
-
* Its own module for the same reason `schema/atlas-argv.ts` is: `cli.ts` pulls
|
|
1080
|
-
* in chalk, execa and the driver runtime, so a unit test that imports it cannot
|
|
1081
|
-
* run. Argv parsing is the part most worth testing and the part least in need
|
|
1082
|
-
* of any of that.
|
|
1083
|
-
*/
|
|
1084
|
-
/**
|
|
1085
|
-
* The flags each driver-side `db branch` action takes, besides the ones the CLI
|
|
1086
|
-
* relays on every line (`--database-url`, `--docker`, `--debug`).
|
|
1087
|
-
*
|
|
1088
|
-
* `switch` is absent: the CLI answers it before the driver is ever spawned.
|
|
1089
|
-
* An action not listed here is not checked, so the dispatch can say it does
|
|
1090
|
-
* not exist in its own words.
|
|
1091
|
-
*/
|
|
1092
|
-
var BRANCH_ACTION_FLAGS = {
|
|
1093
|
-
create: {
|
|
1094
|
-
"--from": String,
|
|
1095
|
-
"--force": Boolean
|
|
1096
|
-
},
|
|
1097
|
-
list: {},
|
|
1098
|
-
info: {},
|
|
1099
|
-
delete: {
|
|
1100
|
-
"--force": Boolean,
|
|
1101
|
-
"--yes": Boolean,
|
|
1102
|
-
"-y": "--yes"
|
|
1103
|
-
},
|
|
1104
|
-
prune: {
|
|
1105
|
-
"--older-than": String,
|
|
1106
|
-
"--include-dev-diff": Boolean,
|
|
1107
|
-
"--yes": Boolean,
|
|
1108
|
-
"-y": "--yes"
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
/**
|
|
1112
|
-
* Refuse a flag `action` does not take, naming the one it was probably meant
|
|
1113
|
-
* to be — the same sentence `db backup` and `db restore` say.
|
|
1114
|
-
*
|
|
1115
|
-
* Throws: the driver's entry turns a thrown error into one red line and exit 1,
|
|
1116
|
-
* and this runs before anything connects.
|
|
1117
|
-
*/
|
|
1118
|
-
function assertKnownBranchFlags(action, rest) {
|
|
1119
|
-
const spec = BRANCH_ACTION_FLAGS[action];
|
|
1120
|
-
if (!spec) return;
|
|
1121
|
-
const full = {
|
|
1122
|
-
...RELAYED_FLAGS,
|
|
1123
|
-
...spec
|
|
1124
|
-
};
|
|
1125
|
-
try {
|
|
1126
|
-
(0, import_arg.default)(full, { argv: [...rest] });
|
|
1127
|
-
} catch (error) {
|
|
1128
|
-
if (!(error instanceof Error) || !("code" in error) || error.code !== "ARG_UNKNOWN_OPTION") throw error;
|
|
1129
|
-
const typed = (/option: (\S+)$/.exec(error.message)?.[1] ?? error.message).split("=")[0];
|
|
1130
|
-
const suggestion = closestWord(typed, Object.keys(full).filter((flag) => flag.startsWith("--")));
|
|
1131
|
-
const own = Object.keys(spec).filter((flag) => flag.startsWith("--"));
|
|
1132
|
-
const takes = own.length > 0 ? `it takes ${own.join(", ")}` : "it takes no options of its own";
|
|
1133
|
-
throw new Error(`\`rebase db branch ${action}\` has no option ${typed}` + (suggestion ? ` — did you mean ${suggestion}?` : ` — ${takes}.`) + " Nothing was run. See `rebase db branch --help`.");
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
/**
|
|
1137
|
-
* Words on a `db branch` command line that no argument accounts for.
|
|
1138
|
-
*
|
|
1139
|
-
* `rebase db branch create alpha beta` created a branch called `alpha` and
|
|
1140
|
-
* threw `beta` away without a word. The shapes that produces are all quiet and
|
|
1141
|
-
* all wrong: an unquoted name (`create my feature` → `my`), a flag written
|
|
1142
|
-
* without its dashes (`create feat from main` → `feat`), a shell that split
|
|
1143
|
-
* something you thought was one token. In each case the command succeeds and
|
|
1144
|
-
* the branch is not the one asked for — and branch names are the thing you
|
|
1145
|
-
* later type to switch, delete, or point a deploy at.
|
|
1146
|
-
*
|
|
1147
|
-
* A flag the action does not take is refused outright, by throwing — see
|
|
1148
|
-
* {@link BRANCH_ACTION_FLAGS}. It was let through on the reasoning that a
|
|
1149
|
-
* subcommand added later might take flags this file had never heard of; what
|
|
1150
|
-
* that bought was every typo running without the flag it meant:
|
|
1151
|
-
* `prune --older-then 1d --yes` pruned by no age, `create x --froce` ran
|
|
1152
|
-
* without --force. A new action gets its line in the table. The value after a
|
|
1153
|
-
* flag that takes one is skipped: it is that flag's argument, not a stray word.
|
|
1154
|
-
*
|
|
1155
|
-
* @param words The command's own arguments: action, name, then the rest.
|
|
1156
|
-
*/
|
|
1157
|
-
function unexpectedBranchArgs(words) {
|
|
1158
|
-
if (words[0]) assertKnownBranchFlags(words[0], words.slice(1));
|
|
1159
|
-
const extras = [];
|
|
1160
|
-
let seenName = false;
|
|
1161
|
-
for (let index = 1; index < words.length; index += 1) {
|
|
1162
|
-
const word = words[index];
|
|
1163
|
-
if (word.startsWith("-")) {
|
|
1164
|
-
if (TAKES_A_VALUE.has(word.split("=")[0])) index += 1;
|
|
1165
|
-
continue;
|
|
1166
|
-
}
|
|
1167
|
-
if (!seenName) {
|
|
1168
|
-
seenName = true;
|
|
1169
|
-
continue;
|
|
1170
|
-
}
|
|
1171
|
-
extras.push(word);
|
|
1172
|
-
}
|
|
1173
|
-
return extras;
|
|
1174
|
-
}
|
|
1175
|
-
/**
|
|
1176
|
-
* Branch-line flags whose next word belongs to them.
|
|
1177
|
-
*
|
|
1178
|
-
* `--from` was the only one listed, and `--database-url` is the one that bit:
|
|
1179
|
-
* `rebase db branch list --database-url postgres://…` — which the CLI itself
|
|
1180
|
-
* appends when the checkout is on a branch, so `rebase.branches` is read in the
|
|
1181
|
-
* parent where it lives — answered `✗ Unexpected argument: postgres://…`. The
|
|
1182
|
-
* `=` form carries its value in the same word and needs no skip.
|
|
1183
|
-
*/
|
|
1184
|
-
var TAKES_A_VALUE = /* @__PURE__ */ new Set([
|
|
1185
|
-
"--from",
|
|
1186
|
-
"--older-than",
|
|
1187
|
-
"--database-url"
|
|
1188
|
-
]);
|
|
1189
|
-
//#endregion
|
|
1190
1073
|
//#region src/cli-collections-path.ts
|
|
1191
1074
|
/**
|
|
1192
1075
|
* `--collections <dir>`, checked once, before anything is written.
|
|
@@ -1263,14 +1146,6 @@ function assertCollectionsPathExists(typed) {
|
|
|
1263
1146
|
throw new CollectionsPathMissing(typed, resolved);
|
|
1264
1147
|
}
|
|
1265
1148
|
//#endregion
|
|
1266
|
-
//#region src/backup-argv.ts
|
|
1267
|
-
/**
|
|
1268
|
-
* @param rawArgs the driver's whole line, `["db", "backup", …]`.
|
|
1269
|
-
*/
|
|
1270
|
-
function backupActionOf(rawArgs) {
|
|
1271
|
-
return rawArgs[2] === "list" ? "list" : "create";
|
|
1272
|
-
}
|
|
1273
|
-
//#endregion
|
|
1274
1149
|
//#region src/branch-prune.ts
|
|
1275
1150
|
/**
|
|
1276
1151
|
* The variable the CLI hands the driver the database its checkout is switched
|
|
@@ -1426,7 +1301,7 @@ function generatesInProcess() {
|
|
|
1426
1301
|
async function generateInProcess(what, label, run) {
|
|
1427
1302
|
let generators;
|
|
1428
1303
|
try {
|
|
1429
|
-
generators = await import("./generate-files-
|
|
1304
|
+
generators = await import("./generate-files-BP-4W_gm.js").then((n) => n.t);
|
|
1430
1305
|
} catch (err) {
|
|
1431
1306
|
outError(chalk.red(`✗ Failed to run ${what}: ${err instanceof Error ? err.message : String(err)}`));
|
|
1432
1307
|
process.exit(1);
|
|
@@ -1466,13 +1341,14 @@ async function runPluginCommand(args) {
|
|
|
1466
1341
|
const domain = args[0];
|
|
1467
1342
|
const subcommand = args[1];
|
|
1468
1343
|
assertKnownFlags(domain, subcommand, args);
|
|
1344
|
+
args = resolveDriverSwitches(domain, subcommand, args);
|
|
1469
1345
|
assertCollectionsPathExists(collectionsPathIn(args));
|
|
1470
1346
|
try {
|
|
1471
1347
|
if (domain === "db") await scratchDatabase.around(() => dbCommand(subcommand, args));
|
|
1472
1348
|
else if (domain === "schema") await schemaCommand(subcommand, args);
|
|
1473
1349
|
else if (domain === "doctor") await doctorPluginCommand(args);
|
|
1474
1350
|
else if (domain === "console") {
|
|
1475
|
-
const { consoleCommand } = await import("./cli-console-
|
|
1351
|
+
const { consoleCommand } = await import("./cli-console-CQrQ0lAY.js");
|
|
1476
1352
|
process.exitCode = await consoleCommand(args);
|
|
1477
1353
|
} else {
|
|
1478
1354
|
outError(chalk.red(`Unknown domain command: ${domain}`));
|
|
@@ -1623,17 +1499,8 @@ var DB_FLAGS = {
|
|
|
1623
1499
|
"-y": "--yes"
|
|
1624
1500
|
};
|
|
1625
1501
|
async function dbCommand(subcommand, rawArgs) {
|
|
1626
|
-
|
|
1627
|
-
"
|
|
1628
|
-
"generate",
|
|
1629
|
-
"migrate",
|
|
1630
|
-
"branch",
|
|
1631
|
-
"backup",
|
|
1632
|
-
"restore",
|
|
1633
|
-
"backups"
|
|
1634
|
-
];
|
|
1635
|
-
if (!subcommand || !VALID_ACTIONS.includes(subcommand)) {
|
|
1636
|
-
outError(chalk.red(`Unknown db command. Valid: ${VALID_ACTIONS.join(", ")}`));
|
|
1502
|
+
if (!isDriverDbSubcommand(subcommand)) {
|
|
1503
|
+
outError(chalk.red(`Unknown db command. Valid: ${DRIVER_DB_SUBCOMMANDS.join(", ")}`));
|
|
1637
1504
|
process.exit(1);
|
|
1638
1505
|
}
|
|
1639
1506
|
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
@@ -1648,7 +1515,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1648
1515
|
return;
|
|
1649
1516
|
}
|
|
1650
1517
|
if (subcommand === "backup" || subcommand === "restore" || subcommand === "backups") {
|
|
1651
|
-
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-
|
|
1518
|
+
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-gijeXe0u.js").then((n) => n.t);
|
|
1652
1519
|
if (subcommand === "backup" && backupActionOf(rawArgs) === "list") await backupsCommand(rawArgs);
|
|
1653
1520
|
else if (subcommand === "backup") await backupCommand(rawArgs);
|
|
1654
1521
|
else if (subcommand === "restore") await restoreCommand(rawArgs);
|
|
@@ -1695,7 +1562,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1695
1562
|
}
|
|
1696
1563
|
const searchContent = readSearchDdl();
|
|
1697
1564
|
if (searchContent) {
|
|
1698
|
-
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-
|
|
1565
|
+
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-DPl1oH_z.js").then((n) => n.o);
|
|
1699
1566
|
const migrationConflicts = findGeneratedColumnConflicts(parseColumnMutations(migrationContent), searchColumnDependencies(await loadCollectionsForCli(collectionsPath)));
|
|
1700
1567
|
const preamble = migrationDropPreamble(migrationConflicts);
|
|
1701
1568
|
if (preamble) {
|
|
@@ -1958,6 +1825,8 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1958
1825
|
if (databaseUrl) {
|
|
1959
1826
|
await ensureRlsUserRole(databaseUrl);
|
|
1960
1827
|
await retireLegacyAuthSchema(databaseUrl);
|
|
1828
|
+
const { stampMigratedPolicies } = await import("./migrate-policy-stamps-3eqfhes6.js");
|
|
1829
|
+
await stampMigratedPolicies(databaseUrl, collectionsPath);
|
|
1961
1830
|
}
|
|
1962
1831
|
}
|
|
1963
1832
|
out("");
|
|
@@ -1979,8 +1848,8 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1979
1848
|
async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
1980
1849
|
let renames;
|
|
1981
1850
|
try {
|
|
1982
|
-
const { loadCollections } = await import("./doctor-
|
|
1983
|
-
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-
|
|
1851
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
1852
|
+
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-CLgYYwPE.js");
|
|
1984
1853
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1985
1854
|
renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1986
1855
|
} catch {
|
|
@@ -1999,8 +1868,8 @@ async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
|
1999
1868
|
/** Names the enum labels the database keeps after the collections dropped them. See `schema/enum-labels-kept.ts`. */
|
|
2000
1869
|
async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
2001
1870
|
try {
|
|
2002
|
-
const { loadCollections } = await import("./doctor-
|
|
2003
|
-
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-
|
|
1871
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
1872
|
+
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-nheku1pB.js");
|
|
2004
1873
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2005
1874
|
const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
2006
1875
|
if (kept.length > 0) outWarn(chalk.yellow(formatKeptEnumLabelsNotice(kept)));
|
|
@@ -2009,8 +1878,8 @@ async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
|
2009
1878
|
async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
2010
1879
|
let missing;
|
|
2011
1880
|
try {
|
|
2012
|
-
const { loadCollections } = await import("./doctor-
|
|
2013
|
-
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-
|
|
1881
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
1882
|
+
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-COd7i6wm.js");
|
|
2014
1883
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2015
1884
|
missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
2016
1885
|
} catch {
|
|
@@ -2020,7 +1889,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
|
2020
1889
|
if (missing.length === 0 || dryRun) return names;
|
|
2021
1890
|
out(chalk.gray(` Building ${missing.length} foreign-key index(es) on existing tables first — CONCURRENTLY, so writes go on:`));
|
|
2022
1891
|
try {
|
|
2023
|
-
const { buildDeferredIndexes } = await import("./deferred-index-build-
|
|
1892
|
+
const { buildDeferredIndexes } = await import("./deferred-index-build-BE0I6sYU.js").then((n) => n.r);
|
|
2024
1893
|
const outcome = await withAppClient(databaseUrl, (client) => buildDeferredIndexes(async () => ({
|
|
2025
1894
|
dedicated: true,
|
|
2026
1895
|
query: async (text) => ({ rows: (await client.query(text)).rows }),
|
|
@@ -2068,9 +1937,9 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
2068
1937
|
let unsecured;
|
|
2069
1938
|
let userRole;
|
|
2070
1939
|
try {
|
|
2071
|
-
const { lockCollectionTables } = await import("./ensure-collection-policies-
|
|
2072
|
-
const { loadCollections } = await import("./doctor-
|
|
2073
|
-
userRole = (await import("./rls-enforcement-
|
|
1940
|
+
const { lockCollectionTables } = await import("./ensure-collection-policies-BnGOURpG.js");
|
|
1941
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
1942
|
+
userRole = (await import("./rls-enforcement-DDyNoOSy.js").then((n) => n.c)).REBASE_USER_ROLE;
|
|
2074
1943
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2075
1944
|
({unsecured} = await withAppClient(databaseUrl, (client) => lockCollectionTables({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections)));
|
|
2076
1945
|
} catch (err) {
|
|
@@ -2105,8 +1974,8 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
2105
1974
|
async function ensureAuthTables(databaseUrl, collectionsPath) {
|
|
2106
1975
|
try {
|
|
2107
1976
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2108
|
-
const { ensureAuthTablesExist } = await import("./ensure-tables-
|
|
2109
|
-
const { loadCollections } = await import("./doctor-
|
|
1977
|
+
const { ensureAuthTablesExist } = await import("./ensure-tables-l_OgFQjN.js").then((n) => n.n);
|
|
1978
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
2110
1979
|
const authCollection = (await loadCollections(path.resolve(process.cwd(), collectionsPath))).find((c) => {
|
|
2111
1980
|
const a = c.auth;
|
|
2112
1981
|
return a === true || typeof a === "object" && a !== null && a.enabled === true;
|
|
@@ -2126,7 +1995,7 @@ async function ensureRlsUserRole(databaseUrl) {
|
|
|
2126
1995
|
const schemas = ["public", "rebase"];
|
|
2127
1996
|
let rls;
|
|
2128
1997
|
try {
|
|
2129
|
-
rls = await import("./rls-enforcement-
|
|
1998
|
+
rls = await import("./rls-enforcement-DDyNoOSy.js").then((n) => n.c);
|
|
2130
1999
|
} catch (err) {
|
|
2131
2000
|
outError(chalk.red(`\n ✗ Could not load the RLS provisioning module: ${err instanceof Error ? err.message : String(err)}`));
|
|
2132
2001
|
return;
|
|
@@ -2186,10 +2055,10 @@ async function applyPolicies(databaseUrl, collectionsPath) {
|
|
|
2186
2055
|
*/
|
|
2187
2056
|
async function policyStamping(databaseUrl, collectionsPath, policiesSql) {
|
|
2188
2057
|
try {
|
|
2189
|
-
const { loadCollections } = await import("./doctor-
|
|
2190
|
-
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-
|
|
2191
|
-
const { policyStampSql } = await import("./ensure-collection-policies-
|
|
2192
|
-
const { pinSearchPath } = await import("./connection-
|
|
2058
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
2059
|
+
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-DPl1oH_z.js").then((n) => n.o);
|
|
2060
|
+
const { policyStampSql } = await import("./ensure-collection-policies-BnGOURpG.js");
|
|
2061
|
+
const { pinSearchPath } = await import("./connection-czvI7TZL.js").then((n) => n.n);
|
|
2193
2062
|
return {
|
|
2194
2063
|
statements: stampableTables(planCollectionPolicies(await loadCollections(path.resolve(process.cwd(), collectionsPath))), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
|
|
2195
2064
|
searchPath: pinSearchPath(databaseUrl) === databaseUrl ? void 0 : "public"
|
|
@@ -2206,9 +2075,9 @@ async function policyStamping(databaseUrl, collectionsPath, policiesSql) {
|
|
|
2206
2075
|
*/
|
|
2207
2076
|
async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
2208
2077
|
try {
|
|
2209
|
-
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-
|
|
2210
|
-
const { loadCollections } = await import("./doctor-
|
|
2211
|
-
const { pinSearchPath } = await import("./connection-
|
|
2078
|
+
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-D2gpQsdv.js");
|
|
2079
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
2080
|
+
const { pinSearchPath } = await import("./connection-czvI7TZL.js").then((n) => n.n);
|
|
2212
2081
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2213
2082
|
const plan = await withAppClient(databaseUrl, (client) => planPolicyPush({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, collections, { searchPath: pinSearchPath(databaseUrl) === databaseUrl ? void 0 : "public" }));
|
|
2214
2083
|
return {
|
|
@@ -2235,8 +2104,8 @@ async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
|
2235
2104
|
*/
|
|
2236
2105
|
async function reconcilePolicies(databaseUrl, collectionsPath) {
|
|
2237
2106
|
try {
|
|
2238
|
-
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-
|
|
2239
|
-
const { loadCollections } = await import("./doctor-
|
|
2107
|
+
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-X4A-xAzv.js").then((n) => n.s);
|
|
2108
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
2240
2109
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2241
2110
|
await withAppClient(databaseUrl, async (client) => {
|
|
2242
2111
|
const drift = await checkPolicyDrift(client, collections);
|
|
@@ -2294,13 +2163,14 @@ async function branchCommand(rawArgs) {
|
|
|
2294
2163
|
return;
|
|
2295
2164
|
}
|
|
2296
2165
|
const extras = unexpectedBranchArgs(rawArgs.slice(2));
|
|
2166
|
+
rawArgs = resolveBranchSwitches(rawArgs);
|
|
2297
2167
|
if (extras.length > 0) {
|
|
2298
2168
|
outError("");
|
|
2299
|
-
outError(chalk.red(` ✗ Unexpected argument${extras.length > 1 ? "s" : ""}: ${extras.join(" ")}`));
|
|
2169
|
+
outError(chalk.red(` ✗ Unexpected argument${extras.length > 1 ? "s" : ""}: ${redactConnectionPasswords(extras.join(" "))}`));
|
|
2300
2170
|
outError("");
|
|
2301
2171
|
outError(chalk.gray(` ${chalk.bold("rebase db branch")} takes one name. A branch name may contain letters,`));
|
|
2302
2172
|
outError(chalk.gray(" digits, underscores and hyphens — no spaces."));
|
|
2303
|
-
if (rawArgs[3]) outError(chalk.gray(` Did you mean: ${chalk.cyan(`rebase db branch ${branchAction} ${[rawArgs[3], ...extras].join("-")}`)}`));
|
|
2173
|
+
if (rawArgs[3]) outError(chalk.gray(` Did you mean: ${chalk.cyan(redactConnectionPasswords(`rebase db branch ${branchAction} ${[rawArgs[3], ...extras].join("-")}`))}`));
|
|
2304
2174
|
outError("");
|
|
2305
2175
|
process.exit(1);
|
|
2306
2176
|
}
|
|
@@ -2318,8 +2188,8 @@ async function branchCommand(rawArgs) {
|
|
|
2318
2188
|
outError(chalk.red("✗ DATABASE_URL is not set. Make sure your .env file is configured."));
|
|
2319
2189
|
process.exit(1);
|
|
2320
2190
|
}
|
|
2321
|
-
const { DatabasePoolManager } = await import("./databasePoolManager-
|
|
2322
|
-
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-
|
|
2191
|
+
const { DatabasePoolManager } = await import("./databasePoolManager-3stMNFL-.js").then((n) => n.n);
|
|
2192
|
+
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-ClklxyAQ.js").then((n) => n.n);
|
|
2323
2193
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2324
2194
|
const { Pool } = await import("pg");
|
|
2325
2195
|
const healed = await reopenClosedDatabases(databaseUrl, [branchAction === "create" ? createSource(rawArgs) : void 0, process.env[ACTIVE_BRANCH_DATABASE_ENV]]);
|
|
@@ -2828,9 +2698,9 @@ async function schemaStaleCommand(rawArgs) {
|
|
|
2828
2698
|
const schemaFile = path.resolve(process.cwd(), outputPath);
|
|
2829
2699
|
const fix = Boolean(argsList["--fix"]);
|
|
2830
2700
|
const generatedExists = fs.existsSync(schemaFile);
|
|
2831
|
-
const { loadCollections } = await import("./doctor-
|
|
2832
|
-
const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-
|
|
2833
|
-
const { generateSchema } = await import("./generate-drizzle-schema-logic-
|
|
2701
|
+
const { loadCollections } = await import("./doctor-BT--1kq3.js").then((n) => n.t);
|
|
2702
|
+
const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-BvNF3i-s.js").then((n) => n.r);
|
|
2703
|
+
const { generateSchema } = await import("./generate-drizzle-schema-logic-CPzCRD-8.js").then((n) => n.n);
|
|
2834
2704
|
const { relationalCollections } = await import("@rebasepro/common");
|
|
2835
2705
|
let stale = [];
|
|
2836
2706
|
let differences = [];
|