@bufbuild/protobuf 0.0.1-alpha.1 → 0.0.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 (127) hide show
  1. package/README.md +21 -1
  2. package/dist/cjs/binary-encoding.js +402 -410
  3. package/dist/cjs/descriptor-registry.js +407 -449
  4. package/dist/cjs/descriptor-set.js +416 -513
  5. package/dist/cjs/field.js +30 -30
  6. package/dist/cjs/google/protobuf/any_pb.js +122 -140
  7. package/dist/cjs/google/protobuf/api_pb.js +177 -224
  8. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +125 -227
  9. package/dist/cjs/google/protobuf/descriptor_pb.js +1029 -1888
  10. package/dist/cjs/google/protobuf/duration_pb.js +72 -88
  11. package/dist/cjs/google/protobuf/empty_pb.js +17 -17
  12. package/dist/cjs/google/protobuf/field_mask_pb.js +77 -94
  13. package/dist/cjs/google/protobuf/source_context_pb.js +25 -25
  14. package/dist/cjs/google/protobuf/struct_pb.js +144 -181
  15. package/dist/cjs/google/protobuf/timestamp_pb.js +86 -123
  16. package/dist/cjs/google/protobuf/type_pb.js +406 -462
  17. package/dist/cjs/google/protobuf/wrappers_pb.js +407 -470
  18. package/dist/cjs/index.js +24 -122
  19. package/dist/cjs/message.js +81 -89
  20. package/dist/cjs/private/assert.js +20 -26
  21. package/dist/cjs/private/base64.js +79 -78
  22. package/dist/cjs/private/binary-format-common.js +195 -208
  23. package/dist/cjs/private/binary-format-proto2.js +75 -109
  24. package/dist/cjs/private/binary-format-proto3.js +57 -90
  25. package/dist/cjs/private/enum.js +38 -43
  26. package/dist/cjs/private/field-list.js +51 -50
  27. package/dist/cjs/private/field-wrapper.js +8 -10
  28. package/dist/cjs/private/field.js +22 -25
  29. package/dist/cjs/private/goog-varint.js +275 -0
  30. package/dist/cjs/private/json-format-common.js +414 -440
  31. package/dist/cjs/private/json-format-proto2.js +78 -89
  32. package/dist/cjs/private/json-format-proto3.js +69 -93
  33. package/dist/cjs/private/message-type.js +26 -27
  34. package/dist/cjs/private/names.js +58 -62
  35. package/dist/cjs/private/proto-runtime.js +11 -16
  36. package/dist/cjs/private/scalars.js +100 -103
  37. package/dist/cjs/private/util-common.js +180 -210
  38. package/dist/cjs/proto-int64.js +111 -112
  39. package/dist/cjs/proto2.js +50 -63
  40. package/dist/cjs/proto3.js +61 -74
  41. package/dist/cjs/service-type.js +14 -17
  42. package/dist/cjs/type-registry.js +33 -31
  43. package/dist/esm/binary-encoding.js +401 -414
  44. package/dist/esm/descriptor-registry.js +409 -458
  45. package/dist/esm/descriptor-set.js +417 -478
  46. package/dist/esm/field.js +29 -29
  47. package/dist/esm/google/protobuf/any_pb.js +122 -140
  48. package/dist/esm/google/protobuf/api_pb.js +177 -197
  49. package/dist/esm/google/protobuf/compiler/plugin_pb.js +123 -216
  50. package/dist/esm/google/protobuf/descriptor_pb.js +1013 -1804
  51. package/dist/esm/google/protobuf/duration_pb.js +72 -88
  52. package/dist/esm/google/protobuf/empty_pb.js +17 -17
  53. package/dist/esm/google/protobuf/field_mask_pb.js +77 -94
  54. package/dist/esm/google/protobuf/source_context_pb.js +25 -25
  55. package/dist/esm/google/protobuf/struct_pb.js +143 -180
  56. package/dist/esm/google/protobuf/timestamp_pb.js +86 -123
  57. package/dist/esm/google/protobuf/type_pb.js +401 -421
  58. package/dist/esm/google/protobuf/wrappers_pb.js +406 -397
  59. package/dist/esm/index.js +1 -1
  60. package/dist/esm/message.js +81 -89
  61. package/dist/esm/private/assert.js +19 -21
  62. package/dist/esm/private/base64.js +79 -78
  63. package/dist/esm/private/binary-format-common.js +196 -207
  64. package/dist/esm/private/binary-format-proto2.js +76 -81
  65. package/dist/esm/private/binary-format-proto3.js +58 -67
  66. package/dist/esm/private/enum.js +38 -43
  67. package/dist/esm/private/field-list.js +51 -50
  68. package/dist/esm/private/field-wrapper.js +8 -10
  69. package/dist/esm/private/field.js +22 -22
  70. package/dist/esm/private/goog-varint.js +266 -0
  71. package/dist/esm/private/json-format-common.js +414 -435
  72. package/dist/esm/private/json-format-proto2.js +76 -81
  73. package/dist/esm/private/json-format-proto3.js +66 -80
  74. package/dist/esm/private/message-type.js +27 -28
  75. package/dist/esm/private/names.js +57 -57
  76. package/dist/esm/private/proto-runtime.js +11 -11
  77. package/dist/esm/private/scalars.js +99 -99
  78. package/dist/esm/private/util-common.js +180 -192
  79. package/dist/esm/proto-int64.js +111 -112
  80. package/dist/esm/proto2.js +50 -57
  81. package/dist/esm/proto3.js +61 -68
  82. package/dist/esm/service-type.js +12 -12
  83. package/dist/esm/type-registry.js +33 -31
  84. package/dist/types/binary-encoding.d.ts +398 -398
  85. package/dist/types/binary-format.d.ts +69 -91
  86. package/dist/types/descriptor-registry.d.ts +23 -29
  87. package/dist/types/descriptor-set.d.ts +107 -128
  88. package/dist/types/enum.d.ts +21 -21
  89. package/dist/types/field-list.d.ts +21 -21
  90. package/dist/types/field.d.ts +191 -231
  91. package/dist/types/google/protobuf/any_pb.d.ts +56 -77
  92. package/dist/types/google/protobuf/api_pb.d.ts +144 -187
  93. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +195 -257
  94. package/dist/types/google/protobuf/descriptor_pb.d.ts +1360 -1737
  95. package/dist/types/google/protobuf/duration_pb.d.ts +30 -50
  96. package/dist/types/google/protobuf/empty_pb.d.ts +9 -28
  97. package/dist/types/google/protobuf/field_mask_pb.d.ts +17 -37
  98. package/dist/types/google/protobuf/source_context_pb.d.ts +16 -35
  99. package/dist/types/google/protobuf/struct_pb.d.ts +64 -115
  100. package/dist/types/google/protobuf/timestamp_pb.d.ts +31 -51
  101. package/dist/types/google/protobuf/type_pb.d.ts +355 -422
  102. package/dist/types/google/protobuf/wrappers_pb.d.ts +181 -297
  103. package/dist/types/index.d.ts +4 -27
  104. package/dist/types/json-format.d.ts +70 -89
  105. package/dist/types/message-type.d.ts +38 -46
  106. package/dist/types/message.d.ts +73 -99
  107. package/dist/types/private/assert.d.ts +1 -4
  108. package/dist/types/private/binary-format-common.d.ts +6 -32
  109. package/dist/types/private/enum.d.ts +4 -11
  110. package/dist/types/private/field-list.d.ts +14 -21
  111. package/dist/types/private/field-wrapper.d.ts +5 -11
  112. package/dist/types/private/field.d.ts +12 -12
  113. package/dist/types/{google/varint.d.ts → private/goog-varint.d.ts} +6 -13
  114. package/dist/types/private/json-format-common.d.ts +5 -27
  115. package/dist/types/private/message-type.d.ts +3 -8
  116. package/dist/types/private/names.d.ts +1 -4
  117. package/dist/types/private/options-map.d.ts +1 -1
  118. package/dist/types/private/proto-runtime.d.ts +29 -42
  119. package/dist/types/private/scalars.d.ts +5 -12
  120. package/dist/types/private/util-common.d.ts +1 -4
  121. package/dist/types/private/util.d.ts +29 -41
  122. package/dist/types/proto-int64.d.ts +42 -42
  123. package/dist/types/service-type.d.ts +37 -57
  124. package/dist/types/type-registry.d.ts +13 -15
  125. package/package.json +2 -2
  126. package/dist/cjs/google/varint.js +0 -280
  127. package/dist/esm/google/varint.js +0 -265
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /* eslint-disable */
3
- // @generated by protoc-gen-es v0.0.1-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
+ // @generated by protoc-gen-es v0.0.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
4
4
  // @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
