@meshagent/meshagent 0.5.19 → 0.6.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 +3 -0
- package/dist/browser/agent-client.d.ts +15 -7
- package/dist/browser/agent-client.js +52 -14
- package/dist/browser/api_keys.d.ts +13 -0
- package/dist/browser/api_keys.js +185 -0
- package/dist/browser/data-types.d.ts +6 -0
- package/dist/browser/data-types.js +20 -1
- package/dist/browser/entrypoint.d.ts +1423 -1464
- package/dist/browser/helpers.d.ts +9 -7
- package/dist/browser/helpers.js +18 -5
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +3 -0
- package/dist/browser/lk-client.d.ts +18 -0
- package/dist/browser/lk-client.js +24 -0
- package/dist/browser/lk-protocol.d.ts +22 -0
- package/dist/browser/lk-protocol.js +37 -0
- package/dist/browser/meshagent-client.d.ts +392 -0
- package/dist/browser/meshagent-client.js +1051 -0
- package/dist/browser/participant-token.d.ts +179 -7
- package/dist/browser/participant-token.js +373 -21
- package/dist/browser/stream-controller.js +3 -14
- package/dist/esm/agent-client.d.ts +15 -7
- package/dist/esm/agent-client.js +52 -14
- package/dist/esm/api_keys.d.ts +13 -0
- package/dist/esm/api_keys.js +175 -0
- package/dist/esm/data-types.d.ts +6 -0
- package/dist/esm/data-types.js +18 -0
- package/dist/esm/entrypoint.d.ts +1423 -1464
- package/dist/esm/helpers.d.ts +9 -7
- package/dist/esm/helpers.js +19 -6
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/lk-client.d.ts +18 -0
- package/dist/esm/lk-client.js +19 -0
- package/dist/esm/lk-protocol.d.ts +22 -0
- package/dist/esm/lk-protocol.js +33 -0
- package/dist/esm/meshagent-client.d.ts +392 -0
- package/dist/esm/meshagent-client.js +1047 -0
- package/dist/esm/participant-token.d.ts +179 -7
- package/dist/esm/participant-token.js +357 -20
- package/dist/esm/stream-controller.js +3 -14
- package/dist/node/agent-client.d.ts +15 -7
- package/dist/node/agent-client.js +52 -14
- package/dist/node/api_keys.d.ts +13 -0
- package/dist/node/api_keys.js +185 -0
- package/dist/node/data-types.d.ts +6 -0
- package/dist/node/data-types.js +20 -1
- package/dist/node/entrypoint.d.ts +1423 -1464
- package/dist/node/helpers.d.ts +9 -7
- package/dist/node/helpers.js +18 -5
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +3 -0
- package/dist/node/lk-client.d.ts +18 -0
- package/dist/node/lk-client.js +24 -0
- package/dist/node/lk-protocol.d.ts +22 -0
- package/dist/node/lk-protocol.js +37 -0
- package/dist/node/meshagent-client.d.ts +392 -0
- package/dist/node/meshagent-client.js +1051 -0
- package/dist/node/participant-token.d.ts +179 -7
- package/dist/node/participant-token.js +373 -21
- package/dist/node/stream-controller.js +3 -14
- package/package.json +6 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
|
-
import { Response } from "./response";
|
|
2
|
+
import { Response, JsonResponse } from "./response";
|
|
3
|
+
import { RemoteParticipant } from "./participant";
|
|
3
4
|
import { Requirement } from "./requirement";
|
|
4
5
|
export declare class AgentDescription {
|
|
5
6
|
readonly name: string;
|
|
@@ -16,10 +17,11 @@ export declare class AgentDescription {
|
|
|
16
17
|
description: string;
|
|
17
18
|
outputSchema?: Record<string, any>;
|
|
18
19
|
inputSchema?: Record<string, any>;
|
|
19
|
-
requires
|
|
20
|
-
labels
|
|
20
|
+
requires?: Requirement[];
|
|
21
|
+
labels?: string[];
|
|
21
22
|
supportsTools: boolean;
|
|
22
23
|
});
|
|
24
|
+
toJson(): Record<string, any>;
|
|
23
25
|
static fromJson(a: Record<string, any>): AgentDescription;
|
|
24
26
|
}
|
|
25
27
|
export declare class ToolDescription {
|
|
@@ -29,13 +31,17 @@ export declare class ToolDescription {
|
|
|
29
31
|
inputSchema: Record<string, any>;
|
|
30
32
|
defs?: Record<string, any>;
|
|
31
33
|
thumbnailUrl?: string;
|
|
32
|
-
|
|
34
|
+
pricing?: string;
|
|
35
|
+
supportsContext?: boolean;
|
|
36
|
+
constructor({ title, name, description, inputSchema, thumbnailUrl, defs, pricing, supportsContext }: {
|
|
33
37
|
title: string;
|
|
34
38
|
name: string;
|
|
35
39
|
description: string;
|
|
36
40
|
inputSchema: Record<string, any>;
|
|
37
41
|
thumbnailUrl?: string;
|
|
38
42
|
defs?: Record<string, any>;
|
|
43
|
+
pricing?: string;
|
|
44
|
+
supportsContext?: boolean;
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
47
|
export declare class ToolkitDescription {
|
|
@@ -53,6 +59,7 @@ export declare class ToolkitDescription {
|
|
|
53
59
|
thumbnailUrl?: string;
|
|
54
60
|
});
|
|
55
61
|
getTool(name: string): ToolDescription | undefined;
|
|
62
|
+
toJson(): Record<string, any>;
|
|
56
63
|
static fromJson(json: Record<string, any>, opts?: {
|
|
57
64
|
name?: string;
|
|
58
65
|
}): ToolkitDescription;
|
|
@@ -74,10 +81,11 @@ export declare class AgentsClient {
|
|
|
74
81
|
arguments: Record<string, any>;
|
|
75
82
|
}): Promise<void>;
|
|
76
83
|
ask(params: {
|
|
77
|
-
|
|
78
|
-
toolkits?: ToolkitConfiguration[];
|
|
84
|
+
agent: string;
|
|
79
85
|
arguments: Record<string, any>;
|
|
80
|
-
|
|
86
|
+
onBehalfOf?: RemoteParticipant;
|
|
87
|
+
requires?: Requirement[];
|
|
88
|
+
}): Promise<JsonResponse>;
|
|
81
89
|
listToolkits(): Promise<ToolkitDescription[]>;
|
|
82
90
|
listAgents(): Promise<AgentDescription[]>;
|
|
83
91
|
invokeTool(params: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AgentsClient = exports.ToolkitConfiguration = exports.ToolkitDescription = exports.ToolDescription = exports.AgentDescription = void 0;
|
|
4
|
+
const response_1 = require("./response");
|
|
4
5
|
const requirement_1 = require("./requirement");
|
|
5
6
|
class AgentDescription {
|
|
6
7
|
constructor({ name, title, description, outputSchema, inputSchema, requires, labels, supportsTools, }) {
|
|
@@ -9,9 +10,21 @@ class AgentDescription {
|
|
|
9
10
|
this.description = description;
|
|
10
11
|
this.outputSchema = outputSchema;
|
|
11
12
|
this.inputSchema = inputSchema;
|
|
12
|
-
this.requires = requires;
|
|
13
|
-
this.labels = labels;
|
|
14
|
-
this.supportsTools = supportsTools;
|
|
13
|
+
this.requires = Array.isArray(requires) ? requires : [];
|
|
14
|
+
this.labels = Array.isArray(labels) ? labels : [];
|
|
15
|
+
this.supportsTools = supportsTools ?? false;
|
|
16
|
+
}
|
|
17
|
+
toJson() {
|
|
18
|
+
return {
|
|
19
|
+
name: this.name,
|
|
20
|
+
title: this.title,
|
|
21
|
+
description: this.description,
|
|
22
|
+
input_schema: this.inputSchema,
|
|
23
|
+
output_schema: this.outputSchema,
|
|
24
|
+
labels: this.labels,
|
|
25
|
+
supports_tools: this.supportsTools,
|
|
26
|
+
requires: this.requires.map((requirement) => requirement.toJson()),
|
|
27
|
+
};
|
|
15
28
|
}
|
|
16
29
|
static fromJson(a) {
|
|
17
30
|
let requires = [];
|
|
@@ -44,13 +57,15 @@ class AgentDescription {
|
|
|
44
57
|
}
|
|
45
58
|
exports.AgentDescription = AgentDescription;
|
|
46
59
|
class ToolDescription {
|
|
47
|
-
constructor({ title, name, description, inputSchema, thumbnailUrl, defs }) {
|
|
60
|
+
constructor({ title, name, description, inputSchema, thumbnailUrl, defs, pricing, supportsContext }) {
|
|
48
61
|
this.title = title;
|
|
49
62
|
this.name = name;
|
|
50
63
|
this.description = description;
|
|
51
64
|
this.inputSchema = inputSchema;
|
|
52
65
|
this.thumbnailUrl = thumbnailUrl;
|
|
53
66
|
this.defs = defs;
|
|
67
|
+
this.pricing = pricing;
|
|
68
|
+
this.supportsContext = supportsContext ?? false;
|
|
54
69
|
}
|
|
55
70
|
}
|
|
56
71
|
exports.ToolDescription = ToolDescription;
|
|
@@ -66,6 +81,22 @@ class ToolkitDescription {
|
|
|
66
81
|
getTool(name) {
|
|
67
82
|
return this._byName.get(name);
|
|
68
83
|
}
|
|
84
|
+
toJson() {
|
|
85
|
+
return {
|
|
86
|
+
name: this.name,
|
|
87
|
+
description: this.description,
|
|
88
|
+
title: this.title,
|
|
89
|
+
thumbnail_url: this.thumbnailUrl,
|
|
90
|
+
tools: this.tools.map((tool) => ({
|
|
91
|
+
name: tool.name,
|
|
92
|
+
title: tool.title,
|
|
93
|
+
description: tool.description,
|
|
94
|
+
input_schema: tool.inputSchema,
|
|
95
|
+
thumbnail_url: tool.thumbnailUrl,
|
|
96
|
+
defs: tool.defs,
|
|
97
|
+
})),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
69
100
|
static fromJson(json, opts) {
|
|
70
101
|
const { name } = opts ?? {};
|
|
71
102
|
const title = json["title"] ?? "";
|
|
@@ -82,6 +113,8 @@ class ToolkitDescription {
|
|
|
82
113
|
inputSchema: tool["input_schema"],
|
|
83
114
|
thumbnailUrl: tool["thumbnail_url"],
|
|
84
115
|
defs: tool["defs"],
|
|
116
|
+
pricing: tool["pricing"],
|
|
117
|
+
supportsContext: tool["supportsContext"],
|
|
85
118
|
}));
|
|
86
119
|
}
|
|
87
120
|
}
|
|
@@ -96,6 +129,8 @@ class ToolkitDescription {
|
|
|
96
129
|
inputSchema: tool["input_schema"],
|
|
97
130
|
thumbnailUrl: tool["thumbnail_url"],
|
|
98
131
|
defs: tool["defs"],
|
|
132
|
+
pricing: tool["pricing"],
|
|
133
|
+
supportsContext: tool["supportsContext"],
|
|
99
134
|
}));
|
|
100
135
|
}
|
|
101
136
|
}
|
|
@@ -141,17 +176,20 @@ class AgentsClient {
|
|
|
141
176
|
await this.client.sendRequest("agent.call", params);
|
|
142
177
|
}
|
|
143
178
|
async ask(params) {
|
|
144
|
-
const {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
Object.assign(usedToolkits, t.toJson());
|
|
148
|
-
}
|
|
149
|
-
const result = (await this.client.sendRequest("agent.ask", {
|
|
150
|
-
agent: agentName,
|
|
179
|
+
const { agent, arguments: args, onBehalfOf, requires } = params;
|
|
180
|
+
const payload = {
|
|
181
|
+
agent,
|
|
151
182
|
arguments: args,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
183
|
+
};
|
|
184
|
+
if (onBehalfOf) {
|
|
185
|
+
payload["on_behalf_of_id"] = onBehalfOf.id;
|
|
186
|
+
}
|
|
187
|
+
if (requires && requires.length > 0) {
|
|
188
|
+
payload["requires"] = requires.map((req) => req.toJson());
|
|
189
|
+
}
|
|
190
|
+
const result = (await this.client.sendRequest("agent.ask", payload));
|
|
191
|
+
const answer = (result.json["answer"] ?? {});
|
|
192
|
+
return new response_1.JsonResponse({ json: answer });
|
|
155
193
|
}
|
|
156
194
|
async listToolkits() {
|
|
157
195
|
const result = (await this.client.sendRequest("agent.list_toolkits", {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function base36Encode(value: bigint | number): string;
|
|
2
|
+
export declare function base36Decode(numberStr: string): bigint;
|
|
3
|
+
export declare function compressUuid(guidString: string): string;
|
|
4
|
+
export declare function decompressUuid(compressedUuid: string): string;
|
|
5
|
+
export declare function base64CompressUuid(id: string): string;
|
|
6
|
+
export declare function base64DecompressUuid(id: string): string;
|
|
7
|
+
export interface ApiKey {
|
|
8
|
+
id: string;
|
|
9
|
+
projectId: string;
|
|
10
|
+
secret: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseApiKey(key: string): ApiKey;
|
|
13
|
+
export declare function encodeApiKey(key: ApiKey): string;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.base36Encode = base36Encode;
|
|
4
|
+
exports.base36Decode = base36Decode;
|
|
5
|
+
exports.compressUuid = compressUuid;
|
|
6
|
+
exports.decompressUuid = decompressUuid;
|
|
7
|
+
exports.base64CompressUuid = base64CompressUuid;
|
|
8
|
+
exports.base64DecompressUuid = base64DecompressUuid;
|
|
9
|
+
exports.parseApiKey = parseApiKey;
|
|
10
|
+
exports.encodeApiKey = encodeApiKey;
|
|
11
|
+
const base_64_1 = require("base-64");
|
|
12
|
+
const BASE36_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
13
|
+
const BASE36 = 36n;
|
|
14
|
+
const UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
|
|
15
|
+
function toBigInt(value) {
|
|
16
|
+
if (typeof value === "bigint") {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === "number") {
|
|
20
|
+
if (!Number.isInteger(value)) {
|
|
21
|
+
throw new TypeError("number must be an integer");
|
|
22
|
+
}
|
|
23
|
+
return BigInt(value);
|
|
24
|
+
}
|
|
25
|
+
throw new TypeError("number must be an integer");
|
|
26
|
+
}
|
|
27
|
+
function base36Encode(value) {
|
|
28
|
+
const number = toBigInt(value);
|
|
29
|
+
if (number < 0n) {
|
|
30
|
+
throw new RangeError("number must be non-negative");
|
|
31
|
+
}
|
|
32
|
+
if (number === 0n) {
|
|
33
|
+
return "0";
|
|
34
|
+
}
|
|
35
|
+
let current = number;
|
|
36
|
+
let base36 = "";
|
|
37
|
+
while (current > 0n) {
|
|
38
|
+
const remainder = Number(current % BASE36);
|
|
39
|
+
base36 = BASE36_ALPHABET[remainder] + base36;
|
|
40
|
+
current /= BASE36;
|
|
41
|
+
}
|
|
42
|
+
return base36;
|
|
43
|
+
}
|
|
44
|
+
function base36Decode(numberStr) {
|
|
45
|
+
const sanitized = numberStr.trim().toLowerCase();
|
|
46
|
+
if (sanitized === "") {
|
|
47
|
+
return 0n;
|
|
48
|
+
}
|
|
49
|
+
let result = 0n;
|
|
50
|
+
for (const char of sanitized) {
|
|
51
|
+
const value = BASE36_ALPHABET.indexOf(char);
|
|
52
|
+
if (value === -1) {
|
|
53
|
+
throw new RangeError(`Invalid character '${char}' for base36 encoding`);
|
|
54
|
+
}
|
|
55
|
+
result = result * BASE36 + BigInt(value);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
function normalizeUuidHex(id) {
|
|
60
|
+
const trimmed = id.trim().toLowerCase().replace(/-/g, "");
|
|
61
|
+
if (!UUID_HEX_REGEX.test(trimmed)) {
|
|
62
|
+
throw new Error("invalid uuid format");
|
|
63
|
+
}
|
|
64
|
+
return trimmed;
|
|
65
|
+
}
|
|
66
|
+
function formatUuidFromHex(hex) {
|
|
67
|
+
return (`${hex.substring(0, 8)}-` +
|
|
68
|
+
`${hex.substring(8, 12)}-` +
|
|
69
|
+
`${hex.substring(12, 16)}-` +
|
|
70
|
+
`${hex.substring(16, 20)}-` +
|
|
71
|
+
`${hex.substring(20)}`);
|
|
72
|
+
}
|
|
73
|
+
function hexToBytes(hex) {
|
|
74
|
+
if (hex.length % 2 !== 0) {
|
|
75
|
+
throw new Error("invalid hex string length");
|
|
76
|
+
}
|
|
77
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
78
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
79
|
+
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
80
|
+
}
|
|
81
|
+
return bytes;
|
|
82
|
+
}
|
|
83
|
+
function bytesToHex(bytes) {
|
|
84
|
+
return Array.from(bytes, byte => byte.toString(16).padStart(2, "0")).join("");
|
|
85
|
+
}
|
|
86
|
+
const globalScope = globalThis;
|
|
87
|
+
function bytesToBase64(bytes) {
|
|
88
|
+
if (globalScope.Buffer) {
|
|
89
|
+
return globalScope.Buffer.from(bytes).toString("base64");
|
|
90
|
+
}
|
|
91
|
+
let binary = "";
|
|
92
|
+
for (const byte of bytes) {
|
|
93
|
+
binary += String.fromCharCode(byte);
|
|
94
|
+
}
|
|
95
|
+
if (globalScope.btoa) {
|
|
96
|
+
return globalScope.btoa(binary);
|
|
97
|
+
}
|
|
98
|
+
return (0, base_64_1.encode)(binary);
|
|
99
|
+
}
|
|
100
|
+
function base64ToBytes(base64) {
|
|
101
|
+
if (globalScope.Buffer) {
|
|
102
|
+
const buffer = globalScope.Buffer.from(base64, "base64");
|
|
103
|
+
return Uint8Array.from(buffer);
|
|
104
|
+
}
|
|
105
|
+
let binary;
|
|
106
|
+
if (globalScope.atob) {
|
|
107
|
+
binary = globalScope.atob(base64);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
binary = (0, base_64_1.decode)(base64);
|
|
111
|
+
}
|
|
112
|
+
const bytes = new Uint8Array(binary.length);
|
|
113
|
+
for (let i = 0; i < binary.length; i += 1) {
|
|
114
|
+
bytes[i] = binary.charCodeAt(i);
|
|
115
|
+
}
|
|
116
|
+
return bytes;
|
|
117
|
+
}
|
|
118
|
+
function compressUuid(guidString) {
|
|
119
|
+
const hex = normalizeUuidHex(guidString);
|
|
120
|
+
const guidInt = BigInt(`0x${hex}`);
|
|
121
|
+
return base36Encode(guidInt);
|
|
122
|
+
}
|
|
123
|
+
function decompressUuid(compressedUuid) {
|
|
124
|
+
const guidInt = base36Decode(compressedUuid);
|
|
125
|
+
const hex = guidInt.toString(16).padStart(32, "0");
|
|
126
|
+
return formatUuidFromHex(hex);
|
|
127
|
+
}
|
|
128
|
+
function base64CompressUuid(id) {
|
|
129
|
+
const hex = normalizeUuidHex(id);
|
|
130
|
+
const bytes = hexToBytes(hex);
|
|
131
|
+
const base64 = bytesToBase64(bytes)
|
|
132
|
+
.replace(/\+/g, "-")
|
|
133
|
+
.replace(/\//g, "_");
|
|
134
|
+
return base64.replace(/-/g, ".").replace(/=+$/g, "");
|
|
135
|
+
}
|
|
136
|
+
function base64DecompressUuid(id) {
|
|
137
|
+
let base64 = id.replace(/\./g, "-");
|
|
138
|
+
const paddingNeeded = base64.length % 4;
|
|
139
|
+
if (paddingNeeded !== 0) {
|
|
140
|
+
base64 += "=".repeat(4 - paddingNeeded);
|
|
141
|
+
}
|
|
142
|
+
base64 = base64.replace(/-/g, "+").replace(/_/g, "/");
|
|
143
|
+
const bytes = base64ToBytes(base64);
|
|
144
|
+
if (bytes.length !== 16) {
|
|
145
|
+
throw new Error("invalid uuid length");
|
|
146
|
+
}
|
|
147
|
+
return formatUuidFromHex(bytesToHex(bytes));
|
|
148
|
+
}
|
|
149
|
+
function splitApiKey(key) {
|
|
150
|
+
const rest = key.slice(3);
|
|
151
|
+
const firstSeparator = rest.indexOf("-");
|
|
152
|
+
if (firstSeparator === -1) {
|
|
153
|
+
throw new Error("invalid api key");
|
|
154
|
+
}
|
|
155
|
+
const secondSeparator = rest.indexOf("-", firstSeparator + 1);
|
|
156
|
+
if (secondSeparator === -1) {
|
|
157
|
+
throw new Error("invalid api key");
|
|
158
|
+
}
|
|
159
|
+
const idPart = rest.slice(0, firstSeparator);
|
|
160
|
+
const projectPart = rest.slice(firstSeparator + 1, secondSeparator);
|
|
161
|
+
const secret = rest.slice(secondSeparator + 1);
|
|
162
|
+
if (!idPart || !projectPart || secret === undefined) {
|
|
163
|
+
throw new Error("invalid api key");
|
|
164
|
+
}
|
|
165
|
+
return { idPart, projectPart, secret };
|
|
166
|
+
}
|
|
167
|
+
function parseApiKey(key) {
|
|
168
|
+
if (!key.startsWith("ma-")) {
|
|
169
|
+
throw new Error("invalid api key");
|
|
170
|
+
}
|
|
171
|
+
const { idPart, projectPart, secret } = splitApiKey(key);
|
|
172
|
+
return {
|
|
173
|
+
id: base64DecompressUuid(idPart),
|
|
174
|
+
projectId: base64DecompressUuid(projectPart),
|
|
175
|
+
secret,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function encodeApiKey(key) {
|
|
179
|
+
return ("ma-" +
|
|
180
|
+
base64CompressUuid(key.id) +
|
|
181
|
+
"-" +
|
|
182
|
+
base64CompressUuid(key.projectId) +
|
|
183
|
+
"-" +
|
|
184
|
+
key.secret);
|
|
185
|
+
}
|
|
@@ -11,6 +11,7 @@ export declare abstract class DataType {
|
|
|
11
11
|
elementType: DataType;
|
|
12
12
|
}): VectorDataType;
|
|
13
13
|
static text(): TextDataType;
|
|
14
|
+
static binary(): BinaryDataType;
|
|
14
15
|
}
|
|
15
16
|
export declare class IntDataType extends DataType {
|
|
16
17
|
constructor();
|
|
@@ -42,3 +43,8 @@ export declare class TextDataType extends DataType {
|
|
|
42
43
|
static fromJson(data: any): TextDataType;
|
|
43
44
|
toJson(): Record<string, unknown>;
|
|
44
45
|
}
|
|
46
|
+
export declare class BinaryDataType extends DataType {
|
|
47
|
+
constructor();
|
|
48
|
+
static fromJson(data: any): BinaryDataType;
|
|
49
|
+
toJson(): Record<string, unknown>;
|
|
50
|
+
}
|
package/dist/node/data-types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextDataType = exports.VectorDataType = exports.FloatDataType = exports.DateDataType = exports.IntDataType = exports.DataType = exports._dataTypes = void 0;
|
|
3
|
+
exports.BinaryDataType = exports.TextDataType = exports.VectorDataType = exports.FloatDataType = exports.DateDataType = exports.IntDataType = exports.DataType = exports._dataTypes = void 0;
|
|
4
4
|
exports._dataTypes = {};
|
|
5
5
|
class DataType {
|
|
6
6
|
constructor(_) { }
|
|
@@ -26,6 +26,9 @@ class DataType {
|
|
|
26
26
|
static text() {
|
|
27
27
|
return new TextDataType();
|
|
28
28
|
}
|
|
29
|
+
static binary() {
|
|
30
|
+
return new BinaryDataType();
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
exports.DataType = DataType;
|
|
31
34
|
class IntDataType extends DataType {
|
|
@@ -117,3 +120,19 @@ class TextDataType extends DataType {
|
|
|
117
120
|
}
|
|
118
121
|
exports.TextDataType = TextDataType;
|
|
119
122
|
exports._dataTypes["text"] = TextDataType;
|
|
123
|
+
class BinaryDataType extends DataType {
|
|
124
|
+
constructor() {
|
|
125
|
+
super();
|
|
126
|
+
}
|
|
127
|
+
static fromJson(data) {
|
|
128
|
+
if (data.type !== "binary") {
|
|
129
|
+
throw new Error(`Expected type 'binary', got '${data.type}'`);
|
|
130
|
+
}
|
|
131
|
+
return new BinaryDataType();
|
|
132
|
+
}
|
|
133
|
+
toJson() {
|
|
134
|
+
return { type: "binary" };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.BinaryDataType = BinaryDataType;
|
|
138
|
+
exports._dataTypes["binary"] = BinaryDataType;
|