better-supabase 0.1.0 → 0.3.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 +34 -31
- package/dist/base64-CQeB1eSf.js +42 -0
- package/dist/claims-CoTobNC-.js +25 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +4 -14
- package/dist/{compiler-DL18ukPe.d.ts → compiler-2zqGzxVZ.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -3
- package/dist/config/index.js +5 -3
- package/dist/config-Be4GwsqI.js +129 -0
- package/dist/{index-BD6wKthp.d.ts → config-C1CYcm6o.d.ts} +75 -54
- package/dist/{config-D-aR2ZoN.js → config-DOsGYSiT.js} +14 -136
- package/dist/{define-QGkq04oe.js → define-DF341GDj.js} +133 -110
- package/dist/{define-CTfWw-SS.d.ts → define-DUbydmJa.d.ts} +32 -14
- package/dist/edge/index.d.ts +4 -4
- package/dist/edge/index.js +4 -4
- package/dist/entitlements-CTEBm7IB.js +20 -0
- package/dist/entitlements-DvJXoI02.d.ts +42 -0
- package/dist/env/index.js +203 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +139 -1
- package/dist/{events-2OJsVG_d.d.ts → events-Do8jXh4D.d.ts} +3 -3
- package/dist/{executor-Bje4suQF.d.ts → executor-B26lgbHD.d.ts} +2 -2
- package/dist/{executor-Ceq60hPM.js → executor-C57jx2pn.js} +7 -2
- package/dist/{executor-Bazhgsgq.d.ts → executor-DynmIWhq.d.ts} +2 -2
- package/dist/guards-BnzDvFrz.js +10 -0
- package/dist/hono/index.d.ts +5 -5
- package/dist/hono/index.js +4 -4
- package/dist/{index-Hf8PP9sP.d.ts → index-BNsABq7P.d.ts} +17 -13
- package/dist/{index-JXHBuS53.d.ts → index-CADlNHK-.d.ts} +27 -14
- package/dist/{index-Nxo3TJcm.d.ts → index-CTTMS6_1.d.ts} +27 -8
- package/dist/index-Cf-D2jk1.d.ts +50 -0
- package/dist/{index-Dup-nSe9.d.ts → index-CriFFJ_p.d.ts} +4 -4
- package/dist/{index-DQVvHzjW.d.ts → index-GV77NpRP.d.ts} +5 -4
- package/dist/{index-Sw43J8HG.d.ts → index-UJ-LUxtI.d.ts} +6 -6
- package/dist/{index-cEeweTeM.d.ts → index-kpgopLNv.d.ts} +4 -3
- package/dist/{index-DRid0qIv.d.ts → index-qriRM9cZ.d.ts} +7 -2
- package/dist/index.d.ts +13 -13
- package/dist/index.js +18 -8
- package/dist/jobs/index.d.ts +25 -24
- package/dist/jobs/index.js +19 -12
- package/dist/{json-schema-BbwO2mZg.js → json-schema--aOXAGfU.js} +9 -3
- package/dist/lint/index.js +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.js +128 -93
- package/dist/{live-6b9i72Ux.d.ts → live-QE3UPbGm.d.ts} +27 -6
- package/dist/logger-glM28NVN.js +21 -0
- package/dist/mcp/index.d.ts +59 -15
- package/dist/mcp/index.js +229 -67
- package/dist/{mfa-CpogP66z.js → mfa-BxoR1RkN.js} +97 -22
- package/dist/{mfa-TVia554c.d.ts → mfa-x3V3vGh-.d.ts} +1 -1
- package/dist/next/index.d.ts +51 -38
- package/dist/next/index.js +31 -25
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +58 -35
- package/dist/orpc/index.d.ts +6 -6
- package/dist/orpc/index.js +3 -3
- package/dist/otel/index.d.ts +3 -3
- package/dist/otel/index.js +5 -3
- package/dist/{template-BeOGnynM.js → permdock-sql-Bta_G0v-.js} +32 -3
- package/dist/permdock-sql-DImJULY-.d.ts +17 -0
- package/dist/{plugin-HvGqCurB.d.ts → plugin-DVRB8qNE.d.ts} +5 -4
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/rules/index.d.ts +4 -3
- package/dist/plugins/rules/index.js +8 -15
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +2 -2
- package/dist/plugins/tenant/index.d.ts +10 -4
- package/dist/plugins/tenant/index.js +15 -13
- 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/pool-B9qsLyFR.d.ts +71 -0
- package/dist/postgres/index.d.ts +10 -5
- package/dist/postgres/index.js +36 -16
- package/dist/{postgrest-Dm-vhY6R.d.ts → postgrest-DmBlevh-.d.ts} +1 -1
- package/dist/{problem-DPu6Fh-t.js → problem-CGt1ADix.js} +14 -8
- package/dist/{problem-DlgB0lYl.d.ts → problem-Z2RTQjZD.d.ts} +6 -4
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +1 -1
- package/dist/{query-ChvDbsDE.js → query-BdKLTPlj.js} +2 -2
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +3 -3
- package/dist/react/server.d.ts +5 -5
- package/dist/react/server.js +1 -1
- package/dist/react/session.d.ts +21 -2
- package/dist/react/session.js +19 -1
- package/dist/{react-CrOvrnIP.js → react-DNBYNazu.js} +28 -23
- package/dist/{read-set-DhX2d04c.js → read-set-D0qBcboM.js} +3 -3
- package/dist/realtime/index.d.ts +4 -2
- package/dist/realtime/index.js +30 -14
- package/dist/{resolve-DW8h9NPm.d.ts → resolve-BRciX2jK.d.ts} +25 -9
- package/dist/{resource-SkPTRJDD.d.ts → resource-CwVgiI5q.d.ts} +16 -7
- package/dist/{resource-CYiu6Ygi.js → resource-D30rp0GN.js} +38 -16
- package/dist/{respond-4-dhoV7x.js → respond-C44EZAJo.js} +38 -19
- package/dist/{respond-PoTpy5DT.d.ts → respond-DAkPIdTH.d.ts} +23 -17
- package/dist/{result-CTkCZ6JA.d.ts → result-c2OYgCV2.d.ts} +13 -8
- package/dist/server/index.d.ts +35 -10
- package/dist/server/index.js +38 -9
- package/dist/{simplify-oHiDKRVQ.js → simplify-LakqK1vH.js} +22 -28
- package/dist/{spec-pins-t6sPaHvl.js → spec-pins-C3oc-Tdp.js} +1 -1
- package/dist/{spec-pins-CJPVghHy.d.ts → spec-pins-CqorWDnO.d.ts} +1 -1
- package/dist/sql/index.d.ts +139 -0
- package/dist/sql/index.js +1983 -0
- package/dist/{sql-M8l3fnS0.js → sql-BIgk12ew.js} +72 -16
- package/dist/ssr/index.d.ts +5 -5
- package/dist/ssr/index.js +3 -3
- package/dist/{standard-CyhRzctb.d.ts → standard-eudBiRk1.d.ts} +1 -1
- package/dist/{stats-3iy8u3_P.js → stats-D78UQ8Yu.js} +8 -7
- package/dist/storage/index.d.ts +4 -2
- package/dist/storage/index.js +530 -1
- package/dist/{tables-rZxRxNPW.js → tables-Dhha3BXM.js} +5 -5
- package/dist/temporal-BwshQk0W.js +27 -0
- package/dist/temporal-required-CMxeSVPo.js +19 -0
- package/dist/testing/index.d.ts +49 -16
- package/dist/testing/index.js +233 -66
- package/dist/{types-C2fslP1z.d.ts → types-DONv9SHN.d.ts} +68 -12
- package/dist/{version-Cqq1m3UY.js → version-BfpG2gks.js} +1 -1
- package/dist/view-3Po_PVlr.d.ts +79 -0
- package/dist/{view-B6F9QbG-.js → view-wZ-9qIUz.js} +12 -2
- package/dist/webhooks/index.d.ts +19 -17
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-DbMTJJX2.js → webhooks-CAIFQSTM.js} +12 -10
- package/package.json +30 -30
- package/schemas/config-v1.json +80 -5
- package/schemas/doctor-report-v1.json +18 -1
- package/schemas/snapshot-v2.json +39 -0
- package/skills/better-supabase/SKILL.md +23 -11
- package/skills/better-supabase/references/plugins.md +28 -16
- package/skills/better-supabase/references/troubleshooting.md +15 -15
- package/skills/better-supabase-api/SKILL.md +9 -9
- package/skills/better-supabase-api/references/adapters.md +30 -25
- package/skills/better-supabase-testing/SKILL.md +15 -11
- package/bin/better-supabase.js +0 -3
- package/dist/casing-da0uRTqt.js +0 -14
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +0 -15
- package/dist/cli/index.d.ts +0 -226
- package/dist/cli/index.js +0 -3
- package/dist/cli-CoByWYja.js +0 -6472
- package/dist/entitlements-BBg61DQZ.d.ts +0 -20
- package/dist/entitlements-BC_khwRy.js +0 -17
- package/dist/env-BEToab0I.js +0 -204
- package/dist/events-BuzTgn2D.js +0 -135
- package/dist/pool-BFeqzwQS.d.ts +0 -37
- package/dist/seed-CzecODcJ.js +0 -101
- package/dist/session-C3osL21k.d.ts +0 -21
- package/dist/session-CD-3orO_.js +0 -19
- package/dist/storage-BWXVUXGk.js +0 -461
- package/dist/view-B0ltUmTi.d.ts +0 -43
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/better-supabase)
|
|
6
6
|
[](https://github.com/ScaleDockHQ/better-supabase/blob/main/LICENSE)
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
`better-supabase gen` extends `supabase gen types` with relation cardinality, unique keys, CHECK unions and typed jsonb. The generated `schema` gives every table a typed repository that compiles to one PostgREST request, returns a `Result` instead of throwing, and runs as the caller so RLS always applies.
|
|
10
10
|
|
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
pnpm add better-supabase @supabase/supabase-js
|
|
15
|
-
pnpm add -D pg
|
|
15
|
+
pnpm add -D @better-supabase/cli pg
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
ESM only. Node 24 or later
|
|
18
|
+
ESM only. The CLI ships as [`@better-supabase/cli`](https://www.npmjs.com/package/@better-supabase/cli), always at the same version as `better-supabase`, and needs Node 24 or later; the runtime entries run on every WinterTC runtime (Node, Deno, Bun, Workers, Supabase Edge Functions). TypeScript 6 and 7 are tested.
|
|
19
19
|
|
|
20
20
|
## Quick start
|
|
21
21
|
|
|
22
|
+
Or start with `npx @better-supabase/cli init`, which detects your frameworks and prints the install command.
|
|
23
|
+
|
|
22
24
|
```bash
|
|
23
25
|
supabase start
|
|
24
26
|
pnpm better-supabase init # config, src/lib/supabase.ts and framework glue
|
|
@@ -26,20 +28,20 @@ pnpm better-supabase gen # database.types.ts and generated.ts
|
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
```ts
|
|
29
|
-
import { createClient } from
|
|
30
|
-
import { defineSupabase } from
|
|
31
|
+
import { createClient } from "@supabase/supabase-js";
|
|
32
|
+
import { defineSupabase } from "better-supabase";
|
|
31
33
|
|
|
32
|
-
import { schema } from
|
|
34
|
+
import { schema } from "./lib/supabase/generated.ts";
|
|
33
35
|
|
|
34
36
|
export const sb = defineSupabase(schema);
|
|
35
37
|
|
|
36
38
|
const db = sb.connect(createClient(url, publishableKey));
|
|
37
39
|
|
|
38
40
|
const result = await db.customers.findMany({
|
|
39
|
-
select: [
|
|
40
|
-
where: { status:
|
|
41
|
-
include: { organization: { select: [
|
|
42
|
-
orderBy: { name:
|
|
41
|
+
select: ["id", "name"],
|
|
42
|
+
where: { status: "active", notes: { some: { kind: "call" } } },
|
|
43
|
+
include: { organization: { select: ["name"] } },
|
|
44
|
+
orderBy: { name: "asc" },
|
|
43
45
|
limit: 20,
|
|
44
46
|
});
|
|
45
47
|
if (!result.ok) return result; // DbError: kind, message, status, code
|
|
@@ -47,27 +49,28 @@ if (!result.ok) return result; // DbError: kind, message, status, code
|
|
|
47
49
|
|
|
48
50
|
## Subpaths
|
|
49
51
|
|
|
50
|
-
| Import
|
|
51
|
-
|
|
|
52
|
-
| `better-supabase`
|
|
53
|
-
| `better-supabase/config`
|
|
54
|
-
| `better-supabase/client`
|
|
55
|
-
| `better-supabase/react`
|
|
56
|
-
| `better-supabase/query`
|
|
57
|
-
| `better-supabase/server`
|
|
58
|
-
| `better-supabase/postgres`
|
|
59
|
-
| `better-supabase/ssr`
|
|
60
|
-
| `better-supabase/next`, `/next/image`
|
|
61
|
-
| `better-supabase/hono`, `/orpc`, `/edge`
|
|
62
|
-
| `better-supabase/mcp`
|
|
63
|
-
| `better-supabase/jobs`
|
|
64
|
-
| `better-supabase/list`
|
|
65
|
-
| `better-supabase/storage`, `/realtime`
|
|
66
|
-
| `better-supabase/env`
|
|
67
|
-
| `better-supabase/events`, `/webhooks`, `/openapi`, `/otel` | CloudEvents, Standard Webhooks, OpenAPI 3.1 and OpenTelemetry
|
|
68
|
-
| `better-supabase/plugins/*`
|
|
69
|
-
| `better-supabase/
|
|
70
|
-
| `better-supabase/
|
|
52
|
+
| Import | What it gives you |
|
|
53
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
54
|
+
| `better-supabase` | `defineSupabase`, repositories, `Result`, `DbError`, `SPEC_PINS` |
|
|
55
|
+
| `better-supabase/config` | `defineConfig` and generators for `better-supabase.config.ts` |
|
|
56
|
+
| `better-supabase/client` | Browser repositories that follow the session |
|
|
57
|
+
| `better-supabase/react` | Provider, typed hooks and the server session |
|
|
58
|
+
| `better-supabase/query` | TanStack Query options with table-based invalidation |
|
|
59
|
+
| `better-supabase/server` | Repositories bound to the caller, admin and acting-as identities |
|
|
60
|
+
| `better-supabase/postgres` | The same repositories over direct Postgres |
|
|
61
|
+
| `better-supabase/ssr` | The `@supabase/ssr` cookie format for any framework |
|
|
62
|
+
| `better-supabase/next`, `/next/image` | Proxy, Server Components, route handlers, server actions, Storage images |
|
|
63
|
+
| `better-supabase/hono`, `/orpc`, `/edge` | Framework adapters |
|
|
64
|
+
| `better-supabase/mcp` | MCP servers whose tools run as the signed-in user |
|
|
65
|
+
| `better-supabase/jobs` | Supabase Queues jobs, idempotency keys and a webhook inbox |
|
|
66
|
+
| `better-supabase/list` | Search, facets, sorting and pagination from one definition |
|
|
67
|
+
| `better-supabase/storage`, `/realtime` | Typed bucket paths and broadcast topics |
|
|
68
|
+
| `better-supabase/env` | Validated Supabase settings |
|
|
69
|
+
| `better-supabase/events`, `/webhooks`, `/openapi`, `/otel` | CloudEvents, Standard Webhooks, OpenAPI 3.1 and OpenTelemetry |
|
|
70
|
+
| `better-supabase/plugins/*` | Timestamps, soft delete, tenant, actor, validation and runtime rules |
|
|
71
|
+
| `better-supabase/sql` | The SQL kit modules and read-set compiler behind `better-supabase sql` |
|
|
72
|
+
| `better-supabase/lint` | Editor rules for unbounded reads and unscoped deletes |
|
|
73
|
+
| `better-supabase/testing` | `asUser`, `localAuth`, typed seeds and conformance kits |
|
|
71
74
|
|
|
72
75
|
## For AI agents
|
|
73
76
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/core/base64.ts
|
|
2
|
+
const encoder = new TextEncoder();
|
|
3
|
+
const decoder = new TextDecoder();
|
|
4
|
+
/** Standard base64 (RFC 4648 section 4) of `input`, with padding. */
|
|
5
|
+
function toBase64(input) {
|
|
6
|
+
const bytes = typeof input === "string" ? encoder.encode(input) : input;
|
|
7
|
+
let binary = "";
|
|
8
|
+
for (const byte of bytes) binary += String.fromCodePoint(byte);
|
|
9
|
+
return btoa(binary);
|
|
10
|
+
}
|
|
11
|
+
/** Bytes of standard or URL-safe base64, padded or not. Throws on invalid input. */
|
|
12
|
+
function fromBase64(text) {
|
|
13
|
+
const base64 = text.replaceAll("-", "+").replaceAll("_", "/");
|
|
14
|
+
const binary = atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
|
|
15
|
+
const bytes = new Uint8Array(binary.length);
|
|
16
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.codePointAt(index) ?? 0;
|
|
17
|
+
return bytes;
|
|
18
|
+
}
|
|
19
|
+
/** URL-safe base64 (RFC 4648 section 5) of `input`, without padding. */
|
|
20
|
+
function toBase64Url(input) {
|
|
21
|
+
return toBase64(input).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
22
|
+
}
|
|
23
|
+
/** UTF-8 text of base64 or base64url. Throws on invalid input. */
|
|
24
|
+
function base64ToText(text) {
|
|
25
|
+
return decoder.decode(fromBase64(text));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The payload of a JWT, decoded without verifying the signature. Only for
|
|
29
|
+
* reading claims such as `exp` from a token that is verified elsewhere.
|
|
30
|
+
*/
|
|
31
|
+
function decodeJwtPayload(token) {
|
|
32
|
+
const part = token.split(".")[1];
|
|
33
|
+
if (!part) return void 0;
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(base64ToText(part));
|
|
36
|
+
return typeof parsed === "object" && parsed !== null ? parsed : void 0;
|
|
37
|
+
} catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { toBase64Url as a, toBase64 as i, decodeJwtPayload as n, fromBase64 as r, base64ToText as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/core/claims.ts
|
|
2
|
+
const DEFAULT_CLAIMS = {
|
|
3
|
+
tenant: "tenant_id",
|
|
4
|
+
scope: "tenant",
|
|
5
|
+
features: "features"
|
|
6
|
+
};
|
|
7
|
+
/** The configured claim names, with defaults for the ones codegen left out. */
|
|
8
|
+
function claimsOf(meta) {
|
|
9
|
+
return {
|
|
10
|
+
...DEFAULT_CLAIMS,
|
|
11
|
+
...meta?.claims
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Where the active tenant is read from: the top-level claim, then `app_metadata`. */
|
|
15
|
+
function tenantClaimPaths(tenant = DEFAULT_CLAIMS.tenant) {
|
|
16
|
+
return [tenant, `app_metadata.${tenant}`];
|
|
17
|
+
}
|
|
18
|
+
/** The string at a dotted claim path, if any. */
|
|
19
|
+
function claimAt(claims, path) {
|
|
20
|
+
let value = claims;
|
|
21
|
+
for (const segment of path.split(".")) value = typeof value === "object" && value !== null ? value[segment] : void 0;
|
|
22
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { tenantClaimPaths as i, claimAt as n, claimsOf as r, DEFAULT_CLAIMS as t };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BrowserOptions, i as BrowserAuth, n as AuthUser, o as createBrowser, r as BetterBrowser, t as AuthSnapshot } from "../index-
|
|
1
|
+
import { a as BrowserOptions, i as BrowserAuth, n as AuthUser, o as createBrowser, r as BetterBrowser, t as AuthSnapshot } from "../index-UJ-LUxtI.js";
|
|
2
2
|
export { AuthSnapshot, AuthUser, BetterBrowser, BrowserAuth, BrowserOptions, createBrowser };
|
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as decodeJwtPayload } from "../base64-CQeB1eSf.js";
|
|
2
|
+
import { EnvValidationError, parseEnv } from "../env/index.js";
|
|
3
|
+
import { t as createQueries } from "../query-BdKLTPlj.js";
|
|
3
4
|
import { createBrowserClient } from "@supabase/ssr";
|
|
4
5
|
import { createClient } from "@supabase/supabase-js";
|
|
5
6
|
//#region src/client/index.ts
|
|
@@ -13,20 +14,9 @@ const SIGNED_OUT = {
|
|
|
13
14
|
user: null,
|
|
14
15
|
claims: null
|
|
15
16
|
};
|
|
16
|
-
function decodeClaims(token) {
|
|
17
|
-
const part = token.split(".")[1];
|
|
18
|
-
if (!part) return {};
|
|
19
|
-
try {
|
|
20
|
-
const bytes = Uint8Array.from(atob(part.replace(/-/g, "+").replace(/_/g, "/")), (char) => char.charCodeAt(0));
|
|
21
|
-
const parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
22
|
-
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
23
|
-
} catch {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
17
|
function snapshotOf(session) {
|
|
28
18
|
if (!session) return SIGNED_OUT;
|
|
29
|
-
const claims =
|
|
19
|
+
const claims = decodeJwtPayload(session.access_token) ?? {};
|
|
30
20
|
const role = typeof claims["role"] === "string" ? claims["role"] : session.user.role;
|
|
31
21
|
return {
|
|
32
22
|
status: "signed-in",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as Operation } from "./executor-
|
|
2
|
-
import { i as PostgrestPlan } from "./postgrest-
|
|
1
|
+
import { g as Operation } from "./executor-DynmIWhq.js";
|
|
2
|
+
import { i as PostgrestPlan } from "./postgrest-DmBlevh-.js";
|
|
3
3
|
//#region src/core/compiler.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Turns an IR operation into something a backend runs. An `Executor` for a
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
|
|
1
|
+
import { a as Casing } from "../types-DONv9SHN.js";
|
|
2
|
+
import { $ as GeneratorMetadata, A as VectorSearchConfig, B as CatalogFunction, C as SoftDeleteConfig, D as TenantConfig, E as TableConfig, F as CatalogCheck, G as CatalogTable, H as CatalogGrant, I as CatalogColumn, J as ExtrasFunction, K as CatalogTrigger, L as CatalogColumnGrant, M as resolveConfig, N as resolveJsonSchema, O as TimestampsConfig, P as Catalog, Q as ForeignKeyAction, R as CatalogEnum, S as SeedConfig, T as SqlConfig, U as CatalogIndex, V as CatalogFunctionArg, W as CatalogPolicy, X as ExtrasHookFunction, Y as ExtrasHook, Z as ExtrasTable, _ as PluginFlagsConfig, a as ClaimsConfig, b as ResolvedConfig, c as EntitlementsConfig, d as Generator, et as Snapshot, f as GeneratorInput, g as PermdockPathsConfig, h as OpenApiConfig, i as CONFIG_SCHEMA_URL, j as defineConfig, k as VectorDistance, l as ExposeConfig, m as JsonTypeConfig, n as BetterSupabaseConfig, nt as SnapshotExtras, o as CodecsConfig, p as JsonSchemaSource, q as CatalogUnique, r as BucketConfig, s as DoctorConfig, t as ActorConfig, tt as SnapshotBucket, u as GeneratedFile, v as Privilege, w as SourceConfig, x as ResolvedExpose, y as RealtimeConfig, z as CatalogForeignKey } from "../config-C1CYcm6o.js";
|
|
3
|
+
import { a as JsonSchemaGeneratorOptions, c as DEFAULT_CLAIMS, i as valibot, l as tenantClaimPaths, n as zod, o as buildJsonSchema, r as ValibotGeneratorOptions, s as jsonSchema, t as ZodGeneratorOptions } from "../index-Cf-D2jk1.js";
|
|
4
|
+
export { type ActorConfig, type BetterSupabaseConfig, type BucketConfig, CONFIG_SCHEMA_URL, type Casing, type Catalog, type CatalogCheck, type CatalogColumn, type CatalogColumnGrant, type CatalogEnum, type CatalogForeignKey, type CatalogFunction, type CatalogFunctionArg, type CatalogGrant, type CatalogIndex, type CatalogPolicy, type CatalogTable, type CatalogTrigger, type CatalogUnique, type ClaimsConfig, type CodecsConfig, DEFAULT_CLAIMS, type DoctorConfig, type EntitlementsConfig, type ExposeConfig, type ExtrasFunction, type ExtrasHook, type ExtrasHookFunction, type ExtrasTable, type ForeignKeyAction, type GeneratedFile, type Generator, type GeneratorInput, type GeneratorMetadata, type JsonSchemaGeneratorOptions, type JsonSchemaSource, type JsonTypeConfig, type OpenApiConfig, type PermdockPathsConfig, type PluginFlagsConfig, type Privilege, type RealtimeConfig, type ResolvedConfig, type ResolvedExpose, type SeedConfig, type Snapshot, type SnapshotBucket, type SnapshotExtras, type SoftDeleteConfig, type SourceConfig, type SqlConfig, type TableConfig, type TenantConfig, type TimestampsConfig, type ValibotGeneratorOptions, type VectorDistance, type VectorSearchConfig, type ZodGeneratorOptions, buildJsonSchema, defineConfig, jsonSchema, resolveConfig, resolveJsonSchema, tenantClaimPaths, valibot, zod };
|
package/dist/config/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { i as tenantClaimPaths, t as DEFAULT_CLAIMS } from "../claims-CoTobNC-.js";
|
|
2
|
+
import { i as resolveJsonSchema, n as defineConfig, r as resolveConfig, t as CONFIG_SCHEMA_URL } from "../config-Be4GwsqI.js";
|
|
3
|
+
import { n as jsonSchema, t as buildJsonSchema } from "../json-schema--aOXAGfU.js";
|
|
4
|
+
import { n as valibot, t as zod } from "../config-DOsGYSiT.js";
|
|
5
|
+
export { CONFIG_SCHEMA_URL, DEFAULT_CLAIMS, buildJsonSchema, defineConfig, jsonSchema, resolveConfig, resolveJsonSchema, tenantClaimPaths, valibot, zod };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { t as DEFAULT_CLAIMS } from "./claims-CoTobNC-.js";
|
|
2
|
+
//#region src/config/config.ts
|
|
3
|
+
/** The JSON Schema document for a `json[...].schema` entry. */
|
|
4
|
+
function resolveJsonSchema(source) {
|
|
5
|
+
const standard = source["~standard"];
|
|
6
|
+
if (standard === void 0) return source;
|
|
7
|
+
const jsonSchema = standard.jsonSchema;
|
|
8
|
+
if (typeof jsonSchema?.input !== "function") throw new TypeError("json[...].schema: this Standard Schema library does not implement Standard JSON Schema; pass a JSON Schema object instead");
|
|
9
|
+
return jsonSchema.input({ target: "draft-2020-12" });
|
|
10
|
+
}
|
|
11
|
+
function entitlementsOf(config = {}) {
|
|
12
|
+
const customer = config.customer ?? "organizations.stripe_customer_id";
|
|
13
|
+
const dot = customer.lastIndexOf(".");
|
|
14
|
+
if (dot <= 0) throw new TypeError(`entitlements.customer must be "table.column", got "${customer}"`);
|
|
15
|
+
return {
|
|
16
|
+
table: customer.slice(0, dot),
|
|
17
|
+
column: customer.slice(dot + 1),
|
|
18
|
+
key: config.key ?? "id",
|
|
19
|
+
permdock: config.permdock === false ? false : { scope: config.permdock?.scope ?? "organization" }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function vectorSearchOf(config = {}) {
|
|
23
|
+
return Object.entries(config).map(([table, entry]) => typeof entry === "string" ? {
|
|
24
|
+
table,
|
|
25
|
+
column: entry,
|
|
26
|
+
distance: "cosine"
|
|
27
|
+
} : {
|
|
28
|
+
table,
|
|
29
|
+
column: entry.column,
|
|
30
|
+
distance: entry.distance ?? "cosine"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const CONFIG_SCHEMA_URL = "https://unpkg.com/better-supabase/schemas/config-v1.json";
|
|
34
|
+
/** Identity helper that types `better-supabase.config.ts`. */
|
|
35
|
+
function defineConfig(config) {
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
38
|
+
function pick(value, defaults) {
|
|
39
|
+
if (value === void 0 || value === false) return void 0;
|
|
40
|
+
if (value === true) return defaults;
|
|
41
|
+
return {
|
|
42
|
+
...defaults,
|
|
43
|
+
...value
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function resolveExpose(entry) {
|
|
47
|
+
if (Array.isArray(entry)) return {
|
|
48
|
+
anon: [],
|
|
49
|
+
authenticated: entry
|
|
50
|
+
};
|
|
51
|
+
const roles = entry;
|
|
52
|
+
return {
|
|
53
|
+
anon: roles.anon ?? [],
|
|
54
|
+
authenticated: roles.authenticated ?? []
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Applies defaults. Paths stay relative to `root`. */
|
|
58
|
+
function resolveConfig(config, root) {
|
|
59
|
+
const output = config.output ?? "src/lib/supabase/generated.ts";
|
|
60
|
+
return {
|
|
61
|
+
root,
|
|
62
|
+
source: config.source ?? {},
|
|
63
|
+
schemas: config.schemas ?? ["public"],
|
|
64
|
+
casing: config.casing ?? "snake",
|
|
65
|
+
tables: config.tables ?? {},
|
|
66
|
+
output,
|
|
67
|
+
databaseTypesOutput: output.replace(/[^/]+$/, "database.types.ts"),
|
|
68
|
+
postgrestVersion: config.postgrestVersion ?? "13",
|
|
69
|
+
json: config.json ?? {},
|
|
70
|
+
codecs: {
|
|
71
|
+
timestamptz: config.codecs?.timestamptz ?? "string",
|
|
72
|
+
int8: config.codecs?.int8 ?? "number",
|
|
73
|
+
numeric: config.codecs?.numeric ?? "number"
|
|
74
|
+
},
|
|
75
|
+
sensitive: config.sensitive ?? [],
|
|
76
|
+
storagePaths: config.storagePaths ?? {},
|
|
77
|
+
expose: Object.fromEntries(Object.entries(config.expose ?? {}).map(([table, entry]) => [table, resolveExpose(entry)])),
|
|
78
|
+
readSets: config.readSets ?? [],
|
|
79
|
+
generators: config.generators ?? [],
|
|
80
|
+
plugins: {
|
|
81
|
+
timestamps: pick(config.plugins?.timestamps, {
|
|
82
|
+
createdAt: "created_at",
|
|
83
|
+
updatedAt: "updated_at"
|
|
84
|
+
}),
|
|
85
|
+
softDelete: pick(config.plugins?.softDelete, { column: "deleted_at" }),
|
|
86
|
+
tenant: pick(config.plugins?.tenant, { column: "organization_id" }),
|
|
87
|
+
actor: pick(config.plugins?.actor, {
|
|
88
|
+
createdBy: "created_by",
|
|
89
|
+
updatedBy: "updated_by"
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
claims: {
|
|
93
|
+
...DEFAULT_CLAIMS,
|
|
94
|
+
...config.claims
|
|
95
|
+
},
|
|
96
|
+
buckets: config.buckets ?? {},
|
|
97
|
+
topics: config.topics ?? {},
|
|
98
|
+
realtime: { tables: config.realtime?.tables ?? [] },
|
|
99
|
+
entitlements: entitlementsOf(config.entitlements),
|
|
100
|
+
permdock: {
|
|
101
|
+
manifest: config.permdock?.manifest ?? "permdock.manifest.json",
|
|
102
|
+
catalog: config.permdock?.catalog ?? "permissions.catalog.json"
|
|
103
|
+
},
|
|
104
|
+
vectorSearch: vectorSearchOf(config.vectorSearch),
|
|
105
|
+
sql: {
|
|
106
|
+
dir: config.sql?.dir ?? "supabase/schemas",
|
|
107
|
+
prefix: config.sql?.prefix ?? "900_better_supabase",
|
|
108
|
+
testsDir: config.sql?.testsDir ?? "supabase/tests",
|
|
109
|
+
kit: config.sql?.kit ?? []
|
|
110
|
+
},
|
|
111
|
+
seed: {
|
|
112
|
+
entry: config.seed?.entry ?? "supabase/seed.ts",
|
|
113
|
+
output: config.seed?.output ?? "supabase/seeds/000_better_supabase.sql"
|
|
114
|
+
},
|
|
115
|
+
openapi: {
|
|
116
|
+
entry: config.openapi?.entry ?? "src/lib/openapi.ts",
|
|
117
|
+
output: config.openapi?.output ?? "openapi.json"
|
|
118
|
+
},
|
|
119
|
+
doctor: {
|
|
120
|
+
ignore: config.doctor?.ignore ?? [],
|
|
121
|
+
strict: config.doctor?.strict ?? false,
|
|
122
|
+
sources: config.doctor?.sources ?? ["src/**/*.{ts,tsx}"],
|
|
123
|
+
policyHelperLimit: config.doctor?.policyHelperLimit ?? 5,
|
|
124
|
+
...config.doctor?.claimsLimit === void 0 ? {} : { claimsLimit: config.doctor.claimsLimit }
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { resolveJsonSchema as i, defineConfig as n, resolveConfig as r, CONFIG_SCHEMA_URL as t };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { A as SchemaMeta, a as Casing, b as PermdockBucketPolicy, i as BucketPolicyName } from "./types-DONv9SHN.js";
|
|
3
|
+
import { GeneratorMetadata } from "@supabase/postgrest-typegen";
|
|
4
|
+
//#region src/config/snapshot.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* What `better-supabase introspect` reads from Postgres. `generator` is the
|
|
6
7
|
* `@supabase/postgrest-typegen` contract (the same metadata behind
|
|
@@ -57,6 +58,8 @@ interface ExtrasHookFunction extends ExtrasFunction {
|
|
|
57
58
|
readonly publicExecute: boolean;
|
|
58
59
|
/** Of the same roles, those with `usage` on its schema. */
|
|
59
60
|
readonly schemaUsage: readonly string[];
|
|
61
|
+
/** The function body (`pg_proc.prosrc`). Absent in snapshots that predate it. */
|
|
62
|
+
readonly source?: string;
|
|
60
63
|
}
|
|
61
64
|
/** A function as doctor needs it for RLS checks, in any schema. */
|
|
62
65
|
interface ExtrasFunction {
|
|
@@ -70,6 +73,8 @@ interface ExtrasFunction {
|
|
|
70
73
|
readonly securityDefiner: boolean;
|
|
71
74
|
/** `set` options, e.g. `{ statement_timeout: '5s' }`. */
|
|
72
75
|
readonly settings: Readonly<Record<string, string>>;
|
|
76
|
+
/** Which of `anon` and `authenticated` may execute it. Absent in older snapshots. */
|
|
77
|
+
readonly execute?: readonly string[];
|
|
73
78
|
}
|
|
74
79
|
interface ExtrasTable {
|
|
75
80
|
/** Table oid, matching `GeneratorMetadata.tables[].id`. */
|
|
@@ -89,6 +94,8 @@ interface ExtrasTable {
|
|
|
89
94
|
readonly policies: readonly CatalogPolicy[];
|
|
90
95
|
readonly triggers: readonly CatalogTrigger[];
|
|
91
96
|
readonly grants: readonly CatalogGrant[];
|
|
97
|
+
/** Absent in snapshots taken before column grants were introspected. */
|
|
98
|
+
readonly columnGrants?: readonly CatalogColumnGrant[];
|
|
92
99
|
/** Postgres estimates at least `LARGE_TABLE_ROWS` rows; the `unbounded-read` lint reads it. */
|
|
93
100
|
readonly large?: true;
|
|
94
101
|
}
|
|
@@ -107,6 +114,10 @@ interface CatalogIndex {
|
|
|
107
114
|
readonly unique: boolean;
|
|
108
115
|
readonly primary: boolean;
|
|
109
116
|
readonly partial: boolean;
|
|
117
|
+
/** Access method (`btree`, `gin`, `gist`, ...). Absent in older snapshots. */
|
|
118
|
+
readonly method?: string;
|
|
119
|
+
/** The `where` of a partial index, as Postgres prints it. Absent in older snapshots. */
|
|
120
|
+
readonly predicate?: string | null;
|
|
110
121
|
}
|
|
111
122
|
interface CatalogPolicy {
|
|
112
123
|
readonly name: string;
|
|
@@ -132,6 +143,12 @@ interface CatalogGrant {
|
|
|
132
143
|
readonly role: string;
|
|
133
144
|
readonly privileges: readonly string[];
|
|
134
145
|
}
|
|
146
|
+
/** A column-level `insert` or `update` grant to `anon` or `authenticated`. */
|
|
147
|
+
interface CatalogColumnGrant {
|
|
148
|
+
readonly column: string;
|
|
149
|
+
readonly role: string;
|
|
150
|
+
readonly privileges: readonly string[];
|
|
151
|
+
}
|
|
135
152
|
interface SnapshotBucket {
|
|
136
153
|
readonly id: string;
|
|
137
154
|
readonly public: boolean;
|
|
@@ -173,6 +190,8 @@ interface CatalogTable {
|
|
|
173
190
|
readonly policies: readonly CatalogPolicy[];
|
|
174
191
|
readonly triggers: readonly CatalogTrigger[];
|
|
175
192
|
readonly grants: readonly CatalogGrant[];
|
|
193
|
+
/** Absent in snapshots taken before column grants were introspected. */
|
|
194
|
+
readonly columnGrants?: readonly CatalogColumnGrant[];
|
|
176
195
|
}
|
|
177
196
|
interface CatalogColumn {
|
|
178
197
|
readonly name: string;
|
|
@@ -235,49 +254,7 @@ interface CatalogFunctionArg {
|
|
|
235
254
|
readonly hasDefault: boolean;
|
|
236
255
|
}
|
|
237
256
|
//#endregion
|
|
238
|
-
//#region src/
|
|
239
|
-
/** What field planning reads: the metadata and the typed-jsonb config. */
|
|
240
|
-
interface SchemaSource {
|
|
241
|
-
readonly meta: SchemaMeta;
|
|
242
|
-
readonly config: {
|
|
243
|
-
readonly json: Readonly<Record<string, unknown>>;
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/generators/json-schema.d.ts
|
|
248
|
-
interface JsonSchemaGeneratorOptions {
|
|
249
|
-
/** Output path relative to the project root. Defaults to `<output>.schema.json`. */
|
|
250
|
-
readonly output?: string;
|
|
251
|
-
/** `$id` of the document. */
|
|
252
|
-
readonly id?: string;
|
|
253
|
-
}
|
|
254
|
-
type JsonSchema = Record<string, unknown>;
|
|
255
|
-
/** JSON Schema (2020-12) `$defs` for every table: `customersRow`, `customersInsert`, ... */
|
|
256
|
-
declare function buildJsonSchema(input: SchemaSource, id?: string): JsonSchema;
|
|
257
|
-
/** Writes the JSON Schema document; `createOpenApi` reuses the same `$defs`. */
|
|
258
|
-
declare function jsonSchema(options?: JsonSchemaGeneratorOptions): Generator;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/generators/valibot.d.ts
|
|
261
|
-
interface ValibotGeneratorOptions {
|
|
262
|
-
/** Output path relative to the project root. Defaults to `<output>.valibot.ts`. */
|
|
263
|
-
readonly output?: string;
|
|
264
|
-
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
265
|
-
readonly json?: Readonly<Record<string, string>>;
|
|
266
|
-
}
|
|
267
|
-
/** Valibot schemas for every table's Row, Insert and Update shape. */
|
|
268
|
-
declare function valibot(options?: ValibotGeneratorOptions): Generator;
|
|
269
|
-
//#endregion
|
|
270
|
-
//#region src/generators/zod.d.ts
|
|
271
|
-
interface ZodGeneratorOptions {
|
|
272
|
-
/** Output path relative to the project root. Defaults to `<output>.zod.ts`. */
|
|
273
|
-
readonly output?: string;
|
|
274
|
-
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
275
|
-
readonly json?: Readonly<Record<string, string>>;
|
|
276
|
-
}
|
|
277
|
-
/** Zod 4 schemas for every table's Row, Insert and Update shape. */
|
|
278
|
-
declare function zod(options?: ZodGeneratorOptions): Generator;
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region src/config/index.d.ts
|
|
257
|
+
//#region src/config/config.d.ts
|
|
281
258
|
/**
|
|
282
259
|
* Where codegen reads the database from. Without any of these, `$DATABASE_URL`
|
|
283
260
|
* and then the local stack (`supabase start`) are used.
|
|
@@ -337,8 +314,18 @@ interface SoftDeleteConfig {
|
|
|
337
314
|
}
|
|
338
315
|
interface TenantConfig {
|
|
339
316
|
readonly column?: string;
|
|
340
|
-
|
|
341
|
-
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Claim names shared by the SQL kit, codegen and the runtime defaults. They
|
|
320
|
+
* follow PermDock's claim contract.
|
|
321
|
+
*/
|
|
322
|
+
interface ClaimsConfig {
|
|
323
|
+
/** Top-level claim holding the active tenant id. Defaults to `tenant_id`. */
|
|
324
|
+
readonly tenant?: string;
|
|
325
|
+
/** `scope` of the tenant entries `membership_claims()` writes. Defaults to `tenant`. */
|
|
326
|
+
readonly scope?: string;
|
|
327
|
+
/** Claim holding plan features per tenant (`{ [tenantId]: string[] }`). Defaults to `features`. */
|
|
328
|
+
readonly features?: string;
|
|
342
329
|
}
|
|
343
330
|
interface ActorConfig {
|
|
344
331
|
readonly createdBy?: string;
|
|
@@ -355,8 +342,8 @@ interface BucketConfig {
|
|
|
355
342
|
readonly public?: boolean;
|
|
356
343
|
/** Path template with `{placeholders}`, e.g. `{orgId}/{customerId}/logo.webp`. */
|
|
357
344
|
readonly path: string;
|
|
358
|
-
/** Generated storage policy. */
|
|
359
|
-
readonly policy?:
|
|
345
|
+
/** Generated storage policy, or a PermDock policy (`{ permdock, scope }`). */
|
|
346
|
+
readonly policy?: BucketPolicyName | PermdockBucketPolicy;
|
|
360
347
|
readonly fileSizeLimit?: string;
|
|
361
348
|
readonly allowedMimeTypes?: readonly string[];
|
|
362
349
|
}
|
|
@@ -397,6 +384,13 @@ interface DoctorConfig {
|
|
|
397
384
|
* asks for an inlinable `language sql stable` function. Defaults to 5.
|
|
398
385
|
*/
|
|
399
386
|
readonly policyHelperLimit?: number;
|
|
387
|
+
/**
|
|
388
|
+
* The BS405 limit in bytes. With a `permdock.config.ts` it is PermDock's
|
|
389
|
+
* budget for `memberships` plus `attrs` (default 1024, matching
|
|
390
|
+
* `supabase.hook.budget`) and the whole token keeps 2048. Without one it
|
|
391
|
+
* limits the whole token's claims (default 2048).
|
|
392
|
+
*/
|
|
393
|
+
readonly claimsLimit?: number;
|
|
400
394
|
}
|
|
401
395
|
/**
|
|
402
396
|
* Runtime types for columns whose JSON form loses information. Defaults
|
|
@@ -404,8 +398,11 @@ interface DoctorConfig {
|
|
|
404
398
|
* `numeric` as numbers.
|
|
405
399
|
*/
|
|
406
400
|
interface CodecsConfig {
|
|
407
|
-
/**
|
|
408
|
-
|
|
401
|
+
/**
|
|
402
|
+
* `'instant'` decodes `timestamptz` columns to `Temporal.Instant` and
|
|
403
|
+
* `timestamp` columns to `Temporal.PlainDateTime`.
|
|
404
|
+
*/
|
|
405
|
+
readonly timestamptz?: "string" | "instant";
|
|
409
406
|
/** `'bigint'` or `'string'` read `int8` exactly (above 2^53). */
|
|
410
407
|
readonly int8?: "number" | "string" | "bigint";
|
|
411
408
|
/** `'string'` reads `numeric` exactly. */
|
|
@@ -456,6 +453,22 @@ interface EntitlementsConfig {
|
|
|
456
453
|
readonly customer?: string;
|
|
457
454
|
/** The tenant id column of that table. Defaults to `id`. */
|
|
458
455
|
readonly key?: string;
|
|
456
|
+
/**
|
|
457
|
+
* With a PermDock manifest, `has_entitlement` and `feature_claims` read
|
|
458
|
+
* PermDock's memberships (`member_<scope>_ids()` and
|
|
459
|
+
* `member_<scope>_ids_for(user)`) instead of `better_supabase.memberships`.
|
|
460
|
+
* `scope` is the PermDock scope tenants are (default `organization`);
|
|
461
|
+
* `false` keeps the kit's memberships table.
|
|
462
|
+
*/
|
|
463
|
+
readonly permdock?: false | {
|
|
464
|
+
readonly scope?: string;
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
interface PermdockPathsConfig {
|
|
468
|
+
/** What `permdock supabase inspect --out` writes. Defaults to `permdock.manifest.json`. */
|
|
469
|
+
readonly manifest?: string;
|
|
470
|
+
/** What `permdock catalog` writes. Defaults to `permissions.catalog.json`. */
|
|
471
|
+
readonly catalog?: string;
|
|
459
472
|
}
|
|
460
473
|
/** pgvector distance: `<=>` (cosine), `<->` (l2) or `<#>` (negative inner product). */
|
|
461
474
|
type VectorDistance = "cosine" | "l2" | "inner_product";
|
|
@@ -530,11 +543,14 @@ interface BetterSupabaseConfig {
|
|
|
530
543
|
readonly generators?: readonly Generator[];
|
|
531
544
|
/** Enables plugin flags in the generated metadata. */
|
|
532
545
|
readonly plugins?: PluginFlagsConfig;
|
|
546
|
+
readonly claims?: ClaimsConfig;
|
|
533
547
|
readonly buckets?: Readonly<Record<string, BucketConfig>>;
|
|
534
548
|
/** Realtime topic templates: `{ notifications: 'org:{orgId}:notifications' }`. */
|
|
535
549
|
readonly topics?: Readonly<Record<string, string>>;
|
|
536
550
|
readonly realtime?: RealtimeConfig;
|
|
537
551
|
readonly entitlements?: EntitlementsConfig;
|
|
552
|
+
/** Where PermDock's JSON outputs are, for doctor, `gen` and the SQL kit. */
|
|
553
|
+
readonly permdock?: PermdockPathsConfig;
|
|
538
554
|
/**
|
|
539
555
|
* Embedding columns, keyed by `table` or `schema.table`. The
|
|
540
556
|
* `vector-search` SQL kit module writes `search_<table>(query, k)` for each,
|
|
@@ -570,12 +586,17 @@ interface ResolvedConfig {
|
|
|
570
586
|
readonly tenant: Required<TenantConfig> | undefined;
|
|
571
587
|
readonly actor: Required<ActorConfig> | undefined;
|
|
572
588
|
};
|
|
589
|
+
readonly claims: Required<ClaimsConfig>;
|
|
573
590
|
readonly buckets: Readonly<Record<string, BucketConfig>>;
|
|
574
591
|
readonly entitlements: {
|
|
575
592
|
readonly table: string;
|
|
576
593
|
readonly column: string;
|
|
577
594
|
readonly key: string;
|
|
595
|
+
readonly permdock: false | {
|
|
596
|
+
readonly scope: string;
|
|
597
|
+
};
|
|
578
598
|
};
|
|
599
|
+
readonly permdock: Required<PermdockPathsConfig>;
|
|
579
600
|
readonly vectorSearch: readonly {
|
|
580
601
|
readonly table: string;
|
|
581
602
|
readonly column: string;
|
|
@@ -586,7 +607,7 @@ interface ResolvedConfig {
|
|
|
586
607
|
readonly sql: Required<SqlConfig>;
|
|
587
608
|
readonly seed: Required<SeedConfig>;
|
|
588
609
|
readonly openapi: Required<OpenApiConfig>;
|
|
589
|
-
readonly doctor: Required<DoctorConfig>;
|
|
610
|
+
readonly doctor: Required<Omit<DoctorConfig, "claimsLimit">> & Pick<DoctorConfig, "claimsLimit">;
|
|
590
611
|
}
|
|
591
612
|
declare const CONFIG_SCHEMA_URL = "https://unpkg.com/better-supabase/schemas/config-v1.json";
|
|
592
613
|
/** Identity helper that types `better-supabase.config.ts`. */
|
|
@@ -594,4 +615,4 @@ declare function defineConfig(config: BetterSupabaseConfig): BetterSupabaseConfi
|
|
|
594
615
|
/** Applies defaults. Paths stay relative to `root`. */
|
|
595
616
|
declare function resolveConfig(config: BetterSupabaseConfig, root: string): ResolvedConfig;
|
|
596
617
|
//#endregion
|
|
597
|
-
export {
|
|
618
|
+
export { GeneratorMetadata as $, VectorSearchConfig as A, CatalogFunction as B, SoftDeleteConfig as C, TenantConfig as D, TableConfig as E, CatalogCheck as F, CatalogTable as G, CatalogGrant as H, CatalogColumn as I, ExtrasFunction as J, CatalogTrigger as K, CatalogColumnGrant as L, resolveConfig as M, resolveJsonSchema as N, TimestampsConfig as O, Catalog as P, ForeignKeyAction as Q, CatalogEnum as R, SeedConfig as S, SqlConfig as T, CatalogIndex as U, CatalogFunctionArg as V, CatalogPolicy as W, ExtrasHookFunction as X, ExtrasHook as Y, ExtrasTable as Z, PluginFlagsConfig as _, ClaimsConfig as a, ResolvedConfig as b, EntitlementsConfig as c, Generator as d, Snapshot as et, GeneratorInput as f, PermdockPathsConfig as g, OpenApiConfig as h, CONFIG_SCHEMA_URL as i, defineConfig as j, VectorDistance as k, ExposeConfig as l, JsonTypeConfig as m, BetterSupabaseConfig as n, SnapshotExtras as nt, CodecsConfig as o, JsonSchemaSource as p, CatalogUnique as q, BucketConfig as r, DoctorConfig as s, ActorConfig as t, SnapshotBucket as tt, GeneratedFile as u, Privilege as v, SourceConfig as w, ResolvedExpose as x, RealtimeConfig as y, CatalogForeignKey as z };
|