@supabase/lite 0.7.1-next.4 → 0.7.1-next.5
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/{Connection-DJbw6dM8.d.ts → Connection-Cm9fpZU3.d.ts} +10 -10
- package/dist/cli/index.js +104 -103
- package/dist/cli/lib.d.ts +3 -2
- package/dist/cli/lib.js +33 -33
- package/dist/db/fallback.d.ts +1 -1
- package/dist/db/workerd/index.js +1 -1
- package/dist/index.d.ts +190 -161
- package/dist/index.js +48 -48
- package/dist/vite/index.d.ts +23 -23
- package/package.json +1 -1
package/dist/db/fallback.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IConnectionConfig, C as Connection } from '../Connection-
|
|
1
|
+
import { I as IConnectionConfig, C as Connection } from '../Connection-Cm9fpZU3.js';
|
|
2
2
|
import 'kysely';
|
|
3
3
|
|
|
4
4
|
declare function createConnection<E extends IConnectionConfig = IConnectionConfig>(_config?: E): Promise<Connection>;
|
package/dist/db/workerd/index.js
CHANGED
|
@@ -8,4 +8,4 @@ import {Kysely}from'kysely';import {GenericSqliteDialect,buildQueryFn,parseBigIn
|
|
|
8
8
|
return emitWarning(warning, ...args);
|
|
9
9
|
};
|
|
10
10
|
} catch {}
|
|
11
|
-
var l=i=>Number.parseInt(i.toString(),10);function f(i,e){let t=(r,o)=>{let a=e(o);try{return i.prepare(r).bind(...a)}catch(u){throw console.error(u),new Error(`Failed to prepare statement: ${r}`)}},n=r=>{if(r.error)throw new Error(r.error);let o=r.meta.changes>0?l(r.meta.changes):void 0;return {insertId:r.meta.last_row_id?l(r.meta.last_row_id):void 0,numAffectedRows:o,rows:r.results}};return {db:i,query:buildQueryFn({all:async(r,o)=>{let a=t(r,o);return n(await a.all()).rows},run:async(r,o)=>{let a=t(r,o);return n(await a.run())}}),close:()=>{}}}var s=class extends SqliteConnection{kysely;driver;constructor(e){super({...e,introspection:{...e.introspection,version:"3.47.0",name:"d1_sqlite",exclude_tables:[...e.introspection?.exclude_tables??[],"_cf_%","d1_migrations"]}}),this.driver=e.binding;let t=new GenericSqliteDialect(()=>f(this.driver,n=>this.prepareBindParams(n)),n=>{this.driver.prepare("pragma foreign_keys = on").run();});this.kysely=new Kysely({dialect:t,plugins:this.withSqlitePlugins()});}normalizeBindParams(e){let t=super.normalizeBindParams(e);for(let n=0;n<t.length;n++)typeof t[n]=="bigint"&&(t[n]=Number(t[n]));return t}async exec(e,...t){let n=e.trimStart().toUpperCase(),r=this.prepareBindParams(t),o=this.driver.prepare(e).bind(...r);if(n.startsWith("SELECT")||n.startsWith("WITH"))return {rows:(await o.all()).results??[]};await o.run();}async transaction(e,t){t?.intent==="migration"&&await this.driver.prepare("PRAGMA foreign_keys=OFF;").run(),await this.driver.batch(e.map(n=>this.driver.prepare(n))),t?.intent==="migration"&&await this.driver.prepare("PRAGMA foreign_keys=ON;").run();}};function S(i){return new s(i)}function g(i){return new s(i)}var q=async(i,e,t)=>t.length>0?await i.sql.exec(e,...t):await i.sql.exec(e),h=(i,e)=>{let t=e.rowsWritten>0?parseBigInt(e.rowsWritten):void 0,n=void 0,r=e.toArray()||[];return {insertId:n,numAffectedRows:t,rows:r,meta:{rowsWritten:e.rowsWritten,rowsRead:e.rowsRead,databaseSize:i.sql.databaseSize}}};function x(i,e){return {db:i,query:async(t,n,r)=>{let o=e(r),a=await q(i,n,o);return h(i,await a)},close:()=>{}}}var c=class extends SqliteConnection{kysely;driver;constructor(e){super({...e,introspection:{...e.introspection,version:"3.47.0",name:"
|
|
11
|
+
var l=i=>Number.parseInt(i.toString(),10);function f(i,e){let t=(r,o)=>{let a=e(o);try{return i.prepare(r).bind(...a)}catch(u){throw console.error(u),new Error(`Failed to prepare statement: ${r}`)}},n=r=>{if(r.error)throw new Error(r.error);let o=r.meta.changes>0?l(r.meta.changes):void 0;return {insertId:r.meta.last_row_id?l(r.meta.last_row_id):void 0,numAffectedRows:o,rows:r.results}};return {db:i,query:buildQueryFn({all:async(r,o)=>{let a=t(r,o);return n(await a.all()).rows},run:async(r,o)=>{let a=t(r,o);return n(await a.run())}}),close:()=>{}}}var s=class extends SqliteConnection{kysely;driver;constructor(e){super({...e,introspection:{...e.introspection,version:"3.47.0",name:"d1_sqlite",exclude_tables:[...e.introspection?.exclude_tables??[],"_cf_%","d1_migrations"]}}),this.driver=e.binding;let t=new GenericSqliteDialect(()=>f(this.driver,n=>this.prepareBindParams(n)),n=>{this.driver.prepare("pragma foreign_keys = on").run();});this.kysely=new Kysely({dialect:t,plugins:this.withSqlitePlugins()});}normalizeBindParams(e){let t=super.normalizeBindParams(e);for(let n=0;n<t.length;n++)typeof t[n]=="bigint"&&(t[n]=Number(t[n]));return t}async exec(e,...t){let n=e.trimStart().toUpperCase(),r=this.prepareBindParams(t),o=this.driver.prepare(e).bind(...r);if(n.startsWith("SELECT")||n.startsWith("WITH"))return {rows:(await o.all()).results??[]};await o.run();}async transaction(e,t){t?.intent==="migration"&&await this.driver.prepare("PRAGMA foreign_keys=OFF;").run(),await this.driver.batch(e.map(n=>this.driver.prepare(n))),t?.intent==="migration"&&await this.driver.prepare("PRAGMA foreign_keys=ON;").run();}};function S(i){return new s(i)}function g(i){return new s(i)}var q=async(i,e,t)=>t.length>0?await i.sql.exec(e,...t):await i.sql.exec(e),h=(i,e)=>{let t=e.rowsWritten>0?parseBigInt(e.rowsWritten):void 0,n=void 0,r=e.toArray()||[];return {insertId:n,numAffectedRows:t,rows:r,meta:{rowsWritten:e.rowsWritten,rowsRead:e.rowsRead,databaseSize:i.sql.databaseSize}}};function x(i,e){return {db:i,query:async(t,n,r)=>{let o=e(r),a=await q(i,n,o);return h(i,await a)},close:()=>{}}}var c=class extends SqliteConnection{kysely;driver;constructor(e){super({...e,introspection:{...e.introspection,version:"3.47.0",name:"do_sqlite",exclude_tables:[...e.introspection?.exclude_tables??[],"_cf_%","__miniflare_%"]}}),this.driver=e.storage;let t=new GenericSqliteDialect(()=>x(this.driver,n=>this.prepareBindParams(n)),n=>{this.driver.sql.exec("pragma foreign_keys = on");});this.kysely=new Kysely({dialect:t,plugins:this.withSqlitePlugins()});}normalizeBindParams(e){let t=super.normalizeBindParams(e);for(let n=0;n<t.length;n++)typeof t[n]=="bigint"&&(t[n]=Number(t[n]));return t}async exec(e,...t){let n=e.trimStart().toUpperCase(),r=this.prepareBindParams(t),o=r.length>0?this.driver.sql.exec(e,...r):this.driver.sql.exec(e);if(n.startsWith("SELECT")||n.startsWith("WITH"))return {rows:o.toArray()};o.toArray();}async transaction(e,t){t?.intent==="migration"&&this.driver.sql.exec("PRAGMA foreign_keys=OFF;"),await this.driver.transaction(async n=>{try{for(let r of e)this.driver.sql.exec(r);}catch(r){throw n.rollback(),new Error(`Failed to execute transaction: ${r}`)}}),t?.intent==="migration"&&this.driver.sql.exec("PRAGMA foreign_keys=ON;");}};function v(i){return new c(i)}function I(i){return new c(i)}async function j(i){throw new Error("Not implemented")}export{s as D1SqliteConnection,c as DoSqliteConnection,j as createConnection,S as createD1SqliteConnection,v as createDoSqliteConnection,g as d1,I as doSqlite};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import { SupabaseClientOptions } from '@supabase/supabase-js';
|
|
|
3
3
|
import { D as DefaultSchema, S as Schema } from './index-xv_pDjEt.js';
|
|
4
4
|
import { Connection, ConnectionMigrator, MaybePromise as MaybePromise$1, SchemaDiffResult, PlanStep, PlanResult, IConnectionConfig, Dialect as Dialect$2, IntrospectResult as IntrospectResult$1, TransactionOptions } from '@supabase/lite';
|
|
5
5
|
import * as hono_hono_base from 'hono/hono-base';
|
|
6
|
-
import { W as Where, a as IntrospectResult, b as CacheDriver, c as CacheSetOptions, A as AnyAST, V as VarsContext, T as TransactionOptions$1 } from './Connection-DJbw6dM8.js';
|
|
7
|
-
export { d as AST, e as ASTType, f as AggregateFunction, B as BaseAST, g as BodyResult, h as CheckConstraintInfo, i as ColumnDef, j as ColumnDiff, k as ColumnInfo, l as ColumnRef, m as CommentInfo, C as Connection, n as ConnectionContextOptions, o as ConnectionMigrator, p as CustomTypesInfo, D as DataLossError, q as DataLossWarning, r as DeleteAST, s as Dialect, t as DiffResult, E as EmbedDef, u as EmbedTransform, v as ExplainOptions, F as FiltersResult, w as ForeignKeyDiff, x as ForeignKeyInfo, y as FunctionInfo, H as HeadersResult, I as IConnectionConfig, z as IndexDiff, G as IndexInfo, J as InsertAST, K as IntrospectOptions, L as JoinDef, M as JoinMap, N as Meta, O as MigrationError, P as OrderEntry, Q as PlanResult, R as PlanStep, S as PlanStepType, U as PreferToken, X as PrimaryKeyInfo, Y as Qb, Z as QbDelete, _ as QbInsert, $ as QbSelect, a0 as QbUpdate, a1 as QueryAST, a2 as QueryParamsResult, a3 as RelationNotFoundError, a4 as RouteResult, a5 as RpcAST, a6 as RpcResult, a7 as SchemaDiffResult, a8 as SelectEntry, a9 as SelectResult, aa as TableDiff, ab as TableInfo, ac as TextSearchValue, ad as TransformsResult, ae as TranslatorConfig, af as TriggerInfo, ag as UniqueConstraintInfo, ah as UpdateAST, ai as UpsertAST, aj as UpsertResult, ak as ViewInfo, al as ViewOptionsMetadata, am as WhereValue, an as isRef } from './Connection-DJbw6dM8.js';
|
|
8
6
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
9
7
|
import * as hono_utils_types from 'hono/utils/types';
|
|
10
8
|
import * as hono_types from 'hono/types';
|
|
@@ -12,166 +10,12 @@ import * as hono from 'hono';
|
|
|
12
10
|
import { MiddlewareHandler, Context } from 'hono';
|
|
13
11
|
import { Kysely, KyselyPlugin } from 'kysely';
|
|
14
12
|
import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
|
|
13
|
+
import { a as CacheDriver, b as CacheSetOptions, W as Where, c as IntrospectResult, A as AnyAST, V as VarsContext, T as TransactionOptions$1 } from './Connection-Cm9fpZU3.js';
|
|
14
|
+
export { d as AST, e as ASTType, f as AggregateFunction, B as BaseAST, g as BodyResult, h as CheckConstraintInfo, i as ColumnDef, j as ColumnDiff, k as ColumnInfo, l as ColumnRef, m as CommentInfo, C as Connection, n as ConnectionContextOptions, o as ConnectionMigrator, p as CustomTypesInfo, D as DataLossError, q as DataLossWarning, r as DeleteAST, s as Dialect, t as DiffResult, E as EmbedDef, u as EmbedTransform, v as ExplainOptions, F as FiltersResult, w as ForeignKeyDiff, x as ForeignKeyInfo, y as FunctionInfo, H as HeadersResult, I as IConnectionConfig, z as IndexDiff, G as IndexInfo, J as InsertAST, K as IntrospectOptions, L as JoinDef, M as JoinMap, N as Meta, O as MigrationError, P as OrderEntry, Q as PlanResult, R as PlanStep, S as PlanStepType, U as PreferToken, X as PrimaryKeyInfo, Y as Qb, Z as QbDelete, _ as QbInsert, $ as QbSelect, a0 as QbUpdate, a1 as QueryAST, a2 as QueryParamsResult, a3 as RelationNotFoundError, a4 as RouteResult, a5 as RpcAST, a6 as RpcResult, a7 as SchemaDiffResult, a8 as SelectEntry, a9 as SelectResult, aa as TableDiff, ab as TableInfo, ac as TextSearchValue, ad as TransformsResult, ae as TranslatorConfig, af as TriggerInfo, ag as UniqueConstraintInfo, ah as UpdateAST, ai as UpsertAST, aj as UpsertResult, ak as ViewInfo, al as ViewOptionsMetadata, am as WhereValue, an as isRef } from './Connection-Cm9fpZU3.js';
|
|
15
15
|
import { ParseResult } from 'libpg-query';
|
|
16
16
|
import { DeparserOptions } from 'pgsql-deparser';
|
|
17
17
|
import 'jsonv-ts';
|
|
18
18
|
|
|
19
|
-
type TUnwrappedConst = string | number | boolean | null | undefined;
|
|
20
|
-
|
|
21
|
-
type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
|
|
22
|
-
type PolicyRole = "anon" | "authenticated" | string;
|
|
23
|
-
interface PolicyData {
|
|
24
|
-
name: string;
|
|
25
|
-
table: string;
|
|
26
|
-
schema?: string;
|
|
27
|
-
command: PolicyCommand;
|
|
28
|
-
permissive: boolean;
|
|
29
|
-
roles: PolicyRole[];
|
|
30
|
-
using?: Where;
|
|
31
|
-
withCheck?: Where;
|
|
32
|
-
}
|
|
33
|
-
declare class Policy {
|
|
34
|
-
readonly data: PolicyData;
|
|
35
|
-
constructor(data: PolicyData);
|
|
36
|
-
appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
|
|
37
|
-
appliesToRole(role: string): boolean;
|
|
38
|
-
toJSON(): PolicyData;
|
|
39
|
-
static fromJSON(data: PolicyData): Policy;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare class CheckConstraintError extends Error {
|
|
43
|
-
readonly table: string;
|
|
44
|
-
readonly column: string;
|
|
45
|
-
readonly constraint: string;
|
|
46
|
-
readonly value: unknown;
|
|
47
|
-
constructor(table: string, column: string, constraint: string, value: unknown);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type SqliteType = "INTEGER" | "REAL" | "TEXT" | "BLOB" | "ANY";
|
|
51
|
-
type DefaultFn = () => unknown;
|
|
52
|
-
interface ValidationResult {
|
|
53
|
-
status: "pass" | "warn" | "fail";
|
|
54
|
-
message: string | null;
|
|
55
|
-
action?: string;
|
|
56
|
-
}
|
|
57
|
-
interface FieldContext {
|
|
58
|
-
schema: string;
|
|
59
|
-
table: string;
|
|
60
|
-
column: string;
|
|
61
|
-
pgTypeName: string;
|
|
62
|
-
nullable: boolean;
|
|
63
|
-
defaultValue: string | null;
|
|
64
|
-
defaultFn?: DefaultFn | null;
|
|
65
|
-
isPrimaryKey: boolean;
|
|
66
|
-
isUnique: boolean;
|
|
67
|
-
isSerial: boolean;
|
|
68
|
-
isGenerated?: boolean;
|
|
69
|
-
fkRef?: {
|
|
70
|
-
refSchema?: string;
|
|
71
|
-
refTable: string;
|
|
72
|
-
refColumn: string;
|
|
73
|
-
constraintName?: string;
|
|
74
|
-
};
|
|
75
|
-
hasCheck?: boolean;
|
|
76
|
-
checkConstraintName?: string;
|
|
77
|
-
uniqueConstraintName?: string;
|
|
78
|
-
}
|
|
79
|
-
interface ColumnDDLOptions {
|
|
80
|
-
includeNullable?: boolean;
|
|
81
|
-
}
|
|
82
|
-
declare abstract class Field {
|
|
83
|
-
readonly context: FieldContext;
|
|
84
|
-
constructor(context: FieldContext);
|
|
85
|
-
abstract get sqliteType(): SqliteType;
|
|
86
|
-
get isShimBacked(): boolean;
|
|
87
|
-
checkConstraint(): string | null;
|
|
88
|
-
serialize(value: unknown): unknown;
|
|
89
|
-
deserialize(value: unknown): unknown;
|
|
90
|
-
validateStorage(_rawSqliteValue: unknown): ValidationResult;
|
|
91
|
-
protected validationFail(message: string, action?: string): ValidationResult;
|
|
92
|
-
protected validationPass(): ValidationResult;
|
|
93
|
-
protected isNullish(value: unknown): value is null | undefined;
|
|
94
|
-
toColumnDDL(options?: ColumnDDLOptions): string;
|
|
95
|
-
protected checkError(constraint: string, value: unknown): CheckConstraintError;
|
|
96
|
-
protected quoteIfNeeded(name: string): string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
type FunctionResolutionMode = "synthetic" | "translate" | "auto";
|
|
100
|
-
|
|
101
|
-
declare class TableSchema {
|
|
102
|
-
readonly table: string;
|
|
103
|
-
readonly schema: string;
|
|
104
|
-
private fields;
|
|
105
|
-
constructor(table: string, schema?: string, fields?: Map<string, Field>);
|
|
106
|
-
get(col: string): Field | undefined;
|
|
107
|
-
has(col: string): boolean;
|
|
108
|
-
set(col: string, field: Field): void;
|
|
109
|
-
columns(): string[];
|
|
110
|
-
all(): Field[];
|
|
111
|
-
serializeRow(row: Record<string, unknown>): Record<string, unknown>;
|
|
112
|
-
deserializeRow(row: Record<string, unknown>): Record<string, unknown>;
|
|
113
|
-
applyDefaults(row: Record<string, unknown>): Record<string, unknown>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
type CollectedEnums = Map<string, string[]>;
|
|
117
|
-
type CollectedVariable = {
|
|
118
|
-
local?: boolean;
|
|
119
|
-
value: TUnwrappedConst;
|
|
120
|
-
};
|
|
121
|
-
type CollectedVariables = Map<string, CollectedVariable>;
|
|
122
|
-
type CollectedRlsTables = Set<string>;
|
|
123
|
-
type CollectedSchema = Map<string, TableSchema>;
|
|
124
|
-
type CollectedTableConstraint = {
|
|
125
|
-
schema: string;
|
|
126
|
-
table: string;
|
|
127
|
-
kind: "unique" | "check" | "foreign_key";
|
|
128
|
-
name?: string;
|
|
129
|
-
columns: string[];
|
|
130
|
-
refSchema?: string;
|
|
131
|
-
refTable?: string;
|
|
132
|
-
refColumns?: string[];
|
|
133
|
-
};
|
|
134
|
-
type CollectedComment = {
|
|
135
|
-
schema: string;
|
|
136
|
-
table: string;
|
|
137
|
-
column?: string;
|
|
138
|
-
text: string;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
type SchemaHandling = "default" | "prefix";
|
|
142
|
-
interface DeparseOptions extends DeparserOptions {
|
|
143
|
-
schemaHandling?: SchemaHandling;
|
|
144
|
-
forceDefaultSchema?: string | false;
|
|
145
|
-
enums?: CollectedEnums;
|
|
146
|
-
/** Current DB introspection. Required for ALTER TABLE ops that need 12-step rebuild. */
|
|
147
|
-
introspection?: IntrospectResult;
|
|
148
|
-
functionResolution?: FunctionResolutionMode;
|
|
149
|
-
/**
|
|
150
|
-
* ColumnDef nodes whose `nextval(...)` default was stripped by `normalize.ts`
|
|
151
|
-
* (pg-delta serial/identity columns). Flagged here because the underlying
|
|
152
|
-
* type is plain `integer`/`bigint` — nothing else marks them serial.
|
|
153
|
-
*/
|
|
154
|
-
serialColumns?: WeakSet<object>;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
declare function translatePostgresDdl(pgSql: string, options?: DeparseOptions): Promise<string>;
|
|
158
|
-
declare function deparsePostgresDdl(pgSql: string, options?: DeparseOptions & {
|
|
159
|
-
strict?: boolean;
|
|
160
|
-
defaultSchema?: string;
|
|
161
|
-
}): Promise<{
|
|
162
|
-
ddl: string;
|
|
163
|
-
enums: CollectedEnums;
|
|
164
|
-
rls: {
|
|
165
|
-
tables: CollectedRlsTables;
|
|
166
|
-
policies: Policy[];
|
|
167
|
-
};
|
|
168
|
-
schema: CollectedSchema;
|
|
169
|
-
vars: CollectedVariables;
|
|
170
|
-
tableConstraints: CollectedTableConstraint[];
|
|
171
|
-
comments: CollectedComment[];
|
|
172
|
-
ast: ParseResult;
|
|
173
|
-
}>;
|
|
174
|
-
|
|
175
19
|
interface UsersTable {
|
|
176
20
|
id: string;
|
|
177
21
|
aud: string;
|
|
@@ -2483,6 +2327,27 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
|
|
|
2483
2327
|
};
|
|
2484
2328
|
}, "/_system">, "/", "*">;
|
|
2485
2329
|
|
|
2330
|
+
type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
|
|
2331
|
+
type PolicyRole = "anon" | "authenticated" | string;
|
|
2332
|
+
interface PolicyData {
|
|
2333
|
+
name: string;
|
|
2334
|
+
table: string;
|
|
2335
|
+
schema?: string;
|
|
2336
|
+
command: PolicyCommand;
|
|
2337
|
+
permissive: boolean;
|
|
2338
|
+
roles: PolicyRole[];
|
|
2339
|
+
using?: Where;
|
|
2340
|
+
withCheck?: Where;
|
|
2341
|
+
}
|
|
2342
|
+
declare class Policy {
|
|
2343
|
+
readonly data: PolicyData;
|
|
2344
|
+
constructor(data: PolicyData);
|
|
2345
|
+
appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
|
|
2346
|
+
appliesToRole(role: string): boolean;
|
|
2347
|
+
toJSON(): PolicyData;
|
|
2348
|
+
static fromJSON(data: PolicyData): Policy;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2486
2351
|
interface IAppConfig extends DefaultSchema {
|
|
2487
2352
|
connection: Connection | Promise<Connection>;
|
|
2488
2353
|
rls?: {
|
|
@@ -2589,6 +2454,141 @@ declare class InvalidPostgresToSQLiteTranslation extends Error {
|
|
|
2589
2454
|
constructor(pgSql: string, sqliteDdl: string, cause: Error | unknown);
|
|
2590
2455
|
}
|
|
2591
2456
|
|
|
2457
|
+
type TUnwrappedConst = string | number | boolean | null | undefined;
|
|
2458
|
+
|
|
2459
|
+
declare class CheckConstraintError extends Error {
|
|
2460
|
+
readonly table: string;
|
|
2461
|
+
readonly column: string;
|
|
2462
|
+
readonly constraint: string;
|
|
2463
|
+
readonly value: unknown;
|
|
2464
|
+
constructor(table: string, column: string, constraint: string, value: unknown);
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
type SqliteType = "INTEGER" | "REAL" | "TEXT" | "BLOB" | "ANY";
|
|
2468
|
+
type DefaultFn = () => unknown;
|
|
2469
|
+
interface ValidationResult {
|
|
2470
|
+
status: "pass" | "warn" | "fail";
|
|
2471
|
+
message: string | null;
|
|
2472
|
+
action?: string;
|
|
2473
|
+
}
|
|
2474
|
+
interface FieldContext {
|
|
2475
|
+
schema: string;
|
|
2476
|
+
table: string;
|
|
2477
|
+
column: string;
|
|
2478
|
+
pgTypeName: string;
|
|
2479
|
+
nullable: boolean;
|
|
2480
|
+
defaultValue: string | null;
|
|
2481
|
+
defaultFn?: DefaultFn | null;
|
|
2482
|
+
isPrimaryKey: boolean;
|
|
2483
|
+
isUnique: boolean;
|
|
2484
|
+
isSerial: boolean;
|
|
2485
|
+
isGenerated?: boolean;
|
|
2486
|
+
fkRef?: {
|
|
2487
|
+
refSchema?: string;
|
|
2488
|
+
refTable: string;
|
|
2489
|
+
refColumn: string;
|
|
2490
|
+
constraintName?: string;
|
|
2491
|
+
};
|
|
2492
|
+
hasCheck?: boolean;
|
|
2493
|
+
checkConstraintName?: string;
|
|
2494
|
+
uniqueConstraintName?: string;
|
|
2495
|
+
}
|
|
2496
|
+
interface ColumnDDLOptions {
|
|
2497
|
+
includeNullable?: boolean;
|
|
2498
|
+
}
|
|
2499
|
+
declare abstract class Field {
|
|
2500
|
+
readonly context: FieldContext;
|
|
2501
|
+
constructor(context: FieldContext);
|
|
2502
|
+
abstract get sqliteType(): SqliteType;
|
|
2503
|
+
get isShimBacked(): boolean;
|
|
2504
|
+
checkConstraint(): string | null;
|
|
2505
|
+
serialize(value: unknown): unknown;
|
|
2506
|
+
deserialize(value: unknown): unknown;
|
|
2507
|
+
validateStorage(_rawSqliteValue: unknown): ValidationResult;
|
|
2508
|
+
protected validationFail(message: string, action?: string): ValidationResult;
|
|
2509
|
+
protected validationPass(): ValidationResult;
|
|
2510
|
+
protected isNullish(value: unknown): value is null | undefined;
|
|
2511
|
+
toColumnDDL(options?: ColumnDDLOptions): string;
|
|
2512
|
+
protected checkError(constraint: string, value: unknown): CheckConstraintError;
|
|
2513
|
+
protected quoteIfNeeded(name: string): string;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
type FunctionResolutionMode = "synthetic" | "translate" | "auto";
|
|
2517
|
+
|
|
2518
|
+
declare class TableSchema {
|
|
2519
|
+
readonly table: string;
|
|
2520
|
+
readonly schema: string;
|
|
2521
|
+
private fields;
|
|
2522
|
+
constructor(table: string, schema?: string, fields?: Map<string, Field>);
|
|
2523
|
+
get(col: string): Field | undefined;
|
|
2524
|
+
has(col: string): boolean;
|
|
2525
|
+
set(col: string, field: Field): void;
|
|
2526
|
+
columns(): string[];
|
|
2527
|
+
all(): Field[];
|
|
2528
|
+
serializeRow(row: Record<string, unknown>): Record<string, unknown>;
|
|
2529
|
+
deserializeRow(row: Record<string, unknown>): Record<string, unknown>;
|
|
2530
|
+
applyDefaults(row: Record<string, unknown>): Record<string, unknown>;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
type CollectedEnums = Map<string, string[]>;
|
|
2534
|
+
type CollectedVariable = {
|
|
2535
|
+
local?: boolean;
|
|
2536
|
+
value: TUnwrappedConst;
|
|
2537
|
+
};
|
|
2538
|
+
type CollectedVariables = Map<string, CollectedVariable>;
|
|
2539
|
+
type CollectedRlsTables = Set<string>;
|
|
2540
|
+
type CollectedSchema = Map<string, TableSchema>;
|
|
2541
|
+
type CollectedTableConstraint = {
|
|
2542
|
+
schema: string;
|
|
2543
|
+
table: string;
|
|
2544
|
+
kind: "unique" | "check" | "foreign_key";
|
|
2545
|
+
name?: string;
|
|
2546
|
+
columns: string[];
|
|
2547
|
+
refSchema?: string;
|
|
2548
|
+
refTable?: string;
|
|
2549
|
+
refColumns?: string[];
|
|
2550
|
+
};
|
|
2551
|
+
type CollectedComment = {
|
|
2552
|
+
schema: string;
|
|
2553
|
+
table: string;
|
|
2554
|
+
column?: string;
|
|
2555
|
+
text: string;
|
|
2556
|
+
};
|
|
2557
|
+
|
|
2558
|
+
type SchemaHandling = "default" | "prefix";
|
|
2559
|
+
interface DeparseOptions extends DeparserOptions {
|
|
2560
|
+
schemaHandling?: SchemaHandling;
|
|
2561
|
+
forceDefaultSchema?: string | false;
|
|
2562
|
+
enums?: CollectedEnums;
|
|
2563
|
+
/** Current DB introspection. Required for ALTER TABLE ops that need 12-step rebuild. */
|
|
2564
|
+
introspection?: IntrospectResult;
|
|
2565
|
+
functionResolution?: FunctionResolutionMode;
|
|
2566
|
+
/**
|
|
2567
|
+
* ColumnDef nodes whose `nextval(...)` default was stripped by `normalize.ts`
|
|
2568
|
+
* (pg-delta serial/identity columns). Flagged here because the underlying
|
|
2569
|
+
* type is plain `integer`/`bigint` — nothing else marks them serial.
|
|
2570
|
+
*/
|
|
2571
|
+
serialColumns?: WeakSet<object>;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
declare function translatePostgresDdl(pgSql: string, options?: DeparseOptions): Promise<string>;
|
|
2575
|
+
declare function deparsePostgresDdl(pgSql: string, options?: DeparseOptions & {
|
|
2576
|
+
strict?: boolean;
|
|
2577
|
+
defaultSchema?: string;
|
|
2578
|
+
}): Promise<{
|
|
2579
|
+
ddl: string;
|
|
2580
|
+
enums: CollectedEnums;
|
|
2581
|
+
rls: {
|
|
2582
|
+
tables: CollectedRlsTables;
|
|
2583
|
+
policies: Policy[];
|
|
2584
|
+
};
|
|
2585
|
+
schema: CollectedSchema;
|
|
2586
|
+
vars: CollectedVariables;
|
|
2587
|
+
tableConstraints: CollectedTableConstraint[];
|
|
2588
|
+
comments: CollectedComment[];
|
|
2589
|
+
ast: ParseResult;
|
|
2590
|
+
}>;
|
|
2591
|
+
|
|
2592
2592
|
type SqliteMigratorOptions = {
|
|
2593
2593
|
onTranslation?: (result: SqlitePostgresTranslationResult) => MaybePromise$1<void>;
|
|
2594
2594
|
};
|
|
@@ -2661,13 +2661,32 @@ interface ISqliteConnectionConfig extends IConnectionConfig {
|
|
|
2661
2661
|
defaultSchema?: string | false;
|
|
2662
2662
|
};
|
|
2663
2663
|
/**
|
|
2664
|
-
* Deparse details the connection must be aware of
|
|
2664
|
+
* Deparse details the connection must be aware of. Accepts either the
|
|
2665
|
+
* live in-memory shape (`SqlitePostgresDeparseInfo`, with `Set`/`Map`/
|
|
2666
|
+
* `Policy` instances) or its JSON-serialized form (`PersistedDeparseInfo`,
|
|
2667
|
+
* e.g. a `deparse.json` produced by `lite db translate --deparse`). The
|
|
2668
|
+
* constructor normalizes both via `parseDeparseInfo`.
|
|
2665
2669
|
*/
|
|
2666
|
-
deparse?: SqlitePostgresDeparseInfo;
|
|
2670
|
+
deparse?: SqlitePostgresDeparseInfo | PersistedDeparseInfo;
|
|
2667
2671
|
};
|
|
2668
2672
|
}
|
|
2669
2673
|
type DeparsePostgresDdlResult = Awaited<ReturnType<typeof deparsePostgresDdl>>;
|
|
2670
2674
|
type SqlitePostgresDeparseInfo = Pick<DeparsePostgresDdlResult, "enums" | "rls" | "schema" | "vars"> & Partial<Pick<DeparsePostgresDdlResult, "tableConstraints" | "comments">>;
|
|
2675
|
+
/**
|
|
2676
|
+
* The JSON-serializable form of the deparse info — the load-bearing runtime
|
|
2677
|
+
* subset (`rls` + `vars`) that survives a `JSON.stringify` round-trip and is
|
|
2678
|
+
* rehydrated by {@link SqliteConnection.parseDeparseInfo}. `ast`/`ddl` and the
|
|
2679
|
+
* class-instance metadata (`schema`/`enums`/`tableConstraints`/`comments`) are
|
|
2680
|
+
* intentionally omitted — they are build-time artifacts that cannot round-trip.
|
|
2681
|
+
* Produced by {@link SqliteConnection.serializeDeparseInfo}.
|
|
2682
|
+
*/
|
|
2683
|
+
interface PersistedDeparseInfo {
|
|
2684
|
+
rls: {
|
|
2685
|
+
tables: string[];
|
|
2686
|
+
policies: PolicyData[];
|
|
2687
|
+
};
|
|
2688
|
+
vars?: Record<string, CollectedVariable>;
|
|
2689
|
+
}
|
|
2671
2690
|
type SqlitePostgresTranslationResult = Pick<DeparsePostgresDdlResult, "ddl"> & Partial<DeparsePostgresDdlResult>;
|
|
2672
2691
|
declare abstract class SqliteConnection<Driver = unknown, DB = any, Config extends ISqliteConnectionConfig = ISqliteConnectionConfig> extends Connection<Driver, DB, Config> {
|
|
2673
2692
|
dialect: Dialect$2;
|
|
@@ -2683,6 +2702,16 @@ declare abstract class SqliteConnection<Driver = unknown, DB = any, Config exten
|
|
|
2683
2702
|
};
|
|
2684
2703
|
vars: any;
|
|
2685
2704
|
};
|
|
2705
|
+
/**
|
|
2706
|
+
* Serialize deparse info to its JSON form — the inverse of
|
|
2707
|
+
* {@link SqliteConnection.parseDeparseInfo}. Coerces `Set` → array, `Map` →
|
|
2708
|
+
* object, and `Policy` → `PolicyData` (via `Policy.toJSON`), keeping only the
|
|
2709
|
+
* `rls` + `vars` subset the runtime reconstructs. Feed the result to
|
|
2710
|
+
* `JSON.stringify` for a `deparse.json` you can re-import into
|
|
2711
|
+
* `translation.deparse`. Accepts a `translateDdl` result or a stored
|
|
2712
|
+
* `SqlitePostgresDeparseInfo`.
|
|
2713
|
+
*/
|
|
2714
|
+
static serializeDeparseInfo(info: Partial<Pick<SqlitePostgresDeparseInfo, "rls" | "vars">> | undefined | null): PersistedDeparseInfo;
|
|
2686
2715
|
updateDeparseInfo(details: NonNullable<ISqliteConnectionConfig["translation"]>["deparse"]): void;
|
|
2687
2716
|
protected withSqlitePlugins(add_plugins?: KyselyPlugin[]): KyselyPlugin[];
|
|
2688
2717
|
translateDdl(ddl: string): Promise<SqlitePostgresTranslationResult>;
|
|
@@ -2904,4 +2933,4 @@ declare function isExperimentalEnabled(name: ExperimentalFeature): boolean;
|
|
|
2904
2933
|
declare function setExperimental(name: ExperimentalFeature, enabled: boolean): void;
|
|
2905
2934
|
declare function listEnabledExperimentals(): ExperimentalFeature[];
|
|
2906
2935
|
|
|
2907
|
-
export { AnyAST, App, type AppDrivers, AwsSesEmailDriver, type AwsSesEmailDriverOptions, type BooleanLike, CacheDriver, CacheSetOptions, CloudConnection, CloudflareKvCacheDriver, type CloudflareKvCacheDriverOptions, type DefaultAppConfig, type EmailDriver, type EmailMessage, type ExperimentalFeature, type HonoContext, type IAppConfig, type ICloudConnectionConfig, type ISqliteConnectionConfig, InMemoryEmailDriver, type InMemoryEmailDriverOptions, InMemoryLruCacheDriver, type InMemoryLruCacheDriverOptions, IntrospectResult, InvalidPostgresToSQLiteTranslation, type MatchPattern, type MaybePromise, NoopEmailDriver, type NoopEmailDriverOptions, NoopSmsDriver, type NoopSmsDriverOptions, type PartialAppDrivers, type Primitive, type RedisCacheClient, RedisCacheDriver, type RedisCacheDriverOptions, ResendEmailDriver, type ResendEmailDriverOptions, SUPABASE_AUTH_HELPERS_SQL, Schema, SendmailEmailDriver, type SendmailEmailDriverOptions, type ServerOptions, type SmsDriver, type SmsMessage, SqliteConnection, type SqlitePostgresTranslationResult, type StoredEmailMessage, TransactionOptions$1 as TransactionOptions, UnableToCreateRuntimeConnection, VarsContext, Where, checkPasswordStrength, cleanSql, cloud, createAppDrivers, ensureVar, filterSearchParams, formatSendmailMessage, fuzzyMatch, getAuthSchemaSql, getPath, getStatementsArray, getStorageSchemaSql, invariant, isBooleanLike, isBun, isEmail, isEqual, isExperimentalEnabled, isNode, isObject, isPlainObject, isPrimitive, isString, jsonStringify, listEnabledExperimentals, measureTime, mergeObject, mergeObjectWith, normalizeDefault, normalizeSql, normalizeString, normalizeType, objectDiff, omit, params, parseBigInt, patternMatch, pick, pipe, pipeEach, quote, randomString, replacePlaceholders, requireAuth, resolveAuth, setExperimental, setPath, slugify, snakeToPascalWithSpaces, splitSqlStatements, studioRouteHandler, threw, threwAsync, translatePostgresDdl, truncate, trySync, ucFirst, ucFirstAll, uuid };
|
|
2936
|
+
export { AnyAST, App, type AppDrivers, AwsSesEmailDriver, type AwsSesEmailDriverOptions, type BooleanLike, CacheDriver, CacheSetOptions, CloudConnection, CloudflareKvCacheDriver, type CloudflareKvCacheDriverOptions, type DefaultAppConfig, type EmailDriver, type EmailMessage, type ExperimentalFeature, type HonoContext, type IAppConfig, type ICloudConnectionConfig, type ISqliteConnectionConfig, InMemoryEmailDriver, type InMemoryEmailDriverOptions, InMemoryLruCacheDriver, type InMemoryLruCacheDriverOptions, IntrospectResult, InvalidPostgresToSQLiteTranslation, type MatchPattern, type MaybePromise, NoopEmailDriver, type NoopEmailDriverOptions, NoopSmsDriver, type NoopSmsDriverOptions, type PartialAppDrivers, type PersistedDeparseInfo, Policy, type PolicyCommand, type PolicyData, type PolicyRole, type Primitive, type RedisCacheClient, RedisCacheDriver, type RedisCacheDriverOptions, ResendEmailDriver, type ResendEmailDriverOptions, SUPABASE_AUTH_HELPERS_SQL, Schema, SendmailEmailDriver, type SendmailEmailDriverOptions, type ServerOptions, type SmsDriver, type SmsMessage, SqliteConnection, type SqlitePostgresDeparseInfo, type SqlitePostgresTranslationResult, type StoredEmailMessage, TransactionOptions$1 as TransactionOptions, UnableToCreateRuntimeConnection, VarsContext, Where, checkPasswordStrength, cleanSql, cloud, createAppDrivers, ensureVar, filterSearchParams, formatSendmailMessage, fuzzyMatch, getAuthSchemaSql, getPath, getStatementsArray, getStorageSchemaSql, invariant, isBooleanLike, isBun, isEmail, isEqual, isExperimentalEnabled, isNode, isObject, isPlainObject, isPrimitive, isString, jsonStringify, listEnabledExperimentals, measureTime, mergeObject, mergeObjectWith, normalizeDefault, normalizeSql, normalizeString, normalizeType, objectDiff, omit, params, parseBigInt, patternMatch, pick, pipe, pipeEach, quote, randomString, replacePlaceholders, requireAuth, resolveAuth, setExperimental, setPath, slugify, snakeToPascalWithSpaces, splitSqlStatements, studioRouteHandler, threw, threwAsync, translatePostgresDdl, truncate, trySync, ucFirst, ucFirstAll, uuid };
|