@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.
Files changed (144) hide show
  1. package/dist/src/Config.d.ts +22 -22
  2. package/dist/src/Config.d.ts.map +1 -1
  3. package/dist/src/Console.d.ts +62 -7
  4. package/dist/src/Console.d.ts.map +1 -1
  5. package/dist/src/Console.js +20 -4
  6. package/dist/src/Crypto.d.ts +76 -4
  7. package/dist/src/Crypto.d.ts.map +1 -1
  8. package/dist/src/Crypto.js +55 -4
  9. package/dist/src/Error.d.ts +45 -0
  10. package/dist/src/Error.d.ts.map +1 -1
  11. package/dist/src/Error.js +69 -0
  12. package/dist/src/Fs.d.ts +92 -18
  13. package/dist/src/Fs.d.ts.map +1 -1
  14. package/dist/src/Fs.js +2 -0
  15. package/dist/src/Identicon.d.ts +2 -2
  16. package/dist/src/Identicon.js +2 -2
  17. package/dist/src/LeakDetector.d.ts +22 -3
  18. package/dist/src/LeakDetector.d.ts.map +1 -1
  19. package/dist/src/LeakDetector.js +12 -2
  20. package/dist/src/LockManager.d.ts +8 -0
  21. package/dist/src/LockManager.d.ts.map +1 -1
  22. package/dist/src/LockManager.js +6 -0
  23. package/dist/src/Object.d.ts.map +1 -1
  24. package/dist/src/Object.js +5 -0
  25. package/dist/src/Platform.d.ts +47 -7
  26. package/dist/src/Platform.d.ts.map +1 -1
  27. package/dist/src/Platform.js +24 -5
  28. package/dist/src/Random.d.ts +25 -2
  29. package/dist/src/Random.d.ts.map +1 -1
  30. package/dist/src/Random.js +14 -2
  31. package/dist/src/Resource.d.ts +156 -1
  32. package/dist/src/Resource.d.ts.map +1 -1
  33. package/dist/src/Resource.js +201 -72
  34. package/dist/src/Schedule.d.ts +11 -10
  35. package/dist/src/Schedule.d.ts.map +1 -1
  36. package/dist/src/Schedule.js +1 -1
  37. package/dist/src/Sqlite.d.ts +132 -16
  38. package/dist/src/Sqlite.d.ts.map +1 -1
  39. package/dist/src/Sqlite.js +63 -9
  40. package/dist/src/Task.d.ts +15 -4
  41. package/dist/src/Task.d.ts.map +1 -1
  42. package/dist/src/Task.js +41 -15
  43. package/dist/src/Test.d.ts +9 -0
  44. package/dist/src/Test.d.ts.map +1 -1
  45. package/dist/src/Test.js +4 -0
  46. package/dist/src/Time.d.ts +106 -9
  47. package/dist/src/Time.d.ts.map +1 -1
  48. package/dist/src/Time.js +55 -4
  49. package/dist/src/Type.d.ts +1455 -1310
  50. package/dist/src/Type.d.ts.map +1 -1
  51. package/dist/src/Type.js +1274 -517
  52. package/dist/src/WebSocket.d.ts +164 -13
  53. package/dist/src/WebSocket.d.ts.map +1 -1
  54. package/dist/src/WebSocket.js +133 -24
  55. package/dist/src/Worker.d.ts +90 -8
  56. package/dist/src/Worker.d.ts.map +1 -1
  57. package/dist/src/Worker.js +28 -2
  58. package/dist/src/index.d.ts +6 -7
  59. package/dist/src/index.d.ts.map +1 -1
  60. package/dist/src/index.js +2 -3
  61. package/dist/src/local-first/Db.d.ts +52 -3
  62. package/dist/src/local-first/Db.d.ts.map +1 -1
  63. package/dist/src/local-first/Db.js +412 -137
  64. package/dist/src/local-first/Evolu.d.ts +336 -211
  65. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  66. package/dist/src/local-first/Evolu.js +102 -15
  67. package/dist/src/local-first/Owner.d.ts +13 -30
  68. package/dist/src/local-first/Owner.d.ts.map +1 -1
  69. package/dist/src/local-first/Owner.js +13 -30
  70. package/dist/src/local-first/Protocol.d.ts +94 -16
  71. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  72. package/dist/src/local-first/Protocol.js +118 -38
  73. package/dist/src/local-first/Query.d.ts +8 -15
  74. package/dist/src/local-first/Query.d.ts.map +1 -1
  75. package/dist/src/local-first/Schema.d.ts +335 -21
  76. package/dist/src/local-first/Schema.d.ts.map +1 -1
  77. package/dist/src/local-first/Schema.js +214 -17
  78. package/dist/src/local-first/Shared.d.ts +537 -22
  79. package/dist/src/local-first/Shared.d.ts.map +1 -1
  80. package/dist/src/local-first/Shared.js +1437 -234
  81. package/dist/src/local-first/Storage.d.ts +192 -14
  82. package/dist/src/local-first/Storage.d.ts.map +1 -1
  83. package/dist/src/local-first/Storage.js +81 -20
  84. package/dist/src/local-first/Timestamp.d.ts +392 -41
  85. package/dist/src/local-first/Timestamp.d.ts.map +1 -1
  86. package/dist/src/local-first/Timestamp.js +403 -81
  87. package/dist/src/local-first/index.d.ts +0 -1
  88. package/dist/src/local-first/index.d.ts.map +1 -1
  89. package/dist/src/local-first/index.js +0 -1
  90. package/package.json +1 -1
  91. package/src/Assert.test.ts +2 -5
  92. package/src/Config.test.ts +2 -6
  93. package/src/Config.ts +133 -133
  94. package/src/Console.ts +62 -7
  95. package/src/Crypto.ts +76 -4
  96. package/src/Eq.test.ts +2 -3
  97. package/src/Error.test.ts +76 -3
  98. package/src/Error.ts +71 -0
  99. package/src/Fs.ts +92 -18
  100. package/src/Identicon.ts +2 -2
  101. package/src/LeakDetector.ts +22 -3
  102. package/src/LockManager.ts +8 -0
  103. package/src/Object.test.ts +27 -12
  104. package/src/Object.ts +5 -0
  105. package/src/Platform.ts +50 -8
  106. package/src/Random.ts +25 -2
  107. package/src/Resource.test.ts +837 -0
  108. package/src/Resource.ts +235 -15
  109. package/src/Schedule.test.ts +50 -12
  110. package/src/Schedule.ts +24 -14
  111. package/src/Sqlite.ts +137 -17
  112. package/src/Task.test.ts +189 -8
  113. package/src/Task.ts +56 -17
  114. package/src/Test.ts +9 -0
  115. package/src/Time.ts +106 -9
  116. package/src/Type.test.ts +946 -1028
  117. package/src/Type.ts +4195 -3136
  118. package/src/Types.test.ts +4 -14
  119. package/src/WebSocket.ts +313 -40
  120. package/src/Worker.ts +90 -8
  121. package/src/index.ts +15 -6
  122. package/src/local-first/Db.ts +644 -339
  123. package/src/local-first/Evolu.test.ts +686 -21
  124. package/src/local-first/Evolu.ts +450 -228
  125. package/src/local-first/Owner.ts +13 -30
  126. package/src/local-first/Protocol.test.ts +617 -10
  127. package/src/local-first/Protocol.ts +196 -72
  128. package/src/local-first/Query.ts +8 -15
  129. package/src/local-first/Schema.test.ts +143 -0
  130. package/src/local-first/Schema.ts +363 -24
  131. package/src/local-first/Shared.test.ts +7731 -559
  132. package/src/local-first/Shared.ts +2036 -267
  133. package/src/local-first/Storage.ts +218 -32
  134. package/src/local-first/Timestamp.test.ts +344 -70
  135. package/src/local-first/Timestamp.ts +434 -118
  136. package/src/local-first/index.ts +0 -1
  137. package/dist/src/local-first/Error.d.ts +0 -12
  138. package/dist/src/local-first/Error.d.ts.map +0 -1
  139. package/dist/src/local-first/Error.js +0 -6
  140. package/dist/src/local-first/LocalAuth.d.ts +0 -150
  141. package/dist/src/local-first/LocalAuth.d.ts.map +0 -1
  142. package/dist/src/local-first/LocalAuth.js +0 -179
  143. package/src/local-first/Error.ts +0 -17
  144. package/src/local-first/LocalAuth.ts +0 -457
