rivetkit 2.3.0-rc.8 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.d.ts +481 -74
- package/dist/browser/client.js +174 -148
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +47 -18
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2160 -2086
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +479 -73
- package/dist/tsup/agent-os/index.d.ts +479 -73
- package/dist/tsup/agent-os/index.js +2160 -2086
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-KY3CERZR.js → chunk-2OTRTA3J.js} +7 -21
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-HGW6PBWR.cjs → chunk-3677IIOV.cjs} +11 -25
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-OT7FF6GB.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-EMFKMVJR.js → chunk-4JDSFJS5.js} +69 -58
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-7HLFSAJP.cjs → chunk-7QKCIVAY.cjs} +225 -214
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-AWTPTUQ7.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/{chunk-AWTPTUQ7.cjs.map → chunk-B6VUNZUD.cjs.map} +1 -1
- package/dist/tsup/{chunk-D3T3ZBSY.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-TMLOKTRB.js → chunk-BRP62GZC.js} +1 -1
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-D5G75T7J.js → chunk-DPIMKYNB.js} +61 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-BATTOVHF.cjs → chunk-DXXJPH55.cjs} +40 -13
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4BPKKZJO.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-63WNTDRC.cjs → chunk-KORQB2IR.cjs} +1 -1
- package/dist/tsup/{chunk-63WNTDRC.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-6TQSSJ4F.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-6TQSSJ4F.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-4JU3IPG2.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-SRNOPUC6.cjs → chunk-NIY3RSPX.cjs} +62 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-UZXQEGVJ.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/{chunk-UZXQEGVJ.js.map → chunk-P2GNQ4RN.js.map} +1 -1
- package/dist/tsup/{chunk-VUGENVIK.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-GBG63SUG.js → chunk-VTTFNQQI.js} +32 -5
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-Ak1lv4gF.d.ts → config-BxWAw3iH.d.ts} +512 -27
- package/dist/tsup/{config-DU_xj4qZ.d.cts → config-CZQQ-mso.d.cts} +512 -27
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-DAAp4Lpg.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-Dt_L55q8.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +615 -348
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +511 -244
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +279 -279
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +380 -380
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +29 -9
- package/src/actor/config.ts +156 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +8 -2
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +11 -11
- package/src/client/actor-handle.ts +69 -52
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -4
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -6
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +13 -17
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +3 -2
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -2
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +48 -46
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +5 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +5 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +226 -83
- package/src/registry/napi-runtime.ts +46 -12
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +307 -164
- package/src/registry/process-metrics.ts +90 -23
- package/src/registry/runtime.ts +53 -6
- package/src/registry/wasm-runtime.ts +30 -3
- package/src/serde.ts +1 -1
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +30 -29
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +2 -2
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4BPKKZJO.cjs.map +0 -1
- package/dist/tsup/chunk-4JU3IPG2.js.map +0 -1
- package/dist/tsup/chunk-7HLFSAJP.cjs.map +0 -1
- package/dist/tsup/chunk-BATTOVHF.cjs.map +0 -1
- package/dist/tsup/chunk-D5G75T7J.js.map +0 -1
- package/dist/tsup/chunk-EMFKMVJR.js.map +0 -1
- package/dist/tsup/chunk-GBG63SUG.js.map +0 -1
- package/dist/tsup/chunk-HGW6PBWR.cjs.map +0 -1
- package/dist/tsup/chunk-KY3CERZR.js.map +0 -1
- package/dist/tsup/chunk-OT7FF6GB.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-SRNOPUC6.cjs.map +0 -1
- package/dist/tsup/chunk-TMLOKTRB.js.map +0 -1
- package/dist/tsup/chunk-VUGENVIK.js.map +0 -1
- package/dist/tsup/process-metrics-NW754INA.js +0 -118
- package/dist/tsup/process-metrics-NW754INA.js.map +0 -1
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs +0 -118
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs.map +0 -1
- /package/dist/tsup/{chunk-D3T3ZBSY.js.map → chunk-BEI24WTI.js.map} +0 -0
|
@@ -1,280 +1,284 @@
|
|
|
1
1
|
// Vendored BARE codec. Keep the wire format compatible with the existing runtime.
|
|
2
2
|
|
|
3
|
-
import * as bare from "@rivetkit/bare-ts"
|
|
3
|
+
import * as bare from "@rivetkit/bare-ts";
|
|
4
4
|
|
|
5
|
-
const config = /* @__PURE__ */ bare.Config({})
|
|
5
|
+
const config = /* @__PURE__ */ bare.Config({});
|
|
6
6
|
|
|
7
|
-
export type i64 = bigint
|
|
8
|
-
export type u16 = number
|
|
7
|
+
export type i64 = bigint;
|
|
8
|
+
export type u16 = number;
|
|
9
9
|
|
|
10
|
-
export type GatewayId = ArrayBuffer
|
|
10
|
+
export type GatewayId = ArrayBuffer;
|
|
11
11
|
|
|
12
12
|
export function readGatewayId(bc: bare.ByteCursor): GatewayId {
|
|
13
|
-
|
|
13
|
+
return bare.readFixedData(bc, 4);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function writeGatewayId(bc: bare.ByteCursor, x: GatewayId): void {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
assert(x.byteLength === 4);
|
|
18
|
+
bare.writeFixedData(bc, x);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export type RequestId = ArrayBuffer
|
|
21
|
+
export type RequestId = ArrayBuffer;
|
|
22
22
|
|
|
23
23
|
export function readRequestId(bc: bare.ByteCursor): RequestId {
|
|
24
|
-
|
|
24
|
+
return bare.readFixedData(bc, 4);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function writeRequestId(bc: bare.ByteCursor, x: RequestId): void {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
assert(x.byteLength === 4);
|
|
29
|
+
bare.writeFixedData(bc, x);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export type MessageIndex = u16
|
|
32
|
+
export type MessageIndex = u16;
|
|
33
33
|
|
|
34
34
|
export function readMessageIndex(bc: bare.ByteCursor): MessageIndex {
|
|
35
|
-
|
|
35
|
+
return bare.readU16(bc);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function writeMessageIndex(bc: bare.ByteCursor, x: MessageIndex): void {
|
|
39
|
-
|
|
39
|
+
bare.writeU16(bc, x);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function encodeMessageIndex(x: MessageIndex): Uint8Array {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const bc = new bare.ByteCursor(
|
|
44
|
+
new Uint8Array(config.initialBufferLength),
|
|
45
|
+
config,
|
|
46
|
+
);
|
|
47
|
+
writeMessageIndex(bc, x);
|
|
48
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export function decodeMessageIndex(bytes: Uint8Array): MessageIndex {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
const bc = new bare.ByteCursor(bytes, config);
|
|
53
|
+
const result = readMessageIndex(bc);
|
|
54
|
+
if (bc.offset < bc.view.byteLength) {
|
|
55
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export type Cbor = ArrayBuffer
|
|
60
|
+
export type Cbor = ArrayBuffer;
|
|
61
61
|
|
|
62
62
|
export function readCbor(bc: bare.ByteCursor): Cbor {
|
|
63
|
-
|
|
63
|
+
return bare.readData(bc);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export function writeCbor(bc: bare.ByteCursor, x: Cbor): void {
|
|
67
|
-
|
|
67
|
+
bare.writeData(bc, x);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export type Subscription = {
|
|
71
|
-
|
|
72
|
-
}
|
|
71
|
+
readonly eventName: string;
|
|
72
|
+
};
|
|
73
73
|
|
|
74
74
|
export function readSubscription(bc: bare.ByteCursor): Subscription {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
return {
|
|
76
|
+
eventName: bare.readString(bc),
|
|
77
|
+
};
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function writeSubscription(bc: bare.ByteCursor, x: Subscription): void {
|
|
81
|
-
|
|
81
|
+
bare.writeString(bc, x.eventName);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function read0(bc: bare.ByteCursor): readonly Subscription[] {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
const len = bare.readUintSafe(bc);
|
|
86
|
+
if (len === 0) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const result = [readSubscription(bc)];
|
|
90
|
+
for (let i = 1; i < len; i++) {
|
|
91
|
+
result[i] = readSubscription(bc);
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
function write0(bc: bare.ByteCursor, x: readonly Subscription[]): void {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
bare.writeUintSafe(bc, x.length);
|
|
98
|
+
for (let i = 0; i < x.length; i++) {
|
|
99
|
+
writeSubscription(bc, x[i]);
|
|
100
|
+
}
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
function read1(bc: bare.ByteCursor): ReadonlyMap<string, string> {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
const len = bare.readUintSafe(bc);
|
|
105
|
+
const result = new Map<string, string>();
|
|
106
|
+
for (let i = 0; i < len; i++) {
|
|
107
|
+
const offset = bc.offset;
|
|
108
|
+
const key = bare.readString(bc);
|
|
109
|
+
if (result.has(key)) {
|
|
110
|
+
bc.offset = offset;
|
|
111
|
+
throw new bare.BareError(offset, "duplicated key");
|
|
112
|
+
}
|
|
113
|
+
result.set(key, bare.readString(bc));
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
function write1(bc: bare.ByteCursor, x: ReadonlyMap<string, string>): void {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
bare.writeUintSafe(bc, x.size);
|
|
120
|
+
for (const kv of x) {
|
|
121
|
+
bare.writeString(bc, kv[0]);
|
|
122
|
+
bare.writeString(bc, kv[1]);
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
export type Conn = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly parameters: Cbor;
|
|
129
|
+
readonly state: Cbor;
|
|
130
|
+
readonly subscriptions: readonly Subscription[];
|
|
131
|
+
readonly gatewayId: GatewayId;
|
|
132
|
+
readonly requestId: RequestId;
|
|
133
|
+
readonly serverMessageIndex: u16;
|
|
134
|
+
readonly clientMessageIndex: u16;
|
|
135
|
+
readonly requestPath: string;
|
|
136
|
+
readonly requestHeaders: ReadonlyMap<string, string>;
|
|
137
|
+
};
|
|
136
138
|
|
|
137
139
|
export function readConn(bc: bare.ByteCursor): Conn {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
return {
|
|
141
|
+
id: bare.readString(bc),
|
|
142
|
+
parameters: readCbor(bc),
|
|
143
|
+
state: readCbor(bc),
|
|
144
|
+
subscriptions: read0(bc),
|
|
145
|
+
gatewayId: readGatewayId(bc),
|
|
146
|
+
requestId: readRequestId(bc),
|
|
147
|
+
serverMessageIndex: bare.readU16(bc),
|
|
148
|
+
clientMessageIndex: bare.readU16(bc),
|
|
149
|
+
requestPath: bare.readString(bc),
|
|
150
|
+
requestHeaders: read1(bc),
|
|
151
|
+
};
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
export function writeConn(bc: bare.ByteCursor, x: Conn): void {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
bare.writeString(bc, x.id);
|
|
156
|
+
writeCbor(bc, x.parameters);
|
|
157
|
+
writeCbor(bc, x.state);
|
|
158
|
+
write0(bc, x.subscriptions);
|
|
159
|
+
writeGatewayId(bc, x.gatewayId);
|
|
160
|
+
writeRequestId(bc, x.requestId);
|
|
161
|
+
bare.writeU16(bc, x.serverMessageIndex);
|
|
162
|
+
bare.writeU16(bc, x.clientMessageIndex);
|
|
163
|
+
bare.writeString(bc, x.requestPath);
|
|
164
|
+
write1(bc, x.requestHeaders);
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
export function encodeConn(x: Conn): Uint8Array {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
const bc = new bare.ByteCursor(
|
|
169
|
+
new Uint8Array(config.initialBufferLength),
|
|
170
|
+
config,
|
|
171
|
+
);
|
|
172
|
+
writeConn(bc, x);
|
|
173
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
export function decodeConn(bytes: Uint8Array): Conn {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
const bc = new bare.ByteCursor(bytes, config);
|
|
178
|
+
const result = readConn(bc);
|
|
179
|
+
if (bc.offset < bc.view.byteLength) {
|
|
180
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
function read2(bc: bare.ByteCursor): Cbor | null {
|
|
184
|
-
|
|
185
|
-
? readCbor(bc)
|
|
186
|
-
: null
|
|
186
|
+
return bare.readBool(bc) ? readCbor(bc) : null;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function write2(bc: bare.ByteCursor, x: Cbor | null): void {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
bare.writeBool(bc, x !== null);
|
|
191
|
+
if (x !== null) {
|
|
192
|
+
writeCbor(bc, x);
|
|
193
|
+
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
export type ScheduleEvent = {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
197
|
+
readonly eventId: string;
|
|
198
|
+
readonly timestamp: i64;
|
|
199
|
+
readonly action: string;
|
|
200
|
+
readonly args: Cbor | null;
|
|
201
|
+
};
|
|
202
202
|
|
|
203
203
|
export function readScheduleEvent(bc: bare.ByteCursor): ScheduleEvent {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
return {
|
|
205
|
+
eventId: bare.readString(bc),
|
|
206
|
+
timestamp: bare.readI64(bc),
|
|
207
|
+
action: bare.readString(bc),
|
|
208
|
+
args: read2(bc),
|
|
209
|
+
};
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
export function writeScheduleEvent(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
export function writeScheduleEvent(
|
|
213
|
+
bc: bare.ByteCursor,
|
|
214
|
+
x: ScheduleEvent,
|
|
215
|
+
): void {
|
|
216
|
+
bare.writeString(bc, x.eventId);
|
|
217
|
+
bare.writeI64(bc, x.timestamp);
|
|
218
|
+
bare.writeString(bc, x.action);
|
|
219
|
+
write2(bc, x.args);
|
|
217
220
|
}
|
|
218
221
|
|
|
219
222
|
function read3(bc: bare.ByteCursor): readonly ScheduleEvent[] {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
const len = bare.readUintSafe(bc);
|
|
224
|
+
if (len === 0) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
const result = [readScheduleEvent(bc)];
|
|
228
|
+
for (let i = 1; i < len; i++) {
|
|
229
|
+
result[i] = readScheduleEvent(bc);
|
|
230
|
+
}
|
|
231
|
+
return result;
|
|
227
232
|
}
|
|
228
233
|
|
|
229
234
|
function write3(bc: bare.ByteCursor, x: readonly ScheduleEvent[]): void {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
235
|
+
bare.writeUintSafe(bc, x.length);
|
|
236
|
+
for (let i = 0; i < x.length; i++) {
|
|
237
|
+
writeScheduleEvent(bc, x[i]);
|
|
238
|
+
}
|
|
234
239
|
}
|
|
235
240
|
|
|
236
241
|
export type Actor = {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
+
readonly input: Cbor | null;
|
|
243
|
+
readonly hasInitialized: boolean;
|
|
244
|
+
readonly state: Cbor;
|
|
245
|
+
readonly scheduledEvents: readonly ScheduleEvent[];
|
|
246
|
+
};
|
|
242
247
|
|
|
243
248
|
export function readActor(bc: bare.ByteCursor): Actor {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
249
|
+
return {
|
|
250
|
+
input: read2(bc),
|
|
251
|
+
hasInitialized: bare.readBool(bc),
|
|
252
|
+
state: readCbor(bc),
|
|
253
|
+
scheduledEvents: read3(bc),
|
|
254
|
+
};
|
|
250
255
|
}
|
|
251
256
|
|
|
252
257
|
export function writeActor(bc: bare.ByteCursor, x: Actor): void {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
write2(bc, x.input);
|
|
259
|
+
bare.writeBool(bc, x.hasInitialized);
|
|
260
|
+
writeCbor(bc, x.state);
|
|
261
|
+
write3(bc, x.scheduledEvents);
|
|
257
262
|
}
|
|
258
263
|
|
|
259
264
|
export function encodeActor(x: Actor): Uint8Array {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
const bc = new bare.ByteCursor(
|
|
266
|
+
new Uint8Array(config.initialBufferLength),
|
|
267
|
+
config,
|
|
268
|
+
);
|
|
269
|
+
writeActor(bc, x);
|
|
270
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
266
271
|
}
|
|
267
272
|
|
|
268
273
|
export function decodeActor(bytes: Uint8Array): Actor {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
const bc = new bare.ByteCursor(bytes, config);
|
|
275
|
+
const result = readActor(bc);
|
|
276
|
+
if (bc.offset < bc.view.byteLength) {
|
|
277
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
278
|
+
}
|
|
279
|
+
return result;
|
|
275
280
|
}
|
|
276
281
|
|
|
277
|
-
|
|
278
282
|
function assert(condition: boolean, message?: string): asserts condition {
|
|
279
|
-
|
|
283
|
+
if (!condition) throw new Error(message ?? "Assertion failed");
|
|
280
284
|
}
|