UNPKG

@mapeo/schema

Version:

JSON schema and flow types for Mapeo

303 lines (272 loc) 10.8 kB
/* eslint-disable */ import _m0 from "protobufjs/minimal.js"; import { Common_1 } from "../common/v1.js"; import { Struct } from "../google/protobuf/struct.js"; export const protobufPackage = "mapeo"; export interface Observation_5 { common?: Common_1; lat?: number | undefined; lon?: number | undefined; refs: { [key: string]: any }[]; attachments: { [key: string]: any }[]; tags?: { [key: string]: any }; metadata?: Observation_5_Metadata | undefined; } export interface Observation_5_Metadata { location?: Observation_5_Metadata_Location | undefined; manual_location?: boolean | undefined; } export interface Observation_5_Metadata_Location { precision?: number | undefined; altitude?: number | undefined; } function createBaseObservation_5(): Observation_5 { return { common: undefined, lat: undefined, lon: undefined, refs: [], attachments: [], tags: undefined, metadata: undefined, }; } export const Observation_5 = { encode(message: Observation_5, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.common !== undefined) { Common_1.encode(message.common, writer.uint32(10).fork()).ldelim(); } if (message.lat !== undefined) { writer.uint32(21).float(message.lat); } if (message.lon !== undefined) { writer.uint32(29).float(message.lon); } for (const v of message.refs) { Struct.encode(Struct.wrap(v!), writer.uint32(34).fork()).ldelim(); } for (const v of message.attachments) { Struct.encode(Struct.wrap(v!), writer.uint32(42).fork()).ldelim(); } if (message.tags !== undefined) { Struct.encode(Struct.wrap(message.tags), writer.uint32(50).fork()).ldelim(); } if (message.metadata !== undefined) { Observation_5_Metadata.encode(message.metadata, writer.uint32(58).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): Observation_5 { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseObservation_5(); 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.lat = reader.float(); break; case 3: message.lon = reader.float(); break; case 4: message.refs.push(Struct.unwrap(Struct.decode(reader, reader.uint32()))); break; case 5: message.attachments.push(Struct.unwrap(Struct.decode(reader, reader.uint32()))); break; case 6: message.tags = Struct.unwrap(Struct.decode(reader, reader.uint32())); break; case 7: message.metadata = Observation_5_Metadata.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): Observation_5 { return { common: isSet(object.common) ? Common_1.fromJSON(object.common) : undefined, lat: isSet(object.lat) ? Number(object.lat) : undefined, lon: isSet(object.lon) ? Number(object.lon) : undefined, refs: Array.isArray(object?.refs) ? [...object.refs] : [], attachments: Array.isArray(object?.attachments) ? [...object.attachments] : [], tags: isObject(object.tags) ? object.tags : undefined, metadata: isSet(object.metadata) ? Observation_5_Metadata.fromJSON(object.metadata) : undefined, }; }, toJSON(message: Observation_5): unknown { const obj: any = {}; message.common !== undefined && (obj.common = message.common ? Common_1.toJSON(message.common) : undefined); message.lat !== undefined && (obj.lat = message.lat); message.lon !== undefined && (obj.lon = message.lon); if (message.refs) { obj.refs = message.refs.map((e) => e); } else { obj.refs = []; } if (message.attachments) { obj.attachments = message.attachments.map((e) => e); } else { obj.attachments = []; } message.tags !== undefined && (obj.tags = message.tags); message.metadata !== undefined && (obj.metadata = message.metadata ? Observation_5_Metadata.toJSON(message.metadata) : undefined); return obj; }, create<I extends Exact<DeepPartial<Observation_5>, I>>(base?: I): Observation_5 { return Observation_5.fromPartial(base ?? {}); }, fromPartial<I extends Exact<DeepPartial<Observation_5>, I>>(object: I): Observation_5 { const message = createBaseObservation_5(); message.common = (object.common !== undefined && object.common !== null) ? Common_1.fromPartial(object.common) : undefined; message.lat = object.lat ?? undefined; message.lon = object.lon ?? undefined; message.refs = object.refs?.map((e) => e) || []; message.attachments = object.attachments?.map((e) => e) || []; message.tags = object.tags ?? undefined; message.metadata = (object.metadata !== undefined && object.metadata !== null) ? Observation_5_Metadata.fromPartial(object.metadata) : undefined; return message; }, }; function createBaseObservation_5_Metadata(): Observation_5_Metadata { return { location: undefined, manual_location: undefined }; } export const Observation_5_Metadata = { encode(message: Observation_5_Metadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.location !== undefined) { Observation_5_Metadata_Location.encode(message.location, writer.uint32(10).fork()).ldelim(); } if (message.manual_location !== undefined) { writer.uint32(16).bool(message.manual_location); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): Observation_5_Metadata { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseObservation_5_Metadata(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.location = Observation_5_Metadata_Location.decode(reader, reader.uint32()); break; case 2: message.manual_location = reader.bool(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): Observation_5_Metadata { return { location: isSet(object.location) ? Observation_5_Metadata_Location.fromJSON(object.location) : undefined, manual_location: isSet(object.manual_location) ? Boolean(object.manual_location) : undefined, }; }, toJSON(message: Observation_5_Metadata): unknown { const obj: any = {}; message.location !== undefined && (obj.location = message.location ? Observation_5_Metadata_Location.toJSON(message.location) : undefined); message.manual_location !== undefined && (obj.manual_location = message.manual_location); return obj; }, create<I extends Exact<DeepPartial<Observation_5_Metadata>, I>>(base?: I): Observation_5_Metadata { return Observation_5_Metadata.fromPartial(base ?? {}); }, fromPartial<I extends Exact<DeepPartial<Observation_5_Metadata>, I>>(object: I): Observation_5_Metadata { const message = createBaseObservation_5_Metadata(); message.location = (object.location !== undefined && object.location !== null) ? Observation_5_Metadata_Location.fromPartial(object.location) : undefined; message.manual_location = object.manual_location ?? undefined; return message; }, }; function createBaseObservation_5_Metadata_Location(): Observation_5_Metadata_Location { return { precision: undefined, altitude: undefined }; } export const Observation_5_Metadata_Location = { encode(message: Observation_5_Metadata_Location, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.precision !== undefined) { writer.uint32(13).float(message.precision); } if (message.altitude !== undefined) { writer.uint32(16).int32(message.altitude); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): Observation_5_Metadata_Location { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseObservation_5_Metadata_Location(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.precision = reader.float(); break; case 2: message.altitude = reader.int32(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): Observation_5_Metadata_Location { return { precision: isSet(object.precision) ? Number(object.precision) : undefined, altitude: isSet(object.altitude) ? Number(object.altitude) : undefined, }; }, toJSON(message: Observation_5_Metadata_Location): unknown { const obj: any = {}; message.precision !== undefined && (obj.precision = message.precision); message.altitude !== undefined && (obj.altitude = Math.round(message.altitude)); return obj; }, create<I extends Exact<DeepPartial<Observation_5_Metadata_Location>, I>>(base?: I): Observation_5_Metadata_Location { return Observation_5_Metadata_Location.fromPartial(base ?? {}); }, fromPartial<I extends Exact<DeepPartial<Observation_5_Metadata_Location>, I>>( object: I, ): Observation_5_Metadata_Location { const message = createBaseObservation_5_Metadata_Location(); message.precision = object.precision ?? undefined; message.altitude = object.altitude ?? undefined; 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 isObject(value: any): boolean { return typeof value === "object" && value !== null; } function isSet(value: any): boolean { return value !== null && value !== undefined; }