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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { t as KitTransport } from "./kit-transport-B82k1djG.js";
|
|
3
|
+
//#region src/webhooks/url-policy.d.ts
|
|
4
|
+
/** Decides whether a webhook may be sent to `url`. Rejecting counts as `false`. */
|
|
5
|
+
type AllowUrl = (url: URL) => boolean | Promise<boolean>;
|
|
6
|
+
/** The addresses a host name resolves to. */
|
|
7
|
+
type ResolveHost = (hostname: string) => Promise<readonly string[]>;
|
|
8
|
+
interface PublicUrlOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Resolves host names so each address can be checked. Defaults to
|
|
11
|
+
* `node:dns` where the runtime has it (Node, Bun, Deno); pass one on other
|
|
12
|
+
* runtimes, or `false` to check only the URL.
|
|
13
|
+
*/
|
|
14
|
+
readonly resolve?: ResolveHost | false;
|
|
15
|
+
/** Allow `http:` URLs, e.g. for local development. */
|
|
16
|
+
readonly allowHttp?: boolean;
|
|
17
|
+
/** Host names that skip every check, e.g. an internal receiver you trust. */
|
|
18
|
+
readonly allowHosts?: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Whether an IP address is reachable on the public internet: not loopback,
|
|
22
|
+
* private, link-local (cloud metadata), carrier-grade NAT, multicast or
|
|
23
|
+
* reserved. Returns `false` for anything that isn't an IP address.
|
|
24
|
+
*/
|
|
25
|
+
declare function isPublicAddress(address: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The default `allowUrl`: HTTPS only, no credentials in the URL, no local
|
|
28
|
+
* host names, and every address the host resolves to must be public. The
|
|
29
|
+
* delivery transport calls it again for each redirect.
|
|
30
|
+
*
|
|
31
|
+
* DNS can change between this check and the connection. Route webhooks
|
|
32
|
+
* through an egress proxy when that matters.
|
|
33
|
+
*/
|
|
34
|
+
declare function publicUrl(options?: PublicUrlOptions): AllowUrl;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/webhooks/http.d.ts
|
|
37
|
+
interface WebhookRequest {
|
|
38
|
+
readonly url: string;
|
|
39
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
40
|
+
readonly body: string;
|
|
41
|
+
readonly signal?: AbortSignal;
|
|
42
|
+
}
|
|
43
|
+
interface WebhookResponse {
|
|
44
|
+
readonly status: number;
|
|
45
|
+
readonly body: string;
|
|
46
|
+
/** Seconds from the `Retry-After` header, when the receiver sent one. */
|
|
47
|
+
readonly retryAfter?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sends one signed webhook request. Throw `WebhookPolicyError` when the
|
|
51
|
+
* request must never be retried (a blocked URL); any other error retries.
|
|
52
|
+
*/
|
|
53
|
+
interface WebhookTransport {
|
|
54
|
+
readonly apiVersion: 1;
|
|
55
|
+
readonly name: string;
|
|
56
|
+
send(request: WebhookRequest): Promise<WebhookResponse>;
|
|
57
|
+
}
|
|
58
|
+
/** A delivery that must not be retried, e.g. a URL `allowUrl` rejected. */
|
|
59
|
+
declare class WebhookPolicyError extends Error {
|
|
60
|
+
override readonly name = "WebhookPolicyError";
|
|
61
|
+
}
|
|
62
|
+
interface FetchTransportOptions {
|
|
63
|
+
readonly fetch?: typeof fetch;
|
|
64
|
+
/** Checked before the first request and before each redirect. */
|
|
65
|
+
readonly allowUrl?: AllowUrl;
|
|
66
|
+
/**
|
|
67
|
+
* Defaults to 0: a redirect fails the delivery without a retry. Each hop
|
|
68
|
+
* you allow is checked with `allowUrl` first.
|
|
69
|
+
*/
|
|
70
|
+
readonly maxRedirects?: number;
|
|
71
|
+
/** Per request. Defaults to 10 seconds. */
|
|
72
|
+
readonly timeoutMs?: number;
|
|
73
|
+
/** The response body bytes kept; the rest is not read. Defaults to 64 KiB. */
|
|
74
|
+
readonly maxResponseBytes?: number;
|
|
75
|
+
}
|
|
76
|
+
/** Sends webhooks with `fetch`, following redirects only to allowed URLs. */
|
|
77
|
+
declare function fetchTransport(options?: FetchTransportOptions): WebhookTransport;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/webhooks/secrets.d.ts
|
|
80
|
+
interface RotateSecretOptions {
|
|
81
|
+
/** How long older secrets keep signing, e.g. `'24 hours'` (the default). */
|
|
82
|
+
readonly overlap?: string;
|
|
83
|
+
/** Use this secret instead of a generated one, e.g. when migrating. */
|
|
84
|
+
readonly secret?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Where endpoint signing secrets live. `sqlSecretStore` (Vault or a
|
|
88
|
+
* column, set in `kits.webhooks-out.options.secretStorage`) is the default;
|
|
89
|
+
* implement it for a KMS or a secrets manager.
|
|
90
|
+
*/
|
|
91
|
+
interface WebhookSecretStore {
|
|
92
|
+
readonly apiVersion: 1;
|
|
93
|
+
/** The live secrets of an endpoint, newest first. */
|
|
94
|
+
secrets(endpointId: string): Promise<readonly string[]>;
|
|
95
|
+
/** Creates a new secret and returns it once. */
|
|
96
|
+
rotate?(endpointId: string, options?: RotateSecretOptions): Promise<string>;
|
|
97
|
+
}
|
|
98
|
+
/** The kit's `webhook_secrets` and `rotate_webhook_secret` functions. */
|
|
99
|
+
declare function sqlSecretStore(transport: KitTransport, options?: {
|
|
100
|
+
readonly schema?: string;
|
|
101
|
+
}): WebhookSecretStore;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/webhooks/signers.d.ts
|
|
104
|
+
interface WebhookSignInput {
|
|
105
|
+
/** The delivery id, the same on every retry so receivers can deduplicate. */
|
|
106
|
+
readonly id: string;
|
|
107
|
+
readonly body: string;
|
|
108
|
+
readonly timestamp: Temporal.Instant;
|
|
109
|
+
/** The endpoint's live secrets, newest first. Sign with each while rotating. */
|
|
110
|
+
readonly secrets: readonly string[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds the signature headers to an outgoing webhook. `standardWebhooks()`
|
|
114
|
+
* is the default; `hmacSigner()` covers custom header and payload formats.
|
|
115
|
+
*/
|
|
116
|
+
interface WebhookSigner {
|
|
117
|
+
readonly apiVersion: 1;
|
|
118
|
+
readonly name: string;
|
|
119
|
+
sign(input: WebhookSignInput): Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
|
|
120
|
+
}
|
|
121
|
+
interface StandardWebhooksOptions {
|
|
122
|
+
/** Header names, for receivers that expect a prefix such as `svix-`. */
|
|
123
|
+
readonly headers?: {
|
|
124
|
+
readonly id?: string;
|
|
125
|
+
readonly timestamp?: string;
|
|
126
|
+
readonly signature?: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Signs with the [Standard Webhooks](https://www.standardwebhooks.com/)
|
|
131
|
+
* scheme: `webhook-id`, `webhook-timestamp` and one `v1,` signature per
|
|
132
|
+
* secret in `webhook-signature`. `verifyWebhook` checks it.
|
|
133
|
+
*/
|
|
134
|
+
declare function standardWebhooks(options?: StandardWebhooksOptions): WebhookSigner;
|
|
135
|
+
interface HmacSignerOptions {
|
|
136
|
+
readonly name?: string;
|
|
137
|
+
/** e.g. `x-acme-signature`. */
|
|
138
|
+
readonly signatureHeader: string;
|
|
139
|
+
/** Sends the epoch-seconds timestamp in this header. */
|
|
140
|
+
readonly timestampHeader?: string;
|
|
141
|
+
/** Sends the delivery id in this header. */
|
|
142
|
+
readonly idHeader?: string;
|
|
143
|
+
/** The signed text. Defaults to `${timestamp}.${body}`. */
|
|
144
|
+
readonly content?: (input: {
|
|
145
|
+
readonly id: string;
|
|
146
|
+
readonly timestamp: string;
|
|
147
|
+
readonly body: string;
|
|
148
|
+
}) => string;
|
|
149
|
+
/** Defaults to `hex`. */
|
|
150
|
+
readonly encoding?: "hex" | "base64";
|
|
151
|
+
/** Written before each signature. Defaults to `v1=`. */
|
|
152
|
+
readonly prefix?: string;
|
|
153
|
+
/** Joins the signatures of several secrets. Defaults to `,`. */
|
|
154
|
+
readonly separator?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* HMAC-SHA256 with the secret's UTF-8 bytes as the key, for receivers that
|
|
158
|
+
* verify an existing format, e.g. `v1=<hex>` over `timestamp.body`.
|
|
159
|
+
*/
|
|
160
|
+
declare function hmacSigner(options: HmacSignerOptions): WebhookSigner;
|
|
161
|
+
//#endregion
|
|
162
|
+
export { PublicUrlOptions as _, hmacSigner as a, publicUrl as b, WebhookSecretStore as c, WebhookPolicyError as d, WebhookRequest as f, AllowUrl as g, fetchTransport as h, WebhookSigner as i, sqlSecretStore as l, WebhookTransport as m, StandardWebhooksOptions as n, standardWebhooks as o, WebhookResponse as p, WebhookSignInput as r, RotateSecretOptions as s, HmacSignerOptions as t, FetchTransportOptions as u, ResolveHost as v, isPublicAddress as y };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { n as isPlainObject } from "./clone-BfgmLU90.js";
|
|
2
|
+
import { n as dbError, t as DbException } from "./errors-DtwXa6b8.js";
|
|
3
|
+
import { t as lookupOf } from "./lookup-BaP5bI27.js";
|
|
4
4
|
import { i as or, r as not, t as and } from "./types-6cYK9pbJ.js";
|
|
5
|
+
import { r as encodeValue } from "./wire-D2dT86vi.js";
|
|
5
6
|
//#region src/schema/define.ts
|
|
6
7
|
/**
|
|
7
8
|
* Binds generated model types to runtime metadata. Called from the generated
|
|
@@ -28,90 +29,6 @@ function relationMeta(meta, table, relation) {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
//#endregion
|
|
31
|
-
//#region src/ir/codec.ts
|
|
32
|
-
/** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
|
|
33
|
-
function encodeValue(value) {
|
|
34
|
-
if (typeof value === "bigint") return value.toString();
|
|
35
|
-
const text = temporalText(value);
|
|
36
|
-
if (text !== void 0) return text;
|
|
37
|
-
if (Array.isArray(value)) return value.map(encodeValue);
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
function decodeScalar(codec, value) {
|
|
41
|
-
if (value === null || value === void 0) return value;
|
|
42
|
-
switch (codec) {
|
|
43
|
-
case "instant": return temporal().Instant.from(String(value));
|
|
44
|
-
case "plainDateTime": return temporal().PlainDateTime.from(String(value));
|
|
45
|
-
case "bigint": return BigInt(value);
|
|
46
|
-
case "string": return String(value);
|
|
47
|
-
default: return codec;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function decode(codec, value) {
|
|
51
|
-
return Array.isArray(value) ? value.map((item) => decodeScalar(codec, item)) : decodeScalar(codec, value);
|
|
52
|
-
}
|
|
53
|
-
/** Whether decoding `selection` changes anything, so plain reads skip the walk. */
|
|
54
|
-
function needsDecoding(selection) {
|
|
55
|
-
return selection.aggregate !== void 0 || selection.columns.some((column) => column.codec !== void 0) || selection.includes.some((include) => include.count !== void 0 || include.aggregate !== void 0 || needsDecoding(include.selection));
|
|
56
|
-
}
|
|
57
|
-
/** PostgREST returns `[{ count }]` for a `(count)` embed; SQL returns the number. */
|
|
58
|
-
function countOf(value) {
|
|
59
|
-
if (Array.isArray(value)) {
|
|
60
|
-
const first = value[0];
|
|
61
|
-
return Number(first?.count ?? 0);
|
|
62
|
-
}
|
|
63
|
-
return Number(value ?? 0);
|
|
64
|
-
}
|
|
65
|
-
function measureOf(measure, value) {
|
|
66
|
-
if (value === void 0 || value === null) return null;
|
|
67
|
-
return measure.codec ? decodeScalar(measure.codec, value) : value;
|
|
68
|
-
}
|
|
69
|
-
/** Adds `value` under `row[key][name]`, next to what is already there. */
|
|
70
|
-
function fold(row, key, name, value) {
|
|
71
|
-
row[key] = {
|
|
72
|
-
...row[key] ?? {},
|
|
73
|
-
[name]: value
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function decodeRow(selection, row) {
|
|
77
|
-
const out = { ...row };
|
|
78
|
-
for (const column of selection.columns) if (column.codec && column.alias in out) out[column.alias] = decode(column.codec, out[column.alias]);
|
|
79
|
-
if (selection.aggregate) {
|
|
80
|
-
if (selection.aggregate.count) out["_count"] = countOf(out["_count"]);
|
|
81
|
-
for (const measure of selection.aggregate.measures) {
|
|
82
|
-
const value = out[measure.key];
|
|
83
|
-
delete out[measure.key];
|
|
84
|
-
fold(out, `_${measure.fn}`, measure.alias, measureOf(measure, value));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
for (const include of selection.includes) {
|
|
88
|
-
const value = out[include.alias];
|
|
89
|
-
if (include.count !== void 0) {
|
|
90
|
-
if (!(include.alias in out)) continue;
|
|
91
|
-
delete out[include.alias];
|
|
92
|
-
fold(out, "_count", include.count, countOf(value));
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (include.aggregate !== void 0) {
|
|
96
|
-
if (!(include.alias in out)) continue;
|
|
97
|
-
delete out[include.alias];
|
|
98
|
-
const inner = Array.isArray(value) ? value[0] : value;
|
|
99
|
-
const measures = {};
|
|
100
|
-
for (const measure of include.selection.aggregate?.measures ?? []) measures[measure.alias] = measureOf(measure, inner?.[measure.key]);
|
|
101
|
-
fold(out, `_${include.aggregate.fn}`, include.aggregate.name, measures);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (Array.isArray(value)) out[include.alias] = value.map((item) => decodeRow(include.selection, item));
|
|
105
|
-
else if (value && typeof value === "object") out[include.alias] = decodeRow(include.selection, value);
|
|
106
|
-
}
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
/** Applies column codecs to returned rows, including embedded relations. */
|
|
110
|
-
function decodeRows(selection, rows) {
|
|
111
|
-
if (!selection || !needsDecoding(selection)) return rows;
|
|
112
|
-
return rows.map((row) => decodeRow(selection, row));
|
|
113
|
-
}
|
|
114
|
-
//#endregion
|
|
115
32
|
//#region src/ir/build.ts
|
|
116
33
|
const AGGREGATE_KEYS = {
|
|
117
34
|
_sum: "sum",
|
|
@@ -158,11 +75,6 @@ const FIELD_OPS = /* @__PURE__ */ new Set([
|
|
|
158
75
|
"has",
|
|
159
76
|
"containedBy"
|
|
160
77
|
]);
|
|
161
|
-
function isPlainObject(value) {
|
|
162
|
-
if (typeof value !== "object" || value === null) return false;
|
|
163
|
-
const proto = Object.getPrototypeOf(value);
|
|
164
|
-
return proto === Object.prototype || proto === null;
|
|
165
|
-
}
|
|
166
78
|
function isOpsObject(value) {
|
|
167
79
|
if (!isPlainObject(value)) return false;
|
|
168
80
|
const keys = Object.keys(value);
|
|
@@ -176,8 +88,20 @@ function writable(meta, mode) {
|
|
|
176
88
|
function escapeLike(value) {
|
|
177
89
|
return value.replaceAll(/[\\%_]/g, (char) => `\\${char}`);
|
|
178
90
|
}
|
|
91
|
+
const builders = /* @__PURE__ */ new WeakMap();
|
|
92
|
+
/** The shared builder for a schema; a builder holds no per-call state. */
|
|
93
|
+
function builderFor(meta) {
|
|
94
|
+
let builder = builders.get(meta);
|
|
95
|
+
if (!builder) {
|
|
96
|
+
builder = new IrBuilder(meta);
|
|
97
|
+
builders.set(meta, builder);
|
|
98
|
+
}
|
|
99
|
+
return builder;
|
|
100
|
+
}
|
|
179
101
|
var IrBuilder = class {
|
|
180
102
|
meta;
|
|
103
|
+
/** Every column of a table, the selection of reads without `select`. */
|
|
104
|
+
#allColumns = /* @__PURE__ */ new WeakMap();
|
|
181
105
|
constructor(meta) {
|
|
182
106
|
this.meta = meta;
|
|
183
107
|
}
|
|
@@ -323,7 +247,7 @@ var IrBuilder = class {
|
|
|
323
247
|
}
|
|
324
248
|
}
|
|
325
249
|
selection(table, select, include) {
|
|
326
|
-
const columns =
|
|
250
|
+
const columns = select?.map((alias) => this.selectColumn(table, alias)) ?? this.allColumns(table);
|
|
327
251
|
const includes = [];
|
|
328
252
|
if (include !== void 0) {
|
|
329
253
|
if (!isPlainObject(include)) invalidRequest(`"include" on "${table.key}" must be an object`, table.key);
|
|
@@ -424,6 +348,14 @@ var IrBuilder = class {
|
|
|
424
348
|
codec
|
|
425
349
|
};
|
|
426
350
|
}
|
|
351
|
+
allColumns(table) {
|
|
352
|
+
let columns = this.#allColumns.get(table);
|
|
353
|
+
if (!columns) {
|
|
354
|
+
columns = Object.keys(table.columns).map((alias) => this.selectColumn(table, alias));
|
|
355
|
+
this.#allColumns.set(table, columns);
|
|
356
|
+
}
|
|
357
|
+
return columns;
|
|
358
|
+
}
|
|
427
359
|
/** A selected column, with the cast and codec its metadata asks for. */
|
|
428
360
|
selectColumn(table, alias) {
|
|
429
361
|
const column = this.column(table, alias);
|
|
@@ -531,7 +463,7 @@ var IrBuilder = class {
|
|
|
531
463
|
uniqueKey(table, input) {
|
|
532
464
|
if (!isPlainObject(input)) invalidRequest(`"where" on "${table.key}" must be an object`, table.key);
|
|
533
465
|
const given = Object.keys(input).filter((key) => input[key] !== void 0);
|
|
534
|
-
const keys =
|
|
466
|
+
const { keys } = lookupOf(table);
|
|
535
467
|
const match = keys.find((key) => key.length > 0 && key.length === given.length && key.every((column) => given.includes(column)));
|
|
536
468
|
if (!match) {
|
|
537
469
|
const names = keys.filter((key) => key.length > 0).map((key) => `{ ${key.join(", ")} }`).join(", ");
|
|
@@ -656,4 +588,4 @@ function simplifyOrFalse(condition) {
|
|
|
656
588
|
};
|
|
657
589
|
}
|
|
658
590
|
//#endregion
|
|
659
|
-
export { invalidRequest as a,
|
|
591
|
+
export { invalidRequest as a, escapeLike as i, simplifyOrFalse as n, defineSchema as o, builderFor as r, tableMeta as s, simplify as t };
|
package/dist/sql/index.d.ts
CHANGED
|
@@ -1,8 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as ReadSet } from "../define-
|
|
3
|
-
import { b as ResolvedConfig } from "../config-
|
|
4
|
-
import {
|
|
1
|
+
import { c as ClaimsMeta } from "../types-Dnf_wRDz.js";
|
|
2
|
+
import { B as ReadSet } from "../define-Bp_BZa5h.js";
|
|
3
|
+
import { b as ResolvedConfig, ct as KitsConfig, lt as ResolvedKitModule, ot as KitMode } from "../config-T_ejwyd3.js";
|
|
4
|
+
import { a as permdockKeys, i as permdockKeyStatus, n as PermdockCatalog, r as PermdockKeyStatus, t as PERMDOCK_SCHEMA } from "../permdock-sql-C2Inc6Xc.js";
|
|
5
|
+
//#region src/sql/context.d.ts
|
|
6
|
+
/** The scope id types kit modules render. */
|
|
7
|
+
export declare const KIT_ID_TYPES: readonly ["uuid", "text", "bigint", "integer"];
|
|
8
|
+
type KitIdType = (typeof KIT_ID_TYPES)[number];
|
|
9
|
+
export declare const isKitIdType: (value: string) => value is KitIdType;
|
|
10
|
+
/**
|
|
11
|
+
* A Postgres type name as one of `KIT_ID_TYPES`: case and spacing are
|
|
12
|
+
* normalised and aliases such as `int8` resolved. `undefined` for any other
|
|
13
|
+
* type, so callers refuse it instead of guessing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function kitIdType(value: string): KitIdType | undefined;
|
|
16
|
+
/** One logical table of a module: its default name and logical columns. */
|
|
17
|
+
interface KitTableSpec {
|
|
18
|
+
/** Default name, in the module's schema. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Logical column to default column name. */
|
|
21
|
+
readonly columns: Readonly<Record<string, string>>;
|
|
22
|
+
/**
|
|
23
|
+
* Logical columns an adopted table may lack (mapped to `null`): the module
|
|
24
|
+
* leaves out the feature that needs them.
|
|
25
|
+
*/
|
|
26
|
+
readonly optional?: readonly string[];
|
|
27
|
+
/** The app may lack the whole table (`kits.<name>.tables.<table>: null`). */
|
|
28
|
+
readonly optionalTable?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface KitNames {
|
|
31
|
+
readonly tables: Readonly<Record<string, KitTableSpec>>;
|
|
32
|
+
/** The `before_*` and `after_*` hooks the module calls, so `kits.<name>.hooks.functions` is checked. */
|
|
33
|
+
readonly hooks?: readonly string[];
|
|
34
|
+
/** The `kits.<name>.options` keys the module reads; any other key is rejected. */
|
|
35
|
+
readonly options?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/** An event a module writes to the outbox, as SQL expressions. */
|
|
38
|
+
interface KitEmit {
|
|
39
|
+
/** The event type, e.g. `org.created`. */
|
|
40
|
+
readonly type: string;
|
|
41
|
+
/** A `jsonb` expression. */
|
|
42
|
+
readonly payload: string;
|
|
43
|
+
/** A `text` expression, e.g. `'organizations/' || new_org`. */
|
|
44
|
+
readonly subject?: string;
|
|
45
|
+
/** The tenant id expression; it is cast to text. */
|
|
46
|
+
readonly tenant?: string;
|
|
47
|
+
/** A `text` idempotency key expression. */
|
|
48
|
+
readonly key?: string;
|
|
49
|
+
}
|
|
50
|
+
/** A function of a module's contract: what other modules and the TypeScript side call. */
|
|
51
|
+
interface KitContractFunction {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
/** Argument types; `{id}` stands for the module's id type. */
|
|
54
|
+
readonly args: readonly string[];
|
|
55
|
+
readonly returns: string;
|
|
56
|
+
}
|
|
57
|
+
/** What a module's `build` reads: resolved names for one layout. */
|
|
58
|
+
interface KitContext {
|
|
59
|
+
readonly module: string;
|
|
60
|
+
readonly mode: KitMode;
|
|
61
|
+
readonly config: ResolvedKitModule;
|
|
62
|
+
/** The quoted schema of the module's functions and managed tables. */
|
|
63
|
+
readonly schema: string;
|
|
64
|
+
readonly schemaName: string;
|
|
65
|
+
readonly idType: KitIdType;
|
|
66
|
+
readonly claims: ClaimsMeta;
|
|
67
|
+
readonly kits: KitsConfig;
|
|
68
|
+
/** `schema.name` of a module function, quoted. */
|
|
69
|
+
fn(name: string): string;
|
|
70
|
+
/** `schema.table` of a logical table, quoted. */
|
|
71
|
+
table(logical: string): string;
|
|
72
|
+
/** The unquoted schema and name of a logical table. */
|
|
73
|
+
tableName(logical: string): {
|
|
74
|
+
readonly schema: string;
|
|
75
|
+
readonly name: string;
|
|
76
|
+
};
|
|
77
|
+
/** A logical column, quoted. Throws when an adopted table lacks it. */
|
|
78
|
+
col(table: string, column: string): string;
|
|
79
|
+
/** Whether a logical column exists (adopted tables can map it to `null`). */
|
|
80
|
+
has(table: string, column: string): boolean;
|
|
81
|
+
/** Whether an optional logical table exists (it can be mapped to `null`). */
|
|
82
|
+
hasTable(table: string): boolean;
|
|
83
|
+
/** Whether the module owns `table` (managed mode). */
|
|
84
|
+
readonly manages: boolean;
|
|
85
|
+
/** The permission key for a kit action, as a SQL literal. */
|
|
86
|
+
permission(action: string, fallback: string): string;
|
|
87
|
+
/** The permission key for a kit action. */
|
|
88
|
+
permissionKey(action: string, fallback: string): string;
|
|
89
|
+
/** A trigger name with the module's prefix, quoted. */
|
|
90
|
+
trigger(name: string): string;
|
|
91
|
+
/** Whether `module` is installed alongside this one. */
|
|
92
|
+
installed(module: string): boolean;
|
|
93
|
+
/** The context of another module in the same layout. */
|
|
94
|
+
of(module: string): KitContext;
|
|
95
|
+
/** A string module option (`kits.<name>.options`). */
|
|
96
|
+
text(name: string, fallback: string): string;
|
|
97
|
+
number(name: string, fallback: number): number;
|
|
98
|
+
flag(name: string, fallback: boolean): boolean;
|
|
99
|
+
/** A module option that is a list of strings. */
|
|
100
|
+
list(name: string, fallback: readonly string[]): readonly string[];
|
|
101
|
+
/** A declared module option as configured, for object-shaped options. */
|
|
102
|
+
option(name: string): unknown;
|
|
103
|
+
/**
|
|
104
|
+
* PL/pgSQL that calls the app's hook function when it exists, with
|
|
105
|
+
* `[type, expression]` arguments: `if to_regprocedure(...) is not null
|
|
106
|
+
* then perform ...; end if;`.
|
|
107
|
+
*/
|
|
108
|
+
hook(name: string, args: readonly (readonly [string, string])[]): string;
|
|
109
|
+
/** The app function a hook calls, quoted, for hooks that return a value. */
|
|
110
|
+
hookTarget(name: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* PL/pgSQL that writes the event to the outbox (`emit_event`) when the
|
|
113
|
+
* `outbox` module is installed and `kits.<name>.events` isn't false;
|
|
114
|
+
* otherwise an empty string.
|
|
115
|
+
*/
|
|
116
|
+
emit(event: KitEmit): string;
|
|
117
|
+
}
|
|
118
|
+
/** The contract's argument list with `{id}` resolved, as Postgres prints it. */
|
|
119
|
+
export declare function contractSignature(fn: KitContractFunction, idType: string): string;
|
|
120
|
+
//#endregion
|
|
5
121
|
//#region src/sql/kit.d.ts
|
|
122
|
+
/** The step from one module version to the next, for `sql upgrade`. */
|
|
123
|
+
interface KitUpgrade {
|
|
124
|
+
/** The installed version this step upgrades from. */
|
|
125
|
+
readonly from: number;
|
|
126
|
+
readonly description: string;
|
|
127
|
+
/** SQL run before the module's current file, e.g. renames and backfills. */
|
|
128
|
+
readonly sql: (ctx: KitContext) => string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A renamed kit symbol. It keeps a compatibility wrapper for at least one
|
|
132
|
+
* minor release, then is removed; doctor reports uses of both (BS309), and
|
|
133
|
+
* the name stays reserved.
|
|
134
|
+
*/
|
|
135
|
+
interface KitDeprecation {
|
|
136
|
+
readonly kind: "function" | "claim" | "table" | "column";
|
|
137
|
+
/** The old name: `schema.function`, a claim name, `schema.table` or `table.column`. */
|
|
138
|
+
readonly symbol: string;
|
|
139
|
+
/** What to use instead. */
|
|
140
|
+
readonly use: string;
|
|
141
|
+
/** The package version that deprecated it. */
|
|
142
|
+
readonly since: string;
|
|
143
|
+
/** The package version that removed it; until then `wrapper` is written. */
|
|
144
|
+
readonly removed?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The compatibility wrapper the module file keeps, e.g. a function with the
|
|
147
|
+
* old name that calls the new one and a `comment on function ... is
|
|
148
|
+
* 'deprecated: use X'`.
|
|
149
|
+
*/
|
|
150
|
+
readonly wrapper?: (ctx: KitContext) => string;
|
|
151
|
+
}
|
|
6
152
|
/**
|
|
7
153
|
* SQL kit modules for `better-supabase sql add`. Every module is idempotent
|
|
8
154
|
* (`create or replace`, `if not exists`), so re-running it upgrades in place.
|
|
@@ -15,19 +161,42 @@ interface SqlModule {
|
|
|
15
161
|
readonly requires: readonly string[];
|
|
16
162
|
/** What it needs instead when the layout has `permdock`. */
|
|
17
163
|
readonly permdockRequires?: readonly string[];
|
|
164
|
+
/** What it needs for this layout, e.g. per `kits.access.model`; overrides both. */
|
|
165
|
+
readonly dependencies?: (layout: KitLayout) => readonly string[];
|
|
18
166
|
/** `schema` files go with your schemas; `test` files go to `supabase/tests`. */
|
|
19
167
|
readonly target: "schema" | "test";
|
|
20
168
|
/** The module with the default claim names. */
|
|
21
169
|
readonly sql: string;
|
|
22
170
|
/** The module for configured claim names (`config.claims`), when it reads claims. */
|
|
23
171
|
readonly render?: (claims: ClaimsMeta, layout: KitLayout) => string;
|
|
172
|
+
/** Bumped when installed databases need an upgrade step. Defaults to 1. */
|
|
173
|
+
readonly version?: number;
|
|
174
|
+
/** The modes `kits.<name>.mode` accepts. Defaults to `managed` only. */
|
|
175
|
+
readonly modes?: readonly KitMode[];
|
|
176
|
+
/** The logical tables and columns `kits.<name>.tables` and `columns` map. */
|
|
177
|
+
readonly names?: KitNames;
|
|
178
|
+
/** The functions other modules and the TypeScript side call. */
|
|
179
|
+
readonly contract?: (ctx: KitContext) => readonly KitContractFunction[];
|
|
180
|
+
/** Renders the module for a layout; takes precedence over `render`. */
|
|
181
|
+
readonly build?: (ctx: KitContext, layout: KitLayout) => string;
|
|
182
|
+
readonly upgrades?: readonly KitUpgrade[];
|
|
183
|
+
readonly deprecated?: readonly KitDeprecation[];
|
|
184
|
+
/**
|
|
185
|
+
* Rows, role settings and calls that a schema diff doesn't capture. They
|
|
186
|
+
* go to `better-supabase-data/` next to the schema folder and a migration
|
|
187
|
+
* (`sql data`) instead of the schema file.
|
|
188
|
+
*/
|
|
189
|
+
readonly data?: (ctx: KitContext, layout: KitLayout) => string;
|
|
24
190
|
}
|
|
191
|
+
export declare const moduleVersion: (module: SqlModule) => number;
|
|
25
192
|
/** New modules go at the end: the position is part of the file name. */
|
|
26
193
|
export declare const SQL_MODULES: Readonly<Record<string, SqlModule>>;
|
|
27
194
|
/** The modules to install for `names`, dependencies first. Throws on an unknown name. */
|
|
28
195
|
export declare function resolveModules(names: readonly string[], layout?: KitLayout): SqlModule[];
|
|
29
196
|
interface KitFile {
|
|
30
197
|
readonly module: string;
|
|
198
|
+
/** `schema` and `test` files are diffed; `data` files go in a migration too. */
|
|
199
|
+
readonly kind: "schema" | "data" | "test";
|
|
31
200
|
readonly path: string;
|
|
32
201
|
readonly contents: string;
|
|
33
202
|
}
|
|
@@ -42,7 +211,9 @@ interface KitLayout {
|
|
|
42
211
|
readonly version?: string;
|
|
43
212
|
/** `config.realtime.tables`: registered at the end of the `realtime-tables` module. */
|
|
44
213
|
readonly realtimeTables?: readonly string[];
|
|
45
|
-
/**
|
|
214
|
+
/** `config.realtime.global`: tables registered with `tenant_column => null`. */
|
|
215
|
+
readonly realtimeGlobal?: readonly string[];
|
|
216
|
+
/** Tenant column passed to `track_realtime` for the other tables. */
|
|
46
217
|
readonly tenantColumn?: string;
|
|
47
218
|
/** Check constraints for the `jsonb-schemas` module. */
|
|
48
219
|
readonly jsonSchemas?: readonly JsonSchemaCheck[];
|
|
@@ -61,6 +232,8 @@ interface KitLayout {
|
|
|
61
232
|
readonly claims?: ClaimsMeta;
|
|
62
233
|
/** PermDock's helpers and membership sources, from its manifest: `entitlements` reads them instead of `tenant`. */
|
|
63
234
|
readonly permdock?: KitPermdock;
|
|
235
|
+
/** `config.kits`: modes, names and permission keys per module. */
|
|
236
|
+
readonly kits?: KitsConfig;
|
|
64
237
|
}
|
|
65
238
|
/** One PermDock membership source, from the manifest's `memberships`. */
|
|
66
239
|
interface KitMembershipSource {
|
|
@@ -80,6 +253,8 @@ interface KitPermdock {
|
|
|
80
253
|
readonly schema: string;
|
|
81
254
|
/** The PermDock scope tenants map to, e.g. `organization`. */
|
|
82
255
|
readonly scope: string;
|
|
256
|
+
/** The scope's id type, from the manifest's `rls.scopes[].type`. */
|
|
257
|
+
readonly idType: KitIdType;
|
|
83
258
|
readonly memberships: readonly KitMembershipSource[];
|
|
84
259
|
}
|
|
85
260
|
/** An embedding column `db.$search` can query. */
|
|
@@ -91,10 +266,10 @@ interface VectorSearchTable {
|
|
|
91
266
|
}
|
|
92
267
|
/** The table holding each tenant's Stripe customer id. */
|
|
93
268
|
interface EntitlementsSource {
|
|
94
|
-
/** `table` or `schema.table
|
|
95
|
-
readonly table
|
|
269
|
+
/** `table` or `schema.table`; unset uses the `organizations` module's. */
|
|
270
|
+
readonly table?: string;
|
|
96
271
|
/** Column with the Stripe customer id (`cus_...`). */
|
|
97
|
-
readonly column
|
|
272
|
+
readonly column?: string;
|
|
98
273
|
/** Column with the tenant id. */
|
|
99
274
|
readonly key: string;
|
|
100
275
|
}
|
|
@@ -114,13 +289,75 @@ interface JsonSchemaCheck {
|
|
|
114
289
|
}
|
|
115
290
|
/** Whether an installed file matches, ignoring the version stamped in its header. */
|
|
116
291
|
export declare function sameKitFile(current: string | undefined, expected: string): boolean;
|
|
117
|
-
/** The
|
|
292
|
+
/** The installed version of a kit file, from its `@bs-kit` line. */
|
|
293
|
+
export declare function kitFileVersion(contents: string): {
|
|
294
|
+
readonly module: string;
|
|
295
|
+
readonly version: number;
|
|
296
|
+
} | undefined;
|
|
297
|
+
/** A module's SQL for `layout`, without header; `undefined` in custom mode. */
|
|
298
|
+
export declare function moduleBody(name: string, layout?: KitLayout): string | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* The files `sql add` writes for these modules. Modules in `custom` mode
|
|
301
|
+
* write nothing: the app implements their contract. A schema module's rows,
|
|
302
|
+
* role settings and other statements a schema diff can't capture go to a
|
|
303
|
+
* second file in `better-supabase-data/` (`kind: 'data'`), which
|
|
304
|
+
* `sql data` writes into a migration.
|
|
305
|
+
*/
|
|
118
306
|
export declare function renderKit(names: readonly string[], layout?: KitLayout): KitFile[];
|
|
307
|
+
/** An installed module, from its file's `@bs-kit` line or `kit_modules`. */
|
|
308
|
+
interface InstalledKitModule {
|
|
309
|
+
readonly module: string;
|
|
310
|
+
readonly version: number;
|
|
311
|
+
}
|
|
312
|
+
/** What `sql upgrade` runs for one module behind the current version. */
|
|
313
|
+
interface KitUpgradePlan {
|
|
314
|
+
readonly module: string;
|
|
315
|
+
readonly from: number;
|
|
316
|
+
readonly to: number;
|
|
317
|
+
readonly steps: readonly {
|
|
318
|
+
readonly from: number;
|
|
319
|
+
readonly description: string;
|
|
320
|
+
readonly sql: string;
|
|
321
|
+
}[];
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The upgrade steps for modules installed at an older version. A version
|
|
325
|
+
* without a step needs none: the module file upgrades in place. Modules in
|
|
326
|
+
* custom mode belong to the app and are skipped.
|
|
327
|
+
*/
|
|
328
|
+
export declare function upgradePlan(installed: readonly InstalledKitModule[], layout?: KitLayout, modules?: Readonly<Record<string, SqlModule>>): KitUpgradePlan[];
|
|
329
|
+
/** Every deprecated or removed kit symbol, with its module. */
|
|
330
|
+
export declare function kitDeprecations(modules?: Readonly<Record<string, SqlModule>>): readonly (KitDeprecation & {
|
|
331
|
+
readonly module: string;
|
|
332
|
+
})[];
|
|
333
|
+
/** The contract functions of the modules in `custom` mode, for doctor. */
|
|
334
|
+
export declare function customContracts(names: readonly string[], layout?: KitLayout): {
|
|
335
|
+
readonly module: string;
|
|
336
|
+
readonly schema: string;
|
|
337
|
+
readonly idType: KitIdType;
|
|
338
|
+
readonly functions: readonly KitContractFunction[];
|
|
339
|
+
}[];
|
|
119
340
|
//#endregion
|
|
120
341
|
//#region src/sql/layout.d.ts
|
|
121
342
|
/** Where and how `sql add` writes kit files for this config. */
|
|
122
343
|
export declare function kitLayout(config: ResolvedConfig, testsDir?: string, readSets?: KitLayout["readSets"], permdock?: KitPermdock): KitLayout;
|
|
123
344
|
//#endregion
|
|
345
|
+
//#region src/sql/migration-options.d.ts
|
|
346
|
+
/** A migration-only option a config sets. */
|
|
347
|
+
interface MigrationOptionUse {
|
|
348
|
+
readonly module: string;
|
|
349
|
+
readonly option: string;
|
|
350
|
+
readonly value: unknown;
|
|
351
|
+
readonly adopted: boolean;
|
|
352
|
+
/** `kits.<module>.options.<option> ... It <effect>.` */
|
|
353
|
+
readonly message: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The migration-only options `kits` sets to a value other than the managed
|
|
357
|
+
* default. They are accepted in `adopt` mode only; doctor warns about each.
|
|
358
|
+
*/
|
|
359
|
+
export declare function migrationOptionUses(kits?: KitsConfig): MigrationOptionUse[];
|
|
360
|
+
//#endregion
|
|
124
361
|
//#region src/sql/read-sets.d.ts
|
|
125
362
|
/** A read set compiled to the SQL of its function. */
|
|
126
363
|
interface CompiledReadSet {
|
|
@@ -136,4 +373,4 @@ export declare function compileReadSet(set: ReadSet): Promise<CompiledReadSet>;
|
|
|
136
373
|
/** Compiles every set, sorted by name. Throws on a duplicate name. */
|
|
137
374
|
export declare function compileReadSets(sets: readonly ReadSet[]): Promise<CompiledReadSet[]>;
|
|
138
375
|
//#endregion
|
|
139
|
-
export { type CompiledReadSet, type KitFile, type KitLayout, type KitPermdock, type SqlModule, permdockKeys };
|
|
376
|
+
export { type CompiledReadSet, type InstalledKitModule, type KitContext, type KitContractFunction, type KitDeprecation, type KitFile, type KitIdType, type KitLayout, type KitNames, type KitPermdock, type KitTableSpec, type KitUpgrade, type KitUpgradePlan, type MigrationOptionUse, PERMDOCK_SCHEMA, type PermdockCatalog, type PermdockKeyStatus, type SqlModule, permdockKeyStatus, permdockKeys };
|