@voidhash/mimic-effect 0.0.2 → 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.
Files changed (99) hide show
  1. package/.turbo/turbo-build.log +99 -14
  2. package/dist/DocumentManager.cjs +118 -0
  3. package/dist/DocumentManager.d.cts +45 -0
  4. package/dist/DocumentManager.d.cts.map +1 -0
  5. package/dist/DocumentManager.d.mts +45 -0
  6. package/dist/DocumentManager.d.mts.map +1 -0
  7. package/dist/DocumentManager.mjs +105 -0
  8. package/dist/DocumentManager.mjs.map +1 -0
  9. package/dist/DocumentProtocol.cjs +94 -0
  10. package/dist/DocumentProtocol.d.cts +113 -0
  11. package/dist/DocumentProtocol.d.cts.map +1 -0
  12. package/dist/DocumentProtocol.d.mts +113 -0
  13. package/dist/DocumentProtocol.d.mts.map +1 -0
  14. package/dist/DocumentProtocol.mjs +89 -0
  15. package/dist/DocumentProtocol.mjs.map +1 -0
  16. package/dist/MimicAuthService.cjs +55 -0
  17. package/dist/MimicAuthService.d.cts +65 -0
  18. package/dist/MimicAuthService.d.cts.map +1 -0
  19. package/dist/MimicAuthService.d.mts +65 -0
  20. package/dist/MimicAuthService.d.mts.map +1 -0
  21. package/dist/MimicAuthService.mjs +47 -0
  22. package/dist/MimicAuthService.mjs.map +1 -0
  23. package/dist/MimicConfig.cjs +50 -0
  24. package/dist/MimicConfig.d.cts +99 -0
  25. package/dist/MimicConfig.d.cts.map +1 -0
  26. package/dist/MimicConfig.d.mts +99 -0
  27. package/dist/MimicConfig.d.mts.map +1 -0
  28. package/dist/MimicConfig.mjs +41 -0
  29. package/dist/MimicConfig.mjs.map +1 -0
  30. package/dist/MimicDataStorage.cjs +83 -0
  31. package/dist/MimicDataStorage.d.cts +113 -0
  32. package/dist/MimicDataStorage.d.cts.map +1 -0
  33. package/dist/MimicDataStorage.d.mts +113 -0
  34. package/dist/MimicDataStorage.d.mts.map +1 -0
  35. package/dist/MimicDataStorage.mjs +74 -0
  36. package/dist/MimicDataStorage.mjs.map +1 -0
  37. package/dist/MimicServer.cjs +230 -0
  38. package/dist/MimicServer.d.cts +192 -0
  39. package/dist/MimicServer.d.cts.map +1 -0
  40. package/dist/MimicServer.d.mts +192 -0
  41. package/dist/MimicServer.d.mts.map +1 -0
  42. package/dist/MimicServer.mjs +223 -0
  43. package/dist/MimicServer.mjs.map +1 -0
  44. package/dist/PresenceManager.cjs +108 -0
  45. package/dist/PresenceManager.d.cts +91 -0
  46. package/dist/PresenceManager.d.cts.map +1 -0
  47. package/dist/PresenceManager.d.mts +91 -0
  48. package/dist/PresenceManager.d.mts.map +1 -0
  49. package/dist/PresenceManager.mjs +95 -0
  50. package/dist/PresenceManager.mjs.map +1 -0
  51. package/dist/WebSocketHandler.cjs +366 -0
  52. package/dist/WebSocketHandler.d.cts +34 -0
  53. package/dist/WebSocketHandler.d.cts.map +1 -0
  54. package/dist/WebSocketHandler.d.mts +34 -0
  55. package/dist/WebSocketHandler.d.mts.map +1 -0
  56. package/dist/WebSocketHandler.mjs +355 -0
  57. package/dist/WebSocketHandler.mjs.map +1 -0
  58. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
  59. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
  60. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
  61. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
  62. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
  63. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
  64. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
  65. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
  66. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
  67. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
  68. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  69. package/dist/{chunk-C6wwvPpM.mjs → _virtual/rolldown_runtime.mjs} +1 -1
  70. package/dist/auth/NoAuth.cjs +43 -0
  71. package/dist/auth/NoAuth.d.cts +22 -0
  72. package/dist/auth/NoAuth.d.cts.map +1 -0
  73. package/dist/auth/NoAuth.d.mts +22 -0
  74. package/dist/auth/NoAuth.d.mts.map +1 -0
  75. package/dist/auth/NoAuth.mjs +36 -0
  76. package/dist/auth/NoAuth.mjs.map +1 -0
  77. package/dist/errors.cjs +74 -0
  78. package/dist/errors.d.cts +89 -0
  79. package/dist/errors.d.cts.map +1 -0
  80. package/dist/errors.d.mts +89 -0
  81. package/dist/errors.d.mts.map +1 -0
  82. package/dist/errors.mjs +67 -0
  83. package/dist/errors.mjs.map +1 -0
  84. package/dist/index.cjs +29 -1227
  85. package/dist/index.d.cts +12 -795
  86. package/dist/index.d.mts +12 -795
  87. package/dist/index.mjs +13 -1162
  88. package/dist/storage/InMemoryDataStorage.cjs +57 -0
  89. package/dist/storage/InMemoryDataStorage.d.cts +19 -0
  90. package/dist/storage/InMemoryDataStorage.d.cts.map +1 -0
  91. package/dist/storage/InMemoryDataStorage.d.mts +19 -0
  92. package/dist/storage/InMemoryDataStorage.d.mts.map +1 -0
  93. package/dist/storage/InMemoryDataStorage.mjs +48 -0
  94. package/dist/storage/InMemoryDataStorage.mjs.map +1 -0
  95. package/package.json +3 -3
  96. package/tsdown.config.ts +1 -1
  97. package/dist/index.d.cts.map +0 -1
  98. package/dist/index.d.mts.map +0 -1
  99. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,113 @@
