All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from __future__ import annotations
|
|
import os
|
|
import hashlib
|
|
from typing import Dict
|
|
from .parser import ParsedNote
|
|
from .parser import extract_wikilinks
|
|
|
|
def sha256_text(text: str) -> str:
|
|
h = hashlib.sha256()
|
|
h.update(text.encode("utf-8"))
|
|
return h.hexdigest()
|
|
|
|
def make_note_payload(parsed: ParsedNote, vault_root: str) -> Dict:
|
|
fm = parsed.frontmatter
|
|
body = parsed.body
|
|
rel_path = os.path.relpath(parsed.path, vault_root) if vault_root else parsed.path
|
|
|
|
payload = {
|
|
"note_id": fm.get("id"),
|
|
"title": fm.get("title"),
|
|
"type": fm.get("type"),
|
|
"status": fm.get("status"),
|
|
"created": fm.get("created"),
|
|
"updated": fm.get("updated"),
|
|
"tags": fm.get("tags") or [],
|
|
"priority": fm.get("priority"),
|
|
"effort_min": fm.get("effort_min"),
|
|
"due": fm.get("due"),
|
|
"people": fm.get("people") or [],
|
|
"aliases": fm.get("aliases") or [],
|
|
"depends_on": fm.get("depends_on") or [],
|
|
"assigned_to": fm.get("assigned_to") or [],
|
|
"references": list(sorted(set(extract_wikilinks(body)))),
|
|
"lang": fm.get("lang") or None,
|
|
"path": rel_path.replace("\\", "/"),
|
|
"hash_fulltext": sha256_text(body.strip()),
|
|
}
|
|
# Entferne None-Werte für saubere Payloads
|
|
return {k: v for k, v in payload.items() if v not in (None, [])}
|