Debian Codegraph @

node/@bufbuild/protobuf/dist/commonjs/registry.d.ts

raw
1 import type { FileDescriptorProto, FileDescriptorSet } from "./wkt/gen/google/protobuf/descriptor_pb.js";
2 import { type DescEnum, type DescExtension, type DescFile, type DescMessage, type DescService, type SupportedEdition } from "./descriptors.js";
3 /**
4 * A set of descriptors for messages, enumerations, extensions,
5 * and services.
6 */
7 export interface Registry {
8 readonly kind: "registry";
9 /**
10 * All types (message, enumeration, extension, or service) contained
11 * in this registry.
12 */
13 [Symbol.iterator](): IterableIterator<DescMessage | DescEnum | DescExtension | DescService>;
14 /**
15 * Look up a type (message, enumeration, extension, or service) by
16 * its fully qualified name.
17 */
18 get(typeName: string): DescMessage | DescEnum | DescExtension | DescService | undefined;
19 /**
20 * Look up a message descriptor by its fully qualified name.
21 */
22 getMessage(typeName: string): DescMessage | undefined;
23 /**
24 * Look up an enumeration descriptor by its fully qualified name.
25 */
26 getEnum(typeName: string): DescEnum | undefined;
27 /**
28 * Look up an extension descriptor by its fully qualified name.
29 */
30 getExtension(typeName: string): DescExtension | undefined;
31 /**
32 * Look up an extension by the extendee - the message it extends - and
33 * the extension number.
34 */
35 getExtensionFor(extendee: DescMessage, no: number): DescExtension | undefined;
36 /**
37 * Look up a service descriptor by its fully qualified name.
38 */
39 getService(typeName: string): DescService | undefined;
40 }
41 /**
42 * A registry that allows adding and removing descriptors.
43 */
44 export interface MutableRegistry extends Registry {
45 /**
46 * Adds the given descriptor - but not types nested within - to the registry.
47 */
48 add(desc: DescMessage | DescEnum | DescExtension | DescService): void;
49 /**
50 * Remove the given descriptor - but not types nested within - from the registry.
51 */
52 remove(desc: DescMessage | DescEnum | DescExtension | DescService): void;
53 }
54 /**
55 * A registry that includes files.
56 */
57 export interface FileRegistry extends Registry {
58 /**
59 * All files in this registry.
60 */
61 readonly files: Iterable<DescFile>;
62 /**
63 * Look up a file descriptor by file name.
64 */
65 getFile(fileName: string): DescFile | undefined;
66 }
67 /**
68 * Create a registry from the given inputs.
69 *
70 * An input can be:
71 * - Any message, enum, service, or extension descriptor, which adds just the
72 * descriptor for this type.
73 * - A file descriptor, which adds all typed defined in this file.
74 * - A registry, which adds all types from the registry.
75 *
76 * For duplicate descriptors (same type name), the one given last wins.
77 */
78 export declare function createRegistry(...input: (Registry | DescFile | DescMessage | DescEnum | DescExtension | DescService)[]): Registry;
79 /**
80 * Create a registry that allows adding and removing descriptors.
81 */
82 export declare function createMutableRegistry(...input: (Registry | DescFile | DescMessage | DescEnum | DescExtension | DescService)[]): MutableRegistry;
83 /**
84 * Create a registry (including file descriptors) from a google.protobuf.FileDescriptorSet
85 * message.
86 */
87 export declare function createFileRegistry(fileDescriptorSet: FileDescriptorSet): FileRegistry;
88 /**
89 * Create a registry (including file descriptors) from a google.protobuf.FileDescriptorProto
90 * message. For every import, the given resolver function is called.
91 */
92 export declare function createFileRegistry(fileDescriptorProto: FileDescriptorProto, resolve: (protoFileName: string) => FileDescriptorProto | DescFile | undefined): FileRegistry;
93 /**
94 * Create a registry (including file descriptors) from one or more registries,
95 * merging them.
96 */
97 export declare function createFileRegistry(...registries: FileRegistry[]): FileRegistry;
98 export declare const minimumEdition: SupportedEdition, maximumEdition: SupportedEdition;