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.
Files changed (139) hide show
  1. package/README.md +34 -31
  2. package/dist/base64-CQeB1eSf.js +42 -0
  3. package/dist/client/index.d.ts +1 -1
  4. package/dist/client/index.js +4 -14
  5. package/dist/{compiler-CZ9nIuqy.d.ts → compiler-2zqGzxVZ.d.ts} +2 -2
  6. package/dist/config/index.d.ts +4 -3
  7. package/dist/config/index.js +5 -3
  8. package/dist/config-Be4GwsqI.js +129 -0
  9. package/dist/{index-DOsjFvMf.d.ts → config-C1CYcm6o.d.ts} +49 -49
  10. package/dist/{config-ClDXmVtY.js → config-DOsGYSiT.js} +14 -137
  11. package/dist/{define-BXMYD9AY.js → define-DF341GDj.js} +71 -51
  12. package/dist/{define-e3zI4_4g.d.ts → define-DUbydmJa.d.ts} +10 -9
  13. package/dist/edge/index.d.ts +4 -4
  14. package/dist/edge/index.js +4 -4
  15. package/dist/{entitlements-Dng-ctuT.d.ts → entitlements-DvJXoI02.d.ts} +1 -1
  16. package/dist/env/index.js +203 -1
  17. package/dist/events/index.d.ts +1 -1
  18. package/dist/events/index.js +139 -1
  19. package/dist/{events-DOt3nSO-.d.ts → events-Do8jXh4D.d.ts} +3 -3
  20. package/dist/{executor-BYXQ9AGn.d.ts → executor-B26lgbHD.d.ts} +2 -2
  21. package/dist/{executor-DeppvirK.js → executor-C57jx2pn.js} +7 -2
  22. package/dist/{executor-CGdNQ27g.d.ts → executor-DynmIWhq.d.ts} +2 -2
  23. package/dist/hono/index.d.ts +5 -5
  24. package/dist/hono/index.js +4 -4
  25. package/dist/{index-CBDufH1M.d.ts → index-BNsABq7P.d.ts} +8 -8
  26. package/dist/{index-Bw1bwtC0.d.ts → index-CADlNHK-.d.ts} +27 -14
  27. package/dist/{index-DuP14VHo.d.ts → index-CTTMS6_1.d.ts} +19 -8
  28. package/dist/index-Cf-D2jk1.d.ts +50 -0
  29. package/dist/{index-K-3WM2Hp.d.ts → index-CriFFJ_p.d.ts} +4 -4
  30. package/dist/{index-Ciu5Xlml.d.ts → index-GV77NpRP.d.ts} +5 -4
  31. package/dist/{index-D4v7sncu.d.ts → index-UJ-LUxtI.d.ts} +3 -3
  32. package/dist/{index-CG69s15v.d.ts → index-kpgopLNv.d.ts} +4 -3
  33. package/dist/{index-DbxFr7XG.d.ts → index-qriRM9cZ.d.ts} +7 -2
  34. package/dist/index.d.ts +12 -12
  35. package/dist/index.js +16 -7
  36. package/dist/jobs/index.d.ts +25 -24
  37. package/dist/jobs/index.js +16 -10
  38. package/dist/{json-schema-BpYqkCKf.js → json-schema--aOXAGfU.js} +7 -2
  39. package/dist/lint/index.js +1 -1
  40. package/dist/list/index.d.ts +2 -2
  41. package/dist/list/index.js +128 -93
  42. package/dist/{live-DJyZMD6w.d.ts → live-QE3UPbGm.d.ts} +16 -6
  43. package/dist/mcp/index.d.ts +24 -17
  44. package/dist/mcp/index.js +41 -12
  45. package/dist/{mfa-CpLfJSde.js → mfa-BxoR1RkN.js} +74 -19
  46. package/dist/{mfa-TVia554c.d.ts → mfa-x3V3vGh-.d.ts} +1 -1
  47. package/dist/next/index.d.ts +39 -26
  48. package/dist/next/index.js +28 -23
  49. package/dist/openapi/index.d.ts +1 -1
  50. package/dist/openapi/index.js +57 -34
  51. package/dist/orpc/index.d.ts +6 -6
  52. package/dist/orpc/index.js +3 -3
  53. package/dist/otel/index.d.ts +2 -2
  54. package/dist/otel/index.js +4 -2
  55. package/dist/{permdock-sql-CghlHPuH.js → permdock-sql-Bta_G0v-.js} +11 -6
  56. package/dist/permdock-sql-DImJULY-.d.ts +17 -0
  57. package/dist/{plugin-C4TR9J0Z.d.ts → plugin-DVRB8qNE.d.ts} +5 -4
  58. package/dist/plugins/actor/index.d.ts +1 -1
  59. package/dist/plugins/rules/index.d.ts +2 -2
  60. package/dist/plugins/rules/index.js +4 -4
  61. package/dist/plugins/soft-delete/index.d.ts +3 -3
  62. package/dist/plugins/soft-delete/index.js +2 -2
  63. package/dist/plugins/tenant/index.d.ts +2 -2
  64. package/dist/plugins/timestamps/index.d.ts +1 -1
  65. package/dist/plugins/timestamps/index.js +1 -1
  66. package/dist/plugins/validation/index.d.ts +2 -2
  67. package/dist/pool-B9qsLyFR.d.ts +71 -0
  68. package/dist/postgres/index.d.ts +10 -5
  69. package/dist/postgres/index.js +36 -16
  70. package/dist/{postgrest-cAEQ_IQN.d.ts → postgrest-DmBlevh-.d.ts} +1 -1
  71. package/dist/{problem-BTkTtRV9.js → problem-CGt1ADix.js} +10 -4
  72. package/dist/{problem-DlgB0lYl.d.ts → problem-Z2RTQjZD.d.ts} +6 -4
  73. package/dist/query/index.d.ts +2 -2
  74. package/dist/query/index.js +1 -1
  75. package/dist/{query-ChvDbsDE.js → query-BdKLTPlj.js} +2 -2
  76. package/dist/react/index.d.ts +7 -7
  77. package/dist/react/index.js +2 -2
  78. package/dist/react/server.d.ts +3 -3
  79. package/dist/react/server.js +1 -1
  80. package/dist/react/session.d.ts +21 -2
  81. package/dist/react/session.js +19 -1
  82. package/dist/{react-C83BdBGt.js → react-DNBYNazu.js} +20 -16
  83. package/dist/{read-set-4lI3W_gZ.js → read-set-D0qBcboM.js} +3 -3
  84. package/dist/realtime/index.d.ts +4 -3
  85. package/dist/realtime/index.js +7 -6
  86. package/dist/{resolve-CjHILk2w.d.ts → resolve-BRciX2jK.d.ts} +6 -5
  87. package/dist/{resource-CgZa3YG_.d.ts → resource-CwVgiI5q.d.ts} +16 -7
  88. package/dist/{resource-BHEWmQJK.js → resource-D30rp0GN.js} +38 -16
  89. package/dist/{respond-DMcbQwfN.js → respond-C44EZAJo.js} +35 -19
  90. package/dist/{respond-Dne1ARSa.d.ts → respond-DAkPIdTH.d.ts} +15 -9
  91. package/dist/{result-CTkCZ6JA.d.ts → result-c2OYgCV2.d.ts} +13 -8
  92. package/dist/server/index.d.ts +35 -10
  93. package/dist/server/index.js +38 -9
  94. package/dist/{simplify-bwJpLnaS.js → simplify-LakqK1vH.js} +10 -16
  95. package/dist/sql/index.d.ts +139 -0
  96. package/dist/sql/index.js +1983 -0
  97. package/dist/{sql-DTjA1LPj.js → sql-BIgk12ew.js} +72 -16
  98. package/dist/ssr/index.d.ts +4 -4
  99. package/dist/ssr/index.js +2 -2
  100. package/dist/{standard-CyhRzctb.d.ts → standard-eudBiRk1.d.ts} +1 -1
  101. package/dist/{stats-C5W-rBfR.js → stats-D78UQ8Yu.js} +8 -7
  102. package/dist/storage/index.d.ts +4 -3
  103. package/dist/storage/index.js +530 -1
  104. package/dist/{tables-rZxRxNPW.js → tables-Dhha3BXM.js} +5 -5
  105. package/dist/temporal-BwshQk0W.js +27 -0
  106. package/dist/temporal-required-CMxeSVPo.js +19 -0
  107. package/dist/testing/index.d.ts +13 -11
  108. package/dist/testing/index.js +128 -29
  109. package/dist/{types-C83v5SQz.d.ts → types-DONv9SHN.d.ts} +14 -11
  110. package/dist/{version-Cqq1m3UY.js → version-BfpG2gks.js} +1 -1
  111. package/dist/{view-D1s0wa0T.d.ts → view-3Po_PVlr.d.ts} +34 -4
  112. package/dist/{view-aOYizTeE.js → view-wZ-9qIUz.js} +11 -2
  113. package/dist/webhooks/index.d.ts +18 -16
  114. package/dist/webhooks/index.js +1 -1
  115. package/dist/{webhooks-DMipjhSP.js → webhooks-CAIFQSTM.js} +11 -9
  116. package/package.json +24 -28
  117. package/schemas/config-v1.json +31 -1
  118. package/schemas/doctor-report-v1.json +17 -1
  119. package/schemas/snapshot-v2.json +35 -0
  120. package/skills/better-supabase/SKILL.md +23 -11
  121. package/skills/better-supabase/references/plugins.md +21 -18
  122. package/skills/better-supabase/references/troubleshooting.md +15 -15
  123. package/skills/better-supabase-api/SKILL.md +7 -7
  124. package/skills/better-supabase-api/references/adapters.md +30 -25
  125. package/skills/better-supabase-testing/SKILL.md +11 -8
  126. package/bin/better-supabase.js +0 -4
  127. package/dist/casing-da0uRTqt.js +0 -14
  128. package/dist/cli/bin.d.ts +0 -1
  129. package/dist/cli/bin.js +0 -15
  130. package/dist/cli/index.d.ts +0 -226
  131. package/dist/cli/index.js +0 -3
  132. package/dist/cli-DrSgDOQC.js +0 -6646
  133. package/dist/env-BEToab0I.js +0 -204
  134. package/dist/events-BuzTgn2D.js +0 -135
  135. package/dist/pool-R2m_DkXi.d.ts +0 -37
  136. package/dist/seed-CzecODcJ.js +0 -101
  137. package/dist/session-C3LxnQ0e.d.ts +0 -22
  138. package/dist/session-CqEwzVup.js +0 -20
  139. package/dist/storage-DuGn38fr.js +0 -527
