Files
blitzkit/packages/core/src/protos/reviews.ts
T

369 lines
10 KiB
TypeScript

// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.7.7
// protoc v3.19.6
// source: reviews.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export const protobufPackage = "blitzkit";
export interface Reviews {
reviews: { [key: number]: Review };
}
export interface Reviews_ReviewsEntry {
key: number;
value: Review | undefined;
}
export interface Review {
last_updated: number;
videos: Video[];
}
export interface Video {
id: string;
author: string;
}
function createBaseReviews(): Reviews {
return { reviews: {} };
}
export const Reviews: MessageFns<Reviews> = {
encode(message: Reviews, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
Object.entries(message.reviews).forEach(([key, value]) => {
Reviews_ReviewsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
});
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Reviews {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseReviews();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
const entry1 = Reviews_ReviewsEntry.decode(reader, reader.uint32());
if (entry1.value !== undefined) {
message.reviews[entry1.key] = entry1.value;
}
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Reviews {
return {
reviews: isObject(object.reviews)
? Object.entries(object.reviews).reduce<{ [key: number]: Review }>((acc, [key, value]) => {
acc[globalThis.Number(key)] = Review.fromJSON(value);
return acc;
}, {})
: {},
};
},
toJSON(message: Reviews): unknown {
const obj: any = {};
if (message.reviews) {
const entries = Object.entries(message.reviews);
if (entries.length > 0) {
obj.reviews = {};
entries.forEach(([k, v]) => {
obj.reviews[k] = Review.toJSON(v);
});
}
}
return obj;
},
create<I extends Exact<DeepPartial<Reviews>, I>>(base?: I): Reviews {
return Reviews.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Reviews>, I>>(object: I): Reviews {
const message = createBaseReviews();
message.reviews = Object.entries(object.reviews ?? {}).reduce<{ [key: number]: Review }>((acc, [key, value]) => {
if (value !== undefined) {
acc[globalThis.Number(key)] = Review.fromPartial(value);
}
return acc;
}, {});
return message;
},
};
function createBaseReviews_ReviewsEntry(): Reviews_ReviewsEntry {
return { key: 0, value: undefined };
}
export const Reviews_ReviewsEntry: MessageFns<Reviews_ReviewsEntry> = {
encode(message: Reviews_ReviewsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.key !== 0) {
writer.uint32(8).uint32(message.key);
}
if (message.value !== undefined) {
Review.encode(message.value, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Reviews_ReviewsEntry {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseReviews_ReviewsEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.key = reader.uint32();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.value = Review.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Reviews_ReviewsEntry {
return {
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
value: isSet(object.value) ? Review.fromJSON(object.value) : undefined,
};
},
toJSON(message: Reviews_ReviewsEntry): unknown {
const obj: any = {};
if (message.key !== 0) {
obj.key = Math.round(message.key);
}
if (message.value !== undefined) {
obj.value = Review.toJSON(message.value);
}
return obj;
},
create<I extends Exact<DeepPartial<Reviews_ReviewsEntry>, I>>(base?: I): Reviews_ReviewsEntry {
return Reviews_ReviewsEntry.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Reviews_ReviewsEntry>, I>>(object: I): Reviews_ReviewsEntry {
const message = createBaseReviews_ReviewsEntry();
message.key = object.key ?? 0;
message.value = (object.value !== undefined && object.value !== null)
? Review.fromPartial(object.value)
: undefined;
return message;
},
};
function createBaseReview(): Review {
return { last_updated: 0, videos: [] };
}
export const Review: MessageFns<Review> = {
encode(message: Review, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.last_updated !== 0) {
writer.uint32(13).float(message.last_updated);
}
for (const v of message.videos) {
Video.encode(v!, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Review {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseReview();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 13) {
break;
}
message.last_updated = reader.float();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.videos.push(Video.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Review {
return {
last_updated: isSet(object.last_updated) ? globalThis.Number(object.last_updated) : 0,
videos: globalThis.Array.isArray(object?.videos) ? object.videos.map((e: any) => Video.fromJSON(e)) : [],
};
},
toJSON(message: Review): unknown {
const obj: any = {};
if (message.last_updated !== 0) {
obj.last_updated = message.last_updated;
}
if (message.videos?.length) {
obj.videos = message.videos.map((e) => Video.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<Review>, I>>(base?: I): Review {
return Review.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Review>, I>>(object: I): Review {
const message = createBaseReview();
message.last_updated = object.last_updated ?? 0;
message.videos = object.videos?.map((e) => Video.fromPartial(e)) || [];
return message;
},
};
function createBaseVideo(): Video {
return { id: "", author: "" };
}
export const Video: MessageFns<Video> = {
encode(message: Video, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.author !== "") {
writer.uint32(18).string(message.author);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Video {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseVideo();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.author = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Video {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
author: isSet(object.author) ? globalThis.String(object.author) : "",
};
},
toJSON(message: Video): unknown {
const obj: any = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.author !== "") {
obj.author = message.author;
}
return obj;
},
create<I extends Exact<DeepPartial<Video>, I>>(base?: I): Video {
return Video.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Video>, I>>(object: I): Video {
const message = createBaseVideo();
message.id = object.id ?? "";
message.author = object.author ?? "";
return message;
},
};
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial<T["value"]> }
: 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;
}
export interface MessageFns<T> {
encode(message: T, writer?: BinaryWriter): BinaryWriter;
decode(input: BinaryReader | Uint8Array, length?: number): T;
fromJSON(object: any): T;
toJSON(message: T): unknown;
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
}