@thingd/sdk 0.36.0 → 0.37.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/dist/client/in-memory-thing-store.d.ts +0 -1
- package/dist/client/in-memory-thing-store.d.ts.map +1 -1
- package/dist/client/in-memory-thing-store.js +0 -2
- package/dist/client/thingd.d.ts +2 -45
- package/dist/client/thingd.d.ts.map +1 -1
- package/dist/client/thingd.js +1 -115
- package/dist/stores/cloud-thing-store.d.ts +10 -6
- package/dist/stores/cloud-thing-store.d.ts.map +1 -1
- package/dist/stores/cloud-thing-store.js +112 -14
- package/dist/stores/in-memory-thing-store.d.ts +1 -0
- package/dist/stores/in-memory-thing-store.d.ts.map +1 -1
- package/dist/stores/in-memory-thing-store.js +12 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -4,7 +4,6 @@ export declare class InMemoryThingStore implements ThingStore {
|
|
|
4
4
|
private events;
|
|
5
5
|
private jobs;
|
|
6
6
|
private links;
|
|
7
|
-
private linkCounter;
|
|
8
7
|
put(collection: string, object: MemoryObject): Promise<StoredMemoryObject>;
|
|
9
8
|
get<T = StoredMemoryObject>(collection: string, id: string): Promise<T | null>;
|
|
10
9
|
delete(_collection: string, _id: string): Promise<ThingDeleteResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-thing-store.d.ts","sourceRoot":"","sources":["../../src/client/in-memory-thing-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACX,MAAM,aAAa,CAAC;AAyBr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CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAIzC,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,aAAsB,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,EAAE,CAAC;IAyBZ,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAQlC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAQhC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKpC,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIhC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAE5B,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -12,7 +12,6 @@ export class InMemoryThingStore {
|
|
|
12
12
|
events = new Map();
|
|
13
13
|
jobs = new Map();
|
|
14
14
|
links = new Map();
|
|
15
|
-
linkCounter = 0;
|
|
16
15
|
async put(collection, object) {
|
|
17
16
|
const key = `${collection}:${object.id}`;
|
|
18
17
|
const existing = this.objects.get(key);
|
|
@@ -189,7 +188,6 @@ export class InMemoryThingStore {
|
|
|
189
188
|
return count;
|
|
190
189
|
}
|
|
191
190
|
async createLink(fromRef, linkType, toRef, weight, metadataJson) {
|
|
192
|
-
this.linkCounter++;
|
|
193
191
|
const link = {
|
|
194
192
|
id: uid(),
|
|
195
193
|
fromRef,
|
package/dist/client/thingd.d.ts
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export type ThingDOpenOptions = {
|
|
4
|
-
driver?: ThingDDriver;
|
|
5
|
-
store?: ThingStore;
|
|
6
|
-
authToken?: string;
|
|
7
|
-
};
|
|
8
|
-
export type ThingDOpenConfig = ThingDOpenOptions & {
|
|
9
|
-
path?: string;
|
|
10
|
-
url?: string;
|
|
11
|
-
};
|
|
12
|
-
export declare class ThingD implements ThingDConnection {
|
|
13
|
-
readonly path: string;
|
|
14
|
-
private readonly store;
|
|
15
|
-
static open(pathOrConfig?: string | ThingDOpenConfig, options?: ThingDOpenOptions): Promise<ThingD>;
|
|
16
|
-
private constructor();
|
|
17
|
-
put(collection: string, object: MemoryObject): Promise<StoredMemoryObject>;
|
|
18
|
-
get<T = StoredMemoryObject>(collection: string, id: string): Promise<T | null>;
|
|
19
|
-
delete(collection: string, id: string): Promise<ThingDeleteResult>;
|
|
20
|
-
listObjects<T = StoredMemoryObject>(collection: string, options?: ListObjectsOptions): Promise<T[]>;
|
|
21
|
-
search(query: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
|
|
22
|
-
searchObjects<T = StoredMemoryObject>(query: string, options?: MemorySearchOptions): Promise<T[]>;
|
|
23
|
-
putBatch(collection: string, objects: MemoryObject[]): Promise<StoredMemoryObject[]>;
|
|
24
|
-
deleteBatch(collection: string, ids: string[]): Promise<number>;
|
|
25
|
-
readonly events: {
|
|
26
|
-
append: (stream: string, event: MemoryEvent) => Promise<StoredMemoryEvent>;
|
|
27
|
-
list: <T = StoredMemoryEvent>(stream?: string, options?: ListEventsOptions) => Promise<T[]>;
|
|
28
|
-
};
|
|
29
|
-
queue(name: string): MemoryQueue;
|
|
30
|
-
readonly links: {
|
|
31
|
-
create: (fromRef: string, linkType: string, toRef: string, weight?: number, metadataJson?: string) => Promise<import("../types.js").Link>;
|
|
32
|
-
delete: (id: string) => Promise<boolean>;
|
|
33
|
-
get: (id: string) => Promise<import("../types.js").Link | null>;
|
|
34
|
-
neighbors: (reference: string, direction?: import("../types.js").LinkDirection, options?: import("../types.js").LinkQueryOptions) => Promise<import("../types.js").Link[]>;
|
|
35
|
-
};
|
|
36
|
-
close(): Promise<void>;
|
|
37
|
-
countObjects(): Promise<number>;
|
|
38
|
-
countEvents(): Promise<number>;
|
|
39
|
-
countActiveJobs(): Promise<number>;
|
|
40
|
-
countDeadJobs(): Promise<number>;
|
|
41
|
-
countLinks(): Promise<number>;
|
|
42
|
-
listCollections(): Promise<string[]>;
|
|
43
|
-
listStreams(): Promise<string[]>;
|
|
44
|
-
listQueues(): Promise<string[]>;
|
|
45
|
-
}
|
|
1
|
+
export type { ThingDDriver, ThingDOpenConfig, ThingDOpenOptions, } from "../thingd.js";
|
|
2
|
+
export { ThingD } from "../thingd.js";
|
|
46
3
|
//# sourceMappingURL=thingd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thingd.d.ts","sourceRoot":"","sources":["../../src/client/thingd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thingd.d.ts","sourceRoot":"","sources":["../../src/client/thingd.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/client/thingd.js
CHANGED
|
@@ -1,115 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { InMemoryThingStore } from "../client/in-memory-thing-store.js";
|
|
3
|
-
export class ThingD {
|
|
4
|
-
path;
|
|
5
|
-
store;
|
|
6
|
-
static async open(pathOrConfig, options = {}) {
|
|
7
|
-
const resolved = resolveOpenOptions(pathOrConfig, options);
|
|
8
|
-
return new ThingD(resolved.path, await openStore(resolved.path, resolved));
|
|
9
|
-
}
|
|
10
|
-
constructor(path, store) {
|
|
11
|
-
this.path = path;
|
|
12
|
-
this.store = store;
|
|
13
|
-
}
|
|
14
|
-
put(collection, object) {
|
|
15
|
-
return this.store.put(collection, object);
|
|
16
|
-
}
|
|
17
|
-
get(collection, id) {
|
|
18
|
-
return this.store.get(collection, id);
|
|
19
|
-
}
|
|
20
|
-
delete(collection, id) {
|
|
21
|
-
return this.store.delete(collection, id);
|
|
22
|
-
}
|
|
23
|
-
listObjects(collection, options) {
|
|
24
|
-
return this.store.listObjects?.(collection, options) ?? Promise.resolve([]);
|
|
25
|
-
}
|
|
26
|
-
search(query, options = {}) {
|
|
27
|
-
return this.store.search(query, options);
|
|
28
|
-
}
|
|
29
|
-
async searchObjects(query, options = {}) {
|
|
30
|
-
const results = await this.search(query, options);
|
|
31
|
-
return results
|
|
32
|
-
.filter((r) => r.kind === "object")
|
|
33
|
-
.map((r) => r.value);
|
|
34
|
-
}
|
|
35
|
-
async putBatch(collection, objects) {
|
|
36
|
-
return (this.store.putBatch?.(collection, objects) ??
|
|
37
|
-
Promise.reject(new Error("Batch put not supported by this driver")));
|
|
38
|
-
}
|
|
39
|
-
async deleteBatch(collection, ids) {
|
|
40
|
-
return (this.store.deleteBatch?.(collection, ids) ??
|
|
41
|
-
Promise.reject(new Error("Batch delete not supported by this driver")));
|
|
42
|
-
}
|
|
43
|
-
events = {
|
|
44
|
-
append: (stream, event) => this.store.appendEvent(stream, event),
|
|
45
|
-
list: (stream, options) => this.store.listEvents(stream, options),
|
|
46
|
-
};
|
|
47
|
-
queue(name) {
|
|
48
|
-
return {
|
|
49
|
-
push: (payload, options) => this.store.pushJob(name, payload, options),
|
|
50
|
-
claim: (options) => this.store.claimJob(name, options),
|
|
51
|
-
ack: (jobId) => this.store.ackJob(name, jobId),
|
|
52
|
-
nack: (jobId, options) => this.store.nackJob(name, jobId, options),
|
|
53
|
-
list: () => this.store.listJobs(name),
|
|
54
|
-
dead: () => this.store.listDeadJobs(name),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
links = {
|
|
58
|
-
create: (fromRef, linkType, toRef, weight, metadataJson) => this.store.createLink?.(fromRef, linkType, toRef, weight, metadataJson) ??
|
|
59
|
-
Promise.reject(new Error("Graph links not supported by this driver")),
|
|
60
|
-
delete: (id) => this.store.deleteLink?.(id) ?? Promise.resolve(false),
|
|
61
|
-
get: (id) => this.store.getLink?.(id) ?? Promise.resolve(null),
|
|
62
|
-
neighbors: (reference, direction = "Both", options = {}) => this.store.getNeighbors?.(reference, direction, options) ?? Promise.resolve([]),
|
|
63
|
-
};
|
|
64
|
-
async close() {
|
|
65
|
-
await this.store.close?.();
|
|
66
|
-
}
|
|
67
|
-
async countObjects() {
|
|
68
|
-
return this.store.countObjects?.() ?? 0;
|
|
69
|
-
}
|
|
70
|
-
async countEvents() {
|
|
71
|
-
return this.store.countEvents?.() ?? 0;
|
|
72
|
-
}
|
|
73
|
-
async countActiveJobs() {
|
|
74
|
-
return this.store.countActiveJobs?.() ?? 0;
|
|
75
|
-
}
|
|
76
|
-
async countDeadJobs() {
|
|
77
|
-
return this.store.countDeadJobs?.() ?? 0;
|
|
78
|
-
}
|
|
79
|
-
async countLinks() {
|
|
80
|
-
return this.store.countLinks?.() ?? 0;
|
|
81
|
-
}
|
|
82
|
-
async listCollections() {
|
|
83
|
-
return this.store.listCollections?.() ?? [];
|
|
84
|
-
}
|
|
85
|
-
async listStreams() {
|
|
86
|
-
return this.store.listStreams?.() ?? [];
|
|
87
|
-
}
|
|
88
|
-
async listQueues() {
|
|
89
|
-
return this.store.listQueues?.() ?? [];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function resolveOpenOptions(pathOrConfig, options) {
|
|
93
|
-
const config = typeof pathOrConfig === "string" ? { path: pathOrConfig } : (pathOrConfig ?? {});
|
|
94
|
-
const path = config.url ?? config.path ?? ":memory:";
|
|
95
|
-
const driver = options.driver ?? config.driver ?? (isHttpPath(path) ? "http" : "memory");
|
|
96
|
-
return {
|
|
97
|
-
...config,
|
|
98
|
-
...options,
|
|
99
|
-
path,
|
|
100
|
-
driver,
|
|
101
|
-
authToken: options.authToken ?? config.authToken,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function isHttpPath(path) {
|
|
105
|
-
return path.startsWith("http://") || path.startsWith("https://") || path.startsWith("thingd://");
|
|
106
|
-
}
|
|
107
|
-
async function openStore(path, options) {
|
|
108
|
-
if (options.store) {
|
|
109
|
-
return options.store;
|
|
110
|
-
}
|
|
111
|
-
if (options.driver === "http") {
|
|
112
|
-
return HttpThingStore.open({ url: path, authToken: options.authToken });
|
|
113
|
-
}
|
|
114
|
-
return new InMemoryThingStore();
|
|
115
|
-
}
|
|
1
|
+
export { ThingD } from "../thingd.js";
|
|
@@ -33,12 +33,12 @@ export declare class CloudThingStore implements ThingStore {
|
|
|
33
33
|
countActiveJobs(): Promise<number>;
|
|
34
34
|
countDeadJobs(): Promise<number>;
|
|
35
35
|
countLinks(): Promise<number>;
|
|
36
|
-
putBatch(
|
|
37
|
-
deleteBatch(
|
|
38
|
-
createLink(
|
|
39
|
-
deleteLink(
|
|
40
|
-
getLink(
|
|
41
|
-
getNeighbors(
|
|
36
|
+
putBatch(collection: string, objects: import("../types.js").MemoryObject[]): Promise<import("../types.js").StoredMemoryObject[]>;
|
|
37
|
+
deleteBatch(collection: string, ids: string[]): Promise<number>;
|
|
38
|
+
createLink(fromRef: string, linkType: string, toRef: string, weight?: number, metadataJson?: string): Promise<import("../types.js").Link>;
|
|
39
|
+
deleteLink(id: string): Promise<boolean>;
|
|
40
|
+
getLink(id: string): Promise<import("../types.js").Link | null>;
|
|
41
|
+
getNeighbors(reference: string, direction: import("../types.js").LinkDirection, options: import("../types.js").LinkQueryOptions): Promise<import("../types.js").Link[]>;
|
|
42
42
|
listCollections(): Promise<string[]>;
|
|
43
43
|
listStreams(): Promise<string[]>;
|
|
44
44
|
listQueues(): Promise<string[]>;
|
|
@@ -48,6 +48,10 @@ export declare class CloudThingStore implements ThingStore {
|
|
|
48
48
|
framesAfter: number;
|
|
49
49
|
};
|
|
50
50
|
private callTool;
|
|
51
|
+
private restBaseUrl;
|
|
52
|
+
private restGet;
|
|
53
|
+
private restPost;
|
|
54
|
+
private restDelete;
|
|
51
55
|
private callToolOnce;
|
|
52
56
|
}
|
|
53
57
|
//# sourceMappingURL=cloud-thing-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-thing-store.d.ts","sourceRoot":"","sources":["../../src/stores/cloud-thing-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACX,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qBAAa,eAAgB,YAAW,UAAU;IA4B9C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ,CAAC,cAAc;WA5BpB,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IA0B1F,OAAO;IAKP;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBhC,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAO1E,GAAG,CAAC,CAAC,GAAG,kBAAkB,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAO9E,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOlE,WAAW,CAAC,CAAC,GAAG,kBAAkB,EAChC,UAA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,EAAE,kBAAkB,EAAE,CAAC;IAShD,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAW/D,UAAU,CACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,aAAa,EAAE,IAAI,CAAC;IAYhC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASxC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAS/D,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,aAAa,EAAE,aAAa,EAC9C,OAAO,EAAE,OAAO,aAAa,EAAE,gBAAgB,GAC9C,OAAO,CAAC,OAAO,aAAa,EAAE,IAAI,EAAE,CAAC;IAgBlC,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIpC,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIhC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,aAAa,IAAI;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;YAIhD,QAAQ;IAItB,OAAO,CAAC,WAAW;YAKL,OAAO;YAaP,QAAQ;YAiBR,UAAU;YAgBV,YAAY;CAiC3B"}
|
|
@@ -163,25 +163,76 @@ export class CloudThingStore {
|
|
|
163
163
|
return this.callTool("thing_count_dead_jobs", {});
|
|
164
164
|
}
|
|
165
165
|
async countLinks() {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
try {
|
|
167
|
+
const res = await this.restGet("/v1/counts/links");
|
|
168
|
+
return res.data?.count ?? 0;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
170
173
|
}
|
|
171
|
-
async
|
|
172
|
-
|
|
174
|
+
async putBatch(collection, objects) {
|
|
175
|
+
const results = [];
|
|
176
|
+
for (const obj of objects) {
|
|
177
|
+
const result = await this.put(collection, obj);
|
|
178
|
+
results.push(result);
|
|
179
|
+
}
|
|
180
|
+
return results;
|
|
181
|
+
}
|
|
182
|
+
async deleteBatch(collection, ids) {
|
|
183
|
+
let count = 0;
|
|
184
|
+
for (const id of ids) {
|
|
185
|
+
const deleted = await this.delete(collection, id);
|
|
186
|
+
if (deleted) {
|
|
187
|
+
count++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return count;
|
|
173
191
|
}
|
|
174
|
-
async createLink(
|
|
175
|
-
|
|
192
|
+
async createLink(fromRef, linkType, toRef, weight, metadataJson) {
|
|
193
|
+
const body = { fromRef, linkType, toRef };
|
|
194
|
+
if (weight !== undefined) {
|
|
195
|
+
body.weight = weight;
|
|
196
|
+
}
|
|
197
|
+
if (metadataJson !== undefined) {
|
|
198
|
+
body.metadataJson = metadataJson;
|
|
199
|
+
}
|
|
200
|
+
const res = await this.restPost("/v1/links", body);
|
|
201
|
+
return res.data;
|
|
176
202
|
}
|
|
177
|
-
async deleteLink(
|
|
178
|
-
|
|
203
|
+
async deleteLink(id) {
|
|
204
|
+
try {
|
|
205
|
+
await this.restDelete(`/v1/links/${encodeURIComponent(id)}`);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
179
211
|
}
|
|
180
|
-
async getLink(
|
|
181
|
-
|
|
212
|
+
async getLink(id) {
|
|
213
|
+
try {
|
|
214
|
+
const res = await this.restGet(`/v1/links/${encodeURIComponent(id)}`);
|
|
215
|
+
return res.data ?? null;
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
182
220
|
}
|
|
183
|
-
async getNeighbors(
|
|
184
|
-
|
|
221
|
+
async getNeighbors(reference, direction, options) {
|
|
222
|
+
const params = new URLSearchParams({ reference, direction: direction || "Both" });
|
|
223
|
+
if (options.linkType) {
|
|
224
|
+
params.set("linkType", options.linkType);
|
|
225
|
+
}
|
|
226
|
+
if (options.limit !== undefined) {
|
|
227
|
+
params.set("limit", String(options.limit));
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const res = await this.restGet(`/v1/links?${params.toString()}`);
|
|
231
|
+
return res.data ?? [];
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
185
236
|
}
|
|
186
237
|
async listCollections() {
|
|
187
238
|
return this.callTool("thing_list_collections", {});
|
|
@@ -201,6 +252,53 @@ export class CloudThingStore {
|
|
|
201
252
|
async callTool(name, args) {
|
|
202
253
|
return this.callToolOnce(name, args, true);
|
|
203
254
|
}
|
|
255
|
+
restBaseUrl() {
|
|
256
|
+
const url = resolveMcpUrl(this.connectOptions.url);
|
|
257
|
+
return url.replace(/\/mcp$/, "");
|
|
258
|
+
}
|
|
259
|
+
async restGet(path) {
|
|
260
|
+
const base = this.restBaseUrl();
|
|
261
|
+
const headers = { "Content-Type": "application/json" };
|
|
262
|
+
if (this.connectOptions.authToken) {
|
|
263
|
+
headers.Authorization = `Bearer ${this.connectOptions.authToken}`;
|
|
264
|
+
}
|
|
265
|
+
const res = await fetch(`${base}${path}`, { headers });
|
|
266
|
+
if (!res.ok) {
|
|
267
|
+
throw new Error(`REST request failed: ${res.status} ${res.statusText}`);
|
|
268
|
+
}
|
|
269
|
+
return res.json();
|
|
270
|
+
}
|
|
271
|
+
async restPost(path, body) {
|
|
272
|
+
const base = this.restBaseUrl();
|
|
273
|
+
const headers = { "Content-Type": "application/json" };
|
|
274
|
+
if (this.connectOptions.authToken) {
|
|
275
|
+
headers.Authorization = `Bearer ${this.connectOptions.authToken}`;
|
|
276
|
+
}
|
|
277
|
+
const res = await fetch(`${base}${path}`, {
|
|
278
|
+
method: "POST",
|
|
279
|
+
headers,
|
|
280
|
+
body: JSON.stringify(body),
|
|
281
|
+
});
|
|
282
|
+
if (!res.ok) {
|
|
283
|
+
throw new Error(`REST request failed: ${res.status} ${res.statusText}`);
|
|
284
|
+
}
|
|
285
|
+
return res.json();
|
|
286
|
+
}
|
|
287
|
+
async restDelete(path) {
|
|
288
|
+
const base = this.restBaseUrl();
|
|
289
|
+
const headers = { "Content-Type": "application/json" };
|
|
290
|
+
if (this.connectOptions.authToken) {
|
|
291
|
+
headers.Authorization = `Bearer ${this.connectOptions.authToken}`;
|
|
292
|
+
}
|
|
293
|
+
const res = await fetch(`${base}${path}`, {
|
|
294
|
+
method: "DELETE",
|
|
295
|
+
headers,
|
|
296
|
+
});
|
|
297
|
+
if (!res.ok) {
|
|
298
|
+
throw new Error(`REST request failed: ${res.status} ${res.statusText}`);
|
|
299
|
+
}
|
|
300
|
+
return res.json();
|
|
301
|
+
}
|
|
204
302
|
async callToolOnce(name, args, retryOnTransportError) {
|
|
205
303
|
let result;
|
|
206
304
|
try {
|
|
@@ -20,6 +20,7 @@ export declare class InMemoryThingStore implements ThingStore {
|
|
|
20
20
|
listJobs(queue: string): Promise<QueueJob[]>;
|
|
21
21
|
listDeadJobs(queue: string): Promise<QueueJob[]>;
|
|
22
22
|
search(query: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
|
|
23
|
+
private matchesFilter;
|
|
23
24
|
countObjects(): Promise<number>;
|
|
24
25
|
countEvents(): Promise<number>;
|
|
25
26
|
countActiveJobs(): Promise<number>;
|
|
@@ -1 +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,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,YAA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U,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQhC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,aAAa,IAAI;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;IAI9D,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,QAAQ;CAQjB"}
|
|
@@ -224,12 +224,16 @@ export class InMemoryThingStore {
|
|
|
224
224
|
async search(query, options = {}) {
|
|
225
225
|
const normalizedQuery = query.toLowerCase();
|
|
226
226
|
const collections = options.collections ? new Set(options.collections) : null;
|
|
227
|
+
const filter = options.filter;
|
|
227
228
|
const results = [];
|
|
228
229
|
for (const [collection, records] of this.collections) {
|
|
229
230
|
if (collections && !collections.has(collection)) {
|
|
230
231
|
continue;
|
|
231
232
|
}
|
|
232
233
|
for (const record of records.values()) {
|
|
234
|
+
if (filter && !this.matchesFilter(filter, record)) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
233
237
|
const haystack = JSON.stringify(record).toLowerCase();
|
|
234
238
|
if (haystack.includes(normalizedQuery)) {
|
|
235
239
|
results.push({
|
|
@@ -243,6 +247,9 @@ export class InMemoryThingStore {
|
|
|
243
247
|
}
|
|
244
248
|
}
|
|
245
249
|
for (const event of this.events) {
|
|
250
|
+
if (filter && !this.matchesFilter(filter, event)) {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
246
253
|
const haystack = JSON.stringify(event).toLowerCase();
|
|
247
254
|
if (haystack.includes(normalizedQuery)) {
|
|
248
255
|
results.push({
|
|
@@ -256,6 +263,11 @@ export class InMemoryThingStore {
|
|
|
256
263
|
}
|
|
257
264
|
return options.limit !== undefined ? results.slice(0, options.limit) : results;
|
|
258
265
|
}
|
|
266
|
+
matchesFilter(filter, obj) {
|
|
267
|
+
return Object.entries(filter).every(([key, expected]) => {
|
|
268
|
+
return key in obj && obj[key] === expected;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
259
271
|
async countObjects() {
|
|
260
272
|
let total = 0;
|
|
261
273
|
for (const records of this.collections.values()) {
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thingd/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "A fast object-first data engine for applications and AI agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Sayan Mohsin",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"zod": "^4.4.3"
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
|
66
|
-
"@thingd/native": "0.
|
|
66
|
+
"@thingd/native": "0.37.0"
|
|
67
67
|
},
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=24.0.0"
|