5
5
  //
6
6
  // Protocol Buffers - Google's data interchange format
@@ -45,16 +45,16 @@ const index_js_1 = require("../../index.js");
45
45
  */
46
46
  var NullValue;
47
47
  (function (NullValue) {
48
- /**
49
- * Null value.
50
- *
51
- * @generated from enum value: NULL_VALUE = 0;
52
- */
53
- NullValue[(NullValue["NULL_VALUE"] = 0)] = "NULL_VALUE";
54
- })((NullValue = exports.NullValue || (exports.NullValue = {})));
48
+ /**
49
+ * Null value.
50
+ *
51
+ * @generated from enum value: NULL_VALUE = 0;
52
+ */
53
+ NullValue[NullValue["NULL_VALUE"] = 0] = "NULL_VALUE";
54
+ })(NullValue = exports.NullValue || (exports.NullValue = {}));
55
55
  // Retrieve enum metadata with: proto3.getEnumType(NullValue)
56
56
  index_js_1.proto3.util.setEnumType(NullValue, "google.protobuf.NullValue", [
57
- { no: 0, name: "NULL_VALUE" },
57
+ { no: 0, name: "NULL_VALUE" },
58
58
  ]);
59
59
  /**
60
60
  * `Struct` represents a structured data value, consisting of fields
@@ -69,59 +69,50 @@ index_js_1.proto3.util.setEnumType(NullValue, "google.protobuf.NullValue", [
69
69
  * @generated from message google.protobuf.Struct
70
70
  */
