rivetkit 2.3.3-rc.1 → 2.3.3-rc.2

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 (108) hide show
  1. package/dist/browser/client.d.ts +1 -0
  2. package/dist/browser/client.js +9 -6
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +22 -2
  5. package/dist/browser/inspector/client.js +996 -222
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/agent-os/index.cjs +9 -6
  8. package/dist/tsup/agent-os/index.cjs.map +1 -1
  9. package/dist/tsup/agent-os/index.d.cts +1 -0
  10. package/dist/tsup/agent-os/index.d.ts +1 -0
  11. package/dist/tsup/agent-os/index.js +9 -6
  12. package/dist/tsup/agent-os/index.js.map +1 -1
  13. package/dist/tsup/{chunk-KVSK67EL.cjs → chunk-6JRGYOBR.cjs} +18 -10
  14. package/dist/tsup/chunk-6JRGYOBR.cjs.map +1 -0
  15. package/dist/tsup/{chunk-TXO4XNNB.js → chunk-CLQHFXG3.js} +2 -2
  16. package/dist/tsup/{chunk-VEJGWALU.cjs → chunk-GRXM3FQX.cjs} +3 -3
  17. package/dist/tsup/{chunk-VEJGWALU.cjs.map → chunk-GRXM3FQX.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-T5YE5THK.cjs → chunk-LIZO2BE3.cjs} +24 -4
  19. package/dist/tsup/chunk-LIZO2BE3.cjs.map +1 -0
  20. package/dist/tsup/{chunk-EIB2XNTL.js → chunk-OUIOGTEL.js} +12 -4
  21. package/dist/tsup/chunk-OUIOGTEL.js.map +1 -0
  22. package/dist/tsup/{chunk-CN4IAGVP.cjs → chunk-Q3DY23PN.cjs} +141 -141
  23. package/dist/tsup/{chunk-CN4IAGVP.cjs.map → chunk-Q3DY23PN.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-J7NGTEDW.js → chunk-Q6EIXJ2L.js} +3 -3
  25. package/dist/tsup/{chunk-GMD47RV5.cjs → chunk-QIRZKXPN.cjs} +5 -5
  26. package/dist/tsup/{chunk-GMD47RV5.cjs.map → chunk-QIRZKXPN.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-3UWWME7J.js → chunk-QRPFFGZB.js} +22 -2
  28. package/dist/tsup/chunk-QRPFFGZB.js.map +1 -0
  29. package/dist/tsup/{chunk-CFVNICL7.cjs → chunk-QXKIL5NU.cjs} +7 -7
  30. package/dist/tsup/{chunk-CFVNICL7.cjs.map → chunk-QXKIL5NU.cjs.map} +1 -1
  31. package/dist/tsup/{chunk-MLFI5BLT.cjs → chunk-SNTYTMHE.cjs} +12 -8
  32. package/dist/tsup/chunk-SNTYTMHE.cjs.map +1 -0
  33. package/dist/tsup/{chunk-2ZBWR7HC.js → chunk-URLGKL2B.js} +2 -2
  34. package/dist/tsup/{chunk-D5KMS3WU.js → chunk-VPKNVMUA.js} +11 -7
  35. package/dist/tsup/chunk-VPKNVMUA.js.map +1 -0
  36. package/dist/tsup/{chunk-VNWYKWBM.js → chunk-ZEBW32PT.js} +7 -7
  37. package/dist/tsup/client/mod.cjs +7 -7
  38. package/dist/tsup/client/mod.cjs.map +1 -1
  39. package/dist/tsup/client/mod.d.cts +2 -2
  40. package/dist/tsup/client/mod.d.ts +2 -2
  41. package/dist/tsup/client/mod.js +6 -6
  42. package/dist/tsup/common/log.cjs +4 -2
  43. package/dist/tsup/common/log.cjs.map +1 -1
  44. package/dist/tsup/common/log.d.cts +5 -1
  45. package/dist/tsup/common/log.d.ts +5 -1
  46. package/dist/tsup/common/log.js +5 -3
  47. package/dist/tsup/common/websocket.cjs +3 -3
  48. package/dist/tsup/common/websocket.js +2 -2
  49. package/dist/tsup/{config-CzvopP5m.d.cts → config-BfBhjEbk.d.cts} +1 -0
  50. package/dist/tsup/{config-DZuT7tcp.d.ts → config-ZkIsRFsN.d.ts} +1 -0
  51. package/dist/tsup/{context-CyAdY-aA.d.ts → context-B7-84u9K.d.ts} +2 -1
  52. package/dist/tsup/{context-sNB28g0N.d.cts → context-sZ9GlaBK.d.cts} +2 -1
  53. package/dist/tsup/dynamic/mod.d.cts +1 -1
  54. package/dist/tsup/dynamic/mod.d.ts +1 -1
  55. package/dist/tsup/inspector/mod.cjs +46 -11
  56. package/dist/tsup/inspector/mod.cjs.map +1 -1
  57. package/dist/tsup/inspector/mod.d.cts +37 -15
  58. package/dist/tsup/inspector/mod.d.ts +37 -15
  59. package/dist/tsup/inspector/mod.js +45 -10
  60. package/dist/tsup/inspector/mod.js.map +1 -1
  61. package/dist/tsup/inspector-tab/mod.cjs +1 -12
  62. package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
  63. package/dist/tsup/inspector-tab/mod.d.cts +3 -13
  64. package/dist/tsup/inspector-tab/mod.d.ts +3 -13
  65. package/dist/tsup/inspector-tab/mod.js +0 -11
  66. package/dist/tsup/inspector-tab/mod.js.map +1 -1
  67. package/dist/tsup/mod.cjs +121 -62
  68. package/dist/tsup/mod.cjs.map +1 -1
  69. package/dist/tsup/mod.d.cts +3 -3
  70. package/dist/tsup/mod.d.ts +3 -3
  71. package/dist/tsup/mod.js +66 -7
  72. package/dist/tsup/mod.js.map +1 -1
  73. package/dist/tsup/test/mod.cjs +10 -10
  74. package/dist/tsup/test/mod.d.cts +1 -1
  75. package/dist/tsup/test/mod.d.ts +1 -1
  76. package/dist/tsup/test/mod.js +6 -6
  77. package/dist/tsup/utils.cjs +2 -2
  78. package/dist/tsup/utils.js +1 -1
  79. package/dist/tsup/workflow/mod.cjs +10 -7
  80. package/dist/tsup/workflow/mod.cjs.map +1 -1
  81. package/dist/tsup/workflow/mod.d.cts +3 -3
  82. package/dist/tsup/workflow/mod.d.ts +3 -3
  83. package/dist/tsup/workflow/mod.js +7 -4
  84. package/dist/tsup/workflow/mod.js.map +1 -1
  85. package/package.json +8 -8
  86. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  87. package/src/common/bare/transport/v1.ts +36 -0
  88. package/src/common/log.ts +14 -8
  89. package/src/inspector/client.browser.ts +73 -16
  90. package/src/inspector/mod.ts +1 -1
  91. package/src/inspector-tab/mod.ts +0 -15
  92. package/src/registry/index.ts +4 -0
  93. package/src/registry/napi-runtime.ts +11 -0
  94. package/src/registry/native.ts +70 -2
  95. package/src/registry/runtime.ts +1 -0
  96. package/src/registry/wasm-runtime.ts +5 -0
  97. package/src/workflow/context.ts +4 -0
  98. package/src/workflow/inspector.ts +8 -0
  99. package/dist/tsup/chunk-3UWWME7J.js.map +0 -1
  100. package/dist/tsup/chunk-D5KMS3WU.js.map +0 -1
  101. package/dist/tsup/chunk-EIB2XNTL.js.map +0 -1
  102. package/dist/tsup/chunk-KVSK67EL.cjs.map +0 -1
  103. package/dist/tsup/chunk-MLFI5BLT.cjs.map +0 -1
  104. package/dist/tsup/chunk-T5YE5THK.cjs.map +0 -1
  105. /package/dist/tsup/{chunk-TXO4XNNB.js.map → chunk-CLQHFXG3.js.map} +0 -0
  106. /package/dist/tsup/{chunk-J7NGTEDW.js.map → chunk-Q6EIXJ2L.js.map} +0 -0
  107. /package/dist/tsup/{chunk-2ZBWR7HC.js.map → chunk-URLGKL2B.js.map} +0 -0
  108. /package/dist/tsup/{chunk-VNWYKWBM.js.map → chunk-ZEBW32PT.js.map} +0 -0
