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