@meshagent/meshagent 0.38.3 → 0.39.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 +12 -2
- package/dist/browser/datasets-client.d.ts +415 -0
- package/dist/{node/database-client.js → browser/datasets-client.js} +480 -234
- package/dist/browser/entrypoint.js +9 -17
- package/dist/browser/index.d.ts +1 -2
- package/dist/browser/index.js +1 -2
- package/dist/browser/meshagent-client.d.ts +109 -1
- package/dist/browser/meshagent-client.js +269 -3
- package/dist/browser/participant-token.d.ts +5 -5
- package/dist/browser/participant-token.js +14 -13
- package/dist/browser/room-client.d.ts +5 -3
- package/dist/browser/room-client.js +70 -4
- package/dist/esm/datasets-client.d.ts +415 -0
- package/dist/esm/{database-client.js → datasets-client.js} +473 -227
- package/dist/esm/entrypoint.js +6 -12
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/meshagent-client.d.ts +109 -1
- package/dist/esm/meshagent-client.js +269 -3
- package/dist/esm/participant-token.d.ts +5 -5
- package/dist/esm/participant-token.js +12 -11
- package/dist/esm/room-client.d.ts +5 -3
- package/dist/esm/room-client.js +70 -4
- package/dist/node/datasets-client.d.ts +415 -0
- package/dist/{browser/database-client.js → node/datasets-client.js} +480 -234
- package/dist/node/entrypoint.js +6 -12
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.js +1 -2
- package/dist/node/meshagent-client.d.ts +109 -1
- package/dist/node/meshagent-client.js +269 -3
- package/dist/node/participant-token.d.ts +5 -5
- package/dist/node/participant-token.js +14 -13
- package/dist/node/room-client.d.ts +5 -3
- package/dist/node/room-client.js +70 -4
- package/package.json +3 -2
- package/dist/browser/data-types.d.ts +0 -67
- package/dist/browser/data-types.js +0 -192
- package/dist/browser/database-client.d.ts +0 -281
- package/dist/esm/data-types.d.ts +0 -67
- package/dist/esm/data-types.js +0 -179
- package/dist/esm/database-client.d.ts +0 -281
- package/dist/node/data-types.d.ts +0 -67
- package/dist/node/data-types.js +0 -192
- package/dist/node/database-client.d.ts +0 -281
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.OAuthEndpoint = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.
|
|
3
|
+
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.OAuthEndpoint = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.DatasetGrant = exports.TableGrant = exports.MessagingGrant = exports.QueuesGrant = exports.LivekitGrant = exports.AgentsGrant = void 0;
|
|
4
4
|
const jose_1 = require("jose");
|
|
5
5
|
const api_keys_1 = require("./api_keys");
|
|
6
6
|
const version_1 = require("./version");
|
|
@@ -220,7 +220,7 @@ class TableGrant {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
exports.TableGrant = TableGrant;
|
|
223
|
-
class
|
|
223
|
+
class DatasetGrant {
|
|
224
224
|
constructor({ tables, listTables, } = {}) {
|
|
225
225
|
this.tables = tables;
|
|
226
226
|
this.listTables = listTables ?? true;
|
|
@@ -286,9 +286,9 @@ class DatabaseGrant {
|
|
|
286
286
|
}
|
|
287
287
|
static fromJSON(obj) {
|
|
288
288
|
if (!isRecord(obj)) {
|
|
289
|
-
return new
|
|
289
|
+
return new DatasetGrant();
|
|
290
290
|
}
|
|
291
|
-
return new
|
|
291
|
+
return new DatasetGrant({
|
|
292
292
|
tables: Array.isArray(obj.tables)
|
|
293
293
|
? obj.tables.map((tableGrant) => TableGrant.fromJSON(tableGrant))
|
|
294
294
|
: undefined,
|
|
@@ -296,7 +296,7 @@ class DatabaseGrant {
|
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
exports.
|
|
299
|
+
exports.DatasetGrant = DatasetGrant;
|
|
300
300
|
class MemoryPermissions {
|
|
301
301
|
constructor({ create, drop, inspect, query, upsert, ingest, recall, optimize, } = {}) {
|
|
302
302
|
this.create = create ?? true;
|
|
@@ -922,11 +922,11 @@ class LLMGrant {
|
|
|
922
922
|
}
|
|
923
923
|
exports.LLMGrant = LLMGrant;
|
|
924
924
|
class ApiScope {
|
|
925
|
-
constructor({ livekit, queues, messaging,
|
|
925
|
+
constructor({ livekit, queues, messaging, dataset, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services, } = {}) {
|
|
926
926
|
this.livekit = livekit;
|
|
927
927
|
this.queues = queues;
|
|
928
928
|
this.messaging = messaging;
|
|
929
|
-
this.
|
|
929
|
+
this.dataset = dataset;
|
|
930
930
|
this.memory = memory;
|
|
931
931
|
this.sync = sync;
|
|
932
932
|
this.storage = storage;
|
|
@@ -944,7 +944,7 @@ class ApiScope {
|
|
|
944
944
|
livekit: new LivekitGrant(),
|
|
945
945
|
queues: new QueuesGrant(),
|
|
946
946
|
messaging: new MessagingGrant(),
|
|
947
|
-
|
|
947
|
+
dataset: new DatasetGrant(),
|
|
948
948
|
memory: new MemoryGrant(),
|
|
949
949
|
sync: new SyncGrant(),
|
|
950
950
|
storage: new StorageGrant(),
|
|
@@ -962,7 +962,7 @@ class ApiScope {
|
|
|
962
962
|
livekit: new LivekitGrant(),
|
|
963
963
|
queues: new QueuesGrant(),
|
|
964
964
|
messaging: new MessagingGrant(),
|
|
965
|
-
|
|
965
|
+
dataset: new DatasetGrant(),
|
|
966
966
|
memory: new MemoryGrant(),
|
|
967
967
|
sync: new SyncGrant(),
|
|
968
968
|
storage: new StorageGrant(),
|
|
@@ -978,7 +978,7 @@ class ApiScope {
|
|
|
978
978
|
livekit: new LivekitGrant(),
|
|
979
979
|
queues: new QueuesGrant(),
|
|
980
980
|
messaging: new MessagingGrant(),
|
|
981
|
-
|
|
981
|
+
dataset: new DatasetGrant(),
|
|
982
982
|
memory: new MemoryGrant(),
|
|
983
983
|
sync: new SyncGrant(),
|
|
984
984
|
storage: new StorageGrant(),
|
|
@@ -1003,8 +1003,8 @@ class ApiScope {
|
|
|
1003
1003
|
if (this.messaging !== undefined) {
|
|
1004
1004
|
json["messaging"] = this.messaging.toJSON();
|
|
1005
1005
|
}
|
|
1006
|
-
if (this.
|
|
1007
|
-
json["
|
|
1006
|
+
if (this.dataset !== undefined) {
|
|
1007
|
+
json["dataset"] = this.dataset.toJSON();
|
|
1008
1008
|
}
|
|
1009
1009
|
if (this.memory !== undefined) {
|
|
1010
1010
|
json["memory"] = this.memory.toJSON();
|
|
@@ -1045,11 +1045,12 @@ class ApiScope {
|
|
|
1045
1045
|
if (!isRecord(obj)) {
|
|
1046
1046
|
return new ApiScope();
|
|
1047
1047
|
}
|
|
1048
|
+
const rawDataset = obj.dataset ?? obj.database ?? obj.datasets;
|
|
1048
1049
|
return new ApiScope({
|
|
1049
1050
|
livekit: obj.livekit ? LivekitGrant.fromJSON(obj.livekit) : undefined,
|
|
1050
1051
|
queues: obj.queues ? QueuesGrant.fromJSON(obj.queues) : undefined,
|
|
1051
1052
|
messaging: obj.messaging ? MessagingGrant.fromJSON(obj.messaging) : undefined,
|
|
1052
|
-
|
|
1053
|
+
dataset: rawDataset ? DatasetGrant.fromJSON(rawDataset) : undefined,
|
|
1053
1054
|
memory: obj.memory ? MemoryGrant.fromJSON(obj.memory) : undefined,
|
|
1054
1055
|
sync: obj.sync ? SyncGrant.fromJSON(obj.sync) : undefined,
|
|
1055
1056
|
storage: obj.storage ? StorageGrant.fromJSON(obj.storage) : undefined,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatasetsClient } from "./datasets-client";
|
|
2
2
|
import { DeveloperClient } from "./developer-client";
|
|
3
3
|
import { type EventHandler, type EventName } from "./event-emitter";
|
|
4
4
|
import { MessagingClient } from "./messaging-client";
|
|
@@ -52,7 +52,7 @@ export declare class RoomClient {
|
|
|
52
52
|
readonly developer: DeveloperClient;
|
|
53
53
|
readonly messaging: MessagingClient;
|
|
54
54
|
readonly queues: QueuesClient;
|
|
55
|
-
readonly
|
|
55
|
+
readonly datasets: DatasetsClient;
|
|
56
56
|
readonly agents: AgentsClient;
|
|
57
57
|
readonly secrets: SecretsClient;
|
|
58
58
|
readonly containers: ContainersClient;
|
|
@@ -111,7 +111,9 @@ export declare class RoomClient {
|
|
|
111
111
|
on(eventName: EventName, callback: EventHandler<RoomEvent>): void;
|
|
112
112
|
off(eventName: EventName, callback: EventHandler<RoomEvent>): void;
|
|
113
113
|
emit(event: RoomEvent): void;
|
|
114
|
-
listen(
|
|
114
|
+
listen({ abortSignal }?: {
|
|
115
|
+
abortSignal?: AbortSignal;
|
|
116
|
+
}): AsyncIterable<RoomEvent>;
|
|
115
117
|
waitForClose(): Promise<void>;
|
|
116
118
|
waitUntilConnected(): Promise<void>;
|
|
117
119
|
_waitUntilConnectedForMessages(): Promise<void>;
|
package/dist/node/room-client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RoomClient = exports.RoomProtocolProxy = void 0;
|
|
4
4
|
const completer_1 = require("./completer");
|
|
5
|
-
const
|
|
5
|
+
const datasets_client_1 = require("./datasets-client");
|
|
6
6
|
const developer_client_1 = require("./developer-client");
|
|
7
7
|
const event_emitter_1 = require("./event-emitter");
|
|
8
8
|
const messaging_client_1 = require("./messaging-client");
|
|
@@ -248,7 +248,7 @@ class RoomClient {
|
|
|
248
248
|
this.developer = new developer_client_1.DeveloperClient({ room: this });
|
|
249
249
|
this.messaging = new messaging_client_1.MessagingClient({ room: this });
|
|
250
250
|
this.queues = new queues_client_1.QueuesClient({ room: this });
|
|
251
|
-
this.
|
|
251
|
+
this.datasets = new datasets_client_1.DatasetsClient({ room: this });
|
|
252
252
|
this.agents = new agent_client_1.AgentsClient({ room: this });
|
|
253
253
|
this.secrets = new secrets_client_1.SecretsClient({
|
|
254
254
|
room: this,
|
|
@@ -302,8 +302,74 @@ class RoomClient {
|
|
|
302
302
|
this._eventsController.add(event);
|
|
303
303
|
this._eventEmitter.emit(event.name, event);
|
|
304
304
|
}
|
|
305
|
-
listen() {
|
|
306
|
-
|
|
305
|
+
listen({ abortSignal } = {}) {
|
|
306
|
+
if (abortSignal === undefined || abortSignal === null) {
|
|
307
|
+
return this._eventsController.stream;
|
|
308
|
+
}
|
|
309
|
+
const source = this._eventsController.stream;
|
|
310
|
+
return {
|
|
311
|
+
[Symbol.asyncIterator]() {
|
|
312
|
+
const eventIterator = source[Symbol.asyncIterator]();
|
|
313
|
+
let abortReject = null;
|
|
314
|
+
let cleanedUp = false;
|
|
315
|
+
const abortError = () => {
|
|
316
|
+
if (abortSignal.reason != null) {
|
|
317
|
+
return abortSignal.reason;
|
|
318
|
+
}
|
|
319
|
+
const error = new Error("Aborted");
|
|
320
|
+
error.name = "AbortError";
|
|
321
|
+
return error;
|
|
322
|
+
};
|
|
323
|
+
const cleanup = async () => {
|
|
324
|
+
if (cleanedUp) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
cleanedUp = true;
|
|
328
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
329
|
+
await eventIterator.return?.();
|
|
330
|
+
};
|
|
331
|
+
const onAbort = () => {
|
|
332
|
+
const reject = abortReject;
|
|
333
|
+
abortReject = null;
|
|
334
|
+
reject?.(abortError());
|
|
335
|
+
void cleanup();
|
|
336
|
+
};
|
|
337
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
338
|
+
return {
|
|
339
|
+
async next() {
|
|
340
|
+
if (abortSignal.aborted) {
|
|
341
|
+
await cleanup();
|
|
342
|
+
return Promise.reject(abortError());
|
|
343
|
+
}
|
|
344
|
+
const abortPromise = new Promise((_, reject) => {
|
|
345
|
+
abortReject = reject;
|
|
346
|
+
});
|
|
347
|
+
try {
|
|
348
|
+
const result = await Promise.race([eventIterator.next(), abortPromise]);
|
|
349
|
+
if (result.done) {
|
|
350
|
+
await cleanup();
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
await cleanup();
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
abortReject = null;
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
async return() {
|
|
363
|
+
await cleanup();
|
|
364
|
+
return { done: true, value: undefined };
|
|
365
|
+
},
|
|
366
|
+
async throw(e) {
|
|
367
|
+
await cleanup();
|
|
368
|
+
return Promise.reject(e);
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
},
|
|
372
|
+
};
|
|
307
373
|
}
|
|
308
374
|
async waitForClose() {
|
|
309
375
|
await this._roomClosed.fut;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshagent/meshagent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "Meshagent Client",
|
|
5
5
|
"homepage": "https://github.com/meshagent/meshagent-ts",
|
|
6
6
|
"scripts": {
|
|
@@ -45,11 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@kayahr/text-encoding": "^2.0.0",
|
|
48
|
+
"apache-arrow": "^21.0.0",
|
|
48
49
|
"base-64": "^1.0.0",
|
|
49
50
|
"isomorphic-ws": "^5.0.0",
|
|
50
51
|
"jose": "^6.0.8",
|
|
51
52
|
"livekit-client": "^2.15.5",
|
|
52
|
-
"uuid": "^
|
|
53
|
+
"uuid": "^14.0.0",
|
|
53
54
|
"ws": "^8.18.0",
|
|
54
55
|
"yjs": "^13.6.28"
|
|
55
56
|
},
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export declare const _dataTypes: Record<string, typeof DataType>;
|
|
2
|
-
export declare abstract class DataType {
|
|
3
|
-
constructor(_?: any);
|
|
4
|
-
abstract toJson(): Record<string, unknown>;
|
|
5
|
-
static fromJson(data: any): DataType;
|
|
6
|
-
static int(): IntDataType;
|
|
7
|
-
static date(): DateDataType;
|
|
8
|
-
static float(): FloatDataType;
|
|
9
|
-
static vector({ size, elementType }: {
|
|
10
|
-
size: number;
|
|
11
|
-
elementType: DataType;
|
|
12
|
-
}): VectorDataType;
|
|
13
|
-
static text(): TextDataType;
|
|
14
|
-
static json(): JsonDataType;
|
|
15
|
-
static uuid(): UuidDataType;
|
|
16
|
-
static binary(): BinaryDataType;
|
|
17
|
-
}
|
|
18
|
-
export declare class BoolDataType extends DataType {
|
|
19
|
-
constructor();
|
|
20
|
-
static fromJson(data: any): IntDataType;
|
|
21
|
-
toJson(): Record<string, unknown>;
|
|
22
|
-
}
|
|
23
|
-
export declare class IntDataType extends DataType {
|
|
24
|
-
constructor();
|
|
25
|
-
static fromJson(data: any): IntDataType;
|
|
26
|
-
toJson(): Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
export declare class DateDataType extends DataType {
|
|
29
|
-
constructor();
|
|
30
|
-
static fromJson(data: any): DateDataType;
|
|
31
|
-
toJson(): Record<string, unknown>;
|
|
32
|
-
}
|
|
33
|
-
export declare class FloatDataType extends DataType {
|
|
34
|
-
constructor();
|
|
35
|
-
static fromJson(data: any): FloatDataType;
|
|
36
|
-
toJson(): Record<string, unknown>;
|
|
37
|
-
}
|
|
38
|
-
export declare class VectorDataType extends DataType {
|
|
39
|
-
size: number;
|
|
40
|
-
elementType: DataType;
|
|
41
|
-
constructor({ size, elementType }: {
|
|
42
|
-
size: number;
|
|
43
|
-
elementType: DataType;
|
|
44
|
-
});
|
|
45
|
-
static fromJson(data: any): VectorDataType;
|
|
46
|
-
toJson(): Record<string, unknown>;
|
|
47
|
-
}
|
|
48
|
-
export declare class TextDataType extends DataType {
|
|
49
|
-
constructor();
|
|
50
|
-
static fromJson(data: any): TextDataType;
|
|
51
|
-
toJson(): Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
export declare class JsonDataType extends DataType {
|
|
54
|
-
constructor();
|
|
55
|
-
static fromJson(data: any): JsonDataType;
|
|
56
|
-
toJson(): Record<string, unknown>;
|
|
57
|
-
}
|
|
58
|
-
export declare class UuidDataType extends DataType {
|
|
59
|
-
constructor();
|
|
60
|
-
static fromJson(data: any): UuidDataType;
|
|
61
|
-
toJson(): Record<string, unknown>;
|
|
62
|
-
}
|
|
63
|
-
export declare class BinaryDataType extends DataType {
|
|
64
|
-
constructor();
|
|
65
|
-
static fromJson(data: any): BinaryDataType;
|
|
66
|
-
toJson(): Record<string, unknown>;
|
|
67
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinaryDataType = exports.UuidDataType = exports.JsonDataType = exports.TextDataType = exports.VectorDataType = exports.FloatDataType = exports.DateDataType = exports.IntDataType = exports.BoolDataType = exports.DataType = exports._dataTypes = void 0;
|
|
4
|
-
exports._dataTypes = {};
|
|
5
|
-
class DataType {
|
|
6
|
-
constructor(_) { }
|
|
7
|
-
static fromJson(data) {
|
|
8
|
-
const ctor = exports._dataTypes[data.type];
|
|
9
|
-
if (!ctor) {
|
|
10
|
-
throw new Error(`Unknown data type: ${data.type}`);
|
|
11
|
-
}
|
|
12
|
-
return ctor.fromJson(data);
|
|
13
|
-
}
|
|
14
|
-
static int() {
|
|
15
|
-
return new IntDataType();
|
|
16
|
-
}
|
|
17
|
-
static date() {
|
|
18
|
-
return new DateDataType();
|
|
19
|
-
}
|
|
20
|
-
static float() {
|
|
21
|
-
return new FloatDataType();
|
|
22
|
-
}
|
|
23
|
-
static vector({ size, elementType }) {
|
|
24
|
-
return new VectorDataType({ size, elementType });
|
|
25
|
-
}
|
|
26
|
-
static text() {
|
|
27
|
-
return new TextDataType();
|
|
28
|
-
}
|
|
29
|
-
static json() {
|
|
30
|
-
return new JsonDataType();
|
|
31
|
-
}
|
|
32
|
-
static uuid() {
|
|
33
|
-
return new UuidDataType();
|
|
34
|
-
}
|
|
35
|
-
static binary() {
|
|
36
|
-
return new BinaryDataType();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.DataType = DataType;
|
|
40
|
-
class BoolDataType extends DataType {
|
|
41
|
-
constructor() {
|
|
42
|
-
super();
|
|
43
|
-
}
|
|
44
|
-
static fromJson(data) {
|
|
45
|
-
if (data.type !== "bool") {
|
|
46
|
-
throw new Error(`Expected type 'bool', got '${data.type}'`);
|
|
47
|
-
}
|
|
48
|
-
return new BoolDataType();
|
|
49
|
-
}
|
|
50
|
-
toJson() {
|
|
51
|
-
return { type: "bool" };
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.BoolDataType = BoolDataType;
|
|
55
|
-
exports._dataTypes["bool"] = BoolDataType;
|
|
56
|
-
class IntDataType extends DataType {
|
|
57
|
-
constructor() {
|
|
58
|
-
super();
|
|
59
|
-
}
|
|
60
|
-
static fromJson(data) {
|
|
61
|
-
if (data.type !== "int") {
|
|
62
|
-
throw new Error(`Expected type 'int', got '${data.type}'`);
|
|
63
|
-
}
|
|
64
|
-
return new IntDataType();
|
|
65
|
-
}
|
|
66
|
-
toJson() {
|
|
67
|
-
return { type: "int" };
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.IntDataType = IntDataType;
|
|
71
|
-
exports._dataTypes["int"] = IntDataType;
|
|
72
|
-
class DateDataType extends DataType {
|
|
73
|
-
constructor() {
|
|
74
|
-
super();
|
|
75
|
-
}
|
|
76
|
-
static fromJson(data) {
|
|
77
|
-
if (data.type !== "date") {
|
|
78
|
-
throw new Error(`Expected type 'date', got '${data.type}'`);
|
|
79
|
-
}
|
|
80
|
-
return new DateDataType();
|
|
81
|
-
}
|
|
82
|
-
toJson() {
|
|
83
|
-
return { type: "date" };
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.DateDataType = DateDataType;
|
|
87
|
-
exports._dataTypes["date"] = DateDataType;
|
|
88
|
-
class FloatDataType extends DataType {
|
|
89
|
-
constructor() {
|
|
90
|
-
super();
|
|
91
|
-
}
|
|
92
|
-
static fromJson(data) {
|
|
93
|
-
if (data.type !== "float") {
|
|
94
|
-
throw new Error(`Expected type 'float', got '${data.type}'`);
|
|
95
|
-
}
|
|
96
|
-
return new FloatDataType();
|
|
97
|
-
}
|
|
98
|
-
toJson() {
|
|
99
|
-
return { type: "float" };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.FloatDataType = FloatDataType;
|
|
103
|
-
exports._dataTypes["float"] = FloatDataType;
|
|
104
|
-
class VectorDataType extends DataType {
|
|
105
|
-
constructor({ size, elementType }) {
|
|
106
|
-
super();
|
|
107
|
-
this.size = size;
|
|
108
|
-
this.elementType = elementType;
|
|
109
|
-
}
|
|
110
|
-
static fromJson(data) {
|
|
111
|
-
if (data.type !== "vector") {
|
|
112
|
-
throw new Error(`Expected type 'vector', got '${data.type}'`);
|
|
113
|
-
}
|
|
114
|
-
return new VectorDataType({
|
|
115
|
-
size: data.size,
|
|
116
|
-
elementType: DataType.fromJson(data.element_type),
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
toJson() {
|
|
120
|
-
return {
|
|
121
|
-
type: "vector",
|
|
122
|
-
size: this.size,
|
|
123
|
-
element_type: this.elementType.toJson(),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.VectorDataType = VectorDataType;
|
|
128
|
-
exports._dataTypes["vector"] = VectorDataType;
|
|
129
|
-
class TextDataType extends DataType {
|
|
130
|
-
constructor() {
|
|
131
|
-
super();
|
|
132
|
-
}
|
|
133
|
-
static fromJson(data) {
|
|
134
|
-
if (data.type !== "text") {
|
|
135
|
-
throw new Error(`Expected type 'text', got '${data.type}'`);
|
|
136
|
-
}
|
|
137
|
-
return new TextDataType();
|
|
138
|
-
}
|
|
139
|
-
toJson() {
|
|
140
|
-
return { type: "text" };
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.TextDataType = TextDataType;
|
|
144
|
-
exports._dataTypes["text"] = TextDataType;
|
|
145
|
-
class JsonDataType extends DataType {
|
|
146
|
-
constructor() {
|
|
147
|
-
super();
|
|
148
|
-
}
|
|
149
|
-
static fromJson(data) {
|
|
150
|
-
if (data.type !== "json") {
|
|
151
|
-
throw new Error(`Expected type 'json', got '${data.type}'`);
|
|
152
|
-
}
|
|
153
|
-
return new JsonDataType();
|
|
154
|
-
}
|
|
155
|
-
toJson() {
|
|
156
|
-
return { type: "json" };
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.JsonDataType = JsonDataType;
|
|
160
|
-
exports._dataTypes["json"] = JsonDataType;
|
|
161
|
-
class UuidDataType extends DataType {
|
|
162
|
-
constructor() {
|
|
163
|
-
super();
|
|
164
|
-
}
|
|
165
|
-
static fromJson(data) {
|
|
166
|
-
if (data.type !== "uuid") {
|
|
167
|
-
throw new Error(`Expected type 'uuid', got '${data.type}'`);
|
|
168
|
-
}
|
|
169
|
-
return new UuidDataType();
|
|
170
|
-
}
|
|
171
|
-
toJson() {
|
|
172
|
-
return { type: "uuid" };
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.UuidDataType = UuidDataType;
|
|
176
|
-
exports._dataTypes["uuid"] = UuidDataType;
|
|
177
|
-
class BinaryDataType extends DataType {
|
|
178
|
-
constructor() {
|
|
179
|
-
super();
|
|
180
|
-
}
|
|
181
|
-
static fromJson(data) {
|
|
182
|
-
if (data.type !== "binary") {
|
|
183
|
-
throw new Error(`Expected type 'binary', got '${data.type}'`);
|
|
184
|
-
}
|
|
185
|
-
return new BinaryDataType();
|
|
186
|
-
}
|
|
187
|
-
toJson() {
|
|
188
|
-
return { type: "binary" };
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.BinaryDataType = BinaryDataType;
|
|
192
|
-
exports._dataTypes["binary"] = BinaryDataType;
|