better-supabase 0.21.0 → 0.22.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 (216) hide show
  1. package/dist/{adapter-DZJZTY6g.js → adapter-D4aNBxhm.js} +2 -2
  2. package/dist/api-3C0AWFeP.js +696 -0
  3. package/dist/{api-Cj4W_pqT.d.ts → api-CHObZL7m.d.ts} +1 -1
  4. package/dist/{app-tables-C5HjXs2k.d.ts → app-tables-BGzdnQm5.d.ts} +1 -1
  5. package/dist/astro/index.js +5 -5
  6. package/dist/blocks/access-requests/index.js +1 -1
  7. package/dist/blocks/activities/index.js +1 -1
  8. package/dist/blocks/agents/index.js +1 -1
  9. package/dist/blocks/ai-chat/index.js +1 -1
  10. package/dist/blocks/ai-keys/index.js +1 -1
  11. package/dist/blocks/announcements/index.js +1 -1
  12. package/dist/blocks/api-keys/index.js +1 -1
  13. package/dist/blocks/approvals/index.js +1 -1
  14. package/dist/blocks/assets/index.js +1 -1
  15. package/dist/blocks/assignment/index.js +1 -1
  16. package/dist/blocks/attachments/index.js +1 -1
  17. package/dist/blocks/audit/index.d.ts +1 -1
  18. package/dist/blocks/audit/index.js +1 -1
  19. package/dist/blocks/automations/index.js +1 -1
  20. package/dist/blocks/billable-time/index.js +1 -1
  21. package/dist/blocks/billing/index.js +2 -2
  22. package/dist/blocks/bookings/index.js +1 -1
  23. package/dist/blocks/bulk/index.js +1 -1
  24. package/dist/blocks/calendar/index.js +1 -1
  25. package/dist/blocks/catalog/index.js +1 -1
  26. package/dist/blocks/channels/index.js +1 -1
  27. package/dist/blocks/collections/index.js +1 -1
  28. package/dist/blocks/compliance/index.js +1 -1
  29. package/dist/blocks/connectors/index.js +1 -1
  30. package/dist/blocks/contacts/index.js +1 -1
  31. package/dist/blocks/content/index.js +1 -1
  32. package/dist/blocks/contracts/index.js +1 -1
  33. package/dist/blocks/courses/index.js +1 -1
  34. package/dist/blocks/custom-fields/index.js +1 -1
  35. package/dist/blocks/data-lifecycle/index.js +1 -1
  36. package/dist/blocks/deals/index.js +1 -1
  37. package/dist/blocks/dispatch/index.js +1 -1
  38. package/dist/blocks/documents/index.js +1 -1
  39. package/dist/blocks/domains/index.js +1 -1
  40. package/dist/blocks/donations/index.js +1 -1
  41. package/dist/blocks/drive/index.js +1 -1
  42. package/dist/blocks/employees/index.js +1 -1
  43. package/dist/blocks/enrichment/index.js +1 -1
  44. package/dist/blocks/enrollments/index.js +1 -1
  45. package/dist/blocks/expenses/index.js +1 -1
  46. package/dist/blocks/flags/index.js +1 -1
  47. package/dist/blocks/forecasts/index.js +1 -1
  48. package/dist/blocks/forms/index.js +1 -1
  49. package/dist/blocks/guests/index.js +1 -1
  50. package/dist/blocks/hiring/index.js +1 -1
  51. package/dist/blocks/imports/index.js +1 -1
  52. package/dist/blocks/inbox/index.js +1 -1
  53. package/dist/blocks/incidents/index.js +1 -1
  54. package/dist/blocks/index.js +2 -2
  55. package/dist/blocks/inventory/index.js +1 -1
  56. package/dist/blocks/invoices/index.js +1 -1
  57. package/dist/blocks/leases/index.js +1 -1
  58. package/dist/blocks/leave/index.js +1 -1
  59. package/dist/blocks/ledger/index.js +1 -1
  60. package/dist/blocks/mail-sync/index.js +1 -1
  61. package/dist/blocks/messaging/index.js +1 -1
  62. package/dist/blocks/metrics/index.js +1 -1
  63. package/dist/blocks/moderation/index.js +1 -1
  64. package/dist/blocks/notifications/index.js +3 -3
  65. package/dist/blocks/numbering/index.js +1 -1
  66. package/dist/blocks/oauth-server/index.js +1 -1
  67. package/dist/blocks/orders/index.js +1 -1
  68. package/dist/blocks/organizations/index.js +1 -1
  69. package/dist/blocks/outbox/index.js +1 -1
  70. package/dist/blocks/passes/index.js +1 -1
  71. package/dist/blocks/pipelines/index.js +1 -1
  72. package/dist/blocks/posts/index.js +1 -1
  73. package/dist/blocks/promotions/index.js +1 -1
  74. package/dist/blocks/push/index.js +1 -1
  75. package/dist/blocks/quotes/index.js +1 -1
  76. package/dist/blocks/reactions/index.js +1 -1
  77. package/dist/blocks/relations/index.js +1 -1
  78. package/dist/blocks/reminders/index.js +1 -1
  79. package/dist/blocks/reviews/index.js +1 -1
  80. package/dist/blocks/saved-views/index.js +1 -1
  81. package/dist/blocks/scores/index.js +1 -1
  82. package/dist/blocks/search/index.js +1 -1
  83. package/dist/blocks/security-events/index.js +1 -1
  84. package/dist/blocks/segments/index.js +1 -1
  85. package/dist/blocks/sequences/index.js +1 -1
  86. package/dist/blocks/service-accounts/index.js +1 -1
  87. package/dist/blocks/settings/index.js +1 -1
  88. package/dist/blocks/share-links/index.js +1 -1
  89. package/dist/blocks/shipments/index.js +1 -1
  90. package/dist/blocks/signatures/index.js +1 -1
  91. package/dist/blocks/signing-keys/index.js +1 -1
  92. package/dist/blocks/sla/index.js +1 -1
  93. package/dist/blocks/sso/index.js +1 -1
  94. package/dist/blocks/state-machine/index.js +1 -1
  95. package/dist/blocks/tags/index.js +1 -1
  96. package/dist/blocks/tasks/index.js +2 -2
  97. package/dist/blocks/teams/index.js +1 -1
  98. package/dist/blocks/templates/index.js +1 -1
  99. package/dist/blocks/time-tracking/index.js +1 -1
  100. package/dist/blocks/timeline/index.js +1 -1
  101. package/dist/blocks/trash/index.js +1 -1
  102. package/dist/blocks/vercel-marketplace/index.js +1 -1
  103. package/dist/blocks/versions/index.js +1 -1
  104. package/dist/blocks/waitlist/index.js +1 -1
  105. package/dist/blocks/webhooks/index.js +4 -4
  106. package/dist/blocks/workflow-editor/index.js +1 -1
  107. package/dist/blocks/workflows/index.js +1 -1
  108. package/dist/cli/{add-C0w-mVTQ.js → add-B6CQOt3A.js} +2 -2
  109. package/dist/cli/{add-BTDPjVGC.js → add-BXFzr0Wf.js} +9 -9
  110. package/dist/cli/add-w_HumDPX.js +1 -0
  111. package/dist/cli/{backfill-BDdBs6Ne.js → backfill-Dflp6JZk.js} +1 -1
  112. package/dist/cli/bin.js +1 -1
  113. package/dist/cli/{blocks-Bs-lA-U_.js → blocks-CBH3N7Fy.js} +1 -1
  114. package/dist/cli/{blocks-CQLME-HQ.js → blocks-FtOIcUbu.js} +1 -1
  115. package/dist/cli/{cache-DDKao2Va.js → cache-61VwYKEv.js} +1 -1
  116. package/dist/cli/{codemod-Bjl998Do.js → codemod-CqPRa25J.js} +1 -1
  117. package/dist/cli/{content-mapper-DgSTl-DL.js → content-mapper-DGQQY5IA.js} +2 -2
  118. package/dist/cli/{doctor-CMLWbt44.js → doctor-BxxSO193.js} +19 -17
  119. package/dist/cli/{gen-D3VX8WdV.js → gen-D2cqqqTH.js} +11 -11
  120. package/dist/cli/index.d.ts +1 -1
  121. package/dist/cli/index.js +6 -6
  122. package/dist/cli/{init-D6D6eWze.js → init-BnG1IE1y.js} +5 -5
  123. package/dist/cli/{live-C_xgTOfD.js → live-D26OWOAb.js} +2 -2
  124. package/dist/cli/{mcp-B0Irjbes.js → mcp-1l3C_GdB.js} +2 -2
  125. package/dist/cli/{metadata-cLXra-XB.js → metadata-DDfPBHwI.js} +3 -3
  126. package/dist/cli/{migration-safety-OUK-Afbb.js → migration-safety-CQbrfZIx.js} +1 -1
  127. package/dist/cli/{migrations-CHenMvl_.js → migrations-Ch5Uuvyj.js} +1 -1
  128. package/dist/cli/{module-migration-6V7vXWUK.js → module-migration-Dul1uTYX.js} +2 -2
  129. package/dist/cli/{powersync-D83yAFbl.js → powersync-CfT-tRx1.js} +2 -2
  130. package/dist/cli/powersync-Vmhw5c1N.js +1 -0
  131. package/dist/cli/{print-C0OmQyTu.js → print-CbPT4PTL.js} +2 -2
  132. package/dist/cli/{remove-BWlOngNT.js → remove-kDH1yxKZ.js} +5 -5
  133. package/dist/cli/{render-9m70qveo.js → render-0Vd7BaNA.js} +3 -3
  134. package/dist/cli/{run-gE4eAazR.js → run-Dafms0D2.js} +8 -8
  135. package/dist/cli/{run-He3M-ZRq.js → run-DxTd55Ug.js} +21 -21
  136. package/dist/cli/{shared-Cx2WFVWq.js → shared-BQAMXvwd.js} +1 -1
  137. package/dist/cli/{snapshot-CZb3uVKE.js → snapshot-B8K6gYjA.js} +2 -2
  138. package/dist/cli/{source-CrYSCdPZ.js → source-CXDyCWz5.js} +1 -1
  139. package/dist/cli/{spec-Cn5RhuQc.js → spec-BGsnTkIl.js} +2 -2
  140. package/dist/cli/{spec-D4b9ePuQ.js → spec-CaN7nOqI.js} +1 -1
  141. package/dist/cli/{sql-layout-CLJ67h3L.js → sql-layout-BGAlcp1U.js} +2 -2
  142. package/dist/cli/{sync-B8VGiaHk.js → sync-CT_5VG0E.js} +3 -3
  143. package/dist/cli/{upgrade-DMiYx1C8.js → upgrade-DA7aO88E.js} +2 -2
  144. package/dist/cli/{upgrade-BvBWK3Fo.js → upgrade-frUtPDDb.js} +4 -4
  145. package/dist/cli/{version-BVg2Z6yv.js → version-CUdPyV6J.js} +1 -1
  146. package/dist/{composite-Dw5ofSF_.js → composite-CBRbvn5j.js} +2 -2
  147. package/dist/config/index.d.ts +1 -1
  148. package/dist/config/index.js +4 -4
  149. package/dist/{config-CD2OGfCG.js → config-C9AOcQ9S.js} +1 -1
  150. package/dist/{config-BOt5T6Vs.js → config-CH-D2B-4.js} +3 -3
  151. package/dist/{context-sgrUjA3U.d.ts → context-DEisra3V.d.ts} +15 -3
  152. package/dist/create/index.d.ts +72 -451
  153. package/dist/create/index.js +15 -1687
  154. package/dist/create/lite/index.d.ts +250 -13
  155. package/dist/create/lite/index.js +1007 -24
  156. package/dist/credentials/index.js +1 -1
  157. package/dist/edge/index.js +7 -7
  158. package/dist/elysia/index.js +1 -1
  159. package/dist/events/index.js +1 -1
  160. package/dist/expo/index.js +3 -3
  161. package/dist/{framework-DXM1vNcV.js → framework-DYEUraqt.js} +1 -1
  162. package/dist/h3/index.js +1 -1
  163. package/dist/h3/v1/index.js +1 -1
  164. package/dist/hono/index.js +6 -6
  165. package/dist/{index-5JSxY1MG.d.ts → index-3p_oWttZ.d.ts} +77 -2
  166. package/dist/{index-Bt7_mxn0.d.ts → index-CM2aGNRo.d.ts} +1 -1
  167. package/dist/{app-tables-DyswUg6J.js → instances-CK0jR3Pc.js} +147 -3
  168. package/dist/{kit-DhlB-vv_.js → kit-Bcd9wYCV.js} +1 -1
  169. package/dist/mapper/bin.js +5 -5
  170. package/dist/mcp/index.js +6 -6
  171. package/dist/mcp/sdk/index.js +2 -2
  172. package/dist/nestjs/index.js +1 -1
  173. package/dist/next/index.js +7 -7
  174. package/dist/node/index.js +1 -1
  175. package/dist/orpc/index.d.ts +1 -1
  176. package/dist/orpc/index.js +5 -5
  177. package/dist/otel/index.js +4 -4
  178. package/dist/preset/index.d.ts +4 -4
  179. package/dist/preset/index.js +4 -4
  180. package/dist/{preset-B3CukUhu.js → preset-CS490mYJ.js} +179 -7
  181. package/dist/project-NmP1NdLi.js +1760 -0
  182. package/dist/react/index.js +2 -2
  183. package/dist/react/server.js +2 -2
  184. package/dist/{react-_D_CeZMk.js → react-CcrQQl0_.js} +2 -2
  185. package/dist/react-router/index.js +5 -5
  186. package/dist/realtime/index.js +1 -1
  187. package/dist/{refusal-D48CMqpQ.js → refusal-DDlInPff.js} +2 -2
  188. package/dist/{instances-DDt7NdVl.js → resolved-names-DdlJzoMK.js} +2 -146
  189. package/dist/{resource-R3KToNze.js → resource-BUJcZKiW.js} +2 -2
  190. package/dist/{resources-DqIwoQsP.js → resources-jb3R6rEa.js} +1 -1
  191. package/dist/server/index.js +7 -7
  192. package/dist/{sign-in-1FJiXXyG.js → sign-in-NO7LWlw4.js} +2 -2
  193. package/dist/solid/index.js +1 -1
  194. package/dist/solid-start/index.js +5 -5
  195. package/dist/spec/index.d.ts +2 -2
  196. package/dist/spec/index.js +2 -693
  197. package/dist/sql/index.d.ts +3 -3
  198. package/dist/sql/index.js +2 -2
  199. package/dist/{sql-BjjgwJKg.js → sql-BMXEHTvr.js} +17 -3
  200. package/dist/svelte/index.js +1 -1
  201. package/dist/sveltekit/index.js +5 -5
  202. package/dist/tanstack-start/index.js +5 -5
  203. package/dist/testing/index.d.ts +2 -2
  204. package/dist/testing/index.js +4 -4
  205. package/dist/types-BC1HLEVx.d.ts +461 -0
  206. package/dist/vue/index.js +1 -1
  207. package/dist/yjs/index.js +1 -1
  208. package/package.json +1 -1
  209. package/dist/cli/add-CspY9jKT.js +0 -1
  210. package/dist/cli/powersync-DwhCH0gs.js +0 -1
  211. package/dist/types-DGHfTW8_.d.ts +0 -9
  212. package/dist/{build-CM8PJqwW.js → build-CH2N3Yf0.js} +3 -3
  213. package/dist/{create-blocks-CUS28FfS.js → create-blocks-BfrDUSM6.js} +1 -1
  214. package/dist/{data-hooks-tgF1Ct0F.js → data-hooks-CdcZfVS1.js} +1 -1
  215. package/dist/{respond-3RKp6VgU.js → respond-CZMWbUs3.js} +1 -1
  216. package/dist/{topic-J9I3yu6f.js → topic-DClSoqY7.js} +1 -1
