@bufbuild/protobuf 0.0.1-alpha.1 → 0.0.2-alpha.2

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.
Files changed (138) hide show
  1. package/dist/cjs/binary-encoding.js +414 -409
  2. package/dist/cjs/binary-format.js +13 -0
  3. package/dist/cjs/descriptor-registry.js +420 -449
  4. package/dist/cjs/descriptor-set.js +429 -513
  5. package/dist/cjs/enum.js +13 -0
  6. package/dist/cjs/field-list.js +13 -0
  7. package/dist/cjs/field.js +43 -30
  8. package/dist/cjs/google/protobuf/any_pb.js +122 -140
  9. package/dist/cjs/google/protobuf/api_pb.js +177 -224
  10. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +125 -227
  11. package/dist/cjs/google/protobuf/descriptor_pb.js +1029 -1888
  12. package/dist/cjs/google/protobuf/duration_pb.js +72 -88
  13. package/dist/cjs/google/protobuf/empty_pb.js +17 -17
  14. package/dist/cjs/google/protobuf/field_mask_pb.js +77 -94
  15. package/dist/cjs/google/protobuf/source_context_pb.js +25 -25
  16. package/dist/cjs/google/protobuf/struct_pb.js +144 -181
  17. package/dist/cjs/google/protobuf/timestamp_pb.js +86 -123
  18. package/dist/cjs/google/protobuf/type_pb.js +406 -462
  19. package/dist/cjs/google/protobuf/wrappers_pb.js +407 -470
  20. package/dist/cjs/google/varint.js +166 -171
  21. package/dist/cjs/index.js +41 -122
  22. package/dist/cjs/json-format.js +13 -0
  23. package/dist/cjs/message-type.js +13 -0
  24. package/dist/cjs/message.js +89 -85
  25. package/dist/cjs/private/assert.js +33 -26
  26. package/dist/cjs/private/base64.js +93 -79
  27. package/dist/cjs/private/binary-format-common.js +208 -208
  28. package/dist/cjs/private/binary-format-proto2.js +88 -109
  29. package/dist/cjs/private/binary-format-proto3.js +70 -90
  30. package/dist/cjs/private/enum.js +77 -44
  31. package/dist/cjs/private/field-list.js +64 -50
  32. package/dist/cjs/private/field-wrapper.js +21 -10
  33. package/dist/cjs/private/field.js +35 -25
  34. package/dist/cjs/private/json-format-common.js +427 -440
  35. package/dist/cjs/private/json-format-proto2.js +91 -89
  36. package/dist/cjs/private/json-format-proto3.js +82 -93
  37. package/dist/cjs/private/message-type.js +39 -27
  38. package/dist/cjs/private/names.js +71 -62
  39. package/dist/cjs/private/options-map.js +13 -0
  40. package/dist/cjs/private/proto-runtime.js +25 -16
  41. package/dist/cjs/private/scalars.js +113 -103
  42. package/dist/cjs/private/util-common.js +193 -210
  43. package/dist/cjs/private/util.js +13 -0
  44. package/dist/cjs/proto-int64.js +123 -111
  45. package/dist/cjs/proto2.js +63 -63
  46. package/dist/cjs/proto3.js +74 -74
  47. package/dist/cjs/service-type.js +27 -17
  48. package/dist/cjs/type-registry.js +46 -31
  49. package/dist/esm/binary-encoding.js +414 -414
  50. package/dist/esm/binary-format.js +13 -0
  51. package/dist/esm/descriptor-registry.js +422 -458
  52. package/dist/esm/descriptor-set.js +430 -478
  53. package/dist/esm/enum.js +13 -0
  54. package/dist/esm/field-list.js +13 -0
  55. package/dist/esm/field.js +42 -29
  56. package/dist/esm/google/protobuf/any_pb.js +122 -140
  57. package/dist/esm/google/protobuf/api_pb.js +177 -197
  58. package/dist/esm/google/protobuf/compiler/plugin_pb.js +123 -216
  59. package/dist/esm/google/protobuf/descriptor_pb.js +1013 -1804
  60. package/dist/esm/google/protobuf/duration_pb.js +72 -88
  61. package/dist/esm/google/protobuf/empty_pb.js +17 -17
  62. package/dist/esm/google/protobuf/field_mask_pb.js +77 -94
  63. package/dist/esm/google/protobuf/source_context_pb.js +25 -25
  64. package/dist/esm/google/protobuf/struct_pb.js +143 -180
  65. package/dist/esm/google/protobuf/timestamp_pb.js +86 -123
  66. package/dist/esm/google/protobuf/type_pb.js +401 -421
  67. package/dist/esm/google/protobuf/wrappers_pb.js +406 -397
  68. package/dist/esm/google/varint.js +165 -164
  69. package/dist/esm/index.js +14 -1
  70. package/dist/esm/json-format.js +13 -0
  71. package/dist/esm/message-type.js +13 -0
  72. package/dist/esm/message.js +89 -85
  73. package/dist/esm/private/assert.js +32 -21
  74. package/dist/esm/private/base64.js +92 -78
  75. package/dist/esm/private/binary-format-common.js +209 -207
  76. package/dist/esm/private/binary-format-proto2.js +89 -81
  77. package/dist/esm/private/binary-format-proto3.js +71 -67
  78. package/dist/esm/private/enum.js +75 -43
  79. package/dist/esm/private/field-list.js +64 -50
  80. package/dist/esm/private/field-wrapper.js +21 -10
  81. package/dist/esm/private/field.js +35 -22
  82. package/dist/esm/private/json-format-common.js +427 -435
  83. package/dist/esm/private/json-format-proto2.js +89 -81
  84. package/dist/esm/private/json-format-proto3.js +79 -80
  85. package/dist/esm/private/message-type.js +40 -28
  86. package/dist/esm/private/names.js +70 -57
  87. package/dist/esm/private/options-map.js +13 -0
  88. package/dist/esm/private/proto-runtime.js +26 -12
  89. package/dist/esm/private/scalars.js +112 -99
  90. package/dist/esm/private/util-common.js +193 -192
  91. package/dist/esm/private/util.js +13 -0
  92. package/dist/esm/proto-int64.js +123 -111
  93. package/dist/esm/proto2.js +63 -57
  94. package/dist/esm/proto3.js +74 -68
  95. package/dist/esm/service-type.js +25 -12
  96. package/dist/esm/type-registry.js +46 -31
  97. package/dist/types/binary-encoding.d.ts +398 -398
  98. package/dist/types/binary-format.d.ts +69 -91
  99. package/dist/types/descriptor-registry.d.ts +23 -29
  100. package/dist/types/descriptor-set.d.ts +107 -128
  101. package/dist/types/enum.d.ts +21 -21
  102. package/dist/types/field-list.d.ts +21 -21
  103. package/dist/types/field.d.ts +191 -231
  104. package/dist/types/google/protobuf/any_pb.d.ts +56 -77
  105. package/dist/types/google/protobuf/api_pb.d.ts +144 -187
  106. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +195 -257
  107. package/dist/types/google/protobuf/descriptor_pb.d.ts +1360 -1737
  108. package/dist/types/google/protobuf/duration_pb.d.ts +30 -50
  109. package/dist/types/google/protobuf/empty_pb.d.ts +9 -28
  110. package/dist/types/google/protobuf/field_mask_pb.d.ts +17 -37
  111. package/dist/types/google/protobuf/source_context_pb.d.ts +16 -35
  112. package/dist/types/google/protobuf/struct_pb.d.ts +64 -115
  113. package/dist/types/google/protobuf/timestamp_pb.d.ts +31 -51
  114. package/dist/types/google/protobuf/type_pb.d.ts +355 -422
  115. package/dist/types/google/protobuf/wrappers_pb.d.ts +181 -297
  116. package/dist/types/google/varint.d.ts +6 -13
  117. package/dist/types/index.d.ts +4 -27
  118. package/dist/types/json-format.d.ts +70 -89
  119. package/dist/types/message-type.d.ts +37 -45
  120. package/dist/types/message.d.ts +62 -87
  121. package/dist/types/private/assert.d.ts +1 -4
  122. package/dist/types/private/binary-format-common.d.ts +6 -32
  123. package/dist/types/private/enum.d.ts +13 -11
  124. package/dist/types/private/field-list.d.ts +14 -21
  125. package/dist/types/private/field-wrapper.d.ts +4 -10
  126. package/dist/types/private/field.d.ts +12 -12
  127. package/dist/types/private/json-format-common.d.ts +5 -27
  128. package/dist/types/private/message-type.d.ts +12 -7
  129. package/dist/types/private/names.d.ts +1 -4
  130. package/dist/types/private/options-map.d.ts +1 -1
  131. package/dist/types/private/proto-runtime.d.ts +34 -42
  132. package/dist/types/private/scalars.d.ts +5 -12
  133. package/dist/types/private/util-common.d.ts +1 -4
  134. package/dist/types/private/util.d.ts +29 -41
  135. package/dist/types/proto-int64.d.ts +42 -42
  136. package/dist/types/service-type.d.ts +36 -56
  137. package/dist/types/type-registry.d.ts +13 -15
  138. package/package.json +2 -3
