@supabase/lite 0.0.1 → 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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@supabase/lite",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Lightweight TypeScript-native Supabase implementation on SQLite (alpha). PostgREST + GoTrue compatible — use @supabase/supabase-js as-is.",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/supabase/lite.git",
8
+ "url": "https://github.com/supabase-community/lite.git",
9
9
  "directory": "app"
10
10
  },
11
11
  "bin": {
@@ -111,7 +111,7 @@
111
111
  "dev": "vite",
112
112
  "typecheck": "tsc --project tsconfig.check.json",
113
113
  "build": "bun run build.ts",
114
- "build:all": "bun run build:static && bun run build.ts --types",
114
+ "build:all": "bun run build:static && bun run build.ts --types --minify",
115
115
  "build:static": "vite build",
116
116
  "watch:static": "vite build --watch",
117
117
  "dev:bun": "bun run --hot dev/bun/bun.dev.ts",
@@ -120,6 +120,8 @@
120
120
  "cli": "LOCAL=1 bun src/cli/index.ts",
121
121
  "docs:generate": "bun run internal/extract.ts",
122
122
  "smoke:pack": "bun run internal/smoke-pack.ts",
123
+ "prepack": "bun run internal/package-readme.ts prepare",
124
+ "postpack": "bun run internal/package-readme.ts cleanup",
123
125
  "prepublishOnly": "npm whoami && bun run typecheck && bun run test && bun run build:all && bun run smoke:pack -- --no-build",
124
126
  "release:patch": "echo \"Use GitHub Actions > Release with version_specifier=patch.\" && exit 1",
125
127
  "release:minor": "echo \"Use GitHub Actions > Release with version_specifier=minor.\" && exit 1",
@@ -1,529 +0,0 @@
1
- import { SelectQueryBuilder, InsertQueryBuilder, UpdateQueryBuilder, DeleteQueryBuilder, KyselyConfig, Kysely } from 'kysely';
2
-
3
- /**
4
- * Nested object for runtime variable substitution.
5
- * Paths are resolved via lodash-style dot-path access (e.g. "auth.jwt.role" → vars.auth.jwt.role).
6
- * e.g. { auth: { uid: "uuid-here", role: "authenticated", jwt: { role: "admin" } } }
7
- */
8
- type VarsContext = Record<string, unknown>;
9
-
10
- type ASTType = "query" | "insert" | "update" | "delete" | "upsert" | "put" | "rpc";
11
- type QbSelect = SelectQueryBuilder<any, any, any>;
12
- type QbInsert = InsertQueryBuilder<any, any, any>;
13
- type QbUpdate = UpdateQueryBuilder<any, any, any, any>;
14
- type QbDelete = DeleteQueryBuilder<any, any, any>;
15
- type Qb = QbSelect | QbInsert | QbUpdate | QbDelete;
16
- type ColumnDef = {
17
- column?: string;
18
- cast?: string;
19
- preCast?: string;
20
- aggregate?: AggregateFunction;
21
- path?: string;
22
- };
23
- type EmbedDef = {
24
- select?: SelectEntry[];
25
- where?: Where;
26
- order?: OrderEntry[];
27
- limit?: number;
28
- offset?: number;
29
- spread?: boolean;
30
- join?: JoinMap;
31
- };
32
- type SelectEntry = string | Record<string, ColumnDef | EmbedDef>;
33
- type JoinDef = {
34
- from?: string;
35
- type?: "inner" | "left";
36
- hint?: string;
37
- on?: Where;
38
- };
39
- type JoinMap = Record<string, JoinDef>;
40
- type ColumnRef = {
41
- $ref: string;
42
- };
43
- declare function isRef(val: unknown): val is ColumnRef;
44
- type WhereValue = {
45
- [op: string]: unknown;
46
- };
47
- type Where = Record<string, unknown>;
48
- type OrderEntry = {
49
- column: string;
50
- direction?: "asc" | "desc";
51
- nullsFirst?: boolean;
52
- /** For ordering by embedded resource column: embed alias */
53
- embed?: string;
54
- };
55
- type TextSearchValue = {
56
- query: string;
57
- type?: "plain" | "phrase" | "websearch";
58
- config?: string;
59
- };
60
- type ExplainOptions = {
61
- analyze?: boolean;
62
- verbose?: boolean;
63
- settings?: boolean;
64
- buffers?: boolean;
65
- wal?: boolean;
66
- };
67
- type Meta = {
68
- cardinality?: "one" | "maybe" | "many";
69
- count?: "exact" | "planned" | "estimated";
70
- head?: boolean;
71
- maxAffected?: number;
72
- rollback?: boolean;
73
- missing?: "null" | "default";
74
- handling?: "strict" | "lenient";
75
- timezone?: string;
76
- columns?: string[];
77
- stripNulls?: boolean;
78
- explain?: ExplainOptions;
79
- headers?: Record<string, string>;
80
- return?: "minimal" | "headers-only" | "representation";
81
- tx?: "commit" | "rollback";
82
- };
83
- interface BaseAST {
84
- from: string;
85
- schema?: string;
86
- select?: SelectEntry[];
87
- $meta?: Meta;
88
- }
89
- interface QueryAST extends BaseAST {
90
- type: "query";
91
- join?: JoinMap;
92
- where?: Where;
93
- order?: OrderEntry[];
94
- limit?: number;
95
- offset?: number;
96
- group?: string[];
97
- }
98
- interface InsertAST extends BaseAST {
99
- type: "insert";
100
- values: object | object[];
101
- }
102
- interface UpdateAST extends BaseAST {
103
- type: "update";
104
- values: object;
105
- where?: Where;
106
- order?: OrderEntry[];
107
- limit?: number;
108
- offset?: number;
109
- }
110
- interface DeleteAST extends BaseAST {
111
- type: "delete";
112
- where?: Where;
113
- order?: OrderEntry[];
114
- limit?: number;
115
- offset?: number;
116
- }
117
- interface UpsertAST extends BaseAST {
118
- type: "upsert" | "put";
119
- values: object;
120
- onConflict?: string[];
121
- ignoreDuplicates?: boolean;
122
- }
123
- interface RpcAST extends BaseAST {
124
- type: "rpc";
125
- function: string;
126
- args?: object | unknown[];
127
- where?: Where;
128
- order?: OrderEntry[];
129
- limit?: number;
130
- offset?: number;
131
- httpMethod?: "GET" | "POST";
132
- paramsType?: "named" | "positional";
133
- inputType?: "json" | "text" | "binary" | "xml";
134
- }
135
- type AST = QueryAST | InsertAST | UpdateAST | DeleteAST | UpsertAST | RpcAST;
136
- type AnyAST = {
137
- type?: string;
138
- from?: string;
139
- function?: string;
140
- schema?: string;
141
- join?: JoinMap;
142
- select?: SelectEntry[];
143
- where?: Where;
144
- values?: object | object[];
145
- args?: object | unknown[];
146
- order?: OrderEntry[];
147
- limit?: number;
148
- offset?: number;
149
- group?: string[];
150
- onConflict?: string[];
151
- ignoreDuplicates?: boolean;
152
- httpMethod?: "GET" | "POST";
153
- paramsType?: "named" | "positional";
154
- inputType?: "json" | "text" | "binary" | "xml";
155
- $meta?: Meta;
156
- };
157
- type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
158
- type RouteResult = {
159
- from?: string;
160
- function?: string;
161
- isRpc: boolean;
162
- };
163
- type PreferToken = {
164
- key: "count";
165
- value: "exact" | "planned" | "estimated";
166
- } | {
167
- key: "resolution";
168
- value: "merge-duplicates" | "ignore-duplicates";
169
- } | {
170
- key: "return";
171
- value: "minimal" | "headers-only" | "representation";
172
- } | {
173
- key: "tx";
174
- value: "commit" | "rollback";
175
- } | {
176
- key: "missing";
177
- value: "default" | "null";
178
- } | {
179
- key: "handling";
180
- value: "strict" | "lenient";
181
- } | {
182
- key: "max-affected";
183
- value: number;
184
- } | {
185
- key: "timezone";
186
- value: string;
187
- } | {
188
- key: "params";
189
- value: "single-object" | "multiple-objects";
190
- };
191
- type HeadersResult = {
192
- schema?: string;
193
- preferTokens: PreferToken[];
194
- accept: string;
195
- };
196
- type SelectResult = {
197
- select: SelectEntry[];
198
- join: JoinMap;
199
- embeddedAliases: Set<string>;
200
- };
201
- type BodyResult = {
202
- values?: object | object[];
203
- args?: object;
204
- raw?: string;
205
- };
206
- type QueryParamsResult = Map<string, string[]>;
207
- type FiltersResult = {
208
- where: Where;
209
- embeddedWheres: Record<string, Where>;
210
- };
211
- type EmbedTransform = {
212
- order?: OrderEntry[];
213
- limit?: number;
214
- offset?: number;
215
- _nested?: Record<string, {
216
- order?: OrderEntry[];
217
- limit?: number;
218
- offset?: number;
219
- }>;
220
- };
221
- type TransformsResult = {
222
- order?: OrderEntry[];
223
- limit?: number;
224
- offset?: number;
225
- embeddedTransforms: Record<string, EmbedTransform>;
226
- };
227
- type RpcResult = {
228
- args?: object | unknown[];
229
- httpMethod?: "GET" | "POST";
230
- paramsType?: "named" | "positional";
231
- inputType?: "json" | "text" | "binary" | "xml";
232
- };
233
- type UpsertResult = {
234
- onConflict?: string[];
235
- ignoreDuplicates: boolean;
236
- };
237
- type TranslatorConfig = {
238
- parseRoute?: (req: Request) => RouteResult;
239
- parseHeaders?: (req: Request) => HeadersResult;
240
- parseSelect?: (req: Request) => SelectResult;
241
- parseBody?: (req: Request) => Promise<BodyResult>;
242
- parseQueryParams?: (req: Request) => QueryParamsResult;
243
- resolveType?: (route: RouteResult, method: string, headers: HeadersResult) => ASTType;
244
- resolveFilters?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>) => FiltersResult;
245
- resolveTransforms?: (queryParams: QueryParamsResult, embeddedAliases: Set<string>) => TransformsResult;
246
- resolveMeta?: (headers: HeadersResult, queryParams: QueryParamsResult, method: string) => Meta;
247
- resolveRpcParams?: (route: RouteResult, method: string, queryParams: QueryParamsResult, body: BodyResult) => RpcResult;
248
- resolveUpsertParams?: (queryParams: QueryParamsResult, headers: HeadersResult) => UpsertResult;
249
- basePath?: string;
250
- };
251
-
252
- type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
253
- type PolicyRole = "anon" | "authenticated" | string;
254
- interface PolicyData {
255
- name: string;
256
- table: string;
257
- schema?: string;
258
- command: PolicyCommand;
259
- permissive: boolean;
260
- roles: PolicyRole[];
261
- using?: Where;
262
- withCheck?: Where;
263
- }
264
- declare class Policy {
265
- readonly data: PolicyData;
266
- constructor(data: PolicyData);
267
- appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
268
- appliesToRole(role: string): boolean;
269
- toJSON(): PolicyData;
270
- static fromJSON(data: PolicyData): Policy;
271
- }
272
-
273
- interface TableInfo {
274
- name: string;
275
- sql: string;
276
- schema: string;
277
- type: "table" | "view";
278
- rows: number;
279
- engine: string;
280
- collation: string;
281
- }
282
- interface ColumnInfo {
283
- table: string;
284
- name: string;
285
- type: string;
286
- nullable: boolean;
287
- default_value: string | null;
288
- is_primary_key: boolean;
289
- schema: string;
290
- ordinal_position: number;
291
- collation: string;
292
- character_maximum_length: string | null;
293
- precision: {
294
- precision: number | null;
295
- scale: number | null;
296
- } | null;
297
- is_identity: boolean;
298
- }
299
- interface IndexInfo {
300
- table: string;
301
- name: string;
302
- unique: boolean;
303
- columns: string[];
304
- schema: string;
305
- }
306
- interface ForeignKeyInfo {
307
- table: string;
308
- column: string;
309
- ref_table: string;
310
- ref_column: string;
311
- on_update: string;
312
- on_delete: string;
313
- schema: string;
314
- ref_schema?: string;
315
- foreign_key_name: string;
316
- fk_def: string;
317
- }
318
- interface PrimaryKeyInfo {
319
- table: string;
320
- columns: string[];
321
- schema: string;
322
- field_count: number;
323
- }
324
- interface ViewInfo {
325
- name: string;
326
- sql: string;
327
- schema: string;
328
- }
329
- interface CheckConstraintInfo {
330
- schema: string;
331
- table: string;
332
- expression: string;
333
- }
334
- interface TriggerInfo {
335
- table: string;
336
- name: string;
337
- sql: string;
338
- schema: string;
339
- }
340
- interface CustomTypesInfo {
341
- schema: string;
342
- type: string;
343
- kind: "enum" | "composite";
344
- values?: string[];
345
- fields?: {
346
- name: string;
347
- type: string;
348
- }[];
349
- }
350
- type IntrospectOptions = {
351
- exclude_tables?: string[];
352
- name?: string;
353
- version?: string;
354
- };
355
- interface IntrospectResult {
356
- tables: TableInfo[];
357
- columns: ColumnInfo[];
358
- indexes: IndexInfo[];
359
- foreign_keys: ForeignKeyInfo[];
360
- primary_keys: PrimaryKeyInfo[];
361
- views: ViewInfo[];
362
- check_constraints: CheckConstraintInfo[];
363
- custom_types: CustomTypesInfo[];
364
- triggers: TriggerInfo[];
365
- database_name: string;
366
- version: string;
367
- ddl_dialect?: "postgres" | "sqlite";
368
- schema_separator?: string;
369
- }
370
- interface TableDiff {
371
- type: "added" | "removed" | "modified";
372
- name: string;
373
- sql?: string;
374
- }
375
- interface ColumnDiff {
376
- type: "added" | "removed" | "modified";
377
- table: string;
378
- name: string;
379
- changes?: {
380
- type?: {
381
- from: string;
382
- to: string;
383
- };
384
- nullable?: {
385
- from: boolean;
386
- to: boolean;
387
- };
388
- default_value?: {
389
- from: string | null;
390
- to: string | null;
391
- };
392
- };
393
- column?: ColumnInfo;
394
- }
395
- interface IndexDiff {
396
- type: "added" | "removed";
397
- table: string;
398
- name: string;
399
- unique: boolean;
400
- columns: string[];
401
- }
402
- interface ForeignKeyDiff {
403
- type: "added" | "removed";
404
- table: string;
405
- column: string;
406
- ref_table: string;
407
- ref_column: string;
408
- on_update: string;
409
- on_delete: string;
410
- }
411
- interface DiffResult {
412
- tables: TableDiff[];
413
- columns: ColumnDiff[];
414
- indexes: IndexDiff[];
415
- foreign_keys: ForeignKeyDiff[];
416
- has_changes: boolean;
417
- }
418
- declare const enum PlanStepType {
419
- DISABLE_FOREIGN_KEYS = "disable_foreign_keys",
420
- ENABLE_FOREIGN_KEYS = "enable_foreign_keys",
421
- BEGIN_TRANSACTION = "begin_transaction",
422
- COMMIT_TRANSACTION = "commit_transaction",
423
- CREATE_TABLE = "create_table",
424
- ADD_COLUMN = "add_column",
425
- DROP_COLUMN = "drop_column",
426
- ADD_INDEX = "add_index",
427
- DROP_INDEX = "drop_index",
428
- DROP_TABLE = "drop_table",
429
- RENAME_TABLE = "rename_table",
430
- COPY_DATA = "copy_data",
431
- CREATE_TRIGGER = "create_trigger"
432
- }
433
- interface PlanStep {
434
- sql: string;
435
- description?: string;
436
- type?: PlanStepType;
437
- }
438
- interface DataLossWarning {
439
- table: string;
440
- reason: string;
441
- }
442
- interface PlanResult {
443
- steps: PlanStep[];
444
- warnings?: DataLossWarning[];
445
- unsafe: boolean;
446
- }
447
- declare class DataLossError extends Error {
448
- warnings: DataLossWarning[];
449
- constructor(warnings: DataLossWarning[]);
450
- }
451
- declare class MigrationError extends Error {
452
- stepIndex: number;
453
- sql: string;
454
- cause: Error;
455
- constructor(stepIndex: number, sql: string, cause: Error);
456
- }
457
- interface SchemaDiffResult {
458
- current?: IntrospectResult;
459
- desired?: IntrospectResult;
460
- diff: DiffResult | string;
461
- plan: PlanResult;
462
- }
463
- interface ConnectionMigrator {
464
- diff(): Promise<SchemaDiffResult>;
465
- migrate(opts?: {
466
- force?: boolean;
467
- }): Promise<SchemaDiffResult>;
468
- migratePlan(planResult: PlanResult, opts?: {
469
- force?: boolean;
470
- }): Promise<void>;
471
- safeSortPlanSteps(steps: PlanStep[]): PlanStep[];
472
- }
473
-
474
- interface IConnectionConfig extends Partial<KyselyConfig> {
475
- url?: string;
476
- introspection?: IntrospectOptions;
477
- /**
478
- * Base schema of the connection that is always prepended to any schema operations.
479
- * E.g. when migrating to a desired schema, `baseSchema` is always prepended.
480
- * This is useful for when auth is enabled, and auth schema must be present.
481
- */
482
- baseSchema?: string;
483
- }
484
- type Dialect = "sqlite" | "postgres";
485
- type TransactionOptions = {
486
- intent?: "migration";
487
- };
488
- declare class RelationNotFoundError extends Error {
489
- readonly schema: string | undefined;
490
- readonly relation: string;
491
- constructor(schema: string | undefined, relation: string);
492
- }
493
- declare abstract class Connection<Driver = unknown, DB = any, Config extends IConnectionConfig = IConnectionConfig> {
494
- config: Config;
495
- kysely: Kysely<DB>;
496
- abstract driver: Driver;
497
- abstract dialect: Dialect;
498
- protected introspection: IntrospectResult | undefined;
499
- protected constructor(config: Config);
500
- /**
501
- * Connection-level DDL translation, mainly for SQLite connections to override.
502
- */
503
- translateDdl(ddl: string): Promise<unknown>;
504
- clearSchemaCache(): void;
505
- exec<T = {
506
- rows: unknown[];
507
- } | void>(query: string, ...parameters: readonly unknown[]): Promise<T>;
508
- ping(): Promise<boolean | void>;
509
- abstract introspect(options?: {
510
- useCache?: boolean;
511
- }): Promise<IntrospectResult>;
512
- transaction(_statements: string[], _opts?: TransactionOptions): Promise<void>;
513
- abstract close(): Promise<void>;
514
- createMigrator(_desiredSchema: string): ConnectionMigrator;
515
- onPostgrestAST(ast: AnyAST, _vars?: VarsContext): Promise<AnyAST>;
516
- /**
517
- * Normalize a database error into a PG-style error object.
518
- * Override in subclasses to map dialect-specific error codes.
519
- */
520
- normalizeDbError(e: unknown): unknown;
521
- /**
522
- * Wrap PostgREST query execution with connection-specific context.
523
- * For Postgres: wraps in a transaction with SET LOCAL role/claims.
524
- * Default: pass-through.
525
- */
526
- withContext<T>(_vars: VarsContext | undefined, fn: (db: Kysely<any>) => Promise<T>): Promise<T>;
527
- }
528
-
529
- export { type QueryParamsResult as $, type AnyAST as A, type BaseAST as B, Connection as C, DataLossError as D, type EmbedDef as E, type FiltersResult as F, type JoinMap as G, type HeadersResult as H, type IntrospectResult as I, type JoinDef as J, MigrationError as K, type PlanResult as L, type Meta as M, type PlanStep as N, type OrderEntry as O, Policy as P, PlanStepType as Q, type PreferToken as R, type PrimaryKeyInfo as S, type TransactionOptions as T, type Qb as U, type VarsContext as V, type QbDelete as W, type QbInsert as X, type QbSelect as Y, type QbUpdate as Z, type QueryAST as _, type IConnectionConfig as a, RelationNotFoundError as a0, type RouteResult as a1, type RpcAST as a2, type RpcResult as a3, type SchemaDiffResult as a4, type SelectEntry as a5, type SelectResult as a6, type TableDiff as a7, type TableInfo as a8, type TextSearchValue as a9, type TransformsResult as aa, type TranslatorConfig as ab, type TriggerInfo as ac, type UpdateAST as ad, type UpsertAST as ae, type UpsertResult as af, type ViewInfo as ag, type Where as ah, type WhereValue as ai, isRef as aj, type PolicyCommand as b, type PolicyRole as c, type AST as d, type ASTType as e, type AggregateFunction as f, type BodyResult as g, type CheckConstraintInfo as h, type ColumnDef as i, type ColumnDiff as j, type ColumnInfo as k, type ColumnRef as l, type ConnectionMigrator as m, type CustomTypesInfo as n, type DataLossWarning as o, type DeleteAST as p, type Dialect as q, type DiffResult as r, type EmbedTransform as s, type ExplainOptions as t, type ForeignKeyDiff as u, type ForeignKeyInfo as v, type IndexDiff as w, type IndexInfo as x, type InsertAST as y, type IntrospectOptions as z };