1
+ import * as Schema from "effect/Schema";
2
+
3
+ //#region src/DocumentProtocol.d.ts
4
+ declare namespace DocumentProtocol_d_exports {
5
+ export { AuthResultMessage, AuthResultMessageSchema, ErrorMessage, ErrorMessageSchema, OperationSchema, PongMessage, PongMessageSchema, ServerBroadcast, ServerBroadcastSchema, SnapshotMessage, SnapshotMessageSchema, SubmitResult, SubmitResultSchema, Transaction, TransactionMessage, TransactionMessageSchema, TransactionSchema };
6
+ }
7
+ /**
8
+ * Schema for a transaction operation.
9
+ */
10
+ declare const OperationSchema: Schema.Struct<{
11
+ kind: typeof Schema.String;
12
+ path: typeof Schema.Unknown;
13
+ payload: typeof Schema.Unknown;
14
+ }>;
15
+ /**
16
+ * Schema for a transaction.
17
+ */
18
+ declare const TransactionSchema: Schema.Struct<{
19
+ id: typeof Schema.String;
20
+ ops: Schema.Array$<Schema.Struct<{
21
+ kind: typeof Schema.String;
22
+ path: typeof Schema.Unknown;
23
+ payload: typeof Schema.Unknown;
24
+ }>>;
25
+ timestamp: typeof Schema.Number;
26
+ }>;
27
+ type Transaction = Schema.Schema.Type<typeof TransactionSchema>;
28
+ /**
29
+ * Schema for a server message that broadcasts a committed transaction.
30
+ */
31
+ declare const TransactionMessageSchema: Schema.Struct<{
32
+ type: Schema.Literal<["transaction"]>;
33
+ transaction: 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
+ version: typeof Schema.Number;
43
+ }>;
44
+ type TransactionMessage = Schema.Schema.Type<typeof TransactionMessageSchema>;
45
+ /**
46
+ * Schema for a server message containing a snapshot.
47
+ */
48
+ declare const SnapshotMessageSchema: Schema.Struct<{
49
+ type: Schema.Literal<["snapshot"]>;
50
+ state: typeof Schema.Unknown;
51
+ version: typeof Schema.Number;
52
+ }>;
53
+ type SnapshotMessage = Schema.Schema.Type<typeof SnapshotMessageSchema>;
54
+ /**
55
+ * Schema for a server error message.
56
+ */
57
+ declare const ErrorMessageSchema: Schema.Struct<{
58
+ type: Schema.Literal<["error"]>;
59
+ transactionId: typeof Schema.String;
60
+ reason: typeof Schema.String;
61
+ }>;
62
+ type ErrorMessage = Schema.Schema.Type<typeof ErrorMessageSchema>;
63
+ /**
64
+ * Schema for a pong message.
65
+ */
66
+ declare const PongMessageSchema: Schema.Struct<{
67
+ type: Schema.Literal<["pong"]>;
68
+ }>;
69
+ type PongMessage = Schema.Schema.Type<typeof PongMessageSchema>;
70
+ /**
71
+ * Schema for authentication result message.
72
+ */
73
+ declare const AuthResultMessageSchema: Schema.Struct<{
74
+ type: Schema.Literal<["auth_result"]>;
75
+ success: typeof Schema.Boolean;
76
+ error: Schema.optional<typeof Schema.String>;
77
+ }>;
78
+ type AuthResultMessage = Schema.Schema.Type<typeof AuthResultMessageSchema>;
79
+ /**
80
+ * Union of all server broadcast messages.
81
+ */
82
+ declare const ServerBroadcastSchema: Schema.Union<[Schema.Struct<{
83
+ type: Schema.Literal<["transaction"]>;
84
+ transaction: Schema.Struct<{
85
+ id: typeof Schema.String;
86
+ ops: Schema.Array$<Schema.Struct<{
87
+ kind: typeof Schema.String;
88
+ path: typeof Schema.Unknown;
89
+ payload: typeof Schema.Unknown;
90
+ }>>;
91
+ timestamp: typeof Schema.Number;
92
+ }>;
93
+ version: typeof Schema.Number;
94
+ }>, Schema.Struct<{
95
+ type: Schema.Literal<["error"]>;
96
+ transactionId: typeof Schema.String;
97
+ reason: typeof Schema.String;
98
+ }>]>;
99
+ type ServerBroadcast = Schema.Schema.Type<typeof ServerBroadcastSchema>;
100
+ /**
101
+ * Result of submitting a transaction.
102
+ */
103
+ declare const SubmitResultSchema: Schema.Union<[Schema.Struct<{
104
+ success: Schema.Literal<[true]>;
105
+ version: typeof Schema.Number;
106
+ }>, Schema.Struct<{
107
+ success: Schema.Literal<[false]>;
108
+ reason: typeof Schema.String;
109
+ }>]>;
110
+ type SubmitResult = Schema.Schema.Type<typeof SubmitResultSchema>;
111
+ //#endregion
112
+ export { DocumentProtocol_d_exports, ServerBroadcast, SnapshotMessage, SubmitResult };
113
+ //# sourceMappingURL=DocumentProtocol.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentProtocol.d.cts","names":[],"sources":["../src/DocumentProtocol.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAaa,iBAAe,MAAA,CAAA;;;;;;;;cASf,mBAAiB,MAAA,CAAA;;;;;;;EATjB,SAAA,EAAA,oBAIX;;KAWU,WAAA,GAAc,MAAA,CAAO,MAAA,CAAO,YAAY;;;;AANvC,cAWA,wBAPX,EAOmC,MAAA,CAAA,MAPnC,CAAA;;;;;;;;IAJ4B,CAAA,CAAA,CAAA;IAAA,SAAA,EAAA,oBAAA;EAMlB,CAAA,CAAA;EAKC,OAAA,EAAA,oBAIX;;KAEU,kBAAA,GAAqB,MAAA,CAAO,MAAA,CAAO,YAAY;;;;cAK9C,uBAAqB,MAAA,CAAA;;;;;AAXG,KAiBzB,eAAA,GAAkB,MAAA,CAAO,MAAA,CAAO,IAjBP,CAAA,OAiBmB,qBAjBnB,CAAA;;AAMrC;AAKA;cAWa,oBAAkB,MAAA,CAAA;;;EAXG,MAAA,EAAA,oBAAA;CAAA,CAAA;AAMtB,KAWA,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,IAXe,CAAA,OAWH,kBAXT,CAAA;AAK5C;;;cAWa,mBAAiB,MAAA,CAAA;EAXC,IAAA,EAa7B,MAAA,CAAA,OAb6B,CAAA,CAAA,MAAA,CAAA,CAAA;CAAA,CAAA;AAMnB,KASA,WAAA,GAAc,MAAA,CAAO,MAAA,CAAO,IATa,CAAA,OASD,iBATX,CAAI;AAK7C;AAIA;AAKA;cAAa,yBAAuB,MAAA,CAAA;;;;CAAA,CAAA;AAAA,KAMxB,iBAAA,GAAoB,MAAA,CAAO,MAAA,CAAO,IANV,CAAA,OAMsB,uBANtB,CAAA;AAMpC;AAKA;;cAAa,uBAAqB,MAAA,CAAA,OAAA,MAAA,CAAA;;;;;;;;;IAAA,SAAA,EAAA,oBAAA;;;;;EAAA,aAAA,EAAA,oBAAA;EAAA,MAAA,EAAA,oBAAA;AAKlC,CAAA,CAAA,CAAA,CAAY;AASC,KATD,eAAA,GAAkB,MAAA,CAAO,MAAA,CAAO,IAkB3C,CAAA,OAlBuD,qBAkBvD,CAAA;;;;cATY,oBAAkB,MAAA,CAAA,OAAA,MAAA,CAAA;;;CAAA,CAAA,eAAA,CAAA;EAAA,OAAA,gBAAA,CAAA,CAAA,KAAA,CAAA,CAAA;EAWnB,MAAA,EAAA,oBAAyC;;KAAzC,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,YAAY"}
@@ -0,0 +1,113 @@
1
+ import * as Schema from "effect/Schema";
2
+
3
+ //#region src/DocumentProtocol.d.ts
4
+ declare namespace DocumentProtocol_d_exports {
5
+ export { AuthResultMessage, AuthResultMessageSchema, ErrorMessage, ErrorMessageSchema, OperationSchema, PongMessage, PongMessageSchema, ServerBroadcast, ServerBroadcastSchema, SnapshotMessage, SnapshotMessageSchema, SubmitResult, SubmitResultSchema, Transaction, TransactionMessage, TransactionMessageSchema, TransactionSchema };
6
+ }
7
+ /**
8
+ * Schema for a transaction operation.
9
+ */
10
+ declare const OperationSchema: Schema.Struct<{
11
+ kind: typeof Schema.String;
12
+ path: typeof Schema.Unknown;
13
+ payload: typeof Schema.Unknown;
14
+ }>;
15
+ /**
16
+ * Schema for a transaction.
17
+ */
18
+ declare const TransactionSchema: Schema.Struct<{
19
+ id: typeof Schema.String;
20
+ ops: Schema.Array$<Schema.Struct<{
21
+ kind: typeof Schema.String;
22
+ path: typeof Schema.Unknown;
23
+ payload: typeof Schema.Unknown;
24
+ }>>;
25
+ timestamp: typeof Schema.Number;
26
+ }>;
27
+ type Transaction = Schema.Schema.Type<typeof TransactionSchema>;
28
+ /**
29
+ * Schema for a server message that broadcasts a committed transaction.
30
+ */
31
+ declare const TransactionMessageSchema: Schema.Struct<{
32
+ type: Schema.Literal<["transaction"]>;
33
+ transaction: 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
+ version: typeof Schema.Number;
43
+ }>;
44
+ type TransactionMessage = Schema.Schema.Type<typeof TransactionMessageSchema>;
45
+ /**
46
+ * Schema for a server message containing a snapshot.
47
+ */
48
+ declare const SnapshotMessageSchema: Schema.Struct<{
49
+ type: Schema.Literal<["snapshot"]>;
50
+ state: typeof Schema.Unknown;
51
+ version: typeof Schema.Number;
52
+ }>;
53
+ type SnapshotMessage = Schema.Schema.Type<typeof SnapshotMessageSchema>;
54
+ /**
55
+ * Schema for a server error message.
56
+ */
57
+ declare const ErrorMessageSchema: Schema.Struct<{
58
+ type: Schema.Literal<["error"]>;
59
+ transactionId: typeof Schema.String;
60
+ reason: typeof Schema.String;
61
+ }>;
62
+ type ErrorMessage = Schema.Schema.Type<typeof ErrorMessageSchema>;
63
+ /**
64
+ * Schema for a pong message.
65
+ */
66
+ declare const PongMessageSchema: Schema.Struct<{
67
+ type: Schema.Literal<["pong"]>;
68
+ }>;
69
+ type PongMessage = Schema.Schema.Type<typeof PongMessageSchema>;
70
+ /**
71
+ * Schema for authentication result message.
72
+ */
73
+ declare const AuthResultMessageSchema: Schema.Struct<{
74
+ type: Schema.Literal<["auth_result"]>;
75
+ success: typeof Schema.Boolean;
76
+ error: Schema.optional<typeof Schema.String>;
77
+ }>;
78
+ type AuthResultMessage = Schema.Schema.Type<typeof AuthResultMessageSchema>;
79
+ /**
80
+ * Union of all server broadcast messages.
81
+ */
82
+ declare const ServerBroadcastSchema: Schema.Union<[Schema.Struct<{
83
+ type: Schema.Literal<["transaction"]>;
84
+ transaction: Schema.Struct<{
85
+ id: typeof Schema.String;
86
+ ops: Schema.Array$<Schema.Struct<{
87
+ kind: typeof Schema.String;
88
+ path: typeof Schema.Unknown;
89
+ payload: typeof Schema.Unknown;
90
+ }>>;
91
+ timestamp: typeof Schema.Number;
92
+ }>;
93
+ version: typeof Schema.Number;
94
+ }>, Schema.Struct<{
95
+ type: Schema.Literal<["error"]>;
96
+ transactionId: typeof Schema.String;
97
+ reason: typeof Schema.String;
98
+ }>]>;
99
+ type ServerBroadcast = Schema.Schema.Type<typeof ServerBroadcastSchema>;
100
+ /**
101
+ * Result of submitting a transaction.
102
+ */
103
+ declare const SubmitResultSchema: Schema.Union<[Schema.Struct<{
104
+ success: Schema.Literal<[true]>;
105
+ version: typeof Schema.Number;
106
+ }>, Schema.Struct<{
107
+ success: Schema.Literal<[false]>;
108
+ reason: typeof Schema.String;
109
+ }>]>;
110
+ type SubmitResult = Schema.Schema.Type<typeof SubmitResultSchema>;
111
+ //#endregion
112
+ export { DocumentProtocol_d_exports, ServerBroadcast, SnapshotMessage, SubmitResult };
113
+ //# sourceMappingURL=DocumentProtocol.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentProtocol.d.mts","names":[],"sources":["../src/DocumentProtocol.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAaa,iBAAe,MAAA,CAAA;;;;;;;;cASf,mBAAiB,MAAA,CAAA;;;;;;;EATjB,SAAA,EAAA,oBAIX;;KAWU,WAAA,GAAc,MAAA,CAAO,MAAA,CAAO,YAAY;;;;AANvC,cAWA,wBAPX,EAOmC,MAAA,CAAA,MAPnC,CAAA;;;;;;;;IAJ4B,CAAA,CAAA,CAAA;IAAA,SAAA,EAAA,oBAAA;EAMlB,CAAA,CAAA;EAKC,OAAA,EAAA,oBAIX;;KAEU,kBAAA,GAAqB,MAAA,CAAO,MAAA,CAAO,YAAY;;;;cAK9C,uBAAqB,MAAA,CAAA;;;;;AAXG,KAiBzB,eAAA,GAAkB,MAAA,CAAO,MAAA,CAAO,IAjBP,CAAA,OAiBmB,qBAjBnB,CAAA;;AAMrC;AAKA;cAWa,oBAAkB,MAAA,CAAA;;;EAXG,MAAA,EAAA,oBAAA;CAAA,CAAA;AAMtB,KAWA,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,IAXe,CAAA,OAWH,kBAXT,CAAA;AAK5C;;;cAWa,mBAAiB,MAAA,CAAA;EAXC,IAAA,EAa7B,MAAA,CAAA,OAb6B,CAAA,CAAA,MAAA,CAAA,CAAA;CAAA,CAAA;AAMnB,KASA,WAAA,GAAc,MAAA,CAAO,MAAA,CAAO,IATa,CAAA,OASD,iBATX,CAAI;AAK7C;AAIA;AAKA;cAAa,yBAAuB,MAAA,CAAA;;;;CAAA,CAAA;AAAA,KAMxB,iBAAA,GAAoB,MAAA,CAAO,MAAA,CAAO,IANV,CAAA,OAMsB,uBANtB,CAAA;AAMpC;AAKA;;cAAa,uBAAqB,MAAA,CAAA,OAAA,MAAA,CAAA;;;;;;;;;IAAA,SAAA,EAAA,oBAAA;;;;;EAAA,aAAA,EAAA,oBAAA;EAAA,MAAA,EAAA,oBAAA;AAKlC,CAAA,CAAA,CAAA,CAAY;AASC,KATD,eAAA,GAAkB,MAAA,CAAO,MAAA,CAAO,IAkB3C,CAAA,OAlBuD,qBAkBvD,CAAA;;;;cATY,oBAAkB,MAAA,CAAA,OAAA,MAAA,CAAA;;;CAAA,CAAA,eAAA,CAAA;EAAA,OAAA,gBAAA,CAAA,CAAA,KAAA,CAAA,CAAA;EAWnB,MAAA,EAAA,oBAAyC;;KAAzC,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,YAAY"}
@@ -0,0 +1,89 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.mjs";
2
+ import * as Schema from "effect/Schema";
3
+
4
+ //#region src/DocumentProtocol.ts
5
+ /**
6
+ * @since 0.0.1
7
+ * Protocol and schema definitions for document communication.
8
+ */
9
+ var DocumentProtocol_exports = /* @__PURE__ */ __export({
10
+ AuthResultMessageSchema: () => AuthResultMessageSchema,
11
+ ErrorMessageSchema: () => ErrorMessageSchema,
12
+ OperationSchema: () => OperationSchema,
13
+ PongMessageSchema: () => PongMessageSchema,
14
+ ServerBroadcastSchema: () => ServerBroadcastSchema,
15
+ SnapshotMessageSchema: () => SnapshotMessageSchema,
16
+ SubmitResultSchema: () => SubmitResultSchema,
17
+ TransactionMessageSchema: () => TransactionMessageSchema,
18
+ TransactionSchema: () => TransactionSchema
19
+ });
20
+ /**
21
+ * Schema for a transaction operation.
22
+ */
23
+ const OperationSchema = Schema.Struct({
24
+ kind: Schema.String,
25
+ path: Schema.Unknown,
26
+ payload: Schema.Unknown
27
+ });
28
+ /**
29
+ * Schema for a transaction.
30
+ */
31
+ const TransactionSchema = Schema.Struct({
32
+ id: Schema.String,
33
+ ops: Schema.Array(OperationSchema),
34
+ timestamp: Schema.Number
35
+ });
36
+ /**
37
+ * Schema for a server message that broadcasts a committed transaction.
38
+ */
39
+ const TransactionMessageSchema = Schema.Struct({
40
+ type: Schema.Literal("transaction"),
41
+ transaction: TransactionSchema,
42
+ version: Schema.Number
43
+ });
44
+ /**
45
+ * Schema for a server message containing a snapshot.
46
+ */
47
+ const SnapshotMessageSchema = Schema.Struct({
48
+ type: Schema.Literal("snapshot"),
49
+ state: Schema.Unknown,
50
+ version: Schema.Number
51
+ });
52
+ /**
53
+ * Schema for a server error message.
54
+ */
55
+ const ErrorMessageSchema = Schema.Struct({
56
+ type: Schema.Literal("error"),
57
+ transactionId: Schema.String,
58
+ reason: Schema.String
59
+ });
60
+ /**
61
+ * Schema for a pong message.
62
+ */
63
+ const PongMessageSchema = Schema.Struct({ type: Schema.Literal("pong") });
64
+ /**
65
+ * Schema for authentication result message.
66
+ */
67
+ const AuthResultMessageSchema = Schema.Struct({
68
+ type: Schema.Literal("auth_result"),
69
+ success: Schema.Boolean,
70
+ error: Schema.optional(Schema.String)
71
+ });
72
+ /**
73
+ * Union of all server broadcast messages.
74
+ */
75
+ const ServerBroadcastSchema = Schema.Union(TransactionMessageSchema, ErrorMessageSchema);
76
+ /**
77
+ * Result of submitting a transaction.
78
+ */
79
+ const SubmitResultSchema = Schema.Union(Schema.Struct({
80
+ success: Schema.Literal(true),
81
+ version: Schema.Number
82
+ }), Schema.Struct({
83
+ success: Schema.Literal(false),
84
+ reason: Schema.String
85
+ }));
86
+
87
+ //#endregion
88
+ export { DocumentProtocol_exports };
89
+ //# sourceMappingURL=DocumentProtocol.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentProtocol.mjs","names":[],"sources":["../src/DocumentProtocol.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Protocol and schema definitions for document communication.\n */\nimport * as Schema from \"effect/Schema\";\n\n// =============================================================================\n// Schema Definitions\n// =============================================================================\n\n/**\n * Schema for a transaction operation.\n */\nexport const OperationSchema = Schema.Struct({\n kind: Schema.String,\n path: Schema.Unknown, // OperationPath is complex, treat as unknown\n payload: Schema.Unknown,\n});\n\n/**\n * Schema for a transaction.\n */\nexport const TransactionSchema = Schema.Struct({\n id: Schema.String,\n ops: Schema.Array(OperationSchema),\n timestamp: Schema.Number,\n});\n\nexport type Transaction = Schema.Schema.Type<typeof TransactionSchema>;\n\n/**\n * Schema for a server message that broadcasts a committed transaction.\n */\nexport const TransactionMessageSchema = Schema.Struct({\n type: Schema.Literal(\"transaction\"),\n transaction: TransactionSchema,\n version: Schema.Number,\n});\n\nexport type TransactionMessage = Schema.Schema.Type<typeof TransactionMessageSchema>;\n\n/**\n * Schema for a server message containing a snapshot.\n */\nexport const SnapshotMessageSchema = Schema.Struct({\n type: Schema.Literal(\"snapshot\"),\n state: Schema.Unknown,\n version: Schema.Number,\n});\n\nexport type SnapshotMessage = Schema.Schema.Type<typeof SnapshotMessageSchema>;\n\n/**\n * Schema for a server error message.\n */\nexport const ErrorMessageSchema = Schema.Struct({\n type: Schema.Literal(\"error\"),\n transactionId: Schema.String,\n reason: Schema.String,\n});\n\nexport type ErrorMessage = Schema.Schema.Type<typeof ErrorMessageSchema>;\n\n/**\n * Schema for a pong message.\n */\nexport const PongMessageSchema = Schema.Struct({\n type: Schema.Literal(\"pong\"),\n});\n\nexport type PongMessage = Schema.Schema.Type<typeof PongMessageSchema>;\n\n/**\n * Schema for authentication result message.\n */\nexport const AuthResultMessageSchema = Schema.Struct({\n type: Schema.Literal(\"auth_result\"),\n success: Schema.Boolean,\n error: Schema.optional(Schema.String),\n});\n\nexport type AuthResultMessage = Schema.Schema.Type<typeof AuthResultMessageSchema>;\n\n/**\n * Union of all server broadcast messages.\n */\nexport const ServerBroadcastSchema = Schema.Union(\n TransactionMessageSchema,\n ErrorMessageSchema\n);\n\nexport type ServerBroadcast = Schema.Schema.Type<typeof ServerBroadcastSchema>;\n\n// =============================================================================\n// Submit Result\n// =============================================================================\n\n/**\n * Result of submitting a transaction.\n */\nexport const SubmitResultSchema = Schema.Union(\n Schema.Struct({\n success: Schema.Literal(true),\n version: Schema.Number,\n }),\n Schema.Struct({\n success: Schema.Literal(false),\n reason: Schema.String,\n })\n);\n\nexport type SubmitResult = Schema.Schema.Type<typeof SubmitResultSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaA,MAAa,kBAAkB,OAAO,OAAO;CAC3C,MAAM,OAAO;CACb,MAAM,OAAO;CACb,SAAS,OAAO;CACjB,CAAC;;;;AAKF,MAAa,oBAAoB,OAAO,OAAO;CAC7C,IAAI,OAAO;CACX,KAAK,OAAO,MAAM,gBAAgB;CAClC,WAAW,OAAO;CACnB,CAAC;;;;AAOF,MAAa,2BAA2B,OAAO,OAAO;CACpD,MAAM,OAAO,QAAQ,cAAc;CACnC,aAAa;CACb,SAAS,OAAO;CACjB,CAAC;;;;AAOF,MAAa,wBAAwB,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,WAAW;CAChC,OAAO,OAAO;CACd,SAAS,OAAO;CACjB,CAAC;;;;AAOF,MAAa,qBAAqB,OAAO,OAAO;CAC9C,MAAM,OAAO,QAAQ,QAAQ;CAC7B,eAAe,OAAO;CACtB,QAAQ,OAAO;CAChB,CAAC;;;;AAOF,MAAa,oBAAoB,OAAO,OAAO,EAC7C,MAAM,OAAO,QAAQ,OAAO,EAC7B,CAAC;;;;AAOF,MAAa,0BAA0B,OAAO,OAAO;CACnD,MAAM,OAAO,QAAQ,cAAc;CACnC,SAAS,OAAO;CAChB,OAAO,OAAO,SAAS,OAAO,OAAO;CACtC,CAAC;;;;AAOF,MAAa,wBAAwB,OAAO,MAC1C,0BACA,mBACD;;;;AAWD,MAAa,qBAAqB,OAAO,MACvC,OAAO,OAAO;CACZ,SAAS,OAAO,QAAQ,KAAK;CAC7B,SAAS,OAAO;CACjB,CAAC,EACF,OAAO,OAAO;CACZ,SAAS,OAAO,QAAQ,MAAM;CAC9B,QAAQ,OAAO;CAChB,CAAC,CACH"}
@@ -0,0 +1,55 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let effect_Effect = require("effect/Effect");
3
+ effect_Effect = require_rolldown_runtime.__toESM(effect_Effect);
4
+ let effect_Layer = require("effect/Layer");
5
+ effect_Layer = require_rolldown_runtime.__toESM(effect_Layer);
6
+ let effect_Context = require("effect/Context");
7
+ effect_Context = require_rolldown_runtime.__toESM(effect_Context);
8
+
9
+ //#region src/MimicAuthService.ts
10
+ /**
11
+ * @since 0.0.1
12
+ * Authentication service interface for Mimic connections.
13
+ * Provides pluggable authentication adapters.
14
+ */
15
+ var MimicAuthService_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
16
+ MimicAuthServiceTag: () => MimicAuthServiceTag,
17
+ layer: () => layer,
18
+ layerEffect: () => layerEffect,
19
+ layerService: () => layerService,
20
+ make: () => make,
21
+ makeEffect: () => makeEffect
22
+ });
23
+ /**
24
+ * Context tag for MimicAuthService service.
25
+ */
26
+ var MimicAuthServiceTag = class extends effect_Context.Tag("@voidhash/mimic-server-effect/MimicAuthService")() {};
27
+ /**
28
+ * Create a MimicAuthService layer from an auth handler function.
29
+ */
30
+ const layer = (options) => effect_Layer.succeed(MimicAuthServiceTag, { authenticate: (token) => effect_Effect.promise(() => Promise.resolve(options.authHandler(token))) });
31
+ /**
32
+ * Create a MimicAuthService layer from an auth service implementation.
33
+ */
34
+ const layerService = (service) => effect_Layer.succeed(MimicAuthServiceTag, service);
35
+ /**
36
+ * Create a MimicAuthService layer from an Effect that produces an auth service.
37
+ */
38
+ const layerEffect = (effect) => effect_Layer.effect(MimicAuthServiceTag, effect);
39
+ /**
40
+ * Create an auth service from an auth handler function.
41
+ */
42
+ const make = (authHandler) => ({ authenticate: (token) => effect_Effect.promise(() => Promise.resolve(authHandler(token))) });
43
+ /**
44
+ * Create an auth service from an Effect-based authenticate function.
45
+ */
46
+ const makeEffect = (authenticate) => ({ authenticate });
47
+
48
+ //#endregion
49
+ exports.MimicAuthServiceTag = MimicAuthServiceTag;
50
+ Object.defineProperty(exports, 'MimicAuthService_exports', {
51
+ enumerable: true,
52
+ get: function () {
53
+ return MimicAuthService_exports;
54
+ }
55
+ });
@@ -0,0 +1,65 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
3
+ import * as Context from "effect/Context";
4
+
5
+ //#region src/MimicAuthService.d.ts
6
+ declare namespace MimicAuthService_d_exports {
7
+ export { AuthHandler, AuthResult, MimicAuthService, MimicAuthServiceTag, layer, layerEffect, layerService, make, makeEffect };
8
+ }
9
+ /**
10
+ * Result of an authentication attempt.
11
+ */
12
+ type AuthResult = {
13
+ readonly success: true;
14
+ readonly userId?: string;
15
+ } | {
16
+ readonly success: false;
17
+ readonly error: string;
18
+ };
19
+ /**
20
+ * Authentication handler function type.
21
+ * Can be synchronous or return a Promise.
22
+ */
23
+ type AuthHandler = (token: string) => Promise<AuthResult> | AuthResult;
24
+ /**
25
+ * Authentication service interface.
26
+ * Implementations can authenticate connections using various methods (JWT, API keys, etc.)
27
+ */
28
+ interface MimicAuthService {
29
+ /**
30
+ * Authenticate a connection using the provided token.
31
+ * @param token - The authentication token provided by the client
32
+ * @returns The authentication result
33
+ */
34
+ readonly authenticate: (token: string) => Effect.Effect<AuthResult>;
35
+ }
36
+ declare const MimicAuthServiceTag_base: Context.TagClass<MimicAuthServiceTag, "@voidhash/mimic-server-effect/MimicAuthService", MimicAuthService>;
37
+ /**
38
+ * Context tag for MimicAuthService service.
39
+ */
40
+ declare class MimicAuthServiceTag extends MimicAuthServiceTag_base {}
41
+ /**
42
+ * Create a MimicAuthService layer from an auth handler function.
43
+ */
44
+ declare const layer: (options: {
45
+ readonly authHandler: AuthHandler;
46
+ }) => Layer.Layer<MimicAuthServiceTag>;
47
+ /**
48
+ * Create a MimicAuthService layer from an auth service implementation.
49
+ */
50
+ declare const layerService: (service: MimicAuthService) => Layer.Layer<MimicAuthServiceTag>;
51
+ /**
52
+ * Create a MimicAuthService layer from an Effect that produces an auth service.
53
+ */
54
+ declare const layerEffect: <E, R>(effect: Effect.Effect<MimicAuthService, E, R>) => Layer.Layer<MimicAuthServiceTag, E, R>;
55
+ /**
56
+ * Create an auth service from an auth handler function.
57
+ */
58
+ declare const make: (authHandler: AuthHandler) => MimicAuthService;
59
+ /**
60
+ * Create an auth service from an Effect-based authenticate function.
61
+ */
62
+ declare const makeEffect: (authenticate: (token: string) => Effect.Effect<AuthResult>) => MimicAuthService;
63
+ //#endregion
64
+ export { MimicAuthServiceTag, MimicAuthService_d_exports };
65
+ //# sourceMappingURL=MimicAuthService.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MimicAuthService.d.cts","names":[],"sources":["../src/MimicAuthService.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KAgBY,UAAA;;;;;;AAAZ,CAAA;AAQA;;;;AAA6E,KAAjE,WAAA,GAAiE,CAAA,KAAA,EAAA,MAAA,EAAA,GAAhC,OAAgC,CAAxB,UAAwB,CAAA,GAAV,UAAU;AAU7E;AAOC;;;UAPgB,gBAAA;;AAgBjB;AAWA;;;EAEI,SAAM,YAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAvBkC,MAAA,CAAO,MAuBzC,CAvBgD,UAuBhD,CAAA;;AASV,cA/BC,wBAgC4C,kBAAA,oBAAA,EAAA,gDAAA,kBAAA,CAAA;;;;AADuB,cAtBvD,mBAAA,SAA4B,wBAAA,CAsB2B;;;;AAO1D,cAlBG,KAkBI,EAAA,CAAA,OAAA,EAAA;EACF,SAAA,WAAA,EAlBS,WAkBT;CAAqB,EAAA,GAjBhC,KAAA,CAAM,KAiB0B,CAjBpB,mBAiBoB,CAAA;;;;AAUvB,cAlBA,YAkBqB,EAAA,CAAc,OAAA,EAlBV,gBAqBpC,EAAA,GArBuD,KAAA,CAAM,KAqB7D,CArBmE,mBAqBnE,CAAA;AAKF;;;AAEG,cAtBU,WAsBV,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,EArBO,MAAA,CAAO,MAqBd,CArBqB,gBAqBrB,EArBuC,CAqBvC,EArB0C,CAqB1C,CAAA,EAAA,GApBA,KAAA,CAAM,KAoBN,CApBY,mBAoBZ,EApBiC,CAoBjC,EApBoC,CAoBpC,CAAA;;;;cAVU,oBAAqB,gBAAc;;;;cAQnC,8CACsB,MAAA,CAAO,OAAO,gBAC9C"}
@@ -0,0 +1,65 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
3
+ import * as Context from "effect/Context";
4
+
5
+ //#region src/MimicAuthService.d.ts
6
+ declare namespace MimicAuthService_d_exports {
7
+ export { AuthHandler, AuthResult, MimicAuthService, MimicAuthServiceTag, layer, layerEffect, layerService, make, makeEffect };
8
+ }
9
+ /**
10
+ * Result of an authentication attempt.
11
+ */
12
+ type AuthResult = {
13
+ readonly success: true;
14
+ readonly userId?: string;
15
+ } | {
16
+ readonly success: false;
17
+ readonly error: string;
18
+ };
19
+ /**
20
+ * Authentication handler function type.
21
+ * Can be synchronous or return a Promise.
22
+ */
23
+ type AuthHandler = (token: string) => Promise<AuthResult> | AuthResult;
24
+ /**
25
+ * Authentication service interface.
26
+ * Implementations can authenticate connections using various methods (JWT, API keys, etc.)
27
+ */
28
+ interface MimicAuthService {
29
+ /**
30
+ * Authenticate a connection using the provided token.
31
+ * @param token - The authentication token provided by the client
32
+ * @returns The authentication result
33
+ */
34
+ readonly authenticate: (token: string) => Effect.Effect<AuthResult>;
35
+ }
36
+ declare const MimicAuthServiceTag_base: Context.TagClass<MimicAuthServiceTag, "@voidhash/mimic-server-effect/MimicAuthService", MimicAuthService>;
37
+ /**
38
+ * Context tag for MimicAuthService service.
39
+ */
40
+ declare class MimicAuthServiceTag extends MimicAuthServiceTag_base {}
41
+ /**
42
+ * Create a MimicAuthService layer from an auth handler function.
43
+ */
44
+ declare const layer: (options: {
45
+ readonly authHandler: AuthHandler;
46
+ }) => Layer.Layer<MimicAuthServiceTag>;
47
+ /**
48
+ * Create a MimicAuthService layer from an auth service implementation.
49
+ */
50
+ declare const layerService: (service: MimicAuthService) => Layer.Layer<MimicAuthServiceTag>;
51
+ /**
52
+ * Create a MimicAuthService layer from an Effect that produces an auth service.
53
+ */
54
+ declare const layerEffect: <E, R>(effect: Effect.Effect<MimicAuthService, E, R>) => Layer.Layer<MimicAuthServiceTag, E, R>;
55
+ /**
56
+ * Create an auth service from an auth handler function.
57
+ */
58
+ declare const make: (authHandler: AuthHandler) => MimicAuthService;
59
+ /**
60
+ * Create an auth service from an Effect-based authenticate function.
61
+ */
62
+ declare const makeEffect: (authenticate: (token: string) => Effect.Effect<AuthResult>) => MimicAuthService;
63
+ //#endregion
64
+ export { MimicAuthServiceTag, MimicAuthService_d_exports };
65
+ //# sourceMappingURL=MimicAuthService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MimicAuthService.d.mts","names":[],"sources":["../src/MimicAuthService.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KAgBY,UAAA;;;;;;AAAZ,CAAA;AAQA;;;;AAA6E,KAAjE,WAAA,GAAiE,CAAA,KAAA,EAAA,MAAA,EAAA,GAAhC,OAAgC,CAAxB,UAAwB,CAAA,GAAV,UAAU;AAU7E;AAOC;;;UAPgB,gBAAA;;AAgBjB;AAWA;;;EAEI,SAAM,YAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAvBkC,MAAA,CAAO,MAuBzC,CAvBgD,UAuBhD,CAAA;;AASV,cA/BC,wBAgC4C,kBAAA,oBAAA,EAAA,gDAAA,kBAAA,CAAA;;;;AADuB,cAtBvD,mBAAA,SAA4B,wBAAA,CAsB2B;;;;AAO1D,cAlBG,KAkBI,EAAA,CAAA,OAAA,EAAA;EACF,SAAA,WAAA,EAlBS,WAkBT;CAAqB,EAAA,GAjBhC,KAAA,CAAM,KAiB0B,CAjBpB,mBAiBoB,CAAA;;;;AAUvB,cAlBA,YAkBqB,EAAA,CAAc,OAAA,EAlBV,gBAqBpC,EAAA,GArBuD,KAAA,CAAM,KAqB7D,CArBmE,mBAqBnE,CAAA;AAKF;;;AAEG,cAtBU,WAsBV,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,EArBO,MAAA,CAAO,MAqBd,CArBqB,gBAqBrB,EArBuC,CAqBvC,EArB0C,CAqB1C,CAAA,EAAA,GApBA,KAAA,CAAM,KAoBN,CApBY,mBAoBZ,EApBiC,CAoBjC,EApBoC,CAoBpC,CAAA;;;;cAVU,oBAAqB,gBAAc;;;;cAQnC,8CACsB,MAAA,CAAO,OAAO,gBAC9C"}
@@ -0,0 +1,47 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Context from "effect/Context";
5
+
6
+ //#region src/MimicAuthService.ts
7
+ /**
8
+ * @since 0.0.1
9
+ * Authentication service interface for Mimic connections.
10
+ * Provides pluggable authentication adapters.
11
+ */
12
+ var MimicAuthService_exports = /* @__PURE__ */ __export({
13
+ MimicAuthServiceTag: () => MimicAuthServiceTag,
14
+ layer: () => layer,
15
+ layerEffect: () => layerEffect,
16
+ layerService: () => layerService,
17
+ make: () => make,
18
+ makeEffect: () => makeEffect
19
+ });
20
+ /**
21
+ * Context tag for MimicAuthService service.
22
+ */
23
+ var MimicAuthServiceTag = class extends Context.Tag("@voidhash/mimic-server-effect/MimicAuthService")() {};
24
+ /**
25
+ * Create a MimicAuthService layer from an auth handler function.
26
+ */
27
+ const layer = (options) => Layer.succeed(MimicAuthServiceTag, { authenticate: (token) => Effect.promise(() => Promise.resolve(options.authHandler(token))) });
28
+ /**
29
+ * Create a MimicAuthService layer from an auth service implementation.
30
+ */
31
+ const layerService = (service) => Layer.succeed(MimicAuthServiceTag, service);
32
+ /**
33
+ * Create a MimicAuthService layer from an Effect that produces an auth service.
34
+ */
35
+ const layerEffect = (effect) => Layer.effect(MimicAuthServiceTag, effect);
36
+ /**
37
+ * Create an auth service from an auth handler function.
38
+ */
39
+ const make = (authHandler) => ({ authenticate: (token) => Effect.promise(() => Promise.resolve(authHandler(token))) });
40
+ /**
41
+ * Create an auth service from an Effect-based authenticate function.
42
+ */
43
+ const makeEffect = (authenticate) => ({ authenticate });
44
+
45
+ //#endregion
46
+ export { MimicAuthServiceTag, MimicAuthService_exports };
47
+ //# sourceMappingURL=MimicAuthService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MimicAuthService.mjs","names":[],"sources":["../src/MimicAuthService.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Authentication service interface for Mimic connections.\n * Provides pluggable authentication adapters.\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\n\n// =============================================================================\n// Authentication Types\n// =============================================================================\n\n/**\n * Result of an authentication attempt.\n */\nexport type AuthResult =\n | { readonly success: true; readonly userId?: string }\n | { readonly success: false; readonly error: string };\n\n/**\n * Authentication handler function type.\n * Can be synchronous or return a Promise.\n */\nexport type AuthHandler = (token: string) => Promise<AuthResult> | AuthResult;\n\n// =============================================================================\n// Auth Service Interface\n// =============================================================================\n\n/**\n * Authentication service interface.\n * Implementations can authenticate connections using various methods (JWT, API keys, etc.)\n */\nexport interface MimicAuthService {\n /**\n * Authenticate a connection using the provided token.\n * @param token - The authentication token provided by the client\n * @returns The authentication result\n */\n readonly authenticate: (token: string) => Effect.Effect<AuthResult>;\n}\n\n// =============================================================================\n// Context Tag\n// =============================================================================\n\n/**\n * Context tag for MimicAuthService service.\n */\nexport class MimicAuthServiceTag extends Context.Tag(\n \"@voidhash/mimic-server-effect/MimicAuthService\"\n)<MimicAuthServiceTag, MimicAuthService>() {}\n\n// =============================================================================\n// Layer Constructors\n// =============================================================================\n\n/**\n * Create a MimicAuthService layer from an auth handler function.\n */\nexport const layer = (options: {\n readonly authHandler: AuthHandler;\n}): Layer.Layer<MimicAuthServiceTag> =>\n Layer.succeed(MimicAuthServiceTag, {\n authenticate: (token: string) =>\n Effect.promise(() => Promise.resolve(options.authHandler(token))),\n });\n\n/**\n * Create a MimicAuthService layer from an auth service implementation.\n */\nexport const layerService = (service: MimicAuthService): Layer.Layer<MimicAuthServiceTag> =>\n Layer.succeed(MimicAuthServiceTag, service);\n\n/**\n * Create a MimicAuthService layer from an Effect that produces an auth service.\n */\nexport const layerEffect = <E, R>(\n effect: Effect.Effect<MimicAuthService, E, R>\n): Layer.Layer<MimicAuthServiceTag, E, R> =>\n Layer.effect(MimicAuthServiceTag, effect);\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\n/**\n * Create an auth service from an auth handler function.\n */\nexport const make = (authHandler: AuthHandler): MimicAuthService => ({\n authenticate: (token: string) =>\n Effect.promise(() => Promise.resolve(authHandler(token))),\n});\n\n/**\n * Create an auth service from an Effect-based authenticate function.\n */\nexport const makeEffect = (\n authenticate: (token: string) => Effect.Effect<AuthResult>\n): MimicAuthService => ({\n authenticate,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAa,sBAAb,cAAyC,QAAQ,IAC/C,iDACD,EAAyC,CAAC;;;;AAS3C,MAAa,SAAS,YAGpB,MAAM,QAAQ,qBAAqB,EACjC,eAAe,UACb,OAAO,cAAc,QAAQ,QAAQ,QAAQ,YAAY,MAAM,CAAC,CAAC,EACpE,CAAC;;;;AAKJ,MAAa,gBAAgB,YAC3B,MAAM,QAAQ,qBAAqB,QAAQ;;;;AAK7C,MAAa,eACX,WAEA,MAAM,OAAO,qBAAqB,OAAO;;;;AAS3C,MAAa,QAAQ,iBAAgD,EACnE,eAAe,UACb,OAAO,cAAc,QAAQ,QAAQ,YAAY,MAAM,CAAC,CAAC,EAC5D;;;;AAKD,MAAa,cACX,kBACsB,EACtB,cACD"}
@@ -0,0 +1,50 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let effect_Layer = require("effect/Layer");
3
+ effect_Layer = require_rolldown_runtime.__toESM(effect_Layer);
4
+ let effect_Context = require("effect/Context");
5
+ effect_Context = require_rolldown_runtime.__toESM(effect_Context);
6
+ let effect_Duration = require("effect/Duration");
7
+ effect_Duration = require_rolldown_runtime.__toESM(effect_Duration);
8
+
9
+ //#region src/MimicConfig.ts
10
+ /**
11
+ * @since 0.0.1
12
+ * Configuration types for the Mimic server.
13
+ */
14
+ var MimicConfig_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
15
+ MimicServerConfigTag: () => MimicServerConfigTag,
16
+ layer: () => layer,
17
+ make: () => make
18
+ });
19
+ /**
20
+ * Create a MimicServerConfig from options.
21
+ */
22
+ const make = (options) => {
23
+ var _options$maxIdleTime, _options$maxTransacti, _options$heartbeatInt, _options$heartbeatTim;
24
+ return {
25
+ schema: options.schema,
26
+ maxIdleTime: effect_Duration.decode((_options$maxIdleTime = options.maxIdleTime) !== null && _options$maxIdleTime !== void 0 ? _options$maxIdleTime : "5 minutes"),
27
+ maxTransactionHistory: (_options$maxTransacti = options.maxTransactionHistory) !== null && _options$maxTransacti !== void 0 ? _options$maxTransacti : 1e3,
28
+ heartbeatInterval: effect_Duration.decode((_options$heartbeatInt = options.heartbeatInterval) !== null && _options$heartbeatInt !== void 0 ? _options$heartbeatInt : "30 seconds"),
29
+ heartbeatTimeout: effect_Duration.decode((_options$heartbeatTim = options.heartbeatTimeout) !== null && _options$heartbeatTim !== void 0 ? _options$heartbeatTim : "10 seconds"),
30
+ presence: options.presence
31
+ };
32
+ };
33
+ /**
34
+ * Context tag for MimicServerConfig.
35
+ */
36
+ var MimicServerConfigTag = class extends effect_Context.Tag("@voidhash/mimic-server-effect/MimicServerConfig")() {};
37
+ /**
38
+ * Create a Layer that provides MimicServerConfig.
39
+ */
40
+ const layer = (options) => effect_Layer.succeed(MimicServerConfigTag, make(options));
41
+
42
+ //#endregion
43
+ Object.defineProperty(exports, 'MimicConfig_exports', {
44
+ enumerable: true,
45
+ get: function () {
46
+ return MimicConfig_exports;
47
+ }
48
+ });
49
+ exports.MimicServerConfigTag = MimicServerConfigTag;
50
+ exports.layer = layer;