@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.
Files changed (146) hide show
  1. package/README.md +6 -0
  2. package/dist/cjs/binary-encoding.js +434 -0
  3. package/dist/cjs/binary-format.js +2 -0
  4. package/dist/cjs/descriptor-registry.js +518 -0
  5. package/dist/cjs/descriptor-set.js +557 -0
  6. package/dist/cjs/enum.js +2 -0
  7. package/dist/cjs/field-list.js +2 -0
  8. package/dist/cjs/field.js +40 -0
  9. package/dist/cjs/google/protobuf/any_pb.js +280 -0
  10. package/dist/cjs/google/protobuf/api_pb.js +383 -0
  11. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +334 -0
  12. package/dist/cjs/google/protobuf/descriptor_pb.js +2311 -0
  13. package/dist/cjs/google/protobuf/duration_pb.js +201 -0
  14. package/dist/cjs/google/protobuf/empty_pb.js +72 -0
  15. package/dist/cjs/google/protobuf/field_mask_pb.js +347 -0
  16. package/dist/cjs/google/protobuf/source_context_pb.js +74 -0
  17. package/dist/cjs/google/protobuf/struct_pb.js +288 -0
  18. package/dist/cjs/google/protobuf/timestamp_pb.js +271 -0
  19. package/dist/cjs/google/protobuf/type_pb.js +613 -0
  20. package/dist/cjs/google/protobuf/wrappers_pb.js +658 -0
  21. package/dist/cjs/google/varint.js +280 -0
  22. package/dist/cjs/index.js +148 -0
  23. package/dist/cjs/json-format.js +2 -0
  24. package/dist/cjs/message-type.js +2 -0
  25. package/dist/cjs/message.js +98 -0
  26. package/dist/cjs/private/assert.js +52 -0
  27. package/dist/cjs/private/base64.js +118 -0
  28. package/dist/cjs/private/binary-format-common.js +253 -0
  29. package/dist/cjs/private/binary-format-proto2.js +120 -0
  30. package/dist/cjs/private/binary-format-proto3.js +102 -0
  31. package/dist/cjs/private/enum.js +70 -0
  32. package/dist/cjs/private/field-list.js +62 -0
  33. package/dist/cjs/private/field-wrapper.js +25 -0
  34. package/dist/cjs/private/field.js +34 -0
  35. package/dist/cjs/private/json-format-common.js +482 -0
  36. package/dist/cjs/private/json-format-proto2.js +100 -0
  37. package/dist/cjs/private/json-format-proto3.js +103 -0
  38. package/dist/cjs/private/message-type.js +37 -0
  39. package/dist/cjs/private/names.js +101 -0
  40. package/dist/cjs/private/options-map.js +2 -0
  41. package/dist/cjs/private/proto-runtime.js +24 -0
  42. package/dist/cjs/private/scalars.js +138 -0
  43. package/dist/cjs/private/util-common.js +229 -0
  44. package/dist/cjs/private/util.js +2 -0
  45. package/dist/cjs/proto-int64.js +121 -0
  46. package/dist/cjs/proto2.js +86 -0
  47. package/dist/cjs/proto3.js +99 -0
  48. package/dist/cjs/service-type.js +43 -0
  49. package/dist/cjs/type-registry.js +42 -0
  50. package/dist/esm/binary-encoding.js +434 -0
  51. package/dist/esm/binary-format.js +1 -0
  52. package/dist/esm/descriptor-registry.js +521 -0
  53. package/dist/esm/descriptor-set.js +517 -0
  54. package/dist/esm/enum.js +1 -0
  55. package/dist/esm/field-list.js +1 -0
  56. package/dist/esm/field.js +37 -0
  57. package/dist/esm/google/protobuf/any_pb.js +276 -0
  58. package/dist/esm/google/protobuf/api_pb.js +350 -0
  59. package/dist/esm/google/protobuf/compiler/plugin_pb.js +318 -0
  60. package/dist/esm/google/protobuf/descriptor_pb.js +2213 -0
  61. package/dist/esm/google/protobuf/duration_pb.js +197 -0
  62. package/dist/esm/google/protobuf/empty_pb.js +68 -0
  63. package/dist/esm/google/protobuf/field_mask_pb.js +343 -0
  64. package/dist/esm/google/protobuf/source_context_pb.js +70 -0
  65. package/dist/esm/google/protobuf/struct_pb.js +282 -0
  66. package/dist/esm/google/protobuf/timestamp_pb.js +267 -0
  67. package/dist/esm/google/protobuf/type_pb.js +569 -0
  68. package/dist/esm/google/protobuf/wrappers_pb.js +574 -0
  69. package/dist/esm/google/varint.js +265 -0
  70. package/dist/esm/index.js +24 -0
  71. package/dist/esm/json-format.js +1 -0
  72. package/dist/esm/message-type.js +1 -0
  73. package/dist/esm/message.js +94 -0
  74. package/dist/esm/private/assert.js +41 -0
  75. package/dist/esm/private/base64.js +113 -0
  76. package/dist/esm/private/binary-format-common.js +243 -0
  77. package/dist/esm/private/binary-format-proto2.js +87 -0
  78. package/dist/esm/private/binary-format-proto3.js +74 -0
  79. package/dist/esm/private/enum.js +64 -0
  80. package/dist/esm/private/field-list.js +58 -0
  81. package/dist/esm/private/field-wrapper.js +20 -0
  82. package/dist/esm/private/field.js +27 -0
  83. package/dist/esm/private/json-format-common.js +473 -0
  84. package/dist/esm/private/json-format-proto2.js +90 -0
  85. package/dist/esm/private/json-format-proto3.js +89 -0
  86. package/dist/esm/private/message-type.js +33 -0
  87. package/dist/esm/private/names.js +90 -0
  88. package/dist/esm/private/options-map.js +1 -0
  89. package/dist/esm/private/proto-runtime.js +15 -0
  90. package/dist/esm/private/scalars.js +129 -0
  91. package/dist/esm/private/util-common.js +207 -0
  92. package/dist/esm/private/util.js +1 -0
  93. package/dist/esm/proto-int64.js +118 -0
  94. package/dist/esm/proto2.js +77 -0
  95. package/dist/esm/proto3.js +90 -0
  96. package/dist/esm/service-type.js +37 -0
  97. package/dist/esm/type-registry.js +38 -0
  98. package/dist/types/binary-encoding.d.ts +421 -0
  99. package/dist/types/binary-format.d.ts +109 -0
  100. package/dist/types/descriptor-registry.d.ts +42 -0
  101. package/dist/types/descriptor-set.d.ts +171 -0
  102. package/dist/types/enum.d.ts +31 -0
  103. package/dist/types/field-list.d.ts +27 -0
  104. package/dist/types/field.d.ts +295 -0
  105. package/dist/types/google/protobuf/any_pb.d.ts +167 -0
  106. package/dist/types/google/protobuf/api_pb.d.ts +296 -0
  107. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +294 -0
  108. package/dist/types/google/protobuf/descriptor_pb.d.ts +1959 -0
  109. package/dist/types/google/protobuf/duration_pb.d.ts +117 -0
  110. package/dist/types/google/protobuf/empty_pb.d.ts +44 -0
  111. package/dist/types/google/protobuf/field_mask_pb.d.ts +243 -0
  112. package/dist/types/google/protobuf/source_context_pb.d.ts +44 -0
  113. package/dist/types/google/protobuf/struct_pb.d.ts +205 -0
  114. package/dist/types/google/protobuf/timestamp_pb.d.ts +151 -0
  115. package/dist/types/google/protobuf/type_pb.d.ts +482 -0
  116. package/dist/types/google/protobuf/wrappers_pb.d.ts +379 -0
  117. package/dist/types/google/varint.d.ts +65 -0
  118. package/dist/types/index.d.ts +53 -0
  119. package/dist/types/json-format.d.ts +129 -0
  120. package/dist/types/message-type.d.ts +58 -0
  121. package/dist/types/message.d.ts +124 -0
  122. package/dist/types/private/assert.d.ts +19 -0
  123. package/dist/types/private/base64.d.ts +18 -0
  124. package/dist/types/private/binary-format-common.d.ts +38 -0
  125. package/dist/types/private/binary-format-proto2.d.ts +2 -0
  126. package/dist/types/private/binary-format-proto3.d.ts +2 -0
  127. package/dist/types/private/enum.d.ts +29 -0
  128. package/dist/types/private/field-list.d.ts +25 -0
  129. package/dist/types/private/field-wrapper.d.ts +27 -0
  130. package/dist/types/private/field.d.ts +15 -0
  131. package/dist/types/private/json-format-common.d.ts +30 -0
  132. package/dist/types/private/json-format-proto2.d.ts +2 -0
  133. package/dist/types/private/json-format-proto3.d.ts +2 -0
  134. package/dist/types/private/message-type.d.ts +15 -0
  135. package/dist/types/private/names.d.ts +19 -0
  136. package/dist/types/private/options-map.d.ts +7 -0
  137. package/dist/types/private/proto-runtime.d.ts +55 -0
  138. package/dist/types/private/scalars.d.ts +33 -0
  139. package/dist/types/private/util-common.d.ts +5 -0
  140. package/dist/types/private/util.d.ts +55 -0
  141. package/dist/types/proto-int64.d.ts +94 -0
  142. package/dist/types/proto2.d.ts +4 -0
  143. package/dist/types/proto3.d.ts +4 -0
  144. package/dist/types/service-type.d.ts +118 -0
  145. package/dist/types/type-registry.d.ts +37 -0
  146. package/package.json +31 -0
