@evolu/common 6.0.1-preview.2 → 6.0.1-preview.21

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 (154) hide show
  1. package/dist/src/Assert.d.ts +6 -3
  2. package/dist/src/Assert.d.ts.map +1 -1
  3. package/dist/src/Assert.js +7 -4
  4. package/dist/src/Brand.d.ts +75 -0
  5. package/dist/src/Brand.d.ts.map +1 -0
  6. package/dist/src/Brand.js +1 -0
  7. package/dist/src/Buffer.d.ts +1 -1
  8. package/dist/src/Buffer.d.ts.map +1 -1
  9. package/dist/src/Buffer.js +1 -1
  10. package/dist/src/CallbackRegistry.d.ts +53 -0
  11. package/dist/src/CallbackRegistry.d.ts.map +1 -0
  12. package/dist/src/CallbackRegistry.js +25 -0
  13. package/dist/src/Console.d.ts +31 -6
  14. package/dist/src/Console.d.ts.map +1 -1
  15. package/dist/src/Console.js +72 -9
  16. package/dist/src/Crypto.d.ts +61 -34
  17. package/dist/src/Crypto.d.ts.map +1 -1
  18. package/dist/src/Crypto.js +29 -42
  19. package/dist/src/Evolu/Db.d.ts +159 -66
  20. package/dist/src/Evolu/Db.d.ts.map +1 -1
  21. package/dist/src/Evolu/Db.js +300 -705
  22. package/dist/src/Evolu/Diff.d.ts +3 -3
  23. package/dist/src/Evolu/Diff.d.ts.map +1 -1
  24. package/dist/src/Evolu/Diff.js +7 -5
  25. package/dist/src/Evolu/Evolu.d.ts +200 -115
  26. package/dist/src/Evolu/Evolu.d.ts.map +1 -1
  27. package/dist/src/Evolu/Evolu.js +287 -157
  28. package/dist/src/Evolu/Internal.d.ts +0 -2
  29. package/dist/src/Evolu/Internal.d.ts.map +1 -1
  30. package/dist/src/Evolu/Internal.js +0 -2
  31. package/dist/src/Evolu/LocalAuth.d.ts +144 -0
  32. package/dist/src/Evolu/LocalAuth.d.ts.map +1 -0
  33. package/dist/src/Evolu/LocalAuth.js +171 -0
  34. package/dist/src/Evolu/Owner.d.ts +209 -124
  35. package/dist/src/Evolu/Owner.d.ts.map +1 -1
  36. package/dist/src/Evolu/Owner.js +118 -104
  37. package/dist/src/Evolu/Platform.d.ts +9 -7
  38. package/dist/src/Evolu/Platform.d.ts.map +1 -1
  39. package/dist/src/Evolu/Protocol.d.ts +256 -211
  40. package/dist/src/Evolu/Protocol.d.ts.map +1 -1
  41. package/dist/src/Evolu/Protocol.js +558 -359
  42. package/dist/src/Evolu/Public.d.ts +6 -8
  43. package/dist/src/Evolu/Public.d.ts.map +1 -1
  44. package/dist/src/Evolu/Public.js +2 -3
  45. package/dist/src/Evolu/PublicKysely.js +3 -3
  46. package/dist/src/Evolu/Query.d.ts +2 -1
  47. package/dist/src/Evolu/Query.d.ts.map +1 -1
  48. package/dist/src/Evolu/Relay.d.ts +72 -4
  49. package/dist/src/Evolu/Relay.d.ts.map +1 -1
  50. package/dist/src/Evolu/Relay.js +124 -13
  51. package/dist/src/Evolu/Schema.d.ts +129 -73
  52. package/dist/src/Evolu/Schema.d.ts.map +1 -1
  53. package/dist/src/Evolu/Schema.js +169 -89
  54. package/dist/src/Evolu/Storage.d.ts +159 -14
  55. package/dist/src/Evolu/Storage.d.ts.map +1 -1
  56. package/dist/src/Evolu/Storage.js +42 -32
  57. package/dist/src/Evolu/Sync.d.ts +68 -13
  58. package/dist/src/Evolu/Sync.d.ts.map +1 -1
  59. package/dist/src/Evolu/Sync.js +414 -20
  60. package/dist/src/Evolu/Timestamp.d.ts +35 -27
  61. package/dist/src/Evolu/Timestamp.d.ts.map +1 -1
  62. package/dist/src/Evolu/Timestamp.js +27 -18
  63. package/dist/src/ManyToManyMap.d.ts +74 -10
  64. package/dist/src/ManyToManyMap.d.ts.map +1 -1
  65. package/dist/src/ManyToManyMap.js +41 -6
  66. package/dist/src/Number.d.ts +2 -1
  67. package/dist/src/Number.d.ts.map +1 -1
  68. package/dist/src/Random.d.ts +3 -2
  69. package/dist/src/Random.d.ts.map +1 -1
  70. package/dist/src/RefCountedResourceManager.d.ts +119 -0
  71. package/dist/src/RefCountedResourceManager.d.ts.map +1 -0
  72. package/dist/src/RefCountedResourceManager.js +197 -0
  73. package/dist/src/Result.d.ts +176 -51
  74. package/dist/src/Result.d.ts.map +1 -1
  75. package/dist/src/Result.js +30 -241
  76. package/dist/src/Sqlite.d.ts +21 -4
  77. package/dist/src/Sqlite.d.ts.map +1 -1
  78. package/dist/src/Sqlite.js +50 -8
  79. package/dist/src/Task.d.ts +511 -0
  80. package/dist/src/Task.d.ts.map +1 -0
  81. package/dist/src/Task.js +410 -0
  82. package/dist/src/Time.d.ts +59 -0
  83. package/dist/src/Time.d.ts.map +1 -1
  84. package/dist/src/Time.js +87 -4
  85. package/dist/src/Type.d.ts +474 -327
  86. package/dist/src/Type.d.ts.map +1 -1
  87. package/dist/src/Type.js +502 -436
  88. package/dist/src/Types.d.ts +0 -74
  89. package/dist/src/Types.d.ts.map +1 -1
  90. package/dist/src/WebSocket.d.ts +5 -2
  91. package/dist/src/WebSocket.d.ts.map +1 -1
  92. package/dist/src/WebSocket.js +12 -13
  93. package/dist/src/Worker.d.ts +39 -11
  94. package/dist/src/Worker.d.ts.map +1 -1
  95. package/dist/src/Worker.js +22 -4
  96. package/dist/src/index.d.ts +3 -3
  97. package/dist/src/index.d.ts.map +1 -1
  98. package/dist/src/index.js +3 -3
  99. package/package.json +14 -13
  100. package/src/Assert.ts +8 -7
  101. package/src/Brand.ts +75 -0
  102. package/src/Buffer.ts +1 -1
  103. package/src/CallbackRegistry.ts +84 -0
  104. package/src/Console.ts +91 -11
  105. package/src/Crypto.ts +94 -79
  106. package/src/Evolu/Db.ts +528 -1027
  107. package/src/Evolu/Diff.ts +7 -5
  108. package/src/Evolu/Evolu.ts +682 -329
  109. package/src/Evolu/Internal.ts +0 -2
  110. package/src/Evolu/LocalAuth.ts +422 -0
  111. package/src/Evolu/Owner.ts +282 -227
  112. package/src/Evolu/Platform.ts +9 -9
  113. package/src/Evolu/Protocol.ts +788 -640
  114. package/src/Evolu/Public.ts +7 -14
  115. package/src/Evolu/PublicKysely.ts +3 -3
  116. package/src/Evolu/Query.ts +2 -1
  117. package/src/Evolu/Relay.ts +238 -18
  118. package/src/Evolu/Schema.ts +391 -191
  119. package/src/Evolu/Storage.ts +275 -55
  120. package/src/Evolu/Sync.ts +708 -37
  121. package/src/Evolu/Timestamp.ts +38 -35
  122. package/src/ManyToManyMap.ts +127 -24
  123. package/src/Number.ts +2 -6
  124. package/src/Random.ts +3 -2
  125. package/src/RefCountedResourceManager.ts +368 -0
  126. package/src/Result.ts +183 -53
  127. package/src/Sqlite.ts +59 -23
  128. package/src/Task.ts +779 -0
  129. package/src/Time.ts +168 -4
  130. package/src/Type.ts +708 -660
  131. package/src/Types.ts +0 -76
  132. package/src/WebSocket.ts +23 -17
  133. package/src/Worker.ts +72 -23
  134. package/src/index.ts +3 -3
  135. package/dist/src/Callbacks.d.ts +0 -20
  136. package/dist/src/Callbacks.d.ts.map +0 -1
  137. package/dist/src/Callbacks.js +0 -18
  138. package/dist/src/Evolu/Config.d.ts +0 -69
  139. package/dist/src/Evolu/Config.d.ts.map +0 -1
  140. package/dist/src/Evolu/Config.js +0 -9
  141. package/dist/src/Evolu/Kysely.d.ts +0 -6
  142. package/dist/src/Evolu/Kysely.d.ts.map +0 -1
  143. package/dist/src/Evolu/Kysely.js +0 -21
  144. package/dist/src/NanoId.d.ts +0 -27
  145. package/dist/src/NanoId.d.ts.map +0 -1
  146. package/dist/src/NanoId.js +0 -6
  147. package/dist/src/Promise.d.ts +0 -180
  148. package/dist/src/Promise.d.ts.map +0 -1
  149. package/dist/src/Promise.js +0 -176
  150. package/src/Callbacks.ts +0 -43
  151. package/src/Evolu/Config.ts +0 -83
  152. package/src/Evolu/Kysely.ts +0 -38
  153. package/src/NanoId.ts +0 -39
  154. package/src/Promise.ts +0 -295
