@bufbuild/protobuf 0.0.8 → 0.1.0
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 +34 -4
- package/dist/cjs/codegen-info.js +60 -0
- package/dist/cjs/create-descriptor-set.js +952 -0
- package/dist/cjs/create-registry-from-desc.js +270 -0
- package/dist/cjs/create-registry.js +75 -0
- package/dist/cjs/descriptor-set.js +0 -436
- package/dist/cjs/google/protobuf/descriptor_pb.js +2 -2
- package/dist/cjs/google/protobuf/empty_pb.js +0 -1
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/google/varint.js +85 -37
- package/dist/cjs/index.js +11 -7
- package/dist/cjs/private/enum.js +22 -31
- package/dist/cjs/private/field-wrapper.js +30 -1
- package/dist/cjs/private/field.js +1 -1
- package/dist/cjs/private/json-format-common.js +6 -6
- package/dist/cjs/private/names.js +168 -29
- package/dist/cjs/proto-int64.js +23 -40
- package/dist/cjs/proto2.js +2 -2
- package/dist/cjs/proto3.js +2 -2
- package/dist/cjs/type-registry.js +0 -87
- package/dist/esm/codegen-info.js +57 -0
- package/dist/esm/create-descriptor-set.js +947 -0
- package/dist/esm/create-registry-from-desc.js +266 -0
- package/dist/esm/create-registry.js +71 -0
- package/dist/esm/descriptor-set.js +1 -434
- package/dist/esm/google/protobuf/descriptor_pb.js +2 -2
- package/dist/esm/google/protobuf/empty_pb.js +0 -1
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/google/varint.js +81 -34
- package/dist/esm/index.js +6 -3
- package/dist/esm/private/enum.js +22 -31
- package/dist/esm/private/field-wrapper.js +28 -0
- package/dist/esm/private/field.js +2 -2
- package/dist/esm/private/json-format-common.js +6 -6
- package/dist/esm/private/names.js +163 -24
- package/dist/esm/proto-int64.js +24 -41
- package/dist/esm/proto2.js +3 -3
- package/dist/esm/proto3.js +3 -3
- package/dist/esm/type-registry.js +1 -85
- package/dist/types/codegen-info.d.ts +19 -0
- package/dist/types/create-descriptor-set.d.ts +16 -0
- package/dist/types/create-registry-from-desc.d.ts +15 -0
- package/dist/types/create-registry.d.ts +8 -0
- package/dist/types/descriptor-set.d.ts +554 -108
- package/dist/types/enum.d.ts +9 -5
- package/dist/types/google/protobuf/descriptor_pb.d.ts +6 -6
- package/dist/types/google/protobuf/empty_pb.d.ts +0 -1
- package/dist/types/google/varint.d.ts +21 -9
- package/dist/types/index.d.ts +6 -3
- package/dist/types/message.d.ts +3 -1
- package/dist/types/private/enum.d.ts +4 -8
- package/dist/types/private/field-wrapper.d.ts +7 -0
- package/dist/types/private/message-type.d.ts +1 -4
- package/dist/types/private/names.d.ts +26 -8
- package/dist/types/private/proto-runtime.d.ts +2 -2
- package/dist/types/private/util.d.ts +1 -6
- package/dist/types/proto-int64.d.ts +14 -13
- package/dist/types/type-registry.d.ts +0 -38
- package/package.json +6 -10
- package/dist/cjs/descriptor-registry.js +0 -460
- package/dist/esm/descriptor-registry.js +0 -456
- package/dist/protobuf.cjs +0 -2
- package/dist/protobuf.cjs.map +0 -1
- package/dist/protobuf.esm.js +0 -2
- package/dist/protobuf.esm.js.map +0 -1
- package/dist/protobuf.modern.js +0 -2
- package/dist/protobuf.modern.js.map +0 -1
- package/dist/types/descriptor-registry.d.ts +0 -43
package/dist/types/enum.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reflection information for a protobuf
|
|
2
|
+
* Reflection information for a protobuf enumeration.
|
|
3
3
|
*/
|
|
4
4
|
export interface EnumType {
|
|
5
5
|
/**
|
|
6
|
-
* The fully qualified name of the
|
|
6
|
+
* The fully qualified name of the enumeration.
|
|
7
7
|
*/
|
|
8
8
|
readonly typeName: string;
|
|
9
9
|
readonly values: readonly EnumValueInfo[];
|
|
@@ -17,15 +17,19 @@ export interface EnumType {
|
|
|
17
17
|
findNumber(no: number): EnumValueInfo | undefined;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Reflection information for a protobuf
|
|
20
|
+
* Reflection information for a protobuf enumeration value.
|
|
21
21
|
*/
|
|
22
22
|
export interface EnumValueInfo {
|
|
23
23
|
/**
|
|
24
|
-
* The
|
|
24
|
+
* The numeric enumeration value, as specified in the protobuf source.
|
|
25
25
|
*/
|
|
26
26
|
readonly no: number;
|
|
27
27
|
/**
|
|
28
|
-
* The name of the value as specified in
|
|
28
|
+
* The name of the enumeration value, as specified in the protobuf source.
|
|
29
29
|
*/
|
|
30
30
|
readonly name: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the enumeration value in generated code.
|
|
33
|
+
*/
|
|
34
|
+
readonly localName: string;
|
|
31
35
|
}
|
|
@@ -1333,8 +1333,8 @@ export declare class UninterpretedOption extends Message<UninterpretedOption> {
|
|
|
1333
1333
|
* The name of the uninterpreted option. Each string represents a segment in
|
|
1334
1334
|
* a dot-separated name. is_extension is true iff a segment represents an
|
|
1335
1335
|
* extension (denoted with parentheses in options specs in .proto files).
|
|
1336
|
-
* E.g.,{ ["foo", false], ["bar.baz", true], ["
|
|
1337
|
-
* "foo.(bar.baz).
|
|
1336
|
+
* E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
|
|
1337
|
+
* "foo.(bar.baz).moo".
|
|
1338
1338
|
*
|
|
1339
1339
|
* @generated from message google.protobuf.UninterpretedOption.NamePart
|
|
1340
1340
|
*/
|
|
@@ -1490,13 +1490,13 @@ export declare class SourceCodeInfo_Location extends Message<SourceCodeInfo_Loca
|
|
|
1490
1490
|
* // Comment attached to baz.
|
|
1491
1491
|
* // Another line attached to baz.
|
|
1492
1492
|
*
|
|
1493
|
-
* // Comment attached to
|
|
1493
|
+
* // Comment attached to moo.
|
|
1494
1494
|
* //
|
|
1495
|
-
* // Another line attached to
|
|
1496
|
-
* optional double
|
|
1495
|
+
* // Another line attached to moo.
|
|
1496
|
+
* optional double moo = 4;
|
|
1497
1497
|
*
|
|
1498
1498
|
* // Detached comment for corge. This is not leading or trailing comments
|
|
1499
|
-
* // to
|
|
1499
|
+
* // to moo or corge because there are blank lines separating it from
|
|
1500
1500
|
* // both.
|
|
1501
1501
|
*
|
|
1502
1502
|
* // Detached comment for corge paragraph 2.
|
|
@@ -12,7 +12,6 @@ import type { JsonReadOptions, JsonValue } from "../../json-format.js";
|
|
|
12
12
|
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
13
13
|
* }
|
|
14
14
|
*
|
|
15
|
-
* The JSON representation for `Empty` is empty JSON object `{}`.
|
|
16
15
|
*
|
|
17
16
|
* @generated from message google.protobuf.Empty
|
|
18
17
|
*/
|
|
@@ -21,20 +21,32 @@ export declare function varint64write(lo: number, hi: number, bytes: number[]):
|
|
|
21
21
|
/**
|
|
22
22
|
* Parse decimal string of 64 bit integer value as two JS numbers.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
24
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
25
|
+
*
|
|
26
|
+
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
27
|
+
*/
|
|
28
|
+
export declare function int64FromString(dec: string): {
|
|
29
|
+
lo: number;
|
|
30
|
+
hi: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Losslessly converts a 64-bit signed integer in 32:32 split representation
|
|
34
|
+
* into a decimal string.
|
|
35
|
+
*
|
|
36
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
28
37
|
*
|
|
29
|
-
*
|
|
38
|
+
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
30
39
|
*/
|
|
31
|
-
export declare function
|
|
40
|
+
export declare function int64ToString(lo: number, hi: number): string;
|
|
32
41
|
/**
|
|
33
|
-
*
|
|
42
|
+
* Losslessly converts a 64-bit unsigned integer in 32:32 split representation
|
|
43
|
+
* into a decimal string.
|
|
44
|
+
*
|
|
45
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
34
46
|
*
|
|
35
|
-
*
|
|
47
|
+
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
36
48
|
*/
|
|
37
|
-
export declare function
|
|
49
|
+
export declare function uInt64ToString(lo: number, hi: number): string;
|
|
38
50
|
/**
|
|
39
51
|
* Write a 32 bit varint, signed or unsigned. Same as `varint64write(0, value, bytes)`
|
|
40
52
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { proto3 } from "./proto3.js";
|
|
|
2
2
|
export { proto2 } from "./proto2.js";
|
|
3
3
|
export { protoInt64 } from "./proto-int64.js";
|
|
4
4
|
export { protoBase64 } from "./proto-base64.js";
|
|
5
|
+
export { codegenInfo } from "./codegen-info.js";
|
|
5
6
|
export { Message, AnyMessage, PartialMessage, PlainMessage, } from "./message.js";
|
|
6
7
|
export type { FieldInfo } from "./field.js";
|
|
7
8
|
export type { FieldList } from "./field-list.js";
|
|
@@ -10,13 +11,15 @@ export type { MessageType } from "./message-type.js";
|
|
|
10
11
|
export type { EnumType, EnumValueInfo } from "./enum.js";
|
|
11
12
|
export type { ServiceType, MethodInfo, MethodInfoUnary, MethodInfoServerStreaming, MethodInfoClientStreaming, MethodInfoBiDiStreaming, } from "./service-type.js";
|
|
12
13
|
export { MethodKind, MethodIdempotency } from "./service-type.js";
|
|
13
|
-
export { TypeRegistry, IMessageTypeRegistry } from "./type-registry.js";
|
|
14
|
-
export { DescriptorRegistry } from "./descriptor-registry.js";
|
|
15
|
-
export { DescriptorSet } from "./descriptor-set.js";
|
|
16
14
|
export { WireType, BinaryWriter, BinaryReader } from "./binary-encoding.js";
|
|
17
15
|
export type { IBinaryReader, IBinaryWriter } from "./binary-encoding.js";
|
|
18
16
|
export type { BinaryFormat, BinaryWriteOptions, BinaryReadOptions, } from "./binary-format.js";
|
|
19
17
|
export { JsonFormat, JsonObject, JsonValue, JsonReadOptions, JsonWriteOptions, JsonWriteStringOptions, } from "./json-format.js";
|
|
18
|
+
export { DescriptorSet, DescFile, DescEnum, DescEnumValue, DescMessage, DescOneof, DescField, DescService, DescMethod, DescExtension, DescComments, } from "./descriptor-set.js";
|
|
19
|
+
export { createDescriptorSet } from "./create-descriptor-set.js";
|
|
20
|
+
export { IMessageTypeRegistry } from "./type-registry.js";
|
|
21
|
+
export { createRegistry } from "./create-registry.js";
|
|
22
|
+
export { createRegistryFromDescriptors } from "./create-registry-from-desc.js";
|
|
20
23
|
export * from "./google/protobuf/compiler/plugin_pb.js";
|
|
21
24
|
export * from "./google/protobuf/api_pb.js";
|
|
22
25
|
export * from "./google/protobuf/any_pb.js";
|
package/dist/types/message.d.ts
CHANGED
|
@@ -67,7 +67,9 @@ export declare class Message<T extends Message<T> = AnyMessage> {
|
|
|
67
67
|
* PlainMessage<T> strips all methods from a message, leaving only fields
|
|
68
68
|
* and oneof groups.
|
|
69
69
|
*/
|
|
70
|
-
export declare type PlainMessage<T extends Message> =
|
|
70
|
+
export declare type PlainMessage<T extends Message> = {
|
|
71
|
+
[P in keyof T as T[P] extends Function ? never : P]: T[P];
|
|
72
|
+
};
|
|
71
73
|
/**
|
|
72
74
|
* PartialMessage<T> constructs a type from a message. The resulting type
|
|
73
75
|
* only contains the protobuf field members of the message, and all of them
|
|
@@ -15,17 +15,13 @@ export declare function getEnumType(enumObject: EnumObject): EnumType;
|
|
|
15
15
|
/**
|
|
16
16
|
* Sets reflection information on a generated enum.
|
|
17
17
|
*/
|
|
18
|
-
export declare function setEnumType(enumObject: EnumObject, typeName: string, values: EnumValueInfo[]): void;
|
|
18
|
+
export declare function setEnumType(enumObject: EnumObject, typeName: string, values: Omit<EnumValueInfo, "localName">[], opt?: {}): void;
|
|
19
19
|
/**
|
|
20
20
|
* Create a new EnumType with the given values.
|
|
21
21
|
*/
|
|
22
|
-
export declare function makeEnumType(typeName: string, values: EnumValueInfo[]): EnumType;
|
|
22
|
+
export declare function makeEnumType(typeName: string, values: (EnumValueInfo | Omit<EnumValueInfo, "localName">)[], _opt?: {}): EnumType;
|
|
23
23
|
/**
|
|
24
24
|
* Create a new enum object with the given values.
|
|
25
|
+
* Sets reflection information.
|
|
25
26
|
*/
|
|
26
|
-
export declare function makeEnum(typeName: string, values: EnumValueInfo[], opt?: {
|
|
27
|
-
/**
|
|
28
|
-
* MY_ENUM_ for `enum MyEnum {MY_ENUM_A=0; MY_ENUM_B=1;}`, or blank string
|
|
29
|
-
*/
|
|
30
|
-
sharedPrefix?: string;
|
|
31
|
-
}): EnumObject;
|
|
27
|
+
export declare function makeEnum(typeName: string, values: (EnumValueInfo | Omit<EnumValueInfo, "localName">)[], opt?: {}): EnumObject;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Message } from "../message.js";
|
|
2
2
|
import type { MessageType } from "../message-type.js";
|
|
3
|
+
import type { DescField } from "../descriptor-set.js";
|
|
4
|
+
import { ScalarType } from "../field.js";
|
|
3
5
|
/**
|
|
4
6
|
* A field wrapper unwraps a message to a primitive value that is more
|
|
5
7
|
* ergonomic for use as a message field.
|
|
@@ -19,3 +21,8 @@ export declare function wrapField<T extends Message<T>>(type: MessageType<T>, va
|
|
|
19
21
|
* Unwrap field values whose message type has a wrapper.
|
|
20
22
|
*/
|
|
21
23
|
export declare function unwrapField<T extends Message<T>>(type: MessageType<T>, value: T): any;
|
|
24
|
+
/**
|
|
25
|
+
* If the given field uses one of the well-known wrapper types, return
|
|
26
|
+
* the base type it wraps.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getUnwrappedFieldType(field: DescField): ScalarType | undefined;
|
|
@@ -11,10 +11,7 @@ export declare function makeMessageType<T extends Message<T> = AnyMessage>(runti
|
|
|
11
11
|
* It is useful in stack traces, debuggers and test frameworks,
|
|
12
12
|
* but has no other implications.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* from the given typeName is used. Since this does not take
|
|
16
|
-
* reserved words into account, we provide this property so that
|
|
17
|
-
* an escaped name can be given.
|
|
14
|
+
* If omitted, the last part of the typeName is used.
|
|
18
15
|
*/
|
|
19
16
|
localName?: string;
|
|
20
17
|
}): MessageType<T>;
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
+
import type { DescEnum, DescEnumValue, DescField, DescMessage, DescService } from "../descriptor-set.js";
|
|
2
|
+
import type { DescMethod, DescOneof } from "../descriptor-set.js";
|
|
1
3
|
/**
|
|
2
|
-
* Returns the
|
|
4
|
+
* Returns the name of a protobuf element in generated code.
|
|
5
|
+
*
|
|
6
|
+
* Field names - including oneofs - are converted to lowerCamelCase. For
|
|
7
|
+
* messages, enumerations and services, the package name is stripped from
|
|
8
|
+
* the type name. For nested messages and enumerations, the names are joined
|
|
9
|
+
* with an underscore. For methods, the first character is made lowercase.
|
|
10
|
+
*/
|
|
11
|
+
export declare function localName(desc: DescEnum | DescEnumValue | DescMessage | DescOneof | DescField | DescService | DescMethod): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the name of a field in generated code.
|
|
3
14
|
*/
|
|
4
|
-
export declare function
|
|
15
|
+
export declare function localFieldName(protoName: string, inOneof: boolean): string;
|
|
5
16
|
/**
|
|
6
|
-
* Returns the
|
|
17
|
+
* Returns the name of a oneof group in generated code.
|
|
18
|
+
*/
|
|
19
|
+
export declare function localOneofName(protoName: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the JSON name for a protobuf field, exactly like protoc does.
|
|
7
22
|
*/
|
|
8
|
-
export declare
|
|
23
|
+
export declare const fieldJsonName: typeof protoCamelCase;
|
|
9
24
|
/**
|
|
10
|
-
*
|
|
25
|
+
* Finds a prefix shared by enum values, for example `MY_ENUM_` for
|
|
26
|
+
* `enum MyEnum {MY_ENUM_A=0; MY_ENUM_B=1;}`.
|
|
11
27
|
*/
|
|
12
|
-
export declare function
|
|
28
|
+
export declare function findEnumSharedPrefix(enumName: string, valueNames: string[]): string | undefined;
|
|
13
29
|
/**
|
|
14
|
-
*
|
|
30
|
+
* Converts snake_case to protoCamelCase according to the convention
|
|
31
|
+
* used by protoc to convert a field name to a JSON name.
|
|
15
32
|
*/
|
|
16
|
-
|
|
33
|
+
declare function protoCamelCase(snakeCase: string): string;
|
|
34
|
+
export {};
|
|
@@ -30,13 +30,13 @@ export interface ProtoRuntime {
|
|
|
30
30
|
* The type name and other reflection information is accessible
|
|
31
31
|
* via getEnumType().
|
|
32
32
|
*/
|
|
33
|
-
makeEnum(typeName: string, values: EnumValueInfo[], opt?: {}): EnumObject;
|
|
33
|
+
makeEnum(typeName: string, values: (EnumValueInfo | Omit<EnumValueInfo, "localName">)[], opt?: {}): EnumObject;
|
|
34
34
|
/**
|
|
35
35
|
* Create an enum type at runtime, without generating code.
|
|
36
36
|
* Note that this only creates the reflection information, not an
|
|
37
37
|
* actual enum object.
|
|
38
38
|
*/
|
|
39
|
-
makeEnumType(typeName: string, values: EnumValueInfo[], opt?: {}): EnumType;
|
|
39
|
+
makeEnumType(typeName: string, values: (EnumValueInfo | Omit<EnumValueInfo, "localName">)[], opt?: {}): EnumType;
|
|
40
40
|
/**
|
|
41
41
|
* Get reflection information - the EnumType - from an enum object.
|
|
42
42
|
* If this function is called on something other than a generated
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { FieldListSource } from "./field-list.js";
|
|
2
2
|
import type { FieldList } from "../field-list.js";
|
|
3
3
|
import type { EnumObject } from "./enum.js";
|
|
4
|
-
import type { JsonValue } from "../json-format.js";
|
|
5
4
|
import type { Message, PartialMessage, PlainMessage } from "../message.js";
|
|
6
5
|
import type { MessageType } from "../message-type.js";
|
|
7
6
|
import type { EnumValueInfo } from "../enum.js";
|
|
@@ -18,11 +17,7 @@ export interface Util {
|
|
|
18
17
|
/**
|
|
19
18
|
* Sets reflection information on a generated enum.
|
|
20
19
|
*/
|
|
21
|
-
setEnumType(enumObject: EnumObject, typeName: string, values: EnumValueInfo[], opt?: {
|
|
22
|
-
options?: {
|
|
23
|
-
readonly [extensionName: string]: JsonValue;
|
|
24
|
-
};
|
|
25
|
-
}): void;
|
|
20
|
+
setEnumType(enumObject: EnumObject, typeName: string, values: Omit<EnumValueInfo, "localName">[], opt?: {}): void;
|
|
26
21
|
/**
|
|
27
22
|
* Set default field values on the target message.
|
|
28
23
|
*/
|
|
@@ -29,22 +29,23 @@
|
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
31
|
* If you need to manipulate 64-bit integral values that are outside the
|
|
32
|
-
* range of safe representation as Number,
|
|
33
|
-
*
|
|
32
|
+
* range of safe representation as a JavaScript Number, we recommend you
|
|
33
|
+
* use a third party library, for example the npm package "long":
|
|
34
34
|
*
|
|
35
35
|
* ```ts
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* }
|
|
43
|
-
* message.int64Field = protoInt64.dec(t.lo, t.hi);
|
|
44
|
-
* ```
|
|
36
|
+
* // convert the field value to a Long
|
|
37
|
+
* const bits = protoInt64.enc(message.int64Field);
|
|
38
|
+
* const longValue = Long.fromBits(bits.lo, bits.hi);
|
|
39
|
+
*
|
|
40
|
+
* // perform arithmetic
|
|
41
|
+
* const longResult = longValue.subtract(1);
|
|
45
42
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
43
|
+
* // set the result in the field
|
|
44
|
+
* message.int64Field = protoInt64.dec(longResult.low, longResult.high);
|
|
45
|
+
*
|
|
46
|
+
* // Assuming int64Field contains 9223372036854775807:
|
|
47
|
+
* console.log(message.int64Field); // 9223372036854775806
|
|
48
|
+
* ```
|
|
48
49
|
*/
|
|
49
50
|
interface Int64Support {
|
|
50
51
|
/**
|
|
@@ -28,41 +28,3 @@ export interface IServiceTypeRegistry {
|
|
|
28
28
|
*/
|
|
29
29
|
findService(typeName: string): ServiceType | undefined;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* TypeRegistry is a simple registry for all message, enum, or service types.
|
|
33
|
-
*/
|
|
34
|
-
export declare class TypeRegistry implements IMessageTypeRegistry, IEnumTypeRegistry, IServiceTypeRegistry {
|
|
35
|
-
private readonly messages;
|
|
36
|
-
private readonly enums;
|
|
37
|
-
private readonly services;
|
|
38
|
-
/**
|
|
39
|
-
* Find a message type by its protobuf type name.
|
|
40
|
-
*/
|
|
41
|
-
findMessage(typeName: string): MessageType | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Find an enum type by its protobuf type name.
|
|
44
|
-
*/
|
|
45
|
-
findEnum(typeName: string): EnumType | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Find a service type by its protobuf type name.
|
|
48
|
-
*/
|
|
49
|
-
findService(typeName: string): ServiceType | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Create a new TypeRegistry from the given types.
|
|
52
|
-
*/
|
|
53
|
-
static from(...types: Array<MessageType | EnumType | ServiceType>): TypeRegistry;
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated use TypeRegistry.from()
|
|
56
|
-
*/
|
|
57
|
-
static fromIterable(types: Iterable<MessageType>): TypeRegistry;
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated use TypeRegistry.from()
|
|
60
|
-
*/
|
|
61
|
-
static fromTypes(...types: MessageType[]): TypeRegistry;
|
|
62
|
-
/**
|
|
63
|
-
* Add a type to the registry. For messages, the types used in message
|
|
64
|
-
* fields are added recursively. For services, the message types used
|
|
65
|
-
* for requests and responses are added recursively.
|
|
66
|
-
*/
|
|
67
|
-
add(type: MessageType | EnumType | ServiceType): void;
|
|
68
|
-
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protobuf",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
|
5
|
-
"description": "A complete implementation of
|
|
5
|
+
"description": "A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/bufbuild/protobuf-es.git",
|
|
@@ -12,19 +12,15 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
|
|
14
14
|
"build": "npm run build:cjs && npm run build:esm+types",
|
|
15
|
-
"build:cjs": "
|
|
16
|
-
"build:esm+types": "
|
|
15
|
+
"build:cjs": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
|
|
16
|
+
"build:esm+types": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
|
|
17
17
|
},
|
|
18
|
-
"main": "./dist/
|
|
18
|
+
"main": "./dist/cjs/index.js",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"exports": {
|
|
22
22
|
"import": "./dist/esm/index.js",
|
|
23
|
-
"require": "./dist/cjs/index.js"
|
|
24
|
-
"default": "./dist/esm/index.js"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"typescript": "^4.7.4"
|
|
23
|
+
"require": "./dist/cjs/index.js"
|
|
28
24
|
},
|
|
29
25
|
"files": [
|
|
30
26
|
"dist/**/"
|