@@ -1,30 +1,8 @@
1
- import type {
2
- JsonFormat,
3
- JsonValue,
4
- JsonWriteOptions,
5
- } from "../json-format.js";
1
+ import type { JsonFormat, JsonValue, JsonWriteOptions } from "../json-format.js";
6
2
  import { FieldInfo, ScalarType } from "../field.js";
7
3
  import type { EnumType } from "../enum.js";
8
- declare type JsonFormatWriteFieldFn = (
9
- field: FieldInfo,
10
- value: any,
11
- options: JsonWriteOptions
12
- ) => JsonValue | undefined;
13
- export declare function makeJsonFormatCommon(
14
- makeWriteField: (
15
- writeEnumFn: typeof writeEnum,
16
- writeScalarFn: typeof writeScalar
17
- ) => JsonFormatWriteFieldFn
18
- ): JsonFormat;
19
- declare function writeEnum(
20
- type: EnumType,
21
- value: number | undefined,
22
- emitIntrinsicDefault: boolean,
23
- enumAsInteger: boolean
24
- ): JsonValue | undefined;
25
- declare function writeScalar(
26
- type: ScalarType,
27
- value: any,
28
- emitIntrinsicDefault: boolean
29
- ): JsonValue | undefined;
4
+ declare type JsonFormatWriteFieldFn = (field: FieldInfo, value: any, options: JsonWriteOptions) => JsonValue | undefined;
5
+ export declare function makeJsonFormatCommon(makeWriteField: (writeEnumFn: typeof writeEnum, writeScalarFn: typeof writeScalar) => JsonFormatWriteFieldFn): JsonFormat;
6
+ declare function writeEnum(type: EnumType, value: number | undefined, emitIntrinsicDefault: boolean, enumAsInteger: boolean): JsonValue | undefined;
7
+ declare function writeScalar(type: ScalarType, value: any, emitIntrinsicDefault: boolean): JsonValue | undefined;
30
8
  export {};
