@voidhash/mimic-effect 0.0.1 → 0.0.3
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/.turbo/turbo-build.log +99 -14
- package/dist/DocumentManager.cjs +118 -0
- package/dist/DocumentManager.d.cts +45 -0
- package/dist/DocumentManager.d.cts.map +1 -0
- package/dist/DocumentManager.d.mts +45 -0
- package/dist/DocumentManager.d.mts.map +1 -0
- package/dist/DocumentManager.mjs +105 -0
- package/dist/DocumentManager.mjs.map +1 -0
- package/dist/DocumentProtocol.cjs +94 -0
- package/dist/DocumentProtocol.d.cts +113 -0
- package/dist/DocumentProtocol.d.cts.map +1 -0
- package/dist/DocumentProtocol.d.mts +113 -0
- package/dist/DocumentProtocol.d.mts.map +1 -0
- package/dist/DocumentProtocol.mjs +89 -0
- package/dist/DocumentProtocol.mjs.map +1 -0
- package/dist/MimicAuthService.cjs +55 -0
- package/dist/MimicAuthService.d.cts +65 -0
- package/dist/MimicAuthService.d.cts.map +1 -0
- package/dist/MimicAuthService.d.mts +65 -0
- package/dist/MimicAuthService.d.mts.map +1 -0
- package/dist/MimicAuthService.mjs +47 -0
- package/dist/MimicAuthService.mjs.map +1 -0
- package/dist/MimicConfig.cjs +50 -0
- package/dist/MimicConfig.d.cts +99 -0
- package/dist/MimicConfig.d.cts.map +1 -0
- package/dist/MimicConfig.d.mts +99 -0
- package/dist/MimicConfig.d.mts.map +1 -0
- package/dist/MimicConfig.mjs +41 -0
- package/dist/MimicConfig.mjs.map +1 -0
- package/dist/MimicDataStorage.cjs +83 -0
- package/dist/MimicDataStorage.d.cts +113 -0
- package/dist/MimicDataStorage.d.cts.map +1 -0
- package/dist/MimicDataStorage.d.mts +113 -0
- package/dist/MimicDataStorage.d.mts.map +1 -0
- package/dist/MimicDataStorage.mjs +74 -0
- package/dist/MimicDataStorage.mjs.map +1 -0
- package/dist/MimicServer.cjs +230 -0
- package/dist/MimicServer.d.cts +192 -0
- package/dist/MimicServer.d.cts.map +1 -0
- package/dist/MimicServer.d.mts +192 -0
- package/dist/MimicServer.d.mts.map +1 -0
- package/dist/MimicServer.mjs +223 -0
- package/dist/MimicServer.mjs.map +1 -0
- package/dist/PresenceManager.cjs +108 -0
- package/dist/PresenceManager.d.cts +91 -0
- package/dist/PresenceManager.d.cts.map +1 -0
- package/dist/PresenceManager.d.mts +91 -0
- package/dist/PresenceManager.d.mts.map +1 -0
- package/dist/PresenceManager.mjs +95 -0
- package/dist/PresenceManager.mjs.map +1 -0
- package/dist/WebSocketHandler.cjs +366 -0
- package/dist/WebSocketHandler.d.cts +34 -0
- package/dist/WebSocketHandler.d.cts.map +1 -0
- package/dist/WebSocketHandler.d.mts +34 -0
- package/dist/WebSocketHandler.d.mts.map +1 -0
- package/dist/WebSocketHandler.mjs +355 -0
- package/dist/WebSocketHandler.mjs.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/{chunk-C6wwvPpM.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/auth/NoAuth.cjs +43 -0
- package/dist/auth/NoAuth.d.cts +22 -0
- package/dist/auth/NoAuth.d.cts.map +1 -0
- package/dist/auth/NoAuth.d.mts +22 -0
- package/dist/auth/NoAuth.d.mts.map +1 -0
- package/dist/auth/NoAuth.mjs +36 -0
- package/dist/auth/NoAuth.mjs.map +1 -0
- package/dist/errors.cjs +74 -0
- package/dist/errors.d.cts +89 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +89 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +67 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +29 -1227
- package/dist/index.d.cts +12 -795
- package/dist/index.d.mts +12 -795
- package/dist/index.mjs +13 -1162
- package/dist/storage/InMemoryDataStorage.cjs +57 -0
- package/dist/storage/InMemoryDataStorage.d.cts +19 -0
- package/dist/storage/InMemoryDataStorage.d.cts.map +1 -0
- package/dist/storage/InMemoryDataStorage.d.mts +19 -0
- package/dist/storage/InMemoryDataStorage.d.mts.map +1 -0
- package/dist/storage/InMemoryDataStorage.mjs +48 -0
- package/dist/storage/InMemoryDataStorage.mjs.map +1 -0
- package/package.json +3 -3
- package/src/MimicServer.ts +1 -1
- package/tsdown.config.ts +1 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,795 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
import * as Scope from "effect/Scope";
|
|
14
|
-
import * as effect_Types6 from "effect/Types";
|
|
15
|
-
import * as effect_Cause6 from "effect/Cause";
|
|
16
|
-
import { PathInput } from "@effect/platform/HttpRouter";
|
|
17
|
-
|
|
18
|
-
//#region src/DocumentProtocol.d.ts
|
|
19
|
-
declare namespace DocumentProtocol_d_exports {
|
|
20
|
-
export { AuthResultMessage, AuthResultMessageSchema, ErrorMessage, ErrorMessageSchema, OperationSchema, PongMessage, PongMessageSchema, ServerBroadcast, ServerBroadcastSchema, SnapshotMessage, SnapshotMessageSchema, SubmitResult, SubmitResultSchema, Transaction$1 as Transaction, TransactionMessage, TransactionMessageSchema, TransactionSchema };
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Schema for a transaction operation.
|
|
24
|
-
*/
|
|
25
|
-
declare const OperationSchema: Schema.Struct<{
|
|
26
|
-
kind: typeof Schema.String;
|
|
27
|
-
path: typeof Schema.Unknown;
|
|
28
|
-
payload: typeof Schema.Unknown;
|
|
29
|
-
}>;
|
|
30
|
-
/**
|
|
31
|
-
* Schema for a transaction.
|
|
32
|
-
*/
|
|
33
|
-
declare const TransactionSchema: Schema.Struct<{
|
|
34
|
-
id: typeof Schema.String;
|
|
35
|
-
ops: Schema.Array$<Schema.Struct<{
|
|
36
|
-
kind: typeof Schema.String;
|
|
37
|
-
path: typeof Schema.Unknown;
|
|
38
|
-
payload: typeof Schema.Unknown;
|
|
39
|
-
}>>;
|
|
40
|
-
timestamp: typeof Schema.Number;
|
|
41
|
-
}>;
|
|
42
|
-
type Transaction$1 = Schema.Schema.Type<typeof TransactionSchema>;
|
|
43
|
-
/**
|
|
44
|
-
* Schema for a server message that broadcasts a committed transaction.
|
|
45
|
-
*/
|
|
46
|
-
declare const TransactionMessageSchema: Schema.Struct<{
|
|
47
|
-
type: Schema.Literal<["transaction"]>;
|
|
48
|
-
transaction: Schema.Struct<{
|
|
49
|
-
id: typeof Schema.String;
|
|
50
|
-
ops: Schema.Array$<Schema.Struct<{
|
|
51
|
-
kind: typeof Schema.String;
|
|
52
|
-
path: typeof Schema.Unknown;
|
|
53
|
-
payload: typeof Schema.Unknown;
|
|
54
|
-
}>>;
|
|
55
|
-
timestamp: typeof Schema.Number;
|
|
56
|
-
}>;
|
|
57
|
-
version: typeof Schema.Number;
|
|
58
|
-
}>;
|
|
59
|
-
type TransactionMessage = Schema.Schema.Type<typeof TransactionMessageSchema>;
|
|
60
|
-
/**
|
|
61
|
-
* Schema for a server message containing a snapshot.
|
|
62
|
-
*/
|
|
63
|
-
declare const SnapshotMessageSchema: Schema.Struct<{
|
|
64
|
-
type: Schema.Literal<["snapshot"]>;
|
|
65
|
-
state: typeof Schema.Unknown;
|
|
66
|
-
version: typeof Schema.Number;
|
|
67
|
-
}>;
|
|
68
|
-
type SnapshotMessage = Schema.Schema.Type<typeof SnapshotMessageSchema>;
|
|
69
|
-
/**
|
|
70
|
-
* Schema for a server error message.
|
|
71
|
-
*/
|
|
72
|
-
declare const ErrorMessageSchema: Schema.Struct<{
|
|
73
|
-
type: Schema.Literal<["error"]>;
|
|
74
|
-
transactionId: typeof Schema.String;
|
|
75
|
-
reason: typeof Schema.String;
|
|
76
|
-
}>;
|
|
77
|
-
type ErrorMessage = Schema.Schema.Type<typeof ErrorMessageSchema>;
|
|
78
|
-
/**
|
|
79
|
-
* Schema for a pong message.
|
|
80
|
-
*/
|
|
81
|
-
declare const PongMessageSchema: Schema.Struct<{
|
|
82
|
-
type: Schema.Literal<["pong"]>;
|
|
83
|
-
}>;
|
|
84
|
-
type PongMessage = Schema.Schema.Type<typeof PongMessageSchema>;
|
|
85
|
-
/**
|
|
86
|
-
* Schema for authentication result message.
|
|
87
|
-
*/
|
|
88
|
-
declare const AuthResultMessageSchema: Schema.Struct<{
|
|
89
|
-
type: Schema.Literal<["auth_result"]>;
|
|
90
|
-
success: typeof Schema.Boolean;
|
|
91
|
-
error: Schema.optional<typeof Schema.String>;
|
|
92
|
-
}>;
|
|
93
|
-
type AuthResultMessage = Schema.Schema.Type<typeof AuthResultMessageSchema>;
|
|
94
|
-
/**
|
|
95
|
-
* Union of all server broadcast messages.
|
|
96
|
-
*/
|
|
97
|
-
declare const ServerBroadcastSchema: Schema.Union<[Schema.Struct<{
|
|
98
|
-
type: Schema.Literal<["transaction"]>;
|
|
99
|
-
transaction: Schema.Struct<{
|
|
100
|
-
id: typeof Schema.String;
|
|
101
|
-
ops: Schema.Array$<Schema.Struct<{
|
|
102
|
-
kind: typeof Schema.String;
|
|
103
|
-
path: typeof Schema.Unknown;
|
|
104
|
-
payload: typeof Schema.Unknown;
|
|
105
|
-
}>>;
|
|
106
|
-
timestamp: typeof Schema.Number;
|
|
107
|
-
}>;
|
|
108
|
-
version: typeof Schema.Number;
|
|
109
|
-
}>, Schema.Struct<{
|
|
110
|
-
type: Schema.Literal<["error"]>;
|
|
111
|
-
transactionId: typeof Schema.String;
|
|
112
|
-
reason: typeof Schema.String;
|
|
113
|
-
}>]>;
|
|
114
|
-
type ServerBroadcast = Schema.Schema.Type<typeof ServerBroadcastSchema>;
|
|
115
|
-
/**
|
|
116
|
-
* Result of submitting a transaction.
|
|
117
|
-
*/
|
|
118
|
-
declare const SubmitResultSchema: Schema.Union<[Schema.Struct<{
|
|
119
|
-
success: Schema.Literal<[true]>;
|
|
120
|
-
version: typeof Schema.Number;
|
|
121
|
-
}>, Schema.Struct<{
|
|
122
|
-
success: Schema.Literal<[false]>;
|
|
123
|
-
reason: typeof Schema.String;
|
|
124
|
-
}>]>;
|
|
125
|
-
type SubmitResult = Schema.Schema.Type<typeof SubmitResultSchema>;
|
|
126
|
-
declare namespace MimicConfig_d_exports {
|
|
127
|
-
export { MimicServerConfig, MimicServerConfigOptions, MimicServerConfigTag, layer$7 as layer, make$2 as make };
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Configuration for the Mimic server.
|
|
131
|
-
*
|
|
132
|
-
* Note: Authentication and persistence are now handled by injectable services
|
|
133
|
-
* (MimicAuthService and MimicDataStorage) rather than config options.
|
|
134
|
-
*/
|
|
135
|
-
interface MimicServerConfig<TSchema extends Primitive.AnyPrimitive = Primitive.AnyPrimitive> {
|
|
136
|
-
/**
|
|
137
|
-
* The schema defining the document structure.
|
|
138
|
-
*/
|
|
139
|
-
readonly schema: TSchema;
|
|
140
|
-
/**
|
|
141
|
-
* Maximum idle time for a document before it is cleaned up.
|
|
142
|
-
* @default "5 minutes"
|
|
143
|
-
*/
|
|
144
|
-
readonly maxIdleTime: Duration.Duration;
|
|
145
|
-
/**
|
|
146
|
-
* Maximum number of processed transaction IDs to track for deduplication.
|
|
147
|
-
* @default 1000
|
|
148
|
-
*/
|
|
149
|
-
readonly maxTransactionHistory: number;
|
|
150
|
-
/**
|
|
151
|
-
* Heartbeat interval for WebSocket connections.
|
|
152
|
-
* @default "30 seconds"
|
|
153
|
-
*/
|
|
154
|
-
readonly heartbeatInterval: Duration.Duration;
|
|
155
|
-
/**
|
|
156
|
-
* Timeout for heartbeat responses before considering connection dead.
|
|
157
|
-
* @default "10 seconds"
|
|
158
|
-
*/
|
|
159
|
-
readonly heartbeatTimeout: Duration.Duration;
|
|
160
|
-
/**
|
|
161
|
-
* Optional presence schema for ephemeral per-user data.
|
|
162
|
-
* When provided, enables presence features on WebSocket connections.
|
|
163
|
-
* @default undefined (presence disabled)
|
|
164
|
-
*/
|
|
165
|
-
readonly presence: Presence.AnyPresence | undefined;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Options for creating a MimicServerConfig.
|
|
169
|
-
*/
|
|
170
|
-
interface MimicServerConfigOptions<TSchema extends Primitive.AnyPrimitive = Primitive.AnyPrimitive> {
|
|
171
|
-
/**
|
|
172
|
-
* The schema defining the document structure.
|
|
173
|
-
*/
|
|
174
|
-
readonly schema: TSchema;
|
|
175
|
-
/**
|
|
176
|
-
* Maximum idle time for a document before it is cleaned up.
|
|
177
|
-
* @default "5 minutes"
|
|
178
|
-
*/
|
|
179
|
-
readonly maxIdleTime?: DurationInput;
|
|
180
|
-
/**
|
|
181
|
-
* Maximum number of processed transaction IDs to track for deduplication.
|
|
182
|
-
* @default 1000
|
|
183
|
-
*/
|
|
184
|
-
readonly maxTransactionHistory?: number;
|
|
185
|
-
/**
|
|
186
|
-
* Heartbeat interval for WebSocket connections.
|
|
187
|
-
* @default "30 seconds"
|
|
188
|
-
*/
|
|
189
|
-
readonly heartbeatInterval?: DurationInput;
|
|
190
|
-
/**
|
|
191
|
-
* Timeout for heartbeat responses.
|
|
192
|
-
* @default "10 seconds"
|
|
193
|
-
*/
|
|
194
|
-
readonly heartbeatTimeout?: DurationInput;
|
|
195
|
-
/**
|
|
196
|
-
* Optional presence schema for ephemeral per-user data.
|
|
197
|
-
* When provided, enables presence features on WebSocket connections.
|
|
198
|
-
* @default undefined (presence disabled)
|
|
199
|
-
*/
|
|
200
|
-
readonly presence?: Presence.AnyPresence;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Create a MimicServerConfig from options.
|
|
204
|
-
*/
|
|
205
|
-
declare const make$2: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => MimicServerConfig<TSchema>;
|
|
206
|
-
declare const MimicServerConfigTag_base: Context.TagClass<MimicServerConfigTag, "@voidhash/mimic-server-effect/MimicServerConfig", MimicServerConfig<Primitive.AnyPrimitive>>;
|
|
207
|
-
/**
|
|
208
|
-
* Context tag for MimicServerConfig.
|
|
209
|
-
*/
|
|
210
|
-
declare class MimicServerConfigTag extends MimicServerConfigTag_base {}
|
|
211
|
-
/**
|
|
212
|
-
* Create a Layer that provides MimicServerConfig.
|
|
213
|
-
*/
|
|
214
|
-
declare const layer$7: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<MimicServerConfigTag>;
|
|
215
|
-
declare namespace MimicDataStorage_d_exports {
|
|
216
|
-
export { MimicDataStorage, MimicDataStorageTag, StorageDeleteError, StorageError, StorageLoadError, StorageSaveError, layer$6 as layer, layerEffect$1 as layerEffect, make$1 as make };
|
|
217
|
-
}
|
|
218
|
-
declare const StorageLoadError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
219
|
-
readonly _tag: "StorageLoadError";
|
|
220
|
-
} & Readonly<A>;
|
|
221
|
-
/**
|
|
222
|
-
* Error when loading a document from storage fails.
|
|
223
|
-
*/
|
|
224
|
-
declare class StorageLoadError extends StorageLoadError_base<{
|
|
225
|
-
readonly documentId: string;
|
|
226
|
-
readonly cause: unknown;
|
|
227
|
-
}> {
|
|
228
|
-
get message(): string;
|
|
229
|
-
}
|
|
230
|
-
declare const StorageSaveError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
231
|
-
readonly _tag: "StorageSaveError";
|
|
232
|
-
} & Readonly<A>;
|
|
233
|
-
/**
|
|
234
|
-
* Error when saving a document to storage fails.
|
|
235
|
-
*/
|
|
236
|
-
declare class StorageSaveError extends StorageSaveError_base<{
|
|
237
|
-
readonly documentId: string;
|
|
238
|
-
readonly cause: unknown;
|
|
239
|
-
}> {
|
|
240
|
-
get message(): string;
|
|
241
|
-
}
|
|
242
|
-
declare const StorageDeleteError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
243
|
-
readonly _tag: "StorageDeleteError";
|
|
244
|
-
} & Readonly<A>;
|
|
245
|
-
/**
|
|
246
|
-
* Error when deleting a document from storage fails.
|
|
247
|
-
*/
|
|
248
|
-
declare class StorageDeleteError extends StorageDeleteError_base<{
|
|
249
|
-
readonly documentId: string;
|
|
250
|
-
readonly cause: unknown;
|
|
251
|
-
}> {
|
|
252
|
-
get message(): string;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Union of all storage errors.
|
|
256
|
-
*/
|
|
257
|
-
type StorageError = StorageLoadError | StorageSaveError | StorageDeleteError;
|
|
258
|
-
/**
|
|
259
|
-
* Data storage service interface.
|
|
260
|
-
* Implementations can persist documents to various backends (memory, S3, database, etc.)
|
|
261
|
-
*/
|
|
262
|
-
interface MimicDataStorage {
|
|
263
|
-
/**
|
|
264
|
-
* Load a document's state from storage.
|
|
265
|
-
* @param documentId - The unique identifier for the document
|
|
266
|
-
* @returns The document state, or undefined if not found
|
|
267
|
-
*/
|
|
268
|
-
readonly load: (documentId: string) => Effect.Effect<unknown | undefined, StorageLoadError>;
|
|
269
|
-
/**
|
|
270
|
-
* Save a document's state to storage.
|
|
271
|
-
* @param documentId - The unique identifier for the document
|
|
272
|
-
* @param state - The document state to persist
|
|
273
|
-
*/
|
|
274
|
-
readonly save: (documentId: string, state: unknown) => Effect.Effect<void, StorageSaveError>;
|
|
275
|
-
/**
|
|
276
|
-
* Delete a document from storage.
|
|
277
|
-
* @param documentId - The unique identifier for the document
|
|
278
|
-
*/
|
|
279
|
-
readonly delete: (documentId: string) => Effect.Effect<void, StorageDeleteError>;
|
|
280
|
-
/**
|
|
281
|
-
* Transform data after loading from storage.
|
|
282
|
-
* Useful for migrations, decryption, decompression, etc.
|
|
283
|
-
* @param state - The raw state loaded from storage
|
|
284
|
-
* @returns The transformed state
|
|
285
|
-
*/
|
|
286
|
-
readonly onLoad: (state: unknown) => Effect.Effect<unknown>;
|
|
287
|
-
/**
|
|
288
|
-
* Transform/validate data before saving to storage.
|
|
289
|
-
* Useful for encryption, compression, validation, etc.
|
|
290
|
-
* @param state - The state to be saved
|
|
291
|
-
* @returns The transformed state
|
|
292
|
-
*/
|
|
293
|
-
readonly onSave: (state: unknown) => Effect.Effect<unknown>;
|
|
294
|
-
}
|
|
295
|
-
declare const MimicDataStorageTag_base: Context.TagClass<MimicDataStorageTag, "@voidhash/mimic-server-effect/MimicDataStorage", MimicDataStorage>;
|
|
296
|
-
/**
|
|
297
|
-
* Context tag for MimicDataStorage service.
|
|
298
|
-
*/
|
|
299
|
-
declare class MimicDataStorageTag extends MimicDataStorageTag_base {}
|
|
300
|
-
/**
|
|
301
|
-
* Create a MimicDataStorage layer from a storage implementation.
|
|
302
|
-
*/
|
|
303
|
-
declare const layer$6: (storage: MimicDataStorage) => Layer.Layer<MimicDataStorageTag>;
|
|
304
|
-
/**
|
|
305
|
-
* Create a MimicDataStorage layer from an Effect that produces a storage implementation.
|
|
306
|
-
*/
|
|
307
|
-
declare const layerEffect$1: <E, R>(effect: Effect.Effect<MimicDataStorage, E, R>) => Layer.Layer<MimicDataStorageTag, E, R>;
|
|
308
|
-
/**
|
|
309
|
-
* Create a simple storage implementation with minimal configuration.
|
|
310
|
-
*/
|
|
311
|
-
declare const make$1: (options: {
|
|
312
|
-
readonly load: (documentId: string) => Effect.Effect<unknown | undefined, StorageLoadError>;
|
|
313
|
-
readonly save: (documentId: string, state: unknown) => Effect.Effect<void, StorageSaveError>;
|
|
314
|
-
readonly delete?: (documentId: string) => Effect.Effect<void, StorageDeleteError>;
|
|
315
|
-
readonly onLoad?: (state: unknown) => Effect.Effect<unknown>;
|
|
316
|
-
readonly onSave?: (state: unknown) => Effect.Effect<unknown>;
|
|
317
|
-
}) => MimicDataStorage;
|
|
318
|
-
declare namespace DocumentManager_d_exports {
|
|
319
|
-
export { DocumentManager, DocumentManagerTag, layer$5 as layer };
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Service interface for the DocumentManager.
|
|
323
|
-
*/
|
|
324
|
-
interface DocumentManager {
|
|
325
|
-
/**
|
|
326
|
-
* Submit a transaction to a document.
|
|
327
|
-
*/
|
|
328
|
-
readonly submit: (documentId: string, transaction: Transaction.Transaction) => Effect.Effect<SubmitResult>;
|
|
329
|
-
/**
|
|
330
|
-
* Get a snapshot of a document.
|
|
331
|
-
*/
|
|
332
|
-
readonly getSnapshot: (documentId: string) => Effect.Effect<SnapshotMessage>;
|
|
333
|
-
/**
|
|
334
|
-
* Subscribe to broadcasts for a document.
|
|
335
|
-
* Returns a Stream of server broadcasts.
|
|
336
|
-
*/
|
|
337
|
-
readonly subscribe: (documentId: string) => Effect.Effect<Stream.Stream<ServerBroadcast>, never, Scope.Scope>;
|
|
338
|
-
}
|
|
339
|
-
declare const DocumentManagerTag_base: Context.TagClass<DocumentManagerTag, "@voidhash/mimic-server-effect/DocumentManager", DocumentManager>;
|
|
340
|
-
/**
|
|
341
|
-
* Context tag for DocumentManager.
|
|
342
|
-
*/
|
|
343
|
-
declare class DocumentManagerTag extends DocumentManagerTag_base {}
|
|
344
|
-
/**
|
|
345
|
-
* Layer that provides DocumentManager.
|
|
346
|
-
* Requires MimicServerConfigTag and MimicDataStorageTag.
|
|
347
|
-
*/
|
|
348
|
-
declare const layer$5: Layer.Layer<DocumentManagerTag, never, MimicServerConfigTag | MimicDataStorageTag>;
|
|
349
|
-
declare namespace MimicAuthService_d_exports {
|
|
350
|
-
export { AuthHandler, AuthResult, MimicAuthService, MimicAuthServiceTag, layer$4 as layer, layerEffect, layerService, make, makeEffect };
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Result of an authentication attempt.
|
|
354
|
-
*/
|
|
355
|
-
type AuthResult = {
|
|
356
|
-
readonly success: true;
|
|
357
|
-
readonly userId?: string;
|
|
358
|
-
} | {
|
|
359
|
-
readonly success: false;
|
|
360
|
-
readonly error: string;
|
|
361
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* Authentication handler function type.
|
|
364
|
-
* Can be synchronous or return a Promise.
|
|
365
|
-
*/
|
|
366
|
-
type AuthHandler = (token: string) => Promise<AuthResult> | AuthResult;
|
|
367
|
-
/**
|
|
368
|
-
* Authentication service interface.
|
|
369
|
-
* Implementations can authenticate connections using various methods (JWT, API keys, etc.)
|
|
370
|
-
*/
|
|
371
|
-
interface MimicAuthService {
|
|
372
|
-
/**
|
|
373
|
-
* Authenticate a connection using the provided token.
|
|
374
|
-
* @param token - The authentication token provided by the client
|
|
375
|
-
* @returns The authentication result
|
|
376
|
-
*/
|
|
377
|
-
readonly authenticate: (token: string) => Effect.Effect<AuthResult>;
|
|
378
|
-
}
|
|
379
|
-
declare const MimicAuthServiceTag_base: Context.TagClass<MimicAuthServiceTag, "@voidhash/mimic-server-effect/MimicAuthService", MimicAuthService>;
|
|
380
|
-
/**
|
|
381
|
-
* Context tag for MimicAuthService service.
|
|
382
|
-
*/
|
|
383
|
-
declare class MimicAuthServiceTag extends MimicAuthServiceTag_base {}
|
|
384
|
-
/**
|
|
385
|
-
* Create a MimicAuthService layer from an auth handler function.
|
|
386
|
-
*/
|
|
387
|
-
declare const layer$4: (options: {
|
|
388
|
-
readonly authHandler: AuthHandler;
|
|
389
|
-
}) => Layer.Layer<MimicAuthServiceTag>;
|
|
390
|
-
/**
|
|
391
|
-
* Create a MimicAuthService layer from an auth service implementation.
|
|
392
|
-
*/
|
|
393
|
-
declare const layerService: (service: MimicAuthService) => Layer.Layer<MimicAuthServiceTag>;
|
|
394
|
-
/**
|
|
395
|
-
* Create a MimicAuthService layer from an Effect that produces an auth service.
|
|
396
|
-
*/
|
|
397
|
-
declare const layerEffect: <E, R>(effect: Effect.Effect<MimicAuthService, E, R>) => Layer.Layer<MimicAuthServiceTag, E, R>;
|
|
398
|
-
/**
|
|
399
|
-
* Create an auth service from an auth handler function.
|
|
400
|
-
*/
|
|
401
|
-
declare const make: (authHandler: AuthHandler) => MimicAuthService;
|
|
402
|
-
/**
|
|
403
|
-
* Create an auth service from an Effect-based authenticate function.
|
|
404
|
-
*/
|
|
405
|
-
declare const makeEffect: (authenticate: (token: string) => Effect.Effect<AuthResult>) => MimicAuthService;
|
|
406
|
-
declare namespace MimicServer_d_exports {
|
|
407
|
-
export { MimicLayerOptions, MimicWebSocketHandler, documentManagerLayer, handlerLayer, layer$3 as layer, layerHttpLayerRouter, run };
|
|
408
|
-
}
|
|
409
|
-
declare const MimicWebSocketHandler_base: Context.TagClass<MimicWebSocketHandler, "@voidhash/mimic-server-effect/MimicWebSocketHandler", (socket: Socket.Socket, documentId: string) => Effect.Effect<void, unknown>>;
|
|
410
|
-
/**
|
|
411
|
-
* Tag for the WebSocket handler function.
|
|
412
|
-
*/
|
|
413
|
-
declare class MimicWebSocketHandler extends MimicWebSocketHandler_base {}
|
|
414
|
-
/**
|
|
415
|
-
* Options for creating a Mimic server layer.
|
|
416
|
-
*/
|
|
417
|
-
interface MimicLayerOptions<TSchema extends Primitive.AnyPrimitive> {
|
|
418
|
-
/**
|
|
419
|
-
* Base path for document routes (used for path matching).
|
|
420
|
-
* @example "/mimic/todo" - documents accessed at "/mimic/todo/:documentId"
|
|
421
|
-
*/
|
|
422
|
-
readonly basePath?: PathInput;
|
|
423
|
-
/**
|
|
424
|
-
* The schema defining the document structure.
|
|
425
|
-
*/
|
|
426
|
-
readonly schema: TSchema;
|
|
427
|
-
/**
|
|
428
|
-
* Maximum number of processed transaction IDs to track for deduplication.
|
|
429
|
-
* @default 1000
|
|
430
|
-
*/
|
|
431
|
-
readonly maxTransactionHistory?: number;
|
|
432
|
-
/**
|
|
433
|
-
* Optional presence schema for ephemeral per-user data.
|
|
434
|
-
* When provided, enables presence features on WebSocket connections.
|
|
435
|
-
*/
|
|
436
|
-
readonly presence?: Presence.AnyPresence;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Create a Mimic WebSocket handler layer.
|
|
440
|
-
*
|
|
441
|
-
* This layer provides a handler function that can be used with any WebSocket server
|
|
442
|
-
* implementation. The handler takes a socket and document ID and manages the
|
|
443
|
-
* document synchronization.
|
|
444
|
-
*
|
|
445
|
-
* By default, uses in-memory storage and no authentication.
|
|
446
|
-
* Override these by providing MimicDataStorage and MimicAuthService layers.
|
|
447
|
-
*
|
|
448
|
-
* @example
|
|
449
|
-
* ```typescript
|
|
450
|
-
* import { MimicServer, MimicAuthService } from "@voidhash/mimic-effect";
|
|
451
|
-
* import { Primitive } from "@voidhash/mimic";
|
|
452
|
-
*
|
|
453
|
-
* const TodoSchema = Primitive.Struct({
|
|
454
|
-
* title: Primitive.String(),
|
|
455
|
-
* completed: Primitive.Boolean(),
|
|
456
|
-
* });
|
|
457
|
-
*
|
|
458
|
-
* // Create the handler layer with defaults
|
|
459
|
-
* const HandlerLayer = MimicServer.layer({
|
|
460
|
-
* basePath: "/mimic/todo",
|
|
461
|
-
* schema: TodoSchema
|
|
462
|
-
* });
|
|
463
|
-
*
|
|
464
|
-
* // Or with custom auth
|
|
465
|
-
* const HandlerLayerWithAuth = MimicServer.layer({
|
|
466
|
-
* basePath: "/mimic/todo",
|
|
467
|
-
* schema: TodoSchema
|
|
468
|
-
* }).pipe(
|
|
469
|
-
* Layer.provideMerge(MimicAuthService.layer({
|
|
470
|
-
* authHandler: (token) => ({ success: true, userId: "user-123" })
|
|
471
|
-
* }))
|
|
472
|
-
* );
|
|
473
|
-
* ```
|
|
474
|
-
*/
|
|
475
|
-
declare const layer$3: <TSchema extends Primitive.AnyPrimitive>(options: MimicLayerOptions<TSchema>) => Layer.Layer<MimicWebSocketHandler | DocumentManagerTag>;
|
|
476
|
-
/**
|
|
477
|
-
* Create the Mimic server handler layer.
|
|
478
|
-
* This layer provides the WebSocket handler that can be used with any WebSocket server.
|
|
479
|
-
*
|
|
480
|
-
* @example
|
|
481
|
-
* ```typescript
|
|
482
|
-
* import { MimicServer } from "@voidhash/mimic-server-effect";
|
|
483
|
-
* import { SocketServer } from "@effect/platform/SocketServer";
|
|
484
|
-
* import { Primitive } from "@voidhash/mimic";
|
|
485
|
-
*
|
|
486
|
-
* // Define your document schema
|
|
487
|
-
* const TodoSchema = Primitive.Struct({
|
|
488
|
-
* title: Primitive.String(),
|
|
489
|
-
* completed: Primitive.Boolean(),
|
|
490
|
-
* });
|
|
491
|
-
*
|
|
492
|
-
* // Create the server layer
|
|
493
|
-
* const serverLayer = MimicServer.handlerLayer({
|
|
494
|
-
* schema: TodoSchema,
|
|
495
|
-
* });
|
|
496
|
-
*
|
|
497
|
-
* // Run with your socket server
|
|
498
|
-
* Effect.gen(function* () {
|
|
499
|
-
* const handler = yield* MimicServer.MimicWebSocketHandler;
|
|
500
|
-
* const server = yield* SocketServer;
|
|
501
|
-
*
|
|
502
|
-
* yield* server.run((socket) =>
|
|
503
|
-
* // Extract document ID from request and call handler
|
|
504
|
-
* handler(socket, "my-document-id")
|
|
505
|
-
* );
|
|
506
|
-
* }).pipe(
|
|
507
|
-
* Effect.provide(serverLayer),
|
|
508
|
-
* Effect.provide(YourSocketServerLayer),
|
|
509
|
-
* );
|
|
510
|
-
* ```
|
|
511
|
-
*/
|
|
512
|
-
declare const handlerLayer: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<MimicWebSocketHandler>;
|
|
513
|
-
/**
|
|
514
|
-
* Create the document manager layer.
|
|
515
|
-
*/
|
|
516
|
-
declare const documentManagerLayer: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<DocumentManagerTag>;
|
|
517
|
-
/**
|
|
518
|
-
* Run a Mimic WebSocket server with the provided handler.
|
|
519
|
-
*
|
|
520
|
-
* This is a helper that:
|
|
521
|
-
* 1. Gets the WebSocket handler from context
|
|
522
|
-
* 2. Runs the socket server with the handler
|
|
523
|
-
*
|
|
524
|
-
* Note: The document ID extraction from socket is implementation-specific.
|
|
525
|
-
* You may need to customize this based on your socket server.
|
|
526
|
-
*/
|
|
527
|
-
declare const run: (extractDocumentId: (socket: Socket.Socket) => Effect.Effect<string>) => Effect.Effect<void, _effect_platform_SocketServer0.SocketServerError, MimicWebSocketHandler | SocketServer>;
|
|
528
|
-
/**
|
|
529
|
-
* Create a Mimic server layer that integrates with HttpLayerRouter.
|
|
530
|
-
*
|
|
531
|
-
* This function creates a layer that:
|
|
532
|
-
* 1. Registers a WebSocket route at the specified base path
|
|
533
|
-
* 2. Handles WebSocket upgrades for document sync
|
|
534
|
-
* 3. Provides all required dependencies (config, auth, storage, document manager)
|
|
535
|
-
*
|
|
536
|
-
* By default, uses in-memory storage and no authentication.
|
|
537
|
-
* To override these defaults, provide custom layers before the defaults:
|
|
538
|
-
*
|
|
539
|
-
* @example
|
|
540
|
-
* ```typescript
|
|
541
|
-
* import { MimicServer, MimicAuthService } from "@voidhash/mimic-effect";
|
|
542
|
-
* import { HttpLayerRouter } from "@effect/platform";
|
|
543
|
-
* import { Primitive } from "@voidhash/mimic";
|
|
544
|
-
*
|
|
545
|
-
* const TodoSchema = Primitive.Struct({
|
|
546
|
-
* title: Primitive.String(),
|
|
547
|
-
* completed: Primitive.Boolean(),
|
|
548
|
-
* });
|
|
549
|
-
*
|
|
550
|
-
* // Create the Mimic route layer with defaults
|
|
551
|
-
* const MimicRoute = MimicServer.layerHttpLayerRouter({
|
|
552
|
-
* basePath: "/mimic/todo",
|
|
553
|
-
* schema: TodoSchema
|
|
554
|
-
* });
|
|
555
|
-
*
|
|
556
|
-
* // Or with custom auth - use Layer.provide to inject before defaults
|
|
557
|
-
* const MimicRouteWithAuth = MimicServer.layerHttpLayerRouter({
|
|
558
|
-
* basePath: "/mimic/todo",
|
|
559
|
-
* schema: TodoSchema,
|
|
560
|
-
* authLayer: MimicAuthService.layer({
|
|
561
|
-
* authHandler: (token) => ({ success: true, userId: token })
|
|
562
|
-
* })
|
|
563
|
-
* });
|
|
564
|
-
*
|
|
565
|
-
* // Merge with other routes and serve
|
|
566
|
-
* const AllRoutes = Layer.mergeAll(MimicRoute, OtherRoutes);
|
|
567
|
-
* HttpLayerRouter.serve(AllRoutes).pipe(
|
|
568
|
-
* Layer.provide(BunHttpServer.layer({ port: 3000 })),
|
|
569
|
-
* Layer.launch,
|
|
570
|
-
* BunRuntime.runMain
|
|
571
|
-
* );
|
|
572
|
-
* ```
|
|
573
|
-
*/
|
|
574
|
-
declare const layerHttpLayerRouter: <TSchema extends Primitive.AnyPrimitive>(options: MimicLayerOptions<TSchema> & {
|
|
575
|
-
/** Custom auth layer. Defaults to NoAuth (all connections allowed). */
|
|
576
|
-
readonly authLayer?: Layer.Layer<MimicAuthServiceTag>;
|
|
577
|
-
/** Custom storage layer. Defaults to InMemoryDataStorage. */
|
|
578
|
-
readonly storageLayer?: Layer.Layer<MimicDataStorageTag>;
|
|
579
|
-
}) => Layer.Layer<never, never, HttpLayerRouter.HttpRouter>;
|
|
580
|
-
declare namespace InMemoryDataStorage_d_exports {
|
|
581
|
-
export { layer$2 as layer, layerDefault$2 as layerDefault };
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Layer that provides in-memory data storage.
|
|
585
|
-
* This is the default storage implementation - ephemeral and non-persistent.
|
|
586
|
-
*/
|
|
587
|
-
declare const layer$2: Layer.Layer<MimicDataStorageTag>;
|
|
588
|
-
/**
|
|
589
|
-
* Default layer alias for convenience.
|
|
590
|
-
*/
|
|
591
|
-
declare const layerDefault$2: Layer.Layer<MimicDataStorageTag, never, never>;
|
|
592
|
-
declare namespace NoAuth_d_exports {
|
|
593
|
-
export { layer$1 as layer, layerDefault$1 as layerDefault };
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* Layer that provides no authentication (open access).
|
|
597
|
-
* All connections are automatically authenticated.
|
|
598
|
-
*
|
|
599
|
-
* WARNING: Only use this for development or when authentication
|
|
600
|
-
* is handled at a different layer (e.g., API gateway, reverse proxy).
|
|
601
|
-
*/
|
|
602
|
-
declare const layer$1: Layer.Layer<MimicAuthServiceTag>;
|
|
603
|
-
/**
|
|
604
|
-
* Default layer alias for convenience.
|
|
605
|
-
*/
|
|
606
|
-
declare const layerDefault$1: Layer.Layer<MimicAuthServiceTag, never, never>;
|
|
607
|
-
declare namespace PresenceManager_d_exports {
|
|
608
|
-
export { PresenceEntry, PresenceEvent, PresenceManager, PresenceManagerTag, PresenceRemoveEvent, PresenceSnapshot, PresenceUpdateEvent, layer, layerDefault };
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* A presence entry stored in the manager.
|
|
612
|
-
*/
|
|
613
|
-
interface PresenceEntry {
|
|
614
|
-
/** The presence data */
|
|
615
|
-
readonly data: unknown;
|
|
616
|
-
/** Optional user ID from authentication */
|
|
617
|
-
readonly userId?: string;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Event emitted when a presence is updated.
|
|
621
|
-
*/
|
|
622
|
-
interface PresenceUpdateEvent {
|
|
623
|
-
readonly type: "presence_update";
|
|
624
|
-
/** The connection ID of the user who updated */
|
|
625
|
-
readonly id: string;
|
|
626
|
-
/** The presence data */
|
|
627
|
-
readonly data: unknown;
|
|
628
|
-
/** Optional user ID from authentication */
|
|
629
|
-
readonly userId?: string;
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Event emitted when a presence is removed (user disconnected).
|
|
633
|
-
*/
|
|
634
|
-
interface PresenceRemoveEvent {
|
|
635
|
-
readonly type: "presence_remove";
|
|
636
|
-
/** The connection ID of the user who disconnected */
|
|
637
|
-
readonly id: string;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Union of all presence events.
|
|
641
|
-
*/
|
|
642
|
-
type PresenceEvent = PresenceUpdateEvent | PresenceRemoveEvent;
|
|
643
|
-
/**
|
|
644
|
-
* A snapshot of all presence entries for a document.
|
|
645
|
-
*/
|
|
646
|
-
interface PresenceSnapshot {
|
|
647
|
-
/** Map of connectionId to presence entry */
|
|
648
|
-
readonly presences: Record<string, PresenceEntry>;
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* Service interface for the PresenceManager.
|
|
652
|
-
*/
|
|
653
|
-
interface PresenceManager {
|
|
654
|
-
/**
|
|
655
|
-
* Get a snapshot of all presences for a document.
|
|
656
|
-
*/
|
|
657
|
-
readonly getSnapshot: (documentId: string) => Effect.Effect<PresenceSnapshot>;
|
|
658
|
-
/**
|
|
659
|
-
* Set/update presence for a connection.
|
|
660
|
-
* Broadcasts the update to all subscribers.
|
|
661
|
-
*/
|
|
662
|
-
readonly set: (documentId: string, connectionId: string, entry: PresenceEntry) => Effect.Effect<void>;
|
|
663
|
-
/**
|
|
664
|
-
* Remove presence for a connection (e.g., on disconnect).
|
|
665
|
-
* Broadcasts the removal to all subscribers.
|
|
666
|
-
*/
|
|
667
|
-
readonly remove: (documentId: string, connectionId: string) => Effect.Effect<void>;
|
|
668
|
-
/**
|
|
669
|
-
* Subscribe to presence events for a document.
|
|
670
|
-
* Returns a Stream of presence events.
|
|
671
|
-
*/
|
|
672
|
-
readonly subscribe: (documentId: string) => Effect.Effect<Stream.Stream<PresenceEvent>, never, Scope.Scope>;
|
|
673
|
-
}
|
|
674
|
-
declare const PresenceManagerTag_base: Context.TagClass<PresenceManagerTag, "@voidhash/mimic-server-effect/PresenceManager", PresenceManager>;
|
|
675
|
-
/**
|
|
676
|
-
* Context tag for PresenceManager.
|
|
677
|
-
*/
|
|
678
|
-
declare class PresenceManagerTag extends PresenceManagerTag_base {}
|
|
679
|
-
/**
|
|
680
|
-
* Layer that provides PresenceManager.
|
|
681
|
-
*/
|
|
682
|
-
declare const layer: Layer.Layer<PresenceManagerTag>;
|
|
683
|
-
/**
|
|
684
|
-
* Default layer that provides PresenceManager.
|
|
685
|
-
* Uses the default priority for layer composition.
|
|
686
|
-
*/
|
|
687
|
-
declare const layerDefault: Layer.Layer<PresenceManagerTag>;
|
|
688
|
-
//#endregion
|
|
689
|
-
//#region src/errors.d.ts
|
|
690
|
-
declare const DocumentTypeNotFoundError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
691
|
-
readonly _tag: "DocumentTypeNotFoundError";
|
|
692
|
-
} & Readonly<A>;
|
|
693
|
-
/**
|
|
694
|
-
* Error when a document type is not found in the schema registry.
|
|
695
|
-
*/
|
|
696
|
-
declare class DocumentTypeNotFoundError extends DocumentTypeNotFoundError_base<{
|
|
697
|
-
readonly documentType: string;
|
|
698
|
-
}> {
|
|
699
|
-
get message(): string;
|
|
700
|
-
}
|
|
701
|
-
declare const DocumentNotFoundError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
702
|
-
readonly _tag: "DocumentNotFoundError";
|
|
703
|
-
} & Readonly<A>;
|
|
704
|
-
/**
|
|
705
|
-
* Error when a document is not found.
|
|
706
|
-
*/
|
|
707
|
-
declare class DocumentNotFoundError extends DocumentNotFoundError_base<{
|
|
708
|
-
readonly documentId: string;
|
|
709
|
-
}> {
|
|
710
|
-
get message(): string;
|
|
711
|
-
}
|
|
712
|
-
declare const AuthenticationError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
713
|
-
readonly _tag: "AuthenticationError";
|
|
714
|
-
} & Readonly<A>;
|
|
715
|
-
/**
|
|
716
|
-
* Error when authentication fails.
|
|
717
|
-
*/
|
|
718
|
-
declare class AuthenticationError extends AuthenticationError_base<{
|
|
719
|
-
readonly reason: string;
|
|
720
|
-
}> {
|
|
721
|
-
get message(): string;
|
|
722
|
-
}
|
|
723
|
-
declare const TransactionRejectedError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
724
|
-
readonly _tag: "TransactionRejectedError";
|
|
725
|
-
} & Readonly<A>;
|
|
726
|
-
/**
|
|
727
|
-
* Error when a transaction is rejected.
|
|
728
|
-
*/
|
|
729
|
-
declare class TransactionRejectedError extends TransactionRejectedError_base<{
|
|
730
|
-
readonly transactionId: string;
|
|
731
|
-
readonly reason: string;
|
|
732
|
-
}> {
|
|
733
|
-
get message(): string;
|
|
734
|
-
}
|
|
735
|
-
declare const MessageParseError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
736
|
-
readonly _tag: "MessageParseError";
|
|
737
|
-
} & Readonly<A>;
|
|
738
|
-
/**
|
|
739
|
-
* Error when parsing a client message fails.
|
|
740
|
-
*/
|
|
741
|
-
declare class MessageParseError extends MessageParseError_base<{
|
|
742
|
-
readonly cause: unknown;
|
|
743
|
-
}> {
|
|
744
|
-
get message(): string;
|
|
745
|
-
}
|
|
746
|
-
declare const InvalidConnectionError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
747
|
-
readonly _tag: "InvalidConnectionError";
|
|
748
|
-
} & Readonly<A>;
|
|
749
|
-
/**
|
|
750
|
-
* Error when the WebSocket connection is invalid.
|
|
751
|
-
*/
|
|
752
|
-
declare class InvalidConnectionError extends InvalidConnectionError_base<{
|
|
753
|
-
readonly reason: string;
|
|
754
|
-
}> {
|
|
755
|
-
get message(): string;
|
|
756
|
-
}
|
|
757
|
-
declare const MissingDocumentIdError_base: new <A extends Record<string, any> = {}>(args: effect_Types6.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause6.YieldableError & {
|
|
758
|
-
readonly _tag: "MissingDocumentIdError";
|
|
759
|
-
} & Readonly<A>;
|
|
760
|
-
/**
|
|
761
|
-
* Error when the document ID is missing from the URL path.
|
|
762
|
-
*/
|
|
763
|
-
declare class MissingDocumentIdError extends MissingDocumentIdError_base<{
|
|
764
|
-
readonly path?: string;
|
|
765
|
-
}> {
|
|
766
|
-
get message(): string;
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Union of all Mimic server errors.
|
|
770
|
-
*/
|
|
771
|
-
type MimicServerError = DocumentTypeNotFoundError | DocumentNotFoundError | AuthenticationError | TransactionRejectedError | MessageParseError | InvalidConnectionError | MissingDocumentIdError;
|
|
772
|
-
declare namespace WebSocketHandler_d_exports {
|
|
773
|
-
export { extractDocumentId, handleConnection, makeHandler };
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Extract document ID from URL path.
|
|
777
|
-
* Expected format: /doc/{documentId}
|
|
778
|
-
*/
|
|
779
|
-
declare const extractDocumentId: (path: string) => Effect.Effect<string, MissingDocumentIdError>;
|
|
780
|
-
/**
|
|
781
|
-
* Handle a WebSocket connection for a document.
|
|
782
|
-
*
|
|
783
|
-
* @param socket - The Effect Platform Socket
|
|
784
|
-
* @param path - The URL path (e.g., "/doc/my-document-id")
|
|
785
|
-
* @returns An Effect that handles the connection lifecycle
|
|
786
|
-
*/
|
|
787
|
-
declare const handleConnection: (socket: Socket.Socket, path: string) => Effect.Effect<void, Socket.SocketError | MissingDocumentIdError | MessageParseError, MimicServerConfigTag | MimicAuthServiceTag | DocumentManagerTag | PresenceManagerTag | Scope.Scope>;
|
|
788
|
-
/**
|
|
789
|
-
* Create a handler function for the WebSocket server.
|
|
790
|
-
* Returns a function that takes a socket and document ID.
|
|
791
|
-
*/
|
|
792
|
-
declare const makeHandler: Effect.Effect<(socket: Socket.Socket, documentId: string) => Effect.Effect<void, MessageParseError | Socket.SocketError, never>, never, DocumentManagerTag | MimicAuthServiceTag | MimicServerConfigTag | PresenceManagerTag>;
|
|
793
|
-
//#endregion
|
|
794
|
-
export { AuthenticationError, DocumentManager_d_exports as DocumentManager, DocumentNotFoundError, DocumentProtocol_d_exports as DocumentProtocol, DocumentTypeNotFoundError, InvalidConnectionError, MessageParseError, MimicAuthService_d_exports as MimicAuthService, MimicConfig_d_exports as MimicConfig, MimicDataStorage_d_exports as MimicDataStorage, InMemoryDataStorage_d_exports as MimicInMemoryDataStorage, NoAuth_d_exports as MimicNoAuth, MimicServer_d_exports as MimicServer, MimicServerError, MissingDocumentIdError, PresenceManager_d_exports as PresenceManager, TransactionRejectedError, WebSocketHandler_d_exports as WebSocketHandler };
|
|
795
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { DocumentProtocol_d_exports } from "./DocumentProtocol.mjs";
|
|
2
|
+
import { MimicConfig_d_exports } from "./MimicConfig.mjs";
|
|
3
|
+
import { MimicDataStorage_d_exports } from "./MimicDataStorage.mjs";
|
|
4
|
+
import { DocumentManager_d_exports } from "./DocumentManager.mjs";
|
|
5
|
+
import { MimicAuthService_d_exports } from "./MimicAuthService.mjs";
|
|
6
|
+
import { MimicServer_d_exports } from "./MimicServer.mjs";
|
|
7
|
+
import { InMemoryDataStorage_d_exports } from "./storage/InMemoryDataStorage.mjs";
|
|
8
|
+
import { NoAuth_d_exports } from "./auth/NoAuth.mjs";
|
|
9
|
+
import { PresenceManager_d_exports } from "./PresenceManager.mjs";
|
|
10
|
+
import { AuthenticationError, DocumentNotFoundError, DocumentTypeNotFoundError, InvalidConnectionError, MessageParseError, MimicServerError, MissingDocumentIdError, TransactionRejectedError } from "./errors.mjs";
|
|
11
|
+
import { WebSocketHandler_d_exports } from "./WebSocketHandler.mjs";
|
|
12
|
+
export { AuthenticationError, DocumentManager_d_exports as DocumentManager, DocumentNotFoundError, DocumentProtocol_d_exports as DocumentProtocol, DocumentTypeNotFoundError, InvalidConnectionError, MessageParseError, MimicAuthService_d_exports as MimicAuthService, MimicConfig_d_exports as MimicConfig, MimicDataStorage_d_exports as MimicDataStorage, InMemoryDataStorage_d_exports as MimicInMemoryDataStorage, NoAuth_d_exports as MimicNoAuth, MimicServer_d_exports as MimicServer, MimicServerError, MissingDocumentIdError, PresenceManager_d_exports as PresenceManager, TransactionRejectedError, WebSocketHandler_d_exports as WebSocketHandler };
|