Skip to content
This repository was archived by the owner on Jul 31, 2020. It is now read-only.

Add metaInfo to record for better extensibility #330

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ message SyncRecord {
repeated string fields = 6;
bool hideInToolbar = 7;
string order = 8;
repeated MetaInfo metaInfo= 9;
repeated MetaInfo metaInfo = 9;
}
message SiteSetting {
string hostPattern = 1;
Expand Down Expand Up @@ -92,4 +92,5 @@ message SyncRecord {
SiteSetting siteSetting = 6;
Device device = 7;
}
repeated MetaInfo metaInfo = 8;
}
44 changes: 44 additions & 0 deletions lib/api.proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@
* @property {api.SyncRecord.ISite|null} [historySite] SyncRecord historySite
* @property {api.SyncRecord.ISiteSetting|null} [siteSetting] SyncRecord siteSetting
* @property {api.SyncRecord.IDevice|null} [device] SyncRecord device
* @property {Array.<api.IMetaInfo>|null} [metaInfo] SyncRecord metaInfo
*/

/**
Expand All @@ -1281,6 +1282,7 @@
* @param {api.ISyncRecord=} [properties] Properties to set
*/
function SyncRecord(properties) {
this.metaInfo = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
Expand Down Expand Up @@ -1343,6 +1345,14 @@
*/
SyncRecord.prototype.device = null;

/**
* SyncRecord metaInfo.
* @member {Array.<api.IMetaInfo>} metaInfo
* @memberof api.SyncRecord
* @instance
*/
SyncRecord.prototype.metaInfo = $util.emptyArray;

// OneOf field names bound to virtual getters and setters
var $oneOfFields;

Expand Down Expand Up @@ -1395,6 +1405,9 @@
$root.api.SyncRecord.SiteSetting.encode(message.siteSetting, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim();
if (message.device != null && message.hasOwnProperty("device"))
$root.api.SyncRecord.Device.encode(message.device, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
if (message.metaInfo != null && message.metaInfo.length)
for (var i = 0; i < message.metaInfo.length; ++i)
$root.api.MetaInfo.encode(message.metaInfo[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim();
return writer;
};

Expand Down Expand Up @@ -1450,6 +1463,11 @@
case 7:
message.device = $root.api.SyncRecord.Device.decode(reader, reader.uint32());
break;
case 8:
if (!(message.metaInfo && message.metaInfo.length))
message.metaInfo = [];
message.metaInfo.push($root.api.MetaInfo.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -1539,6 +1557,15 @@
return "device." + error;
}
}
if (message.metaInfo != null && message.hasOwnProperty("metaInfo")) {
if (!Array.isArray(message.metaInfo))
return "metaInfo: array expected";
for (var i = 0; i < message.metaInfo.length; ++i) {
var error = $root.api.MetaInfo.verify(message.metaInfo[i]);
if (error)
return "metaInfo." + error;
}
}
return null;
};

Expand Down Expand Up @@ -1598,6 +1625,16 @@
throw TypeError(".api.SyncRecord.device: object expected");
message.device = $root.api.SyncRecord.Device.fromObject(object.device);
}
if (object.metaInfo) {
if (!Array.isArray(object.metaInfo))
throw TypeError(".api.SyncRecord.metaInfo: array expected");
message.metaInfo = [];
for (var i = 0; i < object.metaInfo.length; ++i) {
if (typeof object.metaInfo[i] !== "object")
throw TypeError(".api.SyncRecord.metaInfo: object expected");
message.metaInfo[i] = $root.api.MetaInfo.fromObject(object.metaInfo[i]);
}
}
return message;
};

Expand All @@ -1614,6 +1651,8 @@
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.metaInfo = [];
if (options.defaults) {
object.action = options.enums === String ? "CREATE" : 0;
if (options.bytes === String)
Expand Down Expand Up @@ -1657,6 +1696,11 @@
if (options.oneofs)
object.objectData = "device";
}
if (message.metaInfo && message.metaInfo.length) {
object.metaInfo = [];
for (var j = 0; j < message.metaInfo.length; ++j)
object.metaInfo[j] = $root.api.MetaInfo.toObject(message.metaInfo[j], options);
}
return object;
};

Expand Down