@@ -5,11 +5,16 @@ import type { ProtoRuntime } from "./proto-runtime.js";
5
5
  /**
6
6
  * Create a new message type using the given runtime.
7
7
  */
8
- export declare function makeMessageType<T extends Message<T> = AnyMessage>(
9
- runtime: ProtoRuntime,
10
- typeName: string,
11
- fields: FieldListSource,
12
- opt?: {
8
+ export declare function makeMessageType<T extends Message<T> = AnyMessage>(runtime: ProtoRuntime, typeName: string, fields: FieldListSource, opt?: {
9
+ /**
10
+ * localName is the "name" property of the constructed function.
11
+ * It is useful in stack traces, debuggers and test frameworks,
12
+ * but has no other implications.
13
+ *
14
+ * This property is optional because by default, the last part
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.
18
+ */
13
19
  localName?: string;
14
- }
15
- ): MessageType<T>;
20
+ }): MessageType<T>;
@@ -5,10 +5,7 @@ export declare function makeJsonName(protoName: string): string;
5
5
  /**
6
6
  * Returns the local name of a field, exactly like protoc-gen-es does.
7
7
  */
8
- export declare function makeFieldName(
9
- protoName: string,
10
- inOneof: boolean
11
- ): string;
8
+ export declare function makeFieldName(protoName: string, inOneof: boolean): string;
12
9
  /**
13
10
  * Returns the local name of a oneof group, exactly like protoc-gen-es does.
14
11
  */
