supernote 0.25.0__tar.gz → 0.26.0__tar.gz
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.
- {supernote-0.25.0/supernote.egg-info → supernote-0.26.0}/PKG-INFO +1 -1
- {supernote-0.25.0 → supernote-0.26.0}/pyproject.toml +7 -1
- supernote-0.26.0/supernote/alembic/versions/f3b4c5d6e7f8_migrate_generated_summaries_to_ai_category.py +365 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/cli/server.py +11 -1
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/__init__.py +0 -6
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/app.py +0 -4
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/session.py +25 -11
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/mcp/auth.py +192 -80
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/mcp/models.py +40 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/mcp/server.py +3 -1
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/metrics.py +39 -22
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/file_web.py +2 -15
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor.py +11 -2
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor_modules/summary.py +209 -151
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/summary.py +22 -8
- supernote-0.26.0/supernote/server/static/index.html +230 -0
- supernote-0.26.0/supernote/server/static/js/api/client.js +732 -0
- supernote-0.26.0/supernote/server/static/js/api/http.js +161 -0
- supernote-0.26.0/supernote/server/static/js/api/schedule.js +194 -0
- supernote-0.26.0/supernote/server/static/js/components/FileBrowserPanel.js +808 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/components/FileCard.js +74 -37
- supernote-0.26.0/supernote/server/static/js/components/FileViewer.js +652 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/components/LoginCard.js +35 -22
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/components/MoveModal.js +148 -94
- supernote-0.26.0/supernote/server/static/js/components/OAuthConsentCard.js +193 -0
- supernote-0.26.0/supernote/server/static/js/components/RenameModal.js +75 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/components/SearchModal.js +71 -63
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/components/SystemPanel.js +98 -68
- supernote-0.26.0/supernote/server/static/js/components/TaskPanel.js +500 -0
- supernote-0.26.0/supernote/server/static/js/components/tasks/TaskEditorModal.js +211 -0
- supernote-0.26.0/supernote/server/static/js/components/tasks/TaskIcsModal.js +192 -0
- supernote-0.26.0/supernote/server/static/js/components/tasks/TaskRow.js +168 -0
- supernote-0.26.0/supernote/server/static/js/components/tasks/TaskSidebar.js +168 -0
- supernote-0.26.0/supernote/server/static/js/components/viewer/ViewerMediaPreview.js +94 -0
- supernote-0.26.0/supernote/server/static/js/components/viewer/ViewerSidePanel.js +359 -0
- supernote-0.26.0/supernote/server/static/js/components/viewer/ViewerToolbar.js +171 -0
- supernote-0.26.0/supernote/server/static/js/components/viewer/noteMeta.js +164 -0
- supernote-0.26.0/supernote/server/static/js/composables/useCanvasScrollSync.js +307 -0
- supernote-0.26.0/supernote/server/static/js/composables/useFileSystem.js +178 -0
- supernote-0.26.0/supernote/server/static/js/composables/useModalEscape.js +101 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/composables/useProcessingStatus.js +58 -14
- supernote-0.26.0/supernote/server/static/js/composables/useRouter.js +671 -0
- supernote-0.26.0/supernote/server/static/js/composables/useSchedule.js +285 -0
- supernote-0.26.0/supernote/server/static/js/composables/useToast.js +59 -0
- supernote-0.26.0/supernote/server/static/js/main.js +360 -0
- supernote-0.26.0/supernote/server/static/js/types.d.ts +384 -0
- supernote-0.26.0/supernote/server/static/js/utils/clipboard.js +51 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/js/utils/format.js +63 -3
- supernote-0.26.0/supernote/server/static/js/utils/markdown.js +61 -0
- supernote-0.26.0/supernote/server/static/js/utils/oauth.js +143 -0
- supernote-0.26.0/supernote/server/static/style.css +297 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/paths.py +27 -9
- {supernote-0.25.0 → supernote-0.26.0/supernote.egg-info}/PKG-INFO +1 -1
- {supernote-0.25.0 → supernote-0.26.0}/supernote.egg-info/SOURCES.txt +19 -0
- {supernote-0.25.0 → supernote-0.26.0}/tests/test_init.py +5 -2
- supernote-0.25.0/supernote/server/static/index.html +0 -506
- supernote-0.25.0/supernote/server/static/js/api/client.js +0 -892
- supernote-0.25.0/supernote/server/static/js/api/schedule.js +0 -244
- supernote-0.25.0/supernote/server/static/js/components/FileViewer.js +0 -1206
- supernote-0.25.0/supernote/server/static/js/components/RenameModal.js +0 -60
- supernote-0.25.0/supernote/server/static/js/components/TaskPanel.js +0 -852
- supernote-0.25.0/supernote/server/static/js/composables/useFileSystem.js +0 -124
- supernote-0.25.0/supernote/server/static/js/composables/useSchedule.js +0 -216
- supernote-0.25.0/supernote/server/static/js/composables/useToast.js +0 -31
- supernote-0.25.0/supernote/server/static/js/main.js +0 -1090
- supernote-0.25.0/supernote/server/static/style.css +0 -82
- {supernote-0.25.0 → supernote-0.26.0}/LICENSE +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/NOTICE +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/README.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/setup.cfg +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/env.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/script.py.mako +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/0543a383957b_initial_schema.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/68964804740d_prevent_user_id_reuse.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/7a8291f043bc_add_links_and_sort_fields_to_schedule_task.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/a2b3c4d5e6f7_scope_summary_unique_identifier_by_user.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/b7397248a96b_merge_mixed_case_system_roots.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/b8e9c0d1e2f3_backfill_summary_md5_and_timestamps.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/c1d2e3f4a5b6_add_embedding_model_to_note_page_content.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/c3d4e5f6a7b8_seed_sync_initialized_for_existing_users.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/d1e2f3a4b5c6_add_client_task_ids.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/d4e5f6a7b8c9_unify_schedule_ids_as_string.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/d5e6f7a8b9c0_reset_legacy_default_user_quota.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/e6f7a8b9c0d1_add_note_and_page_metadata_tables.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/e7f8a9b0c1d2_add_update_time_to_schedule_task_group.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/e8f9a0b1c2d3_add_api_keys_table.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/f1a2b3c4d5e6_make_schedule_task_list_id_nullable.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic/versions/f2a3b4c5d6e7_add_user_event_log_table.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/alembic.ini +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/cli/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/cli/admin.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/cli/client.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/cli/main.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/cli/notebook.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/admin.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/api.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/auth.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/client.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/device.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/events.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/exceptions.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/extended.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/hashing.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/login_client.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/schedule.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/socket.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/client/web.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/auth.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/base.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/equipment.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/events.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/extended.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/file_common.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/file_device.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/file_web.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/schedule.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/socket.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/system.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/user.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/models/webhook.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/author.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/color.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/converter.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/decoder.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/encoder.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/exceptions.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/fileformat.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/manipulator.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/parser.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/renderer.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/ArchitectsDaughter-Regular.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/Caveat-Variable.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/InstrumentSerif-Italic.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/InstrumentSerif-Regular.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/Karla-Variable.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/OFL-ArchitectsDaughter.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/OFL-Caveat.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/OFL-InstrumentSerif.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/OFL-Karla.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/OFL-SpaceMono.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/SpaceMono-Bold.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/SpaceMono-Regular.ttf +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/resources/fonts/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/schema.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/notebook/utils.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/py.typed +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/base.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/eval.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/apple/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/apple/backend.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/apple/ocr.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/embedding.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/fake/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/fake/embedding.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/fake/ocr.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/fake/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/gemini/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/gemini/backend.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/gemini/embedding.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/gemini/ocr.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/gemini/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/ocr.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/openai/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/openai/backend.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/openai/embedding.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/openai/ocr.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/openai/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/models/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/ai/prompts.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/config.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/constants.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/base.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/migrations.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/api_key.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/device.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/event_log.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/file.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/kv.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/login_record.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/note_processing.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/schedule.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/db/models/user.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/events.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/exceptions.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/keys.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/mcp/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/ocr/common/context.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/ocr/common/legend.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/ocr/daily/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/ocr/default/system.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/ocr/monthly/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/ocr/weekly/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/summary/common/instruction.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/summary/daily/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/summary/default/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/summary/monthly/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/resources/prompts/summary/weekly/prompt.md +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/admin.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/auth.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/decorators.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/events.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/extended.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/file_device.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/oss.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/schedule.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/summary.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/routes/system.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/blob.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/conversion.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/coordination.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/event_log.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/file.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/ical_export.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/integrity.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor_modules/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor_modules/embedding.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor_modules/ocr.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor_modules/page_hashing.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/processor_modules/png_conversion.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/schedule.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/search.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/storage_metrics.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/user.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/vfs.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/services/webhook.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/socket.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/socket_auth.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/static/favicon.ico +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/trace.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/auth_utils.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/hashing.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/note_content.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/prompt_loader.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/rapid_log.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/rate_limit.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/tasks.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/unique_id.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/server/utils/url_signer.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/testing/__init__.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/testing/notebook_fixtures.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote/testing/server_runner.py +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote.egg-info/dependency_links.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote.egg-info/entry_points.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote.egg-info/requires.txt +0 -0
- {supernote-0.25.0 → supernote-0.26.0}/supernote.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: supernote
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.26.0
|
|
4
4
|
Summary: Unofficial Python toolkit for Ratta Supernote: parse and author .note files, self-host a lightweight SQLite private cloud, and run optional AI synthesis
|
|
5
5
|
Author-email: Allen Porter <allen.porter@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -4,7 +4,7 @@ requires = ["setuptools>=77.0"]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "supernote"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.26.0"
|
|
8
8
|
license = "Apache-2.0"
|
|
9
9
|
license-files = ["LICENSE", "NOTICE"]
|
|
10
10
|
description = "Unofficial Python toolkit for Ratta Supernote: parse and author .note files, self-host a lightweight SQLite private cloud, and run optional AI synthesis"
|
|
@@ -128,6 +128,12 @@ markers = [
|
|
|
128
128
|
"integration: mark test as out-of-process integration test",
|
|
129
129
|
]
|
|
130
130
|
|
|
131
|
+
[tool.coverage.run]
|
|
132
|
+
# Enable PEP 669 sys.monitoring on Python 3.13+ (coverage only defaults to it on
|
|
133
|
+
# Python 3.14+, falling back to ~2x slower sys.settrace on Python 3.13).
|
|
134
|
+
core = "sysmon"
|
|
135
|
+
disable_warnings = ["no-sysmon"]
|
|
136
|
+
|
|
131
137
|
[tool.ty.src]
|
|
132
138
|
exclude = [
|
|
133
139
|
"supernote/cli/",
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""Migrate generated summaries to AI Summaries Digest category
|
|
2
|
+
|
|
3
|
+
Revision ID: f3b4c5d6e7f8
|
|
4
|
+
Revises: e8f9a0b1c2d3
|
|
5
|
+
Create Date: 2026-11-16 03:05:00.000000
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import hashlib
|
|
10
|
+
import time
|
|
11
|
+
from collections import defaultdict
|
|
12
|
+
from collections.abc import Sequence
|
|
13
|
+
|
|
14
|
+
import sqlalchemy as sa
|
|
15
|
+
from alembic import op
|
|
16
|
+
|
|
17
|
+
from supernote.server.utils.paths import (
|
|
18
|
+
AI_SUMMARIES_GROUP_NAME,
|
|
19
|
+
flatten_vfs_path,
|
|
20
|
+
get_ai_summaries_group_id,
|
|
21
|
+
get_summary_id,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# revision identifiers, used by Alembic.
|
|
25
|
+
revision: str = "f3b4c5d6e7f8"
|
|
26
|
+
down_revision: str | Sequence[str] | None = "e8f9a0b1c2d3"
|
|
27
|
+
branch_labels: str | Sequence[str] | None = None
|
|
28
|
+
depends_on: str | Sequence[str] | None = None
|
|
29
|
+
|
|
30
|
+
_AI_GROUP_MD5 = hashlib.md5(AI_SUMMARIES_GROUP_NAME.encode("utf-8")).hexdigest()
|
|
31
|
+
_EPOCH_OFFSET_MS = 1609459200000
|
|
32
|
+
_MAX_PATH_DEPTH = 50
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _has_annotations(row: sa.Row) -> bool:
|
|
36
|
+
return any(
|
|
37
|
+
(val or "").strip()
|
|
38
|
+
for val in (
|
|
39
|
+
row.comment_str,
|
|
40
|
+
row.comment_handwrite_name,
|
|
41
|
+
row.handwrite_inner_name,
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _resolve_file_state(
|
|
47
|
+
bind: sa.Connection, user_id: int, file_id: int
|
|
48
|
+
) -> tuple[str | None, bool]:
|
|
49
|
+
"""Return `(flattened_active_path, exists_inactive_in_vfs)` for `(user_id, file_id)`."""
|
|
50
|
+
node = bind.execute(
|
|
51
|
+
sa.text(
|
|
52
|
+
"SELECT id, directory_id, file_name, is_folder, is_active "
|
|
53
|
+
"FROM f_user_file WHERE user_id = :uid AND id = :fid"
|
|
54
|
+
),
|
|
55
|
+
{"uid": user_id, "fid": file_id},
|
|
56
|
+
).fetchone()
|
|
57
|
+
if node is None or node.is_folder == "Y":
|
|
58
|
+
return None, False
|
|
59
|
+
if node.is_active != "Y":
|
|
60
|
+
return None, True
|
|
61
|
+
|
|
62
|
+
parts = [node.file_name]
|
|
63
|
+
curr_dir = int(node.directory_id)
|
|
64
|
+
visited = {int(node.id)}
|
|
65
|
+
while curr_dir != 0 and len(visited) <= _MAX_PATH_DEPTH and curr_dir not in visited:
|
|
66
|
+
visited.add(curr_dir)
|
|
67
|
+
parent = bind.execute(
|
|
68
|
+
sa.text(
|
|
69
|
+
"SELECT id, directory_id, file_name, is_active "
|
|
70
|
+
"FROM f_user_file WHERE user_id = :uid AND id = :did"
|
|
71
|
+
),
|
|
72
|
+
{"uid": user_id, "did": curr_dir},
|
|
73
|
+
).fetchone()
|
|
74
|
+
if parent is None:
|
|
75
|
+
break
|
|
76
|
+
if parent.is_active != "Y":
|
|
77
|
+
return None, True
|
|
78
|
+
parts.insert(0, parent.file_name)
|
|
79
|
+
curr_dir = int(parent.directory_id)
|
|
80
|
+
|
|
81
|
+
return flatten_vfs_path("/".join(parts)) or node.file_name, False
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def upgrade() -> None:
|
|
85
|
+
"""Migrate generated summaries to AI Summaries and soft-delete stale transcripts/groups."""
|
|
86
|
+
bind = op.get_bind()
|
|
87
|
+
now_ms = int(time.time() * 1000)
|
|
88
|
+
max_existing = int(
|
|
89
|
+
bind.execute(sa.text("SELECT COALESCE(MAX(id), 0) FROM f_summary")).scalar_one()
|
|
90
|
+
)
|
|
91
|
+
next_id = max(max_existing + 1, max(1, (now_ms - _EPOCH_OFFSET_MS) << 22))
|
|
92
|
+
file_cache: dict[tuple[int, int], tuple[str | None, bool]] = {}
|
|
93
|
+
ensured_groups: dict[int, str] = {}
|
|
94
|
+
|
|
95
|
+
def alloc_id() -> int:
|
|
96
|
+
nonlocal next_id
|
|
97
|
+
allocated = next_id
|
|
98
|
+
next_id += 1
|
|
99
|
+
return allocated
|
|
100
|
+
|
|
101
|
+
def file_state(user_id: int, file_id: int) -> tuple[str | None, bool]:
|
|
102
|
+
key = (user_id, file_id)
|
|
103
|
+
if key not in file_cache:
|
|
104
|
+
file_cache[key] = _resolve_file_state(bind, user_id, file_id)
|
|
105
|
+
return file_cache[key]
|
|
106
|
+
|
|
107
|
+
def soft_delete(user_id: int, row_id: int) -> None:
|
|
108
|
+
bind.execute(
|
|
109
|
+
sa.text(
|
|
110
|
+
"UPDATE f_summary SET is_deleted = :t, last_modified_time = :now, "
|
|
111
|
+
"update_time = :now WHERE user_id = :uid AND id = :id"
|
|
112
|
+
),
|
|
113
|
+
{"t": True, "now": now_ms, "uid": user_id, "id": row_id},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def detach_file(user_id: int, row_id: int) -> None:
|
|
117
|
+
bind.execute(
|
|
118
|
+
sa.text(
|
|
119
|
+
"UPDATE f_summary SET file_id = NULL, update_time = :now "
|
|
120
|
+
"WHERE user_id = :uid AND id = :id"
|
|
121
|
+
),
|
|
122
|
+
{"now": now_ms, "uid": user_id, "id": row_id},
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def ensure_ai_group(user_id: int) -> str:
|
|
126
|
+
if user_id in ensured_groups:
|
|
127
|
+
return ensured_groups[user_id]
|
|
128
|
+
group_uuid = get_ai_summaries_group_id(user_id)
|
|
129
|
+
existing = bind.execute(
|
|
130
|
+
sa.text(
|
|
131
|
+
"SELECT is_deleted, is_summary_group FROM f_summary "
|
|
132
|
+
"WHERE user_id = :uid AND unique_identifier = :uuid"
|
|
133
|
+
),
|
|
134
|
+
{"uid": user_id, "uuid": group_uuid},
|
|
135
|
+
).fetchone()
|
|
136
|
+
if existing is None or existing.is_deleted or not existing.is_summary_group:
|
|
137
|
+
if existing is not None:
|
|
138
|
+
bind.execute(
|
|
139
|
+
sa.text(
|
|
140
|
+
"DELETE FROM f_summary WHERE user_id = :uid AND unique_identifier = :uuid"
|
|
141
|
+
),
|
|
142
|
+
{"uid": user_id, "uuid": group_uuid},
|
|
143
|
+
)
|
|
144
|
+
bind.execute(
|
|
145
|
+
sa.text(
|
|
146
|
+
"INSERT INTO f_summary "
|
|
147
|
+
"(id, user_id, name, unique_identifier, is_summary_group, md5_hash, "
|
|
148
|
+
"creation_time, last_modified_time, is_deleted, create_time, update_time) "
|
|
149
|
+
"VALUES (:id, :uid, :name, :uuid, :t, :md5, :now, :now, :f, :now, :now)"
|
|
150
|
+
),
|
|
151
|
+
{
|
|
152
|
+
"id": alloc_id(),
|
|
153
|
+
"uid": user_id,
|
|
154
|
+
"name": AI_SUMMARIES_GROUP_NAME,
|
|
155
|
+
"uuid": group_uuid,
|
|
156
|
+
"t": True,
|
|
157
|
+
"f": False,
|
|
158
|
+
"md5": _AI_GROUP_MD5,
|
|
159
|
+
"now": now_ms,
|
|
160
|
+
},
|
|
161
|
+
)
|
|
162
|
+
ensured_groups[user_id] = group_uuid
|
|
163
|
+
return group_uuid
|
|
164
|
+
|
|
165
|
+
def resolve_parent(user_id: int, parent: str | None) -> str:
|
|
166
|
+
if parent == "":
|
|
167
|
+
return ""
|
|
168
|
+
if parent and not parent.endswith("-group"):
|
|
169
|
+
exists = bind.execute(
|
|
170
|
+
sa.text(
|
|
171
|
+
"SELECT 1 FROM f_summary WHERE user_id = :uid AND unique_identifier = :p "
|
|
172
|
+
"AND is_deleted = :f AND is_summary_group = :t"
|
|
173
|
+
),
|
|
174
|
+
{"uid": user_id, "p": parent, "f": False, "t": True},
|
|
175
|
+
).fetchone()
|
|
176
|
+
if exists is not None:
|
|
177
|
+
return parent
|
|
178
|
+
return ensure_ai_group(user_id)
|
|
179
|
+
|
|
180
|
+
active_leaves = list(
|
|
181
|
+
bind.execute(
|
|
182
|
+
sa.text(
|
|
183
|
+
"SELECT * FROM f_summary WHERE is_deleted = :f AND is_summary_group = :f"
|
|
184
|
+
),
|
|
185
|
+
{"f": False},
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
active_by_uuid = {
|
|
189
|
+
(int(r.user_id), str(r.unique_identifier)): r
|
|
190
|
+
for r in active_leaves
|
|
191
|
+
if r.unique_identifier
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
by_file: dict[tuple[int, int], list[sa.Row]] = defaultdict(list)
|
|
195
|
+
for row in active_leaves:
|
|
196
|
+
user_id = int(row.user_id)
|
|
197
|
+
file_id = int(row.file_id) if row.file_id is not None else None
|
|
198
|
+
uid = row.unique_identifier or ""
|
|
199
|
+
if (row.data_source or "").upper() == "OCR" or uid.endswith("-transcript"):
|
|
200
|
+
if _has_annotations(row):
|
|
201
|
+
if file_id is not None and file_state(user_id, file_id)[0] is None:
|
|
202
|
+
detach_file(user_id, int(row.id))
|
|
203
|
+
else:
|
|
204
|
+
soft_delete(user_id, int(row.id))
|
|
205
|
+
continue
|
|
206
|
+
|
|
207
|
+
if not (
|
|
208
|
+
uid.endswith("-summary")
|
|
209
|
+
or (file_id is not None and uid == get_summary_id(user_id, file_id))
|
|
210
|
+
):
|
|
211
|
+
continue
|
|
212
|
+
if file_id is None:
|
|
213
|
+
if not _has_annotations(row):
|
|
214
|
+
soft_delete(user_id, int(row.id))
|
|
215
|
+
continue
|
|
216
|
+
by_file[(user_id, file_id)].append(row)
|
|
217
|
+
|
|
218
|
+
for (user_id, file_id), rows in sorted(by_file.items()):
|
|
219
|
+
source_path, exists_inactive = file_state(user_id, file_id)
|
|
220
|
+
if source_path is None:
|
|
221
|
+
for row in rows:
|
|
222
|
+
if _has_annotations(row):
|
|
223
|
+
detach_file(user_id, int(row.id))
|
|
224
|
+
else:
|
|
225
|
+
soft_delete(user_id, int(row.id))
|
|
226
|
+
if exists_inactive:
|
|
227
|
+
bind.execute(
|
|
228
|
+
sa.text(
|
|
229
|
+
"DELETE FROM f_system_task "
|
|
230
|
+
"WHERE file_id = :fid AND task_type = 'SUMMARY_GENERATION'"
|
|
231
|
+
),
|
|
232
|
+
{"fid": file_id},
|
|
233
|
+
)
|
|
234
|
+
continue
|
|
235
|
+
|
|
236
|
+
canonical_uuid = get_summary_id(user_id, file_id)
|
|
237
|
+
canonical_row = active_by_uuid.get((user_id, canonical_uuid))
|
|
238
|
+
if canonical_row is not None:
|
|
239
|
+
target_parent = resolve_parent(
|
|
240
|
+
user_id, canonical_row.parent_unique_identifier
|
|
241
|
+
)
|
|
242
|
+
md5 = canonical_row.md5_hash or (
|
|
243
|
+
hashlib.md5(canonical_row.content.encode("utf-8")).hexdigest()
|
|
244
|
+
if canonical_row.content
|
|
245
|
+
else None
|
|
246
|
+
)
|
|
247
|
+
if (
|
|
248
|
+
canonical_row.file_id,
|
|
249
|
+
canonical_row.parent_unique_identifier,
|
|
250
|
+
canonical_row.source_path,
|
|
251
|
+
canonical_row.md5_hash,
|
|
252
|
+
) != (file_id, target_parent, source_path, md5):
|
|
253
|
+
bind.execute(
|
|
254
|
+
sa.text(
|
|
255
|
+
"UPDATE f_summary SET file_id = :fid, parent_unique_identifier = :parent, "
|
|
256
|
+
"source_path = :path, md5_hash = :md5, last_modified_time = :now, "
|
|
257
|
+
"update_time = :now WHERE user_id = :uid AND id = :id"
|
|
258
|
+
),
|
|
259
|
+
{
|
|
260
|
+
"fid": file_id,
|
|
261
|
+
"parent": target_parent,
|
|
262
|
+
"path": source_path,
|
|
263
|
+
"md5": md5,
|
|
264
|
+
"now": now_ms,
|
|
265
|
+
"uid": user_id,
|
|
266
|
+
"id": int(canonical_row.id),
|
|
267
|
+
},
|
|
268
|
+
)
|
|
269
|
+
kept_id = canonical_row.id
|
|
270
|
+
else:
|
|
271
|
+
winner = max(
|
|
272
|
+
rows,
|
|
273
|
+
key=lambda r: (
|
|
274
|
+
int(r.last_modified_time or r.update_time or r.create_time or 0),
|
|
275
|
+
int(r.id),
|
|
276
|
+
),
|
|
277
|
+
)
|
|
278
|
+
target_parent = resolve_parent(user_id, winner.parent_unique_identifier)
|
|
279
|
+
bind.execute(
|
|
280
|
+
sa.text(
|
|
281
|
+
"DELETE FROM f_summary WHERE user_id = :uid AND unique_identifier = :uuid"
|
|
282
|
+
),
|
|
283
|
+
{"uid": user_id, "uuid": canonical_uuid},
|
|
284
|
+
)
|
|
285
|
+
md5 = winner.md5_hash or (
|
|
286
|
+
hashlib.md5(winner.content.encode("utf-8")).hexdigest()
|
|
287
|
+
if winner.content
|
|
288
|
+
else None
|
|
289
|
+
)
|
|
290
|
+
bind.execute(
|
|
291
|
+
sa.text(
|
|
292
|
+
"INSERT INTO f_summary "
|
|
293
|
+
"(id, user_id, file_id, name, unique_identifier, parent_unique_identifier, "
|
|
294
|
+
"content, source_path, data_source, source_type, is_summary_group, description, "
|
|
295
|
+
"tags, md5_hash, extra_metadata, comment_str, comment_handwrite_name, "
|
|
296
|
+
"handwrite_inner_name, handwrite_md5, creation_time, last_modified_time, "
|
|
297
|
+
"is_deleted, create_time, update_time, author) "
|
|
298
|
+
"VALUES (:id, :uid, :fid, :name, :uuid, :parent, :content, :path, :ds, :st, :f, "
|
|
299
|
+
":desc, :tags, :md5, :meta, :cstr, :chw, :hin, :hmd5, :ctime, :now, :f, :now, :now, :author)"
|
|
300
|
+
),
|
|
301
|
+
{
|
|
302
|
+
"id": alloc_id(),
|
|
303
|
+
"uid": user_id,
|
|
304
|
+
"fid": file_id,
|
|
305
|
+
"name": winner.name,
|
|
306
|
+
"uuid": canonical_uuid,
|
|
307
|
+
"parent": target_parent,
|
|
308
|
+
"content": winner.content,
|
|
309
|
+
"path": source_path,
|
|
310
|
+
"ds": winner.data_source,
|
|
311
|
+
"st": winner.source_type,
|
|
312
|
+
"f": False,
|
|
313
|
+
"desc": winner.description,
|
|
314
|
+
"tags": winner.tags,
|
|
315
|
+
"md5": md5,
|
|
316
|
+
"meta": winner.extra_metadata,
|
|
317
|
+
"cstr": winner.comment_str,
|
|
318
|
+
"chw": winner.comment_handwrite_name,
|
|
319
|
+
"hin": winner.handwrite_inner_name,
|
|
320
|
+
"hmd5": winner.handwrite_md5,
|
|
321
|
+
"ctime": winner.creation_time or winner.create_time or now_ms,
|
|
322
|
+
"now": now_ms,
|
|
323
|
+
"author": winner.author,
|
|
324
|
+
},
|
|
325
|
+
)
|
|
326
|
+
soft_delete(user_id, int(winner.id))
|
|
327
|
+
kept_id = winner.id
|
|
328
|
+
|
|
329
|
+
for row in rows:
|
|
330
|
+
if row.id != kept_id and not _has_annotations(row):
|
|
331
|
+
soft_delete(user_id, int(row.id))
|
|
332
|
+
|
|
333
|
+
non_empty_parents = {
|
|
334
|
+
(int(r.user_id), str(r.parent_unique_identifier))
|
|
335
|
+
for r in bind.execute(
|
|
336
|
+
sa.text(
|
|
337
|
+
"SELECT user_id, parent_unique_identifier FROM f_summary "
|
|
338
|
+
"WHERE is_deleted = :f AND is_summary_group = :f "
|
|
339
|
+
"AND parent_unique_identifier IS NOT NULL AND parent_unique_identifier != '' "
|
|
340
|
+
"GROUP BY user_id, parent_unique_identifier"
|
|
341
|
+
),
|
|
342
|
+
{"f": False},
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
for g in bind.execute(
|
|
346
|
+
sa.text(
|
|
347
|
+
"SELECT id, user_id, unique_identifier, comment_str, comment_handwrite_name, "
|
|
348
|
+
"handwrite_inner_name FROM f_summary "
|
|
349
|
+
"WHERE is_deleted = :f AND is_summary_group = :t AND unique_identifier LIKE '%-group'"
|
|
350
|
+
),
|
|
351
|
+
{"f": False, "t": True},
|
|
352
|
+
):
|
|
353
|
+
g_uid = int(g.user_id)
|
|
354
|
+
g_uuid = str(g.unique_identifier)
|
|
355
|
+
if (
|
|
356
|
+
g_uuid.endswith("-group")
|
|
357
|
+
and not _has_annotations(g)
|
|
358
|
+
and (g_uid, g_uuid) not in non_empty_parents
|
|
359
|
+
):
|
|
360
|
+
soft_delete(g_uid, int(g.id))
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def downgrade() -> None:
|
|
364
|
+
"""Non-destructive data migration; leave canonical Digest records intact on downgrade."""
|
|
365
|
+
pass
|
|
@@ -7,11 +7,17 @@ See `supernote.cli` and `supernote.guides.cli_reference` for server startup flag
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
import argparse
|
|
10
|
+
import importlib.util
|
|
10
11
|
import os
|
|
11
12
|
import tempfile
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
# `supernote.cli.main` imports every subparser module during CLI startup and catches
|
|
16
|
+
# ImportError/ModuleNotFoundError to mark uninstalled optional extras as disabled.
|
|
17
|
+
# Probe `sqlalchemy` via `find_spec` so missing `[server]` extras still fail fast here
|
|
18
|
+
# without paying the ~2s cost of importing the server runtime on unrelated commands.
|
|
19
|
+
if importlib.util.find_spec("sqlalchemy") is None:
|
|
20
|
+
raise ModuleNotFoundError("No module named 'sqlalchemy'", name="sqlalchemy")
|
|
15
21
|
|
|
16
22
|
# For ephemeral mode
|
|
17
23
|
DEBUG_EMAIL = "debug@example.com"
|
|
@@ -22,6 +28,10 @@ EXAMPLE_COMMAND = "supernote cloud ls"
|
|
|
22
28
|
|
|
23
29
|
def serve_run(args: argparse.Namespace) -> None:
|
|
24
30
|
"""Wrapper for serve command to handle ephemeral mode."""
|
|
31
|
+
# Defer importing the server application (SQLAlchemy, Alembic, routes, services)
|
|
32
|
+
# until `supernote serve` is actually executed rather than on every CLI invocation.
|
|
33
|
+
from supernote.server import app as server_app # noqa: PLC0415
|
|
34
|
+
|
|
25
35
|
if getattr(args, "ephemeral", False):
|
|
26
36
|
with tempfile.TemporaryDirectory(prefix="supernote-ephemeral-") as tmp_dir:
|
|
27
37
|
tmp_path = Path(tmp_dir)
|
|
@@ -2,23 +2,17 @@
|
|
|
2
2
|
.. include:: ./README.md
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .app import create_app, run
|
|
6
|
-
from .config import ServerConfig
|
|
7
|
-
|
|
8
5
|
__all__ = [
|
|
9
|
-
"ServerConfig",
|
|
10
6
|
"ai",
|
|
11
7
|
"app",
|
|
12
8
|
"config",
|
|
13
9
|
"constants",
|
|
14
|
-
"create_app",
|
|
15
10
|
"db",
|
|
16
11
|
"events",
|
|
17
12
|
"exceptions",
|
|
18
13
|
"mcp",
|
|
19
14
|
"metrics",
|
|
20
15
|
"routes",
|
|
21
|
-
"run",
|
|
22
16
|
"services",
|
|
23
17
|
"socket",
|
|
24
18
|
"socket_auth",
|
|
@@ -69,7 +69,6 @@ from .keys import (
|
|
|
69
69
|
)
|
|
70
70
|
from .metrics import (
|
|
71
71
|
HTTP_REQUEST_DURATION_SECONDS,
|
|
72
|
-
HTTP_REQUESTS_IN_PROGRESS,
|
|
73
72
|
HTTP_REQUESTS_TOTAL,
|
|
74
73
|
)
|
|
75
74
|
from .routes import (
|
|
@@ -169,8 +168,6 @@ def create_metrics_middleware(
|
|
|
169
168
|
return await handler(request)
|
|
170
169
|
|
|
171
170
|
method = _normalize_http_method(request.method)
|
|
172
|
-
in_progress = HTTP_REQUESTS_IN_PROGRESS.labels(method=method)
|
|
173
|
-
in_progress.inc()
|
|
174
171
|
start_time = time.perf_counter()
|
|
175
172
|
status = 500
|
|
176
173
|
cancelled = False
|
|
@@ -187,7 +184,6 @@ def create_metrics_middleware(
|
|
|
187
184
|
raise
|
|
188
185
|
finally:
|
|
189
186
|
duration = time.perf_counter() - start_time
|
|
190
|
-
in_progress.dec()
|
|
191
187
|
path_pattern = _resolve_metrics_path(request, status, mcp_auth_paths)
|
|
192
188
|
HTTP_REQUESTS_TOTAL.labels(
|
|
193
189
|
method=method, path=path_pattern, status=str(status)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
`DatabaseSessionManager` manages an `AsyncEngine` (`sqlite+aiosqlite`) configured with
|
|
4
4
|
`PRAGMA journal_mode=WAL`, `PRAGMA synchronous=NORMAL`, and `PRAGMA busy_timeout`,
|
|
5
|
-
exposing an `@asynccontextmanager` `session()` helper that
|
|
6
|
-
(`supernote.server.metrics.
|
|
5
|
+
exposing an `@asynccontextmanager` `session()` helper that records database session
|
|
6
|
+
errors (`supernote.server.metrics.DB_SESSION_ERRORS_TOTAL`) and rolls back automatically on error:
|
|
7
7
|
|
|
8
8
|
```python
|
|
9
9
|
session_manager = DatabaseSessionManager("sqlite+aiosqlite:///supernote.db")
|
|
@@ -16,7 +16,7 @@ await session_manager.close()
|
|
|
16
16
|
```
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
from collections.abc import AsyncGenerator
|
|
19
|
+
from collections.abc import AsyncGenerator, Mapping
|
|
20
20
|
from contextlib import asynccontextmanager, suppress
|
|
21
21
|
from typing import Any
|
|
22
22
|
|
|
@@ -31,7 +31,7 @@ from sqlalchemy.ext.asyncio import (
|
|
|
31
31
|
|
|
32
32
|
from supernote.server.constants import SQLITE_TIMEOUT_SECONDS
|
|
33
33
|
from supernote.server.exceptions import DatabaseError
|
|
34
|
-
from supernote.server.metrics import DB_SESSION_ERRORS_TOTAL
|
|
34
|
+
from supernote.server.metrics import DB_SESSION_ERRORS_TOTAL
|
|
35
35
|
|
|
36
36
|
from .base import Base
|
|
37
37
|
|
|
@@ -40,6 +40,12 @@ ENGINE_KWARGS: dict[str, Any] = {
|
|
|
40
40
|
"echo": False,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
DEFAULT_SQLITE_PRAGMAS: dict[str, str | int] = {
|
|
44
|
+
"journal_mode": "WAL",
|
|
45
|
+
"synchronous": "NORMAL",
|
|
46
|
+
"foreign_keys": "ON",
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
|
|
44
50
|
async def _rollback_quietly(session: AsyncSession) -> None:
|
|
45
51
|
"""Perform a best-effort session rollback without masking the active exception."""
|
|
@@ -50,7 +56,12 @@ async def _rollback_quietly(session: AsyncSession) -> None:
|
|
|
50
56
|
class DatabaseSessionManager:
|
|
51
57
|
"""Database session manager."""
|
|
52
58
|
|
|
53
|
-
def __init__(
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
host: str,
|
|
62
|
+
engine_kwargs: dict[str, Any] | None = None,
|
|
63
|
+
sqlite_pragmas: Mapping[str, str | int] | None = None,
|
|
64
|
+
) -> None:
|
|
54
65
|
"""Initialize the database session manager."""
|
|
55
66
|
if engine_kwargs is None:
|
|
56
67
|
engine_kwargs = dict(ENGINE_KWARGS)
|
|
@@ -71,13 +82,18 @@ class DatabaseSessionManager:
|
|
|
71
82
|
# Enable WAL (Write-Ahead Logging) and Normal synchronous mode for SQLite
|
|
72
83
|
if "sqlite" in host:
|
|
73
84
|
assert self._engine is not None
|
|
85
|
+
pragmas = {**DEFAULT_SQLITE_PRAGMAS, **(sqlite_pragmas or {})}
|
|
86
|
+
pragma_statements = tuple(
|
|
87
|
+
f"PRAGMA {name}={value}" for name, value in pragmas.items()
|
|
88
|
+
)
|
|
74
89
|
|
|
75
90
|
@event.listens_for(self._engine.sync_engine, "connect")
|
|
76
|
-
def set_sqlite_pragma(
|
|
91
|
+
def set_sqlite_pragma(
|
|
92
|
+
dbapi_connection: Any, _connection_record: Any
|
|
93
|
+
) -> None:
|
|
77
94
|
cursor = dbapi_connection.cursor()
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
cursor.execute("PRAGMA foreign_keys=ON")
|
|
95
|
+
for stmt in pragma_statements:
|
|
96
|
+
cursor.execute(stmt)
|
|
81
97
|
cursor.close()
|
|
82
98
|
|
|
83
99
|
async def close(self) -> None:
|
|
@@ -94,7 +110,6 @@ class DatabaseSessionManager:
|
|
|
94
110
|
if self._sessionmaker is None:
|
|
95
111
|
raise DatabaseError("DatabaseSessionManager has been closed")
|
|
96
112
|
session = self._sessionmaker()
|
|
97
|
-
DB_SESSIONS_ACTIVE.inc()
|
|
98
113
|
try:
|
|
99
114
|
yield session
|
|
100
115
|
except DatabaseError:
|
|
@@ -109,7 +124,6 @@ class DatabaseSessionManager:
|
|
|
109
124
|
await _rollback_quietly(session)
|
|
110
125
|
raise
|
|
111
126
|
finally:
|
|
112
|
-
DB_SESSIONS_ACTIVE.dec()
|
|
113
127
|
await session.close()
|
|
114
128
|
|
|
115
129
|
async def create_all_tables(self) -> None:
|