@powerhousedao/knowledge-note 1.0.2 → 1.0.3
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/editors/knowledge-vault/components/GraphView.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/components/GraphView.js +210 -32
- package/dist/editors/knowledge-vault/components/NoteList.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/components/NoteList.js +13 -16
- package/dist/editors/knowledge-vault/hooks/use-drive-init.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/hooks/use-drive-init.js +0 -2
- package/dist/package.json +2 -2
- package/dist/processors/factory.d.ts.map +1 -1
- package/dist/processors/factory.js +0 -3
- package/dist/processors/graph-indexer/index.d.ts.map +1 -1
- package/dist/processors/graph-indexer/index.js +5 -8
- package/dist/style.css +67 -0
- package/dist/subgraphs/index.d.ts +0 -1
- package/dist/subgraphs/index.d.ts.map +1 -1
- package/dist/subgraphs/index.js +0 -1
- package/dist/subgraphs/knowledge-graph/subgraph.d.ts +28 -13
- package/dist/subgraphs/knowledge-graph/subgraph.d.ts.map +1 -1
- package/dist/subgraphs/knowledge-graph/subgraph.js +99 -7
- package/package.json +3 -3
- package/dist/processors/methodology-indexer/factory.d.ts +0 -4
- package/dist/processors/methodology-indexer/factory.d.ts.map +0 -1
- package/dist/processors/methodology-indexer/factory.js +0 -23
- package/dist/processors/methodology-indexer/index.d.ts +0 -11
- package/dist/processors/methodology-indexer/index.d.ts.map +0 -1
- package/dist/processors/methodology-indexer/index.js +0 -116
- package/dist/processors/methodology-indexer/migrations.d.ts +0 -4
- package/dist/processors/methodology-indexer/migrations.d.ts.map +0 -1
- package/dist/processors/methodology-indexer/migrations.js +0 -39
- package/dist/processors/methodology-indexer/query.d.ts +0 -35
- package/dist/processors/methodology-indexer/query.d.ts.map +0 -1
- package/dist/processors/methodology-indexer/query.js +0 -114
- package/dist/processors/methodology-indexer/schema.d.ts +0 -22
- package/dist/processors/methodology-indexer/schema.d.ts.map +0 -1
- package/dist/processors/methodology-indexer/schema.js +0 -1
- package/dist/subgraphs/methodology/index.d.ts +0 -2
- package/dist/subgraphs/methodology/index.d.ts.map +0 -1
- package/dist/subgraphs/methodology/index.js +0 -1
- package/dist/subgraphs/methodology/subgraph.d.ts +0 -47
- package/dist/subgraphs/methodology/subgraph.d.ts.map +0 -1
- package/dist/subgraphs/methodology/subgraph.js +0 -100
package/dist/style.css
CHANGED
|
@@ -239,6 +239,9 @@
|
|
|
239
239
|
.pointer-events-none {
|
|
240
240
|
pointer-events: none;
|
|
241
241
|
}
|
|
242
|
+
.collapse {
|
|
243
|
+
visibility: collapse;
|
|
244
|
+
}
|
|
242
245
|
.invisible {
|
|
243
246
|
visibility: hidden;
|
|
244
247
|
}
|
|
@@ -257,6 +260,9 @@
|
|
|
257
260
|
.static {
|
|
258
261
|
position: static;
|
|
259
262
|
}
|
|
263
|
+
.sticky {
|
|
264
|
+
position: sticky;
|
|
265
|
+
}
|
|
260
266
|
.inset-0 {
|
|
261
267
|
inset: calc(var(--spacing) * 0);
|
|
262
268
|
}
|
|
@@ -287,6 +293,9 @@
|
|
|
287
293
|
.left-4 {
|
|
288
294
|
left: calc(var(--spacing) * 4);
|
|
289
295
|
}
|
|
296
|
+
.isolate {
|
|
297
|
+
isolation: isolate;
|
|
298
|
+
}
|
|
290
299
|
.z-10 {
|
|
291
300
|
z-index: 10;
|
|
292
301
|
}
|
|
@@ -614,9 +623,15 @@
|
|
|
614
623
|
.flex-shrink-0 {
|
|
615
624
|
flex-shrink: 0;
|
|
616
625
|
}
|
|
626
|
+
.shrink {
|
|
627
|
+
flex-shrink: 1;
|
|
628
|
+
}
|
|
617
629
|
.shrink-0 {
|
|
618
630
|
flex-shrink: 0;
|
|
619
631
|
}
|
|
632
|
+
.grow {
|
|
633
|
+
flex-grow: 1;
|
|
634
|
+
}
|
|
620
635
|
.border-collapse {
|
|
621
636
|
border-collapse: collapse;
|
|
622
637
|
}
|
|
@@ -856,6 +871,9 @@
|
|
|
856
871
|
.border-\[\#cba6f7\]\/20 {
|
|
857
872
|
border-color: color-mix(in oklab, #cba6f7 20%, transparent);
|
|
858
873
|
}
|
|
874
|
+
.border-\[var\(--bai-border\)\] {
|
|
875
|
+
border-color: var(--bai-border);
|
|
876
|
+
}
|
|
859
877
|
.border-amber-500\/30 {
|
|
860
878
|
border-color: color-mix(in srgb, oklch(76.9% 0.188 70.08) 30%, transparent);
|
|
861
879
|
@supports (color: color-mix(in lab, red, red)) {
|
|
@@ -946,6 +964,9 @@
|
|
|
946
964
|
.bg-\[\#cba6f7\]\/10 {
|
|
947
965
|
background-color: color-mix(in oklab, #cba6f7 10%, transparent);
|
|
948
966
|
}
|
|
967
|
+
.bg-\[var\(--bai-surface\)\] {
|
|
968
|
+
background-color: var(--bai-surface);
|
|
969
|
+
}
|
|
949
970
|
.bg-amber-400 {
|
|
950
971
|
background-color: var(--color-amber-400);
|
|
951
972
|
}
|
|
@@ -1265,6 +1286,9 @@
|
|
|
1265
1286
|
.text-\[\#cba6f7\]\/40 {
|
|
1266
1287
|
color: color-mix(in oklab, #cba6f7 40%, transparent);
|
|
1267
1288
|
}
|
|
1289
|
+
.text-\[var\(--bai-text\)\] {
|
|
1290
|
+
color: var(--bai-text);
|
|
1291
|
+
}
|
|
1268
1292
|
.text-amber-300 {
|
|
1269
1293
|
color: var(--color-amber-300);
|
|
1270
1294
|
}
|
|
@@ -1356,6 +1380,10 @@
|
|
|
1356
1380
|
.opacity-60 {
|
|
1357
1381
|
opacity: 60%;
|
|
1358
1382
|
}
|
|
1383
|
+
.shadow {
|
|
1384
|
+
--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
|
1385
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
1386
|
+
}
|
|
1359
1387
|
.shadow-2xl {
|
|
1360
1388
|
--tw-shadow: 0 25px 50px -12px var(--tw-shadow-color, rgb(0 0 0 / 0.25));
|
|
1361
1389
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
@@ -1364,6 +1392,10 @@
|
|
|
1364
1392
|
--tw-shadow: 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
|
1365
1393
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
1366
1394
|
}
|
|
1395
|
+
.ring {
|
|
1396
|
+
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
|
1397
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
1398
|
+
}
|
|
1367
1399
|
.ring-1 {
|
|
1368
1400
|
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
|
1369
1401
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
@@ -1380,6 +1412,14 @@
|
|
|
1380
1412
|
--tw-ring-color: color-mix(in oklab, var(--color-white) 5%, transparent);
|
|
1381
1413
|
}
|
|
1382
1414
|
}
|
|
1415
|
+
.outline {
|
|
1416
|
+
outline-style: var(--tw-outline-style);
|
|
1417
|
+
outline-width: 1px;
|
|
1418
|
+
}
|
|
1419
|
+
.blur {
|
|
1420
|
+
--tw-blur: blur(8px);
|
|
1421
|
+
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1422
|
+
}
|
|
1383
1423
|
.filter {
|
|
1384
1424
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1385
1425
|
}
|
|
@@ -1424,6 +1464,13 @@
|
|
|
1424
1464
|
}
|
|
1425
1465
|
}
|
|
1426
1466
|
}
|
|
1467
|
+
.group-hover\:text-\[var\(--bai-accent\)\] {
|
|
1468
|
+
&:is(:where(.group):hover *) {
|
|
1469
|
+
@media (hover: hover) {
|
|
1470
|
+
color: var(--bai-accent);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1427
1474
|
.group-hover\:opacity-100 {
|
|
1428
1475
|
&:is(:where(.group):hover *) {
|
|
1429
1476
|
@media (hover: hover) {
|
|
@@ -1453,6 +1500,13 @@
|
|
|
1453
1500
|
}
|
|
1454
1501
|
}
|
|
1455
1502
|
}
|
|
1503
|
+
.hover\:border-\[var\(--bai-accent\)\] {
|
|
1504
|
+
&:hover {
|
|
1505
|
+
@media (hover: hover) {
|
|
1506
|
+
border-color: var(--bai-accent);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1456
1510
|
.hover\:border-gray-600 {
|
|
1457
1511
|
&:hover {
|
|
1458
1512
|
@media (hover: hover) {
|
|
@@ -1474,6 +1528,13 @@
|
|
|
1474
1528
|
}
|
|
1475
1529
|
}
|
|
1476
1530
|
}
|
|
1531
|
+
.hover\:bg-\[var\(--bai-hover\)\] {
|
|
1532
|
+
&:hover {
|
|
1533
|
+
@media (hover: hover) {
|
|
1534
|
+
background-color: var(--bai-hover);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1477
1538
|
.hover\:bg-amber-700 {
|
|
1478
1539
|
&:hover {
|
|
1479
1540
|
@media (hover: hover) {
|
|
@@ -1928,6 +1989,11 @@
|
|
|
1928
1989
|
inherits: false;
|
|
1929
1990
|
initial-value: 0 0 #0000;
|
|
1930
1991
|
}
|
|
1992
|
+
@property --tw-outline-style {
|
|
1993
|
+
syntax: "*";
|
|
1994
|
+
inherits: false;
|
|
1995
|
+
initial-value: solid;
|
|
1996
|
+
}
|
|
1931
1997
|
@property --tw-blur {
|
|
1932
1998
|
syntax: "*";
|
|
1933
1999
|
inherits: false;
|
|
@@ -2054,6 +2120,7 @@
|
|
|
2054
2120
|
--tw-ring-offset-width: 0px;
|
|
2055
2121
|
--tw-ring-offset-color: #fff;
|
|
2056
2122
|
--tw-ring-offset-shadow: 0 0 #0000;
|
|
2123
|
+
--tw-outline-style: solid;
|
|
2057
2124
|
--tw-blur: initial;
|
|
2058
2125
|
--tw-brightness: initial;
|
|
2059
2126
|
--tw-contrast: initial;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../subgraphs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,sBAAsB,MAAM,4BAA4B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../subgraphs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,sBAAsB,MAAM,4BAA4B,CAAC"}
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -3,6 +3,15 @@ export declare class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
3
3
|
name: string;
|
|
4
4
|
typeDefs: import("graphql").DocumentNode;
|
|
5
5
|
resolvers: {
|
|
6
|
+
Mutation: {
|
|
7
|
+
knowledgeGraphReindex: (_: unknown, args: {
|
|
8
|
+
driveId: string;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
indexedNodes: number;
|
|
11
|
+
indexedEdges: number;
|
|
12
|
+
errors: string[];
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
6
15
|
Query: {
|
|
7
16
|
knowledgeGraphNodes: (_: unknown, args: {
|
|
8
17
|
driveId: string;
|
|
@@ -62,27 +71,32 @@ export declare class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
62
71
|
rawNodeCount: number;
|
|
63
72
|
rawEdgeCount: number;
|
|
64
73
|
rawNodes: {
|
|
65
|
-
id:
|
|
66
|
-
documentId:
|
|
67
|
-
title:
|
|
68
|
-
description:
|
|
69
|
-
noteType:
|
|
70
|
-
status:
|
|
71
|
-
updatedAt:
|
|
74
|
+
id: string;
|
|
75
|
+
documentId: string;
|
|
76
|
+
title: string | null;
|
|
77
|
+
description: string | null;
|
|
78
|
+
noteType: string | null;
|
|
79
|
+
status: string | null;
|
|
80
|
+
updatedAt: string;
|
|
72
81
|
}[];
|
|
73
82
|
rawEdges: {
|
|
74
|
-
id:
|
|
75
|
-
sourceDocumentId:
|
|
76
|
-
targetDocumentId:
|
|
77
|
-
linkType:
|
|
78
|
-
targetTitle:
|
|
79
|
-
updatedAt:
|
|
83
|
+
id: string;
|
|
84
|
+
sourceDocumentId: string;
|
|
85
|
+
targetDocumentId: string;
|
|
86
|
+
linkType: string | null;
|
|
87
|
+
targetTitle: string | null;
|
|
88
|
+
updatedAt: string;
|
|
80
89
|
}[];
|
|
81
90
|
processorNamespace: string;
|
|
82
91
|
}>;
|
|
83
92
|
};
|
|
84
93
|
};
|
|
85
94
|
constructor(args: SubgraphArgs);
|
|
95
|
+
/**
|
|
96
|
+
* Returns a Kysely<DB> instance scoped to the processor's namespace
|
|
97
|
+
* for the given drive. Centralizes the Legacy → IRelationalDb cast.
|
|
98
|
+
*/
|
|
99
|
+
private getDb;
|
|
86
100
|
private getQuery;
|
|
87
101
|
/**
|
|
88
102
|
* Ensures a bai/knowledge-graph document exists in the given drive.
|
|
@@ -90,6 +104,7 @@ export declare class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
90
104
|
* requiring the Connect UI to have initialized the drive first.
|
|
91
105
|
*/
|
|
92
106
|
private ensuredDrives;
|
|
107
|
+
private reindexDrive;
|
|
93
108
|
private ensureGraphDoc;
|
|
94
109
|
}
|
|
95
110
|
//# sourceMappingURL=subgraph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../subgraphs/knowledge-graph/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../subgraphs/knowledge-graph/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAO7E,qBAAa,sBAAuB,SAAQ,YAAY;IAC7C,IAAI,SAAoB;IAExB,QAAQ,iCAqGf;IAEO,SAAS;;uCAEa,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;8BAiLtC,MAAM;8BAAgB,MAAM;wBAAU,MAAM,EAAE;;;;qCA7KtC,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;qCAMlC,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;qCAMlC,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;gDAO5D,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE;uCAMd,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;2CAM9D,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE;6CAO1D,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,MAAM,EAAE,MAAM,CAAA;aAAE;yCAOtC,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE;uCAMd,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;sCAM9D,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE;yCAOrD,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE;;;;;uCAWV,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;4CAM9D,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE;qCAMhB,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;;;;;;;;;;;;;;;;;;;;;;;MAiDnE;gBAEU,IAAI,EAAE,YAAY;IAI9B;;;OAGG;IACH,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,QAAQ;IAIhB;;;;OAIG;IACH,OAAO,CAAC,aAAa,CAAqB;YAE5B,YAAY;YAqGZ,cAAc;CAmD7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gql } from "graphql-tag";
|
|
2
|
-
import { BaseSubgraph
|
|
2
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
3
3
|
import { GraphIndexerProcessor } from "../../processors/graph-indexer/index.js";
|
|
4
4
|
import { createGraphQuery } from "../../processors/graph-indexer/query.js";
|
|
5
5
|
export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
@@ -91,8 +91,25 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
91
91
|
rawEdges: [KnowledgeGraphEdge!]!
|
|
92
92
|
processorNamespace: String!
|
|
93
93
|
}
|
|
94
|
+
|
|
95
|
+
type ReindexResult {
|
|
96
|
+
indexedNodes: Int!
|
|
97
|
+
indexedEdges: Int!
|
|
98
|
+
errors: [String!]!
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
extend type Mutation {
|
|
102
|
+
"""
|
|
103
|
+
Backfill the graph index by reading all bai/knowledge-note documents
|
|
104
|
+
in the drive. Use when the processor missed historical operations.
|
|
105
|
+
"""
|
|
106
|
+
knowledgeGraphReindex(driveId: ID!): ReindexResult!
|
|
107
|
+
}
|
|
94
108
|
`;
|
|
95
109
|
resolvers = {
|
|
110
|
+
Mutation: {
|
|
111
|
+
knowledgeGraphReindex: (_, args) => this.reindexDrive(args.driveId),
|
|
112
|
+
},
|
|
96
113
|
Query: {
|
|
97
114
|
knowledgeGraphNodes: async (_, args) => {
|
|
98
115
|
await this.ensureGraphDoc(args.driveId);
|
|
@@ -157,11 +174,12 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
157
174
|
knowledgeGraphDebug: async (_, args) => {
|
|
158
175
|
const namespace = GraphIndexerProcessor.getNamespace(args.driveId);
|
|
159
176
|
try {
|
|
160
|
-
const
|
|
177
|
+
const db = this.getDb(args.driveId);
|
|
178
|
+
const rawNodes = await db
|
|
161
179
|
.selectFrom("graph_nodes")
|
|
162
180
|
.selectAll()
|
|
163
181
|
.execute();
|
|
164
|
-
const rawEdges = await
|
|
182
|
+
const rawEdges = await db
|
|
165
183
|
.selectFrom("graph_edges")
|
|
166
184
|
.selectAll()
|
|
167
185
|
.execute();
|
|
@@ -204,11 +222,15 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
204
222
|
constructor(args) {
|
|
205
223
|
super(args);
|
|
206
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Returns a Kysely<DB> instance scoped to the processor's namespace
|
|
227
|
+
* for the given drive. Centralizes the Legacy → IRelationalDb cast.
|
|
228
|
+
*/
|
|
229
|
+
getDb(driveId) {
|
|
230
|
+
return GraphIndexerProcessor.query(driveId, this.relationalDb);
|
|
231
|
+
}
|
|
207
232
|
getQuery(driveId) {
|
|
208
|
-
|
|
209
|
-
// (same pattern as the working workstreams example)
|
|
210
|
-
const queryBuilder = GraphIndexerProcessor.query(driveId, this.relationalDb);
|
|
211
|
-
return createGraphQuery(queryBuilder);
|
|
233
|
+
return createGraphQuery(this.getDb(driveId));
|
|
212
234
|
}
|
|
213
235
|
/**
|
|
214
236
|
* Ensures a bai/knowledge-graph document exists in the given drive.
|
|
@@ -216,6 +238,76 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
216
238
|
* requiring the Connect UI to have initialized the drive first.
|
|
217
239
|
*/
|
|
218
240
|
ensuredDrives = new Set();
|
|
241
|
+
async reindexDrive(driveId) {
|
|
242
|
+
const errors = [];
|
|
243
|
+
let indexedNodes = 0;
|
|
244
|
+
let indexedEdges = 0;
|
|
245
|
+
try {
|
|
246
|
+
const drive = await this.reactorClient.get(driveId);
|
|
247
|
+
const nodes = drive.state.global.nodes;
|
|
248
|
+
const noteNodes = nodes.filter((n) => n.kind === "file" && n.documentType === "bai/knowledge-note");
|
|
249
|
+
const db = this.getDb(driveId);
|
|
250
|
+
const now = new Date().toISOString();
|
|
251
|
+
for (const node of noteNodes) {
|
|
252
|
+
try {
|
|
253
|
+
const doc = await this.reactorClient.get(node.id);
|
|
254
|
+
const state = doc.state;
|
|
255
|
+
const global = state.global;
|
|
256
|
+
await db
|
|
257
|
+
.insertInto("graph_nodes")
|
|
258
|
+
.values({
|
|
259
|
+
id: node.id,
|
|
260
|
+
document_id: node.id,
|
|
261
|
+
title: global.title ?? null,
|
|
262
|
+
description: global.description ?? null,
|
|
263
|
+
note_type: global.noteType ?? null,
|
|
264
|
+
status: global.status ?? "DRAFT",
|
|
265
|
+
updated_at: now,
|
|
266
|
+
})
|
|
267
|
+
.onConflict((oc) => oc.column("document_id").doUpdateSet({
|
|
268
|
+
title: global.title ?? null,
|
|
269
|
+
description: global.description ?? null,
|
|
270
|
+
note_type: global.noteType ?? null,
|
|
271
|
+
status: global.status ?? "DRAFT",
|
|
272
|
+
updated_at: now,
|
|
273
|
+
}))
|
|
274
|
+
.execute();
|
|
275
|
+
indexedNodes++;
|
|
276
|
+
// Reconcile edges
|
|
277
|
+
await db
|
|
278
|
+
.deleteFrom("graph_edges")
|
|
279
|
+
.where("source_document_id", "=", node.id)
|
|
280
|
+
.execute();
|
|
281
|
+
const links = global.links ?? [];
|
|
282
|
+
if (links.length > 0) {
|
|
283
|
+
await db
|
|
284
|
+
.insertInto("graph_edges")
|
|
285
|
+
.values(links.map((link) => ({
|
|
286
|
+
id: link.id ??
|
|
287
|
+
`${node.id}-${link.targetDocumentId}`,
|
|
288
|
+
source_document_id: node.id,
|
|
289
|
+
target_document_id: link.targetDocumentId ?? "",
|
|
290
|
+
link_type: link.linkType ?? null,
|
|
291
|
+
target_title: link.targetTitle ?? null,
|
|
292
|
+
updated_at: now,
|
|
293
|
+
})))
|
|
294
|
+
.execute();
|
|
295
|
+
indexedEdges += links.length;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
catch (err) {
|
|
299
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
300
|
+
errors.push(`${node.id}: ${msg}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
console.log(`[KnowledgeGraphSubgraph] Reindex complete: ${indexedNodes} nodes, ${indexedEdges} edges, ${errors.length} errors`);
|
|
304
|
+
}
|
|
305
|
+
catch (err) {
|
|
306
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
307
|
+
errors.push(`Drive read failed: ${msg}`);
|
|
308
|
+
}
|
|
309
|
+
return { indexedNodes, indexedEdges, errors };
|
|
310
|
+
}
|
|
219
311
|
async ensureGraphDoc(driveId) {
|
|
220
312
|
if (this.ensuredDrives.has(driveId))
|
|
221
313
|
return;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/knowledge-note",
|
|
3
3
|
"description": "Knowledge Note document model package for Powerhouse",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"/dist"
|
|
9
9
|
],
|
|
10
|
-
|
|
10
|
+
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"@powerhousedao/document-engineering": "1.40.1",
|
|
114
114
|
"@powerhousedao/vetra": "6.0.0-dev.105",
|
|
115
115
|
"cytoscape": "^3.33.1",
|
|
116
|
-
"cytoscape-
|
|
116
|
+
"cytoscape-fcose": "^2.2.0",
|
|
117
117
|
"document-model": "6.0.0-dev.105",
|
|
118
118
|
"graphql": "16.12.0",
|
|
119
119
|
"graphql-tag": "^2.12.6",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ProcessorRecord, IProcessorHostModule } from "@powerhousedao/reactor-browser";
|
|
2
|
-
import type { PHDocumentHeader } from "document-model";
|
|
3
|
-
export declare const methodologyIndexerProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
|
|
4
|
-
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,kCAAkC,GAC5C,QAAQ,oBAAoB,MACtB,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAgC/D,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {} from "@powerhousedao/shared/processors";
|
|
2
|
-
import { MethodologyIndexerProcessor } from "./index.js";
|
|
3
|
-
export const methodologyIndexerProcessorFactory = (module) => async (driveHeader) => {
|
|
4
|
-
const namespace = MethodologyIndexerProcessor.getNamespace(driveHeader.id);
|
|
5
|
-
console.log(`[MethodologyIndexer] Factory called for drive: ${driveHeader.id}, namespace: ${namespace}`);
|
|
6
|
-
const store = await module.relationalDb.createNamespace(namespace);
|
|
7
|
-
const filter = {
|
|
8
|
-
branch: ["main"],
|
|
9
|
-
documentId: ["*"],
|
|
10
|
-
documentType: ["bai/research-claim", "powerhouse/document-drive"],
|
|
11
|
-
scope: ["global"],
|
|
12
|
-
};
|
|
13
|
-
const processor = new MethodologyIndexerProcessor(namespace, filter, store);
|
|
14
|
-
await processor.initAndUpgrade();
|
|
15
|
-
console.log(`[MethodologyIndexer] Processor created for drive: ${driveHeader.id}`);
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
processor,
|
|
19
|
-
filter,
|
|
20
|
-
startFrom: "beginning",
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RelationalDbProcessor } from "@powerhousedao/shared/processors";
|
|
2
|
-
import type { OperationWithContext } from "@powerhousedao/shared/document-model";
|
|
3
|
-
import type { MethodologyDB } from "./schema.js";
|
|
4
|
-
export declare class MethodologyIndexerProcessor extends RelationalDbProcessor<MethodologyDB> {
|
|
5
|
-
static getNamespace(driveId: string): string;
|
|
6
|
-
initAndUpgrade(): Promise<void>;
|
|
7
|
-
onOperations(operations: OperationWithContext[]): Promise<void>;
|
|
8
|
-
onDisconnect(): Promise<void>;
|
|
9
|
-
private deleteClaim;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,qBAAa,2BAA4B,SAAQ,qBAAqB,CAAC,aAAa,CAAC;WACnE,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY,CACzB,UAAU,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IAsGV,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;YAYrB,WAAW;CAkB1B"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { RelationalDbProcessor } from "@powerhousedao/shared/processors";
|
|
2
|
-
import { up } from "./migrations.js";
|
|
3
|
-
export class MethodologyIndexerProcessor extends RelationalDbProcessor {
|
|
4
|
-
static getNamespace(driveId) {
|
|
5
|
-
return super.getNamespace(driveId);
|
|
6
|
-
}
|
|
7
|
-
async initAndUpgrade() {
|
|
8
|
-
await up(this.relationalDb);
|
|
9
|
-
}
|
|
10
|
-
async onOperations(operations) {
|
|
11
|
-
if (operations.length === 0)
|
|
12
|
-
return;
|
|
13
|
-
const lastByDocument = new Map();
|
|
14
|
-
for (const entry of operations) {
|
|
15
|
-
const { operation, context } = entry;
|
|
16
|
-
const documentId = context.documentId;
|
|
17
|
-
// Handle deletion from drive
|
|
18
|
-
if (context.documentType === "powerhouse/document-drive" &&
|
|
19
|
-
operation.action.type === "DELETE_NODE") {
|
|
20
|
-
const deleteInput = operation.action.input;
|
|
21
|
-
await this.deleteClaim(deleteInput.id);
|
|
22
|
-
lastByDocument.delete(deleteInput.id);
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
// Only process research-claim documents
|
|
26
|
-
if (context.documentType !== "bai/research-claim")
|
|
27
|
-
continue;
|
|
28
|
-
if (context.resultingState) {
|
|
29
|
-
lastByDocument.set(documentId, entry);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
for (const [documentId, entry] of lastByDocument) {
|
|
33
|
-
try {
|
|
34
|
-
const stateJson = entry.context.resultingState;
|
|
35
|
-
if (!stateJson)
|
|
36
|
-
continue;
|
|
37
|
-
const parsed = JSON.parse(stateJson);
|
|
38
|
-
const global = (parsed.global ?? parsed);
|
|
39
|
-
const now = new Date().toISOString();
|
|
40
|
-
// Upsert claim
|
|
41
|
-
const topics = global.topics ?? [];
|
|
42
|
-
const methodology = global.methodology ?? [];
|
|
43
|
-
await this.relationalDb
|
|
44
|
-
.insertInto("methodology_claims")
|
|
45
|
-
.values({
|
|
46
|
-
id: documentId,
|
|
47
|
-
document_id: documentId,
|
|
48
|
-
title: global.title ?? null,
|
|
49
|
-
description: global.description ?? null,
|
|
50
|
-
kind: global.kind ?? null,
|
|
51
|
-
topics: JSON.stringify(topics),
|
|
52
|
-
methodology: JSON.stringify(methodology),
|
|
53
|
-
updated_at: now,
|
|
54
|
-
})
|
|
55
|
-
.onConflict((oc) => oc.column("document_id").doUpdateSet({
|
|
56
|
-
title: global.title ?? null,
|
|
57
|
-
description: global.description ?? null,
|
|
58
|
-
kind: global.kind ?? null,
|
|
59
|
-
topics: JSON.stringify(topics),
|
|
60
|
-
methodology: JSON.stringify(methodology),
|
|
61
|
-
updated_at: now,
|
|
62
|
-
}))
|
|
63
|
-
.execute();
|
|
64
|
-
// Reconcile connections
|
|
65
|
-
await this.relationalDb
|
|
66
|
-
.deleteFrom("methodology_connections")
|
|
67
|
-
.where("source_document_id", "=", documentId)
|
|
68
|
-
.execute();
|
|
69
|
-
const connections = global.connections ?? [];
|
|
70
|
-
if (connections.length > 0) {
|
|
71
|
-
await this.relationalDb
|
|
72
|
-
.insertInto("methodology_connections")
|
|
73
|
-
.values(connections.map((conn) => ({
|
|
74
|
-
id: conn.id ??
|
|
75
|
-
`${documentId}-${conn.targetRef}`,
|
|
76
|
-
source_document_id: documentId,
|
|
77
|
-
target_ref: conn.targetRef ?? "",
|
|
78
|
-
context_phrase: conn.contextPhrase ?? null,
|
|
79
|
-
updated_at: now,
|
|
80
|
-
})))
|
|
81
|
-
.execute();
|
|
82
|
-
}
|
|
83
|
-
console.log(`[MethodologyIndexer] Reconciled ${documentId}: ${connections.length} connections`);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
console.error(`[MethodologyIndexer] Error reconciling ${documentId}:`, err);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async onDisconnect() {
|
|
91
|
-
try {
|
|
92
|
-
await this.relationalDb.deleteFrom("methodology_connections").execute();
|
|
93
|
-
await this.relationalDb.deleteFrom("methodology_claims").execute();
|
|
94
|
-
console.log(`[MethodologyIndexer] Cleaned up namespace: ${this.namespace}`);
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
console.error(`[MethodologyIndexer] Error cleaning up:`, err);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async deleteClaim(documentId) {
|
|
101
|
-
try {
|
|
102
|
-
await this.relationalDb
|
|
103
|
-
.deleteFrom("methodology_connections")
|
|
104
|
-
.where("source_document_id", "=", documentId)
|
|
105
|
-
.execute();
|
|
106
|
-
await this.relationalDb
|
|
107
|
-
.deleteFrom("methodology_claims")
|
|
108
|
-
.where("document_id", "=", documentId)
|
|
109
|
-
.execute();
|
|
110
|
-
console.log(`[MethodologyIndexer] Deleted claim ${documentId}`);
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
console.error(`[MethodologyIndexer] Error deleting claim ${documentId}:`, err);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,wBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC9D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export async function up(db) {
|
|
2
|
-
await db.schema
|
|
3
|
-
.createTable("methodology_claims")
|
|
4
|
-
.addColumn("id", "varchar(255)", (col) => col.primaryKey())
|
|
5
|
-
.addColumn("document_id", "varchar(255)", (col) => col.notNull().unique())
|
|
6
|
-
.addColumn("title", "varchar(1024)")
|
|
7
|
-
.addColumn("description", "text")
|
|
8
|
-
.addColumn("kind", "varchar(100)")
|
|
9
|
-
.addColumn("topics", "text") // JSON array as string
|
|
10
|
-
.addColumn("methodology", "text") // JSON array as string
|
|
11
|
-
.addColumn("updated_at", "varchar(50)", (col) => col.notNull())
|
|
12
|
-
.ifNotExists()
|
|
13
|
-
.execute();
|
|
14
|
-
await db.schema
|
|
15
|
-
.createTable("methodology_connections")
|
|
16
|
-
.addColumn("id", "varchar(255)", (col) => col.primaryKey())
|
|
17
|
-
.addColumn("source_document_id", "varchar(255)", (col) => col.notNull())
|
|
18
|
-
.addColumn("target_ref", "varchar(255)", (col) => col.notNull())
|
|
19
|
-
.addColumn("context_phrase", "text")
|
|
20
|
-
.addColumn("updated_at", "varchar(50)", (col) => col.notNull())
|
|
21
|
-
.ifNotExists()
|
|
22
|
-
.execute();
|
|
23
|
-
await db.schema
|
|
24
|
-
.createIndex("idx_methodology_claims_kind")
|
|
25
|
-
.on("methodology_claims")
|
|
26
|
-
.column("kind")
|
|
27
|
-
.ifNotExists()
|
|
28
|
-
.execute();
|
|
29
|
-
await db.schema
|
|
30
|
-
.createIndex("idx_methodology_connections_source")
|
|
31
|
-
.on("methodology_connections")
|
|
32
|
-
.column("source_document_id")
|
|
33
|
-
.ifNotExists()
|
|
34
|
-
.execute();
|
|
35
|
-
}
|
|
36
|
-
export async function down(db) {
|
|
37
|
-
await db.schema.dropTable("methodology_connections").ifExists().execute();
|
|
38
|
-
await db.schema.dropTable("methodology_claims").ifExists().execute();
|
|
39
|
-
}
|