@@ -0,0 +1,197 @@
1
+ /* eslint-disable */
2
+ // @generated by protoc-gen-es v0.0.1-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
+ // @generated from file google/protobuf/duration.proto (package google.protobuf, syntax proto3)
4
+ //
5
+ // Protocol Buffers - Google's data interchange format
6
+ // Copyright 2008 Google Inc. All rights reserved.
7
+ // https://developers.google.com/protocol-buffers/
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions are
11
+ // met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ // * Redistributions in binary form must reproduce the above
16
+ // copyright notice, this list of conditions and the following disclaimer
17
+ // in the documentation and/or other materials provided with the
18
+ // distribution.
19
+ // * Neither the name of Google Inc. nor the names of its
20
+ // contributors may be used to endorse or promote products derived from
21
+ // this software without specific prior written permission.
22
+ //
23
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ import { Message, proto3, protoInt64 } from "../../index.js";
35
+ /**
36
+ * A Duration represents a signed, fixed-length span of time represented
37
+ * as a count of seconds and fractions of seconds at nanosecond
38
+ * resolution. It is independent of any calendar and concepts like "day"
39
+ * or "month". It is related to Timestamp in that the difference between
40
+ * two Timestamp values is a Duration and it can be added or subtracted
41
+ * from a Timestamp. Range is approximately +-10,000 years.
42
+ *
43
+ * # Examples
44
+ *
45
+ * Example 1: Compute Duration from two Timestamps in pseudo code.
46
+ *
47
+ * Timestamp start = ...;
48
+ * Timestamp end = ...;
49
+ * Duration duration = ...;
50
+ *
51
+ * duration.seconds = end.seconds - start.seconds;
52
+ * duration.nanos = end.nanos - start.nanos;
53
+ *
54
+ * if (duration.seconds < 0 && duration.nanos > 0) {
55
+ * duration.seconds += 1;
56
+ * duration.nanos -= 1000000000;
57
+ * } else if (duration.seconds > 0 && duration.nanos < 0) {
58
+ * duration.seconds -= 1;
59
+ * duration.nanos += 1000000000;
60
+ * }
61
+ *
62
+ * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
63
+ *
64
+ * Timestamp start = ...;
65
+ * Duration duration = ...;
66
+ * Timestamp end = ...;
67
+ *
68
+ * end.seconds = start.seconds + duration.seconds;
69
+ * end.nanos = start.nanos + duration.nanos;
70
+ *
71
+ * if (end.nanos < 0) {
72
+ * end.seconds -= 1;
73
+ * end.nanos += 1000000000;
74
+ * } else if (end.nanos >= 1000000000) {
75
+ * end.seconds += 1;
76
+ * end.nanos -= 1000000000;
77
+ * }
78
+ *
79
+ * Example 3: Compute Duration from datetime.timedelta in Python.
80
+ *
81
+ * td = datetime.timedelta(days=3, minutes=10)
82
+ * duration = Duration()
83
+ * duration.FromTimedelta(td)
84
+ *
85
+ * # JSON Mapping
86
+ *
87
+ * In JSON format, the Duration type is encoded as a string rather than an
88
+ * object, where the string ends in the suffix "s" (indicating seconds) and
89
+ * is preceded by the number of seconds, with nanoseconds expressed as
90
+ * fractional seconds. For example, 3 seconds with 0 nanoseconds should be
91
+ * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
92
+ * be expressed in JSON format as "3.000000001s", and 3 seconds and 1
93
+ * microsecond should be expressed in JSON format as "3.000001s".
94
+ *
95
+ *
96
+ *
97
+ * @generated from message google.protobuf.Duration
98
+ */
99
+ export class Duration extends Message {
100
+ constructor(data) {
101
+ super();
102
+ /**
103
+ * Signed seconds of the span of time. Must be from -315,576,000,000
104
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
105
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
106
+ *
107
+ * @generated from field: int64 seconds = 1;
108
+ */
109
+ this.seconds = protoInt64.zero;
110
+ /**
111
+ * Signed fractions of a second at nanosecond resolution of the span
112
+ * of time. Durations less than one second are represented with a 0
113
+ * `seconds` field and a positive or negative `nanos` field. For durations
114
+ * of one second or more, a non-zero value for the `nanos` field must be
115
+ * of the same sign as the `seconds` field. Must be from -999,999,999
116
+ * to +999,999,999 inclusive.
117
+ *
118
+ * @generated from field: int32 nanos = 2;
119
+ */
120
+ this.nanos = 0;
121
+ proto3.util.initPartial(data, this);
122
+ }
123
+ fromJson(json, options) {
124
+ if (typeof json !== "string") {
125
+ throw new Error(
126
+ `cannot decode google.protobuf.Duration from JSON: ${proto3.json.debug(
127
+ json
128
+ )}`
129
+ );
130
+ }
131
+ const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);
132
+ if (match === null) {
133
+ throw new Error(
134
+ `cannot decode google.protobuf.Duration from JSON: ${proto3.json.debug(
135
+ json
136
+ )}`
137
+ );
138
+ }
139
+ const longSeconds = Number(match[1]);
140
+ if (longSeconds > 315576000000 || longSeconds < -315576000000) {
141
+ throw new Error(
142
+ `cannot decode google.protobuf.Duration from JSON: ${proto3.json.debug(
143
+ json
144
+ )}`
145
+ );
146
+ }
147
+ this.seconds = protoInt64.parse(longSeconds);
148
+ if (typeof match[2] == "string") {
149
+ const nanosStr = match[2] + "0".repeat(9 - match[2].length);
150
+ this.nanos = parseInt(nanosStr);
151
+ if (longSeconds < 0n) {
152
+ this.nanos = -this.nanos;
153
+ }
154
+ }
155
+ return this;
156
+ }
157
+ toJson(options) {
158
+ if (
159
+ Number(this.seconds) > 315576000000 ||
160
+ Number(this.seconds) < -315576000000
161
+ ) {
162
+ throw new Error(
163
+ `cannot encode google.protobuf.Duration to JSON: value out of range`
164
+ );
165
+ }
166
+ let text = this.seconds.toString();
167
+ if (this.nanos !== 0) {
168
+ let nanosStr = Math.abs(this.nanos).toString();
169
+ nanosStr = "0".repeat(9 - nanosStr.length) + nanosStr;
170
+ if (nanosStr.substring(3) === "000000") {
171
+ nanosStr = nanosStr.substring(0, 3);
172
+ } else if (nanosStr.substring(6) === "000") {
173
+ nanosStr = nanosStr.substring(0, 6);
174
+ }
175
+ text += "." + nanosStr;
176
+ }
177
+ return text + "s";
178
+ }
179
+ static fromBinary(bytes, options) {
180
+ return new Duration().fromBinary(bytes, options);
181
+ }
182
+ static fromJson(jsonValue, options) {
183
+ return new Duration().fromJson(jsonValue, options);
184
+ }
185
+ static fromJsonString(jsonString, options) {
186
+ return new Duration().fromJsonString(jsonString, options);
187
+ }
188
+ static equals(a, b) {
189
+ return proto3.util.equals(Duration, a, b);
190
+ }
191
+ }
192
+ Duration.runtime = proto3;
193
+ Duration.typeName = "google.protobuf.Duration";
194
+ Duration.fields = proto3.util.newFieldList(() => [
195
+ { no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
196
+ { no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
197
+ ]);
@@ -0,0 +1,68 @@
1
+ /* eslint-disable */
2
+ // @generated by protoc-gen-es v0.0.1-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
+ // @generated from file google/protobuf/empty.proto (package google.protobuf, syntax proto3)
4
+ //
5
+ // Protocol Buffers - Google's data interchange format
6
+ // Copyright 2008 Google Inc. All rights reserved.
7
+ // https://developers.google.com/protocol-buffers/
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions are
11
+ // met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ // * Redistributions in binary form must reproduce the above
16
+ // copyright notice, this list of conditions and the following disclaimer
17
+ // in the documentation and/or other materials provided with the
18
+ // distribution.
19
+ // * Neither the name of Google Inc. nor the names of its
20
+ // contributors may be used to endorse or promote products derived from
21
+ // this software without specific prior written permission.
22
+ //
23
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ import { Message, proto3 } from "../../index.js";
35
+ /**
36
+ * A generic empty message that you can re-use to avoid defining duplicated
37
+ * empty messages in your APIs. A typical example is to use it as the request
38
+ * or the response type of an API method. For instance:
39
+ *
40
+ * service Foo {
41
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
42
+ * }
43
+ *
44
+ * The JSON representation for `Empty` is empty JSON object `{}`.
45
+ *
46
+ * @generated from message google.protobuf.Empty
47
+ */
48
+ export class Empty extends Message {
49
+ constructor(data) {
50
+ super();
51
+ proto3.util.initPartial(data, this);
52
+ }
53
+ static fromBinary(bytes, options) {
54
+ return new Empty().fromBinary(bytes, options);
55
+ }
56
+ static fromJson(jsonValue, options) {
57
+ return new Empty().fromJson(jsonValue, options);
58
+ }
59
+ static fromJsonString(jsonString, options) {
60
+ return new Empty().fromJsonString(jsonString, options);
61
+ }
62
+ static equals(a, b) {
63
+ return proto3.util.equals(Empty, a, b);
64
+ }
65
+ }
66
+ Empty.runtime = proto3;
67
+ Empty.typeName = "google.protobuf.Empty";
68
+ Empty.fields = proto3.util.newFieldList(() => []);
@@ -0,0 +1,343 @@
1
+ /* eslint-disable */
2
+ // @generated by protoc-gen-es v0.0.1-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
+ // @generated from file google/protobuf/field_mask.proto (package google.protobuf, syntax proto3)
4
+ //
5
+ // Protocol Buffers - Google's data interchange format
6
+ // Copyright 2008 Google Inc. All rights reserved.
7
+ // https://developers.google.com/protocol-buffers/
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions are
11
+ // met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ // * Redistributions in binary form must reproduce the above
16
+ // copyright notice, this list of conditions and the following disclaimer
17
+ // in the documentation and/or other materials provided with the
18
+ // distribution.
19
+ // * Neither the name of Google Inc. nor the names of its
20
+ // contributors may be used to endorse or promote products derived from
21
+ // this software without specific prior written permission.
22
+ //
23
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ import { Message, proto3 } from "../../index.js";
35
+ /**
36
+ * `FieldMask` represents a set of symbolic field paths, for example:
37
+ *
38
+ * paths: "f.a"
39
+ * paths: "f.b.d"
40
+ *
41
+ * Here `f` represents a field in some root message, `a` and `b`
42
+ * fields in the message found in `f`, and `d` a field found in the
43
+ * message in `f.b`.
44
+ *
45
+ * Field masks are used to specify a subset of fields that should be
46
+ * returned by a get operation or modified by an update operation.
47
+ * Field masks also have a custom JSON encoding (see below).
48
+ *
49
+ * # Field Masks in Projections
50
+ *
51
+ * When used in the context of a projection, a response message or
52
+ * sub-message is filtered by the API to only contain those fields as
53
+ * specified in the mask. For example, if the mask in the previous
54
+ * example is applied to a response message as follows:
55
+ *
56
+ * f {
57
+ * a : 22
58
+ * b {
59
+ * d : 1
60
+ * x : 2
61
+ * }
62
+ * y : 13
63
+ * }
64
+ * z: 8
65
+ *
66
+ * The result will not contain specific values for fields x,y and z
67
+ * (their value will be set to the default, and omitted in proto text
68
+ * output):
69
+ *
70
+ *
71
+ * f {
72
+ * a : 22
73
+ * b {
74
+ * d : 1
75
+ * }
76
+ * }
77
+ *
78
+ * A repeated field is not allowed except at the last position of a
79
+ * paths string.
80
+ *
81
+ * If a FieldMask object is not present in a get operation, the
82
+ * operation applies to all fields (as if a FieldMask of all fields
83
+ * had been specified).
84
+ *
85
+ * Note that a field mask does not necessarily apply to the
86
+ * top-level response message. In case of a REST get operation, the
87
+ * field mask applies directly to the response, but in case of a REST
88
+ * list operation, the mask instead applies to each individual message
89
+ * in the returned resource list. In case of a REST custom method,
90
+ * other definitions may be used. Where the mask applies will be
91
+ * clearly documented together with its declaration in the API. In
92
+ * any case, the effect on the returned resource/resources is required
93
+ * behavior for APIs.
94
+ *
95
+ * # Field Masks in Update Operations
96
+ *
97
+ * A field mask in update operations specifies which fields of the
98
+ * targeted resource are going to be updated. The API is required
99
+ * to only change the values of the fields as specified in the mask
100
+ * and leave the others untouched. If a resource is passed in to
101
+ * describe the updated values, the API ignores the values of all
102
+ * fields not covered by the mask.
103
+ *
104
+ * If a repeated field is specified for an update operation, new values will
105
+ * be appended to the existing repeated field in the target resource. Note that
106
+ * a repeated field is only allowed in the last position of a `paths` string.
107
+ *
108
+ * If a sub-message is specified in the last position of the field mask for an
109
+ * update operation, then new value will be merged into the existing sub-message
110
+ * in the target resource.
111
+ *
112
+ * For example, given the target message:
113
+ *
114
+ * f {
115
+ * b {
116
+ * d: 1
117
+ * x: 2
118
+ * }
119
+ * c: [1]
120
+ * }
121
+ *
122
+ * And an update message:
123
+ *
124
+ * f {
125
+ * b {
126
+ * d: 10
127
+ * }
128
+ * c: [2]
129
+ * }
130
+ *
131
+ * then if the field mask is:
132
+ *
133
+ * paths: ["f.b", "f.c"]
134
+ *
135
+ * then the result will be:
136
+ *
137
+ * f {
138
+ * b {
139
+ * d: 10
140
+ * x: 2
141
+ * }
142
+ * c: [1, 2]
143
+ * }
144
+ *
145
+ * An implementation may provide options to override this default behavior for
146
+ * repeated and message fields.
147
+ *
148
+ * In order to reset a field's value to the default, the field must
149
+ * be in the mask and set to the default value in the provided resource.
150
+ * Hence, in order to reset all fields of a resource, provide a default
151
+ * instance of the resource and set all fields in the mask, or do
152
+ * not provide a mask as described below.
153
+ *
154
+ * If a field mask is not present on update, the operation applies to
155
+ * all fields (as if a field mask of all fields has been specified).
156
+ * Note that in the presence of schema evolution, this may mean that
157
+ * fields the client does not know and has therefore not filled into
158
+ * the request will be reset to their default. If this is unwanted
159
+ * behavior, a specific service may require a client to always specify
160
+ * a field mask, producing an error if not.
161
+ *
162
+ * As with get operations, the location of the resource which
163
+ * describes the updated values in the request message depends on the
164
+ * operation kind. In any case, the effect of the field mask is
165
+ * required to be honored by the API.
166
+ *
167
+ * ## Considerations for HTTP REST
168
+ *
169
+ * The HTTP kind of an update operation which uses a field mask must
170
+ * be set to PATCH instead of PUT in order to satisfy HTTP semantics
171
+ * (PUT must only be used for full updates).
172
+ *
173
+ * # JSON Encoding of Field Masks
174
+ *
175
+ * In JSON, a field mask is encoded as a single string where paths are
176
+ * separated by a comma. Fields name in each path are converted
177
+ * to/from lower-camel naming conventions.
178
+ *
179
+ * As an example, consider the following message declarations:
180
+ *
181
+ * message Profile {
182
+ * User user = 1;
183
+ * Photo photo = 2;
184
+ * }
185
+ * message User {
186
+ * string display_name = 1;
187
+ * string address = 2;
188
+ * }
189
+ *
190
+ * In proto a field mask for `Profile` may look as such:
191
+ *
192
+ * mask {
193
+ * paths: "user.display_name"
194
+ * paths: "photo"
195
+ * }
196
+ *
197
+ * In JSON, the same mask is represented as below:
198
+ *
199
+ * {
200
+ * mask: "user.displayName,photo"
201
+ * }
202
+ *
203
+ * # Field Masks and Oneof Fields
204
+ *
205
+ * Field masks treat fields in oneofs just as regular fields. Consider the
206
+ * following message:
207
+ *
208
+ * message SampleMessage {
209
+ * oneof test_oneof {
210
+ * string name = 4;
211
+ * SubMessage sub_message = 9;
212
+ * }
213
+ * }
214
+ *
215
+ * The field mask can be:
216
+ *
217
+ * mask {
218
+ * paths: "name"
219
+ * }
220
+ *
221
+ * Or:
222
+ *
223
+ * mask {
224
+ * paths: "sub_message"
225
+ * }
226
+ *
227
+ * Note that oneof type names ("test_oneof" in this case) cannot be used in
228
+ * paths.
229
+ *
230
+ * ## Field Mask Verification
231
+ *
232
+ * The implementation of any API method which has a FieldMask type field in the
233
+ * request should verify the included field paths, and return an
234
+ * `INVALID_ARGUMENT` error if any path is unmappable.
235
+ *
236
+ * @generated from message google.protobuf.FieldMask
237
+ */
238
+ export class FieldMask extends Message {
239
+ constructor(data) {
240
+ super();
241
+ /**
242
+ * The set of field mask paths.
243
+ *
244
+ * @generated from field: repeated string paths = 1;
245
+ */
246
+ this.paths = [];
247
+ proto3.util.initPartial(data, this);
248
+ }
249
+ toJson(options) {
250
+ // Converts snake_case to protoCamelCase according to the convention
251
+ // used by protoc to convert a field name to a JSON name.
252
+ function protoCamelCase(snakeCase) {
253
+ let capNext = false;
254
+ const b = [];
255
+ for (let i = 0; i < snakeCase.length; i++) {
256
+ let c = snakeCase.charAt(i);
257
+ switch (c) {
258
+ case "_":
259
+ capNext = true;
260
+ break;
261
+ case "0":
262
+ case "1":
263
+ case "2":
264
+ case "3":
265
+ case "4":
266
+ case "5":
267
+ case "6":
268
+ case "7":
269
+ case "8":
270
+ case "9":
271
+ b.push(c);
272
+ capNext = false;
273
+ break;
274
+ default:
275
+ if (capNext) {
276
+ capNext = false;
277
+ c = c.toUpperCase();
278
+ }
279
+ b.push(c);
280
+ break;
281
+ }
282
+ }
283
+ return b.join("");
284
+ }
285
+ return this.paths
286
+ .map((p) => {
287
+ if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {
288
+ throw new Error(
289
+ 'cannot decode google.protobuf.FieldMask from JSON: lowerCamelCase of path name "' +
290
+ p +
291
+ '" is irreversible'
292
+ );
293
+ }
294
+ return protoCamelCase(p);
295
+ })
296
+ .join(",");
297
+ }
298
+ fromJson(json, options) {
299
+ if (typeof json !== "string") {
300
+ throw new Error(
301
+ "cannot decode google.protobuf.FieldMask from JSON: " +
302
+ proto3.json.debug(json)
303
+ );
304
+ }
305
+ if (json === "") {
306
+ return this;
307
+ }
308
+ function camelToSnake(str) {
309
+ if (str.includes("_")) {
310
+ throw new Error(
311
+ "cannot decode google.protobuf.FieldMask from JSON: path names must be lowerCamelCase"
312
+ );
313
+ }
314
+ const sc = str.replace(/[A-Z]/g, (letter) => "_" + letter.toLowerCase());
315
+ return sc[0] === "_" ? sc.substring(1) : sc;
316
+ }
317
+ this.paths = json.split(",").map(camelToSnake);
318
+ return this;
319
+ }
320
+ static fromBinary(bytes, options) {
321
+ return new FieldMask().fromBinary(bytes, options);
322
+ }
323
+ static fromJson(jsonValue, options) {
324
+ return new FieldMask().fromJson(jsonValue, options);
325
+ }
326
+ static fromJsonString(jsonString, options) {
327
+ return new FieldMask().fromJsonString(jsonString, options);
328
+ }
329
+ static equals(a, b) {
330
+ return proto3.util.equals(FieldMask, a, b);
331
+ }
332
+ }
333
+ FieldMask.runtime = proto3;
334
+ FieldMask.typeName = "google.protobuf.FieldMask";
335
+ FieldMask.fields = proto3.util.newFieldList(() => [
336
+ {
337
+ no: 1,
338
+ name: "paths",
339
+ kind: "scalar",
340
+ T: 9 /* ScalarType.STRING */,
341
+ repeated: true,
342
+ },
343
+ ]);
@@ -0,0 +1,70 @@
1
+ /* eslint-disable */
2
+ // @generated by protoc-gen-es v0.0.1-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
+ // @generated from file google/protobuf/source_context.proto (package google.protobuf, syntax proto3)
4
+ //
5
+ // Protocol Buffers - Google's data interchange format
6
+ // Copyright 2008 Google Inc. All rights reserved.
7
+ // https://developers.google.com/protocol-buffers/
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions are
11
+ // met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ // * Redistributions in binary form must reproduce the above
16
+ // copyright notice, this list of conditions and the following disclaimer
17
+ // in the documentation and/or other materials provided with the
18
+ // distribution.
19
+ // * Neither the name of Google Inc. nor the names of its
20
+ // contributors may be used to endorse or promote products derived from
21
+ // this software without specific prior written permission.
22
+ //
23
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ import { Message, proto3 } from "../../index.js";
35
+ /**
36
+ * `SourceContext` represents information about the source of a
37
+ * protobuf element, like the file in which it is defined.
38
+ *
39
+ * @generated from message google.protobuf.SourceContext
40
+ */
41
+ export class SourceContext extends Message {
42
+ constructor(data) {
43
+ super();
44
+ /**
45
+ * The path-qualified name of the .proto file that contained the associated
46
+ * protobuf element. For example: `"google/protobuf/source_context.proto"`.
47
+ *
48
+ * @generated from field: string file_name = 1;
49
+ */
50
+ this.fileName = "";
51
+ proto3.util.initPartial(data, this);
52
+ }
53
+ static fromBinary(bytes, options) {
54
+ return new SourceContext().fromBinary(bytes, options);
55
+ }
56
+ static fromJson(jsonValue, options) {
57
+ return new SourceContext().fromJson(jsonValue, options);
58
+ }
59
+ static fromJsonString(jsonString, options) {
60
+ return new SourceContext().fromJsonString(jsonString, options);
61
+ }
62
+ static equals(a, b) {
63
+ return proto3.util.equals(SourceContext, a, b);
64
+ }
65
+ }
66
+ SourceContext.runtime = proto3;
67
+ SourceContext.typeName = "google.protobuf.SourceContext";
68
+ SourceContext.fields = proto3.util.newFieldList(() => [
69
+ { no: 1, name: "file_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
70
+ ]);