6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
import { useQuery } from "@rocicorp/zero/react";
|
|
import { useMemo } from "react";
|
|
import type { SearchSourceConnector } from "@/contracts/types/connector.types";
|
|
import { queries } from "@/zero/queries";
|
|
|
|
/**
|
|
* Syncs connectors for a workspace via Zero.
|
|
* Returns connectors, loading state, error, and a refresh function.
|
|
*/
|
|
export function useConnectorsSync(workspaceId: number | string | null) {
|
|
const spaceId = workspaceId ? Number(workspaceId) : -1;
|
|
|
|
const [data, result] = useQuery(queries.connectors.bySpace({ workspaceId: spaceId }));
|
|
|
|
const connectors: SearchSourceConnector[] = useMemo(() => {
|
|
if (!workspaceId || !data) return [];
|
|
return data.map((c) => ({
|
|
id: c.id,
|
|
name: c.name,
|
|
connector_type: c.connectorType as SearchSourceConnector["connector_type"],
|
|
is_indexable: c.isIndexable,
|
|
is_active: true,
|
|
last_indexed_at: c.lastIndexedAt ? new Date(c.lastIndexedAt).toISOString() : null,
|
|
config: (c.config as Record<string, unknown>) ?? {},
|
|
periodic_indexing_enabled: c.periodicIndexingEnabled,
|
|
indexing_frequency_minutes: c.indexingFrequencyMinutes ?? null,
|
|
next_scheduled_at: c.nextScheduledAt ? new Date(c.nextScheduledAt).toISOString() : null,
|
|
workspace_id: c.workspaceId,
|
|
user_id: c.userId,
|
|
created_at: c.createdAt ? new Date(c.createdAt).toISOString() : new Date().toISOString(),
|
|
}));
|
|
}, [workspaceId, data]);
|
|
|
|
const loading = !workspaceId ? false : result.type !== "complete";
|
|
const error = !workspaceId ? null : null;
|
|
|
|
const refreshConnectors = async () => {};
|
|
|
|
return { connectors, loading, error, refreshConnectors };
|
|
}
|