rivetkit 2.3.0-rc.5 → 2.3.0-rc.6

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 (113) hide show
  1. package/dist/browser/client.d.ts +21 -18
  2. package/dist/browser/client.js +735 -170
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +4 -2
  7. package/dist/tsup/actor/errors.cjs.map +1 -1
  8. package/dist/tsup/actor/errors.d.cts +1 -74
  9. package/dist/tsup/actor/errors.d.ts +1 -74
  10. package/dist/tsup/actor/errors.js +3 -1
  11. package/dist/tsup/agent-os/index.cjs +1 -1
  12. package/dist/tsup/agent-os/index.cjs.map +1 -1
  13. package/dist/tsup/agent-os/index.d.cts +18 -7
  14. package/dist/tsup/agent-os/index.d.ts +18 -7
  15. package/dist/tsup/agent-os/index.js +1 -1
  16. package/dist/tsup/agent-os/index.js.map +1 -1
  17. package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2G64KSZQ.cjs} +10 -10
  18. package/dist/tsup/{chunk-2GANBXVP.cjs.map → chunk-2G64KSZQ.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-N2DQSJIW.js → chunk-6S25NVAP.js} +13 -46
  20. package/dist/tsup/chunk-6S25NVAP.js.map +1 -0
  21. package/dist/tsup/{chunk-NATOT3ET.js → chunk-CAF6JDJE.js} +4 -4
  22. package/dist/tsup/{chunk-PGYEMIOE.js → chunk-DEO7MMWQ.js} +2 -2
  23. package/dist/tsup/{chunk-SULB574D.js → chunk-EMO6E3PJ.js} +3 -3
  24. package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ENK7C66G.cjs} +838 -236
  25. package/dist/tsup/chunk-ENK7C66G.cjs.map +1 -0
  26. package/dist/tsup/{chunk-JY73X7VU.js → chunk-FLODVLYW.js} +690 -88
  27. package/dist/tsup/chunk-FLODVLYW.js.map +1 -0
  28. package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-HTR4YLNT.cjs} +4 -4
  29. package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-HTR4YLNT.cjs.map} +1 -1
  30. package/dist/tsup/{chunk-LELRJK66.cjs → chunk-JALSAX7Z.cjs} +3 -3
  31. package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-JALSAX7Z.cjs.map} +1 -1
  32. package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-K5BA2LEO.cjs} +19 -52
  33. package/dist/tsup/chunk-K5BA2LEO.cjs.map +1 -0
  34. package/dist/tsup/{chunk-K34B3OVG.js → chunk-KIWH5H3K.js} +30 -9
  35. package/dist/tsup/chunk-KIWH5H3K.js.map +1 -0
  36. package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-LIXXFXVR.cjs} +5 -5
  37. package/dist/tsup/{chunk-NW2J4SOL.cjs.map → chunk-LIXXFXVR.cjs.map} +1 -1
  38. package/dist/tsup/{chunk-HR547GVH.cjs → chunk-M5C7YNI5.cjs} +8 -8
  39. package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-M5C7YNI5.cjs.map} +1 -1
  40. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-QAZLM4WT.cjs} +31 -10
  41. package/dist/tsup/chunk-QAZLM4WT.cjs.map +1 -0
  42. package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-RTC2AZGB.js} +2 -2
  43. package/dist/tsup/{chunk-UXTP4EBU.js → chunk-ZI5QJMKO.js} +2 -2
  44. package/dist/tsup/client/mod.cjs +7 -7
  45. package/dist/tsup/client/mod.d.cts +3 -4
  46. package/dist/tsup/client/mod.d.ts +3 -4
  47. package/dist/tsup/client/mod.js +6 -6
  48. package/dist/tsup/common/log.cjs +3 -3
  49. package/dist/tsup/common/log.js +2 -2
  50. package/dist/tsup/common/websocket.cjs +4 -4
  51. package/dist/tsup/common/websocket.js +3 -3
  52. package/dist/tsup/{config-CvQUtDp9.d.ts → config-0Ta55UV0.d.ts} +10 -9
  53. package/dist/tsup/{config-C-a9vrke.d.cts → config-Ca8dN4cS.d.cts} +10 -9
  54. package/dist/tsup/{context-A7R0bsZL.d.ts → context-B_IWbWne.d.ts} +1 -1
  55. package/dist/tsup/{context-CA3r-pf2.d.cts → context-CUrQ9MHc.d.cts} +1 -1
  56. package/dist/tsup/inspector/mod.cjs +6 -6
  57. package/dist/tsup/inspector/mod.js +5 -5
  58. package/dist/tsup/mod.cjs +252 -207
  59. package/dist/tsup/mod.cjs.map +1 -1
  60. package/dist/tsup/mod.d.cts +4 -5
  61. package/dist/tsup/mod.d.ts +4 -5
  62. package/dist/tsup/mod.js +183 -138
  63. package/dist/tsup/mod.js.map +1 -1
  64. package/dist/tsup/test/mod.cjs +10 -10
  65. package/dist/tsup/test/mod.d.cts +2 -3
  66. package/dist/tsup/test/mod.d.ts +2 -3
  67. package/dist/tsup/test/mod.js +6 -6
  68. package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
  69. package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
  70. package/dist/tsup/utils.cjs +3 -3
  71. package/dist/tsup/utils.d.cts +1 -1
  72. package/dist/tsup/utils.d.ts +1 -1
  73. package/dist/tsup/utils.js +2 -2
  74. package/dist/tsup/workflow/mod.cjs +9 -9
  75. package/dist/tsup/workflow/mod.d.cts +4 -5
  76. package/dist/tsup/workflow/mod.d.ts +4 -5
  77. package/dist/tsup/workflow/mod.js +5 -5
  78. package/package.json +8 -8
  79. package/src/actor/errors.ts +53 -7
  80. package/src/client/actor-conn.ts +52 -29
  81. package/src/client/actor-handle.ts +57 -23
  82. package/src/client/errors.ts +2 -1
  83. package/src/client/raw-utils.ts +2 -4
  84. package/src/client/utils.ts +32 -3
  85. package/src/common/actor-router-consts.ts +4 -0
  86. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  87. package/src/common/client-protocol-versioned.ts +125 -18
  88. package/src/common/client-protocol-zod.ts +7 -0
  89. package/src/common/client-protocol.ts +1 -1
  90. package/src/common/database/native-database.test.ts +35 -0
  91. package/src/common/database/native-database.ts +8 -4
  92. package/src/common/router.ts +38 -8
  93. package/src/common/utils.ts +9 -52
  94. package/src/drivers/engine/actor-driver.ts +18 -17
  95. package/src/registry/config/index.ts +3 -5
  96. package/src/registry/index.ts +156 -19
  97. package/src/registry/napi-runtime.ts +44 -6
  98. package/src/registry/native.ts +5 -152
  99. package/src/registry/runtime.ts +16 -5
  100. package/src/registry/wasm-runtime.ts +22 -2
  101. package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
  102. package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
  103. package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
  104. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  105. package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
  106. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  107. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  108. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  109. /package/dist/tsup/{chunk-NATOT3ET.js.map → chunk-CAF6JDJE.js.map} +0 -0
  110. /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-DEO7MMWQ.js.map} +0 -0
  111. /package/dist/tsup/{chunk-SULB574D.js.map → chunk-EMO6E3PJ.js.map} +0 -0
  112. /package/dist/tsup/{chunk-LDTT6WKJ.js.map → chunk-RTC2AZGB.js.map} +0 -0
  113. /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-ZI5QJMKO.js.map} +0 -0
