better-supabase 0.3.0 → 0.5.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 +9 -6
- package/bin/better-supabase.js +4 -0
- package/dist/{base64-CQeB1eSf.js → base64-D2gsioCY.js} +2 -2
- package/dist/channel-FQW-CnGR.d.ts +70 -0
- package/dist/claims-BAf6c7is.js +48 -0
- package/dist/cli/_format-Cax5EsM9.js +101 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +48 -0
- package/dist/cli/codemod-DqV7612m.js +388 -0
- package/dist/cli/command-CK14fP91.js +502 -0
- package/dist/cli/compare-BmIWVEui.js +9 -0
- package/dist/cli/config-CPVpXP5I.js +1965 -0
- package/dist/cli/config-dtoekM0v.js +2 -0
- package/dist/cli/db-DOBPt660.js +52 -0
- package/dist/cli/diff-SjkO5rNr.js +752 -0
- package/dist/cli/dist-DBPdlPYK.js +1112 -0
- package/dist/cli/dist-DreZ24Sz.js +129 -0
- package/dist/cli/dist-xn4wlboc.js +732 -0
- package/dist/cli/doctor-L7Z8mYTx.js +2863 -0
- package/dist/cli/env-DmKv_G4A.js +108 -0
- package/dist/cli/env-jIFUADLY.js +511 -0
- package/dist/cli/errors-4v4DTtda.js +56 -0
- package/dist/cli/fastest-levenshtein-CFN-lNDv.js +120 -0
- package/dist/cli/gen-BJc9vdyu.js +2 -0
- package/dist/cli/gen-C2osRcr5.js +2204 -0
- package/dist/cli/index.d.ts +493 -0
- package/dist/cli/index.js +184 -0
- package/dist/cli/init-Saf5-R9T.js +550 -0
- package/dist/cli/introspect--H7oGmcd.js +81 -0
- package/dist/cli/io-k41_z-jT.js +24 -0
- package/dist/cli/json5-ChRycquj.js +787 -0
- package/dist/cli/jsonc-BUniUpOk.js +2 -0
- package/dist/cli/jsonc-D5Fu67jw.js +45 -0
- package/dist/cli/keys-ByKHnvP9.js +83 -0
- package/dist/cli/ohash-D7bG_EOb.js +277 -0
- package/dist/cli/openapi-Cp5Fyta-.js +66 -0
- package/dist/cli/project-B_GeXyHh.js +70 -0
- package/dist/cli/prompts-BNcNfAve.js +1142 -0
- package/dist/cli/prompts-BTYQGunc.js +2 -0
- package/dist/cli/read-sets-BfMQcKy8.js +289 -0
- package/dist/cli/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/cli/run-BKR2W_79.js +351 -0
- package/dist/cli/seed-CUlqWh-8.js +98 -0
- package/dist/cli/skills-LJJIhLFR.js +137 -0
- package/dist/cli/sql-DzPbfngx.js +348 -0
- package/dist/cli/style-C0NFdJRL.js +29 -0
- package/dist/cli/toml-DB-MNnFs.js +424 -0
- package/dist/cli/version-BDJuO0UR.js +4 -0
- package/dist/cli/yaml-CYCbJ6et.js +2252 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +15 -22
- package/dist/clone-BfgmLU90.js +21 -0
- package/dist/{compiler-2zqGzxVZ.d.ts → compiler-BXH_aZ7N.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +5 -5
- package/dist/{config-DOsGYSiT.js → config-DreERlKo.js} +1 -1
- package/dist/{config-C1CYcm6o.d.ts → config-T_ejwyd3.d.ts} +176 -11
- package/dist/{define-DUbydmJa.d.ts → define-Bp_BZa5h.d.ts} +37 -29
- package/dist/{define-DF341GDj.js → define-cNKzqwL_.js} +356 -89
- package/dist/edge/index.d.ts +20 -13
- package/dist/edge/index.js +55 -26
- package/dist/{entitlements-DvJXoI02.d.ts → entitlements-DUxU4oHe.d.ts} +2 -2
- package/dist/env/index.d.ts +2 -2
- package/dist/env/index.js +34 -1
- package/dist/{errors-Bl3rkOzo.js → errors-DtwXa6b8.js} +2 -1
- package/dist/events/index.d.ts +3 -2
- package/dist/events/index.js +69 -16
- package/dist/events-aIO7vsIk.d.ts +230 -0
- package/dist/executor-BunPOO-k.d.ts +402 -0
- package/dist/{executor-B26lgbHD.d.ts → executor-Cghdstwu.d.ts} +1 -2
- package/dist/{executor-C57jx2pn.js → executor-XycESQPH.js} +3 -3
- package/dist/hono/index.d.ts +27 -23
- package/dist/hono/index.js +46 -11
- package/dist/impersonation-VfaGc4Q_.js +41 -0
- package/dist/{index-BNsABq7P.d.ts → index-BGdgBPdf.d.ts} +66 -25
- package/dist/{index-qriRM9cZ.d.ts → index-C7f8cOBM.d.ts} +4 -4
- package/dist/{index-Dy6kuF0P.d.ts → index-CLg87OBW.d.ts} +6 -1
- package/dist/{index-GV77NpRP.d.ts → index-DOESKG27.d.ts} +34 -9
- package/dist/{index-CriFFJ_p.d.ts → index-DgILJRXj.d.ts} +43 -17
- package/dist/{index-UJ-LUxtI.d.ts → index-DmXSxbLi.d.ts} +14 -14
- package/dist/{index-Cf-D2jk1.d.ts → index-Dxn2a5cw.d.ts} +2 -2
- package/dist/{index-CTTMS6_1.d.ts → index-SaTsEfGP.d.ts} +86 -9
- package/dist/{index-CADlNHK-.d.ts → index-fag8VJZ2.d.ts} +5 -6
- package/dist/index.d.ts +34 -17
- package/dist/index.js +15 -14
- package/dist/jobs/index.d.ts +147 -95
- package/dist/jobs/index.js +773 -250
- package/dist/{json-schema--aOXAGfU.js → json-schema-m1fiwKgN.js} +23 -2
- package/dist/kit-events-CTFDfSwb.js +60 -0
- package/dist/kit-transport-B82k1djG.d.ts +33 -0
- package/dist/kit-transport-DJlHQUBU.js +55 -0
- package/dist/{config-Be4GwsqI.js → kits-CGLLrNPd.js} +38 -10
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +3 -3
- package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
- package/dist/{live-QE3UPbGm.d.ts → live-D9W2M5aO.d.ts} +16 -15
- package/dist/lookup-BaP5bI27.js +18 -0
- package/dist/mcp/index.d.ts +39 -22
- package/dist/mcp/index.js +39 -25
- package/dist/{mfa-x3V3vGh-.d.ts → mfa-CusDgPaD.d.ts} +5 -1
- package/dist/next/image/index.js +6 -3
- package/dist/next/index.d.ts +60 -36
- package/dist/next/index.js +167 -50
- package/dist/notifications/index.d.ts +162 -0
- package/dist/notifications/index.js +264 -0
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +6 -6
- package/dist/orgs/index.d.ts +132 -0
- package/dist/orgs/index.js +245 -0
- package/dist/orpc/index.d.ts +37 -20
- package/dist/orpc/index.js +24 -11
- package/dist/otel/index.d.ts +24 -5
- package/dist/otel/index.js +124 -64
- package/dist/permdock-sql-C2Inc6Xc.d.ts +29 -0
- package/dist/permdock-sql-DgOfeixi.js +51 -0
- package/dist/plugin-DwARMuQp.js +59 -0
- package/dist/{plugin-DVRB8qNE.d.ts → plugin-o144f322.d.ts} +17 -5
- package/dist/plugins/actor/index.d.ts +5 -2
- package/dist/plugins/actor/index.js +22 -8
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +52 -17
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +14 -5
- package/dist/plugins/tenant/index.d.ts +3 -3
- package/dist/plugins/tenant/index.js +45 -21
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +4 -3
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +26 -6
- package/dist/{pool-B9qsLyFR.d.ts → pool-C9voM4Kw.d.ts} +24 -6
- package/dist/postgres/index.d.ts +5 -5
- package/dist/postgres/index.js +20 -10
- package/dist/{postgrest-DmBlevh-.d.ts → postgrest-CruYKAvV.d.ts} +1 -1
- package/dist/{problem-CGt1ADix.js → problem-BW1KhzSG.js} +2 -1
- package/dist/{problem-Z2RTQjZD.d.ts → problem-Blxe8S31.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +3 -3
- package/dist/{query-BdKLTPlj.js → query-CCbo44lG.js} +18 -18
- package/dist/queue-BYUCjr59.d.ts +252 -0
- package/dist/react/index.d.ts +8 -7
- package/dist/react/index.js +4 -3
- package/dist/react/server.d.ts +16 -5
- package/dist/react/server.js +12 -4
- package/dist/react/session.d.ts +10 -4
- package/dist/react/session.js +11 -3
- package/dist/{react-DNBYNazu.js → react-C_s7kiNz.js} +138 -46
- package/dist/{read-set-D0qBcboM.js → read-set-DQFt1N_Y.js} +71 -15
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +14 -12
- package/dist/{index-kpgopLNv.d.ts → refresh-BTrQ_ZTp.d.ts} +6 -3
- package/dist/{resolve-BRciX2jK.d.ts → resolve-C15TJq77.d.ts} +22 -11
- package/dist/{resource-D30rp0GN.js → resource-CRxxwkQq.js} +24 -9
- package/dist/{resource-CwVgiI5q.d.ts → resource-D8iqWMr-.d.ts} +6 -6
- package/dist/respond-D2OQl62-.d.ts +371 -0
- package/dist/{result-DWXatkd6.js → result-BKiliPY7.js} +2 -2
- package/dist/server/index.d.ts +17 -15
- package/dist/server/index.js +16 -22
- package/dist/server-Csx2sRjg.js +655 -0
- package/dist/{shared-_6-uPL7E.js → shared-D1dRUrAg.js} +19 -4
- package/dist/signers-Cc6r98SW.d.ts +162 -0
- package/dist/{simplify-LakqK1vH.js → simplify-_0oUKqCd.js} +27 -95
- package/dist/sql/index.d.ts +247 -10
- package/dist/sql/index.js +8591 -780
- package/dist/{sql-BIgk12ew.js → sql-Coh6n4cC.js} +11 -3
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +1 -2
- package/dist/{standard-FUi3Z3-7.js → standard-D7r6dMUu.js} +6 -3
- package/dist/{standard-eudBiRk1.d.ts → standard-J4YgMOLm.d.ts} +1 -1
- package/dist/{stats-D78UQ8Yu.js → stats-Bqob3WqT.js} +34 -9
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.js +174 -27
- package/dist/support-DT-OhSxD.d.ts +88 -0
- package/dist/support-Dk6vdmEw.js +291 -0
- package/dist/support-view-Da5peKFg.d.ts +17 -0
- package/dist/support-view-g4YLBeqX.js +18 -0
- package/dist/{tables-Dhha3BXM.js → tables-Cb-3_VWc.js} +14 -0
- package/dist/{permdock-sql-Bta_G0v-.js → template-TxrGI5jR.js} +2 -31
- package/dist/{temporal-BwshQk0W.js → temporal-CVlIV2DZ.js} +17 -4
- package/dist/{temporal-required-CMxeSVPo.js → temporal-required-CAt4Dc9Z.js} +2 -2
- package/dist/testing/index.d.ts +113 -24
- package/dist/testing/index.js +375 -47
- package/dist/{types-DONv9SHN.d.ts → types-Dnf_wRDz.d.ts} +26 -3
- package/dist/user-change-CHFEUro1.js +49 -0
- package/dist/{webhooks-CAIFQSTM.js → verify-Ce49ETPz.js} +38 -19
- package/dist/{version-BfpG2gks.js → version-DM_Roffb.js} +1 -1
- package/dist/{view-3Po_PVlr.d.ts → view-BEf0diC5.d.ts} +10 -5
- package/dist/{mfa-BxoR1RkN.js → view-Bq64ki8-.js} +210 -64
- package/dist/webhooks/index.d.ts +136 -5
- package/dist/webhooks/index.js +588 -2
- package/dist/wire-D2dT86vi.js +35 -0
- package/package.json +50 -10
- package/schemas/config-v1.json +131 -1
- package/schemas/doctor-report-v1.json +10 -0
- package/skills/better-supabase/SKILL.md +60 -10
- package/skills/better-supabase/references/plugins.md +13 -14
- package/skills/better-supabase/references/troubleshooting.md +25 -4
- package/skills/better-supabase-api/SKILL.md +74 -19
- package/skills/better-supabase-api/references/adapters.md +48 -27
- package/skills/better-supabase-auth/SKILL.md +149 -0
- package/skills/better-supabase-auth/references/permdock.md +100 -0
- package/skills/better-supabase-testing/SKILL.md +58 -4
- package/dist/claims-CoTobNC-.js +0 -25
- package/dist/events-Do8jXh4D.d.ts +0 -84
- package/dist/executor-DynmIWhq.d.ts +0 -195
- package/dist/invalidate-DbxuL2jL.js +0 -18
- package/dist/permdock-sql-DImJULY-.d.ts +0 -17
- package/dist/plugin-BqR6wKMB.js +0 -23
- package/dist/respond-C44EZAJo.js +0 -399
- package/dist/respond-DAkPIdTH.d.ts +0 -175
- package/dist/result-c2OYgCV2.d.ts +0 -203
- package/dist/view-wZ-9qIUz.js +0 -45
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { g as Operation } from "./executor-DynmIWhq.js";
|
|
2
|
-
import { p as DbError } from "./result-c2OYgCV2.js";
|
|
3
|
-
import { h as RequestContext, l as MutationKind } from "./plugin-DVRB8qNE.js";
|
|
4
|
-
//#region src/core/logger.d.ts
|
|
5
|
-
type LogFields = Readonly<Record<string, unknown>>;
|
|
6
|
-
/**
|
|
7
|
-
* Where better-supabase reports problems it swallows on purpose: event
|
|
8
|
-
* handlers, `afterMutation` hooks, sinks and cache adapters that throw.
|
|
9
|
-
* Structured loggers (pino, consola, OpenTelemetry logs) fit directly.
|
|
10
|
-
*/
|
|
11
|
-
interface Logger {
|
|
12
|
-
debug(message: string, fields?: LogFields): void;
|
|
13
|
-
info(message: string, fields?: LogFields): void;
|
|
14
|
-
warn(message: string, fields?: LogFields): void;
|
|
15
|
-
error(message: string, fields?: LogFields): void;
|
|
16
|
-
}
|
|
17
|
-
/** The default: `console`, with a `better-supabase:` prefix. */
|
|
18
|
-
declare const consoleLogger: Logger;
|
|
19
|
-
declare const silentLogger: Logger;
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/core/events.d.ts
|
|
22
|
-
interface QueryEvent {
|
|
23
|
-
readonly table: string;
|
|
24
|
-
readonly operation: Operation["kind"];
|
|
25
|
-
readonly ok: boolean;
|
|
26
|
-
readonly durationMs: number;
|
|
27
|
-
readonly rows: number;
|
|
28
|
-
/**
|
|
29
|
-
* An unbounded read returned `maxRows` rows: PostgREST's `db-max-rows`
|
|
30
|
-
* probably cut it short. Add `limit` or use `paginate`.
|
|
31
|
-
*/
|
|
32
|
-
readonly truncated: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface MutationNotice {
|
|
35
|
-
readonly table: string;
|
|
36
|
-
readonly kind: MutationKind;
|
|
37
|
-
readonly rows: readonly Readonly<Record<string, unknown>>[];
|
|
38
|
-
readonly context: RequestContext;
|
|
39
|
-
}
|
|
40
|
-
/** A successful RPC registered with `sb.defineRpc(name, { invalidates })`. */
|
|
41
|
-
interface RpcNotice {
|
|
42
|
-
readonly name: string;
|
|
43
|
-
/** App keys of the tables the function changes. */
|
|
44
|
-
readonly invalidates: readonly string[];
|
|
45
|
-
readonly context: RequestContext;
|
|
46
|
-
}
|
|
47
|
-
interface ErrorEvent {
|
|
48
|
-
readonly table?: string;
|
|
49
|
-
readonly error: DbError;
|
|
50
|
-
}
|
|
51
|
-
interface AuthEvent {
|
|
52
|
-
readonly source: "bearer" | "cookie" | "none";
|
|
53
|
-
readonly ok: boolean;
|
|
54
|
-
readonly userId?: string;
|
|
55
|
-
}
|
|
56
|
-
interface RefreshEvent {
|
|
57
|
-
readonly ok: boolean;
|
|
58
|
-
readonly shared: boolean;
|
|
59
|
-
readonly durationMs: number;
|
|
60
|
-
}
|
|
61
|
-
interface BetterSupabaseEvents {
|
|
62
|
-
query: QueryEvent;
|
|
63
|
-
mutation: MutationNotice;
|
|
64
|
-
rpc: RpcNotice;
|
|
65
|
-
error: ErrorEvent;
|
|
66
|
-
auth: AuthEvent;
|
|
67
|
-
refresh: RefreshEvent;
|
|
68
|
-
}
|
|
69
|
-
type EventName = keyof BetterSupabaseEvents;
|
|
70
|
-
type EventHandler<K extends EventName> = (event: BetterSupabaseEvents[K]) => void;
|
|
71
|
-
/**
|
|
72
|
-
* Observers only: a handler that throws is reported to the logger and never
|
|
73
|
-
* changes a result.
|
|
74
|
-
*/
|
|
75
|
-
declare class EventHub {
|
|
76
|
-
#private;
|
|
77
|
-
readonly logger: Logger;
|
|
78
|
-
constructor(logger?: Logger);
|
|
79
|
-
on<K extends EventName>(name: K, handler: EventHandler<K>): () => void;
|
|
80
|
-
has(name: EventName): boolean;
|
|
81
|
-
emit<K extends EventName>(name: K, event: BetterSupabaseEvents[K]): void;
|
|
82
|
-
}
|
|
83
|
-
//#endregion
|
|
84
|
-
export { EventHub as a, QueryEvent as c, LogFields as d, Logger as f, EventHandler as i, RefreshEvent as l, silentLogger as m, BetterSupabaseEvents as n, EventName as o, consoleLogger as p, ErrorEvent as r, MutationNotice as s, AuthEvent as t, RpcNotice as u };
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { P as TableMeta, T as RelationMeta, c as Codec } from "./types-DONv9SHN.js";
|
|
2
|
-
import { o as Result, v as ErrorMapper } from "./result-c2OYgCV2.js";
|
|
3
|
-
//#region src/ir/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* The query IR. Every repository call becomes one of these operations; the
|
|
6
|
-
* executor compiles it to PostgREST or SQL. Column names in the IR are
|
|
7
|
-
* database names; `Selection` carries the app aliases.
|
|
8
|
-
*/
|
|
9
|
-
type ColumnOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "is" | "like" | "ilike" | "contains" | "containedBy" | "overlaps" | "fts";
|
|
10
|
-
type Quantifier = "some" | "none" | "every";
|
|
11
|
-
type Condition = {
|
|
12
|
-
readonly kind: "and";
|
|
13
|
-
readonly items: readonly Condition[];
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: "or";
|
|
16
|
-
readonly items: readonly Condition[];
|
|
17
|
-
} | {
|
|
18
|
-
readonly kind: "not";
|
|
19
|
-
readonly item: Condition;
|
|
20
|
-
} | {
|
|
21
|
-
readonly kind: "column";
|
|
22
|
-
readonly column: string;
|
|
23
|
-
readonly op: ColumnOp;
|
|
24
|
-
readonly value: unknown;
|
|
25
|
-
/** Full-text search configuration for `fts`. */
|
|
26
|
-
readonly config?: string;
|
|
27
|
-
} | {
|
|
28
|
-
readonly kind: "relation";
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly relation: RelationMeta;
|
|
31
|
-
readonly target: TableMeta;
|
|
32
|
-
readonly quantifier: Quantifier;
|
|
33
|
-
readonly where: Condition | undefined;
|
|
34
|
-
};
|
|
35
|
-
interface SelectColumn {
|
|
36
|
-
/** Key in the returned row. */
|
|
37
|
-
readonly alias: string;
|
|
38
|
-
/** Database column name. */
|
|
39
|
-
readonly column: string;
|
|
40
|
-
/** Read the column as text, so exact `int8`/`numeric` values survive JSON. */
|
|
41
|
-
readonly cast?: "text";
|
|
42
|
-
/** Decodes the returned value (see `ColumnMeta.codec`). */
|
|
43
|
-
readonly codec?: Codec;
|
|
44
|
-
}
|
|
45
|
-
interface OrderTerm {
|
|
46
|
-
readonly column: string;
|
|
47
|
-
readonly direction: "asc" | "desc";
|
|
48
|
-
readonly nulls?: "first" | "last";
|
|
49
|
-
}
|
|
50
|
-
interface Include {
|
|
51
|
-
readonly alias: string;
|
|
52
|
-
readonly relation: RelationMeta;
|
|
53
|
-
readonly target: TableMeta;
|
|
54
|
-
readonly selection: Selection;
|
|
55
|
-
readonly where: Condition | undefined;
|
|
56
|
-
readonly orderBy: readonly OrderTerm[];
|
|
57
|
-
readonly limit: number | undefined;
|
|
58
|
-
/** Drop parent rows without a match (`!inner`). */
|
|
59
|
-
readonly required: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* `_count` include: returns the number of matching related rows instead of
|
|
62
|
-
* rows, folded into `row._count[count]` when decoded.
|
|
63
|
-
*/
|
|
64
|
-
readonly count?: string;
|
|
65
|
-
/**
|
|
66
|
-
* `_sum`/`_avg`/`_min`/`_max` include: `selection.aggregate` holds the
|
|
67
|
-
* measures, folded into `row[`_${fn}`][name]` when decoded.
|
|
68
|
-
*/
|
|
69
|
-
readonly aggregate?: {
|
|
70
|
-
readonly fn: AggregateFn;
|
|
71
|
-
readonly name: string;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
type AggregateFn = "sum" | "avg" | "min" | "max";
|
|
75
|
-
interface Measure {
|
|
76
|
-
readonly fn: AggregateFn;
|
|
77
|
-
/** Key in the returned row (`_sum_amount`, or the column alias in an include). */
|
|
78
|
-
readonly key: string;
|
|
79
|
-
/** App column name, the key under `_sum` in the decoded row. */
|
|
80
|
-
readonly alias: string;
|
|
81
|
-
/** Database column name. */
|
|
82
|
-
readonly column: string;
|
|
83
|
-
/** Read the result as text, so exact `int8`/`numeric` values survive JSON. */
|
|
84
|
-
readonly cast?: "text";
|
|
85
|
-
readonly codec?: Codec;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Aggregates instead of rows. `Selection.columns` become the grouping
|
|
89
|
-
* columns; without any, the result is exactly one row.
|
|
90
|
-
*/
|
|
91
|
-
interface Aggregation {
|
|
92
|
-
/** Also return `_count`, the number of rows in each group. */
|
|
93
|
-
readonly count: boolean;
|
|
94
|
-
readonly measures: readonly Measure[];
|
|
95
|
-
}
|
|
96
|
-
interface Selection {
|
|
97
|
-
readonly columns: readonly SelectColumn[];
|
|
98
|
-
readonly includes: readonly Include[];
|
|
99
|
-
readonly aggregate?: Aggregation;
|
|
100
|
-
}
|
|
101
|
-
type CountMode = "exact" | "planned" | "estimated";
|
|
102
|
-
interface SelectOp {
|
|
103
|
-
readonly kind: "select";
|
|
104
|
-
readonly table: TableMeta;
|
|
105
|
-
readonly selection: Selection;
|
|
106
|
-
readonly where: Condition | undefined;
|
|
107
|
-
readonly orderBy: readonly OrderTerm[];
|
|
108
|
-
readonly limit: number | undefined;
|
|
109
|
-
readonly offset: number | undefined;
|
|
110
|
-
readonly count: CountMode | undefined;
|
|
111
|
-
/** Only count, return no rows. */
|
|
112
|
-
readonly head: boolean;
|
|
113
|
-
readonly single: "one" | "maybe" | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* Read from this set-returning function instead of the table (`db.$search`).
|
|
116
|
-
* Only executors with `functionSources` honor it.
|
|
117
|
-
*/
|
|
118
|
-
readonly source?: FunctionSource;
|
|
119
|
-
}
|
|
120
|
-
/** A function returning `setof <table>`, called with named arguments. */
|
|
121
|
-
interface FunctionSource {
|
|
122
|
-
readonly schema: string;
|
|
123
|
-
readonly name: string;
|
|
124
|
-
readonly args: Readonly<Record<string, unknown>>;
|
|
125
|
-
}
|
|
126
|
-
interface InsertOp {
|
|
127
|
-
readonly kind: "insert";
|
|
128
|
-
readonly table: TableMeta;
|
|
129
|
-
/** Rows keyed by database column names. */
|
|
130
|
-
readonly rows: readonly Readonly<Record<string, unknown>>[];
|
|
131
|
-
readonly returning: Selection | undefined;
|
|
132
|
-
readonly onConflict: {
|
|
133
|
-
readonly columns: readonly string[];
|
|
134
|
-
readonly action: "update" | "ignore";
|
|
135
|
-
} | undefined;
|
|
136
|
-
/** Missing columns become `null` instead of their default in bulk inserts. */
|
|
137
|
-
readonly defaultToNull: boolean;
|
|
138
|
-
}
|
|
139
|
-
interface UpdateOp {
|
|
140
|
-
readonly kind: "update";
|
|
141
|
-
readonly table: TableMeta;
|
|
142
|
-
/** Keyed by database column names. */
|
|
143
|
-
readonly set: Readonly<Record<string, unknown>>;
|
|
144
|
-
readonly where: Condition | undefined;
|
|
145
|
-
readonly returning: Selection | undefined;
|
|
146
|
-
}
|
|
147
|
-
interface DeleteOp {
|
|
148
|
-
readonly kind: "delete";
|
|
149
|
-
readonly table: TableMeta;
|
|
150
|
-
readonly where: Condition | undefined;
|
|
151
|
-
readonly returning: Selection | undefined;
|
|
152
|
-
}
|
|
153
|
-
type Operation = SelectOp | InsertOp | UpdateOp | DeleteOp;
|
|
154
|
-
type MutationOp = InsertOp | UpdateOp | DeleteOp;
|
|
155
|
-
declare const and: (...items: (Condition | undefined)[]) => Condition | undefined;
|
|
156
|
-
declare const or: (...items: Condition[]) => Condition;
|
|
157
|
-
declare const not: (item: Condition) => Condition;
|
|
158
|
-
declare const column: (name: string, op: ColumnOp, value: unknown) => Condition;
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/core/executor.d.ts
|
|
161
|
-
interface ExecuteContext {
|
|
162
|
-
readonly signal?: AbortSignal;
|
|
163
|
-
readonly errorMappers: readonly ErrorMapper[];
|
|
164
|
-
}
|
|
165
|
-
interface ExecuteResult {
|
|
166
|
-
/** Rows keyed by the aliases in the operation's selection. */
|
|
167
|
-
readonly rows: readonly Record<string, unknown>[];
|
|
168
|
-
readonly count: number | null;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Runs IR operations. PostgREST (`postgrestExecutor`) and SQL
|
|
172
|
-
* (`better-supabase/postgres`) are built in; any other backend can implement
|
|
173
|
-
* this interface and prove it with `testExecutor` from `better-supabase/testing`.
|
|
174
|
-
*/
|
|
175
|
-
interface Executor {
|
|
176
|
-
readonly name: string;
|
|
177
|
-
/** Honors `SelectOp.source`. `db.$search` fails on executors without it. */
|
|
178
|
-
readonly functionSources?: boolean;
|
|
179
|
-
execute(op: Operation, context: ExecuteContext): Promise<Result<ExecuteResult>>;
|
|
180
|
-
/** Calls a database function. Optional; `db.$rpc` fails without it. */
|
|
181
|
-
rpc?(name: string, args: Readonly<Record<string, unknown>>, context: RpcContext): Promise<Result<unknown>>;
|
|
182
|
-
/**
|
|
183
|
-
* Runs several reads together, for `db.$many`: one transaction on a SQL
|
|
184
|
-
* connection. Returns one result per operation, in order. Optional;
|
|
185
|
-
* without it `db.$many` runs the operations in parallel.
|
|
186
|
-
*/
|
|
187
|
-
batch?(ops: readonly Operation[], context: ExecuteContext): Promise<readonly Result<ExecuteResult>[]>;
|
|
188
|
-
}
|
|
189
|
-
interface RpcContext extends ExecuteContext {
|
|
190
|
-
readonly schema: string;
|
|
191
|
-
/** The function is `stable`: send it as a GET, so read replicas can serve it. */
|
|
192
|
-
readonly get?: boolean;
|
|
193
|
-
}
|
|
194
|
-
//#endregion
|
|
195
|
-
export { and as C, or as E, UpdateOp as S, not as T, OrderTerm as _, AggregateFn as a, SelectOp as b, Condition as c, FunctionSource as d, Include as f, Operation as g, MutationOp as h, RpcContext as i, CountMode as l, Measure as m, ExecuteResult as n, Aggregation as o, InsertOp as p, Executor as r, ColumnOp as s, ExecuteContext as t, DeleteOp as u, Quantifier as v, column as w, Selection as x, SelectColumn as y };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region src/query/invalidate.ts
|
|
2
|
-
function queryTables(query) {
|
|
3
|
-
const tables = query.meta?.["bsTables"];
|
|
4
|
-
if (Array.isArray(tables)) return tables.filter((t) => typeof t === "string");
|
|
5
|
-
const [prefix, table] = query.queryKey;
|
|
6
|
-
return prefix === "bs" && typeof table === "string" ? [table] : void 0;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Invalidates every query that read one of `tables`: better-supabase queries
|
|
10
|
-
* by their `meta.bsTables`, and other `['bs', table, ...]` keys by prefix.
|
|
11
|
-
*/
|
|
12
|
-
function invalidateTables(client, tables) {
|
|
13
|
-
if (tables.length === 0) return Promise.resolve();
|
|
14
|
-
const changed = new Set(tables);
|
|
15
|
-
return client.invalidateQueries({ predicate: (query) => queryTables(query)?.some((table) => changed.has(table)) ?? false });
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { invalidateTables as t };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/core/permdock-sql.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The part of PermDock's `permissions.catalog.json` the Storage and Realtime
|
|
4
|
-
* builders read: `import catalog from './permissions.catalog.json'`.
|
|
5
|
-
*/
|
|
6
|
-
interface PermdockCatalog {
|
|
7
|
-
readonly permissions: readonly {
|
|
8
|
-
readonly key: string;
|
|
9
|
-
readonly rowConditions?: boolean;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
|
-
/** The keys a bucket or topic PermDock policy names. */
|
|
13
|
-
declare function permdockKeys(policy: {
|
|
14
|
-
readonly permdock: object;
|
|
15
|
-
}): string[];
|
|
16
|
-
//#endregion
|
|
17
|
-
export { permdockKeys as n, PermdockCatalog as t };
|
package/dist/plugin-BqR6wKMB.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/core/plugin.ts
|
|
2
|
-
const PLUGIN_API_VERSION = 1;
|
|
3
|
-
const RANK = {
|
|
4
|
-
pre: 0,
|
|
5
|
-
normal: 1,
|
|
6
|
-
post: 2
|
|
7
|
-
};
|
|
8
|
-
/** Plugins in hook order: `pre`, then unmarked in `use()` order, then `post`. */
|
|
9
|
-
function orderPlugins(plugins) {
|
|
10
|
-
return plugins.map((plugin, index) => ({
|
|
11
|
-
plugin,
|
|
12
|
-
index
|
|
13
|
-
})).sort((a, b) => RANK[a.plugin.enforce ?? "normal"] - RANK[b.plugin.enforce ?? "normal"] || a.index - b.index).map(({ plugin }) => plugin);
|
|
14
|
-
}
|
|
15
|
-
/** Identity helper that fixes `apiVersion` and infers the plugin types. */
|
|
16
|
-
function definePlugin(plugin) {
|
|
17
|
-
return {
|
|
18
|
-
...plugin,
|
|
19
|
-
apiVersion: 1
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { definePlugin as n, orderPlugins as r, PLUGIN_API_VERSION as t };
|