@se-uulm/snowballr-grpc-client 0.0.0-stage → 0.2.0
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.
- package/CHANGELOG.md +58 -0
- package/LICENSE +674 -0
- package/README.md +6 -2
- package/dist/.gitkeep +0 -0
- package/dist/authentication.ts +525 -0
- package/dist/base.ts +362 -0
- package/dist/criterion.ts +390 -0
- package/dist/export.ts +213 -0
- package/dist/fetcher.ts +408 -0
- package/dist/google/protobuf/field_mask.ts +334 -0
- package/dist/google/protobuf/timestamp.ts +288 -0
- package/dist/main.client.ts +3197 -0
- package/dist/main.ts +140 -0
- package/dist/paper.ts +581 -0
- package/dist/project.ts +2110 -0
- package/dist/review.ts +349 -0
- package/dist/user.ts +316 -0
- package/dist/user_settings.ts +178 -0
- package/package.json +34 -5
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// @generated by protobuf-ts 2.11.1 with parameter generate_dependencies
|
|
2
|
+
// @generated from protobuf file "google/protobuf/field_mask.proto" (package "google.protobuf", syntax proto3)
|
|
3
|
+
// tslint:disable
|
|
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
|
+
//
|
|
35
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
36
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
37
|
+
import { WireType } from "@protobuf-ts/runtime";
|
|
38
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
39
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
40
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
41
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
42
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
43
|
+
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
44
|
+
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
45
|
+
import { lowerCamelCase } from "@protobuf-ts/runtime";
|
|
46
|
+
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
47
|
+
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
48
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
49
|
+
/**
|
|
50
|
+
* `FieldMask` represents a set of symbolic field paths, for example:
|
|
51
|
+
*
|
|
52
|
+
* paths: "f.a"
|
|
53
|
+
* paths: "f.b.d"
|
|
54
|
+
*
|
|
55
|
+
* Here `f` represents a field in some root message, `a` and `b`
|
|
56
|
+
* fields in the message found in `f`, and `d` a field found in the
|
|
57
|
+
* message in `f.b`.
|
|
58
|
+
*
|
|
59
|
+
* Field masks are used to specify a subset of fields that should be
|
|
60
|
+
* returned by a get operation or modified by an update operation.
|
|
61
|
+
* Field masks also have a custom JSON encoding (see below).
|
|
62
|
+
*
|
|
63
|
+
* # Field Masks in Projections
|
|
64
|
+
*
|
|
65
|
+
* When used in the context of a projection, a response message or
|
|
66
|
+
* sub-message is filtered by the API to only contain those fields as
|
|
67
|
+
* specified in the mask. For example, if the mask in the previous
|
|
68
|
+
* example is applied to a response message as follows:
|
|
69
|
+
*
|
|
70
|
+
* f {
|
|
71
|
+
* a : 22
|
|
72
|
+
* b {
|
|
73
|
+
* d : 1
|
|
74
|
+
* x : 2
|
|
75
|
+
* }
|
|
76
|
+
* y : 13
|
|
77
|
+
* }
|
|
78
|
+
* z: 8
|
|
79
|
+
*
|
|
80
|
+
* The result will not contain specific values for fields x,y and z
|
|
81
|
+
* (their value will be set to the default, and omitted in proto text
|
|
82
|
+
* output):
|
|
83
|
+
*
|
|
84
|
+
*
|
|
85
|
+
* f {
|
|
86
|
+
* a : 22
|
|
87
|
+
* b {
|
|
88
|
+
* d : 1
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* A repeated field is not allowed except at the last position of a
|
|
93
|
+
* paths string.
|
|
94
|
+
*
|
|
95
|
+
* If a FieldMask object is not present in a get operation, the
|
|
96
|
+
* operation applies to all fields (as if a FieldMask of all fields
|
|
97
|
+
* had been specified).
|
|
98
|
+
*
|
|
99
|
+
* Note that a field mask does not necessarily apply to the
|
|
100
|
+
* top-level response message. In case of a REST get operation, the
|
|
101
|
+
* field mask applies directly to the response, but in case of a REST
|
|
102
|
+
* list operation, the mask instead applies to each individual message
|
|
103
|
+
* in the returned resource list. In case of a REST custom method,
|
|
104
|
+
* other definitions may be used. Where the mask applies will be
|
|
105
|
+
* clearly documented together with its declaration in the API. In
|
|
106
|
+
* any case, the effect on the returned resource/resources is required
|
|
107
|
+
* behavior for APIs.
|
|
108
|
+
*
|
|
109
|
+
* # Field Masks in Update Operations
|
|
110
|
+
*
|
|
111
|
+
* A field mask in update operations specifies which fields of the
|
|
112
|
+
* targeted resource are going to be updated. The API is required
|
|
113
|
+
* to only change the values of the fields as specified in the mask
|
|
114
|
+
* and leave the others untouched. If a resource is passed in to
|
|
115
|
+
* describe the updated values, the API ignores the values of all
|
|
116
|
+
* fields not covered by the mask.
|
|
117
|
+
*
|
|
118
|
+
* If a repeated field is specified for an update operation, new values will
|
|
119
|
+
* be appended to the existing repeated field in the target resource. Note that
|
|
120
|
+
* a repeated field is only allowed in the last position of a `paths` string.
|
|
121
|
+
*
|
|
122
|
+
* If a sub-message is specified in the last position of the field mask for an
|
|
123
|
+
* update operation, then new value will be merged into the existing sub-message
|
|
124
|
+
* in the target resource.
|
|
125
|
+
*
|
|
126
|
+
* For example, given the target message:
|
|
127
|
+
*
|
|
128
|
+
* f {
|
|
129
|
+
* b {
|
|
130
|
+
* d: 1
|
|
131
|
+
* x: 2
|
|
132
|
+
* }
|
|
133
|
+
* c: [1]
|
|
134
|
+
* }
|
|
135
|
+
*
|
|
136
|
+
* And an update message:
|
|
137
|
+
*
|
|
138
|
+
* f {
|
|
139
|
+
* b {
|
|
140
|
+
* d: 10
|
|
141
|
+
* }
|
|
142
|
+
* c: [2]
|
|
143
|
+
* }
|
|
144
|
+
*
|
|
145
|
+
* then if the field mask is:
|
|
146
|
+
*
|
|
147
|
+
* paths: ["f.b", "f.c"]
|
|
148
|
+
*
|
|
149
|
+
* then the result will be:
|
|
150
|
+
*
|
|
151
|
+
* f {
|
|
152
|
+
* b {
|
|
153
|
+
* d: 10
|
|
154
|
+
* x: 2
|
|
155
|
+
* }
|
|
156
|
+
* c: [1, 2]
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* An implementation may provide options to override this default behavior for
|
|
160
|
+
* repeated and message fields.
|
|
161
|
+
*
|
|
162
|
+
* Note that libraries which implement FieldMask resolution have various
|
|
163
|
+
* different behaviors in the face of empty masks or the special "*" mask.
|
|
164
|
+
* When implementing a service you should confirm these cases have the
|
|
165
|
+
* appropriate behavior in the underlying FieldMask library that you desire,
|
|
166
|
+
* and you may need to special case those cases in your application code if
|
|
167
|
+
* the underlying field mask library behavior differs from your intended
|
|
168
|
+
* service semantics.
|
|
169
|
+
*
|
|
170
|
+
* Update methods implementing https://google.aip.dev/134
|
|
171
|
+
* - MUST support the special value * meaning "full replace"
|
|
172
|
+
* - MUST treat an omitted field mask as "replace fields which are present".
|
|
173
|
+
*
|
|
174
|
+
* Other methods implementing https://google.aip.dev/157
|
|
175
|
+
* - SHOULD support the special value "*" to mean "get all".
|
|
176
|
+
* - MUST treat an omitted field mask to mean "get all", unless otherwise
|
|
177
|
+
* documented.
|
|
178
|
+
*
|
|
179
|
+
* ## Considerations for HTTP REST
|
|
180
|
+
*
|
|
181
|
+
* The HTTP kind of an update operation which uses a field mask must
|
|
182
|
+
* be set to PATCH instead of PUT in order to satisfy HTTP semantics
|
|
183
|
+
* (PUT must only be used for full updates).
|
|
184
|
+
*
|
|
185
|
+
* # JSON Encoding of Field Masks
|
|
186
|
+
*
|
|
187
|
+
* In JSON, a field mask is encoded as a single string where paths are
|
|
188
|
+
* separated by a comma. Fields name in each path are converted
|
|
189
|
+
* to/from lower-camel naming conventions.
|
|
190
|
+
*
|
|
191
|
+
* As an example, consider the following message declarations:
|
|
192
|
+
*
|
|
193
|
+
* message Profile {
|
|
194
|
+
* User user = 1;
|
|
195
|
+
* Photo photo = 2;
|
|
196
|
+
* }
|
|
197
|
+
* message User {
|
|
198
|
+
* string display_name = 1;
|
|
199
|
+
* string address = 2;
|
|
200
|
+
* }
|
|
201
|
+
*
|
|
202
|
+
* In proto a field mask for `Profile` may look as such:
|
|
203
|
+
*
|
|
204
|
+
* mask {
|
|
205
|
+
* paths: "user.display_name"
|
|
206
|
+
* paths: "photo"
|
|
207
|
+
* }
|
|
208
|
+
*
|
|
209
|
+
* In JSON, the same mask is represented as below:
|
|
210
|
+
*
|
|
211
|
+
* {
|
|
212
|
+
* mask: "user.displayName,photo"
|
|
213
|
+
* }
|
|
214
|
+
*
|
|
215
|
+
* # Field Masks and Oneof Fields
|
|
216
|
+
*
|
|
217
|
+
* Field masks treat fields in oneofs just as regular fields. Consider the
|
|
218
|
+
* following message:
|
|
219
|
+
*
|
|
220
|
+
* message SampleMessage {
|
|
221
|
+
* oneof test_oneof {
|
|
222
|
+
* string name = 4;
|
|
223
|
+
* SubMessage sub_message = 9;
|
|
224
|
+
* }
|
|
225
|
+
* }
|
|
226
|
+
*
|
|
227
|
+
* The field mask can be:
|
|
228
|
+
*
|
|
229
|
+
* mask {
|
|
230
|
+
* paths: "name"
|
|
231
|
+
* }
|
|
232
|
+
*
|
|
233
|
+
* Or:
|
|
234
|
+
*
|
|
235
|
+
* mask {
|
|
236
|
+
* paths: "sub_message"
|
|
237
|
+
* }
|
|
238
|
+
*
|
|
239
|
+
* Note that oneof type names ("test_oneof" in this case) cannot be used in
|
|
240
|
+
* paths.
|
|
241
|
+
*
|
|
242
|
+
* ## Field Mask Verification
|
|
243
|
+
*
|
|
244
|
+
* The implementation of any API method which has a FieldMask type field in the
|
|
245
|
+
* request should verify the included field paths, and return an
|
|
246
|
+
* `INVALID_ARGUMENT` error if any path is unmappable.
|
|
247
|
+
*
|
|
248
|
+
* @generated from protobuf message google.protobuf.FieldMask
|
|
249
|
+
*/
|
|
250
|
+
export interface FieldMask {
|
|
251
|
+
/**
|
|
252
|
+
* The set of field mask paths.
|
|
253
|
+
*
|
|
254
|
+
* @generated from protobuf field: repeated string paths = 1
|
|
255
|
+
*/
|
|
256
|
+
paths: string[];
|
|
257
|
+
}
|
|
258
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
259
|
+
class FieldMask$Type extends MessageType<FieldMask> {
|
|
260
|
+
constructor() {
|
|
261
|
+
super("google.protobuf.FieldMask", [
|
|
262
|
+
{ no: 1, name: "paths", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/ }
|
|
263
|
+
]);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Encode `FieldMask` to JSON object.
|
|
267
|
+
*/
|
|
268
|
+
internalJsonWrite(message: FieldMask, options: JsonWriteOptions): JsonValue {
|
|
269
|
+
const invalidFieldMaskJsonRegex = /[A-Z]|(_([.0-9_]|$))/g;
|
|
270
|
+
return message.paths.map(p => {
|
|
271
|
+
if (invalidFieldMaskJsonRegex.test(p))
|
|
272
|
+
throw new Error("Unable to encode FieldMask to JSON. lowerCamelCase of path name \"" + p + "\" is irreversible.");
|
|
273
|
+
return lowerCamelCase(p);
|
|
274
|
+
}).join(",");
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Decode `FieldMask` from JSON object.
|
|
278
|
+
*/
|
|
279
|
+
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: FieldMask): FieldMask {
|
|
280
|
+
if (typeof json !== "string")
|
|
281
|
+
throw new Error("Unable to parse FieldMask from JSON " + typeofJsonValue(json) + ". Expected string.");
|
|
282
|
+
if (!target)
|
|
283
|
+
target = this.create();
|
|
284
|
+
if (json === "")
|
|
285
|
+
return target;
|
|
286
|
+
let camelToSnake = (str: string) => {
|
|
287
|
+
if (str.includes("_"))
|
|
288
|
+
throw new Error("Unable to parse FieldMask from JSON. Path names must be lowerCamelCase.");
|
|
289
|
+
let sc = str.replace(/[A-Z]/g, letter => "_" + letter.toLowerCase());
|
|
290
|
+
return sc;
|
|
291
|
+
};
|
|
292
|
+
target.paths = json.split(",").map(camelToSnake);
|
|
293
|
+
return target;
|
|
294
|
+
}
|
|
295
|
+
create(value?: PartialMessage<FieldMask>): FieldMask {
|
|
296
|
+
const message = globalThis.Object.create((this.messagePrototype!));
|
|
297
|
+
message.paths = [];
|
|
298
|
+
if (value !== undefined)
|
|
299
|
+
reflectionMergePartial<FieldMask>(this, message, value);
|
|
300
|
+
return message;
|
|
301
|
+
}
|
|
302
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: FieldMask): FieldMask {
|
|
303
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
304
|
+
while (reader.pos < end) {
|
|
305
|
+
let [fieldNo, wireType] = reader.tag();
|
|
306
|
+
switch (fieldNo) {
|
|
307
|
+
case /* repeated string paths */ 1:
|
|
308
|
+
message.paths.push(reader.string());
|
|
309
|
+
break;
|
|
310
|
+
default:
|
|
311
|
+
let u = options.readUnknownField;
|
|
312
|
+
if (u === "throw")
|
|
313
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
314
|
+
let d = reader.skip(wireType);
|
|
315
|
+
if (u !== false)
|
|
316
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return message;
|
|
320
|
+
}
|
|
321
|
+
internalBinaryWrite(message: FieldMask, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
|
322
|
+
/* repeated string paths = 1; */
|
|
323
|
+
for (let i = 0; i < message.paths.length; i++)
|
|
324
|
+
writer.tag(1, WireType.LengthDelimited).string(message.paths[i]);
|
|
325
|
+
let u = options.writeUnknownFields;
|
|
326
|
+
if (u !== false)
|
|
327
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
328
|
+
return writer;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @generated MessageType for protobuf message google.protobuf.FieldMask
|
|
333
|
+
*/
|
|
334
|
+
export const FieldMask = new FieldMask$Type();
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// @generated by protobuf-ts 2.11.1 with parameter generate_dependencies
|
|
2
|
+
// @generated from protobuf file "google/protobuf/timestamp.proto" (package "google.protobuf", syntax proto3)
|
|
3
|
+
// tslint:disable
|
|
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
|
+
//
|
|
35
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
36
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
37
|
+
import { WireType } from "@protobuf-ts/runtime";
|
|
38
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
39
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
40
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
41
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
42
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
43
|
+
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
44
|
+
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
45
|
+
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
46
|
+
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
47
|
+
import { PbLong } from "@protobuf-ts/runtime";
|
|
48
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
49
|
+
/**
|
|
50
|
+
* A Timestamp represents a point in time independent of any time zone or local
|
|
51
|
+
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
52
|
+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
53
|
+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
54
|
+
* Gregorian calendar backwards to year one.
|
|
55
|
+
*
|
|
56
|
+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
57
|
+
* second table is needed for interpretation, using a [24-hour linear
|
|
58
|
+
* smear](https://developers.google.com/time/smear).
|
|
59
|
+
*
|
|
60
|
+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
61
|
+
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
62
|
+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
63
|
+
*
|
|
64
|
+
* # Examples
|
|
65
|
+
*
|
|
66
|
+
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
67
|
+
*
|
|
68
|
+
* Timestamp timestamp;
|
|
69
|
+
* timestamp.set_seconds(time(NULL));
|
|
70
|
+
* timestamp.set_nanos(0);
|
|
71
|
+
*
|
|
72
|
+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
73
|
+
*
|
|
74
|
+
* struct timeval tv;
|
|
75
|
+
* gettimeofday(&tv, NULL);
|
|
76
|
+
*
|
|
77
|
+
* Timestamp timestamp;
|
|
78
|
+
* timestamp.set_seconds(tv.tv_sec);
|
|
79
|
+
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
80
|
+
*
|
|
81
|
+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
82
|
+
*
|
|
83
|
+
* FILETIME ft;
|
|
84
|
+
* GetSystemTimeAsFileTime(&ft);
|
|
85
|
+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
86
|
+
*
|
|
87
|
+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
88
|
+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
89
|
+
* Timestamp timestamp;
|
|
90
|
+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
91
|
+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
92
|
+
*
|
|
93
|
+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
94
|
+
*
|
|
95
|
+
* long millis = System.currentTimeMillis();
|
|
96
|
+
*
|
|
97
|
+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
98
|
+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
99
|
+
*
|
|
100
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
101
|
+
*
|
|
102
|
+
* Instant now = Instant.now();
|
|
103
|
+
*
|
|
104
|
+
* Timestamp timestamp =
|
|
105
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
106
|
+
* .setNanos(now.getNano()).build();
|
|
107
|
+
*
|
|
108
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
109
|
+
*
|
|
110
|
+
* timestamp = Timestamp()
|
|
111
|
+
* timestamp.GetCurrentTime()
|
|
112
|
+
*
|
|
113
|
+
* # JSON Mapping
|
|
114
|
+
*
|
|
115
|
+
* In JSON format, the Timestamp type is encoded as a string in the
|
|
116
|
+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
117
|
+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
118
|
+
* where {year} is always expressed using four digits while {month}, {day},
|
|
119
|
+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
120
|
+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
121
|
+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
122
|
+
* is required. A ProtoJSON serializer should always use UTC (as indicated by
|
|
123
|
+
* "Z") when printing the Timestamp type and a ProtoJSON parser should be
|
|
124
|
+
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
125
|
+
*
|
|
126
|
+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
127
|
+
* 01:30 UTC on January 15, 2017.
|
|
128
|
+
*
|
|
129
|
+
* In JavaScript, one can convert a Date object to this format using the
|
|
130
|
+
* standard
|
|
131
|
+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
132
|
+
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
133
|
+
* to this format using
|
|
134
|
+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
135
|
+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
136
|
+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
137
|
+
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
138
|
+
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
139
|
+
*
|
|
140
|
+
*
|
|
141
|
+
* @generated from protobuf message google.protobuf.Timestamp
|
|
142
|
+
*/
|
|
143
|
+
export interface Timestamp {
|
|
144
|
+
/**
|
|
145
|
+
* Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
|
|
146
|
+
* be between -62135596800 and 253402300799 inclusive (which corresponds to
|
|
147
|
+
* 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).
|
|
148
|
+
*
|
|
149
|
+
* @generated from protobuf field: int64 seconds = 1
|
|
150
|
+
*/
|
|
151
|
+
seconds: bigint;
|
|
152
|
+
/**
|
|
153
|
+
* Non-negative fractions of a second at nanosecond resolution. This field is
|
|
154
|
+
* the nanosecond portion of the duration, not an alternative to seconds.
|
|
155
|
+
* Negative second values with fractions must still have non-negative nanos
|
|
156
|
+
* values that count forward in time. Must be between 0 and 999,999,999
|
|
157
|
+
* inclusive.
|
|
158
|
+
*
|
|
159
|
+
* @generated from protobuf field: int32 nanos = 2
|
|
160
|
+
*/
|
|
161
|
+
nanos: number;
|
|
162
|
+
}
|
|
163
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
164
|
+
class Timestamp$Type extends MessageType<Timestamp> {
|
|
165
|
+
constructor() {
|
|
166
|
+
super("google.protobuf.Timestamp", [
|
|
167
|
+
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
168
|
+
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Creates a new `Timestamp` for the current time.
|
|
173
|
+
*/
|
|
174
|
+
now(): Timestamp {
|
|
175
|
+
const msg = this.create();
|
|
176
|
+
const ms = Date.now();
|
|
177
|
+
msg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();
|
|
178
|
+
msg.nanos = (ms % 1000) * 1000000;
|
|
179
|
+
return msg;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Converts a `Timestamp` to a JavaScript Date.
|
|
183
|
+
*/
|
|
184
|
+
toDate(message: Timestamp): Date {
|
|
185
|
+
return new Date(PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Converts a JavaScript Date to a `Timestamp`.
|
|
189
|
+
*/
|
|
190
|
+
fromDate(date: Date): Timestamp {
|
|
191
|
+
const msg = this.create();
|
|
192
|
+
const ms = date.getTime();
|
|
193
|
+
msg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();
|
|
194
|
+
msg.nanos = ((ms % 1000) + (ms < 0 && ms % 1000 !== 0 ? 1000 : 0)) * 1000000;
|
|
195
|
+
return msg;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
199
|
+
* in the RFC 3339 format.
|
|
200
|
+
*/
|
|
201
|
+
internalJsonWrite(message: Timestamp, options: JsonWriteOptions): JsonValue {
|
|
202
|
+
let ms = PbLong.from(message.seconds).toNumber() * 1000;
|
|
203
|
+
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
|
204
|
+
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
|
205
|
+
if (message.nanos < 0)
|
|
206
|
+
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
|
207
|
+
let z = "Z";
|
|
208
|
+
if (message.nanos > 0) {
|
|
209
|
+
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
|
210
|
+
if (nanosStr.substring(3) === "000000")
|
|
211
|
+
z = "." + nanosStr.substring(0, 3) + "Z";
|
|
212
|
+
else if (nanosStr.substring(6) === "000")
|
|
213
|
+
z = "." + nanosStr.substring(0, 6) + "Z";
|
|
214
|
+
else
|
|
215
|
+
z = "." + nanosStr + "Z";
|
|
216
|
+
}
|
|
217
|
+
return new Date(ms).toISOString().replace(".000Z", z);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
221
|
+
* in the RFC 3339 format.
|
|
222
|
+
*/
|
|
223
|
+
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Timestamp): Timestamp {
|
|
224
|
+
if (typeof json !== "string")
|
|
225
|
+
throw new Error("Unable to parse Timestamp from JSON " + typeofJsonValue(json) + ".");
|
|
226
|
+
let 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]))$/);
|
|
227
|
+
if (!matches)
|
|
228
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
|
229
|
+
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
|
230
|
+
if (Number.isNaN(ms))
|
|
231
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
|
232
|
+
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
|
233
|
+
throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
|
234
|
+
if (!target)
|
|
235
|
+
target = this.create();
|
|
236
|
+
target.seconds = PbLong.from(ms / 1000).toBigInt();
|
|
237
|
+
target.nanos = 0;
|
|
238
|
+
if (matches[7])
|
|
239
|
+
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
|
240
|
+
return target;
|
|
241
|
+
}
|
|
242
|
+
create(value?: PartialMessage<Timestamp>): Timestamp {
|
|
243
|
+
const message = globalThis.Object.create((this.messagePrototype!));
|
|
244
|
+
message.seconds = 0n;
|
|
245
|
+
message.nanos = 0;
|
|
246
|
+
if (value !== undefined)
|
|
247
|
+
reflectionMergePartial<Timestamp>(this, message, value);
|
|
248
|
+
return message;
|
|
249
|
+
}
|
|
250
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Timestamp): Timestamp {
|
|
251
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
252
|
+
while (reader.pos < end) {
|
|
253
|
+
let [fieldNo, wireType] = reader.tag();
|
|
254
|
+
switch (fieldNo) {
|
|
255
|
+
case /* int64 seconds */ 1:
|
|
256
|
+
message.seconds = reader.int64().toBigInt();
|
|
257
|
+
break;
|
|
258
|
+
case /* int32 nanos */ 2:
|
|
259
|
+
message.nanos = reader.int32();
|
|
260
|
+
break;
|
|
261
|
+
default:
|
|
262
|
+
let u = options.readUnknownField;
|
|
263
|
+
if (u === "throw")
|
|
264
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
265
|
+
let d = reader.skip(wireType);
|
|
266
|
+
if (u !== false)
|
|
267
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return message;
|
|
271
|
+
}
|
|
272
|
+
internalBinaryWrite(message: Timestamp, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
|
273
|
+
/* int64 seconds = 1; */
|
|
274
|
+
if (message.seconds !== 0n)
|
|
275
|
+
writer.tag(1, WireType.Varint).int64(message.seconds);
|
|
276
|
+
/* int32 nanos = 2; */
|
|
277
|
+
if (message.nanos !== 0)
|
|
278
|
+
writer.tag(2, WireType.Varint).int32(message.nanos);
|
|
279
|
+
let u = options.writeUnknownFields;
|
|
280
|
+
if (u !== false)
|
|
281
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
282
|
+
return writer;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* @generated MessageType for protobuf message google.protobuf.Timestamp
|
|
287
|
+
*/
|
|
288
|
+
export const Timestamp = new Timestamp$Type();
|