fix: five defects found while rewriting the docs (UF-061 to UF-065)
- Key messages named a Settings > API Keys tab that does not exist; they now point at Settings > Models (UF-061). - The connector suggestion looked for vault.db, which never exists; it now checks the vault for a connector entry (UF-062). - /config and /preferences were registered with a leading slash and never matched (UF-063). - Pins and documents were written under ~/.waggle whatever the data directory; they now use the server's data directory (UF-064). - The Windows uninstaller named a Data & Privacy page that does not exist (UF-065).
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* POST /api/workspaces/:id/documents — register a new document version
|
||||
* GET /api/workspaces/:id/documents/:name/versions — list versions of a document
|
||||
*
|
||||
* Versions are stored in ~/.waggle/workspaces/{id}/documents.json.
|
||||
* Versions are stored in <dataDir>/workspaces/{id}/documents.json.
|
||||
* Part of Wave 7 — Professional & Vertical Features.
|
||||
*/
|
||||
|
||||
@@ -33,13 +33,13 @@ interface DocumentsRegistry {
|
||||
}
|
||||
|
||||
/** Resolve the documents.json path for a workspace. */
|
||||
function documentsFilePath(workspaceId: string): string {
|
||||
return path.join(os.homedir(), '.waggle', 'workspaces', workspaceId, 'documents.json');
|
||||
function documentsFilePath(dataDir: string, workspaceId: string): string {
|
||||
return path.join(dataDir, 'workspaces', workspaceId, 'documents.json');
|
||||
}
|
||||
|
||||
/** Read document registry from disk. Returns empty registry if file doesn't exist. */
|
||||
function readRegistry(workspaceId: string): DocumentsRegistry {
|
||||
const filePath = documentsFilePath(workspaceId);
|
||||
function readRegistry(dataDir: string, workspaceId: string): DocumentsRegistry {
|
||||
const filePath = documentsFilePath(dataDir, workspaceId);
|
||||
try {
|
||||
if (fs.existsSync(filePath)) {
|
||||
const raw = fs.readFileSync(filePath, 'utf-8');
|
||||
@@ -52,8 +52,8 @@ function readRegistry(workspaceId: string): DocumentsRegistry {
|
||||
}
|
||||
|
||||
/** Write document registry to disk. Creates directory if needed. */
|
||||
function writeRegistry(workspaceId: string, registry: DocumentsRegistry): void {
|
||||
const filePath = documentsFilePath(workspaceId);
|
||||
function writeRegistry(dataDir: string, workspaceId: string, registry: DocumentsRegistry): void {
|
||||
const filePath = documentsFilePath(dataDir, workspaceId);
|
||||
const dir = path.dirname(filePath);
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
@@ -62,13 +62,15 @@ function writeRegistry(workspaceId: string, registry: DocumentsRegistry): void {
|
||||
}
|
||||
|
||||
export const documentRoutes: FastifyPluginAsync = async (server) => {
|
||||
const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle');
|
||||
|
||||
// GET /api/workspaces/:id/documents — list all tracked documents
|
||||
server.get<{
|
||||
Params: { id: string };
|
||||
}>('/api/workspaces/:id/documents', async (request) => {
|
||||
const { id } = request.params;
|
||||
assertSafeSegment(id, 'id');
|
||||
const registry = readRegistry(id);
|
||||
const registry = readRegistry(dataDir, id);
|
||||
return {
|
||||
documents: registry.documents.map(doc => ({
|
||||
name: doc.name,
|
||||
@@ -96,7 +98,7 @@ export const documentRoutes: FastifyPluginAsync = async (server) => {
|
||||
}
|
||||
assertSafeSegment(name, 'name');
|
||||
|
||||
const registry = readRegistry(id);
|
||||
const registry = readRegistry(dataDir, id);
|
||||
let doc = registry.documents.find(d => d.name === name);
|
||||
|
||||
if (!doc) {
|
||||
@@ -116,7 +118,7 @@ export const documentRoutes: FastifyPluginAsync = async (server) => {
|
||||
};
|
||||
|
||||
doc.versions.push(version);
|
||||
writeRegistry(id, registry);
|
||||
writeRegistry(dataDir, id, registry);
|
||||
|
||||
return reply.status(201).send({ document: name, version });
|
||||
});
|
||||
@@ -128,7 +130,7 @@ export const documentRoutes: FastifyPluginAsync = async (server) => {
|
||||
const { id, name } = request.params;
|
||||
assertSafeSegment(id, 'id');
|
||||
assertSafeSegment(name, 'name');
|
||||
const registry = readRegistry(id);
|
||||
const registry = readRegistry(dataDir, id);
|
||||
const doc = registry.documents.find(d => d.name === name);
|
||||
|
||||
if (!doc) {
|
||||
|
||||
Reference in New Issue
Block a user