@@ -3,5 +3,5 @@ import type { JsonValue } from "../json-format";
3
3
  *
4
4
  */
5
5
  export declare type OptionsMap = {
6
- readonly [extensionName: string]: JsonValue;
6
+ readonly [extensionName: string]: JsonValue;
7
7
  };
@@ -1,4 +1,4 @@
1
- import type { JsonFormat, JsonValue } from "../json-format.js";
1
+ import type { JsonFormat } from "../json-format.js";
2
2
  import type { BinaryFormat } from "../binary-format.js";
3
3
  import type { AnyMessage } from "../message.js";
4
4
  import type { Message } from "../message.js";
@@ -11,45 +11,37 @@ import type { Util } from "./util.js";
11
11
  * A facade that provides serialization and other internal functionality.
12
12
  */
13
13
  export interface ProtoRuntime {
14
- readonly syntax: string;
15
- readonly json: JsonFormat;
16
- readonly bin: BinaryFormat;
17
- readonly util: Util;
18
- /**
19
- * Create a message type at runtime, without generating code.
20
- */
21
- makeMessageType<T extends Message<T> = AnyMessage>(
22
- typeName: string,
23
- fields: FieldListSource,
24
- opt?: {
25
- localName?: string;
26
- options?: {
27
- readonly [extensionName: string]: JsonValue;
28
- };
29
- }
30
- ): MessageType<T>;
31
- /**
32
- * Create an enum type at runtime, without generating code.
33
- */
34
- makeEnumType(
35
- typeName: string,
36
- values: EnumValueInfo[],
37
- opt?: {
38
- options?: {
39
- readonly [extensionName: string]: JsonValue;
40
- };
41
- }
42
- ): EnumType;
43
- /**
44
- * Get reflection information from a generated enum.
45
- * If this function is called on something other than a generated
46
- * enum, it raises an error.
47
- */
48
- getEnumType(enumObject: EnumObject): EnumType;
14
+ readonly syntax: string;
15
+ readonly json: JsonFormat;
16
+ readonly bin: BinaryFormat;
17
+ readonly util: Util;
18
+ /**
19
+ * Create a message type at runtime, without generating code.
20
+ */
21
+ makeMessageType<T extends Message<T> = AnyMessage>(typeName: string, fields: FieldListSource, opt?: {
22
+ localName?: string;
23
+ }): MessageType<T>;
24
+ /**
25
+ * Create an enum object at runtime, without generating code.
26
+ *
27
+ * The object conforms to TypeScript enums, and comes with
28
+ * mapping from name to value, and from value to name.
29
+ *
30
+ * The type name and other reflection information is accessible
31
+ * via getEnumType().
32
+ */
33
+ makeEnum(typeName: string, values: EnumValueInfo[], opt?: {}): EnumObject;
34
+ /**
35
+ * Create an enum type at runtime, without generating code.
36
+ * Note that this only creates the reflection information, not an
37
+ * actual enum object.
38
+ */
39
+ makeEnumType(typeName: string, values: EnumValueInfo[], opt?: {}): EnumType;
40
+ /**
41
+ * Get reflection information - the EnumType - from an enum object.
42
+ * If this function is called on something other than a generated
43
+ * enum, or an enum constructed with makeEnum(), it raises an error.
44
+ */
45
+ getEnumType(enumObject: EnumObject): EnumType;
49
46
  }
