pastebin/webui/src/gen/v1/pastebin_model.ts

281 lines
7.6 KiB
TypeScript

/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "model.v1";
/** @table_name: pastebin */
export interface ModelPastebin {
/** ID */
id: number;
/** 创建时间 */
created_at: number;
/** 过期时间 */
expired_at: number;
/** ID别名 */
short_id: string;
/** 标题 */
title: string;
/** 作者 */
author: string;
/** 内容 */
content: string;
/** 语言 */
lang: string;
/** 是否需要密码 */
password: string;
/** 是否需要密码 */
need_password: boolean;
/** 是否可以修改 */
editable: boolean;
}
function createBaseModelPastebin(): ModelPastebin {
return {
id: 0,
created_at: 0,
expired_at: 0,
short_id: "",
title: "",
author: "",
content: "",
lang: "",
password: "",
need_password: false,
editable: false,
};
}
export const ModelPastebin = {
encode(message: ModelPastebin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int64(message.id);
}
if (message.created_at !== 0) {
writer.uint32(16).int64(message.created_at);
}
if (message.expired_at !== 0) {
writer.uint32(24).int64(message.expired_at);
}
if (message.short_id !== "") {
writer.uint32(34).string(message.short_id);
}
if (message.title !== "") {
writer.uint32(42).string(message.title);
}
if (message.author !== "") {
writer.uint32(50).string(message.author);
}
if (message.content !== "") {
writer.uint32(58).string(message.content);
}
if (message.lang !== "") {
writer.uint32(66).string(message.lang);
}
if (message.password !== "") {
writer.uint32(74).string(message.password);
}
if (message.need_password === true) {
writer.uint32(80).bool(message.need_password);
}
if (message.editable === true) {
writer.uint32(88).bool(message.editable);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ModelPastebin {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseModelPastebin();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.id = longToNumber(reader.int64() as Long);
continue;
case 2:
if (tag !== 16) {
break;
}
message.created_at = longToNumber(reader.int64() as Long);
continue;
case 3:
if (tag !== 24) {
break;
}
message.expired_at = longToNumber(reader.int64() as Long);
continue;
case 4:
if (tag !== 34) {
break;
}
message.short_id = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.title = reader.string();
continue;
case 6:
if (tag !== 50) {
break;
}
message.author = reader.string();
continue;
case 7:
if (tag !== 58) {
break;
}
message.content = reader.string();
continue;
case 8:
if (tag !== 66) {
break;
}
message.lang = reader.string();
continue;
case 9:
if (tag !== 74) {
break;
}
message.password = reader.string();
continue;
case 10:
if (tag !== 80) {
break;
}
message.need_password = reader.bool();
continue;
case 11:
if (tag !== 88) {
break;
}
message.editable = reader.bool();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ModelPastebin {
return {
id: isSet(object.id) ? globalThis.Number(object.id) : 0,
created_at: isSet(object.createdAt) ? globalThis.Number(object.createdAt) : 0,
expired_at: isSet(object.expiredAt) ? globalThis.Number(object.expiredAt) : 0,
short_id: isSet(object.shortId) ? globalThis.String(object.shortId) : "",
title: isSet(object.title) ? globalThis.String(object.title) : "",
author: isSet(object.author) ? globalThis.String(object.author) : "",
content: isSet(object.content) ? globalThis.String(object.content) : "",
lang: isSet(object.lang) ? globalThis.String(object.lang) : "",
password: isSet(object.password) ? globalThis.String(object.password) : "",
need_password: isSet(object.needPassword) ? globalThis.Boolean(object.needPassword) : false,
editable: isSet(object.editable) ? globalThis.Boolean(object.editable) : false,
};
},
toJSON(message: ModelPastebin): unknown {
const obj: any = {};
if (message.id !== 0) {
obj.id = Math.round(message.id);
}
if (message.created_at !== 0) {
obj.createdAt = Math.round(message.created_at);
}
if (message.expired_at !== 0) {
obj.expiredAt = Math.round(message.expired_at);
}
if (message.short_id !== "") {
obj.shortId = message.short_id;
}
if (message.title !== "") {
obj.title = message.title;
}
if (message.author !== "") {
obj.author = message.author;
}
if (message.content !== "") {
obj.content = message.content;
}
if (message.lang !== "") {
obj.lang = message.lang;
}
if (message.password !== "") {
obj.password = message.password;
}
if (message.need_password === true) {
obj.needPassword = message.need_password;
}
if (message.editable === true) {
obj.editable = message.editable;
}
return obj;
},
create<I extends Exact<DeepPartial<ModelPastebin>, I>>(base?: I): ModelPastebin {
return ModelPastebin.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ModelPastebin>, I>>(object: I): ModelPastebin {
const message = createBaseModelPastebin();
message.id = object.id ?? 0;
message.created_at = object.created_at ?? 0;
message.expired_at = object.expired_at ?? 0;
message.short_id = object.short_id ?? "";
message.title = object.title ?? "";
message.author = object.author ?? "";
message.content = object.content ?? "";
message.lang = object.lang ?? "";
message.password = object.password ?? "";
message.need_password = object.need_password ?? false;
message.editable = object.editable ?? false;
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 {} ? { [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 longToNumber(long: Long): number {
if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
}
return long.toNumber();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}