@powerhousedao/network-admin 0.0.55 → 0.0.56
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/builders-addon/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/builders-addon/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAe5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAsaxE,CAAC"}
|
|
@@ -65,35 +65,112 @@ export const getResolvers = (subgraph) => {
|
|
|
65
65
|
return {
|
|
66
66
|
Query: {
|
|
67
67
|
builders: async (parent, args) => {
|
|
68
|
-
const filter = args.filter;
|
|
69
68
|
const drives = await getCandidateDrives();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
const filter = args.filter;
|
|
70
|
+
let builderDocs = [];
|
|
71
|
+
let sowDocs = [];
|
|
72
|
+
let allowedDriveIds = new Set(drives);
|
|
73
|
+
// Step 1: If networkSlug is provided, identify the network drive and valid builder PHIDs
|
|
74
|
+
if (filter?.networkSlug) {
|
|
75
|
+
allowedDriveIds.clear();
|
|
76
|
+
const targetNetworkSlug = filter.networkSlug.toLowerCase().trim();
|
|
77
|
+
let targetDriveId = null;
|
|
78
|
+
let builderPhids = [];
|
|
79
|
+
// Find the network drive matching the slug
|
|
80
|
+
for (const driveId of drives) {
|
|
81
|
+
try {
|
|
82
|
+
const docIds = await reactor.getDocuments(driveId);
|
|
83
|
+
const docs = await Promise.all(docIds.map(async (docId) => {
|
|
84
|
+
try {
|
|
85
|
+
return await reactor.getDocument(docId);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
const networkDoc = docs.find((doc) => {
|
|
92
|
+
if (!doc || doc.header.documentType !== "powerhouse/network-profile")
|
|
93
|
+
return false;
|
|
94
|
+
const state = doc.state.global;
|
|
95
|
+
if (!state?.name)
|
|
96
|
+
return false;
|
|
97
|
+
const slug = state.name.toLowerCase().trim().split(/\s+/).join("-");
|
|
98
|
+
return slug === targetNetworkSlug;
|
|
99
|
+
});
|
|
100
|
+
if (networkDoc) {
|
|
101
|
+
targetDriveId = driveId;
|
|
102
|
+
// Get the builders list from this drive
|
|
103
|
+
const buildersDoc = docs.find((doc) => doc && doc.header.documentType === "powerhouse/builders");
|
|
104
|
+
if (buildersDoc) {
|
|
105
|
+
const state = buildersDoc.state.global;
|
|
106
|
+
if (Array.isArray(state.builders)) {
|
|
107
|
+
builderPhids = state.builders.filter((id) => typeof id === "string");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.warn(`Failed to inspect drive ${driveId}:`, error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (targetDriveId) {
|
|
118
|
+
allowedDriveIds.add(targetDriveId);
|
|
119
|
+
// Fetch SOWs from the network drive
|
|
120
|
+
try {
|
|
121
|
+
const docIds = await reactor.getDocuments(targetDriveId);
|
|
122
|
+
for (const docId of docIds) {
|
|
123
|
+
try {
|
|
124
|
+
const doc = await reactor.getDocument(docId);
|
|
125
|
+
if (doc.header.documentType === "powerhouse/scopeofwork") {
|
|
126
|
+
sowDocs.push(doc);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch { }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
console.warn(`Failed to fetch SOWs from drive ${targetDriveId}`, e);
|
|
134
|
+
}
|
|
135
|
+
// Fetch specific builder profiles
|
|
136
|
+
builderDocs = (await Promise.all(builderPhids.map(async (phid) => {
|
|
77
137
|
try {
|
|
78
|
-
|
|
138
|
+
const doc = await reactor.getDocument(phid);
|
|
139
|
+
return doc.header.documentType === "powerhouse/builder-profile" ? doc : null;
|
|
79
140
|
}
|
|
80
141
|
catch {
|
|
81
142
|
return null;
|
|
82
143
|
}
|
|
83
|
-
}));
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
144
|
+
}))).filter((doc) => doc !== null);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Default behavior: Scan all drives
|
|
149
|
+
for (const driveId of drives) {
|
|
150
|
+
try {
|
|
151
|
+
const docIds = await reactor.getDocuments(driveId);
|
|
152
|
+
const docs = await Promise.all(docIds.map(async (docId) => {
|
|
153
|
+
try {
|
|
154
|
+
return await reactor.getDocument(docId);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
for (const doc of docs) {
|
|
161
|
+
if (!doc)
|
|
162
|
+
continue;
|
|
163
|
+
if (doc.header.documentType === "powerhouse/builder-profile") {
|
|
164
|
+
builderDocs.push(doc);
|
|
165
|
+
}
|
|
166
|
+
else if (doc.header.documentType === "powerhouse/scopeofwork") {
|
|
167
|
+
sowDocs.push(doc);
|
|
168
|
+
}
|
|
92
169
|
}
|
|
93
170
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.warn(`Failed to process drive ${driveId}:`, error);
|
|
173
|
+
}
|
|
97
174
|
}
|
|
98
175
|
}
|
|
99
176
|
// Step 2: Build a map of deliverable OID -> deliverable object for each SOW
|
|
@@ -255,7 +332,13 @@ export const getResolvers = (subgraph) => {
|
|
|
255
332
|
};
|
|
256
333
|
return builder;
|
|
257
334
|
})
|
|
258
|
-
.filter((builder) =>
|
|
335
|
+
.filter((builder) => {
|
|
336
|
+
// Apply standard filters
|
|
337
|
+
if (!applyFilters(builder, filter)) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
return true;
|
|
341
|
+
});
|
|
259
342
|
return builders;
|
|
260
343
|
},
|
|
261
344
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/builders-addon/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/builders-addon/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAgNpB,CAAC"}
|