mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: names
This commit is contained in:
1 parent
6f11fb4a70
commit
0864825513
5 files changed
+429
-19
No files matched your search
@@ -3,5 +3,10 @@ syntax = "proto2";
|
||||
package blitzkit;
|
||||
|
||||
message Tanks {
|
||||
repeated string tanks = 1;
|
||||
repeated TankMeta tanks = 1;
|
||||
}
|
||||
|
||||
message TankMeta {
|
||||
required string id = 1;
|
||||
required string seo_id = 2;
|
||||
}
|
||||
@@ -10,7 +10,12 @@ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
export const protobufPackage = "blitzkit";
|
||||
|
||||
export interface Tanks {
|
||||
tanks: string[];
|
||||
tanks: TankMeta[];
|
||||
}
|
||||
|
||||
export interface TankMeta {
|
||||
id: string;
|
||||
seo_id: string;
|
||||
}
|
||||
|
||||
function createBaseTanks(): Tanks {
|
||||
@@ -20,7 +25,7 @@ function createBaseTanks(): Tanks {
|
||||
export const Tanks: MessageFns<Tanks> = {
|
||||
encode(message: Tanks, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
for (const v of message.tanks) {
|
||||
writer.uint32(10).string(v!);
|
||||
TankMeta.encode(v!, writer.uint32(10).fork()).join();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
@@ -37,7 +42,7 @@ export const Tanks: MessageFns<Tanks> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.tanks.push(reader.string());
|
||||
message.tanks.push(TankMeta.decode(reader, reader.uint32()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -50,13 +55,13 @@ export const Tanks: MessageFns<Tanks> = {
|
||||
},
|
||||
|
||||
fromJSON(object: any): Tanks {
|
||||
return { tanks: globalThis.Array.isArray(object?.tanks) ? object.tanks.map((e: any) => globalThis.String(e)) : [] };
|
||||
return { tanks: globalThis.Array.isArray(object?.tanks) ? object.tanks.map((e: any) => TankMeta.fromJSON(e)) : [] };
|
||||
},
|
||||
|
||||
toJSON(message: Tanks): unknown {
|
||||
const obj: any = {};
|
||||
if (message.tanks?.length) {
|
||||
obj.tanks = message.tanks;
|
||||
obj.tanks = message.tanks.map((e) => TankMeta.toJSON(e));
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
@@ -66,7 +71,83 @@ export const Tanks: MessageFns<Tanks> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<Tanks>, I>>(object: I): Tanks {
|
||||
const message = createBaseTanks();
|
||||
message.tanks = object.tanks?.map((e) => e) || [];
|
||||
message.tanks = object.tanks?.map((e) => TankMeta.fromPartial(e)) || [];
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseTankMeta(): TankMeta {
|
||||
return { id: "", seo_id: "" };
|
||||
}
|
||||
|
||||
export const TankMeta: MessageFns<TankMeta> = {
|
||||
encode(message: TankMeta, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.id !== "") {
|
||||
writer.uint32(10).string(message.id);
|
||||
}
|
||||
if (message.seo_id !== "") {
|
||||
writer.uint32(18).string(message.seo_id);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): TankMeta {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseTankMeta();
|
||||
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.seo_id = reader.string();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): TankMeta {
|
||||
return {
|
||||
id: globalThis.String(assertSet("TankMeta.id", object.id)),
|
||||
seo_id: globalThis.String(assertSet("TankMeta.seo_id", object.seo_id)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: TankMeta): unknown {
|
||||
const obj: any = {};
|
||||
if (message.id !== "") {
|
||||
obj.id = message.id;
|
||||
}
|
||||
if (message.seo_id !== "") {
|
||||
obj.seo_id = message.seo_id;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<TankMeta>, I>>(base?: I): TankMeta {
|
||||
return TankMeta.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<TankMeta>, I>>(object: I): TankMeta {
|
||||
const message = createBaseTankMeta();
|
||||
message.id = object.id ?? "";
|
||||
message.seo_id = object.seo_id ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
@@ -84,6 +165,18 @@ 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;
|
||||
}
|
||||
|
||||
function assertSet<T>(field: string, value: T | undefined): T {
|
||||
if (!isSet(value)) {
|
||||
throw new TypeError(`Required field ${field} is not set`);
|
||||
}
|
||||
|
||||
return value as T;
|
||||
}
|
||||
|
||||
export interface MessageFns<T> {
|
||||
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
||||
|
||||
Reference in new issue
Block a user