@bufbuild/protobuf 1.3.0 → 1.3.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 (119) hide show
  1. package/dist/cjs/google/protobuf/struct_pb.js +1 -1
  2. package/dist/cjs/google/protobuf/type_pb.js +1 -1
  3. package/dist/cjs/private/json-format-common.js +2 -1
  4. package/dist/cjs/private/util-common.js +37 -8
  5. package/dist/esm/binary-encoding.d.ts +421 -0
  6. package/dist/esm/binary-format.d.ts +87 -0
  7. package/dist/esm/codegen-info.d.ts +23 -0
  8. package/dist/esm/create-descriptor-set.d.ts +16 -0
  9. package/dist/esm/create-registry-from-desc.d.ts +15 -0
  10. package/dist/esm/create-registry.d.ts +8 -0
  11. package/dist/esm/descriptor-set.d.ts +606 -0
  12. package/dist/esm/enum.d.ts +35 -0
  13. package/dist/esm/field-list.d.ts +27 -0
  14. package/dist/esm/field.d.ts +255 -0
  15. package/dist/esm/google/protobuf/any_pb.d.ts +156 -0
  16. package/dist/esm/google/protobuf/api_pb.d.ts +256 -0
  17. package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +236 -0
  18. package/dist/esm/google/protobuf/descriptor_pb.d.ts +1851 -0
  19. package/dist/esm/google/protobuf/duration_pb.d.ts +100 -0
  20. package/dist/esm/google/protobuf/empty_pb.d.ts +28 -0
  21. package/dist/esm/google/protobuf/field_mask_pb.d.ts +227 -0
  22. package/dist/esm/google/protobuf/source_context_pb.d.ts +29 -0
  23. package/dist/esm/google/protobuf/struct_pb.d.ts +158 -0
  24. package/dist/esm/google/protobuf/struct_pb.js +1 -1
  25. package/dist/esm/google/protobuf/timestamp_pb.d.ts +132 -0
  26. package/dist/esm/google/protobuf/type_pb.d.ts +437 -0
  27. package/dist/esm/google/protobuf/type_pb.js +1 -1
  28. package/dist/esm/google/protobuf/wrappers_pb.d.ts +267 -0
  29. package/dist/esm/google/varint.d.ts +70 -0
  30. package/dist/esm/index.d.ts +38 -0
  31. package/dist/esm/json-format.d.ts +110 -0
  32. package/dist/esm/message-type.d.ts +51 -0
  33. package/dist/esm/message.d.ts +130 -0
  34. package/dist/esm/private/assert.d.ts +16 -0
  35. package/dist/esm/private/binary-format-common.d.ts +13 -0
  36. package/dist/esm/private/binary-format-proto2.d.ts +2 -0
  37. package/dist/esm/private/binary-format-proto3.d.ts +2 -0
  38. package/dist/esm/private/enum.d.ts +27 -0
  39. package/dist/esm/private/field-list.d.ts +18 -0
  40. package/dist/esm/private/field-wrapper.d.ts +25 -0
  41. package/dist/esm/private/field.d.ts +15 -0
  42. package/dist/esm/private/json-format-common.d.ts +9 -0
  43. package/dist/esm/private/json-format-common.js +2 -1
  44. package/dist/esm/private/json-format-proto2.d.ts +2 -0
  45. package/dist/esm/private/json-format-proto3.d.ts +2 -0
  46. package/dist/esm/private/message-type.d.ts +18 -0
  47. package/dist/esm/private/names.d.ts +43 -0
  48. package/dist/esm/private/options-map.d.ts +7 -0
  49. package/dist/esm/private/proto-runtime.d.ts +47 -0
  50. package/dist/esm/private/reify-wkt.d.ts +100 -0
  51. package/dist/esm/private/scalars.d.ts +27 -0
  52. package/dist/esm/private/util-common.d.ts +2 -0
  53. package/dist/esm/private/util-common.js +37 -8
  54. package/dist/esm/private/util.d.ts +38 -0
  55. package/dist/esm/proto-base64.d.ts +18 -0
  56. package/dist/esm/proto-delimited.d.ts +54 -0
  57. package/dist/esm/proto-double.d.ts +5 -0
  58. package/dist/esm/proto-int64.d.ts +95 -0
  59. package/dist/esm/proto2.d.ts +4 -0
  60. package/dist/esm/proto3.d.ts +4 -0
  61. package/dist/esm/service-type.d.ts +96 -0
  62. package/dist/esm/to-plain-message.d.ts +9 -0
  63. package/dist/esm/type-registry.d.ts +30 -0
  64. package/package.json +14 -9
  65. /package/dist/{types → cjs}/binary-encoding.d.ts +0 -0
  66. /package/dist/{types → cjs}/binary-format.d.ts +0 -0
  67. /package/dist/{types → cjs}/codegen-info.d.ts +0 -0
  68. /package/dist/{types → cjs}/create-descriptor-set.d.ts +0 -0
  69. /package/dist/{types → cjs}/create-registry-from-desc.d.ts +0 -0
  70. /package/dist/{types → cjs}/create-registry.d.ts +0 -0
  71. /package/dist/{types → cjs}/descriptor-set.d.ts +0 -0
  72. /package/dist/{types → cjs}/enum.d.ts +0 -0
  73. /package/dist/{types → cjs}/field-list.d.ts +0 -0
  74. /package/dist/{types → cjs}/field.d.ts +0 -0
  75. /package/dist/{types → cjs}/google/protobuf/any_pb.d.ts +0 -0
  76. /package/dist/{types → cjs}/google/protobuf/api_pb.d.ts +0 -0
  77. /package/dist/{types → cjs}/google/protobuf/compiler/plugin_pb.d.ts +0 -0
  78. /package/dist/{types → cjs}/google/protobuf/descriptor_pb.d.ts +0 -0
  79. /package/dist/{types → cjs}/google/protobuf/duration_pb.d.ts +0 -0
  80. /package/dist/{types → cjs}/google/protobuf/empty_pb.d.ts +0 -0
  81. /package/dist/{types → cjs}/google/protobuf/field_mask_pb.d.ts +0 -0
  82. /package/dist/{types → cjs}/google/protobuf/source_context_pb.d.ts +0 -0
  83. /package/dist/{types → cjs}/google/protobuf/struct_pb.d.ts +0 -0
  84. /package/dist/{types → cjs}/google/protobuf/timestamp_pb.d.ts +0 -0
  85. /package/dist/{types → cjs}/google/protobuf/type_pb.d.ts +0 -0
  86. /package/dist/{types → cjs}/google/protobuf/wrappers_pb.d.ts +0 -0
  87. /package/dist/{types → cjs}/google/varint.d.ts +0 -0
  88. /package/dist/{types → cjs}/index.d.ts +0 -0
  89. /package/dist/{types → cjs}/json-format.d.ts +0 -0
  90. /package/dist/{types → cjs}/message-type.d.ts +0 -0
  91. /package/dist/{types → cjs}/message.d.ts +0 -0
  92. /package/dist/{types → cjs}/private/assert.d.ts +0 -0
  93. /package/dist/{types → cjs}/private/binary-format-common.d.ts +0 -0
  94. /package/dist/{types → cjs}/private/binary-format-proto2.d.ts +0 -0
  95. /package/dist/{types → cjs}/private/binary-format-proto3.d.ts +0 -0
  96. /package/dist/{types → cjs}/private/enum.d.ts +0 -0
  97. /package/dist/{types → cjs}/private/field-list.d.ts +0 -0
  98. /package/dist/{types → cjs}/private/field-wrapper.d.ts +0 -0
  99. /package/dist/{types → cjs}/private/field.d.ts +0 -0
  100. /package/dist/{types → cjs}/private/json-format-common.d.ts +0 -0
  101. /package/dist/{types → cjs}/private/json-format-proto2.d.ts +0 -0
  102. /package/dist/{types → cjs}/private/json-format-proto3.d.ts +0 -0
  103. /package/dist/{types → cjs}/private/message-type.d.ts +0 -0
  104. /package/dist/{types → cjs}/private/names.d.ts +0 -0
  105. /package/dist/{types → cjs}/private/options-map.d.ts +0 -0
  106. /package/dist/{types → cjs}/private/proto-runtime.d.ts +0 -0
  107. /package/dist/{types → cjs}/private/reify-wkt.d.ts +0 -0
  108. /package/dist/{types → cjs}/private/scalars.d.ts +0 -0
  109. /package/dist/{types → cjs}/private/util-common.d.ts +0 -0
  110. /package/dist/{types → cjs}/private/util.d.ts +0 -0
  111. /package/dist/{types → cjs}/proto-base64.d.ts +0 -0
  112. /package/dist/{types → cjs}/proto-delimited.d.ts +0 -0
  113. /package/dist/{types → cjs}/proto-double.d.ts +0 -0
  114. /package/dist/{types → cjs}/proto-int64.d.ts +0 -0
  115. /package/dist/{types → cjs}/proto2.d.ts +0 -0
  116. /package/dist/{types → cjs}/proto3.d.ts +0 -0
  117. /package/dist/{types → cjs}/service-type.d.ts +0 -0
  118. /package/dist/{types → cjs}/to-plain-message.d.ts +0 -0
  119. /package/dist/{types → cjs}/type-registry.d.ts +0 -0