@@ -7,13 +7,19 @@ import * as Kysely from "kysely";
7
7
  import type { StandardSchemaV1 } from "@standard-schema/spec";
8
8
  import { type ReadonlyRecord } from "../Object.ts";
9
9
  import { SqliteBoolean, type SqliteDep, type SqliteQueryOptions, type SqliteSchema, SqliteValue } from "../Sqlite.ts";
10
+ import type { Millis } from "../Time.ts";
10
11
  import { DateIso, type Id, IdBytes, type InferType, Null, type ObjectType, type UnionType } from "../Type.ts";
11
12
  import type { CompileTimeError, Simplify } from "../Types.ts";
13
+ import type { OwnerIdBytes } from "./Owner.ts";
12
14
  import { OwnerId } from "./Owner.ts";
13
15
  import type { Query, Row } from "./Query.ts";
14
16
  import type { DbChange } from "./Storage.ts";
15
17
  import { TimestampBytes } from "./Timestamp.ts";
16
- /** Any Standard Schema V1 declaration. */
18
+ /**
19
+ * Any Standard Schema V1 declaration.
20
+ *
21
+ * @group Core
22
+ */
17
23
  export type AnyStandardSchemaV1 = StandardSchemaV1<any, any>;
18
24
  /**
19
25
  * Defines the schema of an Evolu database.
@@ -84,10 +90,117 @@ export type AnyStandardSchemaV1 = StandardSchemaV1<any, any>;
84
90
  * };
85
91
  * assertTrue(ZodSchema.todo.title.safeParse("Write docs").success);
86
92
  * ```
93
+ *
94
+ * @group Core
87
95
  */
