report-empty-hosted-frontmatter.mjs
66 lines 2.3 KB
Raw
sha256:fd47ab66017e55331b88ba3a59c34c23e4e05c5aec424251d3a404c5a7998c8e feat(hub): restore integration tile detail modals; add Herm… Human minor ⚠ breaking 16 days ago
1 #!/usr/bin/env node
2 /**
3 * Lists vault-relative paths where stored frontmatter JSON parses to an empty object.
4 * Read-only. Same env as verify-hosted-hub-api.mjs (KNOWTATION_HUB_TOKEN, KNOWTATION_HUB_API, KNOWTATION_HUB_VAULT_ID).
5 *
6 * KNOWTATION_HUB_TOKEN='...' node scripts/report-empty-hosted-frontmatter.mjs
7 * KNOWTATION_HUB_TOKEN_FILE=~/.config/knowtation/hub_jwt.txt node scripts/report-empty-hosted-frontmatter.mjs
8 */
9
10 import fs from 'fs';
11 import path from 'path';
12 import { fileURLToPath } from 'url';
13 import dotenv from 'dotenv';
14 import { materializeListFrontmatter } from '../hub/gateway/note-facets.mjs';
15
16 const __dirname = path.dirname(fileURLToPath(import.meta.url));
17 const repoRoot = path.resolve(__dirname, '..');
18 dotenv.config({ path: path.join(repoRoot, '.env') });
19
20 function resolveToken() {
21 let t = process.env.KNOWTATION_HUB_TOKEN || process.env.HUB_JWT || '';
22 const fp = (process.env.KNOWTATION_HUB_TOKEN_FILE || '').trim();
23 if (!t && fp) {
24 const expanded = fp.startsWith('~') ? path.join(process.env.HOME || '', fp.slice(1)) : fp;
25 t = fs.readFileSync(expanded, 'utf8').trim();
26 }
27 return t;
28 }
29
30 const token = resolveToken();
31 const apiBase = (process.env.KNOWTATION_HUB_API || 'https://knowtation-gateway.netlify.app').replace(/\/$/, '');
32 const vaultId = process.env.KNOWTATION_HUB_VAULT_ID || 'default';
33
34 async function main() {
35 if (!token) {
36 console.error('Set KNOWTATION_HUB_TOKEN (or HUB_JWT).');
37 process.exit(1);
38 }
39 const res = await fetch(`${apiBase}/api/v1/notes?limit=500&offset=0`, {
40 headers: {
41 Accept: 'application/json',
42 Authorization: 'Bearer ' + token,
43 'X-Vault-Id': vaultId,
44 },
45 });
46 const text = await res.text();
47 if (!res.ok) {
48 console.error(res.status, text.slice(0, 400));
49 process.exit(1);
50 }
51 const data = JSON.parse(text);
52 const notes = Array.isArray(data.notes) ? data.notes : [];
53 const emptyPaths = [];
54 for (const n of notes) {
55 const fm = materializeListFrontmatter(n.frontmatter);
56 if (Object.keys(fm).length === 0) emptyPaths.push(n.path || '(no path)');
57 }
58 console.log('total_notes', notes.length);
59 console.log('empty_frontmatter_paths', emptyPaths.length);
60 emptyPaths.forEach((p) => console.log(p));
61 }
62
63 main().catch((e) => {
64 console.error(e);
65 process.exit(1);
66 });
File History 3 commits
sha256:fd47ab66017e55331b88ba3a59c34c23e4e05c5aec424251d3a404c5a7998c8e feat(hub): restore integration tile detail modals; add Herm… Human minor 16 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 16 days ago