@@ -0,0 +1,95 @@
1
+ /**
2
+ * We use the `bigint` primitive to represent 64-bit integral types. If bigint
3
+ * is unavailable, we fall back to a string representation, which means that
4
+ * all values typed as `bigint` will actually be strings.
5
+ *
6
+ * If your code is intended to run in an environment where bigint may be
7
+ * unavailable, it must handle both the bigint and the string representation.
8
+ * For presenting values, this is straight-forward with implicit or explicit
9
+ * conversion to string:
10
+ *
11
+ * ```ts
12
+ * let el = document.createElement("span");
13
+ * el.innerText = message.int64Field; // assuming a protobuf int64 field
14
+ *
15
+ * console.log(`int64: ${message.int64Field}`);
16
+ *
17
+ * let str: string = message.int64Field.toString();
18
+ * ```
19
+ *
20
+ * If you need to manipulate 64-bit integral values and are sure the values
21
+ * can be safely represented as an IEEE-754 double precision number, you can
22
+ * convert to a JavaScript Number:
23
+ *
24
+ * ```ts
25
+ * console.log(message.int64Field.toString())
26
+ * let num = Number(message.int64Field);
27
+ * num = num + 1;
28
+ * message.int64Field = protoInt64.parse(num);
29
+ * ```
30
+ *
31
+ * If you need to manipulate 64-bit integral values that are outside the
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
+ *
35
+ * ```ts
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);
42
+ *
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
+ * ```
49
+ */
50
+ interface Int64Support {
51
+ /**
52
+ * 0n if bigint is available, "0" if unavailable.
53
+ */
54
+ readonly zero: bigint;
55
+ /**
56
+ * Is bigint available?
57
+ */
58
+ readonly supported: boolean;
59
+ /**
60
+ * Parse a signed 64-bit integer.
61
+ * Returns a bigint if available, a string otherwise.
62
+ */
63
+ parse(value: string | number | bigint): bigint;
64
+ /**
65
+ * Parse an unsigned 64-bit integer.
66
+ * Returns a bigint if available, a string otherwise.
67
+ */
68
+ uParse(value: string | number | bigint): bigint;
69
+ /**
70
+ * Convert a signed 64-bit integral value to a two's complement.
71
+ */
72
+ enc(value: string | number | bigint): {
73
+ lo: number;
74
+ hi: number;
75
+ };
76
+ /**
77
+ * Convert an unsigned 64-bit integral value to a two's complement.
78
+ */
79
+ uEnc(value: string | number | bigint): {
80
+ lo: number;
81
+ hi: number;
82
+ };
83
+ /**
84
+ * Convert a two's complement to a signed 64-bit integral value.
85
+ * Returns a bigint if available, a string otherwise.
86
+ */
87
+ dec(lo: number, hi: number): bigint;
88
+ /**
89
+ * Convert a two's complement to an unsigned 64-bit integral value.
90
+ * Returns a bigint if available, a string otherwise.
91
+ */
92
+ uDec(lo: number, hi: number): bigint;
93
+ }
94
+ export declare const protoInt64: Int64Support;
95
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Provides functionality for messages defined with the proto2 syntax.
3
+ */
4
+ export declare const proto2: import("./private/proto-runtime.js").ProtoRuntime;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Provides functionality for messages defined with the proto3 syntax.
3
+ */
4
+ export declare const proto3: import("./private/proto-runtime.js").ProtoRuntime;
@@ -0,0 +1,96 @@
1
+ import type { AnyMessage, Message } from "./message.js";
2
+ import type { MessageType } from "./message-type.js";
3
+ /**
4
+ * ServiceType represents a protobuf services. It provides metadata for
5
+ * reflection-based operations.
6
+ */
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
+ };
18
+ }
19
+ /**
20
+ * MethodInfo represents a method of a protobuf service, a remote procedure
21
+ * call. All methods provide the following properties:
22
+ *
23
+ * - "name": The original name of the protobuf rpc.
24
+ * - "I": The input message type.
25
+ * - "O": The output message type.
26
+ * - "kind": The method type.
27
+ * - "idempotency": User-provided indication whether the method will cause
28
+ * the same effect every time it is called.
29
+ */
30
+ export type MethodInfo<I extends Message<I> = AnyMessage, O extends Message<O> = AnyMessage> = MethodInfoUnary<I, O> | MethodInfoServerStreaming<I, O> | MethodInfoClientStreaming<I, O> | MethodInfoBiDiStreaming<I, O>;
31
+ /**
32
+ * A unary method: rpc (Input) returns (Output)
33
+ */
34
+ export interface MethodInfoUnary<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
35
+ readonly kind: MethodKind.Unary;
36
+ }
37
+ /**
38
+ * A server streaming method: rpc (Input) returns (stream Output)
39
+ */
40
+ export interface MethodInfoServerStreaming<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
41
+ readonly kind: MethodKind.ServerStreaming;
42
+ }
43
+ /**
44
+ * A client streaming method: rpc (stream Input) returns (Output)
45
+ */
46
+ export interface MethodInfoClientStreaming<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
47
+ readonly kind: MethodKind.ClientStreaming;
48
+ }
49
+ /**
50
+ * A method that streams bi-directionally: rpc (stream Input) returns (stream Output)
51
+ */
52
+ export interface MethodInfoBiDiStreaming<I extends Message<I>, O extends Message<O>> extends miShared<I, O> {
53
+ readonly kind: MethodKind.BiDiStreaming;
54
+ }
55
+ interface miShared<I extends Message<I> = AnyMessage, O extends Message<O> = AnyMessage> {
56
+ readonly name: string;
57
+ readonly I: MessageType<I>;
58
+ readonly O: MessageType<O>;
59
+ readonly idempotency?: MethodIdempotency;
60
+ }
61
+ /**
62
+ * MethodKind represents the four method types that can be declared in
63
+ * protobuf with the `stream` keyword:
64
+ *
65
+ * 1. Unary: rpc (Input) returns (Output)
66
+ * 2. ServerStreaming: rpc (Input) returns (stream Output)
67
+ * 3. ClientStreaming: rpc (stream Input) returns (Output)
68
+ * 4. BiDiStreaming: rpc (stream Input) returns (stream Output)
69
+ */
70
+ export declare enum MethodKind {
71
+ Unary = 0,
72
+ ServerStreaming = 1,
73
+ ClientStreaming = 2,
74
+ BiDiStreaming = 3
75
+ }
76
+ /**
77
+ * Is this method side-effect-free (or safe in HTTP parlance), or just
78
+ * idempotent, or neither? HTTP based RPC implementation may choose GET verb
79
+ * for safe methods, and PUT verb for idempotent methods instead of the
80
+ * default POST.
81
+ *
82
+ * This enum matches the protobuf enum google.protobuf.MethodOptions.IdempotencyLevel,
83
+ * defined in the well-known type google/protobuf/descriptor.proto, but
84
+ * drops UNKNOWN.
85
+ */
86
+ export declare enum MethodIdempotency {
87
+ /**
88
+ * Idempotent, no side effects.
89
+ */
90
+ NoSideEffects = 1,
91
+ /**
92
+ * Idempotent, but may have side effects.
93
+ */
94
+ Idempotent = 2
95
+ }
96
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Message } from "./message.js";
2
+ import type { PlainMessage } from "./message.js";
3
+ /**
4
+ * toPlainMessage returns a new object by striping
5
+ * all methods from a message, leaving only fields and
6
+ * oneof groups. It is recursive, meaning it applies this
7
+ * same logic to all nested message fields as well.
8
+ */
9
+ export declare function toPlainMessage<T extends Message<T>>(message: T): PlainMessage<T>;
@@ -0,0 +1,30 @@
1
+ import type { MessageType } from "./message-type.js";
2
+ import type { EnumType } from "./enum.js";
3
+ import type { ServiceType } from "./service-type.js";
4
+ /**
5
+ * IMessageTypeRegistry provides look-up for message types.
6
+ */
7
+ export interface IMessageTypeRegistry {
8
+ /**
9
+ * Find a message type by its protobuf type name.
10
+ */
11
+ findMessage(typeName: string): MessageType | undefined;
12
+ }
13
+ /**
14
+ * IEnumTypeRegistry provides look-up for enum types.
15
+ */
16
+ export interface IEnumTypeRegistry {
17
+ /**
18
+ * Find an enum type by its protobuf type name.
19
+ */
20
+ findEnum(typeName: string): EnumType | undefined;
21
+ }
22
+ /**
23
+ * IServiceTypeRegistry provides look-up for service types.
24
+ */
25
+ export interface IServiceTypeRegistry {
26
+ /**
27
+ * Find a service type by its protobuf type name.
28
+ */
29
+ findService(typeName: string): ServiceType | undefined;
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protobuf",
3
- "version": "1.3.0",
3
+ "version": "1.3.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": {
@@ -10,18 +10,23 @@
10
10
  },
11
11
  "sideEffects": false,
12
12
  "scripts": {
13
- "clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
14
- "build": "npm run build:cjs && npm run 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 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/types"
13
+ "clean": "rm -rf ./dist/cjs/* ./dist/esm/*",
14
+ "build": "npm run build:cjs && npm run build:esm",
15
+ "build:cjs": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
16
+ "build:esm": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm",
17
+ "attw": "attw --pack"
17
18
  },
18
19
  "main": "./dist/cjs/index.js",
19
20
  "type": "module",
20
- "types": "./dist/types/index.d.ts",
21
21
  "exports": {
22
- "import": "./dist/esm/index.js",
23
- "require": "./dist/cjs/index.js",
24
- "types": "./dist/types/index.d.ts"
22
+ "import": {
23
+ "types": "./dist/esm/index.d.ts",
24
+ "default": "./dist/esm/index.js"
25
+ },
26
+ "require": {
27
+ "types": "./dist/cjs/index.d.ts",
28
+ "default": "./dist/cjs/index.js"
29
+ }
25
30
  },
26
31
  "files": [
27
32
  "dist/**"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes