@evolu/common 5.4.7 → 6.0.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 (242) hide show
  1. package/README.md +30 -34
  2. package/dist/src/Array.d.ts +17 -0
  3. package/dist/src/Array.d.ts.map +1 -0
  4. package/dist/src/Array.js +12 -0
  5. package/dist/src/Assert.d.ts +68 -0
  6. package/dist/src/Assert.d.ts.map +1 -0
  7. package/dist/src/Assert.js +77 -0
  8. package/dist/src/BigInt.d.ts +20 -0
  9. package/dist/src/BigInt.d.ts.map +1 -0
  10. package/dist/src/BigInt.js +18 -0
  11. package/dist/src/Buffer.d.ts +92 -0
  12. package/dist/src/Buffer.d.ts.map +1 -0
  13. package/dist/src/Buffer.js +62 -0
  14. package/dist/src/Callbacks.d.ts +20 -0
  15. package/dist/src/Callbacks.d.ts.map +1 -0
  16. package/dist/src/Callbacks.js +18 -0
  17. package/dist/src/Console.d.ts +78 -0
  18. package/dist/src/Console.d.ts.map +1 -0
  19. package/dist/src/Console.js +103 -0
  20. package/dist/src/Crypto.d.ts +72 -39
  21. package/dist/src/Crypto.d.ts.map +1 -1
  22. package/dist/src/Crypto.js +89 -54
  23. package/dist/src/Eq.d.ts +97 -0
  24. package/dist/src/Eq.d.ts.map +1 -0
  25. package/dist/src/Eq.js +167 -0
  26. package/dist/src/Error.d.ts +14 -10
  27. package/dist/src/Error.d.ts.map +1 -1
  28. package/dist/src/Error.js +43 -11
  29. package/dist/src/Evolu/Config.d.ts +69 -0
  30. package/dist/src/Evolu/Config.d.ts.map +1 -0
  31. package/dist/src/Evolu/Config.js +9 -0
  32. package/dist/src/Evolu/Db.d.ts +126 -0
  33. package/dist/src/Evolu/Db.d.ts.map +1 -0
  34. package/dist/src/Evolu/Db.js +774 -0
  35. package/dist/src/Evolu/Diff.d.ts +43 -0
  36. package/dist/src/Evolu/Diff.d.ts.map +1 -0
  37. package/dist/src/Evolu/Diff.js +95 -0
  38. package/dist/src/Evolu/Evolu.d.ts +334 -0
  39. package/dist/src/Evolu/Evolu.d.ts.map +1 -0
  40. package/dist/src/Evolu/Evolu.js +434 -0
  41. package/dist/src/Evolu/Internal.d.ts +26 -0
  42. package/dist/src/Evolu/Internal.d.ts.map +1 -0
  43. package/dist/src/Evolu/Internal.js +25 -0
  44. package/dist/src/Evolu/Kysely.d.ts +6 -0
  45. package/dist/src/Evolu/Kysely.d.ts.map +1 -0
  46. package/dist/src/Evolu/Kysely.js +21 -0
  47. package/dist/src/Evolu/Owner.d.ts +155 -0
  48. package/dist/src/Evolu/Owner.d.ts.map +1 -0
  49. package/dist/src/Evolu/Owner.js +126 -0
  50. package/dist/src/Evolu/Platform.d.ts +23 -0
  51. package/dist/src/Evolu/Platform.d.ts.map +1 -0
  52. package/dist/src/Evolu/Platform.js +1 -0
  53. package/dist/src/Evolu/Protocol.d.ts +401 -0
  54. package/dist/src/Evolu/Protocol.d.ts.map +1 -0
  55. package/dist/src/Evolu/Protocol.js +1151 -0
  56. package/dist/src/Evolu/Public.d.ts +18 -0
  57. package/dist/src/Evolu/Public.d.ts.map +1 -0
  58. package/dist/src/Evolu/Public.js +11 -0
  59. package/dist/src/Evolu/PublicKysely.d.ts +148 -0
  60. package/dist/src/Evolu/PublicKysely.d.ts.map +1 -0
  61. package/dist/src/Evolu/PublicKysely.js +185 -0
  62. package/dist/src/Evolu/Query.d.ts +63 -0
  63. package/dist/src/Evolu/Query.d.ts.map +1 -0
  64. package/dist/src/Evolu/Query.js +61 -0
  65. package/dist/src/Evolu/Relay.d.ts +13 -0
  66. package/dist/src/Evolu/Relay.d.ts.map +1 -0
  67. package/dist/src/Evolu/Relay.js +109 -0
  68. package/dist/src/Evolu/Schema.d.ts +201 -0
  69. package/dist/src/Evolu/Schema.d.ts.map +1 -0
  70. package/dist/src/Evolu/Schema.js +150 -0
  71. package/dist/src/Evolu/Storage.d.ts +49 -0
  72. package/dist/src/Evolu/Storage.d.ts.map +1 -0
  73. package/dist/src/Evolu/Storage.js +1111 -0
  74. package/dist/src/Evolu/Sync.d.ts +59 -0
  75. package/dist/src/Evolu/Sync.d.ts.map +1 -0
  76. package/dist/src/Evolu/Sync.js +29 -0
  77. package/dist/src/Evolu/Timestamp.d.ts +106 -0
  78. package/dist/src/Evolu/Timestamp.d.ts.map +1 -0
  79. package/dist/src/Evolu/Timestamp.js +179 -0
  80. package/dist/src/Function.d.ts +54 -0
  81. package/dist/src/Function.d.ts.map +1 -0
  82. package/dist/src/Function.js +38 -0
  83. package/dist/src/ManyToManyMap.d.ts +26 -0
  84. package/dist/src/ManyToManyMap.d.ts.map +1 -0
  85. package/dist/src/ManyToManyMap.js +92 -0
  86. package/dist/src/NanoId.d.ts +27 -0
  87. package/dist/src/NanoId.d.ts.map +1 -0
  88. package/dist/src/NanoId.js +6 -0
  89. package/dist/src/Number.d.ts +42 -0
  90. package/dist/src/Number.d.ts.map +1 -0
  91. package/dist/src/Number.js +55 -0
  92. package/dist/src/Object.d.ts +35 -0
  93. package/dist/src/Object.d.ts.map +1 -0
  94. package/dist/src/Object.js +36 -0
  95. package/dist/src/Order.d.ts +90 -0
  96. package/dist/src/Order.d.ts.map +1 -0
  97. package/dist/src/Order.js +85 -0
  98. package/dist/src/Promise.d.ts +180 -0
  99. package/dist/src/Promise.d.ts.map +1 -0
  100. package/dist/src/Promise.js +176 -0
  101. package/dist/src/Random.d.ts +52 -0
  102. package/dist/src/Random.d.ts.map +1 -0
  103. package/dist/src/Random.js +29 -0
  104. package/dist/src/Ref.d.ts +40 -0
  105. package/dist/src/Ref.d.ts.map +1 -0
  106. package/dist/src/Ref.js +13 -0
  107. package/dist/src/Result.d.ts +421 -0
  108. package/dist/src/Result.d.ts.map +1 -0
  109. package/dist/src/Result.js +357 -0
  110. package/dist/src/Skiplist.d.ts +23 -0
  111. package/dist/src/Skiplist.d.ts.map +1 -0
  112. package/dist/src/Skiplist.js +58 -0
  113. package/dist/src/Sqlite.d.ts +116 -52
  114. package/dist/src/Sqlite.d.ts.map +1 -1
  115. package/dist/src/Sqlite.js +183 -67
  116. package/dist/src/Store.d.ts +45 -8
  117. package/dist/src/Store.d.ts.map +1 -1
  118. package/dist/src/Store.js +33 -17
  119. package/dist/src/String.d.ts +2 -0
  120. package/dist/src/String.d.ts.map +1 -0
  121. package/dist/src/String.js +14 -0
  122. package/dist/src/Time.d.ts +20 -0
  123. package/dist/src/Time.d.ts.map +1 -0
  124. package/dist/src/Time.js +25 -0
  125. package/dist/src/Type.d.ts +1937 -0
  126. package/dist/src/Type.d.ts.map +1 -0
  127. package/dist/src/Type.js +2002 -0
  128. package/dist/src/Types.d.ts +188 -0
  129. package/dist/src/Types.d.ts.map +1 -0
  130. package/dist/src/Types.js +6 -0
  131. package/dist/src/WebSocket.d.ts +112 -0
  132. package/dist/src/WebSocket.d.ts.map +1 -0
  133. package/dist/src/WebSocket.js +139 -0
  134. package/dist/src/Worker.d.ts +44 -0
  135. package/dist/src/Worker.d.ts.map +1 -0
  136. package/dist/src/Worker.js +66 -0
  137. package/dist/src/index.d.ts +24 -11
  138. package/dist/src/index.d.ts.map +1 -1
  139. package/dist/src/index.js +24 -11
  140. package/package.json +29 -38
  141. package/src/Array.ts +39 -0
  142. package/src/Assert.ts +116 -0
  143. package/src/BigInt.ts +29 -0
  144. package/src/Buffer.ts +175 -0
  145. package/src/Callbacks.ts +43 -0
  146. package/src/Console.ts +159 -0
  147. package/src/Crypto.ts +169 -115
  148. package/src/Eq.ts +204 -0
  149. package/src/Error.ts +57 -20
  150. package/src/Evolu/Config.ts +83 -0
  151. package/src/Evolu/Db.ts +1275 -0
  152. package/src/Evolu/Diff.ts +142 -0
  153. package/src/Evolu/Evolu.ts +947 -0
  154. package/src/Evolu/Internal.ts +26 -0
  155. package/src/Evolu/Kysely.ts +38 -0
  156. package/src/Evolu/Owner.ts +296 -0
  157. package/src/Evolu/Platform.ts +27 -0
  158. package/src/Evolu/Protocol.ts +1857 -0
  159. package/src/Evolu/Public.ts +43 -0
  160. package/src/Evolu/PublicKysely.ts +240 -0
  161. package/src/Evolu/Query.ts +167 -0
  162. package/src/Evolu/Relay.ts +142 -0
  163. package/src/Evolu/Schema.ts +417 -0
  164. package/src/Evolu/Storage.ts +1281 -0
  165. package/src/Evolu/Sync.ts +105 -0
  166. package/src/Evolu/Timestamp.ts +311 -0
  167. package/src/Function.ts +58 -0
  168. package/src/ManyToManyMap.ts +140 -0
  169. package/src/NanoId.ts +39 -0
  170. package/src/Number.ts +90 -0
  171. package/src/Object.ts +64 -0
  172. package/src/Order.ts +113 -0
  173. package/src/Promise.ts +295 -0
  174. package/src/Random.ts +68 -0
  175. package/src/Ref.ts +63 -0
  176. package/src/Result.ts +453 -0
  177. package/src/Skiplist.ts +102 -0
  178. package/src/Sqlite.ts +366 -153
  179. package/src/Store.ts +79 -36
  180. package/src/String.ts +10 -0
  181. package/src/Time.ts +36 -0
  182. package/src/Type.ts +3978 -0
  183. package/src/Types.ts +209 -0
  184. package/src/WebSocket.ts +273 -0
  185. package/src/Worker.ts +129 -0
  186. package/src/index.ts +24 -11
  187. package/dist/src/Config.d.ts +0 -56
  188. package/dist/src/Config.d.ts.map +0 -1
  189. package/dist/src/Config.js +0 -39
  190. package/dist/src/Crdt.d.ts +0 -89
  191. package/dist/src/Crdt.d.ts.map +0 -1
  192. package/dist/src/Crdt.js +0 -181
  193. package/dist/src/Db.d.ts +0 -107
  194. package/dist/src/Db.d.ts.map +0 -1
  195. package/dist/src/Db.js +0 -443
  196. package/dist/src/Diff.d.ts +0 -27
  197. package/dist/src/Diff.d.ts.map +0 -1
  198. package/dist/src/Diff.js +0 -84
  199. package/dist/src/Evolu.d.ts +0 -426
  200. package/dist/src/Evolu.d.ts.map +0 -1
  201. package/dist/src/Evolu.js +0 -333
  202. package/dist/src/Model.d.ts +0 -141
  203. package/dist/src/Model.d.ts.map +0 -1
  204. package/dist/src/Model.js +0 -125
  205. package/dist/src/Murmurhash.d.ts +0 -2
  206. package/dist/src/Murmurhash.d.ts.map +0 -1
  207. package/dist/src/Murmurhash.js +0 -60
  208. package/dist/src/Owner.d.ts +0 -33
  209. package/dist/src/Owner.d.ts.map +0 -1
  210. package/dist/src/Owner.js +0 -26
  211. package/dist/src/Platform.d.ts +0 -37
  212. package/dist/src/Platform.d.ts.map +0 -1
  213. package/dist/src/Platform.js +0 -11
  214. package/dist/src/Protobuf.d.ts +0 -81
  215. package/dist/src/Protobuf.d.ts.map +0 -1
  216. package/dist/src/Protobuf.js +0 -92
  217. package/dist/src/Public.d.ts +0 -13
  218. package/dist/src/Public.d.ts.map +0 -1
  219. package/dist/src/Public.js +0 -6
  220. package/dist/src/Socket.d.ts +0 -8
  221. package/dist/src/Socket.d.ts.map +0 -1
  222. package/dist/src/Socket.js +0 -51
  223. package/dist/src/Sql.d.ts +0 -12
  224. package/dist/src/Sql.d.ts.map +0 -1
  225. package/dist/src/Sql.js +0 -30
  226. package/dist/src/Sync.d.ts +0 -70
  227. package/dist/src/Sync.d.ts.map +0 -1
  228. package/dist/src/Sync.js +0 -127
  229. package/src/Config.ts +0 -119
  230. package/src/Crdt.ts +0 -361
  231. package/src/Db.ts +0 -955
  232. package/src/Diff.ts +0 -114
  233. package/src/Evolu.ts +0 -1016
  234. package/src/Model.ts +0 -233
  235. package/src/Murmurhash.ts +0 -70
  236. package/src/Owner.ts +0 -69
  237. package/src/Platform.ts +0 -47
  238. package/src/Protobuf.ts +0 -155
  239. package/src/Public.ts +0 -12
  240. package/src/Socket.ts +0 -83
  241. package/src/Sql.ts +0 -41
  242. package/src/Sync.ts +0 -315
