@meshagent/meshagent 0.42.2 → 0.43.0
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/CHANGELOG.md +7 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +3 -3
- package/dist/browser/containers-client.js +76 -76
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +3 -3
- package/dist/esm/containers-client.js +82 -87
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +3 -3
- package/dist/node/containers-client.js +76 -76
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatasetsClient = exports.DatasetUuid = exports.DatasetJson = exports.DatasetStruct = exports.DatasetDate = exports.DatasetExpression = exports.DatasetValueEncoder = void 0;
|
|
4
4
|
const apache_arrow_1 = require("apache-arrow");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
6
|
+
const response_js_1 = require("./response.js");
|
|
7
7
|
const ARROW_IPC_STREAM_MIME_TYPE = "application/vnd.apache.arrow.stream";
|
|
8
8
|
class DatasetValueEncoder {
|
|
9
9
|
}
|
|
@@ -88,7 +88,7 @@ const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
|
88
88
|
function normalizeUuidHex(value) {
|
|
89
89
|
const normalized = value.trim().toLowerCase().replace(/-/g, "");
|
|
90
90
|
if (!UUID_HEX_REGEX.test(normalized)) {
|
|
91
|
-
throw new
|
|
91
|
+
throw new room_server_client_js_1.RoomServerException("invalid uuid format");
|
|
92
92
|
}
|
|
93
93
|
return normalized;
|
|
94
94
|
}
|
|
@@ -191,7 +191,7 @@ function encodeRecordValue(value) {
|
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
if (isRecord(value)) {
|
|
194
|
-
throw new
|
|
194
|
+
throw new room_server_client_js_1.RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
|
|
195
195
|
}
|
|
196
196
|
return value;
|
|
197
197
|
}
|
|
@@ -216,62 +216,62 @@ function datasetSqlLiteral(value) {
|
|
|
216
216
|
}
|
|
217
217
|
function decodeRecordValue(value) {
|
|
218
218
|
if (Array.isArray(value)) {
|
|
219
|
-
throw new
|
|
219
|
+
throw new room_server_client_js_1.RoomServerException("dataset list values must use a {'list': [...]} wrapper");
|
|
220
220
|
}
|
|
221
221
|
if (!isRecord(value)) {
|
|
222
222
|
return value;
|
|
223
223
|
}
|
|
224
224
|
const entries = Object.entries(value);
|
|
225
225
|
if (entries.length !== 1) {
|
|
226
|
-
throw new
|
|
226
|
+
throw new room_server_client_js_1.RoomServerException("dataset object values must use a single-key type wrapper");
|
|
227
227
|
}
|
|
228
228
|
const [wrapper, payload] = entries[0];
|
|
229
229
|
switch (wrapper) {
|
|
230
230
|
case "binary":
|
|
231
231
|
if (typeof payload !== "string") {
|
|
232
|
-
throw new
|
|
232
|
+
throw new room_server_client_js_1.RoomServerException("dataset binary values must be base64 strings");
|
|
233
233
|
}
|
|
234
234
|
return base64ToBytes(payload);
|
|
235
235
|
case "uuid":
|
|
236
236
|
if (typeof payload !== "string") {
|
|
237
|
-
throw new
|
|
237
|
+
throw new room_server_client_js_1.RoomServerException("dataset uuid values must be strings");
|
|
238
238
|
}
|
|
239
239
|
return new DatasetUuid(payload);
|
|
240
240
|
case "expression":
|
|
241
241
|
if (typeof payload !== "string") {
|
|
242
|
-
throw new
|
|
242
|
+
throw new room_server_client_js_1.RoomServerException("dataset expression values must be strings");
|
|
243
243
|
}
|
|
244
244
|
return new DatasetExpression(payload);
|
|
245
245
|
case "date":
|
|
246
246
|
if (typeof payload !== "string") {
|
|
247
|
-
throw new
|
|
247
|
+
throw new room_server_client_js_1.RoomServerException("dataset date values must be strings");
|
|
248
248
|
}
|
|
249
249
|
return new DatasetDate(payload);
|
|
250
250
|
case "timestamp":
|
|
251
251
|
if (typeof payload !== "string") {
|
|
252
|
-
throw new
|
|
252
|
+
throw new room_server_client_js_1.RoomServerException("dataset timestamp values must be strings");
|
|
253
253
|
}
|
|
254
254
|
{
|
|
255
255
|
const parsed = new Date(payload);
|
|
256
256
|
if (Number.isNaN(parsed.getTime())) {
|
|
257
|
-
throw new
|
|
257
|
+
throw new room_server_client_js_1.RoomServerException("dataset timestamp value is not valid");
|
|
258
258
|
}
|
|
259
259
|
return parsed;
|
|
260
260
|
}
|
|
261
261
|
case "list":
|
|
262
262
|
if (!Array.isArray(payload)) {
|
|
263
|
-
throw new
|
|
263
|
+
throw new room_server_client_js_1.RoomServerException("dataset list values must be arrays");
|
|
264
264
|
}
|
|
265
265
|
return payload.map((item) => decodeRecordValue(item));
|
|
266
266
|
case "struct":
|
|
267
267
|
if (!isRecord(payload)) {
|
|
268
|
-
throw new
|
|
268
|
+
throw new room_server_client_js_1.RoomServerException("dataset struct values must be objects");
|
|
269
269
|
}
|
|
270
270
|
return new DatasetStruct(Object.fromEntries(Object.entries(payload).map(([key, item]) => [key, decodeRecordValue(item)])));
|
|
271
271
|
case "json":
|
|
272
272
|
return new DatasetJson(normalizeDatasetJsonValue(payload));
|
|
273
273
|
default:
|
|
274
|
-
throw new
|
|
274
|
+
throw new room_server_client_js_1.RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
function encodeDatasetRecord(record) {
|
|
@@ -290,28 +290,28 @@ function rowsChunk(records) {
|
|
|
290
290
|
}
|
|
291
291
|
function recordsFromRowsChunk(payload, operation) {
|
|
292
292
|
if (!isRecord(payload) || payload.kind !== "rows" || !Array.isArray(payload.rows)) {
|
|
293
|
-
throw new
|
|
293
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
294
294
|
}
|
|
295
295
|
return payload.rows.map((row) => {
|
|
296
296
|
if (!isRecord(row) || !Array.isArray(row.columns)) {
|
|
297
|
-
throw new
|
|
297
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
298
298
|
}
|
|
299
299
|
return Object.fromEntries(row.columns.map((column) => {
|
|
300
300
|
if (!isRecord(column) || typeof column.name !== "string") {
|
|
301
|
-
throw new
|
|
301
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
302
302
|
}
|
|
303
303
|
try {
|
|
304
304
|
return [column.name, decodeRecordValue(column.value)];
|
|
305
305
|
}
|
|
306
306
|
catch {
|
|
307
|
-
throw new
|
|
307
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
308
308
|
}
|
|
309
309
|
}));
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
function rowChunkList(records, rowsPerChunk = 128) {
|
|
313
313
|
if (rowsPerChunk <= 0) {
|
|
314
|
-
throw new
|
|
314
|
+
throw new room_server_client_js_1.RoomServerException("rowsPerChunk must be greater than zero");
|
|
315
315
|
}
|
|
316
316
|
const chunks = [];
|
|
317
317
|
for (let index = 0; index < records.length; index += rowsPerChunk) {
|
|
@@ -346,14 +346,14 @@ function normalizeTableRefs(tables) {
|
|
|
346
346
|
}
|
|
347
347
|
function tableIndexFromJson(value) {
|
|
348
348
|
if (!isRecord(value) || typeof value.name !== "string" || typeof value.type !== "string" || !Array.isArray(value.columns)) {
|
|
349
|
-
throw new
|
|
349
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_indexes");
|
|
350
350
|
}
|
|
351
351
|
return {
|
|
352
352
|
name: value.name,
|
|
353
353
|
type: value.type,
|
|
354
354
|
columns: value.columns.map((column) => {
|
|
355
355
|
if (typeof column !== "string") {
|
|
356
|
-
throw new
|
|
356
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_indexes");
|
|
357
357
|
}
|
|
358
358
|
return column;
|
|
359
359
|
}),
|
|
@@ -368,7 +368,7 @@ function tableIndexFromJson(value) {
|
|
|
368
368
|
}
|
|
369
369
|
function optimizeResultFromJson(value) {
|
|
370
370
|
if (!isRecord(value)) {
|
|
371
|
-
throw new
|
|
371
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.optimize");
|
|
372
372
|
}
|
|
373
373
|
return {
|
|
374
374
|
compaction: typeof value.compaction_json === "string" ? JSON.parse(value.compaction_json) : isRecord(value.compaction) ? value.compaction : null,
|
|
@@ -378,32 +378,32 @@ function optimizeResultFromJson(value) {
|
|
|
378
378
|
}
|
|
379
379
|
function tableStatsFromJson(value) {
|
|
380
380
|
if (!isRecord(value)) {
|
|
381
|
-
throw new
|
|
381
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.stats");
|
|
382
382
|
}
|
|
383
383
|
const dataset = typeof value.dataset_json === "string" ? JSON.parse(value.dataset_json) : value.dataset;
|
|
384
384
|
const data = typeof value.data_json === "string" ? JSON.parse(value.data_json) : value.data;
|
|
385
385
|
if (!isRecord(dataset) || !isRecord(data)) {
|
|
386
|
-
throw new
|
|
386
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.stats");
|
|
387
387
|
}
|
|
388
388
|
return { dataset, data };
|
|
389
389
|
}
|
|
390
390
|
function tableVersionFromJson(value) {
|
|
391
391
|
if (!isRecord(value) || typeof value.metadata_json !== "string" || typeof value.timestamp !== "string" || typeof value.version !== "number") {
|
|
392
|
-
throw new
|
|
392
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
393
393
|
}
|
|
394
394
|
const timestamp = new Date(value.timestamp);
|
|
395
395
|
if (Number.isNaN(timestamp.getTime())) {
|
|
396
|
-
throw new
|
|
396
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
397
397
|
}
|
|
398
398
|
let metadata;
|
|
399
399
|
try {
|
|
400
400
|
metadata = JSON.parse(value.metadata_json);
|
|
401
401
|
}
|
|
402
402
|
catch (_) {
|
|
403
|
-
throw new
|
|
403
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
404
404
|
}
|
|
405
405
|
if (!isRecord(metadata)) {
|
|
406
|
-
throw new
|
|
406
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
407
407
|
}
|
|
408
408
|
return {
|
|
409
409
|
version: value.version,
|
|
@@ -413,27 +413,27 @@ function tableVersionFromJson(value) {
|
|
|
413
413
|
}
|
|
414
414
|
function tableBranchFromJson(value) {
|
|
415
415
|
if (!isRecord(value) || typeof value.name !== "string") {
|
|
416
|
-
throw new
|
|
416
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
417
417
|
}
|
|
418
418
|
if (value.parent_branch != null && typeof value.parent_branch !== "string") {
|
|
419
|
-
throw new
|
|
419
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
420
420
|
}
|
|
421
421
|
if (value.parent_version != null
|
|
422
422
|
&& (typeof value.parent_version !== "number" || !Number.isInteger(value.parent_version))) {
|
|
423
|
-
throw new
|
|
423
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
424
424
|
}
|
|
425
425
|
if (value.manifest_size != null
|
|
426
426
|
&& (typeof value.manifest_size !== "number" || !Number.isInteger(value.manifest_size))) {
|
|
427
|
-
throw new
|
|
427
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
428
428
|
}
|
|
429
429
|
let createdAt = null;
|
|
430
430
|
if (value.created_at != null) {
|
|
431
431
|
if (typeof value.created_at !== "string") {
|
|
432
|
-
throw new
|
|
432
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
433
433
|
}
|
|
434
434
|
createdAt = new Date(value.created_at);
|
|
435
435
|
if (Number.isNaN(createdAt.getTime())) {
|
|
436
|
-
throw new
|
|
436
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
return {
|
|
@@ -499,7 +499,7 @@ class DatasetWriteInputStream {
|
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
501
|
async *stream() {
|
|
502
|
-
yield new
|
|
502
|
+
yield new response_js_1.JsonContent({ json: this.start });
|
|
503
503
|
while (!this.closed) {
|
|
504
504
|
await this.waitForPull();
|
|
505
505
|
if (this.closed) {
|
|
@@ -512,7 +512,7 @@ class DatasetWriteInputStream {
|
|
|
512
512
|
if (nextChunk.value.length === 0) {
|
|
513
513
|
continue;
|
|
514
514
|
}
|
|
515
|
-
yield new
|
|
515
|
+
yield new response_js_1.JsonContent({ json: rowsChunk(nextChunk.value) });
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
}
|
|
@@ -533,7 +533,7 @@ function schemaToIPC(schema) {
|
|
|
533
533
|
function tableFromIPCBytes(data) {
|
|
534
534
|
const table = (0, apache_arrow_1.tableFromIPC)(data);
|
|
535
535
|
if (table instanceof Promise) {
|
|
536
|
-
throw new
|
|
536
|
+
throw new room_server_client_js_1.RoomServerException("unexpected async Arrow IPC result");
|
|
537
537
|
}
|
|
538
538
|
return table;
|
|
539
539
|
}
|
|
@@ -591,7 +591,7 @@ class DatasetArrowWriteInputStream {
|
|
|
591
591
|
});
|
|
592
592
|
}
|
|
593
593
|
async *stream() {
|
|
594
|
-
yield new
|
|
594
|
+
yield new response_js_1.BinaryContent({
|
|
595
595
|
data: this.schema == null ? new Uint8Array() : schemaToIPC(this.schema),
|
|
596
596
|
headers: this.start,
|
|
597
597
|
});
|
|
@@ -607,7 +607,7 @@ class DatasetArrowWriteInputStream {
|
|
|
607
607
|
if (nextChunk.value.numRows === 0) {
|
|
608
608
|
continue;
|
|
609
609
|
}
|
|
610
|
-
yield new
|
|
610
|
+
yield new response_js_1.BinaryContent({
|
|
611
611
|
data: (0, apache_arrow_1.tableToIPC)(nextChunk.value, "stream"),
|
|
612
612
|
headers: { kind: "data", content_type: ARROW_IPC_STREAM_MIME_TYPE },
|
|
613
613
|
});
|
|
@@ -655,13 +655,13 @@ class DatasetReadInputStream {
|
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
657
|
async *stream() {
|
|
658
|
-
yield new
|
|
658
|
+
yield new response_js_1.JsonContent({ json: this.start });
|
|
659
659
|
while (!this.closed) {
|
|
660
660
|
await this.waitForPull();
|
|
661
661
|
if (this.closed) {
|
|
662
662
|
return;
|
|
663
663
|
}
|
|
664
|
-
yield new
|
|
664
|
+
yield new response_js_1.JsonContent({ json: { kind: "pull" } });
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
}
|
|
@@ -706,13 +706,13 @@ class DatasetArrowReadInputStream {
|
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
708
|
async *stream() {
|
|
709
|
-
yield new
|
|
709
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: this.start });
|
|
710
710
|
while (!this.closed) {
|
|
711
711
|
await this.waitForPull();
|
|
712
712
|
if (this.closed) {
|
|
713
713
|
return;
|
|
714
714
|
}
|
|
715
|
-
yield new
|
|
715
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
718
|
}
|
|
@@ -721,11 +721,11 @@ class DatasetsClient {
|
|
|
721
721
|
this.room = room;
|
|
722
722
|
}
|
|
723
723
|
_unexpectedResponseError(operation) {
|
|
724
|
-
return new
|
|
724
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
725
725
|
}
|
|
726
726
|
async invoke(operation, input) {
|
|
727
727
|
const response = await this.room.invoke({ toolkit: "dataset", tool: operation, input });
|
|
728
|
-
if (response instanceof
|
|
728
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
729
729
|
return response;
|
|
730
730
|
}
|
|
731
731
|
if (response == null) {
|
|
@@ -743,23 +743,23 @@ class DatasetsClient {
|
|
|
743
743
|
const response = await this.invokeStream(operation, input.stream());
|
|
744
744
|
try {
|
|
745
745
|
for await (const chunk of response) {
|
|
746
|
-
if (chunk instanceof
|
|
747
|
-
throw new
|
|
746
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
747
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
748
748
|
}
|
|
749
|
-
if (chunk instanceof
|
|
749
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
750
750
|
if (chunk.method === "close") {
|
|
751
751
|
return;
|
|
752
752
|
}
|
|
753
753
|
throw this._unexpectedResponseError(operation);
|
|
754
754
|
}
|
|
755
|
-
if (chunk instanceof
|
|
755
|
+
if (chunk instanceof response_js_1.BinaryContent) {
|
|
756
756
|
if (chunk.headers.kind !== "pull") {
|
|
757
757
|
throw this._unexpectedResponseError(operation);
|
|
758
758
|
}
|
|
759
759
|
input.requestNext();
|
|
760
760
|
continue;
|
|
761
761
|
}
|
|
762
|
-
if (!(chunk instanceof
|
|
762
|
+
if (!(chunk instanceof response_js_1.JsonContent) || chunk.json.kind !== "pull") {
|
|
763
763
|
throw this._unexpectedResponseError(operation);
|
|
764
764
|
}
|
|
765
765
|
input.requestNext();
|
|
@@ -775,16 +775,16 @@ class DatasetsClient {
|
|
|
775
775
|
input.requestNext();
|
|
776
776
|
try {
|
|
777
777
|
for await (const chunk of response) {
|
|
778
|
-
if (chunk instanceof
|
|
779
|
-
throw new
|
|
778
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
779
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
780
780
|
}
|
|
781
|
-
if (chunk instanceof
|
|
781
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
782
782
|
if (chunk.method === "close") {
|
|
783
783
|
return;
|
|
784
784
|
}
|
|
785
785
|
throw this._unexpectedResponseError(operation);
|
|
786
786
|
}
|
|
787
|
-
if (!(chunk instanceof
|
|
787
|
+
if (!(chunk instanceof response_js_1.JsonContent)) {
|
|
788
788
|
throw this._unexpectedResponseError(operation);
|
|
789
789
|
}
|
|
790
790
|
yield recordsFromRowsChunk(chunk.json, operation);
|
|
@@ -801,16 +801,16 @@ class DatasetsClient {
|
|
|
801
801
|
input.requestNext();
|
|
802
802
|
try {
|
|
803
803
|
for await (const chunk of response) {
|
|
804
|
-
if (chunk instanceof
|
|
805
|
-
throw new
|
|
804
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
805
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
806
806
|
}
|
|
807
|
-
if (chunk instanceof
|
|
807
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
808
808
|
if (chunk.method === "close") {
|
|
809
809
|
return;
|
|
810
810
|
}
|
|
811
811
|
throw this._unexpectedResponseError(operation);
|
|
812
812
|
}
|
|
813
|
-
if (!(chunk instanceof
|
|
813
|
+
if (!(chunk instanceof response_js_1.BinaryContent) || chunk.headers.kind !== "data") {
|
|
814
814
|
throw this._unexpectedResponseError(operation);
|
|
815
815
|
}
|
|
816
816
|
yield tableFromIPCBytes(chunk.data);
|
|
@@ -826,7 +826,7 @@ class DatasetsClient {
|
|
|
826
826
|
namespace: namespace ?? null,
|
|
827
827
|
branch: branch ?? null,
|
|
828
828
|
});
|
|
829
|
-
if (!(response instanceof
|
|
829
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
830
830
|
throw this._unexpectedResponseError("list_tables");
|
|
831
831
|
}
|
|
832
832
|
return Array.isArray(response.json.tables) ? response.json.tables : [];
|
|
@@ -973,7 +973,7 @@ class DatasetsClient {
|
|
|
973
973
|
}
|
|
974
974
|
async addColumns({ table, newColumns, namespace, branch }) {
|
|
975
975
|
if (newColumns instanceof apache_arrow_1.Schema) {
|
|
976
|
-
await this.invokeContent("add_columns", new
|
|
976
|
+
await this.invokeContent("add_columns", new response_js_1.BinaryContent({
|
|
977
977
|
data: schemaToIPC(newColumns),
|
|
978
978
|
headers: {
|
|
979
979
|
table,
|
|
@@ -1064,7 +1064,7 @@ class DatasetsClient {
|
|
|
1064
1064
|
return tableFromChunks(await this.sql({ query, tables, params, namespace, branch }));
|
|
1065
1065
|
}
|
|
1066
1066
|
async openSqlQuery({ query, tables, params, namespace, branch }) {
|
|
1067
|
-
const response = await this.invokeContent("open_sql_query", new
|
|
1067
|
+
const response = await this.invokeContent("open_sql_query", new response_js_1.BinaryContent({
|
|
1068
1068
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
1069
1069
|
headers: {
|
|
1070
1070
|
query,
|
|
@@ -1073,7 +1073,7 @@ class DatasetsClient {
|
|
|
1073
1073
|
branch: branch ?? null,
|
|
1074
1074
|
},
|
|
1075
1075
|
}));
|
|
1076
|
-
if (!(response instanceof
|
|
1076
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
1077
1077
|
throw this._unexpectedResponseError("open_sql_query");
|
|
1078
1078
|
}
|
|
1079
1079
|
const queryId = response.headers.query_id;
|
|
@@ -1087,7 +1087,7 @@ class DatasetsClient {
|
|
|
1087
1087
|
};
|
|
1088
1088
|
}
|
|
1089
1089
|
async executeSql({ query, tables, params, namespace, branch }) {
|
|
1090
|
-
const response = await this.invokeContent("execute_sql", new
|
|
1090
|
+
const response = await this.invokeContent("execute_sql", new response_js_1.BinaryContent({
|
|
1091
1091
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
1092
1092
|
headers: {
|
|
1093
1093
|
query,
|
|
@@ -1096,7 +1096,7 @@ class DatasetsClient {
|
|
|
1096
1096
|
branch: branch ?? null,
|
|
1097
1097
|
},
|
|
1098
1098
|
}));
|
|
1099
|
-
if (response instanceof
|
|
1099
|
+
if (response instanceof response_js_1.BinaryContent) {
|
|
1100
1100
|
if (response.headers.kind !== "query") {
|
|
1101
1101
|
throw this._unexpectedResponseError("execute_sql");
|
|
1102
1102
|
}
|
|
@@ -1110,7 +1110,7 @@ class DatasetsClient {
|
|
|
1110
1110
|
queryId,
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
|
-
if (response instanceof
|
|
1113
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
1114
1114
|
if (response.json.kind !== "statement"
|
|
1115
1115
|
|| typeof response.json.rows_affected !== "number"
|
|
1116
1116
|
|| !Number.isInteger(response.json.rows_affected)) {
|
|
@@ -1126,7 +1126,7 @@ class DatasetsClient {
|
|
|
1126
1126
|
async *sqlStream({ query, tables, params, namespace, branch }) {
|
|
1127
1127
|
const result = await this.executeSql({ query, tables, params, namespace, branch });
|
|
1128
1128
|
if (result.kind === "statement") {
|
|
1129
|
-
throw new
|
|
1129
|
+
throw new room_server_client_js_1.RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
|
|
1130
1130
|
}
|
|
1131
1131
|
const opened = result;
|
|
1132
1132
|
try {
|
|
@@ -1144,20 +1144,20 @@ class DatasetsClient {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
async closeSqlQuery({ queryId }) {
|
|
1146
1146
|
const response = await this.room.invoke({ toolkit: "dataset", tool: "close_sql_query", input: { query_id: queryId } });
|
|
1147
|
-
if (!(response instanceof
|
|
1147
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
1148
1148
|
throw this._unexpectedResponseError("close_sql_query");
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
async cancelSqlQuery({ queryId }) {
|
|
1152
1152
|
const response = await this.room.invoke({ toolkit: "dataset", tool: "cancel_sql_query", input: { query_id: queryId } });
|
|
1153
|
-
if (!(response instanceof
|
|
1153
|
+
if (!(response instanceof response_js_1.JsonContent)
|
|
1154
1154
|
|| !["cancelled", "cancelling", "not_cancellable"].includes(response.json.status)) {
|
|
1155
1155
|
throw this._unexpectedResponseError("cancel_sql_query");
|
|
1156
1156
|
}
|
|
1157
1157
|
return { status: response.json.status };
|
|
1158
1158
|
}
|
|
1159
1159
|
async executeSqlStatement({ query, tables, params, namespace, branch }) {
|
|
1160
|
-
const response = await this.invokeContent("execute_sql_statement", new
|
|
1160
|
+
const response = await this.invokeContent("execute_sql_statement", new response_js_1.BinaryContent({
|
|
1161
1161
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
1162
1162
|
headers: {
|
|
1163
1163
|
query,
|
|
@@ -1166,7 +1166,7 @@ class DatasetsClient {
|
|
|
1166
1166
|
branch: branch ?? null,
|
|
1167
1167
|
},
|
|
1168
1168
|
}));
|
|
1169
|
-
if (!(response instanceof
|
|
1169
|
+
if (!(response instanceof response_js_1.JsonContent)
|
|
1170
1170
|
|| typeof response.json.rows_affected !== "number"
|
|
1171
1171
|
|| !Number.isInteger(response.json.rows_affected)) {
|
|
1172
1172
|
throw this._unexpectedResponseError("execute_sql_statement");
|
|
@@ -1233,16 +1233,16 @@ class DatasetsClient {
|
|
|
1233
1233
|
input.requestNext();
|
|
1234
1234
|
try {
|
|
1235
1235
|
for await (const chunk of response) {
|
|
1236
|
-
if (chunk instanceof
|
|
1237
|
-
throw new
|
|
1236
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
1237
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
1238
1238
|
}
|
|
1239
|
-
if (chunk instanceof
|
|
1239
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
1240
1240
|
if (chunk.method === "close") {
|
|
1241
1241
|
return;
|
|
1242
1242
|
}
|
|
1243
1243
|
throw this._unexpectedResponseError("watch_table");
|
|
1244
1244
|
}
|
|
1245
|
-
if (chunk instanceof
|
|
1245
|
+
if (chunk instanceof response_js_1.BinaryContent) {
|
|
1246
1246
|
if (chunk.headers.kind !== "data") {
|
|
1247
1247
|
throw this._unexpectedResponseError("watch_table");
|
|
1248
1248
|
}
|
|
@@ -1260,7 +1260,7 @@ class DatasetsClient {
|
|
|
1260
1260
|
input.requestNext();
|
|
1261
1261
|
continue;
|
|
1262
1262
|
}
|
|
1263
|
-
if (chunk instanceof
|
|
1263
|
+
if (chunk instanceof response_js_1.JsonContent) {
|
|
1264
1264
|
if (!isRecord(chunk.json)) {
|
|
1265
1265
|
throw this._unexpectedResponseError("watch_table");
|
|
1266
1266
|
}
|
|
@@ -1299,7 +1299,7 @@ class DatasetsClient {
|
|
|
1299
1299
|
branch: branch ?? null,
|
|
1300
1300
|
version: version ?? null,
|
|
1301
1301
|
});
|
|
1302
|
-
if (!(response instanceof
|
|
1302
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
|
|
1303
1303
|
throw this._unexpectedResponseError("count");
|
|
1304
1304
|
}
|
|
1305
1305
|
return response.json.count;
|
|
@@ -1315,7 +1315,7 @@ class DatasetsClient {
|
|
|
1315
1315
|
version: version ?? null,
|
|
1316
1316
|
},
|
|
1317
1317
|
});
|
|
1318
|
-
if (!(response instanceof
|
|
1318
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
1319
1319
|
throw this._unexpectedResponseError("inspect");
|
|
1320
1320
|
}
|
|
1321
1321
|
return tableFromIPCBytes(response.data).schema;
|
|
@@ -1331,7 +1331,7 @@ class DatasetsClient {
|
|
|
1331
1331
|
branch: branch ?? null,
|
|
1332
1332
|
config: config ?? null,
|
|
1333
1333
|
});
|
|
1334
|
-
if (!(response instanceof
|
|
1334
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
1335
1335
|
throw this._unexpectedResponseError("optimize");
|
|
1336
1336
|
}
|
|
1337
1337
|
return optimizeResultFromJson(response.json);
|
|
@@ -1344,7 +1344,7 @@ class DatasetsClient {
|
|
|
1344
1344
|
version: version ?? null,
|
|
1345
1345
|
max_rows_per_group: maxRowsPerGroup ?? null,
|
|
1346
1346
|
});
|
|
1347
|
-
if (!(response instanceof
|
|
1347
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
1348
1348
|
throw this._unexpectedResponseError("stats");
|
|
1349
1349
|
}
|
|
1350
1350
|
return tableStatsFromJson(response.json);
|
|
@@ -1362,7 +1362,7 @@ class DatasetsClient {
|
|
|
1362
1362
|
namespace: namespace ?? null,
|
|
1363
1363
|
branch: branch ?? null,
|
|
1364
1364
|
});
|
|
1365
|
-
if (!(response instanceof
|
|
1365
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.versions)) {
|
|
1366
1366
|
throw this._unexpectedResponseError("list_versions");
|
|
1367
1367
|
}
|
|
1368
1368
|
return response.json.versions.map((version) => tableVersionFromJson(version));
|
|
@@ -1381,7 +1381,7 @@ class DatasetsClient {
|
|
|
1381
1381
|
branch: branch ?? null,
|
|
1382
1382
|
version: version ?? null,
|
|
1383
1383
|
});
|
|
1384
|
-
if (!(response instanceof
|
|
1384
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.indexes)) {
|
|
1385
1385
|
throw this._unexpectedResponseError("list_indexes");
|
|
1386
1386
|
}
|
|
1387
1387
|
return response.json.indexes.map((index) => tableIndexFromJson(index));
|
|
@@ -1390,7 +1390,7 @@ class DatasetsClient {
|
|
|
1390
1390
|
const response = await this.invoke("list_branches", {
|
|
1391
1391
|
namespace: namespace ?? null,
|
|
1392
1392
|
});
|
|
1393
|
-
if (!(response instanceof
|
|
1393
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.branches)) {
|
|
1394
1394
|
throw this._unexpectedResponseError("list_branches");
|
|
1395
1395
|
}
|
|
1396
1396
|
return response.json.branches.map((branch) => tableBranchFromJson(branch));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventEmitter } from "./event-emitter";
|
|
2
|
-
import { RoomClient } from "./room-client";
|
|
3
|
-
import { RoomLogEvent } from "./room-event";
|
|
1
|
+
import { EventEmitter } from "./event-emitter.js";
|
|
2
|
+
import { RoomClient } from "./room-client.js";
|
|
3
|
+
import { RoomLogEvent } from "./room-event.js";
|
|
4
4
|
export declare class DeveloperClient extends EventEmitter<RoomLogEvent> {
|
|
5
5
|
private client;
|
|
6
6
|
constructor({ room }: {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DeveloperClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
class DeveloperClient extends
|
|
4
|
+
const event_emitter_js_1 = require("./event-emitter.js");
|
|
5
|
+
const response_js_1 = require("./response.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const room_event_js_1 = require("./room-event.js");
|
|
8
|
+
class DeveloperClient extends event_emitter_js_1.EventEmitter {
|
|
9
9
|
constructor({ room }) {
|
|
10
10
|
super();
|
|
11
11
|
this.client = room;
|
|
12
12
|
this.client.protocol.addHandler("developer.log", this._handleDeveloperLog.bind(this));
|
|
13
13
|
}
|
|
14
14
|
_emitDeveloperLog(type, data) {
|
|
15
|
-
const event = new
|
|
15
|
+
const event = new room_event_js_1.RoomLogEvent({ type, data });
|
|
16
16
|
this.client.emit(event);
|
|
17
17
|
this.emit("log", event);
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ class DeveloperClient extends event_emitter_1.EventEmitter {
|
|
|
20
20
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
const [rawJson, _] = (0,
|
|
23
|
+
const [rawJson, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
24
24
|
this._emitDeveloperLog(rawJson["type"], rawJson["data"]);
|
|
25
25
|
}
|
|
26
26
|
async log(type, data) {
|
|
@@ -45,16 +45,16 @@ class DeveloperClient extends event_emitter_1.EventEmitter {
|
|
|
45
45
|
});
|
|
46
46
|
try {
|
|
47
47
|
for await (const chunk of stream) {
|
|
48
|
-
if (chunk instanceof
|
|
48
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
49
49
|
throw new Error(chunk.text);
|
|
50
50
|
}
|
|
51
|
-
if (chunk instanceof
|
|
51
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
52
52
|
if (chunk.method === "close") {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
throw new Error("unexpected return type from developer.logs");
|
|
56
56
|
}
|
|
57
|
-
if (!(chunk instanceof
|
|
57
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
58
58
|
throw new Error("unexpected return type from developer.logs");
|
|
59
59
|
}
|
|
60
60
|
const logType = chunk.headers["type"];
|
|
@@ -67,7 +67,7 @@ class DeveloperClient extends event_emitter_1.EventEmitter {
|
|
|
67
67
|
if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) {
|
|
68
68
|
throw new Error("developer.logs returned invalid JSON data");
|
|
69
69
|
}
|
|
70
|
-
const event = new
|
|
70
|
+
const event = new room_event_js_1.RoomLogEvent({ type: logType, data: decoded });
|
|
71
71
|
this.client.emit(event);
|
|
72
72
|
this.emit("log", event);
|
|
73
73
|
yield event;
|