rivetkit 2.3.3 → 2.3.5-rc.1

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 (161) hide show
  1. package/dist/browser/client.d.ts +157 -9
  2. package/dist/browser/client.js +518 -542
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +101 -2
  5. package/dist/browser/inspector/client.js +1245 -227
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/agent-os/index.cjs +103 -36
  8. package/dist/tsup/agent-os/index.cjs.map +1 -1
  9. package/dist/tsup/agent-os/index.d.cts +159 -11
  10. package/dist/tsup/agent-os/index.d.ts +159 -11
  11. package/dist/tsup/agent-os/index.js +103 -36
  12. package/dist/tsup/agent-os/index.js.map +1 -1
  13. package/dist/tsup/{chunk-34P567PO.cjs → chunk-4XKED5P5.cjs} +145 -176
  14. package/dist/tsup/chunk-4XKED5P5.cjs.map +1 -0
  15. package/dist/tsup/{chunk-PYO2U53V.cjs → chunk-6HQCLWAW.cjs} +384 -4
  16. package/dist/tsup/chunk-6HQCLWAW.cjs.map +1 -0
  17. package/dist/tsup/{chunk-JZ7TWV65.js → chunk-7AFZMFPQ.js} +15 -1
  18. package/dist/tsup/chunk-7AFZMFPQ.js.map +1 -0
  19. package/dist/tsup/{chunk-BLDO2FKO.js → chunk-B4IZU537.js} +382 -2
  20. package/dist/tsup/chunk-B4IZU537.js.map +1 -0
  21. package/dist/tsup/{chunk-3MHDOUD7.cjs → chunk-G3CCRCTK.cjs} +14 -9
  22. package/dist/tsup/chunk-G3CCRCTK.cjs.map +1 -0
  23. package/dist/tsup/{chunk-CXRPENO3.js → chunk-GAV4PKFT.js} +15 -46
  24. package/dist/tsup/{chunk-CXRPENO3.js.map → chunk-GAV4PKFT.js.map} +1 -1
  25. package/dist/tsup/{chunk-HXUEHHJF.js → chunk-JI6GZ2C2.js} +2 -11
  26. package/dist/tsup/{chunk-HXUEHHJF.js.map → chunk-JI6GZ2C2.js.map} +1 -1
  27. package/dist/tsup/{chunk-YUEC5SEY.cjs → chunk-M3FCXL3Q.cjs} +3 -3
  28. package/dist/tsup/{chunk-YUEC5SEY.cjs.map → chunk-M3FCXL3Q.cjs.map} +1 -1
  29. package/dist/tsup/{chunk-KEKWJECX.js → chunk-MGTSVSUC.js} +2 -2
  30. package/dist/tsup/{chunk-VE2X4KMG.cjs → chunk-MYWZCDML.cjs} +2 -11
  31. package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
  32. package/dist/tsup/{chunk-DFA7SYSW.js → chunk-NIC3QLKL.js} +3 -3
  33. package/dist/tsup/{chunk-BZM4PMFS.js → chunk-P4OGQ4JL.js} +5 -7
  34. package/dist/tsup/{chunk-BZM4PMFS.js.map → chunk-P4OGQ4JL.js.map} +1 -1
  35. package/dist/tsup/{chunk-NT2NK3VT.js → chunk-PAG6G46L.js} +2 -2
  36. package/dist/tsup/{chunk-XIX5DOZN.js → chunk-SHBE77IT.js} +14 -9
  37. package/dist/tsup/chunk-SHBE77IT.js.map +1 -0
  38. package/dist/tsup/{chunk-TYLP3U4Y.cjs → chunk-TNIWIUNV.cjs} +9 -11
  39. package/dist/tsup/chunk-TNIWIUNV.cjs.map +1 -0
  40. package/dist/tsup/{chunk-S644FL73.cjs → chunk-TR5NLR5V.cjs} +4 -4
  41. package/dist/tsup/{chunk-S644FL73.cjs.map → chunk-TR5NLR5V.cjs.map} +1 -1
  42. package/dist/tsup/{chunk-ZA7FLHKH.cjs → chunk-UEULFXUI.cjs} +16 -2
  43. package/dist/tsup/chunk-UEULFXUI.cjs.map +1 -0
  44. package/dist/tsup/{chunk-X63ROSOG.cjs → chunk-UJ2FQY63.cjs} +7 -7
  45. package/dist/tsup/{chunk-X63ROSOG.cjs.map → chunk-UJ2FQY63.cjs.map} +1 -1
  46. package/dist/tsup/client/mod.cjs +7 -8
  47. package/dist/tsup/client/mod.cjs.map +1 -1
  48. package/dist/tsup/client/mod.d.cts +5 -4
  49. package/dist/tsup/client/mod.d.ts +5 -4
  50. package/dist/tsup/client/mod.js +6 -7
  51. package/dist/tsup/common/log.cjs +2 -2
  52. package/dist/tsup/common/log.js +1 -1
  53. package/dist/tsup/common/websocket.cjs +3 -3
  54. package/dist/tsup/common/websocket.js +2 -2
  55. package/dist/tsup/{config-D49x8NpL.d.cts → config-BxOimoGX.d.cts} +16 -0
  56. package/dist/tsup/{config-D49x8NpL.d.ts → config-BxOimoGX.d.ts} +16 -0
  57. package/dist/tsup/{config-ZkIsRFsN.d.ts → config-BzdqbLAP.d.ts} +164 -27
  58. package/dist/tsup/{config-BfBhjEbk.d.cts → config-CPPEwn_e.d.cts} +164 -27
  59. package/dist/tsup/{context-sZ9GlaBK.d.cts → context-DSA9gFXB.d.cts} +2 -2
  60. package/dist/tsup/{context-B7-84u9K.d.ts → context-wWv-K2K_.d.ts} +2 -2
  61. package/dist/tsup/db/drizzle.cjs +120 -68
  62. package/dist/tsup/db/drizzle.cjs.map +1 -1
  63. package/dist/tsup/db/drizzle.d.cts +8 -3
  64. package/dist/tsup/db/drizzle.d.ts +8 -3
  65. package/dist/tsup/db/drizzle.js +120 -68
  66. package/dist/tsup/db/drizzle.js.map +1 -1
  67. package/dist/tsup/db/mod.cjs +74 -22
  68. package/dist/tsup/db/mod.cjs.map +1 -1
  69. package/dist/tsup/db/mod.d.cts +4 -3
  70. package/dist/tsup/db/mod.d.ts +4 -3
  71. package/dist/tsup/db/mod.js +74 -22
  72. package/dist/tsup/db/mod.js.map +1 -1
  73. package/dist/tsup/dynamic/mod.cjs +2 -2
  74. package/dist/tsup/dynamic/mod.d.cts +3 -3
  75. package/dist/tsup/dynamic/mod.d.ts +3 -3
  76. package/dist/tsup/dynamic/mod.js +1 -1
  77. package/dist/tsup/inspector/mod.cjs +4 -5
  78. package/dist/tsup/inspector/mod.cjs.map +1 -1
  79. package/dist/tsup/inspector/mod.js +3 -4
  80. package/dist/tsup/inspector/mod.js.map +1 -1
  81. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  82. package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
  83. package/dist/tsup/inspector-tab/mod.d.cts +5 -5
  84. package/dist/tsup/inspector-tab/mod.d.ts +5 -5
  85. package/dist/tsup/inspector-tab/mod.js +1 -1
  86. package/dist/tsup/inspector-tab/mod.js.map +1 -1
  87. package/dist/tsup/mod.cjs +605 -158
  88. package/dist/tsup/mod.cjs.map +1 -1
  89. package/dist/tsup/mod.d.cts +5 -5
  90. package/dist/tsup/mod.d.ts +5 -5
  91. package/dist/tsup/mod.js +528 -81
  92. package/dist/tsup/mod.js.map +1 -1
  93. package/dist/tsup/test/mod.cjs +10 -11
  94. package/dist/tsup/test/mod.cjs.map +1 -1
  95. package/dist/tsup/test/mod.d.cts +3 -3
  96. package/dist/tsup/test/mod.d.ts +3 -3
  97. package/dist/tsup/test/mod.js +6 -7
  98. package/dist/tsup/test/mod.js.map +1 -1
  99. package/dist/tsup/utils-CV0akuDD.d.ts +162 -0
  100. package/dist/tsup/utils-DQDCphrl.d.cts +162 -0
  101. package/dist/tsup/utils.cjs +6 -2
  102. package/dist/tsup/utils.cjs.map +1 -1
  103. package/dist/tsup/utils.d.cts +3 -146
  104. package/dist/tsup/utils.d.ts +3 -146
  105. package/dist/tsup/utils.js +5 -1
  106. package/dist/tsup/workflow/mod.cjs +198 -151
  107. package/dist/tsup/workflow/mod.cjs.map +1 -1
  108. package/dist/tsup/workflow/mod.d.cts +5 -5
  109. package/dist/tsup/workflow/mod.d.ts +5 -5
  110. package/dist/tsup/workflow/mod.js +187 -140
  111. package/dist/tsup/workflow/mod.js.map +1 -1
  112. package/package.json +8 -8
  113. package/src/actor/config.test.ts +14 -0
  114. package/src/actor/config.ts +104 -16
  115. package/src/actor/definition.ts +18 -7
  116. package/src/agent-os/actor/index.ts +2 -2
  117. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  118. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  119. package/src/common/database/config.ts +24 -0
  120. package/src/common/database/mod.test.ts +148 -59
  121. package/src/common/database/mod.ts +93 -23
  122. package/src/common/database/native-database.test.ts +9 -0
  123. package/src/common/database/native-database.ts +151 -0
  124. package/src/common/database/shared.ts +15 -0
  125. package/src/common/encoding.ts +28 -21
  126. package/src/db/drizzle.test.ts +157 -0
  127. package/src/db/drizzle.ts +170 -79
  128. package/src/dynamic/isolate-runtime.ts +0 -2
  129. package/src/engine-client/driver.ts +0 -15
  130. package/src/engine-client/mod.ts +0 -41
  131. package/src/inspector/client.browser.ts +69 -8
  132. package/src/inspector-tab/mod.ts +1 -0
  133. package/src/registry/config/index.ts +1 -35
  134. package/src/registry/napi-runtime.ts +204 -16
  135. package/src/registry/native.ts +200 -30
  136. package/src/registry/runtime.ts +146 -3
  137. package/src/registry/wasm-runtime.ts +217 -6
  138. package/src/utils.ts +3 -0
  139. package/src/workflow/context.ts +5 -27
  140. package/src/workflow/driver.test.ts +62 -0
  141. package/src/workflow/driver.ts +231 -113
  142. package/src/workflow/mod.ts +3 -3
  143. package/dist/tsup/chunk-34P567PO.cjs.map +0 -1
  144. package/dist/tsup/chunk-3MHDOUD7.cjs.map +0 -1
  145. package/dist/tsup/chunk-APW73HCH.cjs +0 -382
  146. package/dist/tsup/chunk-APW73HCH.cjs.map +0 -1
  147. package/dist/tsup/chunk-BLDO2FKO.js.map +0 -1
  148. package/dist/tsup/chunk-DHXWD4DF.js +0 -382
  149. package/dist/tsup/chunk-DHXWD4DF.js.map +0 -1
  150. package/dist/tsup/chunk-JZ7TWV65.js.map +0 -1
  151. package/dist/tsup/chunk-PYO2U53V.cjs.map +0 -1
  152. package/dist/tsup/chunk-TYLP3U4Y.cjs.map +0 -1
  153. package/dist/tsup/chunk-VE2X4KMG.cjs.map +0 -1
  154. package/dist/tsup/chunk-XIX5DOZN.js.map +0 -1
  155. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +0 -1
  156. package/src/actor/driver.ts +0 -141
  157. package/src/actor/instance/mod.ts +0 -2484
  158. package/src/drivers/engine/actor-driver.ts +0 -2473
  159. /package/dist/tsup/{chunk-KEKWJECX.js.map → chunk-MGTSVSUC.js.map} +0 -0
  160. /package/dist/tsup/{chunk-DFA7SYSW.js.map → chunk-NIC3QLKL.js.map} +0 -0
  161. /package/dist/tsup/{chunk-NT2NK3VT.js.map → chunk-PAG6G46L.js.map} +0 -0
