Fix appendToStream with expectedVersion any and same event not working due to protobufjs bug

This commit is contained in:
Nicolas Dextraze 2019-08-02 22:34:38 -07:00
parent d64f181dbb
commit 02642c5cfb
3 changed files with 65 additions and 19 deletions

20
package-lock.json generated
View File

@ -12,12 +12,12 @@
"@protobufjs/base64": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
"integrity": "sha1-TIVzDlm5ofHzSQR9vyQpYDS7JzU="
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="
},
"@protobufjs/codegen": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
"integrity": "sha1-fvN/DQEPsCitGtWXIuUG2SYoFcs="
"integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg=="
},
"@protobufjs/eventemitter": {
"version": "1.1.0",
@ -1861,7 +1861,8 @@
"safe-buffer": {
"version": "5.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -1967,7 +1968,8 @@
"yallist": {
"version": "3.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
@ -2921,6 +2923,7 @@
"resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
"integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
"dev": true,
"optional": true,
"requires": {
"kind-of": "^3.0.2",
"longest": "^1.0.1",
@ -4254,7 +4257,8 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
"integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=",
"dev": true
"dev": true,
"optional": true
},
"loose-envify": {
"version": "1.3.1",
@ -6114,9 +6118,9 @@
"integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q=="
},
"@types/node": {
"version": "10.9.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz",
"integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw=="
"version": "10.14.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.14.tgz",
"integrity": "sha512-xXD08vZsvpv4xptQXj1+ky22f7ZoKu5ZNI/4l+/BXG3X+XaeZsmaFbbTKuhSE3NjjvRuZFxFf9sQBMXIcZNFMQ=="
},
"long": {
"version": "4.0.0",

View File

@ -48,9 +48,9 @@
"@types/long": "^3.0.31",
"@types/node": "^6.0.47",
"long": "^3.2",
"protobufjs": "^6.7.3",
"uuid": "^3.0.1",
"strict-event-emitter-types": "^1.2.0"
"protobufjs": "^6.8.8",
"strict-event-emitter-types": "^1.2.0",
"uuid": "^3.0.1"
},
"devDependencies": {
"jsdoc": "^3.5.5",

View File

@ -1,4 +1,4 @@
/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
@ -340,12 +340,30 @@
options = {};
var object = {};
if (options.defaults) {
object.eventId = options.bytes === String ? "" : [];
if (options.bytes === String)
object.eventId = "";
else {
object.eventId = [];
if (options.bytes !== Array)
object.eventId = $util.newBuffer(object.eventId);
}
object.eventType = "";
object.dataContentType = 0;
object.metadataContentType = 0;
object.data = options.bytes === String ? "" : [];
object.metadata = options.bytes === String ? "" : [];
if (options.bytes === String)
object.data = "";
else {
object.data = [];
if (options.bytes !== Array)
object.data = $util.newBuffer(object.data);
}
if (options.bytes === String)
object.metadata = "";
else {
object.metadata = [];
if (options.bytes !== Array)
object.metadata = $util.newBuffer(object.metadata);
}
}
if (message.eventId != null && message.hasOwnProperty("eventId"))
object.eventId = options.bytes === String ? $util.base64.encode(message.eventId, 0, message.eventId.length) : options.bytes === Array ? Array.prototype.slice.call(message.eventId) : message.eventId;
@ -750,12 +768,30 @@
object.eventNumber = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
} else
object.eventNumber = options.longs === String ? "0" : 0;
object.eventId = options.bytes === String ? "" : [];
if (options.bytes === String)
object.eventId = "";
else {
object.eventId = [];
if (options.bytes !== Array)
object.eventId = $util.newBuffer(object.eventId);
}
object.eventType = "";
object.dataContentType = 0;
object.metadataContentType = 0;
object.data = options.bytes === String ? "" : [];
object.metadata = options.bytes === String ? "" : [];
if (options.bytes === String)
object.data = "";
else {
object.data = [];
if (options.bytes !== Array)
object.data = $util.newBuffer(object.data);
}
if (options.bytes === String)
object.metadata = "";
else {
object.metadata = [];
if (options.bytes !== Array)
object.metadata = $util.newBuffer(object.metadata);
}
if ($util.Long) {
var long = new $util.Long(0, 0, false);
object.created = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
@ -10930,7 +10966,13 @@
var object = {};
if (options.defaults) {
object.reason = options.enums === String ? "NotReady" : 0;
object.additionalInfo = options.bytes === String ? "" : [];
if (options.bytes === String)
object.additionalInfo = "";
else {
object.additionalInfo = [];
if (options.bytes !== Array)
object.additionalInfo = $util.newBuffer(object.additionalInfo);
}
}
if (message.reason != null && message.hasOwnProperty("reason"))
object.reason = options.enums === String ? $root.EventStore.Client.Messages.NotHandled.NotHandledReason[message.reason] : message.reason;