protoscript
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -1,3 +0,3 @@ | ||
export declare type UserConfig = Partial<Config>; | ||
declare type Config = { | ||
export type UserConfig = Partial<Config>; | ||
type Config = { | ||
/** | ||
@@ -4,0 +4,0 @@ * The root directory. `.proto` files will be searched under this directory, and `proto` import paths will be resolved relative to this directory. ProtoScript will recursively search all subdirectories for `.proto` files. |
@@ -17,5 +17,5 @@ import { type FileDescriptorProto } from "google-protobuf/google/protobuf/descriptor_pb.js"; | ||
}; | ||
export declare type Config = typeof config; | ||
export type Config = typeof config; | ||
export declare function printIfTypescript(str: string): string; | ||
export declare function generate(fileDescriptorProto: FileDescriptorProto, identifierTable: IdentifierTable, options: Pick<UserConfig, "language" | "json" | "typescript">, plugins: Plugin[]): string; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { processTypes } from "../utils.js"; | ||
import { cycleDetected, processTypes, uniqueBy, } from "../utils.js"; | ||
const DEFAULT_IMPORT_TRACKER = { | ||
@@ -6,4 +6,5 @@ hasBytes: false, | ||
let IMPORT_TRACKER; | ||
function writeTypes(types, isTopLevel) { | ||
function writeTypes(types, parents) { | ||
let result = ""; | ||
const isTopLevel = parents.length === 0; | ||
types.forEach((node) => { | ||
@@ -25,2 +26,6 @@ const name = node.content.name; | ||
} | ||
const mandatoryOptional = cycleDetected(tsType, [ | ||
...parents, | ||
node.content.name, | ||
]); | ||
result += `${fieldName}${printIf(optional, "?")}:`; | ||
@@ -32,3 +37,3 @@ if (map) { | ||
result += tsType; | ||
if (optional) { | ||
if (optional || mandatoryOptional) { | ||
result += "| null | undefined"; | ||
@@ -45,3 +50,4 @@ } | ||
result += `${printIf(isTopLevel, "export declare")} namespace ${name} { \n`; | ||
result += writeTypes(node.children, false) + "\n\n"; | ||
result += | ||
writeTypes(node.children, [...parents, node.content.name]) + "\n\n"; | ||
result += `}\n\n`; | ||
@@ -55,4 +61,5 @@ } | ||
const fromMapMessage = (x) => `Object.fromEntries(${x}.map(({ key, value }) => [key, value]))`; | ||
function writeProtobufSerializers(types, isTopLevel) { | ||
function writeProtobufSerializers(types, parents) { | ||
let result = ""; | ||
const isTopLevel = parents.length === 0; | ||
types.forEach((node) => { | ||
@@ -112,3 +119,11 @@ result += isTopLevel | ||
else if (field.read === "readMessage" && !field.map) { | ||
return `${field.name}: ${field.tsType}.initialize(),`; | ||
if (cycleDetected(field.tsType, [ | ||
...parents, | ||
node.content.name, | ||
])) { | ||
return `${field.name}: undefined,`; | ||
} | ||
else { | ||
return `${field.name}: ${field.tsType}.initialize(),`; | ||
} | ||
} | ||
@@ -276,3 +291,6 @@ else { | ||
result += "},\n\n"; | ||
result += writeProtobufSerializers(node.children, false); | ||
result += writeProtobufSerializers(node.children, [ | ||
...parents, | ||
node.content.name, | ||
]); | ||
result += `}${isTopLevel ? ";" : ","}\n\n`; | ||
@@ -298,3 +316,5 @@ break; | ||
`; | ||
node.content.values.forEach(({ name, value }) => { | ||
// Though all alias values are valid during deserialization, the first value is always used when serializing | ||
// https://protobuf.dev/programming-guides/proto3/#enum | ||
uniqueBy(node.content.values, (x) => x.value).forEach(({ name, value }) => { | ||
result += `case ${value}: { return '${name}'; }\n`; | ||
@@ -329,4 +349,5 @@ }); | ||
} | ||
function writeJSONSerializers(types, isTopLevel) { | ||
function writeJSONSerializers(types, parents) { | ||
let result = ""; | ||
const isTopLevel = parents.length === 0; | ||
types.forEach((node) => { | ||
@@ -386,3 +407,11 @@ result += isTopLevel | ||
else if (field.read === "readMessage" && !field.map) { | ||
return `${field.name}: ${field.tsTypeJSON}.initialize(),`; | ||
if (cycleDetected(field.tsTypeJSON, [ | ||
...parents, | ||
node.content.name, | ||
])) { | ||
return `${field.name}: undefined,`; | ||
} | ||
else { | ||
return `${field.name}: ${field.tsTypeJSON}.initialize(),`; | ||
} | ||
} | ||
@@ -507,3 +536,3 @@ else { | ||
res += `for (const item of ${name}) {`; | ||
res += `const m = ${field.tsType}.initialize();`; | ||
res += `const m = ${field.tsTypeJSON}.initialize();`; | ||
res += `${field.tsTypeJSON}._readMessage(m, item);`; | ||
@@ -514,3 +543,3 @@ res += `msg.${field.name}.push(m);`; | ||
else { | ||
res += `const m = ${field.tsType}.initialize();`; | ||
res += `const m = ${field.tsTypeJSON}.initialize();`; | ||
res += `${field.tsTypeJSON}._readMessage(m, ${name});`; | ||
@@ -545,3 +574,6 @@ res += `msg.${field.name} = m;`; | ||
result += "},\n\n"; | ||
result += writeJSONSerializers(node.children, false); | ||
result += writeJSONSerializers(node.children, [ | ||
...parents, | ||
node.content.name, | ||
]); | ||
result += `}${isTopLevel ? ";" : ","}\n\n`; | ||
@@ -567,3 +599,5 @@ break; | ||
`; | ||
node.content.values.forEach(({ name, value }) => { | ||
// Though all alias values are valid during deserialization, the first value is always used when serializing | ||
// https://protobuf.dev/programming-guides/proto3/#enum | ||
uniqueBy(node.content.values, (x) => x.value).forEach(({ name, value }) => { | ||
result += `case ${value}: { return '${name}'; }\n`; | ||
@@ -659,8 +693,8 @@ }); | ||
!!types.find((x) => x.type === "message"); | ||
const typeDefinitions = hasTypes && config.isTS ? writeTypes(types, true) : ""; | ||
const typeDefinitions = hasTypes && config.isTS ? writeTypes(types, []) : ""; | ||
const protobufSerializers = !config.typescript.emitDeclarationOnly | ||
? writeProtobufSerializers(types, true) | ||
? writeProtobufSerializers(types, []) | ||
: ""; | ||
const jsonSerializers = !config.typescript.emitDeclarationOnly | ||
? writeJSONSerializers(types, true) | ||
? writeJSONSerializers(types, []) | ||
: ""; | ||
@@ -667,0 +701,0 @@ return `\ |
@@ -5,4 +5,6 @@ import type { CodeGeneratorRequest } from "google-protobuf/google/protobuf/compiler/plugin_pb.js"; | ||
export declare function lowerCase(str: string): string; | ||
declare type ReaderMethod = keyof BinaryReader | "map"; | ||
declare type WriterMethod = keyof BinaryWriter | "map"; | ||
export declare function uniqueBy<T>(arr: T[], cb: (el: T) => unknown): T[]; | ||
export declare function cycleDetected(node: string, graph: string[]): boolean; | ||
type ReaderMethod = keyof BinaryReader | "map"; | ||
type WriterMethod = keyof BinaryWriter | "map"; | ||
interface Descriptor { | ||
@@ -26,3 +28,3 @@ defaultValue: string; | ||
*/ | ||
export declare type IdentifierTable = { | ||
export type IdentifierTable = { | ||
namespacedIdentifier: string; | ||
@@ -74,7 +76,7 @@ file: string; | ||
} | ||
export declare type EnumType = { | ||
export type EnumType = { | ||
type: "enum"; | ||
content: EnumOpts; | ||
}; | ||
export declare type MessageType = { | ||
export type MessageType = { | ||
type: "message"; | ||
@@ -84,3 +86,3 @@ content: MessageOpts; | ||
}; | ||
export declare type ProtoTypes = EnumType | MessageType; | ||
export type ProtoTypes = EnumType | MessageType; | ||
export interface Service { | ||
@@ -87,0 +89,0 @@ name: string; |
@@ -14,2 +14,14 @@ import { dirname, relative } from "path"; | ||
} | ||
export function uniqueBy(arr, cb) { | ||
const seen = new Set(); | ||
return arr.filter((x) => { | ||
const val = cb(x); | ||
const dup = seen.has(val); | ||
seen.add(val); | ||
return !dup; | ||
}); | ||
} | ||
export function cycleDetected(node, graph) { | ||
return graph.includes(node); | ||
} | ||
const FileLabel = { | ||
@@ -565,4 +577,5 @@ Message: 4, | ||
} | ||
const nameWithoutUnderscores = value.getName()?.split(/_+/).filter(Boolean) ?? []; | ||
return { | ||
name: camelCase(value.getName()?.split("_") ?? []), | ||
name: camelCase(nameWithoutUnderscores), | ||
protoName: value.getName() ?? "", | ||
@@ -569,0 +582,0 @@ jsonName: value.getJsonName(), |
@@ -1,6 +0,3 @@ | ||
export { BinaryReader } from "./runtime/reader.js"; | ||
export { BinaryWriter } from "./runtime/writer.js"; | ||
export { decodeBase64Bytes, encodeBase64Bytes } from "./runtime/json.js"; | ||
export * from "./runtime/index.js"; | ||
export * from "./runtime/well-known-types/index.js"; | ||
export declare type ByteSource = ArrayBuffer | Uint8Array | number[] | string; | ||
export type { UserConfig as Config } from "./cli/core.js"; |
@@ -1,4 +0,2 @@ | ||
export { BinaryReader } from "./runtime/reader.js"; | ||
export { BinaryWriter } from "./runtime/writer.js"; | ||
export { decodeBase64Bytes, encodeBase64Bytes } from "./runtime/json.js"; | ||
export * from "./runtime/index.js"; | ||
export * from "./runtime/well-known-types/index.js"; |
{ | ||
"name": "protoscript", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "A Protobuf runtime and code generation tool for JavaScript and TypeScript", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -20,3 +20,3 @@ import type { Config } from "./codegen/autogenerate/index.js"; | ||
*/ | ||
export declare type Plugin = (opts: PluginOpts) => Partial<PluginOut> | undefined; | ||
export type Plugin = (opts: PluginOpts) => Partial<PluginOut> | undefined; | ||
export { | ||
@@ -23,0 +23,0 @@ /** |
@@ -24,3 +24,3 @@ export declare const FieldType: { | ||
}; | ||
export declare type FieldType = typeof FieldType[keyof typeof FieldType]; | ||
export type FieldType = (typeof FieldType)[keyof typeof FieldType]; | ||
/** | ||
@@ -38,3 +38,3 @@ * Wire-format type codes, taken from proto2/public/wire_format_lite.h. | ||
}; | ||
export declare type WireType = typeof WireType[keyof typeof WireType]; | ||
export type WireType = (typeof WireType)[keyof typeof WireType]; | ||
/** | ||
@@ -41,0 +41,0 @@ * Translates field type to wire type. |
@@ -9,2 +9,18 @@ import { assert, fail } from "./goog/asserts.js"; | ||
export class BinaryDecoder { | ||
/** | ||
* Pops an instance off the instance cache, or creates one if the cache is | ||
* empty. | ||
*/ | ||
static alloc(opt_bytes, opt_start, opt_length) { | ||
const newDecoder = BinaryDecoder.instanceCache_.pop(); | ||
if (newDecoder) { | ||
if (opt_bytes) { | ||
newDecoder.setBlock(opt_bytes, opt_start, opt_length); | ||
} | ||
return newDecoder; | ||
} | ||
else { | ||
return new BinaryDecoder(opt_bytes, opt_start, opt_length); | ||
} | ||
} | ||
constructor(opt_bytes, opt_start, opt_length) { | ||
@@ -37,18 +53,2 @@ /** | ||
/** | ||
* Pops an instance off the instance cache, or creates one if the cache is | ||
* empty. | ||
*/ | ||
static alloc(opt_bytes, opt_start, opt_length) { | ||
const newDecoder = BinaryDecoder.instanceCache_.pop(); | ||
if (newDecoder) { | ||
if (opt_bytes) { | ||
newDecoder.setBlock(opt_bytes, opt_start, opt_length); | ||
} | ||
return newDecoder; | ||
} | ||
else { | ||
return new BinaryDecoder(opt_bytes, opt_start, opt_length); | ||
} | ||
} | ||
/** | ||
* Puts this instance back in the instance cache. | ||
@@ -55,0 +55,0 @@ */ |
@@ -10,2 +10,18 @@ /* eslint-disable @typescript-eslint/unbound-method */ | ||
export class BinaryReader { | ||
/** | ||
* Pops an instance off the instance cache, or creates one if the cache is | ||
* empty. | ||
*/ | ||
static alloc(opt_bytes, opt_start, opt_length) { | ||
const newReader = BinaryReader.instanceCache_.pop(); | ||
if (newReader) { | ||
if (opt_bytes) { | ||
newReader.decoder_.setBlock(opt_bytes, opt_start, opt_length); | ||
} | ||
return newReader; | ||
} | ||
else { | ||
return new BinaryReader(opt_bytes, opt_start, opt_length); | ||
} | ||
} | ||
constructor(opt_bytes = undefined, opt_start = undefined, opt_length = undefined) { | ||
@@ -39,18 +55,2 @@ /** | ||
/** | ||
* Pops an instance off the instance cache, or creates one if the cache is | ||
* empty. | ||
*/ | ||
static alloc(opt_bytes, opt_start, opt_length) { | ||
const newReader = BinaryReader.instanceCache_.pop(); | ||
if (newReader) { | ||
if (opt_bytes) { | ||
newReader.decoder_.setBlock(opt_bytes, opt_start, opt_length); | ||
} | ||
return newReader; | ||
} | ||
else { | ||
return new BinaryReader(opt_bytes, opt_start, opt_length); | ||
} | ||
} | ||
/** | ||
* Puts this instance back in the instance cache. | ||
@@ -57,0 +57,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
export declare type ByteSource = ArrayBuffer | Uint8Array | number[] | string; | ||
export type ByteSource = ArrayBuffer | Uint8Array | number[] | string; | ||
/** | ||
@@ -3,0 +3,0 @@ * Converts any type defined in jspb.ByteSource into a Uint8Array. |
@@ -108,9 +108,9 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
_readMessage: function (msg, json) { | ||
const _typeUrl = json["typeUrl"] ?? json["type_url"]; | ||
if (_typeUrl) { | ||
msg.typeUrl = _typeUrl; | ||
const _typeUrl_ = json["typeUrl"] ?? json["type_url"]; | ||
if (_typeUrl_) { | ||
msg.typeUrl = _typeUrl_; | ||
} | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = decodeBase64Bytes(_value); | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = decodeBase64Bytes(_value_); | ||
} | ||
@@ -117,0 +117,0 @@ return msg; |
import type { ByteSource } from "protoscript"; | ||
import { BinaryReader, BinaryWriter } from "protoscript"; | ||
import { Option, SourceContext, Syntax } from "protoscript"; | ||
import * as protoscript from "protoscript"; | ||
/** | ||
@@ -28,3 +28,3 @@ * Api is a light-weight descriptor for an API Interface. | ||
*/ | ||
options: Option[]; | ||
options: protoscript.Option[]; | ||
/** | ||
@@ -58,3 +58,3 @@ * A version string for this interface. If specified, must have the form | ||
*/ | ||
sourceContext: SourceContext; | ||
sourceContext: protoscript.SourceContext; | ||
/** | ||
@@ -67,3 +67,3 @@ * Included interfaces. See [Mixin][]. | ||
*/ | ||
syntax: Syntax; | ||
syntax: protoscript.Syntax; | ||
} | ||
@@ -97,7 +97,7 @@ /** | ||
*/ | ||
options: Option[]; | ||
options: protoscript.Option[]; | ||
/** | ||
* The source syntax of this method. | ||
*/ | ||
syntax: Syntax; | ||
syntax: protoscript.Syntax; | ||
} | ||
@@ -104,0 +104,0 @@ /** |
@@ -5,3 +5,3 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
import { BinaryReader, BinaryWriter } from "protoscript"; | ||
import { Option, OptionJSON, SourceContext, SourceContextJSON, Syntax, SyntaxJSON, } from "protoscript"; | ||
import * as protoscript from "protoscript"; | ||
//========================================// | ||
@@ -32,5 +32,5 @@ // Protobuf Encode / Decode // | ||
version: "", | ||
sourceContext: SourceContext.initialize(), | ||
sourceContext: protoscript.SourceContext.initialize(), | ||
mixins: [], | ||
syntax: Syntax._fromInt(0), | ||
syntax: protoscript.Syntax._fromInt(0), | ||
}; | ||
@@ -49,3 +49,3 @@ }, | ||
if (msg.options?.length) { | ||
writer.writeRepeatedMessage(3, msg.options, Option._writeMessage); | ||
writer.writeRepeatedMessage(3, msg.options, protoscript.Option._writeMessage); | ||
} | ||
@@ -56,3 +56,3 @@ if (msg.version) { | ||
if (msg.sourceContext) { | ||
writer.writeMessage(5, msg.sourceContext, SourceContext._writeMessage); | ||
writer.writeMessage(5, msg.sourceContext, protoscript.SourceContext._writeMessage); | ||
} | ||
@@ -62,4 +62,4 @@ if (msg.mixins?.length) { | ||
} | ||
if (msg.syntax && Syntax._toInt(msg.syntax)) { | ||
writer.writeEnum(7, Syntax._toInt(msg.syntax)); | ||
if (msg.syntax && protoscript.Syntax._toInt(msg.syntax)) { | ||
writer.writeEnum(7, protoscript.Syntax._toInt(msg.syntax)); | ||
} | ||
@@ -86,4 +86,4 @@ return writer; | ||
case 3: { | ||
const m = Option.initialize(); | ||
reader.readMessage(m, Option._readMessage); | ||
const m = protoscript.Option.initialize(); | ||
reader.readMessage(m, protoscript.Option._readMessage); | ||
msg.options.push(m); | ||
@@ -97,3 +97,3 @@ break; | ||
case 5: { | ||
reader.readMessage(msg.sourceContext, SourceContext._readMessage); | ||
reader.readMessage(msg.sourceContext, protoscript.SourceContext._readMessage); | ||
break; | ||
@@ -108,3 +108,3 @@ } | ||
case 7: { | ||
msg.syntax = Syntax._fromInt(reader.readEnum()); | ||
msg.syntax = protoscript.Syntax._fromInt(reader.readEnum()); | ||
break; | ||
@@ -145,3 +145,3 @@ } | ||
options: [], | ||
syntax: Syntax._fromInt(0), | ||
syntax: protoscript.Syntax._fromInt(0), | ||
}; | ||
@@ -169,6 +169,6 @@ }, | ||
if (msg.options?.length) { | ||
writer.writeRepeatedMessage(6, msg.options, Option._writeMessage); | ||
writer.writeRepeatedMessage(6, msg.options, protoscript.Option._writeMessage); | ||
} | ||
if (msg.syntax && Syntax._toInt(msg.syntax)) { | ||
writer.writeEnum(7, Syntax._toInt(msg.syntax)); | ||
if (msg.syntax && protoscript.Syntax._toInt(msg.syntax)) { | ||
writer.writeEnum(7, protoscript.Syntax._toInt(msg.syntax)); | ||
} | ||
@@ -205,4 +205,4 @@ return writer; | ||
case 6: { | ||
const m = Option.initialize(); | ||
reader.readMessage(m, Option._readMessage); | ||
const m = protoscript.Option.initialize(); | ||
reader.readMessage(m, protoscript.Option._readMessage); | ||
msg.options.push(m); | ||
@@ -212,3 +212,3 @@ break; | ||
case 7: { | ||
msg.syntax = Syntax._fromInt(reader.readEnum()); | ||
msg.syntax = protoscript.Syntax._fromInt(reader.readEnum()); | ||
break; | ||
@@ -308,5 +308,5 @@ } | ||
version: "", | ||
sourceContext: SourceContext.initialize(), | ||
sourceContext: protoscript.SourceContextJSON.initialize(), | ||
mixins: [], | ||
syntax: Syntax._fromInt(0), | ||
syntax: protoscript.Syntax._fromInt(0), | ||
}; | ||
@@ -326,3 +326,3 @@ }, | ||
if (msg.options?.length) { | ||
json["options"] = msg.options.map(OptionJSON._writeMessage); | ||
json["options"] = msg.options.map(protoscript.OptionJSON._writeMessage); | ||
} | ||
@@ -333,5 +333,5 @@ if (msg.version) { | ||
if (msg.sourceContext) { | ||
const sourceContext = SourceContextJSON._writeMessage(msg.sourceContext); | ||
if (Object.keys(sourceContext).length > 0) { | ||
json["sourceContext"] = sourceContext; | ||
const _sourceContext_ = protoscript.SourceContextJSON._writeMessage(msg.sourceContext); | ||
if (Object.keys(_sourceContext_).length > 0) { | ||
json["sourceContext"] = _sourceContext_; | ||
} | ||
@@ -342,3 +342,3 @@ } | ||
} | ||
if (msg.syntax && SyntaxJSON._toInt(msg.syntax)) { | ||
if (msg.syntax && protoscript.SyntaxJSON._toInt(msg.syntax)) { | ||
json["syntax"] = msg.syntax; | ||
@@ -352,10 +352,10 @@ } | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _methods = json["methods"]; | ||
if (_methods) { | ||
for (const item of _methods) { | ||
const m = Method.initialize(); | ||
const _methods_ = json["methods"]; | ||
if (_methods_) { | ||
for (const item of _methods_) { | ||
const m = MethodJSON.initialize(); | ||
MethodJSON._readMessage(m, item); | ||
@@ -365,24 +365,24 @@ msg.methods.push(m); | ||
} | ||
const _options = json["options"]; | ||
if (_options) { | ||
for (const item of _options) { | ||
const m = Option.initialize(); | ||
OptionJSON._readMessage(m, item); | ||
const _options_ = json["options"]; | ||
if (_options_) { | ||
for (const item of _options_) { | ||
const m = protoscript.OptionJSON.initialize(); | ||
protoscript.OptionJSON._readMessage(m, item); | ||
msg.options.push(m); | ||
} | ||
} | ||
const _version = json["version"]; | ||
if (_version) { | ||
msg.version = _version; | ||
const _version_ = json["version"]; | ||
if (_version_) { | ||
msg.version = _version_; | ||
} | ||
const _sourceContext = json["sourceContext"] ?? json["source_context"]; | ||
if (_sourceContext) { | ||
const m = SourceContext.initialize(); | ||
SourceContextJSON._readMessage(m, _sourceContext); | ||
const _sourceContext_ = json["sourceContext"] ?? json["source_context"]; | ||
if (_sourceContext_) { | ||
const m = protoscript.SourceContextJSON.initialize(); | ||
protoscript.SourceContextJSON._readMessage(m, _sourceContext_); | ||
msg.sourceContext = m; | ||
} | ||
const _mixins = json["mixins"]; | ||
if (_mixins) { | ||
for (const item of _mixins) { | ||
const m = Mixin.initialize(); | ||
const _mixins_ = json["mixins"]; | ||
if (_mixins_) { | ||
for (const item of _mixins_) { | ||
const m = MixinJSON.initialize(); | ||
MixinJSON._readMessage(m, item); | ||
@@ -392,5 +392,5 @@ msg.mixins.push(m); | ||
} | ||
const _syntax = json["syntax"]; | ||
if (_syntax) { | ||
msg.syntax = _syntax; | ||
const _syntax_ = json["syntax"]; | ||
if (_syntax_) { | ||
msg.syntax = _syntax_; | ||
} | ||
@@ -424,3 +424,3 @@ return msg; | ||
options: [], | ||
syntax: Syntax._fromInt(0), | ||
syntax: protoscript.Syntax._fromInt(0), | ||
}; | ||
@@ -449,5 +449,5 @@ }, | ||
if (msg.options?.length) { | ||
json["options"] = msg.options.map(OptionJSON._writeMessage); | ||
json["options"] = msg.options.map(protoscript.OptionJSON._writeMessage); | ||
} | ||
if (msg.syntax && SyntaxJSON._toInt(msg.syntax)) { | ||
if (msg.syntax && protoscript.SyntaxJSON._toInt(msg.syntax)) { | ||
json["syntax"] = msg.syntax; | ||
@@ -461,33 +461,33 @@ } | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _requestTypeUrl = json["requestTypeUrl"] ?? json["request_type_url"]; | ||
if (_requestTypeUrl) { | ||
msg.requestTypeUrl = _requestTypeUrl; | ||
const _requestTypeUrl_ = json["requestTypeUrl"] ?? json["request_type_url"]; | ||
if (_requestTypeUrl_) { | ||
msg.requestTypeUrl = _requestTypeUrl_; | ||
} | ||
const _requestStreaming = json["requestStreaming"] ?? json["request_streaming"]; | ||
if (_requestStreaming) { | ||
msg.requestStreaming = _requestStreaming; | ||
const _requestStreaming_ = json["requestStreaming"] ?? json["request_streaming"]; | ||
if (_requestStreaming_) { | ||
msg.requestStreaming = _requestStreaming_; | ||
} | ||
const _responseTypeUrl = json["responseTypeUrl"] ?? json["response_type_url"]; | ||
if (_responseTypeUrl) { | ||
msg.responseTypeUrl = _responseTypeUrl; | ||
const _responseTypeUrl_ = json["responseTypeUrl"] ?? json["response_type_url"]; | ||
if (_responseTypeUrl_) { | ||
msg.responseTypeUrl = _responseTypeUrl_; | ||
} | ||
const _responseStreaming = json["responseStreaming"] ?? json["response_streaming"]; | ||
if (_responseStreaming) { | ||
msg.responseStreaming = _responseStreaming; | ||
const _responseStreaming_ = json["responseStreaming"] ?? json["response_streaming"]; | ||
if (_responseStreaming_) { | ||
msg.responseStreaming = _responseStreaming_; | ||
} | ||
const _options = json["options"]; | ||
if (_options) { | ||
for (const item of _options) { | ||
const m = Option.initialize(); | ||
OptionJSON._readMessage(m, item); | ||
const _options_ = json["options"]; | ||
if (_options_) { | ||
for (const item of _options_) { | ||
const m = protoscript.OptionJSON.initialize(); | ||
protoscript.OptionJSON._readMessage(m, item); | ||
msg.options.push(m); | ||
} | ||
} | ||
const _syntax = json["syntax"]; | ||
if (_syntax) { | ||
msg.syntax = _syntax; | ||
const _syntax_ = json["syntax"]; | ||
if (_syntax_) { | ||
msg.syntax = _syntax_; | ||
} | ||
@@ -536,9 +536,9 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _root = json["root"]; | ||
if (_root) { | ||
msg.root = _root; | ||
const _root_ = json["root"]; | ||
if (_root_) { | ||
msg.root = _root_; | ||
} | ||
@@ -545,0 +545,0 @@ return msg; |
@@ -108,9 +108,9 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
_readMessage: function (msg, json) { | ||
const _seconds = json["seconds"]; | ||
if (_seconds) { | ||
msg.seconds = BigInt(_seconds); | ||
const _seconds_ = json["seconds"]; | ||
if (_seconds_) { | ||
msg.seconds = BigInt(_seconds_); | ||
} | ||
const _nanos = json["nanos"]; | ||
if (_nanos) { | ||
msg.nanos = _nanos; | ||
const _nanos_ = json["nanos"]; | ||
if (_nanos_) { | ||
msg.nanos = _nanos_; | ||
} | ||
@@ -117,0 +117,0 @@ return msg; |
@@ -96,5 +96,5 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
_readMessage: function (msg, json) { | ||
const _paths = json["paths"]; | ||
if (_paths) { | ||
msg.paths = _paths; | ||
const _paths_ = json["paths"]; | ||
if (_paths_) { | ||
msg.paths = _paths_; | ||
} | ||
@@ -101,0 +101,0 @@ return msg; |
@@ -96,5 +96,5 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
_readMessage: function (msg, json) { | ||
const _fileName = json["fileName"] ?? json["file_name"]; | ||
if (_fileName) { | ||
msg.fileName = _fileName; | ||
const _fileName_ = json["fileName"] ?? json["file_name"]; | ||
if (_fileName_) { | ||
msg.fileName = _fileName_; | ||
} | ||
@@ -101,0 +101,0 @@ return msg; |
@@ -9,3 +9,3 @@ import type { ByteSource } from "protoscript"; | ||
*/ | ||
export declare type NullValue = "NULL_VALUE"; | ||
export type NullValue = "NULL_VALUE"; | ||
/** | ||
@@ -12,0 +12,0 @@ * `Struct` represents a structured data value, consisting of fields |
@@ -343,8 +343,8 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
if (msg.fields) { | ||
const fields = Object.fromEntries(Object.entries(msg.fields) | ||
const _fields_ = Object.fromEntries(Object.entries(msg.fields) | ||
.map(([key, value]) => ({ key: key, value: value })) | ||
.map(StructJSON.Fields._writeMessage) | ||
.map(({ key, value }) => [key, value])); | ||
if (Object.keys(fields).length > 0) { | ||
json["fields"] = fields; | ||
if (Object.keys(_fields_).length > 0) { | ||
json["fields"] = _fields_; | ||
} | ||
@@ -358,5 +358,5 @@ } | ||
_readMessage: function (msg, json) { | ||
const _fields = json["fields"]; | ||
if (_fields) { | ||
msg.fields = Object.fromEntries(Object.entries(_fields) | ||
const _fields_ = json["fields"]; | ||
if (_fields_) { | ||
msg.fields = Object.fromEntries(Object.entries(_fields_) | ||
.map(([key, value]) => ({ key: key, value: value })) | ||
@@ -378,5 +378,5 @@ .map(StructJSON.Fields._readMessage) | ||
if (msg.value) { | ||
const value = ValueJSON._writeMessage(msg.value); | ||
if (Object.keys(value).length > 0) { | ||
json["value"] = value; | ||
const _value_ = ValueJSON._writeMessage(msg.value); | ||
if (Object.keys(_value_).length > 0) { | ||
json["value"] = _value_; | ||
} | ||
@@ -390,10 +390,10 @@ } | ||
_readMessage: function (msg, json) { | ||
const _key = json["key"]; | ||
if (_key) { | ||
msg.key = _key; | ||
const _key_ = json["key"]; | ||
if (_key_) { | ||
msg.key = _key_; | ||
} | ||
const _value = json["value"]; | ||
if (_value) { | ||
const m = Value.initialize(); | ||
ValueJSON._readMessage(m, _value); | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
const m = ValueJSON.initialize(); | ||
ValueJSON._readMessage(m, _value_); | ||
msg.value = m; | ||
@@ -449,8 +449,8 @@ } | ||
if (msg.structValue != undefined) { | ||
const structValue = StructJSON._writeMessage(msg.structValue); | ||
json["structValue"] = structValue; | ||
const _structValue_ = StructJSON._writeMessage(msg.structValue); | ||
json["structValue"] = _structValue_; | ||
} | ||
if (msg.listValue != undefined) { | ||
const listValue = ListValueJSON._writeMessage(msg.listValue); | ||
json["listValue"] = listValue; | ||
const _listValue_ = ListValueJSON._writeMessage(msg.listValue); | ||
json["listValue"] = _listValue_; | ||
} | ||
@@ -463,28 +463,28 @@ return json; | ||
_readMessage: function (msg, json) { | ||
const _nullValue = json["nullValue"] ?? json["null_value"]; | ||
if (_nullValue) { | ||
msg.nullValue = _nullValue; | ||
const _nullValue_ = json["nullValue"] ?? json["null_value"]; | ||
if (_nullValue_) { | ||
msg.nullValue = _nullValue_; | ||
} | ||
const _numberValue = json["numberValue"] ?? json["number_value"]; | ||
if (_numberValue) { | ||
msg.numberValue = _numberValue; | ||
const _numberValue_ = json["numberValue"] ?? json["number_value"]; | ||
if (_numberValue_) { | ||
msg.numberValue = _numberValue_; | ||
} | ||
const _stringValue = json["stringValue"] ?? json["string_value"]; | ||
if (_stringValue) { | ||
msg.stringValue = _stringValue; | ||
const _stringValue_ = json["stringValue"] ?? json["string_value"]; | ||
if (_stringValue_) { | ||
msg.stringValue = _stringValue_; | ||
} | ||
const _boolValue = json["boolValue"] ?? json["bool_value"]; | ||
if (_boolValue) { | ||
msg.boolValue = _boolValue; | ||
const _boolValue_ = json["boolValue"] ?? json["bool_value"]; | ||
if (_boolValue_) { | ||
msg.boolValue = _boolValue_; | ||
} | ||
const _structValue = json["structValue"] ?? json["struct_value"]; | ||
if (_structValue) { | ||
const m = Struct.initialize(); | ||
StructJSON._readMessage(m, _structValue); | ||
const _structValue_ = json["structValue"] ?? json["struct_value"]; | ||
if (_structValue_) { | ||
const m = StructJSON.initialize(); | ||
StructJSON._readMessage(m, _structValue_); | ||
msg.structValue = m; | ||
} | ||
const _listValue = json["listValue"] ?? json["list_value"]; | ||
if (_listValue) { | ||
const m = ListValue.initialize(); | ||
ListValueJSON._readMessage(m, _listValue); | ||
const _listValue_ = json["listValue"] ?? json["list_value"]; | ||
if (_listValue_) { | ||
const m = ListValueJSON.initialize(); | ||
ListValueJSON._readMessage(m, _listValue_); | ||
msg.listValue = m; | ||
@@ -530,6 +530,6 @@ } | ||
_readMessage: function (msg, json) { | ||
const _values = json["values"]; | ||
if (_values) { | ||
for (const item of _values) { | ||
const m = Value.initialize(); | ||
const _values_ = json["values"]; | ||
if (_values_) { | ||
for (const item of _values_) { | ||
const m = ValueJSON.initialize(); | ||
ValueJSON._readMessage(m, item); | ||
@@ -536,0 +536,0 @@ msg.values.push(m); |
@@ -108,9 +108,9 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
_readMessage: function (msg, json) { | ||
const _seconds = json["seconds"]; | ||
if (_seconds) { | ||
msg.seconds = BigInt(_seconds); | ||
const _seconds_ = json["seconds"]; | ||
if (_seconds_) { | ||
msg.seconds = BigInt(_seconds_); | ||
} | ||
const _nanos = json["nanos"]; | ||
if (_nanos) { | ||
msg.nanos = _nanos; | ||
const _nanos_ = json["nanos"]; | ||
if (_nanos_) { | ||
msg.nanos = _nanos_; | ||
} | ||
@@ -117,0 +117,0 @@ return msg; |
import type { ByteSource } from "protoscript"; | ||
import { BinaryReader, BinaryWriter } from "protoscript"; | ||
import { SourceContext, Any } from "protoscript"; | ||
import * as protoscript from "protoscript"; | ||
/** | ||
* The syntax in which a protocol buffer element is defined. | ||
*/ | ||
export declare type Syntax = "SYNTAX_PROTO2" | "SYNTAX_PROTO3"; | ||
export type Syntax = "SYNTAX_PROTO2" | "SYNTAX_PROTO3"; | ||
/** | ||
@@ -31,3 +31,3 @@ * A protocol buffer message type. | ||
*/ | ||
sourceContext: SourceContext; | ||
sourceContext: protoscript.SourceContext; | ||
/** | ||
@@ -114,3 +114,3 @@ * The source syntax. | ||
*/ | ||
sourceContext: SourceContext; | ||
sourceContext: protoscript.SourceContext; | ||
/** | ||
@@ -156,3 +156,3 @@ * The source syntax. | ||
*/ | ||
value: Any; | ||
value: protoscript.Any; | ||
} | ||
@@ -159,0 +159,0 @@ export declare const Syntax: { |
@@ -5,3 +5,3 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
import { BinaryReader, BinaryWriter } from "protoscript"; | ||
import { SourceContext, SourceContextJSON, Any, AnyJSON } from "protoscript"; | ||
import * as protoscript from "protoscript"; | ||
//========================================// | ||
@@ -76,3 +76,3 @@ // Protobuf Encode / Decode // | ||
options: [], | ||
sourceContext: SourceContext.initialize(), | ||
sourceContext: protoscript.SourceContext.initialize(), | ||
syntax: Syntax._fromInt(0), | ||
@@ -98,3 +98,3 @@ }; | ||
if (msg.sourceContext) { | ||
writer.writeMessage(5, msg.sourceContext, SourceContext._writeMessage); | ||
writer.writeMessage(5, msg.sourceContext, protoscript.SourceContext._writeMessage); | ||
} | ||
@@ -134,3 +134,3 @@ if (msg.syntax && Syntax._toInt(msg.syntax)) { | ||
case 5: { | ||
reader.readMessage(msg.sourceContext, SourceContext._readMessage); | ||
reader.readMessage(msg.sourceContext, protoscript.SourceContext._readMessage); | ||
break; | ||
@@ -574,3 +574,3 @@ } | ||
options: [], | ||
sourceContext: SourceContext.initialize(), | ||
sourceContext: protoscript.SourceContext.initialize(), | ||
syntax: Syntax._fromInt(0), | ||
@@ -593,3 +593,3 @@ }; | ||
if (msg.sourceContext) { | ||
writer.writeMessage(4, msg.sourceContext, SourceContext._writeMessage); | ||
writer.writeMessage(4, msg.sourceContext, protoscript.SourceContext._writeMessage); | ||
} | ||
@@ -625,3 +625,3 @@ if (msg.syntax && Syntax._toInt(msg.syntax)) { | ||
case 4: { | ||
reader.readMessage(msg.sourceContext, SourceContext._readMessage); | ||
reader.readMessage(msg.sourceContext, protoscript.SourceContext._readMessage); | ||
break; | ||
@@ -729,3 +729,3 @@ } | ||
name: "", | ||
value: Any.initialize(), | ||
value: protoscript.Any.initialize(), | ||
}; | ||
@@ -741,3 +741,3 @@ }, | ||
if (msg.value) { | ||
writer.writeMessage(2, msg.value, Any._writeMessage); | ||
writer.writeMessage(2, msg.value, protoscript.Any._writeMessage); | ||
} | ||
@@ -758,3 +758,3 @@ return writer; | ||
case 2: { | ||
reader.readMessage(msg.value, Any._readMessage); | ||
reader.readMessage(msg.value, protoscript.Any._readMessage); | ||
break; | ||
@@ -840,3 +840,3 @@ } | ||
options: [], | ||
sourceContext: SourceContext.initialize(), | ||
sourceContext: protoscript.SourceContextJSON.initialize(), | ||
syntax: Syntax._fromInt(0), | ||
@@ -863,5 +863,5 @@ }; | ||
if (msg.sourceContext) { | ||
const sourceContext = SourceContextJSON._writeMessage(msg.sourceContext); | ||
if (Object.keys(sourceContext).length > 0) { | ||
json["sourceContext"] = sourceContext; | ||
const _sourceContext_ = protoscript.SourceContextJSON._writeMessage(msg.sourceContext); | ||
if (Object.keys(_sourceContext_).length > 0) { | ||
json["sourceContext"] = _sourceContext_; | ||
} | ||
@@ -878,10 +878,10 @@ } | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _fields = json["fields"]; | ||
if (_fields) { | ||
for (const item of _fields) { | ||
const m = Field.initialize(); | ||
const _fields_ = json["fields"]; | ||
if (_fields_) { | ||
for (const item of _fields_) { | ||
const m = FieldJSON.initialize(); | ||
FieldJSON._readMessage(m, item); | ||
@@ -891,10 +891,10 @@ msg.fields.push(m); | ||
} | ||
const _oneofs = json["oneofs"]; | ||
if (_oneofs) { | ||
msg.oneofs = _oneofs; | ||
const _oneofs_ = json["oneofs"]; | ||
if (_oneofs_) { | ||
msg.oneofs = _oneofs_; | ||
} | ||
const _options = json["options"]; | ||
if (_options) { | ||
for (const item of _options) { | ||
const m = Option.initialize(); | ||
const _options_ = json["options"]; | ||
if (_options_) { | ||
for (const item of _options_) { | ||
const m = OptionJSON.initialize(); | ||
OptionJSON._readMessage(m, item); | ||
@@ -904,11 +904,11 @@ msg.options.push(m); | ||
} | ||
const _sourceContext = json["sourceContext"] ?? json["source_context"]; | ||
if (_sourceContext) { | ||
const m = SourceContext.initialize(); | ||
SourceContextJSON._readMessage(m, _sourceContext); | ||
const _sourceContext_ = json["sourceContext"] ?? json["source_context"]; | ||
if (_sourceContext_) { | ||
const m = protoscript.SourceContextJSON.initialize(); | ||
protoscript.SourceContextJSON._readMessage(m, _sourceContext_); | ||
msg.sourceContext = m; | ||
} | ||
const _syntax = json["syntax"]; | ||
if (_syntax) { | ||
msg.syntax = _syntax; | ||
const _syntax_ = json["syntax"]; | ||
if (_syntax_) { | ||
msg.syntax = _syntax_; | ||
} | ||
@@ -989,34 +989,34 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _kind = json["kind"]; | ||
if (_kind) { | ||
msg.kind = _kind; | ||
const _kind_ = json["kind"]; | ||
if (_kind_) { | ||
msg.kind = _kind_; | ||
} | ||
const _cardinality = json["cardinality"]; | ||
if (_cardinality) { | ||
msg.cardinality = _cardinality; | ||
const _cardinality_ = json["cardinality"]; | ||
if (_cardinality_) { | ||
msg.cardinality = _cardinality_; | ||
} | ||
const _number = json["number"]; | ||
if (_number) { | ||
msg.number = _number; | ||
const _number_ = json["number"]; | ||
if (_number_) { | ||
msg.number = _number_; | ||
} | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _typeUrl = json["typeUrl"] ?? json["type_url"]; | ||
if (_typeUrl) { | ||
msg.typeUrl = _typeUrl; | ||
const _typeUrl_ = json["typeUrl"] ?? json["type_url"]; | ||
if (_typeUrl_) { | ||
msg.typeUrl = _typeUrl_; | ||
} | ||
const _oneofIndex = json["oneofIndex"] ?? json["oneof_index"]; | ||
if (_oneofIndex) { | ||
msg.oneofIndex = _oneofIndex; | ||
const _oneofIndex_ = json["oneofIndex"] ?? json["oneof_index"]; | ||
if (_oneofIndex_) { | ||
msg.oneofIndex = _oneofIndex_; | ||
} | ||
const _packed = json["packed"]; | ||
if (_packed) { | ||
msg.packed = _packed; | ||
const _packed_ = json["packed"]; | ||
if (_packed_) { | ||
msg.packed = _packed_; | ||
} | ||
const _options = json["options"]; | ||
if (_options) { | ||
for (const item of _options) { | ||
const m = Option.initialize(); | ||
const _options_ = json["options"]; | ||
if (_options_) { | ||
for (const item of _options_) { | ||
const m = OptionJSON.initialize(); | ||
OptionJSON._readMessage(m, item); | ||
@@ -1026,9 +1026,9 @@ msg.options.push(m); | ||
} | ||
const _jsonName = json["jsonName"] ?? json["json_name"]; | ||
if (_jsonName) { | ||
msg.jsonName = _jsonName; | ||
const _jsonName_ = json["jsonName"] ?? json["json_name"]; | ||
if (_jsonName_) { | ||
msg.jsonName = _jsonName_; | ||
} | ||
const _defaultValue = json["defaultValue"] ?? json["default_value"]; | ||
if (_defaultValue) { | ||
msg.defaultValue = _defaultValue; | ||
const _defaultValue_ = json["defaultValue"] ?? json["default_value"]; | ||
if (_defaultValue_) { | ||
msg.defaultValue = _defaultValue_; | ||
} | ||
@@ -1337,3 +1337,3 @@ return msg; | ||
options: [], | ||
sourceContext: SourceContext.initialize(), | ||
sourceContext: protoscript.SourceContextJSON.initialize(), | ||
syntax: Syntax._fromInt(0), | ||
@@ -1357,5 +1357,5 @@ }; | ||
if (msg.sourceContext) { | ||
const sourceContext = SourceContextJSON._writeMessage(msg.sourceContext); | ||
if (Object.keys(sourceContext).length > 0) { | ||
json["sourceContext"] = sourceContext; | ||
const _sourceContext_ = protoscript.SourceContextJSON._writeMessage(msg.sourceContext); | ||
if (Object.keys(_sourceContext_).length > 0) { | ||
json["sourceContext"] = _sourceContext_; | ||
} | ||
@@ -1372,10 +1372,10 @@ } | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _enumvalue = json["enumvalue"]; | ||
if (_enumvalue) { | ||
for (const item of _enumvalue) { | ||
const m = EnumValue.initialize(); | ||
const _enumvalue_ = json["enumvalue"]; | ||
if (_enumvalue_) { | ||
for (const item of _enumvalue_) { | ||
const m = EnumValueJSON.initialize(); | ||
EnumValueJSON._readMessage(m, item); | ||
@@ -1385,6 +1385,6 @@ msg.enumvalue.push(m); | ||
} | ||
const _options = json["options"]; | ||
if (_options) { | ||
for (const item of _options) { | ||
const m = Option.initialize(); | ||
const _options_ = json["options"]; | ||
if (_options_) { | ||
for (const item of _options_) { | ||
const m = OptionJSON.initialize(); | ||
OptionJSON._readMessage(m, item); | ||
@@ -1394,11 +1394,11 @@ msg.options.push(m); | ||
} | ||
const _sourceContext = json["sourceContext"] ?? json["source_context"]; | ||
if (_sourceContext) { | ||
const m = SourceContext.initialize(); | ||
SourceContextJSON._readMessage(m, _sourceContext); | ||
const _sourceContext_ = json["sourceContext"] ?? json["source_context"]; | ||
if (_sourceContext_) { | ||
const m = protoscript.SourceContextJSON.initialize(); | ||
protoscript.SourceContextJSON._readMessage(m, _sourceContext_); | ||
msg.sourceContext = m; | ||
} | ||
const _syntax = json["syntax"]; | ||
if (_syntax) { | ||
msg.syntax = _syntax; | ||
const _syntax_ = json["syntax"]; | ||
if (_syntax_) { | ||
msg.syntax = _syntax_; | ||
} | ||
@@ -1451,14 +1451,14 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _number = json["number"]; | ||
if (_number) { | ||
msg.number = _number; | ||
const _number_ = json["number"]; | ||
if (_number_) { | ||
msg.number = _number_; | ||
} | ||
const _options = json["options"]; | ||
if (_options) { | ||
for (const item of _options) { | ||
const m = Option.initialize(); | ||
const _options_ = json["options"]; | ||
if (_options_) { | ||
for (const item of _options_) { | ||
const m = OptionJSON.initialize(); | ||
OptionJSON._readMessage(m, item); | ||
@@ -1490,3 +1490,3 @@ msg.options.push(m); | ||
name: "", | ||
value: Any.initialize(), | ||
value: protoscript.AnyJSON.initialize(), | ||
}; | ||
@@ -1503,5 +1503,5 @@ }, | ||
if (msg.value) { | ||
const value = AnyJSON._writeMessage(msg.value); | ||
if (Object.keys(value).length > 0) { | ||
json["value"] = value; | ||
const _value_ = protoscript.AnyJSON._writeMessage(msg.value); | ||
if (Object.keys(_value_).length > 0) { | ||
json["value"] = _value_; | ||
} | ||
@@ -1515,10 +1515,10 @@ } | ||
_readMessage: function (msg, json) { | ||
const _name = json["name"]; | ||
if (_name) { | ||
msg.name = _name; | ||
const _name_ = json["name"]; | ||
if (_name_) { | ||
msg.name = _name_; | ||
} | ||
const _value = json["value"]; | ||
if (_value) { | ||
const m = Any.initialize(); | ||
AnyJSON._readMessage(m, _value); | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
const m = protoscript.AnyJSON.initialize(); | ||
protoscript.AnyJSON._readMessage(m, _value_); | ||
msg.value = m; | ||
@@ -1525,0 +1525,0 @@ } |
@@ -496,5 +496,5 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = _value; | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = _value_; | ||
} | ||
@@ -539,5 +539,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = _value; | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = _value_; | ||
} | ||
@@ -582,5 +582,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = BigInt(_value); | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = BigInt(_value_); | ||
} | ||
@@ -625,5 +625,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = BigInt(_value); | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = BigInt(_value_); | ||
} | ||
@@ -668,5 +668,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = _value; | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = _value_; | ||
} | ||
@@ -711,5 +711,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = _value; | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = _value_; | ||
} | ||
@@ -754,5 +754,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = _value; | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = _value_; | ||
} | ||
@@ -797,5 +797,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = _value; | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = _value_; | ||
} | ||
@@ -840,5 +840,5 @@ return msg; | ||
_readMessage: function (msg, json) { | ||
const _value = json["value"]; | ||
if (_value) { | ||
msg.value = decodeBase64Bytes(_value); | ||
const _value_ = json["value"]; | ||
if (_value_) { | ||
msg.value = decodeBase64Bytes(_value_); | ||
} | ||
@@ -845,0 +845,0 @@ return msg; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67
654625
21525