@meshagent/meshagent 0.36.3 → 0.37.1
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 +16 -0
- package/dist/browser/agent-client.d.ts +2 -10
- package/dist/browser/agent-client.js +2 -30
- package/dist/browser/agent.d.ts +22 -22
- package/dist/browser/agent.js +36 -16
- package/dist/browser/containers-client.d.ts +7 -19
- package/dist/browser/containers-client.js +27 -21
- package/dist/browser/data-types.d.ts +12 -0
- package/dist/browser/data-types.js +39 -1
- package/dist/browser/database-client.d.ts +134 -47
- package/dist/browser/database-client.js +359 -133
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/meshagent-client.js +12 -1
- package/dist/browser/participant-token.d.ts +189 -22
- package/dist/browser/participant-token.js +1001 -189
- package/dist/browser/room-client.d.ts +1 -1
- package/dist/browser/services-client.d.ts +1 -1
- package/dist/browser/version.d.ts +1 -0
- package/dist/browser/version.js +4 -0
- package/dist/esm/agent-client.d.ts +2 -10
- package/dist/esm/agent-client.js +1 -28
- package/dist/esm/agent.d.ts +22 -22
- package/dist/esm/agent.js +33 -14
- package/dist/esm/containers-client.d.ts +7 -19
- package/dist/esm/containers-client.js +27 -21
- package/dist/esm/data-types.d.ts +12 -0
- package/dist/esm/data-types.js +36 -0
- package/dist/esm/database-client.d.ts +134 -47
- package/dist/esm/database-client.js +352 -132
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/meshagent-client.js +12 -1
- package/dist/esm/participant-token.d.ts +189 -22
- package/dist/esm/participant-token.js +992 -188
- package/dist/esm/room-client.d.ts +1 -1
- package/dist/esm/services-client.d.ts +1 -1
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +1 -0
- package/dist/node/agent-client.d.ts +2 -10
- package/dist/node/agent-client.js +2 -30
- package/dist/node/agent.d.ts +22 -22
- package/dist/node/agent.js +36 -16
- package/dist/node/containers-client.d.ts +7 -19
- package/dist/node/containers-client.js +27 -21
- package/dist/node/data-types.d.ts +12 -0
- package/dist/node/data-types.js +39 -1
- package/dist/node/database-client.d.ts +134 -47
- package/dist/node/database-client.js +359 -133
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/meshagent-client.js +12 -1
- package/dist/node/participant-token.d.ts +189 -22
- package/dist/node/participant-token.js +1001 -189
- package/dist/node/room-client.d.ts +1 -1
- package/dist/node/services-client.d.ts +1 -1
- package/dist/node/version.d.ts +1 -0
- package/dist/node/version.js +4 -0
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import { ContainersClient } from "./containers-client";
|
|
|
12
12
|
import { MemoryClient } from "./memory-client";
|
|
13
13
|
import { ServicesClient } from "./services-client";
|
|
14
14
|
import { RoomEvent } from "./room-event";
|
|
15
|
-
import { Content } from "./response";
|
|
15
|
+
import { type Content } from "./response";
|
|
16
16
|
interface RequestHeader {
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const __version__ = "0.36.3";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
|
-
import { Content } from "./response";
|
|
2
|
+
import type { Content } from "./response";
|
|
3
3
|
import { ToolContentSpec } from "./tool-content-type";
|
|
4
4
|
export declare class ToolDescription {
|
|
5
5
|
title: string;
|
|
@@ -10,8 +10,7 @@ export declare class ToolDescription {
|
|
|
10
10
|
defs?: Record<string, any>;
|
|
11
11
|
thumbnailUrl?: string;
|
|
12
12
|
pricing?: string;
|
|
13
|
-
|
|
14
|
-
constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing, supportsContext }: {
|
|
13
|
+
constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing }: {
|
|
15
14
|
title: string;
|
|
16
15
|
name: string;
|
|
17
16
|
description: string;
|
|
@@ -22,7 +21,6 @@ export declare class ToolDescription {
|
|
|
22
21
|
thumbnailUrl?: string;
|
|
23
22
|
defs?: Record<string, any>;
|
|
24
23
|
pricing?: string;
|
|
25
|
-
supportsContext?: boolean;
|
|
26
24
|
});
|
|
27
25
|
get inputSchema(): Record<string, any> | undefined;
|
|
28
26
|
get outputSchema(): Record<string, any> | undefined;
|
|
@@ -49,12 +47,6 @@ export declare class ToolkitDescription {
|
|
|
49
47
|
name?: string;
|
|
50
48
|
}): ToolkitDescription;
|
|
51
49
|
}
|
|
52
|
-
export declare class ToolkitConfiguration {
|
|
53
|
-
name: string;
|
|
54
|
-
use?: string[] | undefined;
|
|
55
|
-
constructor(name: string, use?: string[] | undefined);
|
|
56
|
-
toJson(): Record<string, any>;
|
|
57
|
-
}
|
|
58
50
|
export declare class AgentsClient {
|
|
59
51
|
private client;
|
|
60
52
|
constructor({ room }: {
|
package/dist/esm/agent-client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToolContentSpec } from "./tool-content-type";
|
|
2
2
|
export class ToolDescription {
|
|
3
|
-
constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing
|
|
3
|
+
constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing }) {
|
|
4
4
|
this.title = title;
|
|
5
5
|
this.name = name;
|
|
6
6
|
this.description = description;
|
|
@@ -41,7 +41,6 @@ export class ToolDescription {
|
|
|
41
41
|
this.thumbnailUrl = thumbnailUrl;
|
|
42
42
|
this.defs = defs;
|
|
43
43
|
this.pricing = pricing;
|
|
44
|
-
this.supportsContext = supportsContext ?? false;
|
|
45
44
|
}
|
|
46
45
|
get inputSchema() {
|
|
47
46
|
return this.inputSpec?.schema;
|
|
@@ -81,7 +80,6 @@ export class ToolkitDescription {
|
|
|
81
80
|
thumbnail_url: tool.thumbnailUrl,
|
|
82
81
|
defs: tool.defs,
|
|
83
82
|
pricing: tool.pricing,
|
|
84
|
-
supports_context: tool.supportsContext,
|
|
85
83
|
})),
|
|
86
84
|
};
|
|
87
85
|
}
|
|
@@ -106,7 +104,6 @@ export class ToolkitDescription {
|
|
|
106
104
|
thumbnailUrl: tool["thumbnail_url"],
|
|
107
105
|
defs: tool["defs"],
|
|
108
106
|
pricing: tool["pricing"],
|
|
109
|
-
supportsContext: tool["supports_context"] ?? tool["supportsContext"],
|
|
110
107
|
}));
|
|
111
108
|
}
|
|
112
109
|
}
|
|
@@ -125,7 +122,6 @@ export class ToolkitDescription {
|
|
|
125
122
|
thumbnailUrl: tool["thumbnail_url"],
|
|
126
123
|
defs: tool["defs"],
|
|
127
124
|
pricing: tool["pricing"],
|
|
128
|
-
supportsContext: tool["supports_context"] ?? tool["supportsContext"],
|
|
129
125
|
}));
|
|
130
126
|
}
|
|
131
127
|
}
|
|
@@ -139,29 +135,6 @@ export class ToolkitDescription {
|
|
|
139
135
|
});
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
|
-
export class ToolkitConfiguration {
|
|
143
|
-
constructor(name, use) {
|
|
144
|
-
this.name = name;
|
|
145
|
-
this.use = use;
|
|
146
|
-
}
|
|
147
|
-
toJson() {
|
|
148
|
-
if (!this.use) {
|
|
149
|
-
return {
|
|
150
|
-
[this.name]: {},
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
return {
|
|
155
|
-
[this.name]: {
|
|
156
|
-
use: this.use.reduce((acc, tool) => {
|
|
157
|
-
acc[tool] = {};
|
|
158
|
-
return acc;
|
|
159
|
-
}, {}),
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
138
|
export class AgentsClient {
|
|
166
139
|
constructor({ room }) {
|
|
167
140
|
this.client = room;
|
package/dist/esm/agent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
2
|
import { RequiredToolkit } from "./requirement";
|
|
3
|
-
import { Content } from "./response";
|
|
3
|
+
import { type Content } from "./response";
|
|
4
4
|
import { ToolContentSpec } from "./tool-content-type";
|
|
5
5
|
export declare abstract class Tool {
|
|
6
6
|
readonly name: string;
|
|
@@ -23,10 +23,18 @@ export declare abstract class Tool {
|
|
|
23
23
|
get outputSchema(): Record<string, any> | undefined;
|
|
24
24
|
abstract execute(arguments_: Record<string, any>): Promise<Content>;
|
|
25
25
|
}
|
|
26
|
-
export declare
|
|
26
|
+
export declare class Toolkit {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly title: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly thumbnailUrl?: string;
|
|
27
31
|
readonly tools: Tool[];
|
|
28
32
|
readonly rules: string[];
|
|
29
|
-
constructor({ tools, rules }: {
|
|
33
|
+
constructor({ name, title, description, thumbnailUrl, tools, rules }: {
|
|
34
|
+
name: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
thumbnailUrl?: string;
|
|
30
38
|
tools: Tool[];
|
|
31
39
|
rules?: string[];
|
|
32
40
|
});
|
|
@@ -34,28 +42,20 @@ export declare abstract class Toolkit {
|
|
|
34
42
|
getTools(): Record<string, any>;
|
|
35
43
|
execute(name: string, args: Record<string, any>): Promise<Content>;
|
|
36
44
|
}
|
|
37
|
-
export declare
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
constructor({ name, title, description, room, tools, rules }: {
|
|
44
|
-
name: string;
|
|
45
|
-
title: string;
|
|
46
|
-
description: string;
|
|
47
|
-
room: RoomClient;
|
|
48
|
-
tools: Tool[];
|
|
49
|
-
rules?: string[];
|
|
45
|
+
export declare class HostedToolkit {
|
|
46
|
+
readonly toolkit: Toolkit;
|
|
47
|
+
private readonly _stopHostedToolkit;
|
|
48
|
+
constructor({ toolkit, stopHostedToolkit }: {
|
|
49
|
+
toolkit: Toolkit;
|
|
50
|
+
stopHostedToolkit: () => Promise<void>;
|
|
50
51
|
});
|
|
51
|
-
start({ public_: isPublic }?: {
|
|
52
|
-
public_?: boolean;
|
|
53
|
-
}): Promise<void>;
|
|
54
52
|
stop(): Promise<void>;
|
|
55
|
-
private _register;
|
|
56
|
-
private _unregister;
|
|
57
|
-
private _toolCall;
|
|
58
53
|
}
|
|
54
|
+
export declare function startHostedToolkit({ room, toolkit, public_: isPublic }: {
|
|
55
|
+
room: RoomClient;
|
|
56
|
+
toolkit: Toolkit;
|
|
57
|
+
public_?: boolean;
|
|
58
|
+
}): Promise<HostedToolkit>;
|
|
59
59
|
export declare abstract class RemoteTaskRunner {
|
|
60
60
|
protected readonly client: RoomClient;
|
|
61
61
|
protected readonly name: string;
|
package/dist/esm/agent.js
CHANGED
|
@@ -50,7 +50,11 @@ export class Tool {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
export class Toolkit {
|
|
53
|
-
constructor({ tools, rules = [] }) {
|
|
53
|
+
constructor({ name, title = name, description = "", thumbnailUrl, tools, rules = [] }) {
|
|
54
|
+
this.name = name;
|
|
55
|
+
this.title = title;
|
|
56
|
+
this.description = description;
|
|
57
|
+
this.thumbnailUrl = thumbnailUrl;
|
|
54
58
|
this.tools = tools;
|
|
55
59
|
this.rules = rules;
|
|
56
60
|
}
|
|
@@ -78,30 +82,37 @@ export class Toolkit {
|
|
|
78
82
|
return this.getTool(name).execute(args);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
|
-
export class
|
|
82
|
-
constructor({
|
|
83
|
-
|
|
85
|
+
export class HostedToolkit {
|
|
86
|
+
constructor({ toolkit, stopHostedToolkit }) {
|
|
87
|
+
this.toolkit = toolkit;
|
|
88
|
+
this._stopHostedToolkit = stopHostedToolkit;
|
|
89
|
+
}
|
|
90
|
+
async stop() {
|
|
91
|
+
await this._stopHostedToolkit();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
class _RemoteToolkitWrapper {
|
|
95
|
+
constructor({ toolkit, room }) {
|
|
96
|
+
this.toolkit = toolkit;
|
|
84
97
|
this.client = room;
|
|
85
|
-
this.name = name;
|
|
86
|
-
this.title = title;
|
|
87
|
-
this.description = description;
|
|
88
98
|
}
|
|
89
99
|
async start({ public_: isPublic = false } = {}) {
|
|
90
100
|
const handler = this._toolCall.bind(this);
|
|
91
|
-
this.client.protocol.addHandler(`room.tool_call.${this.name}`, handler);
|
|
101
|
+
this.client.protocol.addHandler(`room.tool_call.${this.toolkit.name}`, handler);
|
|
92
102
|
await this._register(isPublic);
|
|
93
103
|
}
|
|
94
104
|
async stop() {
|
|
95
105
|
await this._unregister();
|
|
96
|
-
this.client.protocol.removeHandler(`room.tool_call.${this.name}`);
|
|
106
|
+
this.client.protocol.removeHandler(`room.tool_call.${this.toolkit.name}`);
|
|
97
107
|
}
|
|
98
108
|
async _register(public_) {
|
|
99
109
|
const response = await this.client.sendRequest("room.register_toolkit", {
|
|
100
|
-
name: this.name,
|
|
101
|
-
title: this.title,
|
|
102
|
-
description: this.description,
|
|
103
|
-
tools: this.getTools(),
|
|
110
|
+
name: this.toolkit.name,
|
|
111
|
+
title: this.toolkit.title,
|
|
112
|
+
description: this.toolkit.description,
|
|
113
|
+
tools: this.toolkit.getTools(),
|
|
104
114
|
public: public_,
|
|
115
|
+
thumbnail_url: this.toolkit.thumbnailUrl,
|
|
105
116
|
});
|
|
106
117
|
const json = response.json;
|
|
107
118
|
this._registrationId = json["id"];
|
|
@@ -138,7 +149,7 @@ export class RemoteToolkit extends Toolkit {
|
|
|
138
149
|
else {
|
|
139
150
|
args = rawArguments ?? {};
|
|
140
151
|
}
|
|
141
|
-
const response = await this.execute(toolName, args);
|
|
152
|
+
const response = await this.toolkit.execute(toolName, args);
|
|
142
153
|
await this.client.protocol.send("room.tool_call_response", response.pack(), messageId);
|
|
143
154
|
}
|
|
144
155
|
catch (e) {
|
|
@@ -147,6 +158,14 @@ export class RemoteToolkit extends Toolkit {
|
|
|
147
158
|
}
|
|
148
159
|
}
|
|
149
160
|
}
|
|
161
|
+
export async function startHostedToolkit({ room, toolkit, public_: isPublic = false }) {
|
|
162
|
+
const wrapper = new _RemoteToolkitWrapper({ toolkit, room });
|
|
163
|
+
await wrapper.start({ public_: isPublic });
|
|
164
|
+
return new HostedToolkit({
|
|
165
|
+
toolkit,
|
|
166
|
+
stopHostedToolkit: () => wrapper.stop(),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
150
169
|
export class RemoteTaskRunner {
|
|
151
170
|
constructor({ name, description, client, inputSchema, outputSchema, supportsTools = false, required = [], }) {
|
|
152
171
|
this.client = client;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ContainerMountSpec } from "./meshagent-client";
|
|
2
|
-
import { Content } from "./response";
|
|
1
|
+
import type { ContainerMountSpec } from "./meshagent-client";
|
|
2
|
+
import { type Content } from "./response";
|
|
3
3
|
import { RoomClient } from "./room-client";
|
|
4
4
|
export interface DockerSecret {
|
|
5
5
|
username: string;
|
|
@@ -138,29 +138,17 @@ export declare class ContainersClient {
|
|
|
138
138
|
writableRootFs?: boolean;
|
|
139
139
|
private?: boolean;
|
|
140
140
|
}): Promise<string>;
|
|
141
|
-
startBuild(params: {
|
|
142
|
-
tag: string;
|
|
143
|
-
mounts: ContainerMountSpec[];
|
|
144
|
-
contextPath: string;
|
|
145
|
-
dockerfilePath?: string;
|
|
146
|
-
private?: boolean;
|
|
147
|
-
credentials?: DockerSecret[];
|
|
148
|
-
contextArchivePath?: string;
|
|
149
|
-
contextArchiveRef?: string;
|
|
150
|
-
contextArchiveMountPath?: string;
|
|
151
|
-
contextArchiveArch?: string;
|
|
152
|
-
}): Promise<string>;
|
|
153
141
|
build(params: {
|
|
154
142
|
tag: string;
|
|
155
|
-
|
|
143
|
+
mountPath: string;
|
|
156
144
|
contextPath: string;
|
|
145
|
+
chunks: AsyncIterable<Uint8Array>;
|
|
157
146
|
dockerfilePath?: string;
|
|
147
|
+
optimizeImage?: boolean;
|
|
158
148
|
private?: boolean;
|
|
159
149
|
credentials?: DockerSecret[];
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
contextArchiveMountPath?: string;
|
|
163
|
-
contextArchiveArch?: string;
|
|
150
|
+
builderName?: string;
|
|
151
|
+
size?: number;
|
|
164
152
|
}): Promise<string>;
|
|
165
153
|
listBuilds(): Promise<BuildJob[]>;
|
|
166
154
|
cancelBuild(params: {
|
|
@@ -131,19 +131,28 @@ function parseBuildJob(data, operation) {
|
|
|
131
131
|
exitCode: readOptionalIntegerField(data, "exit_code", operation),
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
async function* buildInputStream(params) {
|
|
135
|
+
yield new BinaryContent({
|
|
136
|
+
data: new Uint8Array(0),
|
|
137
|
+
headers: {
|
|
138
|
+
kind: "start",
|
|
139
|
+
tag: params.tag,
|
|
140
|
+
mount_path: params.mountPath,
|
|
141
|
+
context_path: params.contextPath,
|
|
142
|
+
dockerfile_path: params.dockerfilePath ?? null,
|
|
143
|
+
optimize_image: params.optimizeImage ?? true,
|
|
144
|
+
private: params.private ?? false,
|
|
145
|
+
credentials: toCredentials(params.credentials ?? []),
|
|
146
|
+
builder_name: params.builderName ?? null,
|
|
147
|
+
size: params.size ?? null,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
for await (const chunk of params.chunks) {
|
|
151
|
+
yield new BinaryContent({
|
|
152
|
+
data: new Uint8Array(chunk),
|
|
153
|
+
headers: { kind: "data" },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
147
156
|
}
|
|
148
157
|
export class ExecSession {
|
|
149
158
|
constructor(params) {
|
|
@@ -383,15 +392,12 @@ export class ContainersClient {
|
|
|
383
392
|
}
|
|
384
393
|
return readStringField(output.json, "container_id", "run");
|
|
385
394
|
}
|
|
386
|
-
async startBuild(params) {
|
|
387
|
-
const output = await this.invoke("start_build", buildRequestPayload(params));
|
|
388
|
-
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
389
|
-
throw this.unexpectedResponseError("start_build");
|
|
390
|
-
}
|
|
391
|
-
return readStringField(output.json, "build_id", "start_build");
|
|
392
|
-
}
|
|
393
395
|
async build(params) {
|
|
394
|
-
const output = await this.
|
|
396
|
+
const output = await this.room.invokeWithStreamInput({
|
|
397
|
+
toolkit: "containers",
|
|
398
|
+
tool: "build",
|
|
399
|
+
input: buildInputStream(params),
|
|
400
|
+
});
|
|
395
401
|
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
396
402
|
throw this.unexpectedResponseError("build");
|
|
397
403
|
}
|
package/dist/esm/data-types.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare abstract class DataType {
|
|
|
11
11
|
elementType: DataType;
|
|
12
12
|
}): VectorDataType;
|
|
13
13
|
static text(): TextDataType;
|
|
14
|
+
static json(): JsonDataType;
|
|
15
|
+
static uuid(): UuidDataType;
|
|
14
16
|
static binary(): BinaryDataType;
|
|
15
17
|
}
|
|
16
18
|
export declare class BoolDataType extends DataType {
|
|
@@ -48,6 +50,16 @@ export declare class TextDataType extends DataType {
|
|
|
48
50
|
static fromJson(data: any): TextDataType;
|
|
49
51
|
toJson(): Record<string, unknown>;
|
|
50
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
|
+
}
|
|
51
63
|
export declare class BinaryDataType extends DataType {
|
|
52
64
|
constructor();
|
|
53
65
|
static fromJson(data: any): BinaryDataType;
|
package/dist/esm/data-types.js
CHANGED
|
@@ -23,6 +23,12 @@ export class DataType {
|
|
|
23
23
|
static text() {
|
|
24
24
|
return new TextDataType();
|
|
25
25
|
}
|
|
26
|
+
static json() {
|
|
27
|
+
return new JsonDataType();
|
|
28
|
+
}
|
|
29
|
+
static uuid() {
|
|
30
|
+
return new UuidDataType();
|
|
31
|
+
}
|
|
26
32
|
static binary() {
|
|
27
33
|
return new BinaryDataType();
|
|
28
34
|
}
|
|
@@ -126,6 +132,36 @@ export class TextDataType extends DataType {
|
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
_dataTypes["text"] = TextDataType;
|
|
135
|
+
export class JsonDataType extends DataType {
|
|
136
|
+
constructor() {
|
|
137
|
+
super();
|
|
138
|
+
}
|
|
139
|
+
static fromJson(data) {
|
|
140
|
+
if (data.type !== "json") {
|
|
141
|
+
throw new Error(`Expected type 'json', got '${data.type}'`);
|
|
142
|
+
}
|
|
143
|
+
return new JsonDataType();
|
|
144
|
+
}
|
|
145
|
+
toJson() {
|
|
146
|
+
return { type: "json" };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
_dataTypes["json"] = JsonDataType;
|
|
150
|
+
export class UuidDataType extends DataType {
|
|
151
|
+
constructor() {
|
|
152
|
+
super();
|
|
153
|
+
}
|
|
154
|
+
static fromJson(data) {
|
|
155
|
+
if (data.type !== "uuid") {
|
|
156
|
+
throw new Error(`Expected type 'uuid', got '${data.type}'`);
|
|
157
|
+
}
|
|
158
|
+
return new UuidDataType();
|
|
159
|
+
}
|
|
160
|
+
toJson() {
|
|
161
|
+
return { type: "uuid" };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
_dataTypes["uuid"] = UuidDataType;
|
|
129
165
|
export class BinaryDataType extends DataType {
|
|
130
166
|
constructor() {
|
|
131
167
|
super();
|