@replit/protocol 0.4.21 → 0.4.22
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/README.md +54 -0
- package/dist/api/client.d.ts +202 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +394 -0
- package/dist/api/features/features.d.ts +112 -0
- package/dist/api/features/features.d.ts.map +1 -0
- package/dist/api/features/features.js +199 -0
- package/dist/api/lore/lore.d.ts +543 -0
- package/dist/api/lore/lore.d.ts.map +1 -0
- package/dist/api/lore/lore.js +982 -0
- package/dist/api/lore/service.client.d.ts +283 -0
- package/dist/api/lore/service.client.d.ts.map +1 -0
- package/dist/api/lore/service.client.js +172 -0
- package/dist/api/lore/service.d.ts +1100 -0
- package/dist/api/lore/service.d.ts.map +1 -0
- package/dist/api/lore/service.js +2279 -0
- package/dist/api/powerup.d.ts +147 -0
- package/dist/api/powerup.d.ts.map +1 -0
- package/dist/api/powerup.js +286 -0
- package/dist/api/repl/repl.d.ts +552 -0
- package/dist/api/repl/repl.d.ts.map +1 -0
- package/dist/api/repl/repl.js +787 -0
- package/dist/api/signing.d.ts +618 -0
- package/dist/api/signing.d.ts.map +1 -0
- package/dist/api/signing.js +785 -0
- package/dist/api/token/token.d.ts +335 -0
- package/dist/api/token/token.d.ts.map +1 -0
- package/dist/api/token/token.js +463 -0
- package/dist/api/types.d.ts +8629 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +17225 -0
- package/dist/google/protobuf/empty.d.ts +31 -0
- package/dist/google/protobuf/empty.d.ts.map +1 -0
- package/dist/google/protobuf/empty.js +41 -0
- package/dist/google/protobuf/field_mask.d.ts +239 -0
- package/dist/google/protobuf/field_mask.d.ts.map +1 -0
- package/dist/google/protobuf/field_mask.js +83 -0
- package/dist/google/protobuf/struct.d.ts +186 -0
- package/dist/google/protobuf/struct.d.ts.map +1 -0
- package/dist/google/protobuf/struct.js +337 -0
- package/dist/google/protobuf/timestamp.d.ts +156 -0
- package/dist/google/protobuf/timestamp.d.ts.map +1 -0
- package/dist/google/protobuf/timestamp.js +132 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/package.json +3 -0
- package/iotester/index.d.ts +6 -6
- package/iotester/index.js +25 -12
- package/main/index.d.ts +6 -6
- package/main/index.js +25 -12
- package/package.json +43 -4
- package/gen.sh +0 -51
- package/jsdoc.js +0 -171
- package/pnpm-workspace.yaml +0 -6
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { WireType } from "@protobuf-ts/runtime";
|
|
2
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
3
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
4
|
+
import { isJsonObject } from "@protobuf-ts/runtime";
|
|
5
|
+
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
6
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
7
|
+
/**
|
|
8
|
+
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
9
|
+
* `Value` type union.
|
|
10
|
+
*
|
|
11
|
+
* The JSON representation for `NullValue` is JSON `null`.
|
|
12
|
+
*
|
|
13
|
+
* @generated from protobuf enum google.protobuf.NullValue
|
|
14
|
+
*/
|
|
15
|
+
export var NullValue;
|
|
16
|
+
(function (NullValue) {
|
|
17
|
+
/**
|
|
18
|
+
* Null value.
|
|
19
|
+
*
|
|
20
|
+
* @generated from protobuf enum value: NULL_VALUE = 0;
|
|
21
|
+
*/
|
|
22
|
+
NullValue[NullValue["NULL_VALUE"] = 0] = "NULL_VALUE";
|
|
23
|
+
})(NullValue || (NullValue = {}));
|
|
24
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
25
|
+
class Struct$Type extends MessageType {
|
|
26
|
+
constructor() {
|
|
27
|
+
super("google.protobuf.Struct", [
|
|
28
|
+
{ no: 1, name: "fields", kind: "map", K: 9 /*ScalarType.STRING*/, V: { kind: "message", T: () => Value } }
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Encode `Struct` to JSON object.
|
|
33
|
+
*/
|
|
34
|
+
internalJsonWrite(message, options) {
|
|
35
|
+
let json = {};
|
|
36
|
+
for (let [k, v] of Object.entries(message.fields)) {
|
|
37
|
+
json[k] = Value.toJson(v);
|
|
38
|
+
}
|
|
39
|
+
return json;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Decode `Struct` from JSON object.
|
|
43
|
+
*/
|
|
44
|
+
internalJsonRead(json, options, target) {
|
|
45
|
+
if (!isJsonObject(json))
|
|
46
|
+
throw new globalThis.Error("Unable to parse message " + this.typeName + " from JSON " + typeofJsonValue(json) + ".");
|
|
47
|
+
if (!target)
|
|
48
|
+
target = this.create();
|
|
49
|
+
for (let [k, v] of globalThis.Object.entries(json)) {
|
|
50
|
+
target.fields[k] = Value.fromJson(v);
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
}
|
|
54
|
+
create(value) {
|
|
55
|
+
const message = globalThis.Object.create((this.messagePrototype));
|
|
56
|
+
message.fields = {};
|
|
57
|
+
if (value !== undefined)
|
|
58
|
+
reflectionMergePartial(this, message, value);
|
|
59
|
+
return message;
|
|
60
|
+
}
|
|
61
|
+
internalBinaryRead(reader, length, options, target) {
|
|
62
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
63
|
+
while (reader.pos < end) {
|
|
64
|
+
let [fieldNo, wireType] = reader.tag();
|
|
65
|
+
switch (fieldNo) {
|
|
66
|
+
case /* map<string, google.protobuf.Value> fields */ 1:
|
|
67
|
+
this.binaryReadMap1(message.fields, reader, options);
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
let u = options.readUnknownField;
|
|
71
|
+
if (u === "throw")
|
|
72
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
73
|
+
let d = reader.skip(wireType);
|
|
74
|
+
if (u !== false)
|
|
75
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return message;
|
|
79
|
+
}
|
|
80
|
+
binaryReadMap1(map, reader, options) {
|
|
81
|
+
let len = reader.uint32(), end = reader.pos + len, key, val;
|
|
82
|
+
while (reader.pos < end) {
|
|
83
|
+
let [fieldNo, wireType] = reader.tag();
|
|
84
|
+
switch (fieldNo) {
|
|
85
|
+
case 1:
|
|
86
|
+
key = reader.string();
|
|
87
|
+
break;
|
|
88
|
+
case 2:
|
|
89
|
+
val = Value.internalBinaryRead(reader, reader.uint32(), options);
|
|
90
|
+
break;
|
|
91
|
+
default: throw new globalThis.Error("unknown map entry field for google.protobuf.Struct.fields");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
map[key ?? ""] = val ?? Value.create();
|
|
95
|
+
}
|
|
96
|
+
internalBinaryWrite(message, writer, options) {
|
|
97
|
+
/* map<string, google.protobuf.Value> fields = 1; */
|
|
98
|
+
for (let k of globalThis.Object.keys(message.fields)) {
|
|
99
|
+
writer.tag(1, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k);
|
|
100
|
+
writer.tag(2, WireType.LengthDelimited).fork();
|
|
101
|
+
Value.internalBinaryWrite(message.fields[k], writer, options);
|
|
102
|
+
writer.join().join();
|
|
103
|
+
}
|
|
104
|
+
let u = options.writeUnknownFields;
|
|
105
|
+
if (u !== false)
|
|
106
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
107
|
+
return writer;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @generated MessageType for protobuf message google.protobuf.Struct
|
|
112
|
+
*/
|
|
113
|
+
export const Struct = new Struct$Type();
|
|
114
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
115
|
+
class Value$Type extends MessageType {
|
|
116
|
+
constructor() {
|
|
117
|
+
super("google.protobuf.Value", [
|
|
118
|
+
{ no: 1, name: "null_value", kind: "enum", oneof: "kind", T: () => ["google.protobuf.NullValue", NullValue] },
|
|
119
|
+
{ no: 2, name: "number_value", kind: "scalar", oneof: "kind", T: 1 /*ScalarType.DOUBLE*/ },
|
|
120
|
+
{ no: 3, name: "string_value", kind: "scalar", oneof: "kind", T: 9 /*ScalarType.STRING*/ },
|
|
121
|
+
{ no: 4, name: "bool_value", kind: "scalar", oneof: "kind", T: 8 /*ScalarType.BOOL*/ },
|
|
122
|
+
{ no: 5, name: "struct_value", kind: "message", oneof: "kind", T: () => Struct },
|
|
123
|
+
{ no: 6, name: "list_value", kind: "message", oneof: "kind", T: () => ListValue }
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Encode `Value` to JSON value.
|
|
128
|
+
*/
|
|
129
|
+
internalJsonWrite(message, options) {
|
|
130
|
+
if (message.kind.oneofKind === undefined)
|
|
131
|
+
throw new globalThis.Error();
|
|
132
|
+
switch (message.kind.oneofKind) {
|
|
133
|
+
case undefined: throw new globalThis.Error();
|
|
134
|
+
case "boolValue": return message.kind.boolValue;
|
|
135
|
+
case "nullValue": return null;
|
|
136
|
+
case "numberValue":
|
|
137
|
+
let numberValue = message.kind.numberValue;
|
|
138
|
+
if (typeof numberValue == "number" && !Number.isFinite(numberValue))
|
|
139
|
+
throw new globalThis.Error();
|
|
140
|
+
return numberValue;
|
|
141
|
+
case "stringValue": return message.kind.stringValue;
|
|
142
|
+
case "listValue":
|
|
143
|
+
let listValueField = this.fields.find(f => f.no === 6);
|
|
144
|
+
if (listValueField?.kind !== "message")
|
|
145
|
+
throw new globalThis.Error();
|
|
146
|
+
return listValueField.T().toJson(message.kind.listValue);
|
|
147
|
+
case "structValue":
|
|
148
|
+
let structValueField = this.fields.find(f => f.no === 5);
|
|
149
|
+
if (structValueField?.kind !== "message")
|
|
150
|
+
throw new globalThis.Error();
|
|
151
|
+
return structValueField.T().toJson(message.kind.structValue);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Decode `Value` from JSON value.
|
|
156
|
+
*/
|
|
157
|
+
internalJsonRead(json, options, target) {
|
|
158
|
+
if (!target)
|
|
159
|
+
target = this.create();
|
|
160
|
+
switch (typeof json) {
|
|
161
|
+
case "number":
|
|
162
|
+
target.kind = { oneofKind: "numberValue", numberValue: json };
|
|
163
|
+
break;
|
|
164
|
+
case "string":
|
|
165
|
+
target.kind = { oneofKind: "stringValue", stringValue: json };
|
|
166
|
+
break;
|
|
167
|
+
case "boolean":
|
|
168
|
+
target.kind = { oneofKind: "boolValue", boolValue: json };
|
|
169
|
+
break;
|
|
170
|
+
case "object":
|
|
171
|
+
if (json === null) {
|
|
172
|
+
target.kind = { oneofKind: "nullValue", nullValue: NullValue.NULL_VALUE };
|
|
173
|
+
}
|
|
174
|
+
else if (globalThis.Array.isArray(json)) {
|
|
175
|
+
target.kind = { oneofKind: "listValue", listValue: ListValue.fromJson(json) };
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
target.kind = { oneofKind: "structValue", structValue: Struct.fromJson(json) };
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
default: throw new globalThis.Error("Unable to parse " + this.typeName + " from JSON " + typeofJsonValue(json));
|
|
182
|
+
}
|
|
183
|
+
return target;
|
|
184
|
+
}
|
|
185
|
+
create(value) {
|
|
186
|
+
const message = globalThis.Object.create((this.messagePrototype));
|
|
187
|
+
message.kind = { oneofKind: undefined };
|
|
188
|
+
if (value !== undefined)
|
|
189
|
+
reflectionMergePartial(this, message, value);
|
|
190
|
+
return message;
|
|
191
|
+
}
|
|
192
|
+
internalBinaryRead(reader, length, options, target) {
|
|
193
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
194
|
+
while (reader.pos < end) {
|
|
195
|
+
let [fieldNo, wireType] = reader.tag();
|
|
196
|
+
switch (fieldNo) {
|
|
197
|
+
case /* google.protobuf.NullValue null_value */ 1:
|
|
198
|
+
message.kind = {
|
|
199
|
+
oneofKind: "nullValue",
|
|
200
|
+
nullValue: reader.int32()
|
|
201
|
+
};
|
|
202
|
+
break;
|
|
203
|
+
case /* double number_value */ 2:
|
|
204
|
+
message.kind = {
|
|
205
|
+
oneofKind: "numberValue",
|
|
206
|
+
numberValue: reader.double()
|
|
207
|
+
};
|
|
208
|
+
break;
|
|
209
|
+
case /* string string_value */ 3:
|
|
210
|
+
message.kind = {
|
|
211
|
+
oneofKind: "stringValue",
|
|
212
|
+
stringValue: reader.string()
|
|
213
|
+
};
|
|
214
|
+
break;
|
|
215
|
+
case /* bool bool_value */ 4:
|
|
216
|
+
message.kind = {
|
|
217
|
+
oneofKind: "boolValue",
|
|
218
|
+
boolValue: reader.bool()
|
|
219
|
+
};
|
|
220
|
+
break;
|
|
221
|
+
case /* google.protobuf.Struct struct_value */ 5:
|
|
222
|
+
message.kind = {
|
|
223
|
+
oneofKind: "structValue",
|
|
224
|
+
structValue: Struct.internalBinaryRead(reader, reader.uint32(), options, message.kind.structValue)
|
|
225
|
+
};
|
|
226
|
+
break;
|
|
227
|
+
case /* google.protobuf.ListValue list_value */ 6:
|
|
228
|
+
message.kind = {
|
|
229
|
+
oneofKind: "listValue",
|
|
230
|
+
listValue: ListValue.internalBinaryRead(reader, reader.uint32(), options, message.kind.listValue)
|
|
231
|
+
};
|
|
232
|
+
break;
|
|
233
|
+
default:
|
|
234
|
+
let u = options.readUnknownField;
|
|
235
|
+
if (u === "throw")
|
|
236
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
237
|
+
let d = reader.skip(wireType);
|
|
238
|
+
if (u !== false)
|
|
239
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return message;
|
|
243
|
+
}
|
|
244
|
+
internalBinaryWrite(message, writer, options) {
|
|
245
|
+
/* google.protobuf.NullValue null_value = 1; */
|
|
246
|
+
if (message.kind.oneofKind === "nullValue")
|
|
247
|
+
writer.tag(1, WireType.Varint).int32(message.kind.nullValue);
|
|
248
|
+
/* double number_value = 2; */
|
|
249
|
+
if (message.kind.oneofKind === "numberValue")
|
|
250
|
+
writer.tag(2, WireType.Bit64).double(message.kind.numberValue);
|
|
251
|
+
/* string string_value = 3; */
|
|
252
|
+
if (message.kind.oneofKind === "stringValue")
|
|
253
|
+
writer.tag(3, WireType.LengthDelimited).string(message.kind.stringValue);
|
|
254
|
+
/* bool bool_value = 4; */
|
|
255
|
+
if (message.kind.oneofKind === "boolValue")
|
|
256
|
+
writer.tag(4, WireType.Varint).bool(message.kind.boolValue);
|
|
257
|
+
/* google.protobuf.Struct struct_value = 5; */
|
|
258
|
+
if (message.kind.oneofKind === "structValue")
|
|
259
|
+
Struct.internalBinaryWrite(message.kind.structValue, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
|
|
260
|
+
/* google.protobuf.ListValue list_value = 6; */
|
|
261
|
+
if (message.kind.oneofKind === "listValue")
|
|
262
|
+
ListValue.internalBinaryWrite(message.kind.listValue, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
|
|
263
|
+
let u = options.writeUnknownFields;
|
|
264
|
+
if (u !== false)
|
|
265
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
266
|
+
return writer;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @generated MessageType for protobuf message google.protobuf.Value
|
|
271
|
+
*/
|
|
272
|
+
export const Value = new Value$Type();
|
|
273
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
274
|
+
class ListValue$Type extends MessageType {
|
|
275
|
+
constructor() {
|
|
276
|
+
super("google.protobuf.ListValue", [
|
|
277
|
+
{ no: 1, name: "values", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Value }
|
|
278
|
+
]);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Encode `ListValue` to JSON array.
|
|
282
|
+
*/
|
|
283
|
+
internalJsonWrite(message, options) {
|
|
284
|
+
return message.values.map(v => Value.toJson(v));
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Decode `ListValue` from JSON array.
|
|
288
|
+
*/
|
|
289
|
+
internalJsonRead(json, options, target) {
|
|
290
|
+
if (!globalThis.Array.isArray(json))
|
|
291
|
+
throw new globalThis.Error("Unable to parse " + this.typeName + " from JSON " + typeofJsonValue(json));
|
|
292
|
+
if (!target)
|
|
293
|
+
target = this.create();
|
|
294
|
+
let values = json.map(v => Value.fromJson(v));
|
|
295
|
+
target.values.push(...values);
|
|
296
|
+
return target;
|
|
297
|
+
}
|
|
298
|
+
create(value) {
|
|
299
|
+
const message = globalThis.Object.create((this.messagePrototype));
|
|
300
|
+
message.values = [];
|
|
301
|
+
if (value !== undefined)
|
|
302
|
+
reflectionMergePartial(this, message, value);
|
|
303
|
+
return message;
|
|
304
|
+
}
|
|
305
|
+
internalBinaryRead(reader, length, options, target) {
|
|
306
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
307
|
+
while (reader.pos < end) {
|
|
308
|
+
let [fieldNo, wireType] = reader.tag();
|
|
309
|
+
switch (fieldNo) {
|
|
310
|
+
case /* repeated google.protobuf.Value values */ 1:
|
|
311
|
+
message.values.push(Value.internalBinaryRead(reader, reader.uint32(), options));
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
let u = options.readUnknownField;
|
|
315
|
+
if (u === "throw")
|
|
316
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
317
|
+
let d = reader.skip(wireType);
|
|
318
|
+
if (u !== false)
|
|
319
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return message;
|
|
323
|
+
}
|
|
324
|
+
internalBinaryWrite(message, writer, options) {
|
|
325
|
+
/* repeated google.protobuf.Value values = 1; */
|
|
326
|
+
for (let i = 0; i < message.values.length; i++)
|
|
327
|
+
Value.internalBinaryWrite(message.values[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
|
328
|
+
let u = options.writeUnknownFields;
|
|
329
|
+
if (u !== false)
|
|
330
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
331
|
+
return writer;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @generated MessageType for protobuf message google.protobuf.ListValue
|
|
336
|
+
*/
|
|
337
|
+
export const ListValue = new ListValue$Type();
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
2
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
3
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
4
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
5
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
6
|
+
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
7
|
+
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
8
|
+
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
9
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
10
|
+
/**
|
|
11
|
+
* A Timestamp represents a point in time independent of any time zone or local
|
|
12
|
+
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
13
|
+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
14
|
+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
15
|
+
* Gregorian calendar backwards to year one.
|
|
16
|
+
*
|
|
17
|
+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
18
|
+
* second table is needed for interpretation, using a [24-hour linear
|
|
19
|
+
* smear](https://developers.google.com/time/smear).
|
|
20
|
+
*
|
|
21
|
+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
22
|
+
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
23
|
+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
24
|
+
*
|
|
25
|
+
* # Examples
|
|
26
|
+
*
|
|
27
|
+
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
28
|
+
*
|
|
29
|
+
* Timestamp timestamp;
|
|
30
|
+
* timestamp.set_seconds(time(NULL));
|
|
31
|
+
* timestamp.set_nanos(0);
|
|
32
|
+
*
|
|
33
|
+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
34
|
+
*
|
|
35
|
+
* struct timeval tv;
|
|
36
|
+
* gettimeofday(&tv, NULL);
|
|
37
|
+
*
|
|
38
|
+
* Timestamp timestamp;
|
|
39
|
+
* timestamp.set_seconds(tv.tv_sec);
|
|
40
|
+
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
41
|
+
*
|
|
42
|
+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
43
|
+
*
|
|
44
|
+
* FILETIME ft;
|
|
45
|
+
* GetSystemTimeAsFileTime(&ft);
|
|
46
|
+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
47
|
+
*
|
|
48
|
+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
49
|
+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
50
|
+
* Timestamp timestamp;
|
|
51
|
+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
52
|
+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
53
|
+
*
|
|
54
|
+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
55
|
+
*
|
|
56
|
+
* long millis = System.currentTimeMillis();
|
|
57
|
+
*
|
|
58
|
+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
59
|
+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
60
|
+
*
|
|
61
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
62
|
+
*
|
|
63
|
+
* Instant now = Instant.now();
|
|
64
|
+
*
|
|
65
|
+
* Timestamp timestamp =
|
|
66
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
67
|
+
* .setNanos(now.getNano()).build();
|
|
68
|
+
*
|
|
69
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
70
|
+
*
|
|
71
|
+
* timestamp = Timestamp()
|
|
72
|
+
* timestamp.GetCurrentTime()
|
|
73
|
+
*
|
|
74
|
+
* # JSON Mapping
|
|
75
|
+
*
|
|
76
|
+
* In JSON format, the Timestamp type is encoded as a string in the
|
|
77
|
+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
78
|
+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
79
|
+
* where {year} is always expressed using four digits while {month}, {day},
|
|
80
|
+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
81
|
+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
82
|
+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
83
|
+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
84
|
+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
85
|
+
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
86
|
+
*
|
|
87
|
+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
88
|
+
* 01:30 UTC on January 15, 2017.
|
|
89
|
+
*
|
|
90
|
+
* In JavaScript, one can convert a Date object to this format using the
|
|
91
|
+
* standard
|
|
92
|
+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
93
|
+
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
94
|
+
* to this format using
|
|
95
|
+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
96
|
+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
97
|
+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
98
|
+
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
99
|
+
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
100
|
+
*
|
|
101
|
+
*
|
|
102
|
+
* @generated from protobuf message google.protobuf.Timestamp
|
|
103
|
+
*/
|
|
104
|
+
export interface Timestamp {
|
|
105
|
+
/**
|
|
106
|
+
* Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
|
|
107
|
+
* be between -315576000000 and 315576000000 inclusive (which corresponds to
|
|
108
|
+
* 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).
|
|
109
|
+
*
|
|
110
|
+
* @generated from protobuf field: int64 seconds = 1
|
|
111
|
+
*/
|
|
112
|
+
seconds: bigint;
|
|
113
|
+
/**
|
|
114
|
+
* Non-negative fractions of a second at nanosecond resolution. This field is
|
|
115
|
+
* the nanosecond portion of the duration, not an alternative to seconds.
|
|
116
|
+
* Negative second values with fractions must still have non-negative nanos
|
|
117
|
+
* values that count forward in time. Must be between 0 and 999,999,999
|
|
118
|
+
* inclusive.
|
|
119
|
+
*
|
|
120
|
+
* @generated from protobuf field: int32 nanos = 2
|
|
121
|
+
*/
|
|
122
|
+
nanos: number;
|
|
123
|
+
}
|
|
124
|
+
declare class Timestamp$Type extends MessageType<Timestamp> {
|
|
125
|
+
constructor();
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new `Timestamp` for the current time.
|
|
128
|
+
*/
|
|
129
|
+
now(): Timestamp;
|
|
130
|
+
/**
|
|
131
|
+
* Converts a `Timestamp` to a JavaScript Date.
|
|
132
|
+
*/
|
|
133
|
+
toDate(message: Timestamp): Date;
|
|
134
|
+
/**
|
|
135
|
+
* Converts a JavaScript Date to a `Timestamp`.
|
|
136
|
+
*/
|
|
137
|
+
fromDate(date: Date): Timestamp;
|
|
138
|
+
/**
|
|
139
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
140
|
+
* in the RFC 3339 format.
|
|
141
|
+
*/
|
|
142
|
+
internalJsonWrite(message: Timestamp, options: JsonWriteOptions): JsonValue;
|
|
143
|
+
/**
|
|
144
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
145
|
+
* in the RFC 3339 format.
|
|
146
|
+
*/
|
|
147
|
+
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Timestamp): Timestamp;
|
|
148
|
+
create(value?: PartialMessage<Timestamp>): Timestamp;
|
|
149
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Timestamp): Timestamp;
|
|
150
|
+
internalBinaryWrite(message: Timestamp, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @generated MessageType for protobuf message google.protobuf.Timestamp
|
|
154
|
+
*/
|
|
155
|
+
export declare const Timestamp: Timestamp$Type;
|
|
156
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.d.ts","sourceRoot":"","sources":["timestamp.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,MAAM,WAAW,SAAS;IACtB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,cAAe,SAAQ,WAAW,CAAC,SAAS,CAAC;;IAO/C;;OAEG;IACH,GAAG,IAAI,SAAS;IAOhB;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;IAGhC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAO/B;;;OAGG;IACH,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAG,SAAS;IAkB3E;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAmB1F,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,SAAS;IAQpD,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAsBpH,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAY7G;AACD;;GAEG;AACH,eAAO,MAAM,SAAS,gBAAuB,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { WireType } from "@protobuf-ts/runtime";
|
|
2
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
3
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
4
|
+
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
5
|
+
import { PbLong } from "@protobuf-ts/runtime";
|
|
6
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
7
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
8
|
+
class Timestamp$Type extends MessageType {
|
|
9
|
+
constructor() {
|
|
10
|
+
super("google.protobuf.Timestamp", [
|
|
11
|
+
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
12
|
+
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new `Timestamp` for the current time.
|
|
17
|
+
*/
|
|
18
|
+
now() {
|
|
19
|
+
const msg = this.create();
|
|
20
|
+
const ms = Date.now();
|
|
21
|
+
msg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();
|
|
22
|
+
msg.nanos = (ms % 1000) * 1000000;
|
|
23
|
+
return msg;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts a `Timestamp` to a JavaScript Date.
|
|
27
|
+
*/
|
|
28
|
+
toDate(message) {
|
|
29
|
+
return new Date(PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts a JavaScript Date to a `Timestamp`.
|
|
33
|
+
*/
|
|
34
|
+
fromDate(date) {
|
|
35
|
+
const msg = this.create();
|
|
36
|
+
const ms = date.getTime();
|
|
37
|
+
msg.seconds = PbLong.from(Math.floor(ms / 1000)).toBigInt();
|
|
38
|
+
msg.nanos = ((ms % 1000) + (ms < 0 && ms % 1000 !== 0 ? 1000 : 0)) * 1000000;
|
|
39
|
+
return msg;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
43
|
+
* in the RFC 3339 format.
|
|
44
|
+
*/
|
|
45
|
+
internalJsonWrite(message, options) {
|
|
46
|
+
let ms = PbLong.from(message.seconds).toNumber() * 1000;
|
|
47
|
+
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
|
48
|
+
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
|
49
|
+
if (message.nanos < 0)
|
|
50
|
+
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
|
51
|
+
let z = "Z";
|
|
52
|
+
if (message.nanos > 0) {
|
|
53
|
+
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
|
54
|
+
if (nanosStr.substring(3) === "000000")
|
|
55
|
+
z = "." + nanosStr.substring(0, 3) + "Z";
|
|
56
|
+
else if (nanosStr.substring(6) === "000")
|
|
57
|
+
z = "." + nanosStr.substring(0, 6) + "Z";
|
|
58
|
+
else
|
|
59
|
+
z = "." + nanosStr + "Z";
|
|
60
|
+
}
|
|
61
|
+
return new Date(ms).toISOString().replace(".000Z", z);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
65
|
+
* in the RFC 3339 format.
|
|
66
|
+
*/
|
|
67
|
+
internalJsonRead(json, options, target) {
|
|
68
|
+
if (typeof json !== "string")
|
|
69
|
+
throw new Error("Unable to parse Timestamp from JSON " + typeofJsonValue(json) + ".");
|
|
70
|
+
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]))$/);
|
|
71
|
+
if (!matches)
|
|
72
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
|
73
|
+
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
|
74
|
+
if (Number.isNaN(ms))
|
|
75
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
|
76
|
+
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
|
77
|
+
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.");
|
|
78
|
+
if (!target)
|
|
79
|
+
target = this.create();
|
|
80
|
+
target.seconds = PbLong.from(ms / 1000).toBigInt();
|
|
81
|
+
target.nanos = 0;
|
|
82
|
+
if (matches[7])
|
|
83
|
+
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
|
84
|
+
return target;
|
|
85
|
+
}
|
|
86
|
+
create(value) {
|
|
87
|
+
const message = globalThis.Object.create((this.messagePrototype));
|
|
88
|
+
message.seconds = 0n;
|
|
89
|
+
message.nanos = 0;
|
|
90
|
+
if (value !== undefined)
|
|
91
|
+
reflectionMergePartial(this, message, value);
|
|
92
|
+
return message;
|
|
93
|
+
}
|
|
94
|
+
internalBinaryRead(reader, length, options, target) {
|
|
95
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
96
|
+
while (reader.pos < end) {
|
|
97
|
+
let [fieldNo, wireType] = reader.tag();
|
|
98
|
+
switch (fieldNo) {
|
|
99
|
+
case /* int64 seconds */ 1:
|
|
100
|
+
message.seconds = reader.int64().toBigInt();
|
|
101
|
+
break;
|
|
102
|
+
case /* int32 nanos */ 2:
|
|
103
|
+
message.nanos = reader.int32();
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
let u = options.readUnknownField;
|
|
107
|
+
if (u === "throw")
|
|
108
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
109
|
+
let d = reader.skip(wireType);
|
|
110
|
+
if (u !== false)
|
|
111
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return message;
|
|
115
|
+
}
|
|
116
|
+
internalBinaryWrite(message, writer, options) {
|
|
117
|
+
/* int64 seconds = 1; */
|
|
118
|
+
if (message.seconds !== 0n)
|
|
119
|
+
writer.tag(1, WireType.Varint).int64(message.seconds);
|
|
120
|
+
/* int32 nanos = 2; */
|
|
121
|
+
if (message.nanos !== 0)
|
|
122
|
+
writer.tag(2, WireType.Varint).int32(message.nanos);
|
|
123
|
+
let u = options.writeUnknownFields;
|
|
124
|
+
if (u !== false)
|
|
125
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
126
|
+
return writer;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @generated MessageType for protobuf message google.protobuf.Timestamp
|
|
131
|
+
*/
|
|
132
|
+
export const Timestamp = new Timestamp$Type();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './api/types.js';
|
|
2
|
+
export * from './api/client.js';
|
|
3
|
+
export * from './api/signing.js';
|
|
4
|
+
export * from './api/token/token.js';
|
|
5
|
+
export * from './api/lore/lore.js';
|
|
6
|
+
export * from './api/features/features.js';
|
|
7
|
+
export * from './api/powerup.js';
|
|
8
|
+
export * from './google/protobuf/timestamp.js';
|
|
9
|
+
export * from './google/protobuf/struct.js';
|
|
10
|
+
export * from './google/protobuf/empty.js';
|
|
11
|
+
export * from './google/protobuf/field_mask.js';
|
|
12
|
+
export * as LoreService from './api/lore/service.js';
|
|
13
|
+
export * as ReplApi from './api/repl/repl.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Re-export all types from proto files
|
|
2
|
+
export * from './api/types.js';
|
|
3
|
+
export * from './api/client.js';
|
|
4
|
+
export * from './api/signing.js';
|
|
5
|
+
export * from './api/token/token.js';
|
|
6
|
+
export * from './api/lore/lore.js';
|
|
7
|
+
export * from './api/features/features.js';
|
|
8
|
+
export * from './api/powerup.js';
|
|
9
|
+
export * from './google/protobuf/timestamp.js';
|
|
10
|
+
export * from './google/protobuf/struct.js';
|
|
11
|
+
export * from './google/protobuf/empty.js';
|
|
12
|
+
export * from './google/protobuf/field_mask.js';
|
|
13
|
+
// Namespace exports to avoid naming conflicts
|
|
14
|
+
// Both lore/service and repl/repl export Buckets and Repl
|
|
15
|
+
export * as LoreService from './api/lore/service.js';
|
|
16
|
+
export * as ReplApi from './api/repl/repl.js';
|