@meshagent/meshagent 0.39.8 → 0.39.9

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 CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.39.9]
2
+ - Added streaming `watchTable` support to the TypeScript DatasetsClient to receive dataset table change events with versioning metadata.
3
+
1
4
  ## [0.39.8]
2
5
  - TypeScript API: `RoomContainer` now includes a required `ports: number[]` field (and validation) in container listings
3
6
  - TypeScript API: `ContainerSpec` now supports optional fields `private`, `on_demand`, and `writable_root_fs`
@@ -123,6 +123,16 @@ export type DatasetSqlCancelStatus = "cancelled" | "cancelling" | "not_cancellab
123
123
  export interface DatasetSqlCancelResult {
124
124
  status: DatasetSqlCancelStatus;
125
125
  }
126
+ export interface DatasetWatchEvent {
127
+ kind: "data" | "ready";
128
+ phase?: string;
129
+ table?: Table;
130
+ version?: number;
131
+ changeType?: string;
132
+ beginVersion?: number;
133
+ endVersion?: number;
134
+ watchEvent?: string;
135
+ }
126
136
  export declare abstract class DatasetValueEncoder {
127
137
  abstract encodeDatasetValue(): unknown;
128
138
  }
@@ -368,6 +378,12 @@ export declare class DatasetsClient {
368
378
  branch?: string;
369
379
  version?: number;
370
380
  }): AsyncIterable<Table>;