88
96
  export type EvoluSchema = ReadonlyRecord<string, TableSchema>;
89
- /** A table schema: column names mapped to Standard Schema validators. */
97
+ /**
98
+ * A table schema: column names mapped to Standard Schema validators.
99
+ *
100
+ * @group Core
101
+ */
90
102
  export type TableSchema = ReadonlyRecord<string, AnyStandardSchemaV1>;
103
+ /**
104
+ * Whether a table is local-only: its name starts with an underscore, so its
105
+ * changes are stored without synchronization.
106
+ *
107
+ * @group Core
108
+ */
109
+ export declare const isLocalOnlyTable: (table: string) => boolean;
110
+ /**
111
+ * Todo ID Type for {@link testEvoluSchema}.
112
+ *
113
+ * @group Testing
114
+ */
115
+ export declare const TestTodoId: import("../Type.ts").TableId<"Todo">;
116
+ export type TestTodoId = typeof TestTodoId.Output;
117
+ /**
118
+ * Deterministic {@link TestTodoId} for tests and examples.
119
+ *
120
+ * @group Testing
121
+ */
122
+ export declare const testTodoId: string & import("../Brand.ts").Brand<"Id"> & import("../Brand.ts").Brand<"Todo">;
123
+ /**
124
+ * Project ID Type for {@link testEvoluSchema}.
125
+ *
126
+ * @group Testing
127
+ */
128
+ export declare const TestProjectId: import("../Type.ts").TableId<"Project">;
129
+ export type TestProjectId = typeof TestProjectId.Output;
130
+ /**
131
+ * Deterministic {@link TestProjectId} for tests and examples.
132
+ *
133
+ * @group Testing
134
+ */
135
+ export declare const testProjectId: string & import("../Brand.ts").Brand<"Id"> & import("../Brand.ts").Brand<"Project">;
136
+ /**
137
+ * Todo and project schema for tests and examples. A todo can belong to a
138
+ * project or have no project. Use an explicit schema when teaching schema
139
+ * definition.
140
+ *
141
+ * ### Example
142
+ *
143
+ * ```ts
144
+ * import {
145
+ * assertOk,
146
+ * testEvoluSchema,
147
+ * testProjectId,
148
+ * testTodoId,
149
+ * } from "@evolu/common";
150
+ *
151
+ * assertOk(testEvoluSchema.todo.id.from(testTodoId), testTodoId);
152
+ * assertOk(
153
+ * testEvoluSchema.todo.projectId.from(testProjectId),
154
+ * testProjectId,
155
+ * );
156
+ * ```
157
+ *
158
+ * @group Testing
159
+ */
160
+ export declare const testEvoluSchema: {
161
+ readonly todo: {
162
+ readonly id: import("../Type.ts").TableId<"Todo">;
163
+ readonly title: import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"String", string, string, import("../Type.ts").TypeOfError<"String">, null, import("../Type.ts").TypeOfError<"String">, never, string, true>, "Trimmed", import("../Type.ts").TrimmedError>, "MinLength1", import("../Type.ts").MinLengthError<1>>, "MaxLength100", import("../Type.ts").MaxLengthError<100>>;
164
+ readonly isCompleted: UnionType<readonly [UnionType<readonly [import("../Type.ts").LiteralType<0>, import("../Type.ts").LiteralType<1>]>, import("../Type.ts").LiteralType<null>]>;
165
+ readonly projectId: UnionType<readonly [import("../Type.ts").TableId<"Project">, import("../Type.ts").LiteralType<null>]>;
166
+ };
167
+ readonly project: {
168
+ readonly id: import("../Type.ts").TableId<"Project">;
169
+ readonly name: import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"String", string, string, import("../Type.ts").TypeOfError<"String">, null, import("../Type.ts").TypeOfError<"String">, never, string, true>, "Trimmed", import("../Type.ts").TrimmedError>, "MinLength1", import("../Type.ts").MinLengthError<1>>, "MaxLength100", import("../Type.ts").MaxLengthError<100>>;
170
+ };
171
+ };
172
+ /**
173
+ * Schema type of {@link testEvoluSchema}.
174
+ *
175
+ * @group Testing
176
+ */
177
+ export type TestEvoluSchema = typeof testEvoluSchema;
178
+ /**
179
+ * App-owner registry schema with local tables for tests and examples.
180
+ *
181
+ * Stores operational keys separately from optional recovery material. A null
182
+ * secret represents an owner whose recovery material is managed elsewhere or
183
+ * unavailable. Names are optional device-local labels; identicons can be
184
+ * derived from the owner identity without an additional column.
185
+ *
186
+ * This fixture does not define the production registry's persistence contract.
187
+ *
188
+ * @group Testing
189
+ */
190
+ export declare const testLocalOnlyEvoluSchema: {
191
+ readonly _appOwner: {
192
+ readonly id: import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"String", string, string, import("../Type.ts").TypeOfError<"String">, null, import("../Type.ts").TypeOfError<"String">, never, string, true>, "Id", import("../Type.ts").IdError>, "OwnerId", never>;
193
+ readonly encryptionKey: import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("../Type.ts").ObjectTagError<"Uint8Array">, null, import("../Type.ts").ObjectTagError<"Uint8Array">, never, Uint8Array<ArrayBufferLike>, true>, "Entropy", never>, "Length32", import("../Type.ts").LengthError<32>>, "EncryptionKey", never>, "OwnerEncryptionKey", never>;
194
+ readonly writeKey: import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("../Type.ts").ObjectTagError<"Uint8Array">, null, import("../Type.ts").ObjectTagError<"Uint8Array">, never, Uint8Array<ArrayBufferLike>, true>, "Entropy", never>, "Length16", import("../Type.ts").LengthError<16>>, "OwnerWriteKey", never>;
195
+ readonly secret: UnionType<readonly [import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("../Type.ts").ObjectTagError<"Uint8Array">, null, import("../Type.ts").ObjectTagError<"Uint8Array">, never, Uint8Array<ArrayBufferLike>, true>, "Entropy", never>, "Length32", import("../Type.ts").LengthError<32>>, "OwnerSecret", never>, import("../Type.ts").LiteralType<null>]>;
196
+ readonly name: UnionType<readonly [import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").BrandType<import("../Type.ts").Type<"String", string, string, import("../Type.ts").TypeOfError<"String">, null, import("../Type.ts").TypeOfError<"String">, never, string, true>, "Trimmed", import("../Type.ts").TrimmedError>, "MinLength1", import("../Type.ts").MinLengthError<1>>, "MaxLength100", import("../Type.ts").MaxLengthError<100>>, import("../Type.ts").LiteralType<null>]>;
197
+ };
198
+ };
199
+ /**
200
+ * Dependency wrapper for {@link SqliteSchema}.
201
+ *
202
+ * @group SQLite
203
+ */
91
204
  export interface SqliteSchemaDep {
92
205
  readonly sqliteSchema: SqliteSchema;
93
206
  }
@@ -103,15 +216,108 @@ export interface SqliteSchemaDep {
103
216
  * 2. The 'id' column output type must extend {@link Id}
104
217
  * 3. Tables cannot use system column names (createdAt, updatedAt, isDeleted)
105
218
  * 4. All column output types must be compatible with SQLite (extend SqliteValue)
219
+ *
220
+ * @group Validation
106
221
  */
107
222
  export type ValidateSchema<S extends EvoluSchema> = ValidateSchemaHasId<S> extends never ? ValidateIdColumnType<S> extends never ? ValidateNoSystemColumns<S> extends never ? ValidateColumnTypes<S> extends never ? S : ValidateColumnTypes<S> : ValidateNoSystemColumns<S> : ValidateIdColumnType<S> : ValidateSchemaHasId<S>;
223
+ /**
224
+ * Defines SQLite indexes with Kysely's index builder.
225
+ *
226
+ * @group SQLite
227
+ */
108
228
  export type IndexesConfig = (create: (indexName: string) => Kysely.CreateIndexBuilder) => ReadonlyArray<Kysely.CreateIndexBuilder<any>>;
229
+ /**
230
+ * Why a message is stored in `evolu_message_quarantine` instead of being
231
+ * applied to its table. Persisted codes: names may change, but numbers must not
232
+ * be reassigned.
233
+ *
234
+ * Quarantine is queryable state, not an error. An application subscribes to a
235
+ * query over `evolu_message_quarantine` to tell the user what is waiting. Each
236
+ * row is one column of a message, so distinct `ownerId` and `timestamp` pairs
237
+ * count messages. `origin` records whether this database stamped the message
238
+ * for a local mutation or received it from sync, see {@link QuarantineOrigin}.
239
+ * `quarantinedAt` is the system time captured for the request that quarantined
240
+ * the row, in milliseconds; it is null for rows written before Evolu recorded
241
+ * it. The clock-drift rules are described in the Timestamp module.
242
+ *
243
+ * ### Example
244
+ *
245
+ * ```ts
246
+ * import {
247
+ * assertType,
248
+ * createQueryBuilder,
249
+ * type Millis,
250
+ * type OwnerIdBytes,
251
+ * type QuarantineOrigin,
252
+ * QuarantineReason,
253
+ * testEvoluSchema,
254
+ * type TimestampBytes,
255
+ * } from "@evolu/common";
256
+ *
257
+ * const createQuery = createQueryBuilder(testEvoluSchema);
258
+ *
259
+ * // Messages waiting in drift quarantine, one row per message.
260
+ * const driftQuarantineQuery = createQuery((db) =>
261
+ * db
262
+ * .selectFrom("evolu_message_quarantine")
263
+ * .select(["ownerId", "timestamp", "origin", "quarantinedAt"])
264
+ * .where("reason", "=", QuarantineReason.TimestampDrift)
265
+ * .distinct(),
266
+ * );
267
+ *
268
+ * assertType<
269
+ * typeof driftQuarantineQuery.Row,
270
+ * {
271
+ * ownerId: OwnerIdBytes;
272
+ * timestamp: TimestampBytes;
273
+ * origin: QuarantineOrigin;
274
+ * quarantinedAt: Millis | null;
275
+ * }
276
+ * >();
277
+ * ```
278
+ *
279
+ * @group Queries
280
+ */
281
+ export declare const QuarantineReason: {
282
+ /**
283
+ * The message has a table or column the current schema does not define. It is
284
+ * applied automatically once a schema update defines them. A received change
285
+ * to a {@link isLocalOnlyTable | local-only} table is also stored here and is
286
+ * never applied.
287
+ */
288
+ readonly Schema: 0;
289
+ /**
290
+ * The message's timestamp exceeded the drift limit when it was stored. It is
291
+ * applied when the database worker starts, once system time comes within the
292
+ * limit of the timestamp.
293
+ */
294
+ readonly TimestampDrift: 1;
295
+ };
296
+ export type QuarantineReason = (typeof QuarantineReason)[keyof typeof QuarantineReason];
297
+ /**
298
+ * Whether a quarantined message was stamped by this database for a local
299
+ * mutation or received from sync. Persisted codes: names may change, but
300
+ * numbers must not be reassigned.
301
+ *
302
+ * @group Queries
303
+ */
304
+ export declare const QuarantineOrigin: {
305
+ readonly LocalMutation: 0;
306
+ readonly ReceivedMessage: 1;
307
+ };
308
+ export type QuarantineOrigin = (typeof QuarantineOrigin)[keyof typeof QuarantineOrigin];
309
+ /**
310
+ * Typed query factory returned by {@link createQueryBuilder}.
311
+ *
312
+ * @group Queries
313
+ */
109
314
  export type CreateQuery<S extends EvoluSchema> = <R extends Row>(queryCallback: (db: Pick<Kysely.Kysely<{
110
315
  [Table in keyof S]: {
111
316
  readonly [Column in keyof S[Table]]: Column extends "id" ? StandardSchemaV1.InferOutput<S[Table][Column]> : StandardSchemaV1.InferOutput<S[Table][Column]> | null;
112
317
  } & SystemColumns;
113
318
  } & {
114
319
  readonly evolu_history: {
320
+ readonly ownerId: OwnerIdBytes;
115
321
  readonly timestamp: TimestampBytes;
116
322
  readonly table: keyof S;
117
323
  readonly id: IdBytes;
@@ -119,11 +325,15 @@ export type CreateQuery<S extends EvoluSchema> = <R extends Row>(queryCallback:
119
325
  readonly value: SqliteValue;
120
326
  };
121
327
  readonly evolu_message_quarantine: {
328
+ readonly ownerId: OwnerIdBytes;
122
329
  readonly timestamp: TimestampBytes;
123
330
  readonly table: string;
124
331
  readonly id: IdBytes;
125
332
  readonly column: string;
126
333
  readonly value: SqliteValue;
334
+ readonly reason: QuarantineReason;
335
+ readonly origin: QuarantineOrigin;
336
+ readonly quarantinedAt: Millis | null;
127
337
  };
128
338
  }>, "selectFrom" | "fn" | "with" | "withRecursive">) => Kysely.SelectQueryBuilder<any, any, R>, options?: SqliteQueryOptions) => Query<S, Kysely.Simplify<R>>;
129
339
  /**
@@ -134,6 +344,8 @@ export type CreateQuery<S extends EvoluSchema> = <R extends Row>(queryCallback:
134
344
  * - `isDeleted`: Soft delete flag created by Evolu and used by the developer to
135
345
  * mark rows as deleted.
136
346
  * - `ownerId`: Represents ownership and logically partitions the database.
347
+ *
348
+ * @group Core
137
349
  */
138
350
  export declare const SystemColumns: ObjectType<{
139
351
  readonly createdAt: typeof DateIso;
@@ -143,6 +355,11 @@ export declare const SystemColumns: ObjectType<{
143
355
  }>;
144
356
  export interface SystemColumns extends InferType<typeof SystemColumns> {
145
357
  }
358
+ /**
359
+ * Kind of a {@link Mutation}: insert, update, or upsert.
360
+ *
361
+ * @group Mutations
362
+ */
146
363
  export type MutationKind = "insert" | "update" | "upsert";
147
364
  /**
148
365
  * Mutation function type. Accepts already-validated values — validation is the
@@ -163,15 +380,32 @@ export type MutationKind = "insert" | "update" | "upsert";
163
380
  * `id` omitted (auto-generated)
164
381
  * - **update**: only `id` required, everything else optional
165
382
  * - **upsert**: like insert but `id` required too
383
+ *
384
+ * @group Mutations
166
385
  */
167
386
  export type Mutation<S extends EvoluSchema, Kind extends MutationKind> = <TableName extends keyof S>(table: TableName, values: MutationValues<S[TableName], Kind>, options?: MutationOptions) => {
168
387
  readonly id: StandardSchemaV1.InferOutput<S[TableName]["id"]>;
169
388
  };
389
+ /**
390
+ * Options accepted by every {@link Mutation}.
391
+ *
392
+ * @group Mutations
393
+ */
170
394
  export interface MutationOptions {
171
395
  /**
172
- * Called after the mutation is completed and the local state is updated.
173
- * Useful for triggering side effects (e.g., notifications, UI updates) after
174
- * insert, update, or upsert.
396
+ * Called after the mutation's changes are stored and subscribed queries
397
+ * reflect them. Useful for follow-up work (e.g., notifications, navigation)
398
+ * after insert, update, or upsert. It never runs when the database is
399
+ * unavailable.
400
+ *
401
+ * Stored does not always mean visible. A change quarantined for
402
+ * {@link QuarantineReason.TimestampDrift} is stored in
403
+ * `evolu_message_quarantine` without changing application rows. `onComplete`
404
+ * still fires after storage commits; no drift error is reported. Applications
405
+ * can subscribe to the quarantine table; those query results reflect the
406
+ * change before `onComplete` runs. See the
407
+ * {@link @evolu/common!"local-first/Timestamp" | Timestamp module} for drift
408
+ * and release behavior.
175
409
  */
176
410
  readonly onComplete?: () => void;
177
411
  /**
@@ -234,22 +468,34 @@ export interface MutationOptions {
234
468
  */
235
469
  readonly ownerId?: OwnerId;
236
470
  }
471
+ /**
472
+ * Database change produced by a {@link Mutation}, attributed to the
473
+ * {@link OwnerId} that owns the row.
474
+ *
475
+ * @group Mutations
476
+ */
237
477
  export interface MutationChange extends DbChange {
238
478
  readonly ownerId: OwnerId;
239
479
  }
240
480
  /**
241
481
  * Derives the expected values type for a mutation from a table's column schemas
242
482
  * and a {@link MutationKind}.
483
+ *
484
+ * @group Mutations
243
485
  */
244
486
  export type MutationValues<T extends TableSchema, M extends MutationKind> = Simplify<M extends "insert" ? InsertValues<T> : M extends "update" ? UpdateValues<T> : UpsertValues<T>>;
245
487
  /**
246
488
  * Insert values: `id` omitted (auto-generated), nullable columns optional,
247
489
  * non-nullable columns required.
490
+ *
491
+ * @group Mutations
248
492
  */
249
493
  export type InsertValues<T extends TableSchema> = Omit<NullableColumnsToOptional<T>, "id">;
250
494
  /**
251
495
  * Update values: `id` required, all other columns optional. Includes
252
496
  * `isDeleted` for soft deletes.
497
+ *
498
+ * @group Mutations
253
499
  */
254
500
  export type UpdateValues<T extends TableSchema> = {
255
501
  readonly id: StandardSchemaV1.InferOutput<T["id"]>;
@@ -261,30 +507,85 @@ export type UpdateValues<T extends TableSchema> = {
261
507
  /**
262
508
  * Upsert values: `id` required, nullable columns optional, non-nullable columns
263
509
  * required. Includes `isDeleted` for soft deletes.
510
+ *
511
+ * @group Mutations
264
512
  */
265
513
  export type UpsertValues<T extends TableSchema> = NullableColumnsToOptional<T> & {
266
514
  readonly isDeleted?: SqliteBoolean;
267
515
  };
516
+ /**
517
+ * Requires an `id` column in every table.
518
+ *
519
+ * @group Validation
520
+ */
268
521
  export type ValidateSchemaHasId<S extends EvoluSchema> = keyof S extends infer TableName ? TableName extends keyof S ? "id" extends keyof S[TableName] ? never : SchemaValidationError<`Table "${TableName & string}" is missing required id column.`> : never : never;
522
+ /**
523
+ * Requires every `id` column output type to extend {@link Id}.
524
+ *
525
+ * @group Validation
526
+ */
269
527
  export type ValidateIdColumnType<S extends EvoluSchema> = keyof S extends infer TableName ? TableName extends keyof S ? "id" extends keyof S[TableName] ? StandardSchemaV1.InferOutput<S[TableName]["id"]> extends Id ? never : SchemaValidationError<`Table "${TableName & string}" id column output type must extend Id. Use id("${TableName & string}") from Evolu Type.`> : never : never : never;
528
+ /**
529
+ * Rejects tables that define system column names.
530
+ *
531
+ * @group Validation
532
+ */
270
533
  export type ValidateNoSystemColumns<S extends EvoluSchema> = keyof S extends infer TableName ? TableName extends keyof S ? keyof S[TableName] extends infer ColumnName ? ColumnName extends keyof S[TableName] ? ColumnName extends "createdAt" | "updatedAt" | "isDeleted" | "ownerId" ? SchemaValidationError<`Table "${TableName & string}" uses system column name "${ColumnName & string}". System columns (createdAt, updatedAt, isDeleted, ownerId) are added automatically.`> : never : never : never : never : never;
534
+ /**
535
+ * Requires every column output type to be compatible with SQLite.
536
+ *
537
+ * @group Validation
538
+ */
271
539
  export type ValidateColumnTypes<S extends EvoluSchema> = keyof S extends infer TableName ? TableName extends keyof S ? keyof S[TableName] extends infer ColumnName ? ColumnName extends keyof S[TableName] ? StandardSchemaV1.InferOutput<S[TableName][ColumnName]> extends SqliteValue | SqliteBoolean ? never : SchemaValidationError<`Table "${TableName & string}" column "${ColumnName & string}" type is not compatible with SQLite. Column types must extend SqliteValue (string, FiniteNumber, Uint8Array, or null).`> : never : never : never : never;
272
- /** Schema validation error that shows clear, readable messages */
540
+ /**
541
+ * Schema validation error that shows clear, readable messages
542
+ *
543
+ * @group Validation
544
+ */
273
545
  export type SchemaValidationError<Message extends string> = CompileTimeError<"Schema", Message>;
274
- /** Makes columns whose output type includes `null` optional. */
546
+ /**
547
+ * Makes columns whose output type includes `null` optional.
548
+ *
549
+ * @group Mutations
550
+ */
275
551
  export type NullableColumnsToOptional<T extends TableSchema> = {
276
552
  readonly [K in RequiredColumnKeys<T>]: StandardSchemaV1.InferOutput<T[K]>;
277
553
  } & {
278
554
  readonly [K in OptionalColumnKeys<T>]?: StandardSchemaV1.InferOutput<T[K]>;
279
555
  };
556
+ /**
557
+ * Column names whose output type excludes `null`.
558
+ *
559
+ * @group Mutations
560
+ */
280
561
  export type RequiredColumnKeys<T extends TableSchema> = {
281
562
  [K in keyof T]: null extends StandardSchemaV1.InferOutput<T[K]> ? never : K;
282
563
  }[keyof T];
564
+ /**
565
+ * Column names whose output type includes `null`.
566
+ *
567
+ * @group Mutations
568
+ */
283
569
  export type OptionalColumnKeys<T extends TableSchema> = {
284
570
  [K in keyof T]: null extends StandardSchemaV1.InferOutput<T[K]> ? K : never;
285
571
  }[keyof T];
572
+ /**
573
+ * Names of {@link SystemColumns}.
574
+ *
575
+ * @group Core
576
+ */
286
577
  export declare const systemColumns: ReadonlySet<string>;
578
+ /**
579
+ * Names of {@link SystemColumns} together with `id`.
580
+ *
581
+ * @group Core
582
+ */
287
583
  export declare const systemColumnsWithId: ReadonlyArray<string>;
584
+ /**
585
+ * Derives {@link SqliteSchema} tables and indexes from an {@link EvoluSchema}.
586
+ *
587
+ * @group SQLite
588
+ */
288
589
  export declare const evoluSchemaToSqliteSchema: <S extends EvoluSchema>(schema: ValidateSchema<S> extends never ? S : ValidateSchema<S>, indexesConfig?: IndexesConfig) => SqliteSchema;
289
590
  /**
290
591
  * Creates a query builder from a {@link EvoluSchema}.
@@ -301,24 +602,14 @@ export declare const evoluSchemaToSqliteSchema: <S extends EvoluSchema>(schema:
301
602
  * import {
302
603
  * assertType,
303
604
  * createQueryBuilder,
304
- * id,
605
+ * testEvoluSchema,
606
+ * type TestTodoId,
305
607
  * NonEmptyTrimmedString100,
306
- * nullOr,
307
608
  * SqliteBoolean,
308
609
  * } from "@evolu/common";
309
610
  *
310
- * const TodoId = id("Todo");
311
- * type TodoId = typeof TodoId.Output;
312
- * const Schema = {
313
- * todo: {
314
- * id: TodoId,
315
- * title: NonEmptyTrimmedString100,
316
- * isCompleted: nullOr(SqliteBoolean),
317
- * },
318
- * };
319
- *
320
611
  * // Create one typed builder per schema and reuse it for every query.
321
- * const createQuery = createQueryBuilder(Schema);
612
+ * const createQuery = createQueryBuilder(testEvoluSchema);
322
613
  * const todosQuery = createQuery((db) =>
323
614
  * db.selectFrom("todo").select(["id", "title", "isCompleted"]),
324
615
  * );
@@ -326,15 +617,38 @@ export declare const evoluSchemaToSqliteSchema: <S extends EvoluSchema>(schema:
326
617
  * assertType<
327
618
  * typeof todosQuery.Row,
328
619
  * {
329
- * id: TodoId;
620
+ * id: TestTodoId;
330
621
  * title: NonEmptyTrimmedString100 | null;
331
622
  * isCompleted: SqliteBoolean | null;
332
623
  * }
333
624
  * >();
334
625
  * ```
626
+ *
627
+ * @group Queries
335
628
  */
336
629
  export declare const createQueryBuilder: <S extends EvoluSchema>(_schema: S) => CreateQuery<S>;
630
+ /**
631
+ * Creates missing tables, columns, and indexes, and drops indexes that the new
632
+ * schema no longer defines.
633
+ *
634
+ * @group SQLite
635
+ */
337
636
  export declare const ensureSqliteSchema: (deps: SqliteDep) => (newSchema: SqliteSchema, currentSchema?: SqliteSchema) => void;
637
+ /**
638
+ * Reads the current application {@link SqliteSchema}, excluding Evolu's internal
639
+ * indexes.
640
+ *
641
+ * @group SQLite
642
+ */
338
643
  export declare const getEvoluSqliteSchema: (deps: SqliteDep) => () => SqliteSchema;
644
+ /**
645
+ * Kysely instance that only compiles queries to SQL. It never executes them;
646
+ * Evolu runs the compiled SQL itself.
647
+ *
648
+ * See [Splitting query building and
649
+ * execution](https://kysely.dev/docs/recipes/splitting-query-building-and-execution).
650
+ *
651
+ * @group Queries
652
+ */
339
653
  export declare const kysely: Kysely.Kysely<unknown>;
340
654
  //# sourceMappingURL=Schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/local-first/Schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAML,aAAa,EACb,KAAK,SAAS,EAGd,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EACj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