better-supabase 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -31
- package/dist/base64-CQeB1eSf.js +42 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +4 -14
- package/dist/{compiler-CZ9nIuqy.d.ts → compiler-2zqGzxVZ.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -3
- package/dist/config/index.js +5 -3
- package/dist/config-Be4GwsqI.js +129 -0
- package/dist/{index-DOsjFvMf.d.ts → config-C1CYcm6o.d.ts} +49 -49
- package/dist/{config-ClDXmVtY.js → config-DOsGYSiT.js} +14 -137
- package/dist/{define-BXMYD9AY.js → define-DF341GDj.js} +71 -51
- package/dist/{define-e3zI4_4g.d.ts → define-DUbydmJa.d.ts} +10 -9
- package/dist/edge/index.d.ts +4 -4
- package/dist/edge/index.js +4 -4
- package/dist/{entitlements-Dng-ctuT.d.ts → entitlements-DvJXoI02.d.ts} +1 -1
- package/dist/env/index.js +203 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +139 -1
- package/dist/{events-DOt3nSO-.d.ts → events-Do8jXh4D.d.ts} +3 -3
- package/dist/{executor-BYXQ9AGn.d.ts → executor-B26lgbHD.d.ts} +2 -2
- package/dist/{executor-DeppvirK.js → executor-C57jx2pn.js} +7 -2
- package/dist/{executor-CGdNQ27g.d.ts → executor-DynmIWhq.d.ts} +2 -2
- package/dist/hono/index.d.ts +5 -5
- package/dist/hono/index.js +4 -4
- package/dist/{index-CBDufH1M.d.ts → index-BNsABq7P.d.ts} +8 -8
- package/dist/{index-Bw1bwtC0.d.ts → index-CADlNHK-.d.ts} +27 -14
- package/dist/{index-DuP14VHo.d.ts → index-CTTMS6_1.d.ts} +19 -8
- package/dist/index-Cf-D2jk1.d.ts +50 -0
- package/dist/{index-K-3WM2Hp.d.ts → index-CriFFJ_p.d.ts} +4 -4
- package/dist/{index-Ciu5Xlml.d.ts → index-GV77NpRP.d.ts} +5 -4
- package/dist/{index-D4v7sncu.d.ts → index-UJ-LUxtI.d.ts} +3 -3
- package/dist/{index-CG69s15v.d.ts → index-kpgopLNv.d.ts} +4 -3
- package/dist/{index-DbxFr7XG.d.ts → index-qriRM9cZ.d.ts} +7 -2
- package/dist/index.d.ts +12 -12
- package/dist/index.js +16 -7
- package/dist/jobs/index.d.ts +25 -24
- package/dist/jobs/index.js +16 -10
- package/dist/{json-schema-BpYqkCKf.js → json-schema--aOXAGfU.js} +7 -2
- package/dist/lint/index.js +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.js +128 -93
- package/dist/{live-DJyZMD6w.d.ts → live-QE3UPbGm.d.ts} +16 -6
- package/dist/mcp/index.d.ts +24 -17
- package/dist/mcp/index.js +41 -12
- package/dist/{mfa-CpLfJSde.js → mfa-BxoR1RkN.js} +74 -19
- package/dist/{mfa-TVia554c.d.ts → mfa-x3V3vGh-.d.ts} +1 -1
- package/dist/next/index.d.ts +39 -26
- package/dist/next/index.js +28 -23
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +57 -34
- package/dist/orpc/index.d.ts +6 -6
- package/dist/orpc/index.js +3 -3
- package/dist/otel/index.d.ts +2 -2
- package/dist/otel/index.js +4 -2
- package/dist/{permdock-sql-CghlHPuH.js → permdock-sql-Bta_G0v-.js} +11 -6
- package/dist/permdock-sql-DImJULY-.d.ts +17 -0
- package/dist/{plugin-C4TR9J0Z.d.ts → plugin-DVRB8qNE.d.ts} +5 -4
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +4 -4
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +2 -2
- package/dist/plugins/tenant/index.d.ts +2 -2
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +1 -1
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/pool-B9qsLyFR.d.ts +71 -0
- package/dist/postgres/index.d.ts +10 -5
- package/dist/postgres/index.js +36 -16
- package/dist/{postgrest-cAEQ_IQN.d.ts → postgrest-DmBlevh-.d.ts} +1 -1
- package/dist/{problem-BTkTtRV9.js → problem-CGt1ADix.js} +10 -4
- package/dist/{problem-DlgB0lYl.d.ts → problem-Z2RTQjZD.d.ts} +6 -4
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +1 -1
- package/dist/{query-ChvDbsDE.js → query-BdKLTPlj.js} +2 -2
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +2 -2
- package/dist/react/server.d.ts +3 -3
- package/dist/react/server.js +1 -1
- package/dist/react/session.d.ts +21 -2
- package/dist/react/session.js +19 -1
- package/dist/{react-C83BdBGt.js → react-DNBYNazu.js} +20 -16
- package/dist/{read-set-4lI3W_gZ.js → read-set-D0qBcboM.js} +3 -3
- package/dist/realtime/index.d.ts +4 -3
- package/dist/realtime/index.js +7 -6
- package/dist/{resolve-CjHILk2w.d.ts → resolve-BRciX2jK.d.ts} +6 -5
- package/dist/{resource-CgZa3YG_.d.ts → resource-CwVgiI5q.d.ts} +16 -7
- package/dist/{resource-BHEWmQJK.js → resource-D30rp0GN.js} +38 -16
- package/dist/{respond-DMcbQwfN.js → respond-C44EZAJo.js} +35 -19
- package/dist/{respond-Dne1ARSa.d.ts → respond-DAkPIdTH.d.ts} +15 -9
- package/dist/{result-CTkCZ6JA.d.ts → result-c2OYgCV2.d.ts} +13 -8
- package/dist/server/index.d.ts +35 -10
- package/dist/server/index.js +38 -9
- package/dist/{simplify-bwJpLnaS.js → simplify-LakqK1vH.js} +10 -16
- package/dist/sql/index.d.ts +139 -0
- package/dist/sql/index.js +1983 -0
- package/dist/{sql-DTjA1LPj.js → sql-BIgk12ew.js} +72 -16
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +2 -2
- package/dist/{standard-CyhRzctb.d.ts → standard-eudBiRk1.d.ts} +1 -1
- package/dist/{stats-C5W-rBfR.js → stats-D78UQ8Yu.js} +8 -7
- package/dist/storage/index.d.ts +4 -3
- package/dist/storage/index.js +530 -1
- package/dist/{tables-rZxRxNPW.js → tables-Dhha3BXM.js} +5 -5
- package/dist/temporal-BwshQk0W.js +27 -0
- package/dist/temporal-required-CMxeSVPo.js +19 -0
- package/dist/testing/index.d.ts +13 -11
- package/dist/testing/index.js +128 -29
- package/dist/{types-C83v5SQz.d.ts → types-DONv9SHN.d.ts} +14 -11
- package/dist/{version-Cqq1m3UY.js → version-BfpG2gks.js} +1 -1
- package/dist/{view-D1s0wa0T.d.ts → view-3Po_PVlr.d.ts} +34 -4
- package/dist/{view-aOYizTeE.js → view-wZ-9qIUz.js} +11 -2
- package/dist/webhooks/index.d.ts +18 -16
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-DMipjhSP.js → webhooks-CAIFQSTM.js} +11 -9
- package/package.json +24 -28
- package/schemas/config-v1.json +31 -1
- package/schemas/doctor-report-v1.json +17 -1
- package/schemas/snapshot-v2.json +35 -0
- package/skills/better-supabase/SKILL.md +23 -11
- package/skills/better-supabase/references/plugins.md +21 -18
- package/skills/better-supabase/references/troubleshooting.md +15 -15
- package/skills/better-supabase-api/SKILL.md +7 -7
- package/skills/better-supabase-api/references/adapters.md +30 -25
- package/skills/better-supabase-testing/SKILL.md +11 -8
- package/bin/better-supabase.js +0 -4
- package/dist/casing-da0uRTqt.js +0 -14
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +0 -15
- package/dist/cli/index.d.ts +0 -226
- package/dist/cli/index.js +0 -3
- package/dist/cli-DrSgDOQC.js +0 -6646
- package/dist/env-BEToab0I.js +0 -204
- package/dist/events-BuzTgn2D.js +0 -135
- package/dist/pool-R2m_DkXi.d.ts +0 -37
- package/dist/seed-CzecODcJ.js +0 -101
- package/dist/session-C3LxnQ0e.d.ts +0 -22
- package/dist/session-CqEwzVup.js +0 -20
- package/dist/storage-DuGn38fr.js +0 -527
package/dist/server/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
1
|
+
import { n as dbError } from "../errors-Bl3rkOzo.js";
|
|
2
|
+
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-CGt1ADix.js";
|
|
3
|
+
import { a as settle, i as respond, n as guard, o as createServer, r as isResult, u as PRIMARY_COOKIE } from "../respond-C44EZAJo.js";
|
|
4
|
+
import { a as clientIp, f as sessionCookieName, i as authContext, m as refreshSession, n as amrOf, o as resolveAuth, p as writeSession, r as checkAal, s as AUTH_CACHE_HEADERS, t as aalOf, u as readSession, v as impersonatorOf } from "../mfa-BxoR1RkN.js";
|
|
5
|
+
import { n as postgresExecutor } from "../executor-C57jx2pn.js";
|
|
6
|
+
import { t as toSession } from "../view-wZ-9qIUz.js";
|
|
7
|
+
import { t as defineResource } from "../resource-D30rp0GN.js";
|
|
6
8
|
import { defineMiddleware } from "@supabase/middleware";
|
|
7
9
|
//#region src/server/middleware.ts
|
|
8
10
|
/** Repository context from a `@supabase/server` context. */
|
|
@@ -14,8 +16,8 @@ function contextFromSupabase(ctx) {
|
|
|
14
16
|
actor: {
|
|
15
17
|
id: ctx.userClaims.id,
|
|
16
18
|
kind: "user",
|
|
17
|
-
...ctx.userClaims.role
|
|
18
|
-
...ctx.userClaims.email
|
|
19
|
+
...ctx.userClaims.role === void 0 ? {} : { role: ctx.userClaims.role },
|
|
20
|
+
...ctx.userClaims.email === void 0 ? {} : { email: ctx.userClaims.email }
|
|
19
21
|
},
|
|
20
22
|
claims: ctx.jwtClaims ?? {}
|
|
21
23
|
};
|
|
@@ -29,7 +31,10 @@ function contextFromSupabase(ctx) {
|
|
|
29
31
|
};
|
|
30
32
|
case "publishable":
|
|
31
33
|
case "none": break;
|
|
32
|
-
default:
|
|
34
|
+
default: {
|
|
35
|
+
const unknown = ctx.authMode;
|
|
36
|
+
throw new TypeError(`contextFromSupabase: unknown auth mode "${String(unknown)}"`);
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
return {
|
|
35
40
|
actor: {
|
|
@@ -65,4 +70,28 @@ function withBetterPostgres(sb) {
|
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
72
|
//#endregion
|
|
68
|
-
|
|
73
|
+
//#region src/auth/revocation.ts
|
|
74
|
+
const UUID = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
|
|
75
|
+
const ACTIVE = `select exists (
|
|
76
|
+
select 1 from auth.sessions s
|
|
77
|
+
where s.id = $1::uuid and s.user_id = $2::uuid
|
|
78
|
+
and (s.not_after is null or s.not_after > now())
|
|
79
|
+
) as active`;
|
|
80
|
+
/**
|
|
81
|
+
* `undefined` when the user token's session still exists in `auth.sessions`;
|
|
82
|
+
* otherwise an `unauthorized` error with code `SESSION_REVOKED`. A verified
|
|
83
|
+
* access token stays valid until it expires, even after sign-out; call this
|
|
84
|
+
* before sensitive actions (deleting the account, changing the email) to
|
|
85
|
+
* reject tokens of ended sessions. It costs one query, so nothing calls it
|
|
86
|
+
* by default. Non-user callers pass: `guard` decides about them.
|
|
87
|
+
*/
|
|
88
|
+
async function checkSession(sql, auth) {
|
|
89
|
+
if (auth.kind !== "user" || !("claims" in auth)) return void 0;
|
|
90
|
+
const { sub, session_id: sessionId } = auth.claims;
|
|
91
|
+
const revoked = dbError("unauthorized", "This session has ended", { code: "SESSION_REVOKED" });
|
|
92
|
+
if (typeof sessionId !== "string" || typeof sub !== "string" || !UUID.test(sessionId) || !UUID.test(sub)) return revoked;
|
|
93
|
+
const [row] = await sql.queryRaw(ACTIVE, [sessionId, sub]);
|
|
94
|
+
return row?.active === true ? void 0 : revoked;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { AUTH_CACHE_HEADERS, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, aalOf, amrOf, authContext, checkAal, checkSession, clientIp, contextFromSupabase, createServer, defineResource, fromProblem, guard, impersonatorOf, isProblem, isResult, problemResponse, readSession, refreshSession, resolveAuth, respond, sessionCookieName, settle, toProblem, toSession, withBetterPostgres, withBetterSupabase, writeSession };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { n as dbError, t as DbException } from "./errors-Bl3rkOzo.js";
|
|
2
|
+
import { i as temporalText } from "./temporal-BwshQk0W.js";
|
|
3
|
+
import { t as temporal } from "./temporal-required-CMxeSVPo.js";
|
|
2
4
|
import { i as or, r as not, t as and } from "./types-6cYK9pbJ.js";
|
|
3
5
|
//#region src/schema/define.ts
|
|
4
6
|
/**
|
|
@@ -27,17 +29,19 @@ function relationMeta(meta, table, relation) {
|
|
|
27
29
|
}
|
|
28
30
|
//#endregion
|
|
29
31
|
//#region src/ir/codec.ts
|
|
30
|
-
/** Wire form of an app value:
|
|
32
|
+
/** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
|
|
31
33
|
function encodeValue(value) {
|
|
32
|
-
if (value instanceof Date) return value.toISOString();
|
|
33
34
|
if (typeof value === "bigint") return value.toString();
|
|
35
|
+
const text = temporalText(value);
|
|
36
|
+
if (text !== void 0) return text;
|
|
34
37
|
if (Array.isArray(value)) return value.map(encodeValue);
|
|
35
38
|
return value;
|
|
36
39
|
}
|
|
37
40
|
function decodeScalar(codec, value) {
|
|
38
41
|
if (value === null || value === void 0) return value;
|
|
39
42
|
switch (codec) {
|
|
40
|
-
case "
|
|
43
|
+
case "instant": return temporal().Instant.from(String(value));
|
|
44
|
+
case "plainDateTime": return temporal().PlainDateTime.from(String(value));
|
|
41
45
|
case "bigint": return BigInt(value);
|
|
42
46
|
case "string": return String(value);
|
|
43
47
|
default: return codec;
|
|
@@ -170,7 +174,7 @@ function writable(meta, mode) {
|
|
|
170
174
|
}
|
|
171
175
|
/** Escapes LIKE wildcards so user input matches literally. */
|
|
172
176
|
function escapeLike(value) {
|
|
173
|
-
return value.
|
|
177
|
+
return value.replaceAll(/[\\%_]/g, (char) => `\\${char}`);
|
|
174
178
|
}
|
|
175
179
|
var IrBuilder = class {
|
|
176
180
|
meta;
|
|
@@ -411,13 +415,7 @@ var IrBuilder = class {
|
|
|
411
415
|
alias,
|
|
412
416
|
column
|
|
413
417
|
};
|
|
414
|
-
return
|
|
415
|
-
fn,
|
|
416
|
-
key,
|
|
417
|
-
alias,
|
|
418
|
-
column,
|
|
419
|
-
codec
|
|
420
|
-
} : {
|
|
418
|
+
return {
|
|
421
419
|
fn,
|
|
422
420
|
key,
|
|
423
421
|
alias,
|
|
@@ -434,11 +432,7 @@ var IrBuilder = class {
|
|
|
434
432
|
alias,
|
|
435
433
|
column
|
|
436
434
|
};
|
|
437
|
-
return
|
|
438
|
-
alias,
|
|
439
|
-
column,
|
|
440
|
-
codec
|
|
441
|
-
} : {
|
|
435
|
+
return {
|
|
442
436
|
alias,
|
|
443
437
|
column,
|
|
444
438
|
cast: "text",
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { s as ClaimsMeta } from "../types-DONv9SHN.js";
|
|
2
|
+
import { B as ReadSet } from "../define-DUbydmJa.js";
|
|
3
|
+
import { b as ResolvedConfig } from "../config-C1CYcm6o.js";
|
|
4
|
+
import { n as permdockKeys } from "../permdock-sql-DImJULY-.js";
|
|
5
|
+
//#region src/sql/kit.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* SQL kit modules for `better-supabase sql add`. Every module is idempotent
|
|
8
|
+
* (`create or replace`, `if not exists`), so re-running it upgrades in place.
|
|
9
|
+
*/
|
|
10
|
+
interface SqlModule {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
/** Modules this one needs, added along with it. */
|
|
15
|
+
readonly requires: readonly string[];
|
|
16
|
+
/** What it needs instead when the layout has `permdock`. */
|
|
17
|
+
readonly permdockRequires?: readonly string[];
|
|
18
|
+
/** `schema` files go with your schemas; `test` files go to `supabase/tests`. */
|
|
19
|
+
readonly target: "schema" | "test";
|
|
20
|
+
/** The module with the default claim names. */
|
|
21
|
+
readonly sql: string;
|
|
22
|
+
/** The module for configured claim names (`config.claims`), when it reads claims. */
|
|
23
|
+
readonly render?: (claims: ClaimsMeta, layout: KitLayout) => string;
|
|
24
|
+
}
|
|
25
|
+
/** New modules go at the end: the position is part of the file name. */
|
|
26
|
+
export declare const SQL_MODULES: Readonly<Record<string, SqlModule>>;
|
|
27
|
+
/** The modules to install for `names`, dependencies first. Throws on an unknown name. */
|
|
28
|
+
export declare function resolveModules(names: readonly string[], layout?: KitLayout): SqlModule[];
|
|
29
|
+
interface KitFile {
|
|
30
|
+
readonly module: string;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly contents: string;
|
|
33
|
+
}
|
|
34
|
+
interface KitLayout {
|
|
35
|
+
/** Directory for schema modules. Defaults to `supabase/schemas`. */
|
|
36
|
+
readonly dir?: string;
|
|
37
|
+
/** File prefix. Defaults to `900_better_supabase`. */
|
|
38
|
+
readonly prefix?: string;
|
|
39
|
+
/** Directory for pgTAP files. Defaults to `supabase/tests`. */
|
|
40
|
+
readonly testsDir?: string;
|
|
41
|
+
/** Version stamped into the header. */
|
|
42
|
+
readonly version?: string;
|
|
43
|
+
/** `config.realtime.tables`: registered at the end of the `realtime-tables` module. */
|
|
44
|
+
readonly realtimeTables?: readonly string[];
|
|
45
|
+
/** Tenant column passed to `track_realtime`; tables without it broadcast unscoped. */
|
|
46
|
+
readonly tenantColumn?: string;
|
|
47
|
+
/** Check constraints for the `jsonb-schemas` module. */
|
|
48
|
+
readonly jsonSchemas?: readonly JsonSchemaCheck[];
|
|
49
|
+
/** `config.expose`: the grants the `grants` module writes. */
|
|
50
|
+
readonly grants?: readonly TableGrant[];
|
|
51
|
+
/** `config.readSets`, compiled: the functions the `read-sets` module writes. */
|
|
52
|
+
readonly readSets?: readonly {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly sql: string;
|
|
55
|
+
}[];
|
|
56
|
+
/** `config.entitlements`: where the `entitlements` module finds each tenant's Stripe customer. */
|
|
57
|
+
readonly entitlements?: EntitlementsSource;
|
|
58
|
+
/** `config.vectorSearch`: the tables the `vector-search` module writes a search function for. */
|
|
59
|
+
readonly vectorSearch?: readonly VectorSearchTable[];
|
|
60
|
+
/** `config.claims`: claim names the modules read and write. */
|
|
61
|
+
readonly claims?: ClaimsMeta;
|
|
62
|
+
/** PermDock's helpers and membership sources, from its manifest: `entitlements` reads them instead of `tenant`. */
|
|
63
|
+
readonly permdock?: KitPermdock;
|
|
64
|
+
}
|
|
65
|
+
/** One PermDock membership source, from the manifest's `memberships`. */
|
|
66
|
+
interface KitMembershipSource {
|
|
67
|
+
/** `schema.table`. */
|
|
68
|
+
readonly table: string;
|
|
69
|
+
readonly userColumn: string;
|
|
70
|
+
readonly scope: {
|
|
71
|
+
readonly column: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly value: string;
|
|
74
|
+
};
|
|
75
|
+
readonly idColumn: string;
|
|
76
|
+
}
|
|
77
|
+
/** Where PermDock's `member_<scope>_ids` helpers live, and the tables behind them. */
|
|
78
|
+
interface KitPermdock {
|
|
79
|
+
/** PermDock's `rls.schema`. */
|
|
80
|
+
readonly schema: string;
|
|
81
|
+
/** The PermDock scope tenants map to, e.g. `organization`. */
|
|
82
|
+
readonly scope: string;
|
|
83
|
+
readonly memberships: readonly KitMembershipSource[];
|
|
84
|
+
}
|
|
85
|
+
/** An embedding column `db.$search` can query. */
|
|
86
|
+
interface VectorSearchTable {
|
|
87
|
+
/** `table` or `schema.table`. */
|
|
88
|
+
readonly table: string;
|
|
89
|
+
readonly column: string;
|
|
90
|
+
readonly distance: "cosine" | "l2" | "inner_product";
|
|
91
|
+
}
|
|
92
|
+
/** The table holding each tenant's Stripe customer id. */
|
|
93
|
+
interface EntitlementsSource {
|
|
94
|
+
/** `table` or `schema.table`. */
|
|
95
|
+
readonly table: string;
|
|
96
|
+
/** Column with the Stripe customer id (`cus_...`). */
|
|
97
|
+
readonly column: string;
|
|
98
|
+
/** Column with the tenant id. */
|
|
99
|
+
readonly key: string;
|
|
100
|
+
}
|
|
101
|
+
/** Privileges one Data API role gets on a table or view. */
|
|
102
|
+
interface TableGrant {
|
|
103
|
+
/** `table` or `schema.table`. */
|
|
104
|
+
readonly table: string;
|
|
105
|
+
readonly role: "anon" | "authenticated";
|
|
106
|
+
readonly privileges: readonly ("select" | "insert" | "update" | "delete")[];
|
|
107
|
+
}
|
|
108
|
+
/** A jsonb column and the JSON Schema its values must match. */
|
|
109
|
+
interface JsonSchemaCheck {
|
|
110
|
+
/** `table` or `schema.table`. */
|
|
111
|
+
readonly table: string;
|
|
112
|
+
readonly column: string;
|
|
113
|
+
readonly schema: Readonly<Record<string, unknown>>;
|
|
114
|
+
}
|
|
115
|
+
/** Whether an installed file matches, ignoring the version stamped in its header. */
|
|
116
|
+
export declare function sameKitFile(current: string | undefined, expected: string): boolean;
|
|
117
|
+
/** The files `sql add` writes for these modules. */
|
|
118
|
+
export declare function renderKit(names: readonly string[], layout?: KitLayout): KitFile[];
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/sql/layout.d.ts
|
|
121
|
+
/** Where and how `sql add` writes kit files for this config. */
|
|
122
|
+
export declare function kitLayout(config: ResolvedConfig, testsDir?: string, readSets?: KitLayout["readSets"], permdock?: KitPermdock): KitLayout;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/sql/read-sets.d.ts
|
|
125
|
+
/** A read set compiled to the SQL of its function. */
|
|
126
|
+
interface CompiledReadSet {
|
|
127
|
+
readonly name: string;
|
|
128
|
+
readonly sql: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The function for a read set: `stable`, `security invoker` (RLS applies to
|
|
132
|
+
* the caller) and with an empty `search_path`. Parameters are read from the
|
|
133
|
+
* `p jsonb` argument; nothing is built dynamically.
|
|
134
|
+
*/
|
|
135
|
+
export declare function compileReadSet(set: ReadSet): Promise<CompiledReadSet>;
|
|
136
|
+
/** Compiles every set, sorted by name. Throws on a duplicate name. */
|
|
137
|
+
export declare function compileReadSets(sets: readonly ReadSet[]): Promise<CompiledReadSet[]>;
|
|
138
|
+
//#endregion
|
|
139
|
+
export { type CompiledReadSet, type KitFile, type KitLayout, type KitPermdock, type SqlModule, permdockKeys };
|