Initial commit: note-taking/task-tracking app with LLM integration scaffold
Vue 3 + TypeScript frontend with Pinia stores, markdown rendering (marked + DOMPurify), wikilink/tag linkification, and autocomplete. Quart async backend with SQLAlchemy 2.0, PostgreSQL ARRAY columns, task-note companion linking, backlinks, and note-to-task conversion. Docker Compose setup with PostgreSQL 16 and Ollama. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
from quart import Blueprint, jsonify
|
||||
|
||||
api = Blueprint("api", __name__, url_prefix="/api")
|
||||
|
||||
|
||||
@api.route("/health")
|
||||
async def health():
|
||||
return jsonify({"status": "ok"})
|
||||
@@ -0,0 +1,120 @@
|
||||
from quart import Blueprint, jsonify, request
|
||||
|
||||
from fabledassistant.services.notes import (
|
||||
convert_note_to_task,
|
||||
create_note,
|
||||
delete_note,
|
||||
get_all_tags,
|
||||
get_backlinks,
|
||||
get_note,
|
||||
get_note_by_title,
|
||||
get_or_create_note_by_title,
|
||||
list_notes,
|
||||
update_note,
|
||||
)
|
||||
from fabledassistant.utils.tags import extract_tags
|
||||
|
||||
notes_bp = Blueprint("notes", __name__, url_prefix="/api/notes")
|
||||
|
||||
|
||||
@notes_bp.route("", methods=["GET"])
|
||||
async def list_notes_route():
|
||||
q = request.args.get("q")
|
||||
tag = request.args.getlist("tag")
|
||||
sort = request.args.get("sort", "updated_at")
|
||||
order = request.args.get("order", "desc")
|
||||
limit = request.args.get("limit", 50, type=int)
|
||||
offset = request.args.get("offset", 0, type=int)
|
||||
|
||||
notes, total = await list_notes(
|
||||
q=q, tags=tag or None, sort=sort, order=order, limit=limit, offset=offset
|
||||
)
|
||||
return jsonify({"notes": [n.to_dict() for n in notes], "total": total})
|
||||
|
||||
|
||||
@notes_bp.route("", methods=["POST"])
|
||||
async def create_note_route():
|
||||
data = await request.get_json()
|
||||
body = data.get("body", "")
|
||||
tags = extract_tags(body)
|
||||
note = await create_note(
|
||||
title=data.get("title", ""),
|
||||
body=body,
|
||||
tags=tags,
|
||||
parent_id=data.get("parent_id"),
|
||||
)
|
||||
return jsonify(note.to_dict()), 201
|
||||
|
||||
|
||||
@notes_bp.route("/tags", methods=["GET"])
|
||||
async def list_tags_route():
|
||||
q = request.args.get("q")
|
||||
tags = await get_all_tags(q=q)
|
||||
return jsonify({"tags": tags})
|
||||
|
||||
|
||||
@notes_bp.route("/by-title", methods=["GET"])
|
||||
async def get_note_by_title_route():
|
||||
title = request.args.get("title", "")
|
||||
if not title:
|
||||
return jsonify({"error": "title parameter is required"}), 400
|
||||
note = await get_note_by_title(title)
|
||||
if note is None:
|
||||
return jsonify({"error": "Note not found"}), 404
|
||||
return jsonify(note.to_dict())
|
||||
|
||||
|
||||
@notes_bp.route("/resolve-title", methods=["POST"])
|
||||
async def resolve_title_route():
|
||||
data = await request.get_json()
|
||||
title = data.get("title", "").strip()
|
||||
if not title:
|
||||
return jsonify({"error": "title is required"}), 400
|
||||
note = await get_or_create_note_by_title(title)
|
||||
return jsonify(note.to_dict())
|
||||
|
||||
|
||||
@notes_bp.route("/<int:note_id>", methods=["GET"])
|
||||
async def get_note_route(note_id: int):
|
||||
note = await get_note(note_id)
|
||||
if note is None:
|
||||
return jsonify({"error": "Note not found"}), 404
|
||||
return jsonify(note.to_dict())
|
||||
|
||||
|
||||
@notes_bp.route("/<int:note_id>", methods=["PUT"])
|
||||
async def update_note_route(note_id: int):
|
||||
data = await request.get_json()
|
||||
fields = {}
|
||||
for key in ("title", "body", "parent_id"):
|
||||
if key in data:
|
||||
fields[key] = data[key]
|
||||
if "body" in fields:
|
||||
fields["tags"] = extract_tags(fields["body"])
|
||||
note = await update_note(note_id, **fields)
|
||||
if note is None:
|
||||
return jsonify({"error": "Note not found"}), 404
|
||||
return jsonify(note.to_dict())
|
||||
|
||||
|
||||
@notes_bp.route("/<int:note_id>", methods=["DELETE"])
|
||||
async def delete_note_route(note_id: int):
|
||||
deleted = await delete_note(note_id)
|
||||
if not deleted:
|
||||
return jsonify({"error": "Note not found"}), 404
|
||||
return "", 204
|
||||
|
||||
|
||||
@notes_bp.route("/<int:note_id>/convert-to-task", methods=["POST"])
|
||||
async def convert_note_to_task_route(note_id: int):
|
||||
try:
|
||||
task = await convert_note_to_task(note_id)
|
||||
return jsonify(task.to_dict()), 201
|
||||
except ValueError as e:
|
||||
return jsonify({"error": str(e)}), 404
|
||||
|
||||
|
||||
@notes_bp.route("/<int:note_id>/backlinks", methods=["GET"])
|
||||
async def get_backlinks_route(note_id: int):
|
||||
links = await get_backlinks(note_id)
|
||||
return jsonify({"backlinks": links})
|
||||
@@ -0,0 +1,123 @@
|
||||
from datetime import date
|
||||
|
||||
from quart import Blueprint, jsonify, request
|
||||
|
||||
from fabledassistant.models.task import TaskPriority, TaskStatus
|
||||
from fabledassistant.services.tasks import (
|
||||
create_task,
|
||||
delete_task,
|
||||
get_task,
|
||||
list_tasks,
|
||||
update_task,
|
||||
)
|
||||
from fabledassistant.utils.tags import extract_tags
|
||||
|
||||
tasks_bp = Blueprint("tasks", __name__, url_prefix="/api/tasks")
|
||||
|
||||
|
||||
@tasks_bp.route("", methods=["GET"])
|
||||
async def list_tasks_route():
|
||||
q = request.args.get("q")
|
||||
tag = request.args.getlist("tag")
|
||||
status = request.args.get("status")
|
||||
priority = request.args.get("priority")
|
||||
note_id = request.args.get("note_id", type=int)
|
||||
sort = request.args.get("sort", "updated_at")
|
||||
order = request.args.get("order", "desc")
|
||||
limit = request.args.get("limit", 50, type=int)
|
||||
offset = request.args.get("offset", 0, type=int)
|
||||
|
||||
tasks, total = await list_tasks(
|
||||
q=q,
|
||||
tags=tag or None,
|
||||
status=status,
|
||||
priority=priority,
|
||||
note_id=note_id,
|
||||
sort=sort,
|
||||
order=order,
|
||||
limit=limit,
|
||||
offset=offset,
|
||||
)
|
||||
return jsonify({"tasks": [t.to_dict() for t in tasks], "total": total})
|
||||
|
||||
|
||||
@tasks_bp.route("", methods=["POST"])
|
||||
async def create_task_route():
|
||||
data = await request.get_json()
|
||||
description = data.get("description", "")
|
||||
tags = extract_tags(description)
|
||||
|
||||
due_date = None
|
||||
if data.get("due_date"):
|
||||
due_date = date.fromisoformat(data["due_date"])
|
||||
|
||||
status = TaskStatus(data["status"]) if "status" in data else TaskStatus.todo
|
||||
priority = (
|
||||
TaskPriority(data["priority"]) if "priority" in data else TaskPriority.none
|
||||
)
|
||||
|
||||
task = await create_task(
|
||||
title=data.get("title", ""),
|
||||
description=description,
|
||||
status=status,
|
||||
priority=priority,
|
||||
due_date=due_date,
|
||||
tags=tags,
|
||||
)
|
||||
return jsonify(task.to_dict()), 201
|
||||
|
||||
|
||||
@tasks_bp.route("/<int:task_id>", methods=["GET"])
|
||||
async def get_task_route(task_id: int):
|
||||
task = await get_task(task_id)
|
||||
if task is None:
|
||||
return jsonify({"error": "Task not found"}), 404
|
||||
return jsonify(task.to_dict())
|
||||
|
||||
|
||||
@tasks_bp.route("/<int:task_id>", methods=["PUT"])
|
||||
async def update_task_route(task_id: int):
|
||||
data = await request.get_json()
|
||||
fields = {}
|
||||
for key in ("title", "description", "status", "priority"):
|
||||
if key in data:
|
||||
fields[key] = data[key]
|
||||
|
||||
if "due_date" in data:
|
||||
fields["due_date"] = (
|
||||
date.fromisoformat(data["due_date"]) if data["due_date"] else None
|
||||
)
|
||||
|
||||
if "description" in fields:
|
||||
fields["tags"] = extract_tags(fields["description"])
|
||||
|
||||
task = await update_task(task_id, **fields)
|
||||
if task is None:
|
||||
return jsonify({"error": "Task not found"}), 404
|
||||
return jsonify(task.to_dict())
|
||||
|
||||
|
||||
@tasks_bp.route("/<int:task_id>/status", methods=["PATCH"])
|
||||
async def patch_task_status(task_id: int):
|
||||
data = await request.get_json()
|
||||
status_val = data.get("status")
|
||||
if not status_val:
|
||||
return jsonify({"error": "status is required"}), 400
|
||||
|
||||
try:
|
||||
TaskStatus(status_val)
|
||||
except ValueError:
|
||||
return jsonify({"error": f"Invalid status: {status_val}"}), 400
|
||||
|
||||
task = await update_task(task_id, status=status_val)
|
||||
if task is None:
|
||||
return jsonify({"error": "Task not found"}), 404
|
||||
return jsonify(task.to_dict())
|
||||
|
||||
|
||||
@tasks_bp.route("/<int:task_id>", methods=["DELETE"])
|
||||
async def delete_task_route(task_id: int):
|
||||
deleted = await delete_task(task_id)
|
||||
if not deleted:
|
||||
return jsonify({"error": "Task not found"}), 404
|
||||
return "", 204
|
||||
Reference in New Issue
Block a user