@mapeo/schema
Version:
JSON schema and flow types for Mapeo
111 lines (110 loc) • 4.79 kB
JavaScript
/* eslint-disable */
import _m0 from "protobufjs/minimal.js";
import { Common_1 } from "../common/v1.js";
export const protobufPackage = "mapeo";
function createBaseDevice_1() {
return { common: undefined, action: "", authorId: "", projectId: "", signature: "", authorIndex: 0, deviceIndex: 0 };
}
export const Device_1 = {
encode(message, writer = _m0.Writer.create()) {
if (message.common !== undefined) {
Common_1.encode(message.common, writer.uint32(10).fork()).ldelim();
}
if (message.action !== "") {
writer.uint32(18).string(message.action);
}
if (message.authorId !== "") {
writer.uint32(26).string(message.authorId);
}
if (message.projectId !== "") {
writer.uint32(34).string(message.projectId);
}
if (message.signature !== "") {
writer.uint32(42).string(message.signature);
}
if (message.authorIndex !== 0) {
writer.uint32(48).int32(message.authorIndex);
}
if (message.deviceIndex !== 0) {
writer.uint32(56).int32(message.deviceIndex);
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDevice_1();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.common = Common_1.decode(reader, reader.uint32());
break;
case 2:
message.action = reader.string();
break;
case 3:
message.authorId = reader.string();
break;
case 4:
message.projectId = reader.string();
break;
case 5:
message.signature = reader.string();
break;
case 6:
message.authorIndex = reader.int32();
break;
case 7:
message.deviceIndex = reader.int32();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object) {
return {
common: isSet(object.common) ? Common_1.fromJSON(object.common) : undefined,
action: isSet(object.action) ? String(object.action) : "",
authorId: isSet(object.authorId) ? String(object.authorId) : "",
projectId: isSet(object.projectId) ? String(object.projectId) : "",
signature: isSet(object.signature) ? String(object.signature) : "",
authorIndex: isSet(object.authorIndex) ? Number(object.authorIndex) : 0,
deviceIndex: isSet(object.deviceIndex) ? Number(object.deviceIndex) : 0,
};
},
toJSON(message) {
const obj = {};
message.common !== undefined && (obj.common = message.common ? Common_1.toJSON(message.common) : undefined);
message.action !== undefined && (obj.action = message.action);
message.authorId !== undefined && (obj.authorId = message.authorId);
message.projectId !== undefined && (obj.projectId = message.projectId);
message.signature !== undefined && (obj.signature = message.signature);
message.authorIndex !== undefined && (obj.authorIndex = Math.round(message.authorIndex));
message.deviceIndex !== undefined && (obj.deviceIndex = Math.round(message.deviceIndex));
return obj;
},
create(base) {
return Device_1.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f;
const message = createBaseDevice_1();
message.common = (object.common !== undefined && object.common !== null)
? Common_1.fromPartial(object.common)
: undefined;
message.action = (_a = object.action) !== null && _a !== void 0 ? _a : "";
message.authorId = (_b = object.authorId) !== null && _b !== void 0 ? _b : "";
message.projectId = (_c = object.projectId) !== null && _c !== void 0 ? _c : "";
message.signature = (_d = object.signature) !== null && _d !== void 0 ? _d : "";
message.authorIndex = (_e = object.authorIndex) !== null && _e !== void 0 ? _e : 0;
message.deviceIndex = (_f = object.deviceIndex) !== null && _f !== void 0 ? _f : 0;
return message;
},
};
function isSet(value) {
return value !== null && value !== undefined;
}