@@ -1,14 +0,0 @@
1
- //#region src/casing/index.ts
2
- /** `first_name` to `firstName`. Leaves already camel-cased names untouched. */
3
- function toCamel(name) {
4
- return name.replace(/_+([a-z0-9])/g, (_, char) => char.toUpperCase());
5
- }
6
- /** `firstName` to `first_name`. */
7
- function toSnake(name) {
8
- return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase();
9
- }
10
- function applyCasing(name, casing) {
11
- return casing === "camel" ? toCamel(name) : name;
12
- }
13
- //#endregion
14
- export { toCamel as n, toSnake as r, applyCasing as t };
package/dist/cli/bin.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}
package/dist/cli/bin.js DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- import { i as run } from "../cli-DrSgDOQC.js";
3
- //#region src/cli/bin.ts
4
- const controller = new AbortController();
5
- process.once("SIGINT", () => controller.abort());
6
- process.once("SIGTERM", () => controller.abort());
7
- const result = await run(process.argv.slice(2), {
8
- signal: controller.signal,
9
- io: {
10
- stdout: (text) => process.stdout.write(text),
11
- stderr: (text) => process.stderr.write(text)
12
- }
13
- });
14
- process.exitCode = result.code;
15
- //#endregion
@@ -1,226 +0,0 @@
1
- import { $ as ExtrasFunction, B as Catalog, G as CatalogFunction, H as CatalogColumn, J as CatalogIndex, K as CatalogFunctionArg, Q as CatalogUnique, U as CatalogEnum, V as CatalogCheck, W as CatalogForeignKey, X as CatalogTable, Y as CatalogPolicy, Z as CatalogTrigger, at as SnapshotBucket, ct as Queryable, et as ExtrasHook, it as Snapshot, nt as ExtrasTable, ot as SnapshotExtras, q as CatalogGrant, rt as ForeignKeyAction, st as GeneratorMetadata, tt as ExtrasHookFunction, u as GeneratedFile, y as ResolvedConfig } from "../index-DOsjFvMf.js";
2
- import { A as SchemaMeta, P as TableMeta, T as RelationMeta, a as Casing, c as Codec, m as FunctionMeta } from "../types-C83v5SQz.js";
3
- //#region src/cli/args.d.ts
4
- type FlagValue = string | boolean | readonly string[];
5
- interface ParsedArgs {
6
- readonly command: string | undefined;
7
- readonly rest: readonly string[];
8
- readonly flags: Readonly<Record<string, FlagValue>>;
9
- }
10
- //#endregion
11
- //#region src/cli/io.d.ts
12
- interface CliIo {
13
- readonly stdout: (text: string) => void;
14
- readonly stderr: (text: string) => void;
15
- readonly now?: () => Date;
16
- /** Environment; defaults to `process.env`. */
17
- readonly env?: Readonly<Record<string, string | undefined>>;
18
- }
19
- interface RunResult {
20
- readonly code: number;
21
- readonly stdout: string;
22
- readonly stderr: string;
23
- }
24
- interface CommandResult {
25
- readonly code: number;
26
- readonly output?: string;
27
- readonly error?: string;
28
- }
29
- //#endregion
30
- //#region src/cli/run.d.ts
31
- export declare const HELP: string;
32
- type Command = (context: CommandContext) => Promise<CommandResult>;
33
- interface CommandContext {
34
- readonly args: ParsedArgs;
35
- readonly cwd: string;
36
- readonly config: ResolvedConfig;
37
- readonly io: CliIo;
38
- readonly env: Readonly<Record<string, string | undefined>>;
39
- readonly signal: AbortSignal | undefined;
40
- }
41
- /** Registers a command; the built-in commands register themselves below. */
42
- export declare function registerCommand(name: string, command: Command, help?: string): void;
43
- interface RunOptions {
44
- readonly cwd?: string;
45
- readonly io?: CliIo;
46
- readonly signal?: AbortSignal;
47
- }
48
- /** Runs the CLI. Never exits the process; returns the exit code and output. */
49
- export declare function run(argv: readonly string[], options?: RunOptions): Promise<RunResult>;
50
- //#endregion
51
- //#region src/cli/introspect/source.d.ts
52
- /** A connection introspection can query, plus how to release it. */
53
- interface IntrospectionSource {
54
- readonly queryable: Queryable;
55
- readonly describe: string;
56
- close(): Promise<void>;
57
- }
58
- /**
59
- * A `pg` connection. Typegen issues its queries concurrently; one `pg.Client`
60
- * must run them one at a time, so calls are queued.
61
- */
62
- export declare function pgSource(url: string): Promise<IntrospectionSource>;
63
- interface ManagementSourceOptions {
64
- readonly projectRef: string;
65
- readonly accessToken: string;
66
- /** Defaults to `https://api.supabase.com`. */
67
- readonly apiUrl?: string;
68
- readonly fetch?: typeof fetch;
69
- }
70
- /**
71
- * Runs introspection SQL through the Supabase Management API as the
72
- * read-only database user, so hosted projects need no database password.
73
- */
74
- export declare function managementSource(options: ManagementSourceOptions): IntrospectionSource;
75
- //#endregion
76
- //#region src/cli/commands/snapshot.d.ts
77
- interface SnapshotSource {
78
- readonly snapshotPath?: string;
79
- readonly dbUrl?: string;
80
- readonly projectRef?: string;
81
- /** Ignore `source.snapshot` and read the database. */
82
- readonly live?: boolean;
83
- }
84
- type Env = Readonly<Record<string, string | undefined>>;
85
- /** Loads a saved snapshot or introspects the database. */
86
- export declare function loadSnapshot(config: ResolvedConfig, env: Env, source: SnapshotSource): Promise<Snapshot>;
87
- /** Validates a parsed snapshot document. */
88
- export declare function parseSnapshot(data: unknown, label?: string): Snapshot;
89
- export declare function serializeSnapshot(snapshot: Snapshot): string;
90
- //#endregion
91
- //#region src/cli/commands/gen.d.ts
92
- interface GenOptions extends SnapshotSource {
93
- readonly config: ResolvedConfig;
94
- readonly env: Readonly<Record<string, string | undefined>>;
95
- readonly check: boolean;
96
- /** Pre-loaded snapshot (tests, watch mode). */
97
- readonly snapshot?: Snapshot;
98
- }
99
- /**
100
- * Renders every generated file for a snapshot, without touching disk:
101
- * `database.types.ts` (what `supabase gen types` prints), the main module,
102
- * then each configured generator's files.
103
- */
104
- export declare function renderFiles(config: ResolvedConfig, snapshot: Snapshot): Promise<GeneratedFile[]>;
105
- export declare function runGen(options: GenOptions): Promise<CommandResult>;
106
- //#endregion
107
- //#region src/cli/introspect/extras.d.ts
108
- /** A hook function to introspect: `[auth.hook.<hook>]` pointing at `schema.name`. */
109
- interface HookTarget {
110
- readonly hook: string;
111
- readonly schema: string;
112
- readonly name: string;
113
- }
114
- //#endregion
115
- //#region src/cli/introspect/catalog.d.ts
116
- /** Joins the typegen metadata and the extras into one record per object. */
117
- export declare function toCatalog(snapshot: Snapshot): Catalog;
118
- //#endregion
119
- //#region src/cli/introspect/index.d.ts
120
- interface IntrospectOptions {
121
- /** Auth hook functions to read too, in any schema (`[auth.hook.*]`). */
122
- readonly hooks?: readonly HookTarget[];
123
- }
124
- /** Reads a v2 snapshot: typegen metadata plus the extras. */
125
- export declare function introspect(db: Queryable, schemas: readonly string[], options?: IntrospectOptions): Promise<Snapshot>;
126
- //#endregion
127
- //#region src/cli/introspect/from-catalog.d.ts
128
- /**
129
- * Builds a snapshot from catalog records: the inverse of `toCatalog`. Tests
130
- * and benchmarks describe schemas as tables and functions; this produces the
131
- * typegen metadata and extras those records imply.
132
- */
133
- export declare function fromCatalog(catalog: Catalog): Snapshot;
134
- //#endregion
135
- //#region src/cli/gen/model.d.ts
136
- interface ColumnModel {
137
- readonly app: string;
138
- readonly db: string;
139
- readonly snapshot: CatalogColumn;
140
- /** TypeScript type without `| null`. */
141
- readonly tsType: string;
142
- readonly nullable: boolean;
143
- /** Optional on insert. */
144
- readonly optional: boolean;
145
- /** Not writable (generated always / identity always). */
146
- readonly readonly: boolean;
147
- readonly values: readonly string[] | undefined;
148
- readonly json: boolean;
149
- readonly codec: Codec | undefined;
150
- /** Bucket id from `config.storagePaths`. */
151
- readonly storage: string | undefined;
152
- readonly insertable: boolean;
153
- readonly updatable: boolean;
154
- }
155
- interface RelationModel {
156
- readonly name: string;
157
- readonly meta: RelationMeta;
158
- }
159
- interface TableModel {
160
- readonly key: string;
161
- readonly snapshot: CatalogTable;
162
- readonly casing: Casing;
163
- readonly columns: readonly ColumnModel[];
164
- readonly relations: readonly RelationModel[];
165
- readonly meta: TableMeta;
166
- }
167
- interface EnumModel {
168
- readonly schema: string;
169
- readonly name: string;
170
- /** Constant name for the value array, e.g. `noteKindValues`. */
171
- readonly constant: string;
172
- readonly values: readonly string[];
173
- }
174
- interface FunctionModel {
175
- readonly key: string;
176
- readonly meta: FunctionMeta;
177
- readonly args: readonly {
178
- name: string;
179
- tsType: string;
180
- optional: boolean;
181
- }[];
182
- readonly returns: string;
183
- }
184
- interface JsonImport {
185
- readonly name: string;
186
- /** Path relative to the project root, without the `#Name` part. */
187
- readonly from: string;
188
- }
189
- interface Model {
190
- readonly tables: readonly TableModel[];
191
- readonly enums: readonly EnumModel[];
192
- readonly functions: readonly FunctionModel[];
193
- readonly jsonImports: readonly JsonImport[];
194
- readonly meta: SchemaMeta;
195
- readonly config: ResolvedConfig;
196
- readonly catalog: Catalog;
197
- /** Typegen metadata restricted to the configured schemas. */
198
- readonly introspection: GeneratorMetadata;
199
- }
200
- /** Builds the codegen model from a snapshot and config. */
201
- export declare function buildModel(snapshot: Snapshot, config: ResolvedConfig): Model;
202
- //#endregion
203
- //#region src/cli/gen/emit.d.ts
204
- export declare const GENERATED_HEADER = "// @generated by better-supabase gen. Do not edit; run `better-supabase gen` instead.";
205
- interface EmitOptions {
206
- /** Import path from the generated module to `better-supabase`. */
207
- readonly runtimeImport?: string;
208
- /** Import path from the generated module to `database.types.ts`. */
209
- readonly databaseTypesImport?: string;
210
- /** Import path for each JSON type import, keyed by the configured path. */
211
- readonly importPathFor: (from: string) => string;
212
- }
213
- /** Renders the generated module. */
214
- export declare function emitModule(model: Model, options: EmitOptions): string;
215
- //#endregion
216
- //#region src/cli/config.d.ts
217
- /**
218
- * Loads the config with a native `import()`. Node 24 strips types from
219
- * `.ts` files, so no loader is needed.
220
- */
221
- export declare function loadConfig(cwd: string, explicit?: string): Promise<ResolvedConfig>;
222
- //#endregion
223
- //#region src/cli/version.d.ts
224
- export declare const VERSION = "0.0.0";
225
- //#endregion
226
- export type { Catalog, CatalogCheck, CatalogColumn, CatalogEnum, CatalogForeignKey, CatalogFunction, CatalogFunctionArg, CatalogGrant, CatalogIndex, CatalogPolicy, CatalogTable, CatalogTrigger, CatalogUnique, CliIo, Command, CommandContext, CommandResult, ExtrasFunction, ExtrasHook, ExtrasHookFunction, ExtrasTable, ForeignKeyAction, GeneratorMetadata, IntrospectionSource, ManagementSourceOptions, Queryable, RunOptions, RunResult, Snapshot, SnapshotBucket, SnapshotExtras };
package/dist/cli/index.js DELETED
@@ -1,3 +0,0 @@
1
- import { t as VERSION } from "../version-Cqq1m3UY.js";
2
- import { _ as emitModule, a as renderFiles, c as parseSnapshot, d as managementSource, f as pgSource, g as GENERATED_HEADER, h as toCatalog, i as run, l as serializeSnapshot, m as buildModel, n as HELP, o as runGen, p as loadConfig, r as registerCommand, s as loadSnapshot, t as fromCatalog, u as introspect } from "../cli-DrSgDOQC.js";
3
- export { GENERATED_HEADER, HELP, VERSION, buildModel, emitModule, fromCatalog, introspect, loadConfig, loadSnapshot, managementSource, parseSnapshot, pgSource, registerCommand, renderFiles, run, runGen, serializeSnapshot, toCatalog };