@evolu/common 8.10.0 → 8.11.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/dist/src/Config.d.ts +22 -22
- package/dist/src/Config.d.ts.map +1 -1
- package/dist/src/Console.d.ts +62 -7
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +20 -4
- package/dist/src/Crypto.d.ts +76 -4
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +55 -4
- package/dist/src/Error.d.ts +45 -0
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +69 -0
- package/dist/src/Fs.d.ts +92 -18
- package/dist/src/Fs.d.ts.map +1 -1
- package/dist/src/Fs.js +2 -0
- package/dist/src/Identicon.d.ts +2 -2
- package/dist/src/Identicon.js +2 -2
- package/dist/src/LeakDetector.d.ts +22 -3
- package/dist/src/LeakDetector.d.ts.map +1 -1
- package/dist/src/LeakDetector.js +12 -2
- package/dist/src/LockManager.d.ts +8 -0
- package/dist/src/LockManager.d.ts.map +1 -1
- package/dist/src/LockManager.js +6 -0
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +5 -0
- package/dist/src/Platform.d.ts +47 -7
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +24 -5
- package/dist/src/Random.d.ts +25 -2
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Random.js +14 -2
- package/dist/src/Resource.d.ts +156 -1
- package/dist/src/Resource.d.ts.map +1 -1
- package/dist/src/Resource.js +201 -72
- package/dist/src/Schedule.d.ts +11 -10
- package/dist/src/Schedule.d.ts.map +1 -1
- package/dist/src/Schedule.js +1 -1
- package/dist/src/Sqlite.d.ts +132 -16
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +63 -9
- package/dist/src/Task.d.ts +15 -4
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +41 -15
- package/dist/src/Test.d.ts +9 -0
- package/dist/src/Test.d.ts.map +1 -1
- package/dist/src/Test.js +4 -0
- package/dist/src/Time.d.ts +106 -9
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +55 -4
- package/dist/src/Type.d.ts +1455 -1310
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +1274 -517
- package/dist/src/WebSocket.d.ts +164 -13
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +133 -24
- package/dist/src/Worker.d.ts +90 -8
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +28 -2
- package/dist/src/index.d.ts +6 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -3
- package/dist/src/local-first/Db.d.ts +52 -3
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +412 -137
- package/dist/src/local-first/Evolu.d.ts +336 -211
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +102 -15
- package/dist/src/local-first/Owner.d.ts +13 -30
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +13 -30
- package/dist/src/local-first/Protocol.d.ts +94 -16
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +118 -38
- package/dist/src/local-first/Query.d.ts +8 -15
- package/dist/src/local-first/Query.d.ts.map +1 -1
- package/dist/src/local-first/Schema.d.ts +335 -21
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Schema.js +214 -17
- package/dist/src/local-first/Shared.d.ts +537 -22
- package/dist/src/local-first/Shared.d.ts.map +1 -1
- package/dist/src/local-first/Shared.js +1437 -234
- package/dist/src/local-first/Storage.d.ts +192 -14
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/dist/src/local-first/Storage.js +81 -20
- package/dist/src/local-first/Timestamp.d.ts +392 -41
- package/dist/src/local-first/Timestamp.d.ts.map +1 -1
- package/dist/src/local-first/Timestamp.js +403 -81
- package/dist/src/local-first/index.d.ts +0 -1
- package/dist/src/local-first/index.d.ts.map +1 -1
- package/dist/src/local-first/index.js +0 -1
- package/package.json +1 -1
- package/src/Assert.test.ts +2 -5
- package/src/Config.test.ts +2 -6
- package/src/Config.ts +133 -133
- package/src/Console.ts +62 -7
- package/src/Crypto.ts +76 -4
- package/src/Eq.test.ts +2 -3
- package/src/Error.test.ts +76 -3
- package/src/Error.ts +71 -0
- package/src/Fs.ts +92 -18
- package/src/Identicon.ts +2 -2
- package/src/LeakDetector.ts +22 -3
- package/src/LockManager.ts +8 -0
- package/src/Object.test.ts +27 -12
- package/src/Object.ts +5 -0
- package/src/Platform.ts +50 -8
- package/src/Random.ts +25 -2
- package/src/Resource.test.ts +837 -0
- package/src/Resource.ts +235 -15
- package/src/Schedule.test.ts +50 -12
- package/src/Schedule.ts +24 -14
- package/src/Sqlite.ts +137 -17
- package/src/Task.test.ts +189 -8
- package/src/Task.ts +56 -17
- package/src/Test.ts +9 -0
- package/src/Time.ts +106 -9
- package/src/Type.test.ts +946 -1028
- package/src/Type.ts +4195 -3136
- package/src/Types.test.ts +4 -14
- package/src/WebSocket.ts +313 -40
- package/src/Worker.ts +90 -8
- package/src/index.ts +15 -6
- package/src/local-first/Db.ts +644 -339
- package/src/local-first/Evolu.test.ts +686 -21
- package/src/local-first/Evolu.ts +450 -228
- package/src/local-first/Owner.ts +13 -30
- package/src/local-first/Protocol.test.ts +617 -10
- package/src/local-first/Protocol.ts +196 -72
- package/src/local-first/Query.ts +8 -15
- package/src/local-first/Schema.test.ts +143 -0
- package/src/local-first/Schema.ts +363 -24
- package/src/local-first/Shared.test.ts +7731 -559
- package/src/local-first/Shared.ts +2036 -267
- package/src/local-first/Storage.ts +218 -32
- package/src/local-first/Timestamp.test.ts +344 -70
- package/src/local-first/Timestamp.ts +434 -118
- package/src/local-first/index.ts +0 -1
- package/dist/src/local-first/Error.d.ts +0 -12
- package/dist/src/local-first/Error.d.ts.map +0 -1
- package/dist/src/local-first/Error.js +0 -6
- package/dist/src/local-first/LocalAuth.d.ts +0 -150
- package/dist/src/local-first/LocalAuth.d.ts.map +0 -1
- package/dist/src/local-first/LocalAuth.js +0 -179
- package/src/local-first/Error.ts +0 -17
- package/src/local-first/LocalAuth.ts +0 -457
package/dist/src/Sqlite.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { type ArrayType, type InferType, type Name, type ObjectType, type Record
|
|
|
15
15
|
* API is synchronous because it provides
|
|
16
16
|
* {@link https://github.com/WiseLibs/better-sqlite3/issues/262 | better concurrency}
|
|
17
17
|
* for SQLite.
|
|
18
|
+
*
|
|
19
|
+
* @group Core
|
|
18
20
|
*/
|
|
19
21
|
export interface Sqlite extends AsyncDisposable {
|
|
20
22
|
readonly exec: <R extends SqliteRow = SqliteRow>(query: SqliteQuery) => SqliteExecResult<R>;
|
|
@@ -37,22 +39,44 @@ export interface Sqlite extends AsyncDisposable {
|
|
|
37
39
|
*/
|
|
38
40
|
readonly export: () => Uint8Array<ArrayBuffer>;
|
|
39
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Dependency wrapper for {@link Sqlite}.
|
|
44
|
+
*
|
|
45
|
+
* @group Core
|
|
46
|
+
*/
|
|
40
47
|
export interface SqliteDep {
|
|
41
48
|
readonly sqlite: Sqlite;
|
|
42
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Runs a callback inside a SQLite transaction.
|
|
52
|
+
*
|
|
53
|
+
* @group Core
|
|
54
|
+
*/
|
|
43
55
|
export interface SqliteTransaction {
|
|
44
56
|
<T, E>(callback: () => Result<T, E>): Result<T, E>;
|
|
45
57
|
(callback: () => void): void;
|
|
46
58
|
}
|
|
47
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Represents a SQL query to be executed on a {@link Sqlite} database.
|
|
61
|
+
*
|
|
62
|
+
* @group Queries
|
|
63
|
+
*/
|
|
48
64
|
export interface SqliteQuery {
|
|
49
65
|
readonly sql: SafeSql;
|
|
50
66
|
readonly parameters: SqliteQueryParameters;
|
|
51
67
|
readonly options?: SqliteQueryOptions;
|
|
52
68
|
}
|
|
53
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Serialized {@link SqliteQuery} used as a stable string key.
|
|
71
|
+
*
|
|
72
|
+
* @group Queries
|
|
73
|
+
*/
|
|
54
74
|
export type SqliteQueryString = string & Brand<"SqliteQueryString">;
|
|
55
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* A sanitized SQL string for {@link SqliteQuery}.
|
|
77
|
+
*
|
|
78
|
+
* @group Queries
|
|
79
|
+
*/
|
|
56
80
|
export type SafeSql = string & Brand<"SafeSql">;
|
|
57
81
|
/**
|
|
58
82
|
* A value that can be stored in {@link Sqlite}.
|
|
@@ -64,10 +88,16 @@ export type SafeSql = string & Brand<"SafeSql">;
|
|
|
64
88
|
*
|
|
65
89
|
* Note that Evolu can't support Int64 because expo-sqlite (and some others) do
|
|
66
90
|
* not support it.
|
|
91
|
+
*
|
|
92
|
+
* @group Values
|
|
67
93
|
*/
|
|
68
94
|
export declare const SqliteValue: import("./Type.ts").UnionType<readonly [import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, import("./Type.ts").LiteralType<null>, import("./Type.ts").Type<"String", string, string, import("./Type.ts").TypeOfError<"String">, null, import("./Type.ts").TypeOfError<"String">, never, string, true>, import("./Type.ts").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("./Type.ts").ObjectTagError<"Uint8Array">, null, import("./Type.ts").ObjectTagError<"Uint8Array">, never, Uint8Array<ArrayBufferLike>, true>]>;
|
|
69
95
|
export type SqliteValue = typeof SqliteValue.Output;
|
|
70
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Parameters of a {@link SqliteQuery}.
|
|
98
|
+
*
|
|
99
|
+
* @group Queries
|
|
100
|
+
*/
|
|
71
101
|
export declare const SqliteQueryParameters: ArrayType<import("./Type.ts").UnionType<readonly [import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, import("./Type.ts").LiteralType<null>, import("./Type.ts").Type<"String", string, string, import("./Type.ts").TypeOfError<"String">, null, import("./Type.ts").TypeOfError<"String">, never, string, true>, import("./Type.ts").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("./Type.ts").ObjectTagError<"Uint8Array">, null, import("./Type.ts").ObjectTagError<"Uint8Array">, never, Uint8Array<ArrayBufferLike>, true>]>>;
|
|
72
102
|
export type SqliteQueryParameters = typeof SqliteQueryParameters.Output;
|
|
73
103
|
/**
|
|
@@ -76,11 +106,21 @@ export type SqliteQueryParameters = typeof SqliteQueryParameters.Output;
|
|
|
76
106
|
*
|
|
77
107
|
* It differs from {@link SqliteValue} only by using `number` instead of
|
|
78
108
|
* {@link FiniteNumber}.
|
|
109
|
+
*
|
|
110
|
+
* @group Values
|
|
79
111
|
*/
|
|
80
112
|
export type SqliteValueInput = typeof SqliteValue.Input;
|
|
81
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Equality comparison for {@link SqliteValueInput}.
|
|
115
|
+
*
|
|
116
|
+
* @group Values
|
|
117
|
+
*/
|
|
82
118
|
export declare const eqSqliteValue: Eq<SqliteValueInput>;
|
|
83
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Options for configuring {@link SqliteQuery} execution behavior.
|
|
121
|
+
*
|
|
122
|
+
* @group Queries
|
|
123
|
+
*/
|
|
84
124
|
export interface SqliteQueryOptions {
|
|
85
125
|
/**
|
|
86
126
|
* If set to `true`, logs the time taken to execute the SQL query. Useful for
|
|
@@ -104,24 +144,41 @@ export interface SqliteQueryOptions {
|
|
|
104
144
|
*/
|
|
105
145
|
readonly prepare?: boolean;
|
|
106
146
|
}
|
|
107
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Converts a {@link SqliteQuery} into a stable {@link SqliteQueryString}.
|
|
149
|
+
*
|
|
150
|
+
* @group Queries
|
|
151
|
+
*/
|
|
108
152
|
export declare const sqliteQueryToSqliteQueryString: (query: SqliteQuery) => SqliteQueryString;
|
|
109
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Converts a {@link SqliteQueryString} back into a {@link SqliteQuery}.
|
|
155
|
+
*
|
|
156
|
+
* @group Queries
|
|
157
|
+
*/
|
|
110
158
|
export declare const sqliteQueryStringToSqliteQuery: (query: SqliteQueryString) => SqliteQuery;
|
|
111
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Result of executing a SQLite query.
|
|
161
|
+
*
|
|
162
|
+
* @group Queries
|
|
163
|
+
*/
|
|
112
164
|
export interface SqliteExecResult<R extends SqliteRow = SqliteRow> {
|
|
113
165
|
readonly rows: ReadonlyArray<R>;
|
|
166
|
+
/** The number of rows an insert, update, or delete statement changed. */
|
|
114
167
|
readonly changes: number;
|
|
115
168
|
}
|
|
116
169
|
/**
|
|
117
170
|
* A row returned from a {@link Sqlite} query, mapping column names to
|
|
118
171
|
* {@link SqliteValueInput}.
|
|
172
|
+
*
|
|
173
|
+
* @group Values
|
|
119
174
|
*/
|
|
120
175
|
export type SqliteRow = Record<string, SqliteValueInput>;
|
|
121
176
|
/**
|
|
122
177
|
* SQLite driver interface.
|
|
123
178
|
*
|
|
124
179
|
* Platform-specific drivers must implement this interface.
|
|
180
|
+
*
|
|
181
|
+
* @group Core
|
|
125
182
|
*/
|
|
126
183
|
export interface SqliteDriver extends Disposable {
|
|
127
184
|
readonly exec: (query: SqliteQuery) => SqliteExecResult;
|
|
@@ -135,8 +192,17 @@ export interface SqliteDriver extends Disposable {
|
|
|
135
192
|
*/
|
|
136
193
|
readonly export: () => Uint8Array<ArrayBuffer>;
|
|
137
194
|
}
|
|
138
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Creates a {@link SqliteDriver}.
|
|
197
|
+
*
|
|
198
|
+
* @group Core
|
|
199
|
+
*/
|
|
139
200
|
export type CreateSqliteDriver = (name: Name, options?: SqliteDriverOptions) => Task<SqliteDriver>;
|
|
201
|
+
/**
|
|
202
|
+
* Dependency wrapper for {@link CreateSqliteDriver}.
|
|
203
|
+
*
|
|
204
|
+
* @group Core
|
|
205
|
+
*/
|
|
140
206
|
export interface CreateSqliteDriverDep {
|
|
141
207
|
createSqliteDriver: CreateSqliteDriver;
|
|
142
208
|
}
|
|
@@ -145,6 +211,8 @@ export interface CreateSqliteDriverDep {
|
|
|
145
211
|
*
|
|
146
212
|
* Three mutually exclusive modes: in-memory (for testing), encrypted persistent
|
|
147
213
|
* (OPFS/file with encryption key), or persistent (default when omitted).
|
|
214
|
+
*
|
|
215
|
+
* @group Core
|
|
148
216
|
*/
|
|
149
217
|
export type SqliteDriverOptions = {
|
|
150
218
|
readonly mode: "memory";
|
|
@@ -157,15 +225,23 @@ export type SqliteDriverOptions = {
|
|
|
157
225
|
*
|
|
158
226
|
* The driver is created via {@link CreateSqliteDriver} and wrapped with logging,
|
|
159
227
|
* error handling, and transaction helpers.
|
|
228
|
+
*
|
|
229
|
+
* @group Core
|
|
160
230
|
*/
|
|
161
231
|
export declare const createSqlite: (name: Name, options?: SqliteDriverOptions) => Task<Sqlite, never, CreateSqliteDriverDep>;
|
|
162
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* Creates a test setup with a in-memory {@link Sqlite}.
|
|
234
|
+
*
|
|
235
|
+
* @group Testing
|
|
236
|
+
*/
|
|
163
237
|
export declare const testSetupSqlite: (deps: CreateSqliteDriverDep) => Promise<AsyncDisposable & SqliteDep & TestRunDep<CreateSqliteDriverDep & SqliteDep>>;
|
|
164
238
|
/**
|
|
165
239
|
* Cache for compiled prepared statements.
|
|
166
240
|
*
|
|
167
241
|
* Statements are created on first access and reused for subsequent calls with
|
|
168
242
|
* the same SQL. Disposing the cache finalizes all cached statements.
|
|
243
|
+
*
|
|
244
|
+
* @group Core
|
|
169
245
|
*/
|
|
170
246
|
export interface PreparedStatements<P> extends Disposable {
|
|
171
247
|
readonly get: <T extends boolean>(query: SqliteQuery, alwaysPrepare?: T) => T extends true ? P : P | null;
|
|
@@ -173,9 +249,15 @@ export interface PreparedStatements<P> extends Disposable {
|
|
|
173
249
|
/**
|
|
174
250
|
* Creates a {@link PreparedStatements} cache backed by the given factory and
|
|
175
251
|
* dispose function.
|
|
252
|
+
*
|
|
253
|
+
* @group Core
|
|
176
254
|
*/
|
|
177
255
|
export declare const createPreparedStatementsCache: <P>(factory: (sql: SafeSql) => P, disposeFn: (statement: P) => void) => PreparedStatements<P>;
|
|
178
|
-
/**
|
|
256
|
+
/**
|
|
257
|
+
* A double-quoted SQL identifier for safe column or table name interpolation.
|
|
258
|
+
*
|
|
259
|
+
* @group Queries
|
|
260
|
+
*/
|
|
179
261
|
export interface SqlIdentifier extends Typed<"SqlIdentifier"> {
|
|
180
262
|
readonly sql: SafeSql;
|
|
181
263
|
}
|
|
@@ -183,11 +265,17 @@ export interface SqlIdentifier extends Typed<"SqlIdentifier"> {
|
|
|
183
265
|
* An unescaped SQL fragment inserted verbatim into a query.
|
|
184
266
|
*
|
|
185
267
|
* **Warning**: Use only with trusted, constant strings to avoid SQL injection.
|
|
268
|
+
*
|
|
269
|
+
* @group Queries
|
|
186
270
|
*/
|
|
187
271
|
export interface RawSql extends Typed<"RawSql"> {
|
|
188
272
|
readonly sql: string;
|
|
189
273
|
}
|
|
190
|
-
/**
|
|
274
|
+
/**
|
|
275
|
+
* A parameter accepted by the {@link sql} tagged template.
|
|
276
|
+
*
|
|
277
|
+
* @group Queries
|
|
278
|
+
*/
|
|
191
279
|
export type SqlTemplateParam = SqliteValueInput | SqlIdentifier | RawSql;
|
|
192
280
|
export declare function sql(strings: TemplateStringsArray, ...parameters: Array<SqlTemplateParam>): SqliteQuery;
|
|
193
281
|
export declare namespace sql {
|
|
@@ -195,19 +283,29 @@ export declare namespace sql {
|
|
|
195
283
|
var raw: (raw: string) => RawSql;
|
|
196
284
|
var prepared: (strings: TemplateStringsArray, ...parameters: Array<SqlTemplateParam>) => SqliteQuery;
|
|
197
285
|
}
|
|
198
|
-
/**
|
|
286
|
+
/**
|
|
287
|
+
* Index metadata stored in `sqlite_master` for a {@link Sqlite} database.
|
|
288
|
+
*
|
|
289
|
+
* @group Schema
|
|
290
|
+
*/
|
|
199
291
|
export declare const SqliteIndex: ObjectType<{
|
|
200
292
|
readonly name: typeof String;
|
|
201
293
|
readonly sql: typeof String;
|
|
202
294
|
}>;
|
|
203
295
|
export interface SqliteIndex extends InferType<typeof SqliteIndex> {
|
|
204
296
|
}
|
|
205
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* {@link Eq} instance for {@link SqliteIndex}.
|
|
299
|
+
*
|
|
300
|
+
* @group Schema
|
|
301
|
+
*/
|
|
206
302
|
export declare const eqSqliteIndex: Eq<SqliteIndex>;
|
|
207
303
|
/**
|
|
208
304
|
* Full schema metadata for a {@link Sqlite} database.
|
|
209
305
|
*
|
|
210
306
|
* Includes table-column mappings and user-visible indexes.
|
|
307
|
+
*
|
|
308
|
+
* @group Schema
|
|
211
309
|
*/
|
|
212
310
|
export declare const SqliteSchema: ObjectType<{
|
|
213
311
|
readonly tables: RecordType<typeof String, SetType<typeof String>>;
|
|
@@ -215,7 +313,11 @@ export declare const SqliteSchema: ObjectType<{
|
|
|
215
313
|
}>;
|
|
216
314
|
export interface SqliteSchema extends InferType<typeof SqliteSchema> {
|
|
217
315
|
}
|
|
218
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* Get the current SQLite schema by reading SQLite metadata.
|
|
318
|
+
*
|
|
319
|
+
* @group Schema
|
|
320
|
+
*/
|
|
219
321
|
export declare const getSqliteSchema: (deps: SqliteDep) => ({ excludeIndexNamePrefix, }?: {
|
|
220
322
|
/**
|
|
221
323
|
* If provided, indexes with names starting with this prefix are excluded in
|
|
@@ -226,6 +328,8 @@ export declare const getSqliteSchema: (deps: SqliteDep) => ({ excludeIndexNamePr
|
|
|
226
328
|
/**
|
|
227
329
|
* Returns {@link SqliteSchema} and full {@link SqliteRow} table contents for
|
|
228
330
|
* inspection and testing.
|
|
331
|
+
*
|
|
332
|
+
* @group Schema
|
|
229
333
|
*/
|
|
230
334
|
export interface SqliteSnapshot {
|
|
231
335
|
readonly schema: SqliteSchema;
|
|
@@ -239,6 +343,8 @@ export interface SqliteSnapshot {
|
|
|
239
343
|
*
|
|
240
344
|
* The snapshot includes current {@link SqliteSchema} and all rows from every
|
|
241
345
|
* discovered table. Table order follows `schema.tables` iteration order.
|
|
346
|
+
*
|
|
347
|
+
* @group Schema
|
|
242
348
|
*/
|
|
243
349
|
export declare const getSqliteSnapshot: (deps: SqliteDep) => SqliteSnapshot;
|
|
244
350
|
/**
|
|
@@ -251,6 +357,8 @@ export declare const getSqliteSnapshot: (deps: SqliteDep) => SqliteSnapshot;
|
|
|
251
357
|
* readability.
|
|
252
358
|
* - Use {@link booleanToSqliteBoolean} and {@link sqliteBooleanToBoolean} for
|
|
253
359
|
* converting between JavaScript booleans and SQLite boolean values.
|
|
360
|
+
*
|
|
361
|
+
* @group Values
|
|
254
362
|
*/
|
|
255
363
|
export declare const SqliteBoolean: import("./Type.ts").UnionType<readonly [import("./Type.ts").LiteralType<0>, import("./Type.ts").LiteralType<1>]>;
|
|
256
364
|
export type SqliteBoolean = typeof SqliteBoolean.Output;
|
|
@@ -258,12 +366,16 @@ export type SqliteBoolean = typeof SqliteBoolean.Output;
|
|
|
258
366
|
* Represents the {@link SqliteBoolean} value for `true`.
|
|
259
367
|
*
|
|
260
368
|
* See {@link SqliteBoolean}.
|
|
369
|
+
*
|
|
370
|
+
* @group Values
|
|
261
371
|
*/
|
|
262
372
|
export declare const sqliteTrue = 1;
|
|
263
373
|
/**
|
|
264
374
|
* Represents the {@link SqliteBoolean} value for `false`.
|
|
265
375
|
*
|
|
266
376
|
* See {@link SqliteBoolean}.
|
|
377
|
+
*
|
|
378
|
+
* @group Values
|
|
267
379
|
*/
|
|
268
380
|
export declare const sqliteFalse = 0;
|
|
269
381
|
/**
|
|
@@ -276,6 +388,8 @@ export declare const sqliteFalse = 0;
|
|
|
276
388
|
*
|
|
277
389
|
* assertEqual(booleanToSqliteBoolean(true), 1);
|
|
278
390
|
* ```
|
|
391
|
+
*
|
|
392
|
+
* @group Values
|
|
279
393
|
*/
|
|
280
394
|
export declare const booleanToSqliteBoolean: (value: boolean) => SqliteBoolean;
|
|
281
395
|
/**
|
|
@@ -288,6 +402,8 @@ export declare const booleanToSqliteBoolean: (value: boolean) => SqliteBoolean;
|
|
|
288
402
|
*
|
|
289
403
|
* assertTrue(sqliteBooleanToBoolean(1));
|
|
290
404
|
* ```
|
|
405
|
+
*
|
|
406
|
+
* @group Values
|
|
291
407
|
*/
|
|
292
408
|
export declare const sqliteBooleanToBoolean: (value: SqliteBoolean) => boolean;
|
|
293
409
|
//# sourceMappingURL=Sqlite.d.ts.map
|
package/dist/src/Sqlite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sqlite.d.ts","sourceRoot":"","sources":["../../src/Sqlite.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAIlC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,IAAI,EAAiB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,SAAS,EACd,K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H,eAAO,MAAM,sBAAsB,UAAW,OAAO,KAAG,aACtB,CAAC;AAEnC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,UAAW,aAAa,KAAG,OACxC,CAAC"}
|
package/dist/src/Sqlite.js
CHANGED
|
@@ -72,13 +72,27 @@ import { array, FiniteNumber, Null, object, record, set, String, testName, Uint8
|
|
|
72
72
|
*
|
|
73
73
|
* Note that Evolu can't support Int64 because expo-sqlite (and some others) do
|
|
74
74
|
* not support it.
|
|
75
|
+
*
|
|
76
|
+
* @group Values
|
|
75
77
|
*/
|
|
76
78
|
export const SqliteValue = /*#__PURE__*/ union(FiniteNumber, Null, String, Uint8Array);
|
|
77
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Parameters of a {@link SqliteQuery}.
|
|
81
|
+
*
|
|
82
|
+
* @group Queries
|
|
83
|
+
*/
|
|
78
84
|
export const SqliteQueryParameters = /*#__PURE__*/ array(SqliteValue);
|
|
79
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Equality comparison for {@link SqliteValueInput}.
|
|
87
|
+
*
|
|
88
|
+
* @group Values
|
|
89
|
+
*/
|
|
80
90
|
export const eqSqliteValue = (x, y) => Uint8Array.is(x) && Uint8Array.is(y) ? eqUint8Array(x, y) : x === y;
|
|
81
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Converts a {@link SqliteQuery} into a stable {@link SqliteQueryString}.
|
|
93
|
+
*
|
|
94
|
+
* @group Queries
|
|
95
|
+
*/
|
|
82
96
|
export const sqliteQueryToSqliteQueryString = (query) => {
|
|
83
97
|
const params = query.parameters.map((value) => Uint8Array.is(value)
|
|
84
98
|
? ["b", bytesToHex(value)]
|
|
@@ -88,7 +102,11 @@ export const sqliteQueryToSqliteQueryString = (query) => {
|
|
|
88
102
|
: [];
|
|
89
103
|
return JSON.stringify([query.sql, params, options]);
|
|
90
104
|
};
|
|
91
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Converts a {@link SqliteQueryString} back into a {@link SqliteQuery}.
|
|
107
|
+
*
|
|
108
|
+
* @group Queries
|
|
109
|
+
*/
|
|
92
110
|
export const sqliteQueryStringToSqliteQuery = (query) => {
|
|
93
111
|
const [sql, paramsArr, optionsArr] = JSON.parse(query);
|
|
94
112
|
const parameters = paramsArr.map(([type, value]) => type === "b" ? hexToBytes(value) : value);
|
|
@@ -106,6 +124,8 @@ export const sqliteQueryStringToSqliteQuery = (query) => {
|
|
|
106
124
|
*
|
|
107
125
|
* The driver is created via {@link CreateSqliteDriver} and wrapped with logging,
|
|
108
126
|
* error handling, and transaction helpers.
|
|
127
|
+
*
|
|
128
|
+
* @group Core
|
|
109
129
|
*/
|
|
110
130
|
export const createSqlite = (name, options) => async (run) => {
|
|
111
131
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
@@ -179,7 +199,11 @@ export const createSqlite = (name, options) => async (run) => {
|
|
|
179
199
|
await result_1;
|
|
180
200
|
}
|
|
181
201
|
};
|
|
182
|
-
/**
|
|
202
|
+
/**
|
|
203
|
+
* Creates a test setup with a in-memory {@link Sqlite}.
|
|
204
|
+
*
|
|
205
|
+
* @group Testing
|
|
206
|
+
*/
|
|
183
207
|
export const testSetupSqlite = async (deps) => {
|
|
184
208
|
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
185
209
|
try {
|
|
@@ -223,6 +247,8 @@ const drawSqliteQueryPlan = (rows) => rows
|
|
|
223
247
|
/**
|
|
224
248
|
* Creates a {@link PreparedStatements} cache backed by the given factory and
|
|
225
249
|
* dispose function.
|
|
250
|
+
*
|
|
251
|
+
* @group Core
|
|
226
252
|
*/
|
|
227
253
|
export const createPreparedStatementsCache = (factory, disposeFn) => {
|
|
228
254
|
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
@@ -312,6 +338,8 @@ export const createPreparedStatementsCache = (factory, disposeFn) => {
|
|
|
312
338
|
* Use `prettier-plugin-sql-cst` for SQL formatting. Like Prettier for
|
|
313
339
|
* JavaScript, this plugin formats SQL expressions differently depending on
|
|
314
340
|
* their length.
|
|
341
|
+
*
|
|
342
|
+
* @group Queries
|
|
315
343
|
*/
|
|
316
344
|
export const sql = (strings, ...parameters) => {
|
|
317
345
|
let sql = "";
|
|
@@ -325,7 +353,7 @@ export const sql = (strings, ...parameters) => {
|
|
|
325
353
|
}
|
|
326
354
|
else {
|
|
327
355
|
sql += "?";
|
|
328
|
-
values.push(
|
|
356
|
+
values.push(typeof param === "number" ? FiniteNumber.orThrow(param) : param);
|
|
329
357
|
}
|
|
330
358
|
}
|
|
331
359
|
}
|
|
@@ -348,9 +376,17 @@ sql.prepared = (strings, ...parameters) => {
|
|
|
348
376
|
const query = sql(strings, ...parameters);
|
|
349
377
|
return { ...query, options: { prepare: true } };
|
|
350
378
|
};
|
|
351
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* Index metadata stored in `sqlite_master` for a {@link Sqlite} database.
|
|
381
|
+
*
|
|
382
|
+
* @group Schema
|
|
383
|
+
*/
|
|
352
384
|
export const SqliteIndex = /*#__PURE__*/ object({ name: String, sql: String });
|
|
353
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* {@link Eq} instance for {@link SqliteIndex}.
|
|
387
|
+
*
|
|
388
|
+
* @group Schema
|
|
389
|
+
*/
|
|
354
390
|
export const eqSqliteIndex = /*#__PURE__*/ createEqObject({
|
|
355
391
|
name: eqString,
|
|
356
392
|
sql: eqString,
|
|
@@ -359,12 +395,18 @@ export const eqSqliteIndex = /*#__PURE__*/ createEqObject({
|
|
|
359
395
|
* Full schema metadata for a {@link Sqlite} database.
|
|
360
396
|
*
|
|
361
397
|
* Includes table-column mappings and user-visible indexes.
|
|
398
|
+
*
|
|
399
|
+
* @group Schema
|
|
362
400
|
*/
|
|
363
401
|
export const SqliteSchema = /*#__PURE__*/ object({
|
|
364
402
|
tables: /*#__PURE__*/ record(String, /*#__PURE__*/ set(String)),
|
|
365
403
|
indexes: /*#__PURE__*/ array(SqliteIndex),
|
|
366
404
|
});
|
|
367
|
-
/**
|
|
405
|
+
/**
|
|
406
|
+
* Get the current SQLite schema by reading SQLite metadata.
|
|
407
|
+
*
|
|
408
|
+
* @group Schema
|
|
409
|
+
*/
|
|
368
410
|
export const getSqliteSchema = (deps) => ({ excludeIndexNamePrefix, } = {}) => {
|
|
369
411
|
const tables = createMutableRecord();
|
|
370
412
|
const tableAndColumnInfoRows = deps.sqlite.exec(sql `
|
|
@@ -408,6 +450,8 @@ export const getSqliteSchema = (deps) => ({ excludeIndexNamePrefix, } = {}) => {
|
|
|
408
450
|
*
|
|
409
451
|
* The snapshot includes current {@link SqliteSchema} and all rows from every
|
|
410
452
|
* discovered table. Table order follows `schema.tables` iteration order.
|
|
453
|
+
*
|
|
454
|
+
* @group Schema
|
|
411
455
|
*/
|
|
412
456
|
export const getSqliteSnapshot = (deps) => {
|
|
413
457
|
const schema = getSqliteSchema(deps)();
|
|
@@ -433,18 +477,24 @@ export const getSqliteSnapshot = (deps) => {
|
|
|
433
477
|
* readability.
|
|
434
478
|
* - Use {@link booleanToSqliteBoolean} and {@link sqliteBooleanToBoolean} for
|
|
435
479
|
* converting between JavaScript booleans and SQLite boolean values.
|
|
480
|
+
*
|
|
481
|
+
* @group Values
|
|
436
482
|
*/
|
|
437
483
|
export const SqliteBoolean = /*#__PURE__*/ union(0, 1);
|
|
438
484
|
/**
|
|
439
485
|
* Represents the {@link SqliteBoolean} value for `true`.
|
|
440
486
|
*
|
|
441
487
|
* See {@link SqliteBoolean}.
|
|
488
|
+
*
|
|
489
|
+
* @group Values
|
|
442
490
|
*/
|
|
443
491
|
export const sqliteTrue = 1;
|
|
444
492
|
/**
|
|
445
493
|
* Represents the {@link SqliteBoolean} value for `false`.
|
|
446
494
|
*
|
|
447
495
|
* See {@link SqliteBoolean}.
|
|
496
|
+
*
|
|
497
|
+
* @group Values
|
|
448
498
|
*/
|
|
449
499
|
export const sqliteFalse = 0;
|
|
450
500
|
/**
|
|
@@ -457,6 +507,8 @@ export const sqliteFalse = 0;
|
|
|
457
507
|
*
|
|
458
508
|
* assertEqual(booleanToSqliteBoolean(true), 1);
|
|
459
509
|
* ```
|
|
510
|
+
*
|
|
511
|
+
* @group Values
|
|
460
512
|
*/
|
|
461
513
|
export const booleanToSqliteBoolean = (value) => value ? sqliteTrue : sqliteFalse;
|
|
462
514
|
/**
|
|
@@ -469,5 +521,7 @@ export const booleanToSqliteBoolean = (value) => value ? sqliteTrue : sqliteFals
|
|
|
469
521
|
*
|
|
470
522
|
* assertTrue(sqliteBooleanToBoolean(1));
|
|
471
523
|
* ```
|
|
524
|
+
*
|
|
525
|
+
* @group Values
|
|
472
526
|
*/
|
|
473
527
|
export const sqliteBooleanToBoolean = (value) => value === sqliteTrue;
|
package/dist/src/Task.d.ts
CHANGED
|
@@ -1314,9 +1314,19 @@ export interface Run<D = unknown> {
|
|
|
1314
1314
|
* ```
|
|
1315
1315
|
*/
|
|
1316
1316
|
readonly onAbort: (callback: (abortError: AbortError) => void) => Disposable | null;
|
|
1317
|
-
/**
|
|
1317
|
+
/**
|
|
1318
|
+
* Returns the current {@link RunState} of this {@link Run}.
|
|
1319
|
+
*
|
|
1320
|
+
* Abort requests are recorded before propagating to descendants. Observed
|
|
1321
|
+
* aborts are recorded before this Run's abort callbacks execute.
|
|
1322
|
+
*/
|
|
1318
1323
|
readonly getState: () => RunState;
|
|
1319
|
-
/**
|
|
1324
|
+
/**
|
|
1325
|
+
* Creates a memoized recursive {@link RunSnapshot} of the current Run tree.
|
|
1326
|
+
*
|
|
1327
|
+
* Reflects abort requests and observations with the same timing as
|
|
1328
|
+
* {@link Run.getState}.
|
|
1329
|
+
*/
|
|
1320
1330
|
readonly snapshot: () => RunSnapshot;
|
|
1321
1331
|
/**
|
|
1322
1332
|
* Callback for monitoring Run events emitted by this Run or descendants.
|
|
@@ -1867,8 +1877,9 @@ export interface ReportDefectDep {
|
|
|
1867
1877
|
* platforms without native global error reporting. Browser adapters use the
|
|
1868
1878
|
* native
|
|
1869
1879
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/reportError | reportError}
|
|
1870
|
-
* API
|
|
1871
|
-
*
|
|
1880
|
+
* API, and other platform adapters can use platform-specific reporting.
|
|
1881
|
+
* Adapters report an `Error` from {@link defectToError}, which such reporting
|
|
1882
|
+
* shows readably.
|
|
1872
1883
|
*
|
|
1873
1884
|
* @group Run
|
|
1874
1885
|
*/
|