feat(graph): fix
This commit is contained in:
@@ -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/");
|
||||
|
||||
Reference in New Issue
Block a user