381
+ watchTable({ table, namespace, branch, pollIntervalSeconds }: {
382
+ table: string;
383
+ namespace?: string[];
384
+ branch?: string;
385
+ pollIntervalSeconds?: number;
386
+ }): AsyncIterable<DatasetWatchEvent>;
371
387
  count({ table, text, vector, where, namespace, branch, version }: {
372
388
  table: string;
373
389
  text?: string;
@@ -444,6 +444,18 @@ function tableBranchFromJson(value) {
444
444
  manifestSize: value.manifest_size ?? null,
445
445
  };
446
446
  }
447
+ function optionalDatasetInt(value) {
448
+ if (typeof value === "number" && Number.isInteger(value)) {
449
+ return value;
450
+ }
451
+ if (typeof value === "string" && /^-?\d+$/.test(value)) {
452
+ return Number.parseInt(value, 10);
453
+ }
454
+ return undefined;
455
+ }
456
+ function optionalDatasetString(value) {
457
+ return typeof value === "string" ? value : undefined;
458
+ }
447
459
  class DatasetWriteInputStream {
448
460
  constructor(start, chunks) {
449
461
  this.start = start;
@@ -1130,6 +1142,63 @@ class DatasetsClient {
1130
1142
  version: version ?? null,
1131
1143
  });
1132
1144
  }
1145
+ async *watchTable({ table, namespace, branch, pollIntervalSeconds = 0.5 }) {
1146
+ const input = new DatasetArrowReadInputStream({
1147
+ kind: "start",
1148
+ table,
1149
+ namespace: namespace ?? null,
1150
+ branch: branch ?? null,
1151
+ poll_interval_seconds: pollIntervalSeconds,
1152
+ });
1153
+ const response = await this.invokeStream("watch_table", input.stream());
1154
+ input.requestNext();
1155
+ try {
1156
+ for await (const chunk of response) {
1157
+ if (chunk instanceof response_1.ErrorContent) {
1158
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
1159
+ }
1160
+ if (chunk instanceof response_1.ControlContent) {
1161
+ if (chunk.method === "close") {
1162
+ return;
1163
+ }
1164
+ throw this._unexpectedResponseError("watch_table");
1165
+ }
1166
+ if (chunk instanceof response_1.BinaryContent) {
1167
+ if (chunk.headers.kind !== "data") {
1168
+ throw this._unexpectedResponseError("watch_table");
1169
+ }
1170
+ yield {
1171
+ kind: "data",
1172
+ phase: optionalDatasetString(chunk.headers.phase),
1173
+ table: tableFromIPCBytes(chunk.data),
1174
+ version: optionalDatasetInt(chunk.headers.version),
1175
+ changeType: optionalDatasetString(chunk.headers.change_type),
1176
+ beginVersion: optionalDatasetInt(chunk.headers.begin_version),
1177
+ endVersion: optionalDatasetInt(chunk.headers.end_version),
1178
+ watchEvent: optionalDatasetString(chunk.headers.watch_event),
1179
+ };
1180
+ input.requestNext();
1181
+ continue;
1182
+ }
1183
+ if (chunk instanceof response_1.JsonContent) {
1184
+ if (chunk.json.kind !== "ready") {
1185
+ throw this._unexpectedResponseError("watch_table");
1186
+ }
1187
+ yield {
1188
+ kind: "ready",
1189
+ phase: optionalDatasetString(chunk.json.phase),
1190
+ version: optionalDatasetInt(chunk.json.version),
1191
+ };
1192
+ input.requestNext();
1193
+ continue;
1194
+ }
1195
+ throw this._unexpectedResponseError("watch_table");
1196
+ }
1197
+ }
1198
+ finally {
1199
+ input.close();
1200
+ }
1201
+ }
1133
1202
  async count({ table, text, vector, where, namespace, branch, version }) {
1134
1203
  const response = await this.invoke("count", {
1135
1204
  table,
@@ -123,6 +123,16 @@ export type DatasetSqlCancelStatus = "cancelled" | "cancelling" | "not_cancellab
123
123
  export interface DatasetSqlCancelResult {
124
124
  status: DatasetSqlCancelStatus;
125
125
  }
126
+ export interface DatasetWatchEvent {
127
+ kind: "data" | "ready";
128
+ phase?: string;
129
+ table?: Table;
130
+ version?: number;
131
+ changeType?: string;
132
+ beginVersion?: number;
133
+ endVersion?: number;
134
+ watchEvent?: string;
135
+ }
126
136
  export declare abstract class DatasetValueEncoder {
127
137
  abstract encodeDatasetValue(): unknown;
128
138
  }
@@ -368,6 +378,12 @@ export declare class DatasetsClient {
368
378
  branch?: string;
369
379
  version?: number;
370
380
  }): AsyncIterable<Table>;
381
+ watchTable({ table, namespace, branch, pollIntervalSeconds }: {
382
+ table: string;
383
+ namespace?: string[];
384
+ branch?: string;
385
+ pollIntervalSeconds?: number;
386
+ }): AsyncIterable<DatasetWatchEvent>;
371
387
  count({ table, text, vector, where, namespace, branch, version }: {
372
388
  table: string;
373
389
  text?: string;
@@ -444,6 +444,18 @@ function tableBranchFromJson(value) {
444
444
  manifestSize: value.manifest_size ?? null,
445
445
  };
446
446
  }
447
+ function optionalDatasetInt(value) {
448
+ if (typeof value === "number" && Number.isInteger(value)) {
449
+ return value;
450
+ }
451
+ if (typeof value === "string" && /^-?\d+$/.test(value)) {
452
+ return Number.parseInt(value, 10);
453
+ }
454
+ return undefined;
455
+ }
456
+ function optionalDatasetString(value) {
457
+ return typeof value === "string" ? value : undefined;
458
+ }
447
459
  class DatasetWriteInputStream {
448
460
  constructor(start, chunks) {
449
461
  this.start = start;
@@ -1130,6 +1142,63 @@ class DatasetsClient {
1130
1142
  version: version ?? null,
1131
1143
  });
1132
1144
  }
1145
+ async *watchTable({ table, namespace, branch, pollIntervalSeconds = 0.5 }) {
1146
+ const input = new DatasetArrowReadInputStream({
1147
+ kind: "start",
1148
+ table,
1149
+ namespace: namespace ?? null,
1150
+ branch: branch ?? null,
1151
+ poll_interval_seconds: pollIntervalSeconds,
1152
+ });
1153
+ const response = await this.invokeStream("watch_table", input.stream());
1154
+ input.requestNext();
1155
+ try {
1156
+ for await (const chunk of response) {
1157
+ if (chunk instanceof response_1.ErrorContent) {
1158
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
1159
+ }
1160
+ if (chunk instanceof response_1.ControlContent) {
1161
+ if (chunk.method === "close") {
1162
+ return;
1163
+ }
1164
+ throw this._unexpectedResponseError("watch_table");
1165
+ }
1166
+ if (chunk instanceof response_1.BinaryContent) {
1167
+ if (chunk.headers.kind !== "data") {
1168
+ throw this._unexpectedResponseError("watch_table");
1169
+ }
1170
+ yield {
1171
+ kind: "data",
1172
+ phase: optionalDatasetString(chunk.headers.phase),
1173
+ table: tableFromIPCBytes(chunk.data),
1174
+ version: optionalDatasetInt(chunk.headers.version),
1175
+ changeType: optionalDatasetString(chunk.headers.change_type),
1176
+ beginVersion: optionalDatasetInt(chunk.headers.begin_version),
1177
+ endVersion: optionalDatasetInt(chunk.headers.end_version),
1178
+ watchEvent: optionalDatasetString(chunk.headers.watch_event),
1179
+ };
1180
+ input.requestNext();
1181
+ continue;
1182
+ }
1183
+ if (chunk instanceof response_1.JsonContent) {
1184
+ if (chunk.json.kind !== "ready") {
1185
+ throw this._unexpectedResponseError("watch_table");
1186
+ }
1187
+ yield {
1188
+ kind: "ready",
1189
+ phase: optionalDatasetString(chunk.json.phase),
1190
+ version: optionalDatasetInt(chunk.json.version),
1191
+ };
1192
+ input.requestNext();
1193
+ continue;
1194
+ }
1195
+ throw this._unexpectedResponseError("watch_table");
1196
+ }
1197
+ }
1198
+ finally {
1199
+ input.close();
1200
+ }
1201
+ }
1133
1202
  async count({ table, text, vector, where, namespace, branch, version }) {
1134
1203
  const response = await this.invoke("count", {
1135
1204
  table,
@@ -123,6 +123,16 @@ export type DatasetSqlCancelStatus = "cancelled" | "cancelling" | "not_cancellab
123
123
  export interface DatasetSqlCancelResult {
124
124
  status: DatasetSqlCancelStatus;
125
125
  }
126
+ export interface DatasetWatchEvent {
127
+ kind: "data" | "ready";
128
+ phase?: string;
129
+ table?: Table;
130
+ version?: number;
131
+ changeType?: string;
132
+ beginVersion?: number;
133
+ endVersion?: number;
134
+ watchEvent?: string;
135
+ }
126
136
  export declare abstract class DatasetValueEncoder {
127
137
  abstract encodeDatasetValue(): unknown;
128
138
  }
@@ -368,6 +378,12 @@ export declare class DatasetsClient {
368
378
  branch?: string;
369
379
  version?: number;
370
380
  }): AsyncIterable<Table>;
381
+ watchTable({ table, namespace, branch, pollIntervalSeconds }: {
382
+ table: string;
383
+ namespace?: string[];
384
+ branch?: string;
385
+ pollIntervalSeconds?: number;
386
+ }): AsyncIterable<DatasetWatchEvent>;
371
387
  count({ table, text, vector, where, namespace, branch, version }: {
372
388
  table: string;
373
389
  text?: string;
@@ -444,6 +444,18 @@ function tableBranchFromJson(value) {
444
444
  manifestSize: value.manifest_size ?? null,
445
445
  };
446
446
  }
447
+ function optionalDatasetInt(value) {
448
+ if (typeof value === "number" && Number.isInteger(value)) {
449
+ return value;
450
+ }
451
+ if (typeof value === "string" && /^-?\d+$/.test(value)) {
452
+ return Number.parseInt(value, 10);
453
+ }
454
+ return undefined;
455
+ }
456
+ function optionalDatasetString(value) {
457
+ return typeof value === "string" ? value : undefined;
458
+ }
447
459
  class DatasetWriteInputStream {
448
460
  constructor(start, chunks) {
449
461
  this.start = start;
@@ -1130,6 +1142,63 @@ class DatasetsClient {
1130
1142
  version: version ?? null,
1131
1143
  });
1132
1144
  }
1145
+ async *watchTable({ table, namespace, branch, pollIntervalSeconds = 0.5 }) {
1146
+ const input = new DatasetArrowReadInputStream({
1147
+ kind: "start",
1148
+ table,
1149
+ namespace: namespace ?? null,
1150
+ branch: branch ?? null,
1151
+ poll_interval_seconds: pollIntervalSeconds,
1152
+ });
1153
+ const response = await this.invokeStream("watch_table", input.stream());
1154
+ input.requestNext();
1155
+ try {
1156
+ for await (const chunk of response) {
1157
+ if (chunk instanceof response_1.ErrorContent) {
1158
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
1159
+ }
1160
+ if (chunk instanceof response_1.ControlContent) {
1161
+ if (chunk.method === "close") {
1162
+ return;
1163
+ }
1164
+ throw this._unexpectedResponseError("watch_table");
1165
+ }
1166
+ if (chunk instanceof response_1.BinaryContent) {
1167
+ if (chunk.headers.kind !== "data") {
1168
+ throw this._unexpectedResponseError("watch_table");
1169
+ }
1170
+ yield {
1171
+ kind: "data",
1172
+ phase: optionalDatasetString(chunk.headers.phase),
1173
+ table: tableFromIPCBytes(chunk.data),
1174
+ version: optionalDatasetInt(chunk.headers.version),
1175
+ changeType: optionalDatasetString(chunk.headers.change_type),
1176
+ beginVersion: optionalDatasetInt(chunk.headers.begin_version),
1177
+ endVersion: optionalDatasetInt(chunk.headers.end_version),
1178
+ watchEvent: optionalDatasetString(chunk.headers.watch_event),
1179
+ };
1180
+ input.requestNext();
1181
+ continue;
1182
+ }
1183
+ if (chunk instanceof response_1.JsonContent) {
1184
+ if (chunk.json.kind !== "ready") {
1185
+ throw this._unexpectedResponseError("watch_table");
1186
+ }
1187
+ yield {
1188
+ kind: "ready",
1189
+ phase: optionalDatasetString(chunk.json.phase),
1190
+ version: optionalDatasetInt(chunk.json.version),
1191
+ };
1192
+ input.requestNext();
1193
+ continue;
1194
+ }
1195
+ throw this._unexpectedResponseError("watch_table");
1196
+ }
1197
+ }
1198
+ finally {
1199
+ input.close();
1200
+ }
1201
+ }
1133
1202
  async count({ table, text, vector, where, namespace, branch, version }) {
1134
1203
  const response = await this.invoke("count", {
1135
1204
  table,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshagent/meshagent",
3
- "version": "0.39.8",
3
+ "version": "0.39.9",
4
4
  "description": "Meshagent Client",
5
5
  "homepage": "https://github.com/meshagent/meshagent-ts",
6
6
  "scripts": {