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