better-supabase 0.0.0 → 0.1.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 +3 -0
- package/dist/casing-da0uRTqt.js +14 -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-CoByWYja.js +6472 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +112 -0
- package/dist/compiler-DL18ukPe.d.ts +14 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +3 -0
- package/dist/config-D-aR2ZoN.js +276 -0
- package/dist/define-CTfWw-SS.d.ts +662 -0
- package/dist/define-QGkq04oe.js +1068 -0
- package/dist/edge/index.d.ts +43 -0
- package/dist/edge/index.js +103 -0
- package/dist/entitlements-BBg61DQZ.d.ts +20 -0
- package/dist/entitlements-BC_khwRy.js +17 -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-2OJsVG_d.d.ts +84 -0
- package/dist/events-BuzTgn2D.js +135 -0
- package/dist/executor-Bazhgsgq.d.ts +195 -0
- package/dist/executor-Bje4suQF.d.ts +25 -0
- package/dist/executor-Ceq60hPM.js +89 -0
- package/dist/hono/index.d.ts +45 -0
- package/dist/hono/index.js +70 -0
- package/dist/index-BD6wKthp.d.ts +597 -0
- package/dist/index-DQVvHzjW.d.ts +74 -0
- package/dist/index-DRid0qIv.d.ts +76 -0
- package/dist/index-Dup-nSe9.d.ts +117 -0
- package/dist/index-Dy6kuF0P.d.ts +71 -0
- package/dist/index-Hf8PP9sP.d.ts +116 -0
- package/dist/index-JXHBuS53.d.ts +144 -0
- package/dist/index-Nxo3TJcm.d.ts +208 -0
- package/dist/index-Sw43J8HG.d.ts +62 -0
- package/dist/index-cEeweTeM.d.ts +38 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +42 -0
- package/dist/invalidate-DbxuL2jL.js +18 -0
- package/dist/jobs/index.d.ts +173 -0
- package/dist/jobs/index.js +477 -0
- package/dist/json-schema-BbwO2mZg.js +181 -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-6b9i72Ux.d.ts +180 -0
- package/dist/live-D8rV1Ldw.js +168 -0
- package/dist/mcp/index.d.ts +105 -0
- package/dist/mcp/index.js +330 -0
- package/dist/mfa-CpogP66z.js +521 -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 +426 -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/plugin-BqR6wKMB.js +23 -0
- package/dist/plugin-HvGqCurB.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 +88 -0
- package/dist/plugins/rules/index.js +174 -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 +43 -0
- package/dist/plugins/tenant/index.js +73 -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-BFeqzwQS.d.ts +37 -0
- package/dist/postgres/index.d.ts +28 -0
- package/dist/postgres/index.js +79 -0
- package/dist/postgrest-Dm-vhY6R.d.ts +43 -0
- package/dist/problem-DPu6Fh-t.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-CrOvrnIP.js +241 -0
- package/dist/read-set-DhX2d04c.js +216 -0
- package/dist/realtime/index.d.ts +3 -0
- package/dist/realtime/index.js +253 -0
- package/dist/resolve-DW8h9NPm.d.ts +155 -0
- package/dist/resource-CYiu6Ygi.js +175 -0
- package/dist/resource-SkPTRJDD.d.ts +65 -0
- package/dist/respond-4-dhoV7x.js +380 -0
- package/dist/respond-PoTpy5DT.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-C3osL21k.d.ts +21 -0
- package/dist/session-CD-3orO_.js +19 -0
- package/dist/shared-_6-uPL7E.js +57 -0
- package/dist/simplify-oHiDKRVQ.js +665 -0
- package/dist/spec-pins-CJPVghHy.d.ts +20 -0
- package/dist/spec-pins-t6sPaHvl.js +20 -0
- package/dist/sql-M8l3fnS0.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-3iy8u3_P.js +566 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage-BWXVUXGk.js +461 -0
- package/dist/tables-rZxRxNPW.js +59 -0
- package/dist/template-BeOGnynM.js +93 -0
- package/dist/template-mbvlysOo.d.ts +6 -0
- package/dist/testing/index.d.ts +294 -0
- package/dist/testing/index.js +751 -0
- package/dist/types-6cYK9pbJ.js +29 -0
- package/dist/types-C2fslP1z.d.ts +195 -0
- package/dist/version-Cqq1m3UY.js +4 -0
- package/dist/view-B0ltUmTi.d.ts +43 -0
- package/dist/view-B6F9QbG-.js +35 -0
- package/dist/webhooks/index.d.ts +152 -0
- package/dist/webhooks/index.js +2 -0
- package/dist/webhooks-DbMTJJX2.js +139 -0
- package/package.json +246 -17
- package/schemas/config-v1.json +328 -0
- package/schemas/doctor-report-v1.json +105 -0
- package/schemas/snapshot-v2.json +1002 -0
- package/skills/better-supabase/SKILL.md +84 -0
- package/skills/better-supabase/references/plugins.md +56 -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 +65 -0
- package/index.js +0 -1
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
import { E as SchemaMeta, i as Casing } from "./types-C2fslP1z.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
|
+
}
|
|
61
|
+
/** A function as doctor needs it for RLS checks, in any schema. */
|
|
62
|
+
interface ExtrasFunction {
|
|
63
|
+
readonly schema: string;
|
|
64
|
+
readonly name: string;
|
|
65
|
+
/** Identity arguments, e.g. `org uuid`. */
|
|
66
|
+
readonly signature: string;
|
|
67
|
+
/** `sql`, `plpgsql`, `c`, ... */
|
|
68
|
+
readonly language: string;
|
|
69
|
+
readonly volatility: "immutable" | "stable" | "volatile";
|
|
70
|
+
readonly securityDefiner: boolean;
|
|
71
|
+
/** `set` options, e.g. `{ statement_timeout: '5s' }`. */
|
|
72
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
73
|
+
}
|
|
74
|
+
interface ExtrasTable {
|
|
75
|
+
/** Table oid, matching `GeneratorMetadata.tables[].id`. */
|
|
76
|
+
readonly id: number;
|
|
77
|
+
readonly schema: string;
|
|
78
|
+
readonly name: string;
|
|
79
|
+
/** Primary key columns in key order. */
|
|
80
|
+
readonly primaryKey: readonly string[];
|
|
81
|
+
readonly uniques: readonly CatalogUnique[];
|
|
82
|
+
readonly foreignKeys: readonly {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly onDelete: ForeignKeyAction;
|
|
85
|
+
readonly onUpdate: ForeignKeyAction;
|
|
86
|
+
}[];
|
|
87
|
+
readonly checks: readonly CatalogCheck[];
|
|
88
|
+
readonly indexes: readonly CatalogIndex[];
|
|
89
|
+
readonly policies: readonly CatalogPolicy[];
|
|
90
|
+
readonly triggers: readonly CatalogTrigger[];
|
|
91
|
+
readonly grants: readonly CatalogGrant[];
|
|
92
|
+
/** Postgres estimates at least `LARGE_TABLE_ROWS` rows; the `unbounded-read` lint reads it. */
|
|
93
|
+
readonly large?: true;
|
|
94
|
+
}
|
|
95
|
+
type ForeignKeyAction = "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
96
|
+
interface CatalogUnique {
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly columns: readonly string[];
|
|
99
|
+
}
|
|
100
|
+
interface CatalogCheck {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly definition: string;
|
|
103
|
+
}
|
|
104
|
+
interface CatalogIndex {
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly columns: readonly string[];
|
|
107
|
+
readonly unique: boolean;
|
|
108
|
+
readonly primary: boolean;
|
|
109
|
+
readonly partial: boolean;
|
|
110
|
+
}
|
|
111
|
+
interface CatalogPolicy {
|
|
112
|
+
readonly name: string;
|
|
113
|
+
readonly command: "all" | "select" | "insert" | "update" | "delete";
|
|
114
|
+
readonly roles: readonly string[];
|
|
115
|
+
readonly permissive: boolean;
|
|
116
|
+
readonly using: string | null;
|
|
117
|
+
readonly check: string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Functions the policy expressions call, as `schema.name`, from
|
|
120
|
+
* `pg_depend`. Absent in older snapshots.
|
|
121
|
+
*/
|
|
122
|
+
readonly functions?: readonly string[];
|
|
123
|
+
}
|
|
124
|
+
interface CatalogTrigger {
|
|
125
|
+
readonly name: string;
|
|
126
|
+
readonly timing: "before" | "after" | "instead of";
|
|
127
|
+
readonly events: readonly ("insert" | "update" | "delete" | "truncate")[];
|
|
128
|
+
readonly level: "row" | "statement";
|
|
129
|
+
readonly function: string;
|
|
130
|
+
}
|
|
131
|
+
interface CatalogGrant {
|
|
132
|
+
readonly role: string;
|
|
133
|
+
readonly privileges: readonly string[];
|
|
134
|
+
}
|
|
135
|
+
interface SnapshotBucket {
|
|
136
|
+
readonly id: string;
|
|
137
|
+
readonly public: boolean;
|
|
138
|
+
readonly fileSizeLimit: number | null;
|
|
139
|
+
readonly allowedMimeTypes: readonly string[] | null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The snapshot joined into one record per table, function and enum. Codegen
|
|
143
|
+
* and doctor read this view rather than the raw snapshot.
|
|
144
|
+
*/
|
|
145
|
+
interface Catalog {
|
|
146
|
+
readonly schemas: readonly string[];
|
|
147
|
+
readonly tables: readonly CatalogTable[];
|
|
148
|
+
readonly enums: readonly CatalogEnum[];
|
|
149
|
+
readonly functions: readonly CatalogFunction[];
|
|
150
|
+
readonly buckets: readonly SnapshotBucket[];
|
|
151
|
+
readonly realtime: readonly string[];
|
|
152
|
+
}
|
|
153
|
+
interface CatalogTable {
|
|
154
|
+
readonly id: number;
|
|
155
|
+
readonly schema: string;
|
|
156
|
+
readonly name: string;
|
|
157
|
+
/** Materialized views count as views; foreign tables as tables. */
|
|
158
|
+
readonly kind: "table" | "view";
|
|
159
|
+
readonly rls: boolean;
|
|
160
|
+
readonly forceRls: boolean;
|
|
161
|
+
readonly replicaIdentity: "DEFAULT" | "INDEX" | "FULL" | "NOTHING" | null;
|
|
162
|
+
/** Inserts work (always true for tables). */
|
|
163
|
+
readonly insertable: boolean;
|
|
164
|
+
/** Updates work (always true for tables). */
|
|
165
|
+
readonly updatable: boolean;
|
|
166
|
+
readonly comment: string | null;
|
|
167
|
+
readonly columns: readonly CatalogColumn[];
|
|
168
|
+
readonly primaryKey: readonly string[];
|
|
169
|
+
readonly uniques: readonly CatalogUnique[];
|
|
170
|
+
readonly foreignKeys: readonly CatalogForeignKey[];
|
|
171
|
+
readonly checks: readonly CatalogCheck[];
|
|
172
|
+
readonly indexes: readonly CatalogIndex[];
|
|
173
|
+
readonly policies: readonly CatalogPolicy[];
|
|
174
|
+
readonly triggers: readonly CatalogTrigger[];
|
|
175
|
+
readonly grants: readonly CatalogGrant[];
|
|
176
|
+
}
|
|
177
|
+
interface CatalogColumn {
|
|
178
|
+
readonly name: string;
|
|
179
|
+
/** Type name; the element type for arrays (`uuid`, `int8`, `note_kind`). */
|
|
180
|
+
readonly udt: string;
|
|
181
|
+
/** Raw type name as Postgres reports it (`_text` for `text[]`). */
|
|
182
|
+
readonly format: string;
|
|
183
|
+
readonly typeSchema: string;
|
|
184
|
+
readonly isArray: boolean;
|
|
185
|
+
readonly isEnum: boolean;
|
|
186
|
+
readonly nullable: boolean;
|
|
187
|
+
readonly hasDefault: boolean;
|
|
188
|
+
readonly default: string | null;
|
|
189
|
+
readonly identity: "always" | "by default" | null;
|
|
190
|
+
readonly generated: boolean;
|
|
191
|
+
readonly updatable: boolean;
|
|
192
|
+
readonly comment: string | null;
|
|
193
|
+
}
|
|
194
|
+
interface CatalogForeignKey {
|
|
195
|
+
readonly name: string;
|
|
196
|
+
readonly columns: readonly string[];
|
|
197
|
+
readonly refSchema: string;
|
|
198
|
+
readonly refTable: string;
|
|
199
|
+
readonly refColumns: readonly string[];
|
|
200
|
+
readonly oneToOne: boolean;
|
|
201
|
+
readonly onDelete: ForeignKeyAction;
|
|
202
|
+
readonly onUpdate: ForeignKeyAction;
|
|
203
|
+
}
|
|
204
|
+
interface CatalogEnum {
|
|
205
|
+
readonly schema: string;
|
|
206
|
+
readonly name: string;
|
|
207
|
+
readonly values: readonly string[];
|
|
208
|
+
}
|
|
209
|
+
interface CatalogFunction {
|
|
210
|
+
readonly schema: string;
|
|
211
|
+
readonly name: string;
|
|
212
|
+
/** Signature that tells overloads apart, e.g. `a integer, b text`. */
|
|
213
|
+
readonly signature: string;
|
|
214
|
+
readonly args: readonly CatalogFunctionArg[];
|
|
215
|
+
/** Columns for `returns table (...)` functions. */
|
|
216
|
+
readonly returnsTable: readonly {
|
|
217
|
+
readonly name: string;
|
|
218
|
+
readonly udt: string;
|
|
219
|
+
}[] | null;
|
|
220
|
+
/** Return type name (`int4`, `_text`, a table's row type). */
|
|
221
|
+
readonly returns: string;
|
|
222
|
+
/** `schema.table` when the function returns rows of a table or view. */
|
|
223
|
+
readonly returnsRelation: string | null;
|
|
224
|
+
readonly returnsSet: boolean;
|
|
225
|
+
readonly volatility: "immutable" | "stable" | "volatile";
|
|
226
|
+
readonly securityDefiner: boolean;
|
|
227
|
+
readonly language: string;
|
|
228
|
+
/** `search_path` from `SET search_path`, or `null` when unset. */
|
|
229
|
+
readonly searchPath: string | null;
|
|
230
|
+
}
|
|
231
|
+
interface CatalogFunctionArg {
|
|
232
|
+
readonly name: string;
|
|
233
|
+
readonly udt: string;
|
|
234
|
+
readonly isArray: boolean;
|
|
235
|
+
readonly hasDefault: boolean;
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/generators/shared.d.ts
|
|
239
|
+
/** What field planning reads: the metadata and the typed-jsonb config. */
|
|
240
|
+
interface SchemaSource {
|
|
241
|
+
readonly meta: SchemaMeta;
|
|
242
|
+
readonly config: {
|
|
243
|
+
readonly json: Readonly<Record<string, unknown>>;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/generators/json-schema.d.ts
|
|
248
|
+
interface JsonSchemaGeneratorOptions {
|
|
249
|
+
/** Output path relative to the project root. Defaults to `<output>.schema.json`. */
|
|
250
|
+
readonly output?: string;
|
|
251
|
+
/** `$id` of the document. */
|
|
252
|
+
readonly id?: string;
|
|
253
|
+
}
|
|
254
|
+
type JsonSchema = Record<string, unknown>;
|
|
255
|
+
/** JSON Schema (2020-12) `$defs` for every table: `customersRow`, `customersInsert`, ... */
|
|
256
|
+
declare function buildJsonSchema(input: SchemaSource, id?: string): JsonSchema;
|
|
257
|
+
/** Writes the JSON Schema document; `createOpenApi` reuses the same `$defs`. */
|
|
258
|
+
declare function jsonSchema(options?: JsonSchemaGeneratorOptions): Generator;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/generators/valibot.d.ts
|
|
261
|
+
interface ValibotGeneratorOptions {
|
|
262
|
+
/** Output path relative to the project root. Defaults to `<output>.valibot.ts`. */
|
|
263
|
+
readonly output?: string;
|
|
264
|
+
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
265
|
+
readonly json?: Readonly<Record<string, string>>;
|
|
266
|
+
}
|
|
267
|
+
/** Valibot schemas for every table's Row, Insert and Update shape. */
|
|
268
|
+
declare function valibot(options?: ValibotGeneratorOptions): Generator;
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/generators/zod.d.ts
|
|
271
|
+
interface ZodGeneratorOptions {
|
|
272
|
+
/** Output path relative to the project root. Defaults to `<output>.zod.ts`. */
|
|
273
|
+
readonly output?: string;
|
|
274
|
+
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
275
|
+
readonly json?: Readonly<Record<string, string>>;
|
|
276
|
+
}
|
|
277
|
+
/** Zod 4 schemas for every table's Row, Insert and Update shape. */
|
|
278
|
+
declare function zod(options?: ZodGeneratorOptions): Generator;
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/config/index.d.ts
|
|
281
|
+
/**
|
|
282
|
+
* Where codegen reads the database from. Without any of these, `$DATABASE_URL`
|
|
283
|
+
* and then the local stack (`supabase start`) are used.
|
|
284
|
+
*/
|
|
285
|
+
interface SourceConfig {
|
|
286
|
+
/** Postgres connection string. */
|
|
287
|
+
readonly dbUrl?: string;
|
|
288
|
+
/**
|
|
289
|
+
* Hosted project ref. Read through the Management API's read-only SQL
|
|
290
|
+
* endpoint, so no database password is needed.
|
|
291
|
+
*/
|
|
292
|
+
readonly projectRef?: string;
|
|
293
|
+
/**
|
|
294
|
+
* Management API token for `projectRef`. Defaults to
|
|
295
|
+
* `$SUPABASE_ACCESS_TOKEN`; prefer the env var over committing a token.
|
|
296
|
+
*/
|
|
297
|
+
readonly accessToken?: string;
|
|
298
|
+
/** Read a saved `better-supabase introspect` snapshot instead of connecting. */
|
|
299
|
+
readonly snapshot?: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* A JSON Schema object, or a Standard JSON Schema value (zod 4, valibot,
|
|
303
|
+
* arktype, ...) that can produce one.
|
|
304
|
+
*/
|
|
305
|
+
type JsonSchemaSource = Readonly<Record<string, unknown>> | {
|
|
306
|
+
readonly "~standard": {
|
|
307
|
+
readonly jsonSchema: {
|
|
308
|
+
readonly input: (options: {
|
|
309
|
+
readonly target: string;
|
|
310
|
+
}) => Record<string, unknown>;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
type JsonTypeConfig = ({
|
|
315
|
+
readonly import: string;
|
|
316
|
+
} | {
|
|
317
|
+
readonly type: string;
|
|
318
|
+
}) & {
|
|
319
|
+
/** Enforced in the database by `sql add jsonb-schemas` (pg_jsonschema). */
|
|
320
|
+
readonly schema?: JsonSchemaSource;
|
|
321
|
+
};
|
|
322
|
+
/** The JSON Schema document for a `json[...].schema` entry. */
|
|
323
|
+
declare function resolveJsonSchema(source: JsonSchemaSource): Readonly<Record<string, unknown>>;
|
|
324
|
+
interface TableConfig {
|
|
325
|
+
readonly casing?: Casing;
|
|
326
|
+
/** Leave the table out of the generated models. */
|
|
327
|
+
readonly exclude?: boolean;
|
|
328
|
+
/** Rename generated relations: `{ primaryContact: 'contact' }`. */
|
|
329
|
+
readonly relations?: Readonly<Record<string, string>>;
|
|
330
|
+
}
|
|
331
|
+
interface TimestampsConfig {
|
|
332
|
+
readonly createdAt?: string;
|
|
333
|
+
readonly updatedAt?: string;
|
|
334
|
+
}
|
|
335
|
+
interface SoftDeleteConfig {
|
|
336
|
+
readonly column?: string;
|
|
337
|
+
}
|
|
338
|
+
interface TenantConfig {
|
|
339
|
+
readonly column?: string;
|
|
340
|
+
/** JWT claim holding the tenant id. */
|
|
341
|
+
readonly claim?: string;
|
|
342
|
+
}
|
|
343
|
+
interface ActorConfig {
|
|
344
|
+
readonly createdBy?: string;
|
|
345
|
+
readonly updatedBy?: string;
|
|
346
|
+
}
|
|
347
|
+
interface PluginFlagsConfig {
|
|
348
|
+
readonly timestamps?: boolean | TimestampsConfig;
|
|
349
|
+
readonly softDelete?: boolean | SoftDeleteConfig;
|
|
350
|
+
readonly tenant?: boolean | TenantConfig;
|
|
351
|
+
readonly actor?: boolean | ActorConfig;
|
|
352
|
+
}
|
|
353
|
+
interface BucketConfig {
|
|
354
|
+
readonly id?: string;
|
|
355
|
+
readonly public?: boolean;
|
|
356
|
+
/** Path template with `{placeholders}`, e.g. `{orgId}/{customerId}/logo.webp`. */
|
|
357
|
+
readonly path: string;
|
|
358
|
+
/** Generated storage policy. */
|
|
359
|
+
readonly policy?: "tenant" | "owner" | "public" | "none";
|
|
360
|
+
readonly fileSizeLimit?: string;
|
|
361
|
+
readonly allowedMimeTypes?: readonly string[];
|
|
362
|
+
}
|
|
363
|
+
interface SqlConfig {
|
|
364
|
+
/** Directory declarative schema files are written to. */
|
|
365
|
+
readonly dir?: string;
|
|
366
|
+
/** File name prefix, so generated files sort after yours. */
|
|
367
|
+
readonly prefix?: string;
|
|
368
|
+
/** Directory pgTAP files (the `pgtap` module) are written to. */
|
|
369
|
+
readonly testsDir?: string;
|
|
370
|
+
/** SQL kit modules to keep in sync (`better-supabase sql add`). */
|
|
371
|
+
readonly kit?: readonly string[];
|
|
372
|
+
}
|
|
373
|
+
interface SeedConfig {
|
|
374
|
+
/** Module exporting `defineSeed(...)` as `seed` or default. */
|
|
375
|
+
readonly entry?: string;
|
|
376
|
+
/** SQL file `better-supabase seed` writes. Add it to `[db.seed] sql_paths`. */
|
|
377
|
+
readonly output?: string;
|
|
378
|
+
}
|
|
379
|
+
interface OpenApiConfig {
|
|
380
|
+
/** Module exporting the document (or a function returning it) as `openapi` or default. */
|
|
381
|
+
readonly entry?: string;
|
|
382
|
+
/** JSON file `better-supabase openapi emit` writes. */
|
|
383
|
+
readonly output?: string;
|
|
384
|
+
}
|
|
385
|
+
interface DoctorConfig {
|
|
386
|
+
/** Finding codes to skip, e.g. `['BS204']`. */
|
|
387
|
+
readonly ignore?: readonly string[];
|
|
388
|
+
/** Treat warnings as errors. */
|
|
389
|
+
readonly strict?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* App source files doctor scans for API use (BS210). Globs relative to the
|
|
392
|
+
* root. Defaults to `['src/**\/*.{ts,tsx}']`.
|
|
393
|
+
*/
|
|
394
|
+
readonly sources?: readonly string[];
|
|
395
|
+
/**
|
|
396
|
+
* How many policies a security definer helper may appear in before BS206
|
|
397
|
+
* asks for an inlinable `language sql stable` function. Defaults to 5.
|
|
398
|
+
*/
|
|
399
|
+
readonly policyHelperLimit?: number;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Runtime types for columns whose JSON form loses information. Defaults
|
|
403
|
+
* match `supabase gen types`: timestamps as ISO strings, `int8` and
|
|
404
|
+
* `numeric` as numbers.
|
|
405
|
+
*/
|
|
406
|
+
interface CodecsConfig {
|
|
407
|
+
/** `'date'` decodes `timestamptz`/`timestamp` columns to `Date`. */
|
|
408
|
+
readonly timestamptz?: "string" | "date";
|
|
409
|
+
/** `'bigint'` or `'string'` read `int8` exactly (above 2^53). */
|
|
410
|
+
readonly int8?: "number" | "string" | "bigint";
|
|
411
|
+
/** `'string'` reads `numeric` exactly. */
|
|
412
|
+
readonly numeric?: "number" | "string";
|
|
413
|
+
}
|
|
414
|
+
interface GeneratedFile {
|
|
415
|
+
/** Path relative to the project root. */
|
|
416
|
+
readonly path: string;
|
|
417
|
+
readonly contents: string;
|
|
418
|
+
}
|
|
419
|
+
interface GeneratorInput {
|
|
420
|
+
readonly meta: SchemaMeta;
|
|
421
|
+
/**
|
|
422
|
+
* The `@supabase/postgrest-typegen` metadata for the configured schemas,
|
|
423
|
+
* the same contract `supabase gen types` is built on.
|
|
424
|
+
*/
|
|
425
|
+
readonly introspection: GeneratorMetadata;
|
|
426
|
+
/** Constraints, indexes, policies, triggers and grants typegen leaves out. */
|
|
427
|
+
readonly extras: SnapshotExtras;
|
|
428
|
+
readonly config: ResolvedConfig;
|
|
429
|
+
/** Absolute path of the main generated module. */
|
|
430
|
+
readonly output: string;
|
|
431
|
+
/** Import path from `from` (a generated file) to `to`, with extension. */
|
|
432
|
+
readonly importPath: (from: string, to: string) => string;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Codegen extension point. First-party generators: `zod()`, `valibot()`,
|
|
436
|
+
* `jsonSchema()`. Prove custom ones with `testGenerator`.
|
|
437
|
+
*/
|
|
438
|
+
interface Generator {
|
|
439
|
+
readonly name: string;
|
|
440
|
+
generate(input: GeneratorInput): readonly GeneratedFile[] | Promise<readonly GeneratedFile[]>;
|
|
441
|
+
}
|
|
442
|
+
interface RealtimeConfig {
|
|
443
|
+
/**
|
|
444
|
+
* Tables that broadcast a change signal for live queries (`table` or
|
|
445
|
+
* `schema.table`). Tenant tables broadcast per tenant. Install the
|
|
446
|
+
* triggers with `better-supabase sql add realtime-tables`.
|
|
447
|
+
*/
|
|
448
|
+
readonly tables?: readonly string[];
|
|
449
|
+
}
|
|
450
|
+
interface EntitlementsConfig {
|
|
451
|
+
/**
|
|
452
|
+
* `table.column` (or `schema.table.column`) holding each tenant's Stripe
|
|
453
|
+
* customer id, read by the `entitlements` SQL kit module. Defaults to
|
|
454
|
+
* `organizations.stripe_customer_id`.
|
|
455
|
+
*/
|
|
456
|
+
readonly customer?: string;
|
|
457
|
+
/** The tenant id column of that table. Defaults to `id`. */
|
|
458
|
+
readonly key?: string;
|
|
459
|
+
}
|
|
460
|
+
/** pgvector distance: `<=>` (cosine), `<->` (l2) or `<#>` (negative inner product). */
|
|
461
|
+
type VectorDistance = "cosine" | "l2" | "inner_product";
|
|
462
|
+
/** The embedding column, or the column and its distance (default `cosine`). */
|
|
463
|
+
type VectorSearchConfig = string | {
|
|
464
|
+
readonly column: string;
|
|
465
|
+
readonly distance?: VectorDistance;
|
|
466
|
+
};
|
|
467
|
+
/** A privilege the Data API roles can be granted on a table or view. */
|
|
468
|
+
type Privilege = "select" | "insert" | "update" | "delete";
|
|
469
|
+
/**
|
|
470
|
+
* Data API grants for one table: privileges for `authenticated`, or per
|
|
471
|
+
* role.
|
|
472
|
+
*/
|
|
473
|
+
type ExposeConfig = readonly Privilege[] | {
|
|
474
|
+
readonly anon?: readonly Privilege[];
|
|
475
|
+
readonly authenticated?: readonly Privilege[];
|
|
476
|
+
};
|
|
477
|
+
/** Resolved grants for one table. */
|
|
478
|
+
interface ResolvedExpose {
|
|
479
|
+
readonly anon: readonly Privilege[];
|
|
480
|
+
readonly authenticated: readonly Privilege[];
|
|
481
|
+
}
|
|
482
|
+
interface BetterSupabaseConfig {
|
|
483
|
+
readonly $schema?: string;
|
|
484
|
+
readonly source?: SourceConfig;
|
|
485
|
+
/** Postgres schemas to generate. Defaults to `['public']`. */
|
|
486
|
+
readonly schemas?: readonly string[];
|
|
487
|
+
/** Casing of generated models and returned rows. Defaults to `'snake'`. */
|
|
488
|
+
readonly casing?: Casing;
|
|
489
|
+
readonly tables?: Readonly<Record<string, TableConfig>>;
|
|
490
|
+
/**
|
|
491
|
+
* Main generated module. Defaults to `src/lib/supabase/generated.ts`;
|
|
492
|
+
* `database.types.ts` is written next to it.
|
|
493
|
+
*/
|
|
494
|
+
readonly output?: string;
|
|
495
|
+
/**
|
|
496
|
+
* PostgREST major version, written to `__InternalSupabase` in
|
|
497
|
+
* `database.types.ts` so `createClient` picks matching behavior.
|
|
498
|
+
* Defaults to `'13'`.
|
|
499
|
+
*/
|
|
500
|
+
readonly postgrestVersion?: string;
|
|
501
|
+
/** Types for jsonb columns, keyed by `table.column`. */
|
|
502
|
+
readonly json?: Readonly<Record<string, JsonTypeConfig>>;
|
|
503
|
+
readonly codecs?: CodecsConfig;
|
|
504
|
+
/**
|
|
505
|
+
* Columns that must not be read by accident (`table.column` or
|
|
506
|
+
* `schema.table.column`, database names), for the `noSensitiveSelect` rule.
|
|
507
|
+
*/
|
|
508
|
+
readonly sensitive?: readonly string[];
|
|
509
|
+
/**
|
|
510
|
+
* Text columns that hold an object path, keyed by `table.column` or
|
|
511
|
+
* `schema.table.column` (database names), with the bucket as the value (a
|
|
512
|
+
* `buckets` key or a bucket id). Generated rows type them as
|
|
513
|
+
* `StoragePath<'bucket-id'>`.
|
|
514
|
+
*/
|
|
515
|
+
readonly storagePaths?: Readonly<Record<string, string>>;
|
|
516
|
+
/**
|
|
517
|
+
* Data API grants, keyed by `table` or `schema.table`. Supabase no longer
|
|
518
|
+
* grants new tables to `anon` and `authenticated` automatically; the
|
|
519
|
+
* `grants` SQL kit module writes these, and doctor (BS106) checks them.
|
|
520
|
+
* Tables not listed need `select, insert, update, delete` for
|
|
521
|
+
* `authenticated` (`select` for views).
|
|
522
|
+
*/
|
|
523
|
+
readonly expose?: Readonly<Record<string, ExposeConfig>>;
|
|
524
|
+
/**
|
|
525
|
+
* Modules that export `defineReadSet` results. `gen` compiles each set to
|
|
526
|
+
* a function in the `read-sets` SQL kit module. Node imports them, so
|
|
527
|
+
* relative imports need their `.ts` extension.
|
|
528
|
+
*/
|
|
529
|
+
readonly readSets?: readonly string[];
|
|
530
|
+
readonly generators?: readonly Generator[];
|
|
531
|
+
/** Enables plugin flags in the generated metadata. */
|
|
532
|
+
readonly plugins?: PluginFlagsConfig;
|
|
533
|
+
readonly buckets?: Readonly<Record<string, BucketConfig>>;
|
|
534
|
+
/** Realtime topic templates: `{ notifications: 'org:{orgId}:notifications' }`. */
|
|
535
|
+
readonly topics?: Readonly<Record<string, string>>;
|
|
536
|
+
readonly realtime?: RealtimeConfig;
|
|
537
|
+
readonly entitlements?: EntitlementsConfig;
|
|
538
|
+
/**
|
|
539
|
+
* Embedding columns, keyed by `table` or `schema.table`. The
|
|
540
|
+
* `vector-search` SQL kit module writes `search_<table>(query, k)` for each,
|
|
541
|
+
* which `db.$search(table, { vector, k })` calls.
|
|
542
|
+
*/
|
|
543
|
+
readonly vectorSearch?: Readonly<Record<string, VectorSearchConfig>>;
|
|
544
|
+
readonly sql?: SqlConfig;
|
|
545
|
+
readonly seed?: SeedConfig;
|
|
546
|
+
readonly openapi?: OpenApiConfig;
|
|
547
|
+
readonly doctor?: DoctorConfig;
|
|
548
|
+
}
|
|
549
|
+
/** The config with defaults applied. */
|
|
550
|
+
interface ResolvedConfig {
|
|
551
|
+
readonly root: string;
|
|
552
|
+
readonly source: SourceConfig;
|
|
553
|
+
readonly schemas: readonly string[];
|
|
554
|
+
readonly casing: Casing;
|
|
555
|
+
readonly tables: Readonly<Record<string, TableConfig>>;
|
|
556
|
+
readonly output: string;
|
|
557
|
+
/** `database.types.ts` next to `output`. */
|
|
558
|
+
readonly databaseTypesOutput: string;
|
|
559
|
+
readonly postgrestVersion: string;
|
|
560
|
+
readonly json: Readonly<Record<string, JsonTypeConfig>>;
|
|
561
|
+
readonly codecs: Required<CodecsConfig>;
|
|
562
|
+
readonly sensitive: readonly string[];
|
|
563
|
+
readonly storagePaths: Readonly<Record<string, string>>;
|
|
564
|
+
readonly expose: Readonly<Record<string, ResolvedExpose>>;
|
|
565
|
+
readonly readSets: readonly string[];
|
|
566
|
+
readonly generators: readonly Generator[];
|
|
567
|
+
readonly plugins: {
|
|
568
|
+
readonly timestamps: Required<TimestampsConfig> | undefined;
|
|
569
|
+
readonly softDelete: Required<SoftDeleteConfig> | undefined;
|
|
570
|
+
readonly tenant: Required<TenantConfig> | undefined;
|
|
571
|
+
readonly actor: Required<ActorConfig> | undefined;
|
|
572
|
+
};
|
|
573
|
+
readonly buckets: Readonly<Record<string, BucketConfig>>;
|
|
574
|
+
readonly entitlements: {
|
|
575
|
+
readonly table: string;
|
|
576
|
+
readonly column: string;
|
|
577
|
+
readonly key: string;
|
|
578
|
+
};
|
|
579
|
+
readonly vectorSearch: readonly {
|
|
580
|
+
readonly table: string;
|
|
581
|
+
readonly column: string;
|
|
582
|
+
readonly distance: VectorDistance;
|
|
583
|
+
}[];
|
|
584
|
+
readonly topics: Readonly<Record<string, string>>;
|
|
585
|
+
readonly realtime: Required<RealtimeConfig>;
|
|
586
|
+
readonly sql: Required<SqlConfig>;
|
|
587
|
+
readonly seed: Required<SeedConfig>;
|
|
588
|
+
readonly openapi: Required<OpenApiConfig>;
|
|
589
|
+
readonly doctor: Required<DoctorConfig>;
|
|
590
|
+
}
|
|
591
|
+
declare const CONFIG_SCHEMA_URL = "https://unpkg.com/better-supabase/schemas/config-v1.json";
|
|
592
|
+
/** Identity helper that types `better-supabase.config.ts`. */
|
|
593
|
+
declare function defineConfig(config: BetterSupabaseConfig): BetterSupabaseConfig;
|
|
594
|
+
/** Applies defaults. Paths stay relative to `root`. */
|
|
595
|
+
declare function resolveConfig(config: BetterSupabaseConfig, root: string): ResolvedConfig;
|
|
596
|
+
//#endregion
|
|
597
|
+
export { ExtrasHook as $, resolveConfig as A, CatalogCheck as B, SqlConfig as C, VectorDistance as D, TimestampsConfig as E, valibot as F, CatalogFunctionArg as G, CatalogEnum as H, JsonSchemaGeneratorOptions as I, CatalogPolicy as J, CatalogGrant as K, buildJsonSchema as L, ZodGeneratorOptions as M, zod as N, VectorSearchConfig as O, ValibotGeneratorOptions as P, ExtrasFunction as Q, jsonSchema as R, SourceConfig as S, TenantConfig as T, CatalogForeignKey as U, CatalogColumn as V, CatalogFunction as W, CatalogTrigger as X, CatalogTable as Y, CatalogUnique as Z, RealtimeConfig as _, CodecsConfig as a, SnapshotExtras as at, SeedConfig as b, ExposeConfig as c, GeneratorInput as d, ExtrasHookFunction as et, JsonSchemaSource as f, Privilege as g, PluginFlagsConfig as h, CONFIG_SCHEMA_URL as i, SnapshotBucket as it, resolveJsonSchema as j, defineConfig as k, GeneratedFile as l, OpenApiConfig as m, BetterSupabaseConfig as n, ForeignKeyAction as nt, DoctorConfig as o, GeneratorMetadata as ot, JsonTypeConfig as p, CatalogIndex as q, BucketConfig as r, Snapshot as rt, EntitlementsConfig as s, Queryable as st, ActorConfig as t, ExtrasTable as tt, Generator as u, ResolvedConfig as v, TableConfig as w, SoftDeleteConfig as x, ResolvedExpose as y, Catalog as z };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { E as SchemaMeta } from "./types-C2fslP1z.js";
|
|
2
|
+
import { a as EventHub, s as MutationNotice } from "./events-2OJsVG_d.js";
|
|
3
|
+
import { l as MutationKind } from "./plugin-HvGqCurB.js";
|
|
4
|
+
//#region src/events/index.d.ts
|
|
5
|
+
/** A CloudEvents 1.0 event. Extension attributes are lowercase alphanumerics. */
|
|
6
|
+
interface CloudEvent<T = unknown> {
|
|
7
|
+
readonly specversion: "1.0";
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly source: string;
|
|
10
|
+
readonly type: string;
|
|
11
|
+
readonly subject?: string;
|
|
12
|
+
readonly time?: string;
|
|
13
|
+
readonly datacontenttype?: string;
|
|
14
|
+
readonly dataschema?: string;
|
|
15
|
+
readonly data?: T;
|
|
16
|
+
readonly [extension: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
declare const ROW_EVENT_TYPES: { readonly [K in MutationKind]: string; };
|
|
19
|
+
interface RowEventData {
|
|
20
|
+
readonly table: string;
|
|
21
|
+
readonly row: Readonly<Record<string, unknown>>;
|
|
22
|
+
}
|
|
23
|
+
interface CloudEventOptions {
|
|
24
|
+
/** URI-reference of the producer, e.g. `https://crm.example.com` or `/crm`. */
|
|
25
|
+
readonly source: string;
|
|
26
|
+
/** Replaces the `dev.better-supabase` type prefix. */
|
|
27
|
+
readonly typePrefix?: string;
|
|
28
|
+
readonly id?: () => string;
|
|
29
|
+
readonly now?: () => Date;
|
|
30
|
+
}
|
|
31
|
+
/** Sends events somewhere: a queue, a bus, an outbox table, an HTTP endpoint. */
|
|
32
|
+
interface EventSink {
|
|
33
|
+
send(events: readonly CloudEvent[]): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* One CloudEvent per mutated row: `dev.better-supabase.row.created` with the
|
|
37
|
+
* app-cased row as `data`, the primary key as `subject`, the tenant as
|
|
38
|
+
* `partitionkey` and the actor as `actorid`.
|
|
39
|
+
*/
|
|
40
|
+
declare function toCloudEvents(notice: MutationNotice, options: CloudEventOptions & {
|
|
41
|
+
readonly meta?: SchemaMeta;
|
|
42
|
+
}): CloudEvent<RowEventData>[];
|
|
43
|
+
interface ForwardOptions extends CloudEventOptions {
|
|
44
|
+
/** Only forward these tables or kinds. */
|
|
45
|
+
readonly filter?: (notice: MutationNotice) => boolean;
|
|
46
|
+
/** Sink failures never fail the mutation. Defaults to the `Logger`. */
|
|
47
|
+
readonly onError?: (error: unknown, events: readonly CloudEvent[]) => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sends a CloudEvent for every mutation to `sink`. Returns a function that
|
|
51
|
+
* stops forwarding. Use an outbox (SQL kit) when events must not be lost.
|
|
52
|
+
*/
|
|
53
|
+
declare function forwardMutations(sb: {
|
|
54
|
+
readonly events: EventHub;
|
|
55
|
+
readonly meta: SchemaMeta;
|
|
56
|
+
}, sink: EventSink, options: ForwardOptions): () => void;
|
|
57
|
+
type HttpMode = "structured" | "binary" | "batch";
|
|
58
|
+
/** The HTTP protocol binding: headers and body for one event (or a batch). */
|
|
59
|
+
declare function toHttp(events: CloudEvent | readonly CloudEvent[], mode?: HttpMode): {
|
|
60
|
+
headers: Record<string, string>;
|
|
61
|
+
body: string;
|
|
62
|
+
}[];
|
|
63
|
+
declare function isCloudEvent(value: unknown): value is CloudEvent;
|
|
64
|
+
/** Reads CloudEvents from a request in any of the three HTTP modes. */
|
|
65
|
+
declare function fromHttp(request: Request): Promise<CloudEvent[]>;
|
|
66
|
+
interface HttpSinkOptions {
|
|
67
|
+
readonly mode?: HttpMode;
|
|
68
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
69
|
+
readonly fetch?: typeof fetch;
|
|
70
|
+
}
|
|
71
|
+
/** POSTs events to `url`. Non-2xx responses reject. */
|
|
72
|
+
declare function httpSink(url: string | URL, options?: HttpSinkOptions): EventSink;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { HttpMode as a, RowEventData as c, httpSink as d, isCloudEvent as f, ForwardOptions as i, forwardMutations as l, toHttp as m, CloudEventOptions as n, HttpSinkOptions as o, toCloudEvents as p, EventSink as r, ROW_EVENT_TYPES as s, CloudEvent as t, fromHttp as u };
|