Skip to content

Commit d20bd97

Browse files
committed
fix: satisfy coderabbit
1 parent aa1f25f commit d20bd97

6 files changed

Lines changed: 87 additions & 28 deletions

File tree

infrastructure/control-panel/config/admin-enames.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"@7218b67d-da21-54d6-9a85-7c4db1d09768",
44
"@82f7a77a-f03a-52aa-88fc-1b1e488ad498",
55
"@35a31f0d-dd76-5780-b383-29f219fcae99",
6-
"@82f7a77a-f03a-52aa-88fc-1b1e488ad498",
76
"@6e1bbcd4-1f59-5bd8-aa3c-6f5301c356d7"
87
]
98
}

infrastructure/control-panel/src/lib/server/evault.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import { PUBLIC_CONTROL_PANEL_URL, PUBLIC_REGISTRY_URL } from '$env/static/publi
33
import type { BindingDocument, SocialConnection } from '@metastate-foundation/types';
44

55
const BINDING_DOCUMENTS_QUERY = gql`
6-
query GetBindingDocuments($first: Int!) {
7-
bindingDocuments(first: $first) {
6+
query GetBindingDocuments($first: Int!, $after: String) {
7+
bindingDocuments(first: $first, after: $after) {
88
edges {
99
node {
1010
id
1111
parsed
1212
}
1313
}
14+
pageInfo {
15+
hasNextPage
16+
endCursor
17+
}
1418
}
1519
}
1620
`;
@@ -46,6 +50,10 @@ interface BindingDocumentsResponse {
4650
parsed: Record<string, unknown> | null;
4751
};
4852
}>;
53+
pageInfo: {
54+
hasNextPage: boolean;
55+
endCursor: string | null;
56+
};
4957
};
5058
}
5159

@@ -169,12 +177,21 @@ class EvaultService {
169177
}
170178
});
171179

