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

View File

@ -48,9 +48,9 @@
"@types/long": "^3.0.31", "@types/long": "^3.0.31",
"@types/node": "^6.0.47", "@types/node": "^6.0.47",
"long": "^3.2", "long": "^3.2",
"protobufjs": "^6.7.3", "protobufjs": "^6.8.8",
"uuid": "^3.0.1", "strict-event-emitter-types": "^1.2.0",
"strict-event-emitter-types": "^1.2.0" "uuid": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {
"jsdoc": "^3.5.5", "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 */ (function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd) /* AMD */ if (typeof define === 'function' && define.amd)
@ -340,12 +340,30 @@
options = {}; options = {};
var object = {}; var object = {};
if (options.defaults) { 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.eventType = "";
object.dataContentType = 0; object.dataContentType = 0;
object.metadataContentType = 0; object.metadataContentType = 0;
object.data = options.bytes === String ? "" : []; if (options.bytes === String)
object.metadata = 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")) 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; 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; object.eventNumber = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
} else } else
object.eventNumber = options.longs === String ? "0" : 0; 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.eventType = "";
object.dataContentType = 0; object.dataContentType = 0;
object.metadataContentType = 0; object.metadataContentType = 0;
object.data = options.bytes === String ? "" : []; if (options.bytes === String)
object.metadata = 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) { if ($util.Long) {
var long = new $util.Long(0, 0, false); var long = new $util.Long(0, 0, false);
object.created = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; object.created = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
@ -10930,7 +10966,13 @@
var object = {}; var object = {};
if (options.defaults) { if (options.defaults) {
object.reason = options.enums === String ? "NotReady" : 0; 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")) if (message.reason != null && message.hasOwnProperty("reason"))
object.reason = options.enums === String ? $root.EventStore.Client.Messages.NotHandled.NotHandledReason[message.reason] : message.reason; object.reason = options.enums === String ? $root.EventStore.Client.Messages.NotHandled.NotHandledReason[message.reason] : message.reason;