@@ -5,23 +5,17 @@
5
5
  */
6
6
 
7
7
  export { createEvolu } from "./Evolu.js";
8
- export type {
9
- Evolu,
10
- EvoluConfigWithInitialData,
11
- EvoluDeps,
12
- EvoluError,
13
- } from "./Evolu.js";
8
+ export type { Evolu, EvoluConfig, EvoluDeps, EvoluError } from "./Evolu.js";
14
9
  export * from "./Owner.js";
15
- export { binaryIdToId, idToBinaryId } from "./Protocol.js";
16
- export type { BinaryId } from "./Protocol.js";
10
+ export * from "./LocalAuth.js";
17
11
  export * as kysely from "./PublicKysely.js";
18
12
  export type { InferRow, Query, QueryRows, Row } from "./Query.js";
19
- export { formatValidMutationSizeError } from "./Schema.js";
20
- export type { EvoluSchema, ValidMutationSizeError } from "./Schema.js";
13
+ export type { EvoluSchema } from "./Schema.js";
21
14
  export type {
22
15
  NetworkError,
23
16
  PaymentRequiredError,
24
17
  ServerError,
18
+ SyncOwner,
25
19
  SyncState,
26
20
  SyncStateInitial,
27
21
  SyncStateIsNotSynced,
@@ -29,15 +23,14 @@ export type {
29
23
  SyncStateIsSyncing,
30
24
  } from "./Sync.js";
31
25
  export {
32
- binaryTimestampToTimestamp,
33
26
  Timestamp,
34
- timestampToBinaryTimestamp,
27
+ timestampBytesToTimestamp,
28
+ timestampToTimestampBytes,
35
29
  } from "./Timestamp.js";
36
30
  export type {
37
- BinaryTimestamp,
31
+ TimestampBytes,
38
32
  TimestampCounterOverflowError,
39
33
  TimestampDriftError,
40
- TimestampDuplicateNodeError,
41
34
  TimestampError,
42
35
  TimestampTimeOutOfRangeError,
43
36
  } from "./Timestamp.js";
@@ -65,7 +65,7 @@ export type { NotNull } from "kysely";
65
65
  * from "person"
66
66
  * ```
67
67
  */
68
- // SQL formatting breaks generated SQL for some reason.
68
+ // Kysely expects strict AST.
69
69
  // prettier-ignore
70
70
  export function jsonArrayFrom<O>(
71
71
  expr: SelectQueryBuilderExpression<O>,
@@ -122,7 +122,7 @@ export function jsonArrayFrom<O>(
122
122
  * from "person";
123
123
  * ```
124
124
  */
125
- // SQL formatting breaks generated SQL for some reason.
125
+ // Kysely expects strict AST.
126
126
  // prettier-ignore
127
127
  export function jsonObjectFrom<O>(
128
128
  expr: SelectQueryBuilderExpression<O>,
@@ -172,7 +172,7 @@ export function jsonObjectFrom<O>(
172
172
  * from "person"
173
173
  * ```
174
174
  */
175
- // SQL formatting breaks generated SQL for some reason.
175
+ // Kysely expects strict AST.
176
176
  // prettier-ignore
177
177
  export function jsonBuildObject<O extends Record<string, Expression<unknown>>>(
178
178
  obj: O,
@@ -8,7 +8,8 @@ import {
8
8
  SqliteValue,
9
9
  } from "../Sqlite.js";
10
10
  import { Store, StoreSubscribe } from "../Store.js";
11
- import { Brand, Simplify } from "../Types.js";
11
+ import { Simplify } from "../Types.js";
12
+ import { Brand } from "../Brand.js";
12
13
 
13
14
  /**
14
15
  * A type-safe SQL query.
@@ -1,26 +1,73 @@
1
1
  import { isNonEmptyReadonlyArray } from "../Array.js";
2
- import { ConsoleConfig } from "../Console.js";
3
- import { eqArrayNumber } from "../Eq.js";
4
- import { ok, Result } from "../Result.js";
2
+ import { ConsoleConfig, ConsoleDep } from "../Console.js";
3
+ import { TimingSafeEqualDep } from "../Crypto.js";
4
+ import { LazyValue } from "../Function.js";
5
+ import { err, ok, Result } from "../Result.js";
5
6
  import { sql, SqliteError } from "../Sqlite.js";
6
7
  import { SimpleName } from "../Type.js";
7
- import { OwnerId, WriteKey } from "./Owner.js";
8
- import { EncryptedDbChange, Storage } from "./Protocol.js";
8
+ import { OwnerId, OwnerWriteKey, TransportConfig } from "./Owner.js";
9
+ import { ProtocolInvalidDataError } from "./Protocol.js";
9
10
  import {
10
11
  createSqliteStorageBase,
11
12
  CreateSqliteStorageBaseOptions,
13
+ EncryptedDbChange,
12
14
  SqliteStorageDeps,
15
+ Storage,
13
16
  } from "./Storage.js";
14
- import { timestampToBinaryTimestamp } from "./Timestamp.js";
17
+ import { timestampToTimestampBytes } from "./Timestamp.js";
15
18
 
16
19
  export interface Relay extends Disposable {}
17
20
 
18
21
  export interface RelayConfig extends ConsoleConfig {
22
+ /**
23
+ * The relay name.
24
+ *
25
+ * Implementations can use this for identification purposes (e.g., database
26
+ * file name, logging).
27
+ */
19
28
  readonly name?: SimpleName;
29
+
30
+ /**
31
+ * Optional callback to authenticate an {@link OwnerId} with the relay.
32
+ *
33
+ * If this callback is not provided, all owners are allowed.
34
+ *
35
+ * If provided, the callback receives the OwnerId and should return a promise
36
+ * that resolves to `true` to allow access, or `false` to deny.
37
+ *
38
+ * The callback returns a boolean rather than an error type because error
39
+ * handling and logging are the responsibility of the callback implementation,
40
+ * not the relay. This prevents leaking authentication implementation details
41
+ * into the generic relay interface.
42
+ *
43
+ * OwnerId is used for authentication rather than short-lived tokens because
44
+ * this only controls relay access, not write permissions. Since all data is
45
+ * encrypted on the relay, OwnerId exposure is safe.
46
+ *
47
+ * Owners specify which relays to connect to via {@link TransportConfig}. In
48
+ * WebSocket-based implementations, this check occurs before accepting the
49
+ * connection, with the OwnerId typically extracted from the URL path (e.g.,
50
+ * `ws://localhost:4000/<ownerId>`).
51
+ *
52
+ * ### Example
53
+ *
54
+ * ```ts
55
+ * const relay = await createNodeJsRelay(deps)({
56
+ * authenticateOwner: async (ownerId) => {
57
+ * const isRegistered = await db.checkOwner(ownerId);
58
+ * if (!isRegistered) {
59
+ * logger.warn("Unauthorized access attempt", { ownerId });
60
+ * }
61
+ * return isRegistered;
62
+ * },
63
+ * });
64
+ * ```
65
+ */
66
+ readonly authenticateOwner?: (ownerId: OwnerId) => Promise<boolean>;
20
67
  }
21
68
 
22
- export const createRelayStorage =
23
- (deps: SqliteStorageDeps) =>
69
+ export const createRelaySqliteStorage =
70
+ (deps: SqliteStorageDeps & TimingSafeEqualDep) =>
24
71
  (options: CreateSqliteStorageBaseOptions): Result<Storage, SqliteError> => {
25
72
  const sqliteStorageBase = createSqliteStorageBase(deps)(options);
26
73
  if (!sqliteStorageBase.ok) return sqliteStorageBase;
@@ -53,7 +100,7 @@ export const createRelayStorage =
53
100
  ...sqliteStorageBase.value,
54
101
 
55
102
  /**
56
- * Lazily authorizes the initiator's {@link WriteKey} for the given
103
+ * Lazily authorizes the initiator's {@link OwnerWriteKey} for the given
57
104
  * {@link OwnerId}.
58
105
  *
59
106
  * - If the {@link OwnerId} does not exist, it is created and associated with
@@ -62,11 +109,13 @@ export const createRelayStorage =
62
109
  * stored key.
63
110
  */
64
111
  validateWriteKey: (ownerId, writeKey) => {
65
- const selectWriteKey = deps.sqlite.exec<{ writeKey: WriteKey }>(sql`
66
- select writeKey
67
- from evolu_writeKey
68
- where ownerId = ${ownerId};
69
- `);
112
+ const selectWriteKey = deps.sqlite.exec<{ writeKey: OwnerWriteKey }>(
113
+ sql`
114
+ select writeKey
115
+ from evolu_writeKey
116
+ where ownerId = ${ownerId};
117
+ `,
118
+ );
70
119
  if (!selectWriteKey.ok) {
71
120
  options.onStorageError(selectWriteKey.error);
72
121
  return false;
@@ -87,16 +136,33 @@ export const createRelayStorage =
87
136
  return true;
88
137
  }
89
138
 
90
- return eqArrayNumber(rows[0].writeKey, writeKey);
139
+ return deps.timingSafeEqual(rows[0].writeKey, writeKey);
140
+ },
141
+
142
+ setWriteKey: (ownerId, writeKey) => {
143
+ const upsertWriteKey = deps.sqlite.exec(sql`
144
+ insert into evolu_writeKey (ownerId, writeKey)
145
+ values (${ownerId}, ${writeKey})
146
+ on conflict (ownerId) do update
147
+ set writeKey = excluded.writeKey;
148
+ `);
149
+ if (!upsertWriteKey.ok) {
150
+ options.onStorageError(upsertWriteKey.error);
151
+ return false;
152
+ }
153
+
154
+ return true;
91
155
  },
92
156
 
93
- writeMessages: (ownerId, messages) => {
157
+ // https://eslint.org/docs/latest/rules/require-await#when-not-to-use-it
158
+ // eslint-disable-next-line @typescript-eslint/require-await
159
+ writeMessages: async (ownerId, messages) => {
94
160
  const result = deps.sqlite.transaction(() => {
95
161
  for (const message of messages) {
96
162
  const insertTimestampResult =
97
163
  sqliteStorageBase.value.insertTimestamp(
98
164
  ownerId,
99
- timestampToBinaryTimestamp(message.timestamp),
165
+ timestampToTimestampBytes(message.timestamp),
100
166
  );
101
167
  if (!insertTimestampResult.ok) return insertTimestampResult;
102
168
 
@@ -105,7 +171,7 @@ export const createRelayStorage =
105
171
  values
106
172
  (
107
173
  ${ownerId},
108
- ${timestampToBinaryTimestamp(message.timestamp)},
174
+ ${timestampToTimestampBytes(message.timestamp)},
109
175
  ${message.change}
110
176
  )
111
177
  on conflict do nothing;
@@ -138,5 +204,159 @@ export const createRelayStorage =
138
204
 
139
205
  return result.value.rows[0]?.change;
140
206
  },
207
+
208
+ deleteOwner: (ownerId) => {
209
+ const result = deps.sqlite.transaction(() => {
210
+ const del1 = deps.sqlite.exec(sql`
211
+ delete from evolu_writeKey where ownerId = ${ownerId};
212
+ `);
213
+ if (!del1.ok) return del1;
214
+
215
+ const del2 = deps.sqlite.exec(sql`
216
+ delete from evolu_message where ownerId = ${ownerId};
217
+ `);
218
+ if (!del2.ok) return del2;
219
+
220
+ const del3 = sqliteStorageBase.value.deleteOwner(ownerId);
221
+ if (!del3) return err(null);
222
+
223
+ return ok();
224
+ });
225
+ if (!result.ok) {
226
+ if (result.error) options.onStorageError(result.error);
227
+ return false;
228
+ }
229
+ return true;
230
+ },
141
231
  });
142
232
  };
233
+
234
+ export interface RelayLogger {
235
+ readonly started: (enableLogging: boolean, port: number) => void;
236
+ readonly storageError: (error: unknown) => void;
237
+ readonly upgradeSocketError: (error: Error) => void;
238
+ readonly invalidOrMissingOwnerIdInUrl: (url: string | undefined) => void;
239
+ readonly unauthorizedOwner: (ownerId: OwnerId) => void;
240
+ readonly authenticateOwnerError: (error: unknown) => void;
241
+ readonly connectionEstablished: (totalConnectionCount: number) => void;
242
+ readonly connectionWebSocketError: (error: Error) => void;
243
+ readonly relayOptionSubscribe: (
244
+ ownerId: OwnerId,
245
+ getSubscriberCount: LazyValue<number>,
246
+ ) => void;
247
+ readonly relayOptionUnsubscribe: (
248
+ ownerId: OwnerId,
249
+ getSubscriberCount: LazyValue<number>,
250
+ ) => void;
251
+ readonly relayOptionBroadcast: (
252
+ ownerId: OwnerId,
253
+ broadcastCount: number,
254
+ subscriberCount: number,
255
+ ) => void;
256
+ readonly messageLength: (messageLength: number) => void;
257
+ readonly applyProtocolMessageAsRelayError: (
258
+ error: ProtocolInvalidDataError,
259
+ ) => void;
260
+ readonly responseLength: (responseLength: number) => void;
261
+ readonly applyProtocolMessageAsRelayUnknownError: (error: unknown) => void;
262
+ readonly connectionClosed: (totalConnectionCount: number) => void;
263
+ readonly shuttingDown: () => void;
264
+ readonly webSocketServerDisposed: () => void;
265
+ readonly httpServerDisposed: () => void;
266
+ }
267
+
268
+ export const createRelayLogger = (deps: ConsoleDep): RelayLogger => ({
269
+ started: (enableLogging, port) => {
270
+ deps.console.enabled = true;
271
+ deps.console.log(`Evolu Relay started on port ${port}`);
272
+ deps.console.enabled = enableLogging;
273
+ },
274
+
275
+ storageError: (error) => {
276
+ deps.console.error("[relay]", "storage", error);
277
+ },
278
+
279
+ upgradeSocketError: (error) => {
280
+ deps.console.warn("[relay]", "socket error", { error });
281
+ },
282
+
283
+ invalidOrMissingOwnerIdInUrl: (url) => {
284
+ deps.console.warn("[relay]", "invalid or missing ownerId in URL", { url });
285
+ },
286
+
287
+ unauthorizedOwner: (ownerId) => {
288
+ deps.console.warn("[relay]", "unauthorized owner", { ownerId });
289
+ },
290
+
291
+ authenticateOwnerError: (error) => {
292
+ deps.console.error("[relay]", "authenticateOwner error", error);
293
+ },
294
+
295
+ connectionEstablished: (totalConnectionCount) => {
296
+ deps.console.log("[relay]", "connection", { totalConnectionCount });
297
+ },
298
+
299
+ connectionWebSocketError: (error) => {
300
+ deps.console.error("[relay]", "error", { error });
301
+ },
302
+
303
+ relayOptionSubscribe: (ownerId, getSubscriberCount) => {
304
+ if (deps.console.enabled)
305
+ deps.console.log("[relay]", "subscribe", {
306
+ ownerId,
307
+ subscriberCount: getSubscriberCount(),
308
+ });
309
+ },
310
+
311
+ relayOptionUnsubscribe: (ownerId, getSubscriberCount) => {
312
+ if (deps.console.enabled)
313
+ deps.console.log("[relay]", "unsubscribe", {
314
+ ownerId,
315
+ subscriberCount: getSubscriberCount(),
316
+ });
317
+ },
318
+
319
+ relayOptionBroadcast: (ownerId, broadcastCount, totalSubscribers) => {
320
+ deps.console.log("[relay]", "broadcast", {
321
+ ownerId,
322
+ broadcastCount,
323
+ totalSubscribers,
324
+ });
325
+ },
326
+
327
+ messageLength: (messageLength) => {
328
+ deps.console.log("[relay]", "on message", { messageLength });
329
+ },
330
+
331
+ applyProtocolMessageAsRelayError: (error) => {
332
+ deps.console.error("[relay]", "applyProtocolMessageAsRelay", error);
333
+ },
334
+
335
+ responseLength: (responseLength) => {
336
+ deps.console.log("[relay]", "responseLength", { responseLength });
337
+ },
338
+
339
+ applyProtocolMessageAsRelayUnknownError: (error) => {
340
+ deps.console.error(
341
+ "[relay]",
342
+ "applyProtocolMessageAsRelayUnknownError",
343
+ error,
344
+ );
345
+ },
346
+
347
+ connectionClosed: (totalConnectionCount) => {
348
+ deps.console.log("[relay]", "close", { totalConnectionCount });
349
+ },
350
+
351
+ shuttingDown: () => {
352
+ deps.console.log("Shutting down Evolu Relay...");
353
+ },
354
+
355
+ webSocketServerDisposed: () => {
356
+ deps.console.log("Evolu Relay WebSocketServer disposed");
357
+ },
358
+
359
+ httpServerDisposed: () => {
360
+ deps.console.log("Evolu Relay HTTP server disposed");
361
+ },
362
+ });