mezon-js 2.8.43 → 2.8.44

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -1410,7 +1410,7 @@ export interface ApiSetMuteNotificationRequest {
1410
1410
  //
1411
1411
  active?: number;
1412
1412
  //
1413
- channel_id?: string;
1413
+ id?: string;
1414
1414
  //
1415
1415
  notification_type?: number;
1416
1416
  }
@@ -4954,6 +4954,42 @@ export class MezonApi {
4954
4954
  ]);
4955
4955
  }
4956
4956
 
4957
+ /** set mute notification user channel. */
4958
+ setMuteNotificationCategory(bearerToken: string,
4959
+ body:ApiSetMuteNotificationRequest,
4960
+ options: any = {}): Promise<any> {
4961
+
4962
+ if (body === null || body === undefined) {
4963
+ throw new Error("'body' is a required parameter but is null or undefined.");
4964
+ }
4965
+ const urlPath = "/v2/mutenotificationcategory/set";
4966
+ const queryParams = new Map<string, any>();
4967
+
4968
+ let bodyJson : string = "";
4969
+ bodyJson = JSON.stringify(body || {});
4970
+
4971
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4972
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4973
+ if (bearerToken) {
4974
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4975
+ }
4976
+
4977
+ return Promise.race([
4978
+ fetch(fullUrl, fetchOptions).then((response) => {
4979
+ if (response.status == 204) {
4980
+ return response;
4981
+ } else if (response.status >= 200 && response.status < 300) {
4982
+ return response.json();
4983
+ } else {
4984
+ throw response;
4985
+ }
4986
+ }),
4987
+ new Promise((_, reject) =>
4988
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
4989
+ ),
4990
+ ]);
4991
+ }
4992
+
4957
4993
  /** set mute notification user channel. */
4958
4994
  setMuteNotificationChannel(bearerToken: string,
4959
4995
  body:ApiSetMuteNotificationRequest,
package/client.ts CHANGED
@@ -1932,6 +1932,18 @@ async setNotificationChannel(session: Session, request: ApiSetNotificationReques
1932
1932
  });
1933
1933
  }
1934
1934
 
1935
+ /** Set notification category*/
1936
+ async setMuteNotificationCategory(session: Session, request: ApiSetMuteNotificationRequest): Promise<boolean> {
1937
+ if (this.autoRefreshSession && session.refresh_token &&
1938
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
1939
+ await this.sessionRefresh(session);
1940
+ }
1941
+
1942
+ return this.apiClient.setMuteNotificationCategory(session.token, request).then((response: any) => {
1943
+ return response !== undefined;
1944
+ });
1945
+ }
1946
+
1935
1947
  /** Set notification channel*/