@@ -1,4 +1,8 @@
1
- import { t as PresetMigrationFile } from "../../types-DGHfTW8_.js";
1
+ import { ot as SchemaMeta } from "../../types-DFdg_4yN.js";
2
+ import { ht as PresetInput } from "../../context-DEisra3V.js";
3
+ import { E as CreateDesign } from "../../index-3p_oWttZ.js";
4
+ import { Tt as Issue, t as PresetMigrationFile, u as Design } from "../../types-BC1HLEVx.js";
5
+ import { c as SpecDiagnostic } from "../../format-u-65igKI.js";
2
6
  //#region src/lite/runtime.d.ts
3
7
  /**
4
8
  * The parts of `@supabase/lite` that `liteStack()` uses, typed structurally so
@@ -19,7 +23,7 @@ interface PgliteConnection extends LiteConnection {
19
23
  */
20
24
  readonly driver: {
21
25
  exec(sql: string): Promise<unknown>;
22
- query(sql: string): Promise<{
26
+ query(sql: string, params?: readonly unknown[]): Promise<{
23
27
  rows: unknown[];
24
28
  }>;
25
29
  };
@@ -43,6 +47,16 @@ interface LiteRuntime {
43
47
  createSqliteConnection(url: string): Promise<LiteConnection>;
44
48
  }
45
49
  //#endregion
50
+ //#region src/create/lite/apply.d.ts
51
+ /**
52
+ * A module PGlite can't run, such as one that needs an extension it doesn't
53
+ * ship.
54
+ */
55
+ interface SkippedBlock {
56
+ readonly module: string;
57
+ readonly reason: string;
58
+ }
59
+ //#endregion
46
60
  //#region src/create/lite/prelude.d.ts
47
61
  /**
48
62
  * What a Supabase project already has before the first migration runs: the API
@@ -53,25 +67,243 @@ interface LiteRuntime {
53
67
  */
54
68
  export declare const SUPABASE_PRELUDE: string;
55
69
  //#endregion
56
- //#region src/create/lite/index.d.ts
57
- /** One file that failed to apply in Postgres. */
58
- export interface DesignIssue {
59
- readonly module: string;
70
+ //#region src/create/lite/catalog.d.ts
71
+ interface RawColumn {
72
+ readonly name: string;
73
+ readonly type: string;
74
+ readonly nullable: boolean;
75
+ readonly default: string | null;
76
+ readonly identity: string | null;
77
+ readonly generated: boolean;
78
+ readonly comment: string | null;
79
+ /** The element type's name for arrays (`uuid`, `text`, `note_kind`). */
80
+ readonly udt: string;
81
+ readonly array: boolean;
82
+ readonly enumValues: readonly string[];
83
+ }
84
+ interface RawConstraint {
85
+ readonly name: string;
86
+ readonly type: "p" | "u" | "f";
87
+ readonly columns: readonly string[];
88
+ readonly refSchema: string | null;
89
+ readonly refTable: string | null;
90
+ readonly refColumns: readonly string[] | null;
91
+ readonly onDelete: string | null;
92
+ }
93
+ interface RawIndex {
94
+ readonly columns: readonly string[];
95
+ readonly plain: boolean;
96
+ }
97
+ interface RawTable {
98
+ readonly schema: string;
99
+ readonly name: string;
100
+ readonly kind: string;
101
+ readonly rls: boolean;
102
+ readonly comment: string | null;
103
+ readonly columns: readonly RawColumn[];
104
+ readonly constraints: readonly RawConstraint[];
105
+ readonly indexes: readonly RawIndex[];
106
+ readonly policies: number;
107
+ readonly triggers: number;
108
+ }
109
+ interface RawCatalog {
110
+ readonly tables: readonly RawTable[];
111
+ readonly functions: readonly string[];
112
+ }
113
+ //#endregion
114
+ //#region src/create/lite/import.d.ts
115
+ /** Anything that runs a read-only query and returns rows: PGlite, `pg`, a shim. */
116
+ export interface ImportQueryable {
117
+ query(sql: string): Promise<{
118
+ readonly rows: readonly unknown[];
119
+ }>;
120
+ }
121
+ /**
122
+ * Where a project is read from (ADR 0100).
123
+ *
124
+ * - `files`: a declarative schema folder or a migrations folder, as path and
125
+ * contents. They are applied in path order to a throwaway PGlite database.
126
+ * - `queryable`: a database you can query, such as a `pg` pool or a PGlite
127
+ * instance.
128
+ * - `supabase`: a project ref and an access token, read through the Management
129
+ * API's read-only query endpoint.
130
+ */
131
+ export type ImportSource = {
132
+ readonly kind: "files";
133
+ readonly files: readonly ImportFile[];
134
+ } | {
135
+ readonly kind: "queryable";
136
+ readonly queryable: ImportQueryable;
137
+ } | {
138
+ readonly kind: "supabase";
139
+ readonly projectRef: string;
140
+ readonly accessToken: string;
141
+ readonly fetch?: typeof fetch;
142
+ readonly apiUrl?: string;
143
+ };
144
+ export interface ImportFile {
60
145
  readonly path: string;
146
+ readonly contents: string;
147
+ }
148
+ export interface ImportProjectOptions {
149
+ readonly source: ImportSource;
150
+ /** The schemas to read. Defaults to `public`. */
151
+ readonly schemas?: readonly string[];
152
+ /** A loaded `@supabase/lite`, for `files` sources. Loaded on demand. */
153
+ readonly runtime?: LiteRuntime;
154
+ }
155
+ /** How far a table is along the adoption ladder (ADR 0102). */
156
+ export type AdoptionRung = "open" | "locked" | "protected";
157
+ export interface ImportedTable {
158
+ readonly schema: string;
159
+ readonly name: string;
160
+ readonly rung: AdoptionRung;
161
+ /** `false` when the table is kept as it is, outside the design. */
162
+ readonly modeled: boolean;
163
+ readonly columns: number;
164
+ }
165
+ /** An object the import keeps verbatim and never drops. */
166
+ export interface PreservedObject {
167
+ readonly kind: "table" | "view" | "column" | "foreign_key" | "index" | "default" | "function" | "trigger" | "policy";
168
+ readonly name: string;
169
+ readonly reason: string;
170
+ }
171
+ export interface ImportReport {
172
+ readonly counts: {
173
+ readonly tables: number;
174
+ readonly modeledTables: number;
175
+ readonly columns: number;
176
+ readonly views: number;
177
+ readonly functions: number;
178
+ readonly triggers: number;
179
+ readonly policies: number;
180
+ };
181
+ readonly tables: readonly ImportedTable[];
182
+ /** Tables created by a block (`bsb_` names), which a design never models. */
183
+ readonly blockOwned: readonly string[];
184
+ readonly preserved: readonly PreservedObject[];
185
+ /** SQL errors from `files` and the security findings (`source: "verifier"`). */
186
+ readonly issues: readonly Issue[];
187
+ }
188
+ export interface ImportResult {
189
+ readonly design: Design;
190
+ readonly report: ImportReport;
191
+ }
192
+ /** Turns a catalog into a design and the report the import shows. */
193
+ export declare function designFromCatalog(catalog: RawCatalog, issues?: readonly Issue[]): ImportResult;
194
+ /**
195
+ * Reads an existing project into a `Design` and a report (ADR 0100). The design
196
+ * models the tables Create can express: `public` tables with a single `uuid` or
197
+ * `bigint` `id` key, their columns, references to other modeled tables or
198
+ * `auth.users`, unique keys and plain indexes. Everything else is listed under
199
+ * `report.preserved` and is never dropped: a deploy applies only what the
200
+ * design adds. Tables named `bsb_*` belong to blocks. The report also carries
201
+ * each table's adoption rung and the security findings (`source: "verifier"`).
202
+ *
203
+ * Throws when a `files` source needs `@supabase/lite` and it isn't installed,
204
+ * or when a `supabase` source answers with an error.
205
+ */
206
+ export declare function importProject(options: ImportProjectOptions): Promise<ImportResult>;
207
+ /** Files in the shape `previewFiles` returns, for callers that hold those. */
208
+ export declare function importFilesOf(files: readonly PresetMigrationFile[]): readonly ImportFile[];
209
+ //#endregion
210
+ //#region src/create/lite/sandbox.d.ts
211
+ /** Who a query runs as: the claims a Supabase JWT would carry. */
212
+ interface Persona {
213
+ /** The user id, `auth.uid()`. Leave out for an anonymous caller. */
214
+ readonly sub?: string;
215
+ /** Defaults to `authenticated` with a `sub`, otherwise `anon`. */
216
+ readonly role?: "anon" | "authenticated" | "service_role";
217
+ /** Extra claims, such as `app_metadata` or the tenant claim. */
218
+ readonly claims?: Readonly<Record<string, unknown>>;
219
+ }
220
+ interface SandboxError {
221
+ /** The Postgres error code, such as `42501` or `23505`. */
222
+ readonly code: string;
61
223
  readonly message: string;
62
224
  }
225
+ type SandboxResult = {
226
+ readonly ok: true;
227
+ readonly rows: readonly unknown[];
228
+ } | {
229
+ readonly ok: false;
230
+ readonly error: SandboxError;
231
+ };
232
+ interface SandboxSession {
233
+ /**
234
+ * Runs one statement in a transaction as this persona, with row level
235
+ * security applied. A failed statement rolls back.
236
+ */
237
+ query(sql: string, params?: readonly unknown[]): Promise<SandboxResult>;
238
+ /** A subset of PostgREST over the sandbox, as this persona. */
239
+ rest(request: Request): Promise<Response>;
240
+ }
241
+ interface Sandbox extends SandboxSession {
242
+ /** A persona's session. The sandbox itself runs as the database owner. */
243
+ as(persona: Persona): SandboxSession;
244
+ /** Every table, column and key in `public`. */
245
+ catalog(): Promise<RawCatalog>;
246
+ /** SQL errors from applying the project's files. */
247
+ readonly issues: readonly Issue[];
248
+ readonly skipped: readonly SkippedBlock[];
249
+ close(): Promise<void>;
250
+ }
251
+ interface SandboxOptions {
252
+ /** A loaded `@supabase/lite`; loaded on demand when left out. */
253
+ readonly runtime?: LiteRuntime;
254
+ }
63
255
  /**
64
- * A module PGlite can't run, such as one that needs an extension it doesn't
65
- * ship.
256
+ * Opens an in-memory PGlite database with a project's files applied, the
257
+ * Supabase roles in place and the API roles granted what Supabase grants them
258
+ * by default. Queries run as the database owner, or as a persona through `as({
259
+ * sub, role, claims })` with row level security applied, and `rest` answers a
260
+ * subset of PostgREST: table reads and writes with `select`, filters, `order`,
261
+ * `limit` and `offset`, and `rpc` calls. Embedding, `or`, `and` and range
262
+ * headers are not supported. Throws when `@supabase/lite` isn't installed.
66
263
  */
67
- export interface SkippedBlock {
68
- readonly module: string;
69
- readonly reason: string;
264
+ export declare function openSandbox(project: {
265
+ readonly files: readonly PresetMigrationFile[];
266
+ }, options?: SandboxOptions): Promise<Sandbox>;
267
+ //#endregion
268
+ //#region src/create/lite/data-api.d.ts
269
+ /**
270
+ * The runtime metadata of a catalog's `public` tables and views, in snake
271
+ * casing, keyed by table name. It carries what the Data API document needs:
272
+ * columns, keys and enums. Relations and functions are left out.
273
+ */
274
+ export declare function schemaMetaFromCatalog(catalog: RawCatalog): SchemaMeta;
275
+ export interface DesignDataApiOptions extends SandboxOptions {
276
+ /** The document's `info`. Defaults to the project name `Data API`. */
277
+ readonly title?: string;
278
+ readonly version?: string;
279
+ /** The project URL, which the `/rest/v1` paths resolve against. */
280
+ readonly supabaseUrl?: string;
70
281
  }
282
+ export type DesignDataApi = {
283
+ readonly ok: true;
284
+ /** The OpenAPI 3.1 document of the project's Data API. */
285
+ readonly document: unknown;
286
+ readonly diagnostics: readonly SpecDiagnostic[];
287
+ /** The tables the document describes. */
288
+ readonly tables: readonly string[];
289
+ } | {
290
+ readonly ok: false;
291
+ readonly issues: readonly Issue[];
292
+ };
293
+ /**
294
+ * The OpenAPI document of the Data API a design produces: the files render to a
295
+ * PGlite database, and the tables that come out become `/rest/v1` paths with
296
+ * row, insert and update schemas. It never touches a project. Throws when
297
+ * `@supabase/lite` isn't installed.
298
+ */
299
+ export declare function designDataApi(preset: PresetInput, design?: CreateDesign, options?: DesignDataApiOptions): Promise<DesignDataApi>;
300
+ //#endregion
301
+ //#region src/create/lite/index.d.ts
71
302
  export interface DesignValidation {
72
303
  /** `true` when every file that could run applied cleanly. */
73
304
  readonly ok: boolean;
74
- readonly issues: readonly DesignIssue[];
305
+ /** One issue per file Postgres rejected: `source: "sql"`, `table` the module. */
306
+ readonly issues: readonly Issue[];
75
307
  readonly skipped: readonly SkippedBlock[];
76
308
  /** Tables in `public` after the files applied. */
77
309
  readonly tables: number;
@@ -88,5 +320,10 @@ export interface ValidateDesignOptions {
88
320
  * `@supabase/lite` isn't installed.
89
321
  */
90
322
  export declare function validateDesign(files: readonly PresetMigrationFile[], options?: ValidateDesignOptions): Promise<DesignValidation>;
323
+ /**
324
+ * The issues `validateDesign` finds, for `checkProject`'s `sql` option:
325
+ * `checkProject(project, { sql: sqlIssues })`.
326
+ */
327
+ export declare function sqlIssues(files: readonly PresetMigrationFile[]): Promise<readonly Issue[]>;
91
328
  //#endregion
92
- export {};
329
+ export type { Persona, RawCatalog, RawColumn, RawTable, Sandbox, SandboxError, SandboxOptions, SandboxResult, SandboxSession, SkippedBlock };