Fix sending dates through the protocol

Fixes #253.
This commit is contained in:
Asher
2019-04-04 18:24:21 -05:00
parent 278c59b920
commit e73eb74208
9 changed files with 267 additions and 22 deletions

View File

@@ -40,6 +40,10 @@ message Argument {
message UndefinedValue {}
message DateValue {
string date = 1;
}
oneof msg {
ErrorValue error = 1;
BufferValue buffer = 2;
@@ -52,6 +56,7 @@ message Argument {
double number = 9;
string string = 10;
bool boolean = 11;
DateValue date = 12;
}
}

View File

@@ -59,6 +59,11 @@ export class Argument extends jspb.Message {
getBoolean(): boolean;
setBoolean(value: boolean): void;
hasDate(): boolean;
clearDate(): void;
getDate(): Argument.DateValue | undefined;
setDate(value?: Argument.DateValue): void;
getMsgCase(): Argument.MsgCase;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Argument.AsObject;
@@ -83,6 +88,7 @@ export namespace Argument {
number: number,
string: string,
pb_boolean: boolean,
date?: Argument.DateValue.AsObject,
}
export class ErrorValue extends jspb.Message {
@@ -248,6 +254,26 @@ export namespace Argument {
}
}
export class DateValue extends jspb.Message {
getDate(): string;
setDate(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): DateValue.AsObject;
static toObject(includeInstance: boolean, msg: DateValue): DateValue.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: DateValue, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): DateValue;
static deserializeBinaryFromReader(message: DateValue, reader: jspb.BinaryReader): DateValue;
}
export namespace DateValue {
export type AsObject = {
date: string,
}
}
export enum MsgCase {
MSG_NOT_SET = 0,
ERROR = 1,
@@ -261,6 +287,7 @@ export namespace Argument {
NUMBER = 9,
STRING = 10,
BOOLEAN = 11,
DATE = 12,
}
}

View File

@@ -14,6 +14,7 @@ var global = Function('return this')();
goog.exportSymbol('proto.Argument', null, global);
goog.exportSymbol('proto.Argument.ArrayValue', null, global);
goog.exportSymbol('proto.Argument.BufferValue', null, global);
goog.exportSymbol('proto.Argument.DateValue', null, global);
goog.exportSymbol('proto.Argument.ErrorValue', null, global);
goog.exportSymbol('proto.Argument.FunctionValue', null, global);
goog.exportSymbol('proto.Argument.NullValue', null, global);
@@ -223,6 +224,27 @@ if (goog.DEBUG && !COMPILED) {
*/
proto.Argument.UndefinedValue.displayName = 'proto.Argument.UndefinedValue';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.Argument.DateValue = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.Argument.DateValue, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.Argument.DateValue.displayName = 'proto.Argument.DateValue';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
@@ -505,7 +527,7 @@ if (goog.DEBUG && !COMPILED) {
* @private {!Array<!Array<number>>}
* @const
*/
proto.Argument.oneofGroups_ = [[1,2,3,4,5,6,7,8,9,10,11]];
proto.Argument.oneofGroups_ = [[1,2,3,4,5,6,7,8,9,10,11,12]];
/**
* @enum {number}
@@ -522,7 +544,8 @@ proto.Argument.MsgCase = {
UNDEFINED: 8,
NUMBER: 9,
STRING: 10,
BOOLEAN: 11
BOOLEAN: 11,
DATE: 12
};
/**
@@ -571,7 +594,8 @@ proto.Argument.toObject = function(includeInstance, msg) {
undefined: (f = msg.getUndefined()) && proto.Argument.UndefinedValue.toObject(includeInstance, f),
number: +jspb.Message.getFieldWithDefault(msg, 9, 0.0),
string: jspb.Message.getFieldWithDefault(msg, 10, ""),
pb_boolean: jspb.Message.getFieldWithDefault(msg, 11, false)
pb_boolean: jspb.Message.getFieldWithDefault(msg, 11, false),
date: (f = msg.getDate()) && proto.Argument.DateValue.toObject(includeInstance, f)
};
if (includeInstance) {
@@ -660,6 +684,11 @@ proto.Argument.deserializeBinaryFromReader = function(msg, reader) {
var value = /** @type {boolean} */ (reader.readBool());
msg.setBoolean(value);
break;
case 12:
var value = new proto.Argument.DateValue;
reader.readMessage(value,proto.Argument.DateValue.deserializeBinaryFromReader);
msg.setDate(value);
break;
default:
reader.skipField();
break;
@@ -774,6 +803,14 @@ proto.Argument.serializeBinaryToWriter = function(message, writer) {
f
);
}
f = message.getDate();
if (f != null) {
writer.writeMessage(
12,
f,
proto.Argument.DateValue.serializeBinaryToWriter
);
}
};
@@ -1837,6 +1874,131 @@ proto.Argument.UndefinedValue.serializeBinaryToWriter = function(message, writer
};
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.Argument.DateValue.prototype.toObject = function(opt_includeInstance) {
return proto.Argument.DateValue.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.Argument.DateValue} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.Argument.DateValue.toObject = function(includeInstance, msg) {
var obj = {
date: jspb.Message.getFieldWithDefault(msg, 1, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.Argument.DateValue}
*/
proto.Argument.DateValue.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.Argument.DateValue;
return proto.Argument.DateValue.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.Argument.DateValue} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.Argument.DateValue}
*/
proto.Argument.DateValue.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setDate(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.Argument.DateValue.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.Argument.DateValue.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.Argument.DateValue} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.Argument.DateValue.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getDate();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
};
/**
* optional string date = 1;
* @return {string}
*/
proto.Argument.DateValue.prototype.getDate = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.Argument.DateValue.prototype.setDate = function(value) {
jspb.Message.setProto3StringField(this, 1, value);
};
/**
* optional ErrorValue error = 1;
* @return {?proto.Argument.ErrorValue}
@@ -2199,6 +2361,39 @@ proto.Argument.prototype.hasBoolean = function() {
};
/**
* optional DateValue date = 12;
* @return {?proto.Argument.DateValue}
*/
proto.Argument.prototype.getDate = function() {
return /** @type{?proto.Argument.DateValue} */ (
jspb.Message.getWrapperField(this, proto.Argument.DateValue, 12));
};
/** @param {?proto.Argument.DateValue|undefined} value */
proto.Argument.prototype.setDate = function(value) {
jspb.Message.setOneofWrapperField(this, 12, proto.Argument.oneofGroups_[0], value);
};
/**
* Clears the message field making it undefined.
*/
proto.Argument.prototype.clearDate = function() {
this.setDate(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.Argument.prototype.hasDate = function() {
return jspb.Message.getField(this, 12) != null;
};
/**
* Oneof group definitions for this message. Each group defines the field