1936
1948
  async setMuteNotificationChannel(session: Session, request: ApiSetMuteNotificationRequest): Promise<boolean> {
1937
1949
  if (this.autoRefreshSession && session.refresh_token &&
package/dist/api.gen.d.ts CHANGED
@@ -817,7 +817,7 @@ export interface ApiSetDefaultNotificationRequest {
817
817
  /** */
818
818
  export interface ApiSetMuteNotificationRequest {
819
819
  active?: number;
820
- channel_id?: string;
820
+ id?: string;
821
821
  notification_type?: number;
822
822
  }
823
823
  /** */
@@ -1161,6 +1161,8 @@ export declare class MezonApi {
1161
1161
  /** Add users to a channel. */
1162
1162
  inviteUser(bearerToken: string, inviteId: string, options?: any): Promise<ApiInviteUserRes>;
1163
1163
  /** set mute notification user channel. */
1164
+ setMuteNotificationCategory(bearerToken: string, body: ApiSetMuteNotificationRequest, options?: any): Promise<any>;
1165
+ /** set mute notification user channel. */
1164
1166
  setMuteNotificationChannel(bearerToken: string, body: ApiSetMuteNotificationRequest, options?: any): Promise<any>;
1165
1167
  /** Delete one or more notifications for the current user. */
1166
1168
  deleteNotifications(bearerToken: string, ids?: Array<string>, options?: any): Promise<any>;
package/dist/client.d.ts CHANGED
@@ -505,6 +505,8 @@ export declare class Client {
505
505
  setNotificationClan(session: Session, request: ApiSetDefaultNotificationRequest): Promise<boolean>;
506
506
  /** Set notification channel*/
507
507
  setNotificationChannel(session: Session, request: ApiSetNotificationRequest): Promise<boolean>;
508
+ /** Set notification category*/
509
+ setMuteNotificationCategory(session: Session, request: ApiSetMuteNotificationRequest): Promise<boolean>;
508
510
  /** Set notification channel*/
509
511
  setMuteNotificationChannel(session: Session, request: ApiSetMuteNotificationRequest): Promise<boolean>;
510
512
  /** update channel private*/
@@ -3197,6 +3197,35 @@ var MezonApi = class {
3197
3197
  ]);
3198
3198
  }
3199
3199
  /** set mute notification user channel. */
3200
+ setMuteNotificationCategory(bearerToken, body, options = {}) {
3201
+ if (body === null || body === void 0) {
3202
+ throw new Error("'body' is a required parameter but is null or undefined.");
3203
+ }
3204
+ const urlPath = "/v2/mutenotificationcategory/set";
3205
+ const queryParams = /* @__PURE__ */ new Map();
3206
+ let bodyJson = "";
3207
+ bodyJson = JSON.stringify(body || {});
3208
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3209
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3210
+ if (bearerToken) {
3211
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3212
+ }
3213
+ return Promise.race([
3214
+ fetch(fullUrl, fetchOptions).then((response) => {
3215
+ if (response.status == 204) {
3216
+ return response;
3217
+ } else if (response.status >= 200 && response.status < 300) {
3218
+ return response.json();
3219
+ } else {
3220
+ throw response;
3221
+ }
3222
+ }),
3223
+ new Promise(
3224
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3225
+ )
3226
+ ]);
3227
+ }
3228
+ /** set mute notification user channel. */
3200
3229
  setMuteNotificationChannel(bearerToken, body, options = {}) {
3201
3230
  if (body === null || body === void 0) {
3202
3231
  throw new Error("'body' is a required parameter but is null or undefined.");
@@ -6514,6 +6543,17 @@ var Client = class {
6514
6543
  });
6515
6544
  });
6516
6545
  }
6546
+ /** Set notification category*/
6547
+ setMuteNotificationCategory(session, request) {
6548
+ return __async(this, null, function* () {
6549
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6550
+ yield this.sessionRefresh(session);
6551
+ }
6552
+ return this.apiClient.setMuteNotificationCategory(session.token, request).then((response) => {
6553
+ return response !== void 0;
6554
+ });
6555
+ });
6556
+ }
6517
6557
  /** Set notification channel*/
6518
6558
  setMuteNotificationChannel(session, request) {
6519
6559
  return __async(this, null, function* () {
@@ -3168,6 +3168,35 @@ var MezonApi = class {
3168
3168
  ]);
3169
3169
  }
3170
3170
  /** set mute notification user channel. */
3171
+ setMuteNotificationCategory(bearerToken, body, options = {}) {
3172
+ if (body === null || body === void 0) {
3173
+ throw new Error("'body' is a required parameter but is null or undefined.");
3174
+ }
3175
+ const urlPath = "/v2/mutenotificationcategory/set";
3176
+ const queryParams = /* @__PURE__ */ new Map();
3177
+ let bodyJson = "";
3178
+ bodyJson = JSON.stringify(body || {});
3179
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3180
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3181
+ if (bearerToken) {
3182
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3183
+ }
3184
+ return Promise.race([
3185
+ fetch(fullUrl, fetchOptions).then((response) => {
3186
+ if (response.status == 204) {
3187
+ return response;
3188
+ } else if (response.status >= 200 && response.status < 300) {
3189
+ return response.json();
3190
+ } else {
3191
+ throw response;
3192
+ }
3193
+ }),
3194
+ new Promise(
3195
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3196
+ )
3197
+ ]);
3198
+ }
3199
+ /** set mute notification user channel. */
3171
3200
  setMuteNotificationChannel(bearerToken, body, options = {}) {
3172
3201
  if (body === null || body === void 0) {
3173
3202
  throw new Error("'body' is a required parameter but is null or undefined.");
@@ -6485,6 +6514,17 @@ var Client = class {
6485
6514
  });
6486
6515
  });
6487
6516
  }
6517
+ /** Set notification category*/
6518
+ setMuteNotificationCategory(session, request) {
6519
+ return __async(this, null, function* () {
6520
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6521
+ yield this.sessionRefresh(session);
6522
+ }
6523
+ return this.apiClient.setMuteNotificationCategory(session.token, request).then((response) => {
6524
+ return response !== void 0;
6525
+ });
6526
+ });
6527
+ }
6488
6528
  /** Set notification channel*/
6489
6529
  setMuteNotificationChannel(session, request) {
6490
6530
  return __async(this, null, function* () {
@@ -1,220 +1,220 @@
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
- }
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
+ }