UNPKG

@mapeo/schema

Version:

JSON schema and flow types for Mapeo

140 lines (126 loc) 4.95 kB
/* eslint-disable */ import _m0 from "protobufjs/minimal.js"; import { Common_1 } from "../common/v1.js"; export const protobufPackage = "mapeo"; export interface Device_1 { common?: Common_1; action: string; authorId: string; projectId: string; signature: string; authorIndex: number; deviceIndex: number; } function createBaseDevice_1(): Device_1 { return { common: undefined, action: "", authorId: "", projectId: "", signature: "", authorIndex: 0, deviceIndex: 0 }; } export const Device_1 = { encode(message: Device_1, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 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: _m0.Reader | Uint8Array, length?: number): Device_1 { 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: any): Device_1 { 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: Device_1): unknown { const obj: any = {}; 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<I extends Exact<DeepPartial<Device_1>, I>>(base?: I): Device_1 { return Device_1.fromPartial(base ?? {}); }, fromPartial<I extends Exact<DeepPartial<Device_1>, I>>(object: I): Device_1 { const message = createBaseDevice_1(); message.common = (object.common !== undefined && object.common !== null) ? Common_1.fromPartial(object.common) : undefined; message.action = object.action ?? ""; message.authorId = object.authorId ?? ""; message.projectId = object.projectId ?? ""; message.signature = object.signature ?? ""; message.authorIndex = object.authorIndex ?? 0; message.deviceIndex = object.deviceIndex ?? 0; return message; }, }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } : Partial<T>; type KeysOfUnion<T> = T extends T ? keyof T : never; export type Exact<P, I extends P> = P extends Builtin ? P : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never }; function isSet(value: any): boolean { return value !== null && value !== undefined; }