better-supabase 0.3.0 → 0.4.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/README.md +7 -6
- package/bin/better-supabase.js +4 -0
- package/dist/{base64-CQeB1eSf.js → base64-D2gsioCY.js} +2 -2
- package/dist/claims-BAf6c7is.js +48 -0
- package/dist/cli/_format-Cax5EsM9.js +101 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +48 -0
- package/dist/cli/command-CK14fP91.js +502 -0
- package/dist/cli/compare-BmIWVEui.js +9 -0
- package/dist/cli/config-D9R0o1LH.js +1895 -0
- package/dist/cli/config-SSKSTUl2.js +2 -0
- package/dist/cli/db-DOBPt660.js +52 -0
- package/dist/cli/dist-B1MvLv-M.js +129 -0
- package/dist/cli/dist-CFgGknmZ.js +1112 -0
- package/dist/cli/dist-Du7VnEUG.js +621 -0
- package/dist/cli/doctor-BOym3mbL.js +2382 -0
- package/dist/cli/env-BZ0uy8XK.js +108 -0
- package/dist/cli/env-jIFUADLY.js +511 -0
- package/dist/cli/errors-4v4DTtda.js +56 -0
- package/dist/cli/fastest-levenshtein-CFN-lNDv.js +120 -0
- package/dist/cli/gen-Ccn_p90L.js +2008 -0
- package/dist/cli/gen-D5cLCULx.js +2 -0
- package/dist/cli/index.d.ts +493 -0
- package/dist/cli/index.js +184 -0
- package/dist/cli/init-ClnxRYBF.js +550 -0
- package/dist/cli/introspect-DxqfkVIv.js +81 -0
- package/dist/cli/io-k41_z-jT.js +24 -0
- package/dist/cli/json5-ChRycquj.js +787 -0
- package/dist/cli/jsonc-BUniUpOk.js +2 -0
- package/dist/cli/jsonc-D5Fu67jw.js +45 -0
- package/dist/cli/keys-ByKHnvP9.js +83 -0
- package/dist/cli/ohash-D7bG_EOb.js +277 -0
- package/dist/cli/openapi-8WHjxiTJ.js +66 -0
- package/dist/cli/project-B_GeXyHh.js +70 -0
- package/dist/cli/prompts-BNcNfAve.js +1142 -0
- package/dist/cli/prompts-BTYQGunc.js +2 -0
- package/dist/cli/read-sets-CMa29t9a.js +971 -0
- package/dist/cli/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/cli/run-CP20LKk_.js +347 -0
- package/dist/cli/seed-5J6eu_Xg.js +98 -0
- package/dist/cli/skills-LJJIhLFR.js +137 -0
- package/dist/cli/sql-D4VbqmXi.js +199 -0
- package/dist/cli/style-C0NFdJRL.js +29 -0
- package/dist/cli/toml-DB-MNnFs.js +424 -0
- package/dist/cli/version-5mW_8sY1.js +4 -0
- package/dist/cli/yaml-CYCbJ6et.js +2252 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +13 -13
- package/dist/{compiler-2zqGzxVZ.d.ts → compiler-DB3aSFOA.d.ts} +2 -2
- package/dist/config/index.js +4 -4
- package/dist/{config-Be4GwsqI.js → config-BpxDfnbg.js} +1 -1
- package/dist/{config-DOsGYSiT.js → config-CbvFmGD8.js} +1 -1
- package/dist/{define-DF341GDj.js → define-Bh0AqTik.js} +160 -79
- package/dist/{define-DUbydmJa.d.ts → define-CRS2MRV3.d.ts} +32 -28
- package/dist/edge/index.d.ts +8 -12
- package/dist/edge/index.js +50 -24
- package/dist/{entitlements-DvJXoI02.d.ts → entitlements-Dm-FHpNH.d.ts} +2 -2
- package/dist/{errors-Bl3rkOzo.js → errors-L0xK41y_.js} +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/{events-Do8jXh4D.d.ts → events-B21UOhvP.d.ts} +4 -4
- package/dist/{executor-DynmIWhq.d.ts → executor-B5IoUxLE.d.ts} +1 -1
- package/dist/{executor-C57jx2pn.js → executor-CVt6dD0B.js} +3 -3
- package/dist/{executor-B26lgbHD.d.ts → executor-CZ7ImRiD.d.ts} +2 -2
- package/dist/hono/index.d.ts +16 -23
- package/dist/hono/index.js +10 -10
- package/dist/{index-CTTMS6_1.d.ts → index-528Ugmyp.d.ts} +12 -3
- package/dist/{index-CADlNHK-.d.ts → index-BAy4tsAP.d.ts} +5 -5
- package/dist/{index-BNsABq7P.d.ts → index-BBdvo-5d.d.ts} +23 -25
- package/dist/{index-qriRM9cZ.d.ts → index-BhHEC04r.d.ts} +3 -3
- package/dist/{index-GV77NpRP.d.ts → index-D5IfUIDh.d.ts} +3 -3
- package/dist/{index-CriFFJ_p.d.ts → index-DFmOpBGC.d.ts} +11 -11
- package/dist/{index-UJ-LUxtI.d.ts → index-RlLXd8dL.d.ts} +12 -12
- package/dist/index.d.ts +15 -15
- package/dist/index.js +13 -13
- package/dist/{invalidate-DbxuL2jL.js → invalidate-CgxmRamI.js} +7 -1
- package/dist/jobs/index.d.ts +10 -4
- package/dist/jobs/index.js +32 -16
- package/dist/{json-schema--aOXAGfU.js → json-schema-DP6V7cbr.js} +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +3 -3
- package/dist/{live-QE3UPbGm.d.ts → live-BHakSWWo.d.ts} +12 -12
- package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
- package/dist/lookup-BaP5bI27.js +18 -0
- package/dist/mcp/index.d.ts +18 -18
- package/dist/mcp/index.js +23 -18
- package/dist/{mfa-x3V3vGh-.d.ts → mfa-C7MNQ1Ob.d.ts} +1 -1
- package/dist/{mfa-BxoR1RkN.js → mfa-byfjruR9.js} +118 -29
- package/dist/next/image/index.js +6 -3
- package/dist/next/index.d.ts +38 -35
- package/dist/next/index.js +41 -33
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +6 -6
- package/dist/orpc/index.d.ts +17 -20
- package/dist/orpc/index.js +11 -11
- package/dist/otel/index.d.ts +5 -5
- package/dist/otel/index.js +81 -62
- package/dist/{permdock-sql-Bta_G0v-.js → permdock-sql-C4KFzLc9.js} +1 -1
- package/dist/{plugin-DVRB8qNE.d.ts → plugin-bNhvJwRh.d.ts} +2 -2
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/actor/index.js +1 -1
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +42 -12
- package/dist/plugins/soft-delete/index.d.ts +2 -2
- package/dist/plugins/soft-delete/index.js +2 -2
- package/dist/plugins/tenant/index.d.ts +2 -2
- package/dist/plugins/tenant/index.js +10 -4
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +1 -1
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +3 -3
- package/dist/{pool-B9qsLyFR.d.ts → pool-DFwEQwmN.d.ts} +11 -4
- package/dist/postgres/index.d.ts +5 -5
- package/dist/postgres/index.js +3 -2
- package/dist/{postgrest-DmBlevh-.d.ts → postgrest-Bc-0Xw62.d.ts} +1 -1
- package/dist/{problem-CGt1ADix.js → problem-BihjPR0t.js} +1 -1
- package/dist/{problem-Z2RTQjZD.d.ts → problem-U8UEKccv.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +2 -2
- package/dist/{query-BdKLTPlj.js → query-BMMSWbI7.js} +18 -18
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +1 -1
- package/dist/react/server.d.ts +5 -5
- package/dist/react/server.js +3 -3
- package/dist/react/session.d.ts +4 -4
- package/dist/react/session.js +2 -2
- package/dist/{react-DNBYNazu.js → react-CQHMaESR.js} +39 -39
- package/dist/{read-set-D0qBcboM.js → read-set-FWK8qQ58.js} +50 -15
- package/dist/realtime/index.d.ts +1 -1
- package/dist/realtime/index.js +13 -12
- package/dist/{index-kpgopLNv.d.ts → refresh-BwYkyNOQ.d.ts} +6 -3
- package/dist/{resolve-BRciX2jK.d.ts → resolve-BAqQcwMW.d.ts} +15 -10
- package/dist/{resource-CwVgiI5q.d.ts → resource-BJcaIfxi.d.ts} +5 -5
- package/dist/{resource-D30rp0GN.js → resource-My_y-Syh.js} +6 -6
- package/dist/{respond-DAkPIdTH.d.ts → respond-DgIbdrt8.d.ts} +31 -12
- package/dist/{result-DWXatkd6.js → result-Bj6yt33D.js} +2 -2
- package/dist/{result-c2OYgCV2.d.ts → result-CqEsbgYs.d.ts} +3 -3
- package/dist/server/index.d.ts +14 -14
- package/dist/server/index.js +12 -12
- package/dist/{respond-C44EZAJo.js → server-BA75B0mT.js} +139 -100
- package/dist/{shared-_6-uPL7E.js → shared-DnoCdMDr.js} +4 -3
- package/dist/{simplify-LakqK1vH.js → simplify-Cqvfr9dj.js} +67 -24
- package/dist/sql/index.d.ts +1 -1
- package/dist/sql/index.js +7 -7
- package/dist/{sql-BIgk12ew.js → sql-B34HU2DI.js} +3 -2
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +2 -2
- package/dist/{standard-FUi3Z3-7.js → standard-BRyBGTtp.js} +2 -2
- package/dist/{standard-eudBiRk1.d.ts → standard-BsaCYQJc.d.ts} +1 -1
- package/dist/{stats-D78UQ8Yu.js → stats-C_YxA2r1.js} +33 -8
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +26 -8
- package/dist/{tables-Dhha3BXM.js → tables-Cb-3_VWc.js} +14 -0
- package/dist/{temporal-required-CMxeSVPo.js → temporal-required-CBNHT6ni.js} +1 -1
- package/dist/testing/index.d.ts +20 -21
- package/dist/testing/index.js +45 -45
- package/dist/{version-BfpG2gks.js → version-Bmf7_FzM.js} +1 -1
- package/dist/{view-3Po_PVlr.d.ts → view-B64o81wp.d.ts} +5 -5
- package/dist/{view-wZ-9qIUz.js → view-BrJI2LKp.js} +1 -1
- package/dist/webhooks/index.d.ts +3 -3
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-CAIFQSTM.js → webhooks-Bh_Jf_-l.js} +37 -18
- package/package.json +36 -4
- package/skills/better-supabase/SKILL.md +57 -10
- package/skills/better-supabase/references/plugins.md +7 -11
- package/skills/better-supabase/references/troubleshooting.md +24 -4
- package/skills/better-supabase-api/SKILL.md +66 -18
- package/skills/better-supabase-api/references/adapters.md +44 -26
- package/skills/better-supabase-auth/SKILL.md +146 -0
- package/skills/better-supabase-auth/references/permdock.md +55 -0
- package/skills/better-supabase-testing/SKILL.md +58 -4
- package/dist/claims-CoTobNC-.js +0 -25
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as loadConfig, i as importModule, n as findConfig, o as readSupabasePort, r as importExport, s as stdinDatabaseUrl, t as databaseUrl } from "./config-D9R0o1LH.js";
|
|
2
|
+
export { databaseUrl, findConfig, importExport, importModule, loadConfig, readSupabasePort, stdinDatabaseUrl };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/cli/db.ts
|
|
2
|
+
const CONNECT_TIMEOUT_MS = 1e4;
|
|
3
|
+
const loadPg = () => import("pg");
|
|
4
|
+
/** Opens a `pg` connection. `pg` is an optional peer, loaded on demand. */
|
|
5
|
+
async function connect(url, load = loadPg, options = {}) {
|
|
6
|
+
let pg;
|
|
7
|
+
try {
|
|
8
|
+
const mod = await load();
|
|
9
|
+
pg = mod.default ?? mod;
|
|
10
|
+
} catch {
|
|
11
|
+
throw new Error("better-supabase needs the \"pg\" package to read your database. Install it: pnpm add -D pg");
|
|
12
|
+
}
|
|
13
|
+
options.signal?.throwIfAborted();
|
|
14
|
+
const settings = {
|
|
15
|
+
connectionString: url,
|
|
16
|
+
connectionTimeoutMillis: CONNECT_TIMEOUT_MS,
|
|
17
|
+
...options.statementTimeout === void 0 ? {} : { statement_timeout: options.statementTimeout }
|
|
18
|
+
};
|
|
19
|
+
const pool = options.pool === void 0 || pg.Pool === void 0 ? void 0 : new pg.Pool({
|
|
20
|
+
...settings,
|
|
21
|
+
max: options.pool
|
|
22
|
+
});
|
|
23
|
+
const client = pool ?? new pg.Client(settings);
|
|
24
|
+
const pooled = pool !== void 0;
|
|
25
|
+
client.on?.("error", () => void 0);
|
|
26
|
+
let ended;
|
|
27
|
+
const close = () => ended ??= client.end();
|
|
28
|
+
const onAbort = () => void close().catch(() => void 0);
|
|
29
|
+
try {
|
|
30
|
+
if (pool) (await pool.connect()).release();
|
|
31
|
+
else await client.connect();
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
await close().catch(() => void 0);
|
|
34
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
35
|
+
throw new Error(`Could not connect to ${redact(url)}: ${message}. Is the local stack running (supabase start)?`, { cause });
|
|
36
|
+
}
|
|
37
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
38
|
+
return {
|
|
39
|
+
client,
|
|
40
|
+
...pooled ? { pooled } : {},
|
|
41
|
+
close: () => {
|
|
42
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
43
|
+
return close();
|
|
44
|
+
},
|
|
45
|
+
describe: redact(url)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function redact(url) {
|
|
49
|
+
return url.replace(/\/\/([^:@/]+):([^@/]+)@/, "//$1:***@");
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { connect as t };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { a as isAbsolute, c as resolve, o as join, r as dirname, s as normalize, t as resolveModulePath } from "./dist-CFgGknmZ.js";
|
|
2
|
+
import { n as o, t as i } from "./_format-Cax5EsM9.js";
|
|
3
|
+
import { t as i$1 } from "./jsonc-D5Fu67jw.js";
|
|
4
|
+
import { promises, statSync } from "node:fs";
|
|
5
|
+
import "node:fs/promises";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/json.mjs
|
|
8
|
+
function r(e, r) {
|
|
9
|
+
let i$2 = JSON.parse(i(e), r?.reviver);
|
|
10
|
+
return o(e, i$2, r), i$2;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../node_modules/.pnpm/pkg-types@2.3.3/node_modules/pkg-types/dist/index.mjs
|
|
14
|
+
const defaultFindOptions = {
|
|
15
|
+
startingFrom: ".",
|
|
16
|
+
rootPattern: /^node_modules$/,
|
|
17
|
+
reverse: false,
|
|
18
|
+
test: (filePath) => {
|
|
19
|
+
try {
|
|
20
|
+
if (statSync(filePath).isFile()) return true;
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
async function findFile(filename, _options = {}) {
|
|
25
|
+
const filenames = Array.isArray(filename) ? filename : [filename];
|
|
26
|
+
const options = {
|
|
27
|
+
...defaultFindOptions,
|
|
28
|
+
..._options
|
|
29
|
+
};
|
|
30
|
+
const basePath = resolve(options.startingFrom);
|
|
31
|
+
const leadingSlash = basePath[0] === "/";
|
|
32
|
+
const segments = basePath.split("/").filter(Boolean);
|
|
33
|
+
if (filenames.includes(segments.at(-1)) && await options.test(basePath)) return basePath;
|
|
34
|
+
if (leadingSlash) segments[0] = "/" + segments[0];
|
|
35
|
+
let root = segments.findIndex((r) => r.match(options.rootPattern));
|
|
36
|
+
if (root === -1) root = 0;
|
|
37
|
+
if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename of filenames) {
|
|
38
|
+
const filePath = join(...segments.slice(0, index), filename);
|
|
39
|
+
if (await options.test(filePath)) return filePath;
|
|
40
|
+
}
|
|
41
|
+
else for (let index = segments.length; index > root; index--) for (const filename of filenames) {
|
|
42
|
+
const filePath = join(...segments.slice(0, index), filename);
|
|
43
|
+
if (await options.test(filePath)) return filePath;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
|
|
46
|
+
}
|
|
47
|
+
function findNearestFile(filename, options = {}) {
|
|
48
|
+
return findFile(filename, options);
|
|
49
|
+
}
|
|
50
|
+
function _resolvePath(id, opts = {}) {
|
|
51
|
+
if (id instanceof URL || id.startsWith("file://")) return normalize(fileURLToPath(id));
|
|
52
|
+
if (isAbsolute(id)) return normalize(id);
|
|
53
|
+
return resolveModulePath(id, {
|
|
54
|
+
...opts,
|
|
55
|
+
from: opts.from || opts.parent || opts.url
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const lockFiles = [
|
|
59
|
+
"yarn.lock",
|
|
60
|
+
"package-lock.json",
|
|
61
|
+
"pnpm-lock.yaml",
|
|
62
|
+
"npm-shrinkwrap.json",
|
|
63
|
+
"bun.lockb",
|
|
64
|
+
"bun.lock",
|
|
65
|
+
"deno.lock"
|
|
66
|
+
];
|
|
67
|
+
const packageFiles = [
|
|
68
|
+
"package.json",
|
|
69
|
+
"package.json5",
|
|
70
|
+
"package.yaml"
|
|
71
|
+
];
|
|
72
|
+
const workspaceFiles = [
|
|
73
|
+
"pnpm-workspace.yaml",
|
|
74
|
+
"lerna.json",
|
|
75
|
+
"turbo.json",
|
|
76
|
+
"rush.json",
|
|
77
|
+
"deno.json",
|
|
78
|
+
"deno.jsonc"
|
|
79
|
+
];
|
|
80
|
+
const FileCache = /* #__PURE__ */ new Map();
|
|
81
|
+
async function readPackageJSON(id, options = {}) {
|
|
82
|
+
const resolvedPath = await resolvePackageJSON(id, options);
|
|
83
|
+
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
|
|
84
|
+
if (options.cache && cache.has(resolvedPath)) return cache.get(resolvedPath);
|
|
85
|
+
const blob = await promises.readFile(resolvedPath, "utf8");
|
|
86
|
+
let parsed;
|
|
87
|
+
try {
|
|
88
|
+
parsed = r(blob);
|
|
89
|
+
} catch {
|
|
90
|
+
parsed = i$1(blob);
|
|
91
|
+
}
|
|
92
|
+
cache.set(resolvedPath, parsed);
|
|
93
|
+
return parsed;
|
|
94
|
+
}
|
|
95
|
+
async function resolvePackageJSON(id = process.cwd(), options = {}) {
|
|
96
|
+
return findNearestFile("package.json", {
|
|
97
|
+
...options,
|
|
98
|
+
startingFrom: _resolvePath(id, options)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const workspaceTests = {
|
|
102
|
+
workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r) => dirname(r)),
|
|
103
|
+
gitConfig: (opts) => findFile(".git/config", opts).then((r) => resolve(r, "../..")),
|
|
104
|
+
lockFile: (opts) => findFile(lockFiles, opts).then((r) => dirname(r)),
|
|
105
|
+
packageJson: (opts) => findFile(packageFiles, opts).then((r) => dirname(r))
|
|
106
|
+
};
|
|
107
|
+
async function findWorkspaceDir(id = process.cwd(), options = {}) {
|
|
108
|
+
const startingFrom = _resolvePath(id, options);
|
|
109
|
+
const tests = options.tests || [
|
|
110
|
+
"workspaceFile",
|
|
111
|
+
"gitConfig",
|
|
112
|
+
"lockFile",
|
|
113
|
+
"packageJson"
|
|
114
|
+
];
|
|
115
|
+
for (const testName of tests) {
|
|
116
|
+
const test = workspaceTests[testName];
|
|
117
|
+
if (options[testName] === false || !test) continue;
|
|
118
|
+
const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
|
|
119
|
+
const detected = await test({
|
|
120
|
+
...options,
|
|
121
|
+
startingFrom,
|
|
122
|
+
reverse: direction === "furthest"
|
|
123
|
+
}).catch(() => {});
|
|
124
|
+
if (detected) return detected;
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Cannot detect workspace root from ${id}`);
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { findWorkspaceDir, readPackageJSON };
|