mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 21:46:49 +00:00
2d7cb124b3
A trip can be bound to a folder, tag or space in a self-hosted document store, and documents then move in both directions: what someone uploads in TREK appears there, and what someone files there appears in TREK. Three decisions shape the rest. The connection belongs to the TRIP, not to a person. Every other integration here is per user, and photos are shared only through an opt-in flag; neither can deliver "everyone on the trip sees the same documents", because visibility would depend on whose credentials fetched a file, and a member without their own Paperless account would see nothing. So the trip owner binds the trip once, the server talks to the provider under that one identity, and TREK's own membership decides who sees what. The provider never learns that TREK has members. When the credential holder leaves the trip the binding goes to `orphaned` rather than quietly carrying on with an ex-member's token. TREK keeps the bytes. A synced document is an ordinary trip_files row, so download, trash, offline cache, PDF export and backup keep working untouched, and a provider outage does not blank out a trip that starts tomorrow. Deletion never crosses the boundary on its own. A document that disappears upstream is recorded as missing and waits for a human, and a run that sees more than 40 percent of its known documents vanish at once refuses the whole listing rather than acting on it: an unmounted share answers exactly like a mass delete. The core reconciles by enumerating both sides, because the weakest provider sets the model. A changed-since query cannot see a deletion, Papra does not move updatedAt when a tag changes, a Paperless bulk edit leaves `modified` alone, and Synology FileStation has no change feed at all. A webhook is therefore only ever "look now", never a source of truth. Echo is caught by comparing content, not timestamps: pushed_sha256 records what TREK itself wrote, so a provider reporting TREK's own upload is not mistaken for a stranger's edit. Provider differences are answered by capability data rather than by branching on an id: stable ids where they exist (Paperless document id, oc:fileid, driveId) and a normalised path where they do not, replace-in-place where the API offers it, and a content hash from the listing only where the provider really supplies one. Admins switch providers on under Admin, Addons, Documents, mirroring how photo providers hang off Journey, including the cascade and the 409 when the parent addon is off. The per-trip setup lives in the file manager, where the person has the context that makes the folder choice obvious.
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
export const ADDON_IDS = {
|
|
MCP: 'mcp',
|
|
PACKING: 'packing',
|
|
BUDGET: 'budget',
|
|
DOCUMENTS: 'documents',
|
|
VACAY: 'vacay',
|
|
ATLAS: 'atlas',
|
|
COLLAB: 'collab',
|
|
JOURNEY: 'journey',
|
|
AIRTRAIL: 'airtrail',
|
|
DAWARICH: 'dawarich',
|
|
LLM_PARSING: 'llm_parsing',
|
|
COLLECTIONS: 'collections',
|
|
ROADTRIP: 'roadtrip',
|
|
} as const;
|
|
|
|
export type AddonId = typeof ADDON_IDS[keyof typeof ADDON_IDS];
|
|
|
|
/**
|
|
* The addons that gate an MCP surface, which is what decides whether switching
|
|
* one off has to tear down the live sessions.
|
|
*
|
|
* A `when:` gate is evaluated once per session, at attach time. A client that
|
|
* connected while an addon was on therefore keeps its tools registered and
|
|
* callable after an admin switches it off — the gate never re-runs — while the
|
|
* REST half answers 404 for the same user in the same moment. Only tearing the
|
|
* sessions down closes that.
|
|
*
|
|
* Stated here rather than collected at import time, so nothing depends on which
|
|
* modules a caller happens to have loaded, and guarded by a parity test that
|
|
* reads the gates out of the source: as a hand-kept list this had already
|
|
* drifted, and airtrail and collections were missing from it.
|
|
*
|
|
* MCP itself is on the list for a different reason — it gates the whole surface
|
|
* rather than any single tool.
|
|
*/
|
|
export const MCP_GATED_ADDON_IDS: readonly AddonId[] = [
|
|
ADDON_IDS.MCP,
|
|
ADDON_IDS.AIRTRAIL,
|
|
ADDON_IDS.ATLAS,
|
|
ADDON_IDS.BUDGET,
|
|
ADDON_IDS.COLLAB,
|
|
ADDON_IDS.COLLECTIONS,
|
|
ADDON_IDS.DAWARICH,
|
|
ADDON_IDS.DOCUMENTS,
|
|
ADDON_IDS.JOURNEY,
|
|
ADDON_IDS.PACKING,
|
|
ADDON_IDS.ROADTRIP,
|
|
ADDON_IDS.VACAY,
|
|
];
|