feat(graph): fix

This commit is contained in:
vl.arkhangelskii
2026-09-21 13:21:38 +03:00
parent b8d611beee
commit 236c0bc754
10 changed files with 637 additions and 396 deletions
+18
View File
@@ -64,6 +64,24 @@ export function styleUrl(access: Access, name: string, sourceIds: string[]): str
return serviceUrl(`/api/v1/styles/${encodeURIComponent(name)}?source=${encodeURIComponent(source)}`);
}
export function graphMetaUrl(access: Access, sourceId: string): string {
return serviceUrl(
`/u/${encodeURIComponent(access.slug)}/graph/${encodeURIComponent(sourceId)}?token=${encodeURIComponent(access.token)}`
);
}
export function graphNodesUrl(access: Access, sourceId: string, bbox: string, after = 0, limit = 5000): string {
return serviceUrl(
`/u/${encodeURIComponent(access.slug)}/graph/${encodeURIComponent(sourceId)}/nodes?bbox=${encodeURIComponent(bbox)}&after=${after}&limit=${limit}&token=${encodeURIComponent(access.token)}`
);
}
export function graphEdgesUrl(access: Access, sourceId: string, bbox: string, after = 0, limit = 5000): string {
return serviceUrl(
`/u/${encodeURIComponent(access.slug)}/graph/${encodeURIComponent(sourceId)}/edges?bbox=${encodeURIComponent(bbox)}&after=${after}&limit=${limit}&token=${encodeURIComponent(access.token)}`
);
}
export function rewriteServiceUrl(url: string, access: Access): string {
const resolved = new URL(url, `${API_ORIGIN}/`);
const isService = resolved.pathname.startsWith("/u/") || resolved.pathname.startsWith("/api/");