dsh-mnemon-provider-hindsight 0.5.5 → 0.5.7
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/lib/index.d.ts +3 -1
- package/lib/index.js +17 -5
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { EdgeType, HttpMemoryProvider, HttpProviderOptions, Insight, JsonValue,
|
|
|
3
3
|
//#region src/driver.d.ts
|
|
4
4
|
declare class HindsightProvider extends HttpMemoryProvider implements MemoryProviderAdapter {
|
|
5
5
|
readonly id: "hindsight";
|
|
6
|
-
readonly scoreSemantics:
|
|
6
|
+
readonly scoreSemantics: Readonly<{
|
|
7
|
+
kind: "provider-native";
|
|
8
|
+
}>;
|
|
7
9
|
constructor(memorySpaces: MemorySpaceAuthority, options?: HttpProviderOptions);
|
|
8
10
|
discover(connection: Record<string, string | number | boolean>, signal?: AbortSignal): Promise<ProviderMemorySpace[]>;
|
|
9
11
|
status(body: MemoryBody, signal?: AbortSignal): Promise<ProviderBodyStatus>;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { t as descriptor } from "./descriptor-BxGaZkfv.js";
|
|
2
|
-
import { HttpMemoryProvider, MEMORY_SPACE_PROVIDER_API_VERSION,
|
|
2
|
+
import { HttpMemoryProvider, MEMORY_SPACE_PROVIDER_API_VERSION, defineMemorySpaceProvider, defineMemorySpaceProviderDefinition, firstArray, jsonArray, jsonNumber, jsonObject, jsonString } from "dsh-mnemon-source-memory-spaces/provider-sdk";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/driver.ts
|
|
5
|
+
/**
|
|
6
|
+
* An entity name without the note Hindsight may append in parentheses, `Alice (person)`. The same
|
|
7
|
+
* result as removing /\s*\([^)]*\)\s*$/u, in one pass: that pattern took quadratic time on a
|
|
8
|
+
* name of many "(" without a ")", and the name comes from the server.
|
|
9
|
+
*/
|
|
10
|
+
function withoutTrailingNote(entry) {
|
|
11
|
+
const trimmed = entry.trimEnd();
|
|
12
|
+
if (!trimmed.endsWith(")")) return entry.trim();
|
|
13
|
+
const close = trimmed.length - 1;
|
|
14
|
+
const open = trimmed.indexOf("(", trimmed.lastIndexOf(")", close - 1) + 1);
|
|
15
|
+
return open < 0 || open >= close ? entry.trim() : trimmed.slice(0, open).trim();
|
|
16
|
+
}
|
|
5
17
|
function insight(value) {
|
|
6
18
|
const item = jsonObject(value);
|
|
7
19
|
const id = jsonString(item?.id);
|
|
@@ -11,7 +23,7 @@ function insight(value) {
|
|
|
11
23
|
const score = jsonNumber(scores?.final) ?? jsonNumber(item?.score);
|
|
12
24
|
const createdAt = jsonString(item?.mentioned_at) ?? jsonString(item?.date) ?? jsonString(item?.occurred_start);
|
|
13
25
|
const rawEntities = item?.entities;
|
|
14
|
-
const entities = Array.isArray(rawEntities) ? rawEntities.filter((entry) => typeof entry === "string") : typeof rawEntities === "string" ? rawEntities.split(",").map(
|
|
26
|
+
const entities = Array.isArray(rawEntities) ? rawEntities.filter((entry) => typeof entry === "string") : typeof rawEntities === "string" ? rawEntities.split(",").map(withoutTrailingNote).filter(Boolean) : [];
|
|
15
27
|
const tags = jsonArray(item?.tags).filter((entry) => typeof entry === "string");
|
|
16
28
|
return {
|
|
17
29
|
id,
|
|
@@ -29,7 +41,7 @@ function edgeType(value) {
|
|
|
29
41
|
}
|
|
30
42
|
var HindsightProvider = class extends HttpMemoryProvider {
|
|
31
43
|
id = "hindsight";
|
|
32
|
-
scoreSemantics =
|
|
44
|
+
scoreSemantics = Object.freeze({ kind: "provider-native" });
|
|
33
45
|
constructor(memorySpaces, options = {}) {
|
|
34
46
|
super(memorySpaces, {
|
|
35
47
|
label: descriptor.label,
|
|
@@ -252,7 +264,7 @@ const definition = defineMemorySpaceProviderDefinition({
|
|
|
252
264
|
kind: "provider",
|
|
253
265
|
typeId: descriptor.id,
|
|
254
266
|
packageName: "dsh-mnemon-provider-hindsight",
|
|
255
|
-
version: "0.5.
|
|
267
|
+
version: "0.5.7",
|
|
256
268
|
label: descriptor.label,
|
|
257
269
|
icon: descriptor.icon,
|
|
258
270
|
summary: descriptor.summary,
|
|
@@ -263,7 +275,7 @@ const definition = defineMemorySpaceProviderDefinition({
|
|
|
263
275
|
capabilities: descriptor.capabilities,
|
|
264
276
|
fields: descriptor.fields,
|
|
265
277
|
secrets: descriptor.fields.filter((field) => field.input === "secret").map((field) => field.key),
|
|
266
|
-
scoreSemantics: "
|
|
278
|
+
scoreSemantics: "provider-native"
|
|
267
279
|
},
|
|
268
280
|
create: (context) => new HindsightProvider(context.memorySpaces ?? context.memoryBodies, { requestTimeoutMs: context.config.timeoutMs })
|
|
269
281
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon-provider-hindsight",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "Hindsight Provider child for the Memory Spaces Source.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.0.0",
|
|
37
|
-
"dsh-mnemon-source-memory-spaces": "^0.5.
|
|
37
|
+
"dsh-mnemon-source-memory-spaces": "^0.5.23",
|
|
38
38
|
"tsdown": "^0.22.0",
|
|
39
39
|
"typescript": "^5.9.0",
|
|
40
40
|
"vitest": "^3.2.0"
|