driftsql 1.0.16 → 1.0.17
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/.prettierrc +5 -0
- package/package.json +17 -29
- package/src/drivers/libsql.ts +70 -0
- package/src/drivers/mysql.ts +70 -0
- package/src/drivers/postgres.ts +112 -0
- package/src/drivers/sqlite.ts +122 -0
- package/src/index.ts +225 -0
- package/src/pull.ts +318 -0
- package/src/types.ts +78 -0
- package/tsconfig.json +20 -0
- package/dist/index.d.mts +0 -171
- package/dist/index.d.ts +0 -171
- package/dist/index.mjs +0 -731
package/dist/index.d.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
interface QueryResult<T = any> {
|
|
2
|
-
rows: T[];
|
|
3
|
-
rowCount: number;
|
|
4
|
-
command?: string;
|
|
5
|
-
fields?: QueryField[];
|
|
6
|
-
}
|
|
7
|
-
interface QueryField {
|
|
8
|
-
name: string;
|
|
9
|
-
dataTypeID: number;
|
|
10
|
-
}
|
|
11
|
-
interface DatabaseDriver {
|
|
12
|
-
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
interface TransactionCapable {
|
|
16
|
-
transaction<T>(callback: (driver: DatabaseDriver) => Promise<T>): Promise<T>;
|
|
17
|
-
}
|
|
18
|
-
interface PreparedStatementCapable {
|
|
19
|
-
prepare(sql: string): Promise<PreparedStatement>;
|
|
20
|
-
}
|
|
21
|
-
interface PreparedStatement {
|
|
22
|
-
execute<T = any>(params?: any[]): Promise<QueryResult<T>>;
|
|
23
|
-
finalize(): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
declare class DatabaseError extends Error {
|
|
26
|
-
readonly driverType: string;
|
|
27
|
-
readonly originalError?: Error | undefined;
|
|
28
|
-
constructor(message: string, driverType: string, originalError?: Error | undefined);
|
|
29
|
-
}
|
|
30
|
-
declare class QueryError extends DatabaseError {
|
|
31
|
-
constructor(driverType: string, sql: string, originalError?: Error);
|
|
32
|
-
}
|
|
33
|
-
declare class ConnectionError extends DatabaseError {
|
|
34
|
-
constructor(driverType: string, originalError?: Error);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface PostgresConfig {
|
|
38
|
-
connectionString?: string;
|
|
39
|
-
experimental?: {
|
|
40
|
-
http?: {
|
|
41
|
-
url: string;
|
|
42
|
-
apiKey?: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
declare class PostgresDriver implements DatabaseDriver, TransactionCapable {
|
|
47
|
-
private client;
|
|
48
|
-
constructor(config: PostgresConfig);
|
|
49
|
-
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
50
|
-
transaction<T>(callback: (driver: DatabaseDriver) => Promise<T>): Promise<T>;
|
|
51
|
-
close(): Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface LibSQLConfig {
|
|
55
|
-
url: string;
|
|
56
|
-
authToken?: string;
|
|
57
|
-
useTursoServerlessDriver?: boolean;
|
|
58
|
-
}
|
|
59
|
-
declare class LibSQLDriver implements DatabaseDriver, TransactionCapable {
|
|
60
|
-
private client;
|
|
61
|
-
constructor(config: LibSQLConfig);
|
|
62
|
-
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
63
|
-
transaction<T>(callback: (driver: DatabaseDriver) => Promise<T>): Promise<T>;
|
|
64
|
-
close(): Promise<void>;
|
|
65
|
-
private convertLibsqlResult;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface MySQLConfig {
|
|
69
|
-
connectionString: string;
|
|
70
|
-
}
|
|
71
|
-
declare class MySQLDriver implements DatabaseDriver, TransactionCapable {
|
|
72
|
-
private client;
|
|
73
|
-
constructor(config: MySQLConfig);
|
|
74
|
-
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
75
|
-
transaction<T>(callback: (driver: DatabaseDriver) => Promise<T>): Promise<T>;
|
|
76
|
-
close(): Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
interface SqliteConfig {
|
|
80
|
-
filename: string;
|
|
81
|
-
readonly?: boolean;
|
|
82
|
-
}
|
|
83
|
-
declare class SqliteDriver implements DatabaseDriver, TransactionCapable, PreparedStatementCapable {
|
|
84
|
-
private client;
|
|
85
|
-
constructor(config: SqliteConfig);
|
|
86
|
-
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
87
|
-
transaction<T>(callback: (driver: DatabaseDriver) => Promise<T>): Promise<T>;
|
|
88
|
-
prepare(sql: string): Promise<PreparedStatement>;
|
|
89
|
-
close(): Promise<void>;
|
|
90
|
-
exec(sql: string): void;
|
|
91
|
-
backup(filename: string): Promise<void>;
|
|
92
|
-
pragma(pragma: string): any;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface InspectOptions {
|
|
96
|
-
driver: DatabaseDriver;
|
|
97
|
-
outputFile?: string;
|
|
98
|
-
}
|
|
99
|
-
declare const inspectDB: (options: InspectOptions) => Promise<void>;
|
|
100
|
-
declare const inspectPostgres: (config: {
|
|
101
|
-
connectionString?: string;
|
|
102
|
-
experimental?: {
|
|
103
|
-
http?: {
|
|
104
|
-
url: string;
|
|
105
|
-
apiKey?: string;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
}, outputFile?: string) => Promise<void>;
|
|
109
|
-
declare const inspectLibSQL: (config: {
|
|
110
|
-
url: string;
|
|
111
|
-
authToken?: string;
|
|
112
|
-
useTursoServerlessDriver?: boolean;
|
|
113
|
-
}, outputFile?: string) => Promise<void>;
|
|
114
|
-
declare const inspectMySQL: (config: {
|
|
115
|
-
connectionString: string;
|
|
116
|
-
}, outputFile?: string) => Promise<void>;
|
|
117
|
-
declare const inspectSQLite: (config: {
|
|
118
|
-
filename: string;
|
|
119
|
-
readonly?: boolean;
|
|
120
|
-
}, outputFile?: string) => Promise<void>;
|
|
121
|
-
|
|
122
|
-
interface ClientOptions<T extends DatabaseDriver = DatabaseDriver> {
|
|
123
|
-
driver: T;
|
|
124
|
-
fallbackDrivers?: DatabaseDriver[];
|
|
125
|
-
}
|
|
126
|
-
declare class SQLClient<DT = any> {
|
|
127
|
-
private primaryDriver;
|
|
128
|
-
private fallbackDrivers;
|
|
129
|
-
constructor(options: ClientOptions);
|
|
130
|
-
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
131
|
-
transaction<T>(callback: (client: SQLClient<DT>) => Promise<T>): Promise<T>;
|
|
132
|
-
prepare(sql: string): Promise<PreparedStatement>;
|
|
133
|
-
findFirst<K extends keyof DT>(table: K, where?: Partial<DT[K]>): Promise<DT[K] | null>;
|
|
134
|
-
findMany<K extends keyof DT>(table: K, options?: {
|
|
135
|
-
where?: Partial<DT[K]>;
|
|
136
|
-
limit?: number;
|
|
137
|
-
offset?: number;
|
|
138
|
-
}): Promise<DT[K][]>;
|
|
139
|
-
insert<K extends keyof DT>(table: K, data: Partial<DT[K]>): Promise<DT[K]>;
|
|
140
|
-
update<K extends keyof DT>(table: K, data: Partial<DT[K]>, where: Partial<DT[K]>): Promise<DT[K] | null>;
|
|
141
|
-
delete<K extends keyof DT>(table: K, where: Partial<DT[K]>): Promise<number>;
|
|
142
|
-
getDriver(): DatabaseDriver;
|
|
143
|
-
supportsTransactions(): boolean;
|
|
144
|
-
supportsPreparedStatements(): boolean;
|
|
145
|
-
close(): Promise<void>;
|
|
146
|
-
}
|
|
147
|
-
declare function createPostgresClient<DT = any>(config: {
|
|
148
|
-
connectionString?: string;
|
|
149
|
-
experimental?: {
|
|
150
|
-
http?: {
|
|
151
|
-
url: string;
|
|
152
|
-
apiKey?: string;
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
}): SQLClient<DT>;
|
|
156
|
-
declare function createLibSQLClient<DT = any>(config: {
|
|
157
|
-
url: string;
|
|
158
|
-
authToken?: string;
|
|
159
|
-
useTursoServerlessDriver?: boolean;
|
|
160
|
-
}): SQLClient<DT>;
|
|
161
|
-
declare function createMySQLClient<DT = any>(config: {
|
|
162
|
-
connectionString: string;
|
|
163
|
-
}): SQLClient<DT>;
|
|
164
|
-
declare function createSqliteClient<DT = any>(config: {
|
|
165
|
-
filename: string;
|
|
166
|
-
readonly?: boolean;
|
|
167
|
-
}): SQLClient<DT>;
|
|
168
|
-
declare const DriftSQLClient: typeof SQLClient;
|
|
169
|
-
|
|
170
|
-
export { ConnectionError, DriftSQLClient, LibSQLDriver, MySQLDriver, PostgresDriver, QueryError, SQLClient, SqliteDriver, createLibSQLClient, createMySQLClient, createPostgresClient, createSqliteClient, inspectDB, inspectLibSQL, inspectMySQL, inspectPostgres, inspectSQLite };
|
|
171
|
-
export type { ClientOptions, DatabaseDriver, QueryField, QueryResult };
|