import type { CodeGeneratorRequest } from "google-protobuf/google/protobuf/compiler/plugin_pb.js"; import type { DescriptorProto, FileDescriptorProto, EnumDescriptorProto, FieldDescriptorProto as FieldDescriptorProtoType } from "google-protobuf/google/protobuf/descriptor_pb.js"; import type { BinaryReader, BinaryWriter } from "google-protobuf"; export declare function lowerCase(str: string): string; export declare function uniqueBy(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 { defaultValue: string; jsonParser: string; jsonSerializer: string; map: boolean; optional: boolean; read: ReaderMethod; readPacked: ReaderMethod | undefined; repeated: boolean; tsType: string; tsTypeJSON: string; write: WriterMethod; } export declare function getDescriptor(field: FieldDescriptorProtoType, identifierTable: IdentifierTable, fileDescriptorProto: FileDescriptorProto): Descriptor | undefined; export declare function getProtobufTSFileName(protoFileName: string): string; export declare function getProtobufJSFileName(protoFileName: string): string; export declare const KNOWN_TYPES: string[]; /** * [namespacedIdentifier, file, package, publicImport] */ export type IdentifierTable = { namespacedIdentifier: string; file: string; package: string; publicImport: string | undefined; descriptorProto: DescriptorProto | EnumDescriptorProto; }[]; /** * Example * '.protobuf_unittest_import.PublicImportMessage', 'google/protobuf/unittest_import_public.proto', 'protobuf_unittest_import', 'protobuf_unittest_import_public' */ export declare function buildIdentifierTable(request: CodeGeneratorRequest): IdentifierTable; export interface Import { identifier: string; path: string; moduleName: string; } interface Comments { leading: string | undefined; trailing: string | undefined; } interface EnumOpts { name: string; namespacedName: string; namespacedNameJSON: string; values: { name: string; value: number; comments?: Comments; }[]; comments?: Comments; } interface Field extends Descriptor { comments?: Comments; index: number; jsonName: string | undefined; name: string; protoName: string; } interface MessageOpts { name: string; namespacedName: string; namespacedNameJSON: string; fields: Field[]; comments?: Comments; isMap: boolean; } export type EnumType = { type: "enum"; content: EnumOpts; }; export type MessageType = { type: "message"; content: MessageOpts; children: ProtoTypes[]; }; export type ProtoTypes = EnumType | MessageType; export interface Service { name: string; methods: { name: string; input: string; inputJSON: string; output: string; outputJSON: string; comments?: Comments; }[]; comments?: Comments; } export interface ParsedAst { packageName: string | undefined; imports: { identifiers: string[]; moduleName: string; path: string; }[]; types: ProtoTypes[]; services: Service[]; } export declare function processTypes(fileDescriptorProto: FileDescriptorProto, identifierTable: IdentifierTable, isTS: boolean): ParsedAst; export {};