Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 231a1b9

Browse files
committed
Add orphaned section to diagnostics
1 parent 042fbe1 commit 231a1b9

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

‎src/routes/(protected)/dynamic-entities/diagnostics/+page.server.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,23 @@ export const load: PageServerLoad = async ({ locals }) => {
111111
// Sort by entity name
112112
diagnostics.sort((a, b) => a.entityName.localeCompare(b.entityName));
113113

114+
// Fetch orphaned entities from the diagnostics endpoint
115+
let orphanedEntities: any[] = [];
116+
try {
117+
const diagEndpoint = "/obp/v6.0.0/management/diagnostics/dynamic-entities";
118+
logger.info(`Fetching orphaned entities from: ${diagEndpoint}`);
119+
const diagResponse = await obp_requests.get(diagEndpoint, accessToken);
120+
orphanedEntities = diagResponse.orphaned_entities || [];
121+
logger.info(`Found ${orphanedEntities.length} orphaned entities`);
122+
} catch (err: any) {
123+
logger.warn("Could not fetch orphaned entities:", err?.message);
124+
}
125+
114126
return {
115127
diagnostics,
116128
totalEntities: diagnostics.length,
117129
totalRecords: diagnostics.reduce((sum, d) => sum + d.recordCount, 0),
130+
orphanedEntities,
118131
};
119132
} catch (err: any) {
120133
logger.error("Error in diagnostics:", err);

‎src/routes/(protected)/dynamic-entities/diagnostics/+page.svelte‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const diagnostics = data.diagnostics || [];
66
const totalEntities = data.totalEntities || 0;
77
const totalRecords = data.totalRecords || 0;
8+
const orphanedEntities = data.orphanedEntities || [];
89
910
let searchQuery = $state("");
1011
let copiedId = $state<string | null>(null);
@@ -159,6 +160,62 @@ ${diag.triedKeys ? `Tried Keys: ${diag.triedKeys.join(", ")}` : ""}
159160
</div>
160161
</div>
161162

163+
<!-- Orphaned Entities -->
164+
{#if orphanedEntities.length > 0}
165+
<div class="mb-6 rounded-lg border-2 border-yellow-400 bg-yellow-50 shadow-sm dark:border-yellow-600 dark:bg-yellow-900/20">
166+
<div class="border-b border-yellow-300 p-4 dark:border-yellow-700">
167+
<div class="flex items-center gap-2">
168+
<svg class="h-5 w-5 text-yellow-600 dark:text-yellow-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
169+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
170+
</svg>
171+
<h2 class="text-lg font-semibold text-yellow-800 dark:text-yellow-200">
172+
Orphaned Entities ({orphanedEntities.length})
173+
</h2>
174+
</div>
175+
<p class="mt-1 text-sm text-yellow-700 dark:text-yellow-300">
176+
Data records whose Dynamic Entity definition has been deleted. These records still exist in the database but have no schema and cannot be accessed via the API.
177+
</p>
178+
</div>
179+
<div class="p-4">
180+
<div class="overflow-x-auto">
181+
<table class="min-w-full divide-y divide-yellow-300 dark:divide-yellow-700">
182+
<thead>
183+
<tr>
184+
<th class="px-4 py-2 text-left text-xs font-medium uppercase tracking-wider text-yellow-700 dark:text-yellow-300">Entity Name</th>
185+
<th class="px-4 py-2 text-left text-xs font-medium uppercase tracking-wider text-yellow-700 dark:text-yellow-300">Bank ID</th>
186+
<th class="px-4 py-2 text-right text-xs font-medium uppercase tracking-wider text-yellow-700 dark:text-yellow-300">Record Count</th>
187+
</tr>
188+
</thead>
189+
<tbody class="divide-y divide-yellow-200 dark:divide-yellow-800">
190+
{#each orphanedEntities as orphan}
191+
<tr class="hover:bg-yellow-100 dark:hover:bg-yellow-900/30">
192+
<td class="whitespace-nowrap px-4 py-3 text-sm font-mono font-semibold text-yellow-900 dark:text-yellow-100">
193+
{orphan.entity_name}
194+
</td>
195+
<td class="whitespace-nowrap px-4 py-3 text-sm font-mono text-yellow-800 dark:text-yellow-200">
196+
{orphan.bank_id || ""}
197+
</td>
198+
<td class="whitespace-nowrap px-4 py-3 text-right text-sm font-mono font-semibold text-yellow-900 dark:text-yellow-100">
199+
{orphan.record_count}
200+
</td>
201+
</tr>
202+
{/each}
203+
</tbody>
204+
</table>
205+
</div>
206+
</div>
207+
</div>
208+
{:else}
209+
<div class="mb-6 rounded-lg border border-green-200 bg-green-50 p-4 dark:border-green-800 dark:bg-green-900/20">
210+
<div class="flex items-center gap-2">
211+
<svg class="h-5 w-5 text-green-600 dark:text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
212+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
213+
</svg>
214+
<p class="text-sm font-medium text-green-800 dark:text-green-200">No orphaned entities detected.</p>
215+
</div>
216+
</div>
217+
{/if}
218+
162219
<!-- Search -->
163220
<div class="mb-6">
164221
<input
@@ -411,7 +468,7 @@ ${diag.triedKeys ? `Tried Keys: ${diag.triedKeys.join(", ")}` : ""}
411468
class="whitespace-pre-wrap break-words rounded-lg bg-gray-50 p-4 text-xs dark:bg-gray-900"><code
412469
class="text-gray-900 dark:text-gray-100"
413470
>{JSON.stringify(
414-
{ diagnostics, totalEntities, totalRecords },
471+
{ diagnostics, totalEntities, totalRecords, orphanedEntities },
415472
null,
416473
2,
417474
)}</code

0 commit comments

Comments
 (0)