@se-uulm/snowballr-grpc-client 0.2.0 → 0.2.1-alpha.2fd7ace
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/dist/authentication.d.ts +216 -0
- package/dist/{authentication.ts → authentication.js} +50 -155
- package/dist/base.d.ts +139 -0
- package/dist/{base.ts → base.js} +43 -108
- package/dist/criterion.d.ts +170 -0
- package/dist/{criterion.ts → criterion.js} +33 -122
- package/dist/export.d.ts +84 -0
- package/dist/{export.ts → export.js} +19 -65
- package/dist/fetcher.d.ts +161 -0
- package/dist/{fetcher.ts → fetcher.js} +30 -140
- package/dist/google/protobuf/{field_mask.ts → field_mask.d.ts} +10 -73
- package/dist/google/protobuf/field_mask.js +117 -0
- package/dist/google/protobuf/{timestamp.ts → timestamp.d.ts} +13 -111
- package/dist/google/protobuf/timestamp.js +166 -0
- package/dist/{main.client.ts → main.client.d.ts} +135 -362
- package/dist/main.client.js +1690 -0
- package/dist/main.d.ts +10 -0
- package/dist/{main.ts → main.js} +60 -54
- package/dist/paper.d.ts +217 -0
- package/dist/{paper.ts → paper.js} +41 -187
- package/dist/project.d.ts +866 -0
- package/dist/{project.ts → project.js} +195 -641
- package/dist/review.d.ts +153 -0
- package/dist/{review.ts → review.js} +33 -105
- package/dist/user.d.ts +157 -0
- package/dist/{user.ts → user.js} +33 -93
- package/dist/user_settings.d.ts +74 -0
- package/dist/{user_settings.ts → user_settings.js} +16 -59
- package/package.json +15 -6
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// @generated by protobuf-ts 2.11.1 with parameter generate_dependencies,output_javascript
|
|
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 { WireType } from "@protobuf-ts/runtime";
|
|
36
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
37
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
38
|
+
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
39
|
+
import { lowerCamelCase } from "@protobuf-ts/runtime";
|
|
40
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
41
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
42
|
+
class FieldMask$Type extends MessageType {
|
|
43
|
+
constructor() {
|
|
44
|
+
super("google.protobuf.FieldMask", [
|
|
45
|
+
{ no: 1, name: "paths", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/ }
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Encode `FieldMask` to JSON object.
|
|
50
|
+
*/
|
|
51
|
+
internalJsonWrite(message, options) {
|
|
52
|
+
const invalidFieldMaskJsonRegex = /[A-Z]|(_([.0-9_]|$))/g;
|
|
53
|
+
return message.paths.map(p => {
|
|
54
|
+
if (invalidFieldMaskJsonRegex.test(p))
|
|
55
|
+
throw new Error("Unable to encode FieldMask to JSON. lowerCamelCase of path name \"" + p + "\" is irreversible.");
|
|
56
|
+
return lowerCamelCase(p);
|
|
57
|
+
}).join(",");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Decode `FieldMask` from JSON object.
|
|
61
|
+
*/
|
|
62
|
+
internalJsonRead(json, options, target) {
|
|
63
|
+
if (typeof json !== "string")
|
|
64
|
+
throw new Error("Unable to parse FieldMask from JSON " + typeofJsonValue(json) + ". Expected string.");
|
|
65
|
+
if (!target)
|
|
66
|
+
target = this.create();
|
|
67
|
+
if (json === "")
|
|
68
|
+
return target;
|
|
69
|
+
let camelToSnake = (str) => {
|
|
70
|
+
if (str.includes("_"))
|
|
71
|
+
throw new Error("Unable to parse FieldMask from JSON. Path names must be lowerCamelCase.");
|
|
72
|
+
let sc = str.replace(/[A-Z]/g, letter => "_" + letter.toLowerCase());
|
|
73
|
+
return sc;
|
|
74
|
+
};
|
|
75
|
+
target.paths = json.split(",").map(camelToSnake);
|
|
76
|
+
return target;
|
|
77
|
+
}
|
|
78
|
+
create(value) {
|
|
79
|
+
const message = globalThis.Object.create((this.messagePrototype));
|
|
80
|
+
message.paths = [];
|
|
81
|
+
if (value !== undefined)
|
|
82
|
+
reflectionMergePartial(this, message, value);
|
|
83
|
+
return message;
|
|
84
|
+
}
|
|
85
|
+
internalBinaryRead(reader, length, options, target) {
|
|
86
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
87
|
+
while (reader.pos < end) {
|
|
88
|
+
let [fieldNo, wireType] = reader.tag();
|
|
89
|
+
switch (fieldNo) {
|
|
90
|
+
case /* repeated string paths */ 1:
|
|
91
|
+
message.paths.push(reader.string());
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
let u = options.readUnknownField;
|
|
95
|
+
if (u === "throw")
|
|
96
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
97
|
+
let d = reader.skip(wireType);
|
|
98
|
+
if (u !== false)
|
|
99
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return message;
|
|
103
|
+
}
|
|
104
|
+
internalBinaryWrite(message, writer, options) {
|
|
105
|
+
/* repeated string paths = 1; */
|
|
106
|
+
for (let i = 0; i < message.paths.length; i++)
|
|
107
|
+
writer.tag(1, WireType.LengthDelimited).string(message.paths[i]);
|
|
108
|
+
let u = options.writeUnknownFields;
|
|
109
|
+
if (u !== false)
|
|
110
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
111
|
+
return writer;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @generated MessageType for protobuf message google.protobuf.FieldMask
|
|
116
|
+
*/
|
|
117
|
+
export const FieldMask = new FieldMask$Type();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.11.1 with parameter generate_dependencies
|
|
1
|
+
// @generated by protobuf-ts 2.11.1 with parameter generate_dependencies,output_javascript
|
|
2
2
|
// @generated from protobuf file "google/protobuf/timestamp.proto" (package "google.protobuf", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
//
|
|
@@ -34,17 +34,12 @@
|
|
|
34
34
|
//
|
|
35
35
|
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
36
36
|
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
37
|
-
import { WireType } from "@protobuf-ts/runtime";
|
|
38
37
|
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
39
38
|
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
40
|
-
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
41
39
|
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
42
|
-
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
43
|
-
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
44
40
|
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
45
41
|
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
46
42
|
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
47
|
-
import { PbLong } from "@protobuf-ts/runtime";
|
|
48
43
|
import { MessageType } from "@protobuf-ts/runtime";
|
|
49
44
|
/**
|
|
50
45
|
* A Timestamp represents a point in time independent of any time zone or local
|
|
@@ -160,129 +155,36 @@ export interface Timestamp {
|
|
|
160
155
|
*/
|
|
161
156
|
nanos: number;
|
|
162
157
|
}
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
}
|
|
158
|
+
declare class Timestamp$Type extends MessageType<Timestamp> {
|
|
159
|
+
constructor();
|
|
171
160
|
/**
|
|
172
161
|
* Creates a new `Timestamp` for the current time.
|
|
173
162
|
*/
|
|
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
|
-
}
|
|
163
|
+
now(): Timestamp;
|
|
181
164
|
/**
|
|
182
165
|
* Converts a `Timestamp` to a JavaScript Date.
|
|
183
166
|
*/
|
|
184
|
-
toDate(message: Timestamp): Date
|
|
185
|
-
return new Date(PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
|
186
|
-
}
|
|
167
|
+
toDate(message: Timestamp): Date;
|
|
187
168
|
/**
|
|
188
169
|
* Converts a JavaScript Date to a `Timestamp`.
|
|
189
170
|
*/
|
|
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
|
-
}
|
|
171
|
+
fromDate(date: Date): Timestamp;
|
|
197
172
|
/**
|
|
198
173
|
* In JSON format, the `Timestamp` type is encoded as a string
|
|
199
174
|
* in the RFC 3339 format.
|
|
200
175
|
*/
|
|
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
|
-
}
|
|
176
|
+
internalJsonWrite(message: Timestamp, options: JsonWriteOptions): JsonValue;
|
|
219
177
|
/**
|
|
220
178
|
* In JSON format, the `Timestamp` type is encoded as a string
|
|
221
179
|
* in the RFC 3339 format.
|
|
222
180
|
*/
|
|
223
|
-
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Timestamp): Timestamp
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
}
|
|
181
|
+
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Timestamp): Timestamp;
|
|
182
|
+
create(value?: PartialMessage<Timestamp>): Timestamp;
|
|
183
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Timestamp): Timestamp;
|
|
184
|
+
internalBinaryWrite(message: Timestamp, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
284
185
|
}
|
|
285
186
|
/**
|
|
286
187
|
* @generated MessageType for protobuf message google.protobuf.Timestamp
|
|
287
188
|
*/
|
|
288
|
-
export const Timestamp
|
|
189
|
+
export declare const Timestamp: Timestamp$Type;
|
|
190
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @generated by protobuf-ts 2.11.1 with parameter generate_dependencies,output_javascript
|
|
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 { WireType } from "@protobuf-ts/runtime";
|
|
36
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
37
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
38
|
+
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
39
|
+
import { PbLong } from "@protobuf-ts/runtime";
|
|
40
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
41
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
42
|
+
class Timestamp$Type extends MessageType {
|
|
43
|
+
constructor() {
|
|
44
|
+
super("google.protobuf.Timestamp", [
|
|
45
|
+
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
46
|
+
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new `Timestamp` for the current time.
|
|
51
|
+
*/
|
|
52
|
+
now() {
|
|
53
|
+
const msg = this.create();
|
|
54
|
+
const ms = Date.now();
|
|
55
|
+
msg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();
|
|
56
|
+
msg.nanos = (ms % 1000) * 1000000;
|
|
57
|
+
return msg;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Converts a `Timestamp` to a JavaScript Date.
|
|
61
|
+
*/
|
|
62
|
+
toDate(message) {
|
|
63
|
+
return new Date(PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Converts a JavaScript Date to a `Timestamp`.
|
|
67
|
+
*/
|
|
68
|
+
fromDate(date) {
|
|
69
|
+
const msg = this.create();
|
|
70
|
+
const ms = date.getTime();
|
|
71
|
+
msg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();
|
|
72
|
+
msg.nanos = ((ms % 1000) + (ms < 0 && ms % 1000 !== 0 ? 1000 : 0)) * 1000000;
|
|
73
|
+
return msg;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
77
|
+
* in the RFC 3339 format.
|
|
78
|
+
*/
|
|
79
|
+
internalJsonWrite(message, options) {
|
|
80
|
+
let ms = PbLong.from(message.seconds).toNumber() * 1000;
|
|
81
|
+
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
|
82
|
+
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
|
83
|
+
if (message.nanos < 0)
|
|
84
|
+
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
|
85
|
+
let z = "Z";
|
|
86
|
+
if (message.nanos > 0) {
|
|
87
|
+
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
|
88
|
+
if (nanosStr.substring(3) === "000000")
|
|
89
|
+
z = "." + nanosStr.substring(0, 3) + "Z";
|
|
90
|
+
else if (nanosStr.substring(6) === "000")
|
|
91
|
+
z = "." + nanosStr.substring(0, 6) + "Z";
|
|
92
|
+
else
|
|
93
|
+
z = "." + nanosStr + "Z";
|
|
94
|
+
}
|
|
95
|
+
return new Date(ms).toISOString().replace(".000Z", z);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
99
|
+
* in the RFC 3339 format.
|
|
100
|
+
*/
|
|
101
|
+
internalJsonRead(json, options, target) {
|
|
102
|
+
if (typeof json !== "string")
|
|
103
|
+
throw new Error("Unable to parse Timestamp from JSON " + typeofJsonValue(json) + ".");
|
|
104
|
+
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]))$/);
|
|
105
|
+
if (!matches)
|
|
106
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
|
107
|
+
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
|
108
|
+
if (Number.isNaN(ms))
|
|
109
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
|
110
|
+
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
|
111
|
+
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.");
|
|
112
|
+
if (!target)
|
|
113
|
+
target = this.create();
|
|
114
|
+
target.seconds = PbLong.from(ms / 1000).toBigInt();
|
|
115
|
+
target.nanos = 0;
|
|
116
|
+
if (matches[7])
|
|
117
|
+
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
|
118
|
+
return target;
|
|
119
|
+
}
|
|
120
|
+
create(value) {
|
|
121
|
+
const message = globalThis.Object.create((this.messagePrototype));
|
|
122
|
+
message.seconds = 0n;
|
|
123
|
+
message.nanos = 0;
|
|
124
|
+
if (value !== undefined)
|
|
125
|
+
reflectionMergePartial(this, message, value);
|
|
126
|
+
return message;
|
|
127
|
+
}
|
|
128
|
+
internalBinaryRead(reader, length, options, target) {
|
|
129
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
130
|
+
while (reader.pos < end) {
|
|
131
|
+
let [fieldNo, wireType] = reader.tag();
|
|
132
|
+
switch (fieldNo) {
|
|
133
|
+
case /* int64 seconds */ 1:
|
|
134
|
+
message.seconds = reader.int64().toBigInt();
|
|
135
|
+
break;
|
|
136
|
+
case /* int32 nanos */ 2:
|
|
137
|
+
message.nanos = reader.int32();
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
let u = options.readUnknownField;
|
|
141
|
+
if (u === "throw")
|
|
142
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
143
|
+
let d = reader.skip(wireType);
|
|
144
|
+
if (u !== false)
|
|
145
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return message;
|
|
149
|
+
}
|
|
150
|
+
internalBinaryWrite(message, writer, options) {
|
|
151
|
+
/* int64 seconds = 1; */
|
|
152
|
+
if (message.seconds !== 0n)
|
|
153
|
+
writer.tag(1, WireType.Varint).int64(message.seconds);
|
|
154
|
+
/* int32 nanos = 2; */
|
|
155
|
+
if (message.nanos !== 0)
|
|
156
|
+
writer.tag(2, WireType.Varint).int32(message.nanos);
|
|
157
|
+
let u = options.writeUnknownFields;
|
|
158
|
+
if (u !== false)
|
|
159
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
160
|
+
return writer;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* @generated MessageType for protobuf message google.protobuf.Timestamp
|
|
165
|
+
*/
|
|
166
|
+
export const Timestamp = new Timestamp$Type();
|