172-
const response = await client.request<BindingDocumentsResponse>(
173-
BINDING_DOCUMENTS_QUERY,
174-
{ first: 100 }
175-
);
176-
177-
const documents: BindingDocument[] = response.bindingDocuments.edges
180+
const allEdges: Array<{ node: { id: string; parsed: Record<string, unknown> | null } }> = [];
181+
let afterCursor: string | null = null;
182+
183+
do {
184+
const res: BindingDocumentsResponse = await client.request<BindingDocumentsResponse>(
185+
BINDING_DOCUMENTS_QUERY,
186+
{ first: 100, after: afterCursor ?? undefined }
187+
);
188+
allEdges.push(...res.bindingDocuments.edges);
189+
afterCursor = res.bindingDocuments.pageInfo.hasNextPage
190+
? res.bindingDocuments.pageInfo.endCursor
191+
: null;
192+
} while (afterCursor !== null);
193+
194+
const documents: BindingDocument[] = allEdges
178195
.map((edge) => {
179196
const parsed = edge.node.parsed;
180197
if (!parsed || typeof parsed !== 'object') return null;
@@ -211,7 +228,12 @@ class EvaultService {
211228

212229
if (!otherPartyEName) return null;
213230

214-
const name = await this.resolveDisplayNameForEName(otherPartyEName);
231+
let name: string;
232+
try {
233+
name = await this.resolveDisplayNameForEName(otherPartyEName);
234+
} catch {
235+
name = otherPartyEName;
236+
}
215237

216238
return {
217239
id: doc.id,

infrastructure/control-panel/src/routes/api/evaults/[evaultId]/binding-documents/+server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ export const GET: RequestHandler = async ({ params }) => {
88

99
try {
1010
const evaults = await registryService.getEVaults();
11+
if (evaults.length === 0) {
12+
return json(
13+
{ error: 'Registry unavailable: failed to fetch eVaults' },
14+
{ status: 502 }
15+
);
16+
}
1117
const vault = evaults.find((v) => v.evault === evaultId || v.ename === evaultId);
12-
1318
if (!vault) {
1419
return json({ error: `eVault '${evaultId}' not found in registry.` }, { status: 404 });
1520
}

infrastructure/control-panel/src/routes/evaults/[evaultId]/+page.svelte

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,20 @@
255255
{:else}
256256
<div class="mt-4 space-y-4">
257257
{#each photoDocuments as doc}
258+
{@const photoSrc = typeof doc.data?.photoBlob === 'string' && doc.data.photoBlob ? doc.data.photoBlob : null}
258259
<div class="rounded-md border border-slate-200 p-3">
259260
<p class="text-xs text-slate-500">ID: {doc.id}</p>
260-
<img
261-
class="mt-2 max-h-[100px] w-full rounded object-contain"
262-
src={getDataValue(doc.data, 'photoBlob')}
263-
alt="Binding"
264-
/>
261+
{#if photoSrc}
262+
<img
263+
class="mt-2 max-h-[100px] w-full rounded object-contain"
264+
src={photoSrc}
265+
alt="Binding"
266+
/>
267+
{:else}
268+
<div class="mt-2 flex max-h-[100px] w-full items-center justify-center rounded bg-slate-100 text-sm text-slate-500">
269+
No image
270+
</div>
271+
{/if}
265272
</div>
266273
{/each}
267274
</div>

packages/types/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"types": "./dist/index.d.ts",
1313
"exports": {
1414
".": {
15-
"import": "./dist/index.js",
16-
"types": "./dist/index.d.ts"
15+
"types": "./dist/index.d.ts",
16+
"import": "./dist/index.js"
1717
},
1818
"./binding-document": {
19-
"import": "./dist/binding-document.js",
20-
"types": "./dist/binding-document.d.ts"
19+
"types": "./dist/binding-document.d.ts",
20+
"import": "./dist/binding-document.js"
2121
}
2222
},
2323
"files": [

platforms/enotary/src/lib/server/evault.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ import { PUBLIC_REGISTRY_URL } from "$env/static/public";
55
import type { BindingDocument, SocialConnection } from "@metastate-foundation/types";
66

77
const BINDING_DOCUMENTS_QUERY = gql`
8-
query GetBindingDocuments($first: Int!) {
9-
bindingDocuments(first: $first) {
8+
query GetBindingDocuments($first: Int!, $after: String) {
9+
bindingDocuments(first: $first, after: $after) {
1010
edges {
1111
node {
1212
id
1313
parsed
1414
}
1515
}
16+
pageInfo {
17+
hasNextPage
18+
endCursor
19+
}
1620
}
1721
}
1822
`;
@@ -48,6 +52,10 @@ interface BindingDocumentsResponse {
4852
parsed: Record<string, unknown> | null;
4953
};
5054
}>;
55+
pageInfo: {
56+
hasNextPage: boolean;
57+
endCursor: string | null;
58+
};
5159
};
5260
}
5361

@@ -151,12 +159,25 @@ class EvaultService {
151159
},
152160
});
153161

154-
const response = await client.request<BindingDocumentsResponse>(
155-
BINDING_DOCUMENTS_QUERY,
156-
{ first: 100 },
157-
);
162+
const allEdges: Array<{
163+
node: { id: string; parsed: Record<string, unknown> | null };
164+
}> = [];
165+
let afterCursor: string | null = null;
166+
167+
do {
168+
const response = await client.request<BindingDocumentsResponse>(
169+
BINDING_DOCUMENTS_QUERY,
170+
{ first: 100, after: afterCursor ?? undefined },
171+
);
172+
allEdges.push(...response.bindingDocuments.edges);
173+
if (response.bindingDocuments.pageInfo.hasNextPage) {
174+
afterCursor = response.bindingDocuments.pageInfo.endCursor;
175+
} else {
176+
afterCursor = null;
177+
}
178+
} while (afterCursor !== null);
158179

159-
const documents: BindingDocument[] = response.bindingDocuments.edges
180+
const documents: BindingDocument[] = allEdges
160181
.map((edge) => {
161182
const parsed = edge.node.parsed;
162183
if (!parsed || typeof parsed !== "object") return null;
@@ -193,7 +214,12 @@ class EvaultService {
193214

194215
if (!otherPartyEName) return null;
195216

196-
const name = await this.resolveDisplayNameForEName(otherPartyEName);
217+
let name: string;
218+
try {
219+
name = await this.resolveDisplayNameForEName(otherPartyEName);
220+
} catch {
221+
name = otherPartyEName;
222+
}
197223

198224
return {
199225
id: doc.id,

0 commit comments

Comments
 (0)