@meshagent/meshagent 0.39.3 → 0.39.4

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +134 -21
  3. package/dist/browser/entrypoint.d.ts +1426 -1464
  4. package/dist/browser/meshagent-client.js +7 -2
  5. package/dist/browser/package.json +1 -0
  6. package/dist/esm/agent-client.js +18 -12
  7. package/dist/esm/agent.js +26 -18
  8. package/dist/esm/api_keys.js +21 -11
  9. package/dist/esm/client.js +13 -7
  10. package/dist/esm/completer.js +5 -1
  11. package/dist/esm/containers-client.js +85 -80
  12. package/dist/esm/datasets-client.js +105 -95
  13. package/dist/esm/developer-client.js +15 -11
  14. package/dist/esm/document.js +20 -11
  15. package/dist/esm/entrypoint.d.ts +1426 -1464
  16. package/dist/esm/entrypoint.js +12 -1
  17. package/dist/esm/event-emitter.js +5 -1
  18. package/dist/esm/helpers.js +23 -15
  19. package/dist/esm/index.js +49 -33
  20. package/dist/esm/lk-client.js +12 -7
  21. package/dist/esm/lk-protocol.js +8 -4
  22. package/dist/esm/memory-client.js +11 -7
  23. package/dist/esm/meshagent-client.js +88 -79
  24. package/dist/esm/messaging-client.js +37 -33
  25. package/dist/esm/package.json +1 -0
  26. package/dist/esm/participant-token.js +62 -34
  27. package/dist/esm/participant.js +9 -3
  28. package/dist/esm/protocol.js +43 -29
  29. package/dist/esm/queues-client.js +17 -12
  30. package/dist/esm/requirement.js +11 -4
  31. package/dist/esm/response.js +34 -22
  32. package/dist/esm/room-client.js +134 -129
  33. package/dist/esm/room-event.js +21 -9
  34. package/dist/esm/room-server-client.js +18 -13
  35. package/dist/esm/runtime.js +10 -1
  36. package/dist/esm/schema.js +18 -9
  37. package/dist/esm/secrets-client.js +35 -31
  38. package/dist/esm/services-client.js +13 -9
  39. package/dist/esm/storage-client.js +38 -32
  40. package/dist/esm/stream-controller.js +5 -1
  41. package/dist/esm/sync-client.js +42 -38
  42. package/dist/esm/tool-content-type.js +5 -1
  43. package/dist/esm/utils.js +20 -10
  44. package/dist/esm/version.js +4 -1
  45. package/dist/node/entrypoint.d.ts +1426 -1464
  46. package/dist/node/meshagent-client.js +7 -2
  47. package/dist/node/package.json +1 -0
  48. package/package.json +1 -1
@@ -1,10 +1,14 @@
1
- import { Schema, Table, tableFromIPC, tableToIPC } from "apache-arrow";
2
- import { RoomServerException } from "./room-server-client";
3
- import { BinaryContent, ControlContent, EmptyContent, ErrorContent, JsonContent } from "./response";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatasetsClient = exports.DatasetUuid = exports.DatasetJson = exports.DatasetStruct = exports.DatasetDate = exports.DatasetExpression = exports.DatasetValueEncoder = void 0;
4
+ const apache_arrow_1 = require("apache-arrow");
5
+ const room_server_client_1 = require("./room-server-client");
6
+ const response_1 = require("./response");
4
7
  const ARROW_IPC_STREAM_MIME_TYPE = "application/vnd.apache.arrow.stream";
