@cliphijack/santaclaude 1.0.29 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/santaclaude.js +25 -10
package/package.json
CHANGED
package/santaclaude.js
CHANGED
|
@@ -272,16 +272,31 @@ function refreshNotion() {
|
|
|
272
272
|
const parent = (env.match(/^NOTION_PARENT_PAGE=(.+)$/m) || [])[1];
|
|
273
273
|
if (!tok) { _njCache = null; return; }
|
|
274
274
|
if (!parent) { _njCache = { noParent: true, items: [] }; return; }
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
const H = { Authorization: 'Bearer ' + tok.trim(), 'Notion-Version': '2022-06-28' };
|
|
276
|
+
const ndir = path.join(os.homedir(), '.santaclaude', 'notion');
|
|
277
|
+
let idf = []; try { idf = fs.readdirSync(ndir).filter((f) => f.endsWith('.id')); } catch (e) {}
|
|
278
|
+
// 세션별 페이지 기록(타임라인) 읽기 — 캐시된 page_id 들
|
|
279
|
+
const jobs = idf.slice(0, 10).map((f) => {
|
|
280
|
+
const win = decodeURIComponent(f.replace(/\.id$/, '')); let pid = ''; try { pid = fs.readFileSync(path.join(ndir, f), 'utf8').trim(); } catch (e) {}
|
|
281
|
+
if (!pid) return Promise.resolve(null);
|
|
282
|
+
return fetch('https://api.notion.com/v1/blocks/' + pid + '/children?page_size=100', { headers: H }).then((r) => r.json()).then((j) => {
|
|
283
|
+
const out = []; for (const b of (j.results || [])) { const rt = (b[b.type] && b[b.type].rich_text) || []; const t = rt.map((x) => x.plain_text || '').join('').trim(); if (t) out.push({ type: b.type, text: t.slice(0, 400) }); }
|
|
284
|
+
return { win, entries: out.slice(-25), pid: pid.replace(/-/g, '') };
|
|
285
|
+
}).catch(() => null);
|
|
286
|
+
});
|
|
287
|
+
const pchild = fetch('https://api.notion.com/v1/blocks/' + parent.trim() + '/children?page_size=50', { headers: H }).then((r) => r.json()).catch(() => null);
|
|
288
|
+
Promise.all([pchild, Promise.all(jobs)]).then((res) => {
|
|
289
|
+
const pc = res[0], js = res[1];
|
|
290
|
+
if (pc && pc.object === 'error') { _njCache = { err: pc.message || 'notion error', items: [] }; return; }
|
|
291
|
+
const items = [];
|
|
292
|
+
for (const b of ((pc && pc.results) || [])) {
|
|
293
|
+
if (b.type === 'child_page') items.push({ t: 'page', id: (b.id || '').replace(/-/g, ''), title: (b.child_page && b.child_page.title) || '(제목 없음)' });
|
|
294
|
+
else if (b.type === 'child_database') items.push({ t: 'db', id: (b.id || '').replace(/-/g, ''), title: (b.child_database && b.child_database.title) || '(DB)' });
|
|
295
|
+
}
|
|
296
|
+
const journals = {}, pageIds = {};
|
|
297
|
+
for (const r of js) { if (r) { journals[r.win] = r.entries; pageIds[r.win] = r.pid; } }
|
|
298
|
+
_njCache = { items: items.slice(0, 30), parent: parent.trim().replace(/-/g, ''), journals, pageIds };
|
|
299
|
+
}).catch(() => { _njCache = null; });
|
|
285
300
|
}
|
|
286
301
|
function startShareServer(ip) { // 테일넷 IP에만 바인드 → 테일넷 피어만 접근. 경로 토큰 + basename으로 보호
|
|
287
302
|
if (_shareServer || !ip) return;
|