@thingd/sdk 0.72.0 → 0.74.2
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/dist/__type-tests__/exports.d.ts +178 -0
- package/dist/__type-tests__/exports.d.ts.map +1 -0
- package/dist/__type-tests__/exports.js +87 -0
- package/dist/client/http-thing-store.d.ts +55 -0
- package/dist/client/http-thing-store.d.ts.map +1 -0
- package/dist/client/http-thing-store.js +233 -0
- package/dist/client/in-memory-thing-store.d.ts +41 -0
- package/dist/client/in-memory-thing-store.d.ts.map +1 -0
- package/dist/client/in-memory-thing-store.js +292 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/thingd.d.ts +24 -0
- package/dist/client/thingd.d.ts.map +1 -0
- package/dist/client/thingd.js +27 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/mcp/audit.d.ts +27 -0
- package/dist/mcp/audit.d.ts.map +1 -0
- package/dist/mcp/audit.js +36 -0
- package/dist/mcp/config.d.ts +22 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +52 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/result.d.ts +3 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +10 -0
- package/dist/mcp/server.d.ts +19 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +51 -0
- package/dist/mcp/tools.d.ts +10 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +1033 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +7 -0
- package/dist/rest/helpers.d.ts +17 -0
- package/dist/rest/helpers.d.ts.map +1 -0
- package/dist/rest/helpers.js +60 -0
- package/dist/rest/index.d.ts +3 -0
- package/dist/rest/index.d.ts.map +1 -0
- package/dist/rest/index.js +2 -0
- package/dist/rest/server.d.ts +4 -0
- package/dist/rest/server.d.ts.map +1 -0
- package/dist/rest/server.js +472 -0
- package/dist/scheduler.d.ts +28 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +451 -0
- package/dist/stores/cloud-thing-store.d.ts +60 -0
- package/dist/stores/cloud-thing-store.d.ts.map +1 -0
- package/dist/stores/cloud-thing-store.js +396 -0
- package/dist/stores/in-memory-thing-store.d.ts +59 -0
- package/dist/stores/in-memory-thing-store.d.ts.map +1 -0
- package/dist/stores/in-memory-thing-store.js +709 -0
- package/dist/stores/native-thing-store.d.ts +62 -0
- package/dist/stores/native-thing-store.d.ts.map +1 -0
- package/dist/stores/native-thing-store.js +374 -0
- package/dist/thingd.d.ts +84 -0
- package/dist/thingd.d.ts.map +1 -0
- package/dist/thingd.js +236 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types.d.ts +448 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/package.json +8 -7
- package/LICENSE +0 -201
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
|
+
import { SDK_VERSION } from "../version.js";
|
|
4
|
+
export class CloudThingStore {
|
|
5
|
+
client;
|
|
6
|
+
connectOptions;
|
|
7
|
+
static async open(urlOrOptions) {
|
|
8
|
+
const options = typeof urlOrOptions === "string"
|
|
9
|
+
? {
|
|
10
|
+
url: urlOrOptions,
|
|
11
|
+
}
|
|
12
|
+
: urlOrOptions;
|
|
13
|
+
const client = new Client({
|
|
14
|
+
name: options.clientName ?? "thingd-node-sdk",
|
|
15
|
+
version: options.clientVersion ?? SDK_VERSION,
|
|
16
|
+
});
|
|
17
|
+
const transport = new StreamableHTTPClientTransport(new URL(resolveMcpUrl(options.url)), {
|
|
18
|
+
requestInit: options.authToken
|
|
19
|
+
? {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${options.authToken}`,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
: undefined,
|
|
25
|
+
});
|
|
26
|
+
await client.connect(transport);
|
|
27
|
+
return new CloudThingStore(client, options);
|
|
28
|
+
}
|
|
29
|
+
constructor(client, connectOptions) {
|
|
30
|
+
this.client = client;
|
|
31
|
+
this.connectOptions = connectOptions;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Explicitly reconnect the transport — useful if you detect the connection
|
|
35
|
+
* has dropped and want to recover without recreating the store.
|
|
36
|
+
*/
|
|
37
|
+
async reconnect() {
|
|
38
|
+
try {
|
|
39
|
+
await this.client.close();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// ignore close errors
|
|
43
|
+
}
|
|
44
|
+
const client = new Client({
|
|
45
|
+
name: this.connectOptions.clientName ?? "thingd-node-sdk",
|
|
46
|
+
version: this.connectOptions.clientVersion ?? SDK_VERSION,
|
|
47
|
+
});
|
|
48
|
+
const transport = new StreamableHTTPClientTransport(new URL(resolveMcpUrl(this.connectOptions.url)), {
|
|
49
|
+
requestInit: this.connectOptions.authToken
|
|
50
|
+
? { headers: { Authorization: `Bearer ${this.connectOptions.authToken}` } }
|
|
51
|
+
: undefined,
|
|
52
|
+
});
|
|
53
|
+
await client.connect(transport);
|
|
54
|
+
this.client = client;
|
|
55
|
+
}
|
|
56
|
+
put(collection, object, options) {
|
|
57
|
+
return this.callTool("thing_put", {
|
|
58
|
+
collection,
|
|
59
|
+
object,
|
|
60
|
+
...(options?.expectedVersion !== undefined
|
|
61
|
+
? { expectedVersion: options.expectedVersion }
|
|
62
|
+
: {}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
get(collection, id) {
|
|
66
|
+
return this.callTool("thing_get", {
|
|
67
|
+
collection,
|
|
68
|
+
id,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
getBatch(collection, ids) {
|
|
72
|
+
return this.callTool("thing_objects_get_batch", { collection, ids });
|
|
73
|
+
}
|
|
74
|
+
delete(collection, id) {
|
|
75
|
+
return this.callTool("thing_delete", {
|
|
76
|
+
collection,
|
|
77
|
+
id,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
listObjects(collection, options) {
|
|
81
|
+
const params = { collection };
|
|
82
|
+
if (options?.filter) {
|
|
83
|
+
params.filter = options.filter;
|
|
84
|
+
}
|
|
85
|
+
if (options?.limit) {
|
|
86
|
+
params.limit = options.limit;
|
|
87
|
+
}
|
|
88
|
+
if (options?.offset) {
|
|
89
|
+
params.offset = options.offset;
|
|
90
|
+
}
|
|
91
|
+
return this.callTool("thing_objects_list", params);
|
|
92
|
+
}
|
|
93
|
+
appendEvent(stream, event) {
|
|
94
|
+
return this.callTool("thing_events_append", {
|
|
95
|
+
stream,
|
|
96
|
+
event,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
listEvents(stream, options) {
|
|
100
|
+
const params = {};
|
|
101
|
+
if (stream) {
|
|
102
|
+
params.stream = stream;
|
|
103
|
+
}
|
|
104
|
+
if (options?.fromSequence) {
|
|
105
|
+
params.fromSequence = options.fromSequence;
|
|
106
|
+
}
|
|
107
|
+
if (options?.limit) {
|
|
108
|
+
params.limit = options.limit;
|
|
109
|
+
}
|
|
110
|
+
if (options?.since) {
|
|
111
|
+
params.since = options.since;
|
|
112
|
+
}
|
|
113
|
+
return this.callTool("thing_events_list", params);
|
|
114
|
+
}
|
|
115
|
+
pushJob(queue, payload, options = {}) {
|
|
116
|
+
return this.callTool("thing_queue_push", {
|
|
117
|
+
queue,
|
|
118
|
+
payload,
|
|
119
|
+
idempotencyKey: options.idempotencyKey,
|
|
120
|
+
maxAttempts: options.maxAttempts,
|
|
121
|
+
delayMs: options.delayMs,
|
|
122
|
+
priority: options.priority,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
claimJob(queue, options = {}) {
|
|
126
|
+
return this.callTool("thing_queue_claim", {
|
|
127
|
+
queue,
|
|
128
|
+
leaseMs: options.leaseMs,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
ackJob(queue, jobId) {
|
|
132
|
+
return this.callTool("thing_queue_ack", {
|
|
133
|
+
queue,
|
|
134
|
+
id: jobId,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
nackJob(queue, jobId, options = {}) {
|
|
138
|
+
return this.callTool("thing_queue_nack", {
|
|
139
|
+
queue,
|
|
140
|
+
id: jobId,
|
|
141
|
+
delayMs: options.delayMs,
|
|
142
|
+
error: options.error,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
listJobs(queue) {
|
|
146
|
+
return this.callTool("thing_queue_list", {
|
|
147
|
+
queue,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
listDeadJobs(queue) {
|
|
151
|
+
return this.callTool("thing_queue_dead", {
|
|
152
|
+
queue,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
search(query, options = {}) {
|
|
156
|
+
return this.callTool("thing_search", {
|
|
157
|
+
query,
|
|
158
|
+
collections: options.collections,
|
|
159
|
+
limit: options.limit,
|
|
160
|
+
filter: options.filter,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
vectorSearch(collection, queryVector, options = {}) {
|
|
164
|
+
return this.callTool("thing_vector_search", {
|
|
165
|
+
collection,
|
|
166
|
+
vector: queryVector,
|
|
167
|
+
topK: options.topK,
|
|
168
|
+
filter: options.filter,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async countObjects() {
|
|
172
|
+
return this.callTool("thing_count_objects", {});
|
|
173
|
+
}
|
|
174
|
+
async countObjectsInCollection(collection) {
|
|
175
|
+
return this.callTool("thing_count_objects_in_collection", { collection });
|
|
176
|
+
}
|
|
177
|
+
async countEvents() {
|
|
178
|
+
return this.callTool("thing_count_events", {});
|
|
179
|
+
}
|
|
180
|
+
async countActiveJobs() {
|
|
181
|
+
return this.callTool("thing_count_active_jobs", {});
|
|
182
|
+
}
|
|
183
|
+
async countDeadJobs() {
|
|
184
|
+
return this.callTool("thing_count_dead_jobs", {});
|
|
185
|
+
}
|
|
186
|
+
async countLinks() {
|
|
187
|
+
const res = (await this.restGet("/v1/counts/links"));
|
|
188
|
+
return res.data?.count ?? 0;
|
|
189
|
+
}
|
|
190
|
+
async putBatch(collection, objects) {
|
|
191
|
+
return this.callTool("thing_objects_put_batch", { collection, objects });
|
|
192
|
+
}
|
|
193
|
+
async deleteBatch(collection, ids) {
|
|
194
|
+
const res = await this.callTool("thing_objects_delete_batch", {
|
|
195
|
+
collection,
|
|
196
|
+
ids,
|
|
197
|
+
});
|
|
198
|
+
return res.deleted;
|
|
199
|
+
}
|
|
200
|
+
async createLink(fromRef, linkType, toRef, weight, metadataJson) {
|
|
201
|
+
const body = { fromRef, linkType, toRef };
|
|
202
|
+
if (weight !== undefined) {
|
|
203
|
+
body.weight = weight;
|
|
204
|
+
}
|
|
205
|
+
if (metadataJson !== undefined) {
|
|
206
|
+
body.metadataJson = metadataJson;
|
|
207
|
+
}
|
|
208
|
+
const res = (await this.restPost("/v1/links", body));
|
|
209
|
+
return res.data;
|
|
210
|
+
}
|
|
211
|
+
async deleteLink(id) {
|
|
212
|
+
try {
|
|
213
|
+
await this.restDelete(`/v1/links/${encodeURIComponent(id)}`);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
if (err instanceof Error && err.message.includes("404")) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async getLink(id) {
|
|
224
|
+
try {
|
|
225
|
+
const res = (await this.restGet(`/v1/links/${encodeURIComponent(id)}`));
|
|
226
|
+
return res.data ?? null;
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
if (err instanceof Error && err.message.includes("404")) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
throw err;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async getNeighbors(reference, direction, options) {
|
|
236
|
+
const params = new URLSearchParams({ reference, direction: direction || "Both" });
|
|
237
|
+
if (options.linkType) {
|
|
238
|
+
params.set("linkType", options.linkType);
|
|
239
|
+
}
|
|
240
|
+
if (options.limit !== undefined) {
|
|
241
|
+
params.set("limit", String(options.limit));
|
|
242
|
+
}
|
|
243
|
+
const res = (await this.restGet(`/v1/links?${params.toString()}`));
|
|
244
|
+
return res.data ?? [];
|
|
245
|
+
}
|
|
246
|
+
async listCollections() {
|
|
247
|
+
return this.callTool("thing_list_collections", {});
|
|
248
|
+
}
|
|
249
|
+
async listStreams() {
|
|
250
|
+
return this.callTool("thing_list_streams", {});
|
|
251
|
+
}
|
|
252
|
+
async listQueues() {
|
|
253
|
+
return this.callTool("thing_list_queues", {});
|
|
254
|
+
}
|
|
255
|
+
async createIndex(collection, field) {
|
|
256
|
+
await this.callTool("thing_create_index", { collection, field });
|
|
257
|
+
}
|
|
258
|
+
async listIndexes() {
|
|
259
|
+
return this.callTool("thing_list_indexes", {});
|
|
260
|
+
}
|
|
261
|
+
async close() {
|
|
262
|
+
await this.client.close();
|
|
263
|
+
}
|
|
264
|
+
walCheckpoint() {
|
|
265
|
+
throw new Error("WAL checkpoint is not supported for cloud storage driver");
|
|
266
|
+
}
|
|
267
|
+
async callTool(name, args) {
|
|
268
|
+
return this.callToolOnce(name, args, true);
|
|
269
|
+
}
|
|
270
|
+
restBaseUrl() {
|
|
271
|
+
const url = resolveMcpUrl(this.connectOptions.url);
|
|
272
|
+
return url.replace(/\/mcp$/, "");
|
|
273
|
+
}
|
|
274
|
+
authHeaders() {
|
|
275
|
+
if (this.connectOptions.authToken) {
|
|
276
|
+
return { Authorization: `Bearer ${this.connectOptions.authToken}` };
|
|
277
|
+
}
|
|
278
|
+
return {};
|
|
279
|
+
}
|
|
280
|
+
async restGet(path) {
|
|
281
|
+
const base = this.restBaseUrl();
|
|
282
|
+
const controller = new AbortController();
|
|
283
|
+
const timeout = setTimeout(() => controller.abort(), 30_000);
|
|
284
|
+
try {
|
|
285
|
+
const res = await fetch(`${base}${path}`, {
|
|
286
|
+
headers: this.authHeaders(),
|
|
287
|
+
signal: controller.signal,
|
|
288
|
+
});
|
|
289
|
+
if (!res.ok) {
|
|
290
|
+
throw new Error(`REST request failed: ${res.status} ${res.statusText}`);
|
|
291
|
+
}
|
|
292
|
+
return res.json();
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
clearTimeout(timeout);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async restPost(path, body) {
|
|
299
|
+
const base = this.restBaseUrl();
|
|
300
|
+
const controller = new AbortController();
|
|
301
|
+
const timeout = setTimeout(() => controller.abort(), 30_000);
|
|
302
|
+
try {
|
|
303
|
+
const res = await fetch(`${base}${path}`, {
|
|
304
|
+
method: "POST",
|
|
305
|
+
headers: { ...this.authHeaders(), "Content-Type": "application/json" },
|
|
306
|
+
body: JSON.stringify(body),
|
|
307
|
+
signal: controller.signal,
|
|
308
|
+
});
|
|
309
|
+
if (!res.ok) {
|
|
310
|
+
throw new Error(`REST request failed: ${res.status} ${res.statusText}`);
|
|
311
|
+
}
|
|
312
|
+
return res.json();
|
|
313
|
+
}
|
|
314
|
+
finally {
|
|
315
|
+
clearTimeout(timeout);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
async restDelete(path) {
|
|
319
|
+
const base = this.restBaseUrl();
|
|
320
|
+
const controller = new AbortController();
|
|
321
|
+
const timeout = setTimeout(() => controller.abort(), 30_000);
|
|
322
|
+
try {
|
|
323
|
+
const res = await fetch(`${base}${path}`, {
|
|
324
|
+
method: "DELETE",
|
|
325
|
+
headers: this.authHeaders(),
|
|
326
|
+
signal: controller.signal,
|
|
327
|
+
});
|
|
328
|
+
if (!res.ok) {
|
|
329
|
+
throw new Error(`REST request failed: ${res.status} ${res.statusText}`);
|
|
330
|
+
}
|
|
331
|
+
const text = await res.text();
|
|
332
|
+
return text ? JSON.parse(text) : null;
|
|
333
|
+
}
|
|
334
|
+
finally {
|
|
335
|
+
clearTimeout(timeout);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
async callToolOnce(name, args, retryOnTransportError) {
|
|
339
|
+
let result;
|
|
340
|
+
try {
|
|
341
|
+
result = (await this.client.callTool({ name, arguments: args }));
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
// Transport-level error (connection dropped, ECONNRESET, etc.).
|
|
345
|
+
// Only reconnect+retry for network errors, not API errors.
|
|
346
|
+
if (retryOnTransportError && isTransportError(error)) {
|
|
347
|
+
try {
|
|
348
|
+
await this.reconnect();
|
|
349
|
+
}
|
|
350
|
+
catch (reconnectError) {
|
|
351
|
+
throw new Error(`thingd cloud: transport error calling "${name}" and reconnect failed: ${reconnectError instanceof Error ? reconnectError.message : String(reconnectError)}`);
|
|
352
|
+
}
|
|
353
|
+
return this.callToolOnce(name, args, false);
|
|
354
|
+
}
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
if (result.isError) {
|
|
358
|
+
const text = result.content.find((part) => part.type === "text")?.text;
|
|
359
|
+
throw new Error(text ?? `thingd cloud tool "${name}" returned an error`);
|
|
360
|
+
}
|
|
361
|
+
return parseJsonToolResult(result);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function resolveMcpUrl(value) {
|
|
365
|
+
const normalized = value.startsWith("thingd://")
|
|
366
|
+
? `http://${value.slice("thingd://".length)}`
|
|
367
|
+
: value;
|
|
368
|
+
const url = new URL(normalized);
|
|
369
|
+
if (url.pathname === "" || url.pathname === "/") {
|
|
370
|
+
url.pathname = "/mcp";
|
|
371
|
+
}
|
|
372
|
+
return url.toString();
|
|
373
|
+
}
|
|
374
|
+
function parseJsonToolResult(result) {
|
|
375
|
+
const text = result.content.find((part) => part.type === "text" && typeof part.text === "string")?.text;
|
|
376
|
+
if (!text) {
|
|
377
|
+
throw new Error("thingd cloud tool did not return JSON text content");
|
|
378
|
+
}
|
|
379
|
+
return JSON.parse(text);
|
|
380
|
+
}
|
|
381
|
+
function isTransportError(error) {
|
|
382
|
+
if (error instanceof TypeError) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
if (error instanceof Error) {
|
|
386
|
+
const msg = error.message.toLowerCase();
|
|
387
|
+
return (msg.includes("econnreset") ||
|
|
388
|
+
msg.includes("econnrefused") ||
|
|
389
|
+
msg.includes("eof") ||
|
|
390
|
+
msg.includes("fetch failed") ||
|
|
391
|
+
msg.includes("network") ||
|
|
392
|
+
msg.includes("timed out") ||
|
|
393
|
+
msg.includes("abort"));
|
|
394
|
+
}
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AggregateOptions, AggregateResult, CollectionSchema, ListEventsOptions, ListObjectsOptions, MemoryEvent, MemoryObject, MemorySearchOptions, MemorySearchResult, PutOptions, QueueClaimOptions, QueueJob, QueueJobOptions, QueueJobPayload, QueueJobResult, QueueNackOptions, SchemaOptions, StoredMemoryEvent, StoredMemoryObject, ThingDeleteResult, ThingStore, TimeSeriesOptions, TimeSeriesResult, VectorSearchHit, VectorSearchOptions } from "../types.js";
|
|
2
|
+
export declare class InMemoryThingStore implements ThingStore {
|
|
3
|
+
private readonly collections;
|
|
4
|
+
private readonly events;
|
|
5
|
+
private nextEventSequence;
|
|
6
|
+
private readonly queues;
|
|
7
|
+
private readonly links;
|
|
8
|
+
private readonly mutex;
|
|
9
|
+
private readonly eventIdempotencyKeys;
|
|
10
|
+
private withLock;
|
|
11
|
+
put(collection: string, object: MemoryObject, options?: PutOptions): Promise<StoredMemoryObject>;
|
|
12
|
+
get<T = StoredMemoryObject>(collection: string, id: string): Promise<T | null>;
|
|
13
|
+
getBatch<T = StoredMemoryObject>(collection: string, ids: string[]): Promise<(T | null)[]>;
|
|
14
|
+
delete(collection: string, id: string): Promise<ThingDeleteResult>;
|
|
15
|
+
listObjects<T = StoredMemoryObject>(collection: string, options?: ListObjectsOptions): Promise<T[]>;
|
|
16
|
+
appendEvent(stream: string, event: MemoryEvent): Promise<StoredMemoryEvent>;
|
|
17
|
+
listEvents<T = StoredMemoryEvent>(stream?: string, options?: ListEventsOptions): Promise<T[]>;
|
|
18
|
+
pushJob(queue: string, payload: QueueJobPayload, options?: QueueJobOptions): Promise<QueueJob>;
|
|
19
|
+
claimJob(queue: string, options?: QueueClaimOptions): Promise<QueueJob | null>;
|
|
20
|
+
ackJob(queue: string, jobId: string): Promise<QueueJobResult>;
|
|
21
|
+
nackJob(queue: string, jobId: string, options?: QueueNackOptions): Promise<QueueJobResult>;
|
|
22
|
+
listJobs(queue: string): Promise<QueueJob[]>;
|
|
23
|
+
listDeadJobs(queue: string): Promise<QueueJob[]>;
|
|
24
|
+
search(query: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
|
|
25
|
+
vectorSearch(collection: string, queryVector: number[], options?: VectorSearchOptions): Promise<VectorSearchHit[]>;
|
|
26
|
+
private matchesFilter;
|
|
27
|
+
countObjects(): Promise<number>;
|
|
28
|
+
countObjectsInCollection(collection: string): Promise<number>;
|
|
29
|
+
countEvents(): Promise<number>;
|
|
30
|
+
countActiveJobs(): Promise<number>;
|
|
31
|
+
countDeadJobs(): Promise<number>;
|
|
32
|
+
countLinks(): Promise<number>;
|
|
33
|
+
putBatch(collection: string, objects: MemoryObject[]): Promise<StoredMemoryObject[]>;
|
|
34
|
+
deleteBatch(collection: string, ids: string[]): Promise<number>;
|
|
35
|
+
createLink(fromRef: string, linkType: string, toRef: string, weight?: number, metadataJson?: string): Promise<import("../types.js").Link>;
|
|
36
|
+
deleteLink(id: string): Promise<boolean>;
|
|
37
|
+
getLink(id: string): Promise<import("../types.js").Link | null>;
|
|
38
|
+
getNeighbors(reference: string, direction: import("../types.js").LinkDirection, options: import("../types.js").LinkQueryOptions): Promise<import("../types.js").Link[]>;
|
|
39
|
+
listCollections(): Promise<string[]>;
|
|
40
|
+
listQueues(): Promise<string[]>;
|
|
41
|
+
createIndex(_collection: string, _field: string): Promise<void>;
|
|
42
|
+
listIndexes(): Promise<Array<[string, string]>>;
|
|
43
|
+
listStreams(): Promise<string[]>;
|
|
44
|
+
aggregate(collection: string, options: AggregateOptions): Promise<AggregateResult>;
|
|
45
|
+
timeseries(collection: string, options: TimeSeriesOptions): Promise<TimeSeriesResult>;
|
|
46
|
+
schema(collection?: string, options?: SchemaOptions): Promise<CollectionSchema[]>;
|
|
47
|
+
private inferType;
|
|
48
|
+
private computeAggregate;
|
|
49
|
+
private getTimeBucketFormat;
|
|
50
|
+
private formatTimestamp;
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
walCheckpoint(): import("../types.js").WalCheckpointResult;
|
|
53
|
+
private getCollection;
|
|
54
|
+
private getQueue;
|
|
55
|
+
private findJob;
|
|
56
|
+
private releaseExpiredLeases;
|
|
57
|
+
private cloneJob;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=in-memory-thing-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-thing-store.d.ts","sourceRoot":"","sources":["../../src/stores/in-memory-thing-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa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