@@ -0,0 +1,1016 @@
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 uint = bigint
7
+
8
+ export type State = ArrayBuffer
9
+
10
+ export function readState(bc: bare.ByteCursor): State {
11
+ return bare.readData(bc)
12
+ }
13
+
14
+ export function writeState(bc: bare.ByteCursor, x: State): void {
15
+ bare.writeData(bc, x)
16
+ }
17
+
18
+ export type WorkflowHistory = ArrayBuffer
19
+
20
+ export function readWorkflowHistory(bc: bare.ByteCursor): WorkflowHistory {
21
+ return bare.readData(bc)
22
+ }
23
+
24
+ export function writeWorkflowHistory(bc: bare.ByteCursor, x: WorkflowHistory): void {
25
+ bare.writeData(bc, x)
26
+ }
27
+
28
+ export type PatchStateRequest = {
29
+ readonly state: ArrayBuffer
30
+ }
31
+
32
+ export function readPatchStateRequest(bc: bare.ByteCursor): PatchStateRequest {
33
+ return {
34
+ state: bare.readData(bc),
35
+ }
36
+ }
37
+
38
+ export function writePatchStateRequest(bc: bare.ByteCursor, x: PatchStateRequest): void {
39
+ bare.writeData(bc, x.state)
40
+ }
41
+
42
+ export type ActionRequest = {
43
+ readonly id: uint
44
+ readonly name: string
45
+ readonly args: ArrayBuffer
46
+ }
47
+
48
+ export function readActionRequest(bc: bare.ByteCursor): ActionRequest {
49
+ return {
50
+ id: bare.readUint(bc),
51
+ name: bare.readString(bc),
52
+ args: bare.readData(bc),
53
+ }
54
+ }
55
+
56
+ export function writeActionRequest(bc: bare.ByteCursor, x: ActionRequest): void {
57
+ bare.writeUint(bc, x.id)
58
+ bare.writeString(bc, x.name)
59
+ bare.writeData(bc, x.args)
60
+ }
61
+
62
+ export type StateRequest = {
63
+ readonly id: uint
64
+ }
65
+
66
+ export function readStateRequest(bc: bare.ByteCursor): StateRequest {
67
+ return {
68
+ id: bare.readUint(bc),
69
+ }
70
+ }
71
+
72
+ export function writeStateRequest(bc: bare.ByteCursor, x: StateRequest): void {
73
+ bare.writeUint(bc, x.id)
74
+ }
75
+
76
+ export type ConnectionsRequest = {
77
+ readonly id: uint
78
+ }
79
+
80
+ export function readConnectionsRequest(bc: bare.ByteCursor): ConnectionsRequest {
81
+ return {
82
+ id: bare.readUint(bc),
83
+ }
84
+ }
85
+
86
+ export function writeConnectionsRequest(bc: bare.ByteCursor, x: ConnectionsRequest): void {
87
+ bare.writeUint(bc, x.id)
88
+ }
89
+
90
+ export type RpcsListRequest = {
91
+ readonly id: uint
92
+ }
93
+
94
+ export function readRpcsListRequest(bc: bare.ByteCursor): RpcsListRequest {
95
+ return {
96
+ id: bare.readUint(bc),
97
+ }
98
+ }
99
+
100
+ export function writeRpcsListRequest(bc: bare.ByteCursor, x: RpcsListRequest): void {
101
+ bare.writeUint(bc, x.id)
102
+ }
103
+
104
+ export type TraceQueryRequest = {
105
+ readonly id: uint
106
+ readonly startMs: uint
107
+ readonly endMs: uint
108
+ readonly limit: uint
109
+ }
110
+
111
+ export function readTraceQueryRequest(bc: bare.ByteCursor): TraceQueryRequest {
112
+ return {
113
+ id: bare.readUint(bc),
114
+ startMs: bare.readUint(bc),
115
+ endMs: bare.readUint(bc),
116
+ limit: bare.readUint(bc),
117
+ }
118
+ }
119
+
120
+ export function writeTraceQueryRequest(bc: bare.ByteCursor, x: TraceQueryRequest): void {
121
+ bare.writeUint(bc, x.id)
122
+ bare.writeUint(bc, x.startMs)
123
+ bare.writeUint(bc, x.endMs)
124
+ bare.writeUint(bc, x.limit)
125
+ }
126
+
127
+ export type QueueRequest = {
128
+ readonly id: uint
129
+ readonly limit: uint
130
+ }
131
+
132
+ export function readQueueRequest(bc: bare.ByteCursor): QueueRequest {
133
+ return {
134
+ id: bare.readUint(bc),
135
+ limit: bare.readUint(bc),
136
+ }
137
+ }
138
+
139
+ export function writeQueueRequest(bc: bare.ByteCursor, x: QueueRequest): void {
140
+ bare.writeUint(bc, x.id)
141
+ bare.writeUint(bc, x.limit)
142
+ }
143
+
144
+ export type WorkflowHistoryRequest = {
145
+ readonly id: uint
146
+ }
147
+
148
+ export function readWorkflowHistoryRequest(bc: bare.ByteCursor): WorkflowHistoryRequest {
149
+ return {
150
+ id: bare.readUint(bc),
151
+ }
152
+ }
153
+
154
+ export function writeWorkflowHistoryRequest(bc: bare.ByteCursor, x: WorkflowHistoryRequest): void {
155
+ bare.writeUint(bc, x.id)
156
+ }
157
+
158
+ function read0(bc: bare.ByteCursor): string | null {
159
+ return bare.readBool(bc) ? bare.readString(bc) : null
160
+ }
161
+
162
+ function write0(bc: bare.ByteCursor, x: string | null): void {
163
+ bare.writeBool(bc, x != null)
164
+ if (x != null) {
165
+ bare.writeString(bc, x)
166
+ }
167
+ }
168
+
169
+ export type WorkflowReplayRequest = {
170
+ readonly id: uint
171
+ readonly entryId: string | null
172
+ }
173
+
174
+ export function readWorkflowReplayRequest(bc: bare.ByteCursor): WorkflowReplayRequest {
175
+ return {
176
+ id: bare.readUint(bc),
177
+ entryId: read0(bc),
178
+ }
179
+ }
180
+
181
+ export function writeWorkflowReplayRequest(bc: bare.ByteCursor, x: WorkflowReplayRequest): void {
182
+ bare.writeUint(bc, x.id)
183
+ write0(bc, x.entryId)
184
+ }
185
+
186
+ export type DatabaseSchemaRequest = {
187
+ readonly id: uint
188
+ }
189
+
190
+ export function readDatabaseSchemaRequest(bc: bare.ByteCursor): DatabaseSchemaRequest {
191
+ return {
192
+ id: bare.readUint(bc),
193
+ }
194
+ }
195
+
196
+ export function writeDatabaseSchemaRequest(bc: bare.ByteCursor, x: DatabaseSchemaRequest): void {
197
+ bare.writeUint(bc, x.id)
198
+ }
199
+
200
+ export type DatabaseTableRowsRequest = {
201
+ readonly id: uint
202
+ readonly table: string
203
+ readonly limit: uint
204
+ readonly offset: uint
205
+ }
206
+
207
+ export function readDatabaseTableRowsRequest(bc: bare.ByteCursor): DatabaseTableRowsRequest {
208
+ return {
209
+ id: bare.readUint(bc),
210
+ table: bare.readString(bc),
211
+ limit: bare.readUint(bc),
212
+ offset: bare.readUint(bc),
213
+ }
214
+ }
215
+
216
+ export function writeDatabaseTableRowsRequest(bc: bare.ByteCursor, x: DatabaseTableRowsRequest): void {
217
+ bare.writeUint(bc, x.id)
218
+ bare.writeString(bc, x.table)
219
+ bare.writeUint(bc, x.limit)
220
+ bare.writeUint(bc, x.offset)
221
+ }
222
+
223
+ export type ToServerBody =
224
+ | { readonly tag: "PatchStateRequest"; readonly val: PatchStateRequest }
225
+ | { readonly tag: "StateRequest"; readonly val: StateRequest }
226
+ | { readonly tag: "ConnectionsRequest"; readonly val: ConnectionsRequest }
227
+ | { readonly tag: "ActionRequest"; readonly val: ActionRequest }
228
+ | { readonly tag: "RpcsListRequest"; readonly val: RpcsListRequest }
229
+ | { readonly tag: "TraceQueryRequest"; readonly val: TraceQueryRequest }
230
+ | { readonly tag: "QueueRequest"; readonly val: QueueRequest }
231
+ | { readonly tag: "WorkflowHistoryRequest"; readonly val: WorkflowHistoryRequest }
232
+ | { readonly tag: "WorkflowReplayRequest"; readonly val: WorkflowReplayRequest }
233
+ | { readonly tag: "DatabaseSchemaRequest"; readonly val: DatabaseSchemaRequest }
234
+ | { readonly tag: "DatabaseTableRowsRequest"; readonly val: DatabaseTableRowsRequest }
235
+
236
+ export function readToServerBody(bc: bare.ByteCursor): ToServerBody {
237
+ const offset = bc.offset
238
+ const tag = bare.readU8(bc)
239
+ switch (tag) {
240
+ case 0:
241
+ return { tag: "PatchStateRequest", val: readPatchStateRequest(bc) }
242
+ case 1:
243
+ return { tag: "StateRequest", val: readStateRequest(bc) }
244
+ case 2:
245
+ return { tag: "ConnectionsRequest", val: readConnectionsRequest(bc) }
246
+ case 3:
247
+ return { tag: "ActionRequest", val: readActionRequest(bc) }
248
+ case 4:
249
+ return { tag: "RpcsListRequest", val: readRpcsListRequest(bc) }
250
+ case 5:
251
+ return { tag: "TraceQueryRequest", val: readTraceQueryRequest(bc) }
252
+ case 6:
253
+ return { tag: "QueueRequest", val: readQueueRequest(bc) }
254
+ case 7:
255
+ return { tag: "WorkflowHistoryRequest", val: readWorkflowHistoryRequest(bc) }
256
+ case 8:
257
+ return { tag: "WorkflowReplayRequest", val: readWorkflowReplayRequest(bc) }
258
+ case 9:
259
+ return { tag: "DatabaseSchemaRequest", val: readDatabaseSchemaRequest(bc) }
260
+ case 10:
261
+ return { tag: "DatabaseTableRowsRequest", val: readDatabaseTableRowsRequest(bc) }
262
+ default: {
263
+ bc.offset = offset
264
+ throw new bare.BareError(offset, "invalid tag")
265
+ }
266
+ }
267
+ }
268
+
269
+ export function writeToServerBody(bc: bare.ByteCursor, x: ToServerBody): void {
270
+ switch (x.tag) {
271
+ case "PatchStateRequest": {
272
+ bare.writeU8(bc, 0)
273
+ writePatchStateRequest(bc, x.val)
274
+ break
275
+ }
276
+ case "StateRequest": {
277
+ bare.writeU8(bc, 1)
278
+ writeStateRequest(bc, x.val)
279
+ break
280
+ }
281
+ case "ConnectionsRequest": {
282
+ bare.writeU8(bc, 2)
283
+ writeConnectionsRequest(bc, x.val)
284
+ break
285
+ }
286
+ case "ActionRequest": {
287
+ bare.writeU8(bc, 3)
288
+ writeActionRequest(bc, x.val)
289
+ break
290
+ }
291
+ case "RpcsListRequest": {
292
+ bare.writeU8(bc, 4)
293
+ writeRpcsListRequest(bc, x.val)
294
+ break
295
+ }
296
+ case "TraceQueryRequest": {
297
+ bare.writeU8(bc, 5)
298
+ writeTraceQueryRequest(bc, x.val)
299
+ break
300
+ }
301
+ case "QueueRequest": {
302
+ bare.writeU8(bc, 6)
303
+ writeQueueRequest(bc, x.val)
304
+ break
305
+ }
306
+ case "WorkflowHistoryRequest": {
307
+ bare.writeU8(bc, 7)
308
+ writeWorkflowHistoryRequest(bc, x.val)
309
+ break
310
+ }
311
+ case "WorkflowReplayRequest": {
312
+ bare.writeU8(bc, 8)
313
+ writeWorkflowReplayRequest(bc, x.val)
314
+ break
315
+ }
316
+ case "DatabaseSchemaRequest": {
317
+ bare.writeU8(bc, 9)
318
+ writeDatabaseSchemaRequest(bc, x.val)
319
+ break
320
+ }
321
+ case "DatabaseTableRowsRequest": {
322
+ bare.writeU8(bc, 10)
323
+ writeDatabaseTableRowsRequest(bc, x.val)
324
+ break
325
+ }
326
+ }
327
+ }
328
+
329
+ export type ToServer = {
330
+ readonly body: ToServerBody
331
+ }
332
+
333
+ export function readToServer(bc: bare.ByteCursor): ToServer {
334
+ return {
335
+ body: readToServerBody(bc),
336
+ }
337
+ }
338
+
339
+ export function writeToServer(bc: bare.ByteCursor, x: ToServer): void {
340
+ writeToServerBody(bc, x.body)
341
+ }
342
+
343
+ export function encodeToServer(x: ToServer, config?: Partial<bare.Config>): Uint8Array {
344
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
345
+ const bc = new bare.ByteCursor(
346
+ new Uint8Array(fullConfig.initialBufferLength),
347
+ fullConfig,
348
+ )
349
+ writeToServer(bc, x)
350
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
351
+ }
352
+
353
+ export function decodeToServer(bytes: Uint8Array): ToServer {
354
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
355
+ const result = readToServer(bc)
356
+ if (bc.offset < bc.view.byteLength) {
357
+ throw new bare.BareError(bc.offset, "remaining bytes")
358
+ }
359
+ return result
360
+ }
361
+
362
+ export type Connection = {
363
+ readonly id: string
364
+ readonly details: ArrayBuffer
365
+ }
366
+
367
+ export function readConnection(bc: bare.ByteCursor): Connection {
368
+ return {
369
+ id: bare.readString(bc),
370
+ details: bare.readData(bc),
371
+ }
372
+ }
373
+
374
+ export function writeConnection(bc: bare.ByteCursor, x: Connection): void {
375
+ bare.writeString(bc, x.id)
376
+ bare.writeData(bc, x.details)
377
+ }
378
+
379
+ /**
380
+ * Inspector tab descriptor. `label`/`icon` are set for author-declared custom
381
+ * tabs; a hidden built-in only carries `id` with `hidden` set.
382
+ */
383
+ export type TabConfigEntry = {
384
+ readonly id: string
385
+ readonly label: string | null
386
+ readonly icon: string | null
387
+ readonly hidden: boolean
388
+ }
389
+
390
+ export function readTabConfigEntry(bc: bare.ByteCursor): TabConfigEntry {
391
+ return {
392
+ id: bare.readString(bc),
393
+ label: read0(bc),
394
+ icon: read0(bc),
395
+ hidden: bare.readBool(bc),
396
+ }
397
+ }
398
+
399
+ export function writeTabConfigEntry(bc: bare.ByteCursor, x: TabConfigEntry): void {
400
+ bare.writeString(bc, x.id)
401
+ write0(bc, x.label)
402
+ write0(bc, x.icon)
403
+ bare.writeBool(bc, x.hidden)
404
+ }
405
+
406
+ function read1(bc: bare.ByteCursor): readonly Connection[] {
407
+ const len = bare.readUintSafe(bc)
408
+ if (len === 0) {
409
+ return []
410
+ }
411
+ const result = [readConnection(bc)]
412
+ for (let i = 1; i < len; i++) {
413
+ result[i] = readConnection(bc)
414
+ }
415
+ return result
416
+ }
417
+
418
+ function write1(bc: bare.ByteCursor, x: readonly Connection[]): void {
419
+ bare.writeUintSafe(bc, x.length)
420
+ for (let i = 0; i < x.length; i++) {
421
+ writeConnection(bc, x[i])
422
+ }
423
+ }
424
+
425
+ function read2(bc: bare.ByteCursor): State | null {
426
+ return bare.readBool(bc) ? readState(bc) : null
427
+ }
428
+
429
+ function write2(bc: bare.ByteCursor, x: State | null): void {
430
+ bare.writeBool(bc, x != null)
431
+ if (x != null) {
432
+ writeState(bc, x)
433
+ }
434
+ }
435
+
436
+ function read3(bc: bare.ByteCursor): readonly string[] {
437
+ const len = bare.readUintSafe(bc)
438
+ if (len === 0) {
439
+ return []
440
+ }
441
+ const result = [bare.readString(bc)]
442
+ for (let i = 1; i < len; i++) {
443
+ result[i] = bare.readString(bc)
444
+ }
445
+ return result
446
+ }
447
+
448
+ function write3(bc: bare.ByteCursor, x: readonly string[]): void {
449
+ bare.writeUintSafe(bc, x.length)
450
+ for (let i = 0; i < x.length; i++) {
451
+ bare.writeString(bc, x[i])
452
+ }
453
+ }
454
+
455
+ function read4(bc: bare.ByteCursor): WorkflowHistory | null {
456
+ return bare.readBool(bc) ? readWorkflowHistory(bc) : null
457
+ }
458
+
459
+ function write4(bc: bare.ByteCursor, x: WorkflowHistory | null): void {
460
+ bare.writeBool(bc, x != null)
461
+ if (x != null) {
462
+ writeWorkflowHistory(bc, x)
463
+ }
464
+ }
465
+
466
+ function read5(bc: bare.ByteCursor): readonly TabConfigEntry[] {
467
+ const len = bare.readUintSafe(bc)
468
+ if (len === 0) {
469
+ return []
470
+ }
471
+ const result = [readTabConfigEntry(bc)]
472
+ for (let i = 1; i < len; i++) {
473
+ result[i] = readTabConfigEntry(bc)
474
+ }
475
+ return result
476
+ }
477
+
478
+ function write5(bc: bare.ByteCursor, x: readonly TabConfigEntry[]): void {
479
+ bare.writeUintSafe(bc, x.length)
480
+ for (let i = 0; i < x.length; i++) {
481
+ writeTabConfigEntry(bc, x[i])
482
+ }
483
+ }
484
+
485
+ export type Init = {
486
+ readonly connections: readonly Connection[]
487
+ readonly state: State | null
488
+ readonly isStateEnabled: boolean
489
+ readonly rpcs: readonly string[]
490
+ readonly isDatabaseEnabled: boolean
491
+ readonly queueSize: uint
492
+ readonly workflowHistory: WorkflowHistory | null
493
+ readonly isWorkflowEnabled: boolean
494
+ readonly tabConfig: readonly TabConfigEntry[]
495
+ }
496
+
497
+ export function readInit(bc: bare.ByteCursor): Init {
498
+ return {
499
+ connections: read1(bc),
500
+ state: read2(bc),
501
+ isStateEnabled: bare.readBool(bc),
502
+ rpcs: read3(bc),
503
+ isDatabaseEnabled: bare.readBool(bc),
504
+ queueSize: bare.readUint(bc),
505
+ workflowHistory: read4(bc),
506
+ isWorkflowEnabled: bare.readBool(bc),
507
+ tabConfig: read5(bc),
508
+ }
509
+ }
510
+
511
+ export function writeInit(bc: bare.ByteCursor, x: Init): void {
512
+ write1(bc, x.connections)
513
+ write2(bc, x.state)
514
+ bare.writeBool(bc, x.isStateEnabled)
515
+ write3(bc, x.rpcs)
516
+ bare.writeBool(bc, x.isDatabaseEnabled)
517
+ bare.writeUint(bc, x.queueSize)
518
+ write4(bc, x.workflowHistory)
519
+ bare.writeBool(bc, x.isWorkflowEnabled)
520
+ write5(bc, x.tabConfig)
521
+ }
522
+
523
+ export type ConnectionsResponse = {
524
+ readonly rid: uint
525
+ readonly connections: readonly Connection[]
526
+ }
527
+
528
+ export function readConnectionsResponse(bc: bare.ByteCursor): ConnectionsResponse {
529
+ return {
530
+ rid: bare.readUint(bc),
531
+ connections: read1(bc),
532
+ }
533
+ }
534
+
535
+ export function writeConnectionsResponse(bc: bare.ByteCursor, x: ConnectionsResponse): void {
536
+ bare.writeUint(bc, x.rid)
537
+ write1(bc, x.connections)
538
+ }
539
+
540
+ export type StateResponse = {
541
+ readonly rid: uint
542
+ readonly state: State | null
543
+ readonly isStateEnabled: boolean
544
+ }
545
+
546
+ export function readStateResponse(bc: bare.ByteCursor): StateResponse {
547
+ return {
548
+ rid: bare.readUint(bc),
549
+ state: read2(bc),
550
+ isStateEnabled: bare.readBool(bc),
551
+ }
552
+ }
553
+
554
+ export function writeStateResponse(bc: bare.ByteCursor, x: StateResponse): void {
555
+ bare.writeUint(bc, x.rid)
556
+ write2(bc, x.state)
557
+ bare.writeBool(bc, x.isStateEnabled)
558
+ }
559
+
560
+ export type ActionResponse = {
561
+ readonly rid: uint
562
+ readonly output: ArrayBuffer
563
+ }
564
+
565
+ export function readActionResponse(bc: bare.ByteCursor): ActionResponse {
566
+ return {
567
+ rid: bare.readUint(bc),
568
+ output: bare.readData(bc),
569
+ }
570
+ }
571
+
572
+ export function writeActionResponse(bc: bare.ByteCursor, x: ActionResponse): void {
573
+ bare.writeUint(bc, x.rid)
574
+ bare.writeData(bc, x.output)
575
+ }
576
+
577
+ export type TraceQueryResponse = {
578
+ readonly rid: uint
579
+ readonly payload: ArrayBuffer
580
+ }
581
+
582
+ export function readTraceQueryResponse(bc: bare.ByteCursor): TraceQueryResponse {
583
+ return {
584
+ rid: bare.readUint(bc),
585
+ payload: bare.readData(bc),
586
+ }
587
+ }
588
+
589
+ export function writeTraceQueryResponse(bc: bare.ByteCursor, x: TraceQueryResponse): void {
590
+ bare.writeUint(bc, x.rid)
591
+ bare.writeData(bc, x.payload)
592
+ }
593
+
594
+ export type QueueMessageSummary = {
595
+ readonly id: uint
596
+ readonly name: string
597
+ readonly createdAtMs: uint
598
+ }
599
+
600
+ export function readQueueMessageSummary(bc: bare.ByteCursor): QueueMessageSummary {
601
+ return {
602
+ id: bare.readUint(bc),
603
+ name: bare.readString(bc),
604
+ createdAtMs: bare.readUint(bc),
605
+ }
606
+ }
607
+
608
+ export function writeQueueMessageSummary(bc: bare.ByteCursor, x: QueueMessageSummary): void {
609
+ bare.writeUint(bc, x.id)
610
+ bare.writeString(bc, x.name)
611
+ bare.writeUint(bc, x.createdAtMs)
612
+ }
613
+
614
+ function read6(bc: bare.ByteCursor): readonly QueueMessageSummary[] {
615
+ const len = bare.readUintSafe(bc)
616
+ if (len === 0) {
617
+ return []
618
+ }
619
+ const result = [readQueueMessageSummary(bc)]
620
+ for (let i = 1; i < len; i++) {
621
+ result[i] = readQueueMessageSummary(bc)
622
+ }
623
+ return result
624
+ }
625
+
626
+ function write6(bc: bare.ByteCursor, x: readonly QueueMessageSummary[]): void {
627
+ bare.writeUintSafe(bc, x.length)
628
+ for (let i = 0; i < x.length; i++) {
629
+ writeQueueMessageSummary(bc, x[i])
630
+ }
631
+ }
632
+
633
+ export type QueueStatus = {
634
+ readonly size: uint
635
+ readonly maxSize: uint
636
+ readonly messages: readonly QueueMessageSummary[]
637
+ readonly truncated: boolean
638
+ }
639
+
640
+ export function readQueueStatus(bc: bare.ByteCursor): QueueStatus {
641
+ return {
642
+ size: bare.readUint(bc),
643
+ maxSize: bare.readUint(bc),
644
+ messages: read6(bc),
645
+ truncated: bare.readBool(bc),
646
+ }
647
+ }
648
+
649
+ export function writeQueueStatus(bc: bare.ByteCursor, x: QueueStatus): void {
650
+ bare.writeUint(bc, x.size)
651
+ bare.writeUint(bc, x.maxSize)
652
+ write6(bc, x.messages)
653
+ bare.writeBool(bc, x.truncated)
654
+ }
655
+
656
+ export type QueueResponse = {
657
+ readonly rid: uint
658
+ readonly status: QueueStatus
659
+ }
660
+
661
+ export function readQueueResponse(bc: bare.ByteCursor): QueueResponse {
662
+ return {
663
+ rid: bare.readUint(bc),
664
+ status: readQueueStatus(bc),
665
+ }
666
+ }
667
+
668
+ export function writeQueueResponse(bc: bare.ByteCursor, x: QueueResponse): void {
669
+ bare.writeUint(bc, x.rid)
670
+ writeQueueStatus(bc, x.status)
671
+ }
672
+
673
+ export type WorkflowHistoryResponse = {
674
+ readonly rid: uint
675
+ readonly history: WorkflowHistory | null
676
+ readonly isWorkflowEnabled: boolean
677
+ }
678
+
679
+ export function readWorkflowHistoryResponse(bc: bare.ByteCursor): WorkflowHistoryResponse {
680
+ return {
681
+ rid: bare.readUint(bc),
682
+ history: read4(bc),
683
+ isWorkflowEnabled: bare.readBool(bc),
684
+ }
685
+ }
686
+
687
+ export function writeWorkflowHistoryResponse(bc: bare.ByteCursor, x: WorkflowHistoryResponse): void {
688
+ bare.writeUint(bc, x.rid)
689
+ write4(bc, x.history)
690
+ bare.writeBool(bc, x.isWorkflowEnabled)
691
+ }
692
+
693
+ export type WorkflowReplayResponse = {
694
+ readonly rid: uint
695
+ readonly history: WorkflowHistory | null
696
+ readonly isWorkflowEnabled: boolean
697
+ }
698
+
699
+ export function readWorkflowReplayResponse(bc: bare.ByteCursor): WorkflowReplayResponse {
700
+ return {
701
+ rid: bare.readUint(bc),
702
+ history: read4(bc),
703
+ isWorkflowEnabled: bare.readBool(bc),
704
+ }
705
+ }
706
+
707
+ export function writeWorkflowReplayResponse(bc: bare.ByteCursor, x: WorkflowReplayResponse): void {
708
+ bare.writeUint(bc, x.rid)
709
+ write4(bc, x.history)
710
+ bare.writeBool(bc, x.isWorkflowEnabled)
711
+ }
712
+
713
+ export type DatabaseSchemaResponse = {
714
+ readonly rid: uint
715
+ readonly schema: ArrayBuffer
716
+ }
717
+
718
+ export function readDatabaseSchemaResponse(bc: bare.ByteCursor): DatabaseSchemaResponse {
719
+ return {
720
+ rid: bare.readUint(bc),
721
+ schema: bare.readData(bc),
722
+ }
723
+ }
724
+
725
+ export function writeDatabaseSchemaResponse(bc: bare.ByteCursor, x: DatabaseSchemaResponse): void {
726
+ bare.writeUint(bc, x.rid)
727
+ bare.writeData(bc, x.schema)
728
+ }
729
+
730
+ export type DatabaseTableRowsResponse = {
731
+ readonly rid: uint
732
+ readonly result: ArrayBuffer
733
+ }
734
+
735
+ export function readDatabaseTableRowsResponse(bc: bare.ByteCursor): DatabaseTableRowsResponse {
736
+ return {
737
+ rid: bare.readUint(bc),
738
+ result: bare.readData(bc),
739
+ }
740
+ }
741
+
742
+ export function writeDatabaseTableRowsResponse(bc: bare.ByteCursor, x: DatabaseTableRowsResponse): void {
743
+ bare.writeUint(bc, x.rid)
744
+ bare.writeData(bc, x.result)
745
+ }
746
+
747
+ export type StateUpdated = {
748
+ readonly state: State
749
+ }
750
+
751
+ export function readStateUpdated(bc: bare.ByteCursor): StateUpdated {
752
+ return {
753
+ state: readState(bc),
754
+ }
755
+ }
756
+
757
+ export function writeStateUpdated(bc: bare.ByteCursor, x: StateUpdated): void {
758
+ writeState(bc, x.state)
759
+ }
760
+
761
+ export type QueueUpdated = {
762
+ readonly queueSize: uint
763
+ }
764
+
765
+ export function readQueueUpdated(bc: bare.ByteCursor): QueueUpdated {
766
+ return {
767
+ queueSize: bare.readUint(bc),
768
+ }
769
+ }
770
+
771
+ export function writeQueueUpdated(bc: bare.ByteCursor, x: QueueUpdated): void {
772
+ bare.writeUint(bc, x.queueSize)
773
+ }
774
+
775
+ export type WorkflowHistoryUpdated = {
776
+ readonly history: WorkflowHistory
777
+ }
778
+
779
+ export function readWorkflowHistoryUpdated(bc: bare.ByteCursor): WorkflowHistoryUpdated {
780
+ return {
781
+ history: readWorkflowHistory(bc),
782
+ }
783
+ }
784
+
785
+ export function writeWorkflowHistoryUpdated(bc: bare.ByteCursor, x: WorkflowHistoryUpdated): void {
786
+ writeWorkflowHistory(bc, x.history)
787
+ }
788
+
789
+ export type RpcsListResponse = {
790
+ readonly rid: uint
791
+ readonly rpcs: readonly string[]
792
+ }
793
+
794
+ export function readRpcsListResponse(bc: bare.ByteCursor): RpcsListResponse {
795
+ return {
796
+ rid: bare.readUint(bc),
797
+ rpcs: read3(bc),
798
+ }
799
+ }
800
+
801
+ export function writeRpcsListResponse(bc: bare.ByteCursor, x: RpcsListResponse): void {
802
+ bare.writeUint(bc, x.rid)
803
+ write3(bc, x.rpcs)
804
+ }
805
+
806
+ export type ConnectionsUpdated = {
807
+ readonly connections: readonly Connection[]
808
+ }
809
+
810
+ export function readConnectionsUpdated(bc: bare.ByteCursor): ConnectionsUpdated {
811
+ return {
812
+ connections: read1(bc),
813
+ }
814
+ }
815
+
816
+ export function writeConnectionsUpdated(bc: bare.ByteCursor, x: ConnectionsUpdated): void {
817
+ write1(bc, x.connections)
818
+ }
819
+
820
+ export type Error = {
821
+ readonly message: string
822
+ }
823
+
824
+ export function readError(bc: bare.ByteCursor): Error {
825
+ return {
826
+ message: bare.readString(bc),
827
+ }
828
+ }
829
+
830
+ export function writeError(bc: bare.ByteCursor, x: Error): void {
831
+ bare.writeString(bc, x.message)
832
+ }
833
+
834
+ export type ToClientBody =
835
+ | { readonly tag: "StateResponse"; readonly val: StateResponse }
836
+ | { readonly tag: "ConnectionsResponse"; readonly val: ConnectionsResponse }
837
+ | { readonly tag: "ActionResponse"; readonly val: ActionResponse }
838
+ | { readonly tag: "ConnectionsUpdated"; readonly val: ConnectionsUpdated }
839
+ | { readonly tag: "QueueUpdated"; readonly val: QueueUpdated }
840
+ | { readonly tag: "StateUpdated"; readonly val: StateUpdated }
841
+ | { readonly tag: "WorkflowHistoryUpdated"; readonly val: WorkflowHistoryUpdated }
842
+ | { readonly tag: "RpcsListResponse"; readonly val: RpcsListResponse }
843
+ | { readonly tag: "TraceQueryResponse"; readonly val: TraceQueryResponse }
844
+ | { readonly tag: "QueueResponse"; readonly val: QueueResponse }
845
+ | { readonly tag: "WorkflowHistoryResponse"; readonly val: WorkflowHistoryResponse }
846
+ | { readonly tag: "WorkflowReplayResponse"; readonly val: WorkflowReplayResponse }
847
+ | { readonly tag: "Error"; readonly val: Error }
848
+ | { readonly tag: "Init"; readonly val: Init }
849
+ | { readonly tag: "DatabaseSchemaResponse"; readonly val: DatabaseSchemaResponse }
850
+ | { readonly tag: "DatabaseTableRowsResponse"; readonly val: DatabaseTableRowsResponse }
851
+
852
+ export function readToClientBody(bc: bare.ByteCursor): ToClientBody {
853
+ const offset = bc.offset
854
+ const tag = bare.readU8(bc)
855
+ switch (tag) {
856
+ case 0:
857
+ return { tag: "StateResponse", val: readStateResponse(bc) }
858
+ case 1:
859
+ return { tag: "ConnectionsResponse", val: readConnectionsResponse(bc) }
860
+ case 2:
861
+ return { tag: "ActionResponse", val: readActionResponse(bc) }
862
+ case 3:
863
+ return { tag: "ConnectionsUpdated", val: readConnectionsUpdated(bc) }
864
+ case 4:
865
+ return { tag: "QueueUpdated", val: readQueueUpdated(bc) }
866
+ case 5:
867
+ return { tag: "StateUpdated", val: readStateUpdated(bc) }
868
+ case 6:
869
+ return { tag: "WorkflowHistoryUpdated", val: readWorkflowHistoryUpdated(bc) }
870
+ case 7:
871
+ return { tag: "RpcsListResponse", val: readRpcsListResponse(bc) }
872
+ case 8:
873
+ return { tag: "TraceQueryResponse", val: readTraceQueryResponse(bc) }
874
+ case 9:
875
+ return { tag: "QueueResponse", val: readQueueResponse(bc) }
876
+ case 10:
877
+ return { tag: "WorkflowHistoryResponse", val: readWorkflowHistoryResponse(bc) }
878
+ case 11:
879
+ return { tag: "WorkflowReplayResponse", val: readWorkflowReplayResponse(bc) }
880
+ case 12:
881
+ return { tag: "Error", val: readError(bc) }
882
+ case 13:
883
+ return { tag: "Init", val: readInit(bc) }
884
+ case 14:
885
+ return { tag: "DatabaseSchemaResponse", val: readDatabaseSchemaResponse(bc) }
886
+ case 15:
887
+ return { tag: "DatabaseTableRowsResponse", val: readDatabaseTableRowsResponse(bc) }
888
+ default: {
889
+ bc.offset = offset
890
+ throw new bare.BareError(offset, "invalid tag")
891
+ }
892
+ }
893
+ }
894
+
895
+ export function writeToClientBody(bc: bare.ByteCursor, x: ToClientBody): void {
896
+ switch (x.tag) {
897
+ case "StateResponse": {
898
+ bare.writeU8(bc, 0)
899
+ writeStateResponse(bc, x.val)
900
+ break
901
+ }
902
+ case "ConnectionsResponse": {
903
+ bare.writeU8(bc, 1)
904
+ writeConnectionsResponse(bc, x.val)
905
+ break
906
+ }
907
+ case "ActionResponse": {
908
+ bare.writeU8(bc, 2)
909
+ writeActionResponse(bc, x.val)
910
+ break
911
+ }
912
+ case "ConnectionsUpdated": {
913
+ bare.writeU8(bc, 3)
914
+ writeConnectionsUpdated(bc, x.val)
915
+ break
916
+ }
917
+ case "QueueUpdated": {
918
+ bare.writeU8(bc, 4)
919
+ writeQueueUpdated(bc, x.val)
920
+ break
921
+ }
922
+ case "StateUpdated": {
923
+ bare.writeU8(bc, 5)
924
+ writeStateUpdated(bc, x.val)
925
+ break
926
+ }
927
+ case "WorkflowHistoryUpdated": {
928
+ bare.writeU8(bc, 6)
929
+ writeWorkflowHistoryUpdated(bc, x.val)
930
+ break
931
+ }
932
+ case "RpcsListResponse": {
933
+ bare.writeU8(bc, 7)
934
+ writeRpcsListResponse(bc, x.val)
935
+ break
936
+ }
937
+ case "TraceQueryResponse": {
938
+ bare.writeU8(bc, 8)
939
+ writeTraceQueryResponse(bc, x.val)
940
+ break
941
+ }
942
+ case "QueueResponse": {
943
+ bare.writeU8(bc, 9)
944
+ writeQueueResponse(bc, x.val)
945
+ break
946
+ }
947
+ case "WorkflowHistoryResponse": {
948
+ bare.writeU8(bc, 10)
949
+ writeWorkflowHistoryResponse(bc, x.val)
950
+ break
951
+ }
952
+ case "WorkflowReplayResponse": {
953
+ bare.writeU8(bc, 11)
954
+ writeWorkflowReplayResponse(bc, x.val)
955
+ break
956
+ }
957
+ case "Error": {
958
+ bare.writeU8(bc, 12)
959
+ writeError(bc, x.val)
960
+ break
961
+ }
962
+ case "Init": {
963
+ bare.writeU8(bc, 13)
964
+ writeInit(bc, x.val)
965
+ break
966
+ }
967
+ case "DatabaseSchemaResponse": {
968
+ bare.writeU8(bc, 14)
969
+ writeDatabaseSchemaResponse(bc, x.val)
970
+ break
971
+ }
972
+ case "DatabaseTableRowsResponse": {
973
+ bare.writeU8(bc, 15)
974
+ writeDatabaseTableRowsResponse(bc, x.val)
975
+ break
976
+ }
977
+ }
978
+ }
979
+
980
+ export type ToClient = {
981
+ readonly body: ToClientBody
982
+ }
983
+
984
+ export function readToClient(bc: bare.ByteCursor): ToClient {
985
+ return {
986
+ body: readToClientBody(bc),
987
+ }
988
+ }
989
+
990
+ export function writeToClient(bc: bare.ByteCursor, x: ToClient): void {
991
+ writeToClientBody(bc, x.body)
992
+ }
993
+
994
+ export function encodeToClient(x: ToClient, config?: Partial<bare.Config>): Uint8Array {
995
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
996
+ const bc = new bare.ByteCursor(
997
+ new Uint8Array(fullConfig.initialBufferLength),
998
+ fullConfig,
999
+ )
1000
+ writeToClient(bc, x)
1001
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
1002
+ }
1003
+
1004
+ export function decodeToClient(bytes: Uint8Array): ToClient {
1005
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
1006
+ const result = readToClient(bc)
1007
+ if (bc.offset < bc.view.byteLength) {
1008
+ throw new bare.BareError(bc.offset, "remaining bytes")
1009
+ }
1010
+ return result
1011
+ }
1012
+
1013
+
1014
+ function assert(condition: boolean, message?: string): asserts condition {
1015
+ if (!condition) throw new Error(message ?? "Assertion failed")
1016
+ }