@zlink-systems/stream-connector 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.global.js +342 -124
- package/dist/browser/index.mjs +339 -121
- package/package.json +2 -2
|
@@ -675,7 +675,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
675
675
|
if (error instanceof ZlinkStreamException) {
|
|
676
676
|
return error.error;
|
|
677
677
|
}
|
|
678
|
-
return {
|
|
678
|
+
return {
|
|
679
|
+
code: "remoteError" /* RemoteError */,
|
|
680
|
+
message: error instanceof Error ? error.message : String(error),
|
|
681
|
+
cause: error
|
|
682
|
+
};
|
|
679
683
|
}
|
|
680
684
|
function subscription(dispose) {
|
|
681
685
|
return { dispose };
|
|
@@ -710,7 +714,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
710
714
|
var zlinkStreamAssert = {
|
|
711
715
|
ensure(condition, message) {
|
|
712
716
|
if (typeof message !== "string" || message.trim().length === 0) {
|
|
713
|
-
throw connectorError(
|
|
717
|
+
throw connectorError(
|
|
718
|
+
"validationFailed" /* ValidationFailed */,
|
|
719
|
+
"zlinkStreamAssert.ensure requires a non-empty diagnostic message."
|
|
720
|
+
);
|
|
714
721
|
}
|
|
715
722
|
if (!condition) {
|
|
716
723
|
throw connectorError("validationFailed" /* ValidationFailed */, message);
|
|
@@ -759,10 +766,16 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
759
766
|
throw connectorError("validationFailed" /* ValidationFailed */, "Message name must not be empty.");
|
|
760
767
|
}
|
|
761
768
|
if (!allowReserved && name.startsWith("$zlink.")) {
|
|
762
|
-
throw connectorError(
|
|
769
|
+
throw connectorError(
|
|
770
|
+
"validationFailed" /* ValidationFailed */,
|
|
771
|
+
"Message name uses a reserved zlink prefix."
|
|
772
|
+
);
|
|
763
773
|
}
|
|
764
774
|
if (utf8Encode2(name).length > 255) {
|
|
765
|
-
throw connectorError(
|
|
775
|
+
throw connectorError(
|
|
776
|
+
"validationFailed" /* ValidationFailed */,
|
|
777
|
+
"Message name must not exceed 255 UTF-8 bytes."
|
|
778
|
+
);
|
|
766
779
|
}
|
|
767
780
|
}
|
|
768
781
|
|
|
@@ -779,13 +792,19 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
779
792
|
}
|
|
780
793
|
ensureNotExecuted() {
|
|
781
794
|
if (this.executed) {
|
|
782
|
-
throw connectorError(
|
|
795
|
+
throw connectorError(
|
|
796
|
+
"validationFailed" /* ValidationFailed */,
|
|
797
|
+
"Builder instances can be executed only once."
|
|
798
|
+
);
|
|
783
799
|
}
|
|
784
800
|
this.executed = true;
|
|
785
801
|
}
|
|
786
802
|
resolveMessageName() {
|
|
787
803
|
if (this.name === void 0) {
|
|
788
|
-
throw connectorError(
|
|
804
|
+
throw connectorError(
|
|
805
|
+
"validationFailed" /* ValidationFailed */,
|
|
806
|
+
"Message name is required when the encoded stream payload has no message type."
|
|
807
|
+
);
|
|
789
808
|
}
|
|
790
809
|
return this.name;
|
|
791
810
|
}
|
|
@@ -876,10 +895,12 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
876
895
|
);
|
|
877
896
|
return;
|
|
878
897
|
}
|
|
879
|
-
return operation.then(
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
898
|
+
return operation.then(
|
|
899
|
+
(value) => {
|
|
900
|
+
var _a2;
|
|
901
|
+
return ((_a2 = this.connector.options.codec) != null ? _a2 : zlinkStreamJsonCodec).decode(value);
|
|
902
|
+
}
|
|
903
|
+
);
|
|
883
904
|
}
|
|
884
905
|
submitEncoded(signal) {
|
|
885
906
|
var _a;
|
|
@@ -917,7 +938,12 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
917
938
|
var _a;
|
|
918
939
|
this.markExecuted();
|
|
919
940
|
const timeoutMs = (_a = this.timeoutMs) != null ? _a : this.connector.options.waitTimeoutMs;
|
|
920
|
-
const message = await this.connector.waitForMessage(
|
|
941
|
+
const message = await this.connector.waitForMessage(
|
|
942
|
+
this.name,
|
|
943
|
+
timeoutMs,
|
|
944
|
+
this.predicate,
|
|
945
|
+
signal
|
|
946
|
+
);
|
|
921
947
|
if (message === void 0) {
|
|
922
948
|
throw connectorError(
|
|
923
949
|
"validationFailed" /* ValidationFailed */,
|
|
@@ -928,7 +954,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
928
954
|
}
|
|
929
955
|
ensureConfigurable() {
|
|
930
956
|
if (this.executed) {
|
|
931
|
-
throw connectorError(
|
|
957
|
+
throw connectorError(
|
|
958
|
+
"validationFailed" /* ValidationFailed */,
|
|
959
|
+
"Builder instances can be executed only once."
|
|
960
|
+
);
|
|
932
961
|
}
|
|
933
962
|
}
|
|
934
963
|
markExecuted() {
|
|
@@ -954,9 +983,17 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
954
983
|
async run(signal) {
|
|
955
984
|
this.markExecuted();
|
|
956
985
|
if (this.windowMs === void 0) {
|
|
957
|
-
throw connectorError(
|
|
986
|
+
throw connectorError(
|
|
987
|
+
"validationFailed" /* ValidationFailed */,
|
|
988
|
+
"expectNone requires within(windowMs)."
|
|
989
|
+
);
|
|
958
990
|
}
|
|
959
|
-
const message = await this.connector.waitForMessage(
|
|
991
|
+
const message = await this.connector.waitForMessage(
|
|
992
|
+
this.name,
|
|
993
|
+
this.windowMs,
|
|
994
|
+
() => true,
|
|
995
|
+
signal
|
|
996
|
+
);
|
|
960
997
|
if (message === void 0) {
|
|
961
998
|
return;
|
|
962
999
|
}
|
|
@@ -967,7 +1004,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
967
1004
|
}
|
|
968
1005
|
ensureConfigurable() {
|
|
969
1006
|
if (this.executed) {
|
|
970
|
-
throw connectorError(
|
|
1007
|
+
throw connectorError(
|
|
1008
|
+
"validationFailed" /* ValidationFailed */,
|
|
1009
|
+
"Builder instances can be executed only once."
|
|
1010
|
+
);
|
|
971
1011
|
}
|
|
972
1012
|
}
|
|
973
1013
|
markExecuted() {
|
|
@@ -1001,7 +1041,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1001
1041
|
var _a;
|
|
1002
1042
|
this.markExecuted();
|
|
1003
1043
|
if (this.predicates.length === 0) {
|
|
1004
|
-
throw connectorError(
|
|
1044
|
+
throw connectorError(
|
|
1045
|
+
"validationFailed" /* ValidationFailed */,
|
|
1046
|
+
"waitForSequence requires at least one expectation."
|
|
1047
|
+
);
|
|
1005
1048
|
}
|
|
1006
1049
|
const timeoutMs = (_a = this.timeoutMs) != null ? _a : this.connector.options.waitTimeoutMs;
|
|
1007
1050
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -1033,7 +1076,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1033
1076
|
}
|
|
1034
1077
|
ensureConfigurable() {
|
|
1035
1078
|
if (this.executed) {
|
|
1036
|
-
throw connectorError(
|
|
1079
|
+
throw connectorError(
|
|
1080
|
+
"validationFailed" /* ValidationFailed */,
|
|
1081
|
+
"Builder instances can be executed only once."
|
|
1082
|
+
);
|
|
1037
1083
|
}
|
|
1038
1084
|
}
|
|
1039
1085
|
markExecuted() {
|
|
@@ -1043,7 +1089,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1043
1089
|
};
|
|
1044
1090
|
function validateTimeout(timeoutMs) {
|
|
1045
1091
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
1046
|
-
throw connectorError(
|
|
1092
|
+
throw connectorError(
|
|
1093
|
+
"validationFailed" /* ValidationFailed */,
|
|
1094
|
+
"Timeout must be a non-negative finite number."
|
|
1095
|
+
);
|
|
1047
1096
|
}
|
|
1048
1097
|
}
|
|
1049
1098
|
|
|
@@ -1059,7 +1108,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1059
1108
|
function compressPayload(payload, compression, compressionCodec) {
|
|
1060
1109
|
const codec = resolveCompressionCodec(compression, compressionCodec);
|
|
1061
1110
|
if (codec === void 0) {
|
|
1062
|
-
throw connectorError(
|
|
1111
|
+
throw connectorError(
|
|
1112
|
+
"compressionFailed" /* CompressionFailed */,
|
|
1113
|
+
"Compression codec is not configured."
|
|
1114
|
+
);
|
|
1063
1115
|
}
|
|
1064
1116
|
return codec.compress(payload);
|
|
1065
1117
|
}
|
|
@@ -1069,7 +1121,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1069
1121
|
}
|
|
1070
1122
|
const codec = resolveCompressionCodec(compression, compressionCodec);
|
|
1071
1123
|
if (codec === void 0) {
|
|
1072
|
-
throw connectorError(
|
|
1124
|
+
throw connectorError(
|
|
1125
|
+
"decompressionFailed" /* DecompressionFailed */,
|
|
1126
|
+
"Compression codec is not configured."
|
|
1127
|
+
);
|
|
1073
1128
|
}
|
|
1074
1129
|
try {
|
|
1075
1130
|
const decompressed = codec.decompress(payload, maxDecompressedSize);
|
|
@@ -1102,26 +1157,39 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1102
1157
|
try {
|
|
1103
1158
|
return decodeStreamWireFrame(frame);
|
|
1104
1159
|
} catch (cause) {
|
|
1105
|
-
throw connectorError(
|
|
1160
|
+
throw connectorError(
|
|
1161
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1162
|
+
"Frame length does not match prefix.",
|
|
1163
|
+
cause
|
|
1164
|
+
);
|
|
1106
1165
|
}
|
|
1107
1166
|
}
|
|
1108
1167
|
};
|
|
1109
1168
|
function splitZlinkStreamFrames(chunk) {
|
|
1110
1169
|
if (chunk.length === 0) {
|
|
1111
|
-
throw connectorError(
|
|
1170
|
+
throw connectorError(
|
|
1171
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1172
|
+
"Stream frame prefix is incomplete."
|
|
1173
|
+
);
|
|
1112
1174
|
}
|
|
1113
1175
|
const frames = [];
|
|
1114
1176
|
let offset = 0;
|
|
1115
1177
|
while (offset < chunk.length) {
|
|
1116
1178
|
const remaining = chunk.length - offset;
|
|
1117
1179
|
if (remaining < 6) {
|
|
1118
|
-
throw connectorError(
|
|
1180
|
+
throw connectorError(
|
|
1181
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1182
|
+
"Stream frame prefix is incomplete."
|
|
1183
|
+
);
|
|
1119
1184
|
}
|
|
1120
1185
|
const headerLength = chunk[offset] << 8 | chunk[offset + 1];
|
|
1121
1186
|
const payloadLength = chunk[offset + 2] * 16777216 + (chunk[offset + 3] << 16) + (chunk[offset + 4] << 8) + chunk[offset + 5];
|
|
1122
1187
|
const frameLength = 6 + headerLength + payloadLength;
|
|
1123
1188
|
if (frameLength > remaining) {
|
|
1124
|
-
throw connectorError(
|
|
1189
|
+
throw connectorError(
|
|
1190
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1191
|
+
"Frame length does not match prefix."
|
|
1192
|
+
);
|
|
1125
1193
|
}
|
|
1126
1194
|
frames.push(chunk.subarray(offset, offset + frameLength));
|
|
1127
1195
|
offset += frameLength;
|
|
@@ -1130,7 +1198,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1130
1198
|
}
|
|
1131
1199
|
function validatePayload(payloadLength, maxPayloadSize) {
|
|
1132
1200
|
if (payloadLength > maxPayloadSize) {
|
|
1133
|
-
throw connectorError(
|
|
1201
|
+
throw connectorError(
|
|
1202
|
+
"validationFailed" /* ValidationFailed */,
|
|
1203
|
+
"Payload exceeds MaxSendPayloadSize."
|
|
1204
|
+
);
|
|
1134
1205
|
}
|
|
1135
1206
|
}
|
|
1136
1207
|
|
|
@@ -1148,14 +1219,22 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1148
1219
|
}
|
|
1149
1220
|
return size;
|
|
1150
1221
|
} catch (cause) {
|
|
1151
|
-
throw connectorError(
|
|
1222
|
+
throw connectorError(
|
|
1223
|
+
"validationFailed" /* ValidationFailed */,
|
|
1224
|
+
streamWireErrorMessage(cause),
|
|
1225
|
+
cause
|
|
1226
|
+
);
|
|
1152
1227
|
}
|
|
1153
1228
|
}
|
|
1154
1229
|
static write(metadata, destination) {
|
|
1155
1230
|
try {
|
|
1156
1231
|
destination.set(encodeStreamWireMetadata(metadata.values));
|
|
1157
1232
|
} catch (cause) {
|
|
1158
|
-
throw connectorError(
|
|
1233
|
+
throw connectorError(
|
|
1234
|
+
"validationFailed" /* ValidationFailed */,
|
|
1235
|
+
streamWireErrorMessage(cause),
|
|
1236
|
+
cause
|
|
1237
|
+
);
|
|
1159
1238
|
}
|
|
1160
1239
|
}
|
|
1161
1240
|
static decode(metadata) {
|
|
@@ -1163,7 +1242,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1163
1242
|
const values = decodeStreamWireMetadata(metadata);
|
|
1164
1243
|
return values.size === 0 ? ZlinkStreamMetadataMap.empty : ZlinkStreamMetadataMap.from(values);
|
|
1165
1244
|
} catch (cause) {
|
|
1166
|
-
throw connectorError(
|
|
1245
|
+
throw connectorError(
|
|
1246
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1247
|
+
streamWireErrorMessage(cause),
|
|
1248
|
+
cause
|
|
1249
|
+
);
|
|
1167
1250
|
}
|
|
1168
1251
|
}
|
|
1169
1252
|
};
|
|
@@ -1191,7 +1274,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1191
1274
|
flowOrigin: encodeFlowOrigin(header.flowOrigin)
|
|
1192
1275
|
});
|
|
1193
1276
|
} catch (cause) {
|
|
1194
|
-
throw connectorError(
|
|
1277
|
+
throw connectorError(
|
|
1278
|
+
"validationFailed" /* ValidationFailed */,
|
|
1279
|
+
streamWireErrorMessage2(cause),
|
|
1280
|
+
cause
|
|
1281
|
+
);
|
|
1195
1282
|
}
|
|
1196
1283
|
}
|
|
1197
1284
|
/**
|
|
@@ -1216,7 +1303,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1216
1303
|
flowOrigin: decodeFlowOrigin(wire.flowOrigin)
|
|
1217
1304
|
};
|
|
1218
1305
|
} catch (cause) {
|
|
1219
|
-
throw connectorError(
|
|
1306
|
+
throw connectorError(
|
|
1307
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1308
|
+
streamWireErrorMessage2(cause),
|
|
1309
|
+
cause
|
|
1310
|
+
);
|
|
1220
1311
|
}
|
|
1221
1312
|
validateEnum(decoded.kind, decoded.codec, decoded.flags);
|
|
1222
1313
|
if (!isReplyKind2(decoded.kind)) {
|
|
@@ -1254,19 +1345,31 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1254
1345
|
const hasRequestSeq = header.requestSeq !== void 0 || (header.flags & 1 /* HasRequestSeq */) !== 0;
|
|
1255
1346
|
const hasMetadata = header.metadata.count > 0 || (header.flags & 2 /* HasMetadata */) !== 0;
|
|
1256
1347
|
if (header.kind === 1 /* Send */ && hasRequestSeq) {
|
|
1257
|
-
throw connectorError(
|
|
1348
|
+
throw connectorError(
|
|
1349
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1350
|
+
"Send packet must not contain a request sequence."
|
|
1351
|
+
);
|
|
1258
1352
|
}
|
|
1259
1353
|
if ((header.kind === 2 /* Request */ || header.kind === 3 /* Response */) && !hasRequestSeq) {
|
|
1260
|
-
throw connectorError(
|
|
1354
|
+
throw connectorError(
|
|
1355
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1356
|
+
"Request and response packets must contain a request sequence."
|
|
1357
|
+
);
|
|
1261
1358
|
}
|
|
1262
1359
|
if (header.kind === 4 /* Error */ && header.codec !== 1 /* Json */) {
|
|
1263
|
-
throw connectorError(
|
|
1360
|
+
throw connectorError(
|
|
1361
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1362
|
+
"Error packet must use the JSON codec."
|
|
1363
|
+
);
|
|
1264
1364
|
}
|
|
1265
1365
|
if (header.kind === 5 /* Control */) {
|
|
1266
1366
|
const hasCorrelation = header.correlationId !== void 0 && header.correlationId.length > 0 || (header.flags & 8 /* HasCorrelationId */) !== 0;
|
|
1267
1367
|
const hasFlow = header.flowId !== void 0 || header.flowOrigin !== void 0 || (header.flags & 16 /* HasFlowId */) !== 0;
|
|
1268
1368
|
if (header.flags !== 0 /* None */ || hasRequestSeq || hasMetadata || hasCorrelation || hasFlow || header.codec !== 0 /* Raw */) {
|
|
1269
|
-
throw connectorError(
|
|
1369
|
+
throw connectorError(
|
|
1370
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
1371
|
+
"Control packet must use raw codec and must not contain flags."
|
|
1372
|
+
);
|
|
1270
1373
|
}
|
|
1271
1374
|
}
|
|
1272
1375
|
}
|
|
@@ -1298,17 +1401,30 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1298
1401
|
}
|
|
1299
1402
|
encode(kind, name, payload, metadata, compress, requestSeq, correlationId, flowId, flowOrigin) {
|
|
1300
1403
|
const payloadBytes = compress ? compressPayload(payload.payload, this.options.compression, this.options.compressionCodec) : payload.payload;
|
|
1301
|
-
const header = buildHeader(
|
|
1404
|
+
const header = buildHeader(
|
|
1405
|
+
kind,
|
|
1406
|
+
name,
|
|
1407
|
+
payload.codec,
|
|
1408
|
+
metadata,
|
|
1409
|
+
compress,
|
|
1410
|
+
requestSeq,
|
|
1411
|
+
correlationId,
|
|
1412
|
+
flowId,
|
|
1413
|
+
flowOrigin
|
|
1414
|
+
);
|
|
1302
1415
|
return this.encodeFrame(header, payloadBytes);
|
|
1303
1416
|
}
|
|
1304
1417
|
encodeControl(name, payload = new Uint8Array()) {
|
|
1305
|
-
return this.encodeFrame(
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1418
|
+
return this.encodeFrame(
|
|
1419
|
+
{
|
|
1420
|
+
kind: 5 /* Control */,
|
|
1421
|
+
codec: 0 /* Raw */,
|
|
1422
|
+
flags: 0 /* None */,
|
|
1423
|
+
name,
|
|
1424
|
+
metadata: ZlinkStreamMetadataMap.empty
|
|
1425
|
+
},
|
|
1426
|
+
payload
|
|
1427
|
+
);
|
|
1312
1428
|
}
|
|
1313
1429
|
decode(frameBytes, flowEnabled = this.flowEnabled()) {
|
|
1314
1430
|
const frame = ZlinkStreamFrameCodec.decode(frameBytes);
|
|
@@ -1326,7 +1442,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1326
1442
|
return splitZlinkStreamFrames(chunk).map((frame) => {
|
|
1327
1443
|
const decoded = this.decode(frame, flowEnabled);
|
|
1328
1444
|
if (decoded.payload.length > this.options.maxReceivePayloadSize) {
|
|
1329
|
-
throw connectorError(
|
|
1445
|
+
throw connectorError(
|
|
1446
|
+
"frameTooLarge" /* FrameTooLarge */,
|
|
1447
|
+
"Payload exceeds MaxReceivePayloadSize."
|
|
1448
|
+
);
|
|
1330
1449
|
}
|
|
1331
1450
|
return decoded;
|
|
1332
1451
|
});
|
|
@@ -1387,7 +1506,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1387
1506
|
}
|
|
1388
1507
|
const inferredTransport = inferTransport(endpoint);
|
|
1389
1508
|
if (options.transport !== void 0 && options.transport !== inferredTransport) {
|
|
1390
|
-
throw connectorError(
|
|
1509
|
+
throw connectorError(
|
|
1510
|
+
"configurationError" /* ConfigurationError */,
|
|
1511
|
+
"Configured transport conflicts with endpoint scheme."
|
|
1512
|
+
);
|
|
1391
1513
|
}
|
|
1392
1514
|
validatePositive((_a = options.connectTimeoutMs) != null ? _a : 5e3, "ConnectTimeout");
|
|
1393
1515
|
validatePositive((_b = options.requestTimeoutMs) != null ? _b : 3e4, "RequestTimeout");
|
|
@@ -1442,7 +1564,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1442
1564
|
const compression = (_a = options.compression) != null ? _a : "lz4" /* Lz4 */;
|
|
1443
1565
|
if (compression === "none" /* None */) {
|
|
1444
1566
|
if (options.compressionCodec !== void 0) {
|
|
1445
|
-
throw connectorError(
|
|
1567
|
+
throw connectorError(
|
|
1568
|
+
"configurationError" /* ConfigurationError */,
|
|
1569
|
+
"compressionCodec cannot be set when compression is none."
|
|
1570
|
+
);
|
|
1446
1571
|
}
|
|
1447
1572
|
return void 0;
|
|
1448
1573
|
}
|
|
@@ -1469,7 +1594,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1469
1594
|
validatePositive(intervalMs, "Heartbeat interval");
|
|
1470
1595
|
validatePositive(timeoutMs, "Heartbeat timeout");
|
|
1471
1596
|
if (timeoutMs <= intervalMs) {
|
|
1472
|
-
throw connectorError(
|
|
1597
|
+
throw connectorError(
|
|
1598
|
+
"validationFailed" /* ValidationFailed */,
|
|
1599
|
+
"Heartbeat timeout must be greater than the heartbeat interval."
|
|
1600
|
+
);
|
|
1473
1601
|
}
|
|
1474
1602
|
}
|
|
1475
1603
|
function validateReconnect(options) {
|
|
@@ -1481,11 +1609,17 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1481
1609
|
validatePositive((_b = options == null ? void 0 : options.initialDelayMs) != null ? _b : 250, "Reconnect InitialDelay");
|
|
1482
1610
|
validatePositive((_c = options == null ? void 0 : options.maxDelayMs) != null ? _c : 5e3, "Reconnect MaxDelay");
|
|
1483
1611
|
if (((_d = options == null ? void 0 : options.backoffFactor) != null ? _d : 2) < 1) {
|
|
1484
|
-
throw connectorError(
|
|
1612
|
+
throw connectorError(
|
|
1613
|
+
"validationFailed" /* ValidationFailed */,
|
|
1614
|
+
"Reconnect BackoffFactor must be at least 1.0."
|
|
1615
|
+
);
|
|
1485
1616
|
}
|
|
1486
1617
|
const maxAttempts = (options == null ? void 0 : options.maxAttempts) === void 0 ? 3 : options.maxAttempts;
|
|
1487
1618
|
if (maxAttempts !== null && !(Number.isFinite(maxAttempts) && maxAttempts > 0)) {
|
|
1488
|
-
throw connectorError(
|
|
1619
|
+
throw connectorError(
|
|
1620
|
+
"validationFailed" /* ValidationFailed */,
|
|
1621
|
+
"Reconnect MaxAttempts must be null or positive."
|
|
1622
|
+
);
|
|
1489
1623
|
}
|
|
1490
1624
|
}
|
|
1491
1625
|
|
|
@@ -1525,7 +1659,9 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1525
1659
|
const promise = new Promise((resolve, reject) => {
|
|
1526
1660
|
timeout = setTimeout(() => {
|
|
1527
1661
|
this.active.delete(requestSeq);
|
|
1528
|
-
reject(
|
|
1662
|
+
reject(
|
|
1663
|
+
connectorError("requestTimeout" /* RequestTimeout */, `Request '${packetName}' timed out.`)
|
|
1664
|
+
);
|
|
1529
1665
|
}, timeoutMs);
|
|
1530
1666
|
resolvePending = resolve;
|
|
1531
1667
|
rejectPending = (error) => reject(connectorError(error.code, error.message, error.cause));
|
|
@@ -1792,11 +1928,14 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1792
1928
|
try {
|
|
1793
1929
|
await handler(message, signal);
|
|
1794
1930
|
} catch (cause) {
|
|
1795
|
-
await this.events.publishError(
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1931
|
+
await this.events.publishError(
|
|
1932
|
+
{
|
|
1933
|
+
code: "userCallbackFailed" /* UserCallbackFailed */,
|
|
1934
|
+
message: "Typed message handler failed.",
|
|
1935
|
+
cause
|
|
1936
|
+
},
|
|
1937
|
+
signal
|
|
1938
|
+
);
|
|
1800
1939
|
}
|
|
1801
1940
|
}
|
|
1802
1941
|
}
|
|
@@ -1857,7 +1996,17 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1857
1996
|
const flow = this.protocol.flowEnabled() ? this.flowContext.currentOrCreate(explicitFlow) : void 0;
|
|
1858
1997
|
await this.write(
|
|
1859
1998
|
connection,
|
|
1860
|
-
this.protocol.encode(
|
|
1999
|
+
this.protocol.encode(
|
|
2000
|
+
kind,
|
|
2001
|
+
name,
|
|
2002
|
+
payload,
|
|
2003
|
+
metadata,
|
|
2004
|
+
compress,
|
|
2005
|
+
requestSeq,
|
|
2006
|
+
correlationId,
|
|
2007
|
+
flow == null ? void 0 : flow.flowId,
|
|
2008
|
+
flow == null ? void 0 : flow.flowOrigin
|
|
2009
|
+
),
|
|
1861
2010
|
signal
|
|
1862
2011
|
);
|
|
1863
2012
|
}
|
|
@@ -1892,11 +2041,13 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1892
2041
|
6: "TransportError"
|
|
1893
2042
|
};
|
|
1894
2043
|
function decodeSessionClosing(payload) {
|
|
1895
|
-
if (payload.length < 4 || payload[0] !== 1)
|
|
2044
|
+
if (payload.length < 4 || payload[0] !== 1)
|
|
2045
|
+
throw new Error("Unsupported session-closing version.");
|
|
1896
2046
|
const closeReason = reasons[payload[1]];
|
|
1897
2047
|
if (closeReason === void 0) throw new Error("Unknown session-closing reason.");
|
|
1898
2048
|
const length = payload[2] << 8 | payload[3];
|
|
1899
|
-
if (length > 512 || payload.length !== 4 + length)
|
|
2049
|
+
if (length > 512 || payload.length !== 4 + length)
|
|
2050
|
+
throw new Error("Invalid session-closing diagnostic length.");
|
|
1900
2051
|
const diagnostic = length === 0 ? void 0 : new TextDecoder("utf-8", { fatal: true }).decode(payload.subarray(4));
|
|
1901
2052
|
return { closeReason, diagnostic };
|
|
1902
2053
|
}
|
|
@@ -1952,7 +2103,14 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1952
2103
|
break;
|
|
1953
2104
|
}
|
|
1954
2105
|
try {
|
|
1955
|
-
await this.dispatch(
|
|
2106
|
+
await this.dispatch(
|
|
2107
|
+
connection,
|
|
2108
|
+
frame.header,
|
|
2109
|
+
frame.payload,
|
|
2110
|
+
signal,
|
|
2111
|
+
flowEnabled,
|
|
2112
|
+
connectionForSend
|
|
2113
|
+
);
|
|
1956
2114
|
} catch (cause) {
|
|
1957
2115
|
if (frame.header.kind === 5 /* Control */ && frame.header.name === ZLINK_STREAM_HEARTBEAT_PING) {
|
|
1958
2116
|
throw cause;
|
|
@@ -1972,10 +2130,13 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1972
2130
|
codec: header.codec,
|
|
1973
2131
|
payload: this.protocol.decodePayload(header, payload)
|
|
1974
2132
|
})) {
|
|
1975
|
-
await this.events.publishError(
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2133
|
+
await this.events.publishError(
|
|
2134
|
+
{
|
|
2135
|
+
code: "frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2136
|
+
message: `Response request sequence '${header.requestSeq}' has no pending request.`
|
|
2137
|
+
},
|
|
2138
|
+
signal
|
|
2139
|
+
);
|
|
1979
2140
|
}
|
|
1980
2141
|
} catch (cause) {
|
|
1981
2142
|
const decodeError = toStreamError(
|
|
@@ -1983,10 +2144,7 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1983
2144
|
"decompressionFailed" /* DecompressionFailed */,
|
|
1984
2145
|
"Decompression failed."
|
|
1985
2146
|
);
|
|
1986
|
-
if (!this.pendingRequests.reject(
|
|
1987
|
-
header.requestSeq,
|
|
1988
|
-
decodeError
|
|
1989
|
-
)) {
|
|
2147
|
+
if (!this.pendingRequests.reject(header.requestSeq, decodeError)) {
|
|
1990
2148
|
await this.events.publishError(decodeError, signal);
|
|
1991
2149
|
}
|
|
1992
2150
|
}
|
|
@@ -2004,10 +2162,7 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2004
2162
|
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2005
2163
|
"Remote error payload is invalid."
|
|
2006
2164
|
);
|
|
2007
|
-
if (!this.pendingRequests.reject(
|
|
2008
|
-
header.requestSeq,
|
|
2009
|
-
decodeError
|
|
2010
|
-
)) {
|
|
2165
|
+
if (!this.pendingRequests.reject(header.requestSeq, decodeError)) {
|
|
2011
2166
|
await this.events.publishError(decodeError, signal);
|
|
2012
2167
|
}
|
|
2013
2168
|
}
|
|
@@ -2023,13 +2178,16 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2023
2178
|
}
|
|
2024
2179
|
if (header.kind === 1 /* Send */) {
|
|
2025
2180
|
const flow = flowEnabled ? this.flowContext.createInbound(header.flowId, header.flowOrigin) : void 0;
|
|
2026
|
-
this.receivedMessages.enqueue(
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2181
|
+
this.receivedMessages.enqueue(
|
|
2182
|
+
{
|
|
2183
|
+
name: header.name,
|
|
2184
|
+
metadata: header.metadata,
|
|
2185
|
+
payload: { codec: header.codec, payload: this.protocol.decodePayload(header, payload) },
|
|
2186
|
+
flowId: flow == null ? void 0 : flow.flowId,
|
|
2187
|
+
flowOrigin: flow == null ? void 0 : flow.flowOrigin
|
|
2188
|
+
},
|
|
2189
|
+
signal
|
|
2190
|
+
);
|
|
2033
2191
|
}
|
|
2034
2192
|
}
|
|
2035
2193
|
async dispatchControl(connection, header, payload, signal, connectionForSend) {
|
|
@@ -2040,7 +2198,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2040
2198
|
return;
|
|
2041
2199
|
}
|
|
2042
2200
|
if (payload.length !== 0) {
|
|
2043
|
-
throw connectorError(
|
|
2201
|
+
throw connectorError(
|
|
2202
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2203
|
+
"Control packet payload must be empty."
|
|
2204
|
+
);
|
|
2044
2205
|
}
|
|
2045
2206
|
if (header.name === ZLINK_STREAM_HEARTBEAT_PING) {
|
|
2046
2207
|
try {
|
|
@@ -2068,7 +2229,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2068
2229
|
try {
|
|
2069
2230
|
decoded = JSON.parse(utf8Decode2(decodedPayload));
|
|
2070
2231
|
} catch (cause) {
|
|
2071
|
-
throw connectorError(
|
|
2232
|
+
throw connectorError(
|
|
2233
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2234
|
+
"Remote error payload must be a JSON object.",
|
|
2235
|
+
cause
|
|
2236
|
+
);
|
|
2072
2237
|
}
|
|
2073
2238
|
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded) || typeof decoded.code !== "string" || typeof decoded.message !== "string") {
|
|
2074
2239
|
throw connectorError(
|
|
@@ -2149,7 +2314,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2149
2314
|
this.lateConnectCleanupError = error;
|
|
2150
2315
|
throw error;
|
|
2151
2316
|
}
|
|
2152
|
-
throw connectorError(
|
|
2317
|
+
throw connectorError(
|
|
2318
|
+
"disconnected" /* Disconnected */,
|
|
2319
|
+
"Connector closed while connecting."
|
|
2320
|
+
);
|
|
2153
2321
|
}
|
|
2154
2322
|
this.currentConnection = connection;
|
|
2155
2323
|
this.connectionGeneration += 1;
|
|
@@ -2188,8 +2356,15 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2188
2356
|
}
|
|
2189
2357
|
async serverClosing(reason) {
|
|
2190
2358
|
this.closeReasonValue = reason;
|
|
2191
|
-
const error = {
|
|
2192
|
-
|
|
2359
|
+
const error = {
|
|
2360
|
+
code: "disconnected" /* Disconnected */,
|
|
2361
|
+
message: `Server closed the session: ${reason}.`
|
|
2362
|
+
};
|
|
2363
|
+
await this.disconnectForTransportFailure(
|
|
2364
|
+
error,
|
|
2365
|
+
this.currentConnection,
|
|
2366
|
+
this.connectionGeneration
|
|
2367
|
+
);
|
|
2193
2368
|
}
|
|
2194
2369
|
async closeOnce(signal) {
|
|
2195
2370
|
var _a, _b;
|
|
@@ -2214,7 +2389,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2214
2389
|
} catch (error) {
|
|
2215
2390
|
errors.push(error);
|
|
2216
2391
|
}
|
|
2217
|
-
this.pendingRequests.failAll({
|
|
2392
|
+
this.pendingRequests.failAll({
|
|
2393
|
+
code: "disconnected" /* Disconnected */,
|
|
2394
|
+
message: "Connector closed."
|
|
2395
|
+
});
|
|
2218
2396
|
this.receivedMessages.connectionEnded();
|
|
2219
2397
|
void this.setState("closed" /* Closed */, void 0, signal);
|
|
2220
2398
|
this.publishDisconnectedWithoutWaiting(signal);
|
|
@@ -2341,7 +2519,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2341
2519
|
}
|
|
2342
2520
|
} catch (cause) {
|
|
2343
2521
|
if (signal.aborted) return;
|
|
2344
|
-
const error = toStreamError(
|
|
2522
|
+
const error = toStreamError(
|
|
2523
|
+
cause,
|
|
2524
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2525
|
+
"Receive loop failed."
|
|
2526
|
+
);
|
|
2345
2527
|
await this.disconnectForTransportFailure(error, connection, generation);
|
|
2346
2528
|
} finally {
|
|
2347
2529
|
this.receiveLoopSleeping = false;
|
|
@@ -2401,7 +2583,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2401
2583
|
if (Date.now() - this.lastInboundAt > this.options.heartbeat.timeoutMs) {
|
|
2402
2584
|
this.closeReasonValue = "HeartbeatTimeout";
|
|
2403
2585
|
const error = { code: "disconnected" /* Disconnected */, message: "Heartbeat timed out." };
|
|
2404
|
-
await this.disconnectForTransportFailure(
|
|
2586
|
+
await this.disconnectForTransportFailure(
|
|
2587
|
+
error,
|
|
2588
|
+
this.currentConnection,
|
|
2589
|
+
this.connectionGeneration
|
|
2590
|
+
);
|
|
2405
2591
|
return;
|
|
2406
2592
|
}
|
|
2407
2593
|
const connection = this.currentConnection;
|
|
@@ -2615,7 +2801,11 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2615
2801
|
const message = toUint8Array(event.data);
|
|
2616
2802
|
this.messages.push(message);
|
|
2617
2803
|
} catch (cause) {
|
|
2618
|
-
this.error = cause instanceof Error ? cause : connectorError(
|
|
2804
|
+
this.error = cause instanceof Error ? cause : connectorError(
|
|
2805
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2806
|
+
"WebSocket message decode failed.",
|
|
2807
|
+
cause
|
|
2808
|
+
);
|
|
2619
2809
|
this.closed = true;
|
|
2620
2810
|
this.socket.close();
|
|
2621
2811
|
}
|
|
@@ -2623,13 +2813,19 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2623
2813
|
});
|
|
2624
2814
|
__publicField(this, "onClose", () => {
|
|
2625
2815
|
if (!this.closed) {
|
|
2626
|
-
this.error = connectorError(
|
|
2816
|
+
this.error = connectorError(
|
|
2817
|
+
"disconnected" /* Disconnected */,
|
|
2818
|
+
"Remote stream closed the WebSocket connection."
|
|
2819
|
+
);
|
|
2627
2820
|
}
|
|
2628
2821
|
this.closed = true;
|
|
2629
2822
|
this.wakeReader();
|
|
2630
2823
|
});
|
|
2631
2824
|
__publicField(this, "onError", () => {
|
|
2632
|
-
this.error = connectorError(
|
|
2825
|
+
this.error = connectorError(
|
|
2826
|
+
"disconnected" /* Disconnected */,
|
|
2827
|
+
"Remote stream closed after a WebSocket error."
|
|
2828
|
+
);
|
|
2633
2829
|
this.closed = true;
|
|
2634
2830
|
this.wakeReader();
|
|
2635
2831
|
});
|
|
@@ -2679,7 +2875,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2679
2875
|
}
|
|
2680
2876
|
waitForMessage(signal) {
|
|
2681
2877
|
if (this.readWaiter !== void 0) {
|
|
2682
|
-
throw connectorError(
|
|
2878
|
+
throw connectorError(
|
|
2879
|
+
"validationFailed" /* ValidationFailed */,
|
|
2880
|
+
"Only one pending stream read is supported."
|
|
2881
|
+
);
|
|
2683
2882
|
}
|
|
2684
2883
|
return new Promise((resolve, reject) => {
|
|
2685
2884
|
const onAbort = () => {
|
|
@@ -2736,9 +2935,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2736
2935
|
async function waitForOpen(socket, connectTimeoutMs, signal) {
|
|
2737
2936
|
throwIfAborted(signal);
|
|
2738
2937
|
await new Promise((resolve, reject) => {
|
|
2739
|
-
const timeout = setTimeout(
|
|
2740
|
-
connectorError("connectTimeout" /* ConnectTimeout */, "Connect timed out.")
|
|
2741
|
-
|
|
2938
|
+
const timeout = setTimeout(
|
|
2939
|
+
() => finish(connectorError("connectTimeout" /* ConnectTimeout */, "Connect timed out.")),
|
|
2940
|
+
connectTimeoutMs
|
|
2941
|
+
);
|
|
2742
2942
|
const onOpen = () => finish();
|
|
2743
2943
|
const onClose = () => finish(connectorError("connectTimeout" /* ConnectTimeout */, "Connect closed before opening."));
|
|
2744
2944
|
const onError = () => finish(connectorError("connectTimeout" /* ConnectTimeout */, "Connect failed."));
|
|
@@ -2769,7 +2969,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2769
2969
|
if (ArrayBuffer.isView(data)) {
|
|
2770
2970
|
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
2771
2971
|
}
|
|
2772
|
-
throw connectorError(
|
|
2972
|
+
throw connectorError(
|
|
2973
|
+
"frameDecodeFailed" /* FrameDecodeFailed */,
|
|
2974
|
+
"WebSocket text messages are not supported."
|
|
2975
|
+
);
|
|
2773
2976
|
}
|
|
2774
2977
|
|
|
2775
2978
|
// packages/stream-connector/src/Runtime/ZlinkStreamConnector.ts
|
|
@@ -2897,13 +3100,16 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2897
3100
|
return new ZlinkStreamRequestBuilder(this, this.resolveNameOrDefault(encoded), encoded);
|
|
2898
3101
|
}
|
|
2899
3102
|
on(name, handler, messageType) {
|
|
2900
|
-
const encodedHandler = (message, signal) => handler(
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
3103
|
+
const encodedHandler = (message, signal) => handler(
|
|
3104
|
+
{
|
|
3105
|
+
name: message.name,
|
|
3106
|
+
metadata: message.metadata,
|
|
3107
|
+
payload: this.decodePayload(message.payload, messageType),
|
|
3108
|
+
flowId: message.flowId,
|
|
3109
|
+
flowOrigin: message.flowOrigin
|
|
3110
|
+
},
|
|
3111
|
+
signal
|
|
3112
|
+
);
|
|
2907
3113
|
return this.receivedMessages.on(name, encodedHandler);
|
|
2908
3114
|
}
|
|
2909
3115
|
waitFor(nameOrType) {
|
|
@@ -2924,7 +3130,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2924
3130
|
observedName(nameOrType) {
|
|
2925
3131
|
const name = typeof nameOrType === "function" ? this.options.nameResolver.resolve(nameOrType) : nameOrType;
|
|
2926
3132
|
if (typeof name !== "string") {
|
|
2927
|
-
throw connectorError(
|
|
3133
|
+
throw connectorError(
|
|
3134
|
+
"validationFailed" /* ValidationFailed */,
|
|
3135
|
+
"Packet name must be a string or a payload constructor."
|
|
3136
|
+
);
|
|
2928
3137
|
}
|
|
2929
3138
|
validateName(name);
|
|
2930
3139
|
return name;
|
|
@@ -2944,7 +3153,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2944
3153
|
waitForMessage(name, timeoutMs, predicate, signal) {
|
|
2945
3154
|
validateName(name);
|
|
2946
3155
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
2947
|
-
throw connectorError(
|
|
3156
|
+
throw connectorError(
|
|
3157
|
+
"validationFailed" /* ValidationFailed */,
|
|
3158
|
+
"Timeout must be a non-negative finite number."
|
|
3159
|
+
);
|
|
2948
3160
|
}
|
|
2949
3161
|
throwIfAborted(signal);
|
|
2950
3162
|
return new Promise((resolve, reject) => {
|
|
@@ -2970,30 +3182,36 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2970
3182
|
};
|
|
2971
3183
|
timer = setTimeout(() => finish(), timeoutMs);
|
|
2972
3184
|
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
|
|
2973
|
-
disposable = this.receivedMessages.observe(
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
try {
|
|
2978
|
-
const decoded = {
|
|
2979
|
-
name: message.name,
|
|
2980
|
-
metadata: message.metadata,
|
|
2981
|
-
payload: this.decodeWaitPayload(message.payload),
|
|
2982
|
-
flowId: message.flowId,
|
|
2983
|
-
flowOrigin: message.flowOrigin
|
|
2984
|
-
};
|
|
2985
|
-
if (!predicate(decoded)) {
|
|
3185
|
+
disposable = this.receivedMessages.observe(
|
|
3186
|
+
name,
|
|
3187
|
+
(message) => {
|
|
3188
|
+
if (done) {
|
|
2986
3189
|
return false;
|
|
2987
3190
|
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3191
|
+
try {
|
|
3192
|
+
const decoded = {
|
|
3193
|
+
name: message.name,
|
|
3194
|
+
metadata: message.metadata,
|
|
3195
|
+
payload: this.decodeWaitPayload(message.payload),
|
|
3196
|
+
flowId: message.flowId,
|
|
3197
|
+
flowOrigin: message.flowOrigin
|
|
3198
|
+
};
|
|
3199
|
+
if (!predicate(decoded)) {
|
|
3200
|
+
return false;
|
|
3201
|
+
}
|
|
3202
|
+
finish(void 0, decoded);
|
|
3203
|
+
} catch (cause) {
|
|
3204
|
+
finish(cause);
|
|
3205
|
+
}
|
|
3206
|
+
return true;
|
|
3207
|
+
},
|
|
3208
|
+
() => finish(
|
|
3209
|
+
connectorError(
|
|
3210
|
+
"disconnected" /* Disconnected */,
|
|
3211
|
+
`The connection this wait for '${name}' observed has ended.`
|
|
3212
|
+
)
|
|
3213
|
+
)
|
|
3214
|
+
);
|
|
2997
3215
|
});
|
|
2998
3216
|
}
|
|
2999
3217
|
encodePayload(payload, messageType) {
|