$ cat node-template.py

O

Ontology Delete

// Soft-delete (recoverable server-side) an ontology object or link. Returns its id and the delete timestamp.

Output
Data
#ontology#knowledge-graph#delete#write
template.py
1"""ontology-delete — soft-delete an ontology object or link.23Soft-deletes (recoverable server-side) the object/link identified by ``target``4+ ``targetId`` via the gais.ontology SDK (``Gais.ontology.delete``). The target5id is UUID-validated here (defense in depth). Privileged IO carries the6per-execution USER_TOKEN inside the SDK — this node imports no HTTP client.7Returns the target ``id`` and the ``deleted_at`` timestamp.8"""910from __future__ import annotations1112import json13import re14import sys15import traceback16from typing import Any1718from gais import Gais1920_UUID_RE = re.compile(21    r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",22    re.IGNORECASE,23)24_TARGETS = ("object", "link")252627def _normalize_uuid(value: Any, field: str) -> str:28    """Accept a bare UUID or a ``mention://.../<uuid>`` URI; validate as UUID."""29    if not isinstance(value, str):30        raise ValueError(f"{field} must be a string, got {type(value).__name__}")31    s = value.strip()32    if "://" in s:33        s = s.rsplit("/", 1)[-1]34    if not _UUID_RE.match(s):35        raise ValueError(f"{field} is not a valid UUID: {value!r}")36    return s373839def process(inputs: dict[str, Any]) -> dict[str, Any]:40    target = str(inputs.get("target") or "object").strip().lower()41    if target not in _TARGETS:42        raise ValueError(f"target must be one of {list(_TARGETS)}")4344    target_id = _normalize_uuid(inputs.get("targetId"), "targetId")4546    result = Gais.ontology.delete(target=target, id=target_id)47    if not isinstance(result, dict):48        result = {}4950    deleted_id = result.get("id", target_id)51    deleted_at = result.get("deleted_at")52    if deleted_at is None:53        deleted_at = ""5455    print(56        f"[ontology-delete] target={target} id={deleted_id} deleted_at={deleted_at}",57        file=sys.stderr,58    )5960    return {"id": deleted_id, "deleted_at": deleted_at}616263def main() -> None:64    try:65        envelope = json.loads(sys.stdin.read() or "{}")66        if not isinstance(envelope, dict):67            envelope = {}68        inputs = envelope.get("inputs", {}) or {}69        json.dump(process(inputs), sys.stdout)70    except Exception as e:71        print(72            json.dumps({73                "error": str(e),74                "errorType": type(e).__name__,75                "traceback": traceback.format_exc(),76            }),77            file=sys.stderr,78        )79        sys.exit(1)808182if __name__ == "__main__":83    main()

$ git log --oneline

v1.0.0
HEAD
2026-08-18