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