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,10 +1,10 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { t as BetterSupabase, y as Db } from "./define-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { n as AnyFunctions, r as AnyModels } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { t as BetterSupabase, y as Db } from "./define-Bp_BZa5h.js";
|
|
3
|
+
import { l as PublicEnv } from "./index-CLg87OBW.js";
|
|
4
|
+
import { r as BetterQueries } from "./index-DgILJRXj.js";
|
|
5
5
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
6
6
|
//#region src/client/index.d.ts
|
|
7
|
-
interface
|
|
7
|
+
interface ClientOptions {
|
|
8
8
|
/** URL and publishable key. Not needed when `client` is given. */
|
|
9
9
|
readonly env?: PublicEnv;
|
|
10
10
|
/** Bring your own supabase-js client (React Native, custom storage). */
|
|
@@ -34,29 +34,29 @@ type AuthSnapshot = {
|
|
|
34
34
|
readonly user: AuthUser;
|
|
35
35
|
readonly claims: Readonly<Record<string, unknown>>;
|
|
36
36
|
};
|
|
37
|
-
interface
|
|
37
|
+
interface ClientAuth {
|
|
38
38
|
readonly current: () => AuthSnapshot;
|
|
39
39
|
/** `useSyncExternalStore`-compatible. */
|
|
40
40
|
readonly subscribe: (listener: () => void) => () => void;
|
|
41
41
|
}
|
|
42
|
-
interface
|
|
43
|
-
/** The definition the
|
|
44
|
-
readonly
|
|
42
|
+
interface BetterClient<M extends AnyModels, F extends AnyFunctions, E, C = unknown, P = unknown> {
|
|
43
|
+
/** The definition the client was created from (schema metadata, specs, live queries). */
|
|
44
|
+
readonly betterSupabase: 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>;
|
|
48
48
|
/** TanStack Query option factories over `db`. */
|
|
49
|
-
readonly queries:
|
|
50
|
-
readonly auth:
|
|
49
|
+
readonly queries: BetterQueries<M, E, F>;
|
|
50
|
+
readonly auth: ClientAuth;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* The browser side: a supabase-js client, repositories that follow the
|
|
54
54
|
* session, TanStack Query options and an auth store for UI state.
|
|
55
55
|
*
|
|
56
56
|
* ```ts
|
|
57
|
-
* export const
|
|
57
|
+
* export const bs = createClient(betterSupabase, { env: { url, publishableKey } });
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
declare function
|
|
60
|
+
declare function createClient$1<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown, P = unknown>(betterSupabase: BetterSupabase<M, D, F, E, C, P>, options?: ClientOptions): BetterClient<M, F, E, C, P>;
|
|
61
61
|
//#endregion
|
|
62
|
-
export {
|
|
62
|
+
export { ClientOptions as a, ClientAuth as i, AuthUser as n, createClient$1 as o, BetterClient as r, AuthSnapshot as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as Generator } from "./config-
|
|
1
|
+
import { c as ClaimsMeta, j as SchemaMeta } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { d as Generator } from "./config-T_ejwyd3.js";
|
|
3
3
|
//#region src/core/claims.d.ts
|
|
4
4
|
declare const DEFAULT_CLAIMS: ClaimsMeta;
|
|
5
5
|
/** Where the active tenant is read from: the top-level claim, then `app_metadata`. */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as BucketPolicyName, t as AccessBucketPolicy, x as PermdockBucketPolicy } from "./types-Dnf_wRDz.js";
|
|
3
|
+
import { _ as DbError, a as AsyncResult, u as Result } from "./executor-BunPOO-k.js";
|
|
4
|
+
import { g as RequestContext } from "./plugin-o144f322.js";
|
|
5
|
+
import { n as PermdockCatalog } from "./permdock-sql-C2Inc6Xc.js";
|
|
4
6
|
import { n as StoragePath, t as PathIn } from "./path-Cv__-OTj.js";
|
|
5
|
-
import { t as PermdockCatalog } from "./permdock-sql-DImJULY-.js";
|
|
6
7
|
import { n as TemplateValues, t as TemplateParams } from "./template-mbvlysOo.js";
|
|
7
8
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
8
9
|
//#region src/storage/bucket.d.ts
|
|
9
|
-
type BucketPolicy = BucketPolicyName | PermdockBucketPolicy;
|
|
10
|
+
type BucketPolicy = BucketPolicyName | PermdockBucketPolicy | AccessBucketPolicy;
|
|
10
11
|
interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
11
12
|
/** Bucket id, e.g. `customer-logos`. */
|
|
12
13
|
readonly id: Id;
|
|
@@ -15,8 +16,11 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
15
16
|
readonly public?: boolean;
|
|
16
17
|
/**
|
|
17
18
|
* Generated `storage.objects` policies. `tenant` and `owner` match a path
|
|
18
|
-
* segment against the JWT; `public` allows reads
|
|
19
|
-
* the
|
|
19
|
+
* segment against the JWT; `public` allows reads (on a `public: true`
|
|
20
|
+
* bucket the public URLs need no policy, so none is written and nobody can
|
|
21
|
+
* list the objects); `none` leaves access to
|
|
22
|
+
* the secret key; `{ permdock, scope }` calls PermDock's SQL helpers;
|
|
23
|
+
* `{ access }` calls the SQL kit's access contract (`tenant_ids_with`).
|
|
20
24
|
* Defaults to `none`.
|
|
21
25
|
*
|
|
22
26
|
* The helpers check role and scope only. Use `permdock` just for
|
|
@@ -29,13 +33,19 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
29
33
|
readonly policy?: BucketPolicy;
|
|
30
34
|
/**
|
|
31
35
|
* PermDock's `permissions.catalog.json`. With it, a `permdock` policy
|
|
32
|
-
* naming a permission
|
|
36
|
+
* naming a permission without `rowConditions: false` (including one the
|
|
37
|
+
* catalog doesn't list) throws.
|
|
33
38
|
*/
|
|
34
39
|
readonly catalog?: PermdockCatalog;
|
|
35
40
|
/** `'5MiB'`, `'500KB'` or bytes. */
|
|
36
41
|
readonly fileSizeLimit?: string | number;
|
|
37
42
|
/** `['image/png', 'image/*']`. */
|
|
38
43
|
readonly allowedMimeTypes?: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* The tenant segment. Set it and connected clients only touch paths whose
|
|
46
|
+
* `param` holds the caller's tenant: pass `{ context }` or `{ tenant }` to
|
|
47
|
+
* `connect()`, or `{ allTenants: true }` for cross-tenant admin work.
|
|
48
|
+
*/
|
|
39
49
|
readonly tenant?: {
|
|
40
50
|
/** Placeholder holding the tenant id. Defaults to `orgId`. */
|
|
41
51
|
readonly param?: string;
|
|
@@ -145,6 +155,8 @@ interface ActualBucket {
|
|
|
145
155
|
type StorageClient = Pick<SupabaseClient, "storage">;
|
|
146
156
|
interface BucketClient<P extends string, Id extends string = string> {
|
|
147
157
|
readonly bucket: Bucket<P, Id>;
|
|
158
|
+
/** The object path, checked against the template and, with `tenant`, the caller's tenant. */
|
|
159
|
+
path(target: ObjectTarget<P, Id>): Result<StoragePath<Id>>;
|
|
148
160
|
upload(target: ObjectTarget<P, Id>, body: UploadBody, options?: UploadOptions): AsyncResult<{
|
|
149
161
|
path: StoragePath<Id>;
|
|
150
162
|
}>;
|
|
@@ -186,6 +198,8 @@ interface Bucket<P extends string, Id extends string = string> {
|
|
|
186
198
|
* removes the objects it fills.
|
|
187
199
|
*/
|
|
188
200
|
readonly owner: string | undefined;
|
|
201
|
+
/** Placeholder connected clients check against the caller's tenant; set by `tenant`. */
|
|
202
|
+
readonly tenant: string | undefined;
|
|
189
203
|
readonly fileSizeLimit: number | undefined;
|
|
190
204
|
readonly allowedMimeTypes: readonly string[] | undefined;
|
|
191
205
|
path(values: TemplateValues<P>): StoragePath<Id>;
|
|
@@ -202,7 +216,27 @@ interface Bucket<P extends string, Id extends string = string> {
|
|
|
202
216
|
/** A `[storage.buckets.<id>]` section for `supabase/config.toml`. */
|
|
203
217
|
toml(): string;
|
|
204
218
|
drift(actual: ActualBucket | undefined): readonly BucketDrift[];
|
|
205
|
-
connect(client: StorageClient): BucketClient<P, Id>;
|
|
219
|
+
connect(client: StorageClient, options?: BucketConnectOptions): BucketClient<P, Id>;
|
|
220
|
+
}
|
|
221
|
+
interface BucketConnectOptions {
|
|
222
|
+
/**
|
|
223
|
+
* Reuse a signed URL for the same path, `ttl`, `transform` and `download`
|
|
224
|
+
* until shortly before it expires (a tenth of the `ttl`, at most a minute).
|
|
225
|
+
* The cache belongs to this connection; connect once per request so URLs
|
|
226
|
+
* never cross users.
|
|
227
|
+
*/
|
|
228
|
+
readonly cacheSignedUrls?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* The request context (`db.$context`, or what an adapter passes to
|
|
231
|
+
* `connect`). For a bucket with `tenant`, its tenant (`context.tenant`, the
|
|
232
|
+
* one `tenant()` resolved, or the `tenant.claim` claims) must fill the
|
|
233
|
+
* tenant segment of every path.
|
|
234
|
+
*/
|
|
235
|
+
readonly context?: RequestContext;
|
|
236
|
+
/** The tenant every path must hold, instead of reading it from `context`. */
|
|
237
|
+
readonly tenant?: string;
|
|
238
|
+
/** Skip the tenant check, for admin jobs that work across tenants. */
|
|
239
|
+
readonly allTenants?: boolean;
|
|
206
240
|
}
|
|
207
241
|
declare function parseSize(value: string | number): number;
|
|
208
242
|
/** Maps a Storage error (`StorageApiError`, fetch failures) to a `DbError`. */
|
|
@@ -224,4 +258,47 @@ declare function fromStorageError(raw: unknown, table?: string): DbError;
|
|
|
224
258
|
*/
|
|
225
259
|
declare function defineBucket<const P extends string, const Id extends string = string>(config: BucketConfig<P, Id>): Bucket<P, Id>;
|
|
226
260
|
//#endregion
|
|
227
|
-
|
|
261
|
+
//#region src/storage/presets.d.ts
|
|
262
|
+
/** The image types browsers display everywhere. */
|
|
263
|
+
declare const IMAGE_TYPES: readonly string[];
|
|
264
|
+
interface ImageBucketOptions<P extends string, Id extends string> {
|
|
265
|
+
readonly id?: Id;
|
|
266
|
+
/** The path template; keep the preset's placeholders the policy relies on. */
|
|
267
|
+
readonly path?: P;
|
|
268
|
+
/** Defaults to `true`: images load from their public URL without signing. */
|
|
269
|
+
readonly public?: boolean;
|
|
270
|
+
readonly fileSizeLimit?: string | number;
|
|
271
|
+
readonly allowedMimeTypes?: readonly string[];
|
|
272
|
+
/** Replaces the preset's policy. */
|
|
273
|
+
readonly policy?: BucketPolicy;
|
|
274
|
+
}
|
|
275
|
+
type AvatarBucketOptions<P extends string, Id extends string> = ImageBucketOptions<P, Id>;
|
|
276
|
+
interface OrgLogoBucketOptions<P extends string, Id extends string> extends ImageBucketOptions<P, Id> {
|
|
277
|
+
/**
|
|
278
|
+
* The permission that may upload, replace and delete a logo, checked
|
|
279
|
+
* through the access contract. Defaults to `organization.update`, the
|
|
280
|
+
* `organizations` module's update permission.
|
|
281
|
+
*/
|
|
282
|
+
readonly permission?: string;
|
|
283
|
+
/**
|
|
284
|
+
* The tenant segment connected clients are held to. `false` lets one
|
|
285
|
+
* client upload for any organization the policy allows. Defaults to
|
|
286
|
+
* `{ param: 'orgId' }`.
|
|
287
|
+
*/
|
|
288
|
+
readonly tenant?: BucketConfig["tenant"] | false;
|
|
289
|
+
}
|
|
290
|
+
declare const AVATAR_PATH = "{userId}/avatar-{version}.{ext}";
|
|
291
|
+
declare const LOGO_PATH = "{orgId}/logo-{version}.{ext}";
|
|
292
|
+
/**
|
|
293
|
+
* A bucket for profile pictures: `{userId}/avatar-{version}.{ext}`, public,
|
|
294
|
+
* 2 MiB of images, written only by their owner (the `owner` policy).
|
|
295
|
+
*/
|
|
296
|
+
declare function avatarBucket<const P extends string = typeof AVATAR_PATH, const Id extends string = "avatars">(options?: AvatarBucketOptions<P, Id>): Bucket<P, Id>;
|
|
297
|
+
/**
|
|
298
|
+
* A bucket for organization logos: `{orgId}/logo-{version}.{ext}`, public,
|
|
299
|
+
* 2 MiB of images, written by members with the update permission through
|
|
300
|
+
* the access contract (`tenant_ids_with`), so it follows the app's roles.
|
|
301
|
+
*/
|
|
302
|
+
declare function orgLogoBucket<const P extends string = typeof LOGO_PATH, const Id extends string = "organization-logos">(options?: OrgLogoBucketOptions<P, Id>): Bucket<P, Id>;
|
|
303
|
+
//#endregion
|
|
304
|
+
export { parseSize as A, TransformOptions as C, UrlOptions as D, UploadOptions as E, defineBucket as O, TTL as S, UploadBody as T, Reservation as _, avatarBucket as a, SweepOptions as b, Bucket as c, BucketConnectOptions as d, BucketDrift as f, ReplaceResult as g, ReplaceOptions as h, OrgLogoBucketOptions as i, fromStorageError as k, BucketClient as l, ObjectTarget as m, IMAGE_TYPES as n, orgLogoBucket as o, BucketPolicy as p, ImageBucketOptions as r, ActualBucket as s, AvatarBucketOptions as t, BucketConfig as u, StorageClient as v, TtlPreset as w, SweepResult as x, StoredObject as y };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, _ as CursorPage, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, v as CursorPageArgs, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-DUbydmJa.js";
|
|
1
|
+
import { P as TableKey, k as Row, n as AnyFunctions, r as AnyModels } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { I as CountMode, a as AsyncResult, w as ValidationIssue } from "./executor-BunPOO-k.js";
|
|
3
|
+
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, _ as CursorPage, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, v as CursorPageArgs, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-Bp_BZa5h.js";
|
|
5
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
5
|
//#region src/list/list-query.d.ts
|
|
7
6
|
/** Facet value meaning "not set": filters with `is null`. */
|
|
@@ -144,7 +143,7 @@ type ListParsers<S extends string, F extends string> = {
|
|
|
144
143
|
* OpenAPI parameters and a JSON Schema derived from the same definition.
|
|
145
144
|
*
|
|
146
145
|
* ```ts
|
|
147
|
-
* export const customerList = defineListQuery(
|
|
146
|
+
* export const customerList = defineListQuery(betterSupabase, 'customers', {
|
|
148
147
|
* search: ['name', 'kvk'],
|
|
149
148
|
* facets: { status: 'status' },
|
|
150
149
|
* sorts: { name: { name: 'asc' }, newest: [{ createdAt: 'desc' }, { id: 'asc' }] },
|
|
@@ -152,6 +151,6 @@ type ListParsers<S extends string, F extends string> = {
|
|
|
152
151
|
* });
|
|
153
152
|
* ```
|
|
154
153
|
*/
|
|
155
|
-
declare function defineListQuery<M extends AnyModels, D, Fn extends AnyFunctions, E, T extends TableKey<M>, const S extends string, const F extends string = never, const C extends boolean = false, const P extends ListPagination = "offset">(
|
|
154
|
+
declare function defineListQuery<M extends AnyModels, D, Fn extends AnyFunctions, E, T extends TableKey<M>, const S extends string, const F extends string = never, const C extends boolean = false, const P extends ListPagination = "offset">(betterSupabase: BetterSupabase<M, D, Fn, E>, table: T, config: ListQueryConfig<M, T, S, F, C, P>): ListDefinition<M, T, E, S, F, C, P>;
|
|
156
155
|
//#endregion
|
|
157
156
|
export { ListPage as a, ListParsers as c, ListQueryInput as d, ListSearchParams as f, defineListQuery as g, UNSET as h, ListExtra as i, ListQuery as l, ParserSpec as m, FacetInfo as n, ListPagination as o, OpenApiParameter as p, ListDefinition as r, ListParseResult as s, FacetCounts as t, ListQueryConfig as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-DmBlevh-.js";
|
|
1
|
+
import { A as Schema, C as PrimaryKeyColumn, D as RelationTypes, E as RelationMeta, F as TableMeta, I as UniqueConstraint, L as UniqueKeyName, M as Simplify, N as TableFlags, O as Relations, P as TableKey, R as UniqueWhere, S as PermdockTopicPolicy, T as RealtimeTableMeta, _ as Insert, a as BucketPolicyName, b as ModelsOf, c as ClaimsMeta, d as DatabaseOf, f as Flags, g as FunctionsOf, h as FunctionTypes, i as BucketMeta, j as SchemaMeta, k as Row, l as Codec, m as FunctionMeta, n as AnyFunctions, o as Casing, p as ForeignKeyConstraint, r as AnyModels, s as CheckConstraint, t as AccessBucketPolicy, u as ColumnMeta, v as ModelFlags, w as PrimaryKeyValue, x as PermdockBucketPolicy, y as ModelTypes, z as Update } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { $ as or, A as mapDbError, B as InsertOp, C as RawDbError, D as isConflict, E as isCheck, F as Condition, G as Quantifier, H as MutationOp, I as CountMode, J as Selection, K as SelectColumn, L as DeleteOp, M as AggregateFn, N as Aggregation, O as isDbError, P as ColumnOp, Q as not, R as FunctionSource, S as ErrorMapper, T as dbError, U as Operation, V as Measure, W as OrderTerm, X as and, Y as UpdateOp, Z as column, _ as DbError, a as AsyncResult, b as DbErrorOf, c as Err, f as err, g as toDbError, h as toBetterResult, i as RpcContext, j as statusOf, k as isForeignKey, l as Ok, m as ok, n as ExecuteResult, o as BetterResultApi, p as fromBetterResult, q as SelectOp, r as Executor, s as BetterResultValue, t as ExecuteContext, u as Result, v as DbErrorKind, w as ValidationIssue, x as DbException, y as DbErrorKinds, z as Include } from "./executor-BunPOO-k.js";
|
|
3
|
+
import { D as consoleLogger, E as Logger, O as silentLogger, T as LogFields, _ as KitEventType, a as EventHub, c as QueryEvent, i as EventHandler, l as RefreshEvent, m as KitEventMap, n as BetterSupabaseEvents, o as EventName, p as KitEvent, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-aIO7vsIk.js";
|
|
4
|
+
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 SupabaseOptions, 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 RpcDefinition, 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-Bp_BZa5h.js";
|
|
5
|
+
import { _ as WithExtension, a as ExtensionOf, c as MutationEvent, d as NoExtension, f as PLUGIN_API_VERSION, g as RequestContext, h as RepositoryExtension, i as CallOptions, l as MutationIntent, m as RepositoryApi, n as AnyPlugin, o as HasFlag, p as Plugin, r as ApplyExtension, s as HookArgs, t as Actor, u as MutationKind, v as definePlugin } from "./plugin-o144f322.js";
|
|
6
|
+
import { n as validate, t as StandardSchemaV1 } from "./standard-J4YgMOLm.js";
|
|
7
|
+
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-CruYKAvV.js";
|
|
9
8
|
import { n as StoragePath } from "./path-Cv__-OTj.js";
|
|
10
|
-
import { n as postgrestCompiler, t as Compiler } from "./compiler-
|
|
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-
|
|
9
|
+
import { n as postgrestCompiler, t as Compiler } from "./compiler-BXH_aZ7N.js";
|
|
10
|
+
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-Blxe8S31.js";
|
|
12
11
|
import { t as SPEC_PINS } from "./spec-pins-CqorWDnO.js";
|
|
13
12
|
//#region src/core/define-repository.d.ts
|
|
14
13
|
/** Adds `Methods` to the repository of `Table` only. */
|
|
@@ -20,14 +19,14 @@ interface TableRepositoryExtension<Table extends string, Methods> extends Reposi
|
|
|
20
19
|
* repository at call time, with every other plugin's methods.
|
|
21
20
|
*
|
|
22
21
|
* ```ts
|
|
23
|
-
* const customers = defineRepository(
|
|
22
|
+
* const customers = defineRepository(betterSupabase, 'customers', (base) => ({
|
|
24
23
|
* active: () => base.findMany({ where: { status: 'active' } }),
|
|
25
24
|
* }));
|
|
26
|
-
* export const app =
|
|
25
|
+
* export const app = betterSupabase.use(customers);
|
|
27
26
|
* await app.connect(client).customers.active();
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
|
-
export declare function defineRepository<M extends AnyModels, D, F extends AnyFunctions, E, const Table extends TableKey<M>, Methods extends object>(
|
|
29
|
+
export declare function defineRepository<M extends AnyModels, D, F extends AnyFunctions, E, const Table extends TableKey<M>, Methods extends object>(betterSupabase: BetterSupabase<M, D, F, E>, table: Table, build: (base: RepositoryOf<M, Table, E>) => Methods): Plugin<`repository:${Table}`, TableRepositoryExtension<Table, Methods>>;
|
|
31
30
|
//#endregion
|
|
32
31
|
//#region src/ir/tables.d.ts
|
|
33
32
|
/**
|
|
@@ -41,7 +40,23 @@ export declare function touchedTables(op: Operation): string[];
|
|
|
41
40
|
* plus every table whose foreign key cascades or sets a value on delete,
|
|
42
41
|
* followed through chains of cascades.
|
|
43
42
|
*/
|
|
44
|
-
export declare function invalidationTargets(meta: SchemaMeta, table: string): string[];
|
|
43
|
+
export declare function invalidationTargets(meta: SchemaMeta, table: string): readonly string[];
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/core/policy.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* A callback that decides something a kit would otherwise allow or refuse
|
|
48
|
+
* by default: `authorize`, `canInvite`, `shouldDeliver`, `allowUrl`. Only
|
|
49
|
+
* `true` allows; `false`, any other value, a throw or a rejection denies.
|
|
50
|
+
*/
|
|
51
|
+
type Policy<A extends readonly unknown[]> = (...args: A) => boolean | PromiseLike<boolean>;
|
|
52
|
+
type PolicyDecision = {
|
|
53
|
+
readonly allowed: true;
|
|
54
|
+
} | {
|
|
55
|
+
readonly allowed: false;
|
|
56
|
+
/** `denied`: the policy returned something other than `true`. `threw`: it threw or rejected. */
|
|
57
|
+
readonly reason: "denied" | "threw";
|
|
58
|
+
readonly cause?: unknown;
|
|
59
|
+
};
|
|
45
60
|
//#endregion
|
|
46
61
|
//#region src/core/cursor.d.ts
|
|
47
62
|
/** Opaque, URL-safe keyset cursor. */
|
|
@@ -71,10 +86,12 @@ type EnrichDatabase<D, O> = { [S in keyof D]: S extends keyof O ? EnrichSchema<D
|
|
|
71
86
|
export declare function escapeLike(value: string): string;
|
|
72
87
|
//#endregion
|
|
73
88
|
//#region src/ir/codec.d.ts
|
|
89
|
+
/** Applies column codecs to returned rows, including embedded relations. */
|
|
90
|
+
export declare function decodeRows(selection: Selection | undefined, rows: readonly Record<string, unknown>[], checked?: boolean): Record<string, unknown>[];
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/ir/wire.d.ts
|
|
74
93
|
/** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
|
|
75
94
|
export declare function encodeValue(value: unknown): unknown;
|
|
76
|
-
/** Applies column codecs to returned rows, including embedded relations. */
|
|
77
|
-
export declare function decodeRows(selection: Selection | undefined, rows: readonly Record<string, unknown>[]): Record<string, unknown>[];
|
|
78
95
|
//#endregion
|
|
79
96
|
//#region src/ir/scope.d.ts
|
|
80
97
|
/** Returns the filter that always applies to rows of `table`, if any. */
|
|
@@ -107,4 +124,4 @@ export declare function toCamel(name: string): string;
|
|
|
107
124
|
/** `firstName` to `first_name`. */
|
|
108
125
|
export declare function toSnake(name: string): string;
|
|
109
126
|
//#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 BetterResultValue, 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
|
|
127
|
+
export { type AccessBucketPolicy, 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 BetterResultValue, 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 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 ForeignKeyConstraint, type FunctionMeta, type FunctionSource, type FunctionTypes, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type KitEvent, type KitEventMap, type KitEventType, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelFlags, type ModelTypes, type ModelsOf, type MutationEvent, type MutationIntent, 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 Policy, type PolicyDecision, 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 RelationTypes, 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 SupabaseOptions, 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
|
-
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-
|
|
2
|
-
import { i as escapeLike,
|
|
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-DtwXa6b8.js";
|
|
2
|
+
import { i as escapeLike, o as defineSchema, s as tableMeta, t as simplify } from "./simplify-_0oUKqCd.js";
|
|
3
3
|
import { i as or, n as column, r as not, t as and } from "./types-6cYK9pbJ.js";
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as
|
|
4
|
+
import { r as encodeValue } from "./wire-D2dT86vi.js";
|
|
5
|
+
import { a as toBetterResult, i as ok, n as err, o as toDbError, r as fromBetterResult, t as AsyncResult } from "./result-BKiliPY7.js";
|
|
6
|
+
import { a as decodeRows, c as memoryCache, i as encodeCursor, l as rowKey, n as defineSupabase, o as EventHub, r as decodeCursor, s as cacheTargetOf, t as BetterSupabase, u as rpcCacheTargets } from "./define-cNKzqwL_.js";
|
|
7
|
+
import { n as touchedTables, t as invalidationTargets } from "./tables-Cb-3_VWc.js";
|
|
7
8
|
import { n as silentLogger, t as consoleLogger } from "./logger-glM28NVN.js";
|
|
8
|
-
import {
|
|
9
|
-
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-
|
|
10
|
-
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-
|
|
11
|
-
import { t as validate } from "./standard-
|
|
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-
|
|
9
|
+
import { r as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-DwARMuQp.js";
|
|
10
|
+
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-Bqob3WqT.js";
|
|
11
|
+
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-DQFt1N_Y.js";
|
|
12
|
+
import { t as validate } from "./standard-D7r6dMUu.js";
|
|
13
|
+
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-BW1KhzSG.js";
|
|
13
14
|
import { t as SPEC_PINS } from "./spec-pins-C3oc-Tdp.js";
|
|
14
15
|
import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from "./scope-CDHcS7dE.js";
|
|
15
16
|
//#region src/core/define-repository.ts
|
|
@@ -18,15 +19,15 @@ import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from ".
|
|
|
18
19
|
* repository at call time, with every other plugin's methods.
|
|
19
20
|
*
|
|
20
21
|
* ```ts
|
|
21
|
-
* const customers = defineRepository(
|
|
22
|
+
* const customers = defineRepository(betterSupabase, 'customers', (base) => ({
|
|
22
23
|
* active: () => base.findMany({ where: { status: 'active' } }),
|
|
23
24
|
* }));
|
|
24
|
-
* export const app =
|
|
25
|
+
* export const app = betterSupabase.use(customers);
|
|
25
26
|
* await app.connect(client).customers.active();
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
|
-
function defineRepository(
|
|
29
|
-
if (!(table in
|
|
29
|
+
function defineRepository(betterSupabase, table, build) {
|
|
30
|
+
if (!(table in betterSupabase.meta.tables)) throw new TypeError(`better-supabase: defineRepository: unknown table "${table}"`);
|
|
30
31
|
return definePlugin({
|
|
31
32
|
name: `repository:${table}`,
|
|
32
33
|
repository: ({ table: meta, base }) => meta.key === table ? build(base) : void 0
|