@powerhousedao/knowledge-note 1.0.0 → 1.0.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/editors/health-report-editor/editor.d.ts.map +1 -1
- package/dist/editors/health-report-editor/editor.js +100 -17
- package/dist/editors/knowledge-note-editor/editor.d.ts.map +1 -1
- package/dist/editors/knowledge-note-editor/editor.js +12 -3
- package/dist/editors/knowledge-vault/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/components/GettingStarted.js +26 -7
- package/dist/editors/knowledge-vault/components/GraphView.d.ts +1 -1
- package/dist/editors/knowledge-vault/components/GraphView.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/components/GraphView.js +1 -1
- package/dist/editors/knowledge-vault/components/HealthDashboard.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/components/HealthDashboard.js +16 -4
- package/dist/editors/knowledge-vault/hooks/use-drive-init.d.ts.map +1 -1
- package/dist/editors/knowledge-vault/hooks/use-drive-init.js +78 -62
- package/dist/editors/moc-editor/editor.d.ts.map +1 -1
- package/dist/editors/moc-editor/editor.js +13 -4
- package/dist/editors/tension-editor/editor.d.ts.map +1 -1
- package/dist/editors/tension-editor/editor.js +60 -9
- package/dist/package.json +45 -1
- package/dist/processors/factory.d.ts.map +1 -1
- package/dist/processors/factory.js +4 -1
- package/dist/processors/graph-indexer/index.d.ts.map +1 -1
- package/dist/processors/graph-indexer/query.d.ts.map +1 -1
- package/dist/processors/graph-indexer/query.js +2 -1
- package/dist/processors/methodology-indexer/factory.d.ts +4 -0
- package/dist/processors/methodology-indexer/factory.d.ts.map +1 -0
- package/dist/processors/methodology-indexer/factory.js +23 -0
- package/dist/processors/methodology-indexer/index.d.ts +11 -0
- package/dist/processors/methodology-indexer/index.d.ts.map +1 -0
- package/dist/processors/methodology-indexer/index.js +116 -0
- package/dist/processors/methodology-indexer/migrations.d.ts +4 -0
- package/dist/processors/methodology-indexer/migrations.d.ts.map +1 -0
- package/dist/processors/methodology-indexer/migrations.js +39 -0
- package/dist/processors/methodology-indexer/query.d.ts +35 -0
- package/dist/processors/methodology-indexer/query.d.ts.map +1 -0
- package/dist/processors/methodology-indexer/query.js +114 -0
- package/dist/processors/methodology-indexer/schema.d.ts +22 -0
- package/dist/processors/methodology-indexer/schema.d.ts.map +1 -0
- package/dist/processors/methodology-indexer/schema.js +1 -0
- package/dist/style.css +15 -0
- package/dist/subgraphs/index.d.ts +1 -0
- package/dist/subgraphs/index.d.ts.map +1 -1
- package/dist/subgraphs/index.js +1 -0
- package/dist/subgraphs/knowledge-graph/subgraph.d.ts.map +1 -1
- package/dist/subgraphs/knowledge-graph/subgraph.js +45 -15
- package/dist/subgraphs/methodology/index.d.ts +2 -0
- package/dist/subgraphs/methodology/index.d.ts.map +1 -0
- package/dist/subgraphs/methodology/index.js +1 -0
- package/dist/subgraphs/methodology/subgraph.d.ts +47 -0
- package/dist/subgraphs/methodology/subgraph.d.ts.map +1 -0
- package/dist/subgraphs/methodology/subgraph.js +100 -0
- package/dist/tests/processor/graph-indexer.test.js +8 -2
- package/dist/tests/unit/knowledge-note-reducers.test.js +4 -1
- package/dist/tests/unit/lifecycle-state-machine.test.js +16 -4
- package/dist/tests/unit/moc-reducers.test.js +1 -1
- package/dist/tests/unit/pipeline-queue-reducers.test.js +10 -2
- package/package.json +45 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function rowToClaim(row) {
|
|
2
|
+
return {
|
|
3
|
+
id: row.id,
|
|
4
|
+
documentId: row.document_id,
|
|
5
|
+
title: row.title,
|
|
6
|
+
description: row.description,
|
|
7
|
+
kind: row.kind,
|
|
8
|
+
topics: row.topics ? JSON.parse(row.topics) : [],
|
|
9
|
+
methodology: row.methodology ? JSON.parse(row.methodology) : [],
|
|
10
|
+
updatedAt: row.updated_at,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function rowToConnection(row) {
|
|
14
|
+
return {
|
|
15
|
+
id: row.id,
|
|
16
|
+
sourceDocumentId: row.source_document_id,
|
|
17
|
+
targetRef: row.target_ref,
|
|
18
|
+
contextPhrase: row.context_phrase,
|
|
19
|
+
updatedAt: row.updated_at,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function createMethodologyQuery(db) {
|
|
23
|
+
return {
|
|
24
|
+
async allClaims() {
|
|
25
|
+
const rows = await db
|
|
26
|
+
.selectFrom("methodology_claims")
|
|
27
|
+
.selectAll()
|
|
28
|
+
.execute();
|
|
29
|
+
return rows.map(rowToClaim);
|
|
30
|
+
},
|
|
31
|
+
async claimCount() {
|
|
32
|
+
const rows = await db
|
|
33
|
+
.selectFrom("methodology_claims")
|
|
34
|
+
.selectAll()
|
|
35
|
+
.execute();
|
|
36
|
+
return rows.length;
|
|
37
|
+
},
|
|
38
|
+
async claimByDocumentId(documentId) {
|
|
39
|
+
const row = await db
|
|
40
|
+
.selectFrom("methodology_claims")
|
|
41
|
+
.where("document_id", "=", documentId)
|
|
42
|
+
.selectAll()
|
|
43
|
+
.executeTakeFirst();
|
|
44
|
+
return row ? rowToClaim(row) : undefined;
|
|
45
|
+
},
|
|
46
|
+
async claimsByKind(kind) {
|
|
47
|
+
const rows = await db
|
|
48
|
+
.selectFrom("methodology_claims")
|
|
49
|
+
.where("kind", "=", kind)
|
|
50
|
+
.selectAll()
|
|
51
|
+
.execute();
|
|
52
|
+
return rows.map(rowToClaim);
|
|
53
|
+
},
|
|
54
|
+
async searchClaims(query, limit = 50) {
|
|
55
|
+
const q = `%${query.toLowerCase()}%`;
|
|
56
|
+
const rows = await db
|
|
57
|
+
.selectFrom("methodology_claims")
|
|
58
|
+
.where((eb) => eb.or([
|
|
59
|
+
eb(eb.fn("lower", ["title"]), "like", q),
|
|
60
|
+
eb(eb.fn("lower", ["description"]), "like", q),
|
|
61
|
+
eb(eb.fn("lower", ["topics"]), "like", q),
|
|
62
|
+
]))
|
|
63
|
+
.selectAll()
|
|
64
|
+
.limit(limit)
|
|
65
|
+
.execute();
|
|
66
|
+
return rows.map(rowToClaim);
|
|
67
|
+
},
|
|
68
|
+
async claimsByTopic(topic) {
|
|
69
|
+
const q = `%"${topic.toLowerCase()}"%`;
|
|
70
|
+
const rows = await db
|
|
71
|
+
.selectFrom("methodology_claims")
|
|
72
|
+
.where((eb) => eb(eb.fn("lower", ["topics"]), "like", q))
|
|
73
|
+
.selectAll()
|
|
74
|
+
.execute();
|
|
75
|
+
return rows.map(rowToClaim);
|
|
76
|
+
},
|
|
77
|
+
async connectionsFrom(documentId) {
|
|
78
|
+
const rows = await db
|
|
79
|
+
.selectFrom("methodology_connections")
|
|
80
|
+
.where("source_document_id", "=", documentId)
|
|
81
|
+
.selectAll()
|
|
82
|
+
.execute();
|
|
83
|
+
return rows.map(rowToConnection);
|
|
84
|
+
},
|
|
85
|
+
async connectionsTo(targetRef) {
|
|
86
|
+
const rows = await db
|
|
87
|
+
.selectFrom("methodology_connections")
|
|
88
|
+
.where("target_ref", "=", targetRef)
|
|
89
|
+
.selectAll()
|
|
90
|
+
.execute();
|
|
91
|
+
return rows.map(rowToConnection);
|
|
92
|
+
},
|
|
93
|
+
async stats() {
|
|
94
|
+
const claims = await db
|
|
95
|
+
.selectFrom("methodology_claims")
|
|
96
|
+
.selectAll()
|
|
97
|
+
.execute();
|
|
98
|
+
const connections = await db
|
|
99
|
+
.selectFrom("methodology_connections")
|
|
100
|
+
.selectAll()
|
|
101
|
+
.execute();
|
|
102
|
+
const kindDist = {};
|
|
103
|
+
for (const c of claims) {
|
|
104
|
+
const k = c.kind ?? "unknown";
|
|
105
|
+
kindDist[k] = (kindDist[k] ?? 0) + 1;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
claimCount: claims.length,
|
|
109
|
+
connectionCount: connections.length,
|
|
110
|
+
kindDistribution: kindDist,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface MethodologyClaim {
|
|
2
|
+
id: string;
|
|
3
|
+
document_id: string;
|
|
4
|
+
title: string | null;
|
|
5
|
+
description: string | null;
|
|
6
|
+
kind: string | null;
|
|
7
|
+
topics: string | null;
|
|
8
|
+
methodology: string | null;
|
|
9
|
+
updated_at: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MethodologyConnection {
|
|
12
|
+
id: string;
|
|
13
|
+
source_document_id: string;
|
|
14
|
+
target_ref: string;
|
|
15
|
+
context_phrase: string | null;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
}
|
|
18
|
+
export interface MethodologyDB {
|
|
19
|
+
methodology_claims: MethodologyClaim;
|
|
20
|
+
methodology_connections: MethodologyConnection;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,kBAAkB,EAAE,gBAAgB,CAAC;IACrC,uBAAuB,EAAE,qBAAqB,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/style.css
CHANGED
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
--font-weight-semibold: 600;
|
|
74
74
|
--font-weight-bold: 700;
|
|
75
75
|
--tracking-wider: 0.05em;
|
|
76
|
+
--leading-snug: 1.375;
|
|
76
77
|
--leading-relaxed: 1.625;
|
|
77
78
|
--radius-md: 0.375rem;
|
|
78
79
|
--radius-lg: 0.5rem;
|
|
@@ -601,6 +602,9 @@
|
|
|
601
602
|
.max-w-\[120px\] {
|
|
602
603
|
max-width: 120px;
|
|
603
604
|
}
|
|
605
|
+
.max-w-full {
|
|
606
|
+
max-width: 100%;
|
|
607
|
+
}
|
|
604
608
|
.min-w-0 {
|
|
605
609
|
min-width: calc(var(--spacing) * 0);
|
|
606
610
|
}
|
|
@@ -1222,6 +1226,10 @@
|
|
|
1222
1226
|
--tw-leading: var(--leading-relaxed);
|
|
1223
1227
|
line-height: var(--leading-relaxed);
|
|
1224
1228
|
}
|
|
1229
|
+
.leading-snug {
|
|
1230
|
+
--tw-leading: var(--leading-snug);
|
|
1231
|
+
line-height: var(--leading-snug);
|
|
1232
|
+
}
|
|
1225
1233
|
.font-bold {
|
|
1226
1234
|
--tw-font-weight: var(--font-weight-bold);
|
|
1227
1235
|
font-weight: var(--font-weight-bold);
|
|
@@ -1559,6 +1567,13 @@
|
|
|
1559
1567
|
}
|
|
1560
1568
|
}
|
|
1561
1569
|
}
|
|
1570
|
+
.hover\:underline {
|
|
1571
|
+
&:hover {
|
|
1572
|
+
@media (hover: hover) {
|
|
1573
|
+
text-decoration-line: underline;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1562
1577
|
.hover\:opacity-80 {
|
|
1563
1578
|
&:hover {
|
|
1564
1579
|
@media (hover: hover) {
|
|
@@ -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;AACrE,OAAO,KAAK,mBAAmB,MAAM,wBAAwB,CAAC"}
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../subgraphs/knowledge-graph/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAMpC,qBAAa,sBAAuB,SAAQ,YAAY;IAC7C,IAAI,SAAoB;IAExB,QAAQ,
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../subgraphs/knowledge-graph/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAMpC,qBAAa,sBAAuB,SAAQ,YAAY;IAC7C,IAAI,SAAoB;IAExB,QAAQ,iCAuFf;IAEO,SAAS;;qCAEiB,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;;;;;;;;;;;;;;;;;;;;;;;MAsDnE;gBAEU,IAAI,EAAE,YAAY;IAI9B,OAAO,CAAC,QAAQ;IAUhB;;;;OAIG;IACH,OAAO,CAAC,aAAa,CAAqB;YAE5B,cAAc;CAmD7B"}
|
|
@@ -50,16 +50,31 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
50
50
|
documentId: String!
|
|
51
51
|
depth: Int
|
|
52
52
|
): [ConnectionResult!]!
|
|
53
|
-
knowledgeGraphNodesByStatus(
|
|
54
|
-
|
|
53
|
+
knowledgeGraphNodesByStatus(
|
|
54
|
+
driveId: ID!
|
|
55
|
+
status: String!
|
|
56
|
+
): [KnowledgeGraphNode!]!
|
|
57
|
+
knowledgeGraphBacklinks(
|
|
58
|
+
driveId: ID!
|
|
59
|
+
documentId: String!
|
|
60
|
+
): [KnowledgeGraphEdge!]!
|
|
55
61
|
knowledgeGraphDensity(driveId: ID!): Float!
|
|
56
62
|
|
|
57
|
-
knowledgeGraphSearch(
|
|
63
|
+
knowledgeGraphSearch(
|
|
64
|
+
driveId: ID!
|
|
65
|
+
query: String!
|
|
66
|
+
limit: Int
|
|
67
|
+
): [KnowledgeGraphNode!]!
|
|
58
68
|
knowledgeGraphTriangles(driveId: ID!, limit: Int): [Triangle!]!
|
|
59
69
|
knowledgeGraphBridges(driveId: ID!): [KnowledgeGraphNode!]!
|
|
60
|
-
knowledgeGraphForwardLinks(
|
|
70
|
+
knowledgeGraphForwardLinks(
|
|
71
|
+
driveId: ID!
|
|
72
|
+
documentId: String!
|
|
73
|
+
): [KnowledgeGraphEdge!]!
|
|
61
74
|
|
|
62
|
-
"""
|
|
75
|
+
"""
|
|
76
|
+
Debug: raw processor DB tables
|
|
77
|
+
"""
|
|
63
78
|
knowledgeGraphDebug(driveId: ID!): GraphDebugInfo!
|
|
64
79
|
}
|
|
65
80
|
|
|
@@ -125,7 +140,11 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
125
140
|
knowledgeGraphTriangles: async (_, args) => {
|
|
126
141
|
const query = this.getQuery(args.driveId);
|
|
127
142
|
const triangles = await query.triangles(args.limit ?? 20);
|
|
128
|
-
return triangles.map((t) => ({
|
|
143
|
+
return triangles.map((t) => ({
|
|
144
|
+
noteA: t.a,
|
|
145
|
+
noteB: t.b,
|
|
146
|
+
sharedTarget: t.sharedTarget,
|
|
147
|
+
}));
|
|
129
148
|
},
|
|
130
149
|
knowledgeGraphBridges: async (_, args) => {
|
|
131
150
|
const query = this.getQuery(args.driveId);
|
|
@@ -150,14 +169,21 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
150
169
|
rawNodeCount: rawNodes.length,
|
|
151
170
|
rawEdgeCount: rawEdges.length,
|
|
152
171
|
rawNodes: rawNodes.map((r) => ({
|
|
153
|
-
id: r.id,
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
id: r.id,
|
|
173
|
+
documentId: r.document_id,
|
|
174
|
+
title: r.title,
|
|
175
|
+
description: r.description,
|
|
176
|
+
noteType: r.note_type,
|
|
177
|
+
status: r.status,
|
|
178
|
+
updatedAt: r.updated_at,
|
|
156
179
|
})),
|
|
157
180
|
rawEdges: rawEdges.map((r) => ({
|
|
158
|
-
id: r.id,
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
id: r.id,
|
|
182
|
+
sourceDocumentId: r.source_document_id,
|
|
183
|
+
targetDocumentId: r.target_document_id,
|
|
184
|
+
linkType: r.link_type,
|
|
185
|
+
targetTitle: r.target_title,
|
|
186
|
+
updatedAt: r.updated_at,
|
|
161
187
|
})),
|
|
162
188
|
processorNamespace: namespace,
|
|
163
189
|
};
|
|
@@ -165,8 +191,10 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
165
191
|
catch (err) {
|
|
166
192
|
console.warn(`[KnowledgeGraphSubgraph] Debug query failed for ${namespace}:`, err);
|
|
167
193
|
return {
|
|
168
|
-
rawNodeCount: 0,
|
|
169
|
-
|
|
194
|
+
rawNodeCount: 0,
|
|
195
|
+
rawEdgeCount: 0,
|
|
196
|
+
rawNodes: [],
|
|
197
|
+
rawEdges: [],
|
|
170
198
|
processorNamespace: namespace,
|
|
171
199
|
};
|
|
172
200
|
}
|
|
@@ -205,7 +233,9 @@ export class KnowledgeGraphSubgraph extends BaseSubgraph {
|
|
|
205
233
|
parentIdentifier: parentFolder ?? driveId,
|
|
206
234
|
});
|
|
207
235
|
console.log(`[KnowledgeGraphSubgraph] Auto-created KnowledgeGraph in drive ${driveId}` +
|
|
208
|
-
(parentFolder
|
|
236
|
+
(parentFolder
|
|
237
|
+
? ` (folder: /self/)`
|
|
238
|
+
: ` (drive root — /self/ folder not found)`));
|
|
209
239
|
}
|
|
210
240
|
}
|
|
211
241
|
catch (err) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/methodology/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MethodologySubgraph } from "./subgraph.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseSubgraph, type SubgraphArgs } from "@powerhousedao/reactor-api";
|
|
2
|
+
export declare class MethodologySubgraph extends BaseSubgraph {
|
|
3
|
+
name: string;
|
|
4
|
+
typeDefs: import("graphql").DocumentNode;
|
|
5
|
+
resolvers: {
|
|
6
|
+
Query: {
|
|
7
|
+
methodologySearch: (_: unknown, args: {
|
|
8
|
+
driveId: string;
|
|
9
|
+
query: string;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ClaimResult[]>;
|
|
12
|
+
methodologyClaims: (_: unknown, args: {
|
|
13
|
+
driveId: string;
|
|
14
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ClaimResult[]>;
|
|
15
|
+
methodologyClaimsByKind: (_: unknown, args: {
|
|
16
|
+
driveId: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ClaimResult[]>;
|
|
19
|
+
methodologyClaimsByTopic: (_: unknown, args: {
|
|
20
|
+
driveId: string;
|
|
21
|
+
topic: string;
|
|
22
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ClaimResult[]>;
|
|
23
|
+
methodologyClaimById: (_: unknown, args: {
|
|
24
|
+
driveId: string;
|
|
25
|
+
documentId: string;
|
|
26
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ClaimResult | undefined>;
|
|
27
|
+
methodologyStats: (_: unknown, args: {
|
|
28
|
+
driveId: string;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
claimCount: number;
|
|
31
|
+
connectionCount: number;
|
|
32
|
+
kindDistribution: Record<string, number>;
|
|
33
|
+
}>;
|
|
34
|
+
methodologyConnectionsFrom: (_: unknown, args: {
|
|
35
|
+
driveId: string;
|
|
36
|
+
documentId: string;
|
|
37
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ConnectionResult[]>;
|
|
38
|
+
methodologyConnectionsTo: (_: unknown, args: {
|
|
39
|
+
driveId: string;
|
|
40
|
+
targetRef: string;
|
|
41
|
+
}) => Promise<import("../../processors/methodology-indexer/query.js").ConnectionResult[]>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
constructor(args: SubgraphArgs);
|
|
45
|
+
private getQuery;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=subgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../subgraphs/methodology/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAM7E,qBAAa,mBAAoB,SAAQ,YAAY;IAC1C,IAAI,SAAiB;IAErB,QAAQ,iCAiDf;IAEO,SAAS;;mCAGT,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE;mCAM7B,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;yCAM1D,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAE;0CAOpC,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE;sCAOrC,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE;kCAMnB,OAAO,QAAQ;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE;;;;;4CAMzD,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE;0CAO1C,OAAO,QACJ;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAA;aAAE;;MAMhD;gBAEU,IAAI,EAAE,YAAY;IAI9B,OAAO,CAAC,QAAQ;CASjB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
3
|
+
import { MethodologyIndexerProcessor } from "../../processors/methodology-indexer/index.js";
|
|
4
|
+
import { createMethodologyQuery } from "../../processors/methodology-indexer/query.js";
|
|
5
|
+
export class MethodologySubgraph extends BaseSubgraph {
|
|
6
|
+
name = "methodology";
|
|
7
|
+
typeDefs = gql `
|
|
8
|
+
type MethodologyClaim {
|
|
9
|
+
id: String!
|
|
10
|
+
documentId: String!
|
|
11
|
+
title: String
|
|
12
|
+
description: String
|
|
13
|
+
kind: String
|
|
14
|
+
topics: [String!]!
|
|
15
|
+
methodology: [String!]!
|
|
16
|
+
updatedAt: String!
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type MethodologyConnection {
|
|
20
|
+
id: String!
|
|
21
|
+
sourceDocumentId: String!
|
|
22
|
+
targetRef: String!
|
|
23
|
+
contextPhrase: String
|
|
24
|
+
updatedAt: String!
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type MethodologyStats {
|
|
28
|
+
claimCount: Int!
|
|
29
|
+
connectionCount: Int!
|
|
30
|
+
kindDistribution: JSONObject
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
extend type Query {
|
|
34
|
+
methodologySearch(
|
|
35
|
+
driveId: ID!
|
|
36
|
+
query: String!
|
|
37
|
+
limit: Int
|
|
38
|
+
): [MethodologyClaim!]!
|
|
39
|
+
methodologyClaims(driveId: ID!): [MethodologyClaim!]!
|
|
40
|
+
methodologyClaimsByKind(driveId: ID!, kind: String!): [MethodologyClaim!]!
|
|
41
|
+
methodologyClaimsByTopic(
|
|
42
|
+
driveId: ID!
|
|
43
|
+
topic: String!
|
|
44
|
+
): [MethodologyClaim!]!
|
|
45
|
+
methodologyClaimById(driveId: ID!, documentId: String!): MethodologyClaim
|
|
46
|
+
methodologyStats(driveId: ID!): MethodologyStats!
|
|
47
|
+
methodologyConnectionsFrom(
|
|
48
|
+
driveId: ID!
|
|
49
|
+
documentId: String!
|
|
50
|
+
): [MethodologyConnection!]!
|
|
51
|
+
methodologyConnectionsTo(
|
|
52
|
+
driveId: ID!
|
|
53
|
+
targetRef: String!
|
|
54
|
+
): [MethodologyConnection!]!
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
resolvers = {
|
|
58
|
+
Query: {
|
|
59
|
+
methodologySearch: async (_, args) => {
|
|
60
|
+
const query = this.getQuery(args.driveId);
|
|
61
|
+
return query.searchClaims(args.query, args.limit ?? 50);
|
|
62
|
+
},
|
|
63
|
+
methodologyClaims: async (_, args) => {
|
|
64
|
+
const query = this.getQuery(args.driveId);
|
|
65
|
+
return query.allClaims();
|
|
66
|
+
},
|
|
67
|
+
methodologyClaimsByKind: async (_, args) => {
|
|
68
|
+
const query = this.getQuery(args.driveId);
|
|
69
|
+
return query.claimsByKind(args.kind);
|
|
70
|
+
},
|
|
71
|
+
methodologyClaimsByTopic: async (_, args) => {
|
|
72
|
+
const query = this.getQuery(args.driveId);
|
|
73
|
+
return query.claimsByTopic(args.topic);
|
|
74
|
+
},
|
|
75
|
+
methodologyClaimById: async (_, args) => {
|
|
76
|
+
const query = this.getQuery(args.driveId);
|
|
77
|
+
return query.claimByDocumentId(args.documentId) ?? null;
|
|
78
|
+
},
|
|
79
|
+
methodologyStats: async (_, args) => {
|
|
80
|
+
const query = this.getQuery(args.driveId);
|
|
81
|
+
return query.stats();
|
|
82
|
+
},
|
|
83
|
+
methodologyConnectionsFrom: async (_, args) => {
|
|
84
|
+
const query = this.getQuery(args.driveId);
|
|
85
|
+
return query.connectionsFrom(args.documentId);
|
|
86
|
+
},
|
|
87
|
+
methodologyConnectionsTo: async (_, args) => {
|
|
88
|
+
const query = this.getQuery(args.driveId);
|
|
89
|
+
return query.connectionsTo(args.targetRef);
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
constructor(args) {
|
|
94
|
+
super(args);
|
|
95
|
+
}
|
|
96
|
+
getQuery(driveId) {
|
|
97
|
+
const queryBuilder = MethodologyIndexerProcessor.query(driveId, this.relationalDb);
|
|
98
|
+
return createMethodologyQuery(queryBuilder);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -41,7 +41,10 @@ describe("graph_nodes table", () => {
|
|
|
41
41
|
expect(row.status).toBe("CANONICAL");
|
|
42
42
|
expect(row.updated_at).toBe("2024-01-01T00:00:00Z");
|
|
43
43
|
// cleanup
|
|
44
|
-
await db
|
|
44
|
+
await db
|
|
45
|
+
.deleteFrom("graph_nodes")
|
|
46
|
+
.where("document_id", "=", "doc-1")
|
|
47
|
+
.execute();
|
|
45
48
|
});
|
|
46
49
|
});
|
|
47
50
|
describe("graph_edges table", () => {
|
|
@@ -232,7 +235,10 @@ describe("upsert on conflict", () => {
|
|
|
232
235
|
expect(rows[0].status).toBe("CANONICAL");
|
|
233
236
|
expect(rows[0].updated_at).toBe("2024-06-01T00:00:00Z");
|
|
234
237
|
// cleanup
|
|
235
|
-
await db
|
|
238
|
+
await db
|
|
239
|
+
.deleteFrom("graph_nodes")
|
|
240
|
+
.where("document_id", "=", docId)
|
|
241
|
+
.execute();
|
|
236
242
|
});
|
|
237
243
|
});
|
|
238
244
|
describe("edge reconciliation", () => {
|
|
@@ -4,7 +4,10 @@ import { reducer, utils, actions, } from "@powerhousedao/knowledge-note/document
|
|
|
4
4
|
describe("Content module — state mutations", () => {
|
|
5
5
|
it("SET_TITLE — updates state.global.title", () => {
|
|
6
6
|
const document = utils.createDocument();
|
|
7
|
-
const updated = reducer(document, actions.setTitle({
|
|
7
|
+
const updated = reducer(document, actions.setTitle({
|
|
8
|
+
title: "My Note Title",
|
|
9
|
+
updatedAt: "2026-01-01T00:00:00Z",
|
|
10
|
+
}));
|
|
8
11
|
expect(updated.state.global.title).toBe("My Note Title");
|
|
9
12
|
});
|
|
10
13
|
it("SET_DESCRIPTION — updates state.global.description", () => {
|
|
@@ -204,9 +204,21 @@ describe("Lifecycle state machine — DRAFT → IN_REVIEW → CANONICAL → ARCH
|
|
|
204
204
|
expect(restored.state.global.status).toBe("DRAFT");
|
|
205
205
|
expect(restored.state.global.lifecycleEvents).toHaveLength(4);
|
|
206
206
|
const events = restored.state.global.lifecycleEvents;
|
|
207
|
-
expect(events[0]).toMatchObject({
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
expect(events[0]).toMatchObject({
|
|
208
|
+
fromStatus: "DRAFT",
|
|
209
|
+
toStatus: "IN_REVIEW",
|
|
210
|
+
});
|
|
211
|
+
expect(events[1]).toMatchObject({
|
|
212
|
+
fromStatus: "IN_REVIEW",
|
|
213
|
+
toStatus: "CANONICAL",
|
|
214
|
+
});
|
|
215
|
+
expect(events[2]).toMatchObject({
|
|
216
|
+
fromStatus: "CANONICAL",
|
|
217
|
+
toStatus: "ARCHIVED",
|
|
218
|
+
});
|
|
219
|
+
expect(events[3]).toMatchObject({
|
|
220
|
+
fromStatus: "ARCHIVED",
|
|
221
|
+
toStatus: "DRAFT",
|
|
222
|
+
});
|
|
211
223
|
});
|
|
212
224
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { reducer, utils, actions } from "@powerhousedao/knowledge-note/document-models/moc/v1";
|
|
2
|
+
import { reducer, utils, actions, } from "@powerhousedao/knowledge-note/document-models/moc/v1";
|
|
3
3
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
4
4
|
/** Create a fresh MOC document with CREATE_MOC already applied. */
|
|
5
5
|
function makeInitialisedMoc() {
|
|
@@ -89,7 +89,10 @@ describe("PipelineQueue — queue management reducers", () => {
|
|
|
89
89
|
completedAt: "2026-01-01T03:00:00Z",
|
|
90
90
|
},
|
|
91
91
|
}));
|
|
92
|
-
expect(after2.state.global.tasks[0].completedPhases).toEqual([
|
|
92
|
+
expect(after2.state.global.tasks[0].completedPhases).toEqual([
|
|
93
|
+
"create",
|
|
94
|
+
"reflect",
|
|
95
|
+
]);
|
|
93
96
|
expect(after2.state.global.tasks[0].currentPhase).toBe("reweave");
|
|
94
97
|
});
|
|
95
98
|
// ── Test 4 ──────────────────────────────────────────────────────────────────
|
|
@@ -144,7 +147,12 @@ describe("PipelineQueue — queue management reducers", () => {
|
|
|
144
147
|
const task = completed.state.global.tasks[0];
|
|
145
148
|
expect(task.status).toBe("DONE");
|
|
146
149
|
expect(task.currentPhase).toBeNull();
|
|
147
|
-
expect(task.completedPhases).toEqual([
|
|
150
|
+
expect(task.completedPhases).toEqual([
|
|
151
|
+
"create",
|
|
152
|
+
"reflect",
|
|
153
|
+
"reweave",
|
|
154
|
+
"verify",
|
|
155
|
+
]);
|
|
148
156
|
expect(completed.state.global.completedCount).toBe(1);
|
|
149
157
|
expect(completed.state.global.activeCount).toBe(0);
|
|
150
158
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.2",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -23,6 +23,50 @@
|
|
|
23
23
|
"types": "./dist/editors/index.d.ts",
|
|
24
24
|
"import": "./dist/editors/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./document-models/derivation": {
|
|
27
|
+
"types": "./dist/document-models/derivation/index.d.ts",
|
|
28
|
+
"import": "./dist/document-models/derivation/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./document-models/health-report": {
|
|
31
|
+
"types": "./dist/document-models/health-report/index.d.ts",
|
|
32
|
+
"import": "./dist/document-models/health-report/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./document-models/knowledge-graph": {
|
|
35
|
+
"types": "./dist/document-models/knowledge-graph/index.d.ts",
|
|
36
|
+
"import": "./dist/document-models/knowledge-graph/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./document-models/knowledge-note": {
|
|
39
|
+
"types": "./dist/document-models/knowledge-note/index.d.ts",
|
|
40
|
+
"import": "./dist/document-models/knowledge-note/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./document-models/moc": {
|
|
43
|
+
"types": "./dist/document-models/moc/index.d.ts",
|
|
44
|
+
"import": "./dist/document-models/moc/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./document-models/observation": {
|
|
47
|
+
"types": "./dist/document-models/observation/index.d.ts",
|
|
48
|
+
"import": "./dist/document-models/observation/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./document-models/pipeline-queue": {
|
|
51
|
+
"types": "./dist/document-models/pipeline-queue/index.d.ts",
|
|
52
|
+
"import": "./dist/document-models/pipeline-queue/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./document-models/research-claim": {
|
|
55
|
+
"types": "./dist/document-models/research-claim/index.d.ts",
|
|
56
|
+
"import": "./dist/document-models/research-claim/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./document-models/source": {
|
|
59
|
+
"types": "./dist/document-models/source/index.d.ts",
|
|
60
|
+
"import": "./dist/document-models/source/index.js"
|
|
61
|
+
},
|
|
62
|
+
"./document-models/tension": {
|
|
63
|
+
"types": "./dist/document-models/tension/index.d.ts",
|
|
64
|
+
"import": "./dist/document-models/tension/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./document-models/vault-config": {
|
|
67
|
+
"types": "./dist/document-models/vault-config/index.d.ts",
|
|
68
|
+
"import": "./dist/document-models/vault-config/index.js"
|
|
69
|
+
},
|
|
26
70
|
"./document-models/*": {
|
|
27
71
|
"types": "./dist/document-models/*/index.d.ts",
|
|
28
72
|
"import": "./dist/document-models/*/index.js"
|