@@ -0,0 +1,1367 @@
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 SchedulesRequest = {
224
+ readonly id: uint
225
+ }
226
+
227
+ export function readSchedulesRequest(bc: bare.ByteCursor): SchedulesRequest {
228
+ return {
229
+ id: bare.readUint(bc),
230
+ }
231
+ }
232
+
233
+ export function writeSchedulesRequest(bc: bare.ByteCursor, x: SchedulesRequest): void {
234
+ bare.writeUint(bc, x.id)
235
+ }
236
+
237
+ export type ScheduleHistoryRequest = {
238
+ readonly id: uint
239
+ readonly scheduleId: string
240
+ readonly limit: uint
241
+ }
242
+
243
+ export function readScheduleHistoryRequest(bc: bare.ByteCursor): ScheduleHistoryRequest {
244
+ return {
245
+ id: bare.readUint(bc),
246
+ scheduleId: bare.readString(bc),
247
+ limit: bare.readUint(bc),
248
+ }
249
+ }
250
+
251
+ export function writeScheduleHistoryRequest(bc: bare.ByteCursor, x: ScheduleHistoryRequest): void {
252
+ bare.writeUint(bc, x.id)
253
+ bare.writeString(bc, x.scheduleId)
254
+ bare.writeUint(bc, x.limit)
255
+ }
256
+
257
+ export type ScheduleDeleteRequest = {
258
+ readonly id: uint
259
+ readonly scheduleId: string
260
+ readonly kind: string
261
+ }
262
+
263
+ export function readScheduleDeleteRequest(bc: bare.ByteCursor): ScheduleDeleteRequest {
264
+ return {
265
+ id: bare.readUint(bc),
266
+ scheduleId: bare.readString(bc),
267
+ kind: bare.readString(bc),
268
+ }
269
+ }
270
+
271
+ export function writeScheduleDeleteRequest(bc: bare.ByteCursor, x: ScheduleDeleteRequest): void {
272
+ bare.writeUint(bc, x.id)
273
+ bare.writeString(bc, x.scheduleId)
274
+ bare.writeString(bc, x.kind)
275
+ }
276
+
277
+ export type ToServerBody =
278
+ | { readonly tag: "PatchStateRequest"; readonly val: PatchStateRequest }
279
+ | { readonly tag: "StateRequest"; readonly val: StateRequest }
280
+ | { readonly tag: "ConnectionsRequest"; readonly val: ConnectionsRequest }
281
+ | { readonly tag: "ActionRequest"; readonly val: ActionRequest }
282
+ | { readonly tag: "RpcsListRequest"; readonly val: RpcsListRequest }
283
+ | { readonly tag: "TraceQueryRequest"; readonly val: TraceQueryRequest }
284
+ | { readonly tag: "QueueRequest"; readonly val: QueueRequest }
285
+ | { readonly tag: "WorkflowHistoryRequest"; readonly val: WorkflowHistoryRequest }
286
+ | { readonly tag: "WorkflowReplayRequest"; readonly val: WorkflowReplayRequest }
287
+ | { readonly tag: "DatabaseSchemaRequest"; readonly val: DatabaseSchemaRequest }
288
+ | { readonly tag: "DatabaseTableRowsRequest"; readonly val: DatabaseTableRowsRequest }
289
+ | { readonly tag: "SchedulesRequest"; readonly val: SchedulesRequest }
290
+ | { readonly tag: "ScheduleHistoryRequest"; readonly val: ScheduleHistoryRequest }
291
+ | { readonly tag: "ScheduleDeleteRequest"; readonly val: ScheduleDeleteRequest }
292
+
293
+ export function readToServerBody(bc: bare.ByteCursor): ToServerBody {
294
+ const offset = bc.offset
295
+ const tag = bare.readU8(bc)
296
+ switch (tag) {
297
+ case 0:
298
+ return { tag: "PatchStateRequest", val: readPatchStateRequest(bc) }
299
+ case 1:
300
+ return { tag: "StateRequest", val: readStateRequest(bc) }
301
+ case 2:
302
+ return { tag: "ConnectionsRequest", val: readConnectionsRequest(bc) }
303
+ case 3:
304
+ return { tag: "ActionRequest", val: readActionRequest(bc) }
305
+ case 4:
306
+ return { tag: "RpcsListRequest", val: readRpcsListRequest(bc) }
307
+ case 5:
308
+ return { tag: "TraceQueryRequest", val: readTraceQueryRequest(bc) }
309
+ case 6:
310
+ return { tag: "QueueRequest", val: readQueueRequest(bc) }
311
+ case 7:
312
+ return { tag: "WorkflowHistoryRequest", val: readWorkflowHistoryRequest(bc) }
313
+ case 8:
314
+ return { tag: "WorkflowReplayRequest", val: readWorkflowReplayRequest(bc) }
315
+ case 9:
316
+ return { tag: "DatabaseSchemaRequest", val: readDatabaseSchemaRequest(bc) }
317
+ case 10:
318
+ return { tag: "DatabaseTableRowsRequest", val: readDatabaseTableRowsRequest(bc) }
319
+ case 11:
320
+ return { tag: "SchedulesRequest", val: readSchedulesRequest(bc) }
321
+ case 12:
322
+ return { tag: "ScheduleHistoryRequest", val: readScheduleHistoryRequest(bc) }
323
+ case 13:
324
+ return { tag: "ScheduleDeleteRequest", val: readScheduleDeleteRequest(bc) }
325
+ default: {
326
+ bc.offset = offset
327
+ throw new bare.BareError(offset, "invalid tag")
328
+ }
329
+ }
330
+ }
331
+
332
+ export function writeToServerBody(bc: bare.ByteCursor, x: ToServerBody): void {
333
+ switch (x.tag) {
334
+ case "PatchStateRequest": {
335
+ bare.writeU8(bc, 0)
336
+ writePatchStateRequest(bc, x.val)
337
+ break
338
+ }
339
+ case "StateRequest": {
340
+ bare.writeU8(bc, 1)
341
+ writeStateRequest(bc, x.val)
342
+ break
343
+ }
344
+ case "ConnectionsRequest": {
345
+ bare.writeU8(bc, 2)
346
+ writeConnectionsRequest(bc, x.val)
347
+ break
348
+ }
349
+ case "ActionRequest": {
350
+ bare.writeU8(bc, 3)
351
+ writeActionRequest(bc, x.val)
352
+ break
353
+ }
354
+ case "RpcsListRequest": {
355
+ bare.writeU8(bc, 4)
356
+ writeRpcsListRequest(bc, x.val)
357
+ break
358
+ }
359
+ case "TraceQueryRequest": {
360
+ bare.writeU8(bc, 5)
361
+ writeTraceQueryRequest(bc, x.val)
362
+ break
363
+ }
364
+ case "QueueRequest": {
365
+ bare.writeU8(bc, 6)
366
+ writeQueueRequest(bc, x.val)
367
+ break
368
+ }
369
+ case "WorkflowHistoryRequest": {
370
+ bare.writeU8(bc, 7)
371
+ writeWorkflowHistoryRequest(bc, x.val)
372
+ break
373
+ }
374
+ case "WorkflowReplayRequest": {
375
+ bare.writeU8(bc, 8)
376
+ writeWorkflowReplayRequest(bc, x.val)
377
+ break
378
+ }
379
+ case "DatabaseSchemaRequest": {
380
+ bare.writeU8(bc, 9)
381
+ writeDatabaseSchemaRequest(bc, x.val)
382
+ break
383
+ }
384
+ case "DatabaseTableRowsRequest": {
385
+ bare.writeU8(bc, 10)
386
+ writeDatabaseTableRowsRequest(bc, x.val)
387
+ break
388
+ }
389
+ case "SchedulesRequest": {
390
+ bare.writeU8(bc, 11)
391
+ writeSchedulesRequest(bc, x.val)
392
+ break
393
+ }
394
+ case "ScheduleHistoryRequest": {
395
+ bare.writeU8(bc, 12)
396
+ writeScheduleHistoryRequest(bc, x.val)
397
+ break
398
+ }
399
+ case "ScheduleDeleteRequest": {
400
+ bare.writeU8(bc, 13)
401
+ writeScheduleDeleteRequest(bc, x.val)
402
+ break
403
+ }
404
+ }
405
+ }
406
+
407
+ export type ToServer = {
408
+ readonly body: ToServerBody
409
+ }
410
+
411
+ export function readToServer(bc: bare.ByteCursor): ToServer {
412
+ return {
413
+ body: readToServerBody(bc),
414
+ }
415
+ }
416
+
417
+ export function writeToServer(bc: bare.ByteCursor, x: ToServer): void {
418
+ writeToServerBody(bc, x.body)
419
+ }
420
+
421
+ export function encodeToServer(x: ToServer, config?: Partial<bare.Config>): Uint8Array {
422
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
423
+ const bc = new bare.ByteCursor(
424
+ new Uint8Array(fullConfig.initialBufferLength),
425
+ fullConfig,
426
+ )
427
+ writeToServer(bc, x)
428
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
429
+ }
430
+
431
+ export function decodeToServer(bytes: Uint8Array): ToServer {
432
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
433
+ const result = readToServer(bc)
434
+ if (bc.offset < bc.view.byteLength) {
435
+ throw new bare.BareError(bc.offset, "remaining bytes")
436
+ }
437
+ return result
438
+ }
439
+
440
+ export type Connection = {
441
+ readonly id: string
442
+ readonly details: ArrayBuffer
443
+ }
444
+
445
+ export function readConnection(bc: bare.ByteCursor): Connection {
446
+ return {
447
+ id: bare.readString(bc),
448
+ details: bare.readData(bc),
449
+ }
450
+ }
451
+
452
+ export function writeConnection(bc: bare.ByteCursor, x: Connection): void {
453
+ bare.writeString(bc, x.id)
454
+ bare.writeData(bc, x.details)
455
+ }
456
+
457
+ /**
458
+ * Inspector tab descriptor. `label`/`icon` are set for author-declared custom
459
+ * tabs; a hidden built-in only carries `id` with `hidden` set.
460
+ */
461
+ export type TabConfigEntry = {
462
+ readonly id: string
463
+ readonly label: string | null
464
+ readonly icon: string | null
465
+ readonly hidden: boolean
466
+ }
467
+
468
+ export function readTabConfigEntry(bc: bare.ByteCursor): TabConfigEntry {
469
+ return {
470
+ id: bare.readString(bc),
471
+ label: read0(bc),
472
+ icon: read0(bc),
473
+ hidden: bare.readBool(bc),
474
+ }
475
+ }
476
+
477
+ export function writeTabConfigEntry(bc: bare.ByteCursor, x: TabConfigEntry): void {
478
+ bare.writeString(bc, x.id)
479
+ write0(bc, x.label)
480
+ write0(bc, x.icon)
481
+ bare.writeBool(bc, x.hidden)
482
+ }
483
+
484
+ function read1(bc: bare.ByteCursor): uint | null {
485
+ return bare.readBool(bc) ? bare.readUint(bc) : null
486
+ }
487
+
488
+ function write1(bc: bare.ByteCursor, x: uint | null): void {
489
+ bare.writeBool(bc, x != null)
490
+ if (x != null) {
491
+ bare.writeUint(bc, x)
492
+ }
493
+ }
494
+
495
+ export type Schedule = {
496
+ readonly id: string
497
+ readonly name: string | null
498
+ readonly kind: string
499
+ readonly action: string
500
+ readonly args: ArrayBuffer
501
+ readonly nextRunAt: uint
502
+ readonly lastRunAt: uint | null
503
+ readonly expression: string | null
504
+ readonly timezone: string | null
505
+ readonly intervalMs: uint | null
506
+ readonly maxHistory: uint | null
507
+ }
508
+
509
+ export function readSchedule(bc: bare.ByteCursor): Schedule {
510
+ return {
511
+ id: bare.readString(bc),
512
+ name: read0(bc),
513
+ kind: bare.readString(bc),
514
+ action: bare.readString(bc),
515
+ args: bare.readData(bc),
516
+ nextRunAt: bare.readUint(bc),
517
+ lastRunAt: read1(bc),
518
+ expression: read0(bc),
519
+ timezone: read0(bc),
520
+ intervalMs: read1(bc),
521
+ maxHistory: read1(bc),
522
+ }
523
+ }
524
+
525
+ export function writeSchedule(bc: bare.ByteCursor, x: Schedule): void {
526
+ bare.writeString(bc, x.id)
527
+ write0(bc, x.name)
528
+ bare.writeString(bc, x.kind)
529
+ bare.writeString(bc, x.action)
530
+ bare.writeData(bc, x.args)
531
+ bare.writeUint(bc, x.nextRunAt)
532
+ write1(bc, x.lastRunAt)
533
+ write0(bc, x.expression)
534
+ write0(bc, x.timezone)
535
+ write1(bc, x.intervalMs)
536
+ write1(bc, x.maxHistory)
537
+ }
538
+
539
+ function read2(bc: bare.ByteCursor): ArrayBuffer | null {
540
+ return bare.readBool(bc) ? bare.readData(bc) : null
541
+ }
542
+
543
+ function write2(bc: bare.ByteCursor, x: ArrayBuffer | null): void {
544
+ bare.writeBool(bc, x != null)
545
+ if (x != null) {
546
+ bare.writeData(bc, x)
547
+ }
548
+ }
549
+
550
+ export type ScheduleError = {
551
+ readonly group: string
552
+ readonly code: string
553
+ readonly message: string
554
+ readonly metadata: ArrayBuffer | null
555
+ }
556
+
557
+ export function readScheduleError(bc: bare.ByteCursor): ScheduleError {
558
+ return {
559
+ group: bare.readString(bc),
560
+ code: bare.readString(bc),
561
+ message: bare.readString(bc),
562
+ metadata: read2(bc),
563
+ }
564
+ }
565
+
566
+ export function writeScheduleError(bc: bare.ByteCursor, x: ScheduleError): void {
567
+ bare.writeString(bc, x.group)
568
+ bare.writeString(bc, x.code)
569
+ bare.writeString(bc, x.message)
570
+ write2(bc, x.metadata)
571
+ }
572
+
573
+ function read3(bc: bare.ByteCursor): ScheduleError | null {
574
+ return bare.readBool(bc) ? readScheduleError(bc) : null
575
+ }
576
+
577
+ function write3(bc: bare.ByteCursor, x: ScheduleError | null): void {
578
+ bare.writeBool(bc, x != null)
579
+ if (x != null) {
580
+ writeScheduleError(bc, x)
581
+ }
582
+ }
583
+
584
+ export type ScheduleFire = {
585
+ readonly action: string
586
+ readonly scheduledAt: uint
587
+ readonly firedAt: uint
588
+ readonly finishedAt: uint | null
589
+ readonly result: string
590
+ readonly error: ScheduleError | null
591
+ }
592
+
593
+ export function readScheduleFire(bc: bare.ByteCursor): ScheduleFire {
594
+ return {
595
+ action: bare.readString(bc),
596
+ scheduledAt: bare.readUint(bc),
597
+ firedAt: bare.readUint(bc),
598
+ finishedAt: read1(bc),
599
+ result: bare.readString(bc),
600
+ error: read3(bc),
601
+ }
602
+ }
603
+
604
+ export function writeScheduleFire(bc: bare.ByteCursor, x: ScheduleFire): void {
605
+ bare.writeString(bc, x.action)
606
+ bare.writeUint(bc, x.scheduledAt)
607
+ bare.writeUint(bc, x.firedAt)
608
+ write1(bc, x.finishedAt)
609
+ bare.writeString(bc, x.result)
610
+ write3(bc, x.error)
611
+ }
612
+
613
+ function read4(bc: bare.ByteCursor): readonly Connection[] {
614
+ const len = bare.readUintSafe(bc)
615
+ if (len === 0) {
616
+ return []
617
+ }
618
+ const result = [readConnection(bc)]
619
+ for (let i = 1; i < len; i++) {
620
+ result[i] = readConnection(bc)
621
+ }
622
+ return result
623
+ }
624
+
625
+ function write4(bc: bare.ByteCursor, x: readonly Connection[]): void {
626
+ bare.writeUintSafe(bc, x.length)
627
+ for (let i = 0; i < x.length; i++) {
628
+ writeConnection(bc, x[i])
629
+ }
630
+ }
631
+
632
+ function read5(bc: bare.ByteCursor): State | null {
633
+ return bare.readBool(bc) ? readState(bc) : null
634
+ }
635
+
636
+ function write5(bc: bare.ByteCursor, x: State | null): void {
637
+ bare.writeBool(bc, x != null)
638
+ if (x != null) {
639
+ writeState(bc, x)
640
+ }
641
+ }
642
+
643
+ function read6(bc: bare.ByteCursor): readonly string[] {
644
+ const len = bare.readUintSafe(bc)
645
+ if (len === 0) {
646
+ return []
647
+ }
648
+ const result = [bare.readString(bc)]
649
+ for (let i = 1; i < len; i++) {
650
+ result[i] = bare.readString(bc)
651
+ }
652
+ return result
653
+ }
654
+
655
+ function write6(bc: bare.ByteCursor, x: readonly string[]): void {
656
+ bare.writeUintSafe(bc, x.length)
657
+ for (let i = 0; i < x.length; i++) {
658
+ bare.writeString(bc, x[i])
659
+ }
660
+ }
661
+
662
+ function read7(bc: bare.ByteCursor): WorkflowHistory | null {
663
+ return bare.readBool(bc) ? readWorkflowHistory(bc) : null
664
+ }
665
+
666
+ function write7(bc: bare.ByteCursor, x: WorkflowHistory | null): void {
667
+ bare.writeBool(bc, x != null)
668
+ if (x != null) {
669
+ writeWorkflowHistory(bc, x)
670
+ }
671
+ }
672
+
673
+ function read8(bc: bare.ByteCursor): readonly TabConfigEntry[] {
674
+ const len = bare.readUintSafe(bc)
675
+ if (len === 0) {
676
+ return []
677
+ }
678
+ const result = [readTabConfigEntry(bc)]
679
+ for (let i = 1; i < len; i++) {
680
+ result[i] = readTabConfigEntry(bc)
681
+ }
682
+ return result
683
+ }
684
+
685
+ function write8(bc: bare.ByteCursor, x: readonly TabConfigEntry[]): void {
686
+ bare.writeUintSafe(bc, x.length)
687
+ for (let i = 0; i < x.length; i++) {
688
+ writeTabConfigEntry(bc, x[i])
689
+ }
690
+ }
691
+
692
+ function read9(bc: bare.ByteCursor): readonly Schedule[] {
693
+ const len = bare.readUintSafe(bc)
694
+ if (len === 0) {
695
+ return []
696
+ }
697
+ const result = [readSchedule(bc)]
698
+ for (let i = 1; i < len; i++) {
699
+ result[i] = readSchedule(bc)
700
+ }
701
+ return result
702
+ }
703
+
704
+ function write9(bc: bare.ByteCursor, x: readonly Schedule[]): void {
705
+ bare.writeUintSafe(bc, x.length)
706
+ for (let i = 0; i < x.length; i++) {
707
+ writeSchedule(bc, x[i])
708
+ }
709
+ }
710
+
711
+ export type Init = {
712
+ readonly connections: readonly Connection[]
713
+ readonly state: State | null
714
+ readonly isStateEnabled: boolean
715
+ readonly rpcs: readonly string[]
716
+ readonly isDatabaseEnabled: boolean
717
+ readonly queueSize: uint
718
+ readonly workflowHistory: WorkflowHistory | null
719
+ readonly isWorkflowEnabled: boolean
720
+ readonly tabConfig: readonly TabConfigEntry[]
721
+ readonly schedules: readonly Schedule[]
722
+ }
723
+
724
+ export function readInit(bc: bare.ByteCursor): Init {
725
+ return {
726
+ connections: read4(bc),
727
+ state: read5(bc),
728
+ isStateEnabled: bare.readBool(bc),
729
+ rpcs: read6(bc),
730
+ isDatabaseEnabled: bare.readBool(bc),
731
+ queueSize: bare.readUint(bc),
732
+ workflowHistory: read7(bc),
733
+ isWorkflowEnabled: bare.readBool(bc),
734
+ tabConfig: read8(bc),
735
+ schedules: read9(bc),
736
+ }
737
+ }
738
+
739
+ export function writeInit(bc: bare.ByteCursor, x: Init): void {
740
+ write4(bc, x.connections)
741
+ write5(bc, x.state)
742
+ bare.writeBool(bc, x.isStateEnabled)
743
+ write6(bc, x.rpcs)
744
+ bare.writeBool(bc, x.isDatabaseEnabled)
745
+ bare.writeUint(bc, x.queueSize)
746
+ write7(bc, x.workflowHistory)
747
+ bare.writeBool(bc, x.isWorkflowEnabled)
748
+ write8(bc, x.tabConfig)
749
+ write9(bc, x.schedules)
750
+ }
751
+
752
+ export type ConnectionsResponse = {
753
+ readonly rid: uint
754
+ readonly connections: readonly Connection[]
755
+ }
756
+
757
+ export function readConnectionsResponse(bc: bare.ByteCursor): ConnectionsResponse {
758
+ return {
759
+ rid: bare.readUint(bc),
760
+ connections: read4(bc),
761
+ }
762
+ }
763
+
764
+ export function writeConnectionsResponse(bc: bare.ByteCursor, x: ConnectionsResponse): void {
765
+ bare.writeUint(bc, x.rid)
766
+ write4(bc, x.connections)
767
+ }
768
+
769
+ export type StateResponse = {
770
+ readonly rid: uint
771
+ readonly state: State | null
772
+ readonly isStateEnabled: boolean
773
+ }
774
+
775
+ export function readStateResponse(bc: bare.ByteCursor): StateResponse {
776
+ return {
777
+ rid: bare.readUint(bc),
778
+ state: read5(bc),
779
+ isStateEnabled: bare.readBool(bc),
780
+ }
781
+ }
782
+
783
+ export function writeStateResponse(bc: bare.ByteCursor, x: StateResponse): void {
784
+ bare.writeUint(bc, x.rid)
785
+ write5(bc, x.state)
786
+ bare.writeBool(bc, x.isStateEnabled)
787
+ }
788
+
789
+ export type ActionResponse = {
790
+ readonly rid: uint
791
+ readonly output: ArrayBuffer
792
+ }
793
+
794
+ export function readActionResponse(bc: bare.ByteCursor): ActionResponse {
795
+ return {
796
+ rid: bare.readUint(bc),
797
+ output: bare.readData(bc),
798
+ }
799
+ }
800
+
801
+ export function writeActionResponse(bc: bare.ByteCursor, x: ActionResponse): void {
802
+ bare.writeUint(bc, x.rid)
803
+ bare.writeData(bc, x.output)
804
+ }
805
+
806
+ export type TraceQueryResponse = {
807
+ readonly rid: uint
808
+ readonly payload: ArrayBuffer
809
+ }
810
+
811
+ export function readTraceQueryResponse(bc: bare.ByteCursor): TraceQueryResponse {
812
+ return {
813
+ rid: bare.readUint(bc),
814
+ payload: bare.readData(bc),
815
+ }
816
+ }
817
+
818
+ export function writeTraceQueryResponse(bc: bare.ByteCursor, x: TraceQueryResponse): void {
819
+ bare.writeUint(bc, x.rid)
820
+ bare.writeData(bc, x.payload)
821
+ }
822
+
823
+ export type QueueMessageSummary = {
824
+ readonly id: uint
825
+ readonly name: string
826
+ readonly createdAtMs: uint
827
+ }
828
+
829
+ export function readQueueMessageSummary(bc: bare.ByteCursor): QueueMessageSummary {
830
+ return {
831
+ id: bare.readUint(bc),
832
+ name: bare.readString(bc),
833
+ createdAtMs: bare.readUint(bc),
834
+ }
835
+ }
836
+
837
+ export function writeQueueMessageSummary(bc: bare.ByteCursor, x: QueueMessageSummary): void {
838
+ bare.writeUint(bc, x.id)
839
+ bare.writeString(bc, x.name)
840
+ bare.writeUint(bc, x.createdAtMs)
841
+ }
842
+
843
+ function read10(bc: bare.ByteCursor): readonly QueueMessageSummary[] {
844
+ const len = bare.readUintSafe(bc)
845
+ if (len === 0) {
846
+ return []
847
+ }
848
+ const result = [readQueueMessageSummary(bc)]
849
+ for (let i = 1; i < len; i++) {
850
+ result[i] = readQueueMessageSummary(bc)
851
+ }
852
+ return result
853
+ }
854
+
855
+ function write10(bc: bare.ByteCursor, x: readonly QueueMessageSummary[]): void {
856
+ bare.writeUintSafe(bc, x.length)
857
+ for (let i = 0; i < x.length; i++) {
858
+ writeQueueMessageSummary(bc, x[i])
859
+ }
860
+ }
861
+
862
+ export type QueueStatus = {
863
+ readonly size: uint
864
+ readonly maxSize: uint
865
+ readonly messages: readonly QueueMessageSummary[]
866
+ readonly truncated: boolean
867
+ }
868
+
869
+ export function readQueueStatus(bc: bare.ByteCursor): QueueStatus {
870
+ return {
871
+ size: bare.readUint(bc),
872
+ maxSize: bare.readUint(bc),
873
+ messages: read10(bc),
874
+ truncated: bare.readBool(bc),
875
+ }
876
+ }
877
+
878
+ export function writeQueueStatus(bc: bare.ByteCursor, x: QueueStatus): void {
879
+ bare.writeUint(bc, x.size)
880
+ bare.writeUint(bc, x.maxSize)
881
+ write10(bc, x.messages)
882
+ bare.writeBool(bc, x.truncated)
883
+ }
884
+
885
+ export type QueueResponse = {
886
+ readonly rid: uint
887
+ readonly status: QueueStatus
888
+ }
889
+
890
+ export function readQueueResponse(bc: bare.ByteCursor): QueueResponse {
891
+ return {
892
+ rid: bare.readUint(bc),
893
+ status: readQueueStatus(bc),
894
+ }
895
+ }
896
+
897
+ export function writeQueueResponse(bc: bare.ByteCursor, x: QueueResponse): void {
898
+ bare.writeUint(bc, x.rid)
899
+ writeQueueStatus(bc, x.status)
900
+ }
901
+
902
+ export type WorkflowHistoryResponse = {
903
+ readonly rid: uint
904
+ readonly history: WorkflowHistory | null
905
+ readonly isWorkflowEnabled: boolean
906
+ }
907
+
908
+ export function readWorkflowHistoryResponse(bc: bare.ByteCursor): WorkflowHistoryResponse {
909
+ return {
910
+ rid: bare.readUint(bc),
911
+ history: read7(bc),
912
+ isWorkflowEnabled: bare.readBool(bc),
913
+ }
914
+ }
915
+
916
+ export function writeWorkflowHistoryResponse(bc: bare.ByteCursor, x: WorkflowHistoryResponse): void {
917
+ bare.writeUint(bc, x.rid)
918
+ write7(bc, x.history)
919
+ bare.writeBool(bc, x.isWorkflowEnabled)
920
+ }
921
+
922
+ export type WorkflowReplayResponse = {
923
+ readonly rid: uint
924
+ readonly history: WorkflowHistory | null
925
+ readonly isWorkflowEnabled: boolean
926
+ }
927
+
928
+ export function readWorkflowReplayResponse(bc: bare.ByteCursor): WorkflowReplayResponse {
929
+ return {
930
+ rid: bare.readUint(bc),
931
+ history: read7(bc),
932
+ isWorkflowEnabled: bare.readBool(bc),
933
+ }
934
+ }
935
+
936
+ export function writeWorkflowReplayResponse(bc: bare.ByteCursor, x: WorkflowReplayResponse): void {
937
+ bare.writeUint(bc, x.rid)
938
+ write7(bc, x.history)
939
+ bare.writeBool(bc, x.isWorkflowEnabled)
940
+ }
941
+
942
+ export type DatabaseSchemaResponse = {
943
+ readonly rid: uint
944
+ readonly schema: ArrayBuffer
945
+ }
946
+
947
+ export function readDatabaseSchemaResponse(bc: bare.ByteCursor): DatabaseSchemaResponse {
948
+ return {
949
+ rid: bare.readUint(bc),
950
+ schema: bare.readData(bc),
951
+ }
952
+ }
953
+
954
+ export function writeDatabaseSchemaResponse(bc: bare.ByteCursor, x: DatabaseSchemaResponse): void {
955
+ bare.writeUint(bc, x.rid)
956
+ bare.writeData(bc, x.schema)
957
+ }
958
+
959
+ export type DatabaseTableRowsResponse = {
960
+ readonly rid: uint
961
+ readonly result: ArrayBuffer
962
+ }
963
+
964
+ export function readDatabaseTableRowsResponse(bc: bare.ByteCursor): DatabaseTableRowsResponse {
965
+ return {
966
+ rid: bare.readUint(bc),
967
+ result: bare.readData(bc),
968
+ }
969
+ }
970
+
971
+ export function writeDatabaseTableRowsResponse(bc: bare.ByteCursor, x: DatabaseTableRowsResponse): void {
972
+ bare.writeUint(bc, x.rid)
973
+ bare.writeData(bc, x.result)
974
+ }
975
+
976
+ export type SchedulesResponse = {
977
+ readonly rid: uint
978
+ readonly schedules: readonly Schedule[]
979
+ }
980
+
981
+ export function readSchedulesResponse(bc: bare.ByteCursor): SchedulesResponse {
982
+ return {
983
+ rid: bare.readUint(bc),
984
+ schedules: read9(bc),
985
+ }
986
+ }
987
+
988
+ export function writeSchedulesResponse(bc: bare.ByteCursor, x: SchedulesResponse): void {
989
+ bare.writeUint(bc, x.rid)
990
+ write9(bc, x.schedules)
991
+ }
992
+
993
+ function read11(bc: bare.ByteCursor): readonly ScheduleFire[] {
994
+ const len = bare.readUintSafe(bc)
995
+ if (len === 0) {
996
+ return []
997
+ }
998
+ const result = [readScheduleFire(bc)]
999
+ for (let i = 1; i < len; i++) {
1000
+ result[i] = readScheduleFire(bc)
1001
+ }
1002
+ return result
1003
+ }
1004
+
1005
+ function write11(bc: bare.ByteCursor, x: readonly ScheduleFire[]): void {
1006
+ bare.writeUintSafe(bc, x.length)
1007
+ for (let i = 0; i < x.length; i++) {
1008
+ writeScheduleFire(bc, x[i])
1009
+ }
1010
+ }
1011
+
1012
+ export type ScheduleHistoryResponse = {
1013
+ readonly rid: uint
1014
+ readonly scheduleId: string
1015
+ readonly history: readonly ScheduleFire[]
1016
+ }
1017
+
1018
+ export function readScheduleHistoryResponse(bc: bare.ByteCursor): ScheduleHistoryResponse {
1019
+ return {
1020
+ rid: bare.readUint(bc),
1021
+ scheduleId: bare.readString(bc),
1022
+ history: read11(bc),
1023
+ }
1024
+ }
1025
+
1026
+ export function writeScheduleHistoryResponse(bc: bare.ByteCursor, x: ScheduleHistoryResponse): void {
1027
+ bare.writeUint(bc, x.rid)
1028
+ bare.writeString(bc, x.scheduleId)
1029
+ write11(bc, x.history)
1030
+ }
1031
+
1032
+ export type ScheduleDeleteResponse = {
1033
+ readonly rid: uint
1034
+ readonly scheduleId: string
1035
+ readonly deleted: boolean
1036
+ }
1037
+
1038
+ export function readScheduleDeleteResponse(bc: bare.ByteCursor): ScheduleDeleteResponse {
1039
+ return {
1040
+ rid: bare.readUint(bc),
1041
+ scheduleId: bare.readString(bc),
1042
+ deleted: bare.readBool(bc),
1043
+ }
1044
+ }
1045
+
1046
+ export function writeScheduleDeleteResponse(bc: bare.ByteCursor, x: ScheduleDeleteResponse): void {
1047
+ bare.writeUint(bc, x.rid)
1048
+ bare.writeString(bc, x.scheduleId)
1049
+ bare.writeBool(bc, x.deleted)
1050
+ }
1051
+
1052
+ export type StateUpdated = {
1053
+ readonly state: State
1054
+ }
1055
+
1056
+ export function readStateUpdated(bc: bare.ByteCursor): StateUpdated {
1057
+ return {
1058
+ state: readState(bc),
1059
+ }
1060
+ }
1061
+
1062
+ export function writeStateUpdated(bc: bare.ByteCursor, x: StateUpdated): void {
1063
+ writeState(bc, x.state)
1064
+ }
1065
+
1066
+ export type QueueUpdated = {
1067
+ readonly queueSize: uint
1068
+ }
1069
+
1070
+ export function readQueueUpdated(bc: bare.ByteCursor): QueueUpdated {
1071
+ return {
1072
+ queueSize: bare.readUint(bc),
1073
+ }
1074
+ }
1075
+
1076
+ export function writeQueueUpdated(bc: bare.ByteCursor, x: QueueUpdated): void {
1077
+ bare.writeUint(bc, x.queueSize)
1078
+ }
1079
+
1080
+ export type WorkflowHistoryUpdated = {
1081
+ readonly history: WorkflowHistory
1082
+ }
1083
+
1084
+ export function readWorkflowHistoryUpdated(bc: bare.ByteCursor): WorkflowHistoryUpdated {
1085
+ return {
1086
+ history: readWorkflowHistory(bc),
1087
+ }
1088
+ }
1089
+
1090
+ export function writeWorkflowHistoryUpdated(bc: bare.ByteCursor, x: WorkflowHistoryUpdated): void {
1091
+ writeWorkflowHistory(bc, x.history)
1092
+ }
1093
+
1094
+ export type SchedulesUpdated = {
1095
+ readonly schedules: readonly Schedule[]
1096
+ }
1097
+
1098
+ export function readSchedulesUpdated(bc: bare.ByteCursor): SchedulesUpdated {
1099
+ return {
1100
+ schedules: read9(bc),
1101
+ }
1102
+ }
1103
+
1104
+ export function writeSchedulesUpdated(bc: bare.ByteCursor, x: SchedulesUpdated): void {
1105
+ write9(bc, x.schedules)
1106
+ }
1107
+
1108
+ export type RpcsListResponse = {
1109
+ readonly rid: uint
1110
+ readonly rpcs: readonly string[]
1111
+ }
1112
+
1113
+ export function readRpcsListResponse(bc: bare.ByteCursor): RpcsListResponse {
1114
+ return {
1115
+ rid: bare.readUint(bc),
1116
+ rpcs: read6(bc),
1117
+ }
1118
+ }
1119
+
1120
+ export function writeRpcsListResponse(bc: bare.ByteCursor, x: RpcsListResponse): void {
1121
+ bare.writeUint(bc, x.rid)
1122
+ write6(bc, x.rpcs)
1123
+ }
1124
+
1125
+ export type ConnectionsUpdated = {
1126
+ readonly connections: readonly Connection[]
1127
+ }
1128
+
1129
+ export function readConnectionsUpdated(bc: bare.ByteCursor): ConnectionsUpdated {
1130
+ return {
1131
+ connections: read4(bc),
1132
+ }
1133
+ }
1134
+
1135
+ export function writeConnectionsUpdated(bc: bare.ByteCursor, x: ConnectionsUpdated): void {
1136
+ write4(bc, x.connections)
1137
+ }
1138
+
1139
+ export type Error = {
1140
+ readonly message: string
1141
+ }
1142
+
1143
+ export function readError(bc: bare.ByteCursor): Error {
1144
+ return {
1145
+ message: bare.readString(bc),
1146
+ }
1147
+ }
1148
+
1149
+ export function writeError(bc: bare.ByteCursor, x: Error): void {
1150
+ bare.writeString(bc, x.message)
1151
+ }
1152
+
1153
+ export type ToClientBody =
1154
+ | { readonly tag: "StateResponse"; readonly val: StateResponse }
1155
+ | { readonly tag: "ConnectionsResponse"; readonly val: ConnectionsResponse }
1156
+ | { readonly tag: "ActionResponse"; readonly val: ActionResponse }
1157
+ | { readonly tag: "ConnectionsUpdated"; readonly val: ConnectionsUpdated }
1158
+ | { readonly tag: "QueueUpdated"; readonly val: QueueUpdated }
1159
+ | { readonly tag: "StateUpdated"; readonly val: StateUpdated }
1160
+ | { readonly tag: "WorkflowHistoryUpdated"; readonly val: WorkflowHistoryUpdated }
1161
+ | { readonly tag: "SchedulesUpdated"; readonly val: SchedulesUpdated }
1162
+ | { readonly tag: "RpcsListResponse"; readonly val: RpcsListResponse }
1163
+ | { readonly tag: "TraceQueryResponse"; readonly val: TraceQueryResponse }
1164
+ | { readonly tag: "QueueResponse"; readonly val: QueueResponse }
1165
+ | { readonly tag: "WorkflowHistoryResponse"; readonly val: WorkflowHistoryResponse }
1166
+ | { readonly tag: "WorkflowReplayResponse"; readonly val: WorkflowReplayResponse }
1167
+ | { readonly tag: "SchedulesResponse"; readonly val: SchedulesResponse }
1168
+ | { readonly tag: "ScheduleHistoryResponse"; readonly val: ScheduleHistoryResponse }
1169
+ | { readonly tag: "ScheduleDeleteResponse"; readonly val: ScheduleDeleteResponse }
1170
+ | { readonly tag: "Error"; readonly val: Error }
1171
+ | { readonly tag: "Init"; readonly val: Init }
1172
+ | { readonly tag: "DatabaseSchemaResponse"; readonly val: DatabaseSchemaResponse }
1173
+ | { readonly tag: "DatabaseTableRowsResponse"; readonly val: DatabaseTableRowsResponse }
1174
+
1175
+ export function readToClientBody(bc: bare.ByteCursor): ToClientBody {
1176
+ const offset = bc.offset
1177
+ const tag = bare.readU8(bc)
1178
+ switch (tag) {
1179
+ case 0:
1180
+ return { tag: "StateResponse", val: readStateResponse(bc) }
1181
+ case 1:
1182
+ return { tag: "ConnectionsResponse", val: readConnectionsResponse(bc) }
1183
+ case 2:
1184
+ return { tag: "ActionResponse", val: readActionResponse(bc) }
1185
+ case 3:
1186
+ return { tag: "ConnectionsUpdated", val: readConnectionsUpdated(bc) }
1187
+ case 4:
1188
+ return { tag: "QueueUpdated", val: readQueueUpdated(bc) }
1189
+ case 5:
1190
+ return { tag: "StateUpdated", val: readStateUpdated(bc) }
1191
+ case 6:
1192
+ return { tag: "WorkflowHistoryUpdated", val: readWorkflowHistoryUpdated(bc) }
1193
+ case 7:
1194
+ return { tag: "SchedulesUpdated", val: readSchedulesUpdated(bc) }
1195
+ case 8:
1196
+ return { tag: "RpcsListResponse", val: readRpcsListResponse(bc) }
1197
+ case 9:
1198
+ return { tag: "TraceQueryResponse", val: readTraceQueryResponse(bc) }
1199
+ case 10:
1200
+ return { tag: "QueueResponse", val: readQueueResponse(bc) }
1201
+ case 11:
1202
+ return { tag: "WorkflowHistoryResponse", val: readWorkflowHistoryResponse(bc) }
1203
+ case 12:
1204
+ return { tag: "WorkflowReplayResponse", val: readWorkflowReplayResponse(bc) }
1205
+ case 13:
1206
+ return { tag: "SchedulesResponse", val: readSchedulesResponse(bc) }
1207
+ case 14:
1208
+ return { tag: "ScheduleHistoryResponse", val: readScheduleHistoryResponse(bc) }
1209
+ case 15:
1210
+ return { tag: "ScheduleDeleteResponse", val: readScheduleDeleteResponse(bc) }
1211
+ case 16:
1212
+ return { tag: "Error", val: readError(bc) }
1213
+ case 17:
1214
+ return { tag: "Init", val: readInit(bc) }
1215
+ case 18:
1216
+ return { tag: "DatabaseSchemaResponse", val: readDatabaseSchemaResponse(bc) }
1217
+ case 19:
1218
+ return { tag: "DatabaseTableRowsResponse", val: readDatabaseTableRowsResponse(bc) }
1219
+ default: {
1220
+ bc.offset = offset
1221
+ throw new bare.BareError(offset, "invalid tag")
1222
+ }
1223
+ }
1224
+ }
1225
+
1226
+ export function writeToClientBody(bc: bare.ByteCursor, x: ToClientBody): void {
1227
+ switch (x.tag) {
1228
+ case "StateResponse": {
1229
+ bare.writeU8(bc, 0)
1230
+ writeStateResponse(bc, x.val)
1231
+ break
1232
+ }
1233
+ case "ConnectionsResponse": {
1234
+ bare.writeU8(bc, 1)
1235
+ writeConnectionsResponse(bc, x.val)
1236
+ break
1237
+ }
1238
+ case "ActionResponse": {
1239
+ bare.writeU8(bc, 2)
1240
+ writeActionResponse(bc, x.val)
1241
+ break
1242
+ }
1243
+ case "ConnectionsUpdated": {
1244
+ bare.writeU8(bc, 3)
1245
+ writeConnectionsUpdated(bc, x.val)
1246
+ break
1247
+ }
1248
+ case "QueueUpdated": {
1249
+ bare.writeU8(bc, 4)
1250
+ writeQueueUpdated(bc, x.val)
1251
+ break
1252
+ }
1253
+ case "StateUpdated": {
1254
+ bare.writeU8(bc, 5)
1255
+ writeStateUpdated(bc, x.val)
1256
+ break
1257
+ }
1258
+ case "WorkflowHistoryUpdated": {
1259
+ bare.writeU8(bc, 6)
1260
+ writeWorkflowHistoryUpdated(bc, x.val)
1261
+ break
1262
+ }
1263
+ case "SchedulesUpdated": {
1264
+ bare.writeU8(bc, 7)
1265
+ writeSchedulesUpdated(bc, x.val)
1266
+ break
1267
+ }
1268
+ case "RpcsListResponse": {
1269
+ bare.writeU8(bc, 8)
1270
+ writeRpcsListResponse(bc, x.val)
1271
+ break
1272
+ }
1273
+ case "TraceQueryResponse": {
1274
+ bare.writeU8(bc, 9)
1275
+ writeTraceQueryResponse(bc, x.val)
1276
+ break
1277
+ }
1278
+ case "QueueResponse": {
1279
+ bare.writeU8(bc, 10)
1280
+ writeQueueResponse(bc, x.val)
1281
+ break
1282
+ }
1283
+ case "WorkflowHistoryResponse": {
1284
+ bare.writeU8(bc, 11)
1285
+ writeWorkflowHistoryResponse(bc, x.val)
1286
+ break
1287
+ }
1288
+ case "WorkflowReplayResponse": {
1289
+ bare.writeU8(bc, 12)
1290
+ writeWorkflowReplayResponse(bc, x.val)
1291
+ break
1292
+ }
1293
+ case "SchedulesResponse": {
1294
+ bare.writeU8(bc, 13)
1295
+ writeSchedulesResponse(bc, x.val)
1296
+ break
1297
+ }
1298
+ case "ScheduleHistoryResponse": {
1299
+ bare.writeU8(bc, 14)
1300
+ writeScheduleHistoryResponse(bc, x.val)
1301
+ break
1302
+ }
1303
+ case "ScheduleDeleteResponse": {
1304
+ bare.writeU8(bc, 15)
1305
+ writeScheduleDeleteResponse(bc, x.val)
1306
+ break
1307
+ }
1308
+ case "Error": {
1309
+ bare.writeU8(bc, 16)
1310
+ writeError(bc, x.val)
1311
+ break
1312
+ }
1313
+ case "Init": {
1314
+ bare.writeU8(bc, 17)
1315
+ writeInit(bc, x.val)
1316
+ break
1317
+ }
1318
+ case "DatabaseSchemaResponse": {
1319
+ bare.writeU8(bc, 18)
1320
+ writeDatabaseSchemaResponse(bc, x.val)
1321
+ break
1322
+ }
1323
+ case "DatabaseTableRowsResponse": {
1324
+ bare.writeU8(bc, 19)
1325
+ writeDatabaseTableRowsResponse(bc, x.val)
1326
+ break
1327
+ }
1328
+ }
1329
+ }
1330
+
1331
+ export type ToClient = {
1332
+ readonly body: ToClientBody
1333
+ }
1334
+
1335
+ export function readToClient(bc: bare.ByteCursor): ToClient {
1336
+ return {
1337
+ body: readToClientBody(bc),
1338
+ }
1339
+ }
1340
+
1341
+ export function writeToClient(bc: bare.ByteCursor, x: ToClient): void {
1342
+ writeToClientBody(bc, x.body)
1343
+ }
1344
+
1345
+ export function encodeToClient(x: ToClient, config?: Partial<bare.Config>): Uint8Array {
1346
+ const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
1347
+ const bc = new bare.ByteCursor(
1348
+ new Uint8Array(fullConfig.initialBufferLength),
1349
+ fullConfig,
1350
+ )
1351
+ writeToClient(bc, x)
1352
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
1353
+ }
1354
+
1355
+ export function decodeToClient(bytes: Uint8Array): ToClient {
1356
+ const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
1357
+ const result = readToClient(bc)
1358
+ if (bc.offset < bc.view.byteLength) {
1359
+ throw new bare.BareError(bc.offset, "remaining bytes")
1360
+ }
1361
+ return result
1362
+ }
1363
+
1364
+
1365
+ function assert(condition: boolean, message?: string): asserts condition {
1366
+ if (!condition) throw new Error(message ?? "Assertion failed")
1367
+ }