5
- export class DatasetValueEncoder {
8
+ class DatasetValueEncoder {
6
9
  }
7
- export class DatasetExpression extends DatasetValueEncoder {
10
+ exports.DatasetValueEncoder = DatasetValueEncoder;
11
+ class DatasetExpression extends DatasetValueEncoder {
8
12
  constructor(expression) {
9
13
  super();
10
14
  const normalized = expression.trim();
@@ -22,7 +26,8 @@ export class DatasetExpression extends DatasetValueEncoder {
22
26
  return this.expression;
23
27
  }
24
28
  }
25
- export class DatasetDate extends DatasetValueEncoder {
29
+ exports.DatasetExpression = DatasetExpression;
30
+ class DatasetDate extends DatasetValueEncoder {
26
31
  constructor(value) {
27
32
  super();
28
33
  const normalized = value.trim();
@@ -41,7 +46,8 @@ export class DatasetDate extends DatasetValueEncoder {
41
46
  return this.value;
42
47
  }
43
48
  }
44
- export class DatasetStruct extends DatasetValueEncoder {
49
+ exports.DatasetDate = DatasetDate;
50
+ class DatasetStruct extends DatasetValueEncoder {
45
51
  constructor(fields) {
46
52
  super();
47
53
  this.fields = Object.fromEntries(Object.entries(fields).map(([key, value]) => {
@@ -60,7 +66,8 @@ export class DatasetStruct extends DatasetValueEncoder {
60
66
  };
61
67
  }
62
68
  }
63
- export class DatasetJson extends DatasetValueEncoder {
69
+ exports.DatasetStruct = DatasetStruct;
70
+ class DatasetJson extends DatasetValueEncoder {
64
71
  constructor(value) {
65
72
  super();
66
73
  this.value = normalizeDatasetJsonValue(value);
@@ -74,13 +81,14 @@ export class DatasetJson extends DatasetValueEncoder {
74
81
  };
75
82
  }
76
83
  }
84
+ exports.DatasetJson = DatasetJson;
77
85
  const globalScope = globalThis;
78
86
  const UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
79
87
  const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
80
88
  function normalizeUuidHex(value) {
81
89
  const normalized = value.trim().toLowerCase().replace(/-/g, "");
82
90
  if (!UUID_HEX_REGEX.test(normalized)) {
83
- throw new RoomServerException("invalid uuid format");
91
+ throw new room_server_client_1.RoomServerException("invalid uuid format");
84
92
  }
85
93
  return normalized;
86
94
  }
@@ -91,7 +99,7 @@ function formatUuidHex(value) {
91
99
  `${value.substring(16, 20)}-` +
92
100
  `${value.substring(20)}`);
93
101
  }
94
- export class DatasetUuid {
102
+ class DatasetUuid {
95
103
  constructor(value) {
96
104
  this.value = formatUuidHex(normalizeUuidHex(value));
97
105
  }
@@ -99,6 +107,7 @@ export class DatasetUuid {
99
107
  return this.value;
100
108
  }
101
109
  }
110
+ exports.DatasetUuid = DatasetUuid;
102
111
  function bytesToBase64(bytes) {
103
112
  if (globalScope.Buffer) {
104
113
  return globalScope.Buffer.from(bytes).toString("base64");
@@ -182,7 +191,7 @@ function encodeRecordValue(value) {
182
191
  };
183
192
  }
184
193
  if (isRecord(value)) {
185
- throw new RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
194
+ throw new room_server_client_1.RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
186
195
  }
187
196
  return value;
188
197
  }
@@ -207,62 +216,62 @@ function datasetSqlLiteral(value) {
207
216
  }
208
217
  function decodeRecordValue(value) {
209
218
  if (Array.isArray(value)) {
210
- throw new RoomServerException("dataset list values must use a {'list': [...]} wrapper");
219
+ throw new room_server_client_1.RoomServerException("dataset list values must use a {'list': [...]} wrapper");
211
220
  }
212
221
  if (!isRecord(value)) {
213
222
  return value;
214
223
  }
215
224
  const entries = Object.entries(value);
216
225
  if (entries.length !== 1) {
217
- throw new RoomServerException("dataset object values must use a single-key type wrapper");
226
+ throw new room_server_client_1.RoomServerException("dataset object values must use a single-key type wrapper");
218
227
  }
219
228
  const [wrapper, payload] = entries[0];
220
229
  switch (wrapper) {
221
230
  case "binary":
222
231
  if (typeof payload !== "string") {
223
- throw new RoomServerException("dataset binary values must be base64 strings");
232
+ throw new room_server_client_1.RoomServerException("dataset binary values must be base64 strings");
224
233
  }
225
234
  return base64ToBytes(payload);
226
235
  case "uuid":
227
236
  if (typeof payload !== "string") {
228
- throw new RoomServerException("dataset uuid values must be strings");
237
+ throw new room_server_client_1.RoomServerException("dataset uuid values must be strings");
229
238
  }
230
239
  return new DatasetUuid(payload);
231
240
  case "expression":
232
241
  if (typeof payload !== "string") {
233
- throw new RoomServerException("dataset expression values must be strings");
242
+ throw new room_server_client_1.RoomServerException("dataset expression values must be strings");
234
243
  }
235
244
  return new DatasetExpression(payload);
236
245
  case "date":
237
246
  if (typeof payload !== "string") {
238
- throw new RoomServerException("dataset date values must be strings");
247
+ throw new room_server_client_1.RoomServerException("dataset date values must be strings");
239
248
  }
240
249
  return new DatasetDate(payload);
241
250
  case "timestamp":
242
251
  if (typeof payload !== "string") {
243
- throw new RoomServerException("dataset timestamp values must be strings");
252
+ throw new room_server_client_1.RoomServerException("dataset timestamp values must be strings");
244
253
  }
245
254
  {
246
255
  const parsed = new Date(payload);
247
256
  if (Number.isNaN(parsed.getTime())) {
248
- throw new RoomServerException("dataset timestamp value is not valid");
257
+ throw new room_server_client_1.RoomServerException("dataset timestamp value is not valid");
249
258
  }
250
259
  return parsed;
251
260
  }
252
261
  case "list":
253
262
  if (!Array.isArray(payload)) {
254
- throw new RoomServerException("dataset list values must be arrays");
263
+ throw new room_server_client_1.RoomServerException("dataset list values must be arrays");
255
264
  }
256
265
  return payload.map((item) => decodeRecordValue(item));
257
266
  case "struct":
258
267
  if (!isRecord(payload)) {
259
- throw new RoomServerException("dataset struct values must be objects");
268
+ throw new room_server_client_1.RoomServerException("dataset struct values must be objects");
260
269
  }
261
270
  return new DatasetStruct(Object.fromEntries(Object.entries(payload).map(([key, item]) => [key, decodeRecordValue(item)])));
262
271
  case "json":
263
272
  return new DatasetJson(normalizeDatasetJsonValue(payload));
264
273
  default:
265
- throw new RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
274
+ throw new room_server_client_1.RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
266
275
  }
267
276
  }
268
277
  function encodeDatasetRecord(record) {
@@ -281,28 +290,28 @@ function rowsChunk(records) {
281
290
  }
282
291
  function recordsFromRowsChunk(payload, operation) {
283
292
  if (!isRecord(payload) || payload.kind !== "rows" || !Array.isArray(payload.rows)) {
284
- throw new RoomServerException(`unexpected return type from datasets.${operation}`);
293
+ throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
285
294
  }
286
295
  return payload.rows.map((row) => {
287
296
  if (!isRecord(row) || !Array.isArray(row.columns)) {
288
- throw new RoomServerException(`unexpected return type from datasets.${operation}`);
297
+ throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
289
298
  }
290
299
  return Object.fromEntries(row.columns.map((column) => {
291
300
  if (!isRecord(column) || typeof column.name !== "string") {
292
- throw new RoomServerException(`unexpected return type from datasets.${operation}`);
301
+ throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
293
302
  }
294
303
  try {
295
304
  return [column.name, decodeRecordValue(column.value)];
296
305
  }
297
306
  catch {
298
- throw new RoomServerException(`unexpected return type from datasets.${operation}`);
307
+ throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
299
308
  }
300
309
  }));
301
310
  });
302
311
  }
303
312
  function rowChunkList(records, rowsPerChunk = 128) {
304
313
  if (rowsPerChunk <= 0) {
305
- throw new RoomServerException("rowsPerChunk must be greater than zero");
314
+ throw new room_server_client_1.RoomServerException("rowsPerChunk must be greater than zero");
306
315
  }
307
316
  const chunks = [];
308
317
  for (let index = 0; index < records.length; index += rowsPerChunk) {
@@ -337,14 +346,14 @@ function normalizeTableRefs(tables) {
337
346
  }
338
347
  function tableIndexFromJson(value) {
339
348
  if (!isRecord(value) || typeof value.name !== "string" || typeof value.type !== "string" || !Array.isArray(value.columns)) {
340
- throw new RoomServerException("unexpected return type from datasets.list_indexes");
349
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_indexes");
341
350
  }
342
351
  return {
343
352
  name: value.name,
344
353
  type: value.type,
345
354
  columns: value.columns.map((column) => {
346
355
  if (typeof column !== "string") {
347
- throw new RoomServerException("unexpected return type from datasets.list_indexes");
356
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_indexes");
348
357
  }
349
358
  return column;
350
359
  }),
@@ -359,7 +368,7 @@ function tableIndexFromJson(value) {
359
368
  }
360
369
  function optimizeResultFromJson(value) {
361
370
  if (!isRecord(value)) {
362
- throw new RoomServerException("unexpected return type from datasets.optimize");
371
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.optimize");
363
372
  }
364
373
  return {
365
374
  compaction: typeof value.compaction_json === "string" ? JSON.parse(value.compaction_json) : isRecord(value.compaction) ? value.compaction : null,
@@ -369,32 +378,32 @@ function optimizeResultFromJson(value) {
369
378
  }
370
379
  function tableStatsFromJson(value) {
371
380
  if (!isRecord(value)) {
372
- throw new RoomServerException("unexpected return type from datasets.stats");
381
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.stats");
373
382
  }
374
383
  const dataset = typeof value.dataset_json === "string" ? JSON.parse(value.dataset_json) : value.dataset;
375
384
  const data = typeof value.data_json === "string" ? JSON.parse(value.data_json) : value.data;
376
385
  if (!isRecord(dataset) || !isRecord(data)) {
377
- throw new RoomServerException("unexpected return type from datasets.stats");
386
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.stats");
378
387
  }
379
388
  return { dataset, data };
380
389
  }
381
390
  function tableVersionFromJson(value) {
382
391
  if (!isRecord(value) || typeof value.metadata_json !== "string" || typeof value.timestamp !== "string" || typeof value.version !== "number") {
383
- throw new RoomServerException("unexpected return type from datasets.list_versions");
392
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
384
393
  }
385
394
  const timestamp = new Date(value.timestamp);
386
395
  if (Number.isNaN(timestamp.getTime())) {
387
- throw new RoomServerException("unexpected return type from datasets.list_versions");
396
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
388
397
  }
389
398
  let metadata;
390
399
  try {
391
400
  metadata = JSON.parse(value.metadata_json);
392
401
  }
393
402
  catch (_) {
394
- throw new RoomServerException("unexpected return type from datasets.list_versions");
403
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
395
404
  }
396
405
  if (!isRecord(metadata)) {
397
- throw new RoomServerException("unexpected return type from datasets.list_versions");
406
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
398
407
  }
399
408
  return {
400
409
  version: value.version,
@@ -404,27 +413,27 @@ function tableVersionFromJson(value) {
404
413
  }
405
414
  function tableBranchFromJson(value) {
406
415
  if (!isRecord(value) || typeof value.name !== "string") {
407
- throw new RoomServerException("unexpected return type from datasets.list_branches");
416
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
408
417
  }
409
418
  if (value.parent_branch != null && typeof value.parent_branch !== "string") {
410
- throw new RoomServerException("unexpected return type from datasets.list_branches");
419
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
411
420
  }
412
421
  if (value.parent_version != null
413
422
  && (typeof value.parent_version !== "number" || !Number.isInteger(value.parent_version))) {
414
- throw new RoomServerException("unexpected return type from datasets.list_branches");
423
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
415
424
  }
416
425
  if (value.manifest_size != null
417
426
  && (typeof value.manifest_size !== "number" || !Number.isInteger(value.manifest_size))) {
418
- throw new RoomServerException("unexpected return type from datasets.list_branches");
427
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
419
428
  }
420
429
  let createdAt = null;
421
430
  if (value.created_at != null) {
422
431
  if (typeof value.created_at !== "string") {
423
- throw new RoomServerException("unexpected return type from datasets.list_branches");
432
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
424
433
  }
425
434
  createdAt = new Date(value.created_at);
426
435
  if (Number.isNaN(createdAt.getTime())) {
427
- throw new RoomServerException("unexpected return type from datasets.list_branches");
436
+ throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
428
437
  }
429
438
  }
430
439
  return {
@@ -478,7 +487,7 @@ class DatasetWriteInputStream {
478
487
  });
479
488
  }
480
489
  async *stream() {
481
- yield new JsonContent({ json: this.start });
490
+ yield new response_1.JsonContent({ json: this.start });
482
491
  while (!this.closed) {
483
492
  await this.waitForPull();
484
493
  if (this.closed) {
@@ -491,7 +500,7 @@ class DatasetWriteInputStream {
491
500
  if (nextChunk.value.length === 0) {
492
501
  continue;
493
502
  }
494
- yield new JsonContent({ json: rowsChunk(nextChunk.value) });
503
+ yield new response_1.JsonContent({ json: rowsChunk(nextChunk.value) });
495
504
  }
496
505
  }
497
506
  }
@@ -507,12 +516,12 @@ async function* toAsyncArrowIterable(chunks) {
507
516
  }
508
517
  }
509
518
  function schemaToIPC(schema) {
510
- return tableToIPC(new Table(schema, []), "stream");
519
+ return (0, apache_arrow_1.tableToIPC)(new apache_arrow_1.Table(schema, []), "stream");
511
520
  }
512
521
  function tableFromIPCBytes(data) {
513
- const table = tableFromIPC(data);
522
+ const table = (0, apache_arrow_1.tableFromIPC)(data);
514
523
  if (table instanceof Promise) {
515
- throw new RoomServerException("unexpected async Arrow IPC result");
524
+ throw new room_server_client_1.RoomServerException("unexpected async Arrow IPC result");
516
525
  }
517
526
  return table;
518
527
  }
@@ -563,7 +572,7 @@ class DatasetArrowWriteInputStream {
563
572
  });
564
573
  }
565
574
  async *stream() {
566
- yield new BinaryContent({
575
+ yield new response_1.BinaryContent({
567
576
  data: this.schema == null ? new Uint8Array() : schemaToIPC(this.schema),
568
577
  headers: this.start,
569
578
  });
@@ -579,8 +588,8 @@ class DatasetArrowWriteInputStream {
579
588
  if (nextChunk.value.numRows === 0) {
580
589
  continue;
581
590
  }
582
- yield new BinaryContent({
583
- data: tableToIPC(nextChunk.value, "stream"),
591
+ yield new response_1.BinaryContent({
592
+ data: (0, apache_arrow_1.tableToIPC)(nextChunk.value, "stream"),
584
593
  headers: { kind: "data", content_type: ARROW_IPC_STREAM_MIME_TYPE },
585
594
  });
586
595
  }
@@ -627,13 +636,13 @@ class DatasetReadInputStream {
627
636
  });
628
637
  }
629
638
  async *stream() {
630
- yield new JsonContent({ json: this.start });
639
+ yield new response_1.JsonContent({ json: this.start });
631
640
  while (!this.closed) {
632
641
  await this.waitForPull();
633
642
  if (this.closed) {
634
643
  return;
635
644
  }
636
- yield new JsonContent({ json: { kind: "pull" } });
645
+ yield new response_1.JsonContent({ json: { kind: "pull" } });
637
646
  }
638
647
  }
639
648
  }
@@ -678,26 +687,26 @@ class DatasetArrowReadInputStream {
678
687
  });
679
688
  }
680
689
  async *stream() {
681
- yield new BinaryContent({ data: new Uint8Array(), headers: this.start });
690
+ yield new response_1.BinaryContent({ data: new Uint8Array(), headers: this.start });
682
691
  while (!this.closed) {
683
692
  await this.waitForPull();
684
693
  if (this.closed) {
685
694
  return;
686
695
  }
687
- yield new BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
696
+ yield new response_1.BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
688
697
  }
689
698
  }
690
699
  }
691
- export class DatasetsClient {
700
+ class DatasetsClient {
692
701
  constructor({ room }) {
693
702
  this.room = room;
694
703
  }
695
704
  _unexpectedResponseError(operation) {
696
- return new RoomServerException(`unexpected return type from datasets.${operation}`);
705
+ return new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
697
706
  }
698
707
  async invoke(operation, input) {
699
708
  const response = await this.room.invoke({ toolkit: "dataset", tool: operation, input });
700
- if (response instanceof JsonContent) {
709
+ if (response instanceof response_1.JsonContent) {
701
710
  return response;
702
711
  }
703
712
  if (response == null) {
@@ -715,23 +724,23 @@ export class DatasetsClient {
715
724
  const response = await this.invokeStream(operation, input.stream());
716
725
  try {
717
726
  for await (const chunk of response) {
718
- if (chunk instanceof ErrorContent) {
719
- throw new RoomServerException(chunk.text, chunk.code);
727
+ if (chunk instanceof response_1.ErrorContent) {
728
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
720
729
  }
721
- if (chunk instanceof ControlContent) {
730
+ if (chunk instanceof response_1.ControlContent) {
722
731
  if (chunk.method === "close") {
723
732
  return;
724
733
  }
725
734
  throw this._unexpectedResponseError(operation);
726
735
  }
727
- if (chunk instanceof BinaryContent) {
736
+ if (chunk instanceof response_1.BinaryContent) {
728
737
  if (chunk.headers.kind !== "pull") {
729
738
  throw this._unexpectedResponseError(operation);
730
739
  }
731
740
  input.requestNext();
732
741
  continue;
733
742
  }
734
- if (!(chunk instanceof JsonContent) || chunk.json.kind !== "pull") {
743
+ if (!(chunk instanceof response_1.JsonContent) || chunk.json.kind !== "pull") {
735
744
  throw this._unexpectedResponseError(operation);
736
745
  }
737
746
  input.requestNext();
@@ -747,16 +756,16 @@ export class DatasetsClient {
747
756
  input.requestNext();
748
757
  try {
749
758
  for await (const chunk of response) {
750
- if (chunk instanceof ErrorContent) {
751
- throw new RoomServerException(chunk.text, chunk.code);
759
+ if (chunk instanceof response_1.ErrorContent) {
760
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
752
761
  }
753
- if (chunk instanceof ControlContent) {
762
+ if (chunk instanceof response_1.ControlContent) {
754
763
  if (chunk.method === "close") {
755
764
  return;
756
765
  }
757
766
  throw this._unexpectedResponseError(operation);
758
767
  }
759
- if (!(chunk instanceof JsonContent)) {
768
+ if (!(chunk instanceof response_1.JsonContent)) {
760
769
  throw this._unexpectedResponseError(operation);
761
770
  }
762
771
  yield recordsFromRowsChunk(chunk.json, operation);
@@ -773,16 +782,16 @@ export class DatasetsClient {
773
782
  input.requestNext();
774
783
  try {
775
784
  for await (const chunk of response) {
776
- if (chunk instanceof ErrorContent) {
777
- throw new RoomServerException(chunk.text, chunk.code);
785
+ if (chunk instanceof response_1.ErrorContent) {
786
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
778
787
  }
779
- if (chunk instanceof ControlContent) {
788
+ if (chunk instanceof response_1.ControlContent) {
780
789
  if (chunk.method === "close") {
781
790
  return;
782
791
  }
783
792
  throw this._unexpectedResponseError(operation);
784
793
  }
785
- if (!(chunk instanceof BinaryContent) || chunk.headers.kind !== "data") {
794
+ if (!(chunk instanceof response_1.BinaryContent) || chunk.headers.kind !== "data") {
786
795
  throw this._unexpectedResponseError(operation);
787
796
  }
788
797
  yield tableFromIPCBytes(chunk.data);
@@ -798,7 +807,7 @@ export class DatasetsClient {
798
807
  namespace: namespace ?? null,
799
808
  branch: branch ?? null,
800
809
  });
801
- if (!(response instanceof JsonContent)) {
810
+ if (!(response instanceof response_1.JsonContent)) {
802
811
  throw this._unexpectedResponseError("list_tables");
803
812
  }
804
813
  return Array.isArray(response.json.tables) ? response.json.tables : [];
@@ -818,7 +827,7 @@ export class DatasetsClient {
818
827
  return this.createTable({
819
828
  name,
820
829
  schema,
821
- data: data == null ? undefined : data instanceof Table ? [data] : data,
830
+ data: data == null ? undefined : data instanceof apache_arrow_1.Table ? [data] : data,
822
831
  mode,
823
832
  namespace,
824
833
  branch,
@@ -828,7 +837,7 @@ export class DatasetsClient {
828
837
  async createTableFromData({ name, data, mode = "create", namespace, branch, metadata }) {
829
838
  return this.createTable({
830
839
  name,
831
- data: data == null ? undefined : data instanceof Table ? [data] : data,
840
+ data: data == null ? undefined : data instanceof apache_arrow_1.Table ? [data] : data,
832
841
  mode,
833
842
  namespace,
834
843
  branch,
@@ -869,8 +878,8 @@ export class DatasetsClient {
869
878
  });
870
879
  }
871
880
  async addColumns({ table, newColumns, namespace, branch }) {
872
- if (newColumns instanceof Schema) {
873
- await this.invokeContent("add_columns", new BinaryContent({
881
+ if (newColumns instanceof apache_arrow_1.Schema) {
882
+ await this.invokeContent("add_columns", new response_1.BinaryContent({
874
883
  data: schemaToIPC(newColumns),
875
884
  headers: {
876
885
  table,
@@ -952,8 +961,8 @@ export class DatasetsClient {
952
961
  return results;
953
962
  }
954
963
  async openSqlQuery({ query, tables, params, namespace, branch }) {
955
- const response = await this.invokeContent("open_sql_query", new BinaryContent({
956
- data: params == null ? new Uint8Array() : tableToIPC(params, "stream"),
964
+ const response = await this.invokeContent("open_sql_query", new response_1.BinaryContent({
965
+ data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
957
966
  headers: {
958
967
  query,
959
968
  tables: normalizeTableRefs(tables ?? []),
@@ -961,7 +970,7 @@ export class DatasetsClient {
961
970
  branch: branch ?? null,
962
971
  },
963
972
  }));
964
- if (!(response instanceof BinaryContent)) {
973
+ if (!(response instanceof response_1.BinaryContent)) {
965
974
  throw this._unexpectedResponseError("open_sql_query");
966
975
  }
967
976
  const queryId = response.headers.query_id;
@@ -975,8 +984,8 @@ export class DatasetsClient {
975
984
  };
976
985
  }
977
986
  async executeSql({ query, tables, params, namespace, branch }) {
978
- const response = await this.invokeContent("execute_sql", new BinaryContent({
979
- data: params == null ? new Uint8Array() : tableToIPC(params, "stream"),
987
+ const response = await this.invokeContent("execute_sql", new response_1.BinaryContent({
988
+ data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
980
989
  headers: {
981
990
  query,
982
991
  tables: normalizeTableRefs(tables ?? []),
@@ -984,7 +993,7 @@ export class DatasetsClient {
984
993
  branch: branch ?? null,
985
994
  },
986
995
  }));
987
- if (response instanceof BinaryContent) {
996
+ if (response instanceof response_1.BinaryContent) {
988
997
  if (response.headers.kind !== "query") {
989
998
  throw this._unexpectedResponseError("execute_sql");
990
999
  }
@@ -998,7 +1007,7 @@ export class DatasetsClient {
998
1007
  queryId,
999
1008
  };
1000
1009
  }
1001
- if (response instanceof JsonContent) {
1010
+ if (response instanceof response_1.JsonContent) {
1002
1011
  if (response.json.kind !== "statement"
1003
1012
  || typeof response.json.rows_affected !== "number"
1004
1013
  || !Number.isInteger(response.json.rows_affected)) {
@@ -1014,7 +1023,7 @@ export class DatasetsClient {
1014
1023
  async *sqlStream({ query, tables, params, namespace, branch }) {
1015
1024
  const result = await this.executeSql({ query, tables, params, namespace, branch });
1016
1025
  if (result.kind === "statement") {
1017
- throw new RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
1026
+ throw new room_server_client_1.RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
1018
1027
  }
1019
1028
  const opened = result;
1020
1029
  try {
@@ -1032,21 +1041,21 @@ export class DatasetsClient {
1032
1041
  }
1033
1042
  async closeSqlQuery({ queryId }) {
1034
1043
  const response = await this.room.invoke({ toolkit: "dataset", tool: "close_sql_query", input: { query_id: queryId } });
1035
- if (!(response instanceof EmptyContent)) {
1044
+ if (!(response instanceof response_1.EmptyContent)) {
1036
1045
  throw this._unexpectedResponseError("close_sql_query");
1037
1046
  }
1038
1047
  }
1039
1048
  async cancelSqlQuery({ queryId }) {
1040
1049
  const response = await this.room.invoke({ toolkit: "dataset", tool: "cancel_sql_query", input: { query_id: queryId } });
1041
- if (!(response instanceof JsonContent)
1050
+ if (!(response instanceof response_1.JsonContent)
1042
1051
  || !["cancelled", "cancelling", "not_cancellable"].includes(response.json.status)) {
1043
1052
  throw this._unexpectedResponseError("cancel_sql_query");
1044
1053
  }
1045
1054
  return { status: response.json.status };
1046
1055
  }
1047
1056
  async executeSqlStatement({ query, tables, params, namespace, branch }) {
1048
- const response = await this.invokeContent("execute_sql_statement", new BinaryContent({
1049
- data: params == null ? new Uint8Array() : tableToIPC(params, "stream"),
1057
+ const response = await this.invokeContent("execute_sql_statement", new response_1.BinaryContent({
1058
+ data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
1050
1059
  headers: {
1051
1060
  query,
1052
1061
  tables: normalizeTableRefs(tables ?? []),
@@ -1054,7 +1063,7 @@ export class DatasetsClient {
1054
1063
  branch: branch ?? null,
1055
1064
  },
1056
1065
  }));
1057
- if (!(response instanceof JsonContent)
1066
+ if (!(response instanceof response_1.JsonContent)
1058
1067
  || typeof response.json.rows_affected !== "number"
1059
1068
  || !Number.isInteger(response.json.rows_affected)) {
1060
1069
  throw this._unexpectedResponseError("execute_sql_statement");
@@ -1106,7 +1115,7 @@ export class DatasetsClient {
1106
1115
  branch: branch ?? null,
1107
1116
  version: version ?? null,
1108
1117
  });
1109
- if (!(response instanceof JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
1118
+ if (!(response instanceof response_1.JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
1110
1119
  throw this._unexpectedResponseError("count");
1111
1120
  }
1112
1121
  return response.json.count;
@@ -1122,7 +1131,7 @@ export class DatasetsClient {
1122
1131
  version: version ?? null,
1123
1132
  },
1124
1133
  });
1125
- if (!(response instanceof BinaryContent)) {
1134
+ if (!(response instanceof response_1.BinaryContent)) {
1126
1135
  throw this._unexpectedResponseError("inspect");
1127
1136
  }
1128
1137
  return tableFromIPCBytes(response.data).schema;
@@ -1138,7 +1147,7 @@ export class DatasetsClient {
1138
1147
  branch: branch ?? null,
1139
1148
  config: config ?? null,
1140
1149
  });
1141
- if (!(response instanceof JsonContent)) {
1150
+ if (!(response instanceof response_1.JsonContent)) {
1142
1151
  throw this._unexpectedResponseError("optimize");
1143
1152
  }
1144
1153
  return optimizeResultFromJson(response.json);
@@ -1151,7 +1160,7 @@ export class DatasetsClient {
1151
1160
  version: version ?? null,
1152
1161
  max_rows_per_group: maxRowsPerGroup ?? null,
1153
1162
  });
1154
- if (!(response instanceof JsonContent)) {
1163
+ if (!(response instanceof response_1.JsonContent)) {
1155
1164
  throw this._unexpectedResponseError("stats");
1156
1165
  }
1157
1166
  return tableStatsFromJson(response.json);
@@ -1169,7 +1178,7 @@ export class DatasetsClient {
1169
1178
  namespace: namespace ?? null,
1170
1179
  branch: branch ?? null,
1171
1180
  });
1172
- if (!(response instanceof JsonContent) || !Array.isArray(response.json.versions)) {
1181
+ if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json.versions)) {
1173
1182
  throw this._unexpectedResponseError("list_versions");
1174
1183
  }
1175
1184
  return response.json.versions.map((version) => tableVersionFromJson(version));
@@ -1188,7 +1197,7 @@ export class DatasetsClient {
1188
1197
  branch: branch ?? null,
1189
1198
  version: version ?? null,
1190
1199
  });
1191
- if (!(response instanceof JsonContent) || !Array.isArray(response.json.indexes)) {
1200
+ if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json.indexes)) {
1192
1201
  throw this._unexpectedResponseError("list_indexes");
1193
1202
  }
1194
1203
  return response.json.indexes.map((index) => tableIndexFromJson(index));
@@ -1197,7 +1206,7 @@ export class DatasetsClient {
1197
1206
  const response = await this.invoke("list_branches", {
1198
1207
  namespace: namespace ?? null,
1199
1208
  });
1200
- if (!(response instanceof JsonContent) || !Array.isArray(response.json.branches)) {
1209
+ if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json.branches)) {
1201
1210
  throw this._unexpectedResponseError("list_branches");
1202
1211
  }
1203
1212
  return response.json.branches.map((branch) => tableBranchFromJson(branch));
@@ -1221,3 +1230,4 @@ export class DatasetsClient {
1221
1230
  });
1222
1231
  }
1223
1232
  }
1233
+ exports.DatasetsClient = DatasetsClient;