better-supabase 0.25.0 → 0.28.0
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/{access-sql-bjWFUWlk.js → access-sql-CTDNuxRv.js} +177 -12
- package/dist/ai-sdk/agents/index.d.ts +2 -2
- package/dist/{app-tables-xij_MI5H.d.ts → app-tables-62GqZIhd.d.ts} +1 -1
- package/dist/{authorization-BJV2i8xB.d.ts → authorization-BCG1v0iC.d.ts} +24 -3
- package/dist/{bind-vKDmdu_4.d.ts → bind-C54jD0r3.d.ts} +1 -1
- package/dist/{block-env-wVLz0KMV.d.ts → block-env-CM-LFfj4.d.ts} +3 -3
- package/dist/blocks/ai-chat/index.d.ts +3 -3
- package/dist/blocks/announcements/index.d.ts +3 -3
- package/dist/blocks/api-keys/index.d.ts +1 -1
- package/dist/blocks/attachments/index.d.ts +1 -1
- package/dist/blocks/audit/index.d.ts +2 -2
- package/dist/blocks/automations/index.d.ts +1 -1
- package/dist/blocks/billing/index.d.ts +1 -1
- package/dist/blocks/bookings/index.d.ts +1 -1
- package/dist/blocks/calendar/index.d.ts +1 -1
- package/dist/blocks/comments/index.d.ts +4 -4
- package/dist/blocks/custom-fields/index.js +1 -1
- package/dist/blocks/drive/index.d.ts +1 -1
- package/dist/blocks/employees/index.js +1 -1
- package/dist/blocks/entitlements/index.d.ts +2 -2
- package/dist/blocks/forms/index.d.ts +1 -1
- package/dist/blocks/inbox/index.d.ts +4 -4
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/messaging/index.d.ts +4 -4
- package/dist/blocks/mfa/index.d.ts +1 -1
- package/dist/blocks/notifications/index.d.ts +3 -3
- package/dist/blocks/onboarding/index.d.ts +1 -1
- package/dist/blocks/organizations/index.d.ts +2 -2
- package/dist/blocks/permissions/index.d.ts +1 -1
- package/dist/blocks/push/index.d.ts +1 -1
- package/dist/blocks/reactions/index.d.ts +3 -3
- package/dist/blocks/reminders/index.d.ts +1 -1
- package/dist/blocks/saved-views/index.d.ts +1 -1
- package/dist/blocks/search/index.d.ts +2 -2
- package/dist/blocks/sessions/index.d.ts +1 -1
- package/dist/blocks/settings/index.d.ts +1 -1
- package/dist/blocks/subjects/index.d.ts +1 -1
- package/dist/blocks/tags/index.d.ts +1 -1
- package/dist/blocks/tasks/index.d.ts +1 -1
- package/dist/blocks/tasks/index.js +1 -1
- package/dist/blocks/undo/index.d.ts +1 -1
- package/dist/blocks/usage/index.d.ts +1 -1
- package/dist/blocks/workflow-editor/index.d.ts +3 -3
- package/dist/blocks/workflows/index.d.ts +3 -3
- package/dist/cli/{add-C2pNvVpu.js → add-BKcE_g9D.js} +2 -2
- package/dist/cli/{add-BTVrOGJF.js → add-DUyg9qna.js} +40 -15
- package/dist/cli/add-pDOlqWUa.js +1 -0
- package/dist/cli/{backfill-BicVPugb.js → backfill-r9RELEEh.js} +4 -4
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-sScN-ik-.js → blocks-DTOFdrxL.js} +1 -1
- package/dist/cli/{blocks-BmYOH4T-.js → blocks-k1OG8XDs.js} +2 -2
- package/dist/cli/{cache-1TfBy2K4.js → cache-Czfw7Iow.js} +1 -1
- package/dist/cli/{codemod-ylE6wGLo.js → codemod-ClmbiLuL.js} +3 -3
- package/dist/cli/{command-BWEEXmtz.js → command-CVzTJSLp.js} +31 -0
- package/dist/cli/{completion-8EDK21xj.js → completion-CNCqE-Gb.js} +1 -1
- package/dist/cli/{completion-BfnKI4QZ.js → completion-Dpk6vh0p.js} +2 -2
- package/dist/cli/{completion-Bt7LMypX.js → completion-DxEXxFpz.js} +2 -2
- package/dist/cli/{config-CeaQMrvS.js → config-D2YUlzrl.js} +1 -1
- package/dist/cli/{config-WKDixoGK.js → config-EjNj3HfT.js} +1 -1
- package/dist/cli/{config-BVfeG3A5.js → config-KvV-sLZL.js} +290 -10
- package/dist/cli/{content-mapper-hUW2nb92.js → content-mapper-ez_mT0d4.js} +2 -2
- package/dist/cli/{db-DwjyUbAh.js → db-uYN6O5Eg.js} +38 -14
- package/dist/cli/{doctor-D3WKFBSv.js → doctor-BD9oo4MG.js} +31 -28
- package/dist/cli/{env-DMgjB_4y.js → env-BK0xKMeU.js} +1 -2
- package/dist/cli/{env-C-Bl6Awn.js → env-Bat6ogep.js} +1 -1
- package/dist/cli/env-Cy2lWBRC.js +1 -0
- package/dist/cli/{env-BCgVZkcb.js → env-DEAtgGoj.js} +2 -2
- package/dist/cli/{exec--Q1ZEWUW.js → exec-Ca5s-ygi.js} +1 -1
- package/dist/cli/{gen-CqsUdsB2.js → gen-8Ya8n2sA.js} +16 -16
- package/dist/cli/in-stack-diff-Cp-tVPj2.js +186 -0
- package/dist/cli/index.d.ts +1 -2
- package/dist/cli/index.js +8 -8
- package/dist/cli/{init-DryZ5Mp1.js → init-DgL3sDfQ.js} +118 -11
- package/dist/cli/{keys-CbaL0lnw.js → keys-CsanNk-2.js} +1 -1
- package/dist/cli/{live-Di45imoV.js → live-CMMEct_F.js} +2 -2
- package/dist/cli/{mcp-BklC-3eK.js → mcp-DEHtzAkq.js} +4 -4
- package/dist/cli/{metadata-7PsBF5Xw.js → metadata-BZh-cOzC.js} +3 -3
- package/dist/cli/migrate-sVs1QYTM.js +306 -0
- package/dist/cli/{migration-safety-Doy9qYO8.js → migration-safety-ClnYNMdq.js} +2 -2
- package/dist/cli/migrations-DWh38tO9.js +117 -0
- package/dist/cli/{module-migration-ZIn1NCMi.js → module-migration-CXfRJIV4.js} +2 -2
- package/dist/cli/{moved-DVwgE8lV.js → moved-Cnb4fp49.js} +1 -1
- package/dist/cli/{parse-B079x40m.js → parse-BWM6IGhF.js} +1 -1
- package/dist/cli/powersync-DURhWDVc.js +1 -0
- package/dist/cli/{powersync-BRGXOCJ0.js → powersync-Dnyr-Wy5.js} +4 -3
- package/dist/cli/{print-Dfqd4DB-.js → print-DJrSr56b.js} +2 -2
- package/dist/cli/{migrations-JtsPYv8g.js → providers-CpaISitn.js} +4 -116
- package/dist/cli/{remove-CQzSCYTu.js → remove-ChaieK3t.js} +6 -6
- package/dist/cli/{render-DWRz-uPQ.js → render-DUNJ4Pss.js} +8 -5
- package/dist/cli/{run-DPLedqTF.js → run-ChCQPYOh.js} +41 -39
- package/dist/cli/{run-j54rk2w-.js → run-Cl9COGuy.js} +10 -10
- package/dist/cli/{run-DmOTMa44.js → run-CxFDjL1Q.js} +4 -4
- package/dist/cli/seed-BJ7c-ktX.js +1 -0
- package/dist/cli/{seed-BMynpMPy.js → seed-BzVLTdRl.js} +3 -3
- package/dist/cli/{shared-CslNcs-R.js → shared-5uqc1GBj.js} +1 -1
- package/dist/cli/{skills-FXAVPLzp.js → skills-0gz_qjVb.js} +1 -1
- package/dist/cli/{snapshot-DdN5GlhH.js → snapshot-DdAP7LWO.js} +3 -3
- package/dist/cli/{source-COARbqch.js → source-2irbWSck.js} +1 -1
- package/dist/cli/{source-args-CDmmFmFG.js → source-args-DAcQt-Mh.js} +1 -1
- package/dist/cli/{spec-CgLNZc_C.js → spec-B7n4Rthp.js} +3 -3
- package/dist/cli/{spec-DIhBQlBF.js → spec-_MS0ym5r.js} +1 -1
- package/dist/cli/{sql-layout-8jrP5gIa.js → sql-layout-DYKkQw1k.js} +21 -7
- package/dist/cli/{stack-DgASZP0K.js → stack-CteM33gC.js} +3 -3
- package/dist/cli/{stack-status-B_Ipd_-z.js → stack-status-BkkYRlXG.js} +1 -1
- package/dist/cli/{stacks-BYlQ96WS.js → stacks-CiDBH1dB.js} +1 -1
- package/dist/cli/{sync-SqyVHRSJ.js → sync-DnSOrQuA.js} +4 -3
- package/dist/cli/table-DeH8X0qz.js +89 -0
- package/dist/cli/{upgrade-CY-vj_qh.js → upgrade-CWdrC-K3.js} +5 -4
- package/dist/cli/{upgrade-D0aLhluU.js → upgrade-cMy5fKkg.js} +3 -3
- package/dist/cli/{version-Bhca9D6q.js → version-C5RAWmrD.js} +1 -1
- package/dist/client/index.d.ts +5 -5
- package/dist/client/native/index.d.ts +4 -4
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +4 -4
- package/dist/{config-CP-WaboC.js → config-CTeR7XHK.js} +3 -3
- package/dist/{config-C19McoGo.js → config-CvJHIy5q.js} +1 -1
- package/dist/{context-BJoHD20l.d.ts → context-BFEX0b7H.d.ts} +106 -3
- package/dist/{controller-CwGXms17.d.ts → controller-Cl6HmMBk.d.ts} +1 -1
- package/dist/create/index.d.ts +62 -3
- package/dist/create/index.js +67 -4
- package/dist/create/lite/index.d.ts +140 -3
- package/dist/create/lite/index.js +399 -47
- package/dist/{entitlements-CsZcfllV.d.ts → entitlements-Y-n4RGAd.d.ts} +1 -1
- package/dist/{field-errors-6BVg31Yp.d.ts → field-errors-Btn3czyz.d.ts} +4 -4
- package/dist/{index-Cagz4Z2k.d.ts → index-8wOL81rB.d.ts} +1 -1
- package/dist/{index-D01wHGSN.d.ts → index-C0_cweyT.d.ts} +6 -6
- package/dist/{index-CbUCGMqj.d.ts → index-CAY7rIQs.d.ts} +2 -2
- package/dist/{index-DOHx3JuB.d.ts → index-DPMVWm_Z.d.ts} +2 -2
- package/dist/{index-C0QuN9_P.d.ts → index-k-SyCzcQ.d.ts} +104 -119
- package/dist/{instances-qz2MCMyK.js → instances-C7qUTjhJ.js} +1 -1
- package/dist/mapper/bin.js +7 -7
- package/dist/mcp/index.d.ts +1 -1
- package/dist/next/index.d.ts +3 -3
- package/dist/{operations-CPhOcuzl.d.ts → operations-DE7SOBw-.d.ts} +1 -1
- package/dist/{options-BOGo1qCA.js → options-B5E2MGIz.js} +3 -1
- package/dist/{options-D2s7fT1s.js → options-COo7_3MX.js} +2 -1
- package/dist/{options-D32-YxnO.js → options-DhoLMknl.js} +3 -1
- package/dist/otel/index.js +4 -4
- package/dist/{ports-Bw7uxPd_.d.ts → ports-DP0bthUk.d.ts} +1 -1
- package/dist/powersync/index.d.ts +2 -2
- package/dist/preset/index.d.ts +3 -3
- package/dist/preset/index.js +3 -3
- package/dist/{preset-BbSWLoXM.js → preset-DwuWNBip.js} +2 -2
- package/dist/{project-TN03XDsA.js → project-Bo1vZqVs.js} +5 -5
- package/dist/{push-token-vykw2JXT.d.ts → push-token-v3xCcVU7.d.ts} +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/server.d.ts +5 -5
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +1 -1
- package/dist/records/index.d.ts +3 -3
- package/dist/{resolved-names-Dsf28_Dr.js → resolved-names-iLBOUaib.js} +2 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/solid/index.d.ts +5 -5
- package/dist/sql/index.d.ts +5 -5
- package/dist/sql/index.js +5 -5
- package/dist/{sql-Dg3W1ENk.js → sql-B7vBP9g0.js} +3577 -1246
- package/dist/ssr/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/{subjects-NomQg6Eg.d.ts → subjects-BYCL-6hA.d.ts} +15 -1
- package/dist/svelte/index.d.ts +5 -5
- package/dist/{tenant-BRmKZ7aq.d.ts → tenant-CyLEXgot.d.ts} +1 -1
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +2 -2
- package/dist/{topic-CpsKVBot.d.ts → topic-B_DGdAEs.d.ts} +1 -1
- package/dist/{topic-F0FKzJyQ.js → topic-DnsNG4Kj.js} +1 -1
- package/dist/{types-CjRwmCRP.d.ts → types-DF8JYEf5.d.ts} +2 -2
- package/dist/vue/index.d.ts +5 -5
- package/dist/{watch-topic-BaMZX139.d.ts → watch-topic-1zIAtiNM.d.ts} +1 -1
- package/dist/workflow-sdk/world/index.js +1 -1
- package/dist/{workflow-sdk-CE8sEK57.js → workflow-sdk-CaEw822d.js} +25 -4
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/index.js +1 -1
- package/package.json +11 -1
- package/schemas/config-v1.json +42 -0
- package/dist/cli/add-Bf1fyCWm.js +0 -1
- package/dist/cli/env-xhwXk5Ri.js +0 -1
- package/dist/cli/in-stack-diff-DQTW53Vf.js +0 -257
- package/dist/cli/powersync-Dq-txa0_.js +0 -1
- package/dist/cli/seed-CO3j_bly.js +0 -1
|
@@ -2,10 +2,10 @@ import { n as CliError } from "./errors-BTe6A15O.js";
|
|
|
2
2
|
import { i as readStdin, t as display } from "./io-DH1kcmmP.js";
|
|
3
3
|
import { t as isRecord } from "./guards-CUlDNYZs.js";
|
|
4
4
|
import { c as resolve$1, i as extname$1, n as basename$1, o as join$1, r as dirname$1, s as normalize$1, t as resolveModulePath } from "./dist-DuiMMRbJ.js";
|
|
5
|
-
import { _ as parse$1, d as readSupabaseToml, g as tomlNumber, s as findUp } from "./supabase-toml-CncmQbO0.js";
|
|
6
|
-
import { A as strictObject, C as optional, D as record, E as rawCheck, M as union, N as unknown, O as regex, S as objectWithRest, T as pipe, _ as minLength, a as array, b as number, c as exactOptional, f as lazy, g as maxValue, h as maxLength, j as string, k as safeParse, l as getDotPath, m as literal, o as boolean, p as length, s as custom, u as integer, v as minValue, w as picklist, y as nullable } from "./env-
|
|
5
|
+
import { _ as parse$1, d as readSupabaseToml, f as schemaPaths, g as tomlNumber, p as sqlWorkflow, s as findUp } from "./supabase-toml-CncmQbO0.js";
|
|
6
|
+
import { A as strictObject, C as optional, D as record, E as rawCheck, M as union, N as unknown, O as regex, S as objectWithRest, T as pipe, _ as minLength, a as array, b as number, c as exactOptional, f as lazy, g as maxValue, h as maxLength, j as string, k as safeParse, l as getDotPath, m as literal, o as boolean, p as length, s as custom, u as integer, v as minValue, w as picklist, y as nullable } from "./env-BK0xKMeU.js";
|
|
7
7
|
import { t as importFresh } from "./fresh-import-DzgsGHkX.js";
|
|
8
|
-
import { n as readStackStatus } from "./stack-status-
|
|
8
|
+
import { n as readStackStatus } from "./stack-status-BkkYRlXG.js";
|
|
9
9
|
import * as nodeUtil from "node:util";
|
|
10
10
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
11
11
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -13,8 +13,260 @@ import { readFile, rm } from "node:fs/promises";
|
|
|
13
13
|
import { pathToFileURL } from "node:url";
|
|
14
14
|
import { APP_COLUMN_ACCESS, APP_COLUMN_FORMATS, APP_COLUMN_TYPES, APP_ON_DELETE_ACTIONS, APP_ROLLUP_AGGREGATES, APP_TABLE_EVENT_KINDS, CONFIG_GROUPS, GEN_TASKS, INTEGRATION_NAMES, RENAMED_CONFIG_KEYS, SKILLS_AGENTS, providerApiProblem, resolveConfig } from "better-supabase/config";
|
|
15
15
|
import { CONVENTION_FIELDS } from "better-supabase/preset";
|
|
16
|
-
import { SCOPE_ID_TYPES, scopeProblems } from "better-supabase/sql";
|
|
16
|
+
import { SCOPE_ID_TYPES, parseBsbComment, scopeProblems, tableTagComments } from "better-supabase/sql";
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
|
+
//#region src/cli/subject-tag.ts
|
|
19
|
+
const PERMISSION_PREFIX = "can-";
|
|
20
|
+
function text$1(value) {
|
|
21
|
+
return typeof value === "string" ? value : void 0;
|
|
22
|
+
}
|
|
23
|
+
function columns(value) {
|
|
24
|
+
return typeof value === "string" ? value.split(",").map((item) => item.trim()).filter((item) => item !== "") : [];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The `subject` entry a tag stands for. `table` is the tagged table. Options
|
|
28
|
+
* the tag has no word for (`search.from`, `search.watch`, row grants) stay in
|
|
29
|
+
* `subjects`.
|
|
30
|
+
*/
|
|
31
|
+
function subjectFromTag(args, table) {
|
|
32
|
+
const tenant = text$1(args["tenant"]);
|
|
33
|
+
const searchTitle = text$1(args["search-title"]);
|
|
34
|
+
const searchBody = columns(args["search-body"]);
|
|
35
|
+
const description = text$1(args["search-description"]);
|
|
36
|
+
const exclude = text$1(args["search-exclude"]);
|
|
37
|
+
const versions = columns(args["versions"]);
|
|
38
|
+
const rank = text$1(args["rank"]);
|
|
39
|
+
const permissions = Object.fromEntries(Object.entries(args).flatMap(([key, value]) => key.startsWith(PERMISSION_PREFIX) && typeof value === "string" ? [[key.slice(4), value]] : []));
|
|
40
|
+
const search = searchTitle !== void 0 || searchBody.length > 0 || description !== void 0 || exclude !== void 0 || args["search"] === true;
|
|
41
|
+
const id = text$1(args["id"]);
|
|
42
|
+
const idType = text$1(args["id-type"]);
|
|
43
|
+
const title = text$1(args["title"]);
|
|
44
|
+
const url = text$1(args["url"]);
|
|
45
|
+
const scope = text$1(args["scope"]);
|
|
46
|
+
const deletedAt = text$1(args["deleted-at"]);
|
|
47
|
+
const rankGroup = text$1(args["rank-group"]);
|
|
48
|
+
return {
|
|
49
|
+
table,
|
|
50
|
+
...id === void 0 ? {} : { id },
|
|
51
|
+
...idType === void 0 ? {} : { idType },
|
|
52
|
+
...tenant === void 0 ? {} : { tenant: tenant === "false" ? false : tenant },
|
|
53
|
+
...title === void 0 ? {} : { title },
|
|
54
|
+
...url === void 0 ? {} : { url },
|
|
55
|
+
...scope === void 0 ? {} : { scope },
|
|
56
|
+
...args["cascade"] === true ? { cascade: true } : {},
|
|
57
|
+
...deletedAt === void 0 ? {} : { deletedAt },
|
|
58
|
+
...Object.keys(permissions).length === 0 ? {} : { permissions },
|
|
59
|
+
...search ? { search: {
|
|
60
|
+
...searchTitle === void 0 ? {} : { title: searchTitle },
|
|
61
|
+
...searchBody.length === 0 ? {} : { body: searchBody },
|
|
62
|
+
...description === void 0 ? {} : { description },
|
|
63
|
+
...exclude === void 0 ? {} : { exclude }
|
|
64
|
+
} } : {},
|
|
65
|
+
...rank === void 0 && rankGroup === void 0 ? {} : { rank: {
|
|
66
|
+
column: rank ?? "rank",
|
|
67
|
+
...rankGroup === void 0 ? {} : { group: rankGroup }
|
|
68
|
+
} },
|
|
69
|
+
...versions.length === 0 ? {} : { versions: {
|
|
70
|
+
columns: versions,
|
|
71
|
+
auto: args["versions-auto"] !== "false"
|
|
72
|
+
} }
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The tag arguments for `subject`, or `undefined` when the entry holds an
|
|
77
|
+
* option a tag can't carry, so it stays in `subjects`.
|
|
78
|
+
*/
|
|
79
|
+
function subjectTagArgs(type, subject, table) {
|
|
80
|
+
const permissions = Object.entries(subject.permissions ?? {});
|
|
81
|
+
if (permissions.some(([, value]) => typeof value !== "string") || subject.search?.from !== void 0 || subject.search?.watch !== void 0) return;
|
|
82
|
+
const args = {};
|
|
83
|
+
const set = (key, value) => {
|
|
84
|
+
if (value !== void 0) args[key] = value;
|
|
85
|
+
};
|
|
86
|
+
set("type", type === table ? void 0 : type);
|
|
87
|
+
set("id", subject.id);
|
|
88
|
+
set("id-type", subject.idType);
|
|
89
|
+
set("tenant", subject.tenant === false ? "false" : subject.tenant);
|
|
90
|
+
set("title", subject.title);
|
|
91
|
+
set("url", subject.url);
|
|
92
|
+
set("scope", subject.scope);
|
|
93
|
+
set("cascade", subject.cascade === true ? true : void 0);
|
|
94
|
+
set("deleted-at", subject.deletedAt);
|
|
95
|
+
set("search-title", subject.search?.title);
|
|
96
|
+
set("search-body", subject.search?.body === void 0 ? void 0 : subject.search.body.join(","));
|
|
97
|
+
set("search-description", subject.search?.description);
|
|
98
|
+
set("search-exclude", subject.search?.exclude);
|
|
99
|
+
set("search", subject.search !== void 0 && Object.keys(args).every((key) => !key.startsWith("search-")) ? true : void 0);
|
|
100
|
+
set("rank", subject.rank?.column);
|
|
101
|
+
set("rank-group", subject.rank?.group);
|
|
102
|
+
if (subject.versions !== void 0) {
|
|
103
|
+
set("versions", subject.versions.columns.join(","));
|
|
104
|
+
set("versions-auto", subject.versions.auto ? void 0 : "false");
|
|
105
|
+
}
|
|
106
|
+
for (const [action, key] of permissions) set(`${PERMISSION_PREFIX}${action}`, typeof key === "string" ? key : void 0);
|
|
107
|
+
return args;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/cli/gen/table-tags.ts
|
|
111
|
+
const DISTANCES = /* @__PURE__ */ new Set([
|
|
112
|
+
"cosine",
|
|
113
|
+
"l2",
|
|
114
|
+
"inner_product"
|
|
115
|
+
]);
|
|
116
|
+
function isDistance(value) {
|
|
117
|
+
return DISTANCES.has(value);
|
|
118
|
+
}
|
|
119
|
+
const IMPORT_PREFIX = "import:";
|
|
120
|
+
function isColumnType(value) {
|
|
121
|
+
return APP_COLUMN_TYPES.some((type) => type === value);
|
|
122
|
+
}
|
|
123
|
+
function isEventKind(value) {
|
|
124
|
+
return APP_TABLE_EVENT_KINDS.some((kind) => kind === value);
|
|
125
|
+
}
|
|
126
|
+
function list(value) {
|
|
127
|
+
return typeof value === "string" ? value.split(",").map((item) => item.trim()).filter((item) => item !== "") : [];
|
|
128
|
+
}
|
|
129
|
+
function text(value) {
|
|
130
|
+
return typeof value === "string" ? value : void 0;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `config` with the per-table features the schema's `@bsb` table comments turn
|
|
134
|
+
* on (ADR 0102): `subject`, `realtime`, `vector-search`, `json` (`column=Type`,
|
|
135
|
+
* or `column=import:module#Name`), `encrypted` (`column=type`, a bare column is
|
|
136
|
+
* text) and `events` (`on`, `include`). `audit`, `audit-reads` and `expose`
|
|
137
|
+
* change the table's SQL only, so `gen` has nothing to read from them. A key
|
|
138
|
+
* the config sets itself wins, so a project can move to tags one table at a
|
|
139
|
+
* time. Tables outside `config.schemas` are ignored.
|
|
140
|
+
*/
|
|
141
|
+
function withTableTags(config, tables) {
|
|
142
|
+
const subjects = { ...config.subjects };
|
|
143
|
+
const realtimeTables = [...config.realtime.tables];
|
|
144
|
+
const realtimeGlobal = [...config.realtime.global];
|
|
145
|
+
const realtimeUsers = { ...config.realtime.users };
|
|
146
|
+
const vectorSearch = [...config.vectorSearch];
|
|
147
|
+
const json = { ...config.json };
|
|
148
|
+
const appTables = { ...config.appTables };
|
|
149
|
+
const fromTags = /* @__PURE__ */ new Set();
|
|
150
|
+
const eventTables = /* @__PURE__ */ new Set();
|
|
151
|
+
let changed = false;
|
|
152
|
+
for (const table of tables) {
|
|
153
|
+
if (!config.schemas.includes(table.schema)) continue;
|
|
154
|
+
const { tags } = parseBsbComment(table.comment);
|
|
155
|
+
if (tags.length === 0) continue;
|
|
156
|
+
const qualified = `${table.schema}.${table.name}`;
|
|
157
|
+
const short = table.schema === "public" ? table.name : qualified;
|
|
158
|
+
const names = /* @__PURE__ */ new Set([short, qualified]);
|
|
159
|
+
for (const tag of tags) if (tag.name === "subject") {
|
|
160
|
+
const type = text(tag.args["type"]) ?? table.name;
|
|
161
|
+
if (subjects[type] === void 0) {
|
|
162
|
+
subjects[type] = subjectFromTag(tag.args, short);
|
|
163
|
+
changed = true;
|
|
164
|
+
}
|
|
165
|
+
} else if (tag.name === "realtime" && !realtimeTables.some((each) => names.has(each))) {
|
|
166
|
+
realtimeTables.push(short);
|
|
167
|
+
const user = text(tag.args["user"]);
|
|
168
|
+
if (tag.args["global"] === true) realtimeGlobal.push(short);
|
|
169
|
+
if (user !== void 0) realtimeUsers[short] = user;
|
|
170
|
+
changed = true;
|
|
171
|
+
} else if (tag.name === "json") for (const [column, value] of Object.entries(tag.args)) {
|
|
172
|
+
const key = `${short}.${column}`;
|
|
173
|
+
const taken = [key, `${qualified}.${column}`].some((each) => each in json);
|
|
174
|
+
if (typeof value === "string" && !taken) {
|
|
175
|
+
json[key] = value.startsWith(IMPORT_PREFIX) ? { import: value.slice(7) } : { type: value };
|
|
176
|
+
changed = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (tag.name === "encrypted" && table.schema === "public") for (const [column, value] of Object.entries(tag.args)) {
|
|
180
|
+
const type = value === true ? "text" : value;
|
|
181
|
+
const own = appTables[table.name];
|
|
182
|
+
const existing = own?.columns?.[column];
|
|
183
|
+
const key = `${table.name}.${column}`;
|
|
184
|
+
if (isColumnType(type) && (existing === void 0 || fromTags.has(key))) {
|
|
185
|
+
fromTags.add(key);
|
|
186
|
+
const entry = {
|
|
187
|
+
...existing,
|
|
188
|
+
type,
|
|
189
|
+
encrypted: true
|
|
190
|
+
};
|
|
191
|
+
appTables[table.name] = {
|
|
192
|
+
...own,
|
|
193
|
+
columns: {
|
|
194
|
+
...own?.columns,
|
|
195
|
+
[column]: entry
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
changed = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (tag.name === "server" && table.schema === "public") for (const column of Object.keys(tag.args)) {
|
|
202
|
+
const own = appTables[table.name];
|
|
203
|
+
const existing = own?.columns?.[column];
|
|
204
|
+
const key = `${table.name}.${column}`;
|
|
205
|
+
if (existing === void 0 || fromTags.has(key)) {
|
|
206
|
+
fromTags.add(key);
|
|
207
|
+
const entry = {
|
|
208
|
+
type: "text",
|
|
209
|
+
...existing,
|
|
210
|
+
access: "server"
|
|
211
|
+
};
|
|
212
|
+
appTables[table.name] = {
|
|
213
|
+
...own,
|
|
214
|
+
columns: {
|
|
215
|
+
...own?.columns,
|
|
216
|
+
[column]: entry
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
changed = true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (tag.name === "events" && table.schema === "public" && appTables[table.name]?.events === void 0) {
|
|
223
|
+
const on = list(tag.args["on"]).filter(isEventKind);
|
|
224
|
+
const include = list(tag.args["include"]);
|
|
225
|
+
const events = on.length === 0 && include.length === 0 ? true : {
|
|
226
|
+
...on.length === 0 ? {} : { on },
|
|
227
|
+
...include.length === 0 ? {} : { include }
|
|
228
|
+
};
|
|
229
|
+
appTables[table.name] = {
|
|
230
|
+
...appTables[table.name],
|
|
231
|
+
events
|
|
232
|
+
};
|
|
233
|
+
eventTables.add(table.name);
|
|
234
|
+
changed = true;
|
|
235
|
+
} else if (tag.name === "vector-search" && !vectorSearch.some((each) => names.has(each.table))) {
|
|
236
|
+
const column = text(tag.args["column"]);
|
|
237
|
+
const distance = text(tag.args["distance"]) ?? "cosine";
|
|
238
|
+
if (column !== void 0 && isDistance(distance)) {
|
|
239
|
+
vectorSearch.push({
|
|
240
|
+
table: short,
|
|
241
|
+
column,
|
|
242
|
+
distance
|
|
243
|
+
});
|
|
244
|
+
changed = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
for (const name of eventTables) {
|
|
249
|
+
const type = Object.entries(subjects).find(([, subject]) => subject.table === name || subject.table === `public.${name}`)?.[0];
|
|
250
|
+
if (type !== void 0) appTables[name] = {
|
|
251
|
+
...appTables[name],
|
|
252
|
+
subject: { type }
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return changed ? {
|
|
256
|
+
...config,
|
|
257
|
+
subjects,
|
|
258
|
+
vectorSearch,
|
|
259
|
+
json,
|
|
260
|
+
appTables,
|
|
261
|
+
realtime: {
|
|
262
|
+
...config.realtime,
|
|
263
|
+
tables: realtimeTables,
|
|
264
|
+
global: realtimeGlobal,
|
|
265
|
+
users: realtimeUsers
|
|
266
|
+
}
|
|
267
|
+
} : config;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
18
270
|
//#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
|
|
19
271
|
function isBuffer(obj) {
|
|
20
272
|
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
@@ -693,13 +945,14 @@ function _isDirectory(path) {
|
|
|
693
945
|
*/
|
|
694
946
|
const valueMapsSchema = record(string(), record(string(), record(string(), nullable(union([string(), array(string())])))));
|
|
695
947
|
/**
|
|
696
|
-
* `records.<type>.permissions`: action to a key, or to `{ key, rows, owner
|
|
697
|
-
* The subject registry checks the names.
|
|
948
|
+
* `records.<type>.permissions`: action to a key, or to `{ key, rows, owner,
|
|
949
|
+
* also }`. The subject registry checks the names.
|
|
698
950
|
*/
|
|
699
951
|
const subjectPermissionsSchema = record(string(), union([string(), strictObject({
|
|
700
952
|
key: optional(string()),
|
|
701
953
|
rows: optional(string()),
|
|
702
|
-
owner: optional(string())
|
|
954
|
+
owner: optional(string()),
|
|
955
|
+
also: optional(string())
|
|
703
956
|
})]));
|
|
704
957
|
/** `records.<type>.search`. The subject registry checks the names. */
|
|
705
958
|
const subjectSearchSchema = strictObject({
|
|
@@ -714,7 +967,12 @@ const subjectSearchSchema = strictObject({
|
|
|
714
967
|
watch: optional(array(strictObject({
|
|
715
968
|
table: string(),
|
|
716
969
|
key: string(),
|
|
717
|
-
via: optional(string())
|
|
970
|
+
via: optional(string()),
|
|
971
|
+
through: optional(array(strictObject({
|
|
972
|
+
table: string(),
|
|
973
|
+
from: string(),
|
|
974
|
+
to: string()
|
|
975
|
+
})))
|
|
718
976
|
})))
|
|
719
977
|
});
|
|
720
978
|
//#endregion
|
|
@@ -1508,6 +1766,28 @@ function databaseUrlCredential(config, env, fromStdin) {
|
|
|
1508
1766
|
]);
|
|
1509
1767
|
}
|
|
1510
1768
|
//#endregion
|
|
1769
|
+
//#region src/cli/schema-tags.ts
|
|
1770
|
+
/** The `@bsb` table comments in the project's declarative schema files. */
|
|
1771
|
+
async function schemaTagComments(config) {
|
|
1772
|
+
const toml = await readSupabaseToml(config.root);
|
|
1773
|
+
const { files } = await schemaPaths(config.root, toml, sqlWorkflow(config, toml));
|
|
1774
|
+
return (await Promise.all(files.map((path) => readFile(resolve(config.root, path), "utf-8")))).flatMap((sql) => tableTagComments(sql));
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* `config` with the features the schema files' `@bsb` table comments turn on
|
|
1778
|
+
* (ADR 0102), so the SQL modules, `gen` and doctor read the same config. A key
|
|
1779
|
+
* the config sets itself wins. `appTables` stays as declared: `encrypted` and
|
|
1780
|
+
* `events` tags describe tables whose SQL the files already hold, and `gen`
|
|
1781
|
+
* reads them from the snapshot.
|
|
1782
|
+
*/
|
|
1783
|
+
async function withSchemaTags(config) {
|
|
1784
|
+
const tagged = withTableTags(config, await schemaTagComments(config));
|
|
1785
|
+
return tagged === config ? config : {
|
|
1786
|
+
...tagged,
|
|
1787
|
+
appTables: config.appTables
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
//#endregion
|
|
1511
1791
|
//#region src/cli/config.ts
|
|
1512
1792
|
const CONFIG_FILES = [
|
|
1513
1793
|
"better-supabase.config.ts",
|
|
@@ -1616,7 +1896,7 @@ async function loadConfig(cwd, explicit, environment, path = discoverConfig(cwd,
|
|
|
1616
1896
|
const issues = configIssues(config);
|
|
1617
1897
|
throw new CliError("config_invalid", `${display(cwd, path)} is not a valid config:\n${issues.map((issue) => ` ${issue}`).join("\n")}`, { issues });
|
|
1618
1898
|
}
|
|
1619
|
-
return withEnvironment(resolveConfig(applyEnvironment(config, environment), explicit ? cwd : dirname(path)));
|
|
1899
|
+
return withEnvironment(await withSchemaTags(resolveConfig(applyEnvironment(config, environment), explicit ? cwd : dirname(path))));
|
|
1620
1900
|
}
|
|
1621
1901
|
/** `[db] port` or `[api] port` from `supabase/config.toml`. */
|
|
1622
1902
|
async function readSupabasePort(root, section) {
|
|
@@ -1686,4 +1966,4 @@ async function statusDatabaseUrl(root, env, stack, noPort) {
|
|
|
1686
1966
|
});
|
|
1687
1967
|
}
|
|
1688
1968
|
//#endregion
|
|
1689
|
-
export { findConfig as a, readSupabasePort as c, GEN_TASKS as d, INTEGRATIONS as f, discoverConfig as i, stdinDatabaseUrl as l, databaseUrl as n, importExport as o, isGenTask as p, defaultConfig as r, loadConfig as s, applyEnvironment as t, accessToken as u };
|
|
1969
|
+
export { findConfig as a, readSupabasePort as c, GEN_TASKS as d, INTEGRATIONS as f, subjectTagArgs as h, discoverConfig as i, stdinDatabaseUrl as l, withTableTags as m, databaseUrl as n, importExport as o, isGenTask as p, defaultConfig as r, loadConfig as s, applyEnvironment as t, accessToken as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as readIfExists } from "./io-DH1kcmmP.js";
|
|
2
|
-
import { t as CACHE_DIR } from "./cache-
|
|
3
|
-
import { x as installedVersion } from "./snapshot-
|
|
2
|
+
import { t as CACHE_DIR } from "./cache-Czfw7Iow.js";
|
|
3
|
+
import { x as installedVersion } from "./snapshot-DdAP7LWO.js";
|
|
4
4
|
import { t as i } from "./jsonc-D5Fu67jw.js";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { p as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { p as commandMeta, r as defineCliCommand } from "./command-CVzTJSLp.js";
|
|
2
2
|
import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
|
|
3
3
|
import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
|
|
4
4
|
import { t as display } from "./io-DH1kcmmP.js";
|
|
5
|
-
import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-
|
|
5
|
+
import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-KvV-sLZL.js";
|
|
6
6
|
import { d as readSupabaseToml, f as schemaPaths, n as declarativeSchemasDir, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
|
|
7
|
-
import { r as supabaseCli } from "./exec
|
|
7
|
+
import { r as supabaseCli } from "./exec-Ca5s-ygi.js";
|
|
8
8
|
import { t as connect } from "./db-CQCLx7cx.js";
|
|
9
|
-
import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-
|
|
10
|
-
import { a as migrationFiles, i as isShadowFailure, o as migrationVersion, r as inStackDiff, t as MIGRATION_HEADER } from "./in-stack-diff-
|
|
9
|
+
import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-DAcQt-Mh.js";
|
|
10
|
+
import { a as migrationFiles, i as isShadowFailure, o as migrationVersion, r as inStackDiff, t as MIGRATION_HEADER } from "./in-stack-diff-Cp-tVPj2.js";
|
|
11
11
|
import { dirname, join, resolve } from "node:path";
|
|
12
12
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
13
|
+
import { parseRenameHints } from "better-supabase/create";
|
|
13
14
|
//#region src/cli/commands/db.ts
|
|
14
15
|
const ARGS = {
|
|
15
16
|
file: {
|
|
@@ -98,15 +99,22 @@ const DIFF_ARGS = {
|
|
|
98
99
|
},
|
|
99
100
|
"in-stack": {
|
|
100
101
|
type: "boolean",
|
|
101
|
-
description: "Diff inside the running stack with pg-delta, without the Supabase CLI's shadow database"
|
|
102
|
+
description: "Diff inside the running stack with pg-delta's library plan, without the Supabase CLI's shadow database"
|
|
103
|
+
},
|
|
104
|
+
"allow-data-loss": {
|
|
105
|
+
type: "boolean",
|
|
106
|
+
description: "Write the migration even when it drops tables or columns, or changes a column type"
|
|
102
107
|
}
|
|
103
108
|
};
|
|
104
109
|
const DEFAULT_DIFF_DEPS = {
|
|
105
110
|
supabase: (args, root, env) => supabaseCli(args, root, env),
|
|
106
111
|
inStackDiff,
|
|
107
|
-
now: () => /* @__PURE__ */ new Date(),
|
|
108
112
|
log: () => {}
|
|
109
113
|
};
|
|
114
|
+
/** The renames recorded as `-- bsb: rename old -> new` in the migrations. */
|
|
115
|
+
async function renameHints(root, migrations) {
|
|
116
|
+
return (await Promise.all(migrations.map((file) => readFile(join(root, file), "utf-8")))).flatMap((text) => parseRenameHints(text));
|
|
117
|
+
}
|
|
110
118
|
/**
|
|
111
119
|
* The Supabase CLI's diff for the workflow. pg-delta's `declarative sync`
|
|
112
120
|
* always writes a migration, so printing a diff under pg-delta runs in the
|
|
@@ -146,7 +154,12 @@ async function runDbDiff(config, args, env, deps = DEFAULT_DIFF_DEPS) {
|
|
|
146
154
|
if (workflow === "migrations") throw new CliError("usage", "db diff turns declarative schema files into a migration, and this project writes migrations directly (database.sql.workflow = migrations).");
|
|
147
155
|
let fellBack = false;
|
|
148
156
|
const command = cliDiffCommand(workflow, name);
|
|
149
|
-
|
|
157
|
+
const stack = args.stack ?? env.BSB_STACK;
|
|
158
|
+
const url = await databaseUrl(config, env, "", stack).catch((cause) => {
|
|
159
|
+
if (args["in-stack"] === true) throw cause;
|
|
160
|
+
return null;
|
|
161
|
+
});
|
|
162
|
+
if (!(args["in-stack"] === true || workflow === "pg-delta" && url !== null && isLocalDatabaseUrl(url)) && command !== void 0) {
|
|
150
163
|
const result = await deps.supabase(command, config.root, env);
|
|
151
164
|
if (result.code === 0) return {
|
|
152
165
|
code: 0,
|
|
@@ -169,22 +182,33 @@ async function runDbDiff(config, args, env, deps = DEFAULT_DIFF_DEPS) {
|
|
|
169
182
|
fellBack = true;
|
|
170
183
|
deps.log("The Supabase CLI could not start its shadow database (no shared memory segment left), so db diff diffs inside the running stack. better-supabase dev stack prune frees segments.");
|
|
171
184
|
}
|
|
172
|
-
|
|
173
|
-
if (!isLocalDatabaseUrl(url)) throw new CliError("usage", `db diff --in-stack works on a local stack, and the database is ${databaseHost(url)}.`);
|
|
185
|
+
if (url === null || !isLocalDatabaseUrl(url)) throw new CliError("usage", `db diff --in-stack works on a local stack, and the database is ${url === null ? "unknown" : databaseHost(url)}.`);
|
|
174
186
|
const dir = toml?.dir ?? "supabase";
|
|
175
|
-
const
|
|
187
|
+
const migrations = await migrationFiles(config.root, dir);
|
|
188
|
+
const result = await deps.inStackDiff({
|
|
176
189
|
url,
|
|
177
190
|
root: config.root,
|
|
178
191
|
env,
|
|
179
192
|
files: (await schemaPaths(config.root, toml, workflow)).files,
|
|
180
193
|
schemasDir: declarativeSchemasDir(toml, workflow),
|
|
181
|
-
migrations
|
|
194
|
+
migrations,
|
|
195
|
+
allowDataLoss: args["allow-data-loss"] === true,
|
|
196
|
+
hints: await renameHints(config.root, migrations),
|
|
182
197
|
log: deps.log
|
|
183
198
|
});
|
|
199
|
+
const { sql } = result;
|
|
200
|
+
for (const issue of result.issues) if (issue.severity !== "error") deps.log(issue.message);
|
|
184
201
|
const data = {
|
|
185
202
|
engine: "in-stack",
|
|
186
203
|
fellBack,
|
|
187
|
-
changes: sql !== ""
|
|
204
|
+
changes: sql !== "",
|
|
205
|
+
issues: result.issues
|
|
206
|
+
};
|
|
207
|
+
if (result.gate.blocked) return {
|
|
208
|
+
code: 1,
|
|
209
|
+
errorCode: "check_failed",
|
|
210
|
+
error: `The diff destroys data, so nothing was written:\n${result.gate.destructive.map((action) => ` ${action.sql.split("\n")[0] ?? ""}`).join("\n")}\nRename with \`-- bsb: rename old -> new\` in a migration, or run again with --allow-data-loss.`,
|
|
211
|
+
data
|
|
188
212
|
};
|
|
189
213
|
if (sql === "") return {
|
|
190
214
|
code: 0,
|
|
@@ -196,7 +220,7 @@ async function runDbDiff(config, args, env, deps = DEFAULT_DIFF_DEPS) {
|
|
|
196
220
|
output: sql,
|
|
197
221
|
data
|
|
198
222
|
};
|
|
199
|
-
const path = join(config.root, dir, "migrations", `${migrationVersion(
|
|
223
|
+
const path = join(config.root, dir, "migrations", `${migrationVersion(/* @__PURE__ */ new Date())}_${name}.sql`);
|
|
200
224
|
await mkdir(dirname(path), { recursive: true });
|
|
201
225
|
await writeFile(path, `${MIGRATION_HEADER}\n${sql}\n`);
|
|
202
226
|
return {
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { a as list, p as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { a as list, p as commandMeta, r as defineCliCommand } from "./command-CVzTJSLp.js";
|
|
2
2
|
import { i as plain } from "./style-Bm2X5JrN.js";
|
|
3
|
-
import { t as VERSION } from "./version-
|
|
3
|
+
import { t as VERSION } from "./version-C5RAWmrD.js";
|
|
4
4
|
import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
|
|
5
5
|
import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
|
|
6
6
|
import { a as sameText, t as display } from "./io-DH1kcmmP.js";
|
|
7
|
-
import { t as CACHE_DIR } from "./cache-
|
|
7
|
+
import { t as CACHE_DIR } from "./cache-Czfw7Iow.js";
|
|
8
8
|
import { t as byCodePoint } from "./compare-BmIWVEui.js";
|
|
9
|
-
import { C as satisfies, S as peerVersions, c as isSqliteLiteDriver, n as managementTarget, o as snapshotFile, r as openSource, s as liteDriverOf, t as loadSnapshot, u as MetadataRejectedError } from "./snapshot-
|
|
10
|
-
import { d as configFor, r as renderFiles, u as notNullTag } from "./render-
|
|
9
|
+
import { C as satisfies, S as peerVersions, c as isSqliteLiteDriver, n as managementTarget, o as snapshotFile, r as openSource, s as liteDriverOf, t as loadSnapshot, u as MetadataRejectedError } from "./snapshot-DdAP7LWO.js";
|
|
10
|
+
import { d as configFor, r as renderFiles, u as notNullTag } from "./render-DUNJ4Pss.js";
|
|
11
11
|
import { t as isRecord } from "./guards-CUlDNYZs.js";
|
|
12
|
-
import { i as request } from "./source-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { i as request } from "./source-2irbWSck.js";
|
|
13
|
+
import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-KvV-sLZL.js";
|
|
14
|
+
import { a as compiledReadSets, d as providerLabel } from "./providers-CpaISitn.js";
|
|
15
15
|
import { a as findRepoRoot, c as httpHooks, d as readSupabaseToml, f as schemaPaths, h as tomlGet, i as diffEngine, l as migrationCommand, n as declarativeSchemasDir, p as sqlWorkflow, u as pgFunctionHooks } from "./supabase-toml-CncmQbO0.js";
|
|
16
|
-
import { t as PROCESS_ENV } from "./env-
|
|
17
|
-
import { n as readStackStatus } from "./stack-status-
|
|
16
|
+
import { t as PROCESS_ENV } from "./env-BK0xKMeU.js";
|
|
17
|
+
import { n as readStackStatus } from "./stack-status-BkkYRlXG.js";
|
|
18
18
|
import { t as connect } from "./db-CQCLx7cx.js";
|
|
19
|
-
import { a as hasContentMapper, c as supportsContentMappers, i as contentMapperSetup$1, n as TSCONFIG_SNIPPET, o as needsRunExternalCode, t as RUN_EXTERNAL_CODE } from "./content-mapper-
|
|
19
|
+
import { a as hasContentMapper, c as supportsContentMappers, i as contentMapperSetup$1, n as TSCONFIG_SNIPPET, o as needsRunExternalCode, t as RUN_EXTERNAL_CODE } from "./content-mapper-ez_mT0d4.js";
|
|
20
20
|
import { c as insideRoot, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
|
|
21
|
-
import { C as splinterTables, S as advisorRule, _ as withoutStrings, a as METADATA_GAPS_TEXT, b as appTablesOf, c as accessModule, d as RLS_RULES, f as appliesTo, g as policyHelpers, h as functionObject, l as entitlementsModule, m as functionBody, p as escape$2, s as AUTHORIZATION_RULES, u as COMMANDS$2, v as BLOCK_PREFIX, x as appViewsOf, y as blockTargets } from "./run-
|
|
22
|
-
import { n as migrationsDir, r as moduleLayoutFor, t as blockDeclaredTables } from "./sql-layout-
|
|
23
|
-
import { a as permissionCatalogKeys, i as lineOf, l as tableObject, n as exposed, o as policyObject, r as exposedSchemas, s as qualified, t as catalogOf, u as workflowOf } from "./shared-
|
|
24
|
-
import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-
|
|
25
|
-
import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-
|
|
21
|
+
import { C as splinterTables, S as advisorRule, _ as withoutStrings, a as METADATA_GAPS_TEXT, b as appTablesOf, c as accessModule, d as RLS_RULES, f as appliesTo, g as policyHelpers, h as functionObject, l as entitlementsModule, m as functionBody, p as escape$2, s as AUTHORIZATION_RULES, u as COMMANDS$2, v as BLOCK_PREFIX, x as appViewsOf, y as blockTargets } from "./run-Cl9COGuy.js";
|
|
22
|
+
import { n as migrationsDir, r as moduleLayoutFor, t as blockDeclaredTables } from "./sql-layout-DYKkQw1k.js";
|
|
23
|
+
import { a as permissionCatalogKeys, i as lineOf, l as tableObject, n as exposed, o as policyObject, r as exposedSchemas, s as qualified, t as catalogOf, u as workflowOf } from "./shared-5uqc1GBj.js";
|
|
24
|
+
import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-CXfRJIV4.js";
|
|
25
|
+
import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-ClnYNMdq.js";
|
|
26
26
|
import { t as orphanedBlockFiles } from "./orphans-BAboqyVM.js";
|
|
27
|
-
import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-
|
|
28
|
-
import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-
|
|
27
|
+
import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-CMMEct_F.js";
|
|
28
|
+
import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-DAcQt-Mh.js";
|
|
29
29
|
import { i as PLUGIN_SUBPATH_RENAMES, n as BLOCK_SUBPATH_RENAMES, o as SPEC_SUBPATH_RENAMES, t as BLOCK_EXPORT_RENAMES } from "./codemod-block-renames-BuSaTE_G.js";
|
|
30
|
-
import { n as PLATFORM_SCHEMAS } from "./in-stack-diff-
|
|
30
|
+
import { n as PLATFORM_SCHEMAS } from "./in-stack-diff-Cp-tVPj2.js";
|
|
31
31
|
import { i as staleVariables, r as stackEnvValues, t as PREFIX_NAMES } from "./stack-env-6hS-WEmh.js";
|
|
32
|
-
import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-
|
|
33
|
-
import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-
|
|
32
|
+
import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-CiDBH1dB.js";
|
|
33
|
+
import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-BZh-cOzC.js";
|
|
34
34
|
import { existsSync } from "node:fs";
|
|
35
35
|
import { dirname, resolve } from "node:path";
|
|
36
36
|
import { createHash } from "node:crypto";
|
|
37
37
|
import { glob, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
38
38
|
import { DEFAULT_ACTIVE_TENANT, tenantClaimPaths, tenantNameOf } from "better-supabase/config";
|
|
39
|
-
import { SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedTables, adoptedViews, appTablePolicyNotes, blockFileState, blockSqlVersion, contractSignature, customContracts, dataExportPlan, excludedColumns, expiredFlagsQuery, hasColumnAccess, migrationOptionUses, moduleDeprecations, moduleEventTriggers, moduleFileVersion, moduleLayout, notNullCheckName, renderBlocks, sameBlockFile, sameTenantColumn, sameTenantTrigger, scopePolicyName, sharedRolesProblems, subjectColumns, widenedCommands } from "better-supabase/sql";
|
|
39
|
+
import { SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_NAMES, TENANT_SCOPE_POLICY, adoptedTables, adoptedViews, appTablePolicyNotes, blockFileState, blockSqlVersion, contractSignature, customContracts, dataExportPlan, excludedColumns, expiredFlagsQuery, hasColumnAccess, migrationOptionUses, moduleDeprecations, moduleEventTriggers, moduleFileVersion, moduleLayout, notNullCheckName, renderBlocks, sameBlockFile, sameTenantColumn, sameTenantTrigger, scopePolicyName, sharedRolesProblems, subjectColumns, widenedCommands } from "better-supabase/sql";
|
|
40
40
|
import { defineBucket, parseSize } from "better-supabase/storage";
|
|
41
41
|
//#region src/cli/doctor/env.ts
|
|
42
42
|
const PUBLIC_PREFIXES = [
|
|
@@ -203,7 +203,7 @@ async function fileState(context, file) {
|
|
|
203
203
|
* the block's to grant.
|
|
204
204
|
*/
|
|
205
205
|
function widenedAppTablePolicies(context) {
|
|
206
|
-
const tables = adoptedTables(context.config.blocks, appTablesOf(context));
|
|
206
|
+
const tables = adoptedTables(context.config.blocks, appTablesOf(context), { subjects: context.config.subjects });
|
|
207
207
|
if (tables.length === 0) return [];
|
|
208
208
|
const modules = /* @__PURE__ */ new Map();
|
|
209
209
|
for (const table of tables) {
|
|
@@ -293,7 +293,7 @@ async function keptUpdatedAtTriggers(context) {
|
|
|
293
293
|
* tables keep the app's names, as custom blocks' tables do.
|
|
294
294
|
*/
|
|
295
295
|
function keepsAppsName(context) {
|
|
296
|
-
const adopted = context.config.blockNames.some((name) => moduleDeprecations().some((entry) => entry.module === name && (entry.kind === "table" || entry.kind === "column"))) ? adoptedTables(context.config.blocks, appTablesOf(context)) : [];
|
|
296
|
+
const adopted = context.config.blockNames.some((name) => moduleDeprecations().some((entry) => entry.module === name && (entry.kind === "table" || entry.kind === "column"))) ? adoptedTables(context.config.blocks, appTablesOf(context), { subjects: context.config.subjects }) : [];
|
|
297
297
|
return (entry) => {
|
|
298
298
|
if (entry.kind !== "table" && entry.kind !== "column") return false;
|
|
299
299
|
if ((context.config.blocks[entry.module]?.mode ?? "managed") !== "managed") return true;
|
|
@@ -387,7 +387,7 @@ const ADOPTION_RULES = [
|
|
|
387
387
|
check: (context) => {
|
|
388
388
|
const { tables } = catalogOf(context);
|
|
389
389
|
const ownTables = Object.fromEntries(tables.map((table) => [qualified(table), "database"]));
|
|
390
|
-
return adoptedTables(context.config.blocks, ownTables).flatMap((adopted) => {
|
|
390
|
+
return adoptedTables(context.config.blocks, ownTables, { subjects: context.config.subjects }).flatMap((adopted) => {
|
|
391
391
|
const table = tables.find((entry) => entry.schema === adopted.schema && entry.name === adopted.table);
|
|
392
392
|
if (table === void 0) return [];
|
|
393
393
|
return adopted.textColumns.flatMap((logical) => {
|
|
@@ -411,7 +411,7 @@ const ADOPTION_RULES = [
|
|
|
411
411
|
check: (context) => {
|
|
412
412
|
const block = context.config.blocks["webhooks-out"];
|
|
413
413
|
if (block === void 0 || block.options?.["defaultFormat"] !== void 0 || typeof block.columns?.["endpoints"]?.["format"] === "string") return [];
|
|
414
|
-
const adopted = adoptedTables(context.config.blocks, appTablesOf(context)).find((entry) => entry.module === "webhooks-out" && entry.logical === "endpoints");
|
|
414
|
+
const adopted = adoptedTables(context.config.blocks, appTablesOf(context), { subjects: context.config.subjects }).find((entry) => entry.module === "webhooks-out" && entry.logical === "endpoints");
|
|
415
415
|
if (adopted === void 0) return [];
|
|
416
416
|
const table = catalogOf(context).tables.find((entry) => entry.schema === adopted.schema && entry.name === adopted.table);
|
|
417
417
|
return [{
|
|
@@ -582,7 +582,7 @@ const APP_TABLE_SCOPE_RULES = [{
|
|
|
582
582
|
}, command)));
|
|
583
583
|
const extra = table.policies.filter((policy) => policy.permissive && !own.has(policy.name));
|
|
584
584
|
if (extra.length === 0) return [];
|
|
585
|
-
const narrowed = app.scope === "tenant" && table.policies.some((policy) => !policy.permissive && policy.name === TENANT_SCOPE_POLICY);
|
|
585
|
+
const narrowed = app.scope === "tenant" && table.policies.some((policy) => !policy.permissive && (policy.name === TENANT_SCOPE_POLICY || TENANT_SCOPE_NAMES.includes(policy.name)));
|
|
586
586
|
const names = extra.map((policy) => policy.name).join(", ");
|
|
587
587
|
const label = `${SCHEMA}.${app.name}`;
|
|
588
588
|
return [{
|
|
@@ -1713,7 +1713,10 @@ async function danglingAuditRegistrations(context) {
|
|
|
1713
1713
|
async function missingAdoptedColumns(context) {
|
|
1714
1714
|
const db = context.database;
|
|
1715
1715
|
if (!db || "skipped" in db) return [];
|
|
1716
|
-
const tables = adoptedTables(context.config.blocks, appTablesOf(context),
|
|
1716
|
+
const tables = adoptedTables(context.config.blocks, appTablesOf(context), {
|
|
1717
|
+
...appViewsOf(context),
|
|
1718
|
+
subjects: context.config.subjects
|
|
1719
|
+
});
|
|
1717
1720
|
if (tables.length === 0) return [];
|
|
1718
1721
|
const names = tables.map((table) => `(${literal$1(table.schema)}, ${literal$1(table.table)})`).join(", ");
|
|
1719
1722
|
let rows;
|
|
@@ -1096,8 +1096,7 @@ function parseEnv(env) {
|
|
|
1096
1096
|
CI: optionalString,
|
|
1097
1097
|
BETTER_SUPABASE_ENV: optionalString,
|
|
1098
1098
|
BETTER_SUPABASE_AGENT: optionalString,
|
|
1099
|
-
BSB_STACK: optionalString
|
|
1100
|
-
BSB_PG_BIN: optionalString
|
|
1099
|
+
BSB_STACK: optionalString
|
|
1101
1100
|
},
|
|
1102
1101
|
runtimeEnv: env,
|
|
1103
1102
|
isServer: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as PROCESS_ENV, n as configEnvironment, r as isCi, i as parseEnv } from "./env-
|
|
1
|
+
export { t as PROCESS_ENV, n as configEnvironment, r as isCi, i as parseEnv } from "./env-BK0xKMeU.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as envCommand } from "./env-DEAtgGoj.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { p as commandMeta, r as defineCliCommand } from "./command-CVzTJSLp.js";
|
|
2
2
|
import { n as CliError } from "./errors-BTe6A15O.js";
|
|
3
3
|
import { r as readIfExists, t as display } from "./io-DH1kcmmP.js";
|
|
4
|
-
import { n as readStackStatus, t as parseStackStatus } from "./stack-status-
|
|
4
|
+
import { n as readStackStatus, t as parseStackStatus } from "./stack-status-BkkYRlXG.js";
|
|
5
5
|
import { c as insideRoot, i as changeLines, n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
|
|
6
6
|
import { r as publicPrefix, t as detectProject } from "./detect-D9JaAX20.js";
|
|
7
7
|
import { n as prefixFromFlag, r as stackEnvValues } from "./stack-env-6hS-WEmh.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
|
|
2
2
|
import { t as EXEC_CHANNEL } from "./trace-VbdO6bcN.js";
|
|
3
3
|
import { s as findUp } from "./supabase-toml-CncmQbO0.js";
|
|
4
|
-
import { t as PROCESS_ENV } from "./env-
|
|
4
|
+
import { t as PROCESS_ENV } from "./env-BK0xKMeU.js";
|
|
5
5
|
import { channel } from "node:diagnostics_channel";
|
|
6
6
|
import { closeSync, existsSync, openSync, readSync, statSync } from "node:fs";
|
|
7
7
|
import { basename, delimiter, dirname, join, normalize, resolve } from "node:path";
|