@rebasepro/server-postgres 0.24.1-canary.gcb918fc → 0.25.0-canary.g70dad01
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-Bsn2wfaj.js → BranchService-DO_3_CXt.js} +118 -18
- package/dist/BranchService-DO_3_CXt.js.map +1 -0
- package/dist/PostgresBackendDriver.d.ts +13 -0
- package/dist/PostgresBootstrapper.d.ts +10 -0
- package/dist/backup/backup-cli.d.ts +120 -2
- package/dist/backup/backup-service.d.ts +74 -1
- package/dist/backup/pg-binary.d.ts +2 -2
- package/dist/backup/pg-tools.d.ts +65 -0
- package/dist/backup-cli-Ap2WX2uW.js +647 -0
- package/dist/backup-cli-Ap2WX2uW.js.map +1 -0
- package/dist/{backup-service-BTBB7RXn.js → backup-service-DytMimsL.js} +414 -24
- package/dist/backup-service-DytMimsL.js.map +1 -0
- package/dist/{boot-ddl-DVpsFN6r.js → boot-ddl-D1lMCZLd.js} +3 -3
- package/dist/{boot-ddl-DVpsFN6r.js.map → boot-ddl-D1lMCZLd.js.map} +1 -1
- package/dist/branch-argv.d.ts +18 -6
- package/dist/branch-prune.d.ts +18 -0
- package/dist/cli-console-CQGsBzSY.js +262 -0
- package/dist/cli-console-CQGsBzSY.js.map +1 -0
- package/dist/cli-console.d.ts +11 -0
- package/dist/{cli-errors-CaI4ntyD.js → cli-errors-CJTKAKax.js} +499 -107
- package/dist/cli-errors-CJTKAKax.js.map +1 -0
- package/dist/cli-errors.d.ts +42 -5
- package/dist/{cli-flags-JNI-pwSf.js → cli-flags-D-b0qL9T.js} +71 -6
- package/dist/cli-flags-D-b0qL9T.js.map +1 -0
- package/dist/cli-flags.d.ts +21 -0
- package/dist/cli-helpers.d.ts +53 -24
- package/dist/{arg-Dni7MzLB.js → cli-prompt-egtNKkZl.js} +49 -3
- package/dist/cli-prompt-egtNKkZl.js.map +1 -0
- package/dist/cli-prompt.d.ts +19 -0
- package/dist/cli-scratch-database.d.ts +47 -8
- package/dist/cli.js +615 -100
- package/dist/cli.js.map +1 -1
- package/dist/collections/validate-relations.d.ts +8 -2
- package/dist/{column-plan-helpers-drZIsSNf.js → column-plan-helpers-D_V4oaZh.js} +2 -2
- package/dist/{column-plan-helpers-drZIsSNf.js.map → column-plan-helpers-D_V4oaZh.js.map} +1 -1
- package/dist/{connection-C9mT8bgf.js → connection-C938nR3E.js} +2 -2
- package/dist/{connection-C9mT8bgf.js.map → connection-C938nR3E.js.map} +1 -1
- package/dist/{databasePoolManager-BIuewidb.js → databasePoolManager-Yqdw14wY.js} +4 -4
- package/dist/{databasePoolManager-BIuewidb.js.map → databasePoolManager-Yqdw14wY.js.map} +1 -1
- package/dist/{deferred-index-build-DP1_SNFo.js → deferred-index-build-BiTqxqdl.js} +8 -8
- package/dist/{deferred-index-build-DP1_SNFo.js.map → deferred-index-build-BiTqxqdl.js.map} +1 -1
- package/dist/{doctor-C4WiftHm.js → doctor-N3J88BN_.js} +8 -8
- package/dist/doctor-N3J88BN_.js.map +1 -0
- package/dist/{ensure-collection-policies-CXpbeNag.js → ensure-collection-policies-CVP6kIPT.js} +125 -18
- package/dist/ensure-collection-policies-CVP6kIPT.js.map +1 -0
- package/dist/{ensure-collection-tables-BhsU6qUE.js → ensure-collection-tables-1WVNALOW.js} +10 -10
- package/dist/{ensure-collection-tables-BhsU6qUE.js.map → ensure-collection-tables-1WVNALOW.js.map} +1 -1
- package/dist/{ensure-tables-CVm_yvzb.js → ensure-tables-D-Nm2k3S.js} +5 -5
- package/dist/{ensure-tables-CVm_yvzb.js.map → ensure-tables-D-Nm2k3S.js.map} +1 -1
- package/dist/{enum-labels-kept-D8fI1MoX.js → enum-labels-kept-e_93v2Ic.js} +3 -3
- package/dist/{enum-labels-kept-D8fI1MoX.js.map → enum-labels-kept-e_93v2Ic.js.map} +1 -1
- package/dist/{generate-drizzle-schema-Bz52jH2h.js → generate-drizzle-schema-C3EAP9HE.js} +3 -3
- package/dist/{generate-drizzle-schema-Bz52jH2h.js.map → generate-drizzle-schema-C3EAP9HE.js.map} +1 -1
- package/dist/{generate-drizzle-schema-logic-B74WN37S.js → generate-drizzle-schema-logic-DA3zM8zc.js} +4 -4
- package/dist/{generate-drizzle-schema-logic-B74WN37S.js.map → generate-drizzle-schema-logic-DA3zM8zc.js.map} +1 -1
- package/dist/{generate-files-CdEckX6c.js → generate-files-ClmOUHXj.js} +6 -47
- package/dist/generate-files-ClmOUHXj.js.map +1 -0
- package/dist/generate-next-step-DCeS4LrJ.js +74 -0
- package/dist/generate-next-step-DCeS4LrJ.js.map +1 -0
- package/dist/{generate-postgres-ddl-logic-B64O2oZF.js → generate-postgres-ddl-logic-4eUP4t8w.js} +4 -4
- package/dist/{generate-postgres-ddl-logic-B64O2oZF.js.map → generate-postgres-ddl-logic-4eUP4t8w.js.map} +1 -1
- package/dist/{generated-schema-staleness-Di9c4ZxN.js → generated-schema-staleness-FlxM2i4i.js} +102 -12
- package/dist/{generated-schema-staleness-Di9c4ZxN.js.map → generated-schema-staleness-FlxM2i4i.js.map} +1 -1
- package/dist/index.es.js +11 -11
- package/dist/{introspect-db-logic-C-Di8dA9.js → introspect-db-logic-CI5CU_n0.js} +145 -9
- package/dist/introspect-db-logic-CI5CU_n0.js.map +1 -0
- package/dist/{introspect-db-queries-D6kAqReI.js → introspect-db-queries-DevUrzll.js} +41 -6
- package/dist/introspect-db-queries-DevUrzll.js.map +1 -0
- package/dist/{open-rebase-CbOur0TU.js → open-rebase-Cwnqo5LU.js} +116 -51
- package/dist/open-rebase-Cwnqo5LU.js.map +1 -0
- package/dist/open-rebase.d.ts +12 -4
- package/dist/{pg-error-utils-vJezlXdI.js → pg-error-utils-Cmo8wZPy.js} +19 -5
- package/dist/pg-error-utils-Cmo8wZPy.js.map +1 -0
- package/dist/{plan-schema-B1YF_tYq.js → plan-schema-CXOucCw-.js} +4 -4
- package/dist/{plan-schema-B1YF_tYq.js.map → plan-schema-CXOucCw-.js.map} +1 -1
- package/dist/{policy-drift-Dm8i-s1J.js → policy-drift-vm0BcvcE.js} +28 -14
- package/dist/{policy-drift-Dm8i-s1J.js.map → policy-drift-vm0BcvcE.js.map} +1 -1
- package/dist/{push-index-prebuild-Db4AQF4i.js → push-index-prebuild-SXRlWBjc.js} +4 -4
- package/dist/{push-index-prebuild-Db4AQF4i.js.map → push-index-prebuild-SXRlWBjc.js.map} +1 -1
- package/dist/{push-legacy-renames-BK6ilQq2.js → push-legacy-renames-B37yKDac.js} +4 -4
- package/dist/{push-legacy-renames-BK6ilQq2.js.map → push-legacy-renames-B37yKDac.js.map} +1 -1
- package/dist/push-policy-plan-jXzHAWSu.js +127 -0
- package/dist/push-policy-plan-jXzHAWSu.js.map +1 -0
- package/dist/{render-ddl-CtC3y9Ol.js → render-ddl-CQNwZdse.js} +10 -9
- package/dist/render-ddl-CQNwZdse.js.map +1 -0
- package/dist/{rls-bootstrap-sql-RQUljnJ1.js → rls-bootstrap-sql-Bd-hJk08.js} +3 -58
- package/dist/rls-bootstrap-sql-Bd-hJk08.js.map +1 -0
- package/dist/{rls-enforcement-DvzqlaL1.js → rls-enforcement-D7P4-ZYX.js} +2 -2
- package/dist/{rls-enforcement-DvzqlaL1.js.map → rls-enforcement-D7P4-ZYX.js.map} +1 -1
- package/dist/{__vite-browser-external-BnuHet1e.js → rolldown-runtime-V7rFbMRe.js} +1 -8
- package/dist/schema/atlas-apply-report.d.ts +23 -0
- package/dist/schema/atlas-argv.d.ts +24 -1
- package/dist/schema/atlas-exclude.d.ts +42 -0
- package/dist/schema/atlas-revisions.d.ts +4 -0
- package/dist/schema/carved-out-migration.d.ts +5 -4
- package/dist/schema/destructive-sql.d.ts +23 -1
- package/dist/schema/doctor-cli.js +5 -5
- package/dist/schema/ensure-collection-policies.d.ts +74 -0
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-next-step.d.ts +23 -0
- package/dist/schema/generate-postgres-ddl.js +2 -2
- package/dist/schema/generated-schema-diff.d.ts +7 -0
- package/dist/schema/generated-schema-staleness.d.ts +7 -1
- package/dist/schema/introspect-db-logic.d.ts +32 -1
- package/dist/schema/introspect-db-queries.d.ts +18 -5
- package/dist/schema/introspect-db.js +55 -53
- package/dist/schema/introspect-db.js.map +1 -1
- package/dist/schema/migrate-baseline.d.ts +51 -0
- package/dist/schema/plan/render-ddl.d.ts +2 -1
- package/dist/schema/push-policy-plan.d.ts +70 -0
- package/dist/schema/undeclarable-constraints.d.ts +59 -0
- package/dist/security/policy-drift.d.ts +5 -0
- package/dist/services/BranchService.d.ts +38 -0
- package/dist/{source-DBDbBTL4.js → source-Bv5KPeIx.js} +109 -4
- package/dist/source-Bv5KPeIx.js.map +1 -0
- package/dist/utils/connection-string.d.ts +47 -0
- package/dist/{vector-index-CMJKb3C9.js → vector-index-BFhyEaiz.js} +2 -2
- package/dist/{vector-index-CMJKb3C9.js.map → vector-index-BFhyEaiz.js.map} +1 -1
- package/dist/{websocket-BLGc5yhs.js → websocket-BT85Yv_G.js} +41 -13
- package/dist/websocket-BT85Yv_G.js.map +1 -0
- package/package.json +7 -7
- package/dist/BranchService-Bsn2wfaj.js.map +0 -1
- package/dist/__vite-browser-external-BnuHet1e.js.map +0 -1
- package/dist/arg-Dni7MzLB.js.map +0 -1
- package/dist/backup-cli-DnpJi6I7.js +0 -420
- package/dist/backup-cli-DnpJi6I7.js.map +0 -1
- package/dist/backup-service-BTBB7RXn.js.map +0 -1
- package/dist/cli-console-Ca6ZlAVU.js +0 -154
- package/dist/cli-console-Ca6ZlAVU.js.map +0 -1
- package/dist/cli-errors-CaI4ntyD.js.map +0 -1
- package/dist/cli-flags-JNI-pwSf.js.map +0 -1
- package/dist/doctor-C4WiftHm.js.map +0 -1
- package/dist/ensure-collection-policies-CXpbeNag.js.map +0 -1
- package/dist/generate-files-CdEckX6c.js.map +0 -1
- package/dist/introspect-db-logic-C-Di8dA9.js.map +0 -1
- package/dist/introspect-db-queries-D6kAqReI.js.map +0 -1
- package/dist/open-rebase-CbOur0TU.js.map +0 -1
- package/dist/pg-error-utils-vJezlXdI.js.map +0 -1
- package/dist/render-ddl-CtC3y9Ol.js.map +0 -1
- package/dist/rls-bootstrap-sql-RQUljnJ1.js.map +0 -1
- package/dist/source-DBDbBTL4.js.map +0 -1
- package/dist/websocket-BLGc5yhs.js.map +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `rebase db push` will do to row-level security, read before it does it.
|
|
3
|
+
*
|
|
4
|
+
* Atlas has no model for a policy: its free tier neither plans nor reads one.
|
|
5
|
+
* So its plan, which was everything `db push --dry-run` showed, never named
|
|
6
|
+
* one. After `schema introspect` on a database whose tables had policies of
|
|
7
|
+
* their own and no admin baseline, the dry run said "No changes: the database
|
|
8
|
+
* already matches these collections", and the push then created eight
|
|
9
|
+
* `<table>_default_admin_*` policies that let an admin read and write every
|
|
10
|
+
* row.
|
|
11
|
+
*
|
|
12
|
+
* The plan is the push's own steps, read instead of run:
|
|
13
|
+
*
|
|
14
|
+
* - **RLS switched on:** the tables `lockCollectionTables` switches on
|
|
15
|
+
* ({@link tablesRlsWouldEnable}).
|
|
16
|
+
* - **Policies created and replaced:** `policies.sql`, which DROPs and CREATEs
|
|
17
|
+
* every declared policy, against the database as `checkPolicyDrift` reads
|
|
18
|
+
* it: by name, `TO` list, command, mode and which clauses there are. Text
|
|
19
|
+
* is compared through the stamp the push and every boot write
|
|
20
|
+
* ({@link readPolicyStamps}), which is what catches a rule whose SQL changed
|
|
21
|
+
* under the same name. Where the stamp does not match, or there is none (a
|
|
22
|
+
* policy `db migrate` or a hand made), the policy is made again under a probe
|
|
23
|
+
* name and rolled back ({@link probeRenderedPolicies}): one Postgres would
|
|
24
|
+
* store exactly as it is now is no change. Only one that could not be probed
|
|
25
|
+
* is listed as unstamped.
|
|
26
|
+
* - **Policies dropped and kept:** {@link partitionOrphans}, which is how the
|
|
27
|
+
* push's reconcile step decides.
|
|
28
|
+
*/
|
|
29
|
+
import type { CollectionConfig } from "@rebasepro/types";
|
|
30
|
+
import { type PolicyRef, type Queryable } from "../security/policy-drift.js";
|
|
31
|
+
export interface PolicyPushPlan {
|
|
32
|
+
/** Declared tables in the database with row-level security off, as `schema.table`: the push switches it on. */
|
|
33
|
+
enableRls: string[];
|
|
34
|
+
/** Declared policies the database does not have: the push creates them. */
|
|
35
|
+
create: PolicyRef[];
|
|
36
|
+
/** Declared policies the database has under the same name, defined otherwise: the push replaces them. */
|
|
37
|
+
replace: {
|
|
38
|
+
policy: PolicyRef;
|
|
39
|
+
why: string[];
|
|
40
|
+
}[];
|
|
41
|
+
/** Policies an earlier push generated from a rule edited since: the push drops them. */
|
|
42
|
+
drop: PolicyRef[];
|
|
43
|
+
/** Policies no collection describes, which the push leaves in force. */
|
|
44
|
+
keep: PolicyRef[];
|
|
45
|
+
/** Declared policies the database has with no stamp of Rebase's: re-created from their rules, changed or not. */
|
|
46
|
+
unstamped: PolicyRef[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read the plan.
|
|
50
|
+
*
|
|
51
|
+
* @param options.searchPath the `search_path` the stamps were written under
|
|
52
|
+
* when the connection's own differs — the one `db push` stamps under.
|
|
53
|
+
* See {@link readPolicyStamps}.
|
|
54
|
+
*/
|
|
55
|
+
export declare function planPolicyPush(client: Queryable, collections: CollectionConfig[], options?: {
|
|
56
|
+
searchPath?: string;
|
|
57
|
+
}): Promise<PolicyPushPlan>;
|
|
58
|
+
/** Whether the push would change any row-level security. Kept and unstamped policies are not changes. */
|
|
59
|
+
export declare function policyPlanChanges(plan: PolicyPushPlan): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The plan as `db push --dry-run` prints it: `changes`, what the push does,
|
|
62
|
+
* and `notes`, what it leaves or cannot tell. Both empty when there is
|
|
63
|
+
* nothing to say.
|
|
64
|
+
*/
|
|
65
|
+
export declare function formatPolicyPushPlan(plan: PolicyPushPlan): {
|
|
66
|
+
changes: string[];
|
|
67
|
+
notes: string[];
|
|
68
|
+
};
|
|
69
|
+
/** One line for the push itself: the counts, or `null` when it changes no row-level security. */
|
|
70
|
+
export declare function summarizePolicyPushPlan(plan: PolicyPushPlan): string | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The constraints a collection cannot declare, and how `db push` keeps Atlas
|
|
3
|
+
* from dropping them.
|
|
4
|
+
*
|
|
5
|
+
* `db push` is declarative: Atlas makes each managed table match `schema.sql`,
|
|
6
|
+
* and anything on the table that `schema.sql` does not mention is planned as a
|
|
7
|
+
* drop. The collection model declares a table's primary key, its columns'
|
|
8
|
+
* `NOT NULL`, `UNIQUE` and foreign keys, and nothing else. So a hand-written
|
|
9
|
+
* `CHECK (total >= 0)` — or one an adopted database arrived with, which
|
|
10
|
+
* `schema introspect` reads as `validation.min: 0` — was dropped by the first
|
|
11
|
+
* push, in the same `ALTER TABLE` as whatever else the push changed, with no
|
|
12
|
+
* prompt. From then on the database accepted every row the constraint used to
|
|
13
|
+
* refuse, while the form still enforced the rule and so hid that it had gone.
|
|
14
|
+
*
|
|
15
|
+
* EXCLUDE constraints are the same case: Atlas inspects them and plans their
|
|
16
|
+
* drop the same way. Triggers and functions are not: Atlas's free tier does
|
|
17
|
+
* not inspect either, so it never plans a drop for one. Measured on the pinned
|
|
18
|
+
* atlas 1.2.3 against PG 18; `introspect-check-constraints-e2e` pins all four.
|
|
19
|
+
*
|
|
20
|
+
* Ownership, as with indexes (`getForeignIndexExcludes` in `cli-helpers.ts`)
|
|
21
|
+
* and policies: a constraint the desired state declares is
|
|
22
|
+
* Atlas's to manage, and every other CHECK or EXCLUDE is somebody else's and is
|
|
23
|
+
* kept out of the plan with `--exclude`. Today the desired state declares
|
|
24
|
+
* neither kind, so every one is kept. A rule nobody wants any more is dropped
|
|
25
|
+
* by hand (`ALTER TABLE … DROP CONSTRAINT …`), which is the only statement that
|
|
26
|
+
* can say so.
|
|
27
|
+
*
|
|
28
|
+
* Side-effect free, so it is unit-tested without Atlas or a database.
|
|
29
|
+
*/
|
|
30
|
+
/** A constraint kind the collection model has no way to declare. */
|
|
31
|
+
export type UndeclarableConstraintKind = "check" | "exclude";
|
|
32
|
+
/** A CHECK or EXCLUDE constraint, as the database holds it now. */
|
|
33
|
+
export interface ExistingConstraint {
|
|
34
|
+
schema: string;
|
|
35
|
+
table: string;
|
|
36
|
+
name: string;
|
|
37
|
+
kind: UndeclarableConstraintKind;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Every CHECK and EXCLUDE constraint on an ordinary or partitioned table
|
|
41
|
+
* outside the system schemas.
|
|
42
|
+
*
|
|
43
|
+
* `contype` `c` and `x` only. A primary key (`p`), `UNIQUE` (`u`), foreign key
|
|
44
|
+
* (`f`) and, from PG 18, a catalogued `NOT NULL` (`n`) are what a collection
|
|
45
|
+
* declares, so Atlas keeps managing them.
|
|
46
|
+
*/
|
|
47
|
+
export declare const UNDECLARABLE_CONSTRAINTS_SQL = "\n SELECT n.nspname AS \"schema\",\n c.relname AS \"table\",\n con.conname AS \"name\",\n CASE con.contype WHEN 'c' THEN 'check' ELSE 'exclude' END AS \"kind\"\n FROM pg_constraint con\n JOIN pg_class c ON c.oid = con.conrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE con.contype IN ('c', 'x')\n AND c.relkind IN ('r', 'p')\n AND n.nspname NOT IN ('pg_catalog', 'information_schema')\n AND n.nspname NOT LIKE 'pg\\_%'\n";
|
|
48
|
+
/**
|
|
49
|
+
* The CHECK and EXCLUDE constraint names a desired state (`schema.sql`)
|
|
50
|
+
* declares — Atlas's to manage, and so never excluded.
|
|
51
|
+
*/
|
|
52
|
+
export declare function declaredConstraintNames(desiredSql: string): Set<string>;
|
|
53
|
+
/**
|
|
54
|
+
* The `--exclude` patterns that keep Atlas from dropping the CHECK and EXCLUDE
|
|
55
|
+
* constraints the desired state does not declare. Three-part
|
|
56
|
+
* `schema.table.constraint`, which is what Atlas matches a constraint by: a
|
|
57
|
+
* two-part pattern reads as a table, matches nothing, and reports no error.
|
|
58
|
+
*/
|
|
59
|
+
export declare function undeclaredConstraintExcludes(existing: readonly ExistingConstraint[], desiredSql: string): string[];
|
|
@@ -151,6 +151,11 @@ export interface OrphanCleanup {
|
|
|
151
151
|
* policies belonging to something else sharing the database.
|
|
152
152
|
*/
|
|
153
153
|
export declare function dropOrphanedPolicies(client: Queryable, drift: PolicyDrift, collections: CollectionConfig[]): Promise<OrphanCleanup>;
|
|
154
|
+
/**
|
|
155
|
+
* Which orphans {@link dropOrphanedPolicies} drops and which it keeps, decided
|
|
156
|
+
* without dropping anything: what `db push --dry-run` lists.
|
|
157
|
+
*/
|
|
158
|
+
export declare function partitionOrphans(drift: PolicyDrift, collections: CollectionConfig[]): OrphanCleanup;
|
|
154
159
|
export declare const hasDrift: (d: PolicyDrift) => boolean;
|
|
155
160
|
/** Human-readable report; empty string when the database matches the config. */
|
|
156
161
|
export declare function formatPolicyDrift(drift: PolicyDrift): string;
|
|
@@ -61,6 +61,13 @@ export declare class BranchService {
|
|
|
61
61
|
* pane into a failure with a "Try again" that can never succeed.
|
|
62
62
|
*/
|
|
63
63
|
private assertBranchingSupported;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the `rebase.branches` registry exists. A database that has never
|
|
66
|
+
* had a branch made on it may not have it, and reading it there is an
|
|
67
|
+
* empty answer, not an error — nor a reason to create it. The CLI's `list`
|
|
68
|
+
* and `info` ask this rather than running the DDL that creates it.
|
|
69
|
+
*/
|
|
70
|
+
hasBranchRegistry(): Promise<boolean>;
|
|
64
71
|
/**
|
|
65
72
|
* Ensure the `rebase.branches` metadata table exists in the default database.
|
|
66
73
|
* Idempotent — safe to call on every startup.
|
|
@@ -106,6 +113,37 @@ export declare class BranchService {
|
|
|
106
113
|
* diagnostic that throws would replace a real error with its own.
|
|
107
114
|
*/
|
|
108
115
|
private describeBlockingConnections;
|
|
116
|
+
/**
|
|
117
|
+
* Run `operation` with no other session on `dbName`, disconnecting them
|
|
118
|
+
* first: what `--force` asks for.
|
|
119
|
+
*
|
|
120
|
+
* Disconnected, a client that reconnects — a running `rebase dev`'s
|
|
121
|
+
* realtime listener does — can be back before `CREATE DATABASE … TEMPLATE`
|
|
122
|
+
* or `DROP DATABASE` counts the sessions, and it failed on one about once
|
|
123
|
+
* in seven tries, saying to pass the `--force` that had been passed. So a
|
|
124
|
+
* refusal on a session still connected is retried, disconnecting again, a
|
|
125
|
+
* few times before it is reported.
|
|
126
|
+
*/
|
|
127
|
+
private disconnectingOthers;
|
|
128
|
+
/**
|
|
129
|
+
* Run `operation` with `dbName` refusing new connections, and open it
|
|
130
|
+
* again after, whatever happens.
|
|
131
|
+
*
|
|
132
|
+
* A client disconnected from the source — a running `rebase dev` holds a
|
|
133
|
+
* pool and a realtime listener — cannot then reconnect before the copy has
|
|
134
|
+
* counted the sessions on it. Postgres refuses `ALLOW_CONNECTIONS false` on
|
|
135
|
+
* the database a session is connected to, so both statements run from the
|
|
136
|
+
* server's `postgres` database, and they need the database's owner. Where
|
|
137
|
+
* either is missing, the retries of {@link disconnectingOthers} are what is
|
|
138
|
+
* left. A database that already refused connections is left as it was.
|
|
139
|
+
*
|
|
140
|
+
* Interrupted (Ctrl-C) while closed, it opens the database again before
|
|
141
|
+
* the process exits; one it could not open is named in the error, with the
|
|
142
|
+
* statement that does.
|
|
143
|
+
*/
|
|
144
|
+
private whileClosedToNewConnections;
|
|
145
|
+
/** `ALLOW_CONNECTIONS true` again, from the maintenance database, or an error that says how to do it by hand. */
|
|
146
|
+
private reopenToConnections;
|
|
109
147
|
/**
|
|
110
148
|
* Disconnect every other session on a database, and say how many.
|
|
111
149
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
3
|
+
import { n as __exportAll } from "./rolldown-runtime-V7rFbMRe.js";
|
|
4
4
|
import { isPostgresCollectionConfig, parseEnvBoolean } from "@rebasepro/types";
|
|
5
5
|
import { getTableName, resolveCollectionRelations } from "@rebasepro/common";
|
|
6
6
|
import { sha1Hex, truncateToBytes } from "@rebasepro/utils";
|
|
@@ -342,6 +342,68 @@ var foreignKeyIndexSpec = (schema, table, column) => {
|
|
|
342
342
|
};
|
|
343
343
|
};
|
|
344
344
|
//#endregion
|
|
345
|
+
//#region src/schema/atlas-exclude.ts
|
|
346
|
+
/**
|
|
347
|
+
* The names `db push` hands Atlas's `--exclude`, spelled so they match.
|
|
348
|
+
*
|
|
349
|
+
* An exclude is the only thing between `atlas schema apply --auto-approve` and
|
|
350
|
+
* an object Rebase does not own: a table no collection backs, a hand-written
|
|
351
|
+
* index, a CHECK constraint, the search and vector columns Rebase applies
|
|
352
|
+
* itself. Atlas reads each one as a glob split on `.`, so a name is not a
|
|
353
|
+
* pattern as it stands. Measured against the pinned 1.2.3:
|
|
354
|
+
*
|
|
355
|
+
* - a `.` in a name makes one more part, and Atlas refuses the whole command,
|
|
356
|
+
* `too many parts in pattern` — so every push fails on that database;
|
|
357
|
+
* - `[`, `]`, `*` and `?` are glob syntax. `[v1]` is a class matching `v` or
|
|
358
|
+
* `1`, so `idx[v1]` matches `idxv` and not the index called `idx[v1]`:
|
|
359
|
+
* nothing is excluded, nothing is reported, and Atlas plans the drop. For
|
|
360
|
+
* an index that drop is not gated, so it applied without a word.
|
|
361
|
+
*
|
|
362
|
+
* So each part is escaped on its own and the parts are joined: a `.` becomes
|
|
363
|
+
* `?`, which matches it (and any one character, so a pattern that also keeps a
|
|
364
|
+
* near-namesake errs on the side of keeping), and glob syntax is escaped with
|
|
365
|
+
* `\`, which Atlas reads as the literal.
|
|
366
|
+
*
|
|
367
|
+
* Code that reads these patterns back — the migration stripper, the generated
|
|
368
|
+
* column ownership check, the index ownership check — reads them with
|
|
369
|
+
* {@link excludePatternParts}, the exact inverse for a pattern built here.
|
|
370
|
+
*/
|
|
371
|
+
/** One part of an Atlas `--exclude` pattern that matches exactly this name. */
|
|
372
|
+
function atlasExcludeSegment(name) {
|
|
373
|
+
return name.replace(/[\\*?[\]]/g, (ch) => `\\${ch}`).replace(/\./g, "?");
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The pattern that matches exactly the object these names qualify:
|
|
377
|
+
* `(schema, table)` for a table, `(schema, table, object)` for a column, an
|
|
378
|
+
* index or a constraint. Three parts for anything on a table: a two-part
|
|
379
|
+
* pattern reads as a table, matches nothing, and reports no error.
|
|
380
|
+
*/
|
|
381
|
+
function atlasExcludePattern(...parts) {
|
|
382
|
+
return parts.map(atlasExcludeSegment).join(".");
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The names a pattern from {@link atlasExcludePattern} was built from, or
|
|
386
|
+
* `undefined` for one that is not a plain name — a wildcard such as `auth.*`.
|
|
387
|
+
*
|
|
388
|
+
* Exact for every pattern built there: a `\` escapes the character after it,
|
|
389
|
+
* and an unescaped `?` can only be a dot.
|
|
390
|
+
*/
|
|
391
|
+
function excludePatternParts(pattern) {
|
|
392
|
+
const parts = [];
|
|
393
|
+
for (const segment of pattern.split(".")) {
|
|
394
|
+
let name = "";
|
|
395
|
+
for (let i = 0; i < segment.length; i++) {
|
|
396
|
+
const ch = segment[i];
|
|
397
|
+
if (ch === "\\" && i + 1 < segment.length) name += segment[++i];
|
|
398
|
+
else if (ch === "?") name += ".";
|
|
399
|
+
else if (ch === "*" || ch === "[" || ch === "]") return;
|
|
400
|
+
else name += ch;
|
|
401
|
+
}
|
|
402
|
+
parts.push(name);
|
|
403
|
+
}
|
|
404
|
+
return parts;
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
345
407
|
//#region src/cli-output.ts
|
|
346
408
|
/**
|
|
347
409
|
* Terminal output for the `rebase db|schema|doctor` commands.
|
|
@@ -400,9 +462,52 @@ var wantsStack = () => parseEnvBoolean(process.env.REBASE_DEBUG) === true;
|
|
|
400
462
|
*/
|
|
401
463
|
var describeFailure = (error) => {
|
|
402
464
|
if (!(error instanceof Error)) return String(error);
|
|
403
|
-
|
|
465
|
+
const failedQuery = describeFailedQuery(error);
|
|
466
|
+
const lead = failedQuery?.reason ? `${failedQuery.reason}\n ` : "";
|
|
467
|
+
if (wantsStack() && error.stack) {
|
|
468
|
+
if (!failedQuery) return error.stack;
|
|
469
|
+
const opening = `${error.name}: ${error.message}`;
|
|
470
|
+
const frames = error.stack.startsWith(opening) ? error.stack.slice(opening.length) : `\n${error.stack}`;
|
|
471
|
+
return `${lead}${error.name}: ${failedQuery.query}${frames}`;
|
|
472
|
+
}
|
|
473
|
+
if (failedQuery) return `${lead}${failedQuery.query}\n Re-run with --debug for the stack trace.`;
|
|
404
474
|
return `${error.message}\n Re-run with --debug for the stack trace.`;
|
|
405
475
|
};
|
|
476
|
+
/**
|
|
477
|
+
* A failed query as a reader needs it: why it failed — Postgres' own reason
|
|
478
|
+
* with its SQLSTATE (`relation "nope_table" does not exist (42P01)`), or the
|
|
479
|
+
* driver's when Postgres never answered — and the query without the values it
|
|
480
|
+
* ran with. `null` for any other error.
|
|
481
|
+
*
|
|
482
|
+
* Drizzle reports a failed query as `Failed query: <sql>` and a `params:` line
|
|
483
|
+
* and keeps the error underneath in `cause`, so the message alone names a query
|
|
484
|
+
* and no reason: `rebase console -e` printed exactly that, `--debug` included.
|
|
485
|
+
* The values stay off the terminal: they are whatever the code passed, a
|
|
486
|
+
* password hash or a token as readily as an id.
|
|
487
|
+
*/
|
|
488
|
+
function describeFailedQuery(error) {
|
|
489
|
+
if (!error.message.startsWith("Failed query:")) return null;
|
|
490
|
+
const paramsAt = error.message.lastIndexOf("\nparams:");
|
|
491
|
+
const postgres = postgresError(error.cause);
|
|
492
|
+
return {
|
|
493
|
+
reason: postgres ? `${postgres.message} (${postgres.code})` : deepestMessage(error.cause),
|
|
494
|
+
query: paramsAt === -1 ? error.message : error.message.slice(0, paramsAt)
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
/** The error Postgres raised, from a cause chain: the one carrying a SQLSTATE. */
|
|
498
|
+
function postgresError(cause, depth = 0) {
|
|
499
|
+
if (!(cause instanceof Error) || depth > 5) return null;
|
|
500
|
+
if ("code" in cause && typeof cause.code === "string" && /^[0-9A-Z]{5}$/.test(cause.code) && cause.message) return {
|
|
501
|
+
code: cause.code,
|
|
502
|
+
message: cause.message
|
|
503
|
+
};
|
|
504
|
+
return postgresError(cause.cause, depth + 1);
|
|
505
|
+
}
|
|
506
|
+
/** The innermost message in a cause chain, or `null` when there is none. */
|
|
507
|
+
function deepestMessage(cause, depth = 0) {
|
|
508
|
+
if (!(cause instanceof Error) || depth > 5) return null;
|
|
509
|
+
return deepestMessage(cause.cause, depth + 1) ?? (cause.message || null);
|
|
510
|
+
}
|
|
406
511
|
//#endregion
|
|
407
512
|
//#region ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
408
513
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -806,6 +911,6 @@ Object.defineProperties(createChalk.prototype, styles);
|
|
|
806
911
|
var chalk = createChalk();
|
|
807
912
|
createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
808
913
|
//#endregion
|
|
809
|
-
export { outWarn as a,
|
|
914
|
+
export { sortIndexSpecs as _, outWarn as a, buildCollectionIndexSpecs as c, collection_index_exports as d, deriveIndexName as f, renderPredicate as g, leadsWithColumn as h, outError as i, collectionIndexStatement as l, isRebaseIndexName as m, describeFailure as n, atlasExcludePattern as o, foreignKeyIndexSpec as p, out as r, excludePatternParts as s, chalk as t, collectionIndexStatements as u };
|
|
810
915
|
|
|
811
|
-
//# sourceMappingURL=source-
|
|
916
|
+
//# sourceMappingURL=source-Bv5KPeIx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-Bv5KPeIx.js","names":["styles","process"],"sources":["../src/schema/collection-index.ts","../src/schema/atlas-exclude.ts","../src/cli-output.ts","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js"],"sourcesContent":["/**\n * The one place a collection's `indexes:` block becomes `CREATE INDEX`.\n *\n * Like `search-column.ts` and `vector-index.ts`, this module exists so the DDL\n * generator and the boot-time ensure render the *same* specification rather\n * than describing the same index twice, differently.\n *\n * ## Why every form here is core Postgres\n *\n * `rebase db push` runs `atlas schema apply`, which materialises the desired\n * state in a bare scratch database to plan against. `--exclude` does not\n * suppress that replay, and `CREATE EXTENSION` cannot go in the file. So an\n * index wanting `gin_trgm_ops` or `vector_cosine_ops` would parse, plan, and\n * then fail against a database the author has never heard of. Those are\n * refused here instead, and redirected to the feature that owns them: trigram\n * search is `search:`, ANN is a `vector` property.\n *\n * Verified against atlas v1.2.3 and Postgres 18 before this was written: plain,\n * composite with `DESC NULLS LAST`, partial, unique, covering `INCLUDE`, `GIN`\n * and expression indexes all parse, apply, and re-plan clean. The Atlas\n * limitation that forced the search carve-out is that it will not parse a file\n * containing a function *definition* — a function *call* inside an index is\n * fine. That is why this module needs no carve-out and search did.\n *\n * ## Why the name carries a hash\n *\n * `CREATE INDEX IF NOT EXISTS` is a **name** check, not a definition check. A\n * readable name means a changed declaration keeps the old index and reports\n * success, forever. Hashing the index's *semantics* into its name makes a\n * redefinition a different object: the new one is built before the old one is\n * dropped, there is never a window with no index, and drift detection reduces\n * to a set difference over names.\n */\nimport type { CollectionConfig, CollectionIndex, IndexPredicate, Property, ResolvedRelation } from \"@rebasepro/types\";\nimport { isPostgresCollectionConfig } from \"@rebasepro/types\";\nimport { getTableName, resolveCollectionRelations } from \"@rebasepro/common\";\nimport { sha1Hex, truncateToBytes } from \"@rebasepro/utils\";\n\n/** Resolve a property key to its column name. Injected to avoid an import cycle. */\nexport type ResolveColumnName = (propName: string, prop?: Property | null) => string;\n\nexport type IndexMethod = \"btree\" | \"gin\" | \"brin\";\n\n/** A key column, with the ordering Postgres will actually apply. */\nexport interface ResolvedIndexKey {\n column: string;\n /** Always concrete. `btree` defaults ascending; unordered methods report `asc`. */\n direction: \"asc\" | \"desc\";\n /** Postgres's own default: `last` under `asc`, `first` under `desc`. */\n nulls: \"first\" | \"last\";\n}\n\n/** A predicate resolved onto column names, ready to render and to hash. */\nexport type ResolvedPredicate =\n | { column: string; op: \"=\" | \"!=\" | \"<\" | \"<=\" | \">\" | \">=\"; value: string | number | boolean }\n | { column: string; op: \"is null\" | \"is not null\" }\n | { column: string; op: \"in\"; value: readonly (string | number)[] }\n | { and: readonly ResolvedPredicate[] };\n\n/** One index, fully resolved. The only shape the renderers accept. */\nexport interface CollectionIndexSpec {\n schema: string;\n table: string;\n method: IndexMethod;\n unique: boolean;\n keys: ResolvedIndexKey[];\n include: string[];\n predicate: ResolvedPredicate | null;\n /** The author's one-line justification. Never enters the name. */\n reason: string;\n /** Derived by {@link deriveIndexName}. Frozen — see the module comment. */\n indexName: string;\n /**\n * Set when Rebase derived this index for a foreign key rather than anybody\n * declaring it — see {@link foreignKeyIndexSpec}. Never enters the name, so\n * the derived index and a declared one over the same column are one object.\n *\n * Read by exactly one consumer: boot-ensure, which builds these in the\n * background on a table that already exists instead of holding the boot\n * for the build. Every renderer treats them like any other index.\n */\n derived?: \"foreign-key\";\n}\n\n/**\n * A declaration that cannot become an index.\n *\n * Thrown at build time, naming the collection and the array position, because\n * the alternative is a `CREATE INDEX` that fails during a push with a Postgres\n * error mentioning a column the author never wrote.\n */\nexport class CollectionIndexConfigError extends Error {\n readonly collectionSlug: string;\n readonly position: number;\n\n constructor(collectionSlug: string, position: number, message: string) {\n super(`${collectionSlug}.indexes[${position}]: ${message}`);\n this.name = \"CollectionIndexConfigError\";\n this.collectionSlug = collectionSlug;\n this.position = position;\n }\n}\n\n/** Postgres allows 32 key columns. See the doc comment on `on`. */\nexport const MAX_INDEX_KEYS = 5;\n\n/**\n * `_ix`/`_ux` plus `_` plus 7 hex — the part of the name that must always\n * survive truncation, and therefore is never inside the truncated portion.\n */\nconst NAME_SUFFIX_BYTES = 11;\n\n/**\n * Every Rebase-managed index name, and nothing else.\n *\n * The terminal `_ix_`/`_ux_` plus exactly seven lowercase hex characters is\n * what separates this scheme from every other producer in the codebase —\n * `_fkey`, `_gin`, `_trgm`, `_pkey`, `_key`, the vector distances, and the\n * `idx_` prefix auth uses. `_idx` was rejected as a tail because it is already\n * taken for real: `users_email_verification_token_idx` is byte-for-byte what a\n * naive `<table>_<column>_idx` derives on an auth-enabled `users` collection.\n *\n * Load-bearing for safety, not just tidiness. An index that does NOT match this\n * belongs to somebody else — a hand-written one, or one an introspected\n * database arrived with — and is excluded from the Atlas diff so the push\n * cannot drop it.\n */\nexport const isRebaseIndexName = (name: string): boolean => /_(?:ix|ux)_[0-9a-f]{7}$/.test(name);\n\nconst isOrderedMethod = (method: IndexMethod): boolean => method === \"btree\";\n\n/**\n * The parts of an index that decide what it *is*.\n *\n * A semantic projection, not the rendered statement — the same arrangement as\n * `getPolicyNameHash`, and for the same reason. A change to how this file\n * formats SQL (eliding a default `USING btree`, quoting differently, emitting\n * `NULLS LAST` explicitly) must not silently rename every index in every\n * deployed database. Hashing generator output would make every cosmetic edit a\n * fleet-wide DROP + CREATE.\n *\n * `reason` is deliberately absent: rewording a comment must not rebuild an\n * index. `nulls` is the *effective* placement, so writing Postgres's own\n * default down is a no-op rather than a redefinition.\n *\n * `v` is the only escape hatch, and it is expensive on purpose: bumping it\n * renames every index in the field.\n */\nexport const indexFingerprint = (spec: Omit<CollectionIndexSpec, \"indexName\">): string => sha1Hex(JSON.stringify({\n v: 1,\n s: spec.schema,\n t: spec.table,\n m: spec.method,\n u: spec.unique,\n k: spec.keys.map(k => [k.column, k.direction, k.nulls]),\n i: spec.include,\n w: spec.predicate\n})).substring(0, 7);\n\n/**\n * `<table>_<columns>_ix_<hash>`, or `_ux_` when unique.\n *\n * Truncation eats the readable head and never the hash. `toPostgresIdentifier`\n * truncates the whole string at 63 bytes, which on a hashed name would cut off\n * the one part that makes it unique — the failure already frozen into\n * `contracts/derived-names.txt`, where a foreign key is recorded with its\n * `_fkey` suffix truncated away, so a second foreign key on that table would\n * derive a byte-identical name.\n */\nexport const deriveIndexName = (spec: Omit<CollectionIndexSpec, \"indexName\">): string => {\n // Built suffix-first, so the two parts that carry meaning — the `_ix`/`_ux`\n // tag that {@link isRebaseIndexName} matches on, and the fingerprint — are\n // never in the string being truncated. Composing the whole name and then\n // trimming it to 63 loses both, silently: an 80-byte table name yields\n // `xxxx…xxx_610bb9e` with the tag gone, so the index stops being\n // recognisable as Rebase's and `db push` treats it as foreign forever.\n const tag = spec.unique ? \"ux\" : \"ix\";\n const suffix = `_${tag}_${indexFingerprint(spec)}`;\n const readable = `${spec.table}_${spec.keys.map(k => k.column).join(\"_\")}`;\n return `${truncateToBytes(readable, 63 - NAME_SUFFIX_BYTES)}${suffix}`;\n};\n\nconst quoteLiteral = (value: string | number | boolean): string => {\n if (typeof value === \"number\") return String(value);\n if (typeof value === \"boolean\") return value ? \"TRUE\" : \"FALSE\";\n return `'${value.replace(/'/g, \"''\")}'`;\n};\n\n/** Render a resolved predicate as the body of a `WHERE` clause. */\nexport const renderPredicate = (predicate: ResolvedPredicate): string => {\n if (\"and\" in predicate) {\n // Always parenthesised. Postgres would apply the same precedence\n // without it, but the rendered SQL is read by people diffing a plan.\n return predicate.and.map(renderPredicate).join(\" AND \");\n }\n switch (predicate.op) {\n case \"is null\":\n case \"is not null\":\n return `\"${predicate.column}\" ${predicate.op.toUpperCase()}`;\n case \"in\":\n return `\"${predicate.column}\" IN (${predicate.value.map(quoteLiteral).join(\", \")})`;\n default:\n return `\"${predicate.column}\" ${predicate.op} ${quoteLiteral(predicate.value)}`;\n }\n};\n\n/**\n * The `CREATE INDEX` for one spec.\n *\n * `concurrently` is a parameter rather than a string replacement on the way\n * out. `search-column.ts` and `vector-index.ts` both reach for\n * `.replace(\"CREATE INDEX IF NOT EXISTS\", …)` instead, which silently does\n * nothing for a UNIQUE index — the rendered text is `CREATE UNIQUE INDEX …`\n * and the pattern never matches.\n */\nexport const collectionIndexStatement = (\n spec: CollectionIndexSpec,\n options: { concurrently?: boolean; ifNotExists?: boolean } = {}\n): string => {\n const unique = spec.unique ? \"UNIQUE \" : \"\";\n const concurrently = options.concurrently ? \"CONCURRENTLY \" : \"\";\n const ifNotExists = options.ifNotExists ? \"IF NOT EXISTS \" : \"\";\n const using = spec.method === \"btree\" ? \"\" : ` USING ${spec.method}`;\n\n const keys = spec.keys.map(k => {\n if (!isOrderedMethod(spec.method)) return `\"${k.column}\"`;\n const direction = k.direction === \"desc\" ? \" DESC\" : \"\";\n // Emitted only when it is not what the direction already implies, so\n // the rendered SQL matches what `pg_get_indexdef` reads back and a\n // re-plan finds no difference.\n const impliedNulls = k.direction === \"desc\" ? \"first\" : \"last\";\n const nulls = k.nulls === impliedNulls ? \"\" : ` NULLS ${k.nulls.toUpperCase()}`;\n return `\"${k.column}\"${direction}${nulls}`;\n }).join(\", \");\n\n const include = spec.include.length > 0\n ? ` INCLUDE (${spec.include.map(c => `\"${c}\"`).join(\", \")})`\n : \"\";\n const where = spec.predicate ? ` WHERE ${renderPredicate(spec.predicate)}` : \"\";\n\n return `CREATE ${unique}INDEX ${concurrently}${ifNotExists}\"${spec.indexName}\" ` +\n `ON \"${spec.schema}\".\"${spec.table}\"${using} (${keys})${include}${where};`;\n};\n\nexport const collectionIndexStatements = (\n specs: readonly CollectionIndexSpec[],\n options: { concurrently?: boolean; ifNotExists?: boolean } = {}\n): string[] => specs.map(spec => collectionIndexStatement(spec, options));\n\nconst relationOf = (\n collection: CollectionConfig,\n propKey: string\n): ResolvedRelation | undefined => resolveCollectionRelations(collection)[propKey];\n\n/**\n * The column a property key indexes.\n *\n * A `belongsTo` resolves to its `localKey` — `primaryCategory` becomes\n * `primary_category_id` — which is the case an index is most often wanted for\n * and the case where the property key and the column differ. Everything else\n * goes through `resolveColumnName`.\n *\n * The other relation kinds have no local column at all: the foreign key lives\n * on the target's table, or in a junction. Indexing them here is refused\n * rather than resolved to a column that does not exist.\n */\nexport const resolveIndexableColumn = (\n collection: CollectionConfig,\n propKey: string,\n resolveColumnName: ResolveColumnName,\n fail: (message: string) => never\n): string => {\n const relation = relationOf(collection, propKey);\n if (relation) {\n if (relation.kind === \"belongsTo\") return relation.localKey;\n fail(\n `\"${propKey}\" is a ${relation.kind} relation, which has no column on this table — ` +\n `the foreign key lives on \"${relation.targetSlug}\". Declare the index there.`\n );\n }\n\n const property = collection.properties?.[propKey] as Property | undefined;\n if (!property) {\n fail(`\"${propKey}\" is not a property of this collection.`);\n }\n return resolveColumnName(propKey, property);\n};\n\nconst resolvePredicate = (\n collection: CollectionConfig,\n predicate: IndexPredicate,\n resolveColumnName: ResolveColumnName,\n fail: (message: string) => never\n): ResolvedPredicate => {\n if (\"and\" in predicate) {\n return { and: predicate.and.map(p => resolvePredicate(collection, p, resolveColumnName, fail)) };\n }\n const column = resolveIndexableColumn(collection, predicate.prop, resolveColumnName, fail);\n switch (predicate.op) {\n case \"is null\":\n case \"is not null\":\n return { column, op: predicate.op };\n case \"in\": {\n const seen = new Set(predicate.value);\n if (seen.size !== predicate.value.length) {\n fail(`the \\`in\\` list for \"${predicate.prop}\" repeats a value, which changes nothing.`);\n }\n return { column, op: \"in\", value: [...predicate.value] };\n }\n default:\n return { column, op: predicate.op, value: predicate.value };\n }\n};\n\n/** The primary key columns of a collection, for the \"you already have this\" refusal. */\nconst primaryKeyColumns = (collection: CollectionConfig, resolveColumnName: ResolveColumnName): string[] =>\n Object.entries(collection.properties ?? {})\n .filter(([, prop]) => prop && typeof prop === \"object\" && \"isId\" in prop && Boolean((prop as { isId?: unknown }).isId))\n .map(([key, prop]) => resolveColumnName(key, prop as Property));\n\n/**\n * Every index one collection declares, resolved and named.\n *\n * Throws {@link CollectionIndexConfigError} rather than dropping a bad entry:\n * an index that silently does not exist is the failure mode this whole feature\n * is here to remove.\n */\nexport const buildCollectionIndexSpecs = (\n collection: CollectionConfig,\n resolveColumnName: ResolveColumnName\n): CollectionIndexSpec[] => {\n if (!isPostgresCollectionConfig(collection)) return [];\n const declared = collection.indexes;\n if (!declared || declared.length === 0) return [];\n\n const slug = collection.slug ?? getTableName(collection);\n const schema = collection.schema ?? \"public\";\n const table = getTableName(collection);\n const pk = primaryKeyColumns(collection, resolveColumnName).sort().join(\",\");\n\n const specs: CollectionIndexSpec[] = [];\n const byName = new Map<string, number>();\n\n declared.forEach((index: CollectionIndex, position: number) => {\n const fail = (message: string): never => {\n throw new CollectionIndexConfigError(slug, position, message);\n };\n\n if (typeof index.reason !== \"string\" || index.reason.trim() === \"\") {\n fail(\"`reason` is required — see the doc comment. An index nobody can justify is one nobody can delete.\");\n }\n if (!Array.isArray(index.on) || index.on.length === 0) {\n fail(\"`on` must name at least one property.\");\n }\n if (index.on.length > MAX_INDEX_KEYS) {\n fail(`\\`on\\` has ${index.on.length} keys; the limit is ${MAX_INDEX_KEYS}. Payload columns belong in \\`include\\`.`);\n }\n\n const method: IndexMethod = index.using ?? \"btree\";\n const unique = method === \"btree\" && Boolean((index as { unique?: boolean }).unique);\n if (!isOrderedMethod(method)) {\n for (const key of index.on) {\n if (typeof key !== \"string\" && (\"direction\" in key || \"nulls\" in key)) {\n fail(`access method \"${method}\" does not support ASC/DESC or NULLS options.`);\n }\n }\n }\n\n const keys: ResolvedIndexKey[] = index.on.map(key => {\n const propKey = typeof key === \"string\" ? key : key.prop;\n const column = resolveIndexableColumn(collection, propKey, resolveColumnName, fail);\n const direction = (typeof key === \"string\" ? undefined : (key as { direction?: \"asc\" | \"desc\" }).direction) ?? \"asc\";\n const nulls = (typeof key === \"string\" ? undefined : (key as { nulls?: \"first\" | \"last\" }).nulls)\n ?? (direction === \"desc\" ? \"first\" : \"last\");\n return { column, direction, nulls };\n });\n\n const duplicateKey = keys.map(k => k.column).find((c, i, all) => all.indexOf(c) !== i);\n if (duplicateKey) fail(`\"${duplicateKey}\" appears twice in \\`on\\`.`);\n\n if (keys.map(k => k.column).sort().join(\",\") === pk && pk !== \"\") {\n fail(`this is the primary key — \"${table}_pkey\" already indexes exactly these columns.`);\n }\n\n const include = ((index as { include?: readonly string[] }).include ?? [])\n .map(propKey => resolveIndexableColumn(collection, propKey, resolveColumnName, fail));\n const overlap = include.find(c => keys.some(k => k.column === c));\n if (overlap) fail(`\"${overlap}\" is in both \\`on\\` and \\`include\\`; Postgres rejects the overlap.`);\n\n if (unique && keys.length === 1) {\n const propKey = typeof index.on[0] === \"string\" ? index.on[0] as string : (index.on[0] as { prop: string }).prop;\n const property = collection.properties?.[propKey] as { validation?: { unique?: boolean } } | undefined;\n if (property?.validation?.unique) {\n fail(\n `\"${propKey}\" already declares \\`validation.unique\\`, which compiles to an inline UNIQUE. ` +\n `Two declarations of one guarantee — remove one.`\n );\n }\n }\n\n const predicate = index.where\n ? resolvePredicate(collection, index.where, resolveColumnName, fail)\n : null;\n\n const withoutName = { schema, table, method, unique, keys, include, predicate, reason: index.reason };\n const indexName = deriveIndexName(withoutName);\n\n const clash = byName.get(indexName);\n if (clash !== undefined) {\n fail(`derives the same name as indexes[${clash}] — they are the same index declared twice.`);\n }\n byName.set(indexName, position);\n\n specs.push({ ...withoutName, indexName });\n });\n\n return specs;\n};\n\n/**\n * Every declared index across a set of collections, in a stable order.\n *\n * Sorted because the result reaches `schema.sql`, which `doctor` string-\n * compares against a regenerated copy — `generatePostgresDdl` does not sort its\n * collections, so leaving this in declaration order would make the artifact\n * depend on the order files happened to load in.\n */\nexport const buildCollectionIndexPlan = (\n collections: readonly CollectionConfig[],\n resolveColumnName: ResolveColumnName\n): CollectionIndexSpec[] =>\n sortIndexSpecs(collections.flatMap(collection => buildCollectionIndexSpecs(collection, resolveColumnName)));\n\n/**\n * The stable order every consumer of a set of index specs uses.\n *\n * Exported because the boot-time diff reads the specs off the schema plan\n * rather than rebuilding them, and it has to reach the same order the CLI's\n * exclude list and `schema.sql` do — a second sort written out beside this one\n * is a second order the moment either is edited.\n */\nexport const sortIndexSpecs = (specs: readonly CollectionIndexSpec[]): CollectionIndexSpec[] =>\n [...specs].sort((a, b) =>\n a.schema.localeCompare(b.schema) ||\n a.table.localeCompare(b.table) ||\n a.indexName.localeCompare(b.indexName));\n\n// ── Foreign-key indexes ──────────────────────────────────────────────────────\n\n/**\n * The `reason` a derived foreign-key index carries. Never part of the name —\n * see {@link indexFingerprint} — so rewording it renames nothing.\n */\nexport const FOREIGN_KEY_INDEX_REASON =\n \"Derived for a foreign key: Postgres indexes the key a constraint points at, never the column holding it.\";\n\n/**\n * Whether an index already serves an equality lookup on `column` alone.\n *\n * A btree whose *leading* key is the column does, unique or not — that is the\n * prefix rule, and it is why a composite `(author_id, created_at)` makes a\n * second index on `author_id` pure write amplification. A partial index does\n * not: it serves only the rows its predicate admits, and a foreign-key lookup\n * has to reach every row. Nor does GIN or BRIN, which answer different\n * questions than \"the rows whose key is one of these\".\n */\nexport const leadsWithColumn = (spec: Pick<CollectionIndexSpec, \"method\" | \"predicate\" | \"keys\">, column: string): boolean =>\n spec.method === \"btree\" && spec.predicate === null && spec.keys[0]?.column === column;\n\n/**\n * The btree a foreign-key column gets when nothing else already leads with it.\n *\n * Postgres creates the index a foreign key *references* (the target's primary\n * key) and never the one on the column *holding* it. Every read from the other\n * side of the link filters on that column — a `hasMany`/`hasOne` include, a\n * nested listing (`/authors/5/posts`, page and count), the reverse side of a\n * many-to-many — and so does the `ON DELETE` check when a target row goes. With\n * no index each of those is a sequential scan of the child table: measured at\n * 13 ms for 25 parents over 100k children, and about 250 ms per nested listing\n * at a million.\n *\n * Named by {@link deriveIndexName} like every other index, so it is a\n * Rebase-managed name (`_ix_<fingerprint>`), it is in the Atlas diff, and it\n * is byte-for-byte the name an author's own plain index on the column would\n * derive. That identity is what makes the derived index and a declared one the\n * same object rather than two.\n */\nexport const foreignKeyIndexSpec = (schema: string, table: string, column: string): CollectionIndexSpec => {\n const withoutName = {\n schema,\n table,\n method: \"btree\" as const,\n unique: false,\n keys: [{ column, direction: \"asc\" as const, nulls: \"last\" as const }],\n include: [],\n predicate: null,\n reason: FOREIGN_KEY_INDEX_REASON\n };\n return { ...withoutName, indexName: deriveIndexName(withoutName), derived: \"foreign-key\" };\n};\n","/**\n * The names `db push` hands Atlas's `--exclude`, spelled so they match.\n *\n * An exclude is the only thing between `atlas schema apply --auto-approve` and\n * an object Rebase does not own: a table no collection backs, a hand-written\n * index, a CHECK constraint, the search and vector columns Rebase applies\n * itself. Atlas reads each one as a glob split on `.`, so a name is not a\n * pattern as it stands. Measured against the pinned 1.2.3:\n *\n * - a `.` in a name makes one more part, and Atlas refuses the whole command,\n * `too many parts in pattern` — so every push fails on that database;\n * - `[`, `]`, `*` and `?` are glob syntax. `[v1]` is a class matching `v` or\n * `1`, so `idx[v1]` matches `idxv` and not the index called `idx[v1]`:\n * nothing is excluded, nothing is reported, and Atlas plans the drop. For\n * an index that drop is not gated, so it applied without a word.\n *\n * So each part is escaped on its own and the parts are joined: a `.` becomes\n * `?`, which matches it (and any one character, so a pattern that also keeps a\n * near-namesake errs on the side of keeping), and glob syntax is escaped with\n * `\\`, which Atlas reads as the literal.\n *\n * Code that reads these patterns back — the migration stripper, the generated\n * column ownership check, the index ownership check — reads them with\n * {@link excludePatternParts}, the exact inverse for a pattern built here.\n */\n\n/** One part of an Atlas `--exclude` pattern that matches exactly this name. */\nexport function atlasExcludeSegment(name: string): string {\n return name.replace(/[\\\\*?[\\]]/g, ch => `\\\\${ch}`).replace(/\\./g, \"?\");\n}\n\n/**\n * The pattern that matches exactly the object these names qualify:\n * `(schema, table)` for a table, `(schema, table, object)` for a column, an\n * index or a constraint. Three parts for anything on a table: a two-part\n * pattern reads as a table, matches nothing, and reports no error.\n */\nexport function atlasExcludePattern(...parts: string[]): string {\n return parts.map(atlasExcludeSegment).join(\".\");\n}\n\n/**\n * The names a pattern from {@link atlasExcludePattern} was built from, or\n * `undefined` for one that is not a plain name — a wildcard such as `auth.*`.\n *\n * Exact for every pattern built there: a `\\` escapes the character after it,\n * and an unescaped `?` can only be a dot.\n */\nexport function excludePatternParts(pattern: string): string[] | undefined {\n const parts: string[] = [];\n for (const segment of pattern.split(\".\")) {\n let name = \"\";\n for (let i = 0; i < segment.length; i++) {\n const ch = segment[i];\n if (ch === \"\\\\\" && i + 1 < segment.length) {\n name += segment[++i];\n } else if (ch === \"?\") {\n name += \".\";\n } else if (ch === \"*\" || ch === \"[\" || ch === \"]\") {\n return undefined;\n } else {\n name += ch;\n }\n }\n parts.push(name);\n }\n return parts;\n}\n","/**\n * Terminal output for the `rebase db|schema|doctor` commands.\n *\n * These commands used to write every line through `logger`, and that is a\n * category error with three separate consequences:\n *\n * - `logger` prefixes each line with its own level, so a box-drawn report\n * arrived as `ℹ️ [INFO] ┌─ ✗ Missing Column ───` and the frame no longer\n * lined up with anything;\n * - `logger` is gated by `LOG_LEVEL`, which ships in the scaffold's own\n * `.env.example` — a developer who quietened their dev server with\n * `LOG_LEVEL=warn` got a `rebase db push` that printed almost nothing and\n * still exited non-zero, indistinguishable from a crash;\n * - under `NODE_ENV=production` `logger` emits JSON, so the whole report\n * became log records with the chalk escape codes embedded in them.\n *\n * A CLI's report *is* its return value. It goes to the terminal unconditionally\n * and unadorned. `packages/cli` has always written its output this way; this is\n * the same three functions for the plugin CLI that `rebase` delegates to.\n *\n * `logger` still belongs in this package's *runtime* — a request handler has no\n * terminal and its lines want levels, timestamps and redaction. The rule is the\n * caller, not the severity: anything a developer reads because they typed a\n * command goes here, anything a server emits while running goes to `logger`.\n *\n * Errors and warnings go to stderr so `rebase db push > plan.txt` keeps the\n * diagnosis on the terminal where it is readable.\n */\nimport { parseEnvBoolean } from \"@rebasepro/types\";\n\n/** One line of human-facing output on stdout. */\nexport const out = (line = \"\"): void => {\n console.log(line);\n};\n\n/** One line of human-facing warning output on stderr. */\nexport const outWarn = (line = \"\"): void => {\n console.warn(line);\n};\n\n/** One line of human-facing error output on stderr. */\nexport const outError = (line = \"\"): void => {\n console.error(line);\n};\n\n/**\n * Whether a failure should be printed with its stack — `rebase --debug`, which\n * the launcher passes down as `REBASE_DEBUG`, or `REBASE_DEBUG` set by hand.\n */\nexport const wantsStack = (): boolean => parseEnvBoolean(process.env.REBASE_DEBUG) === true;\n\n/**\n * An error as a person reads it: its message, and its stack only under\n * `--debug`.\n *\n * The rule `rebase` itself follows (`bin/rebase.js`). These commands run in a\n * child process the launcher's handler never sees, so a syntax error in a\n * collection file reached the terminal as `Doctor failed CollectionConfigError:`\n * followed by twenty frames of loader internals, under a sentence that already\n * said which file and which line.\n */\nexport const describeFailure = (error: unknown): string => {\n if (!(error instanceof Error)) return String(error);\n const failedQuery = describeFailedQuery(error);\n const lead = failedQuery?.reason ? `${failedQuery.reason}\\n ` : \"\";\n if (wantsStack() && error.stack) {\n if (!failedQuery) return error.stack;\n // The stack opens with the message, `params:` line and all.\n const opening = `${error.name}: ${error.message}`;\n const frames = error.stack.startsWith(opening) ? error.stack.slice(opening.length) : `\\n${error.stack}`;\n return `${lead}${error.name}: ${failedQuery.query}${frames}`;\n }\n if (failedQuery) return `${lead}${failedQuery.query}\\n Re-run with --debug for the stack trace.`;\n return `${error.message}\\n Re-run with --debug for the stack trace.`;\n};\n\n/**\n * A failed query as a reader needs it: why it failed — Postgres' own reason\n * with its SQLSTATE (`relation \"nope_table\" does not exist (42P01)`), or the\n * driver's when Postgres never answered — and the query without the values it\n * ran with. `null` for any other error.\n *\n * Drizzle reports a failed query as `Failed query: <sql>` and a `params:` line\n * and keeps the error underneath in `cause`, so the message alone names a query\n * and no reason: `rebase console -e` printed exactly that, `--debug` included.\n * The values stay off the terminal: they are whatever the code passed, a\n * password hash or a token as readily as an id.\n */\nfunction describeFailedQuery(error: Error): { reason: string | null; query: string } | null {\n if (!error.message.startsWith(\"Failed query:\")) return null;\n const paramsAt = error.message.lastIndexOf(\"\\nparams:\");\n const postgres = postgresError(error.cause);\n return {\n reason: postgres ? `${postgres.message} (${postgres.code})` : deepestMessage(error.cause),\n query: paramsAt === -1 ? error.message : error.message.slice(0, paramsAt)\n };\n}\n\n/** The error Postgres raised, from a cause chain: the one carrying a SQLSTATE. */\nfunction postgresError(cause: unknown, depth = 0): { code: string; message: string } | null {\n if (!(cause instanceof Error) || depth > 5) return null;\n if (\"code\" in cause && typeof cause.code === \"string\" && /^[0-9A-Z]{5}$/.test(cause.code) && cause.message) {\n return { code: cause.code, message: cause.message };\n }\n return postgresError(cause.cause, depth + 1);\n}\n\n/** The innermost message in a cause chain, or `null` when there is none. */\nfunction deepestMessage(cause: unknown, depth = 0): string | null {\n if (!(cause instanceof Error) || depth > 5) return null;\n return deepestMessage(cause.cause, depth + 1) ?? (cause.message || null);\n}\n","const ANSI_BACKGROUND_OFFSET = 10;\n\nconst wrapAnsi16 = (offset = 0) => code => `\\u001B[${code + offset}m`;\n\nconst wrapAnsi256 = (offset = 0) => code => `\\u001B[${38 + offset};5;${code}m`;\n\nconst wrapAnsi16m = (offset = 0) => (red, green, blue) => `\\u001B[${38 + offset};2;${red};${green};${blue}m`;\n\nconst styles = {\n\tmodifier: {\n\t\treset: [0, 0],\n\t\t// 21 isn't widely supported and 22 does the same thing\n\t\tbold: [1, 22],\n\t\tdim: [2, 22],\n\t\titalic: [3, 23],\n\t\tunderline: [4, 24],\n\t\toverline: [53, 55],\n\t\tinverse: [7, 27],\n\t\thidden: [8, 28],\n\t\tstrikethrough: [9, 29],\n\t},\n\tcolor: {\n\t\tblack: [30, 39],\n\t\tred: [31, 39],\n\t\tgreen: [32, 39],\n\t\tyellow: [33, 39],\n\t\tblue: [34, 39],\n\t\tmagenta: [35, 39],\n\t\tcyan: [36, 39],\n\t\twhite: [37, 39],\n\n\t\t// Bright color\n\t\tblackBright: [90, 39],\n\t\tgray: [90, 39], // Alias of `blackBright`\n\t\tgrey: [90, 39], // Alias of `blackBright`\n\t\tredBright: [91, 39],\n\t\tgreenBright: [92, 39],\n\t\tyellowBright: [93, 39],\n\t\tblueBright: [94, 39],\n\t\tmagentaBright: [95, 39],\n\t\tcyanBright: [96, 39],\n\t\twhiteBright: [97, 39],\n\t},\n\tbgColor: {\n\t\tbgBlack: [40, 49],\n\t\tbgRed: [41, 49],\n\t\tbgGreen: [42, 49],\n\t\tbgYellow: [43, 49],\n\t\tbgBlue: [44, 49],\n\t\tbgMagenta: [45, 49],\n\t\tbgCyan: [46, 49],\n\t\tbgWhite: [47, 49],\n\n\t\t// Bright color\n\t\tbgBlackBright: [100, 49],\n\t\tbgGray: [100, 49], // Alias of `bgBlackBright`\n\t\tbgGrey: [100, 49], // Alias of `bgBlackBright`\n\t\tbgRedBright: [101, 49],\n\t\tbgGreenBright: [102, 49],\n\t\tbgYellowBright: [103, 49],\n\t\tbgBlueBright: [104, 49],\n\t\tbgMagentaBright: [105, 49],\n\t\tbgCyanBright: [106, 49],\n\t\tbgWhiteBright: [107, 49],\n\t},\n};\n\nexport const modifierNames = Object.keys(styles.modifier);\nexport const foregroundColorNames = Object.keys(styles.color);\nexport const backgroundColorNames = Object.keys(styles.bgColor);\nexport const colorNames = [...foregroundColorNames, ...backgroundColorNames];\n\nfunction assembleStyles() {\n\tconst codes = new Map();\n\n\tfor (const [groupName, group] of Object.entries(styles)) {\n\t\tfor (const [styleName, style] of Object.entries(group)) {\n\t\t\tstyles[styleName] = {\n\t\t\t\topen: `\\u001B[${style[0]}m`,\n\t\t\t\tclose: `\\u001B[${style[1]}m`,\n\t\t\t};\n\n\t\t\tgroup[styleName] = styles[styleName];\n\n\t\t\tcodes.set(style[0], style[1]);\n\t\t}\n\n\t\tObject.defineProperty(styles, groupName, {\n\t\t\tvalue: group,\n\t\t\tenumerable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(styles, 'codes', {\n\t\tvalue: codes,\n\t\tenumerable: false,\n\t});\n\n\tstyles.color.close = '\\u001B[39m';\n\tstyles.bgColor.close = '\\u001B[49m';\n\n\tstyles.color.ansi = wrapAnsi16();\n\tstyles.color.ansi256 = wrapAnsi256();\n\tstyles.color.ansi16m = wrapAnsi16m();\n\tstyles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);\n\n\t// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js\n\tObject.defineProperties(styles, {\n\t\trgbToAnsi256: {\n\t\t\tvalue(red, green, blue) {\n\t\t\t\t// We use the extended greyscale palette here, with the exception of\n\t\t\t\t// black and white. normal palette only has 4 greyscale shades.\n\t\t\t\tif (red === green && green === blue) {\n\t\t\t\t\tif (red < 8) {\n\t\t\t\t\t\treturn 16;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (red > 248) {\n\t\t\t\t\t\treturn 231;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Math.round(((red - 8) / 247) * 24) + 232;\n\t\t\t\t}\n\n\t\t\t\treturn 16\n\t\t\t\t\t+ (36 * Math.round(red / 255 * 5))\n\t\t\t\t\t+ (6 * Math.round(green / 255 * 5))\n\t\t\t\t\t+ Math.round(blue / 255 * 5);\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToRgb: {\n\t\t\tvalue(hex) {\n\t\t\t\tconst matches = /[a-f\\d]{6}|[a-f\\d]{3}/i.exec(hex.toString(16));\n\t\t\t\tif (!matches) {\n\t\t\t\t\treturn [0, 0, 0];\n\t\t\t\t}\n\n\t\t\t\tlet [colorString] = matches;\n\n\t\t\t\tif (colorString.length === 3) {\n\t\t\t\t\tcolorString = [...colorString].map(character => character + character).join('');\n\t\t\t\t}\n\n\t\t\t\tconst integer = Number.parseInt(colorString, 16);\n\n\t\t\t\treturn [\n\t\t\t\t\t/* eslint-disable no-bitwise */\n\t\t\t\t\t(integer >> 16) & 0xFF,\n\t\t\t\t\t(integer >> 8) & 0xFF,\n\t\t\t\t\tinteger & 0xFF,\n\t\t\t\t\t/* eslint-enable no-bitwise */\n\t\t\t\t];\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi256: {\n\t\t\tvalue: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t\tansi256ToAnsi: {\n\t\t\tvalue(code) {\n\t\t\t\tif (code < 8) {\n\t\t\t\t\treturn 30 + code;\n\t\t\t\t}\n\n\t\t\t\tif (code < 16) {\n\t\t\t\t\treturn 90 + (code - 8);\n\t\t\t\t}\n\n\t\t\t\tlet red;\n\t\t\t\tlet green;\n\t\t\t\tlet blue;\n\n\t\t\t\tif (code >= 232) {\n\t\t\t\t\tred = (((code - 232) * 10) + 8) / 255;\n\t\t\t\t\tgreen = red;\n\t\t\t\t\tblue = red;\n\t\t\t\t} else {\n\t\t\t\t\tcode -= 16;\n\n\t\t\t\t\tconst remainder = code % 36;\n\n\t\t\t\t\tred = Math.floor(code / 36) / 5;\n\t\t\t\t\tgreen = Math.floor(remainder / 6) / 5;\n\t\t\t\t\tblue = (remainder % 6) / 5;\n\t\t\t\t}\n\n\t\t\t\tconst value = Math.max(red, green, blue) * 2;\n\n\t\t\t\tif (value === 0) {\n\t\t\t\t\treturn 30;\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tlet result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));\n\n\t\t\t\tif (value === 2) {\n\t\t\t\t\tresult += 60;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\trgbToAnsi: {\n\t\t\tvalue: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi: {\n\t\t\tvalue: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t});\n\n\treturn styles;\n}\n\nconst ansiStyles = assembleStyles();\n\nexport default ansiStyles;\n","import process from 'node:process';\nimport os from 'node:os';\nimport tty from 'node:tty';\n\n// From: https://github.com/sindresorhus/has-flag/blob/main/index.js\n/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {\nfunction hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n}\n\nconst {env} = process;\n\nlet flagForceColor;\nif (\n\thasFlag('no-color')\n\t|| hasFlag('no-colors')\n\t|| hasFlag('color=false')\n\t|| hasFlag('color=never')\n) {\n\tflagForceColor = 0;\n} else if (\n\thasFlag('color')\n\t|| hasFlag('colors')\n\t|| hasFlag('color=true')\n\t|| hasFlag('color=always')\n) {\n\tflagForceColor = 1;\n}\n\nfunction envForceColor() {\n\tif ('FORCE_COLOR' in env) {\n\t\tif (env.FORCE_COLOR === 'true') {\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (env.FORCE_COLOR === 'false') {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3,\n\t};\n}\n\nfunction _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {\n\tconst noFlagForceColor = envForceColor();\n\tif (noFlagForceColor !== undefined) {\n\t\tflagForceColor = noFlagForceColor;\n\t}\n\n\tconst forceColor = sniffFlags ? flagForceColor : noFlagForceColor;\n\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (sniffFlags) {\n\t\tif (hasFlag('color=16m')\n\t\t\t|| hasFlag('color=full')\n\t\t\t|| hasFlag('color=truecolor')) {\n\t\t\treturn 3;\n\t\t}\n\n\t\tif (hasFlag('color=256')) {\n\t\t\treturn 2;\n\t\t}\n\t}\n\n\t// Check for Azure DevOps pipelines.\n\t// Has to be above the `!streamIsTTY` check.\n\tif ('TF_BUILD' in env && 'AGENT_NAME' in env) {\n\t\treturn 1;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10\n\t\t\t&& Number(osRelease[2]) >= 10_586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14_931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {\n\t\t\treturn 3;\n\t\t}\n\n\t\tif (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'xterm-kitty') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'xterm-ghostty') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'wezterm') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app': {\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\t}\n\n\t\t\tcase 'Apple_Terminal': {\n\t\t\t\treturn 2;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nexport function createSupportsColor(stream, options = {}) {\n\tconst level = _supportsColor(stream, {\n\t\tstreamIsTTY: stream && stream.isTTY,\n\t\t...options,\n\t});\n\n\treturn translateLevel(level);\n}\n\nconst supportsColor = {\n\tstdout: createSupportsColor({isTTY: tty.isatty(1)}),\n\tstderr: createSupportsColor({isTTY: tty.isatty(2)}),\n};\n\nexport default supportsColor;\n","// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.\nexport function stringReplaceAll(string, substring, replacer) {\n\tlet index = string.indexOf(substring);\n\tif (index === -1) {\n\t\treturn string;\n\t}\n\n\tconst substringLength = substring.length;\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\treturnValue += string.slice(endIndex, index) + substring + replacer;\n\t\tendIndex = index + substringLength;\n\t\tindex = string.indexOf(substring, endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n\nexport function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\tconst gotCR = string[index - 1] === '\\r';\n\t\treturnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\\r\\n' : '\\n') + postfix;\n\t\tendIndex = index + 1;\n\t\tindex = string.indexOf('\\n', endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n","import ansiStyles from '#ansi-styles';\nimport supportsColor from '#supports-color';\nimport { // eslint-disable-line import/order\n\tstringReplaceAll,\n\tstringEncaseCRLFWithFirstIndex,\n} from './utilities.js';\n\nconst {stdout: stdoutColor, stderr: stderrColor} = supportsColor;\n\nconst GENERATOR = Symbol('GENERATOR');\nconst STYLER = Symbol('STYLER');\nconst IS_EMPTY = Symbol('IS_EMPTY');\n\n// `supportsColor.level` → `ansiStyles.color[name]` mapping\nconst levelMapping = [\n\t'ansi',\n\t'ansi',\n\t'ansi256',\n\t'ansi16m',\n];\n\nconst styles = Object.create(null);\n\nconst applyOptions = (object, options = {}) => {\n\tif (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {\n\t\tthrow new Error('The `level` option should be an integer from 0 to 3');\n\t}\n\n\t// Detect level if not set manually\n\tconst colorLevel = stdoutColor ? stdoutColor.level : 0;\n\tobject.level = options.level === undefined ? colorLevel : options.level;\n};\n\nexport class Chalk {\n\tconstructor(options) {\n\t\t// eslint-disable-next-line no-constructor-return\n\t\treturn chalkFactory(options);\n\t}\n}\n\nconst chalkFactory = options => {\n\tconst chalk = (...strings) => strings.join(' ');\n\tapplyOptions(chalk, options);\n\n\tObject.setPrototypeOf(chalk, createChalk.prototype);\n\n\treturn chalk;\n};\n\nfunction createChalk(options) {\n\treturn chalkFactory(options);\n}\n\nObject.setPrototypeOf(createChalk.prototype, Function.prototype);\n\nfor (const [styleName, style] of Object.entries(ansiStyles)) {\n\tstyles[styleName] = {\n\t\tget() {\n\t\t\tconst builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);\n\t\t\tObject.defineProperty(this, styleName, {value: builder});\n\t\t\treturn builder;\n\t\t},\n\t};\n}\n\nstyles.visible = {\n\tget() {\n\t\tconst builder = createBuilder(this, this[STYLER], true);\n\t\tObject.defineProperty(this, 'visible', {value: builder});\n\t\treturn builder;\n\t},\n};\n\nconst getModelAnsi = (model, level, type, ...arguments_) => {\n\tif (model === 'rgb') {\n\t\tif (level === 'ansi16m') {\n\t\t\treturn ansiStyles[type].ansi16m(...arguments_);\n\t\t}\n\n\t\tif (level === 'ansi256') {\n\t\t\treturn ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));\n\t\t}\n\n\t\treturn ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));\n\t}\n\n\tif (model === 'hex') {\n\t\treturn getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));\n\t}\n\n\treturn ansiStyles[type][model](...arguments_);\n};\n\nconst usedModels = ['rgb', 'hex', 'ansi256'];\n\nfor (const model of usedModels) {\n\tstyles[model] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);\n\t\t\t\treturn createBuilder(this, styler, this[IS_EMPTY]);\n\t\t\t};\n\t\t},\n\t};\n\n\tconst bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);\n\tstyles[bgModel] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);\n\t\t\t\treturn createBuilder(this, styler, this[IS_EMPTY]);\n\t\t\t};\n\t\t},\n\t};\n}\n\nconst proto = Object.defineProperties(() => {}, {\n\t...styles,\n\tlevel: {\n\t\tenumerable: true,\n\t\tget() {\n\t\t\treturn this[GENERATOR].level;\n\t\t},\n\t\tset(level) {\n\t\t\tthis[GENERATOR].level = level;\n\t\t},\n\t},\n});\n\nconst createStyler = (open, close, parent) => {\n\tlet openAll;\n\tlet closeAll;\n\tif (parent === undefined) {\n\t\topenAll = open;\n\t\tcloseAll = close;\n\t} else {\n\t\topenAll = parent.openAll + open;\n\t\tcloseAll = close + parent.closeAll;\n\t}\n\n\treturn {\n\t\topen,\n\t\tclose,\n\t\topenAll,\n\t\tcloseAll,\n\t\tparent,\n\t};\n};\n\nconst createBuilder = (self, _styler, _isEmpty) => {\n\t// Single argument is hot path, implicit coercion is faster than anything\n\t// eslint-disable-next-line no-implicit-coercion\n\tconst builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));\n\n\t// We alter the prototype because we must return a function, but there is\n\t// no way to create a function with a different prototype\n\tObject.setPrototypeOf(builder, proto);\n\n\tbuilder[GENERATOR] = self;\n\tbuilder[STYLER] = _styler;\n\tbuilder[IS_EMPTY] = _isEmpty;\n\n\treturn builder;\n};\n\nconst applyStyle = (self, string) => {\n\tif (self.level <= 0 || !string) {\n\t\treturn self[IS_EMPTY] ? '' : string;\n\t}\n\n\tlet styler = self[STYLER];\n\n\tif (styler === undefined) {\n\t\treturn string;\n\t}\n\n\tconst {openAll, closeAll} = styler;\n\tif (string.includes('\\u001B')) {\n\t\twhile (styler !== undefined) {\n\t\t\t// Replace any instances already present with a re-opening code\n\t\t\t// otherwise only the part of the string until said closing code\n\t\t\t// will be colored, and the rest will simply be 'plain'.\n\t\t\tstring = stringReplaceAll(string, styler.close, styler.open);\n\n\t\t\tstyler = styler.parent;\n\t\t}\n\t}\n\n\t// We can move both next actions out of loop, because remaining actions in loop won't have\n\t// any/visible effect on parts we add here. Close the styling before a linebreak and reopen\n\t// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92\n\tconst lfIndex = string.indexOf('\\n');\n\tif (lfIndex !== -1) {\n\t\tstring = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);\n\t}\n\n\treturn openAll + string + closeAll;\n};\n\nObject.defineProperties(createChalk.prototype, styles);\n\nconst chalk = createChalk();\nexport const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});\n\nexport {\n\tmodifierNames,\n\tforegroundColorNames,\n\tbackgroundColorNames,\n\tcolorNames,\n\n\t// TODO: Remove these aliases in the next major version\n\tmodifierNames as modifiers,\n\tforegroundColorNames as foregroundColors,\n\tbackgroundColorNames as backgroundColors,\n\tcolorNames as colors,\n} from './vendor/ansi-styles/index.js';\n\nexport {\n\tstdoutColor as supportsColor,\n\tstderrColor as supportsColorStderr,\n};\n\nexport default chalk;\n"],"x_google_ignoreList":[3,4,5,6],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAa,6BAAb,cAAgD,MAAM;CAClD;CACA;CAEA,YAAY,gBAAwB,UAAkB,SAAiB;EACnE,MAAM,GAAG,eAAe,WAAW,SAAS,KAAK,SAAS;EAC1D,KAAK,OAAO;EACZ,KAAK,iBAAiB;EACtB,KAAK,WAAW;CACpB;AACJ;;;;;AASA,IAAM,oBAAoB;;;;;;;;;;;;;;;;AAiB1B,IAAa,qBAAqB,SAA0B,0BAA0B,KAAK,IAAI;AAE/F,IAAM,mBAAmB,WAAiC,WAAW;;;;;;;;;;;;;;;;;;AAmBrE,IAAa,oBAAoB,SAAyD,QAAQ,KAAK,UAAU;CAC7G,GAAG;CACH,GAAG,KAAK;CACR,GAAG,KAAK;CACR,GAAG,KAAK;CACR,GAAG,KAAK;CACR,GAAG,KAAK,KAAK,KAAI,MAAK;EAAC,EAAE;EAAQ,EAAE;EAAW,EAAE;CAAK,CAAC;CACtD,GAAG,KAAK;CACR,GAAG,KAAK;AACZ,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC;;;;;;;;;;;AAYlB,IAAa,mBAAmB,SAAyD;CAQrF,MAAM,SAAS,IADH,KAAK,SAAS,OAAO,KACV,GAAG,iBAAiB,IAAI;CAE/C,OAAO,GAAG,gBAAgB,GADN,KAAK,MAAM,GAAG,KAAK,KAAK,KAAI,MAAK,EAAE,MAAM,CAAC,CAAC,KAAK,GAAG,KACnC,KAAK,iBAAi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String: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* A connection string for Atlas: {@link forLibpq}, and `sslmode=disable` for a
|
|
32
|
+
* database on this machine whose URL says nothing about SSL.
|
|
33
|
+
*
|
|
34
|
+
* Atlas connects through lib/pq, whose default `sslmode` is `require`.
|
|
35
|
+
* node-postgres — the app, and every step of these commands — asks for no SSL
|
|
36
|
+
* when the URL names none. So a URL that served the app from a local Postgres
|
|
37
|
+
* without SSL (the Docker image, a Homebrew install) failed every schema
|
|
38
|
+
* command with `pq: SSL is not enabled on the server`. Given here, Atlas
|
|
39
|
+
* connects the way the app already does.
|
|
40
|
+
*
|
|
41
|
+
* Nothing that asked for something is touched: a URL naming `sslmode`, `ssl`,
|
|
42
|
+
* `host` or `hostaddr`, any other host, and anything that is not a postgres
|
|
43
|
+
* URL are returned as {@link forLibpq} returns them.
|
|
44
|
+
*/
|
|
45
|
+
export declare function forAtlas(connectionString: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* A connection string with its password taken out, and the password.
|
|
48
|
+
*
|
|
49
|
+
* For a libpq program: the URL goes on its command line, and the password goes
|
|
50
|
+
* in `PGPASSWORD`. On the command line it was readable by anyone who can list
|
|
51
|
+
* processes, and it came back verbatim in every failure, because execa's error
|
|
52
|
+
* message repeats the command: `Command failed with exit code 1: pg_restore
|
|
53
|
+
* '--dbname=postgresql://app:s3cret@…'`, in a terminal, a CI log and the
|
|
54
|
+
* scheduled backup's run history.
|
|
55
|
+
*
|
|
56
|
+
* libpq takes the password from the URL's user info or a `password` parameter,
|
|
57
|
+
* so both are removed. The value is percent-decoded, because `PGPASSWORD` is
|
|
58
|
+
* read literally. Anything that is not a URL is returned as given, with no
|
|
59
|
+
* password: a key/value DSN keeps its own.
|
|
60
|
+
*/
|
|
61
|
+
export declare function splitPassword(connectionString: string): {
|
|
62
|
+
connectionString: string;
|
|
63
|
+
password: string | null;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Every password a line of text carries in a connection string, replaced with
|
|
67
|
+
* `***`.
|
|
68
|
+
*
|
|
69
|
+
* For whatever is about to be printed or logged and may have a connection
|
|
70
|
+
* string in it: an error a client tool or a driver raised, a message that
|
|
71
|
+
* quotes a command line. Covers the URL user-info form (`scheme://user:pass@`,
|
|
72
|
+
* any scheme, a password with a raw `@` in it included) and `password=` in a
|
|
73
|
+
* query string or a key/value DSN. The user, host and database stay, because
|
|
74
|
+
* they are what a reader needs to tell which database it was.
|
|
75
|
+
*/
|
|
76
|
+
export declare function redactConnectionPasswords(text: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
3
|
+
import { n as __exportAll } from "./rolldown-runtime-V7rFbMRe.js";
|
|
4
4
|
import { isPostgresCollectionConfig } from "@rebasepro/types";
|
|
5
5
|
import { getTableName } from "@rebasepro/common";
|
|
6
6
|
import { toPostgresIdentifier } from "@rebasepro/utils";
|
|
@@ -295,4 +295,4 @@ $rebase_vector$;`;
|
|
|
295
295
|
//#endregion
|
|
296
296
|
export { vectorDimensionGuard as a, vectorExtensionStatement as c, vectorIndexStatements as d, vector_index_exports as f, vectorColumnDefinition as i, vectorIndexNames as l, buildVectorColumnSpecs as n, vectorExtensionDeclared as o, buildVectorIndexPlan as r, vectorExtensionHint as s, VECTOR_EXTENSION_OPT_IN as t, vectorIndexStatement as u };
|
|
297
297
|
|
|
298
|
-
//# sourceMappingURL=vector-index-
|
|
298
|
+
//# sourceMappingURL=vector-index-BFhyEaiz.js.map
|