50
- export declare function makeProtoRuntime(
51
- syntax: string,
52
- json: JsonFormat,
53
- bin: BinaryFormat,
54
- util: Util
55
- ): ProtoRuntime;
47
+ export declare function makeProtoRuntime(syntax: string, json: JsonFormat, bin: BinaryFormat, util: Util): ProtoRuntime;
@@ -3,11 +3,7 @@ import { IBinaryWriter, WireType } from "../binary-encoding.js";
3
3
  /**
4
4
  * Returns true if both scalar values are equal.
5
5
  */
6
- export declare function scalarEquals(
7
- type: ScalarType,
8
- a: string | boolean | number | bigint | Uint8Array | undefined,
9
- b: string | boolean | number | bigint | Uint8Array | undefined
10
- ): boolean;
6
+ export declare function scalarEquals(type: ScalarType, a: string | boolean | number | bigint | Uint8Array | undefined, b: string | boolean | number | bigint | Uint8Array | undefined): boolean;
11
7
  /**
12
8
  * Returns the default value for the given scalar type, following
13
9
  * proto3 semantics.
@@ -23,11 +19,8 @@ export declare function scalarDefaultValue(type: ScalarType): any;
23
19
  *
24
20
  * If argument `value` is omitted, [2] is always false.
25
21
  */
