mezon-js 2.8.62 → 2.8.64
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/mezon-js.cjs.js +3 -3
- package/dist/mezon-js.esm.mjs +3 -3
- package/dist/socket.d.ts +2 -1
- package/package.json +1 -1
- package/socket.ts +6 -4
- package/api/api.ts +0 -20099
- package/google/protobuf/struct.ts +0 -485
- package/google/protobuf/timestamp.ts +0 -220
- package/google/protobuf/wrappers.ts +0 -626
- package/rtapi/realtime.ts +0 -7751
@@ -1,485 +0,0 @@
|
|
1
|
-
/* eslint-disable */
|
2
|
-
import _m0 from "protobufjs/minimal";
|
3
|
-
|
4
|
-
export const protobufPackage = "google.protobuf";
|
5
|
-
|
6
|
-
/**
|
7
|
-
* `NullValue` is a singleton enumeration to represent the null value for the
|
8
|
-
* `Value` type union.
|
9
|
-
*
|
10
|
-
* The JSON representation for `NullValue` is JSON `null`.
|
11
|
-
*/
|
12
|
-
export enum NullValue {
|
13
|
-
/** NULL_VALUE - Null value. */
|
14
|
-
NULL_VALUE = 0,
|
15
|
-
UNRECOGNIZED = -1,
|
16
|
-
}
|
17
|
-
|
18
|
-
export function nullValueFromJSON(object: any): NullValue {
|
19
|
-
switch (object) {
|
20
|
-
case 0:
|
21
|
-
case "NULL_VALUE":
|
22
|
-
return NullValue.NULL_VALUE;
|
23
|
-
case -1:
|
24
|
-
case "UNRECOGNIZED":
|
25
|
-
default:
|
26
|
-
return NullValue.UNRECOGNIZED;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
export function nullValueToJSON(object: NullValue): string {
|
31
|
-
switch (object) {
|
32
|
-
case NullValue.NULL_VALUE:
|
33
|
-
return "NULL_VALUE";
|
34
|
-
case NullValue.UNRECOGNIZED:
|
35
|
-
default:
|
36
|
-
return "UNRECOGNIZED";
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
/**
|
41
|
-
* `Struct` represents a structured data value, consisting of fields
|
42
|
-
* which map to dynamically typed values. In some languages, `Struct`
|
43
|
-
* might be supported by a native representation. For example, in
|
44
|
-
* scripting languages like JS a struct is represented as an
|
45
|
-
* object. The details of that representation are described together
|
46
|
-
* with the proto support for the language.
|
47
|
-
*
|
48
|
-
* The JSON representation for `Struct` is JSON object.
|
49
|
-
*/
|
50
|
-
export interface Struct {
|
51
|
-
/** Unordered map of dynamically typed values. */
|
52
|
-
fields: { [key: string]: any | undefined };
|
53
|
-
}
|
54
|
-
|
55
|
-
export interface Struct_FieldsEntry {
|
56
|
-
key: string;
|
57
|
-
value: any | undefined;
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* `Value` represents a dynamically typed value which can be either
|
62
|
-
* null, a number, a string, a boolean, a recursive struct value, or a
|
63
|
-
* list of values. A producer of value is expected to set one of these
|
64
|
-
* variants. Absence of any variant indicates an error.
|
65
|
-
*
|
66
|
-
* The JSON representation for `Value` is JSON value.
|
67
|
-
*/
|
68
|
-
export interface Value {
|
69
|
-
/** Represents a null value. */
|
70
|
-
null_value?:
|
71
|
-
| NullValue
|
72
|
-
| undefined;
|
73
|
-
/** Represents a double value. */
|
74
|
-
number_value?:
|
75
|
-
| number
|
76
|
-
| undefined;
|
77
|
-
/** Represents a string value. */
|
78
|
-
string_value?:
|
79
|
-
| string
|
80
|
-
| undefined;
|
81
|
-
/** Represents a boolean value. */
|
82
|
-
bool_value?:
|
83
|
-
| boolean
|
84
|
-
| undefined;
|
85
|
-
/** Represents a structured value. */
|
86
|
-
struct_value?:
|
87
|
-
| { [key: string]: any }
|
88
|
-
| undefined;
|
89
|
-
/** Represents a repeated `Value`. */
|
90
|
-
list_value?: Array<any> | undefined;
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* `ListValue` is a wrapper around a repeated field of values.
|
95
|
-
*
|
96
|
-
* The JSON representation for `ListValue` is JSON array.
|
97
|
-
*/
|
98
|
-
export interface ListValue {
|
99
|
-
/** Repeated field of dynamically typed values. */
|
100
|
-
values: any[];
|
101
|
-
}
|
102
|
-
|
103
|
-
function createBaseStruct(): Struct {
|
104
|
-
return { fields: {} };
|
105
|
-
}
|
106
|
-
|
107
|
-
export const Struct = {
|
108
|
-
encode(message: Struct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
109
|
-
Object.entries(message.fields).forEach(([key, value]) => {
|
110
|
-
if (value !== undefined) {
|
111
|
-
Struct_FieldsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim();
|
112
|
-
}
|
113
|
-
});
|
114
|
-
return writer;
|
115
|
-
},
|
116
|
-
|
117
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): Struct {
|
118
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
119
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
120
|
-
const message = createBaseStruct();
|
121
|
-
while (reader.pos < end) {
|
122
|
-
const tag = reader.uint32();
|
123
|
-
switch (tag >>> 3) {
|
124
|
-
case 1:
|
125
|
-
const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
|
126
|
-
if (entry1.value !== undefined) {
|
127
|
-
message.fields[entry1.key] = entry1.value;
|
128
|
-
}
|
129
|
-
break;
|
130
|
-
default:
|
131
|
-
reader.skipType(tag & 7);
|
132
|
-
break;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
return message;
|
136
|
-
},
|
137
|
-
|
138
|
-
fromJSON(object: any): Struct {
|
139
|
-
return {
|
140
|
-
fields: isObject(object.fields)
|
141
|
-
? Object.entries(object.fields).reduce<{ [key: string]: any | undefined }>((acc, [key, value]) => {
|
142
|
-
acc[key] = value as any | undefined;
|
143
|
-
return acc;
|
144
|
-
}, {})
|
145
|
-
: {},
|
146
|
-
};
|
147
|
-
},
|
148
|
-
|
149
|
-
toJSON(message: Struct): unknown {
|
150
|
-
const obj: any = {};
|
151
|
-
obj.fields = {};
|
152
|
-
if (message.fields) {
|
153
|
-
Object.entries(message.fields).forEach(([k, v]) => {
|
154
|
-
obj.fields[k] = v;
|
155
|
-
});
|
156
|
-
}
|
157
|
-
return obj;
|
158
|
-
},
|
159
|
-
|
160
|
-
create<I extends Exact<DeepPartial<Struct>, I>>(base?: I): Struct {
|
161
|
-
return Struct.fromPartial(base ?? {});
|
162
|
-
},
|
163
|
-
|
164
|
-
fromPartial<I extends Exact<DeepPartial<Struct>, I>>(object: I): Struct {
|
165
|
-
const message = createBaseStruct();
|
166
|
-
message.fields = Object.entries(object.fields ?? {}).reduce<{ [key: string]: any | undefined }>(
|
167
|
-
(acc, [key, value]) => {
|
168
|
-
if (value !== undefined) {
|
169
|
-
acc[key] = value;
|
170
|
-
}
|
171
|
-
return acc;
|
172
|
-
},
|
173
|
-
{},
|
174
|
-
);
|
175
|
-
return message;
|
176
|
-
},
|
177
|
-
|
178
|
-
wrap(object: { [key: string]: any } | undefined): Struct {
|
179
|
-
const struct = createBaseStruct();
|
180
|
-
if (object !== undefined) {
|
181
|
-
Object.keys(object).forEach((key) => {
|
182
|
-
struct.fields[key] = object[key];
|
183
|
-
});
|
184
|
-
}
|
185
|
-
return struct;
|
186
|
-
},
|
187
|
-
|
188
|
-
unwrap(message: Struct): { [key: string]: any } {
|
189
|
-
const object: { [key: string]: any } = {};
|
190
|
-
Object.keys(message.fields).forEach((key) => {
|
191
|
-
object[key] = message.fields[key];
|
192
|
-
});
|
193
|
-
return object;
|
194
|
-
},
|
195
|
-
};
|
196
|
-
|
197
|
-
function createBaseStruct_FieldsEntry(): Struct_FieldsEntry {
|
198
|
-
return { key: "", value: undefined };
|
199
|
-
}
|
200
|
-
|
201
|
-
export const Struct_FieldsEntry = {
|
202
|
-
encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
203
|
-
if (message.key !== "") {
|
204
|
-
writer.uint32(10).string(message.key);
|
205
|
-
}
|
206
|
-
if (message.value !== undefined) {
|
207
|
-
Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).ldelim();
|
208
|
-
}
|
209
|
-
return writer;
|
210
|
-
},
|
211
|
-
|
212
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry {
|
213
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
214
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
215
|
-
const message = createBaseStruct_FieldsEntry();
|
216
|
-
while (reader.pos < end) {
|
217
|
-
const tag = reader.uint32();
|
218
|
-
switch (tag >>> 3) {
|
219
|
-
case 1:
|
220
|
-
message.key = reader.string();
|
221
|
-
break;
|
222
|
-
case 2:
|
223
|
-
message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
|
224
|
-
break;
|
225
|
-
default:
|
226
|
-
reader.skipType(tag & 7);
|
227
|
-
break;
|
228
|
-
}
|
229
|
-
}
|
230
|
-
return message;
|
231
|
-
},
|
232
|
-
|
233
|
-
fromJSON(object: any): Struct_FieldsEntry {
|
234
|
-
return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined };
|
235
|
-
},
|
236
|
-
|
237
|
-
toJSON(message: Struct_FieldsEntry): unknown {
|
238
|
-
const obj: any = {};
|
239
|
-
message.key !== undefined && (obj.key = message.key);
|
240
|
-
message.value !== undefined && (obj.value = message.value);
|
241
|
-
return obj;
|
242
|
-
},
|
243
|
-
|
244
|
-
create<I extends Exact<DeepPartial<Struct_FieldsEntry>, I>>(base?: I): Struct_FieldsEntry {
|
245
|
-
return Struct_FieldsEntry.fromPartial(base ?? {});
|
246
|
-
},
|
247
|
-
|
248
|
-
fromPartial<I extends Exact<DeepPartial<Struct_FieldsEntry>, I>>(object: I): Struct_FieldsEntry {
|
249
|
-
const message = createBaseStruct_FieldsEntry();
|
250
|
-
message.key = object.key ?? "";
|
251
|
-
message.value = object.value ?? undefined;
|
252
|
-
return message;
|
253
|
-
},
|
254
|
-
};
|
255
|
-
|
256
|
-
function createBaseValue(): Value {
|
257
|
-
return {
|
258
|
-
null_value: undefined,
|
259
|
-
number_value: undefined,
|
260
|
-
string_value: undefined,
|
261
|
-
bool_value: undefined,
|
262
|
-
struct_value: undefined,
|
263
|
-
list_value: undefined,
|
264
|
-
};
|
265
|
-
}
|
266
|
-
|
267
|
-
export const Value = {
|
268
|
-
encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
269
|
-
if (message.null_value !== undefined) {
|
270
|
-
writer.uint32(8).int32(message.null_value);
|
271
|
-
}
|
272
|
-
if (message.number_value !== undefined) {
|
273
|
-
writer.uint32(17).double(message.number_value);
|
274
|
-
}
|
275
|
-
if (message.string_value !== undefined) {
|
276
|
-
writer.uint32(26).string(message.string_value);
|
277
|
-
}
|
278
|
-
if (message.bool_value !== undefined) {
|
279
|
-
writer.uint32(32).bool(message.bool_value);
|
280
|
-
}
|
281
|
-
if (message.struct_value !== undefined) {
|
282
|
-
Struct.encode(Struct.wrap(message.struct_value), writer.uint32(42).fork()).ldelim();
|
283
|
-
}
|
284
|
-
if (message.list_value !== undefined) {
|
285
|
-
ListValue.encode(ListValue.wrap(message.list_value), writer.uint32(50).fork()).ldelim();
|
286
|
-
}
|
287
|
-
return writer;
|
288
|
-
},
|
289
|
-
|
290
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): Value {
|
291
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
292
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
293
|
-
const message = createBaseValue();
|
294
|
-
while (reader.pos < end) {
|
295
|
-
const tag = reader.uint32();
|
296
|
-
switch (tag >>> 3) {
|
297
|
-
case 1:
|
298
|
-
message.null_value = reader.int32() as any;
|
299
|
-
break;
|
300
|
-
case 2:
|
301
|
-
message.number_value = reader.double();
|
302
|
-
break;
|
303
|
-
case 3:
|
304
|
-
message.string_value = reader.string();
|
305
|
-
break;
|
306
|
-
case 4:
|
307
|
-
message.bool_value = reader.bool();
|
308
|
-
break;
|
309
|
-
case 5:
|
310
|
-
message.struct_value = Struct.unwrap(Struct.decode(reader, reader.uint32()));
|
311
|
-
break;
|
312
|
-
case 6:
|
313
|
-
message.list_value = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
|
314
|
-
break;
|
315
|
-
default:
|
316
|
-
reader.skipType(tag & 7);
|
317
|
-
break;
|
318
|
-
}
|
319
|
-
}
|
320
|
-
return message;
|
321
|
-
},
|
322
|
-
|
323
|
-
fromJSON(object: any): Value {
|
324
|
-
return {
|
325
|
-
null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined,
|
326
|
-
number_value: isSet(object.number_value) ? Number(object.number_value) : undefined,
|
327
|
-
string_value: isSet(object.string_value) ? String(object.string_value) : undefined,
|
328
|
-
bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined,
|
329
|
-
struct_value: isObject(object.struct_value) ? object.struct_value : undefined,
|
330
|
-
list_value: Array.isArray(object.list_value) ? [...object.list_value] : undefined,
|
331
|
-
};
|
332
|
-
},
|
333
|
-
|
334
|
-
toJSON(message: Value): unknown {
|
335
|
-
const obj: any = {};
|
336
|
-
message.null_value !== undefined &&
|
337
|
-
(obj.null_value = message.null_value !== undefined ? nullValueToJSON(message.null_value) : undefined);
|
338
|
-
message.number_value !== undefined && (obj.number_value = message.number_value);
|
339
|
-
message.string_value !== undefined && (obj.string_value = message.string_value);
|
340
|
-
message.bool_value !== undefined && (obj.bool_value = message.bool_value);
|
341
|
-
message.struct_value !== undefined && (obj.struct_value = message.struct_value);
|
342
|
-
message.list_value !== undefined && (obj.list_value = message.list_value);
|
343
|
-
return obj;
|
344
|
-
},
|
345
|
-
|
346
|
-
create<I extends Exact<DeepPartial<Value>, I>>(base?: I): Value {
|
347
|
-
return Value.fromPartial(base ?? {});
|
348
|
-
},
|
349
|
-
|
350
|
-
fromPartial<I extends Exact<DeepPartial<Value>, I>>(object: I): Value {
|
351
|
-
const message = createBaseValue();
|
352
|
-
message.null_value = object.null_value ?? undefined;
|
353
|
-
message.number_value = object.number_value ?? undefined;
|
354
|
-
message.string_value = object.string_value ?? undefined;
|
355
|
-
message.bool_value = object.bool_value ?? undefined;
|
356
|
-
message.struct_value = object.struct_value ?? undefined;
|
357
|
-
message.list_value = object.list_value ?? undefined;
|
358
|
-
return message;
|
359
|
-
},
|
360
|
-
|
361
|
-
wrap(value: any): Value {
|
362
|
-
const result = createBaseValue();
|
363
|
-
|
364
|
-
if (value === null) {
|
365
|
-
result.null_value = NullValue.NULL_VALUE;
|
366
|
-
} else if (typeof value === "boolean") {
|
367
|
-
result.bool_value = value;
|
368
|
-
} else if (typeof value === "number") {
|
369
|
-
result.number_value = value;
|
370
|
-
} else if (typeof value === "string") {
|
371
|
-
result.string_value = value;
|
372
|
-
} else if (Array.isArray(value)) {
|
373
|
-
result.list_value = value;
|
374
|
-
} else if (typeof value === "object") {
|
375
|
-
result.struct_value = value;
|
376
|
-
} else if (typeof value !== "undefined") {
|
377
|
-
throw new Error("Unsupported any value type: " + typeof value);
|
378
|
-
}
|
379
|
-
|
380
|
-
return result;
|
381
|
-
},
|
382
|
-
|
383
|
-
unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
|
384
|
-
if (message?.string_value !== undefined) {
|
385
|
-
return message.string_value;
|
386
|
-
} else if (message?.number_value !== undefined) {
|
387
|
-
return message.number_value;
|
388
|
-
} else if (message?.bool_value !== undefined) {
|
389
|
-
return message.bool_value;
|
390
|
-
} else if (message?.struct_value !== undefined) {
|
391
|
-
return message.struct_value;
|
392
|
-
} else if (message?.list_value !== undefined) {
|
393
|
-
return message.list_value;
|
394
|
-
} else if (message?.null_value !== undefined) {
|
395
|
-
return null;
|
396
|
-
}
|
397
|
-
return undefined;
|
398
|
-
},
|
399
|
-
};
|
400
|
-
|
401
|
-
function createBaseListValue(): ListValue {
|
402
|
-
return { values: [] };
|
403
|
-
}
|
404
|
-
|
405
|
-
export const ListValue = {
|
406
|
-
encode(message: ListValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
407
|
-
for (const v of message.values) {
|
408
|
-
Value.encode(Value.wrap(v!), writer.uint32(10).fork()).ldelim();
|
409
|
-
}
|
410
|
-
return writer;
|
411
|
-
},
|
412
|
-
|
413
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): ListValue {
|
414
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
415
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
416
|
-
const message = createBaseListValue();
|
417
|
-
while (reader.pos < end) {
|
418
|
-
const tag = reader.uint32();
|
419
|
-
switch (tag >>> 3) {
|
420
|
-
case 1:
|
421
|
-
message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
|
422
|
-
break;
|
423
|
-
default:
|
424
|
-
reader.skipType(tag & 7);
|
425
|
-
break;
|
426
|
-
}
|
427
|
-
}
|
428
|
-
return message;
|
429
|
-
},
|
430
|
-
|
431
|
-
fromJSON(object: any): ListValue {
|
432
|
-
return { values: Array.isArray(object?.values) ? [...object.values] : [] };
|
433
|
-
},
|
434
|
-
|
435
|
-
toJSON(message: ListValue): unknown {
|
436
|
-
const obj: any = {};
|
437
|
-
if (message.values) {
|
438
|
-
obj.values = message.values.map((e) => e);
|
439
|
-
} else {
|
440
|
-
obj.values = [];
|
441
|
-
}
|
442
|
-
return obj;
|
443
|
-
},
|
444
|
-
|
445
|
-
create<I extends Exact<DeepPartial<ListValue>, I>>(base?: I): ListValue {
|
446
|
-
return ListValue.fromPartial(base ?? {});
|
447
|
-
},
|
448
|
-
|
449
|
-
fromPartial<I extends Exact<DeepPartial<ListValue>, I>>(object: I): ListValue {
|
450
|
-
const message = createBaseListValue();
|
451
|
-
message.values = object.values?.map((e) => e) || [];
|
452
|
-
return message;
|
453
|
-
},
|
454
|
-
|
455
|
-
wrap(value: Array<any> | undefined): ListValue {
|
456
|
-
const result = createBaseListValue();
|
457
|
-
|
458
|
-
result.values = value ?? [];
|
459
|
-
|
460
|
-
return result;
|
461
|
-
},
|
462
|
-
|
463
|
-
unwrap(message: ListValue): Array<any> {
|
464
|
-
return message.values;
|
465
|
-
},
|
466
|
-
};
|
467
|
-
|
468
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
469
|
-
|
470
|
-
export type DeepPartial<T> = T extends Builtin ? T
|
471
|
-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
472
|
-
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
473
|
-
: Partial<T>;
|
474
|
-
|
475
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
476
|
-
export type Exact<P, I extends P> = P extends Builtin ? P
|
477
|
-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
478
|
-
|
479
|
-
function isObject(value: any): boolean {
|
480
|
-
return typeof value === "object" && value !== null;
|
481
|
-
}
|
482
|
-
|
483
|
-
function isSet(value: any): boolean {
|
484
|
-
return value !== null && value !== undefined;
|
485
|
-
}
|
@@ -1,220 +0,0 @@
|
|
1
|
-
/* eslint-disable */
|
2
|
-
import Long from "long";
|
3
|
-
import _m0 from "protobufjs/minimal";
|
4
|
-
|
5
|
-
export const protobufPackage = "google.protobuf";
|
6
|
-
|
7
|
-
/**
|
8
|
-
* A Timestamp represents a point in time independent of any time zone or local
|
9
|
-
* calendar, encoded as a count of seconds and fractions of seconds at
|
10
|
-
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
11
|
-
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
12
|
-
* Gregorian calendar backwards to year one.
|
13
|
-
*
|
14
|
-
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
15
|
-
* second table is needed for interpretation, using a [24-hour linear
|
16
|
-
* smear](https://developers.google.com/time/smear).
|
17
|
-
*
|
18
|
-
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
19
|
-
* restricting to that range, we ensure that we can convert to and from [RFC
|
20
|
-
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
21
|
-
*
|
22
|
-
* # Examples
|
23
|
-
*
|
24
|
-
* Example 1: Compute Timestamp from POSIX `time()`.
|
25
|
-
*
|
26
|
-
* Timestamp timestamp;
|
27
|
-
* timestamp.set_seconds(time(NULL));
|
28
|
-
* timestamp.set_nanos(0);
|
29
|
-
*
|
30
|
-
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
31
|
-
*
|
32
|
-
* struct timeval tv;
|
33
|
-
* gettimeofday(&tv, NULL);
|
34
|
-
*
|
35
|
-
* Timestamp timestamp;
|
36
|
-
* timestamp.set_seconds(tv.tv_sec);
|
37
|
-
* timestamp.set_nanos(tv.tv_usec * 1000);
|
38
|
-
*
|
39
|
-
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
40
|
-
*
|
41
|
-
* FILETIME ft;
|
42
|
-
* GetSystemTimeAsFileTime(&ft);
|
43
|
-
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
44
|
-
*
|
45
|
-
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
46
|
-
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
47
|
-
* Timestamp timestamp;
|
48
|
-
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
49
|
-
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
50
|
-
*
|
51
|
-
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
52
|
-
*
|
53
|
-
* long millis = System.currentTimeMillis();
|
54
|
-
*
|
55
|
-
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
56
|
-
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
57
|
-
*
|
58
|
-
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
59
|
-
*
|
60
|
-
* Instant now = Instant.now();
|
61
|
-
*
|
62
|
-
* Timestamp timestamp =
|
63
|
-
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
64
|
-
* .setNanos(now.getNano()).build();
|
65
|
-
*
|
66
|
-
* Example 6: Compute Timestamp from current time in Python.
|
67
|
-
*
|
68
|
-
* timestamp = Timestamp()
|
69
|
-
* timestamp.GetCurrentTime()
|
70
|
-
*
|
71
|
-
* # JSON Mapping
|
72
|
-
*
|
73
|
-
* In JSON format, the Timestamp type is encoded as a string in the
|
74
|
-
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
75
|
-
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
76
|
-
* where {year} is always expressed using four digits while {month}, {day},
|
77
|
-
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
78
|
-
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
79
|
-
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
80
|
-
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
81
|
-
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
82
|
-
* able to accept both UTC and other timezones (as indicated by an offset).
|
83
|
-
*
|
84
|
-
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
85
|
-
* 01:30 UTC on January 15, 2017.
|
86
|
-
*
|
87
|
-
* In JavaScript, one can convert a Date object to this format using the
|
88
|
-
* standard
|
89
|
-
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
90
|
-
* method. In Python, a standard `datetime.datetime` object can be converted
|
91
|
-
* to this format using
|
92
|
-
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
93
|
-
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
94
|
-
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
95
|
-
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
96
|
-
* ) to obtain a formatter capable of generating timestamps in this format.
|
97
|
-
*/
|
98
|
-
export interface Timestamp {
|
99
|
-
/**
|
100
|
-
* Represents seconds of UTC time since Unix epoch
|
101
|
-
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
102
|
-
* 9999-12-31T23:59:59Z inclusive.
|
103
|
-
*/
|
104
|
-
seconds: number;
|
105
|
-
/**
|
106
|
-
* Non-negative fractions of a second at nanosecond resolution. Negative
|
107
|
-
* second values with fractions must still have non-negative nanos values
|
108
|
-
* that count forward in time. Must be from 0 to 999,999,999
|
109
|
-
* inclusive.
|
110
|
-
*/
|
111
|
-
nanos: number;
|
112
|
-
}
|
113
|
-
|
114
|
-
function createBaseTimestamp(): Timestamp {
|
115
|
-
return { seconds: 0, nanos: 0 };
|
116
|
-
}
|
117
|
-
|
118
|
-
export const Timestamp = {
|
119
|
-
encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
120
|
-
if (message.seconds !== 0) {
|
121
|
-
writer.uint32(8).int64(message.seconds);
|
122
|
-
}
|
123
|
-
if (message.nanos !== 0) {
|
124
|
-
writer.uint32(16).int32(message.nanos);
|
125
|
-
}
|
126
|
-
return writer;
|
127
|
-
},
|
128
|
-
|
129
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp {
|
130
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
131
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
132
|
-
const message = createBaseTimestamp();
|
133
|
-
while (reader.pos < end) {
|
134
|
-
const tag = reader.uint32();
|
135
|
-
switch (tag >>> 3) {
|
136
|
-
case 1:
|
137
|
-
message.seconds = longToNumber(reader.int64() as Long);
|
138
|
-
break;
|
139
|
-
case 2:
|
140
|
-
message.nanos = reader.int32();
|
141
|
-
break;
|
142
|
-
default:
|
143
|
-
reader.skipType(tag & 7);
|
144
|
-
break;
|
145
|
-
}
|
146
|
-
}
|
147
|
-
return message;
|
148
|
-
},
|
149
|
-
|
150
|
-
fromJSON(object: any): Timestamp {
|
151
|
-
return {
|
152
|
-
seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
|
153
|
-
nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
|
154
|
-
};
|
155
|
-
},
|
156
|
-
|
157
|
-
toJSON(message: Timestamp): unknown {
|
158
|
-
const obj: any = {};
|
159
|
-
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
|
160
|
-
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
|
161
|
-
return obj;
|
162
|
-
},
|
163
|
-
|
164
|
-
create<I extends Exact<DeepPartial<Timestamp>, I>>(base?: I): Timestamp {
|
165
|
-
return Timestamp.fromPartial(base ?? {});
|
166
|
-
},
|
167
|
-
|
168
|
-
fromPartial<I extends Exact<DeepPartial<Timestamp>, I>>(object: I): Timestamp {
|
169
|
-
const message = createBaseTimestamp();
|
170
|
-
message.seconds = object.seconds ?? 0;
|
171
|
-
message.nanos = object.nanos ?? 0;
|
172
|
-
return message;
|
173
|
-
},
|
174
|
-
};
|
175
|
-
|
176
|
-
declare var self: any | undefined;
|
177
|
-
declare var window: any | undefined;
|
178
|
-
declare var global: any | undefined;
|
179
|
-
var tsProtoGlobalThis: any = (() => {
|
180
|
-
if (typeof globalThis !== "undefined") {
|
181
|
-
return globalThis;
|
182
|
-
}
|
183
|
-
if (typeof self !== "undefined") {
|
184
|
-
return self;
|
185
|
-
}
|
186
|
-
if (typeof window !== "undefined") {
|
187
|
-
return window;
|
188
|
-
}
|
189
|
-
if (typeof global !== "undefined") {
|
190
|
-
return global;
|
191
|
-
}
|
192
|
-
throw "Unable to locate global object";
|
193
|
-
})();
|
194
|
-
|
195
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
196
|
-
|
197
|
-
export type DeepPartial<T> = T extends Builtin ? T
|
198
|
-
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
199
|
-
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
200
|
-
: Partial<T>;
|
201
|
-
|
202
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
203
|
-
export type Exact<P, I extends P> = P extends Builtin ? P
|
204
|
-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
205
|
-
|
206
|
-
function longToNumber(long: Long): number {
|
207
|
-
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
208
|
-
throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
209
|
-
}
|
210
|
-
return long.toNumber();
|
211
|
-
}
|
212
|
-
|
213
|
-
if (_m0.util.Long !== Long) {
|
214
|
-
_m0.util.Long = Long as any;
|
215
|
-
_m0.configure();
|
216
|
-
}
|
217
|
-
|
218
|
-
function isSet(value: any): boolean {
|
219
|
-
return value !== null && value !== undefined;
|
220
|
-
}
|