Skip to content

Commit 284e95b

Browse files
fix missing export shapes
1 parent 6068013 commit 284e95b

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

backend/src/services/marva-profile.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,40 @@ export function exportMarvaProfiles(workspaceId: string): MarvaProfileDocument[]
317317
}
318318
}
319319

320+
// Expand linkedShapeIds to include shapes referenced transitively via valueShape.
321+
// In Marva profiles, every shape referenced by valueTemplateRefs must exist as a
322+
// resourceTemplate, even if it's not directly linked from the profile's hasPart rows.
323+
const profileShapeIds = new Set(profileShapes.map(ps => ps.shape.shapeId));
324+
325+
function collectTransitiveShapes(startIds: string[]): string[] {
326+
const allIds = new Set(startIds);
327+
const queue = [...startIds];
328+
329+
while (queue.length > 0) {
330+
const id = queue.shift()!;
331+
const shape = shapes.find(s => s.shapeId === id);
332+
if (!shape) continue;
333+
334+
const rows = rowService.list(workspaceId, id);
335+
for (const row of rows) {
336+
if (!row.valueShape) continue;
337+
const refs = row.valueShape.split(/[|\n]/).map(s => s.trim()).filter(Boolean);
338+
for (const ref of refs) {
339+
if (!allIds.has(ref) && !profileShapeIds.has(ref) && !isStartingPointShape(ref)) {
340+
allIds.add(ref);
341+
queue.push(ref);
342+
}
343+
}
344+
}
345+
}
346+
347+
return Array.from(allIds);
348+
}
349+
350+
for (const profileInfo of profileShapes) {
351+
profileInfo.linkedShapeIds = collectTransitiveShapes(profileInfo.linkedShapeIds);
352+
}
353+
320354
// Build profile documents
321355
const documents: MarvaProfileDocument[] = [];
322356

0 commit comments

Comments
 (0)