@bufbuild/protobuf 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/cjs/binary-encoding.js +434 -0
- package/dist/cjs/binary-format.js +2 -0
- package/dist/cjs/descriptor-registry.js +518 -0
- package/dist/cjs/descriptor-set.js +557 -0
- package/dist/cjs/enum.js +2 -0
- package/dist/cjs/field-list.js +2 -0
- package/dist/cjs/field.js +40 -0
- package/dist/cjs/google/protobuf/any_pb.js +280 -0
- package/dist/cjs/google/protobuf/api_pb.js +383 -0
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +334 -0
- package/dist/cjs/google/protobuf/descriptor_pb.js +2311 -0
- package/dist/cjs/google/protobuf/duration_pb.js +201 -0
- package/dist/cjs/google/protobuf/empty_pb.js +72 -0
- package/dist/cjs/google/protobuf/field_mask_pb.js +347 -0
- package/dist/cjs/google/protobuf/source_context_pb.js +74 -0
- package/dist/cjs/google/protobuf/struct_pb.js +288 -0
- package/dist/cjs/google/protobuf/timestamp_pb.js +271 -0
- package/dist/cjs/google/protobuf/type_pb.js +613 -0
- package/dist/cjs/google/protobuf/wrappers_pb.js +658 -0
- package/dist/cjs/google/varint.js +280 -0
- package/dist/cjs/index.js +148 -0
- package/dist/cjs/json-format.js +2 -0
- package/dist/cjs/message-type.js +2 -0
- package/dist/cjs/message.js +98 -0
- package/dist/cjs/private/assert.js +52 -0
- package/dist/cjs/private/base64.js +118 -0
- package/dist/cjs/private/binary-format-common.js +253 -0
- package/dist/cjs/private/binary-format-proto2.js +120 -0
- package/dist/cjs/private/binary-format-proto3.js +102 -0
- package/dist/cjs/private/enum.js +70 -0
- package/dist/cjs/private/field-list.js +62 -0
- package/dist/cjs/private/field-wrapper.js +25 -0
- package/dist/cjs/private/field.js +34 -0
- package/dist/cjs/private/json-format-common.js +482 -0
- package/dist/cjs/private/json-format-proto2.js +100 -0
- package/dist/cjs/private/json-format-proto3.js +103 -0
- package/dist/cjs/private/message-type.js +37 -0
- package/dist/cjs/private/names.js +101 -0
- package/dist/cjs/private/options-map.js +2 -0
- package/dist/cjs/private/proto-runtime.js +24 -0
- package/dist/cjs/private/scalars.js +138 -0
- package/dist/cjs/private/util-common.js +229 -0
- package/dist/cjs/private/util.js +2 -0
- package/dist/cjs/proto-int64.js +121 -0
- package/dist/cjs/proto2.js +86 -0
- package/dist/cjs/proto3.js +99 -0
- package/dist/cjs/service-type.js +43 -0
- package/dist/cjs/type-registry.js +42 -0
- package/dist/esm/binary-encoding.js +434 -0
- package/dist/esm/binary-format.js +1 -0
- package/dist/esm/descriptor-registry.js +521 -0
- package/dist/esm/descriptor-set.js +517 -0
- package/dist/esm/enum.js +1 -0
- package/dist/esm/field-list.js +1 -0
- package/dist/esm/field.js +37 -0
- package/dist/esm/google/protobuf/any_pb.js +276 -0
- package/dist/esm/google/protobuf/api_pb.js +350 -0
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +318 -0
- package/dist/esm/google/protobuf/descriptor_pb.js +2213 -0
- package/dist/esm/google/protobuf/duration_pb.js +197 -0
- package/dist/esm/google/protobuf/empty_pb.js +68 -0
- package/dist/esm/google/protobuf/field_mask_pb.js +343 -0
- package/dist/esm/google/protobuf/source_context_pb.js +70 -0
- package/dist/esm/google/protobuf/struct_pb.js +282 -0
- package/dist/esm/google/protobuf/timestamp_pb.js +267 -0
- package/dist/esm/google/protobuf/type_pb.js +569 -0
- package/dist/esm/google/protobuf/wrappers_pb.js +574 -0
- package/dist/esm/google/varint.js +265 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/json-format.js +1 -0
- package/dist/esm/message-type.js +1 -0
- package/dist/esm/message.js +94 -0
- package/dist/esm/private/assert.js +41 -0
- package/dist/esm/private/base64.js +113 -0
- package/dist/esm/private/binary-format-common.js +243 -0
- package/dist/esm/private/binary-format-proto2.js +87 -0
- package/dist/esm/private/binary-format-proto3.js +74 -0
- package/dist/esm/private/enum.js +64 -0
- package/dist/esm/private/field-list.js +58 -0
- package/dist/esm/private/field-wrapper.js +20 -0
- package/dist/esm/private/field.js +27 -0
- package/dist/esm/private/json-format-common.js +473 -0
- package/dist/esm/private/json-format-proto2.js +90 -0
- package/dist/esm/private/json-format-proto3.js +89 -0
- package/dist/esm/private/message-type.js +33 -0
- package/dist/esm/private/names.js +90 -0
- package/dist/esm/private/options-map.js +1 -0
- package/dist/esm/private/proto-runtime.js +15 -0
- package/dist/esm/private/scalars.js +129 -0
- package/dist/esm/private/util-common.js +207 -0
- package/dist/esm/private/util.js +1 -0
- package/dist/esm/proto-int64.js +118 -0
- package/dist/esm/proto2.js +77 -0
- package/dist/esm/proto3.js +90 -0
- package/dist/esm/service-type.js +37 -0
- package/dist/esm/type-registry.js +38 -0
- package/dist/types/binary-encoding.d.ts +421 -0
- package/dist/types/binary-format.d.ts +109 -0
- package/dist/types/descriptor-registry.d.ts +42 -0
- package/dist/types/descriptor-set.d.ts +171 -0
- package/dist/types/enum.d.ts +31 -0
- package/dist/types/field-list.d.ts +27 -0
- package/dist/types/field.d.ts +295 -0
- package/dist/types/google/protobuf/any_pb.d.ts +167 -0
- package/dist/types/google/protobuf/api_pb.d.ts +296 -0
- package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +294 -0
- package/dist/types/google/protobuf/descriptor_pb.d.ts +1959 -0
- package/dist/types/google/protobuf/duration_pb.d.ts +117 -0
- package/dist/types/google/protobuf/empty_pb.d.ts +44 -0
- package/dist/types/google/protobuf/field_mask_pb.d.ts +243 -0
- package/dist/types/google/protobuf/source_context_pb.d.ts +44 -0
- package/dist/types/google/protobuf/struct_pb.d.ts +205 -0
- package/dist/types/google/protobuf/timestamp_pb.d.ts +151 -0
- package/dist/types/google/protobuf/type_pb.d.ts +482 -0
- package/dist/types/google/protobuf/wrappers_pb.d.ts +379 -0
- package/dist/types/google/varint.d.ts +65 -0
- package/dist/types/index.d.ts +53 -0
- package/dist/types/json-format.d.ts +129 -0
- package/dist/types/message-type.d.ts +58 -0
- package/dist/types/message.d.ts +124 -0
- package/dist/types/private/assert.d.ts +19 -0
- package/dist/types/private/base64.d.ts +18 -0
- package/dist/types/private/binary-format-common.d.ts +38 -0
- package/dist/types/private/binary-format-proto2.d.ts +2 -0
- package/dist/types/private/binary-format-proto3.d.ts +2 -0
- package/dist/types/private/enum.d.ts +29 -0
- package/dist/types/private/field-list.d.ts +25 -0
- package/dist/types/private/field-wrapper.d.ts +27 -0
- package/dist/types/private/field.d.ts +15 -0
- package/dist/types/private/json-format-common.d.ts +30 -0
- package/dist/types/private/json-format-proto2.d.ts +2 -0
- package/dist/types/private/json-format-proto3.d.ts +2 -0
- package/dist/types/private/message-type.d.ts +15 -0
- package/dist/types/private/names.d.ts +19 -0
- package/dist/types/private/options-map.d.ts +7 -0
- package/dist/types/private/proto-runtime.d.ts +55 -0
- package/dist/types/private/scalars.d.ts +33 -0
- package/dist/types/private/util-common.d.ts +5 -0
- package/dist/types/private/util.d.ts +55 -0
- package/dist/types/proto-int64.d.ts +94 -0
- package/dist/types/proto2.d.ts +4 -0
- package/dist/types/proto3.d.ts +4 -0
- package/dist/types/service-type.d.ts +118 -0
- package/dist/types/type-registry.d.ts +37 -0
- package/package.json +31 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FileDescriptorProto } from "./google/protobuf/descriptor_pb.js";
|
|
2
|
+
import type { MessageType } from "./message-type.js";
|
|
3
|
+
import type { EnumType } from "./enum.js";
|
|
4
|
+
import { DescriptorSet } from "./descriptor-set.js";
|
|
5
|
+
import type {
|
|
6
|
+
IEnumTypeRegistry,
|
|
7
|
+
IMessageTypeRegistry,
|
|
8
|
+
IServiceTypeRegistry,
|
|
9
|
+
} from "./type-registry.js";
|
|
10
|
+
import type { ServiceType } from "./service-type.js";
|
|
11
|
+
/**
|
|
12
|
+
* DescriptorRegistry is a type registry that dynamically creates types
|
|
13
|
+
* from a set of google.protobuf.FileDescriptorProto.
|
|
14
|
+
*
|
|
15
|
+
* By default, all well-known types with a specialized JSON representation
|
|
16
|
+
* are replaced with their generated counterpart in this package.
|
|
17
|
+
*/
|
|
18
|
+
export declare class DescriptorRegistry
|
|
19
|
+
implements IMessageTypeRegistry, IEnumTypeRegistry, IServiceTypeRegistry
|
|
20
|
+
{
|
|
21
|
+
private readonly ds;
|
|
22
|
+
private readonly enums;
|
|
23
|
+
private readonly messages;
|
|
24
|
+
private readonly services;
|
|
25
|
+
constructor(descriptorSet?: DescriptorSet, replaceWkt?: boolean);
|
|
26
|
+
/**
|
|
27
|
+
* May raise an error on invalid descriptors.
|
|
28
|
+
*/
|
|
29
|
+
add(...files: FileDescriptorProto[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* May raise an error on invalid descriptors.
|
|
32
|
+
*/
|
|
33
|
+
findEnum(typeName: string): EnumType | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* May raise an error on invalid descriptors.
|
|
36
|
+
*/
|
|
37
|
+
findMessage(typeName: string): MessageType | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* May raise an error on invalid descriptors.
|
|
40
|
+
*/
|
|
41
|
+
findService(typeName: string): ServiceType | undefined;
|
|
42
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DescriptorProto,
|
|
3
|
+
EnumDescriptorProto,
|
|
4
|
+
EnumValueDescriptorProto,
|
|
5
|
+
FieldDescriptorProto,
|
|
6
|
+
OneofDescriptorProto,
|
|
7
|
+
} from "./google/protobuf/descriptor_pb.js";
|
|
8
|
+
import {
|
|
9
|
+
FieldDescriptorProto_Type,
|
|
10
|
+
FileDescriptorProto,
|
|
11
|
+
MethodDescriptorProto,
|
|
12
|
+
ServiceDescriptorProto,
|
|
13
|
+
} from "./google/protobuf/descriptor_pb.js";
|
|
14
|
+
import { ScalarType } from "./field.js";
|
|
15
|
+
import { MethodIdempotency, MethodKind } from "./service-type.js";
|
|
16
|
+
/**
|
|
17
|
+
* DescriptorSet wraps a set of google.protobuf.FileDescriptorProto,
|
|
18
|
+
* asserting basic expectations and providing hierarchical information.
|
|
19
|
+
*
|
|
20
|
+
* Note that all types are kept by their fully qualified type name
|
|
21
|
+
* with a leading dot.
|
|
22
|
+
*/
|
|
23
|
+
export declare class DescriptorSet implements UnresolvedSet {
|
|
24
|
+
readonly enums: Record<string, UnresolvedEnum | undefined>;
|
|
25
|
+
readonly messages: Record<string, UnresolvedMessage | undefined>;
|
|
26
|
+
readonly services: Record<string, UnresolvedService | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* May raise an error on invalid descriptors.
|
|
29
|
+
*/
|
|
30
|
+
add(...files: FileDescriptorProto[]): void;
|
|
31
|
+
listEnums(): UnresolvedEnum[];
|
|
32
|
+
listMessages(): UnresolvedMessage[];
|
|
33
|
+
listServices(): UnresolvedService[];
|
|
34
|
+
}
|
|
35
|
+
interface UnresolvedSet {
|
|
36
|
+
readonly enums: Record<string, UnresolvedEnum | undefined>;
|
|
37
|
+
readonly messages: Record<string, UnresolvedMessage | undefined>;
|
|
38
|
+
readonly services: Record<string, UnresolvedService | undefined>;
|
|
39
|
+
}
|
|
40
|
+
interface File {
|
|
41
|
+
readonly proto: FileDescriptorProto;
|
|
42
|
+
readonly syntax: "proto3" | "proto2";
|
|
43
|
+
readonly name: string;
|
|
44
|
+
toString(): string;
|
|
45
|
+
}
|
|
46
|
+
interface UnresolvedEnum {
|
|
47
|
+
readonly proto: EnumDescriptorProto;
|
|
48
|
+
readonly file: File;
|
|
49
|
+
readonly parent: UnresolvedMessage | undefined;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly typeName: string;
|
|
52
|
+
readonly protoTypeName: string;
|
|
53
|
+
readonly values: UnresolvedEnumValue[];
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
interface UnresolvedEnumValue {
|
|
57
|
+
readonly proto: EnumValueDescriptorProto;
|
|
58
|
+
readonly parent: UnresolvedEnum;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly number: number;
|
|
61
|
+
toString(): string;
|
|
62
|
+
}
|
|
63
|
+
interface UnresolvedMessage {
|
|
64
|
+
readonly proto: DescriptorProto;
|
|
65
|
+
readonly file: File;
|
|
66
|
+
readonly parent: UnresolvedMessage | undefined;
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly typeName: string;
|
|
69
|
+
readonly protoTypeName: string;
|
|
70
|
+
readonly fields: UnresolvedField[];
|
|
71
|
+
readonly oneofs: UnresolvedOneof[];
|
|
72
|
+
readonly nestedEnums: UnresolvedEnum[];
|
|
73
|
+
readonly nestedMessages: UnresolvedMessage[];
|
|
74
|
+
readonly nestedExtensions: UnresolvedExtension[];
|
|
75
|
+
toString(): string;
|
|
76
|
+
}
|
|
77
|
+
interface UnresolvedField {
|
|
78
|
+
readonly proto: FieldDescriptorProto;
|
|
79
|
+
readonly number: number;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly type: FieldDescriptorProto_Type;
|
|
82
|
+
readonly parent: UnresolvedMessage;
|
|
83
|
+
readonly oneof: UnresolvedOneof | undefined;
|
|
84
|
+
readonly optional: boolean;
|
|
85
|
+
readonly packed: boolean;
|
|
86
|
+
toString(): string;
|
|
87
|
+
resolve(us: UnresolvedSet): ResolvedField;
|
|
88
|
+
}
|
|
89
|
+
declare type ResolvedField =
|
|
90
|
+
| (UnresolvedField & {
|
|
91
|
+
repeated: boolean;
|
|
92
|
+
readonly scalarType: ScalarType;
|
|
93
|
+
readonly message: undefined;
|
|
94
|
+
readonly enum: undefined;
|
|
95
|
+
readonly map: undefined;
|
|
96
|
+
})
|
|
97
|
+
| (UnresolvedField & {
|
|
98
|
+
repeated: boolean;
|
|
99
|
+
readonly scalarType: undefined;
|
|
100
|
+
readonly message: UnresolvedMessage;
|
|
101
|
+
readonly enum: undefined;
|
|
102
|
+
readonly map: undefined;
|
|
103
|
+
})
|
|
104
|
+
| (UnresolvedField & {
|
|
105
|
+
repeated: boolean;
|
|
106
|
+
readonly scalarType: undefined;
|
|
107
|
+
readonly message: undefined;
|
|
108
|
+
readonly enum: UnresolvedEnum;
|
|
109
|
+
readonly map: undefined;
|
|
110
|
+
})
|
|
111
|
+
| (UnresolvedField & {
|
|
112
|
+
repeated: false;
|
|
113
|
+
readonly scalarType: undefined;
|
|
114
|
+
readonly message: undefined;
|
|
115
|
+
readonly enum: undefined;
|
|
116
|
+
readonly map: Map;
|
|
117
|
+
});
|
|
118
|
+
declare type Map = {
|
|
119
|
+
key: Exclude<
|
|
120
|
+
ScalarType,
|
|
121
|
+
ScalarType.FLOAT | ScalarType.DOUBLE | ScalarType.BYTES
|
|
122
|
+
>;
|
|
123
|
+
value:
|
|
124
|
+
| {
|
|
125
|
+
enum: UnresolvedEnum;
|
|
126
|
+
message: undefined;
|
|
127
|
+
scalar: undefined;
|
|
128
|
+
}
|
|
129
|
+
| {
|
|
130
|
+
enum: undefined;
|
|
131
|
+
message: UnresolvedMessage;
|
|
132
|
+
scalar: undefined;
|
|
133
|
+
}
|
|
134
|
+
| {
|
|
135
|
+
enum: undefined;
|
|
136
|
+
message: undefined;
|
|
137
|
+
scalarType: ScalarType;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
interface UnresolvedOneof {
|
|
141
|
+
readonly proto: OneofDescriptorProto;
|
|
142
|
+
readonly name: string;
|
|
143
|
+
readonly parent: UnresolvedMessage;
|
|
144
|
+
readonly file: File;
|
|
145
|
+
readonly fields: UnresolvedField[];
|
|
146
|
+
toString(): string;
|
|
147
|
+
}
|
|
148
|
+
interface UnresolvedExtension {
|
|
149
|
+
readonly proto: FieldDescriptorProto;
|
|
150
|
+
readonly parent: UnresolvedMessage | undefined;
|
|
151
|
+
readonly file: File;
|
|
152
|
+
}
|
|
153
|
+
interface UnresolvedService {
|
|
154
|
+
readonly proto: ServiceDescriptorProto;
|
|
155
|
+
readonly file: File;
|
|
156
|
+
readonly methods: UnresolvedMethod[];
|
|
157
|
+
readonly typeName: string;
|
|
158
|
+
readonly protoTypeName: string;
|
|
159
|
+
toString(): string;
|
|
160
|
+
}
|
|
161
|
+
interface UnresolvedMethod {
|
|
162
|
+
readonly proto: MethodDescriptorProto;
|
|
163
|
+
readonly parent: UnresolvedService;
|
|
164
|
+
readonly name: string;
|
|
165
|
+
readonly kind: MethodKind;
|
|
166
|
+
readonly inputTypeName: string;
|
|
167
|
+
readonly outputTypeName: string;
|
|
168
|
+
readonly idempotency?: MethodIdempotency;
|
|
169
|
+
toString(): string;
|
|
170
|
+
}
|
|
171
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reflection information for a protobuf enum.
|
|
3
|
+
*/
|
|
4
|
+
export interface EnumType {
|
|
5
|
+
/**
|
|
6
|
+
* The fully qualified name of the enum.
|
|
7
|
+
*/
|
|
8
|
+
readonly typeName: string;
|
|
9
|
+
readonly values: readonly EnumValueInfo[];
|
|
10
|
+
/**
|
|
11
|
+
* Find an enum value by its (protobuf) name.
|
|
12
|
+
*/
|
|
13
|
+
findName(name: string): EnumValueInfo | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Find an enum value by its number.
|
|
16
|
+
*/
|
|
17
|
+
findNumber(no: number): EnumValueInfo | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reflection information for a protobuf enum value.
|
|
21
|
+
*/
|
|
22
|
+
export interface EnumValueInfo {
|
|
23
|
+
/**
|
|
24
|
+
* The number of the value as specified in proto.
|
|
25
|
+
*/
|
|
26
|
+
readonly no: number;
|
|
27
|
+
/**
|
|
28
|
+
* The name of the value as specified in proto.
|
|
29
|
+
*/
|
|
30
|
+
readonly name: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FieldInfo, OneofInfo } from "./field.js";
|
|
2
|
+
/**
|
|
3
|
+
* Provides convenient access to field information of a message type.
|
|
4
|
+
*/
|
|
5
|
+
export interface FieldList {
|
|
6
|
+
/**
|
|
7
|
+
* Find field information by field name or json_name.
|
|
8
|
+
*/
|
|
9
|
+
findJsonName(jsonName: string): FieldInfo | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Find field information by proto field number.
|
|
12
|
+
*/
|
|
13
|
+
find(fieldNo: number): FieldInfo | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Return field information in the order they appear in the source.
|
|
16
|
+
*/
|
|
17
|
+
list(): readonly FieldInfo[];
|
|
18
|
+
/**
|
|
19
|
+
* Return field information ordered by field number ascending.
|
|
20
|
+
*/
|
|
21
|
+
byNumber(): readonly FieldInfo[];
|
|
22
|
+
/**
|
|
23
|
+
* In order of appearance in the source, list fields and
|
|
24
|
+
* oneof groups.
|
|
25
|
+
*/
|
|
26
|
+
byMember(): readonly (FieldInfo | OneofInfo)[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { EnumType } from "./enum.js";
|
|
2
|
+
import type { MessageType } from "./message-type.js";
|
|
3
|
+
/**
|
|
4
|
+
* FieldInfo describes a field of a protobuf message for runtime reflection. We
|
|
5
|
+
* distinguish between the following kinds of fields:
|
|
6
|
+
*
|
|
7
|
+
* - "scalar": string, bool, float, int32, etc. The scalar type is "T".
|
|
8
|
+
* - "enum": The field was declared with an enum type. The enum type is "T".
|
|
9
|
+
* - "message": The field was declared with a message type. The message type is "T".
|
|
10
|
+
* - "map": The field was declared with map<K,V>. The key type is "K", the value type is "V".
|
|
11
|
+
*
|
|
12
|
+
* Every field always has the following properties:
|
|
13
|
+
*
|
|
14
|
+
* - "no": The field number of the protobuf field.
|
|
15
|
+
* - "name": The original name of the protobuf field.
|
|
16
|
+
* - "localName": The name of the field as used in generated code.
|
|
17
|
+
* - "jsonName": The name for JSON serialization / deserialization.
|
|
18
|
+
* - "opt": Whether the field is optional.
|
|
19
|
+
* - "repeated": Whether the field is repeated.
|
|
20
|
+
* - "packed": Whether the repeated field is packed.
|
|
21
|
+
*
|
|
22
|
+
* Additionally, fields may have the following properties:
|
|
23
|
+
*
|
|
24
|
+
* - "oneof": If the field is member of a oneof group.
|
|
25
|
+
* - "default": Only proto2: An explicit default value.
|
|
26
|
+
*/
|
|
27
|
+
export declare type FieldInfo =
|
|
28
|
+
| fiRules<fiScalar>
|
|
29
|
+
| fiRules<fiEnum>
|
|
30
|
+
| fiRules<fiMessage>
|
|
31
|
+
| fiRules<fiMap>;
|
|
32
|
+
/**
|
|
33
|
+
* Version of `FieldInfo` that allows the following properties
|
|
34
|
+
* to be omitted:
|
|
35
|
+
*
|
|
36
|
+
* - "localName", "jsonName": can be omitted if equal to lowerCamelCase(name)
|
|
37
|
+
* - "opt": Can be omitted if false.
|
|
38
|
+
* - "repeated": Can be omitted if false.
|
|
39
|
+
* - "packed": Can be omitted if equal to the standard packing of the field.
|
|
40
|
+
*/
|
|
41
|
+
export declare type PartialFieldInfo =
|
|
42
|
+
| fiPartialRules<fiScalar>
|
|
43
|
+
| fiPartialRules<fiEnum>
|
|
44
|
+
| fiPartialRules<fiMessage>
|
|
45
|
+
| fiPartialRules<fiMap>;
|
|
46
|
+
/**
|
|
47
|
+
* Provides convenient access to field information of a oneof.
|
|
48
|
+
*/
|
|
49
|
+
export interface OneofInfo {
|
|
50
|
+
readonly kind: "oneof";
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly localName: string;
|
|
53
|
+
readonly repeated: false;
|
|
54
|
+
readonly packed: false;
|
|
55
|
+
readonly opt: false;
|
|
56
|
+
readonly default: undefined;
|
|
57
|
+
readonly fields: readonly FieldInfo[];
|
|
58
|
+
/**
|
|
59
|
+
* Return field information by local name.
|
|
60
|
+
*/
|
|
61
|
+
findField(localName: string): FieldInfo | undefined;
|
|
62
|
+
}
|
|
63
|
+
interface fiShared {
|
|
64
|
+
/**
|
|
65
|
+
* The field number of the .proto field.
|
|
66
|
+
*/
|
|
67
|
+
readonly no: number;
|
|
68
|
+
/**
|
|
69
|
+
* The original name of the .proto field.
|
|
70
|
+
*/
|
|
71
|
+
readonly name: string;
|
|
72
|
+
/**
|
|
73
|
+
* The name of the field as used in generated code.
|
|
74
|
+
*/
|
|
75
|
+
readonly localName: string;
|
|
76
|
+
/**
|
|
77
|
+
* The name for JSON serialization / deserialization.
|
|
78
|
+
*/
|
|
79
|
+
readonly jsonName: string;
|
|
80
|
+
/**
|
|
81
|
+
* The `oneof` group, if this field belongs to one.
|
|
82
|
+
*/
|
|
83
|
+
readonly oneof?: OneofInfo | undefined;
|
|
84
|
+
}
|
|
85
|
+
interface fiScalar extends fiShared {
|
|
86
|
+
readonly kind: "scalar";
|
|
87
|
+
/**
|
|
88
|
+
* Scalar type of the field.
|
|
89
|
+
*/
|
|
90
|
+
readonly T: ScalarType;
|
|
91
|
+
/**
|
|
92
|
+
* Is the field repeated?
|
|
93
|
+
*/
|
|
94
|
+
readonly repeated: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Is this repeated field packed?
|
|
97
|
+
* BYTES and STRING can never be packed, since they are length-delimited.
|
|
98
|
+
* Other types can be packed with the field option "packed".
|
|
99
|
+
* For proto3, fields are packed by default.
|
|
100
|
+
*/
|
|
101
|
+
readonly packed: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Is the field optional?
|
|
104
|
+
*/
|
|
105
|
+
readonly opt: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Only proto2: An explicit default value.
|
|
108
|
+
*/
|
|
109
|
+
readonly default: number | boolean | string | bigint | Uint8Array | undefined;
|
|
110
|
+
}
|
|
111
|
+
interface fiMessage extends fiShared {
|
|
112
|
+
readonly kind: "message";
|
|
113
|
+
/**
|
|
114
|
+
* Message handler for the field.
|
|
115
|
+
*/
|
|
116
|
+
readonly T: MessageType;
|
|
117
|
+
/**
|
|
118
|
+
* Is the field repeated?
|
|
119
|
+
*/
|
|
120
|
+
readonly repeated: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Is this repeated field packed? Never true for messages.
|
|
123
|
+
*/
|
|
124
|
+
readonly packed: false;
|
|
125
|
+
/**
|
|
126
|
+
* An explicit default value (only proto2). Never set for messages.
|
|
127
|
+
*/
|
|
128
|
+
readonly default: undefined;
|
|
129
|
+
}
|
|
130
|
+
interface fiEnum extends fiShared {
|
|
131
|
+
readonly kind: "enum";
|
|
132
|
+
/**
|
|
133
|
+
* Enum type information for the field.
|
|
134
|
+
*/
|
|
135
|
+
readonly T: EnumType;
|
|
136
|
+
/**
|
|
137
|
+
* Is the field repeated?
|
|
138
|
+
*/
|
|
139
|
+
readonly repeated: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Is this repeated field packed?
|
|
142
|
+
* Repeated enums can be packed with the field option "packed".
|
|
143
|
+
* For proto3, they are packed by default.
|
|
144
|
+
*/
|
|
145
|
+
readonly packed: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Is the field optional?
|
|
148
|
+
*/
|
|
149
|
+
readonly opt: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Only proto2: An explicit default value.
|
|
152
|
+
*/
|
|
153
|
+
readonly default: number | undefined;
|
|
154
|
+
}
|
|
155
|
+
interface fiMap extends fiShared {
|
|
156
|
+
readonly kind: "map";
|
|
157
|
+
/**
|
|
158
|
+
* Map key type.
|
|
159
|
+
*
|
|
160
|
+
* The key_type can be any integral or string type
|
|
161
|
+
* (so, any scalar type except for floating point
|
|
162
|
+
* types and bytes)
|
|
163
|
+
*/
|
|
164
|
+
readonly K: Exclude<
|
|
165
|
+
ScalarType,
|
|
166
|
+
ScalarType.FLOAT | ScalarType.DOUBLE | ScalarType.BYTES
|
|
167
|
+
>;
|
|
168
|
+
/**
|
|
169
|
+
* Map value type. Can be scalar, enum, or message.
|
|
170
|
+
*/
|
|
171
|
+
readonly V:
|
|
172
|
+
| {
|
|
173
|
+
readonly kind: "scalar";
|
|
174
|
+
readonly T: ScalarType;
|
|
175
|
+
}
|
|
176
|
+
| {
|
|
177
|
+
readonly kind: "enum";
|
|
178
|
+
readonly T: EnumType;
|
|
179
|
+
}
|
|
180
|
+
| {
|
|
181
|
+
readonly kind: "message";
|
|
182
|
+
readonly T: MessageType;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Is the field repeated? Never true for maps.
|
|
186
|
+
*/
|
|
187
|
+
readonly repeated: false;
|
|
188
|
+
/**
|
|
189
|
+
* Is this repeated field packed? Never true for maps.
|
|
190
|
+
*/
|
|
191
|
+
readonly packed: false;
|
|
192
|
+
/**
|
|
193
|
+
* An explicit default value (only proto2). Never set for maps.
|
|
194
|
+
*/
|
|
195
|
+
readonly default: undefined;
|
|
196
|
+
}
|
|
197
|
+
declare type fiRules<T> = Omit<
|
|
198
|
+
T,
|
|
199
|
+
"oneof" | "repeat" | "repeated" | "packed" | "opt"
|
|
200
|
+
> &
|
|
201
|
+
(
|
|
202
|
+
| {
|
|
203
|
+
readonly repeated: false;
|
|
204
|
+
readonly packed: false;
|
|
205
|
+
readonly opt: false;
|
|
206
|
+
readonly oneof: undefined;
|
|
207
|
+
}
|
|
208
|
+
| {
|
|
209
|
+
readonly repeated: false;
|
|
210
|
+
readonly packed: false;
|
|
211
|
+
readonly opt: true;
|
|
212
|
+
readonly oneof: undefined;
|
|
213
|
+
}
|
|
214
|
+
| {
|
|
215
|
+
readonly repeated: boolean;
|
|
216
|
+
readonly packed: boolean;
|
|
217
|
+
readonly opt: false;
|
|
218
|
+
readonly oneof: undefined;
|
|
219
|
+
}
|
|
220
|
+
| {
|
|
221
|
+
readonly repeated: false;
|
|
222
|
+
readonly packed: false;
|
|
223
|
+
readonly opt: false;
|
|
224
|
+
readonly oneof: OneofInfo;
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
declare type fiPartialRules<T extends fiScalar | fiMap | fiEnum | fiMessage> =
|
|
228
|
+
Omit<
|
|
229
|
+
T,
|
|
230
|
+
| "jsonName"
|
|
231
|
+
| "localName"
|
|
232
|
+
| "oneof"
|
|
233
|
+
| "repeat"
|
|
234
|
+
| "repeated"
|
|
235
|
+
| "packed"
|
|
236
|
+
| "opt"
|
|
237
|
+
| "default"
|
|
238
|
+
> &
|
|
239
|
+
(
|
|
240
|
+
| {
|
|
241
|
+
readonly jsonName?: string;
|
|
242
|
+
readonly repeated?: false;
|
|
243
|
+
readonly packed?: false;
|
|
244
|
+
readonly opt?: false;
|
|
245
|
+
readonly oneof?: undefined;
|
|
246
|
+
default?: T["default"];
|
|
247
|
+
}
|
|
248
|
+
| {
|
|
249
|
+
readonly jsonName?: string;
|
|
250
|
+
readonly repeated?: false;
|
|
251
|
+
readonly packed?: false;
|
|
252
|
+
readonly opt: true;
|
|
253
|
+
readonly oneof?: undefined;
|
|
254
|
+
default?: T["default"];
|
|
255
|
+
}
|
|
256
|
+
| {
|
|
257
|
+
readonly jsonName?: string;
|
|
258
|
+
readonly repeated?: boolean;
|
|
259
|
+
readonly packed?: boolean;
|
|
260
|
+
readonly opt?: false;
|
|
261
|
+
readonly oneof?: undefined;
|
|
262
|
+
default?: T["default"];
|
|
263
|
+
}
|
|
264
|
+
| {
|
|
265
|
+
readonly jsonName?: string;
|
|
266
|
+
readonly repeated?: false;
|
|
267
|
+
readonly packed?: false;
|
|
268
|
+
readonly opt?: false;
|
|
269
|
+
readonly oneof: string;
|
|
270
|
+
default?: T["default"];
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
/**
|
|
274
|
+
* Scalar value types. This is a subset of field types declared by protobuf
|
|
275
|
+
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
|
|
276
|
+
* are omitted, but the numerical values are identical.
|
|
277
|
+
*/
|
|
278
|
+
export declare enum ScalarType {
|
|
279
|
+
DOUBLE = 1,
|
|
280
|
+
FLOAT = 2,
|
|
281
|
+
INT64 = 3,
|
|
282
|
+
UINT64 = 4,
|
|
283
|
+
INT32 = 5,
|
|
284
|
+
FIXED64 = 6,
|
|
285
|
+
FIXED32 = 7,
|
|
286
|
+
BOOL = 8,
|
|
287
|
+
STRING = 9,
|
|
288
|
+
BYTES = 12,
|
|
289
|
+
UINT32 = 13,
|
|
290
|
+
SFIXED32 = 15,
|
|
291
|
+
SFIXED64 = 16,
|
|
292
|
+
SINT32 = 17,
|
|
293
|
+
SINT64 = 18,
|
|
294
|
+
}
|
|
295
|
+
export {};
|