@supabase/lite 0.8.0 → 0.8.1-next.2

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/dist/cli/lib.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _supabase_supabase_js from '@supabase/supabase-js';
2
2
  import { SupportedStorage, SupabaseClient } from '@supabase/supabase-js';
3
- import { S as Schema } from '../index-xv_pDjEt.js';
3
+ import { S as Schema } from '../index-DKO3OQpz.js';
4
4
  import { Connection, DefaultAppConfig, App } from '@supabase/lite';
5
5
  import 'jsonv-ts';
6
6
 
@@ -72,7 +72,24 @@ declare class ProjectLocalApi extends ProjectApi {
72
72
  protected readConfig(file_path?: string): Promise<Schema>;
73
73
  createConnection(): Promise<Connection>;
74
74
  getConfig(file_path?: string): Promise<DefaultAppConfig>;
75
- createApp(config_path?: string): Promise<App>;
75
+ /**
76
+ * Build the `App` for a local project: read the config, resolve the
77
+ * connection, apply caller overrides, and initialize it.
78
+ *
79
+ * @param opts.admin An explicit local-admin-mode decision (see
80
+ * `ServerOptions.admin`) — `--no-admin`, or the Vite preview server's forced
81
+ * opt-out. Wins over `config.toml`: otherwise a config saying `admin = true`
82
+ * would silently re-enable what the operator just turned off.
83
+ * @param opts.adminDefault The launcher's default, applied only when neither
84
+ * the caller nor the config expressed a preference — so a project can set
85
+ * `admin = false` in config and have `lite start` honor it.
86
+ *
87
+ * Resolution order is therefore `admin` > `config.toml` > `adminDefault`.
88
+ */
89
+ createApp(config_path?: string, opts?: {
90
+ admin?: boolean;
91
+ adminDefault?: boolean;
92
+ }): Promise<App>;
76
93
  }
77
94
 
78
95
  declare class ProjectRemoteApi extends ProjectApi {
@@ -119,20 +136,29 @@ declare class Api extends BaseApi<ApiConfig> {
119
136
 
120
137
  declare function createApi(options?: Partial<ApiConfig>): Promise<Api>;
121
138
 
139
+ type GeneratedProjectKeys = {
140
+ publishable?: string;
141
+ secret?: string;
142
+ };
143
+ /** @param created True only on the run that wrote the config, so `lite dev` can announce the scaffold it caused. */
122
144
  declare function ensureInitialStructure(opts?: Partial<{
123
145
  configFormat: "toml" | "json";
124
146
  driver: NonNullable<Schema["db"]>["driver"];
125
147
  recreate: boolean;
126
148
  template: boolean;
127
- }>): Promise<void>;
149
+ }>): Promise<{
150
+ generatedKeys?: GeneratedProjectKeys;
151
+ created: boolean;
152
+ }>;
128
153
 
129
154
  declare function ensureSchema(app: App, opts?: {
130
155
  force?: boolean;
131
156
  }): Promise<void>;
157
+ /** Returns a stop function so callers can tear the watcher down on shutdown. */
132
158
  declare function watchSchema(app: App, opts?: {
133
159
  force?: boolean;
134
160
  translate?: boolean;
135
- }): void;
161
+ }): () => Promise<void>;
136
162
 
137
163
  interface MigrationFile {
138
164
  version: string;
@@ -148,12 +174,39 @@ interface ApplyResult {
148
174
  applied: MigrationFile[];
149
175
  skipped: MigrationFile[];
150
176
  }
177
+ interface ApplyOptions {
178
+ /**
179
+ * Persist the migration-derived deparse snapshot even when the project has
180
+ * declarative `supabase/schemas/*.sql`. Set ONLY by `lite db reset`, which is
181
+ * destructive: it drops whatever a declarative apply built, so migration
182
+ * metadata then describes the fresh database exactly. Non-destructive callers
183
+ * must not opt in — their snapshot would validate on the next `lite start`
184
+ * while missing every declarative policy (LITE-310).
185
+ */
186
+ persistWithDeclarative?: boolean;
187
+ }
151
188
  /**
152
189
  * Apply pending migrations to the connected database, one implicit transaction
153
190
  * per file. The history INSERT is appended to the file's batch so a failure in
154
191
  * any statement rolls back the record too — same semantics as Supabase CLI
155
192
  * (`~/supabase/cli/pkg/migration/file.go:72-103` `ExecBatch`).
156
193
  */
157
- declare function applyPendingMigrations(app: App): Promise<ApplyResult>;
194
+ declare function applyPendingMigrations(app: App, options?: ApplyOptions): Promise<ApplyResult>;
195
+
196
+ /**
197
+ * Resolve the project's configured `auth.publishable_key`, fully substituted
198
+ * (an `env(VAR)` ref resolves to the real value, or "" if unset) — without
199
+ * opening a database connection. Used where only the key is needed (e.g. the
200
+ * Vite plugin's `config()` hook, which runs before the app/connection exists).
201
+ * Returns `undefined` when no project/config is found, the config can't be
202
+ * read (missing/malformed — never crash `vite dev` over this), or no key is
203
+ * configured.
204
+ *
205
+ * `env` defaults to `process.env` but can be overridden with an isolated
206
+ * object — tests share one process (`bun test` interleaves files async), so
207
+ * mutating the real `process.env` here (via `loadDotenvForConfig`'s
208
+ * first-write-wins) would otherwise race with any other test's `.env` load.
209
+ */
210
+ declare function resolveConfiguredPublishableKey(configPath?: string, env?: NodeJS.ProcessEnv): Promise<string | undefined>;
158
211
 
159
- export { applyPendingMigrations, createApi, ensureInitialStructure, ensureSchema, listMigrationFiles, migrationsDir, watchSchema };
212
+ export { applyPendingMigrations, createApi, ensureInitialStructure, ensureSchema, listMigrationFiles, migrationsDir, resolveConfiguredPublishableKey, watchSchema };