@powerhousedao/network-admin 0.0.41 → 0.0.42
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/scripts/sow-mirror/mirror_sow_state.d.ts +3 -0
- package/dist/scripts/sow-mirror/mirror_sow_state.d.ts.map +1 -0
- package/dist/scripts/sow-mirror/mirror_sow_state.js +441 -0
- package/dist/subgraphs/index.d.ts +5 -0
- package/dist/subgraphs/index.d.ts.map +1 -1
- package/dist/subgraphs/index.js +5 -0
- package/dist/subgraphs/networks/index.d.ts +11 -0
- package/dist/subgraphs/networks/index.d.ts.map +1 -0
- package/dist/subgraphs/networks/index.js +11 -0
- package/dist/subgraphs/networks/resolvers.d.ts +3 -0
- package/dist/subgraphs/networks/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/networks/resolvers.js +42 -0
- package/dist/subgraphs/networks/schema.d.ts +3 -0
- package/dist/subgraphs/networks/schema.d.ts.map +1 -0
- package/dist/subgraphs/networks/schema.js +39 -0
- package/dist/subgraphs/payment-terms/index.d.ts +11 -0
- package/dist/subgraphs/payment-terms/index.d.ts.map +1 -0
- package/dist/subgraphs/payment-terms/index.js +11 -0
- package/dist/subgraphs/payment-terms/resolvers.d.ts +3 -0
- package/dist/subgraphs/payment-terms/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/payment-terms/resolvers.js +277 -0
- package/dist/subgraphs/payment-terms/schema.d.ts +3 -0
- package/dist/subgraphs/payment-terms/schema.d.ts.map +1 -0
- package/dist/subgraphs/payment-terms/schema.js +324 -0
- package/dist/subgraphs/request-for-proposals/index.d.ts +11 -0
- package/dist/subgraphs/request-for-proposals/index.d.ts.map +1 -0
- package/dist/subgraphs/request-for-proposals/index.js +11 -0
- package/dist/subgraphs/request-for-proposals/resolvers.d.ts +3 -0
- package/dist/subgraphs/request-for-proposals/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/request-for-proposals/resolvers.js +145 -0
- package/dist/subgraphs/request-for-proposals/schema.d.ts +3 -0
- package/dist/subgraphs/request-for-proposals/schema.d.ts.map +1 -0
- package/dist/subgraphs/request-for-proposals/schema.js +232 -0
- package/dist/subgraphs/workstream/index.d.ts +11 -0
- package/dist/subgraphs/workstream/index.d.ts.map +1 -0
- package/dist/subgraphs/workstream/index.js +11 -0
- package/dist/subgraphs/workstream/resolvers.d.ts +3 -0
- package/dist/subgraphs/workstream/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/workstream/resolvers.js +181 -0
- package/dist/subgraphs/workstream/schema.d.ts +3 -0
- package/dist/subgraphs/workstream/schema.d.ts.map +1 -0
- package/dist/subgraphs/workstream/schema.js +206 -0
- package/dist/subgraphs/workstreams/index.d.ts +11 -0
- package/dist/subgraphs/workstreams/index.d.ts.map +1 -0
- package/dist/subgraphs/workstreams/index.js +11 -0
- package/dist/subgraphs/workstreams/resolvers.d.ts +3 -0
- package/dist/subgraphs/workstreams/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/workstreams/resolvers.js +380 -0
- package/dist/subgraphs/workstreams/schema.d.ts +3 -0
- package/dist/subgraphs/workstreams/schema.d.ts.map +1 -0
- package/dist/subgraphs/workstreams/schema.js +326 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mirror_sow_state.d.ts","sourceRoot":"","sources":["../../../scripts/sow-mirror/mirror_sow_state.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// Parse command line arguments
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
if (args.length !== 6) {
|
|
5
|
+
console.error('Usage: bun mirror_sow_state.ts <remote-mcp-url> <remote-sow-id> <remote-drive-id> <local-mcp-url> <local-sow-id> <local-drive-id>');
|
|
6
|
+
console.error('');
|
|
7
|
+
console.error('Example:');
|
|
8
|
+
console.error(' bun mirror_sow_state.ts \\');
|
|
9
|
+
console.error(' https://switchboard-dev.powerhouse.xyz/mcp \\');
|
|
10
|
+
console.error(' 65f3e7e8-500d-4c42-9e73-8cd5d7966cd8 \\');
|
|
11
|
+
console.error(' powerhouse-network-admin \\');
|
|
12
|
+
console.error(' http://localhost:4001/mcp \\');
|
|
13
|
+
console.error(' 3471233d-c481-4214-afe3-c196b5a7778f \\');
|
|
14
|
+
console.error(' bai-network-admin');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const [REMOTE_MCP_URL, REMOTE_DOC_ID, REMOTE_DRIVE_ID, LOCAL_MCP_URL, LOCAL_DOC_ID, LOCAL_DRIVE_ID] = args;
|
|
18
|
+
// Helper function to make MCP requests
|
|
19
|
+
async function mcpRequest(url, payload) {
|
|
20
|
+
const response = await fetch(url, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
'Accept': 'application/json, text/event-stream'
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify(payload)
|
|
27
|
+
});
|
|
28
|
+
const text = await response.text();
|
|
29
|
+
// Handle SSE format (event: message\ndata: {...})
|
|
30
|
+
if (text.includes('event: message')) {
|
|
31
|
+
const lines = text.split('\n');
|
|
32
|
+
const dataLine = lines.find(line => line.startsWith('data: '));
|
|
33
|
+
if (dataLine) {
|
|
34
|
+
const jsonData = dataLine.substring(6);
|
|
35
|
+
return JSON.parse(jsonData);
|
|
36
|
+
}
|
|
37
|
+
throw new Error('No data line found in SSE response');
|
|
38
|
+
}
|
|
39
|
+
return JSON.parse(text);
|
|
40
|
+
}
|
|
41
|
+
// Fetch remote document
|
|
42
|
+
async function getRemoteDocument() {
|
|
43
|
+
console.log(`Fetching remote document (${REMOTE_DOC_ID}) from drive "${REMOTE_DRIVE_ID}"...`);
|
|
44
|
+
const payload = {
|
|
45
|
+
jsonrpc: '2.0',
|
|
46
|
+
method: 'tools/call',
|
|
47
|
+
params: {
|
|
48
|
+
name: 'getDocument',
|
|
49
|
+
arguments: { id: REMOTE_DOC_ID }
|
|
50
|
+
},
|
|
51
|
+
id: 1
|
|
52
|
+
};
|
|
53
|
+
const response = await mcpRequest(REMOTE_MCP_URL, payload);
|
|
54
|
+
if (response.error) {
|
|
55
|
+
throw new Error(`Remote fetch error: ${JSON.stringify(response.error)}`);
|
|
56
|
+
}
|
|
57
|
+
return response.result.structuredContent.document;
|
|
58
|
+
}
|
|
59
|
+
// Get current local document state
|
|
60
|
+
async function getLocalDocument() {
|
|
61
|
+
console.log(`Fetching local document (${LOCAL_DOC_ID}) from drive "${LOCAL_DRIVE_ID}"...`);
|
|
62
|
+
const payload = {
|
|
63
|
+
jsonrpc: '2.0',
|
|
64
|
+
method: 'tools/call',
|
|
65
|
+
params: {
|
|
66
|
+
name: 'getDocument',
|
|
67
|
+
arguments: { id: LOCAL_DOC_ID }
|
|
68
|
+
},
|
|
69
|
+
id: 2
|
|
70
|
+
};
|
|
71
|
+
const response = await mcpRequest(LOCAL_MCP_URL, payload);
|
|
72
|
+
if (response.error) {
|
|
73
|
+
throw new Error(`Local fetch error: ${JSON.stringify(response.error)}`);
|
|
74
|
+
}
|
|
75
|
+
return response.result.structuredContent.document;
|
|
76
|
+
}
|
|
77
|
+
// Generate actions to mirror remote state
|
|
78
|
+
function generateActions(remoteState, localState) {
|
|
79
|
+
const actions = [];
|
|
80
|
+
// 1. Update basic scope of work details
|
|
81
|
+
if (remoteState.title !== localState.title ||
|
|
82
|
+
remoteState.description !== localState.description ||
|
|
83
|
+
remoteState.status !== localState.status) {
|
|
84
|
+
actions.push({
|
|
85
|
+
type: 'EDIT_SCOPE_OF_WORK',
|
|
86
|
+
scope: 'global',
|
|
87
|
+
input: {
|
|
88
|
+
title: remoteState.title,
|
|
89
|
+
description: remoteState.description,
|
|
90
|
+
status: remoteState.status
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// 2. Add missing contributors
|
|
95
|
+
const localContributorIds = new Set(localState.contributors.map((c) => c.id));
|
|
96
|
+
remoteState.contributors.forEach((contributor) => {
|
|
97
|
+
if (!localContributorIds.has(contributor.id)) {
|
|
98
|
+
const input = {
|
|
99
|
+
id: contributor.id,
|
|
100
|
+
name: contributor.name
|
|
101
|
+
};
|
|
102
|
+
if (contributor.icon)
|
|
103
|
+
input.icon = contributor.icon;
|
|
104
|
+
if (contributor.description)
|
|
105
|
+
input.description = contributor.description;
|
|
106
|
+
actions.push({
|
|
107
|
+
type: 'ADD_AGENT',
|
|
108
|
+
scope: 'global',
|
|
109
|
+
input
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
// 3. Add missing deliverables with all their data
|
|
114
|
+
const localDeliverableIds = new Set(localState.deliverables.map((d) => d.id));
|
|
115
|
+
remoteState.deliverables.forEach((deliverable) => {
|
|
116
|
+
if (!localDeliverableIds.has(deliverable.id)) {
|
|
117
|
+
// Add deliverable
|
|
118
|
+
actions.push({
|
|
119
|
+
type: 'ADD_DELIVERABLE',
|
|
120
|
+
scope: 'global',
|
|
121
|
+
input: {
|
|
122
|
+
id: deliverable.id,
|
|
123
|
+
owner: deliverable.owner || undefined,
|
|
124
|
+
title: deliverable.title,
|
|
125
|
+
code: deliverable.code,
|
|
126
|
+
description: deliverable.description,
|
|
127
|
+
status: deliverable.status
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// Set work progress
|
|
131
|
+
if (deliverable.workProgress) {
|
|
132
|
+
const progressInput = {};
|
|
133
|
+
if (deliverable.workProgress.value !== undefined) {
|
|
134
|
+
progressInput.percentage = deliverable.workProgress.value;
|
|
135
|
+
}
|
|
136
|
+
else if (deliverable.workProgress.total !== undefined) {
|
|
137
|
+
progressInput.storyPoints = {
|
|
138
|
+
total: deliverable.workProgress.total,
|
|
139
|
+
completed: deliverable.workProgress.completed
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
else if (deliverable.workProgress.done !== undefined) {
|
|
143
|
+
progressInput.done = deliverable.workProgress.done;
|
|
144
|
+
}
|
|
145
|
+
if (Object.keys(progressInput).length > 0) {
|
|
146
|
+
actions.push({
|
|
147
|
+
type: 'SET_DELIVERABLE_PROGRESS',
|
|
148
|
+
scope: 'global',
|
|
149
|
+
input: {
|
|
150
|
+
id: deliverable.id,
|
|
151
|
+
workProgress: progressInput
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Add key results
|
|
157
|
+
if (deliverable.keyResults && deliverable.keyResults.length > 0) {
|
|
158
|
+
deliverable.keyResults.forEach((kr) => {
|
|
159
|
+
actions.push({
|
|
160
|
+
type: 'ADD_KEY_RESULT',
|
|
161
|
+
scope: 'global',
|
|
162
|
+
input: {
|
|
163
|
+
id: kr.id,
|
|
164
|
+
deliverableId: deliverable.id,
|
|
165
|
+
title: kr.title,
|
|
166
|
+
link: kr.link
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// Set budget anchor if exists
|
|
172
|
+
if (deliverable.budgetAnchor && deliverable.budgetAnchor.project) {
|
|
173
|
+
actions.push({
|
|
174
|
+
type: 'SET_DELIVERABLE_BUDGET_ANCHOR_PROJECT',
|
|
175
|
+
scope: 'global',
|
|
176
|
+
input: {
|
|
177
|
+
deliverableId: deliverable.id,
|
|
178
|
+
project: deliverable.budgetAnchor.project,
|
|
179
|
+
unit: deliverable.budgetAnchor.unit,
|
|
180
|
+
unitCost: deliverable.budgetAnchor.unitCost,
|
|
181
|
+
quantity: deliverable.budgetAnchor.quantity,
|
|
182
|
+
margin: deliverable.budgetAnchor.margin
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
// 4. Add projects if any
|
|
189
|
+
if (remoteState.projects && remoteState.projects.length > 0) {
|
|
190
|
+
const localProjectsMap = new Map(localState.projects.map((p) => [p.id, p]));
|
|
191
|
+
remoteState.projects.forEach((project) => {
|
|
192
|
+
const localProject = localProjectsMap.get(project.id);
|
|
193
|
+
if (!localProject) {
|
|
194
|
+
// Project doesn't exist, add it
|
|
195
|
+
actions.push({
|
|
196
|
+
type: 'ADD_PROJECT',
|
|
197
|
+
scope: 'global',
|
|
198
|
+
input: {
|
|
199
|
+
id: project.id,
|
|
200
|
+
code: project.code,
|
|
201
|
+
title: project.title,
|
|
202
|
+
projectOwner: project.projectOwner || undefined,
|
|
203
|
+
abstract: project.abstract || undefined,
|
|
204
|
+
imageUrl: project.imageUrl || undefined,
|
|
205
|
+
budgetType: project.budgetType || undefined,
|
|
206
|
+
currency: project.currency || undefined,
|
|
207
|
+
budget: project.budget || 0
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// Add missing deliverables to project scope
|
|
212
|
+
if (project.scope && project.scope.deliverables && project.scope.deliverables.length > 0) {
|
|
213
|
+
const localDeliverables = new Set(((localProject)?.scope?.deliverables) || []);
|
|
214
|
+
project.scope.deliverables.forEach((deliverableId) => {
|
|
215
|
+
if (!localDeliverables.has(deliverableId)) {
|
|
216
|
+
const deliverable = remoteState.deliverables.find((d) => d.id === deliverableId);
|
|
217
|
+
if (deliverable) {
|
|
218
|
+
actions.push({
|
|
219
|
+
type: 'ADD_DELIVERABLE_IN_SET',
|
|
220
|
+
scope: 'global',
|
|
221
|
+
input: {
|
|
222
|
+
projectId: project.id,
|
|
223
|
+
deliverableId: deliverableId
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
// Set project scope metadata (status and deliverablesCompleted)
|
|
230
|
+
if (project.scope.status || project.scope.deliverablesCompleted) {
|
|
231
|
+
actions.push({
|
|
232
|
+
type: 'EDIT_DELIVERABLES_SET',
|
|
233
|
+
scope: 'global',
|
|
234
|
+
input: {
|
|
235
|
+
projectId: project.id,
|
|
236
|
+
status: project.scope.status || undefined,
|
|
237
|
+
deliverablesCompleted: project.scope.deliverablesCompleted || undefined
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
// 5. Add roadmaps if any
|
|
245
|
+
if (remoteState.roadmaps && remoteState.roadmaps.length > 0) {
|
|
246
|
+
const localRoadmapIds = new Set(localState.roadmaps.map((r) => r.id));
|
|
247
|
+
const localRoadmapsMap = new Map(localState.roadmaps.map((r) => [r.id, r]));
|
|
248
|
+
remoteState.roadmaps.forEach((roadmap) => {
|
|
249
|
+
const localRoadmap = localRoadmapsMap.get(roadmap.id);
|
|
250
|
+
if (!localRoadmap) {
|
|
251
|
+
actions.push({
|
|
252
|
+
type: 'ADD_ROADMAP',
|
|
253
|
+
scope: 'global',
|
|
254
|
+
input: {
|
|
255
|
+
id: roadmap.id,
|
|
256
|
+
title: roadmap.title,
|
|
257
|
+
slug: roadmap.slug || undefined,
|
|
258
|
+
description: roadmap.description || undefined
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// Add milestones for this roadmap
|
|
263
|
+
if (roadmap.milestones && roadmap.milestones.length > 0) {
|
|
264
|
+
const localMilestonesMap = new Map(((localRoadmap)?.milestones || []).map((m) => [m.id, m]));
|
|
265
|
+
roadmap.milestones.forEach((milestone) => {
|
|
266
|
+
const localMilestone = localMilestonesMap.get(milestone.id);
|
|
267
|
+
if (!localMilestone) {
|
|
268
|
+
actions.push({
|
|
269
|
+
type: 'ADD_MILESTONE',
|
|
270
|
+
scope: 'global',
|
|
271
|
+
input: {
|
|
272
|
+
id: milestone.id,
|
|
273
|
+
roadmapId: roadmap.id,
|
|
274
|
+
sequenceCode: milestone.sequenceCode || undefined,
|
|
275
|
+
title: milestone.title,
|
|
276
|
+
description: milestone.description || undefined,
|
|
277
|
+
deliveryTarget: milestone.deliveryTarget || undefined
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
// Add coordinators for milestone
|
|
282
|
+
if (milestone.coordinators && milestone.coordinators.length > 0) {
|
|
283
|
+
const localCoordinators = new Set((localMilestone)?.coordinators || []);
|
|
284
|
+
milestone.coordinators.forEach((coordinatorId) => {
|
|
285
|
+
if (!localCoordinators.has(coordinatorId)) {
|
|
286
|
+
actions.push({
|
|
287
|
+
type: 'ADD_COORDINATOR',
|
|
288
|
+
scope: 'global',
|
|
289
|
+
input: {
|
|
290
|
+
id: coordinatorId,
|
|
291
|
+
milestoneId: milestone.id
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// Add deliverables to milestone
|
|
298
|
+
if (milestone.scope && milestone.scope.deliverables && milestone.scope.deliverables.length > 0) {
|
|
299
|
+
const localMilestoneDeliverables = new Set(((localMilestone)?.scope?.deliverables) || []);
|
|
300
|
+
milestone.scope.deliverables.forEach((deliverableId) => {
|
|
301
|
+
if (!localMilestoneDeliverables.has(deliverableId)) {
|
|
302
|
+
actions.push({
|
|
303
|
+
type: 'ADD_DELIVERABLE_IN_SET',
|
|
304
|
+
scope: 'global',
|
|
305
|
+
input: {
|
|
306
|
+
milestoneId: milestone.id,
|
|
307
|
+
deliverableId: deliverableId
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
// Set milestone scope metadata
|
|
313
|
+
if (milestone.scope.status || milestone.scope.deliverablesCompleted) {
|
|
314
|
+
actions.push({
|
|
315
|
+
type: 'EDIT_DELIVERABLES_SET',
|
|
316
|
+
scope: 'global',
|
|
317
|
+
input: {
|
|
318
|
+
milestoneId: milestone.id,
|
|
319
|
+
status: milestone.scope.status || undefined,
|
|
320
|
+
deliverablesCompleted: milestone.scope.deliverablesCompleted || undefined
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return actions;
|
|
330
|
+
}
|
|
331
|
+
// Send actions in batches
|
|
332
|
+
async function sendActions(actions) {
|
|
333
|
+
const BATCH_SIZE = 50;
|
|
334
|
+
const batches = [];
|
|
335
|
+
for (let i = 0; i < actions.length; i += BATCH_SIZE) {
|
|
336
|
+
batches.push(actions.slice(i, i + BATCH_SIZE));
|
|
337
|
+
}
|
|
338
|
+
console.log(`\nSending ${actions.length} actions in ${batches.length} batches...`);
|
|
339
|
+
for (let i = 0; i < batches.length; i++) {
|
|
340
|
+
const batch = batches[i];
|
|
341
|
+
console.log(`\nBatch ${i + 1}/${batches.length} (${batch.length} actions)...`);
|
|
342
|
+
const payload = {
|
|
343
|
+
jsonrpc: '2.0',
|
|
344
|
+
method: 'tools/call',
|
|
345
|
+
params: {
|
|
346
|
+
name: 'addActions',
|
|
347
|
+
arguments: {
|
|
348
|
+
documentId: LOCAL_DOC_ID,
|
|
349
|
+
actions: batch
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
id: 1000 + i
|
|
353
|
+
};
|
|
354
|
+
try {
|
|
355
|
+
const response = await mcpRequest(LOCAL_MCP_URL, payload);
|
|
356
|
+
if (response.error) {
|
|
357
|
+
console.error(`Error in batch ${i + 1}:`, JSON.stringify(response.error, null, 2));
|
|
358
|
+
throw new Error(`Batch ${i + 1} failed`);
|
|
359
|
+
}
|
|
360
|
+
console.log(`✓ Batch ${i + 1} completed successfully`);
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
console.error(`Failed to send batch ${i + 1}:`, error);
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
// Main function
|
|
369
|
+
async function main() {
|
|
370
|
+
try {
|
|
371
|
+
console.log('='.repeat(70));
|
|
372
|
+
console.log('Scope of Work State-Based Mirror Script');
|
|
373
|
+
console.log('='.repeat(70));
|
|
374
|
+
console.log('\nConfiguration:');
|
|
375
|
+
console.log(` Remote MCP: ${REMOTE_MCP_URL}`);
|
|
376
|
+
console.log(` Remote Drive: ${REMOTE_DRIVE_ID}`);
|
|
377
|
+
console.log(` Remote SoW ID: ${REMOTE_DOC_ID}`);
|
|
378
|
+
console.log(` Local MCP: ${LOCAL_MCP_URL}`);
|
|
379
|
+
console.log(` Local Drive: ${LOCAL_DRIVE_ID}`);
|
|
380
|
+
console.log(` Local SoW ID: ${LOCAL_DOC_ID}`);
|
|
381
|
+
console.log('');
|
|
382
|
+
// Fetch remote document
|
|
383
|
+
const remoteDoc = await getRemoteDocument();
|
|
384
|
+
const remoteState = remoteDoc.state.global;
|
|
385
|
+
console.log(`✓ Remote document fetched: "${remoteState.title}"`);
|
|
386
|
+
console.log(` - Status: ${remoteState.status}`);
|
|
387
|
+
console.log(` - Contributors: ${remoteState.contributors.length}`);
|
|
388
|
+
console.log(` - Deliverables: ${remoteState.deliverables.length}`);
|
|
389
|
+
console.log(` - Projects: ${remoteState.projects.length}`);
|
|
390
|
+
console.log(` - Roadmaps: ${remoteState.roadmaps.length}`);
|
|
391
|
+
// Fetch local document
|
|
392
|
+
const localDoc = await getLocalDocument();
|
|
393
|
+
const localState = localDoc.state.global;
|
|
394
|
+
console.log(`\n✓ Local document fetched: "${localState.title}"`);
|
|
395
|
+
console.log(` - Status: ${localState.status}`);
|
|
396
|
+
console.log(` - Contributors: ${localState.contributors.length}`);
|
|
397
|
+
console.log(` - Deliverables: ${localState.deliverables.length}`);
|
|
398
|
+
console.log(` - Projects: ${localState.projects.length}`);
|
|
399
|
+
console.log(` - Roadmaps: ${localState.roadmaps.length}`);
|
|
400
|
+
// Generate actions
|
|
401
|
+
console.log('\nGenerating actions to mirror remote state...');
|
|
402
|
+
const actions = generateActions(remoteState, localState);
|
|
403
|
+
console.log(`✓ Generated ${actions.length} actions`);
|
|
404
|
+
if (actions.length === 0) {
|
|
405
|
+
console.log('\n✓ Documents are already in sync!');
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
// Show action summary
|
|
409
|
+
const actionTypes = {};
|
|
410
|
+
actions.forEach(action => {
|
|
411
|
+
actionTypes[action.type] = (actionTypes[action.type] || 0) + 1;
|
|
412
|
+
});
|
|
413
|
+
console.log('\nAction summary:');
|
|
414
|
+
Object.entries(actionTypes).forEach(([type, count]) => {
|
|
415
|
+
console.log(` - ${type}: ${count}`);
|
|
416
|
+
});
|
|
417
|
+
// Send actions
|
|
418
|
+
await sendActions(actions);
|
|
419
|
+
// Verify final state
|
|
420
|
+
console.log('\nVerifying final state...');
|
|
421
|
+
const finalLocalDoc = await getLocalDocument();
|
|
422
|
+
const finalLocalState = finalLocalDoc.state.global;
|
|
423
|
+
console.log(`✓ Final local document state:`);
|
|
424
|
+
console.log(` - Title: "${finalLocalState.title}"`);
|
|
425
|
+
console.log(` - Status: ${finalLocalState.status}`);
|
|
426
|
+
console.log(` - Contributors: ${finalLocalState.contributors.length}`);
|
|
427
|
+
console.log(` - Deliverables: ${finalLocalState.deliverables.length}`);
|
|
428
|
+
console.log(` - Projects: ${finalLocalState.projects.length}`);
|
|
429
|
+
console.log(` - Roadmaps: ${finalLocalState.roadmaps.length}`);
|
|
430
|
+
console.log('\n' + '='.repeat(70));
|
|
431
|
+
console.log('✓ Mirror complete!');
|
|
432
|
+
console.log('='.repeat(70));
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
console.error('\n✗ Error:', error);
|
|
436
|
+
process.exit(1);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// Run the script
|
|
440
|
+
main();
|
|
441
|
+
export {};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
export * as NetworkProfileSubgraph from "./network-profile/index.js";
|
|
3
|
+
export * as PaymentTermsSubgraph from "./payment-terms/index.js";
|
|
4
|
+
export * as RequestForProposalsSubgraph from "./request-for-proposals/index.js";
|
|
5
|
+
export * as WorkstreamSubgraph from "./workstream/index.js";
|
|
6
|
+
export * as WorkstreamsSubgraph from "./workstreams/index.js";
|
|
7
|
+
export * as NetworksSubgraph from "./networks/index.js";
|
|
3
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../subgraphs/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../subgraphs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AACV,OAAO,KAAK,sBAAsB,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,oBAAoB,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,2BAA2B,MAAM,kCAAkC,CAAC;AAChF,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,mBAAmB,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAC"}
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
export * as NetworkProfileSubgraph from "./network-profile/index.js";
|
|
3
|
+
export * as PaymentTermsSubgraph from "./payment-terms/index.js";
|
|
4
|
+
export * as RequestForProposalsSubgraph from "./request-for-proposals/index.js";
|
|
5
|
+
export * as WorkstreamSubgraph from "./workstream/index.js";
|
|
6
|
+
export * as WorkstreamsSubgraph from "./workstreams/index.js";
|
|
7
|
+
export * as NetworksSubgraph from "./networks/index.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import type { DocumentNode } from "graphql";
|
|
3
|
+
export declare class NetworksSubgraph extends BaseSubgraph {
|
|
4
|
+
name: string;
|
|
5
|
+
typeDefs: DocumentNode;
|
|
6
|
+
resolvers: Record<string, unknown>;
|
|
7
|
+
additionalContextFields: {};
|
|
8
|
+
onSetup(): Promise<void>;
|
|
9
|
+
onDisconnect(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/networks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,IAAI,SAAc;IAClB,QAAQ,EAAE,YAAY,CAAU;IAChC,SAAS,0BAAsB;IAC/B,uBAAuB,KAAM;IACvB,OAAO;IACP,YAAY;CACnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import { schema } from "./schema.js";
|
|
3
|
+
import { getResolvers } from "./resolvers.js";
|
|
4
|
+
export class NetworksSubgraph extends BaseSubgraph {
|
|
5
|
+
name = "networks";
|
|
6
|
+
typeDefs = schema;
|
|
7
|
+
resolvers = getResolvers(this);
|
|
8
|
+
additionalContextFields = {};
|
|
9
|
+
async onSetup() { }
|
|
10
|
+
async onDisconnect() { }
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/networks/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAoDxE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {} from "@powerhousedao/reactor-api";
|
|
2
|
+
export const getResolvers = (subgraph) => {
|
|
3
|
+
const reactor = subgraph.reactor;
|
|
4
|
+
return {
|
|
5
|
+
Query: {
|
|
6
|
+
allNetworks: async () => {
|
|
7
|
+
const drives = await reactor.getDrives();
|
|
8
|
+
const docs = [];
|
|
9
|
+
for (const driveId of drives) {
|
|
10
|
+
const docsIds = await reactor.getDocuments(driveId);
|
|
11
|
+
const driveDocs = await Promise.allSettled(docsIds.map(async (docId) => reactor.getDocument(docId)));
|
|
12
|
+
driveDocs.forEach((result) => {
|
|
13
|
+
if (result.status === "fulfilled" &&
|
|
14
|
+
result.value.header.documentType === "powerhouse/network-profile") {
|
|
15
|
+
docs.push(result.value);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return docs.map((doc) => {
|
|
20
|
+
const state = doc.state.global;
|
|
21
|
+
return {
|
|
22
|
+
id: doc.header.id,
|
|
23
|
+
documentType: doc.header.documentType,
|
|
24
|
+
network: {
|
|
25
|
+
name: state.name,
|
|
26
|
+
icon: state.icon,
|
|
27
|
+
logo: state.logo,
|
|
28
|
+
logoBig: state.logoBig,
|
|
29
|
+
website: state.website ?? null,
|
|
30
|
+
description: state.description,
|
|
31
|
+
category: state.category,
|
|
32
|
+
x: state.x ?? null,
|
|
33
|
+
github: state.github ?? null,
|
|
34
|
+
discord: state.discord ?? null,
|
|
35
|
+
youtube: state.youtube ?? null,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/networks/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAqCpB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
export const schema = gql `
|
|
3
|
+
"""
|
|
4
|
+
Subgraph definition
|
|
5
|
+
"""
|
|
6
|
+
type Query {
|
|
7
|
+
allNetworks: [AllNetworks!]!
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
type AllNetworks {
|
|
12
|
+
id: PHID
|
|
13
|
+
documentType: String
|
|
14
|
+
network: Network
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Network {
|
|
18
|
+
name: String!
|
|
19
|
+
icon: String!
|
|
20
|
+
logo: String!
|
|
21
|
+
logoBig: String!
|
|
22
|
+
website: String
|
|
23
|
+
description: String!
|
|
24
|
+
category: [NetworkCategory!]!
|
|
25
|
+
x: String
|
|
26
|
+
github: String
|
|
27
|
+
discord: String
|
|
28
|
+
youtube: String
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enum NetworkCategory {
|
|
32
|
+
DEFI
|
|
33
|
+
OSS
|
|
34
|
+
CRYPTO
|
|
35
|
+
NGO
|
|
36
|
+
CHARITY
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import type { DocumentNode } from "graphql";
|
|
3
|
+
export declare class PaymentTermsSubgraph extends BaseSubgraph {
|
|
4
|
+
name: string;
|
|
5
|
+
typeDefs: DocumentNode;
|
|
6
|
+
resolvers: Record<string, unknown>;
|
|
7
|
+
additionalContextFields: {};
|
|
8
|
+
onSetup(): Promise<void>;
|
|
9
|
+
onDisconnect(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/payment-terms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,IAAI,SAAmB;IACvB,QAAQ,EAAE,YAAY,CAAU;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAsB;IACxD,uBAAuB,KAAM;IACvB,OAAO;IACP,YAAY;CACnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import { schema } from "./schema.js";
|
|
3
|
+
import { getResolvers } from "./resolvers.js";
|
|
4
|
+
export class PaymentTermsSubgraph extends BaseSubgraph {
|
|
5
|
+
name = "payment-terms";
|
|
6
|
+
typeDefs = schema;
|
|
7
|
+
resolvers = getResolvers(this);
|
|
8
|
+
additionalContextFields = {};
|
|
9
|
+
async onSetup() { }
|
|
10
|
+
async onDisconnect() { }
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/payment-terms/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAwB5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAqexE,CAAC"}
|