71
71
  class Struct extends index_js_1.Message {
72
- constructor(data) {
73
- super();
74
- /**
75
- * Unordered map of dynamically typed values.
76
- *
77
- * @generated from field: map<string, google.protobuf.Value> fields = 1;
78
- */
79
- this.fields = {};
80
- index_js_1.proto3.util.initPartial(data, this);
81
- }
82
- toJson(options) {
83
- const json = {};
84
- for (const [k, v] of Object.entries(this.fields)) {
85
- json[k] = v.toJson(options);
72
+ constructor(data) {
73
+ super();
74
+ /**
75
+ * Unordered map of dynamically typed values.
76
+ *
77
+ * @generated from field: map<string, google.protobuf.Value> fields = 1;
78
+ */
79
+ this.fields = {};
80
+ index_js_1.proto3.util.initPartial(data, this);
81
+ }
82
+ toJson(options) {
83
+ const json = {};
84
+ for (const [k, v] of Object.entries(this.fields)) {
85
+ json[k] = v.toJson(options);
86
+ }
87
+ return json;
86
88
  }
87
- return json;
88
- }
89
- fromJson(json, options) {
90
- if (typeof json != "object" || json == null || Array.isArray(json)) {
91
- throw new Error(
92
- "cannot decode google.protobuf.Struct from JSON " +
93
- index_js_1.proto3.json.debug(json)
94
- );
89
+ fromJson(json, options) {
90
+ if (typeof json != "object" || json == null || Array.isArray(json)) {
91
+ throw new Error("cannot decode google.protobuf.Struct from JSON " + index_js_1.proto3.json.debug(json));
92
+ }
93
+ for (const [k, v] of Object.entries(json)) {
94
+ this.fields[k] = Value.fromJson(v);
95
+ }
96
+ return this;
97
+ }
98
+ static fromBinary(bytes, options) {
99
+ return new Struct().fromBinary(bytes, options);
100
+ }
101
+ static fromJson(jsonValue, options) {
102
+ return new Struct().fromJson(jsonValue, options);
95
103
  }
96
- for (const [k, v] of Object.entries(json)) {
97
- this.fields[k] = Value.fromJson(v);
104
+ static fromJsonString(jsonString, options) {
105
+ return new Struct().fromJsonString(jsonString, options);
106
+ }
107
+ static equals(a, b) {
108
+ return index_js_1.proto3.util.equals(Struct, a, b);
98
109
  }
99
- return this;
100
- }
101
- static fromBinary(bytes, options) {
102
- return new Struct().fromBinary(bytes, options);
103
- }
104
- static fromJson(jsonValue, options) {
105
- return new Struct().fromJson(jsonValue, options);
106
- }
107
- static fromJsonString(jsonString, options) {
108
- return new Struct().fromJsonString(jsonString, options);
109
- }
110
- static equals(a, b) {
111
- return index_js_1.proto3.util.equals(Struct, a, b);
112
- }
113
110
  }
114
111
  exports.Struct = Struct;
115
112
  Struct.runtime = index_js_1.proto3;
116
113
  Struct.typeName = "google.protobuf.Struct";
117
114
  Struct.fields = index_js_1.proto3.util.newFieldList(() => [
118
- {
119
- no: 1,
120
- name: "fields",
121
- kind: "map",
122
- K: 9 /* ScalarType.STRING */,
123
- V: { kind: "message", T: Value },
124
- },
115
+ { no: 1, name: "fields", kind: "map", K: 9 /* ScalarType.STRING */, V: { kind: "message", T: Value } },
125
116
  ]);
126
117
  /**
127
118
  * `Value` represents a dynamically typed value which can be either
@@ -134,105 +125,80 @@ Struct.fields = index_js_1.proto3.util.newFieldList(() => [
134
125
  * @generated from message google.protobuf.Value
135
126
  */
136
127
  class Value extends index_js_1.Message {
137
- constructor(data) {
138
- super();
139
- /**
140
- * The kind of value.
141
- *
142
- * @generated from oneof google.protobuf.Value.kind
143
- */
144
- this.kind = { case: undefined };
145
- index_js_1.proto3.util.initPartial(data, this);
146
- }
147
- toJson(options) {
148
- switch (this.kind.case) {
149
- case "nullValue":
150
- return null;
151
- case "boolValue":
152
- case "numberValue":
153
- case "stringValue":
154
- return this.kind.value;
155
- case "structValue":
156
- case "listValue":
157
- return this.kind.value.toJson({ ...options, emitDefaultValues: true });
128
+ constructor(data) {
129
+ super();
130
+ /**
131
+ * The kind of value.
132
+ *
133
+ * @generated from oneof google.protobuf.Value.kind
134
+ */
135
+ this.kind = { case: undefined };
136
+ index_js_1.proto3.util.initPartial(data, this);
158
137
  }
159
- throw new Error("google.protobuf.Value must have a value");
160
- }
161
- fromJson(json, options) {
162
- switch (typeof json) {
163
- case "number":
164
- this.kind = { case: "numberValue", value: json };
165
- break;
166
- case "string":
167
- this.kind = { case: "stringValue", value: json };
168
- break;
169
- case "boolean":
170
- this.kind = { case: "boolValue", value: json };
171
- break;
172
- case "object":
173
- if (json === null) {
174
- this.kind = { case: "nullValue", value: NullValue.NULL_VALUE };
175
- } else if (Array.isArray(json)) {
176
- this.kind = { case: "listValue", value: ListValue.fromJson(json) };
177
- } else {
178
- this.kind = { case: "structValue", value: Struct.fromJson(json) };
138
+ toJson(options) {
139
+ switch (this.kind.case) {
140
+ case "nullValue":
141
+ return null;
142
+ case "boolValue":
143
+ case "numberValue":
144
+ case "stringValue":
145
+ return this.kind.value;
146
+ case "structValue":
147
+ case "listValue":
148
+ return this.kind.value.toJson({ ...options, emitDefaultValues: true });
179
149
  }
180
- break;
181
- default:
182
- throw new Error(
183
- "cannot decode google.protobuf.Value from JSON " +
184
- index_js_1.proto3.json.debug(json)
185
- );
150
+ throw new Error("google.protobuf.Value must have a value");
151
+ }
152
+ fromJson(json, options) {
153
+ switch (typeof json) {
154
+ case "number":
155
+ this.kind = { case: "numberValue", value: json };
156
+ break;
157
+ case "string":
158
+ this.kind = { case: "stringValue", value: json };
159
+ break;
160
+ case "boolean":
161
+ this.kind = { case: "boolValue", value: json };
162
+ break;
163
+ case "object":
164
+ if (json === null) {
165
+ this.kind = { case: "nullValue", value: NullValue.NULL_VALUE };
166
+ }
167
+ else if (Array.isArray(json)) {
168
+ this.kind = { case: "listValue", value: ListValue.fromJson(json) };
169
+ }
170
+ else {
171
+ this.kind = { case: "structValue", value: Struct.fromJson(json) };
172
+ }
173
+ break;
174
+ default:
175
+ throw new Error("cannot decode google.protobuf.Value from JSON " + index_js_1.proto3.json.debug(json));
176
+ }
177
+ return this;
178
+ }
179
+ static fromBinary(bytes, options) {
180
+ return new Value().fromBinary(bytes, options);
181
+ }
182
+ static fromJson(jsonValue, options) {
183
+ return new Value().fromJson(jsonValue, options);
184
+ }
185
+ static fromJsonString(jsonString, options) {
186
+ return new Value().fromJsonString(jsonString, options);
187
+ }
188
+ static equals(a, b) {
189
+ return index_js_1.proto3.util.equals(Value, a, b);
186
190
  }
187
- return this;
188
- }
189
- static fromBinary(bytes, options) {
190
- return new Value().fromBinary(bytes, options);
191
- }
192
- static fromJson(jsonValue, options) {
193
- return new Value().fromJson(jsonValue, options);
194
- }
195
- static fromJsonString(jsonString, options) {
196
- return new Value().fromJsonString(jsonString, options);
197
- }
198
- static equals(a, b) {
199
- return index_js_1.proto3.util.equals(Value, a, b);
200
- }
201
191
  }
202
192
  exports.Value = Value;
203
193
  Value.runtime = index_js_1.proto3;
204
194
  Value.typeName = "google.protobuf.Value";
205
195
  Value.fields = index_js_1.proto3.util.newFieldList(() => [
206
- {
207
- no: 1,
208
- name: "null_value",
209
- kind: "enum",
210
- T: index_js_1.proto3.getEnumType(NullValue),
211
- oneof: "kind",
212
- },
213
- {
214
- no: 2,
215
- name: "number_value",
216
- kind: "scalar",
217
- T: 1 /* ScalarType.DOUBLE */,
218
- oneof: "kind",
219
- },
220
- {
221
- no: 3,
222
- name: "string_value",
223
- kind: "scalar",
224
- T: 9 /* ScalarType.STRING */,
225
- oneof: "kind",
226
- },
227
- {
228
- no: 4,
229
- name: "bool_value",
230
- kind: "scalar",
231
- T: 8 /* ScalarType.BOOL */,
232
- oneof: "kind",
233
- },
234
- { no: 5, name: "struct_value", kind: "message", T: Struct, oneof: "kind" },
235
- { no: 6, name: "list_value", kind: "message", T: ListValue, oneof: "kind" },
196
+ { no: 1, name: "null_value", kind: "enum", T: index_js_1.proto3.getEnumType(NullValue), oneof: "kind" },
197
+ { no: 2, name: "number_value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, oneof: "kind" },
198
+ { no: 3, name: "string_value", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "kind" },
199
+ { no: 4, name: "bool_value", kind: "scalar", T: 8 /* ScalarType.BOOL */, oneof: "kind" },
200
+ { no: 5, name: "struct_value", kind: "message", T: Struct, oneof: "kind" },
201
+ { no: 6, name: "list_value", kind: "message", T: ListValue, oneof: "kind" },
236
202
  ]);
237
203
  /**
238
204
  * `ListValue` is a wrapper around a repeated field of values.
@@ -242,47 +208,44 @@ Value.fields = index_js_1.proto3.util.newFieldList(() => [
242
208
  * @generated from message google.protobuf.ListValue
243
209
  */
244
210
  class ListValue extends index_js_1.Message {
245
- constructor(data) {
246
- super();
247
- /**
248
- * Repeated field of dynamically typed values.
249
- *
250
- * @generated from field: repeated google.protobuf.Value values = 1;
251
- */
252
- this.values = [];
253
- index_js_1.proto3.util.initPartial(data, this);
254
- }
255
- toJson(options) {
256
- return this.values.map((v) => v.toJson());
257
- }
258
- fromJson(json, options) {
259
- if (!Array.isArray(json)) {
260
- throw new Error(
261
- "cannot decode google.protobuf.ListValue from JSON " +
262
- index_js_1.proto3.json.debug(json)
263
- );
211
+ constructor(data) {
212
+ super();
213
+ /**
214
+ * Repeated field of dynamically typed values.
215
+ *
216
+ * @generated from field: repeated google.protobuf.Value values = 1;
217
+ */
218
+ this.values = [];
219
+ index_js_1.proto3.util.initPartial(data, this);
220
+ }
221
+ toJson(options) {
222
+ return this.values.map(v => v.toJson());
223
+ }
224
+ fromJson(json, options) {
225
+ if (!Array.isArray(json)) {
226
+ throw new Error("cannot decode google.protobuf.ListValue from JSON " + index_js_1.proto3.json.debug(json));
227
+ }
228
+ for (let e of json) {
229
+ this.values.push(Value.fromJson(e));
230
+ }
231
+ return this;
232
+ }
233
+ static fromBinary(bytes, options) {
234
+ return new ListValue().fromBinary(bytes, options);
235
+ }
236
+ static fromJson(jsonValue, options) {
237
+ return new ListValue().fromJson(jsonValue, options);
238
+ }
239
+ static fromJsonString(jsonString, options) {
240
+ return new ListValue().fromJsonString(jsonString, options);
264
241
  }
265
- for (let e of json) {
266
- this.values.push(Value.fromJson(e));
242
+ static equals(a, b) {
243
+ return index_js_1.proto3.util.equals(ListValue, a, b);
267
244
  }
268
- return this;
269
- }
270
- static fromBinary(bytes, options) {
271
- return new ListValue().fromBinary(bytes, options);
272
- }
273
- static fromJson(jsonValue, options) {
274
- return new ListValue().fromJson(jsonValue, options);
275
- }
276
- static fromJsonString(jsonString, options) {
277
- return new ListValue().fromJsonString(jsonString, options);
278
- }
279
- static equals(a, b) {
280
- return index_js_1.proto3.util.equals(ListValue, a, b);
281
- }
282
245
  }
283
246
  exports.ListValue = ListValue;
284
247
  ListValue.runtime = index_js_1.proto3;
285
248
  ListValue.typeName = "google.protobuf.ListValue";
286
249
  ListValue.fields = index_js_1.proto3.util.newFieldList(() => [
287
- { no: 1, name: "values", kind: "message", T: Value, repeated: true },
250
+ { no: 1, name: "values", kind: "message", T: Value, repeated: true },
288
251
  ]);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /* eslint-disable */
3
- // @generated by protoc-gen-es v0.0.1-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
+ // @generated by protoc-gen-es v0.0.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
4
4
  // @generated from file google/protobuf/timestamp.proto (package google.protobuf, syntax proto3)
5
5
  //
6
6
  // Protocol Buffers - Google's data interchange format
@@ -133,139 +133,102 @@ const index_js_1 = require("../../index.js");
133
133
  * @generated from message google.protobuf.Timestamp
134
134
  */
135
135
  class Timestamp extends index_js_1.Message {
136
- constructor(data) {
137
- super();
138
- /**
139
- * Represents seconds of UTC time since Unix epoch
140
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
141
- * 9999-12-31T23:59:59Z inclusive.
142
- *
143
- * @generated from field: int64 seconds = 1;
144
- */
145
- this.seconds = index_js_1.protoInt64.zero;
146
- /**
147
- * Non-negative fractions of a second at nanosecond resolution. Negative
148
- * second values with fractions must still have non-negative nanos values
149
- * that count forward in time. Must be from 0 to 999,999,999
150
- * inclusive.
151
- *
152
- * @generated from field: int32 nanos = 2;
153
- */
154
- this.nanos = 0;
155
- index_js_1.proto3.util.initPartial(data, this);
156
- }
157
- fromJson(json, options) {
158
- if (typeof json !== "string") {
159
- throw new Error(
160
- `cannot decode google.protobuf.Timestamp from JSON: ${index_js_1.proto3.json.debug(
161
- json
162
- )}`
163
- );
136
+ constructor(data) {
137
+ super();
138
+ /**
139
+ * Represents seconds of UTC time since Unix epoch
140
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
141
+ * 9999-12-31T23:59:59Z inclusive.
142
+ *
143
+ * @generated from field: int64 seconds = 1;
144
+ */
145
+ this.seconds = index_js_1.protoInt64.zero;
146
+ /**
147
+ * Non-negative fractions of a second at nanosecond resolution. Negative
148
+ * second values with fractions must still have non-negative nanos values
149
+ * that count forward in time. Must be from 0 to 999,999,999
150
+ * inclusive.
151
+ *
152
+ * @generated from field: int32 nanos = 2;
153
+ */
154
+ this.nanos = 0;
155
+ index_js_1.proto3.util.initPartial(data, this);
164
156
  }
165
- const matches = json.match(
166
- /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/
167
- );
168
- if (!matches) {
169
- throw new Error(
170
- `cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`
171
- );
157
+ fromJson(json, options) {
158
+ if (typeof json !== "string") {
159
+ throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${index_js_1.proto3.json.debug(json)}`);
160
+ }
161
+ const matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
162
+ if (!matches) {
163
+ throw new Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);
164
+ }
165
+ const ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
166
+ if (Number.isNaN(ms)) {
167
+ throw new Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);
168
+ }
169
+ if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z")) {
170
+ throw new Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);
171
+ }
172
+ this.seconds = index_js_1.protoInt64.parse(ms / 1000);
173
+ this.nanos = 0;
174
+ if (matches[7]) {
175
+ this.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
176
+ }
177
+ return this;
172
178
  }
173
- const ms = Date.parse(
174
- matches[1] +
175
- "-" +
176
- matches[2] +
177
- "-" +
178
- matches[3] +
179
- "T" +
180
- matches[4] +
181
- ":" +
182
- matches[5] +
183
- ":" +
184
- matches[6] +
185
- (matches[8] ? matches[8] : "Z")
186
- );
187
- if (Number.isNaN(ms)) {
188
- throw new Error(
189
- `cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`
190
- );
179
+ toJson(options) {
180
+ const ms = Number(this.seconds) * 1000;
181
+ if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z")) {
182
+ throw new Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);
183
+ }
184
+ if (this.nanos < 0) {
185
+ throw new Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);
186
+ }
187
+ let z = "Z";
188
+ if (this.nanos > 0) {
189
+ const nanosStr = (this.nanos + 1000000000).toString().substring(1);
190
+ if (nanosStr.substring(3) === "000000") {
191
+ z = "." + nanosStr.substring(0, 3) + "Z";
192
+ }
193
+ else if (nanosStr.substring(6) === "000") {
194
+ z = "." + nanosStr.substring(0, 6) + "Z";
195
+ }
196
+ else {
197
+ z = "." + nanosStr + "Z";
198
+ }
199
+ }
200
+ return new Date(ms).toISOString().replace(".000Z", z);
191
201
  }
192
- if (
193
- ms < Date.parse("0001-01-01T00:00:00Z") ||
194
- ms > Date.parse("9999-12-31T23:59:59Z")
195
- ) {
196
- throw new Error(
197
- `cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`
198
- );
202
+ toDate() {
203
+ return new Date(Number(this.seconds) * 1000 + Math.ceil(this.nanos / 1000000));
199
204
  }
200
- this.seconds = index_js_1.protoInt64.parse(ms / 1000);
201
- this.nanos = 0;
202
- if (matches[7]) {
203
- this.nanos =
204
- parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) -
205
- 1000000000;
205
+ static now() {
206
+ return Timestamp.fromDate(new Date());
206
207
  }
207
- return this;
208
- }
209
- toJson(options) {
210
- const ms = Number(this.seconds) * 1000;
211
- if (
212
- ms < Date.parse("0001-01-01T00:00:00Z") ||
213
- ms > Date.parse("9999-12-31T23:59:59Z")
214
- ) {
215
- throw new Error(
216
- `cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`
217
- );
208
+ static fromDate(date) {
209
+ const ms = date.getTime();
210
+ return new Timestamp({
211
+ seconds: index_js_1.protoInt64.parse(Math.floor(ms / 1000)),
212
+ nanos: (ms % 1000) * 1000000,
213
+ });
218
214
  }
219
- if (this.nanos < 0) {
220
- throw new Error(
221
- `cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`
222
- );
215
+ static fromBinary(bytes, options) {
216
+ return new Timestamp().fromBinary(bytes, options);
223
217
  }
224
- let z = "Z";
225
- if (this.nanos > 0) {
226
- const nanosStr = (this.nanos + 1000000000).toString().substring(1);
227
- if (nanosStr.substring(3) === "000000") {
228
- z = "." + nanosStr.substring(0, 3) + "Z";
229
- } else if (nanosStr.substring(6) === "000") {
230
- z = "." + nanosStr.substring(0, 6) + "Z";
231
- } else {
232
- z = "." + nanosStr + "Z";
233
- }
218
+ static fromJson(jsonValue, options) {
219
+ return new Timestamp().fromJson(jsonValue, options);
220
+ }
221
+ static fromJsonString(jsonString, options) {
222
+ return new Timestamp().fromJsonString(jsonString, options);
223
+ }
224
+ static equals(a, b) {
225
+ return index_js_1.proto3.util.equals(Timestamp, a, b);
234
226
  }
235
- return new Date(ms).toISOString().replace(".000Z", z);
236
- }
237
- toDate() {
238
- return new Date(
239
- Number(this.seconds) * 1000 + Math.ceil(this.nanos / 1000000)
240
- );
241
- }
242
- static now() {
243
- return Timestamp.fromDate(new Date());
244
- }
245
- static fromDate(date) {
246
- const ms = date.getTime();
247
- return new Timestamp({
248
- seconds: index_js_1.protoInt64.parse(Math.floor(ms / 1000)),
249
- nanos: (ms % 1000) * 1000000,
250
- });
251
- }
252
- static fromBinary(bytes, options) {
253
- return new Timestamp().fromBinary(bytes, options);
254
- }
255
- static fromJson(jsonValue, options) {
256
- return new Timestamp().fromJson(jsonValue, options);
257
- }
258
- static fromJsonString(jsonString, options) {
259
- return new Timestamp().fromJsonString(jsonString, options);
260
- }
261
- static equals(a, b) {
262
- return index_js_1.proto3.util.equals(Timestamp, a, b);
263
- }
264
227
  }
265
228
  exports.Timestamp = Timestamp;
266
229
  Timestamp.runtime = index_js_1.proto3;
267
230
  Timestamp.typeName = "google.protobuf.Timestamp";
268
231
  Timestamp.fields = index_js_1.proto3.util.newFieldList(() => [
269
- { no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
270
- { no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
232
+ { no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
233
+ { no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
271
234
  ]);