@@ -0,0 +1,599 @@
1
+ // @generated - post-processed by build.rs
2
+ import * as bare from "@rivetkit/bare-ts"
3
+
4
+ const DEFAULT_CONFIG = /* @__PURE__ */ bare.Config({})
5
+
6
+ export type u64 = bigint
7
+ export type uint = bigint
8
+
9
+ export type Cbor = ArrayBuffer
10
+
11
+ export function readCbor(bc: bare.ByteCursor): Cbor {
12
+ return bare.readData(bc)
13
+ }
14
+
15
+ export function writeCbor(bc: bare.ByteCursor, x: Cbor): void {
16
+ bare.writeData(bc, x)
17
+ }
18
+
19
+ function read0(bc: bare.ByteCursor): string | null {
20
+ return bare.readBool(bc) ? bare.readString(bc) : null
21
+ }
22
+
23
+ function write0(bc: bare.ByteCursor, x: string | null): void {
24
+ bare.writeBool(bc, x != null)
25
+ if (x != null) {
26
+ bare.writeString(bc, x)
27
+ }
28
+ }
29
+
30
+ export type ActorSpecifier = {
31
+ readonly actorId: string
32
+ readonly generation: uint
33
+ readonly key: string | null
34
+ }
35
+
36
+ export function readActorSpecifier(bc: bare.ByteCursor): ActorSpecifier {
37
+ return {
38
+ actorId: bare.readString(bc),
39
+ generation: bare.readUint(bc),
40
+ key: read0(bc),
41
+ }
42
+ }
43
+
44
+ export function writeActorSpecifier(bc: bare.ByteCursor, x: ActorSpecifier): void {
45
+ bare.writeString(bc, x.actorId)
46
+ bare.writeUint(bc, x.generation)
47
+ write0(bc, x.key)
48
+ }
49
+
50
+ export type Init = {
51
+ readonly actorId: string
52
+ readonly connectionId: string
53
+ }
54
+
55
+ export function readInit(bc: bare.ByteCursor): Init {
56
+ return {
57
+ actorId: bare.readString(bc),
58
+ connectionId: bare.readString(bc),
59
+ }
60
+ }
61
+
62
+ export function writeInit(bc: bare.ByteCursor, x: Init): void {
63
+ bare.writeString(bc, x.actorId)
64
+ bare.writeString(bc, x.connectionId)
65
+ }
66
+
67
+ function read1(bc: bare.ByteCursor): Cbor | null {
68
+ return bare.readBool(bc) ? readCbor(bc) : null
69
+ }
70
+
71
+ function write1(bc: bare.ByteCursor, x: Cbor | null): void {
72
+ bare.writeBool(bc, x != null)
73
+ if (x != null) {
74
+ writeCbor(bc, x)
75
+ }
76
+ }
77
+
78
+ function read2(bc: bare.ByteCursor): uint | null {
79
+ return bare.readBool(bc) ? bare.readUint(bc) : null
80
+ }
81
+
82
+ function write2(bc: bare.ByteCursor, x: uint | null): void {
83
+ bare.writeBool(bc, x != null)
84
+ if (x != null) {
85
+ bare.writeUint(bc, x)
86
+ }
87
+ }
88
+
89
+ function read3(bc: bare.ByteCursor): ActorSpecifier | null {
90
+ return bare.readBool(bc) ? readActorSpecifier(bc) : null
91
+ }
92
+
93
+ function write3(bc: bare.ByteCursor, x: ActorSpecifier | null): void {
94
+ bare.writeBool(bc, x != null)
95
+ if (x != null) {
96
+ writeActorSpecifier(bc, x)
97
+ }
98
+ }
99
+
100
+ export type Error = {
101
+ readonly group: string
102
+ readonly code: string
103
+ readonly message: string
104
+ readonly metadata: Cbor | null
105
+ readonly actionId: uint | null
106
+ readonly actor: ActorSpecifier | null
107
+ }
108
+
109
+ export function readError(bc: bare.ByteCursor): Error {
110
+ return {
111
+ group: bare.readString(bc),
112
+ code: bare.readString(bc),
113
+ message: bare.readString(bc),
114
+ metadata: read1(bc),
115
+ actionId: read2(bc),
116
+ actor: read3(bc),
117
+ }
118
+ }
119
+
120
+ export function writeError(bc: bare.ByteCursor, x: Error): void {
121
+ bare.writeString(bc, x.group)
122
+ bare.writeString(bc, x.code)
123
+ bare.writeString(bc, x.message)
124
+ write1(bc, x.metadata)
125
+ write2(bc, x.actionId)
126
+ write3(bc, x.actor)
127
+ }
128
+
129
+ export type ActionResponse = {
130
+ readonly id: uint
131
+ readonly output: Cbor
132
+ }
133
+
134
+ export function readActionResponse(bc: bare.ByteCursor): ActionResponse {
135
+ return {
136
+ id: bare.readUint(bc),
137
+ output: readCbor(bc),
138
+ }
139
+ }
140
+
141
+ export function writeActionResponse(bc: bare.ByteCursor, x: ActionResponse): void {
142
+ bare.writeUint(bc, x.id)
143
+ writeCbor(bc, x.output)
144
+ }
145
+
146
+ export type Event = {
147
+ readonly name: string
148
+ readonly args: Cbor
149
+ }
150
+
151
+ export function readEvent(bc: bare.ByteCursor): Event {
152
+ return {
153
+ name: bare.readString(bc),
154
+ args: readCbor(bc),
155
+ }
156
+ }
157
+
158
+ export function writeEvent(bc: bare.ByteCursor, x: Event): void {
159
+ bare.writeString(bc, x.name)
160
+ writeCbor(bc, x.args)
161
+ }
162
+
163
+ export type ToClientBody =
164
+ | { readonly tag: "Init"; readonly val: Init }
165
+ | { readonly tag: "Error"; readonly val: Error }
166
+ | { readonly tag: "ActionResponse"; readonly val: ActionResponse }
167
+ | { readonly tag: "Event"; readonly val: Event }
168
+
169
+ export function readToClientBody(bc: bare.ByteCursor): ToClientBody {
170
+ const offset = bc.offset
171
+ const tag = bare.readU8(bc)
172
+ switch (tag) {
173
+ case 0:
174
+ return { tag: "Init", val: readInit(bc) }
175
+ case 1:
176
+ return { tag: "Error", val: readError(bc) }
177
+ case 2:
178
+ return { tag: "ActionResponse", val: readActionResponse(bc) }
179
+ case 3:
180
+ return { tag: "Event", val: readEvent(bc) }
181
+ default: {
182
+ bc.offset = offset
183
+ throw new bare.BareError(offset, "invalid tag")
184
+ }
185
+ }
186
+ }
187
+
188
+ export function writeToClientBody(bc: bare.ByteCursor, x: ToClientBody): void {
189
+ switch (x.tag) {
190
+ case "Init": {
191
+ bare.writeU8(bc, 0)
192
+ writeInit(bc, x.val)
193
+ break
194
+ }
195
+ case "Error": {
196
+ bare.writeU8(bc, 1)
197
+ writeError(bc, x.val)
198
+ break
199
+ }
200
+ case "ActionResponse": {
201
+ bare.writeU8(bc, 2)
202
+ writeActionResponse(bc, x.val)
203
+ break
204
+ }
205
+ case "Event": {
206
+ bare.writeU8(bc, 3)
207
+ writeEvent(bc, x.val)
208
+ break
209
+ }
210
+ }
211
+ }
212
+
213
+ export type ToClient = {
214
+ readonly body: ToClientBody
215
+ }
216
+
217
+ export function readToClient(bc: bare.ByteCursor): ToClient {
218
+ return {
219
+ body: readToClientBody(bc),
220
+ }
221
+ }
222
+
223
+ export function writeToClient(bc: bare.ByteCursor, x: ToClient): void {
224
+ writeToClientBody(bc, x.body)
225
+ }
226
+
227
+ export function encodeToClient(x: ToClient, config?: Partial<bare.Config>): Uint8Array {
228
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
229
+ const bc = new bare.ByteCursor(
230
+ new Uint8Array(fullConfig.initialBufferLength),
231
+ fullConfig,
232
+ )
233
+ writeToClient(bc, x)
234
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
235
+ }
236
+
237
+ export function decodeToClient(bytes: Uint8Array): ToClient {
238
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
239
+ const result = readToClient(bc)
240
+ if (bc.offset < bc.view.byteLength) {
241
+ throw new bare.BareError(bc.offset, "remaining bytes")
242
+ }
243
+ return result
244
+ }
245
+
246
+ export type ActionRequest = {
247
+ readonly id: uint
248
+ readonly name: string
249
+ readonly args: Cbor
250
+ }
251
+
252
+ export function readActionRequest(bc: bare.ByteCursor): ActionRequest {
253
+ return {
254
+ id: bare.readUint(bc),
255
+ name: bare.readString(bc),
256
+ args: readCbor(bc),
257
+ }
258
+ }
259
+
260
+ export function writeActionRequest(bc: bare.ByteCursor, x: ActionRequest): void {
261
+ bare.writeUint(bc, x.id)
262
+ bare.writeString(bc, x.name)
263
+ writeCbor(bc, x.args)
264
+ }
265
+
266
+ export type SubscriptionRequest = {
267
+ readonly eventName: string
268
+ readonly subscribe: boolean
269
+ }
270
+
271
+ export function readSubscriptionRequest(bc: bare.ByteCursor): SubscriptionRequest {
272
+ return {
273
+ eventName: bare.readString(bc),
274
+ subscribe: bare.readBool(bc),
275
+ }
276
+ }
277
+
278
+ export function writeSubscriptionRequest(bc: bare.ByteCursor, x: SubscriptionRequest): void {
279
+ bare.writeString(bc, x.eventName)
280
+ bare.writeBool(bc, x.subscribe)
281
+ }
282
+
283
+ export type ToServerBody =
284
+ | { readonly tag: "ActionRequest"; readonly val: ActionRequest }
285
+ | { readonly tag: "SubscriptionRequest"; readonly val: SubscriptionRequest }
286
+
287
+ export function readToServerBody(bc: bare.ByteCursor): ToServerBody {
288
+ const offset = bc.offset
289
+ const tag = bare.readU8(bc)
290
+ switch (tag) {
291
+ case 0:
292
+ return { tag: "ActionRequest", val: readActionRequest(bc) }
293
+ case 1:
294
+ return { tag: "SubscriptionRequest", val: readSubscriptionRequest(bc) }
295
+ default: {
296
+ bc.offset = offset
297
+ throw new bare.BareError(offset, "invalid tag")
298
+ }
299
+ }
300
+ }
301
+
302
+ export function writeToServerBody(bc: bare.ByteCursor, x: ToServerBody): void {
303
+ switch (x.tag) {
304
+ case "ActionRequest": {
305
+ bare.writeU8(bc, 0)
306
+ writeActionRequest(bc, x.val)
307
+ break
308
+ }
309
+ case "SubscriptionRequest": {
310
+ bare.writeU8(bc, 1)
311
+ writeSubscriptionRequest(bc, x.val)
312
+ break
313
+ }
314
+ }
315
+ }
316
+
317
+ export type ToServer = {
318
+ readonly body: ToServerBody
319
+ }
320
+
321
+ export function readToServer(bc: bare.ByteCursor): ToServer {
322
+ return {
323
+ body: readToServerBody(bc),
324
+ }
325
+ }
326
+
327
+ export function writeToServer(bc: bare.ByteCursor, x: ToServer): void {
328
+ writeToServerBody(bc, x.body)
329
+ }
330
+
331
+ export function encodeToServer(x: ToServer, config?: Partial<bare.Config>): Uint8Array {
332
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
333
+ const bc = new bare.ByteCursor(
334
+ new Uint8Array(fullConfig.initialBufferLength),
335
+ fullConfig,
336
+ )
337
+ writeToServer(bc, x)
338
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
339
+ }
340
+
341
+ export function decodeToServer(bytes: Uint8Array): ToServer {
342
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
343
+ const result = readToServer(bc)
344
+ if (bc.offset < bc.view.byteLength) {
345
+ throw new bare.BareError(bc.offset, "remaining bytes")
346
+ }
347
+ return result
348
+ }
349
+
350
+ export type HttpActionRequest = {
351
+ readonly args: Cbor
352
+ }
353
+
354
+ export function readHttpActionRequest(bc: bare.ByteCursor): HttpActionRequest {
355
+ return {
356
+ args: readCbor(bc),
357
+ }
358
+ }
359
+
360
+ export function writeHttpActionRequest(bc: bare.ByteCursor, x: HttpActionRequest): void {
361
+ writeCbor(bc, x.args)
362
+ }
363
+
364
+ export function encodeHttpActionRequest(x: HttpActionRequest, config?: Partial<bare.Config>): Uint8Array {
365
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
366
+ const bc = new bare.ByteCursor(
367
+ new Uint8Array(fullConfig.initialBufferLength),
368
+ fullConfig,
369
+ )
370
+ writeHttpActionRequest(bc, x)
371
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
372
+ }
373
+
374
+ export function decodeHttpActionRequest(bytes: Uint8Array): HttpActionRequest {
375
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
376
+ const result = readHttpActionRequest(bc)
377
+ if (bc.offset < bc.view.byteLength) {
378
+ throw new bare.BareError(bc.offset, "remaining bytes")
379
+ }
380
+ return result
381
+ }
382
+
383
+ export type HttpActionResponse = {
384
+ readonly output: Cbor
385
+ }
386
+
387
+ export function readHttpActionResponse(bc: bare.ByteCursor): HttpActionResponse {
388
+ return {
389
+ output: readCbor(bc),
390
+ }
391
+ }
392
+
393
+ export function writeHttpActionResponse(bc: bare.ByteCursor, x: HttpActionResponse): void {
394
+ writeCbor(bc, x.output)
395
+ }
396
+
397
+ export function encodeHttpActionResponse(x: HttpActionResponse, config?: Partial<bare.Config>): Uint8Array {
398
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
399
+ const bc = new bare.ByteCursor(
400
+ new Uint8Array(fullConfig.initialBufferLength),
401
+ fullConfig,
402
+ )
403
+ writeHttpActionResponse(bc, x)
404
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
405
+ }
406
+
407
+ export function decodeHttpActionResponse(bytes: Uint8Array): HttpActionResponse {
408
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
409
+ const result = readHttpActionResponse(bc)
410
+ if (bc.offset < bc.view.byteLength) {
411
+ throw new bare.BareError(bc.offset, "remaining bytes")
412
+ }
413
+ return result
414
+ }
415
+
416
+ function read4(bc: bare.ByteCursor): boolean | null {
417
+ return bare.readBool(bc) ? bare.readBool(bc) : null
418
+ }
419
+
420
+ function write4(bc: bare.ByteCursor, x: boolean | null): void {
421
+ bare.writeBool(bc, x != null)
422
+ if (x != null) {
423
+ bare.writeBool(bc, x)
424
+ }
425
+ }
426
+
427
+ function read5(bc: bare.ByteCursor): u64 | null {
428
+ return bare.readBool(bc) ? bare.readU64(bc) : null
429
+ }
430
+
431
+ function write5(bc: bare.ByteCursor, x: u64 | null): void {
432
+ bare.writeBool(bc, x != null)
433
+ if (x != null) {
434
+ bare.writeU64(bc, x)
435
+ }
436
+ }
437
+
438
+ export type HttpQueueSendRequest = {
439
+ readonly body: Cbor
440
+ readonly name: string | null
441
+ readonly wait: boolean | null
442
+ readonly timeout: u64 | null
443
+ }
444
+
445
+ export function readHttpQueueSendRequest(bc: bare.ByteCursor): HttpQueueSendRequest {
446
+ return {
447
+ body: readCbor(bc),
448
+ name: read0(bc),
449
+ wait: read4(bc),
450
+ timeout: read5(bc),
451
+ }
452
+ }
453
+
454
+ export function writeHttpQueueSendRequest(bc: bare.ByteCursor, x: HttpQueueSendRequest): void {
455
+ writeCbor(bc, x.body)
456
+ write0(bc, x.name)
457
+ write4(bc, x.wait)
458
+ write5(bc, x.timeout)
459
+ }
460
+
461
+ export function encodeHttpQueueSendRequest(x: HttpQueueSendRequest, config?: Partial<bare.Config>): Uint8Array {
462
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
463
+ const bc = new bare.ByteCursor(
464
+ new Uint8Array(fullConfig.initialBufferLength),
465
+ fullConfig,
466
+ )
467
+ writeHttpQueueSendRequest(bc, x)
468
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
469
+ }
470
+
471
+ export function decodeHttpQueueSendRequest(bytes: Uint8Array): HttpQueueSendRequest {
472
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
473
+ const result = readHttpQueueSendRequest(bc)
474
+ if (bc.offset < bc.view.byteLength) {
475
+ throw new bare.BareError(bc.offset, "remaining bytes")
476
+ }
477
+ return result
478
+ }
479
+
480
+ export type HttpQueueSendResponse = {
481
+ readonly status: string
482
+ readonly response: Cbor | null
483
+ }
484
+
485
+ export function readHttpQueueSendResponse(bc: bare.ByteCursor): HttpQueueSendResponse {
486
+ return {
487
+ status: bare.readString(bc),
488
+ response: read1(bc),
489
+ }
490
+ }
491
+
492
+ export function writeHttpQueueSendResponse(bc: bare.ByteCursor, x: HttpQueueSendResponse): void {
493
+ bare.writeString(bc, x.status)
494
+ write1(bc, x.response)
495
+ }
496
+
497
+ export function encodeHttpQueueSendResponse(x: HttpQueueSendResponse, config?: Partial<bare.Config>): Uint8Array {
498
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
499
+ const bc = new bare.ByteCursor(
500
+ new Uint8Array(fullConfig.initialBufferLength),
501
+ fullConfig,
502
+ )
503
+ writeHttpQueueSendResponse(bc, x)
504
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
505
+ }
506
+
507
+ export function decodeHttpQueueSendResponse(bytes: Uint8Array): HttpQueueSendResponse {
508
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
509
+ const result = readHttpQueueSendResponse(bc)
510
+ if (bc.offset < bc.view.byteLength) {
511
+ throw new bare.BareError(bc.offset, "remaining bytes")
512
+ }
513
+ return result
514
+ }
515
+
516
+ export type HttpResponseError = {
517
+ readonly group: string
518
+ readonly code: string
519
+ readonly message: string
520
+ readonly metadata: Cbor | null
521
+ readonly actor: ActorSpecifier | null
522
+ }
523
+
524
+ export function readHttpResponseError(bc: bare.ByteCursor): HttpResponseError {
525
+ return {
526
+ group: bare.readString(bc),
527
+ code: bare.readString(bc),
528
+ message: bare.readString(bc),
529
+ metadata: read1(bc),
530
+ actor: read3(bc),
531
+ }
532
+ }
533
+
534
+ export function writeHttpResponseError(bc: bare.ByteCursor, x: HttpResponseError): void {
535
+ bare.writeString(bc, x.group)
536
+ bare.writeString(bc, x.code)
537
+ bare.writeString(bc, x.message)
538
+ write1(bc, x.metadata)
539
+ write3(bc, x.actor)
540
+ }
541
+
542
+ export function encodeHttpResponseError(x: HttpResponseError, config?: Partial<bare.Config>): Uint8Array {
543
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
544
+ const bc = new bare.ByteCursor(
545
+ new Uint8Array(fullConfig.initialBufferLength),
546
+ fullConfig,
547
+ )
548
+ writeHttpResponseError(bc, x)
549
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
550
+ }
551
+
552
+ export function decodeHttpResponseError(bytes: Uint8Array): HttpResponseError {
553
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
554
+ const result = readHttpResponseError(bc)
555
+ if (bc.offset < bc.view.byteLength) {
556
+ throw new bare.BareError(bc.offset, "remaining bytes")
557
+ }
558
+ return result
559
+ }
560
+
561
+ export type HttpResolveRequest = null
562
+
563
+ export type HttpResolveResponse = {
564
+ readonly actorId: string
565
+ }
566
+
567
+ export function readHttpResolveResponse(bc: bare.ByteCursor): HttpResolveResponse {
568
+ return {
569
+ actorId: bare.readString(bc),
570
+ }
571
+ }
572
+
573
+ export function writeHttpResolveResponse(bc: bare.ByteCursor, x: HttpResolveResponse): void {
574
+ bare.writeString(bc, x.actorId)
575
+ }
576
+
577
+ export function encodeHttpResolveResponse(x: HttpResolveResponse, config?: Partial<bare.Config>): Uint8Array {
578
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
579
+ const bc = new bare.ByteCursor(
580
+ new Uint8Array(fullConfig.initialBufferLength),
581
+ fullConfig,
582
+ )
583
+ writeHttpResolveResponse(bc, x)
584
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
585
+ }
586
+
587
+ export function decodeHttpResolveResponse(bytes: Uint8Array): HttpResolveResponse {
588
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
589
+ const result = readHttpResolveResponse(bc)
590
+ if (bc.offset < bc.view.byteLength) {
591
+ throw new bare.BareError(bc.offset, "remaining bytes")
592
+ }
593
+ return result
594
+ }
595
+
596
+
597
+ function assert(condition: boolean, message?: string): asserts condition {
598
+ if (!condition) throw new Error(message ?? "Assertion failed")
599
+ }