@kernelminds/scailo-sdk 0.0.111 → 0.0.112
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/LICENSE +201 -0
- package/README.md +148 -0
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/src/vault_commons.scailo_pb.js +2 -2
- package/lib/cjs/types/index.d.ts +0 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/src/vault_commons.scailo_pb.d.ts +2 -2
- package/lib/esm/index.js +0 -1
- package/lib/esm/src/vault_commons.scailo_pb.js +2 -2
- package/lib/esm/types/index.d.ts +0 -1
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/src/vault_commons.scailo_pb.d.ts +2 -2
- package/package.json +6 -6
- package/lib/cjs/src/genesis.validate.scailo_pb.js +0 -1141
- package/lib/cjs/src/google/protobuf/duration_pb.js +0 -183
- package/lib/cjs/src/google/protobuf/timestamp_pb.js +0 -227
- package/lib/cjs/types/src/genesis.validate.scailo_pb.d.ts +0 -1796
- package/lib/cjs/types/src/genesis.validate.scailo_pb.d.ts.map +0 -1
- package/lib/cjs/types/src/google/protobuf/duration_pb.d.ts +0 -97
- package/lib/cjs/types/src/google/protobuf/duration_pb.d.ts.map +0 -1
- package/lib/cjs/types/src/google/protobuf/timestamp_pb.d.ts +0 -129
- package/lib/cjs/types/src/google/protobuf/timestamp_pb.d.ts.map +0 -1
- package/lib/esm/src/genesis.validate.scailo_pb.js +0 -2045
- package/lib/esm/src/google/protobuf/duration_pb.js +0 -183
- package/lib/esm/src/google/protobuf/timestamp_pb.js +0 -227
- package/lib/esm/types/src/genesis.validate.scailo_pb.d.ts +0 -1796
- package/lib/esm/types/src/genesis.validate.scailo_pb.d.ts.map +0 -1
- package/lib/esm/types/src/google/protobuf/duration_pb.d.ts +0 -97
- package/lib/esm/types/src/google/protobuf/duration_pb.d.ts.map +0 -1
- package/lib/esm/types/src/google/protobuf/timestamp_pb.d.ts +0 -129
- package/lib/esm/types/src/google/protobuf/timestamp_pb.d.ts.map +0 -1
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Protocol Buffers - Google's data interchange format
|
|
3
|
-
// Copyright 2008 Google Inc. All rights reserved.
|
|
4
|
-
// https://developers.google.com/protocol-buffers/
|
|
5
|
-
//
|
|
6
|
-
// Redistribution and use in source and binary forms, with or without
|
|
7
|
-
// modification, are permitted provided that the following conditions are
|
|
8
|
-
// met:
|
|
9
|
-
//
|
|
10
|
-
// * Redistributions of source code must retain the above copyright
|
|
11
|
-
// notice, this list of conditions and the following disclaimer.
|
|
12
|
-
// * Redistributions in binary form must reproduce the above
|
|
13
|
-
// copyright notice, this list of conditions and the following disclaimer
|
|
14
|
-
// in the documentation and/or other materials provided with the
|
|
15
|
-
// distribution.
|
|
16
|
-
// * Neither the name of Google Inc. nor the names of its
|
|
17
|
-
// contributors may be used to endorse or promote products derived from
|
|
18
|
-
// this software without specific prior written permission.
|
|
19
|
-
//
|
|
20
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.Duration = void 0;
|
|
33
|
-
const protobuf_1 = require("@bufbuild/protobuf");
|
|
34
|
-
/**
|
|
35
|
-
* A Duration represents a signed, fixed-length span of time represented
|
|
36
|
-
* as a count of seconds and fractions of seconds at nanosecond
|
|
37
|
-
* resolution. It is independent of any calendar and concepts like "day"
|
|
38
|
-
* or "month". It is related to Timestamp in that the difference between
|
|
39
|
-
* two Timestamp values is a Duration and it can be added or subtracted
|
|
40
|
-
* from a Timestamp. Range is approximately +-10,000 years.
|
|
41
|
-
*
|
|
42
|
-
* # Examples
|
|
43
|
-
*
|
|
44
|
-
* Example 1: Compute Duration from two Timestamps in pseudo code.
|
|
45
|
-
*
|
|
46
|
-
* Timestamp start = ...;
|
|
47
|
-
* Timestamp end = ...;
|
|
48
|
-
* Duration duration = ...;
|
|
49
|
-
*
|
|
50
|
-
* duration.seconds = end.seconds - start.seconds;
|
|
51
|
-
* duration.nanos = end.nanos - start.nanos;
|
|
52
|
-
*
|
|
53
|
-
* if (duration.seconds < 0 && duration.nanos > 0) {
|
|
54
|
-
* duration.seconds += 1;
|
|
55
|
-
* duration.nanos -= 1000000000;
|
|
56
|
-
* } else if (duration.seconds > 0 && duration.nanos < 0) {
|
|
57
|
-
* duration.seconds -= 1;
|
|
58
|
-
* duration.nanos += 1000000000;
|
|
59
|
-
* }
|
|
60
|
-
*
|
|
61
|
-
* Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
|
62
|
-
*
|
|
63
|
-
* Timestamp start = ...;
|
|
64
|
-
* Duration duration = ...;
|
|
65
|
-
* Timestamp end = ...;
|
|
66
|
-
*
|
|
67
|
-
* end.seconds = start.seconds + duration.seconds;
|
|
68
|
-
* end.nanos = start.nanos + duration.nanos;
|
|
69
|
-
*
|
|
70
|
-
* if (end.nanos < 0) {
|
|
71
|
-
* end.seconds -= 1;
|
|
72
|
-
* end.nanos += 1000000000;
|
|
73
|
-
* } else if (end.nanos >= 1000000000) {
|
|
74
|
-
* end.seconds += 1;
|
|
75
|
-
* end.nanos -= 1000000000;
|
|
76
|
-
* }
|
|
77
|
-
*
|
|
78
|
-
* Example 3: Compute Duration from datetime.timedelta in Python.
|
|
79
|
-
*
|
|
80
|
-
* td = datetime.timedelta(days=3, minutes=10)
|
|
81
|
-
* duration = Duration()
|
|
82
|
-
* duration.FromTimedelta(td)
|
|
83
|
-
*
|
|
84
|
-
* # JSON Mapping
|
|
85
|
-
*
|
|
86
|
-
* In JSON format, the Duration type is encoded as a string rather than an
|
|
87
|
-
* object, where the string ends in the suffix "s" (indicating seconds) and
|
|
88
|
-
* is preceded by the number of seconds, with nanoseconds expressed as
|
|
89
|
-
* fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
|
90
|
-
* encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
|
91
|
-
* be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
|
92
|
-
* microsecond should be expressed in JSON format as "3.000001s".
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @generated from message google.protobuf.Duration
|
|
96
|
-
*/
|
|
97
|
-
class Duration extends protobuf_1.Message {
|
|
98
|
-
/**
|
|
99
|
-
* Signed seconds of the span of time. Must be from -315,576,000,000
|
|
100
|
-
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
101
|
-
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
102
|
-
*
|
|
103
|
-
* @generated from field: int64 seconds = 1;
|
|
104
|
-
*/
|
|
105
|
-
seconds = protobuf_1.protoInt64.zero;
|
|
106
|
-
/**
|
|
107
|
-
* Signed fractions of a second at nanosecond resolution of the span
|
|
108
|
-
* of time. Durations less than one second are represented with a 0
|
|
109
|
-
* `seconds` field and a positive or negative `nanos` field. For durations
|
|
110
|
-
* of one second or more, a non-zero value for the `nanos` field must be
|
|
111
|
-
* of the same sign as the `seconds` field. Must be from -999,999,999
|
|
112
|
-
* to +999,999,999 inclusive.
|
|
113
|
-
*
|
|
114
|
-
* @generated from field: int32 nanos = 2;
|
|
115
|
-
*/
|
|
116
|
-
nanos = 0;
|
|
117
|
-
constructor(data) {
|
|
118
|
-
super();
|
|
119
|
-
protobuf_1.proto3.util.initPartial(data, this);
|
|
120
|
-
}
|
|
121
|
-
fromJson(json, options) {
|
|
122
|
-
if (typeof json !== "string") {
|
|
123
|
-
throw new Error(`cannot decode google.protobuf.Duration from JSON: ${protobuf_1.proto3.json.debug(json)}`);
|
|
124
|
-
}
|
|
125
|
-
const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);
|
|
126
|
-
if (match === null) {
|
|
127
|
-
throw new Error(`cannot decode google.protobuf.Duration from JSON: ${protobuf_1.proto3.json.debug(json)}`);
|
|
128
|
-
}
|
|
129
|
-
const longSeconds = Number(match[1]);
|
|
130
|
-
if (longSeconds > 315576000000 || longSeconds < -315576000000) {
|
|
131
|
-
throw new Error(`cannot decode google.protobuf.Duration from JSON: ${protobuf_1.proto3.json.debug(json)}`);
|
|
132
|
-
}
|
|
133
|
-
this.seconds = protobuf_1.protoInt64.parse(longSeconds);
|
|
134
|
-
if (typeof match[2] == "string") {
|
|
135
|
-
const nanosStr = match[2] + "0".repeat(9 - match[2].length);
|
|
136
|
-
this.nanos = parseInt(nanosStr);
|
|
137
|
-
if (longSeconds < 0 || Object.is(longSeconds, -0)) {
|
|
138
|
-
this.nanos = -this.nanos;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
toJson(options) {
|
|
144
|
-
if (Number(this.seconds) > 315576000000 || Number(this.seconds) < -315576000000) {
|
|
145
|
-
throw new Error(`cannot encode google.protobuf.Duration to JSON: value out of range`);
|
|
146
|
-
}
|
|
147
|
-
let text = this.seconds.toString();
|
|
148
|
-
if (this.nanos !== 0) {
|
|
149
|
-
let nanosStr = Math.abs(this.nanos).toString();
|
|
150
|
-
nanosStr = "0".repeat(9 - nanosStr.length) + nanosStr;
|
|
151
|
-
if (nanosStr.substring(3) === "000000") {
|
|
152
|
-
nanosStr = nanosStr.substring(0, 3);
|
|
153
|
-
}
|
|
154
|
-
else if (nanosStr.substring(6) === "000") {
|
|
155
|
-
nanosStr = nanosStr.substring(0, 6);
|
|
156
|
-
}
|
|
157
|
-
text += "." + nanosStr;
|
|
158
|
-
if (this.nanos < 0 && Number(this.seconds) == 0) {
|
|
159
|
-
text = "-" + text;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return text + "s";
|
|
163
|
-
}
|
|
164
|
-
static runtime = protobuf_1.proto3;
|
|
165
|
-
static typeName = "google.protobuf.Duration";
|
|
166
|
-
static fields = protobuf_1.proto3.util.newFieldList(() => [
|
|
167
|
-
{ no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
|
|
168
|
-
{ no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
|
|
169
|
-
]);
|
|
170
|
-
static fromBinary(bytes, options) {
|
|
171
|
-
return new Duration().fromBinary(bytes, options);
|
|
172
|
-
}
|
|
173
|
-
static fromJson(jsonValue, options) {
|
|
174
|
-
return new Duration().fromJson(jsonValue, options);
|
|
175
|
-
}
|
|
176
|
-
static fromJsonString(jsonString, options) {
|
|
177
|
-
return new Duration().fromJsonString(jsonString, options);
|
|
178
|
-
}
|
|
179
|
-
static equals(a, b) {
|
|
180
|
-
return protobuf_1.proto3.util.equals(Duration, a, b);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
exports.Duration = Duration;
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Protocol Buffers - Google's data interchange format
|
|
3
|
-
// Copyright 2008 Google Inc. All rights reserved.
|
|
4
|
-
// https://developers.google.com/protocol-buffers/
|
|
5
|
-
//
|
|
6
|
-
// Redistribution and use in source and binary forms, with or without
|
|
7
|
-
// modification, are permitted provided that the following conditions are
|
|
8
|
-
// met:
|
|
9
|
-
//
|
|
10
|
-
// * Redistributions of source code must retain the above copyright
|
|
11
|
-
// notice, this list of conditions and the following disclaimer.
|
|
12
|
-
// * Redistributions in binary form must reproduce the above
|
|
13
|
-
// copyright notice, this list of conditions and the following disclaimer
|
|
14
|
-
// in the documentation and/or other materials provided with the
|
|
15
|
-
// distribution.
|
|
16
|
-
// * Neither the name of Google Inc. nor the names of its
|
|
17
|
-
// contributors may be used to endorse or promote products derived from
|
|
18
|
-
// this software without specific prior written permission.
|
|
19
|
-
//
|
|
20
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.Timestamp = void 0;
|
|
33
|
-
const protobuf_1 = require("@bufbuild/protobuf");
|
|
34
|
-
/**
|
|
35
|
-
* A Timestamp represents a point in time independent of any time zone or local
|
|
36
|
-
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
37
|
-
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
38
|
-
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
39
|
-
* Gregorian calendar backwards to year one.
|
|
40
|
-
*
|
|
41
|
-
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
42
|
-
* second table is needed for interpretation, using a [24-hour linear
|
|
43
|
-
* smear](https://developers.google.com/time/smear).
|
|
44
|
-
*
|
|
45
|
-
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
46
|
-
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
47
|
-
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
48
|
-
*
|
|
49
|
-
* # Examples
|
|
50
|
-
*
|
|
51
|
-
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
52
|
-
*
|
|
53
|
-
* Timestamp timestamp;
|
|
54
|
-
* timestamp.set_seconds(time(NULL));
|
|
55
|
-
* timestamp.set_nanos(0);
|
|
56
|
-
*
|
|
57
|
-
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
58
|
-
*
|
|
59
|
-
* struct timeval tv;
|
|
60
|
-
* gettimeofday(&tv, NULL);
|
|
61
|
-
*
|
|
62
|
-
* Timestamp timestamp;
|
|
63
|
-
* timestamp.set_seconds(tv.tv_sec);
|
|
64
|
-
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
65
|
-
*
|
|
66
|
-
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
67
|
-
*
|
|
68
|
-
* FILETIME ft;
|
|
69
|
-
* GetSystemTimeAsFileTime(&ft);
|
|
70
|
-
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
71
|
-
*
|
|
72
|
-
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
73
|
-
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
74
|
-
* Timestamp timestamp;
|
|
75
|
-
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
76
|
-
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
77
|
-
*
|
|
78
|
-
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
79
|
-
*
|
|
80
|
-
* long millis = System.currentTimeMillis();
|
|
81
|
-
*
|
|
82
|
-
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
83
|
-
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
84
|
-
*
|
|
85
|
-
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
86
|
-
*
|
|
87
|
-
* Instant now = Instant.now();
|
|
88
|
-
*
|
|
89
|
-
* Timestamp timestamp =
|
|
90
|
-
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
91
|
-
* .setNanos(now.getNano()).build();
|
|
92
|
-
*
|
|
93
|
-
* Example 6: Compute Timestamp from current time in Python.
|
|
94
|
-
*
|
|
95
|
-
* timestamp = Timestamp()
|
|
96
|
-
* timestamp.GetCurrentTime()
|
|
97
|
-
*
|
|
98
|
-
* # JSON Mapping
|
|
99
|
-
*
|
|
100
|
-
* In JSON format, the Timestamp type is encoded as a string in the
|
|
101
|
-
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
102
|
-
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
103
|
-
* where {year} is always expressed using four digits while {month}, {day},
|
|
104
|
-
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
105
|
-
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
106
|
-
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
107
|
-
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
108
|
-
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
109
|
-
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
110
|
-
*
|
|
111
|
-
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
112
|
-
* 01:30 UTC on January 15, 2017.
|
|
113
|
-
*
|
|
114
|
-
* In JavaScript, one can convert a Date object to this format using the
|
|
115
|
-
* standard
|
|
116
|
-
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
117
|
-
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
118
|
-
* to this format using
|
|
119
|
-
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
120
|
-
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
121
|
-
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
122
|
-
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
123
|
-
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* @generated from message google.protobuf.Timestamp
|
|
127
|
-
*/
|
|
128
|
-
class Timestamp extends protobuf_1.Message {
|
|
129
|
-
/**
|
|
130
|
-
* Represents seconds of UTC time since Unix epoch
|
|
131
|
-
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
132
|
-
* 9999-12-31T23:59:59Z inclusive.
|
|
133
|
-
*
|
|
134
|
-
* @generated from field: int64 seconds = 1;
|
|
135
|
-
*/
|
|
136
|
-
seconds = protobuf_1.protoInt64.zero;
|
|
137
|
-
/**
|
|
138
|
-
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
139
|
-
* second values with fractions must still have non-negative nanos values
|
|
140
|
-
* that count forward in time. Must be from 0 to 999,999,999
|
|
141
|
-
* inclusive.
|
|
142
|
-
*
|
|
143
|
-
* @generated from field: int32 nanos = 2;
|
|
144
|
-
*/
|
|
145
|
-
nanos = 0;
|
|
146
|
-
constructor(data) {
|
|
147
|
-
super();
|
|
148
|
-
protobuf_1.proto3.util.initPartial(data, this);
|
|
149
|
-
}
|
|
150
|
-
fromJson(json, options) {
|
|
151
|
-
if (typeof json !== "string") {
|
|
152
|
-
throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${protobuf_1.proto3.json.debug(json)}`);
|
|
153
|
-
}
|
|
154
|
-
const matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
|
155
|
-
if (!matches) {
|
|
156
|
-
throw new Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);
|
|
157
|
-
}
|
|
158
|
-
const ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
|
159
|
-
if (Number.isNaN(ms)) {
|
|
160
|
-
throw new Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);
|
|
161
|
-
}
|
|
162
|
-
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z")) {
|
|
163
|
-
throw new Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);
|
|
164
|
-
}
|
|
165
|
-
this.seconds = protobuf_1.protoInt64.parse(ms / 1000);
|
|
166
|
-
this.nanos = 0;
|
|
167
|
-
if (matches[7]) {
|
|
168
|
-
this.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
|
169
|
-
}
|
|
170
|
-
return this;
|
|
171
|
-
}
|
|
172
|
-
toJson(options) {
|
|
173
|
-
const ms = Number(this.seconds) * 1000;
|
|
174
|
-
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z")) {
|
|
175
|
-
throw new Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);
|
|
176
|
-
}
|
|
177
|
-
if (this.nanos < 0) {
|
|
178
|
-
throw new Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);
|
|
179
|
-
}
|
|
180
|
-
let z = "Z";
|
|
181
|
-
if (this.nanos > 0) {
|
|
182
|
-
const nanosStr = (this.nanos + 1000000000).toString().substring(1);
|
|
183
|
-
if (nanosStr.substring(3) === "000000") {
|
|
184
|
-
z = "." + nanosStr.substring(0, 3) + "Z";
|
|
185
|
-
}
|
|
186
|
-
else if (nanosStr.substring(6) === "000") {
|
|
187
|
-
z = "." + nanosStr.substring(0, 6) + "Z";
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
z = "." + nanosStr + "Z";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return new Date(ms).toISOString().replace(".000Z", z);
|
|
194
|
-
}
|
|
195
|
-
toDate() {
|
|
196
|
-
return new Date(Number(this.seconds) * 1000 + Math.ceil(this.nanos / 1000000));
|
|
197
|
-
}
|
|
198
|
-
static runtime = protobuf_1.proto3;
|
|
199
|
-
static typeName = "google.protobuf.Timestamp";
|
|
200
|
-
static fields = protobuf_1.proto3.util.newFieldList(() => [
|
|
201
|
-
{ no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
|
|
202
|
-
{ no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
|
|
203
|
-
]);
|
|
204
|
-
static now() {
|
|
205
|
-
return Timestamp.fromDate(new Date());
|
|
206
|
-
}
|
|
207
|
-
static fromDate(date) {
|
|
208
|
-
const ms = date.getTime();
|
|
209
|
-
return new Timestamp({
|
|
210
|
-
seconds: protobuf_1.protoInt64.parse(Math.floor(ms / 1000)),
|
|
211
|
-
nanos: (ms % 1000) * 1000000,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
static fromBinary(bytes, options) {
|
|
215
|
-
return new Timestamp().fromBinary(bytes, options);
|
|
216
|
-
}
|
|
217
|
-
static fromJson(jsonValue, options) {
|
|
218
|
-
return new Timestamp().fromJson(jsonValue, options);
|
|
219
|
-
}
|
|
220
|
-
static fromJsonString(jsonString, options) {
|
|
221
|
-
return new Timestamp().fromJsonString(jsonString, options);
|
|
222
|
-
}
|
|
223
|
-
static equals(a, b) {
|
|
224
|
-
return protobuf_1.proto3.util.equals(Timestamp, a, b);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
exports.Timestamp = Timestamp;
|