rivetkit 2.3.0-rc.5 → 2.3.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.d.ts +21 -18
- package/dist/browser/client.js +735 -170
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +4 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +3 -1
- package/dist/tsup/agent-os/index.cjs +1 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +18 -7
- package/dist/tsup/agent-os/index.d.ts +18 -7
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2G64KSZQ.cjs} +10 -10
- package/dist/tsup/{chunk-2GANBXVP.cjs.map → chunk-2G64KSZQ.cjs.map} +1 -1
- package/dist/tsup/{chunk-N2DQSJIW.js → chunk-6S25NVAP.js} +13 -46
- package/dist/tsup/chunk-6S25NVAP.js.map +1 -0
- package/dist/tsup/{chunk-NATOT3ET.js → chunk-CAF6JDJE.js} +4 -4
- package/dist/tsup/{chunk-PGYEMIOE.js → chunk-DEO7MMWQ.js} +2 -2
- package/dist/tsup/{chunk-SULB574D.js → chunk-EMO6E3PJ.js} +3 -3
- package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ENK7C66G.cjs} +838 -236
- package/dist/tsup/chunk-ENK7C66G.cjs.map +1 -0
- package/dist/tsup/{chunk-JY73X7VU.js → chunk-FLODVLYW.js} +690 -88
- package/dist/tsup/chunk-FLODVLYW.js.map +1 -0
- package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-HTR4YLNT.cjs} +4 -4
- package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-HTR4YLNT.cjs.map} +1 -1
- package/dist/tsup/{chunk-LELRJK66.cjs → chunk-JALSAX7Z.cjs} +3 -3
- package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-JALSAX7Z.cjs.map} +1 -1
- package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-K5BA2LEO.cjs} +19 -52
- package/dist/tsup/chunk-K5BA2LEO.cjs.map +1 -0
- package/dist/tsup/{chunk-K34B3OVG.js → chunk-KIWH5H3K.js} +30 -9
- package/dist/tsup/chunk-KIWH5H3K.js.map +1 -0
- package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-LIXXFXVR.cjs} +5 -5
- package/dist/tsup/{chunk-NW2J4SOL.cjs.map → chunk-LIXXFXVR.cjs.map} +1 -1
- package/dist/tsup/{chunk-HR547GVH.cjs → chunk-M5C7YNI5.cjs} +8 -8
- package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-M5C7YNI5.cjs.map} +1 -1
- package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-QAZLM4WT.cjs} +31 -10
- package/dist/tsup/chunk-QAZLM4WT.cjs.map +1 -0
- package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-RTC2AZGB.js} +2 -2
- package/dist/tsup/{chunk-UXTP4EBU.js → chunk-ZI5QJMKO.js} +2 -2
- package/dist/tsup/client/mod.cjs +7 -7
- package/dist/tsup/client/mod.d.cts +3 -4
- package/dist/tsup/client/mod.d.ts +3 -4
- package/dist/tsup/client/mod.js +6 -6
- 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-CvQUtDp9.d.ts → config-0Ta55UV0.d.ts} +10 -9
- package/dist/tsup/{config-C-a9vrke.d.cts → config-Ca8dN4cS.d.cts} +10 -9
- package/dist/tsup/{context-A7R0bsZL.d.ts → context-B_IWbWne.d.ts} +1 -1
- package/dist/tsup/{context-CA3r-pf2.d.cts → context-CUrQ9MHc.d.cts} +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +252 -207
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -5
- package/dist/tsup/mod.d.ts +4 -5
- package/dist/tsup/mod.js +183 -138
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +2 -3
- package/dist/tsup/test/mod.d.ts +2 -3
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
- package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
- 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 +9 -9
- package/dist/tsup/workflow/mod.d.cts +4 -5
- package/dist/tsup/workflow/mod.d.ts +4 -5
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +8 -8
- package/src/actor/errors.ts +53 -7
- package/src/client/actor-conn.ts +52 -29
- package/src/client/actor-handle.ts +57 -23
- package/src/client/errors.ts +2 -1
- package/src/client/raw-utils.ts +2 -4
- package/src/client/utils.ts +32 -3
- package/src/common/actor-router-consts.ts +4 -0
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/client-protocol-versioned.ts +125 -18
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/native-database.test.ts +35 -0
- package/src/common/database/native-database.ts +8 -4
- package/src/common/router.ts +38 -8
- package/src/common/utils.ts +9 -52
- package/src/drivers/engine/actor-driver.ts +18 -17
- package/src/registry/config/index.ts +3 -5
- package/src/registry/index.ts +156 -19
- package/src/registry/napi-runtime.ts +44 -6
- package/src/registry/native.ts +5 -152
- package/src/registry/runtime.ts +16 -5
- package/src/registry/wasm-runtime.ts +22 -2
- package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
- package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
- package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
- package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
- package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
- package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- /package/dist/tsup/{chunk-NATOT3ET.js.map → chunk-CAF6JDJE.js.map} +0 -0
- /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-DEO7MMWQ.js.map} +0 -0
- /package/dist/tsup/{chunk-SULB574D.js.map → chunk-EMO6E3PJ.js.map} +0 -0
- /package/dist/tsup/{chunk-LDTT6WKJ.js.map → chunk-RTC2AZGB.js.map} +0 -0
- /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-ZI5QJMKO.js.map} +0 -0
|
@@ -12,14 +12,14 @@ var _chunkLD5YASJUcjs = require('./chunk-LD5YASJU.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkLIXXFXVRcjs = require('./chunk-LIXXFXVR.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk2NDZ7JCRcjs = require('./chunk-2NDZ7JCR.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkJALSAX7Zcjs = require('./chunk-JALSAX7Z.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -37,13 +37,13 @@ var _chunkLELRJK66cjs = require('./chunk-LELRJK66.cjs');
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkK5BA2LEOcjs = require('./chunk-K5BA2LEO.cjs');
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkQAZLM4WTcjs = require('./chunk-QAZLM4WT.cjs');
|
|
47
47
|
|
|
48
48
|
// src/common/actor-router-consts.ts
|
|
49
49
|
var PATH_CONNECT = "/connect";
|
|
@@ -53,6 +53,8 @@ var HEADER_ACTOR_QUERY = "x-rivet-query";
|
|
|
53
53
|
var HEADER_ENCODING = "x-rivet-encoding";
|
|
54
54
|
var HEADER_CONN_PARAMS = "x-rivet-conn-params";
|
|
55
55
|
var HEADER_ACTOR_ID = "x-rivet-actor";
|
|
56
|
+
var HEADER_ACTOR_GENERATION = "x-rivet-actor-generation";
|
|
57
|
+
var HEADER_ACTOR_KEY = "x-rivet-actor-key";
|
|
56
58
|
var HEADER_RIVET_TOKEN = "x-rivet-token";
|
|
57
59
|
var HEADER_RIVET_TARGET = "x-rivet-target";
|
|
58
60
|
var HEADER_RIVET_ACTOR = "x-rivet-actor";
|
|
@@ -73,6 +75,8 @@ var ALLOWED_PUBLIC_HEADERS = [
|
|
|
73
75
|
HEADER_ENCODING,
|
|
74
76
|
HEADER_CONN_PARAMS,
|
|
75
77
|
HEADER_ACTOR_ID,
|
|
78
|
+
HEADER_ACTOR_GENERATION,
|
|
79
|
+
HEADER_ACTOR_KEY,
|
|
76
80
|
HEADER_RIVET_TARGET,
|
|
77
81
|
HEADER_RIVET_ACTOR,
|
|
78
82
|
HEADER_RIVET_NAMESPACE,
|
|
@@ -107,7 +111,7 @@ function isSchedulingError(group, code) {
|
|
|
107
111
|
return group === "guard" && (code === "actor_ready_timeout" || code === "actor_runner_failed");
|
|
108
112
|
}
|
|
109
113
|
function actorSchedulingError(group, code, actorId, details) {
|
|
110
|
-
return new (0,
|
|
114
|
+
return new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
111
115
|
group,
|
|
112
116
|
code,
|
|
113
117
|
`Actor failed to start (${actorId}): ${JSON.stringify(details)}`,
|
|
@@ -115,7 +119,7 @@ function actorSchedulingError(group, code, actorId, details) {
|
|
|
115
119
|
);
|
|
116
120
|
}
|
|
117
121
|
function internalClientError(message, opts) {
|
|
118
|
-
return new (0,
|
|
122
|
+
return new (0, _chunkQAZLM4WTcjs.RivetError)("rivetkit", _chunkQAZLM4WTcjs.INTERNAL_ERROR_CODE, message, {
|
|
119
123
|
cause: opts == null ? void 0 : opts.cause
|
|
120
124
|
});
|
|
121
125
|
}
|
|
@@ -128,7 +132,7 @@ var _pretry = require('p-retry'); var _pretry2 = _interopRequireDefault(_pretry)
|
|
|
128
132
|
var _vbare = require('vbare');
|
|
129
133
|
|
|
130
134
|
// src/common/bare/generated/client-protocol/v1.ts
|
|
131
|
-
var _barets = require('@rivetkit/bare-ts'); var bare = _interopRequireWildcard(_barets); var bare2 = _interopRequireWildcard(_barets); var bare3 = _interopRequireWildcard(_barets);
|
|
135
|
+
var _barets = require('@rivetkit/bare-ts'); var bare = _interopRequireWildcard(_barets); var bare2 = _interopRequireWildcard(_barets); var bare3 = _interopRequireWildcard(_barets); var bare4 = _interopRequireWildcard(_barets);
|
|
132
136
|
var DEFAULT_CONFIG = /* @__PURE__ */ bare.Config({});
|
|
133
137
|
function readCbor(bc) {
|
|
134
138
|
return bare.readData(bc);
|
|
@@ -1180,8 +1184,440 @@ function decodeHttpResolveResponse3(bytes) {
|
|
|
1180
1184
|
return result;
|
|
1181
1185
|
}
|
|
1182
1186
|
|
|
1187
|
+
// src/common/bare/generated/client-protocol/v4.ts
|
|
1188
|
+
|
|
1189
|
+
var DEFAULT_CONFIG4 = /* @__PURE__ */ bare4.Config({});
|
|
1190
|
+
function readCbor4(bc) {
|
|
1191
|
+
return bare4.readData(bc);
|
|
1192
|
+
}
|
|
1193
|
+
function writeCbor4(bc, x) {
|
|
1194
|
+
bare4.writeData(bc, x);
|
|
1195
|
+
}
|
|
1196
|
+
function read04(bc) {
|
|
1197
|
+
return bare4.readBool(bc) ? bare4.readString(bc) : null;
|
|
1198
|
+
}
|
|
1199
|
+
function write04(bc, x) {
|
|
1200
|
+
bare4.writeBool(bc, x != null);
|
|
1201
|
+
if (x != null) {
|
|
1202
|
+
bare4.writeString(bc, x);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
function readActorSpecifier(bc) {
|
|
1206
|
+
return {
|
|
1207
|
+
actorId: bare4.readString(bc),
|
|
1208
|
+
generation: bare4.readUint(bc),
|
|
1209
|
+
key: read04(bc)
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
function writeActorSpecifier(bc, x) {
|
|
1213
|
+
bare4.writeString(bc, x.actorId);
|
|
1214
|
+
bare4.writeUint(bc, x.generation);
|
|
1215
|
+
write04(bc, x.key);
|
|
1216
|
+
}
|
|
1217
|
+
function readInit4(bc) {
|
|
1218
|
+
return {
|
|
1219
|
+
actorId: bare4.readString(bc),
|
|
1220
|
+
connectionId: bare4.readString(bc)
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
function writeInit4(bc, x) {
|
|
1224
|
+
bare4.writeString(bc, x.actorId);
|
|
1225
|
+
bare4.writeString(bc, x.connectionId);
|
|
1226
|
+
}
|
|
1227
|
+
function read14(bc) {
|
|
1228
|
+
return bare4.readBool(bc) ? readCbor4(bc) : null;
|
|
1229
|
+
}
|
|
1230
|
+
function write14(bc, x) {
|
|
1231
|
+
bare4.writeBool(bc, x != null);
|
|
1232
|
+
if (x != null) {
|
|
1233
|
+
writeCbor4(bc, x);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
function read22(bc) {
|
|
1237
|
+
return bare4.readBool(bc) ? bare4.readUint(bc) : null;
|
|
1238
|
+
}
|
|
1239
|
+
function write22(bc, x) {
|
|
1240
|
+
bare4.writeBool(bc, x != null);
|
|
1241
|
+
if (x != null) {
|
|
1242
|
+
bare4.writeUint(bc, x);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
function read32(bc) {
|
|
1246
|
+
return bare4.readBool(bc) ? readActorSpecifier(bc) : null;
|
|
1247
|
+
}
|
|
1248
|
+
function write32(bc, x) {
|
|
1249
|
+
bare4.writeBool(bc, x != null);
|
|
1250
|
+
if (x != null) {
|
|
1251
|
+
writeActorSpecifier(bc, x);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
function readError4(bc) {
|
|
1255
|
+
return {
|
|
1256
|
+
group: bare4.readString(bc),
|
|
1257
|
+
code: bare4.readString(bc),
|
|
1258
|
+
message: bare4.readString(bc),
|
|
1259
|
+
metadata: read14(bc),
|
|
1260
|
+
actionId: read22(bc),
|
|
1261
|
+
actor: read32(bc)
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function writeError4(bc, x) {
|
|
1265
|
+
bare4.writeString(bc, x.group);
|
|
1266
|
+
bare4.writeString(bc, x.code);
|
|
1267
|
+
bare4.writeString(bc, x.message);
|
|
1268
|
+
write14(bc, x.metadata);
|
|
1269
|
+
write22(bc, x.actionId);
|
|
1270
|
+
write32(bc, x.actor);
|
|
1271
|
+
}
|
|
1272
|
+
function readActionResponse4(bc) {
|
|
1273
|
+
return {
|
|
1274
|
+
id: bare4.readUint(bc),
|
|
1275
|
+
output: readCbor4(bc)
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
function writeActionResponse4(bc, x) {
|
|
1279
|
+
bare4.writeUint(bc, x.id);
|
|
1280
|
+
writeCbor4(bc, x.output);
|
|
1281
|
+
}
|
|
1282
|
+
function readEvent4(bc) {
|
|
1283
|
+
return {
|
|
1284
|
+
name: bare4.readString(bc),
|
|
1285
|
+
args: readCbor4(bc)
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
function writeEvent4(bc, x) {
|
|
1289
|
+
bare4.writeString(bc, x.name);
|
|
1290
|
+
writeCbor4(bc, x.args);
|
|
1291
|
+
}
|
|
1292
|
+
function readToClientBody4(bc) {
|
|
1293
|
+
const offset = bc.offset;
|
|
1294
|
+
const tag = bare4.readU8(bc);
|
|
1295
|
+
switch (tag) {
|
|
1296
|
+
case 0:
|
|
1297
|
+
return { tag: "Init", val: readInit4(bc) };
|
|
1298
|
+
case 1:
|
|
1299
|
+
return { tag: "Error", val: readError4(bc) };
|
|
1300
|
+
case 2:
|
|
1301
|
+
return { tag: "ActionResponse", val: readActionResponse4(bc) };
|
|
1302
|
+
case 3:
|
|
1303
|
+
return { tag: "Event", val: readEvent4(bc) };
|
|
1304
|
+
default: {
|
|
1305
|
+
bc.offset = offset;
|
|
1306
|
+
throw new bare4.BareError(offset, "invalid tag");
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
function writeToClientBody4(bc, x) {
|
|
1311
|
+
switch (x.tag) {
|
|
1312
|
+
case "Init": {
|
|
1313
|
+
bare4.writeU8(bc, 0);
|
|
1314
|
+
writeInit4(bc, x.val);
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
case "Error": {
|
|
1318
|
+
bare4.writeU8(bc, 1);
|
|
1319
|
+
writeError4(bc, x.val);
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
case "ActionResponse": {
|
|
1323
|
+
bare4.writeU8(bc, 2);
|
|
1324
|
+
writeActionResponse4(bc, x.val);
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
case "Event": {
|
|
1328
|
+
bare4.writeU8(bc, 3);
|
|
1329
|
+
writeEvent4(bc, x.val);
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
function readToClient4(bc) {
|
|
1335
|
+
return {
|
|
1336
|
+
body: readToClientBody4(bc)
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
function writeToClient4(bc, x) {
|
|
1340
|
+
writeToClientBody4(bc, x.body);
|
|
1341
|
+
}
|
|
1342
|
+
function encodeToClient4(x, config) {
|
|
1343
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1344
|
+
const bc = new bare4.ByteCursor(
|
|
1345
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1346
|
+
fullConfig
|
|
1347
|
+
);
|
|
1348
|
+
writeToClient4(bc, x);
|
|
1349
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1350
|
+
}
|
|
1351
|
+
function decodeToClient4(bytes) {
|
|
1352
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1353
|
+
const result = readToClient4(bc);
|
|
1354
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1355
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1356
|
+
}
|
|
1357
|
+
return result;
|
|
1358
|
+
}
|
|
1359
|
+
function readActionRequest4(bc) {
|
|
1360
|
+
return {
|
|
1361
|
+
id: bare4.readUint(bc),
|
|
1362
|
+
name: bare4.readString(bc),
|
|
1363
|
+
args: readCbor4(bc)
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
function writeActionRequest4(bc, x) {
|
|
1367
|
+
bare4.writeUint(bc, x.id);
|
|
1368
|
+
bare4.writeString(bc, x.name);
|
|
1369
|
+
writeCbor4(bc, x.args);
|
|
1370
|
+
}
|
|
1371
|
+
function readSubscriptionRequest4(bc) {
|
|
1372
|
+
return {
|
|
1373
|
+
eventName: bare4.readString(bc),
|
|
1374
|
+
subscribe: bare4.readBool(bc)
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
function writeSubscriptionRequest4(bc, x) {
|
|
1378
|
+
bare4.writeString(bc, x.eventName);
|
|
1379
|
+
bare4.writeBool(bc, x.subscribe);
|
|
1380
|
+
}
|
|
1381
|
+
function readToServerBody4(bc) {
|
|
1382
|
+
const offset = bc.offset;
|
|
1383
|
+
const tag = bare4.readU8(bc);
|
|
1384
|
+
switch (tag) {
|
|
1385
|
+
case 0:
|
|
1386
|
+
return { tag: "ActionRequest", val: readActionRequest4(bc) };
|
|
1387
|
+
case 1:
|
|
1388
|
+
return { tag: "SubscriptionRequest", val: readSubscriptionRequest4(bc) };
|
|
1389
|
+
default: {
|
|
1390
|
+
bc.offset = offset;
|
|
1391
|
+
throw new bare4.BareError(offset, "invalid tag");
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
function writeToServerBody4(bc, x) {
|
|
1396
|
+
switch (x.tag) {
|
|
1397
|
+
case "ActionRequest": {
|
|
1398
|
+
bare4.writeU8(bc, 0);
|
|
1399
|
+
writeActionRequest4(bc, x.val);
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
case "SubscriptionRequest": {
|
|
1403
|
+
bare4.writeU8(bc, 1);
|
|
1404
|
+
writeSubscriptionRequest4(bc, x.val);
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
function readToServer4(bc) {
|
|
1410
|
+
return {
|
|
1411
|
+
body: readToServerBody4(bc)
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
function writeToServer4(bc, x) {
|
|
1415
|
+
writeToServerBody4(bc, x.body);
|
|
1416
|
+
}
|
|
1417
|
+
function encodeToServer4(x, config) {
|
|
1418
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1419
|
+
const bc = new bare4.ByteCursor(
|
|
1420
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1421
|
+
fullConfig
|
|
1422
|
+
);
|
|
1423
|
+
writeToServer4(bc, x);
|
|
1424
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1425
|
+
}
|
|
1426
|
+
function decodeToServer4(bytes) {
|
|
1427
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1428
|
+
const result = readToServer4(bc);
|
|
1429
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1430
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1431
|
+
}
|
|
1432
|
+
return result;
|
|
1433
|
+
}
|
|
1434
|
+
function readHttpActionRequest4(bc) {
|
|
1435
|
+
return {
|
|
1436
|
+
args: readCbor4(bc)
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
function writeHttpActionRequest4(bc, x) {
|
|
1440
|
+
writeCbor4(bc, x.args);
|
|
1441
|
+
}
|
|
1442
|
+
function encodeHttpActionRequest4(x, config) {
|
|
1443
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1444
|
+
const bc = new bare4.ByteCursor(
|
|
1445
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1446
|
+
fullConfig
|
|
1447
|
+
);
|
|
1448
|
+
writeHttpActionRequest4(bc, x);
|
|
1449
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1450
|
+
}
|
|
1451
|
+
function decodeHttpActionRequest4(bytes) {
|
|
1452
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1453
|
+
const result = readHttpActionRequest4(bc);
|
|
1454
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1455
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1456
|
+
}
|
|
1457
|
+
return result;
|
|
1458
|
+
}
|
|
1459
|
+
function readHttpActionResponse4(bc) {
|
|
1460
|
+
return {
|
|
1461
|
+
output: readCbor4(bc)
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
function writeHttpActionResponse4(bc, x) {
|
|
1465
|
+
writeCbor4(bc, x.output);
|
|
1466
|
+
}
|
|
1467
|
+
function encodeHttpActionResponse4(x, config) {
|
|
1468
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1469
|
+
const bc = new bare4.ByteCursor(
|
|
1470
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1471
|
+
fullConfig
|
|
1472
|
+
);
|
|
1473
|
+
writeHttpActionResponse4(bc, x);
|
|
1474
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1475
|
+
}
|
|
1476
|
+
function decodeHttpActionResponse4(bytes) {
|
|
1477
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1478
|
+
const result = readHttpActionResponse4(bc);
|
|
1479
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1480
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1481
|
+
}
|
|
1482
|
+
return result;
|
|
1483
|
+
}
|
|
1484
|
+
function read42(bc) {
|
|
1485
|
+
return bare4.readBool(bc) ? bare4.readBool(bc) : null;
|
|
1486
|
+
}
|
|
1487
|
+
function write42(bc, x) {
|
|
1488
|
+
bare4.writeBool(bc, x != null);
|
|
1489
|
+
if (x != null) {
|
|
1490
|
+
bare4.writeBool(bc, x);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
function read5(bc) {
|
|
1494
|
+
return bare4.readBool(bc) ? bare4.readU64(bc) : null;
|
|
1495
|
+
}
|
|
1496
|
+
function write5(bc, x) {
|
|
1497
|
+
bare4.writeBool(bc, x != null);
|
|
1498
|
+
if (x != null) {
|
|
1499
|
+
bare4.writeU64(bc, x);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
function readHttpQueueSendRequest2(bc) {
|
|
1503
|
+
return {
|
|
1504
|
+
body: readCbor4(bc),
|
|
1505
|
+
name: read04(bc),
|
|
1506
|
+
wait: read42(bc),
|
|
1507
|
+
timeout: read5(bc)
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function writeHttpQueueSendRequest2(bc, x) {
|
|
1511
|
+
writeCbor4(bc, x.body);
|
|
1512
|
+
write04(bc, x.name);
|
|
1513
|
+
write42(bc, x.wait);
|
|
1514
|
+
write5(bc, x.timeout);
|
|
1515
|
+
}
|
|
1516
|
+
function encodeHttpQueueSendRequest2(x, config) {
|
|
1517
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1518
|
+
const bc = new bare4.ByteCursor(
|
|
1519
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1520
|
+
fullConfig
|
|
1521
|
+
);
|
|
1522
|
+
writeHttpQueueSendRequest2(bc, x);
|
|
1523
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1524
|
+
}
|
|
1525
|
+
function decodeHttpQueueSendRequest2(bytes) {
|
|
1526
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1527
|
+
const result = readHttpQueueSendRequest2(bc);
|
|
1528
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1529
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1530
|
+
}
|
|
1531
|
+
return result;
|
|
1532
|
+
}
|
|
1533
|
+
function readHttpQueueSendResponse2(bc) {
|
|
1534
|
+
return {
|
|
1535
|
+
status: bare4.readString(bc),
|
|
1536
|
+
response: read14(bc)
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
function writeHttpQueueSendResponse2(bc, x) {
|
|
1540
|
+
bare4.writeString(bc, x.status);
|
|
1541
|
+
write14(bc, x.response);
|
|
1542
|
+
}
|
|
1543
|
+
function encodeHttpQueueSendResponse2(x, config) {
|
|
1544
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1545
|
+
const bc = new bare4.ByteCursor(
|
|
1546
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1547
|
+
fullConfig
|
|
1548
|
+
);
|
|
1549
|
+
writeHttpQueueSendResponse2(bc, x);
|
|
1550
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1551
|
+
}
|
|
1552
|
+
function decodeHttpQueueSendResponse2(bytes) {
|
|
1553
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1554
|
+
const result = readHttpQueueSendResponse2(bc);
|
|
1555
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1556
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1557
|
+
}
|
|
1558
|
+
return result;
|
|
1559
|
+
}
|
|
1560
|
+
function readHttpResponseError4(bc) {
|
|
1561
|
+
return {
|
|
1562
|
+
group: bare4.readString(bc),
|
|
1563
|
+
code: bare4.readString(bc),
|
|
1564
|
+
message: bare4.readString(bc),
|
|
1565
|
+
metadata: read14(bc),
|
|
1566
|
+
actor: read32(bc)
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
function writeHttpResponseError4(bc, x) {
|
|
1570
|
+
bare4.writeString(bc, x.group);
|
|
1571
|
+
bare4.writeString(bc, x.code);
|
|
1572
|
+
bare4.writeString(bc, x.message);
|
|
1573
|
+
write14(bc, x.metadata);
|
|
1574
|
+
write32(bc, x.actor);
|
|
1575
|
+
}
|
|
1576
|
+
function encodeHttpResponseError4(x, config) {
|
|
1577
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1578
|
+
const bc = new bare4.ByteCursor(
|
|
1579
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1580
|
+
fullConfig
|
|
1581
|
+
);
|
|
1582
|
+
writeHttpResponseError4(bc, x);
|
|
1583
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1584
|
+
}
|
|
1585
|
+
function decodeHttpResponseError4(bytes) {
|
|
1586
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1587
|
+
const result = readHttpResponseError4(bc);
|
|
1588
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1589
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1590
|
+
}
|
|
1591
|
+
return result;
|
|
1592
|
+
}
|
|
1593
|
+
function readHttpResolveResponse4(bc) {
|
|
1594
|
+
return {
|
|
1595
|
+
actorId: bare4.readString(bc)
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
function writeHttpResolveResponse4(bc, x) {
|
|
1599
|
+
bare4.writeString(bc, x.actorId);
|
|
1600
|
+
}
|
|
1601
|
+
function encodeHttpResolveResponse4(x, config) {
|
|
1602
|
+
const fullConfig = config != null ? bare4.Config(config) : DEFAULT_CONFIG4;
|
|
1603
|
+
const bc = new bare4.ByteCursor(
|
|
1604
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1605
|
+
fullConfig
|
|
1606
|
+
);
|
|
1607
|
+
writeHttpResolveResponse4(bc, x);
|
|
1608
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1609
|
+
}
|
|
1610
|
+
function decodeHttpResolveResponse4(bytes) {
|
|
1611
|
+
const bc = new bare4.ByteCursor(bytes, DEFAULT_CONFIG4);
|
|
1612
|
+
const result = readHttpResolveResponse4(bc);
|
|
1613
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1614
|
+
throw new bare4.BareError(bc.offset, "remaining bytes");
|
|
1615
|
+
}
|
|
1616
|
+
return result;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1183
1619
|
// src/common/client-protocol-versioned.ts
|
|
1184
|
-
var CURRENT_VERSION =
|
|
1620
|
+
var CURRENT_VERSION = 4;
|
|
1185
1621
|
var v1ToV2 = (v1Data) => {
|
|
1186
1622
|
if (v1Data.body.tag === "Init") {
|
|
1187
1623
|
const { actorId, connectionId } = v1Data.body.val;
|
|
@@ -1217,6 +1653,32 @@ var v2ToV1 = (v2Data) => {
|
|
|
1217
1653
|
var v2ToV3 = (v2Data) => {
|
|
1218
1654
|
return v2Data;
|
|
1219
1655
|
};
|
|
1656
|
+
var v3ToV4 = (v3Data) => {
|
|
1657
|
+
if (v3Data.body.tag === "Error") {
|
|
1658
|
+
return {
|
|
1659
|
+
body: {
|
|
1660
|
+
tag: "Error",
|
|
1661
|
+
val: {
|
|
1662
|
+
...v3Data.body.val,
|
|
1663
|
+
actor: null
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
return v3Data;
|
|
1669
|
+
};
|
|
1670
|
+
var v4ToV3 = (v4Data) => {
|
|
1671
|
+
if (v4Data.body.tag === "Error") {
|
|
1672
|
+
const { actor: _, ...val } = v4Data.body.val;
|
|
1673
|
+
return {
|
|
1674
|
+
body: {
|
|
1675
|
+
tag: "Error",
|
|
1676
|
+
val
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
return v4Data;
|
|
1681
|
+
};
|
|
1220
1682
|
var v3ToV2 = (v3Data) => {
|
|
1221
1683
|
return v3Data;
|
|
1222
1684
|
};
|
|
@@ -1226,12 +1688,26 @@ var v1ToServerV2 = (v1Data) => {
|
|
|
1226
1688
|
var v2ToServerV3 = (v2Data) => {
|
|
1227
1689
|
return v2Data;
|
|
1228
1690
|
};
|
|
1691
|
+
var v3ToServerV4 = (v3Data) => {
|
|
1692
|
+
return v3Data;
|
|
1693
|
+
};
|
|
1694
|
+
var v4ToServerV3 = (v4Data) => {
|
|
1695
|
+
return v4Data;
|
|
1696
|
+
};
|
|
1229
1697
|
var v3ToServerV2 = (v3Data) => {
|
|
1230
1698
|
return v3Data;
|
|
1231
1699
|
};
|
|
1232
1700
|
var v2ToServerV1 = (v2Data) => {
|
|
1233
1701
|
return v2Data;
|
|
1234
1702
|
};
|
|
1703
|
+
var v3HttpResponseErrorToV4 = (v3Data) => ({
|
|
1704
|
+
...v3Data,
|
|
1705
|
+
actor: null
|
|
1706
|
+
});
|
|
1707
|
+
var v4HttpResponseErrorToV3 = (v4Data) => {
|
|
1708
|
+
const { actor: _, ...rest } = v4Data;
|
|
1709
|
+
return rest;
|
|
1710
|
+
};
|
|
1235
1711
|
var CLIENT_PROTOCOL_TO_SERVER = _vbare.createVersionedDataHandler.call(void 0, {
|
|
1236
1712
|
deserializeVersion: (bytes, version) => {
|
|
1237
1713
|
switch (version) {
|
|
@@ -1241,6 +1717,8 @@ var CLIENT_PROTOCOL_TO_SERVER = _vbare.createVersionedDataHandler.call(void 0, {
|
|
|
1241
1717
|
return decodeToServer2(bytes);
|
|
1242
1718
|
case 3:
|
|
1243
1719
|
return decodeToServer3(bytes);
|
|
1720
|
+
case 4:
|
|
1721
|
+
return decodeToServer4(bytes);
|
|
1244
1722
|
default:
|
|
1245
1723
|
throw new Error(`Unknown version ${version}`);
|
|
1246
1724
|
}
|
|
@@ -1253,12 +1731,14 @@ var CLIENT_PROTOCOL_TO_SERVER = _vbare.createVersionedDataHandler.call(void 0, {
|
|
|
1253
1731
|
return encodeToServer2(data);
|
|
1254
1732
|
case 3:
|
|
1255
1733
|
return encodeToServer3(data);
|
|
1734
|
+
case 4:
|
|
1735
|
+
return encodeToServer4(data);
|
|
1256
1736
|
default:
|
|
1257
1737
|
throw new Error(`Unknown version ${version}`);
|
|
1258
1738
|
}
|
|
1259
1739
|
},
|
|
1260
|
-
deserializeConverters: () => [v1ToServerV2, v2ToServerV3],
|
|
1261
|
-
serializeConverters: () => [v3ToServerV2, v2ToServerV1]
|
|
1740
|
+
deserializeConverters: () => [v1ToServerV2, v2ToServerV3, v3ToServerV4],
|
|
1741
|
+
serializeConverters: () => [v4ToServerV3, v3ToServerV2, v2ToServerV1]
|
|
1262
1742
|
});
|
|
1263
1743
|
var CLIENT_PROTOCOL_TO_CLIENT = _vbare.createVersionedDataHandler.call(void 0, {
|
|
1264
1744
|
deserializeVersion: (bytes, version) => {
|
|
@@ -1269,6 +1749,8 @@ var CLIENT_PROTOCOL_TO_CLIENT = _vbare.createVersionedDataHandler.call(void 0, {
|
|
|
1269
1749
|
return decodeToClient2(bytes);
|
|
1270
1750
|
case 3:
|
|
1271
1751
|
return decodeToClient3(bytes);
|
|
1752
|
+
case 4:
|
|
1753
|
+
return decodeToClient4(bytes);
|
|
1272
1754
|
default:
|
|
1273
1755
|
throw new Error(`Unknown version ${version}`);
|
|
1274
1756
|
}
|
|
@@ -1281,12 +1763,14 @@ var CLIENT_PROTOCOL_TO_CLIENT = _vbare.createVersionedDataHandler.call(void 0, {
|
|
|
1281
1763
|
return encodeToClient2(data);
|
|
1282
1764
|
case 3:
|
|
1283
1765
|
return encodeToClient3(data);
|
|
1766
|
+
case 4:
|
|
1767
|
+
return encodeToClient4(data);
|
|
1284
1768
|
default:
|
|
1285
1769
|
throw new Error(`Unknown version ${version}`);
|
|
1286
1770
|
}
|
|
1287
1771
|
},
|
|
1288
|
-
deserializeConverters: () => [v1ToV2, v2ToV3],
|
|
1289
|
-
serializeConverters: () => [v3ToV2, v2ToV1]
|
|
1772
|
+
deserializeConverters: () => [v1ToV2, v2ToV3, v3ToV4],
|
|
1773
|
+
serializeConverters: () => [v4ToV3, v3ToV2, v2ToV1]
|
|
1290
1774
|
});
|
|
1291
1775
|
var HTTP_ACTION_REQUEST_VERSIONED = _vbare.createVersionedDataHandler.call(void 0, {
|
|
1292
1776
|
deserializeVersion: (bytes, version) => {
|
|
@@ -1297,6 +1781,8 @@ var HTTP_ACTION_REQUEST_VERSIONED = _vbare.createVersionedDataHandler.call(void
|
|
|
1297
1781
|
return decodeHttpActionRequest2(bytes);
|
|
1298
1782
|
case 3:
|
|
1299
1783
|
return decodeHttpActionRequest3(bytes);
|
|
1784
|
+
case 4:
|
|
1785
|
+
return decodeHttpActionRequest4(bytes);
|
|
1300
1786
|
default:
|
|
1301
1787
|
throw new Error(`Unknown version ${version}`);
|
|
1302
1788
|
}
|
|
@@ -1315,6 +1801,10 @@ var HTTP_ACTION_REQUEST_VERSIONED = _vbare.createVersionedDataHandler.call(void
|
|
|
1315
1801
|
return encodeHttpActionRequest3(
|
|
1316
1802
|
data
|
|
1317
1803
|
);
|
|
1804
|
+
case 4:
|
|
1805
|
+
return encodeHttpActionRequest4(
|
|
1806
|
+
data
|
|
1807
|
+
);
|
|
1318
1808
|
default:
|
|
1319
1809
|
throw new Error(`Unknown version ${version}`);
|
|
1320
1810
|
}
|
|
@@ -1331,6 +1821,8 @@ var HTTP_ACTION_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(void
|
|
|
1331
1821
|
return decodeHttpActionResponse2(bytes);
|
|
1332
1822
|
case 3:
|
|
1333
1823
|
return decodeHttpActionResponse3(bytes);
|
|
1824
|
+
case 4:
|
|
1825
|
+
return decodeHttpActionResponse4(bytes);
|
|
1334
1826
|
default:
|
|
1335
1827
|
throw new Error(`Unknown version ${version}`);
|
|
1336
1828
|
}
|
|
@@ -1349,6 +1841,10 @@ var HTTP_ACTION_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(void
|
|
|
1349
1841
|
return encodeHttpActionResponse3(
|
|
1350
1842
|
data
|
|
1351
1843
|
);
|
|
1844
|
+
case 4:
|
|
1845
|
+
return encodeHttpActionResponse4(
|
|
1846
|
+
data
|
|
1847
|
+
);
|
|
1352
1848
|
default:
|
|
1353
1849
|
throw new Error(`Unknown version ${version}`);
|
|
1354
1850
|
}
|
|
@@ -1361,6 +1857,8 @@ var HTTP_QUEUE_SEND_REQUEST_VERSIONED = _vbare.createVersionedDataHandler.call(v
|
|
|
1361
1857
|
switch (version) {
|
|
1362
1858
|
case 3:
|
|
1363
1859
|
return decodeHttpQueueSendRequest(bytes);
|
|
1860
|
+
case 4:
|
|
1861
|
+
return decodeHttpQueueSendRequest2(bytes);
|
|
1364
1862
|
default:
|
|
1365
1863
|
throw new Error(
|
|
1366
1864
|
`HttpQueueSendRequest only exists in version 3+, got version ${version}`
|
|
@@ -1373,6 +1871,10 @@ var HTTP_QUEUE_SEND_REQUEST_VERSIONED = _vbare.createVersionedDataHandler.call(v
|
|
|
1373
1871
|
return encodeHttpQueueSendRequest(
|
|
1374
1872
|
data
|
|
1375
1873
|
);
|
|
1874
|
+
case 4:
|
|
1875
|
+
return encodeHttpQueueSendRequest2(
|
|
1876
|
+
data
|
|
1877
|
+
);
|
|
1376
1878
|
default:
|
|
1377
1879
|
throw new Error(
|
|
1378
1880
|
`HttpQueueSendRequest only exists in version 3+, got version ${version}`
|
|
@@ -1387,6 +1889,8 @@ var HTTP_QUEUE_SEND_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(
|
|
|
1387
1889
|
switch (version) {
|
|
1388
1890
|
case 3:
|
|
1389
1891
|
return decodeHttpQueueSendResponse(bytes);
|
|
1892
|
+
case 4:
|
|
1893
|
+
return decodeHttpQueueSendResponse2(bytes);
|
|
1390
1894
|
default:
|
|
1391
1895
|
throw new Error(
|
|
1392
1896
|
`HttpQueueSendResponse only exists in version 3+, got version ${version}`
|
|
@@ -1399,6 +1903,10 @@ var HTTP_QUEUE_SEND_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(
|
|
|
1399
1903
|
return encodeHttpQueueSendResponse(
|
|
1400
1904
|
data
|
|
1401
1905
|
);
|
|
1906
|
+
case 4:
|
|
1907
|
+
return encodeHttpQueueSendResponse2(
|
|
1908
|
+
data
|
|
1909
|
+
);
|
|
1402
1910
|
default:
|
|
1403
1911
|
throw new Error(
|
|
1404
1912
|
`HttpQueueSendResponse only exists in version 3+, got version ${version}`
|
|
@@ -1417,6 +1925,8 @@ var HTTP_RESPONSE_ERROR_VERSIONED = _vbare.createVersionedDataHandler.call(void
|
|
|
1417
1925
|
return decodeHttpResponseError2(bytes);
|
|
1418
1926
|
case 3:
|
|
1419
1927
|
return decodeHttpResponseError3(bytes);
|
|
1928
|
+
case 4:
|
|
1929
|
+
return decodeHttpResponseError4(bytes);
|
|
1420
1930
|
default:
|
|
1421
1931
|
throw new Error(`Unknown version ${version}`);
|
|
1422
1932
|
}
|
|
@@ -1435,12 +1945,24 @@ var HTTP_RESPONSE_ERROR_VERSIONED = _vbare.createVersionedDataHandler.call(void
|
|
|
1435
1945
|
return encodeHttpResponseError3(
|
|
1436
1946
|
data
|
|
1437
1947
|
);
|
|
1948
|
+
case 4:
|
|
1949
|
+
return encodeHttpResponseError4(
|
|
1950
|
+
data
|
|
1951
|
+
);
|
|
1438
1952
|
default:
|
|
1439
1953
|
throw new Error(`Unknown version ${version}`);
|
|
1440
1954
|
}
|
|
1441
1955
|
},
|
|
1442
|
-
deserializeConverters: () => [
|
|
1443
|
-
|
|
1956
|
+
deserializeConverters: () => [
|
|
1957
|
+
(data) => data,
|
|
1958
|
+
(data) => data,
|
|
1959
|
+
v3HttpResponseErrorToV4
|
|
1960
|
+
],
|
|
1961
|
+
serializeConverters: () => [
|
|
1962
|
+
v4HttpResponseErrorToV3,
|
|
1963
|
+
(data) => data,
|
|
1964
|
+
(data) => data
|
|
1965
|
+
]
|
|
1444
1966
|
});
|
|
1445
1967
|
var HTTP_RESOLVE_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(void 0, {
|
|
1446
1968
|
deserializeVersion: (bytes, version) => {
|
|
@@ -1451,6 +1973,8 @@ var HTTP_RESOLVE_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(voi
|
|
|
1451
1973
|
return decodeHttpResolveResponse2(bytes);
|
|
1452
1974
|
case 3:
|
|
1453
1975
|
return decodeHttpResolveResponse3(bytes);
|
|
1976
|
+
case 4:
|
|
1977
|
+
return decodeHttpResolveResponse4(bytes);
|
|
1454
1978
|
default:
|
|
1455
1979
|
throw new Error(`Unknown version ${version}`);
|
|
1456
1980
|
}
|
|
@@ -1469,6 +1993,10 @@ var HTTP_RESOLVE_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(voi
|
|
|
1469
1993
|
return encodeHttpResolveResponse3(
|
|
1470
1994
|
data
|
|
1471
1995
|
);
|
|
1996
|
+
case 4:
|
|
1997
|
+
return encodeHttpResolveResponse4(
|
|
1998
|
+
data
|
|
1999
|
+
);
|
|
1472
2000
|
default:
|
|
1473
2001
|
throw new Error(`Unknown version ${version}`);
|
|
1474
2002
|
}
|
|
@@ -1481,6 +2009,11 @@ var HTTP_RESOLVE_RESPONSE_VERSIONED = _vbare.createVersionedDataHandler.call(voi
|
|
|
1481
2009
|
var _v4 = require('zod/v4'); var _v42 = _interopRequireDefault(_v4);
|
|
1482
2010
|
var UintSchema = _v4.z.bigint();
|
|
1483
2011
|
var OptionalUintSchema = UintSchema.nullable();
|
|
2012
|
+
var ActorSpecifierSchema = _v4.z.object({
|
|
2013
|
+
actorId: _v4.z.string(),
|
|
2014
|
+
generation: _v4.z.union([_v4.z.number(), _v4.z.bigint()]),
|
|
2015
|
+
key: _v4.z.string().optional()
|
|
2016
|
+
});
|
|
1484
2017
|
var InitSchema = _v4.z.object({
|
|
1485
2018
|
actorId: _v4.z.string(),
|
|
1486
2019
|
connectionId: _v4.z.string()
|
|
@@ -1490,7 +2023,8 @@ var ErrorSchema = _v4.z.object({
|
|
|
1490
2023
|
code: _v4.z.string(),
|
|
1491
2024
|
message: _v4.z.string(),
|
|
1492
2025
|
metadata: _v4.z.unknown().optional(),
|
|
1493
|
-
actionId: OptionalUintSchema
|
|
2026
|
+
actionId: OptionalUintSchema,
|
|
2027
|
+
actor: ActorSpecifierSchema.optional()
|
|
1494
2028
|
});
|
|
1495
2029
|
var ActionResponseSchema = _v4.z.object({
|
|
1496
2030
|
id: UintSchema,
|
|
@@ -1548,7 +2082,8 @@ var HttpResponseErrorSchema = _v4.z.object({
|
|
|
1548
2082
|
group: _v4.z.string(),
|
|
1549
2083
|
code: _v4.z.string(),
|
|
1550
2084
|
message: _v4.z.string(),
|
|
1551
|
-
metadata: _v4.z.unknown().optional()
|
|
2085
|
+
metadata: _v4.z.unknown().optional(),
|
|
2086
|
+
actor: ActorSpecifierSchema.optional()
|
|
1552
2087
|
});
|
|
1553
2088
|
var HttpResolveRequestSchema = _v4.z.null();
|
|
1554
2089
|
var HttpResolveResponseSchema = _v4.z.object({
|
|
@@ -1569,7 +2104,7 @@ function getActorNameFromQuery(query) {
|
|
|
1569
2104
|
if ("getForKey" in query) return query.getForKey.name;
|
|
1570
2105
|
if ("getOrCreateForKey" in query) return query.getOrCreateForKey.name;
|
|
1571
2106
|
if ("create" in query) return query.create.name;
|
|
1572
|
-
throw
|
|
2107
|
+
throw _chunkQAZLM4WTcjs.invalidRequest.call(void 0, "Invalid query format");
|
|
1573
2108
|
}
|
|
1574
2109
|
function isDynamicActorQuery(actorQuery) {
|
|
1575
2110
|
return "getForKey" in actorQuery || "getOrCreateForKey" in actorQuery;
|
|
@@ -1579,7 +2114,7 @@ function getGatewayTarget(state) {
|
|
|
1579
2114
|
return { directId: state.getForId.actorId };
|
|
1580
2115
|
}
|
|
1581
2116
|
if ("create" in state) {
|
|
1582
|
-
throw
|
|
2117
|
+
throw _chunkQAZLM4WTcjs.invalidRequest.call(void 0,
|
|
1583
2118
|
"create queries cannot be used as gateway targets. Resolve to an actor ID first."
|
|
1584
2119
|
);
|
|
1585
2120
|
}
|
|
@@ -1593,7 +2128,7 @@ async function checkForSchedulingError(group, code, actorId, query, driver) {
|
|
|
1593
2128
|
try {
|
|
1594
2129
|
const actor = await driver.getForId({ name, actorId });
|
|
1595
2130
|
if (actor == null ? void 0 : actor.error) {
|
|
1596
|
-
|
|
2131
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).info({
|
|
1597
2132
|
msg: "found actor scheduling error",
|
|
1598
2133
|
actorId,
|
|
1599
2134
|
error: actor.error
|
|
@@ -1601,10 +2136,10 @@ async function checkForSchedulingError(group, code, actorId, query, driver) {
|
|
|
1601
2136
|
return actorSchedulingError(group, code, actorId, actor.error);
|
|
1602
2137
|
}
|
|
1603
2138
|
} catch (err) {
|
|
1604
|
-
|
|
2139
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
1605
2140
|
msg: "failed to fetch actor details for scheduling error check",
|
|
1606
2141
|
actorId,
|
|
1607
|
-
error:
|
|
2142
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
1608
2143
|
});
|
|
1609
2144
|
}
|
|
1610
2145
|
return null;
|
|
@@ -1737,7 +2272,7 @@ function classifyTransportError(error) {
|
|
|
1737
2272
|
}
|
|
1738
2273
|
function classifyLifecycleBoundaryError(error) {
|
|
1739
2274
|
for (const current of walkErrorChain(error)) {
|
|
1740
|
-
if (current instanceof
|
|
2275
|
+
if (current instanceof _chunkQAZLM4WTcjs.RivetError) {
|
|
1741
2276
|
const classified = classifyActorError(current);
|
|
1742
2277
|
if (classified) {
|
|
1743
2278
|
return classified;
|
|
@@ -1817,7 +2352,7 @@ function parseWebSocketCloseReason(reason) {
|
|
|
1817
2352
|
const [mainPart, rayId] = reason.split("#");
|
|
1818
2353
|
const [group, code] = mainPart.split(".");
|
|
1819
2354
|
if (!group || !code) {
|
|
1820
|
-
|
|
2355
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({ msg: "failed to parse close reason", reason });
|
|
1821
2356
|
return void 0;
|
|
1822
2357
|
}
|
|
1823
2358
|
return {
|
|
@@ -1839,10 +2374,11 @@ function messageLength(message) {
|
|
|
1839
2374
|
if (typeof message === "string") {
|
|
1840
2375
|
return message.length;
|
|
1841
2376
|
}
|
|
1842
|
-
|
|
2377
|
+
_chunkK5BA2LEOcjs.assertUnreachable.call(void 0, message);
|
|
1843
2378
|
}
|
|
1844
2379
|
async function sendHttpRequest(opts) {
|
|
1845
|
-
|
|
2380
|
+
var _a, _b, _c;
|
|
2381
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
1846
2382
|
msg: "sending http request",
|
|
1847
2383
|
url: opts.url,
|
|
1848
2384
|
encoding: opts.encoding
|
|
@@ -1851,8 +2387,8 @@ async function sendHttpRequest(opts) {
|
|
|
1851
2387
|
let bodyData;
|
|
1852
2388
|
if (opts.method === "POST" || opts.method === "PUT") {
|
|
1853
2389
|
_invariant2.default.call(void 0, opts.body !== void 0, "missing body");
|
|
1854
|
-
contentType =
|
|
1855
|
-
bodyData =
|
|
2390
|
+
contentType = _chunkLIXXFXVRcjs.contentTypeForEncoding.call(void 0, opts.encoding);
|
|
2391
|
+
bodyData = _chunkLIXXFXVRcjs.serializeWithEncoding.call(void 0,
|
|
1856
2392
|
opts.encoding,
|
|
1857
2393
|
opts.body,
|
|
1858
2394
|
opts.requestVersionedDataHandler,
|
|
@@ -1872,7 +2408,7 @@ async function sendHttpRequest(opts) {
|
|
|
1872
2408
|
...contentType ? {
|
|
1873
2409
|
"Content-Type": contentType
|
|
1874
2410
|
} : {},
|
|
1875
|
-
"User-Agent":
|
|
2411
|
+
"User-Agent": _chunkK5BA2LEOcjs.httpUserAgent.call(void 0, )
|
|
1876
2412
|
},
|
|
1877
2413
|
body: bodyData,
|
|
1878
2414
|
credentials: "include",
|
|
@@ -1890,29 +2426,53 @@ async function sendHttpRequest(opts) {
|
|
|
1890
2426
|
const rayId = response.headers.get("x-rivet-ray-id");
|
|
1891
2427
|
const encoding = (contentType2 == null ? void 0 : contentType2.includes("application/json")) ? "json" : opts.encoding;
|
|
1892
2428
|
try {
|
|
1893
|
-
const responseData =
|
|
2429
|
+
const responseData = _chunkLIXXFXVRcjs.deserializeWithEncoding.call(void 0,
|
|
1894
2430
|
encoding,
|
|
1895
2431
|
new Uint8Array(bufferResponse),
|
|
1896
2432
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
1897
2433
|
HttpResponseErrorSchema,
|
|
1898
|
-
// JSON:
|
|
1899
|
-
(json) =>
|
|
2434
|
+
// JSON/CBOR: normalize actor generation to the public number shape.
|
|
2435
|
+
(json) => ({
|
|
2436
|
+
...json,
|
|
2437
|
+
actor: json.actor ? {
|
|
2438
|
+
...json.actor,
|
|
2439
|
+
generation: Number(json.actor.generation)
|
|
2440
|
+
} : void 0
|
|
2441
|
+
}),
|
|
1900
2442
|
// BARE: decode ArrayBuffer metadata to unknown
|
|
1901
|
-
(
|
|
1902
|
-
group:
|
|
1903
|
-
code:
|
|
1904
|
-
message:
|
|
1905
|
-
metadata:
|
|
2443
|
+
(bare5) => ({
|
|
2444
|
+
group: bare5.group,
|
|
2445
|
+
code: bare5.code,
|
|
2446
|
+
message: bare5.message,
|
|
2447
|
+
metadata: bare5.metadata ? _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.metadata)) : void 0,
|
|
2448
|
+
actor: bare5.actor ? {
|
|
2449
|
+
actorId: bare5.actor.actorId,
|
|
2450
|
+
generation: Number(bare5.actor.generation),
|
|
2451
|
+
key: _nullishCoalesce(bare5.actor.key, () => ( void 0))
|
|
2452
|
+
} : void 0
|
|
1906
2453
|
})
|
|
1907
2454
|
);
|
|
1908
|
-
|
|
2455
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
2456
|
+
msg: "http error response",
|
|
2457
|
+
group: responseData.group,
|
|
2458
|
+
code: responseData.code,
|
|
2459
|
+
message: responseData.message,
|
|
2460
|
+
metadata: responseData.metadata,
|
|
2461
|
+
actorId: (_a = responseData.actor) == null ? void 0 : _a.actorId,
|
|
2462
|
+
generation: (_b = responseData.actor) == null ? void 0 : _b.generation,
|
|
2463
|
+
actorKey: (_c = responseData.actor) == null ? void 0 : _c.key
|
|
2464
|
+
});
|
|
2465
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
1909
2466
|
responseData.group,
|
|
1910
2467
|
responseData.code,
|
|
1911
2468
|
responseData.message,
|
|
1912
|
-
|
|
2469
|
+
{
|
|
2470
|
+
metadata: responseData.metadata,
|
|
2471
|
+
actor: responseData.actor
|
|
2472
|
+
}
|
|
1913
2473
|
);
|
|
1914
2474
|
} catch (error) {
|
|
1915
|
-
if (error instanceof
|
|
2475
|
+
if (error instanceof _chunkQAZLM4WTcjs.RivetError) {
|
|
1916
2476
|
throw error;
|
|
1917
2477
|
}
|
|
1918
2478
|
const textResponse = new TextDecoder("utf-8", {
|
|
@@ -1936,7 +2496,7 @@ ${textResponse}`
|
|
|
1936
2496
|
}
|
|
1937
2497
|
try {
|
|
1938
2498
|
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
1939
|
-
return
|
|
2499
|
+
return _chunkLIXXFXVRcjs.deserializeWithEncoding.call(void 0,
|
|
1940
2500
|
opts.encoding,
|
|
1941
2501
|
buffer,
|
|
1942
2502
|
opts.responseVersionedDataHandler,
|
|
@@ -1983,7 +2543,7 @@ function createQueueSender(senderOptions) {
|
|
|
1983
2543
|
}),
|
|
1984
2544
|
requestToBare: (value) => ({
|
|
1985
2545
|
name: _nullishCoalesce(value.name, () => ( name)),
|
|
1986
|
-
body:
|
|
2546
|
+
body: _chunkK5BA2LEOcjs.bufferToArrayBuffer.call(void 0, _chunkLIXXFXVRcjs.encodeCborCompat.call(void 0, value.body)),
|
|
1987
2547
|
wait: _nullishCoalesce(value.wait, () => ( false)),
|
|
1988
2548
|
timeout: value.timeout !== void 0 ? BigInt(value.timeout) : null
|
|
1989
2549
|
}),
|
|
@@ -1996,13 +2556,13 @@ function createQueueSender(senderOptions) {
|
|
|
1996
2556
|
response: json.response
|
|
1997
2557
|
};
|
|
1998
2558
|
},
|
|
1999
|
-
responseFromBare: (
|
|
2000
|
-
if (
|
|
2001
|
-
return { status:
|
|
2559
|
+
responseFromBare: (bare5) => {
|
|
2560
|
+
if (bare5.response === null || bare5.response === void 0) {
|
|
2561
|
+
return { status: bare5.status };
|
|
2002
2562
|
}
|
|
2003
2563
|
return {
|
|
2004
|
-
status:
|
|
2005
|
-
response:
|
|
2564
|
+
status: bare5.status,
|
|
2565
|
+
response: _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.response))
|
|
2006
2566
|
};
|
|
2007
2567
|
}
|
|
2008
2568
|
});
|
|
@@ -2056,7 +2616,7 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
|
2056
2616
|
throw new TypeError("Invalid input type for fetch");
|
|
2057
2617
|
}
|
|
2058
2618
|
try {
|
|
2059
|
-
|
|
2619
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug(
|
|
2060
2620
|
"directId" in target ? {
|
|
2061
2621
|
msg: "sending raw http request to actor",
|
|
2062
2622
|
actorId: target.directId
|
|
@@ -2077,13 +2637,11 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
|
2077
2637
|
});
|
|
2078
2638
|
return driver.sendRequest(target, proxyRequest, options);
|
|
2079
2639
|
} catch (err) {
|
|
2080
|
-
const { group, code, message, metadata } =
|
|
2640
|
+
const { group, code, message, metadata, actor } = _chunkK5BA2LEOcjs.deconstructError.call(void 0,
|
|
2081
2641
|
err,
|
|
2082
|
-
_chunkLELRJK66cjs.logger.call(void 0, ),
|
|
2083
|
-
{},
|
|
2084
2642
|
true
|
|
2085
2643
|
);
|
|
2086
|
-
throw new (0,
|
|
2644
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(group, code, message, { metadata, actor });
|
|
2087
2645
|
}
|
|
2088
2646
|
}
|
|
2089
2647
|
async function rawWebSocket(driver, target, params, path, _protocols, options = {}) {
|
|
@@ -2103,7 +2661,7 @@ async function rawWebSocket(driver, target, params, path, _protocols, options =
|
|
|
2103
2661
|
}
|
|
2104
2662
|
}
|
|
2105
2663
|
const fullPath = `${PATH_WEBSOCKET_PREFIX}${pathPortion}${queryPortion}`;
|
|
2106
|
-
|
|
2664
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2107
2665
|
msg: "opening websocket",
|
|
2108
2666
|
target,
|
|
2109
2667
|
encoding,
|
|
@@ -2133,7 +2691,7 @@ async function resolveGatewayTarget(driver, target) {
|
|
|
2133
2691
|
key: target.getForKey.key
|
|
2134
2692
|
});
|
|
2135
2693
|
if (!output) {
|
|
2136
|
-
throw
|
|
2694
|
+
throw _chunkQAZLM4WTcjs.actorNotFound.call(void 0,
|
|
2137
2695
|
`${target.getForKey.name}:${JSON.stringify(target.getForKey.key)}`
|
|
2138
2696
|
);
|
|
2139
2697
|
}
|
|
@@ -2157,7 +2715,7 @@ async function resolveGatewayTarget(driver, target) {
|
|
|
2157
2715
|
});
|
|
2158
2716
|
return output.actorId;
|
|
2159
2717
|
}
|
|
2160
|
-
throw
|
|
2718
|
+
throw _chunkQAZLM4WTcjs.invalidRequest.call(void 0, "Invalid query format");
|
|
2161
2719
|
}
|
|
2162
2720
|
|
|
2163
2721
|
// src/client/actor-handle.ts
|
|
@@ -2204,7 +2762,13 @@ var ActorHandleRaw = class {
|
|
|
2204
2762
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
2205
2763
|
let actorId;
|
|
2206
2764
|
try {
|
|
2207
|
-
const
|
|
2765
|
+
const gatewayOptions = resolveActorGatewayOptions(
|
|
2766
|
+
this.#gatewayOptions
|
|
2767
|
+
);
|
|
2768
|
+
const target = await this.#resolveGatewayRequestTarget(
|
|
2769
|
+
useQueryTarget,
|
|
2770
|
+
gatewayOptions
|
|
2771
|
+
);
|
|
2208
2772
|
actorId = "directId" in target ? target.directId : void 0;
|
|
2209
2773
|
return await createQueueSender({
|
|
2210
2774
|
encoding: this.#encoding,
|
|
@@ -2213,17 +2777,13 @@ var ActorHandleRaw = class {
|
|
|
2213
2777
|
return await this.#driver.sendRequest(
|
|
2214
2778
|
target,
|
|
2215
2779
|
request,
|
|
2216
|
-
|
|
2217
|
-
this.#gatewayOptions
|
|
2218
|
-
)
|
|
2780
|
+
gatewayOptions
|
|
2219
2781
|
);
|
|
2220
2782
|
}
|
|
2221
2783
|
}).send(name, body, options);
|
|
2222
2784
|
} catch (err) {
|
|
2223
|
-
const { group, code, message, metadata } =
|
|
2785
|
+
const { group, code, message, metadata, actor } = _chunkK5BA2LEOcjs.deconstructError.call(void 0,
|
|
2224
2786
|
err,
|
|
2225
|
-
_chunkLELRJK66cjs.logger.call(void 0, ),
|
|
2226
|
-
{},
|
|
2227
2787
|
true
|
|
2228
2788
|
);
|
|
2229
2789
|
if (this.#shouldRetryQueueDispatchOverload(
|
|
@@ -2266,7 +2826,7 @@ var ActorHandleRaw = class {
|
|
|
2266
2826
|
}
|
|
2267
2827
|
continue;
|
|
2268
2828
|
}
|
|
2269
|
-
throw new (0,
|
|
2829
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(group, code, message, { metadata, actor });
|
|
2270
2830
|
}
|
|
2271
2831
|
}
|
|
2272
2832
|
throw new Error("unreachable queue retry state");
|
|
@@ -2301,15 +2861,18 @@ var ActorHandleRaw = class {
|
|
|
2301
2861
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
2302
2862
|
let actorId;
|
|
2303
2863
|
try {
|
|
2304
|
-
const target = await this.#
|
|
2864
|
+
const target = await this.#resolveGatewayRequestTarget(
|
|
2865
|
+
useQueryTarget,
|
|
2866
|
+
gatewayOptions
|
|
2867
|
+
);
|
|
2305
2868
|
actorId = "directId" in target ? target.directId : void 0;
|
|
2306
|
-
|
|
2869
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug(
|
|
2307
2870
|
actorId ? { msg: "using direct actor gateway target", actorId } : {
|
|
2308
2871
|
msg: "using query gateway target for action",
|
|
2309
2872
|
query: this.#actorResolutionState
|
|
2310
2873
|
}
|
|
2311
2874
|
);
|
|
2312
|
-
|
|
2875
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2313
2876
|
msg: "handling action",
|
|
2314
2877
|
name: opts.name,
|
|
2315
2878
|
encoding: this.#encoding
|
|
@@ -2343,20 +2906,18 @@ var ActorHandleRaw = class {
|
|
|
2343
2906
|
args
|
|
2344
2907
|
}),
|
|
2345
2908
|
requestToBare: (args) => ({
|
|
2346
|
-
args:
|
|
2909
|
+
args: _chunkK5BA2LEOcjs.bufferToArrayBuffer.call(void 0, _chunkLIXXFXVRcjs.encodeCborCompat.call(void 0, args))
|
|
2347
2910
|
}),
|
|
2348
2911
|
responseFromJson: (json) => json.output,
|
|
2349
|
-
responseFromBare: (
|
|
2912
|
+
responseFromBare: (bare5) => _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.output))
|
|
2350
2913
|
});
|
|
2351
2914
|
if (opts.name === "destroy" && actorId) {
|
|
2352
2915
|
await this.#waitForDestroyActionToSettle(actorId);
|
|
2353
2916
|
}
|
|
2354
2917
|
return output;
|
|
2355
2918
|
} catch (err) {
|
|
2356
|
-
const { group, code, message, metadata } =
|
|
2919
|
+
const { group, code, message, metadata, actor } = _chunkK5BA2LEOcjs.deconstructError.call(void 0,
|
|
2357
2920
|
err,
|
|
2358
|
-
_chunkLELRJK66cjs.logger.call(void 0, ),
|
|
2359
|
-
{},
|
|
2360
2921
|
true
|
|
2361
2922
|
);
|
|
2362
2923
|
if (await this.#shouldRetrySchedulingError(
|
|
@@ -2382,11 +2943,11 @@ var ActorHandleRaw = class {
|
|
|
2382
2943
|
continue;
|
|
2383
2944
|
}
|
|
2384
2945
|
if (group === "actor" && code === "destroyed_while_waiting_for_ready" && "getForId" in this.#actorResolutionState) {
|
|
2385
|
-
throw new (0,
|
|
2946
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
2386
2947
|
"actor",
|
|
2387
2948
|
"not_found",
|
|
2388
2949
|
"The actor does not exist or was destroyed.",
|
|
2389
|
-
metadata
|
|
2950
|
+
{ metadata, actor }
|
|
2390
2951
|
);
|
|
2391
2952
|
}
|
|
2392
2953
|
const invalidated = this.#invalidateResolvedActorId(group, code);
|
|
@@ -2397,7 +2958,7 @@ var ActorHandleRaw = class {
|
|
|
2397
2958
|
}
|
|
2398
2959
|
continue;
|
|
2399
2960
|
}
|
|
2400
|
-
throw new (0,
|
|
2961
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(group, code, message, { metadata, actor });
|
|
2401
2962
|
}
|
|
2402
2963
|
}
|
|
2403
2964
|
throw new Error("unreachable action retry state");
|
|
@@ -2490,6 +3051,12 @@ var ActorHandleRaw = class {
|
|
|
2490
3051
|
this.#resolvingActorId = void 0;
|
|
2491
3052
|
}
|
|
2492
3053
|
}
|
|
3054
|
+
async #resolveGatewayRequestTarget(useQueryTarget, gatewayOptions) {
|
|
3055
|
+
if (gatewayOptions.skipReadyWait) {
|
|
3056
|
+
return getGatewayTarget(this.#actorResolutionState);
|
|
3057
|
+
}
|
|
3058
|
+
return await this.#resolveActionTarget(useQueryTarget);
|
|
3059
|
+
}
|
|
2493
3060
|
/**
|
|
2494
3061
|
* Establishes a persistent connection to the actor.
|
|
2495
3062
|
*
|
|
@@ -2497,7 +3064,7 @@ var ActorHandleRaw = class {
|
|
|
2497
3064
|
* @returns {ActorConn<AD>} A connection to the actor.
|
|
2498
3065
|
*/
|
|
2499
3066
|
connect(params, options = {}) {
|
|
2500
|
-
|
|
3067
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2501
3068
|
msg: "establishing connection from handle",
|
|
2502
3069
|
query: this.#actorResolutionState
|
|
2503
3070
|
});
|
|
@@ -2536,7 +3103,10 @@ var ActorHandleRaw = class {
|
|
|
2536
3103
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
2537
3104
|
let actorId;
|
|
2538
3105
|
try {
|
|
2539
|
-
const target = await this.#
|
|
3106
|
+
const target = await this.#resolveGatewayRequestTarget(
|
|
3107
|
+
useQueryTarget,
|
|
3108
|
+
gatewayOptions
|
|
3109
|
+
);
|
|
2540
3110
|
actorId = "directId" in target ? target.directId : void 0;
|
|
2541
3111
|
const response = await rawHttpFetch(
|
|
2542
3112
|
this.#driver,
|
|
@@ -2561,10 +3131,8 @@ var ActorHandleRaw = class {
|
|
|
2561
3131
|
}
|
|
2562
3132
|
return response;
|
|
2563
3133
|
} catch (err) {
|
|
2564
|
-
const { group, code, message, metadata } =
|
|
3134
|
+
const { group, code, message, metadata, actor } = _chunkK5BA2LEOcjs.deconstructError.call(void 0,
|
|
2565
3135
|
err,
|
|
2566
|
-
_chunkLELRJK66cjs.logger.call(void 0, ),
|
|
2567
|
-
{},
|
|
2568
3136
|
true
|
|
2569
3137
|
);
|
|
2570
3138
|
if (await this.#shouldRetrySchedulingError(
|
|
@@ -2597,7 +3165,7 @@ var ActorHandleRaw = class {
|
|
|
2597
3165
|
}
|
|
2598
3166
|
continue;
|
|
2599
3167
|
}
|
|
2600
|
-
throw new (0,
|
|
3168
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(group, code, message, { metadata, actor });
|
|
2601
3169
|
}
|
|
2602
3170
|
}
|
|
2603
3171
|
throw new Error("unreachable fetch retry state");
|
|
@@ -2652,17 +3220,28 @@ var ActorHandleRaw = class {
|
|
|
2652
3220
|
const contentType = response.headers.get("content-type");
|
|
2653
3221
|
const encoding = (contentType == null ? void 0 : contentType.includes("application/json")) ? "json" : this.#encoding;
|
|
2654
3222
|
try {
|
|
2655
|
-
return
|
|
3223
|
+
return _chunkLIXXFXVRcjs.deserializeWithEncoding.call(void 0,
|
|
2656
3224
|
encoding,
|
|
2657
3225
|
new Uint8Array(await response.clone().arrayBuffer()),
|
|
2658
3226
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
2659
3227
|
HttpResponseErrorSchema,
|
|
2660
|
-
(json) =>
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
3228
|
+
(json) => ({
|
|
3229
|
+
...json,
|
|
3230
|
+
actor: json.actor ? {
|
|
3231
|
+
...json.actor,
|
|
3232
|
+
generation: Number(json.actor.generation)
|
|
3233
|
+
} : void 0
|
|
3234
|
+
}),
|
|
3235
|
+
(bare5) => ({
|
|
3236
|
+
group: bare5.group,
|
|
3237
|
+
code: bare5.code,
|
|
3238
|
+
message: bare5.message,
|
|
3239
|
+
metadata: bare5.metadata ? _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.metadata)) : void 0,
|
|
3240
|
+
actor: bare5.actor ? {
|
|
3241
|
+
actorId: bare5.actor.actorId,
|
|
3242
|
+
generation: Number(bare5.actor.generation),
|
|
3243
|
+
key: _nullishCoalesce(bare5.actor.key, () => ( void 0))
|
|
3244
|
+
} : void 0
|
|
2666
3245
|
})
|
|
2667
3246
|
);
|
|
2668
3247
|
} catch (e) {
|
|
@@ -2678,7 +3257,10 @@ var ActorHandleRaw = class {
|
|
|
2678
3257
|
this.#gatewayOptions,
|
|
2679
3258
|
options
|
|
2680
3259
|
);
|
|
2681
|
-
const target =
|
|
3260
|
+
const target = await this.#resolveGatewayRequestTarget(
|
|
3261
|
+
false,
|
|
3262
|
+
gatewayOptions
|
|
3263
|
+
);
|
|
2682
3264
|
return await rawWebSocket(
|
|
2683
3265
|
this.#driver,
|
|
2684
3266
|
target,
|
|
@@ -2718,7 +3300,7 @@ var ActorHandleRaw = class {
|
|
|
2718
3300
|
const response = await this.#driver.sendRequest(target, request);
|
|
2719
3301
|
if (!response.ok) {
|
|
2720
3302
|
const body = await response.text().catch(() => "");
|
|
2721
|
-
throw new (0,
|
|
3303
|
+
throw new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
2722
3304
|
"actor",
|
|
2723
3305
|
"reload_failed",
|
|
2724
3306
|
`reload failed with status ${response.status}: ${body}`,
|
|
@@ -2755,7 +3337,7 @@ var ClientRaw = (_class = class {
|
|
|
2755
3337
|
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
2756
3338
|
*/
|
|
2757
3339
|
getForId(name, actorId, opts) {
|
|
2758
|
-
|
|
3340
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2759
3341
|
msg: "get handle to actor with id",
|
|
2760
3342
|
name,
|
|
2761
3343
|
actorId,
|
|
@@ -2785,7 +3367,7 @@ var ClientRaw = (_class = class {
|
|
|
2785
3367
|
*/
|
|
2786
3368
|
get(name, key, opts) {
|
|
2787
3369
|
const keyArray = typeof key === "string" ? [key] : key || [];
|
|
2788
|
-
|
|
3370
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2789
3371
|
msg: "get handle to actor",
|
|
2790
3372
|
name,
|
|
2791
3373
|
key: keyArray,
|
|
@@ -2815,7 +3397,7 @@ var ClientRaw = (_class = class {
|
|
|
2815
3397
|
*/
|
|
2816
3398
|
getOrCreate(name, key, opts) {
|
|
2817
3399
|
const keyArray = typeof key === "string" ? [key] : key || [];
|
|
2818
|
-
|
|
3400
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2819
3401
|
msg: "get or create handle to actor",
|
|
2820
3402
|
name,
|
|
2821
3403
|
key: keyArray,
|
|
@@ -2857,7 +3439,7 @@ var ClientRaw = (_class = class {
|
|
|
2857
3439
|
key: keyArray
|
|
2858
3440
|
}
|
|
2859
3441
|
};
|
|
2860
|
-
|
|
3442
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2861
3443
|
msg: "create actor handle",
|
|
2862
3444
|
name,
|
|
2863
3445
|
key: keyArray,
|
|
@@ -2865,7 +3447,7 @@ var ClientRaw = (_class = class {
|
|
|
2865
3447
|
create: createQuery.create
|
|
2866
3448
|
});
|
|
2867
3449
|
const actorId = await resolveGatewayTarget(this.#driver, createQuery);
|
|
2868
|
-
|
|
3450
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
2869
3451
|
msg: "created actor with ID",
|
|
2870
3452
|
name,
|
|
2871
3453
|
key: keyArray,
|
|
@@ -2908,11 +3490,11 @@ var ClientRaw = (_class = class {
|
|
|
2908
3490
|
*/
|
|
2909
3491
|
async dispose() {
|
|
2910
3492
|
if (this.#disposed) {
|
|
2911
|
-
|
|
3493
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({ msg: "client already disconnected" });
|
|
2912
3494
|
return;
|
|
2913
3495
|
}
|
|
2914
3496
|
this.#disposed = true;
|
|
2915
|
-
|
|
3497
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({ msg: "disposing client" });
|
|
2916
3498
|
const disposePromises = [];
|
|
2917
3499
|
for (const conn of this[ACTOR_CONNS_SYMBOL].values()) {
|
|
2918
3500
|
disposePromises.push(conn.dispose());
|
|
@@ -3064,8 +3646,11 @@ var ActorConnRaw = class {
|
|
|
3064
3646
|
this.#encoding = encoding;
|
|
3065
3647
|
this.#actorResolutionState = actorResolutionState;
|
|
3066
3648
|
this.#gatewayOptions = resolveActorGatewayOptions(gatewayOptions);
|
|
3067
|
-
|
|
3068
|
-
|
|
3649
|
+
if ("getForId" in actorResolutionState) {
|
|
3650
|
+
this.#actorId = actorResolutionState.getForId.actorId;
|
|
3651
|
+
}
|
|
3652
|
+
this.#readyPromise = _chunkK5BA2LEOcjs.promiseWithResolvers.call(void 0,
|
|
3653
|
+
(reason) => _chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3069
3654
|
msg: "unhandled ready promise rejection",
|
|
3070
3655
|
reason
|
|
3071
3656
|
})
|
|
@@ -3127,11 +3712,11 @@ var ActorConnRaw = class {
|
|
|
3127
3712
|
`Invalid action call: expected an options object { name, args }, got ${typeof opts}. Use conn.actionName(...args) for the shorthand API.`
|
|
3128
3713
|
);
|
|
3129
3714
|
}
|
|
3130
|
-
|
|
3715
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({ msg: "action", name: opts.name, args: opts.args });
|
|
3131
3716
|
const actionId = this.#actionIdCounter;
|
|
3132
3717
|
this.#actionIdCounter += 1;
|
|
3133
|
-
const { promise, resolve, reject } =
|
|
3134
|
-
(reason) =>
|
|
3718
|
+
const { promise, resolve, reject } = _chunkK5BA2LEOcjs.promiseWithResolvers.call(void 0,
|
|
3719
|
+
(reason) => _chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3135
3720
|
msg: "unhandled action promise rejection",
|
|
3136
3721
|
reason
|
|
3137
3722
|
})
|
|
@@ -3141,7 +3726,7 @@ var ActorConnRaw = class {
|
|
|
3141
3726
|
resolve,
|
|
3142
3727
|
reject
|
|
3143
3728
|
});
|
|
3144
|
-
|
|
3729
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3145
3730
|
msg: "added action to in-flight map",
|
|
3146
3731
|
actionId,
|
|
3147
3732
|
actionName: opts.name,
|
|
@@ -3181,9 +3766,9 @@ var ActorConnRaw = class {
|
|
|
3181
3766
|
try {
|
|
3182
3767
|
handler(status);
|
|
3183
3768
|
} catch (err) {
|
|
3184
|
-
|
|
3769
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3185
3770
|
msg: "error in status change handler",
|
|
3186
|
-
error:
|
|
3771
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3187
3772
|
});
|
|
3188
3773
|
}
|
|
3189
3774
|
}
|
|
@@ -3193,9 +3778,9 @@ var ActorConnRaw = class {
|
|
|
3193
3778
|
try {
|
|
3194
3779
|
handler();
|
|
3195
3780
|
} catch (err) {
|
|
3196
|
-
|
|
3781
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3197
3782
|
msg: "error in open handler",
|
|
3198
|
-
error:
|
|
3783
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3199
3784
|
});
|
|
3200
3785
|
}
|
|
3201
3786
|
}
|
|
@@ -3205,9 +3790,9 @@ var ActorConnRaw = class {
|
|
|
3205
3790
|
try {
|
|
3206
3791
|
handler();
|
|
3207
3792
|
} catch (err) {
|
|
3208
|
-
|
|
3793
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3209
3794
|
msg: "error in close handler",
|
|
3210
|
-
error:
|
|
3795
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3211
3796
|
});
|
|
3212
3797
|
}
|
|
3213
3798
|
}
|
|
@@ -3220,21 +3805,21 @@ var ActorConnRaw = class {
|
|
|
3220
3805
|
minTimeout: 250,
|
|
3221
3806
|
maxTimeout: 3e4,
|
|
3222
3807
|
onFailedAttempt: (error) => {
|
|
3223
|
-
|
|
3808
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3224
3809
|
msg: "failed to reconnect",
|
|
3225
3810
|
attempt: error.attemptNumber,
|
|
3226
|
-
error:
|
|
3811
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, error)
|
|
3227
3812
|
});
|
|
3228
3813
|
},
|
|
3229
3814
|
// Cancel retry if aborted
|
|
3230
3815
|
signal: this.#abortController.signal
|
|
3231
3816
|
}).catch((err) => {
|
|
3232
3817
|
if (err instanceof _pretry.AbortError || err.name === "AbortError" || !this.#shouldRetryConnectionOpenError(err)) {
|
|
3233
|
-
|
|
3818
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).info({ msg: "connection retry aborted" });
|
|
3234
3819
|
} else {
|
|
3235
|
-
|
|
3820
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3236
3821
|
msg: "unexpected error in connection retry",
|
|
3237
|
-
error:
|
|
3822
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3238
3823
|
});
|
|
3239
3824
|
}
|
|
3240
3825
|
});
|
|
@@ -3243,8 +3828,8 @@ var ActorConnRaw = class {
|
|
|
3243
3828
|
try {
|
|
3244
3829
|
if (this.#onOpenPromise)
|
|
3245
3830
|
throw new Error("#onOpenPromise already defined");
|
|
3246
|
-
this.#onOpenPromise =
|
|
3247
|
-
(reason) =>
|
|
3831
|
+
this.#onOpenPromise = _chunkK5BA2LEOcjs.promiseWithResolvers.call(void 0,
|
|
3832
|
+
(reason) => _chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3248
3833
|
msg: "unhandled open promise rejection",
|
|
3249
3834
|
reason
|
|
3250
3835
|
})
|
|
@@ -3255,18 +3840,18 @@ var ActorConnRaw = class {
|
|
|
3255
3840
|
if (this.#shouldRetryConnectionOpenError(error)) {
|
|
3256
3841
|
throw error;
|
|
3257
3842
|
}
|
|
3258
|
-
const actorError = error instanceof
|
|
3843
|
+
const actorError = error instanceof _chunkQAZLM4WTcjs.RivetError ? error : new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3259
3844
|
"client",
|
|
3260
3845
|
"connection_open_failed",
|
|
3261
|
-
`Failed to open connection: ${
|
|
3262
|
-
{ error:
|
|
3846
|
+
`Failed to open connection: ${_chunkK5BA2LEOcjs.stringifyError.call(void 0, error)}`,
|
|
3847
|
+
{ error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, error) }
|
|
3263
3848
|
);
|
|
3264
3849
|
this.#clearQueuedMessages();
|
|
3265
3850
|
this.#rejectPendingPromises(actorError, false);
|
|
3266
3851
|
this.#dispatchActorError(actorError);
|
|
3267
3852
|
this.#setConnStatus("idle");
|
|
3268
3853
|
throw new (0, _pretry.AbortError)(
|
|
3269
|
-
error instanceof Error ? error : new Error(
|
|
3854
|
+
error instanceof Error ? error : new Error(_chunkK5BA2LEOcjs.stringifyError.call(void 0, error))
|
|
3270
3855
|
);
|
|
3271
3856
|
} finally {
|
|
3272
3857
|
this.#onOpenPromise = void 0;
|
|
@@ -3276,17 +3861,17 @@ var ActorConnRaw = class {
|
|
|
3276
3861
|
if (error instanceof ActorConnDisposed) {
|
|
3277
3862
|
return false;
|
|
3278
3863
|
}
|
|
3279
|
-
if (error instanceof
|
|
3864
|
+
if (error instanceof _chunkQAZLM4WTcjs.RivetError && this.#shouldReconnectForStaleActor(error.group, error.code)) {
|
|
3280
3865
|
return true;
|
|
3281
3866
|
}
|
|
3282
|
-
if (error instanceof
|
|
3867
|
+
if (error instanceof _chunkQAZLM4WTcjs.RivetError && error.group === "client" && error.code === "get_params_failed") {
|
|
3283
3868
|
return true;
|
|
3284
3869
|
}
|
|
3285
3870
|
return isRetryableLifecycleReconnectSignal(error);
|
|
3286
3871
|
}
|
|
3287
3872
|
#clearQueuedMessages() {
|
|
3288
3873
|
if (this.#messageQueue.length === 0) return;
|
|
3289
|
-
|
|
3874
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3290
3875
|
msg: "clearing queued connection messages",
|
|
3291
3876
|
queueLength: this.#messageQueue.length
|
|
3292
3877
|
});
|
|
@@ -3299,8 +3884,8 @@ var ActorConnRaw = class {
|
|
|
3299
3884
|
try {
|
|
3300
3885
|
return await this.#getParams();
|
|
3301
3886
|
} catch (err) {
|
|
3302
|
-
const errorMessage =
|
|
3303
|
-
const error = new (0,
|
|
3887
|
+
const errorMessage = _chunkK5BA2LEOcjs.stringifyError.call(void 0, err);
|
|
3888
|
+
const error = new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3304
3889
|
"client",
|
|
3305
3890
|
"get_params_failed",
|
|
3306
3891
|
`Failed to resolve connection params: ${errorMessage}`,
|
|
@@ -3314,7 +3899,7 @@ var ActorConnRaw = class {
|
|
|
3314
3899
|
}
|
|
3315
3900
|
async #connectWebSocket() {
|
|
3316
3901
|
const params = await this.#resolveConnectionParams();
|
|
3317
|
-
const target =
|
|
3902
|
+
const target = getGatewayTarget(this.#actorResolutionState);
|
|
3318
3903
|
const ws = await this.#driver.openWebSocket(
|
|
3319
3904
|
PATH_CONNECT,
|
|
3320
3905
|
target,
|
|
@@ -3323,7 +3908,7 @@ var ActorConnRaw = class {
|
|
|
3323
3908
|
this.#gatewayOptions
|
|
3324
3909
|
);
|
|
3325
3910
|
_invariant2.default.call(void 0, ws, "websocket should have been created");
|
|
3326
|
-
|
|
3911
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3327
3912
|
msg: "opened websocket",
|
|
3328
3913
|
connId: this.#connId,
|
|
3329
3914
|
readyState: ws.readyState,
|
|
@@ -3331,7 +3916,7 @@ var ActorConnRaw = class {
|
|
|
3331
3916
|
});
|
|
3332
3917
|
this.#websocket = ws;
|
|
3333
3918
|
ws.addEventListener("open", () => {
|
|
3334
|
-
|
|
3919
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3335
3920
|
msg: "client websocket open",
|
|
3336
3921
|
connId: this.#connId
|
|
3337
3922
|
});
|
|
@@ -3340,9 +3925,9 @@ var ActorConnRaw = class {
|
|
|
3340
3925
|
try {
|
|
3341
3926
|
await this.#handleOnMessage(ev.data);
|
|
3342
3927
|
} catch (err) {
|
|
3343
|
-
|
|
3928
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3344
3929
|
msg: "error in websocket message handler",
|
|
3345
|
-
error:
|
|
3930
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3346
3931
|
});
|
|
3347
3932
|
}
|
|
3348
3933
|
});
|
|
@@ -3350,9 +3935,9 @@ var ActorConnRaw = class {
|
|
|
3350
3935
|
try {
|
|
3351
3936
|
await this.#handleOnClose(ev);
|
|
3352
3937
|
} catch (err) {
|
|
3353
|
-
|
|
3938
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3354
3939
|
msg: "error in websocket close handler",
|
|
3355
|
-
error:
|
|
3940
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3356
3941
|
});
|
|
3357
3942
|
}
|
|
3358
3943
|
});
|
|
@@ -3360,33 +3945,17 @@ var ActorConnRaw = class {
|
|
|
3360
3945
|
try {
|
|
3361
3946
|
this.#handleOnError();
|
|
3362
3947
|
} catch (err) {
|
|
3363
|
-
|
|
3948
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3364
3949
|
msg: "error in websocket error handler",
|
|
3365
|
-
error:
|
|
3950
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3366
3951
|
});
|
|
3367
3952
|
}
|
|
3368
3953
|
});
|
|
3369
3954
|
}
|
|
3370
|
-
async #resolveGatewayTargetForSkipReadyWait() {
|
|
3371
|
-
if ("getForId" in this.#actorResolutionState) {
|
|
3372
|
-
return {
|
|
3373
|
-
directId: this.#actorResolutionState.getForId.actorId
|
|
3374
|
-
};
|
|
3375
|
-
}
|
|
3376
|
-
if (this.#actorId) {
|
|
3377
|
-
return { directId: this.#actorId };
|
|
3378
|
-
}
|
|
3379
|
-
return {
|
|
3380
|
-
directId: await resolveGatewayTarget(
|
|
3381
|
-
this.#driver,
|
|
3382
|
-
this.#actorResolutionState
|
|
3383
|
-
)
|
|
3384
|
-
};
|
|
3385
|
-
}
|
|
3386
3955
|
/** Called by the onopen event from drivers. */
|
|
3387
3956
|
#handleOnOpen() {
|
|
3388
3957
|
if (this.#disposed) {
|
|
3389
|
-
|
|
3958
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3390
3959
|
msg: "handleOnOpen called after dispose, closing websocket"
|
|
3391
3960
|
});
|
|
3392
3961
|
if (this.#websocket) {
|
|
@@ -3402,7 +3971,7 @@ var ActorConnRaw = class {
|
|
|
3402
3971
|
queueMicrotask(() => {
|
|
3403
3972
|
this.#openScheduled = false;
|
|
3404
3973
|
if (this.#disposed) {
|
|
3405
|
-
|
|
3974
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3406
3975
|
msg: "handleOnOpen scheduled after dispose, closing websocket"
|
|
3407
3976
|
});
|
|
3408
3977
|
if (this.#websocket) {
|
|
@@ -3411,7 +3980,7 @@ var ActorConnRaw = class {
|
|
|
3411
3980
|
}
|
|
3412
3981
|
return;
|
|
3413
3982
|
}
|
|
3414
|
-
|
|
3983
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3415
3984
|
msg: "socket open",
|
|
3416
3985
|
messageQueueLength: this.#messageQueue.length,
|
|
3417
3986
|
connId: this.#connId
|
|
@@ -3420,14 +3989,14 @@ var ActorConnRaw = class {
|
|
|
3420
3989
|
if (this.#onOpenPromise) {
|
|
3421
3990
|
this.#onOpenPromise.resolve(void 0);
|
|
3422
3991
|
} else {
|
|
3423
|
-
|
|
3992
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({ msg: "#onOpenPromise is undefined" });
|
|
3424
3993
|
}
|
|
3425
3994
|
for (const eventName of this.#eventSubscriptions.keys()) {
|
|
3426
3995
|
this.#sendSubscription(eventName, true);
|
|
3427
3996
|
}
|
|
3428
3997
|
const queue = this.#messageQueue;
|
|
3429
3998
|
this.#messageQueue = [];
|
|
3430
|
-
|
|
3999
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3431
4000
|
msg: "flushing message queue",
|
|
3432
4001
|
queueLength: queue.length
|
|
3433
4002
|
});
|
|
@@ -3439,65 +4008,77 @@ var ActorConnRaw = class {
|
|
|
3439
4008
|
/** Called by the onmessage event from drivers. */
|
|
3440
4009
|
async #handleOnMessage(data) {
|
|
3441
4010
|
var _a;
|
|
3442
|
-
|
|
4011
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).trace({
|
|
3443
4012
|
msg: "received message",
|
|
3444
4013
|
dataType: typeof data,
|
|
3445
4014
|
isBlob: data instanceof Blob,
|
|
3446
4015
|
isArrayBuffer: data instanceof ArrayBuffer
|
|
3447
4016
|
});
|
|
3448
4017
|
const response = await this.#parseMessage(data);
|
|
3449
|
-
|
|
3450
|
-
|
|
4018
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).trace(
|
|
4019
|
+
_chunkK5BA2LEOcjs.getLogMessage.call(void 0, ) ? {
|
|
3451
4020
|
msg: "parsed message",
|
|
3452
|
-
message:
|
|
4021
|
+
message: _chunkLIXXFXVRcjs.jsonStringifyCompat.call(void 0, response).substring(0, 100) + "..."
|
|
3453
4022
|
} : { msg: "parsed message" }
|
|
3454
4023
|
);
|
|
3455
4024
|
if (response.body.tag === "Init") {
|
|
3456
4025
|
this.#actorId = response.body.val.actorId;
|
|
3457
4026
|
this.#connId = response.body.val.connectionId;
|
|
3458
|
-
|
|
4027
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).trace({
|
|
3459
4028
|
msg: "received init message",
|
|
3460
4029
|
actorId: this.#actorId,
|
|
3461
4030
|
connId: this.#connId
|
|
3462
4031
|
});
|
|
3463
4032
|
this.#handleOnOpen();
|
|
3464
4033
|
} else if (response.body.tag === "Error") {
|
|
3465
|
-
const { group, code, message, metadata, actionId } = response.body.val;
|
|
4034
|
+
const { group, code, message, metadata, actionId, actor } = response.body.val;
|
|
3466
4035
|
if (actionId !== null) {
|
|
3467
4036
|
const inFlight = this.#takeActionInFlight(Number(actionId));
|
|
3468
4037
|
this.#invalidateActorIfStale(group, code);
|
|
3469
|
-
|
|
4038
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3470
4039
|
msg: "action error",
|
|
3471
4040
|
actionId,
|
|
3472
4041
|
actionName: inFlight == null ? void 0 : inFlight.name,
|
|
3473
4042
|
group,
|
|
3474
4043
|
code,
|
|
3475
4044
|
message,
|
|
3476
|
-
metadata
|
|
4045
|
+
metadata,
|
|
4046
|
+
actorId: actor == null ? void 0 : actor.actorId,
|
|
4047
|
+
generation: actor == null ? void 0 : actor.generation,
|
|
4048
|
+
actorKey: actor == null ? void 0 : actor.key
|
|
3477
4049
|
});
|
|
3478
4050
|
inFlight.reject(
|
|
3479
|
-
new (0,
|
|
4051
|
+
new (0, _chunkQAZLM4WTcjs.RivetError)(group, code, message, {
|
|
4052
|
+
metadata,
|
|
4053
|
+
actor
|
|
4054
|
+
})
|
|
3480
4055
|
);
|
|
3481
4056
|
} else {
|
|
3482
|
-
|
|
4057
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3483
4058
|
msg: "connection error",
|
|
3484
4059
|
group,
|
|
3485
4060
|
code,
|
|
3486
4061
|
message,
|
|
3487
|
-
metadata
|
|
4062
|
+
metadata,
|
|
4063
|
+
actorId: actor == null ? void 0 : actor.actorId,
|
|
4064
|
+
generation: actor == null ? void 0 : actor.generation,
|
|
4065
|
+
actorKey: actor == null ? void 0 : actor.key
|
|
3488
4066
|
});
|
|
3489
4067
|
if (this.#shouldReconnectForStaleActor(group, code)) {
|
|
3490
4068
|
this.#clearResolvedActorIdentity();
|
|
3491
4069
|
(_a = this.#onOpenPromise) == null ? void 0 : _a.reject(
|
|
3492
|
-
new (0,
|
|
4070
|
+
new (0, _chunkQAZLM4WTcjs.RivetError)(group, code, message, {
|
|
4071
|
+
metadata,
|
|
4072
|
+
actor
|
|
4073
|
+
})
|
|
3493
4074
|
);
|
|
3494
4075
|
return;
|
|
3495
4076
|
}
|
|
3496
|
-
let errorToThrow = new (0,
|
|
4077
|
+
let errorToThrow = new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3497
4078
|
group,
|
|
3498
4079
|
code,
|
|
3499
4080
|
message,
|
|
3500
|
-
metadata
|
|
4081
|
+
{ metadata, actor }
|
|
3501
4082
|
);
|
|
3502
4083
|
if (isSchedulingError(group, code) && this.#actorId) {
|
|
3503
4084
|
const schedulingError = await checkForSchedulingError(
|
|
@@ -3523,27 +4104,27 @@ var ActorConnRaw = class {
|
|
|
3523
4104
|
}
|
|
3524
4105
|
} else if (response.body.tag === "ActionResponse") {
|
|
3525
4106
|
const { id: actionId } = response.body.val;
|
|
3526
|
-
|
|
4107
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3527
4108
|
msg: "received action response",
|
|
3528
4109
|
actionId: Number(actionId),
|
|
3529
4110
|
inFlightCount: this.#actionsInFlight.size,
|
|
3530
4111
|
inFlightIds: Array.from(this.#actionsInFlight.keys())
|
|
3531
4112
|
});
|
|
3532
4113
|
const inFlight = this.#takeActionInFlight(Number(actionId));
|
|
3533
|
-
|
|
4114
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).trace({
|
|
3534
4115
|
msg: "resolving action promise",
|
|
3535
4116
|
actionId,
|
|
3536
4117
|
actionName: inFlight == null ? void 0 : inFlight.name
|
|
3537
4118
|
});
|
|
3538
4119
|
inFlight.resolve(response.body.val);
|
|
3539
4120
|
} else if (response.body.tag === "Event") {
|
|
3540
|
-
|
|
4121
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).trace({
|
|
3541
4122
|
msg: "received event",
|
|
3542
4123
|
name: response.body.val.name
|
|
3543
4124
|
});
|
|
3544
4125
|
this.#dispatchEvent(response.body.val);
|
|
3545
4126
|
} else {
|
|
3546
|
-
|
|
4127
|
+
_chunkK5BA2LEOcjs.assertUnreachable.call(void 0, response.body);
|
|
3547
4128
|
}
|
|
3548
4129
|
}
|
|
3549
4130
|
/** Called by the onclose event from drivers. */
|
|
@@ -3552,7 +4133,7 @@ var ActorConnRaw = class {
|
|
|
3552
4133
|
const closeEvent = event;
|
|
3553
4134
|
const wasClean = closeEvent.wasClean;
|
|
3554
4135
|
const wasConnected = this.#connStatus === "connected";
|
|
3555
|
-
|
|
4136
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).info({
|
|
3556
4137
|
msg: "socket closed",
|
|
3557
4138
|
code: closeEvent.code,
|
|
3558
4139
|
reason: closeEvent.reason,
|
|
@@ -3573,7 +4154,7 @@ var ActorConnRaw = class {
|
|
|
3573
4154
|
if (this.#shouldReconnectForStaleActor(group, code)) {
|
|
3574
4155
|
this.#clearResolvedActorIdentity();
|
|
3575
4156
|
(_a = this.#onOpenPromise) == null ? void 0 : _a.reject(
|
|
3576
|
-
new (0,
|
|
4157
|
+
new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3577
4158
|
group,
|
|
3578
4159
|
code,
|
|
3579
4160
|
`Connection closed: ${reason}`,
|
|
@@ -3593,7 +4174,7 @@ var ActorConnRaw = class {
|
|
|
3593
4174
|
if (schedulingError) {
|
|
3594
4175
|
error = schedulingError;
|
|
3595
4176
|
} else {
|
|
3596
|
-
error = new (0,
|
|
4177
|
+
error = new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3597
4178
|
group,
|
|
3598
4179
|
code,
|
|
3599
4180
|
`Connection closed: ${reason}`,
|
|
@@ -3601,7 +4182,7 @@ var ActorConnRaw = class {
|
|
|
3601
4182
|
);
|
|
3602
4183
|
}
|
|
3603
4184
|
} else {
|
|
3604
|
-
error = new (0,
|
|
4185
|
+
error = new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3605
4186
|
group,
|
|
3606
4187
|
code,
|
|
3607
4188
|
`Connection closed: ${reason}`,
|
|
@@ -3615,11 +4196,11 @@ var ActorConnRaw = class {
|
|
|
3615
4196
|
);
|
|
3616
4197
|
}
|
|
3617
4198
|
this.#rejectPendingPromises(error, false);
|
|
3618
|
-
if (error instanceof
|
|
4199
|
+
if (error instanceof _chunkQAZLM4WTcjs.RivetError) {
|
|
3619
4200
|
this.#dispatchActorError(error);
|
|
3620
4201
|
}
|
|
3621
4202
|
if (wasConnected) {
|
|
3622
|
-
|
|
4203
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3623
4204
|
msg: "triggering reconnect",
|
|
3624
4205
|
connId: this.#connId
|
|
3625
4206
|
});
|
|
@@ -3643,12 +4224,12 @@ var ActorConnRaw = class {
|
|
|
3643
4224
|
/** Called by the onerror event from drivers. */
|
|
3644
4225
|
#handleOnError() {
|
|
3645
4226
|
if (this.#disposed) return;
|
|
3646
|
-
|
|
4227
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn("socket error");
|
|
3647
4228
|
}
|
|
3648
4229
|
#takeActionInFlight(id) {
|
|
3649
4230
|
const inFlight = this.#actionsInFlight.get(id);
|
|
3650
4231
|
if (!inFlight) {
|
|
3651
|
-
|
|
4232
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3652
4233
|
msg: "action not found in in-flight map",
|
|
3653
4234
|
lookupId: id,
|
|
3654
4235
|
inFlightCount: this.#actionsInFlight.size,
|
|
@@ -3663,7 +4244,7 @@ var ActorConnRaw = class {
|
|
|
3663
4244
|
throw internalClientError(`No in flight response for ${id}`);
|
|
3664
4245
|
}
|
|
3665
4246
|
this.#actionsInFlight.delete(id);
|
|
3666
|
-
|
|
4247
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3667
4248
|
msg: "removed action from in-flight map",
|
|
3668
4249
|
actionId: id,
|
|
3669
4250
|
actionName: inFlight.name,
|
|
@@ -3690,9 +4271,9 @@ var ActorConnRaw = class {
|
|
|
3690
4271
|
try {
|
|
3691
4272
|
handler(error);
|
|
3692
4273
|
} catch (err) {
|
|
3693
|
-
|
|
4274
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3694
4275
|
msg: "error in connection error handler",
|
|
3695
|
-
error:
|
|
4276
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3696
4277
|
});
|
|
3697
4278
|
}
|
|
3698
4279
|
}
|
|
@@ -3797,9 +4378,9 @@ var ActorConnRaw = class {
|
|
|
3797
4378
|
try {
|
|
3798
4379
|
callback();
|
|
3799
4380
|
} catch (err) {
|
|
3800
|
-
|
|
4381
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).error({
|
|
3801
4382
|
msg: "error in open handler",
|
|
3802
|
-
error:
|
|
4383
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, err)
|
|
3803
4384
|
});
|
|
3804
4385
|
}
|
|
3805
4386
|
});
|
|
@@ -3849,7 +4430,7 @@ var ActorConnRaw = class {
|
|
|
3849
4430
|
let queueMessage = false;
|
|
3850
4431
|
if (this.#websocket) {
|
|
3851
4432
|
const readyState = this.#websocket.readyState;
|
|
3852
|
-
|
|
4433
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3853
4434
|
msg: "websocket send attempt",
|
|
3854
4435
|
readyState,
|
|
3855
4436
|
readyStateString: readyState === 0 ? "CONNECTING" : readyState === 1 ? "OPEN" : readyState === 2 ? "CLOSING" : "CLOSED",
|
|
@@ -3858,7 +4439,7 @@ var ActorConnRaw = class {
|
|
|
3858
4439
|
actionName: (_a = message.body.val) == null ? void 0 : _a.name
|
|
3859
4440
|
});
|
|
3860
4441
|
if (this.#connStatus !== "connected") {
|
|
3861
|
-
|
|
4442
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3862
4443
|
msg: "websocket init pending, queueing message",
|
|
3863
4444
|
connStatus: this.#connStatus,
|
|
3864
4445
|
messageType: message.body.tag
|
|
@@ -3866,7 +4447,7 @@ var ActorConnRaw = class {
|
|
|
3866
4447
|
queueMessage = true;
|
|
3867
4448
|
} else if (readyState === 1) {
|
|
3868
4449
|
try {
|
|
3869
|
-
const messageSerialized =
|
|
4450
|
+
const messageSerialized = _chunkLIXXFXVRcjs.serializeWithEncoding.call(void 0,
|
|
3870
4451
|
this.#encoding,
|
|
3871
4452
|
message,
|
|
3872
4453
|
CLIENT_PROTOCOL_TO_SERVER,
|
|
@@ -3883,8 +4464,8 @@ var ActorConnRaw = class {
|
|
|
3883
4464
|
val: {
|
|
3884
4465
|
id: msg.body.val.id,
|
|
3885
4466
|
name: msg.body.val.name,
|
|
3886
|
-
args:
|
|
3887
|
-
|
|
4467
|
+
args: _chunkK5BA2LEOcjs.bufferToArrayBuffer.call(void 0,
|
|
4468
|
+
_chunkLIXXFXVRcjs.encodeCborCompat.call(void 0,
|
|
3888
4469
|
msg.body.val.args
|
|
3889
4470
|
)
|
|
3890
4471
|
)
|
|
@@ -3900,7 +4481,7 @@ var ActorConnRaw = class {
|
|
|
3900
4481
|
if (serializedLength > DEFAULT_MAX_INCOMING_MESSAGE_SIZE && message.body.tag === "ActionRequest") {
|
|
3901
4482
|
const actionId = Number(message.body.val.id);
|
|
3902
4483
|
const inFlight = this.#takeActionInFlight(actionId);
|
|
3903
|
-
const error = new (0,
|
|
4484
|
+
const error = new (0, _chunkQAZLM4WTcjs.RivetError)(
|
|
3904
4485
|
"message",
|
|
3905
4486
|
"incoming_too_long",
|
|
3906
4487
|
"Incoming message too long",
|
|
@@ -3909,7 +4490,7 @@ var ActorConnRaw = class {
|
|
|
3909
4490
|
actualSize: serializedLength
|
|
3910
4491
|
}
|
|
3911
4492
|
);
|
|
3912
|
-
|
|
4493
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3913
4494
|
msg: "rejecting oversized connection action request",
|
|
3914
4495
|
actionId,
|
|
3915
4496
|
actionName: inFlight.name,
|
|
@@ -3921,12 +4502,12 @@ var ActorConnRaw = class {
|
|
|
3921
4502
|
return;
|
|
3922
4503
|
}
|
|
3923
4504
|
this.#websocket.send(messageSerialized);
|
|
3924
|
-
|
|
4505
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).trace({
|
|
3925
4506
|
msg: "sent websocket message",
|
|
3926
4507
|
len: serializedLength
|
|
3927
4508
|
});
|
|
3928
4509
|
} catch (error) {
|
|
3929
|
-
|
|
4510
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
3930
4511
|
msg: "failed to send message, added to queue",
|
|
3931
4512
|
error,
|
|
3932
4513
|
connId: this.#connId
|
|
@@ -3934,19 +4515,19 @@ var ActorConnRaw = class {
|
|
|
3934
4515
|
queueMessage = true;
|
|
3935
4516
|
}
|
|
3936
4517
|
} else {
|
|
3937
|
-
|
|
4518
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3938
4519
|
msg: "websocket not open, queueing message",
|
|
3939
4520
|
readyState
|
|
3940
4521
|
});
|
|
3941
4522
|
queueMessage = true;
|
|
3942
4523
|
}
|
|
3943
4524
|
} else {
|
|
3944
|
-
|
|
4525
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({ msg: "no websocket, queueing message" });
|
|
3945
4526
|
queueMessage = true;
|
|
3946
4527
|
}
|
|
3947
4528
|
if (!(opts == null ? void 0 : opts.ephemeral) && queueMessage) {
|
|
3948
4529
|
this.#messageQueue.push(message);
|
|
3949
|
-
|
|
4530
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({
|
|
3950
4531
|
msg: "queued connection message",
|
|
3951
4532
|
queueLength: this.#messageQueue.length,
|
|
3952
4533
|
connId: this.#connId,
|
|
@@ -3957,14 +4538,32 @@ var ActorConnRaw = class {
|
|
|
3957
4538
|
}
|
|
3958
4539
|
async #parseMessage(data) {
|
|
3959
4540
|
_invariant2.default.call(void 0, this.#websocket, "websocket must be defined");
|
|
3960
|
-
const buffer = await
|
|
3961
|
-
return
|
|
4541
|
+
const buffer = await _chunkLIXXFXVRcjs.inputDataToBuffer.call(void 0, data);
|
|
4542
|
+
return _chunkLIXXFXVRcjs.deserializeWithEncoding.call(void 0,
|
|
3962
4543
|
this.#encoding,
|
|
3963
4544
|
buffer,
|
|
3964
4545
|
CLIENT_PROTOCOL_TO_CLIENT,
|
|
3965
4546
|
ToClientSchema,
|
|
3966
|
-
// JSON:
|
|
3967
|
-
(msg) =>
|
|
4547
|
+
// JSON/CBOR: normalize actor generation to the public number shape.
|
|
4548
|
+
(msg) => {
|
|
4549
|
+
if (msg.body.tag !== "Error" || !msg.body.val.actor) {
|
|
4550
|
+
return msg;
|
|
4551
|
+
}
|
|
4552
|
+
return {
|
|
4553
|
+
body: {
|
|
4554
|
+
tag: "Error",
|
|
4555
|
+
val: {
|
|
4556
|
+
...msg.body.val,
|
|
4557
|
+
actor: {
|
|
4558
|
+
...msg.body.val.actor,
|
|
4559
|
+
generation: Number(
|
|
4560
|
+
msg.body.val.actor.generation
|
|
4561
|
+
)
|
|
4562
|
+
}
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
};
|
|
4566
|
+
},
|
|
3968
4567
|
// BARE: need to decode ArrayBuffer fields back to unknown
|
|
3969
4568
|
(msg) => {
|
|
3970
4569
|
if (msg.body.tag === "Error") {
|
|
@@ -3975,12 +4574,19 @@ var ActorConnRaw = class {
|
|
|
3975
4574
|
group: msg.body.val.group,
|
|
3976
4575
|
code: msg.body.val.code,
|
|
3977
4576
|
message: msg.body.val.message,
|
|
3978
|
-
metadata: msg.body.val.metadata ?
|
|
4577
|
+
metadata: msg.body.val.metadata ? _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0,
|
|
3979
4578
|
new Uint8Array(
|
|
3980
4579
|
msg.body.val.metadata
|
|
3981
4580
|
)
|
|
3982
4581
|
) : null,
|
|
3983
|
-
actionId: msg.body.val.actionId
|
|
4582
|
+
actionId: msg.body.val.actionId,
|
|
4583
|
+
actor: msg.body.val.actor ? {
|
|
4584
|
+
actorId: msg.body.val.actor.actorId,
|
|
4585
|
+
generation: Number(
|
|
4586
|
+
msg.body.val.actor.generation
|
|
4587
|
+
),
|
|
4588
|
+
key: _nullishCoalesce(msg.body.val.actor.key, () => ( void 0))
|
|
4589
|
+
} : void 0
|
|
3984
4590
|
}
|
|
3985
4591
|
}
|
|
3986
4592
|
};
|
|
@@ -3990,7 +4596,7 @@ var ActorConnRaw = class {
|
|
|
3990
4596
|
tag: "ActionResponse",
|
|
3991
4597
|
val: {
|
|
3992
4598
|
id: msg.body.val.id,
|
|
3993
|
-
output:
|
|
4599
|
+
output: _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0,
|
|
3994
4600
|
new Uint8Array(msg.body.val.output)
|
|
3995
4601
|
)
|
|
3996
4602
|
}
|
|
@@ -4002,7 +4608,7 @@ var ActorConnRaw = class {
|
|
|
4002
4608
|
tag: "Event",
|
|
4003
4609
|
val: {
|
|
4004
4610
|
name: msg.body.val.name,
|
|
4005
|
-
args:
|
|
4611
|
+
args: _chunkLIXXFXVRcjs.decodeCborCompat.call(void 0,
|
|
4006
4612
|
new Uint8Array(msg.body.val.args)
|
|
4007
4613
|
)
|
|
4008
4614
|
}
|
|
@@ -4043,11 +4649,11 @@ var ActorConnRaw = class {
|
|
|
4043
4649
|
*/
|
|
4044
4650
|
async dispose() {
|
|
4045
4651
|
if (this.#disposed) {
|
|
4046
|
-
|
|
4652
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).warn({ msg: "connection already disconnected" });
|
|
4047
4653
|
return;
|
|
4048
4654
|
}
|
|
4049
4655
|
this.#disposed = true;
|
|
4050
|
-
|
|
4656
|
+
_chunkJALSAX7Zcjs.logger.call(void 0, ).debug({ msg: "disposing actor conn" });
|
|
4051
4657
|
this.#setConnStatus("idle");
|
|
4052
4658
|
clearInterval(this.#keepNodeAliveInterval);
|
|
4053
4659
|
this.#abortController.abort();
|
|
@@ -4055,8 +4661,8 @@ var ActorConnRaw = class {
|
|
|
4055
4661
|
if (this.#websocket) {
|
|
4056
4662
|
const ws = this.#websocket;
|
|
4057
4663
|
if (ws.readyState !== 2 && ws.readyState !== 3) {
|
|
4058
|
-
const { promise, resolve } =
|
|
4059
|
-
(reason) =>
|
|
4664
|
+
const { promise, resolve } = _chunkK5BA2LEOcjs.promiseWithResolvers.call(void 0,
|
|
4665
|
+
(reason) => _chunkJALSAX7Zcjs.logger.call(void 0, ).warn({
|
|
4060
4666
|
msg: "unhandled websocket close promise rejection",
|
|
4061
4667
|
reason
|
|
4062
4668
|
})
|
|
@@ -4175,7 +4781,7 @@ var ClientConfigSchemaBase = _v42.default.object({
|
|
|
4175
4781
|
* Defaults to http://localhost:6420.
|
|
4176
4782
|
*/
|
|
4177
4783
|
endpoint: _v42.default.string().optional().transform((val) => {
|
|
4178
|
-
const resolved = _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
4784
|
+
const resolved = _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkK5BA2LEOcjs.getRivetEngine.call(void 0, ))), () => ( _chunkK5BA2LEOcjs.getRivetEndpoint.call(void 0, )));
|
|
4179
4785
|
if (!resolved && !hasWarnedMissingEndpoint) {
|
|
4180
4786
|
hasWarnedMissingEndpoint = true;
|
|
4181
4787
|
console.warn(
|
|
@@ -4185,12 +4791,12 @@ var ClientConfigSchemaBase = _v42.default.object({
|
|
|
4185
4791
|
return _nullishCoalesce(resolved, () => ( DEFAULT_ENDPOINT));
|
|
4186
4792
|
}),
|
|
4187
4793
|
/** Token to use to authenticate with the API. */
|
|
4188
|
-
token: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
4794
|
+
token: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkK5BA2LEOcjs.getRivetToken.call(void 0, )))),
|
|
4189
4795
|
/** Namespace to connect to. */
|
|
4190
|
-
namespace: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
4796
|
+
namespace: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkK5BA2LEOcjs.getRivetNamespace.call(void 0, )))),
|
|
4191
4797
|
/** Name of the envoy pool. This is used to group together envoys in to different pools. */
|
|
4192
|
-
poolName: _v42.default.string().default(() => _nullishCoalesce(
|
|
4193
|
-
encoding:
|
|
4798
|
+
poolName: _v42.default.string().default(() => _nullishCoalesce(_chunkK5BA2LEOcjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
4799
|
+
encoding: _chunkLIXXFXVRcjs.EncodingSchema.default("bare"),
|
|
4194
4800
|
headers: _v42.default.record(_v42.default.string(), _v42.default.string()).optional().default(() => ({})),
|
|
4195
4801
|
gateway: _v42.default.object({
|
|
4196
4802
|
skipReadyWait: _v42.default.boolean().optional().default(false)
|
|
@@ -4256,7 +4862,7 @@ function convertRegistryConfigToClientConfig(config) {
|
|
|
4256
4862
|
|
|
4257
4863
|
// src/engine-client/log.ts
|
|
4258
4864
|
function logger2() {
|
|
4259
|
-
return
|
|
4865
|
+
return _chunkK5BA2LEOcjs.getLogger.call(void 0, "engine-client");
|
|
4260
4866
|
}
|
|
4261
4867
|
|
|
4262
4868
|
// src/engine-client/api-utils.ts
|
|
@@ -4265,7 +4871,7 @@ function getEndpoint(config) {
|
|
|
4265
4871
|
}
|
|
4266
4872
|
async function apiCall(config, method, path, body) {
|
|
4267
4873
|
const endpoint = getEndpoint(config);
|
|
4268
|
-
const url =
|
|
4874
|
+
const url = _chunkK5BA2LEOcjs.combineUrlPath.call(void 0, endpoint, path, {
|
|
4269
4875
|
namespace: config.namespace
|
|
4270
4876
|
});
|
|
4271
4877
|
logger2().debug({ msg: "making api call", method, url });
|
|
@@ -4590,7 +5196,7 @@ var BufferedRemoteWebSocket = (_class2 = class {
|
|
|
4590
5196
|
function buildActorGatewayUrl(endpoint, actorId, token, path = "") {
|
|
4591
5197
|
const tokenSegment = token !== void 0 ? `@${encodeURIComponent(token)}` : "";
|
|
4592
5198
|
const gatewayPath = `/gateway/${encodeURIComponent(actorId)}${tokenSegment}${path}`;
|
|
4593
|
-
return
|
|
5199
|
+
return _chunkK5BA2LEOcjs.combineUrlPath.call(void 0, endpoint, gatewayPath);
|
|
4594
5200
|
}
|
|
4595
5201
|
function buildActorQueryGatewayUrl(endpoint, namespace, query, token, path = "", maxInputSize = DEFAULT_MAX_QUERY_INPUT_SIZE, crashPolicy = void 0, runnerName, options = {}) {
|
|
4596
5202
|
if (namespace.length === 0) {
|
|
@@ -4656,7 +5262,7 @@ function buildActorQueryGatewayUrl(endpoint, namespace, query, token, path = "",
|
|
|
4656
5262
|
separator = "?";
|
|
4657
5263
|
}
|
|
4658
5264
|
const gatewayPath = `/gateway/${encodeURIComponent(name)}${path}${separator}${queryString}`;
|
|
4659
|
-
return
|
|
5265
|
+
return _chunkK5BA2LEOcjs.combineUrlPath.call(void 0, endpoint, gatewayPath);
|
|
4660
5266
|
}
|
|
4661
5267
|
function pushKeyQueryParams(params, key) {
|
|
4662
5268
|
if (key.length > 0) {
|
|
@@ -4667,7 +5273,7 @@ function pushInputQueryParam(params, input, maxInputSize) {
|
|
|
4667
5273
|
if (input === void 0) {
|
|
4668
5274
|
return;
|
|
4669
5275
|
}
|
|
4670
|
-
const encodedInput =
|
|
5276
|
+
const encodedInput = _chunkLIXXFXVRcjs.encodeCborCompat.call(void 0, input);
|
|
4671
5277
|
if (encodedInput.byteLength > maxInputSize) {
|
|
4672
5278
|
throw new Error(
|
|
4673
5279
|
`Actor query input exceeds maxInputSize (${encodedInput.byteLength} > ${maxInputSize} bytes). Increase client maxInputSize to allow larger query payloads.`
|
|
@@ -4676,10 +5282,10 @@ function pushInputQueryParam(params, input, maxInputSize) {
|
|
|
4676
5282
|
params.append("rvt-input", uint8ArrayToBase64Url(encodedInput));
|
|
4677
5283
|
}
|
|
4678
5284
|
function uint8ArrayToBase64Url(value) {
|
|
4679
|
-
return
|
|
5285
|
+
return _chunkLIXXFXVRcjs.uint8ArrayToBase64.call(void 0, value).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
4680
5286
|
}
|
|
4681
5287
|
async function openWebSocketToGateway(runConfig, gatewayUrl, encoding, params, options = {}) {
|
|
4682
|
-
const WebSocket2 = await
|
|
5288
|
+
const WebSocket2 = await _chunkJALSAX7Zcjs.importWebSocket.call(void 0, );
|
|
4683
5289
|
const ackHookToken = typeof process !== "undefined" && process.env.VITEST ? crypto.randomUUID() : void 0;
|
|
4684
5290
|
logger2().debug({
|
|
4685
5291
|
msg: "opening websocket to actor via guard",
|
|
@@ -4772,7 +5378,7 @@ async function lookupMetadataCached(config) {
|
|
|
4772
5378
|
msg: "failed to fetch metadata, retrying",
|
|
4773
5379
|
endpoint,
|
|
4774
5380
|
attempt: error.attemptNumber,
|
|
4775
|
-
error:
|
|
5381
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, error)
|
|
4776
5382
|
});
|
|
4777
5383
|
}
|
|
4778
5384
|
}
|
|
@@ -4784,7 +5390,7 @@ async function lookupMetadataCached(config) {
|
|
|
4784
5390
|
|
|
4785
5391
|
// src/engine-client/ws-proxy.ts
|
|
4786
5392
|
async function createWebSocketProxy(c, targetUrl, protocols) {
|
|
4787
|
-
const WebSocket2 = await
|
|
5393
|
+
const WebSocket2 = await _chunkJALSAX7Zcjs.importWebSocket.call(void 0, );
|
|
4788
5394
|
const state = {};
|
|
4789
5395
|
return {
|
|
4790
5396
|
onOpen: async (event, clientWs) => {
|
|
@@ -4847,7 +5453,7 @@ async function createWebSocketProxy(c, targetUrl, protocols) {
|
|
|
4847
5453
|
logger2().error({
|
|
4848
5454
|
msg: "target websocket error",
|
|
4849
5455
|
targetUrl,
|
|
4850
|
-
error:
|
|
5456
|
+
error: _chunkK5BA2LEOcjs.stringifyError.call(void 0, error)
|
|
4851
5457
|
});
|
|
4852
5458
|
closeWebSocketIfOpen(clientWs, 1011, "Target WebSocket error");
|
|
4853
5459
|
});
|
|
@@ -4926,7 +5532,7 @@ var RemoteEngineControlClient = class {
|
|
|
4926
5532
|
#config;
|
|
4927
5533
|
#metadataPromise;
|
|
4928
5534
|
constructor(runConfig) {
|
|
4929
|
-
if (
|
|
5535
|
+
if (_chunkK5BA2LEOcjs.getNextPhase.call(void 0, ) === "phase-production-build") {
|
|
4930
5536
|
logger2().info(
|
|
4931
5537
|
"detected next.js build phase, disabling health check"
|
|
4932
5538
|
);
|
|
@@ -4998,7 +5604,7 @@ var RemoteEngineControlClient = class {
|
|
|
4998
5604
|
});
|
|
4999
5605
|
return apiActorToOutput(actor);
|
|
5000
5606
|
} catch (error) {
|
|
5001
|
-
if (error instanceof
|
|
5607
|
+
if (error instanceof _chunkQAZLM4WTcjs.RivetError && error.group === "actor" && error.code === "not_found") {
|
|
5002
5608
|
return void 0;
|
|
5003
5609
|
}
|
|
5004
5610
|
throw error;
|
|
@@ -5017,7 +5623,7 @@ var RemoteEngineControlClient = class {
|
|
|
5017
5623
|
name,
|
|
5018
5624
|
key: _chunkLD5YASJUcjs.serializeActorKey.call(void 0, key),
|
|
5019
5625
|
runner_name_selector: this.#config.poolName,
|
|
5020
|
-
input: actorInput ?
|
|
5626
|
+
input: actorInput ? _chunkLIXXFXVRcjs.uint8ArrayToBase64.call(void 0, _chunkLIXXFXVRcjs.encodeCborCompat.call(void 0, actorInput)) : void 0,
|
|
5021
5627
|
crash_policy: _nullishCoalesce(crashPolicy, () => ( "sleep"))
|
|
5022
5628
|
});
|
|
5023
5629
|
logger2().info({
|
|
@@ -5043,7 +5649,7 @@ var RemoteEngineControlClient = class {
|
|
|
5043
5649
|
name,
|
|
5044
5650
|
runner_name_selector: this.#config.poolName,
|
|
5045
5651
|
key: _chunkLD5YASJUcjs.serializeActorKey.call(void 0, key),
|
|
5046
|
-
input: input ?
|
|
5652
|
+
input: input ? _chunkLIXXFXVRcjs.uint8ArrayToBase64.call(void 0, _chunkLIXXFXVRcjs.encodeCborCompat.call(void 0, input)) : void 0,
|
|
5047
5653
|
crash_policy: _nullishCoalesce(crashPolicy, () => ( "sleep"))
|
|
5048
5654
|
});
|
|
5049
5655
|
logger2().info({
|
|
@@ -5121,7 +5727,7 @@ var RemoteEngineControlClient = class {
|
|
|
5121
5727
|
const upgradeWebSocket = (_b = (_a = this.#config).getUpgradeWebSocket) == null ? void 0 : _b.call(_a);
|
|
5122
5728
|
_invariant2.default.call(void 0, upgradeWebSocket, "missing getUpgradeWebSocket");
|
|
5123
5729
|
const endpoint = getEndpoint(this.#config);
|
|
5124
|
-
const guardUrl =
|
|
5730
|
+
const guardUrl = _chunkK5BA2LEOcjs.combineUrlPath.call(void 0, endpoint, path);
|
|
5125
5731
|
const wsGuardUrl = guardUrl.replace("http://", "ws://");
|
|
5126
5732
|
logger2().debug({
|
|
5127
5733
|
msg: "forwarding websocket to actor via guard",
|
|
@@ -5140,7 +5746,7 @@ var RemoteEngineControlClient = class {
|
|
|
5140
5746
|
}
|
|
5141
5747
|
);
|
|
5142
5748
|
const args = await createWebSocketProxy(c, wsGuardUrl, protocols);
|
|
5143
|
-
return await upgradeWebSocket(() => args)(c,
|
|
5749
|
+
return await upgradeWebSocket(() => args)(c, _chunkK5BA2LEOcjs.noopNext.call(void 0, ));
|
|
5144
5750
|
}
|
|
5145
5751
|
async kvGet(actorId, key) {
|
|
5146
5752
|
await this.#metadataPromise;
|
|
@@ -5173,7 +5779,7 @@ var RemoteEngineControlClient = class {
|
|
|
5173
5779
|
#buildGatewayUrlForTarget(target, path, options = {}) {
|
|
5174
5780
|
const endpoint = getEndpoint(this.#config);
|
|
5175
5781
|
if (shouldSkipReadyWait(options) && directActorIdFromTarget(target) && canUseDirectSkipReadyWaitPath(path)) {
|
|
5176
|
-
return
|
|
5782
|
+
return _chunkK5BA2LEOcjs.combineUrlPath.call(void 0, endpoint, path);
|
|
5177
5783
|
}
|
|
5178
5784
|
if ("directId" in target) {
|
|
5179
5785
|
return buildActorGatewayUrl(
|
|
@@ -5266,9 +5872,5 @@ function apiActorToOutput(actor) {
|
|
|
5266
5872
|
|
|
5267
5873
|
|
|
5268
5874
|
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
exports.HEADER_ENCODING = HEADER_ENCODING; exports.HEADER_CONN_PARAMS = HEADER_CONN_PARAMS; exports.ALLOWED_PUBLIC_HEADERS = ALLOWED_PUBLIC_HEADERS; exports.CURRENT_VERSION = CURRENT_VERSION; exports.HTTP_RESPONSE_ERROR_VERSIONED = HTTP_RESPONSE_ERROR_VERSIONED; exports.HttpResponseErrorSchema = HttpResponseErrorSchema; exports.ActorClientError = ActorClientError; exports.ManagerError = ManagerError; exports.MalformedResponseMessage = MalformedResponseMessage; exports.ActorConnDisposed = ActorConnDisposed; exports.ActorConnRaw = ActorConnRaw; exports.ActorHandleRaw = ActorHandleRaw; exports.createClientWithDriver = createClientWithDriver; exports.tryParseEndpoint = tryParseEndpoint; exports.ClientConfigSchema = ClientConfigSchema; exports.convertRegistryConfigToClientConfig = convertRegistryConfigToClientConfig; exports.getMetadata = getMetadata; exports.getDatacenters = getDatacenters; exports.updateRunnerConfig = updateRunnerConfig; exports.RemoteEngineControlClient = RemoteEngineControlClient;
|
|
5274
|
-
//# sourceMappingURL=chunk-FTZIZ3JG.cjs.map
|
|
5875
|
+
exports.HEADER_CONN_PARAMS = HEADER_CONN_PARAMS; exports.ALLOWED_PUBLIC_HEADERS = ALLOWED_PUBLIC_HEADERS; exports.ActorClientError = ActorClientError; exports.ManagerError = ManagerError; exports.MalformedResponseMessage = MalformedResponseMessage; exports.ActorConnDisposed = ActorConnDisposed; exports.ActorConnRaw = ActorConnRaw; exports.ActorHandleRaw = ActorHandleRaw; exports.createClientWithDriver = createClientWithDriver; exports.tryParseEndpoint = tryParseEndpoint; exports.ClientConfigSchema = ClientConfigSchema; exports.convertRegistryConfigToClientConfig = convertRegistryConfigToClientConfig; exports.getMetadata = getMetadata; exports.getDatacenters = getDatacenters; exports.updateRunnerConfig = updateRunnerConfig; exports.RemoteEngineControlClient = RemoteEngineControlClient;
|
|
5876
|
+
//# sourceMappingURL=chunk-ENK7C66G.cjs.map
|