@@ -0,0 +1,201 @@
1
+ import { Kysely, SelectQueryBuilder } from "kysely";
2
+ import { ReadonlyRecord } from "../Object.js";
3
+ import { Result } from "../Result.js";
4
+ import { SqliteBoolean, SqliteQueryOptions, SqliteValue } from "../Sqlite.js";
5
+ import { AnyType, BrandType, InferErrors, InferInput, InferType, MergeObjectTypeErrors, NullableToOptionalProps, ObjectType, OptionalType, Type, TypeError } from "../Type.js";
6
+ import { Simplify } from "../Types.js";
7
+ import { DbSchema } from "./Db.js";
8
+ import { DbIndexesBuilder } from "./Kysely.js";
9
+ import { ShardOwner, SharedOwner } from "./Owner.js";
10
+ import { BinaryId } from "./Protocol.js";
11
+ import { Query, Row } from "./Query.js";
12
+ import { BinaryTimestamp } from "./Timestamp.js";
13
+ /**
14
+ * Defines the schema of an Evolu database.
15
+ *
16
+ * - Each top-level key represents a table name.
17
+ * - The value for each table name is a record of column names mapped to their
18
+ * respective data types, defined by {@link Type}.
19
+ * - Each table must include a mandatory `id` column of type {@link Id}.
20
+ * - No table may contain {@link DefaultColumns}.
21
+ *
22
+ * Table schema defines columns that are required for table rows. For not
23
+ * required columns, use {@link nullOr}.
24
+ *
25
+ * ### Example
26
+ *
27
+ * ```ts
28
+ * const TodoId = id("Todo");
29
+ * type TodoId = typeof TodoId.Type;
30
+ *
31
+ * const TodoCategoryId = id("TodoCategory");
32
+ * type TodoCategoryId = typeof TodoCategoryId.Type;
33
+ *
34
+ * const NonEmptyString50 = maxLength(50)(NonEmptyString);
35
+ * type NonEmptyString50 = typeof NonEmptyString50.Type;
36
+ *
37
+ * // Database schema.
38
+ * const Schema = {
39
+ * todo: {
40
+ * id: TodoId,
41
+ * title: NonEmptyString1000,
42
+ * isCompleted: nullable(SqliteBoolean),
43
+ * categoryId: nullable(TodoCategoryId),
44
+ * },
45
+ * todoCategory: {
46
+ * id: TodoCategoryId,
47
+ * name: NonEmptyString50,
48
+ * json: nullable(SomeJson),
49
+ * },
50
+ * };
51
+ * ```
52
+ */
53
+ export type EvoluSchema = ReadonlyRecord<string, ReadonlyRecord<string, Type<any, any, any, any, any>> & {
54
+ readonly id: Type<any, any, any, any, any>;
55
+ }>;
56
+ export type CreateQuery<S extends EvoluSchema> = <R extends Row>(queryCallback: (db: Pick<Kysely<{
57
+ [Table in keyof S]: {
58
+ readonly [Column in keyof S[Table]]: Column extends "id" | "createdAt" | "updatedAt" ? InferType<S[Table][Column]> : InferType<S[Table][Column]> | null;
59
+ } & DefaultColumns;
60
+ } & {
61
+ readonly evolu_history: {
62
+ readonly timestamp: BinaryTimestamp;
63
+ readonly table: keyof S;
64
+ readonly row: BinaryId;
65
+ readonly column: string;
66
+ readonly value: SqliteValue;
67
+ };
68
+ }>, "selectFrom" | "fn" | "with" | "withRecursive">) => SelectQueryBuilder<any, any, R>, options?: SqliteQueryOptions) => Query<Simplify<R>>;
69
+ export declare const DefaultColumns: ObjectType<{
70
+ createdAt: BrandType<Type<"String", string, string, import("../Type.js").StringError, string, import("../Type.js").StringError>, "DateIso", import("../Type.js").DateIsoStringError, import("../Type.js").StringError>;
71
+ updatedAt: BrandType<Type<"String", string, string, import("../Type.js").StringError, string, import("../Type.js").StringError>, "DateIso", import("../Type.js").DateIsoStringError, import("../Type.js").StringError>;
72
+ isDeleted: import("../Type.js").UnionType<[Type<"Null", null, null, import("../Type.js").NullError, null, import("../Type.js").NullError>, import("../Type.js").TransformType<Type<"Boolean", boolean, boolean, import("../Type.js").BooleanError, boolean, import("../Type.js").BooleanError>, import("../Type.js").UnionType<[import("../Type.js").LiteralType<0>, import("../Type.js").LiteralType<1>]>, never>]>;
73
+ }>;
74
+ export type DefaultColumns = typeof DefaultColumns.Type;
75
+ /**
76
+ * Valid {@link EvoluSchema}.
77
+ *
78
+ * - Table and column names must be Base64Url strings.
79
+ * - Each table must include an `id` column of type {@link Id}.
80
+ * - Default column names (`createdAt`, `updatedAt`, `isDeleted`) are not allowed.
81
+ */
82
+ export declare const ValidEvoluSchema: BrandType<import("../Type.js").RecordType<"Brand", string & import("../Types.js").Brand<"Base64Url"> & import("../Types.js").Brand<"MaxLength256">, string, import("../Type.js").MaxLengthError<256>, string & import("../Types.js").Brand<"Base64Url">, import("../Type.js").StringError | import("../Type.js").RegexError<"Base64Url">, import("../Type.js").ObjectWithRecordType<{
83
+ id: Type<"EvoluType", AnyType, AnyType, import("../Type.js").EvoluTypeError, AnyType, import("../Type.js").EvoluTypeError>;
84
+ }, "Brand", string & import("../Types.js").Brand<"Base64Url"> & import("../Types.js").Brand<"MaxLength256">, string, import("../Type.js").MaxLengthError<256>, string & import("../Types.js").Brand<"Base64Url">, import("../Type.js").StringError | import("../Type.js").RegexError<"Base64Url">, Type<"Unknown", unknown, unknown, never, unknown, never>>>, "ValidEvoluSchema", ValidEvoluSchemaError, import("../Type.js").RecordError<import("../Type.js").MaxLengthError<256>, import("../Type.js").ObjectWithRecordError<{
85
+ id: import("../Type.js").EvoluTypeError;
86
+ }, import("../Type.js").MaxLengthError<256>, never>> | import("../Type.js").RecordError<import("../Type.js").StringError | import("../Type.js").RegexError<"Base64Url">, import("../Type.js").ObjectWithRecordError<{
87
+ id: import("../Type.js").EvoluTypeError;
88
+ }, import("../Type.js").StringError | import("../Type.js").RegexError<"Base64Url">, never>>>;
89
+ export type ValidEvoluSchema = typeof ValidEvoluSchema.Type;
90
+ export interface ValidEvoluSchemaError extends TypeError<"ValidEvoluSchema"> {
91
+ readonly reason: {
92
+ kind: "DefaultColumnError";
93
+ tableName: string;
94
+ columnName: string;
95
+ };
96
+ }
97
+ /**
98
+ * Asserts that the given value is {@link ValidEvoluSchema}.
99
+ *
100
+ * Throws an error if the value is not a valid Evolu schema.
101
+ */
102
+ export declare const assertValidEvoluSchema: (value: unknown) => ValidEvoluSchema;
103
+ export declare const validEvoluSchemaToDbSchema: (validEvoluSchema: ValidEvoluSchema, indexes?: DbIndexesBuilder) => DbSchema;
104
+ export type MutationKind = "insert" | "update" | "upsert";
105
+ export type Mutation<S extends EvoluSchema, Kind extends MutationKind> = <TableName extends keyof S>(table: TableName, props: InferInput<ObjectType<MutationMapping<S[TableName], Kind>>>, options?: MutationOptions) => Result<{
106
+ readonly id: S[TableName]["id"]["Type"];
107
+ }, ValidMutationSizeError | MergeObjectTypeErrors<ObjectType<MutationMapping<S[TableName], Kind>>>>;
108
+ export type MutationMapping<P extends Record<string, AnyType>, M extends MutationKind> = M extends "insert" ? InsertableProps<P> : M extends "update" ? UpdateableProps<P> : UpsertableProps<P>;
109
+ export interface MutationOptions {
110
+ readonly onComplete?: () => void;
111
+ /**
112
+ * Only validate, don't mutate.
113
+ *
114
+ * For example, `onChange` handler can call `insert`/`update`/`upsert` with
115
+ * `onlyValidate: true`.
116
+ */
117
+ readonly onlyValidate?: boolean;
118
+ /**
119
+ * The owner to use for this mutation. Can be a {@link ShardOwner} for sharding
120
+ * app data or a {@link SharedOwner} for collaborative write access. If
121
+ * omitted, defaults to the app's {@link AppOwner}.
122
+ */
123
+ readonly owner?: ShardOwner | SharedOwner;
124
+ }
125
+ /**
126
+ * Evolu has to limit the maximum mutation size. Otherwise, sync couldn't use
127
+ * the {@link maxProtocolMessageRangesSize}. The max size is 640KB in bytes,
128
+ * measured via MessagePack. Evolu Protocol DbChange will be smaller thanks to
129
+ * various optimizations.
130
+ */
131
+ export declare const maxMutationSize = 655360;
132
+ export interface ValidMutationSizeError extends TypeError<"ValidMutationSize"> {
133
+ }
134
+ export declare const formatValidMutationSizeError: import("../Type.js").TypeErrorFormatter<ValidMutationSizeError>;
135
+ export type ValidMutationSize<Props extends Record<string, AnyType>> = BrandType<ObjectType<Props>, "ValidMutationSize", ValidMutationSizeError, InferErrors<ObjectType<Props>>>;
136
+ /**
137
+ * Type Factory to create insertable {@link Type}. It makes nullable Types
138
+ * optional, omits Id, and ensures the {@link maxMutationSize}.
139
+ *
140
+ * ### Example
141
+ *
142
+ * ```ts
143
+ * const InsertableTodo = insertable(Schema.todo);
144
+ * type InsertableTodo = typeof InsertableTodo.Type;
145
+ * const todo = InsertableTodo.from({ title });
146
+ * if (!todo.ok) return; // handle errors
147
+ * ```
148
+ */
149
+ export declare const insertable: <Props extends Record<string, AnyType>>(props: Props) => ValidMutationSize<InsertableProps<Props>>;
150
+ export type InsertableProps<Props extends Record<string, AnyType>> = Omit<NullableToOptionalProps<Props>, "id">;
151
+ export type Insertable<Props extends Record<string, AnyType>> = InferInput<ObjectType<InsertableProps<Props>>>;
152
+ /**
153
+ * Type Factory to create updateable {@link Type}. It makes everything except for
154
+ * the `id` column partial (i.e. optional) and ensures the
155
+ * {@link maxMutationSize}.
156
+ *
157
+ * ### Example
158
+ *
159
+ * ```ts
160
+ * const UpdateableTodo = updateable(Schema.todo);
161
+ * type UpdateableTodo = typeof UpdateableTodo.Type;
162
+ *
163
+ * // `id` is required; all other fields are optional.
164
+ * const todoResult = UpdateableTodo.from({
165
+ * id: "123",
166
+ * title: "New Title",
167
+ * });
168
+ * if (!todo.ok) return; // handle errors
169
+ * ```
170
+ */
171
+ export declare const updateable: <Props extends Record<string, AnyType>>(props: Props) => ValidMutationSize<UpdateableProps<Props>>;
172
+ export type UpdateableProps<Props extends Record<string, AnyType>> = {
173
+ [K in keyof Props]: K extends "id" ? Props[K] : OptionalType<Props[K]>;
174
+ } & {
175
+ isDeleted: OptionalType<typeof SqliteBoolean>;
176
+ };
177
+ export type Updateable<Props extends Record<string, AnyType>> = InferInput<ObjectType<UpdateableProps<Props>>>;
178
+ /**
179
+ * Type Factory to create upsertable Type. It makes nullable Types optional and
180
+ * ensures the {@link maxMutationSize}.
181
+ *
182
+ * ### Example
183
+ *
184
+ * ```ts
185
+ * const UpsertableTodo = upsertable(Schema.todo);
186
+ * type UpsertableTodo = typeof UpsertableTodo.Type;
187
+ * const todo = UpsertableTodo.from({ id, title });
188
+ * if (!todo.ok) return; // handle errors
189
+ * ```
190
+ */
191
+ export declare const upsertable: <Props extends Record<string, AnyType>>(props: Props) => ValidMutationSize<UpsertableProps<Props>>;
192
+ export type UpsertableProps<Props extends Record<string, AnyType>> = NullableToOptionalProps<Props>;
193
+ export type Upsertable<Props extends Record<string, AnyType>> = InferInput<ObjectType<UpsertableProps<Props>>>;
194
+ export type InferEvoluSchemaError<S extends EvoluSchema> = {
195
+ [Table in keyof S]: InferMutationTypeErrors<S[Table]>;
196
+ }[keyof S];
197
+ export type InferMutationTypeErrors<T extends Record<string, AnyType>> = InferColumnErrors<T, "insert"> | InferColumnErrors<T, "update"> | InferColumnErrors<T, "upsert">;
198
+ export type InferColumnErrors<T extends Record<string, AnyType>, M extends MutationKind> = {
199
+ [Column in keyof MutationMapping<T, M>]: InferErrors<MutationMapping<T, M>[Column]>;
200
+ }[keyof MutationMapping<T, M>];
201
+ //# sourceMappingURL=Schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAA8B,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAW,MAAM,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,OAAO,EAEP,SAAS,EAKT,WAAW,EACX,UAAU,EACV,SAAS,EACT,qBAAqB,EAErB,uBAAuB,EAGvB,UAAU,EAGV,YAAY,EAEZ,IAAI,EACJ,SAAS,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAW,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAiB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAY,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAEL,QAAQ,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,CACtC,MAAM,EACN,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,C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B,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC9B,iBAAiB,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC9B,iBAAiB,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEnC,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,YAAY,IACpB;KACD,MAAM,IAAI,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAClD,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAC9B;CACF,CAAC,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,150 @@
1
+ import { pack } from "msgpackr";
2
+ import { mapObject, objectToEntries } from "../Object.js";
3
+ import { err, ok } from "../Result.js";
4
+ import { SqliteBoolean } from "../Sqlite.js";
5
+ import { brand, createTypeErrorFormatter, DateIsoString, EvoluType, nullableToOptional, nullOr, object, omit, optional, record, Unknown, } from "../Type.js";
6
+ import { createIndexes } from "./Kysely.js";
7
+ import { Base64Url256, } from "./Protocol.js";
8
+ export const DefaultColumns = object({
9
+ createdAt: DateIsoString,
10
+ updatedAt: DateIsoString,
11
+ isDeleted: nullOr(SqliteBoolean),
12
+ });
13
+ const isDefaultColumnName = (value) => value === "createdAt" || value === "updatedAt" || value === "isDeleted";
14
+ /**
15
+ * Valid {@link EvoluSchema}.
16
+ *
17
+ * - Table and column names must be Base64Url strings.
18
+ * - Each table must include an `id` column of type {@link Id}.
19
+ * - Default column names (`createdAt`, `updatedAt`, `isDeleted`) are not allowed.
20
+ */
21
+ export const ValidEvoluSchema = brand("ValidEvoluSchema", record(Base64Url256, object({ id: EvoluType }, record(Base64Url256, Unknown))), (value) => {
22
+ for (const tableName in value) {
23
+ for (const columnName in value[tableName]) {
24
+ if (isDefaultColumnName(columnName)) {
25
+ return err({
26
+ type: "ValidEvoluSchema",
27
+ value,
28
+ reason: {
29
+ kind: "DefaultColumnError",
30
+ tableName,
31
+ columnName,
32
+ },
33
+ });
34
+ }
35
+ }
36
+ }
37
+ return ok(value);
38
+ });
39
+ /**
40
+ * Asserts that the given value is {@link ValidEvoluSchema}.
41
+ *
42
+ * Throws an error if the value is not a valid Evolu schema.
43
+ */
44
+ export const assertValidEvoluSchema = (value) => {
45
+ const validEvoluSchema = ValidEvoluSchema.fromUnknown(value);
46
+ if (!validEvoluSchema.ok) {
47
+ const message = formatValidEvoluSchemaError(validEvoluSchema.error);
48
+ throw new Error(`Invalid Evolu schema: ${message}`);
49
+ }
50
+ return validEvoluSchema.value;
51
+ };
52
+ const formatValidEvoluSchemaError = (error) => {
53
+ if (error.type === "Record") {
54
+ if (error.reason.kind === "Key") {
55
+ return `The table "${error.reason.key}" has invalid name. A table name must be Base64Url256 string (A-Z, a-z, 0-9, -, _).`;
56
+ }
57
+ if (error.reason.kind === "Value" &&
58
+ error.reason.error.reason.kind === "Props" &&
59
+ error.reason.error.reason.errors.id?.type === "EvoluType") {
60
+ return `The table "${error.reason.key}" has invalid ID column. Check examples.`;
61
+ }
62
+ if (error.reason.kind === "Value" &&
63
+ error.reason.error.reason.kind === "IndexKey") {
64
+ return `The table "${error.reason.key}" has invalid column name "${error.reason.error.reason.key}". A column name must be Base64Url256 string (A-Z, a-z, 0-9, -, _).`;
65
+ }
66
+ }
67
+ if (error.type === "ValidEvoluSchema") {
68
+ return `The table "${error.reason.tableName}" uses reserved column name "${error.reason.columnName}". Reserved column names are: createdAt, updatedAt, isDeleted.`;
69
+ }
70
+ return JSON.stringify(error, null, 2);
71
+ };
72
+ export const validEvoluSchemaToDbSchema = (validEvoluSchema, indexes) => {
73
+ const tables = objectToEntries(validEvoluSchema).map(([tableName, table]) => ({
74
+ name: tableName,
75
+ columns: objectToEntries(table)
76
+ .filter(([k]) => k !== "id")
77
+ .map(([k]) => k),
78
+ }));
79
+ return {
80
+ tables,
81
+ indexes: createIndexes(indexes),
82
+ };
83
+ };
84
+ /**
85
+ * Evolu has to limit the maximum mutation size. Otherwise, sync couldn't use
86
+ * the {@link maxProtocolMessageRangesSize}. The max size is 640KB in bytes,
87
+ * measured via MessagePack. Evolu Protocol DbChange will be smaller thanks to
88
+ * various optimizations.
89
+ */
90
+ export const maxMutationSize = 655360;
91
+ const validMutationSize = (type) => brand("ValidMutationSize", type, (value) => pack(value).byteLength <= maxMutationSize
92
+ ? ok(value)
93
+ : err({ type: "ValidMutationSize", value }));
94
+ export const formatValidMutationSizeError = createTypeErrorFormatter((error) => `The mutation size exceeds the maximum limit of ${maxMutationSize} bytes. The provided mutation has a size of ${pack(error.value).byteLength} bytes.`);
95
+ /**
96
+ * Type Factory to create insertable {@link Type}. It makes nullable Types
97
+ * optional, omits Id, and ensures the {@link maxMutationSize}.
98
+ *
99
+ * ### Example
100
+ *
101
+ * ```ts
102
+ * const InsertableTodo = insertable(Schema.todo);
103
+ * type InsertableTodo = typeof InsertableTodo.Type;
104
+ * const todo = InsertableTodo.from({ title });
105
+ * if (!todo.ok) return; // handle errors
106
+ * ```
107
+ */
108
+ export const insertable = (props) => {
109
+ const optionalNullable = nullableToOptional(props);
110
+ const withoutId = omit(optionalNullable, "id");
111
+ return validMutationSize(withoutId);
112
+ };
113
+ /**
114
+ * Type Factory to create updateable {@link Type}. It makes everything except for
115
+ * the `id` column partial (i.e. optional) and ensures the
116
+ * {@link maxMutationSize}.
117
+ *
118
+ * ### Example
119
+ *
120
+ * ```ts
121
+ * const UpdateableTodo = updateable(Schema.todo);
122
+ * type UpdateableTodo = typeof UpdateableTodo.Type;
123
+ *
124
+ * // `id` is required; all other fields are optional.
125
+ * const todoResult = UpdateableTodo.from({
126
+ * id: "123",
127
+ * title: "New Title",
128
+ * });
129
+ * if (!todo.ok) return; // handle errors
130
+ * ```
131
+ */
132
+ export const updateable = (props) => {
133
+ const propsWithIsDeleted = { ...props, isDeleted: SqliteBoolean };
134
+ const updateableProps = mapObject(propsWithIsDeleted, (value, key) => key === "id" ? value : optional(value));
135
+ return validMutationSize(object(updateableProps));
136
+ };
137
+ /**
138
+ * Type Factory to create upsertable Type. It makes nullable Types optional and
139
+ * ensures the {@link maxMutationSize}.
140
+ *
141
+ * ### Example
142
+ *
143
+ * ```ts
144
+ * const UpsertableTodo = upsertable(Schema.todo);
145
+ * type UpsertableTodo = typeof UpsertableTodo.Type;
146
+ * const todo = UpsertableTodo.from({ id, title });
147
+ * if (!todo.ok) return; // handle errors
148
+ * ```
149
+ */
150
+ export const upsertable = (props) => validMutationSize(nullableToOptional(props));
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Evolu Storage for SQLite
3
+ *
4
+ * Evolu uses a Skiplist, which leverages SQLite indexes. The core logic is
5
+ * implemented in SQL, so it doesn't have to make roundtrips to the DB.
6
+ *
7
+ * The ideal storage for a Relay should use a similar architecture to
8
+ * [strfry](https://github.com/hoytech/strfry) (a KV storage), but with Skiplist
9
+ * to ensure that insertion order doesn't matter (local-first apps can often
10
+ * write in the past.)
11
+ *
12
+ * The ideal client implementation should probably use the SQLite extension
13
+ * instead of SQL or even a KV storage, when such a thing for browsers/native
14
+ * will exist and will be faster than SQLite.
15
+ *
16
+ * # Scaling
17
+ *
18
+ * The load can be distributed by deploying multiple relays, synchronized with
19
+ * each other, if necessary. One relay should handle hundreds of thousands of
20
+ * users, and when it goes down, nothing happens, because it will be
21
+ * synchronized later.
22
+ *
23
+ * @module
24
+ */
25
+ import { RandomDep } from "../Random.js";
26
+ import { Result } from "../Result.js";
27
+ import { SqliteDep, SqliteError } from "../Sqlite.js";
28
+ import { NonNegativeInt } from "../Type.js";
29
+ import { BinaryOwnerId, Storage } from "./Protocol.js";
30
+ import { BinaryTimestamp } from "./Timestamp.js";
31
+ /** Common interface for both client and relay SQLite storages. */
32
+ export interface SqliteStorageBase {
33
+ readonly insertTimestamp: (ownerId: BinaryOwnerId, timestamp: BinaryTimestamp) => Result<void, SqliteError>;
34
+ readonly getSize: Storage["getSize"];
35
+ readonly fingerprint: Storage["fingerprint"];
36
+ readonly fingerprintRanges: Storage["fingerprintRanges"];
37
+ readonly findLowerBound: Storage["findLowerBound"];
38
+ readonly iterate: Storage["iterate"];
39
+ }
40
+ export interface SqliteStorageBaseDep {
41
+ readonly storage: SqliteStorageBase;
42
+ }
43
+ export type SqliteStorageDeps = SqliteDep & RandomDep;
44
+ export interface CreateSqliteStorageBaseOptions {
45
+ onStorageError: (error: SqliteError) => void;
46
+ }
47
+ export declare const createSqliteStorageBase: (deps: SqliteStorageDeps) => (options: CreateSqliteStorageBaseOptions) => Result<SqliteStorageBase, SqliteError>;
48
+ export declare const getTimestampByIndex: (deps: SqliteDep) => (ownerId: BinaryOwnerId, index: NonNegativeInt) => Result<BinaryTimestamp, SqliteError>;
49
+ //# sourceMappingURL=Storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAM,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAO,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAe,cAAc,EAAe,MAAM,YAAY,CAAC;AAGtE,OAAO,EACL,aAAa,EAQb,OAAO,EAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAwB,MAAM,gBAAgB,CAAC;AAEvE,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,eAAe,EAAE,CACxB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,eAAe,KACvB,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAE/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,aAA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