better-supabase 0.1.0 → 0.2.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/bin/better-supabase.js +2 -1
- package/dist/claims-CoTobNC-.js +25 -0
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/{cli-CoByWYja.js → cli-DrSgDOQC.js} +333 -159
- package/dist/client/index.d.ts +1 -1
- package/dist/{compiler-DL18ukPe.d.ts → compiler-CZ9nIuqy.d.ts} +2 -2
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +2 -2
- package/dist/{config-D-aR2ZoN.js → config-ClDXmVtY.js} +11 -10
- package/dist/{define-QGkq04oe.js → define-BXMYD9AY.js} +65 -62
- package/dist/{define-CTfWw-SS.d.ts → define-e3zI4_4g.d.ts} +27 -10
- package/dist/edge/index.d.ts +4 -4
- package/dist/edge/index.js +3 -3
- package/dist/entitlements-CTEBm7IB.js +20 -0
- package/dist/entitlements-Dng-ctuT.d.ts +42 -0
- package/dist/events/index.d.ts +1 -1
- package/dist/{events-2OJsVG_d.d.ts → events-DOt3nSO-.d.ts} +2 -2
- package/dist/{executor-Bje4suQF.d.ts → executor-BYXQ9AGn.d.ts} +1 -1
- package/dist/{executor-Bazhgsgq.d.ts → executor-CGdNQ27g.d.ts} +1 -1
- package/dist/{executor-Ceq60hPM.js → executor-DeppvirK.js} +1 -1
- package/dist/guards-BnzDvFrz.js +10 -0
- package/dist/hono/index.d.ts +5 -5
- package/dist/hono/index.js +3 -3
- package/dist/{index-JXHBuS53.d.ts → index-Bw1bwtC0.d.ts} +3 -3
- package/dist/{index-Hf8PP9sP.d.ts → index-CBDufH1M.d.ts} +15 -11
- package/dist/{index-cEeweTeM.d.ts → index-CG69s15v.d.ts} +3 -3
- package/dist/{index-DQVvHzjW.d.ts → index-Ciu5Xlml.d.ts} +3 -3
- package/dist/{index-Sw43J8HG.d.ts → index-D4v7sncu.d.ts} +6 -6
- package/dist/{index-BD6wKthp.d.ts → index-DOsjFvMf.d.ts} +28 -7
- package/dist/{index-DRid0qIv.d.ts → index-DbxFr7XG.d.ts} +2 -2
- package/dist/{index-Nxo3TJcm.d.ts → index-DuP14VHo.d.ts} +11 -3
- package/dist/{index-Dup-nSe9.d.ts → index-K-3WM2Hp.d.ts} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +7 -6
- package/dist/jobs/index.d.ts +1 -1
- package/dist/jobs/index.js +6 -5
- package/dist/{json-schema-BbwO2mZg.js → json-schema-BpYqkCKf.js} +2 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/{live-6b9i72Ux.d.ts → live-DJyZMD6w.d.ts} +14 -3
- package/dist/logger-glM28NVN.js +21 -0
- package/dist/mcp/index.d.ts +41 -4
- package/dist/mcp/index.js +194 -61
- package/dist/{mfa-CpogP66z.js → mfa-CpLfJSde.js} +23 -3
- package/dist/next/index.d.ts +23 -23
- package/dist/next/index.js +9 -8
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +3 -3
- package/dist/orpc/index.d.ts +4 -4
- package/dist/orpc/index.js +2 -2
- package/dist/otel/index.d.ts +3 -3
- package/dist/otel/index.js +1 -1
- package/dist/{template-BeOGnynM.js → permdock-sql-CghlHPuH.js} +25 -1
- package/dist/{plugin-HvGqCurB.d.ts → plugin-C4TR9J0Z.d.ts} +2 -2
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/rules/index.d.ts +4 -3
- package/dist/plugins/rules/index.js +4 -11
- package/dist/plugins/soft-delete/index.d.ts +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/validation/index.d.ts +1 -1
- package/dist/{pool-BFeqzwQS.d.ts → pool-R2m_DkXi.d.ts} +1 -1
- package/dist/postgres/index.d.ts +4 -4
- package/dist/postgres/index.js +2 -2
- package/dist/{postgrest-Dm-vhY6R.d.ts → postgrest-cAEQ_IQN.d.ts} +1 -1
- package/dist/{problem-DPu6Fh-t.js → problem-BTkTtRV9.js} +4 -4
- package/dist/query/index.d.ts +1 -1
- package/dist/react/index.d.ts +6 -6
- 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 +1 -1
- package/dist/react/session.js +1 -1
- package/dist/{react-CrOvrnIP.js → react-C83BdBGt.js} +9 -8
- package/dist/{read-set-DhX2d04c.js → read-set-4lI3W_gZ.js} +1 -1
- package/dist/realtime/index.d.ts +3 -2
- package/dist/realtime/index.js +26 -11
- package/dist/{resolve-DW8h9NPm.d.ts → resolve-CjHILk2w.d.ts} +21 -6
- package/dist/{resource-CYiu6Ygi.js → resource-BHEWmQJK.js} +1 -1
- package/dist/{resource-SkPTRJDD.d.ts → resource-CgZa3YG_.d.ts} +4 -4
- package/dist/{respond-4-dhoV7x.js → respond-DMcbQwfN.js} +7 -4
- package/dist/{respond-PoTpy5DT.d.ts → respond-Dne1ARSa.d.ts} +14 -14
- package/dist/server/index.d.ts +7 -7
- package/dist/server/index.js +5 -5
- package/dist/{session-C3osL21k.d.ts → session-C3LxnQ0e.d.ts} +4 -3
- package/dist/{session-CD-3orO_.js → session-CqEwzVup.js} +2 -1
- package/dist/{simplify-oHiDKRVQ.js → simplify-bwJpLnaS.js} +12 -12
- 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-M8l3fnS0.js → sql-DTjA1LPj.js} +1 -1
- package/dist/ssr/index.d.ts +5 -5
- package/dist/ssr/index.js +3 -3
- package/dist/{stats-3iy8u3_P.js → stats-C5W-rBfR.js} +1 -1
- package/dist/storage/index.d.ts +3 -2
- package/dist/storage/index.js +1 -1
- package/dist/{storage-BWXVUXGk.js → storage-DuGn38fr.js} +72 -6
- package/dist/testing/index.d.ts +46 -15
- package/dist/testing/index.js +111 -43
- package/dist/{types-C2fslP1z.d.ts → types-C83v5SQz.d.ts} +55 -2
- package/dist/{view-B0ltUmTi.d.ts → view-D1s0wa0T.d.ts} +9 -3
- package/dist/{view-B6F9QbG-.js → view-aOYizTeE.js} +2 -1
- package/dist/webhooks/index.d.ts +3 -3
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-DbMTJJX2.js → webhooks-DMipjhSP.js} +1 -1
- package/package.json +8 -4
- package/schemas/config-v1.json +49 -4
- package/schemas/doctor-report-v1.json +1 -0
- package/schemas/snapshot-v2.json +4 -0
- package/skills/better-supabase/references/plugins.md +9 -0
- package/skills/better-supabase-api/SKILL.md +2 -2
- package/skills/better-supabase-testing/SKILL.md +4 -3
- package/dist/entitlements-BBg61DQZ.d.ts +0 -20
- package/dist/entitlements-BC_khwRy.js +0 -17
package/dist/hono/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as BetterSupabase } from "../define-
|
|
3
|
-
import { r as AuthState } from "../resolve-
|
|
4
|
-
import { d as ServerContext, f as ServerOptions, l as BetterServer, n as GuardOptions } from "../respond-
|
|
5
|
-
import { i as ResourceRouteOptions } from "../resource-
|
|
1
|
+
import { N as TableKey, n as AnyModels, t as AnyFunctions } from "../types-C83v5SQz.js";
|
|
2
|
+
import { t as BetterSupabase } from "../define-e3zI4_4g.js";
|
|
3
|
+
import { r as AuthState } from "../resolve-CjHILk2w.js";
|
|
4
|
+
import { d as ServerContext, f as ServerOptions, l as BetterServer, n as GuardOptions } from "../respond-Dne1ARSa.js";
|
|
5
|
+
import { i as ResourceRouteOptions } from "../resource-CgZa3YG_.js";
|
|
6
6
|
import { Context, ErrorHandler, Hono, MiddlewareHandler } from "hono";
|
|
7
7
|
//#region src/hono/index.d.ts
|
|
8
8
|
/** Hono `Env` with the request's better-supabase context in `c.var`. */
|
package/dist/hono/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as dbError, r as dbErrorOf } from "../errors-Bl3rkOzo.js";
|
|
2
|
-
import { a as problemResponse } from "../problem-
|
|
3
|
-
import { i as respond, n as guard, o as createServer, s as extendServer, t as defaultExpose } from "../respond-
|
|
4
|
-
import { t as defineResource } from "../resource-
|
|
2
|
+
import { a as problemResponse } from "../problem-BTkTtRV9.js";
|
|
3
|
+
import { i as respond, n as guard, o as createServer, s as extendServer, t as defaultExpose } from "../respond-DMcbQwfN.js";
|
|
4
|
+
import { t as defineResource } from "../resource-BHEWmQJK.js";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
//#region src/hono/index.ts
|
|
7
7
|
function contextOf(c) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { l as CountMode } from "./executor-
|
|
1
|
+
import { N as TableKey, O as Row, n as AnyModels, t as AnyFunctions } from "./types-C83v5SQz.js";
|
|
2
|
+
import { l as CountMode } from "./executor-CGdNQ27g.js";
|
|
3
3
|
import { b as ValidationIssue, t as AsyncResult } from "./result-CTkCZ6JA.js";
|
|
4
|
-
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-
|
|
4
|
+
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-e3zI4_4g.js";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
//#region src/list/index.d.ts
|
|
7
7
|
/** Facet value meaning "not set": filters with `is null`. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { p as DbError } from "./result-CTkCZ6JA.js";
|
|
2
|
-
import { Z as QuerySpec } from "./define-
|
|
3
|
-
import { i as BrowserAuth, t as AuthSnapshot } from "./index-
|
|
2
|
+
import { Z as QuerySpec } from "./define-e3zI4_4g.js";
|
|
3
|
+
import { i as BrowserAuth, t as AuthSnapshot } from "./index-D4v7sncu.js";
|
|
4
4
|
import { n as TemplateValues } from "./template-mbvlysOo.js";
|
|
5
|
-
import { t as AuthSession } from "./view-
|
|
6
|
-
import { a as LiveSource, g as Topic, h as SubscriptionStatus, p as SubscribeOptions, r as LiveCountSeed, u as EventSchemas, v as TopicHandlers, y as TopicMessage } from "./live-
|
|
7
|
-
import "./entitlements-
|
|
8
|
-
import "./session-
|
|
5
|
+
import { t as AuthSession } from "./view-D1s0wa0T.js";
|
|
6
|
+
import { a as LiveSource, g as Topic, h as SubscriptionStatus, p as SubscribeOptions, r as LiveCountSeed, u as EventSchemas, v as TopicHandlers, y as TopicMessage } from "./live-DJyZMD6w.js";
|
|
7
|
+
import "./entitlements-Dng-ctuT.js";
|
|
8
|
+
import "./session-C3LxnQ0e.js";
|
|
9
9
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
10
10
|
import { ReactNode } from "react";
|
|
11
11
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -37,13 +37,17 @@ interface BetterHooks<B extends BrowserLike> {
|
|
|
37
37
|
readonly useQueries: () => B["queries"];
|
|
38
38
|
readonly useSupabase: () => SupabaseClient;
|
|
39
39
|
readonly useAuth: () => AuthSnapshot;
|
|
40
|
-
/** `useSession()`
|
|
41
|
-
readonly useSession: () => AuthSession<ClaimsOf<B>>;
|
|
40
|
+
/** `useSession()` typed by the browser's `sb.claims(schema)` and `sb.userMetadata(schema)`. */
|
|
41
|
+
readonly useSession: () => AuthSession<ClaimsOf<B>, ProfileOf<B>>;
|
|
42
42
|
}
|
|
43
43
|
/** The claims type of a browser's `sb.claims(schema)`, `unknown` without one. */
|
|
44
44
|
type ClaimsOf<B extends BrowserLike> = B["sb"] extends {
|
|
45
45
|
readonly claimsSchema: StandardSchemaV1<unknown, infer C> | undefined;
|
|
46
46
|
} ? C : unknown;
|
|
47
|
+
/** The profile type of a browser's `sb.userMetadata(schema)`, `unknown` without one. */
|
|
48
|
+
type ProfileOf<B extends BrowserLike> = B["sb"] extends {
|
|
49
|
+
readonly userMetadataSchema: StandardSchemaV1<unknown, infer P> | undefined;
|
|
50
|
+
} ? P : unknown;
|
|
47
51
|
/**
|
|
48
52
|
* Hooks typed for your schema.
|
|
49
53
|
*
|
|
@@ -71,8 +75,8 @@ interface BroadcastOptions extends Omit<SubscribeOptions, "onStatus"> {
|
|
|
71
75
|
declare function useBroadcast<P extends string, E extends EventSchemas>(topic: Topic<P, E>, values: TemplateValues<P> | null | undefined, handlers?: TopicHandlers<E>, options?: BroadcastOptions): SubscriptionStatus;
|
|
72
76
|
interface LiveQueryHookOptions {
|
|
73
77
|
/**
|
|
74
|
-
* Tenant for tenant-scoped tables. Defaults to the `
|
|
75
|
-
* (top-level or in `app_metadata`).
|
|
78
|
+
* Tenant for tenant-scoped tables. Defaults to the `config.claims.tenant`
|
|
79
|
+
* claim (`tenant_id`, top-level or in `app_metadata`).
|
|
76
80
|
*/
|
|
77
81
|
readonly tenant?: string;
|
|
78
82
|
/** Defaults to 100 ms. */
|
|
@@ -113,4 +117,4 @@ interface LiveCount {
|
|
|
113
117
|
*/
|
|
114
118
|
declare function useLiveCount(source: QuerySpec<string, "count", number> | LiveCountSeed | null | undefined, options?: LiveCountHookOptions): LiveCount;
|
|
115
119
|
//#endregion
|
|
116
|
-
export { BrowserLike as a, LiveCountHookOptions as c,
|
|
120
|
+
export { BrowserLike as a, LiveCountHookOptions as c, createHooks as d, useAuth as f, useSupabase as g, useLiveQuery as h, BroadcastOptions as i, LiveQueryHookOptions as l, useLiveCount as m, BetterSupabaseProvider as n, ClaimsOf as o, useBroadcast as p, BetterSupabaseProviderProps as r, LiveCount as s, BetterHooks as t, ProfileOf as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as StoredSession } from "./resolve-
|
|
2
|
-
import "./view-
|
|
3
|
-
import "./entitlements-
|
|
1
|
+
import { m as StoredSession } from "./resolve-CjHILk2w.js";
|
|
2
|
+
import "./view-D1s0wa0T.js";
|
|
3
|
+
import "./entitlements-Dng-ctuT.js";
|
|
4
4
|
//#region src/auth/refresh.d.ts
|
|
5
5
|
interface RefreshOptions {
|
|
6
6
|
readonly url: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as EventHub, s as MutationNotice } from "./events-
|
|
3
|
-
import { l as MutationKind } from "./plugin-
|
|
1
|
+
import { A as SchemaMeta } from "./types-C83v5SQz.js";
|
|
2
|
+
import { a as EventHub, s as MutationNotice } from "./events-DOt3nSO-.js";
|
|
3
|
+
import { l as MutationKind } from "./plugin-C4TR9J0Z.js";
|
|
4
4
|
//#region src/events/index.d.ts
|
|
5
5
|
/** A CloudEvents 1.0 event. Extension attributes are lowercase alphanumerics. */
|
|
6
6
|
interface CloudEvent<T = unknown> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as AnyModels, t as AnyFunctions } from "./types-
|
|
2
|
-
import { t as BetterSupabase, y as Db } from "./define-
|
|
1
|
+
import { n as AnyModels, t as AnyFunctions } from "./types-C83v5SQz.js";
|
|
2
|
+
import { t as BetterSupabase, y as Db } from "./define-e3zI4_4g.js";
|
|
3
3
|
import { c as PublicEnv } from "./index-Dy6kuF0P.js";
|
|
4
|
-
import { i as Queries } from "./index-
|
|
4
|
+
import { i as Queries } from "./index-K-3WM2Hp.js";
|
|
5
5
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
6
6
|
//#region src/client/index.d.ts
|
|
7
7
|
interface BrowserOptions {
|
|
@@ -39,9 +39,9 @@ interface BrowserAuth {
|
|
|
39
39
|
/** `useSyncExternalStore`-compatible. */
|
|
40
40
|
readonly subscribe: (listener: () => void) => () => void;
|
|
41
41
|
}
|
|
42
|
-
interface BetterBrowser<M extends AnyModels, F extends AnyFunctions, E, C = unknown> {
|
|
42
|
+
interface BetterBrowser<M extends AnyModels, F extends AnyFunctions, E, C = unknown, P = unknown> {
|
|
43
43
|
/** The definition the browser was created from (schema metadata, specs, live queries). */
|
|
44
|
-
readonly sb: BetterSupabase<M, unknown, F, E, C>;
|
|
44
|
+
readonly sb: BetterSupabase<M, unknown, F, E, C, P>;
|
|
45
45
|
readonly supabase: SupabaseClient;
|
|
46
46
|
/** Repositories with the current session's actor and claims. */
|
|
47
47
|
readonly db: Db<M, F, E, SupabaseClient>;
|
|
@@ -57,6 +57,6 @@ interface BetterBrowser<M extends AnyModels, F extends AnyFunctions, E, C = unkn
|
|
|
57
57
|
* export const browser = createBrowser(sb, { env: { url, publishableKey } });
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
declare function createBrowser<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown>(sb: BetterSupabase<M, D, F, E, C>, options?: BrowserOptions): BetterBrowser<M, F, E, C>;
|
|
60
|
+
declare function createBrowser<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown, P = unknown>(sb: BetterSupabase<M, D, F, E, C, P>, options?: BrowserOptions): BetterBrowser<M, F, E, C, P>;
|
|
61
61
|
//#endregion
|
|
62
62
|
export { BrowserOptions as a, BrowserAuth as i, AuthUser as n, createBrowser as o, BetterBrowser as r, AuthSnapshot as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as SchemaMeta, a as Casing, b as PermdockBucketPolicy, i as BucketPolicyName } from "./types-C83v5SQz.js";
|
|
2
2
|
import { GeneratorMetadata, Queryable } from "@supabase/postgrest-typegen";
|
|
3
3
|
//#region src/cli/introspect/types.d.ts
|
|
4
4
|
/**
|
|
@@ -57,6 +57,8 @@ interface ExtrasHookFunction extends ExtrasFunction {
|
|
|
57
57
|
readonly publicExecute: boolean;
|
|
58
58
|
/** Of the same roles, those with `usage` on its schema. */
|
|
59
59
|
readonly schemaUsage: readonly string[];
|
|
60
|
+
/** The function body (`pg_proc.prosrc`). Absent in snapshots that predate it. */
|
|
61
|
+
readonly source?: string;
|
|
60
62
|
}
|
|
61
63
|
/** A function as doctor needs it for RLS checks, in any schema. */
|
|
62
64
|
interface ExtrasFunction {
|
|
@@ -337,8 +339,18 @@ interface SoftDeleteConfig {
|
|
|
337
339
|
}
|
|
338
340
|
interface TenantConfig {
|
|
339
341
|
readonly column?: string;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Claim names shared by the SQL kit, codegen and the runtime defaults. They
|
|
345
|
+
* follow PermDock's claim contract.
|
|
346
|
+
*/
|
|
347
|
+
interface ClaimsConfig {
|
|
348
|
+
/** Top-level claim holding the active tenant id. Defaults to `tenant_id`. */
|
|
349
|
+
readonly tenant?: string;
|
|
350
|
+
/** `scope` of the tenant entries `membership_claims()` writes. Defaults to `tenant`. */
|
|
351
|
+
readonly scope?: string;
|
|
352
|
+
/** Claim holding plan features per tenant (`{ [tenantId]: string[] }`). Defaults to `features`. */
|
|
353
|
+
readonly features?: string;
|
|
342
354
|
}
|
|
343
355
|
interface ActorConfig {
|
|
344
356
|
readonly createdBy?: string;
|
|
@@ -355,8 +367,8 @@ interface BucketConfig {
|
|
|
355
367
|
readonly public?: boolean;
|
|
356
368
|
/** Path template with `{placeholders}`, e.g. `{orgId}/{customerId}/logo.webp`. */
|
|
357
369
|
readonly path: string;
|
|
358
|
-
/** Generated storage policy. */
|
|
359
|
-
readonly policy?:
|
|
370
|
+
/** Generated storage policy, or a PermDock policy (`{ permdock, scope }`). */
|
|
371
|
+
readonly policy?: BucketPolicyName | PermdockBucketPolicy;
|
|
360
372
|
readonly fileSizeLimit?: string;
|
|
361
373
|
readonly allowedMimeTypes?: readonly string[];
|
|
362
374
|
}
|
|
@@ -397,6 +409,13 @@ interface DoctorConfig {
|
|
|
397
409
|
* asks for an inlinable `language sql stable` function. Defaults to 5.
|
|
398
410
|
*/
|
|
399
411
|
readonly policyHelperLimit?: number;
|
|
412
|
+
/**
|
|
413
|
+
* The BS405 limit in bytes. With a `permdock.config.ts` it is PermDock's
|
|
414
|
+
* budget for `memberships` plus `attrs` (default 1024, matching
|
|
415
|
+
* `supabase.hook.budget`) and the whole token keeps 2048. Without one it
|
|
416
|
+
* limits the whole token's claims (default 2048).
|
|
417
|
+
*/
|
|
418
|
+
readonly claimsLimit?: number;
|
|
400
419
|
}
|
|
401
420
|
/**
|
|
402
421
|
* Runtime types for columns whose JSON form loses information. Defaults
|
|
@@ -530,6 +549,7 @@ interface BetterSupabaseConfig {
|
|
|
530
549
|
readonly generators?: readonly Generator[];
|
|
531
550
|
/** Enables plugin flags in the generated metadata. */
|
|
532
551
|
readonly plugins?: PluginFlagsConfig;
|
|
552
|
+
readonly claims?: ClaimsConfig;
|
|
533
553
|
readonly buckets?: Readonly<Record<string, BucketConfig>>;
|
|
534
554
|
/** Realtime topic templates: `{ notifications: 'org:{orgId}:notifications' }`. */
|
|
535
555
|
readonly topics?: Readonly<Record<string, string>>;
|
|
@@ -570,6 +590,7 @@ interface ResolvedConfig {
|
|
|
570
590
|
readonly tenant: Required<TenantConfig> | undefined;
|
|
571
591
|
readonly actor: Required<ActorConfig> | undefined;
|
|
572
592
|
};
|
|
593
|
+
readonly claims: Required<ClaimsConfig>;
|
|
573
594
|
readonly buckets: Readonly<Record<string, BucketConfig>>;
|
|
574
595
|
readonly entitlements: {
|
|
575
596
|
readonly table: 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 { ExtrasFunction as $, defineConfig as A, Catalog as B, SourceConfig as C, TimestampsConfig as D, TenantConfig as E, ValibotGeneratorOptions as F, CatalogFunction as G, CatalogColumn as H, valibot as I, CatalogIndex as J, CatalogFunctionArg as K, JsonSchemaGeneratorOptions as L, resolveJsonSchema as M, ZodGeneratorOptions as N, VectorDistance as O, zod as P, CatalogUnique as Q, buildJsonSchema as R, SoftDeleteConfig as S, TableConfig as T, CatalogEnum as U, CatalogCheck as V, CatalogForeignKey as W, CatalogTable as X, CatalogPolicy as Y, CatalogTrigger as Z, Privilege as _, ClaimsConfig as a, SnapshotBucket as at, ResolvedExpose as b, EntitlementsConfig as c, Queryable as ct, Generator as d, ExtrasHook as et, GeneratorInput as f, PluginFlagsConfig as g, OpenApiConfig as h, CONFIG_SCHEMA_URL as i, Snapshot as it, resolveConfig as j, VectorSearchConfig as k, ExposeConfig as l, JsonTypeConfig as m, BetterSupabaseConfig as n, ExtrasTable as nt, CodecsConfig as o, SnapshotExtras as ot, JsonSchemaSource as p, CatalogGrant as q, BucketConfig as r, ForeignKeyAction as rt, DoctorConfig as s, GeneratorMetadata as st, ActorConfig as t, ExtrasHookFunction as tt, GeneratedFile as u, RealtimeConfig as v, SqlConfig as w, SeedConfig as x, ResolvedConfig as y, jsonSchema as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as OpenApiParameter } from "./index-
|
|
1
|
+
import { A as SchemaMeta } from "./types-C83v5SQz.js";
|
|
2
|
+
import { f as OpenApiParameter } from "./index-Bw1bwtC0.js";
|
|
3
3
|
//#region src/openapi/index.d.ts
|
|
4
4
|
type Json = Record<string, unknown>;
|
|
5
5
|
type ResourceOperation = "list" | "get" | "create" | "update" | "delete";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { b as PermdockBucketPolicy, i as BucketPolicyName } from "./types-C83v5SQz.js";
|
|
1
2
|
import { p as DbError, t as AsyncResult } from "./result-CTkCZ6JA.js";
|
|
2
3
|
import { n as StoragePath, t as PathIn } from "./path-Cv__-OTj.js";
|
|
3
4
|
import { n as TemplateValues, t as TemplateParams } from "./template-mbvlysOo.js";
|
|
4
5
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
5
6
|
//#region src/storage/index.d.ts
|
|
6
|
-
type BucketPolicy =
|
|
7
|
+
type BucketPolicy = BucketPolicyName | PermdockBucketPolicy;
|
|
7
8
|
interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
8
9
|
/** Bucket id, e.g. `customer-logos`. */
|
|
9
10
|
readonly id: Id;
|
|
@@ -13,7 +14,14 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
13
14
|
/**
|
|
14
15
|
* Generated `storage.objects` policies. `tenant` and `owner` match a path
|
|
15
16
|
* segment against the JWT; `public` allows reads; `none` leaves access to
|
|
16
|
-
* the secret key
|
|
17
|
+
* the secret key; `{ permdock, scope }` calls PermDock's SQL helpers.
|
|
18
|
+
* Defaults to `none`.
|
|
19
|
+
*
|
|
20
|
+
* The helpers check role and scope only. Use `permdock` just for
|
|
21
|
+
* permissions whose grants have no row conditions beyond the scope: for a
|
|
22
|
+
* permission with row conditions (e.g. `ownerId = principal.id`) the bucket
|
|
23
|
+
* grants every object in the scope. Leave those to the policies
|
|
24
|
+
* `permdock rls generate` writes.
|
|
17
25
|
*/
|
|
18
26
|
readonly policy?: BucketPolicy;
|
|
19
27
|
/** `'5MiB'`, `'500KB'` or bytes. */
|
|
@@ -23,7 +31,7 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
23
31
|
readonly tenant?: {
|
|
24
32
|
/** Placeholder holding the tenant id. Defaults to `orgId`. */
|
|
25
33
|
readonly param?: string;
|
|
26
|
-
/** JWT claim paths, first match wins. Defaults to `
|
|
34
|
+
/** JWT claim paths, first match wins. Defaults to `tenant_id`, then `app_metadata.tenant_id`. */
|
|
27
35
|
readonly claim?: string | readonly string[];
|
|
28
36
|
/** SQL expression for the tenant id, instead of `claim`. */
|
|
29
37
|
readonly sql?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as PrimaryKeyValue, L as UniqueWhere, N as TableKey, R as Update, _ as Insert, n as AnyModels, t as AnyFunctions } from "./types-C83v5SQz.js";
|
|
2
2
|
import { _ as DbException } from "./result-CTkCZ6JA.js";
|
|
3
|
-
import { C as FindExt, Ct as WhereInput, M as UpsertArgs, N as WriteArgs, S as DeleteExt, T as OffsetPageArgs, X as InferResult, Z as QuerySpec, _ as CursorPage, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, rt as AggregateArgs, st as CountArgs, t as BetterSupabase, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, y as Db, yt as ReadArgs } from "./define-
|
|
3
|
+
import { C as FindExt, Ct as WhereInput, M as UpsertArgs, N as WriteArgs, S as DeleteExt, T as OffsetPageArgs, X as InferResult, Z as QuerySpec, _ as CursorPage, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, rt as AggregateArgs, st as CountArgs, t as BetterSupabase, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, y as Db, yt as ReadArgs } from "./define-e3zI4_4g.js";
|
|
4
4
|
import { DataTag, InfiniteData, QueryClient, SkipToken } from "@tanstack/query-core";
|
|
5
5
|
//#region src/query/invalidate.d.ts
|
|
6
6
|
/** Carried by every better-supabase query: the tables whose changes make it stale. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as and, E as or, S as UpdateOp, T as not, _ as OrderTerm, a as AggregateFn, b as SelectOp, c as Condition, d as FunctionSource, f as Include, g as Operation, h as MutationOp, i as RpcContext, l as CountMode, m as Measure, n as ExecuteResult, o as Aggregation, p as InsertOp, r as Executor, s as ColumnOp, t as ExecuteContext, u as DeleteOp, v as Quantifier, w as column, x as Selection, y as SelectColumn } from "./executor-
|
|
1
|
+
import { A as SchemaMeta, C as PrimaryKeyValue, D as Relations, E as RelationShape, F as UniqueConstraint, I as UniqueKeyName, L as UniqueWhere, M as TableFlags, N as TableKey, O as Row, P as TableMeta, R as Update, S as PrimaryKeyColumn, T as RelationMeta, _ as Insert, a as Casing, b as PermdockBucketPolicy, c as Codec, d as Flags, f as FlagsShape, g as FunctionsOf, h as FunctionShape, i as BucketPolicyName, j as Simplify, k as Schema, l as ColumnMeta, m as FunctionMeta, n as AnyModels, o as CheckConstraint, p as ForeignKeyConstraint, r as BucketMeta, s as ClaimsMeta, t as AnyFunctions, u as DatabaseOf, v as ModelShape, w as RealtimeTableMeta, x as PermdockTopicPolicy, y as ModelsOf } from "./types-C83v5SQz.js";
|
|
2
|
+
import { C as and, E as or, S as UpdateOp, T as not, _ as OrderTerm, a as AggregateFn, b as SelectOp, c as Condition, d as FunctionSource, f as Include, g as Operation, h as MutationOp, i as RpcContext, l as CountMode, m as Measure, n as ExecuteResult, o as Aggregation, p as InsertOp, r as Executor, s as ColumnOp, t as ExecuteContext, u as DeleteOp, v as Quantifier, w as column, x as Selection, y as SelectColumn } from "./executor-CGdNQ27g.js";
|
|
3
3
|
import { C as isConflict, D as statusOf, E as mapDbError, S as isCheck, T as isForeignKey, _ as DbException, a as Ok, b as ValidationIssue, c as err, d as toBetterResult, f as toDbError, g as DbErrorOf, h as DbErrorKinds, i as Err, l as fromBetterResult, m as DbErrorKind, n as BetterResultApi, o as Result, p as DbError, r as BetterResultShape, t as AsyncResult, u as ok, v as ErrorMapper, w as isDbError, x as dbError, y as RawDbError } from "./result-CTkCZ6JA.js";
|
|
4
|
-
import { a as EventHub, c as QueryEvent, d as LogFields, f as Logger, i as EventHandler, l as RefreshEvent, m as silentLogger, n as BetterSupabaseEvents, o as EventName, p as consoleLogger, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-
|
|
5
|
-
import { $ as Specs, A as RpcOptions, B as ReadSet, C as FindExt, Ct as WhereInput, D as Repository, E as PageOf, F as EMPTY_STATS, G as ReadSetParams, H as ReadSetParamType, I as StatsRecorder, J as isReadSet, K as ReadSetResult, L as recordStats, M as UpsertArgs, N as WriteArgs, O as RepositoryOf, P as DbStats, Q as ReadMethod, R as SearchArgs, S as DeleteExt, St as SortDirection, T as OffsetPageArgs, U as ReadSetParamTypes, V as ReadSetOptions, W as ReadSetParamValue, X as InferResult, Y as readSetTables, Z as QuerySpec, _ as CursorPage, _t as OrderByInput, a as defineSupabase, at as AggregateRow, b as DbHelpers, bt as RelationMeasureArg, c as postgrestExecutor, ct as FieldFilter, d as MemoryCache, dt as IncludeArg, et as TableSpecs, f as cacheTargetOf, ft as IncludeArgs, g as ConflictTarget, gt as OrderByArg, h as rpcCacheTargets, ht as NumericMeasureArg, i as RpcDefinition, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, m as rowKey, mt as MeasureKey, n as ConnectOptions, nt as specTables, o as PostgrestClientLike, ot as CountArg, p as memoryCache, pt as MeasureArg, q as defineReadSet, r as DefineSupabaseOptions, rt as AggregateArgs, s as explainPostgrest, st as CountArgs, t as BetterSupabase, tt as isQuerySpec, u as CacheTarget, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, xt as SelectArg, y as Db, yt as ReadArgs, z as InferReadSetParams } from "./define-
|
|
6
|
-
import { _ as definePlugin, a as ExtensionOf, c as MutationEvent, d as PLUGIN_API_VERSION, f as Plugin, g as WithExtension, h as RequestContext, i as CallOptions, l as MutationKind, m as RepositoryExtension, n as AnyPlugin, o as HasFlag, p as RepositoryApi, r as ApplyExtension, s as HookArgs, t as Actor, u as NoExtension } from "./plugin-
|
|
4
|
+
import { a as EventHub, c as QueryEvent, d as LogFields, f as Logger, i as EventHandler, l as RefreshEvent, m as silentLogger, n as BetterSupabaseEvents, o as EventName, p as consoleLogger, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-DOt3nSO-.js";
|
|
5
|
+
import { $ as Specs, A as RpcOptions, B as ReadSet, C as FindExt, Ct as WhereInput, D as Repository, E as PageOf, F as EMPTY_STATS, G as ReadSetParams, H as ReadSetParamType, I as StatsRecorder, J as isReadSet, K as ReadSetResult, L as recordStats, M as UpsertArgs, N as WriteArgs, O as RepositoryOf, P as DbStats, Q as ReadMethod, R as SearchArgs, S as DeleteExt, St as SortDirection, T as OffsetPageArgs, U as ReadSetParamTypes, V as ReadSetOptions, W as ReadSetParamValue, X as InferResult, Y as readSetTables, Z as QuerySpec, _ as CursorPage, _t as OrderByInput, a as defineSupabase, at as AggregateRow, b as DbHelpers, bt as RelationMeasureArg, c as postgrestExecutor, ct as FieldFilter, d as MemoryCache, dt as IncludeArg, et as TableSpecs, f as cacheTargetOf, ft as IncludeArgs, g as ConflictTarget, gt as OrderByArg, h as rpcCacheTargets, ht as NumericMeasureArg, i as RpcDefinition, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, m as rowKey, mt as MeasureKey, n as ConnectOptions, nt as specTables, o as PostgrestClientLike, ot as CountArg, p as memoryCache, pt as MeasureArg, q as defineReadSet, r as DefineSupabaseOptions, rt as AggregateArgs, s as explainPostgrest, st as CountArgs, t as BetterSupabase, tt as isQuerySpec, u as CacheTarget, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, xt as SelectArg, y as Db, yt as ReadArgs, z as InferReadSetParams } from "./define-e3zI4_4g.js";
|
|
6
|
+
import { _ as definePlugin, a as ExtensionOf, c as MutationEvent, d as PLUGIN_API_VERSION, f as Plugin, g as WithExtension, h as RequestContext, i as CallOptions, l as MutationKind, m as RepositoryExtension, n as AnyPlugin, o as HasFlag, p as RepositoryApi, r as ApplyExtension, s as HookArgs, t as Actor, u as NoExtension } from "./plugin-C4TR9J0Z.js";
|
|
7
7
|
import { n as validate, t as StandardSchemaV1 } from "./standard-CyhRzctb.js";
|
|
8
|
-
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-
|
|
8
|
+
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-cAEQ_IQN.js";
|
|
9
9
|
import { n as StoragePath } from "./path-Cv__-OTj.js";
|
|
10
|
-
import { n as postgrestCompiler, t as Compiler } from "./compiler-
|
|
10
|
+
import { n as postgrestCompiler, t as Compiler } from "./compiler-CZ9nIuqy.js";
|
|
11
11
|
import { a as ProblemResponseOptions, c as problemResponse, i as ProblemOptions, l as toProblem, n as PROBLEM_TYPE_BASE, o as fromProblem, r as ProblemDetails, s as isProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-DlgB0lYl.js";
|
|
12
|
-
import { t as SPEC_PINS } from "./spec-pins-
|
|
12
|
+
import { t as SPEC_PINS } from "./spec-pins-CqorWDnO.js";
|
|
13
13
|
//#region src/core/define-repository.d.ts
|
|
14
14
|
/** Adds `Methods` to the repository of `Table` only. */
|
|
15
15
|
interface TableRepositoryExtension<Table extends string, Methods> extends RepositoryExtension {
|
|
@@ -107,4 +107,4 @@ export declare function toCamel(name: string): string;
|
|
|
107
107
|
/** `firstName` to `first_name`. */
|
|
108
108
|
export declare function toSnake(name: string): string;
|
|
109
109
|
//#endregion
|
|
110
|
-
export { type Actor, type AggregateArgs, type AggregateFn, type AggregateResult, type AggregateRow, type Aggregation, type AnyFunctions, type AnyModels, type AnyPlugin, type ApplyExtension, AsyncResult, type AuthEvent, type BetterResultApi, type BetterResultShape, BetterSupabase, type BetterSupabaseEvents, type BucketMeta, type CacheAdapter, type CacheTarget, type CallOptions, type Casing, type CheckConstraint, type Codec, type ColumnMeta, type ColumnOp, type Compiler, type Condition, type ConflictTarget, type ConnectOptions, type CountArg, type CountArgs, type CountMode, type CursorPage, type CursorPageArgs, type DatabaseOf, type Db, type DbError, type DbErrorKind, type DbErrorKinds, type DbErrorOf, DbException, type DbHelpers, type DbStats, type DefineSupabaseOptions, type DeleteArgs, type DeleteExt, type DeleteOp, EMPTY_STATS, type EnrichDatabase, type Err, type ErrorEvent, type ErrorMapper, type EventHandler, EventHub, type EventName, type ExecuteContext, type ExecuteResult, type Executor, type ExtensionOf, type FieldFilter, type FindExt, type FindFirstArgs, type FindManyArgs, type Flags, type FlagsShape, type ForeignKeyConstraint, type FunctionMeta, type FunctionShape, type FunctionSource, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelShape, type ModelsOf, type MutationEvent, type MutationKind, type MutationNotice, type MutationOp, type NoExtension, type NumericMeasureArg, type OffsetPage, type OffsetPageArgs, type Ok, type Operation, type OrderByArg, type OrderByInput, type OrderTerm, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PageOf, type Payload, type PlanFilter, type PlanLimit, type PlanOrder, type Plugin, type PostgrestClientLike, type PostgrestPlan, type PrimaryKeyColumn, type PrimaryKeyValue, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type Quantifier, type QueryEvent, type QuerySpec, type RawDbError, type ReadArgs, type ReadMethod, type ReadSet, type ReadSetOptions, type ReadSetParamType, type ReadSetParamTypes, type ReadSetParamValue, type ReadSetParams, type ReadSetResult, type RealtimeTableMeta, type RefreshEvent, type RelationMeasureArg, type RelationMeta, type RelationShape, type Relations, type Repository, type RepositoryApi, type RepositoryExtension, type RepositoryOf, type RequestContext, type Result, type Returned, type Row, type RpcContext, type RpcDefinition, type RpcNotice, type RpcOptions, SPEC_PINS, type Schema, type SchemaMeta, type ScopeFor, type SearchArgs, type SelectArg, type SelectColumn, type SelectOp, type Selection, type Simplify, type SortDirection, type Specs, type StandardSchemaV1, StatsRecorder, type StoragePath, type TableFlags, type TableKey, type TableMeta, type TableRepositoryExtension, type TableSpecs, type UniqueConstraint, type UniqueKeyName, type UniqueWhere, type Update, type UpdateArgs, type UpdateOp, type UpsertArgs, type ValidationIssue, type WhereInput, type WithExtension, type WriteArgs, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, definePlugin, defineReadSet, defineSupabase, err, explainPostgrest, fromBetterResult, fromProblem, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, silentLogger, specTables, statusOf, toBetterResult, toDbError, toProblem, validate };
|
|
110
|
+
export { type Actor, type AggregateArgs, type AggregateFn, type AggregateResult, type AggregateRow, type Aggregation, type AnyFunctions, type AnyModels, type AnyPlugin, type ApplyExtension, AsyncResult, type AuthEvent, type BetterResultApi, type BetterResultShape, BetterSupabase, type BetterSupabaseEvents, type BucketMeta, type BucketPolicyName, type CacheAdapter, type CacheTarget, type CallOptions, type Casing, type CheckConstraint, type ClaimsMeta, type Codec, type ColumnMeta, type ColumnOp, type Compiler, type Condition, type ConflictTarget, type ConnectOptions, type CountArg, type CountArgs, type CountMode, type CursorPage, type CursorPageArgs, type DatabaseOf, type Db, type DbError, type DbErrorKind, type DbErrorKinds, type DbErrorOf, DbException, type DbHelpers, type DbStats, type DefineSupabaseOptions, type DeleteArgs, type DeleteExt, type DeleteOp, EMPTY_STATS, type EnrichDatabase, type Err, type ErrorEvent, type ErrorMapper, type EventHandler, EventHub, type EventName, type ExecuteContext, type ExecuteResult, type Executor, type ExtensionOf, type FieldFilter, type FindExt, type FindFirstArgs, type FindManyArgs, type Flags, type FlagsShape, type ForeignKeyConstraint, type FunctionMeta, type FunctionShape, type FunctionSource, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelShape, type ModelsOf, type MutationEvent, type MutationKind, type MutationNotice, type MutationOp, type NoExtension, type NumericMeasureArg, type OffsetPage, type OffsetPageArgs, type Ok, type Operation, type OrderByArg, type OrderByInput, type OrderTerm, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PageOf, type Payload, type PermdockBucketPolicy, type PermdockTopicPolicy, type PlanFilter, type PlanLimit, type PlanOrder, type Plugin, type PostgrestClientLike, type PostgrestPlan, type PrimaryKeyColumn, type PrimaryKeyValue, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type Quantifier, type QueryEvent, type QuerySpec, type RawDbError, type ReadArgs, type ReadMethod, type ReadSet, type ReadSetOptions, type ReadSetParamType, type ReadSetParamTypes, type ReadSetParamValue, type ReadSetParams, type ReadSetResult, type RealtimeTableMeta, type RefreshEvent, type RelationMeasureArg, type RelationMeta, type RelationShape, type Relations, type Repository, type RepositoryApi, type RepositoryExtension, type RepositoryOf, type RequestContext, type Result, type Returned, type Row, type RpcContext, type RpcDefinition, type RpcNotice, type RpcOptions, SPEC_PINS, type Schema, type SchemaMeta, type ScopeFor, type SearchArgs, type SelectArg, type SelectColumn, type SelectOp, type Selection, type Simplify, type SortDirection, type Specs, type StandardSchemaV1, StatsRecorder, type StoragePath, type TableFlags, type TableKey, type TableMeta, type TableRepositoryExtension, type TableSpecs, type UniqueConstraint, type UniqueKeyName, type UniqueWhere, type Update, type UpdateArgs, type UpdateOp, type UpsertArgs, type ValidationIssue, type WhereInput, type WithExtension, type WriteArgs, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, definePlugin, defineReadSet, defineSupabase, err, explainPostgrest, fromBetterResult, fromProblem, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, silentLogger, specTables, statusOf, toBetterResult, toDbError, toProblem, validate };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { a as isConflict, c as mapDbError, i as isCheck, l as statusOf, n as dbError, o as isDbError, s as isForeignKey, t as DbException } from "./errors-Bl3rkOzo.js";
|
|
2
|
-
import { i as escapeLike, l as defineSchema, o as decodeRows, s as encodeValue, t as simplify, u as tableMeta } from "./simplify-
|
|
2
|
+
import { i as escapeLike, l as defineSchema, o as decodeRows, s as encodeValue, t as simplify, u as tableMeta } from "./simplify-bwJpLnaS.js";
|
|
3
3
|
import { i as or, n as column, r as not, t as and } from "./types-6cYK9pbJ.js";
|
|
4
4
|
import { a as toBetterResult, i as ok, n as err, o as toDbError, r as fromBetterResult, t as AsyncResult } from "./result-DWXatkd6.js";
|
|
5
|
-
import { a as EventHub, c as
|
|
5
|
+
import { a as EventHub, c as rowKey, i as encodeCursor, l as rpcCacheTargets, n as defineSupabase, o as cacheTargetOf, r as decodeCursor, s as memoryCache, t as BetterSupabase } from "./define-BXMYD9AY.js";
|
|
6
6
|
import { n as touchedTables, t as invalidationTargets } from "./tables-rZxRxNPW.js";
|
|
7
|
+
import { n as silentLogger, t as consoleLogger } from "./logger-glM28NVN.js";
|
|
7
8
|
import { n as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-BqR6wKMB.js";
|
|
8
|
-
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-
|
|
9
|
-
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-
|
|
9
|
+
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-C5W-rBfR.js";
|
|
10
|
+
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-4lI3W_gZ.js";
|
|
10
11
|
import { t as validate } from "./standard-FUi3Z3-7.js";
|
|
11
|
-
import { a as problemResponse, i as isProblem, n as PROBLEM_TYPE_BASE, o as toProblem, r as fromProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-
|
|
12
|
-
import { t as SPEC_PINS } from "./spec-pins-
|
|
12
|
+
import { a as problemResponse, i as isProblem, n as PROBLEM_TYPE_BASE, o as toProblem, r as fromProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-BTkTtRV9.js";
|
|
13
|
+
import { t as SPEC_PINS } from "./spec-pins-C3oc-Tdp.js";
|
|
13
14
|
import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from "./scope-CDHcS7dE.js";
|
|
14
15
|
import { n as toCamel, r as toSnake } from "./casing-da0uRTqt.js";
|
|
15
16
|
//#region src/core/define-repository.ts
|
package/dist/jobs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as Result, p as DbError, t as AsyncResult } from "../result-CTkCZ6JA.js";
|
|
2
|
-
import { t as SqlClient } from "../executor-
|
|
2
|
+
import { t as SqlClient } from "../executor-BYXQ9AGn.js";
|
|
3
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
4
|
//#region src/jobs/index.d.ts
|
|
5
5
|
export type QueueSchemas = Readonly<Record<string, StandardSchemaV1>>;
|
package/dist/jobs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as mapDbError, n as dbError, t as DbException } from "../errors-Bl3rkOzo.js";
|
|
2
2
|
import { i as ok, n as err, o as toDbError, t as AsyncResult } from "../result-DWXatkd6.js";
|
|
3
3
|
import { t as validate } from "../standard-FUi3Z3-7.js";
|
|
4
|
-
import { a as problemResponse } from "../problem-
|
|
5
|
-
import { t as fromPgError } from "../executor-
|
|
6
|
-
import { c as verifyWebhook } from "../webhooks-
|
|
4
|
+
import { a as problemResponse } from "../problem-BTkTtRV9.js";
|
|
5
|
+
import { t as fromPgError } from "../executor-DeppvirK.js";
|
|
6
|
+
import { c as verifyWebhook } from "../webhooks-DMipjhSP.js";
|
|
7
7
|
//#region src/jobs/index.ts
|
|
8
8
|
function run(fn) {
|
|
9
9
|
return AsyncResult.from(async () => {
|
|
@@ -102,7 +102,7 @@ function postgrestTransport(client) {
|
|
|
102
102
|
const call = async (fn, args) => {
|
|
103
103
|
const { data, error } = await client.schema("pgmq_public").rpc(fn, args);
|
|
104
104
|
if (error) {
|
|
105
|
-
const message = typeof error === "object" &&
|
|
105
|
+
const message = typeof error === "object" && "message" in error ? String(error.message) : String(error);
|
|
106
106
|
throw new Error(`pgmq_public.${fn}: ${message}`, { cause: error });
|
|
107
107
|
}
|
|
108
108
|
return data;
|
|
@@ -458,7 +458,8 @@ function createInbox(sql, options) {
|
|
|
458
458
|
/** The Stripe event sent when a customer's active entitlements change. */
|
|
459
459
|
const ENTITLEMENTS_UPDATED = "entitlements.active_entitlement_summary.updated";
|
|
460
460
|
function stripeCustomerOf(payload) {
|
|
461
|
-
|
|
461
|
+
if (typeof payload !== "object" || payload === null) return void 0;
|
|
462
|
+
const customer = (payload.data?.object)?.customer;
|
|
462
463
|
if (typeof customer === "string") return customer;
|
|
463
464
|
const id = customer?.id;
|
|
464
465
|
return typeof id === "string" ? id : void 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as isList } from "./guards-BnzDvFrz.js";
|
|
1
2
|
//#region src/generators/shared.ts
|
|
2
3
|
const INTEGER = /* @__PURE__ */ new Set([
|
|
3
4
|
"int2",
|
|
@@ -132,7 +133,7 @@ function property(plan) {
|
|
|
132
133
|
if (!plan.nullable) return schema;
|
|
133
134
|
if (Object.keys(schema).length === 0) return schema;
|
|
134
135
|
const { enum: values, ...rest } = schema;
|
|
135
|
-
if (
|
|
136
|
+
if (isList(values)) return {
|
|
136
137
|
...rest,
|
|
137
138
|
type: ["string", "null"],
|
|
138
139
|
enum: [...values, null]
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ListPage, c as ListQuery, d as ListSearchParams, f as OpenApiParameter, h as defineListQuery, i as ListExtra, l as ListQueryConfig, m as UNSET, n as FacetInfo, o as ListParseResult, p as ParserSpec, r as ListDefinition, s as ListParsers, t as FacetCounts, u as ListQueryInput } from "../index-
|
|
1
|
+
import { a as ListPage, c as ListQuery, d as ListSearchParams, f as OpenApiParameter, h as defineListQuery, i as ListExtra, l as ListQueryConfig, m as UNSET, n as FacetInfo, o as ListParseResult, p as ParserSpec, r as ListDefinition, s as ListParsers, t as FacetCounts, u as ListQueryInput } from "../index-Bw1bwtC0.js";
|
|
2
2
|
export { FacetCounts, FacetInfo, ListDefinition, ListExtra, ListPage, ListParseResult, ListParsers, ListQuery, ListQueryConfig, ListQueryInput, ListSearchParams, OpenApiParameter, ParserSpec, UNSET, defineListQuery };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as SchemaMeta, N as TableKey, O as Row, n as AnyModels, t as AnyFunctions, x as PermdockTopicPolicy } from "./types-C83v5SQz.js";
|
|
2
2
|
import { b as ValidationIssue, o as Result, p as DbError, t as AsyncResult } from "./result-CTkCZ6JA.js";
|
|
3
|
-
import { Z as QuerySpec, t as BetterSupabase } from "./define-
|
|
3
|
+
import { Z as QuerySpec, t as BetterSupabase } from "./define-e3zI4_4g.js";
|
|
4
4
|
import { n as TemplateValues, t as TemplateParams } from "./template-mbvlysOo.js";
|
|
5
5
|
import { RealtimeChannel, SupabaseClient } from "@supabase/supabase-js";
|
|
6
6
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -15,7 +15,7 @@ interface TopicOptions<E extends EventSchemas> {
|
|
|
15
15
|
readonly private?: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Tenant check for the generated policy. Defaults to `{orgId}` against
|
|
18
|
-
* `
|
|
18
|
+
* `tenant_id` / `app_metadata.tenant_id` when the template has `{orgId}`.
|
|
19
19
|
*/
|
|
20
20
|
readonly tenant?: false | {
|
|
21
21
|
readonly param?: string;
|
|
@@ -26,6 +26,17 @@ interface TopicOptions<E extends EventSchemas> {
|
|
|
26
26
|
readonly owner?: false | {
|
|
27
27
|
readonly param?: string;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Authorize with PermDock's SQL helpers instead of the tenant claim:
|
|
31
|
+
* `permitted_<scope>_ids(receive)` on the scope segment (or
|
|
32
|
+
* `permdock_has` for `scope: 'global'`), and `send` for broadcasting.
|
|
33
|
+
*
|
|
34
|
+
* The helpers check role and scope only. Use this just for permissions
|
|
35
|
+
* whose grants have no row conditions beyond the scope: for a permission
|
|
36
|
+
* with row conditions (e.g. `authorId = principal.id`) every member of the
|
|
37
|
+
* scope may join. Leave those to the policies `permdock rls generate` writes.
|
|
38
|
+
*/
|
|
39
|
+
readonly permdock?: PermdockTopicPolicy;
|
|
29
40
|
/** Let clients broadcast on the topic, not only receive. Defaults to `false`. */
|
|
30
41
|
readonly send?: boolean;
|
|
31
42
|
/** Also authorize presence. Defaults to `false`. */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/core/logger.ts
|
|
2
|
+
const log = (method) => (message, fields) => {
|
|
3
|
+
if (fields === void 0) console[method](`better-supabase: ${message}`);
|
|
4
|
+
else console[method](`better-supabase: ${message}`, fields);
|
|
5
|
+
};
|
|
6
|
+
/** The default: `console`, with a `better-supabase:` prefix. */
|
|
7
|
+
const consoleLogger = {
|
|
8
|
+
debug: log("debug"),
|
|
9
|
+
info: log("info"),
|
|
10
|
+
warn: log("warn"),
|
|
11
|
+
error: log("error")
|
|
12
|
+
};
|
|
13
|
+
const noop = () => {};
|
|
14
|
+
const silentLogger = {
|
|
15
|
+
debug: noop,
|
|
16
|
+
info: noop,
|
|
17
|
+
warn: noop,
|
|
18
|
+
error: noop
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { silentLogger as n, consoleLogger as t };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as BetterSupabase } from "../define-
|
|
3
|
-
import { d as ServerContext, f as ServerOptions, l as BetterServer, n as GuardOptions } from "../respond-
|
|
4
|
-
import { i as ResourceRouteOptions } from "../resource-
|
|
1
|
+
import { N as TableKey, n as AnyModels, t as AnyFunctions } from "../types-C83v5SQz.js";
|
|
2
|
+
import { t as BetterSupabase } from "../define-e3zI4_4g.js";
|
|
3
|
+
import { d as ServerContext, f as ServerOptions, l as BetterServer, n as GuardOptions } from "../respond-Dne1ARSa.js";
|
|
4
|
+
import { i as ResourceRouteOptions } from "../resource-CgZa3YG_.js";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
//#region src/mcp/index.d.ts
|
|
7
7
|
export declare const MCP_PROTOCOL_VERSION: string;
|
|
@@ -31,8 +31,25 @@ export interface McpTool<M extends AnyModels, F extends AnyFunctions, E> {
|
|
|
31
31
|
readonly info: ToolInfo;
|
|
32
32
|
/** Validates arguments; its output is what `run` receives. */
|
|
33
33
|
readonly input?: StandardSchemaV1;
|
|
34
|
+
/** Opaque data for the `authorize` and `visible` hooks. Never sent to clients. */
|
|
35
|
+
readonly meta?: unknown;
|
|
34
36
|
run(args: never, ctx: ToolContext<M, F, E>): unknown;
|
|
35
37
|
}
|
|
38
|
+
/** What the `authorize` and `visible` hooks see of a tool. */
|
|
39
|
+
export interface ToolRef {
|
|
40
|
+
readonly info: ToolInfo;
|
|
41
|
+
/** The tool's `meta`, e.g. a PermDock permission. `undefined` for table tools. */
|
|
42
|
+
readonly meta: unknown;
|
|
43
|
+
}
|
|
44
|
+
/** The outcome of `authorize`. `scopes` turns a refusal into an OAuth challenge. */
|
|
45
|
+
export type ToolDecision = {
|
|
46
|
+
readonly allowed: true;
|
|
47
|
+
} | {
|
|
48
|
+
readonly allowed: false;
|
|
49
|
+
readonly reason?: string;
|
|
50
|
+
/** OAuth scopes the call needs, sent in an `insufficient_scope` challenge. */
|
|
51
|
+
readonly scopes?: readonly string[];
|
|
52
|
+
};
|
|
36
53
|
export interface ToolDefinition<M extends AnyModels, F extends AnyFunctions, E, I> {
|
|
37
54
|
readonly name: string;
|
|
38
55
|
readonly title?: string;
|
|
@@ -45,6 +62,8 @@ export interface ToolDefinition<M extends AnyModels, F extends AnyFunctions, E,
|
|
|
45
62
|
readonly inputSchema?: Json;
|
|
46
63
|
readonly outputSchema?: Json;
|
|
47
64
|
readonly annotations?: ToolAnnotations;
|
|
65
|
+
/** Opaque data for the `authorize` and `visible` hooks. Never sent to clients. */
|
|
66
|
+
readonly meta?: unknown;
|
|
48
67
|
run(args: I, ctx: ToolContext<M, F, E>): unknown;
|
|
49
68
|
}
|
|
50
69
|
export type ToolResources<M extends AnyModels> = { readonly [T in TableKey<M>]?: ResourceRouteOptions<M, T> | true; };
|
|
@@ -64,12 +83,30 @@ export interface McpOptions<M extends AnyModels, F extends AnyFunctions, E> exte
|
|
|
64
83
|
readonly resource?: string | ((request: Request) => string);
|
|
65
84
|
/** Defaults to Supabase Auth of `env.url` (`<url>/auth/v1`). */
|
|
66
85
|
readonly authorizationServers?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Scopes the tools need, published as RFC 9728 `scopes_supported` and in
|
|
88
|
+
* `insufficient_scope` challenges. `offline_access` is left out: refresh
|
|
89
|
+
* tokens are between the client and the authorization server.
|
|
90
|
+
*/
|
|
91
|
+
readonly scopes?: readonly string[];
|
|
67
92
|
/** Origins allowed to call the server (DNS rebinding protection). Defaults to any. */
|
|
68
93
|
readonly allowedOrigins?: readonly string[];
|
|
69
94
|
/** Custom jsonb types, as in `createOpenApi`. */
|
|
70
95
|
readonly json?: Readonly<Record<string, unknown>>;
|
|
71
96
|
/** Include internal error messages in tool results. Defaults to `NODE_ENV === 'development'`. */
|
|
72
97
|
readonly exposeErrors?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Decides each `tools/call` after the arguments are validated and before
|
|
100
|
+
* `run`. `args` are the validated arguments (raw for table tools, which
|
|
101
|
+
* validate in the repository). A refusal is a tool error; a refusal with
|
|
102
|
+
* `scopes` is a 403 `insufficient_scope` challenge naming them.
|
|
103
|
+
*/
|
|
104
|
+
readonly authorize?: (ctx: ToolContext<M, F, E>, tool: ToolRef, args: unknown) => ToolDecision | Promise<ToolDecision>;
|
|
105
|
+
/**
|
|
106
|
+
* Whether the caller sees a tool in `tools/list`. A hidden tool is called
|
|
107
|
+
* like an unknown one. Lists are cached per token (`cacheScope: 'private'`).
|
|
108
|
+
*/
|
|
109
|
+
readonly visible?: (ctx: ToolContext<M, F, E>, tool: ToolRef) => boolean | Promise<boolean>;
|
|
73
110
|
}
|
|
74
111
|
export interface BetterMcp<M extends AnyModels, F extends AnyFunctions, E> extends BetterServer<M, F, E> {
|
|
75
112
|
/** Everything in one handler: the MCP endpoint and `/.well-known/oauth-protected-resource`. */
|