better-supabase 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +88 -1
- package/bin/better-supabase.js +4 -0
- package/dist/casing-da0uRTqt.js +14 -0
- package/dist/claims-CoTobNC-.js +25 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +15 -0
- package/dist/cli/index.d.ts +226 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli-DrSgDOQC.js +6646 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +112 -0
- package/dist/compiler-CZ9nIuqy.d.ts +14 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +3 -0
- package/dist/config-ClDXmVtY.js +277 -0
- package/dist/define-BXMYD9AY.js +1071 -0
- package/dist/define-e3zI4_4g.d.ts +679 -0
- package/dist/edge/index.d.ts +43 -0
- package/dist/edge/index.js +103 -0
- package/dist/entitlements-CTEBm7IB.js +20 -0
- package/dist/entitlements-Dng-ctuT.d.ts +42 -0
- package/dist/env/index.d.ts +2 -0
- package/dist/env/index.js +2 -0
- package/dist/env-BEToab0I.js +204 -0
- package/dist/errors-Bl3rkOzo.js +196 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +2 -0
- package/dist/events-BuzTgn2D.js +135 -0
- package/dist/events-DOt3nSO-.d.ts +84 -0
- package/dist/executor-BYXQ9AGn.d.ts +25 -0
- package/dist/executor-CGdNQ27g.d.ts +195 -0
- package/dist/executor-DeppvirK.js +89 -0
- package/dist/guards-BnzDvFrz.js +10 -0
- package/dist/hono/index.d.ts +45 -0
- package/dist/hono/index.js +70 -0
- package/dist/index-Bw1bwtC0.d.ts +144 -0
- package/dist/index-CBDufH1M.d.ts +120 -0
- package/dist/index-CG69s15v.d.ts +38 -0
- package/dist/index-Ciu5Xlml.d.ts +74 -0
- package/dist/index-D4v7sncu.d.ts +62 -0
- package/dist/index-DOsjFvMf.d.ts +618 -0
- package/dist/index-DbxFr7XG.d.ts +76 -0
- package/dist/index-DuP14VHo.d.ts +216 -0
- package/dist/index-Dy6kuF0P.d.ts +71 -0
- package/dist/index-K-3WM2Hp.d.ts +117 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +43 -0
- package/dist/invalidate-DbxuL2jL.js +18 -0
- package/dist/jobs/index.d.ts +173 -0
- package/dist/jobs/index.js +478 -0
- package/dist/json-schema-BpYqkCKf.js +182 -0
- package/dist/lint/index.d.ts +75 -0
- package/dist/lint/index.js +167 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.js +410 -0
- package/dist/live-D8rV1Ldw.js +168 -0
- package/dist/live-DJyZMD6w.d.ts +191 -0
- package/dist/logger-glM28NVN.js +21 -0
- package/dist/mcp/index.d.ts +142 -0
- package/dist/mcp/index.js +463 -0
- package/dist/mfa-CpLfJSde.js +541 -0
- package/dist/mfa-TVia554c.d.ts +44 -0
- package/dist/next/image/index.d.ts +34 -0
- package/dist/next/image/index.js +40 -0
- package/dist/next/index.d.ts +210 -0
- package/dist/next/index.js +427 -0
- package/dist/openapi/index.d.ts +2 -0
- package/dist/openapi/index.js +332 -0
- package/dist/orpc/index.d.ts +46 -0
- package/dist/orpc/index.js +50 -0
- package/dist/otel/index.d.ts +40 -0
- package/dist/otel/index.js +168 -0
- package/dist/path-Cv__-OTj.d.ts +17 -0
- package/dist/permdock-sql-CghlHPuH.js +117 -0
- package/dist/plugin-BqR6wKMB.js +23 -0
- package/dist/plugin-C4TR9J0Z.d.ts +118 -0
- package/dist/plugins/actor/index.d.ts +13 -0
- package/dist/plugins/actor/index.js +43 -0
- package/dist/plugins/rules/index.d.ts +89 -0
- package/dist/plugins/rules/index.js +167 -0
- package/dist/plugins/soft-delete/index.d.ts +38 -0
- package/dist/plugins/soft-delete/index.js +69 -0
- package/dist/plugins/tenant/index.d.ts +49 -0
- package/dist/plugins/tenant/index.js +75 -0
- package/dist/plugins/timestamps/index.d.ts +9 -0
- package/dist/plugins/timestamps/index.js +37 -0
- package/dist/plugins/validation/index.d.ts +24 -0
- package/dist/plugins/validation/index.js +59 -0
- package/dist/pool-R2m_DkXi.d.ts +37 -0
- package/dist/postgres/index.d.ts +28 -0
- package/dist/postgres/index.js +79 -0
- package/dist/postgrest-cAEQ_IQN.d.ts +43 -0
- package/dist/problem-BTkTtRV9.js +97 -0
- package/dist/problem-DlgB0lYl.d.ts +47 -0
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.js +3 -0
- package/dist/query-ChvDbsDE.js +186 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +5 -0
- package/dist/react/server.d.ts +13 -0
- package/dist/react/server.js +25 -0
- package/dist/react/session.d.ts +2 -0
- package/dist/react/session.js +3 -0
- package/dist/react-C83BdBGt.js +242 -0
- package/dist/read-set-4lI3W_gZ.js +216 -0
- package/dist/realtime/index.d.ts +4 -0
- package/dist/realtime/index.js +268 -0
- package/dist/resolve-CjHILk2w.d.ts +170 -0
- package/dist/resource-BHEWmQJK.js +175 -0
- package/dist/resource-CgZa3YG_.d.ts +65 -0
- package/dist/respond-DMcbQwfN.js +383 -0
- package/dist/respond-Dne1ARSa.d.ts +169 -0
- package/dist/result-CTkCZ6JA.d.ts +198 -0
- package/dist/result-DWXatkd6.js +103 -0
- package/dist/scope-CDHcS7dE.js +90 -0
- package/dist/seed-CzecODcJ.js +101 -0
- package/dist/server/index.d.ts +42 -0
- package/dist/server/index.js +68 -0
- package/dist/session-C3LxnQ0e.d.ts +22 -0
- package/dist/session-CqEwzVup.js +20 -0
- package/dist/shared-_6-uPL7E.js +57 -0
- package/dist/simplify-bwJpLnaS.js +665 -0
- package/dist/spec-pins-C3oc-Tdp.js +20 -0
- package/dist/spec-pins-CqorWDnO.d.ts +20 -0
- package/dist/sql-DTjA1LPj.js +260 -0
- package/dist/ssr/index.d.ts +5 -0
- package/dist/ssr/index.js +4 -0
- package/dist/standard-CyhRzctb.d.ts +7 -0
- package/dist/standard-FUi3Z3-7.js +21 -0
- package/dist/stats-C5W-rBfR.js +566 -0
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage-DuGn38fr.js +527 -0
- package/dist/tables-rZxRxNPW.js +59 -0
- package/dist/template-mbvlysOo.d.ts +6 -0
- package/dist/testing/index.d.ts +325 -0
- package/dist/testing/index.js +819 -0
- package/dist/types-6cYK9pbJ.js +29 -0
- package/dist/types-C83v5SQz.d.ts +248 -0
- package/dist/version-Cqq1m3UY.js +4 -0
- package/dist/view-D1s0wa0T.d.ts +49 -0
- package/dist/view-aOYizTeE.js +36 -0
- package/dist/webhooks/index.d.ts +152 -0
- package/dist/webhooks/index.js +2 -0
- package/dist/webhooks-DMipjhSP.js +139 -0
- package/package.json +250 -17
- package/schemas/config-v1.json +373 -0
- package/schemas/doctor-report-v1.json +106 -0
- package/schemas/snapshot-v2.json +1006 -0
- package/skills/better-supabase/SKILL.md +84 -0
- package/skills/better-supabase/references/plugins.md +65 -0
- package/skills/better-supabase/references/troubleshooting.md +39 -0
- package/skills/better-supabase-api/SKILL.md +67 -0
- package/skills/better-supabase-api/references/adapters.md +108 -0
- package/skills/better-supabase-testing/SKILL.md +66 -0
- package/index.js +0 -1
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import { A as SchemaMeta, a as Casing, b as PermdockBucketPolicy, i as BucketPolicyName } from "./types-C83v5SQz.js";
|
|
2
|
+
import { GeneratorMetadata, Queryable } from "@supabase/postgrest-typegen";
|
|
3
|
+
//#region src/cli/introspect/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* What `better-supabase introspect` reads from Postgres. `generator` is the
|
|
6
|
+
* `@supabase/postgrest-typegen` contract (the same metadata behind
|
|
7
|
+
* `supabase gen types`); `extras` holds what that contract leaves out.
|
|
8
|
+
* Codegen and doctor both work from this snapshot, so either can run offline
|
|
9
|
+
* from a saved file.
|
|
10
|
+
*/
|
|
11
|
+
interface Snapshot {
|
|
12
|
+
readonly $schema?: string;
|
|
13
|
+
readonly version: 2;
|
|
14
|
+
/** Every schema that was read, including helper schemas for doctor. */
|
|
15
|
+
readonly schemas: readonly string[];
|
|
16
|
+
readonly generator: GeneratorMetadata;
|
|
17
|
+
readonly extras: SnapshotExtras;
|
|
18
|
+
}
|
|
19
|
+
/** Catalog details `GeneratorMetadata` does not carry. */
|
|
20
|
+
interface SnapshotExtras {
|
|
21
|
+
readonly tables: readonly ExtrasTable[];
|
|
22
|
+
readonly buckets: readonly SnapshotBucket[];
|
|
23
|
+
/** Tables in the `supabase_realtime` publication, as `schema.table`. */
|
|
24
|
+
readonly realtime: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* `alter role ... set` values for the Data API roles (`authenticator`),
|
|
27
|
+
* such as `pgrst.db_aggregates_enabled`. Absent in older snapshots.
|
|
28
|
+
*/
|
|
29
|
+
readonly roleSettings?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
30
|
+
/**
|
|
31
|
+
* Functions that policies in the read schemas call, plus functions in
|
|
32
|
+
* those schemas with `set` options. Absent in older snapshots.
|
|
33
|
+
*/
|
|
34
|
+
readonly functions?: readonly ExtrasFunction[];
|
|
35
|
+
/**
|
|
36
|
+
* The Postgres functions `supabase/config.toml` configures as Auth hooks,
|
|
37
|
+
* in any schema. Absent in older snapshots and without a `config.toml`.
|
|
38
|
+
*/
|
|
39
|
+
readonly hooks?: readonly ExtrasHook[];
|
|
40
|
+
}
|
|
41
|
+
/** An `[auth.hook.<name>]` with a `pg-functions://` URI. */
|
|
42
|
+
interface ExtrasHook {
|
|
43
|
+
/** `custom_access_token`, `send_email`, ... */
|
|
44
|
+
readonly hook: string;
|
|
45
|
+
readonly schema: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
/** Every overload with that name; empty when the function does not exist. */
|
|
48
|
+
readonly functions: readonly ExtrasHookFunction[];
|
|
49
|
+
}
|
|
50
|
+
interface ExtrasHookFunction extends ExtrasFunction {
|
|
51
|
+
/**
|
|
52
|
+
* Of `supabase_auth_admin`, `authenticated` and `anon`, the roles that may
|
|
53
|
+
* execute it (directly or through `public`).
|
|
54
|
+
*/
|
|
55
|
+
readonly execute: readonly string[];
|
|
56
|
+
/** Whether `public` may execute it (the default until revoked). */
|
|
57
|
+
readonly publicExecute: boolean;
|
|
58
|
+
/** Of the same roles, those with `usage` on its schema. */
|
|
59
|
+
readonly schemaUsage: readonly string[];
|
|
60
|
+
/** The function body (`pg_proc.prosrc`). Absent in snapshots that predate it. */
|
|
61
|
+
readonly source?: string;
|
|
62
|
+
}
|
|
63
|
+
/** A function as doctor needs it for RLS checks, in any schema. */
|
|
64
|
+
interface ExtrasFunction {
|
|
65
|
+
readonly schema: string;
|
|
66
|
+
readonly name: string;
|
|
67
|
+
/** Identity arguments, e.g. `org uuid`. */
|
|
68
|
+
readonly signature: string;
|
|
69
|
+
/** `sql`, `plpgsql`, `c`, ... */
|
|
70
|
+
readonly language: string;
|
|
71
|
+
readonly volatility: "immutable" | "stable" | "volatile";
|
|
72
|
+
readonly securityDefiner: boolean;
|
|
73
|
+
/** `set` options, e.g. `{ statement_timeout: '5s' }`. */
|
|
74
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
75
|
+
}
|
|
76
|
+
interface ExtrasTable {
|
|
77
|
+
/** Table oid, matching `GeneratorMetadata.tables[].id`. */
|
|
78
|
+
readonly id: number;
|
|
79
|
+
readonly schema: string;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
/** Primary key columns in key order. */
|
|
82
|
+
readonly primaryKey: readonly string[];
|
|
83
|
+
readonly uniques: readonly CatalogUnique[];
|
|
84
|
+
readonly foreignKeys: readonly {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly onDelete: ForeignKeyAction;
|
|
87
|
+
readonly onUpdate: ForeignKeyAction;
|
|
88
|
+
}[];
|
|
89
|
+
readonly checks: readonly CatalogCheck[];
|
|
90
|
+
readonly indexes: readonly CatalogIndex[];
|
|
91
|
+
readonly policies: readonly CatalogPolicy[];
|
|
92
|
+
readonly triggers: readonly CatalogTrigger[];
|
|
93
|
+
readonly grants: readonly CatalogGrant[];
|
|
94
|
+
/** Postgres estimates at least `LARGE_TABLE_ROWS` rows; the `unbounded-read` lint reads it. */
|
|
95
|
+
readonly large?: true;
|
|
96
|
+
}
|
|
97
|
+
type ForeignKeyAction = "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
98
|
+
interface CatalogUnique {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly columns: readonly string[];
|
|
101
|
+
}
|
|
102
|
+
interface CatalogCheck {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly definition: string;
|
|
105
|
+
}
|
|
106
|
+
interface CatalogIndex {
|
|
107
|
+
readonly name: string;
|
|
108
|
+
readonly columns: readonly string[];
|
|
109
|
+
readonly unique: boolean;
|
|
110
|
+
readonly primary: boolean;
|
|
111
|
+
readonly partial: boolean;
|
|
112
|
+
}
|
|
113
|
+
interface CatalogPolicy {
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly command: "all" | "select" | "insert" | "update" | "delete";
|
|
116
|
+
readonly roles: readonly string[];
|
|
117
|
+
readonly permissive: boolean;
|
|
118
|
+
readonly using: string | null;
|
|
119
|
+
readonly check: string | null;
|
|
120
|
+
/**
|
|
121
|
+
* Functions the policy expressions call, as `schema.name`, from
|
|
122
|
+
* `pg_depend`. Absent in older snapshots.
|
|
123
|
+
*/
|
|
124
|
+
readonly functions?: readonly string[];
|
|
125
|
+
}
|
|
126
|
+
interface CatalogTrigger {
|
|
127
|
+
readonly name: string;
|
|
128
|
+
readonly timing: "before" | "after" | "instead of";
|
|
129
|
+
readonly events: readonly ("insert" | "update" | "delete" | "truncate")[];
|
|
130
|
+
readonly level: "row" | "statement";
|
|
131
|
+
readonly function: string;
|
|
132
|
+
}
|
|
133
|
+
interface CatalogGrant {
|
|
134
|
+
readonly role: string;
|
|
135
|
+
readonly privileges: readonly string[];
|
|
136
|
+
}
|
|
137
|
+
interface SnapshotBucket {
|
|
138
|
+
readonly id: string;
|
|
139
|
+
readonly public: boolean;
|
|
140
|
+
readonly fileSizeLimit: number | null;
|
|
141
|
+
readonly allowedMimeTypes: readonly string[] | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The snapshot joined into one record per table, function and enum. Codegen
|
|
145
|
+
* and doctor read this view rather than the raw snapshot.
|
|
146
|
+
*/
|
|
147
|
+
interface Catalog {
|
|
148
|
+
readonly schemas: readonly string[];
|
|
149
|
+
readonly tables: readonly CatalogTable[];
|
|
150
|
+
readonly enums: readonly CatalogEnum[];
|
|
151
|
+
readonly functions: readonly CatalogFunction[];
|
|
152
|
+
readonly buckets: readonly SnapshotBucket[];
|
|
153
|
+
readonly realtime: readonly string[];
|
|
154
|
+
}
|
|
155
|
+
interface CatalogTable {
|
|
156
|
+
readonly id: number;
|
|
157
|
+
readonly schema: string;
|
|
158
|
+
readonly name: string;
|
|
159
|
+
/** Materialized views count as views; foreign tables as tables. */
|
|
160
|
+
readonly kind: "table" | "view";
|
|
161
|
+
readonly rls: boolean;
|
|
162
|
+
readonly forceRls: boolean;
|
|
163
|
+
readonly replicaIdentity: "DEFAULT" | "INDEX" | "FULL" | "NOTHING" | null;
|
|
164
|
+
/** Inserts work (always true for tables). */
|
|
165
|
+
readonly insertable: boolean;
|
|
166
|
+
/** Updates work (always true for tables). */
|
|
167
|
+
readonly updatable: boolean;
|
|
168
|
+
readonly comment: string | null;
|
|
169
|
+
readonly columns: readonly CatalogColumn[];
|
|
170
|
+
readonly primaryKey: readonly string[];
|
|
171
|
+
readonly uniques: readonly CatalogUnique[];
|
|
172
|
+
readonly foreignKeys: readonly CatalogForeignKey[];
|
|
173
|
+
readonly checks: readonly CatalogCheck[];
|
|
174
|
+
readonly indexes: readonly CatalogIndex[];
|
|
175
|
+
readonly policies: readonly CatalogPolicy[];
|
|
176
|
+
readonly triggers: readonly CatalogTrigger[];
|
|
177
|
+
readonly grants: readonly CatalogGrant[];
|
|
178
|
+
}
|
|
179
|
+
interface CatalogColumn {
|
|
180
|
+
readonly name: string;
|
|
181
|
+
/** Type name; the element type for arrays (`uuid`, `int8`, `note_kind`). */
|
|
182
|
+
readonly udt: string;
|
|
183
|
+
/** Raw type name as Postgres reports it (`_text` for `text[]`). */
|
|
184
|
+
readonly format: string;
|
|
185
|
+
readonly typeSchema: string;
|
|
186
|
+
readonly isArray: boolean;
|
|
187
|
+
readonly isEnum: boolean;
|
|
188
|
+
readonly nullable: boolean;
|
|
189
|
+
readonly hasDefault: boolean;
|
|
190
|
+
readonly default: string | null;
|
|
191
|
+
readonly identity: "always" | "by default" | null;
|
|
192
|
+
readonly generated: boolean;
|
|
193
|
+
readonly updatable: boolean;
|
|
194
|
+
readonly comment: string | null;
|
|
195
|
+
}
|
|
196
|
+
interface CatalogForeignKey {
|
|
197
|
+
readonly name: string;
|
|
198
|
+
readonly columns: readonly string[];
|
|
199
|
+
readonly refSchema: string;
|
|
200
|
+
readonly refTable: string;
|
|
201
|
+
readonly refColumns: readonly string[];
|
|
202
|
+
readonly oneToOne: boolean;
|
|
203
|
+
readonly onDelete: ForeignKeyAction;
|
|
204
|
+
readonly onUpdate: ForeignKeyAction;
|
|
205
|
+
}
|
|
206
|
+
interface CatalogEnum {
|
|
207
|
+
readonly schema: string;
|
|
208
|
+
readonly name: string;
|
|
209
|
+
readonly values: readonly string[];
|
|
210
|
+
}
|
|
211
|
+
interface CatalogFunction {
|
|
212
|
+
readonly schema: string;
|
|
213
|
+
readonly name: string;
|
|
214
|
+
/** Signature that tells overloads apart, e.g. `a integer, b text`. */
|
|
215
|
+
readonly signature: string;
|
|
216
|
+
readonly args: readonly CatalogFunctionArg[];
|
|
217
|
+
/** Columns for `returns table (...)` functions. */
|
|
218
|
+
readonly returnsTable: readonly {
|
|
219
|
+
readonly name: string;
|
|
220
|
+
readonly udt: string;
|
|
221
|
+
}[] | null;
|
|
222
|
+
/** Return type name (`int4`, `_text`, a table's row type). */
|
|
223
|
+
readonly returns: string;
|
|
224
|
+
/** `schema.table` when the function returns rows of a table or view. */
|
|
225
|
+
readonly returnsRelation: string | null;
|
|
226
|
+
readonly returnsSet: boolean;
|
|
227
|
+
readonly volatility: "immutable" | "stable" | "volatile";
|
|
228
|
+
readonly securityDefiner: boolean;
|
|
229
|
+
readonly language: string;
|
|
230
|
+
/** `search_path` from `SET search_path`, or `null` when unset. */
|
|
231
|
+
readonly searchPath: string | null;
|
|
232
|
+
}
|
|
233
|
+
interface CatalogFunctionArg {
|
|
234
|
+
readonly name: string;
|
|
235
|
+
readonly udt: string;
|
|
236
|
+
readonly isArray: boolean;
|
|
237
|
+
readonly hasDefault: boolean;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/generators/shared.d.ts
|
|
241
|
+
/** What field planning reads: the metadata and the typed-jsonb config. */
|
|
242
|
+
interface SchemaSource {
|
|
243
|
+
readonly meta: SchemaMeta;
|
|
244
|
+
readonly config: {
|
|
245
|
+
readonly json: Readonly<Record<string, unknown>>;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/generators/json-schema.d.ts
|
|
250
|
+
interface JsonSchemaGeneratorOptions {
|
|
251
|
+
/** Output path relative to the project root. Defaults to `<output>.schema.json`. */
|
|
252
|
+
readonly output?: string;
|
|
253
|
+
/** `$id` of the document. */
|
|
254
|
+
readonly id?: string;
|
|
255
|
+
}
|
|
256
|
+
type JsonSchema = Record<string, unknown>;
|
|
257
|
+
/** JSON Schema (2020-12) `$defs` for every table: `customersRow`, `customersInsert`, ... */
|
|
258
|
+
declare function buildJsonSchema(input: SchemaSource, id?: string): JsonSchema;
|
|
259
|
+
/** Writes the JSON Schema document; `createOpenApi` reuses the same `$defs`. */
|
|
260
|
+
declare function jsonSchema(options?: JsonSchemaGeneratorOptions): Generator;
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/generators/valibot.d.ts
|
|
263
|
+
interface ValibotGeneratorOptions {
|
|
264
|
+
/** Output path relative to the project root. Defaults to `<output>.valibot.ts`. */
|
|
265
|
+
readonly output?: string;
|
|
266
|
+
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
267
|
+
readonly json?: Readonly<Record<string, string>>;
|
|
268
|
+
}
|
|
269
|
+
/** Valibot schemas for every table's Row, Insert and Update shape. */
|
|
270
|
+
declare function valibot(options?: ValibotGeneratorOptions): Generator;
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/generators/zod.d.ts
|
|
273
|
+
interface ZodGeneratorOptions {
|
|
274
|
+
/** Output path relative to the project root. Defaults to `<output>.zod.ts`. */
|
|
275
|
+
readonly output?: string;
|
|
276
|
+
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
277
|
+
readonly json?: Readonly<Record<string, string>>;
|
|
278
|
+
}
|
|
279
|
+
/** Zod 4 schemas for every table's Row, Insert and Update shape. */
|
|
280
|
+
declare function zod(options?: ZodGeneratorOptions): Generator;
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/config/index.d.ts
|
|
283
|
+
/**
|
|
284
|
+
* Where codegen reads the database from. Without any of these, `$DATABASE_URL`
|
|
285
|
+
* and then the local stack (`supabase start`) are used.
|
|
286
|
+
*/
|
|
287
|
+
interface SourceConfig {
|
|
288
|
+
/** Postgres connection string. */
|
|
289
|
+
readonly dbUrl?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Hosted project ref. Read through the Management API's read-only SQL
|
|
292
|
+
* endpoint, so no database password is needed.
|
|
293
|
+
*/
|
|
294
|
+
readonly projectRef?: string;
|
|
295
|
+
/**
|
|
296
|
+
* Management API token for `projectRef`. Defaults to
|
|
297
|
+
* `$SUPABASE_ACCESS_TOKEN`; prefer the env var over committing a token.
|
|
298
|
+
*/
|
|
299
|
+
readonly accessToken?: string;
|
|
300
|
+
/** Read a saved `better-supabase introspect` snapshot instead of connecting. */
|
|
301
|
+
readonly snapshot?: string;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* A JSON Schema object, or a Standard JSON Schema value (zod 4, valibot,
|
|
305
|
+
* arktype, ...) that can produce one.
|
|
306
|
+
*/
|
|
307
|
+
type JsonSchemaSource = Readonly<Record<string, unknown>> | {
|
|
308
|
+
readonly "~standard": {
|
|
309
|
+
readonly jsonSchema: {
|
|
310
|
+
readonly input: (options: {
|
|
311
|
+
readonly target: string;
|
|
312
|
+
}) => Record<string, unknown>;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
type JsonTypeConfig = ({
|
|
317
|
+
readonly import: string;
|
|
318
|
+
} | {
|
|
319
|
+
readonly type: string;
|
|
320
|
+
}) & {
|
|
321
|
+
/** Enforced in the database by `sql add jsonb-schemas` (pg_jsonschema). */
|
|
322
|
+
readonly schema?: JsonSchemaSource;
|
|
323
|
+
};
|
|
324
|
+
/** The JSON Schema document for a `json[...].schema` entry. */
|
|
325
|
+
declare function resolveJsonSchema(source: JsonSchemaSource): Readonly<Record<string, unknown>>;
|
|
326
|
+
interface TableConfig {
|
|
327
|
+
readonly casing?: Casing;
|
|
328
|
+
/** Leave the table out of the generated models. */
|
|
329
|
+
readonly exclude?: boolean;
|
|
330
|
+
/** Rename generated relations: `{ primaryContact: 'contact' }`. */
|
|
331
|
+
readonly relations?: Readonly<Record<string, string>>;
|
|
332
|
+
}
|
|
333
|
+
interface TimestampsConfig {
|
|
334
|
+
readonly createdAt?: string;
|
|
335
|
+
readonly updatedAt?: string;
|
|
336
|
+
}
|
|
337
|
+
interface SoftDeleteConfig {
|
|
338
|
+
readonly column?: string;
|
|
339
|
+
}
|
|
340
|
+
interface TenantConfig {
|
|
341
|
+
readonly column?: string;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Claim names shared by the SQL kit, codegen and the runtime defaults. They
|
|
345
|
+
* follow PermDock's claim contract.
|
|
346
|
+
*/
|
|
347
|
+
interface ClaimsConfig {
|
|
348
|
+
/** Top-level claim holding the active tenant id. Defaults to `tenant_id`. */
|
|
349
|
+
readonly tenant?: string;
|
|
350
|
+
/** `scope` of the tenant entries `membership_claims()` writes. Defaults to `tenant`. */
|
|
351
|
+
readonly scope?: string;
|
|
352
|
+
/** Claim holding plan features per tenant (`{ [tenantId]: string[] }`). Defaults to `features`. */
|
|
353
|
+
readonly features?: string;
|
|
354
|
+
}
|
|
355
|
+
interface ActorConfig {
|
|
356
|
+
readonly createdBy?: string;
|
|
357
|
+
readonly updatedBy?: string;
|
|
358
|
+
}
|
|
359
|
+
interface PluginFlagsConfig {
|
|
360
|
+
readonly timestamps?: boolean | TimestampsConfig;
|
|
361
|
+
readonly softDelete?: boolean | SoftDeleteConfig;
|
|
362
|
+
readonly tenant?: boolean | TenantConfig;
|
|
363
|
+
readonly actor?: boolean | ActorConfig;
|
|
364
|
+
}
|
|
365
|
+
interface BucketConfig {
|
|
366
|
+
readonly id?: string;
|
|
367
|
+
readonly public?: boolean;
|
|
368
|
+
/** Path template with `{placeholders}`, e.g. `{orgId}/{customerId}/logo.webp`. */
|
|
369
|
+
readonly path: string;
|
|
370
|
+
/** Generated storage policy, or a PermDock policy (`{ permdock, scope }`). */
|
|
371
|
+
readonly policy?: BucketPolicyName | PermdockBucketPolicy;
|
|
372
|
+
readonly fileSizeLimit?: string;
|
|
373
|
+
readonly allowedMimeTypes?: readonly string[];
|
|
374
|
+
}
|
|
375
|
+
interface SqlConfig {
|
|
376
|
+
/** Directory declarative schema files are written to. */
|
|
377
|
+
readonly dir?: string;
|
|
378
|
+
/** File name prefix, so generated files sort after yours. */
|
|
379
|
+
readonly prefix?: string;
|
|
380
|
+
/** Directory pgTAP files (the `pgtap` module) are written to. */
|
|
381
|
+
readonly testsDir?: string;
|
|
382
|
+
/** SQL kit modules to keep in sync (`better-supabase sql add`). */
|
|
383
|
+
readonly kit?: readonly string[];
|
|
384
|
+
}
|
|
385
|
+
interface SeedConfig {
|
|
386
|
+
/** Module exporting `defineSeed(...)` as `seed` or default. */
|
|
387
|
+
readonly entry?: string;
|
|
388
|
+
/** SQL file `better-supabase seed` writes. Add it to `[db.seed] sql_paths`. */
|
|
389
|
+
readonly output?: string;
|
|
390
|
+
}
|
|
391
|
+
interface OpenApiConfig {
|
|
392
|
+
/** Module exporting the document (or a function returning it) as `openapi` or default. */
|
|
393
|
+
readonly entry?: string;
|
|
394
|
+
/** JSON file `better-supabase openapi emit` writes. */
|
|
395
|
+
readonly output?: string;
|
|
396
|
+
}
|
|
397
|
+
interface DoctorConfig {
|
|
398
|
+
/** Finding codes to skip, e.g. `['BS204']`. */
|
|
399
|
+
readonly ignore?: readonly string[];
|
|
400
|
+
/** Treat warnings as errors. */
|
|
401
|
+
readonly strict?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* App source files doctor scans for API use (BS210). Globs relative to the
|
|
404
|
+
* root. Defaults to `['src/**\/*.{ts,tsx}']`.
|
|
405
|
+
*/
|
|
406
|
+
readonly sources?: readonly string[];
|
|
407
|
+
/**
|
|
408
|
+
* How many policies a security definer helper may appear in before BS206
|
|
409
|
+
* asks for an inlinable `language sql stable` function. Defaults to 5.
|
|
410
|
+
*/
|
|
411
|
+
readonly policyHelperLimit?: number;
|
|
412
|
+
/**
|
|
413
|
+
* The BS405 limit in bytes. With a `permdock.config.ts` it is PermDock's
|
|
414
|
+
* budget for `memberships` plus `attrs` (default 1024, matching
|
|
415
|
+
* `supabase.hook.budget`) and the whole token keeps 2048. Without one it
|
|
416
|
+
* limits the whole token's claims (default 2048).
|
|
417
|
+
*/
|
|
418
|
+
readonly claimsLimit?: number;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Runtime types for columns whose JSON form loses information. Defaults
|
|
422
|
+
* match `supabase gen types`: timestamps as ISO strings, `int8` and
|
|
423
|
+
* `numeric` as numbers.
|
|
424
|
+
*/
|
|
425
|
+
interface CodecsConfig {
|
|
426
|
+
/** `'date'` decodes `timestamptz`/`timestamp` columns to `Date`. */
|
|
427
|
+
readonly timestamptz?: "string" | "date";
|
|
428
|
+
/** `'bigint'` or `'string'` read `int8` exactly (above 2^53). */
|
|
429
|
+
readonly int8?: "number" | "string" | "bigint";
|
|
430
|
+
/** `'string'` reads `numeric` exactly. */
|
|
431
|
+
readonly numeric?: "number" | "string";
|
|
432
|
+
}
|
|
433
|
+
interface GeneratedFile {
|
|
434
|
+
/** Path relative to the project root. */
|
|
435
|
+
readonly path: string;
|
|
436
|
+
readonly contents: string;
|
|
437
|
+
}
|
|
438
|
+
interface GeneratorInput {
|
|
439
|
+
readonly meta: SchemaMeta;
|
|
440
|
+
/**
|
|
441
|
+
* The `@supabase/postgrest-typegen` metadata for the configured schemas,
|
|
442
|
+
* the same contract `supabase gen types` is built on.
|
|
443
|
+
*/
|
|
444
|
+
readonly introspection: GeneratorMetadata;
|
|
445
|
+
/** Constraints, indexes, policies, triggers and grants typegen leaves out. */
|
|
446
|
+
readonly extras: SnapshotExtras;
|
|
447
|
+
readonly config: ResolvedConfig;
|
|
448
|
+
/** Absolute path of the main generated module. */
|
|
449
|
+
readonly output: string;
|
|
450
|
+
/** Import path from `from` (a generated file) to `to`, with extension. */
|
|
451
|
+
readonly importPath: (from: string, to: string) => string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Codegen extension point. First-party generators: `zod()`, `valibot()`,
|
|
455
|
+
* `jsonSchema()`. Prove custom ones with `testGenerator`.
|
|
456
|
+
*/
|
|
457
|
+
interface Generator {
|
|
458
|
+
readonly name: string;
|
|
459
|
+
generate(input: GeneratorInput): readonly GeneratedFile[] | Promise<readonly GeneratedFile[]>;
|
|
460
|
+
}
|
|
461
|
+
interface RealtimeConfig {
|
|
462
|
+
/**
|
|
463
|
+
* Tables that broadcast a change signal for live queries (`table` or
|
|
464
|
+
* `schema.table`). Tenant tables broadcast per tenant. Install the
|
|
465
|
+
* triggers with `better-supabase sql add realtime-tables`.
|
|
466
|
+
*/
|
|
467
|
+
readonly tables?: readonly string[];
|
|
468
|
+
}
|
|
469
|
+
interface EntitlementsConfig {
|
|
470
|
+
/**
|
|
471
|
+
* `table.column` (or `schema.table.column`) holding each tenant's Stripe
|
|
472
|
+
* customer id, read by the `entitlements` SQL kit module. Defaults to
|
|
473
|
+
* `organizations.stripe_customer_id`.
|
|
474
|
+
*/
|
|
475
|
+
readonly customer?: string;
|
|
476
|
+
/** The tenant id column of that table. Defaults to `id`. */
|
|
477
|
+
readonly key?: string;
|
|
478
|
+
}
|
|
479
|
+
/** pgvector distance: `<=>` (cosine), `<->` (l2) or `<#>` (negative inner product). */
|
|
480
|
+
type VectorDistance = "cosine" | "l2" | "inner_product";
|
|
481
|
+
/** The embedding column, or the column and its distance (default `cosine`). */
|
|
482
|
+
type VectorSearchConfig = string | {
|
|
483
|
+
readonly column: string;
|
|
484
|
+
readonly distance?: VectorDistance;
|
|
485
|
+
};
|
|
486
|
+
/** A privilege the Data API roles can be granted on a table or view. */
|
|
487
|
+
type Privilege = "select" | "insert" | "update" | "delete";
|
|
488
|
+
/**
|
|
489
|
+
* Data API grants for one table: privileges for `authenticated`, or per
|
|
490
|
+
* role.
|
|
491
|
+
*/
|
|
492
|
+
type ExposeConfig = readonly Privilege[] | {
|
|
493
|
+
readonly anon?: readonly Privilege[];
|
|
494
|
+
readonly authenticated?: readonly Privilege[];
|
|
495
|
+
};
|
|
496
|
+
/** Resolved grants for one table. */
|
|
497
|
+
interface ResolvedExpose {
|
|
498
|
+
readonly anon: readonly Privilege[];
|
|
499
|
+
readonly authenticated: readonly Privilege[];
|
|
500
|
+
}
|
|
501
|
+
interface BetterSupabaseConfig {
|
|
502
|
+
readonly $schema?: string;
|
|
503
|
+
readonly source?: SourceConfig;
|
|
504
|
+
/** Postgres schemas to generate. Defaults to `['public']`. */
|
|
505
|
+
readonly schemas?: readonly string[];
|
|
506
|
+
/** Casing of generated models and returned rows. Defaults to `'snake'`. */
|
|
507
|
+
readonly casing?: Casing;
|
|
508
|
+
readonly tables?: Readonly<Record<string, TableConfig>>;
|
|
509
|
+
/**
|
|
510
|
+
* Main generated module. Defaults to `src/lib/supabase/generated.ts`;
|
|
511
|
+
* `database.types.ts` is written next to it.
|
|
512
|
+
*/
|
|
513
|
+
readonly output?: string;
|
|
514
|
+
/**
|
|
515
|
+
* PostgREST major version, written to `__InternalSupabase` in
|
|
516
|
+
* `database.types.ts` so `createClient` picks matching behavior.
|
|
517
|
+
* Defaults to `'13'`.
|
|
518
|
+
*/
|
|
519
|
+
readonly postgrestVersion?: string;
|
|
520
|
+
/** Types for jsonb columns, keyed by `table.column`. */
|
|
521
|
+
readonly json?: Readonly<Record<string, JsonTypeConfig>>;
|
|
522
|
+
readonly codecs?: CodecsConfig;
|
|
523
|
+
/**
|
|
524
|
+
* Columns that must not be read by accident (`table.column` or
|
|
525
|
+
* `schema.table.column`, database names), for the `noSensitiveSelect` rule.
|
|
526
|
+
*/
|
|
527
|
+
readonly sensitive?: readonly string[];
|
|
528
|
+
/**
|
|
529
|
+
* Text columns that hold an object path, keyed by `table.column` or
|
|
530
|
+
* `schema.table.column` (database names), with the bucket as the value (a
|
|
531
|
+
* `buckets` key or a bucket id). Generated rows type them as
|
|
532
|
+
* `StoragePath<'bucket-id'>`.
|
|
533
|
+
*/
|
|
534
|
+
readonly storagePaths?: Readonly<Record<string, string>>;
|
|
535
|
+
/**
|
|
536
|
+
* Data API grants, keyed by `table` or `schema.table`. Supabase no longer
|
|
537
|
+
* grants new tables to `anon` and `authenticated` automatically; the
|
|
538
|
+
* `grants` SQL kit module writes these, and doctor (BS106) checks them.
|
|
539
|
+
* Tables not listed need `select, insert, update, delete` for
|
|
540
|
+
* `authenticated` (`select` for views).
|
|
541
|
+
*/
|
|
542
|
+
readonly expose?: Readonly<Record<string, ExposeConfig>>;
|
|
543
|
+
/**
|
|
544
|
+
* Modules that export `defineReadSet` results. `gen` compiles each set to
|
|
545
|
+
* a function in the `read-sets` SQL kit module. Node imports them, so
|
|
546
|
+
* relative imports need their `.ts` extension.
|
|
547
|
+
*/
|
|
548
|
+
readonly readSets?: readonly string[];
|
|
549
|
+
readonly generators?: readonly Generator[];
|
|
550
|
+
/** Enables plugin flags in the generated metadata. */
|
|
551
|
+
readonly plugins?: PluginFlagsConfig;
|
|
552
|
+
readonly claims?: ClaimsConfig;
|
|
553
|
+
readonly buckets?: Readonly<Record<string, BucketConfig>>;
|
|
554
|
+
/** Realtime topic templates: `{ notifications: 'org:{orgId}:notifications' }`. */
|
|
555
|
+
readonly topics?: Readonly<Record<string, string>>;
|
|
556
|
+
readonly realtime?: RealtimeConfig;
|
|
557
|
+
readonly entitlements?: EntitlementsConfig;
|
|
558
|
+
/**
|
|
559
|
+
* Embedding columns, keyed by `table` or `schema.table`. The
|
|
560
|
+
* `vector-search` SQL kit module writes `search_<table>(query, k)` for each,
|
|
561
|
+
* which `db.$search(table, { vector, k })` calls.
|
|
562
|
+
*/
|
|
563
|
+
readonly vectorSearch?: Readonly<Record<string, VectorSearchConfig>>;
|
|
564
|
+
readonly sql?: SqlConfig;
|
|
565
|
+
readonly seed?: SeedConfig;
|
|
566
|
+
readonly openapi?: OpenApiConfig;
|
|
567
|
+
readonly doctor?: DoctorConfig;
|
|
568
|
+
}
|
|
569
|
+
/** The config with defaults applied. */
|
|
570
|
+
interface ResolvedConfig {
|
|
571
|
+
readonly root: string;
|
|
572
|
+
readonly source: SourceConfig;
|
|
573
|
+
readonly schemas: readonly string[];
|
|
574
|
+
readonly casing: Casing;
|
|
575
|
+
readonly tables: Readonly<Record<string, TableConfig>>;
|
|
576
|
+
readonly output: string;
|
|
577
|
+
/** `database.types.ts` next to `output`. */
|
|
578
|
+
readonly databaseTypesOutput: string;
|
|
579
|
+
readonly postgrestVersion: string;
|
|
580
|
+
readonly json: Readonly<Record<string, JsonTypeConfig>>;
|
|
581
|
+
readonly codecs: Required<CodecsConfig>;
|
|
582
|
+
readonly sensitive: readonly string[];
|
|
583
|
+
readonly storagePaths: Readonly<Record<string, string>>;
|
|
584
|
+
readonly expose: Readonly<Record<string, ResolvedExpose>>;
|
|
585
|
+
readonly readSets: readonly string[];
|
|
586
|
+
readonly generators: readonly Generator[];
|
|
587
|
+
readonly plugins: {
|
|
588
|
+
readonly timestamps: Required<TimestampsConfig> | undefined;
|
|
589
|
+
readonly softDelete: Required<SoftDeleteConfig> | undefined;
|
|
590
|
+
readonly tenant: Required<TenantConfig> | undefined;
|
|
591
|
+
readonly actor: Required<ActorConfig> | undefined;
|
|
592
|
+
};
|
|
593
|
+
readonly claims: Required<ClaimsConfig>;
|
|
594
|
+
readonly buckets: Readonly<Record<string, BucketConfig>>;
|
|
595
|
+
readonly entitlements: {
|
|
596
|
+
readonly table: string;
|
|
597
|
+
readonly column: string;
|
|
598
|
+
readonly key: string;
|
|
599
|
+
};
|
|
600
|
+
readonly vectorSearch: readonly {
|
|
601
|
+
readonly table: string;
|
|
602
|
+
readonly column: string;
|
|
603
|
+
readonly distance: VectorDistance;
|
|
604
|
+
}[];
|
|
605
|
+
readonly topics: Readonly<Record<string, string>>;
|
|
606
|
+
readonly realtime: Required<RealtimeConfig>;
|
|
607
|
+
readonly sql: Required<SqlConfig>;
|
|
608
|
+
readonly seed: Required<SeedConfig>;
|
|
609
|
+
readonly openapi: Required<OpenApiConfig>;
|
|
610
|
+
readonly doctor: Required<Omit<DoctorConfig, "claimsLimit">> & Pick<DoctorConfig, "claimsLimit">;
|
|
611
|
+
}
|
|
612
|
+
declare const CONFIG_SCHEMA_URL = "https://unpkg.com/better-supabase/schemas/config-v1.json";
|
|
613
|
+
/** Identity helper that types `better-supabase.config.ts`. */
|
|
614
|
+
declare function defineConfig(config: BetterSupabaseConfig): BetterSupabaseConfig;
|
|
615
|
+
/** Applies defaults. Paths stay relative to `root`. */
|
|
616
|
+
declare function resolveConfig(config: BetterSupabaseConfig, root: string): ResolvedConfig;
|
|
617
|
+
//#endregion
|
|
618
|
+
export { ExtrasFunction as $, defineConfig as A, Catalog as B, SourceConfig as C, TimestampsConfig as D, TenantConfig as E, ValibotGeneratorOptions as F, CatalogFunction as G, CatalogColumn as H, valibot as I, CatalogIndex as J, CatalogFunctionArg as K, JsonSchemaGeneratorOptions as L, resolveJsonSchema as M, ZodGeneratorOptions as N, VectorDistance as O, zod as P, CatalogUnique as Q, buildJsonSchema as R, SoftDeleteConfig as S, TableConfig as T, CatalogEnum as U, CatalogCheck as V, CatalogForeignKey as W, CatalogTable as X, CatalogPolicy as Y, CatalogTrigger as Z, Privilege as _, ClaimsConfig as a, SnapshotBucket as at, ResolvedExpose as b, EntitlementsConfig as c, Queryable as ct, Generator as d, ExtrasHook as et, GeneratorInput as f, PluginFlagsConfig as g, OpenApiConfig as h, CONFIG_SCHEMA_URL as i, Snapshot as it, resolveConfig as j, VectorSearchConfig as k, ExposeConfig as l, JsonTypeConfig as m, BetterSupabaseConfig as n, ExtrasTable as nt, CodecsConfig as o, SnapshotExtras as ot, JsonSchemaSource as p, CatalogGrant as q, BucketConfig as r, ForeignKeyAction as rt, DoctorConfig as s, GeneratorMetadata as st, ActorConfig as t, ExtrasHookFunction as tt, GeneratedFile as u, RealtimeConfig as v, SqlConfig as w, SeedConfig as x, ResolvedConfig as y, jsonSchema as z };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { A as SchemaMeta } from "./types-C83v5SQz.js";
|
|
2
|
+
import { f as OpenApiParameter } from "./index-Bw1bwtC0.js";
|
|
3
|
+
//#region src/openapi/index.d.ts
|
|
4
|
+
type Json = Record<string, unknown>;
|
|
5
|
+
type ResourceOperation = "list" | "get" | "create" | "update" | "delete";
|
|
6
|
+
interface ResourceOptions {
|
|
7
|
+
/** Defaults to every operation for tables, `list` and `get` for views. */
|
|
8
|
+
readonly operations?: readonly ResourceOperation[];
|
|
9
|
+
/** Parameters for `list`, from `defineListQuery`. */
|
|
10
|
+
readonly list?: {
|
|
11
|
+
readonly openapi: readonly OpenApiParameter[];
|
|
12
|
+
};
|
|
13
|
+
/** Path of the collection. Defaults to `/<table>`. */
|
|
14
|
+
readonly path?: string;
|
|
15
|
+
readonly tag?: string;
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
}
|
|
18
|
+
interface OpenApiOptions {
|
|
19
|
+
readonly info: {
|
|
20
|
+
readonly title: string;
|
|
21
|
+
readonly version: string;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
};
|
|
24
|
+
readonly servers?: readonly {
|
|
25
|
+
readonly url: string;
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
}[];
|
|
28
|
+
/** Prefix for every path, e.g. `/api`. */
|
|
29
|
+
readonly basePath?: string;
|
|
30
|
+
/** Tables to publish, by app key. */
|
|
31
|
+
readonly resources: Readonly<Record<string, ResourceOptions | true>>;
|
|
32
|
+
/**
|
|
33
|
+
* Security schemes. `bearer` is a Supabase access token; `oauth2` uses the
|
|
34
|
+
* Supabase OAuth server and needs `supabaseUrl`. Defaults to `['bearer']`.
|
|
35
|
+
*/
|
|
36
|
+
readonly security?: readonly ("bearer" | "oauth2")[];
|
|
37
|
+
readonly supabaseUrl?: string;
|
|
38
|
+
/** Tables with a JSON column typed in `better-supabase.config.ts`. */
|
|
39
|
+
readonly json?: Readonly<Record<string, unknown>>;
|
|
40
|
+
}
|
|
41
|
+
interface OpenApiDocument {
|
|
42
|
+
readonly openapi: string;
|
|
43
|
+
readonly info: OpenApiOptions["info"];
|
|
44
|
+
readonly jsonSchemaDialect: string;
|
|
45
|
+
readonly servers?: OpenApiOptions["servers"];
|
|
46
|
+
readonly tags: readonly {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
}[];
|
|
50
|
+
readonly paths: Readonly<Record<string, Json>>;
|
|
51
|
+
readonly components: {
|
|
52
|
+
readonly schemas: Readonly<Record<string, Json>>;
|
|
53
|
+
readonly responses: Readonly<Record<string, Json>>;
|
|
54
|
+
readonly securitySchemes: Readonly<Record<string, Json>>;
|
|
55
|
+
};
|
|
56
|
+
readonly security: readonly Readonly<Record<string, readonly string[]>>[];
|
|
57
|
+
}
|
|
58
|
+
/** JSON Schema for RFC 9457 Problem Details as better-supabase sends them. */
|
|
59
|
+
declare const PROBLEM_SCHEMA: Json;
|
|
60
|
+
/**
|
|
61
|
+
* An OpenAPI 3.1 document for REST resources over your tables, with schemas
|
|
62
|
+
* from the generated metadata, list-query parameters, Supabase security
|
|
63
|
+
* schemes and Problem Details errors.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* const doc = createOpenApi(sb, {
|
|
67
|
+
* info: { title: 'CRM API', version: '1.0.0' },
|
|
68
|
+
* resources: { customers: { list: customerList }, notes: { operations: ['list', 'get'] } },
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function createOpenApi(sb: {
|
|
73
|
+
readonly meta: SchemaMeta;
|
|
74
|
+
}, options: OpenApiOptions): OpenApiDocument;
|
|
75
|
+
//#endregion
|
|
76
|
+
export { ResourceOptions as a, ResourceOperation as i, OpenApiOptions as n, createOpenApi as o, PROBLEM_SCHEMA as r, OpenApiDocument as t };
|