@ohos-ports/rivetkit-effect 2.3.17-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/Action.d.ts +104 -0
  2. package/dist/Action.d.ts.map +1 -0
  3. package/dist/Action.js +50 -0
  4. package/dist/Action.js.map +1 -0
  5. package/dist/Actor.d.ts +132 -0
  6. package/dist/Actor.d.ts.map +1 -0
  7. package/dist/Actor.js +104 -0
  8. package/dist/Actor.js.map +1 -0
  9. package/dist/Client.d.ts +31 -0
  10. package/dist/Client.d.ts.map +1 -0
  11. package/dist/Client.js +100 -0
  12. package/dist/Client.js.map +1 -0
  13. package/dist/Registry.d.ts +134 -0
  14. package/dist/Registry.d.ts.map +1 -0
  15. package/dist/Registry.js +178 -0
  16. package/dist/Registry.js.map +1 -0
  17. package/dist/RivetError.d.ts +480 -0
  18. package/dist/RivetError.d.ts.map +1 -0
  19. package/dist/RivetError.js +985 -0
  20. package/dist/RivetError.js.map +1 -0
  21. package/dist/RivetLogger.d.ts +41 -0
  22. package/dist/RivetLogger.d.ts.map +1 -0
  23. package/dist/RivetLogger.js +41 -0
  24. package/dist/RivetLogger.js.map +1 -0
  25. package/dist/State.d.ts +159 -0
  26. package/dist/State.d.ts.map +1 -0
  27. package/dist/State.js +98 -0
  28. package/dist/State.js.map +1 -0
  29. package/dist/internal/ActionDispatcher.d.ts +14 -0
  30. package/dist/internal/ActionDispatcher.d.ts.map +1 -0
  31. package/dist/internal/ActionDispatcher.js +100 -0
  32. package/dist/internal/ActionDispatcher.js.map +1 -0
  33. package/dist/internal/ActionErrorEnvelope.d.ts +11 -0
  34. package/dist/internal/ActionErrorEnvelope.d.ts.map +1 -0
  35. package/dist/internal/ActionErrorEnvelope.js +14 -0
  36. package/dist/internal/ActionErrorEnvelope.js.map +1 -0
  37. package/dist/internal/ActorInstanceManager.d.ts +28 -0
  38. package/dist/internal/ActorInstanceManager.d.ts.map +1 -0
  39. package/dist/internal/ActorInstanceManager.js +51 -0
  40. package/dist/internal/ActorInstanceManager.js.map +1 -0
  41. package/dist/internal/ActorStateAdapter.d.ts +18 -0
  42. package/dist/internal/ActorStateAdapter.d.ts.map +1 -0
  43. package/dist/internal/ActorStateAdapter.js +24 -0
  44. package/dist/internal/ActorStateAdapter.js.map +1 -0
  45. package/dist/internal/StateOptions.d.ts +13 -0
  46. package/dist/internal/StateOptions.d.ts.map +1 -0
  47. package/dist/internal/StateOptions.js +2 -0
  48. package/dist/internal/StateOptions.js.map +1 -0
  49. package/dist/internal/logging.d.ts +22 -0
  50. package/dist/internal/logging.d.ts.map +1 -0
  51. package/dist/internal/logging.js +138 -0
  52. package/dist/internal/logging.js.map +1 -0
  53. package/dist/internal/tracing.d.ts +23 -0
  54. package/dist/internal/tracing.d.ts.map +1 -0
  55. package/dist/internal/tracing.js +30 -0
  56. package/dist/internal/tracing.js.map +1 -0
  57. package/dist/internal/utils.d.ts +7 -0
  58. package/dist/internal/utils.d.ts.map +1 -0
  59. package/dist/internal/utils.js +7 -0
  60. package/dist/internal/utils.js.map +1 -0
  61. package/dist/mod.d.ts +8 -0
  62. package/dist/mod.d.ts.map +1 -0
  63. package/dist/mod.js +8 -0
  64. package/dist/mod.js.map +1 -0
  65. package/package.json +56 -0
  66. package/src/Action.ts +231 -0
  67. package/src/Actor.test-d.ts +641 -0
  68. package/src/Actor.test.ts +209 -0
  69. package/src/Actor.ts +575 -0
  70. package/src/Client.test.ts +206 -0
  71. package/src/Client.ts +218 -0
  72. package/src/Registry.test-d.ts +126 -0
  73. package/src/Registry.test.ts +400 -0
  74. package/src/Registry.ts +304 -0
  75. package/src/RivetError.test.ts +199 -0
  76. package/src/RivetError.ts +1163 -0
  77. package/src/RivetLogger.ts +60 -0
  78. package/src/State.test.ts +340 -0
  79. package/src/State.ts +420 -0
  80. package/src/internal/ActionDispatcher.ts +189 -0
  81. package/src/internal/ActionErrorEnvelope.ts +19 -0
  82. package/src/internal/ActorInstanceManager.ts +137 -0
  83. package/src/internal/ActorStateAdapter.ts +82 -0
  84. package/src/internal/StateOptions.ts +21 -0
  85. package/src/internal/logging.test.ts +274 -0
  86. package/src/internal/logging.ts +197 -0
  87. package/src/internal/tracing.ts +42 -0
  88. package/src/internal/utils.ts +12 -0
  89. package/src/mod.ts +7 -0