26
- export declare function scalarTypeInfo(
27
- type: ScalarType,
28
- value?: any
29
- ): [
30
- WireType,
31
- Exclude<keyof IBinaryWriter, "tag" | "raw" | "fork" | "join" | "finish">,
32
- boolean
22
+ export declare function scalarTypeInfo(type: ScalarType, value?: any): [
23
+ WireType,
24
+ Exclude<keyof IBinaryWriter, "tag" | "raw" | "fork" | "join" | "finish">,
25
+ boolean
33
26
  ];
@@ -1,5 +1,2 @@
1
1
  import type { Util } from "./util.js";
2
- export declare function makeUtilCommon(): Omit<
3
- Util,
4
- "newFieldList" | "initFields"
5
- >;
2
+ export declare function makeUtilCommon(): Omit<Util, "newFieldList" | "initFields">;
@@ -11,45 +11,33 @@ import type { EnumValueInfo } from "../enum.js";
11
11
  * future release.
12
12
  */
13
13
  export interface Util {
14
- /**
15
- * Create a field list
16
- */
17
- newFieldList(fields: FieldListSource): FieldList;
18
- /**
19
- * Sets reflection information on a generated enum.
20
- */
21
- setEnumType(
22
- enumObject: EnumObject,
23
- typeName: string,
24
- values: EnumValueInfo[],
25
- opt?: {
26
- options?: {
27
- readonly [extensionName: string]: JsonValue;
28
- };
29
- }
30
- ): void;
31
- /**
32
- * Set default field values on the target message.
33
- */
34
- initFields(target: Message): void;
35
- /**
36
- * Set specified field values on the target message, recursively.
37
- */
38
- initPartial<T extends Message<T>>(
39
- source: PartialMessage<T> | undefined,
40
- target: T
41
- ): void;
42
- /**
43
- * Compares two messages of the same type recursively.
44
- * Will also return true if both messages are `undefined`.
45
- */
46
- equals<T extends Message<T>>(
47
- type: MessageType,
48
- a: T | PlainMessage<T> | undefined,
49
- b: T | PlainMessage<T> | undefined
50
- ): boolean;
51
- /**
52
- * Create a deep copy.
53
- */
54
- clone<T extends Message<T>>(message: T): T;
14
+ /**
15
+ * Create a field list
16
+ */
17
+ newFieldList(fields: FieldListSource): FieldList;
18
+ /**
19
+ * Sets reflection information on a generated enum.
20
+ */
21
+ setEnumType(enumObject: EnumObject, typeName: string, values: EnumValueInfo[], opt?: {
22
+ options?: {
23
+ readonly [extensionName: string]: JsonValue;
24
+ };
25
+ }): void;
26
+ /**
27
+ * Set default field values on the target message.
28
+ */
29
+ initFields(target: Message): void;
30
+ /**
31
+ * Set specified field values on the target message, recursively.
32
+ */
33
+ initPartial<T extends Message<T>>(source: PartialMessage<T> | undefined, target: T): void;
34
+ /**
35
+ * Compares two messages of the same type recursively.
36
+ * Will also return true if both messages are `undefined`.
37
+ */
38
+ equals<T extends Message<T>>(type: MessageType, a: T | PlainMessage<T> | undefined, b: T | PlainMessage<T> | undefined): boolean;
39
+ /**
40
+ * Create a deep copy.
41
+ */
42
+ clone<T extends Message<T>>(message: T): T;
55
43
  }
@@ -47,48 +47,48 @@
47
47
  * on a two's complement, for example the npm package "long".
48
48
  */
49
49
  interface Int64Support {
50
- /**
51
- * 0n if bigint is available, "0" if unavailable.
52
- */
53
- readonly zero: bigint;
54
- /**
55
- * Is bigint available?
56
- */
57
- readonly supported: boolean;
58
- /**
59
- * Parse a signed 64-bit integer.
60
- * Returns a bigint if available, a string otherwise.
61
- */
62
- parse(value: string | number | bigint): bigint;
63
- /**
64
- * Parse an unsigned 64-bit integer.
65
- * Returns a bigint if available, a string otherwise.
66
- */
67
- uParse(value: string | number | bigint): bigint;
68
- /**
69
- * Convert a signed 64-bit integral value to a two's complement.
70
- */
71
- enc(value: string | number | bigint): {
72
- lo: number;
73
- hi: number;
74
- };
75
- /**
76
- * Convert an unsigned 64-bit integral value to a two's complement.
77
- */
78
- uEnc(value: string | number | bigint): {
79
- lo: number;
80
- hi: number;
81
- };
82
- /**
83
- * Convert a two's complement to a signed 64-bit integral value.
84
- * Returns a bigint if available, a string otherwise.
85
- */
86
- dec(lo: number, hi: number): bigint;
87
- /**
88
- * Convert a two's complement to an unsigned 64-bit integral value.
89
- * Returns a bigint if available, a string otherwise.
90
- */
91
- uDec(lo: number, hi: number): bigint;
50
+ /**
51
+ * 0n if bigint is available, "0" if unavailable.
52
+ */
53
+ readonly zero: bigint;
54
+ /**
55
+ * Is bigint available?
56
+ */
57
+ readonly supported: boolean;
58
+ /**
59
+ * Parse a signed 64-bit integer.
60
+ * Returns a bigint if available, a string otherwise.
61
+ */
62
+ parse(value: string | number | bigint): bigint;
63
+ /**
64
+ * Parse an unsigned 64-bit integer.
65
+ * Returns a bigint if available, a string otherwise.
66
+ */
67
+ uParse(value: string | number | bigint): bigint;
68
+ /**
69
+ * Convert a signed 64-bit integral value to a two's complement.
70
+ */
71
+ enc(value: string | number | bigint): {
72
+ lo: number;
73
+ hi: number;
74
+ };
75
+ /**
76
+ * Convert an unsigned 64-bit integral value to a two's complement.
77
+ */
78
+ uEnc(value: string | number | bigint): {
79
+ lo: number;
80
+ hi: number;
81
+ };
82
+ /**
83
+ * Convert a two's complement to a signed 64-bit integral value.
84
+ * Returns a bigint if available, a string otherwise.
85
+ */
86
+ dec(lo: number, hi: number): bigint;
87
+ /**
88
+ * Convert a two's complement to an unsigned 64-bit integral value.
89
+ * Returns a bigint if available, a string otherwise.
90
+ */
91
+ uDec(lo: number, hi: number): bigint;
92
92
  }
93
93
  export declare const protoInt64: Int64Support;
94
94
  export {};
@@ -5,16 +5,16 @@ import type { MessageType } from "./message-type.js";
5
5
  * reflection-based operations.
6
6
  */
7
7
  export interface ServiceType {
8
- /**
9
- * The fully qualified name of the service.
10
- */
11
- readonly typeName: string;
12
- /**
13
- * A map of local name (safe to use in ECMAScript) to method.
14
- */
15
- readonly methods: {
16
- [localName: string]: MethodInfo;
17
- };
8
+ /**
9
+ * The fully qualified name of the service.
10
+ */
11
+ readonly typeName: string;
12
+ /**
13
+ * A map of local name (safe to use in ECMAScript) to method.
14
+ */
15
+ readonly methods: {
16
+ [localName: string]: MethodInfo;
17
+ };
18
18
  }
19
19
  /**
20
20
  * MethodInfo represents a method of a protobuf service, a remote procedure
@@ -29,56 +29,36 @@ export interface ServiceType {
29
29
  * - "idempotency": User-provided indication whether the method will cause
30
30
  * the same effect every time it is called.
31
31
  */
32
- export declare type MethodInfo<
33
- I extends Message<I> = AnyMessage,
34
- O extends Message<O> = AnyMessage
35
- > =
36
- | MethodInfoUnary<I, O>
37
- | MethodInfoServerStreaming<I, O>
38
- | MethodInfoClientStreaming<I, O>
39
- | MethodInfoBiDiStreaming<I, O>;
32
+ export declare type MethodInfo<I extends Message<I> = AnyMessage, O extends Message<O> = AnyMessage> = MethodInfoUnary<I, O> | MethodInfoServerStreaming<I, O> | MethodInfoClientStreaming<I, O> | MethodInfoBiDiStreaming<I, O>;
40
33
  /**
41
34
  * A unary method: rpc (Input) returns (Output)
42
35
  */
43
- export interface MethodInfoUnary<I extends Message<I>, O extends Message<O>>
44
- extends miShared<I, O> {
45
- readonly kind: MethodKind.Unary;
36
+ export interface MethodInfoUnary<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
37
+ readonly kind: MethodKind.Unary;
46
38
  }
47
39
  /**
48
40
  * A server streaming method: rpc (Input) returns (stream Output)
49
41
  */
50
- export interface MethodInfoServerStreaming<
51
- I extends Message<I>,
52
- O extends Message<O>
53
- > extends miShared<I, O> {
54
- readonly kind: MethodKind.ServerStreaming;
42
+ export interface MethodInfoServerStreaming<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
43
+ readonly kind: MethodKind.ServerStreaming;
55
44
  }
56
45
  /**
57
46
  * A client streaming method: rpc (stream Input) returns (Output)
58
47
  */
59
- export interface MethodInfoClientStreaming<
60
- I extends Message<I>,
61
- O extends Message<O>
62
- > extends miShared<I, O> {
63
- readonly kind: MethodKind.ClientStreaming;
48
+ export interface MethodInfoClientStreaming<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
49
+ readonly kind: MethodKind.ClientStreaming;
64
50
  }
65
51
  /**
66
52
  * A method that streams bi-directionally: rpc (stream Input) returns (stream Output)
67
53
  */
68
- export interface MethodInfoBiDiStreaming<
69
- I extends Message<I>,
70
- O extends Message<O>
71
- > extends miShared<I, O> {
72
- readonly kind: MethodKind.BiDiStreaming;
54
+ export interface MethodInfoBiDiStreaming<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
55
+ readonly kind: MethodKind.BiDiStreaming;
73
56
  }
74
- interface miShared<
75
- I extends Message<I> = AnyMessage,
76
- O extends Message<O> = AnyMessage
77
- > {
78
- readonly name: string;
79
- readonly I: MessageType<I>;
80
- readonly O: MessageType<O>;
81
- readonly idempotency?: MethodIdempotency;
57
+ interface miShared<I extends Message<I> = AnyMessage, O extends Message<O> = AnyMessage> {
58
+ readonly name: string;
59
+ readonly I: MessageType<I>;
60
+ readonly O: MessageType<O>;
61
+ readonly idempotency?: MethodIdempotency;
82
62
  }
83
63
  /**
84
64
  * MethodKind represents the four method types that can be declared in
@@ -90,10 +70,10 @@ interface miShared<
90
70
  * 4. BiDiStreaming: rpc (stream Input) returns (stream Output)
91
71
  */
92
72
  export declare enum MethodKind {
93
- Unary = 0,
94
- ServerStreaming = 1,
95
- ClientStreaming = 2,
96
- BiDiStreaming = 3,
73
+ Unary = 0,
74
+ ServerStreaming = 1,
75
+ ClientStreaming = 2,
76
+ BiDiStreaming = 3
97
77
  }
98
78
  /**
99
79
  * Is this method side-effect-free (or safe in HTTP parlance), or just
@@ -106,13 +86,13 @@ export declare enum MethodKind {
106
86
  * drops UNKNOWN.
107
87
  */
108
88
  export declare enum MethodIdempotency {
109
- /**
110
- * Idempotent, no side effects.
111
- */
112
- NoSideEffects = 1,
113
- /**
114
- * Idempotent, but may have side effects.
115
- */
116
- Idempotent = 2,
89
+ /**
90
+ * Idempotent, no side effects.
91
+ */
92
+ NoSideEffects = 1,
93
+ /**
94
+ * Idempotent, but may have side effects.
95
+ */
96
+ Idempotent = 2
117
97
  }
118
98
  export {};
@@ -5,33 +5,31 @@ import type { ServiceType } from "./service-type.js";
5
5
  * IMessageTypeRegistry provides look-up for message types.
6
6
  */
7
7
  export interface IMessageTypeRegistry {
8
- findMessage(typeName: string): MessageType | undefined;
8
+ findMessage(typeName: string): MessageType | undefined;
9
9
  }
10
10
  /**
11
11
  * IEnumTypeRegistry provides look-up for enum types.
12
12
  */
13
13
  export interface IEnumTypeRegistry {
14
- findEnum(typeName: string): EnumType | undefined;
14
+ findEnum(typeName: string): EnumType | undefined;
15
15
  }
16
16
  /**
17
17
  * IServiceTypeRegistry provides look-up for service types.
18
18
  */
19
19
  export interface IServiceTypeRegistry {
20
- findService(typeName: string): ServiceType | undefined;
20
+ findService(typeName: string): ServiceType | undefined;
21
21
  }
22
22
  /**
23
23
  * TypeRegistry is a basic type registry
24
24
  */
25
- export declare class TypeRegistry
26
- implements IMessageTypeRegistry, IEnumTypeRegistry, IServiceTypeRegistry
27
- {
28
- private readonly messages;
29
- private readonly enums;
30
- private readonly services;
31
- findMessage(typeName: string): MessageType | undefined;
32
- findEnum(typeName: string): EnumType | undefined;
33
- findService(typeName: string): ServiceType | undefined;
34
- private add;
35
- static fromIterable(types: Iterable<MessageType>): TypeRegistry;
36
- static fromTypes(...types: MessageType[]): TypeRegistry;
25
+ export declare class TypeRegistry implements IMessageTypeRegistry, IEnumTypeRegistry, IServiceTypeRegistry {
26
+ private readonly messages;
27
+ private readonly enums;
28
+ private readonly services;
29
+ findMessage(typeName: string): MessageType | undefined;
30
+ findEnum(typeName: string): EnumType | undefined;
31
+ findService(typeName: string): ServiceType | undefined;
32
+ private add;
33
+ static fromIterable(types: Iterable<MessageType>): TypeRegistry;
34
+ static fromTypes(...types: MessageType[]): TypeRegistry;
37
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protobuf",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.2-alpha.2",
4
4
  "license": "(Apache-2.0 AND BSD-3-Clause)",
5
5
  "description": "A complete implementation of protocol buffers in TypeScript, suitable for web browsers and Node.js.",
6
6
  "repository": {
@@ -15,7 +15,6 @@
15
15
  "build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
16
16
  },
17
17
  "type": "module",
18
- "main": "./dist/cjs/index.js",
19
18
  "types": "./dist/types/index.d.ts",
20
19
  "exports": {
21
20
  "import": "./dist/esm/index.js",
@@ -23,7 +22,7 @@
23
22
  "default": "./dist/esm/index.js"
24
23
  },
25
24
  "devDependencies": {
26
- "typescript": "^4.5.4"
25
+ "typescript": "^4.6.3"
27
26
  },
28
27
  "files": [
29
28
  "dist/**/"