feat: implement ensure_publication for zero_publication management

- Added the ensure_publication function to create and verify the zero_publication if it is missing, ensuring idempotency during database initialization.
- Integrated ensure_publication into the create_db_and_tables function to prevent zero-cache crash loops on startup.
- Introduced a self-check script to validate the ensure_publication functionality on a create_all-bootstrapped database.
- Updated various components to reflect the transition from search space to workspace, including adjustments in imports and routing paths.
This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-07-05 23:17:13 -07:00
parent 7562bc78ee
commit a64c8205fe
164 changed files with 626 additions and 506 deletions

View file

@ -19,7 +19,7 @@ import {
updateSearchSpaceApiAccessResponse,
updateSearchSpaceRequest,
updateSearchSpaceResponse,
} from "@/contracts/types/search-space.types";
} from "@/contracts/types/workspace.types";
import { ValidationError } from "../error";
import { baseApiService } from "./base-api.service";
@ -50,7 +50,7 @@ class SearchSpacesApiService {
? new URLSearchParams(transformedQueryParams).toString()
: "";
return baseApiService.get(`/api/v1/searchspaces?${queryParams}`, getSearchSpacesResponse);
return baseApiService.get(`/api/v1/workspaces?${queryParams}`, getSearchSpacesResponse);
};
/**
@ -66,7 +66,7 @@ class SearchSpacesApiService {
throw new ValidationError(`Invalid request: ${errorMessage}`);
}
return baseApiService.post(`/api/v1/searchspaces`, createSearchSpaceResponse, {
return baseApiService.post(`/api/v1/workspaces`, createSearchSpaceResponse, {
body: parsedRequest.data,
});
};
@ -84,7 +84,7 @@ class SearchSpacesApiService {
throw new ValidationError(`Invalid request: ${errorMessage}`);
}
return baseApiService.get(`/api/v1/searchspaces/${request.id}`, getSearchSpaceResponse);
return baseApiService.get(`/api/v1/workspaces/${request.id}`, getSearchSpaceResponse);
};
/**
@ -100,7 +100,7 @@ class SearchSpacesApiService {
throw new ValidationError(`Invalid request: ${errorMessage}`);
}
return baseApiService.put(`/api/v1/searchspaces/${request.id}`, updateSearchSpaceResponse, {
return baseApiService.put(`/api/v1/workspaces/${request.id}`, updateSearchSpaceResponse, {
body: parsedRequest.data.data,
});
};
@ -115,7 +115,7 @@ class SearchSpacesApiService {
}
return baseApiService.put(
`/api/v1/searchspaces/${request.id}/api-access`,
`/api/v1/workspaces/${request.id}/api-access`,
updateSearchSpaceApiAccessResponse,
{
body: { api_access_enabled: parsedRequest.data.api_access_enabled },
@ -136,7 +136,7 @@ class SearchSpacesApiService {
throw new ValidationError(`Invalid request: ${errorMessage}`);
}
return baseApiService.delete(`/api/v1/searchspaces/${request.id}`, deleteSearchSpaceResponse);
return baseApiService.delete(`/api/v1/workspaces/${request.id}`, deleteSearchSpaceResponse);
};
/**
@ -144,7 +144,7 @@ class SearchSpacesApiService {
*/
triggerAiSort = async (searchSpaceId: number) => {
return baseApiService.post(
`/api/v1/searchspaces/${searchSpaceId}/ai-sort`,
`/api/v1/workspaces/${searchSpaceId}/ai-sort`,
z.object({ message: z.string() }),
{}
);
@ -156,7 +156,7 @@ class SearchSpacesApiService {
*/
leaveSearchSpace = async (searchSpaceId: number) => {
return baseApiService.delete(
`/api/v1/searchspaces/${searchSpaceId}/members/me`,
`/api/v1/workspaces/${searchSpaceId}/members/me`,
leaveSearchSpaceResponse
);
};