@@ -0,0 +1,985 @@
1
+ import { Duration, Option, Predicate, Record, Schema } from "effect";
2
+ import * as RivetkitErrors from "@ohos-ports/rivetkit/errors";
3
+ const ReasonTypeId = "~@rivetkit/effect/RivetError/Reason";
4
+ const TypeId = "~@rivetkit/effect/RivetError";
5
+ export class Forbidden extends Schema.TaggedErrorClass(`${ReasonTypeId}/Forbidden`)("Forbidden", {
6
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
7
+ }) {
8
+ [ReasonTypeId] = ReasonTypeId;
9
+ get message() {
10
+ return this.cause.message;
11
+ }
12
+ get group() {
13
+ return this.cause.group;
14
+ }
15
+ get code() {
16
+ return this.cause.code;
17
+ }
18
+ get metadata() {
19
+ return this.cause.metadata;
20
+ }
21
+ get actor() {
22
+ return this.cause.actor;
23
+ }
24
+ get statusCode() {
25
+ return this.cause.statusCode;
26
+ }
27
+ get public() {
28
+ return this.cause.public;
29
+ }
30
+ get rayId() {
31
+ return this.cause.rayId;
32
+ }
33
+ get isRetryable() {
34
+ return false;
35
+ }
36
+ }
37
+ export class ActorNotFound extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActorNotFound`)("ActorNotFound", {
38
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
39
+ }) {
40
+ [ReasonTypeId] = ReasonTypeId;
41
+ get message() {
42
+ return this.cause.message;
43
+ }
44
+ get group() {
45
+ return this.cause.group;
46
+ }
47
+ get code() {
48
+ return this.cause.code;
49
+ }
50
+ get metadata() {
51
+ return this.cause.metadata;
52
+ }
53
+ get actor() {
54
+ return this.cause.actor;
55
+ }
56
+ get statusCode() {
57
+ return this.cause.statusCode;
58
+ }
59
+ get public() {
60
+ return this.cause.public;
61
+ }
62
+ get rayId() {
63
+ return this.cause.rayId;
64
+ }
65
+ get isRetryable() {
66
+ return false;
67
+ }
68
+ }
69
+ export class ActorStopping extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActorStopping`)("ActorStopping", {
70
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
71
+ }) {
72
+ [ReasonTypeId] = ReasonTypeId;
73
+ get message() {
74
+ return this.cause.message;
75
+ }
76
+ get group() {
77
+ return this.cause.group;
78
+ }
79
+ get code() {
80
+ return this.cause.code;
81
+ }
82
+ get metadata() {
83
+ return this.cause.metadata;
84
+ }
85
+ get actor() {
86
+ return this.cause.actor;
87
+ }
88
+ get statusCode() {
89
+ return this.cause.statusCode;
90
+ }
91
+ get public() {
92
+ return this.cause.public;
93
+ }
94
+ get rayId() {
95
+ return this.cause.rayId;
96
+ }
97
+ get isRetryable() {
98
+ return true;
99
+ }
100
+ }
101
+ export class ActorRestarting extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActorRestarting`)("ActorRestarting", {
102
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
103
+ }) {
104
+ [ReasonTypeId] = ReasonTypeId;
105
+ get message() {
106
+ return this.cause.message;
107
+ }
108
+ get group() {
109
+ return this.cause.group;
110
+ }
111
+ get code() {
112
+ return this.cause.code;
113
+ }
114
+ get metadata() {
115
+ return this.cause.metadata;
116
+ }
117
+ get actor() {
118
+ return this.cause.actor;
119
+ }
120
+ get statusCode() {
121
+ return this.cause.statusCode;
122
+ }
123
+ get public() {
124
+ return this.cause.public;
125
+ }
126
+ get rayId() {
127
+ return this.cause.rayId;
128
+ }
129
+ get isRetryable() {
130
+ return true;
131
+ }
132
+ get retryAfter() {
133
+ if (!Predicate.isReadonlyObject(this.metadata))
134
+ return undefined;
135
+ return Record.get(this.metadata, "retryAfterMs").pipe(Option.filter(Predicate.isNumber), Option.map(Duration.millis), Option.getOrUndefined);
136
+ }
137
+ }
138
+ export class ActionNotFound extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActionNotFound`)("ActionNotFound", {
139
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
140
+ }) {
141
+ [ReasonTypeId] = ReasonTypeId;
142
+ get message() {
143
+ return this.cause.message;
144
+ }
145
+ get group() {
146
+ return this.cause.group;
147
+ }
148
+ get code() {
149
+ return this.cause.code;
150
+ }
151
+ get metadata() {
152
+ return this.cause.metadata;
153
+ }
154
+ get actor() {
155
+ return this.cause.actor;
156
+ }
157
+ get statusCode() {
158
+ return this.cause.statusCode;
159
+ }
160
+ get public() {
161
+ return this.cause.public;
162
+ }
163
+ get rayId() {
164
+ return this.cause.rayId;
165
+ }
166
+ get isRetryable() {
167
+ return false;
168
+ }
169
+ }
170
+ export class ActionTimedOut extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActionTimedOut`)("ActionTimedOut", { cause: Schema.instanceOf(RivetkitErrors.RivetError) }) {
171
+ [ReasonTypeId] = ReasonTypeId;
172
+ get message() {
173
+ return this.cause.message;
174
+ }
175
+ get group() {
176
+ return this.cause.group;
177
+ }
178
+ get code() {
179
+ return this.cause.code;
180
+ }
181
+ get metadata() {
182
+ return this.cause.metadata;
183
+ }
184
+ get actor() {
185
+ return this.cause.actor;
186
+ }
187
+ get statusCode() {
188
+ return this.cause.statusCode;
189
+ }
190
+ get public() {
191
+ return this.cause.public;
192
+ }
193
+ get rayId() {
194
+ return this.cause.rayId;
195
+ }
196
+ get isRetryable() {
197
+ return true;
198
+ }
199
+ }
200
+ export class ActionAborted extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActionAborted`)("ActionAborted", {
201
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
202
+ }) {
203
+ [ReasonTypeId] = ReasonTypeId;
204
+ get message() {
205
+ return this.cause.message;
206
+ }
207
+ get group() {
208
+ return this.cause.group;
209
+ }
210
+ get code() {
211
+ return this.cause.code;
212
+ }
213
+ get metadata() {
214
+ return this.cause.metadata;
215
+ }
216
+ get actor() {
217
+ return this.cause.actor;
218
+ }
219
+ get statusCode() {
220
+ return this.cause.statusCode;
221
+ }
222
+ get public() {
223
+ return this.cause.public;
224
+ }
225
+ get rayId() {
226
+ return this.cause.rayId;
227
+ }
228
+ get isRetryable() {
229
+ return false;
230
+ }
231
+ }
232
+ export class ActorOverloaded extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActorOverloaded`)("ActorOverloaded", {
233
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
234
+ }) {
235
+ [ReasonTypeId] = ReasonTypeId;
236
+ get message() {
237
+ return this.cause.message;
238
+ }
239
+ get group() {
240
+ return this.cause.group;
241
+ }
242
+ get code() {
243
+ return this.cause.code;
244
+ }
245
+ get metadata() {
246
+ return this.cause.metadata;
247
+ }
248
+ get actor() {
249
+ return this.cause.actor;
250
+ }
251
+ get statusCode() {
252
+ return this.cause.statusCode;
253
+ }
254
+ get public() {
255
+ return this.cause.public;
256
+ }
257
+ get rayId() {
258
+ return this.cause.rayId;
259
+ }
260
+ get isRetryable() {
261
+ return true;
262
+ }
263
+ }
264
+ export class IncomingMessageTooLong extends Schema.TaggedErrorClass(`${ReasonTypeId}/IncomingMessageTooLong`)("IncomingMessageTooLong", {
265
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
266
+ }) {
267
+ [ReasonTypeId] = ReasonTypeId;
268
+ get message() {
269
+ return this.cause.message;
270
+ }
271
+ get group() {
272
+ return this.cause.group;
273
+ }
274
+ get code() {
275
+ return this.cause.code;
276
+ }
277
+ get metadata() {
278
+ return this.cause.metadata;
279
+ }
280
+ get actor() {
281
+ return this.cause.actor;
282
+ }
283
+ get statusCode() {
284
+ return this.cause.statusCode;
285
+ }
286
+ get public() {
287
+ return this.cause.public;
288
+ }
289
+ get rayId() {
290
+ return this.cause.rayId;
291
+ }
292
+ get isRetryable() {
293
+ return false;
294
+ }
295
+ }
296
+ export class OutgoingMessageTooLong extends Schema.TaggedErrorClass(`${ReasonTypeId}/OutgoingMessageTooLong`)("OutgoingMessageTooLong", {
297
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
298
+ }) {
299
+ [ReasonTypeId] = ReasonTypeId;
300
+ get message() {
301
+ return this.cause.message;
302
+ }
303
+ get group() {
304
+ return this.cause.group;
305
+ }
306
+ get code() {
307
+ return this.cause.code;
308
+ }
309
+ get metadata() {
310
+ return this.cause.metadata;
311
+ }
312
+ get actor() {
313
+ return this.cause.actor;
314
+ }
315
+ get statusCode() {
316
+ return this.cause.statusCode;
317
+ }
318
+ get public() {
319
+ return this.cause.public;
320
+ }
321
+ get rayId() {
322
+ return this.cause.rayId;
323
+ }
324
+ get isRetryable() {
325
+ return false;
326
+ }
327
+ }
328
+ export class InvalidEncoding extends Schema.TaggedErrorClass(`${ReasonTypeId}/InvalidEncoding`)("InvalidEncoding", {
329
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
330
+ }) {
331
+ [ReasonTypeId] = ReasonTypeId;
332
+ get message() {
333
+ return this.cause.message;
334
+ }
335
+ get group() {
336
+ return this.cause.group;
337
+ }
338
+ get code() {
339
+ return this.cause.code;
340
+ }
341
+ get metadata() {
342
+ return this.cause.metadata;
343
+ }
344
+ get actor() {
345
+ return this.cause.actor;
346
+ }
347
+ get statusCode() {
348
+ return this.cause.statusCode;
349
+ }
350
+ get public() {
351
+ return this.cause.public;
352
+ }
353
+ get rayId() {
354
+ return this.cause.rayId;
355
+ }
356
+ get isRetryable() {
357
+ return false;
358
+ }
359
+ }
360
+ export class InvalidRequest extends Schema.TaggedErrorClass(`${ReasonTypeId}/InvalidRequest`)("InvalidRequest", {
361
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
362
+ }) {
363
+ [ReasonTypeId] = ReasonTypeId;
364
+ get message() {
365
+ return this.cause.message;
366
+ }
367
+ get group() {
368
+ return this.cause.group;
369
+ }
370
+ get code() {
371
+ return this.cause.code;
372
+ }
373
+ get metadata() {
374
+ return this.cause.metadata;
375
+ }
376
+ get actor() {
377
+ return this.cause.actor;
378
+ }
379
+ get statusCode() {
380
+ return this.cause.statusCode;
381
+ }
382
+ get public() {
383
+ return this.cause.public;
384
+ }
385
+ get rayId() {
386
+ return this.cause.rayId;
387
+ }
388
+ get isRetryable() {
389
+ return false;
390
+ }
391
+ }
392
+ export class GuardActorReadyTimeout extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardActorReadyTimeout`)("GuardActorReadyTimeout", {
393
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
394
+ }) {
395
+ [ReasonTypeId] = ReasonTypeId;
396
+ get message() {
397
+ return this.cause.message;
398
+ }
399
+ get group() {
400
+ return this.cause.group;
401
+ }
402
+ get code() {
403
+ return this.cause.code;
404
+ }
405
+ get metadata() {
406
+ return this.cause.metadata;
407
+ }
408
+ get actor() {
409
+ return this.cause.actor;
410
+ }
411
+ get statusCode() {
412
+ return this.cause.statusCode;
413
+ }
414
+ get public() {
415
+ return this.cause.public;
416
+ }
417
+ get rayId() {
418
+ return this.cause.rayId;
419
+ }
420
+ get isRetryable() {
421
+ return true;
422
+ }
423
+ }
424
+ export class GuardActorWakeRetriesExceeded extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardActorWakeRetriesExceeded`)("GuardActorWakeRetriesExceeded", {
425
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
426
+ }) {
427
+ [ReasonTypeId] = ReasonTypeId;
428
+ get message() {
429
+ return this.cause.message;
430
+ }
431
+ get group() {
432
+ return this.cause.group;
433
+ }
434
+ get code() {
435
+ return this.cause.code;
436
+ }
437
+ get metadata() {
438
+ return this.cause.metadata;
439
+ }
440
+ get actor() {
441
+ return this.cause.actor;
442
+ }
443
+ get statusCode() {
444
+ return this.cause.statusCode;
445
+ }
446
+ get public() {
447
+ return this.cause.public;
448
+ }
449
+ get rayId() {
450
+ return this.cause.rayId;
451
+ }
452
+ get isRetryable() {
453
+ return true;
454
+ }
455
+ }
456
+ export class GuardActorRunnerFailed extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardActorRunnerFailed`)("GuardActorRunnerFailed", {
457
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
458
+ }) {
459
+ [ReasonTypeId] = ReasonTypeId;
460
+ get message() {
461
+ return this.cause.message;
462
+ }
463
+ get group() {
464
+ return this.cause.group;
465
+ }
466
+ get code() {
467
+ return this.cause.code;
468
+ }
469
+ get metadata() {
470
+ return this.cause.metadata;
471
+ }
472
+ get actor() {
473
+ return this.cause.actor;
474
+ }
475
+ get statusCode() {
476
+ return this.cause.statusCode;
477
+ }
478
+ get public() {
479
+ return this.cause.public;
480
+ }
481
+ get rayId() {
482
+ return this.cause.rayId;
483
+ }
484
+ get isRetryable() {
485
+ return false;
486
+ }
487
+ }
488
+ export class GuardServiceUnavailable extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardServiceUnavailable`)("GuardServiceUnavailable", {
489
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
490
+ }) {
491
+ [ReasonTypeId] = ReasonTypeId;
492
+ get message() {
493
+ return this.cause.message;
494
+ }
495
+ get group() {
496
+ return this.cause.group;
497
+ }
498
+ get code() {
499
+ return this.cause.code;
500
+ }
501
+ get metadata() {
502
+ return this.cause.metadata;
503
+ }
504
+ get actor() {
505
+ return this.cause.actor;
506
+ }
507
+ get statusCode() {
508
+ return this.cause.statusCode;
509
+ }
510
+ get public() {
511
+ return this.cause.public;
512
+ }
513
+ get rayId() {
514
+ return this.cause.rayId;
515
+ }
516
+ get isRetryable() {
517
+ return true;
518
+ }
519
+ }
520
+ export class GuardActorStoppedWhileWaiting extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardActorStoppedWhileWaiting`)("GuardActorStoppedWhileWaiting", {
521
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
522
+ }) {
523
+ [ReasonTypeId] = ReasonTypeId;
524
+ get message() {
525
+ return this.cause.message;
526
+ }
527
+ get group() {
528
+ return this.cause.group;
529
+ }
530
+ get code() {
531
+ return this.cause.code;
532
+ }
533
+ get metadata() {
534
+ return this.cause.metadata;
535
+ }
536
+ get actor() {
537
+ return this.cause.actor;
538
+ }
539
+ get statusCode() {
540
+ return this.cause.statusCode;
541
+ }
542
+ get public() {
543
+ return this.cause.public;
544
+ }
545
+ get rayId() {
546
+ return this.cause.rayId;
547
+ }
548
+ get isRetryable() {
549
+ return true;
550
+ }
551
+ }
552
+ export class GuardTunnelRequestAborted extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardTunnelRequestAborted`)("GuardTunnelRequestAborted", {
553
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
554
+ }) {
555
+ [ReasonTypeId] = ReasonTypeId;
556
+ get message() {
557
+ return this.cause.message;
558
+ }
559
+ get group() {
560
+ return this.cause.group;
561
+ }
562
+ get code() {
563
+ return this.cause.code;
564
+ }
565
+ get metadata() {
566
+ return this.cause.metadata;
567
+ }
568
+ get actor() {
569
+ return this.cause.actor;
570
+ }
571
+ get statusCode() {
572
+ return this.cause.statusCode;
573
+ }
574
+ get public() {
575
+ return this.cause.public;
576
+ }
577
+ get rayId() {
578
+ return this.cause.rayId;
579
+ }
580
+ get isRetryable() {
581
+ return true;
582
+ }
583
+ }
584
+ export class GuardTunnelMessageTimeout extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardTunnelMessageTimeout`)("GuardTunnelMessageTimeout", {
585
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
586
+ }) {
587
+ [ReasonTypeId] = ReasonTypeId;
588
+ get message() {
589
+ return this.cause.message;
590
+ }
591
+ get group() {
592
+ return this.cause.group;
593
+ }
594
+ get code() {
595
+ return this.cause.code;
596
+ }
597
+ get metadata() {
598
+ return this.cause.metadata;
599
+ }
600
+ get actor() {
601
+ return this.cause.actor;
602
+ }
603
+ get statusCode() {
604
+ return this.cause.statusCode;
605
+ }
606
+ get public() {
607
+ return this.cause.public;
608
+ }
609
+ get rayId() {
610
+ return this.cause.rayId;
611
+ }
612
+ get isRetryable() {
613
+ return true;
614
+ }
615
+ }
616
+ export class GuardTunnelResponseClosed extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardTunnelResponseClosed`)("GuardTunnelResponseClosed", {
617
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
618
+ }) {
619
+ [ReasonTypeId] = ReasonTypeId;
620
+ get message() {
621
+ return this.cause.message;
622
+ }
623
+ get group() {
624
+ return this.cause.group;
625
+ }
626
+ get code() {
627
+ return this.cause.code;
628
+ }
629
+ get metadata() {
630
+ return this.cause.metadata;
631
+ }
632
+ get actor() {
633
+ return this.cause.actor;
634
+ }
635
+ get statusCode() {
636
+ return this.cause.statusCode;
637
+ }
638
+ get public() {
639
+ return this.cause.public;
640
+ }
641
+ get rayId() {
642
+ return this.cause.rayId;
643
+ }
644
+ get isRetryable() {
645
+ return true;
646
+ }
647
+ }
648
+ export class GuardGatewayResponseStartTimeout extends Schema.TaggedErrorClass(`${ReasonTypeId}/GuardGatewayResponseStartTimeout`)("GuardGatewayResponseStartTimeout", {
649
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
650
+ }) {
651
+ [ReasonTypeId] = ReasonTypeId;
652
+ get message() {
653
+ return this.cause.message;
654
+ }
655
+ get group() {
656
+ return this.cause.group;
657
+ }
658
+ get code() {
659
+ return this.cause.code;
660
+ }
661
+ get metadata() {
662
+ return this.cause.metadata;
663
+ }
664
+ get actor() {
665
+ return this.cause.actor;
666
+ }
667
+ get statusCode() {
668
+ return this.cause.statusCode;
669
+ }
670
+ get public() {
671
+ return this.cause.public;
672
+ }
673
+ get rayId() {
674
+ return this.cause.rayId;
675
+ }
676
+ get isRetryable() {
677
+ return true;
678
+ }
679
+ }
680
+ export class InternalError extends Schema.TaggedErrorClass(`${ReasonTypeId}/InternalError`)("InternalError", {
681
+ cause: Schema.instanceOf(RivetkitErrors.RivetError),
682
+ }) {
683
+ [ReasonTypeId] = ReasonTypeId;
684
+ get message() {
685
+ return this.cause.message;
686
+ }
687
+ get group() {
688
+ return this.cause.group;
689
+ }
690
+ get code() {
691
+ return this.cause.code;
692
+ }
693
+ get metadata() {
694
+ return this.cause.metadata;
695
+ }
696
+ get actor() {
697
+ return this.cause.actor;
698
+ }
699
+ get statusCode() {
700
+ return this.cause.statusCode;
701
+ }
702
+ get public() {
703
+ return this.cause.public;
704
+ }
705
+ get rayId() {
706
+ return this.cause.rayId;
707
+ }
708
+ get isRetryable() {
709
+ return false;
710
+ }
711
+ }
712
+ export class ActionErrorDecodeFailed extends Schema.TaggedErrorClass(`${ReasonTypeId}/ActionErrorDecodeFailed`)("ActionErrorDecodeFailed", {
713
+ cause: Schema.instanceOf(Schema.SchemaError),
714
+ rivetError: Schema.instanceOf(RivetkitErrors.RivetError),
715
+ }) {
716
+ [ReasonTypeId] = ReasonTypeId;
717
+ get message() {
718
+ return `Failed to decode action error ${this.rivetError.group}.${this.rivetError.code}`;
719
+ }
720
+ get group() {
721
+ return this.rivetError.group;
722
+ }
723
+ get code() {
724
+ return this.rivetError.code;
725
+ }
726
+ get metadata() {
727
+ return this.rivetError.metadata;
728
+ }
729
+ get actor() {
730
+ return this.rivetError.actor;
731
+ }
732
+ get statusCode() {
733
+ return this.rivetError.statusCode;
734
+ }
735
+ get public() {
736
+ return this.rivetError.public;
737
+ }
738
+ get rayId() {
739
+ return this.rivetError.rayId;
740
+ }
741
+ get isRetryable() {
742
+ return false;
743
+ }
744
+ }
745
+ /**
746
+ * Open-ended user error reason. Used when the actor threw `UserError` but
747
+ * the failing action did not declare a matching schema in its `error`
748
+ * field — so we can't surface it as a typed domain error in the Effect
749
+ * error channel.
750
+ *
751
+ * Actions that declare their user errors via `Action.make({ error: ... })`
752
+ * receive those errors **typed** in the error channel; this reason is
753
+ * the catch-all for everything else.
754
+ */
755
+ export class UnknownUserError extends Schema.TaggedErrorClass(`${ReasonTypeId}/UnknownUserError`)("UnknownUserError", { cause: Schema.instanceOf(RivetkitErrors.RivetError) }) {
756
+ [ReasonTypeId] = ReasonTypeId;
757
+ get message() {
758
+ return this.cause.message;
759
+ }
760
+ get group() {
761
+ return this.cause.group;
762
+ }
763
+ get code() {
764
+ return this.cause.code;
765
+ }
766
+ get metadata() {
767
+ return this.cause.metadata;
768
+ }
769
+ get actor() {
770
+ return this.cause.actor;
771
+ }
772
+ get statusCode() {
773
+ return this.cause.statusCode;
774
+ }
775
+ get public() {
776
+ return this.cause.public;
777
+ }
778
+ get rayId() {
779
+ return this.cause.rayId;
780
+ }
781
+ get isRetryable() {
782
+ return false;
783
+ }
784
+ }
785
+ /**
786
+ * Forward-compatible catch-all for `(group, code)` pairs the SDK does
787
+ * not recognize yet, and for malformed non-Rivet failures. Known wire
788
+ * fields are mirrored when present, while `cause` preserves the raw input.
789
+ */
790
+ export class UnknownError extends Schema.TaggedErrorClass(`${ReasonTypeId}/UnknownError`)("UnknownError", {
791
+ message: Schema.String,
792
+ cause: Schema.Unknown,
793
+ }) {
794
+ [ReasonTypeId] = ReasonTypeId;
795
+ get group() {
796
+ return this.cause instanceof RivetkitErrors.RivetError
797
+ ? this.cause.group
798
+ : undefined;
799
+ }
800
+ get code() {
801
+ return this.cause instanceof RivetkitErrors.RivetError
802
+ ? this.cause.code
803
+ : undefined;
804
+ }
805
+ get metadata() {
806
+ return this.cause instanceof RivetkitErrors.RivetError
807
+ ? this.cause.metadata
808
+ : undefined;
809
+ }
810
+ get actor() {
811
+ return this.cause instanceof RivetkitErrors.RivetError
812
+ ? this.cause.actor
813
+ : undefined;
814
+ }
815
+ get statusCode() {
816
+ return this.cause instanceof RivetkitErrors.RivetError
817
+ ? this.cause.statusCode
818
+ : undefined;
819
+ }
820
+ get public() {
821
+ return this.cause instanceof RivetkitErrors.RivetError
822
+ ? this.cause.public
823
+ : undefined;
824
+ }
825
+ get rayId() {
826
+ return this.cause instanceof RivetkitErrors.RivetError
827
+ ? this.cause.rayId
828
+ : undefined;
829
+ }
830
+ get isRetryable() {
831
+ return false;
832
+ }
833
+ }
834
+ export const RivetErrorReason = Schema.Union([
835
+ Forbidden,
836
+ ActorNotFound,
837
+ ActorStopping,
838
+ ActorRestarting,
839
+ ActionNotFound,
840
+ ActionTimedOut,
841
+ ActionAborted,
842
+ ActorOverloaded,
843
+ IncomingMessageTooLong,
844
+ OutgoingMessageTooLong,
845
+ InvalidEncoding,
846
+ InvalidRequest,
847
+ GuardActorReadyTimeout,
848
+ GuardActorWakeRetriesExceeded,
849
+ GuardActorRunnerFailed,
850
+ GuardServiceUnavailable,
851
+ GuardActorStoppedWhileWaiting,
852
+ GuardTunnelRequestAborted,
853
+ GuardTunnelMessageTimeout,
854
+ GuardTunnelResponseClosed,
855
+ GuardGatewayResponseStartTimeout,
856
+ InternalError,
857
+ ActionErrorDecodeFailed,
858
+ UnknownUserError,
859
+ UnknownError,
860
+ ]);
861
+ export const isRivetErrorReason = (u) => Predicate.hasProperty(u, ReasonTypeId);
862
+ /**
863
+ * The infrastructure-failure error surfaced by `@rivetkit/effect`
864
+ * calls. Wraps a discriminated `reason` of all known failure
865
+ * modes.
866
+ *
867
+ * Recover with `Effect.catchReason` / `Effect.catchReasons` /
868
+ * `Effect.unwrapReason`:
869
+ *
870
+ * ```ts
871
+ * program.pipe(
872
+ * Effect.catchReasons("RivetError", {
873
+ * Forbidden: () => Effect.fail(new MyAuthError()),
874
+ * ConnectionLost: () => Effect.logWarning("reconnecting"),
875
+ * }),
876
+ * )
877
+ * ```
878
+ *
879
+ * User-defined errors declared on an action via `Action.make({ error })`
880
+ * arrive in the typed error channel separately and do NOT flow through
881
+ * `RivetError`.
882
+ */
883
+ export class RivetError extends Schema.TaggedErrorClass("@rivetkit/effect/RivetError")("RivetError", {
884
+ reason: RivetErrorReason,
885
+ }) {
886
+ /** Marks this value as the top-level Rivet error wrapper for runtime guards. */
887
+ [TypeId] = TypeId;
888
+ /** Exposes the structured Rivet error reason as the JavaScript error cause. */
889
+ cause = this.reason;
890
+ /** Uses the reason message when present, otherwise falls back to the reason tag. */
891
+ get message() {
892
+ return this.reason.message || this.reason._tag;
893
+ }
894
+ /** Delegates to the underlying reason's `group` if present. */
895
+ get group() {
896
+ return "group" in this.reason ? this.reason.group : undefined;
897
+ }
898
+ /** Delegates to the underlying reason's `code` if present. */
899
+ get code() {
900
+ return "code" in this.reason ? this.reason.code : undefined;
901
+ }
902
+ /** Delegates to the underlying reason's `metadata` if present. */
903
+ get metadata() {
904
+ return "metadata" in this.reason ? this.reason.metadata : undefined;
905
+ }
906
+ /** Delegates to the underlying reason's `actor` if present. */
907
+ get actor() {
908
+ return "actor" in this.reason ? this.reason.actor : undefined;
909
+ }
910
+ /** Delegates to the underlying reason's `statusCode` if present. */
911
+ get statusCode() {
912
+ return "statusCode" in this.reason ? this.reason.statusCode : undefined;
913
+ }
914
+ /** Delegates to the underlying reason's `public` if present. */
915
+ get public() {
916
+ return "public" in this.reason ? this.reason.public : undefined;
917
+ }
918
+ /** Delegates to the underlying reason's `rayId` if present. */
919
+ get rayId() {
920
+ return "rayId" in this.reason ? this.reason.rayId : undefined;
921
+ }
922
+ /** Delegates to the underlying reason's `isRetryable` getter. */
923
+ get isRetryable() {
924
+ return this.reason.isRetryable;
925
+ }
926
+ /** Delegates to the underlying reason's `retryAfter` if present. */
927
+ get retryAfter() {
928
+ return "retryAfter" in this.reason ? this.reason.retryAfter : undefined;
929
+ }
930
+ }
931
+ export const isRivetError = (u) => Predicate.hasProperty(u, TypeId);
932
+ const reasonByCode = {
933
+ "auth.forbidden": (error) => new Forbidden({ cause: error }),
934
+ "actor.not_found": (error) => new ActorNotFound({ cause: error }),
935
+ "actor.stopping": (error) => new ActorStopping({ cause: error }),
936
+ "actor.restarting": (error) => new ActorRestarting({ cause: error }),
937
+ "actor.action_not_found": (error) => new ActionNotFound({ cause: error }),
938
+ "actor.action_timed_out": (error) => new ActionTimedOut({ cause: error }),
939
+ "actor.aborted": (error) => new ActionAborted({ cause: error }),
940
+ "actor.overloaded": (error) => new ActorOverloaded({ cause: error }),
941
+ [`actor.${RivetkitErrors.INTERNAL_ERROR_CODE}`]: (error) => new InternalError({ cause: error }),
942
+ [`core.${RivetkitErrors.INTERNAL_ERROR_CODE}`]: (error) => new InternalError({ cause: error }),
943
+ [`rivetkit.${RivetkitErrors.INTERNAL_ERROR_CODE}`]: (error) => new InternalError({ cause: error }),
944
+ "message.incoming_too_long": (error) => new IncomingMessageTooLong({ cause: error }),
945
+ "message.outgoing_too_long": (error) => new OutgoingMessageTooLong({ cause: error }),
946
+ "encoding.invalid": (error) => new InvalidEncoding({ cause: error }),
947
+ "request.invalid": (error) => new InvalidRequest({ cause: error }),
948
+ "guard.actor_ready_timeout": (error) => new GuardActorReadyTimeout({ cause: error }),
949
+ "guard.actor_wake_retries_exceeded": (error) => new GuardActorWakeRetriesExceeded({ cause: error }),
950
+ "guard.actor_runner_failed": (error) => new GuardActorRunnerFailed({ cause: error }),
951
+ "guard.service_unavailable": (error) => new GuardServiceUnavailable({ cause: error }),
952
+ "guard.actor_stopped_while_waiting": (error) => new GuardActorStoppedWhileWaiting({ cause: error }),
953
+ "guard.tunnel_request_aborted": (error) => new GuardTunnelRequestAborted({ cause: error }),
954
+ "guard.tunnel_message_timeout": (error) => new GuardTunnelMessageTimeout({ cause: error }),
955
+ "guard.tunnel_response_closed": (error) => new GuardTunnelResponseClosed({ cause: error }),
956
+ "guard.gateway_response_start_timeout": (error) => new GuardGatewayResponseStartTimeout({ cause: error }),
957
+ };
958
+ const reasonFromRivetkitRivetError = (error) => {
959
+ const makeReason = reasonByCode[`${error.group}.${error.code}`];
960
+ if (makeReason)
961
+ return makeReason(error);
962
+ if (error.group === "user")
963
+ return new UnknownUserError({ cause: error });
964
+ return new UnknownError({
965
+ message: error.message,
966
+ cause: error,
967
+ });
968
+ };
969
+ export const fromRivetkitRivetError = (error) => {
970
+ return new RivetError({ reason: reasonFromRivetkitRivetError(error) });
971
+ };
972
+ export const fromUnknown = (cause) => {
973
+ if (isRivetError(cause))
974
+ return cause;
975
+ if (RivetkitErrors.isRivetErrorLike(cause)) {
976
+ return fromRivetkitRivetError(RivetkitErrors.toRivetError(cause));
977
+ }
978
+ return new RivetError({
979
+ reason: new UnknownError({
980
+ message: cause instanceof Error ? cause.message : String(cause),
981
+ cause,
982
+ }),
983
+ });
984
+ };
985
+ //# sourceMappingURL=RivetError.js.map