mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 21:33:19 +00:00
910c98b971
PLUGIN_DATA binds the plugin data backend to the engine (the same
{ sqlite, postgres }[engine.id] binding the backup port uses): the SQLite
file per plugin, unchanged, or the Postgres schema per plugin. The host
opens a plugin's store through it and an uninstall that deletes data erases
through it, which drops the schema on Postgres. Nothing outside db/engine
asks which engine runs.
A plugin's SQL is passed through as written, so a plugin needs to know the
dialect: db.engine (db:own) answers 'sqlite' or 'postgres', and the SDK
exposes it as ctx.db.engine(), in the mock host (dbEngine option) and in
dev. The plugin facts are regenerated and the SDK goes to 1.10.0.
The Postgres lane's PGPLUG suite installs, uses and erases plugin data on
Postgres and shows that a plugin reaches neither TREK's users table nor
another plugin's schema.
1128 lines
27 KiB
TypeScript
1128 lines
27 KiB
TypeScript
// GENERATED — do not edit by hand.
|
|
// Source: server/src/nest/plugins/protocol/envelope.ts + server/src/plugin-event-sink.ts
|
|
// + server/src/nest/plugins/protocol/manifest-rules.ts
|
|
// + server/src/nest/plugins/protocol/output-contract.ts + server/src/addons.ts
|
|
// + shared/src/plugins/plugin-poi-facts.ts
|
|
// Regenerate: node --import tsx server/scripts/gen-plugin-facts.ts
|
|
|
|
export const HOOK_PERMISSION: Readonly<Record<string, string>> = {
|
|
photoProvider: 'hook:photo-provider',
|
|
calendarSource: 'hook:calendar-source',
|
|
placeDetailProvider: 'hook:place-detail-provider',
|
|
searchProvider: 'hook:search-provider',
|
|
poiCategoryProvider: 'hook:poi-category-provider',
|
|
warningProvider: 'hook:trip-warning-provider',
|
|
tableContributor: 'hook:table-contributor',
|
|
mapMarkerProvider: 'hook:map-marker-provider',
|
|
mapLayerProvider: 'hook:map-layer-provider',
|
|
routeProvider: 'hook:route-provider',
|
|
dayScheduleProvider: 'hook:day-schedule-provider',
|
|
dayTintProvider: 'hook:day-tint-provider',
|
|
pdfSectionProvider: 'hook:pdf-section-provider',
|
|
atlasLayerProvider: 'hook:atlas-layer-provider',
|
|
journalEntryProvider: 'hook:journal-entry-provider',
|
|
tripCardProvider: 'hook:trip-card-provider',
|
|
notificationChannel: 'hook:notification-channel',
|
|
mcpToolProvider: 'mcp:tools',
|
|
};
|
|
|
|
export const KNOWN_PERMISSIONS: string[] = [
|
|
'db:own',
|
|
'db:read:trips',
|
|
'db:read:users',
|
|
'db:read:costs',
|
|
'db:read:packing',
|
|
'db:write:packing',
|
|
'db:read:files',
|
|
'db:read:files:content',
|
|
'db:write:files',
|
|
'db:read:collab',
|
|
'db:write:collab',
|
|
'db:write:members',
|
|
'db:create:trips',
|
|
'db:read:journal',
|
|
'db:read:atlas',
|
|
'rates:read',
|
|
'db:read:vacay',
|
|
'db:read:daynotes',
|
|
'db:read:collections',
|
|
'db:write:collections',
|
|
'db:write:atlas',
|
|
'db:write:vacay',
|
|
'db:write:journal',
|
|
'db:read:categories',
|
|
'db:read:tags',
|
|
'db:write:tags',
|
|
'db:read:todos',
|
|
'db:write:todos',
|
|
'weather:read',
|
|
'db:write:daynotes',
|
|
'db:write:costs',
|
|
'db:write:places',
|
|
'db:write:days',
|
|
'db:write:itinerary',
|
|
'db:write:trips',
|
|
'db:write:reservations',
|
|
'db:write:accommodations',
|
|
'db:meta',
|
|
'ws:broadcast:trip',
|
|
'ws:broadcast:user',
|
|
'hook:photo-provider',
|
|
'hook:calendar-source',
|
|
'hook:place-detail-provider',
|
|
'hook:search-provider',
|
|
'hook:poi-category-provider',
|
|
'hook:trip-warning-provider',
|
|
'hook:table-contributor',
|
|
'hook:map-marker-provider',
|
|
'hook:map-layer-provider',
|
|
'hook:route-provider',
|
|
'hook:day-schedule-provider',
|
|
'hook:day-tint-provider',
|
|
'hook:pdf-section-provider',
|
|
'hook:atlas-layer-provider',
|
|
'hook:journal-entry-provider',
|
|
'hook:trip-card-provider',
|
|
'hook:notification-channel',
|
|
'hook:user-data',
|
|
'events:subscribe',
|
|
'jobs:run',
|
|
'http:outbound',
|
|
'notify:send',
|
|
'ai:invoke',
|
|
'oauth:client',
|
|
'geolocation:read',
|
|
'mcp:tools',
|
|
];
|
|
|
|
export const METHOD_PERMISSION: Readonly<Record<string, string>> = {
|
|
'db.exec': 'db:own',
|
|
'db.query': 'db:own',
|
|
'db.migrate': 'db:own',
|
|
'db.tx': 'db:own',
|
|
'db.engine': 'db:own',
|
|
'trips.getById': 'db:read:trips',
|
|
'trips.getPlaces': 'db:read:trips',
|
|
'trips.getReservations': 'db:read:trips',
|
|
'trips.getDays': 'db:read:trips',
|
|
'trips.getAccommodations': 'db:read:trips',
|
|
'trips.listMine': 'db:read:trips',
|
|
'reservations.listMine': 'db:read:trips',
|
|
'reservations.create': 'db:write:reservations',
|
|
'reservations.update': 'db:write:reservations',
|
|
'reservations.delete': 'db:write:reservations',
|
|
'accommodations.create': 'db:write:accommodations',
|
|
'accommodations.update': 'db:write:accommodations',
|
|
'accommodations.delete': 'db:write:accommodations',
|
|
'packing.list': 'db:read:packing',
|
|
'packing.create': 'db:write:packing',
|
|
'packing.update': 'db:write:packing',
|
|
'packing.delete': 'db:write:packing',
|
|
'packing.listBags': 'db:write:packing',
|
|
'packing.createBag': 'db:write:packing',
|
|
'packing.updateBag': 'db:write:packing',
|
|
'packing.deleteBag': 'db:write:packing',
|
|
'packing.setBagMembers': 'db:write:packing',
|
|
'files.list': 'db:read:files',
|
|
'files.getContent': 'db:read:files:content',
|
|
'files.create': 'db:write:files',
|
|
'files.createLink': 'db:write:files',
|
|
'files.update': 'db:write:files',
|
|
'files.softDelete': 'db:write:files',
|
|
'collab.listNotes': 'db:read:collab',
|
|
'collab.listPolls': 'db:read:collab',
|
|
'collab.listMessages': 'db:read:collab',
|
|
'collab.createNote': 'db:write:collab',
|
|
'collab.createPoll': 'db:write:collab',
|
|
'collab.votePoll': 'db:write:collab',
|
|
'collab.createMessage': 'db:write:collab',
|
|
'trips.addMember': 'db:write:members',
|
|
'trips.removeMember': 'db:write:members',
|
|
'trips.create': 'db:create:trips',
|
|
'journal.listMine': 'db:read:journal',
|
|
'journal.getEntries': 'db:read:journal',
|
|
'atlas.visited': 'db:read:atlas',
|
|
'atlas.bucketList': 'db:read:atlas',
|
|
'rates.get': 'rates:read',
|
|
'vacay.mine': 'db:read:vacay',
|
|
'daynotes.list': 'db:read:daynotes',
|
|
'daynotes.create': 'db:write:daynotes',
|
|
'daynotes.update': 'db:write:daynotes',
|
|
'daynotes.delete': 'db:write:daynotes',
|
|
'collections.listMine': 'db:read:collections',
|
|
'collections.get': 'db:read:collections',
|
|
'collections.create': 'db:write:collections',
|
|
'collections.update': 'db:write:collections',
|
|
'collections.savePlace': 'db:write:collections',
|
|
'collections.copyToTrip': 'db:write:collections',
|
|
'collections.deletePlace': 'db:write:collections',
|
|
'atlas.markCountry': 'db:write:atlas',
|
|
'atlas.unmarkCountry': 'db:write:atlas',
|
|
'atlas.markRegion': 'db:write:atlas',
|
|
'atlas.unmarkRegion': 'db:write:atlas',
|
|
'atlas.createBucketItem': 'db:write:atlas',
|
|
'atlas.deleteBucketItem': 'db:write:atlas',
|
|
'vacay.toggleEntry': 'db:write:vacay',
|
|
'vacay.toggleCompanyHoliday': 'db:write:vacay',
|
|
'journal.createEntry': 'db:write:journal',
|
|
'journal.addEntryPhoto': 'db:write:journal',
|
|
'journal.updateEntry': 'db:write:journal',
|
|
'journal.deleteEntry': 'db:write:journal',
|
|
'journal.createJourney': 'db:write:journal',
|
|
'journal.deleteJourney': 'db:write:journal',
|
|
'weather.get': 'weather:read',
|
|
'categories.list': 'db:read:categories',
|
|
'tags.list': 'db:read:tags',
|
|
'tags.create': 'db:write:tags',
|
|
'tags.update': 'db:write:tags',
|
|
'tags.delete': 'db:write:tags',
|
|
'trips.members': 'db:read:trips',
|
|
'todos.list': 'db:read:todos',
|
|
'todos.create': 'db:write:todos',
|
|
'todos.update': 'db:write:todos',
|
|
'todos.delete': 'db:write:todos',
|
|
'costs.getByTrip': 'db:read:costs',
|
|
'costs.listMine': 'db:read:costs',
|
|
'costs.create': 'db:write:costs',
|
|
'costs.update': 'db:write:costs',
|
|
'costs.delete': 'db:write:costs',
|
|
'places.create': 'db:write:places',
|
|
'places.update': 'db:write:places',
|
|
'places.delete': 'db:write:places',
|
|
'days.create': 'db:write:days',
|
|
'days.update': 'db:write:days',
|
|
'days.delete': 'db:write:days',
|
|
'itinerary.assign': 'db:write:itinerary',
|
|
'itinerary.unassign': 'db:write:itinerary',
|
|
'trips.update': 'db:write:trips',
|
|
'meta.get': 'db:meta',
|
|
'meta.set': 'db:meta',
|
|
'meta.list': 'db:meta',
|
|
'meta.delete': 'db:meta',
|
|
'users.getById': 'db:read:users',
|
|
'ws.broadcastToTrip': 'ws:broadcast:trip',
|
|
'ws.broadcastToUser': 'ws:broadcast:user',
|
|
'notify.send': 'notify:send',
|
|
'ai.complete': 'ai:invoke',
|
|
'ai.extract': 'ai:invoke',
|
|
'oauth.getToken': 'oauth:client',
|
|
'scheduler.set': 'jobs:run',
|
|
'scheduler.cancel': 'jobs:run',
|
|
};
|
|
|
|
export const KNOWN_METHODS: string[] = [
|
|
'db.exec',
|
|
'db.query',
|
|
'db.migrate',
|
|
'db.tx',
|
|
'db.engine',
|
|
'trips.getById',
|
|
'trips.getPlaces',
|
|
'trips.getReservations',
|
|
'trips.getDays',
|
|
'trips.getAccommodations',
|
|
'trips.listMine',
|
|
'reservations.listMine',
|
|
'reservations.create',
|
|
'reservations.update',
|
|
'reservations.delete',
|
|
'accommodations.create',
|
|
'accommodations.update',
|
|
'accommodations.delete',
|
|
'packing.list',
|
|
'packing.create',
|
|
'packing.update',
|
|
'packing.delete',
|
|
'packing.listBags',
|
|
'packing.createBag',
|
|
'packing.updateBag',
|
|
'packing.deleteBag',
|
|
'packing.setBagMembers',
|
|
'files.list',
|
|
'files.getContent',
|
|
'files.create',
|
|
'files.createLink',
|
|
'files.update',
|
|
'files.softDelete',
|
|
'collab.listNotes',
|
|
'collab.listPolls',
|
|
'collab.listMessages',
|
|
'collab.createNote',
|
|
'collab.createPoll',
|
|
'collab.votePoll',
|
|
'collab.createMessage',
|
|
'trips.addMember',
|
|
'trips.removeMember',
|
|
'trips.create',
|
|
'journal.listMine',
|
|
'journal.getEntries',
|
|
'atlas.visited',
|
|
'atlas.bucketList',
|
|
'rates.get',
|
|
'vacay.mine',
|
|
'daynotes.list',
|
|
'daynotes.create',
|
|
'daynotes.update',
|
|
'daynotes.delete',
|
|
'collections.listMine',
|
|
'collections.get',
|
|
'collections.create',
|
|
'collections.update',
|
|
'collections.savePlace',
|
|
'collections.copyToTrip',
|
|
'collections.deletePlace',
|
|
'atlas.markCountry',
|
|
'atlas.unmarkCountry',
|
|
'atlas.markRegion',
|
|
'atlas.unmarkRegion',
|
|
'atlas.createBucketItem',
|
|
'atlas.deleteBucketItem',
|
|
'vacay.toggleEntry',
|
|
'vacay.toggleCompanyHoliday',
|
|
'journal.createEntry',
|
|
'journal.updateEntry',
|
|
'journal.deleteEntry',
|
|
'journal.createJourney',
|
|
'journal.addEntryPhoto',
|
|
'journal.deleteJourney',
|
|
'weather.get',
|
|
'categories.list',
|
|
'tags.list',
|
|
'tags.create',
|
|
'tags.update',
|
|
'tags.delete',
|
|
'trips.members',
|
|
'todos.list',
|
|
'todos.create',
|
|
'todos.update',
|
|
'todos.delete',
|
|
'costs.getByTrip',
|
|
'costs.listMine',
|
|
'costs.create',
|
|
'costs.update',
|
|
'costs.delete',
|
|
'places.create',
|
|
'places.update',
|
|
'places.delete',
|
|
'days.create',
|
|
'days.update',
|
|
'days.delete',
|
|
'itinerary.assign',
|
|
'itinerary.unassign',
|
|
'trips.update',
|
|
'meta.get',
|
|
'meta.set',
|
|
'meta.list',
|
|
'meta.delete',
|
|
'users.getById',
|
|
'ws.broadcastToTrip',
|
|
'ws.broadcastToUser',
|
|
'notify.send',
|
|
'ai.complete',
|
|
'ai.extract',
|
|
'oauth.getToken',
|
|
'scheduler.set',
|
|
'scheduler.cancel',
|
|
];
|
|
|
|
export const USER_DATA_PERMISSION = 'hook:user-data';
|
|
export const EVENTS_PERMISSION = 'events:subscribe';
|
|
export const JOBS_PERMISSION = 'jobs:run';
|
|
export const HTTP_OUTBOUND_PREFIX = 'http:outbound:';
|
|
|
|
/**
|
|
* Core-event catalog. Delivery names are the WebSocket broadcast names,
|
|
* `<family>:<verb>` (e.g. `place:created`). A subscribed plugin receives
|
|
* `{event, tripId, entity?, entityId?, snapshot?}`; `snapshot` is delivered only
|
|
* when the plugin also holds EVENT_SNAPSHOT_GRANT[family]. Delete/reorder/bulk
|
|
* events carry no snapshot.
|
|
*/
|
|
export const EVENT_FAMILIES: readonly string[] = [
|
|
'accommodation',
|
|
'assignment',
|
|
'budget',
|
|
'day',
|
|
'dayNote',
|
|
'file',
|
|
'packing',
|
|
'place',
|
|
'reservation',
|
|
'trip',
|
|
];
|
|
|
|
export const EVENT_SNAPSHOT_GRANT: Readonly<Record<string, string>> = {
|
|
place: 'db:read:trips',
|
|
day: 'db:read:trips',
|
|
reservation: 'db:read:trips',
|
|
accommodation: 'db:read:trips',
|
|
assignment: 'db:read:trips',
|
|
trip: 'db:read:trips',
|
|
budget: 'db:read:costs',
|
|
packing: 'db:read:packing',
|
|
dayNote: 'db:read:daynotes',
|
|
file: 'db:read:files',
|
|
};
|
|
|
|
/**
|
|
* `capabilities.poiCategories` (#1781): the lucide icons a category may use, how many
|
|
* categories one plugin may declare, and the longest label.
|
|
*/
|
|
export const POI_CATEGORY_ICONS: string[] = [
|
|
'Footprints',
|
|
'Mountain',
|
|
'MountainSnow',
|
|
'Signpost',
|
|
'Trees',
|
|
'TentTree',
|
|
'Tent',
|
|
'Accessibility',
|
|
'Droplet',
|
|
'Droplets',
|
|
'PlugZap',
|
|
'Zap',
|
|
'Bath',
|
|
'Bike',
|
|
'Waves',
|
|
'Landmark',
|
|
'MapPin',
|
|
'Star',
|
|
'Heart',
|
|
'Info',
|
|
];
|
|
|
|
export const POI_CATEGORY_MAX = 4;
|
|
export const POI_CATEGORY_LABEL_MAX = 40;
|
|
|
|
/**
|
|
* The addon ids a manifest's `requiredAddons` may name: TREK's ADDON_IDS.
|
|
*/
|
|
export const KNOWN_ADDONS: string[] = [
|
|
'mcp',
|
|
'packing',
|
|
'budget',
|
|
'documents',
|
|
'vacay',
|
|
'atlas',
|
|
'collab',
|
|
'journey',
|
|
'airtrail',
|
|
'dawarich',
|
|
'llm_parsing',
|
|
'collections',
|
|
'roadtrip',
|
|
'tours',
|
|
'ai_assistant',
|
|
];
|
|
|
|
/**
|
|
* The fields each entity result carries, and nothing else: the row's published
|
|
* columns, then the keys the host adds (joined names, counts, hydrated children).
|
|
* A column TREK adds later is not delivered until it is listed here. A literal,
|
|
* unlike the wide tables above, because it is new (nothing published depends on a
|
|
* wider type) and the SDK's entity interfaces are type-checked against it.
|
|
*/
|
|
export const PLUGIN_ENTITY_FIELDS = {
|
|
trip: [
|
|
'id',
|
|
'user_id',
|
|
'title',
|
|
'description',
|
|
'start_date',
|
|
'end_date',
|
|
'currency',
|
|
'cover_image',
|
|
'is_archived',
|
|
'reminder_days',
|
|
'created_at',
|
|
'updated_at',
|
|
'reminder_sent_for',
|
|
'costs_mode',
|
|
'day_count',
|
|
'place_count',
|
|
'is_owner',
|
|
'owner_username',
|
|
'shared_count',
|
|
],
|
|
place: [
|
|
'id',
|
|
'trip_id',
|
|
'name',
|
|
'description',
|
|
'lat',
|
|
'lng',
|
|
'address',
|
|
'category_id',
|
|
'price',
|
|
'currency',
|
|
'reservation_status',
|
|
'reservation_notes',
|
|
'reservation_datetime',
|
|
'place_time',
|
|
'end_time',
|
|
'duration_minutes',
|
|
'notes',
|
|
'image_url',
|
|
'google_place_id',
|
|
'google_ftid',
|
|
'website',
|
|
'phone',
|
|
'transport_mode',
|
|
'created_at',
|
|
'updated_at',
|
|
'osm_id',
|
|
'route_geometry',
|
|
'route_color',
|
|
'stop_type',
|
|
'fill_percent',
|
|
'amap_poi_id',
|
|
'source',
|
|
'email',
|
|
'opening_hours',
|
|
'category_name',
|
|
'category_color',
|
|
'category_icon',
|
|
'tour_place_id',
|
|
'category',
|
|
'tags',
|
|
'ratings',
|
|
'rating_avg',
|
|
'rating_count',
|
|
],
|
|
day: [
|
|
'id',
|
|
'trip_id',
|
|
'day_number',
|
|
'date',
|
|
'notes',
|
|
'title',
|
|
'default_transport_mode',
|
|
'assignments',
|
|
'notes_items',
|
|
],
|
|
reservation: [
|
|
'id',
|
|
'trip_id',
|
|
'day_id',
|
|
'end_day_id',
|
|
'place_id',
|
|
'assignment_id',
|
|
'title',
|
|
'accommodation_id',
|
|
'reservation_time',
|
|
'reservation_end_time',
|
|
'location',
|
|
'confirmation_number',
|
|
'notes',
|
|
'status',
|
|
'type',
|
|
'created_at',
|
|
'metadata',
|
|
'day_plan_position',
|
|
'needs_review',
|
|
'external_source',
|
|
'external_id',
|
|
'external_owner_user_id',
|
|
'external_synced_at',
|
|
'sync_enabled',
|
|
'external_hash',
|
|
'url',
|
|
'ingest_state',
|
|
'day_number',
|
|
'place_name',
|
|
'accommodation_place_id',
|
|
'accommodation_name',
|
|
'accommodation_start_day_id',
|
|
'accommodation_end_day_id',
|
|
'accommodation_check_in',
|
|
'accommodation_check_in_end',
|
|
'accommodation_check_out',
|
|
'day_positions',
|
|
'endpoints',
|
|
'travelers',
|
|
],
|
|
packingItem: [
|
|
'id',
|
|
'trip_id',
|
|
'name',
|
|
'checked',
|
|
'category',
|
|
'sort_order',
|
|
'created_at',
|
|
'weight_grams',
|
|
'bag_id',
|
|
'quantity',
|
|
'updated_at',
|
|
'is_private',
|
|
'owner_id',
|
|
'packed_quantity',
|
|
'owner_username',
|
|
'recipients',
|
|
'contributors',
|
|
],
|
|
tripFile: [
|
|
'id',
|
|
'trip_id',
|
|
'place_id',
|
|
'reservation_id',
|
|
'filename',
|
|
'original_name',
|
|
'file_size',
|
|
'mime_type',
|
|
'description',
|
|
'created_at',
|
|
'note_id',
|
|
'uploaded_by',
|
|
'starred',
|
|
'deleted_at',
|
|
'message_id',
|
|
'reservation_title',
|
|
'uploaded_by_name',
|
|
'uploaded_by_avatar',
|
|
'url',
|
|
'linked_reservation_ids',
|
|
'linked_place_ids',
|
|
'linked_assignment_ids',
|
|
'linked_budget_item_ids',
|
|
],
|
|
budgetItem: [
|
|
'id',
|
|
'trip_id',
|
|
'category',
|
|
'name',
|
|
'total_price',
|
|
'persons',
|
|
'days',
|
|
'note',
|
|
'sort_order',
|
|
'created_at',
|
|
'paid_by_user_id',
|
|
'expense_date',
|
|
'reservation_id',
|
|
'currency',
|
|
'exchange_rate',
|
|
'ticket_json',
|
|
'place_id',
|
|
'members',
|
|
'payers',
|
|
'receipts',
|
|
],
|
|
assignment: [
|
|
'id',
|
|
'day_id',
|
|
'place_id',
|
|
'order_index',
|
|
'notes',
|
|
'assignment_time',
|
|
'assignment_end_time',
|
|
'end_day',
|
|
'leg_transport_mode',
|
|
'incoming_leg_transport_mode',
|
|
'route_excluded',
|
|
'accommodation_id',
|
|
'tour_stage_key',
|
|
'created_at',
|
|
'stay_minutes',
|
|
'participants',
|
|
'tour_place_id',
|
|
'tour_route_geometry',
|
|
'place',
|
|
],
|
|
user: [
|
|
'id',
|
|
'username',
|
|
'display_name',
|
|
'avatar',
|
|
],
|
|
dayNote: [
|
|
'id',
|
|
'day_id',
|
|
'trip_id',
|
|
'text',
|
|
'time',
|
|
'icon',
|
|
'sort_order',
|
|
'created_at',
|
|
'color',
|
|
],
|
|
reservationEndpoint: [
|
|
'id',
|
|
'reservation_id',
|
|
'role',
|
|
'sequence',
|
|
'name',
|
|
'code',
|
|
'lat',
|
|
'lng',
|
|
'timezone',
|
|
'local_time',
|
|
'local_date',
|
|
'created_at',
|
|
],
|
|
tag: [
|
|
'id',
|
|
'user_id',
|
|
'name',
|
|
'color',
|
|
'created_at',
|
|
],
|
|
todo: [
|
|
'id',
|
|
'trip_id',
|
|
'name',
|
|
'checked',
|
|
'category',
|
|
'sort_order',
|
|
'due_date',
|
|
'description',
|
|
'assigned_user_id',
|
|
'priority',
|
|
'created_at',
|
|
'reminded_at',
|
|
],
|
|
accommodation: [
|
|
'id',
|
|
'trip_id',
|
|
'place_id',
|
|
'start_day_id',
|
|
'end_day_id',
|
|
'check_in',
|
|
'check_in_end',
|
|
'check_out',
|
|
'confirmation',
|
|
'notes',
|
|
'created_at',
|
|
'place_name',
|
|
'place_address',
|
|
'place_image',
|
|
'place_lat',
|
|
'place_lng',
|
|
'reservation_title',
|
|
],
|
|
packingBag: [
|
|
'id',
|
|
'trip_id',
|
|
'name',
|
|
'color',
|
|
'weight_limit_grams',
|
|
'sort_order',
|
|
'created_at',
|
|
'user_id',
|
|
'assigned_username',
|
|
'members',
|
|
'total_weight_grams',
|
|
],
|
|
fileLink: [
|
|
'id',
|
|
'file_id',
|
|
'reservation_id',
|
|
'assignment_id',
|
|
'place_id',
|
|
'created_at',
|
|
'budget_item_id',
|
|
],
|
|
collabNote: [
|
|
'id',
|
|
'trip_id',
|
|
'user_id',
|
|
'category',
|
|
'title',
|
|
'content',
|
|
'color',
|
|
'pinned',
|
|
'created_at',
|
|
'updated_at',
|
|
'website',
|
|
'username',
|
|
'avatar',
|
|
'avatar_url',
|
|
'attachments',
|
|
],
|
|
collabPoll: [
|
|
'id',
|
|
'trip_id',
|
|
'user_id',
|
|
'question',
|
|
'options',
|
|
'multiple',
|
|
'closed',
|
|
'deadline',
|
|
'created_at',
|
|
'username',
|
|
'avatar',
|
|
'avatar_url',
|
|
'is_closed',
|
|
'multiple_choice',
|
|
],
|
|
collabMessage: [
|
|
'id',
|
|
'trip_id',
|
|
'user_id',
|
|
'text',
|
|
'reply_to',
|
|
'created_at',
|
|
'deleted',
|
|
'username',
|
|
'avatar',
|
|
'reply_text',
|
|
'reply_username',
|
|
'user_avatar',
|
|
'avatar_url',
|
|
'reactions',
|
|
'attachments',
|
|
],
|
|
journey: [
|
|
'id',
|
|
'user_id',
|
|
'title',
|
|
'subtitle',
|
|
'cover_gradient',
|
|
'status',
|
|
'created_at',
|
|
'updated_at',
|
|
'cover_image',
|
|
'show_trip_tracks',
|
|
'show_verdict',
|
|
'show_mood',
|
|
'show_weather',
|
|
'status_override',
|
|
'photo_location',
|
|
'entry_count',
|
|
'photo_count',
|
|
'place_count',
|
|
'trip_date_min',
|
|
'trip_date_max',
|
|
],
|
|
journalEntry: [
|
|
'id',
|
|
'journey_id',
|
|
'source_trip_id',
|
|
'source_place_id',
|
|
'author_id',
|
|
'type',
|
|
'title',
|
|
'story',
|
|
'entry_date',
|
|
'entry_time',
|
|
'location_name',
|
|
'location_lat',
|
|
'location_lng',
|
|
'mood',
|
|
'weather',
|
|
'tags',
|
|
'visibility',
|
|
'sort_order',
|
|
'created_at',
|
|
'updated_at',
|
|
'pros_cons',
|
|
'stats_excluded',
|
|
'dismissed',
|
|
'country_code',
|
|
'source_assignment_id',
|
|
'is_draft',
|
|
'photos',
|
|
'source_trip_name',
|
|
],
|
|
category: [
|
|
'id',
|
|
'name',
|
|
'color',
|
|
'icon',
|
|
'user_id',
|
|
'created_at',
|
|
],
|
|
bucketItem: [
|
|
'id',
|
|
'user_id',
|
|
'name',
|
|
'lat',
|
|
'lng',
|
|
'country_code',
|
|
'notes',
|
|
'created_at',
|
|
'target_date',
|
|
'visited_at',
|
|
'visited_source',
|
|
'region_code',
|
|
],
|
|
collection: [
|
|
'id',
|
|
'owner_id',
|
|
'name',
|
|
'description',
|
|
'color',
|
|
'icon',
|
|
'cover_image',
|
|
'links',
|
|
'sort_order',
|
|
'created_at',
|
|
'updated_at',
|
|
'place_count',
|
|
'members',
|
|
'is_owner',
|
|
'labels',
|
|
],
|
|
collectionListing: [
|
|
'collections',
|
|
'incomingInvites',
|
|
],
|
|
collectionDetail: [
|
|
'collection',
|
|
'places',
|
|
],
|
|
vacayPlan: [
|
|
'id',
|
|
'owner_id',
|
|
'block_weekends',
|
|
'holidays_enabled',
|
|
'holidays_region',
|
|
'school_holidays_enabled',
|
|
'company_holidays_enabled',
|
|
'carry_over_enabled',
|
|
'created_at',
|
|
'weekend_days',
|
|
'week_start',
|
|
'holiday_calendars',
|
|
],
|
|
vacayHolidayCalendar: [
|
|
'id',
|
|
'plan_id',
|
|
'type',
|
|
'region',
|
|
'label',
|
|
'color',
|
|
'sort_order',
|
|
],
|
|
vacayPlanData: [
|
|
'plan',
|
|
'users',
|
|
'pendingInvites',
|
|
'incomingInvites',
|
|
'isOwner',
|
|
'isFused',
|
|
],
|
|
} as const;
|
|
|
|
/**
|
|
* The fields of an entity that hold rows of another entity (one row or a list),
|
|
* and which one. Those rows carry that entity's PLUGIN_ENTITY_FIELDS and no others,
|
|
* however deep they sit, so a column TREK adds to a child table is held back the
|
|
* same way. A field not listed here holds a value TREK builds field by field.
|
|
*/
|
|
export const PLUGIN_ENTITY_NESTED: Readonly<Record<string, Readonly<Record<string, string>>>> = {
|
|
place: { tags: 'tag' },
|
|
day: { assignments: 'assignment', notes_items: 'dayNote' },
|
|
reservation: { endpoints: 'reservationEndpoint' },
|
|
collectionListing: { collections: 'collection' },
|
|
collectionDetail: { collection: 'collection' },
|
|
vacayPlan: { holiday_calendars: 'vacayHolidayCalendar' },
|
|
vacayPlanData: { plan: 'vacayPlan' },
|
|
};
|
|
|
|
/**
|
|
* What each ctx method returns: an entity from PLUGIN_ENTITY_FIELDS (`trip`, or
|
|
* `trip[]` for a list), `host` for a value the host builds itself or data the
|
|
* plugin owns, or `readModel` for a domain read model passed on as the app's own
|
|
* REST route returns it.
|
|
*/
|
|
export const PLUGIN_METHOD_RESULT: Readonly<Record<string, string>> = {
|
|
'db.exec': 'host',
|
|
'db.query': 'host',
|
|
'db.migrate': 'host',
|
|
'db.tx': 'host',
|
|
'db.engine': 'host',
|
|
'trips.getById': 'trip',
|
|
'trips.getPlaces': 'place[]',
|
|
'trips.getReservations': 'reservation[]',
|
|
'trips.getDays': 'day[]',
|
|
'trips.getAccommodations': 'accommodation[]',
|
|
'trips.listMine': 'trip[]',
|
|
'reservations.listMine': 'reservation[]',
|
|
'reservations.create': 'reservation',
|
|
'reservations.update': 'reservation',
|
|
'reservations.delete': 'host',
|
|
'accommodations.create': 'accommodation',
|
|
'accommodations.update': 'accommodation',
|
|
'accommodations.delete': 'host',
|
|
'packing.list': 'packingItem[]',
|
|
'packing.create': 'packingItem',
|
|
'packing.update': 'packingItem',
|
|
'packing.delete': 'host',
|
|
'packing.listBags': 'packingBag[]',
|
|
'packing.createBag': 'packingBag',
|
|
'packing.updateBag': 'packingBag',
|
|
'packing.deleteBag': 'host',
|
|
'packing.setBagMembers': 'readModel',
|
|
'files.list': 'tripFile[]',
|
|
'files.getContent': 'host',
|
|
'files.create': 'tripFile',
|
|
'files.createLink': 'fileLink[]',
|
|
'files.update': 'tripFile',
|
|
'files.softDelete': 'host',
|
|
'collab.listNotes': 'collabNote[]',
|
|
'collab.listPolls': 'collabPoll[]',
|
|
'collab.listMessages': 'collabMessage[]',
|
|
'collab.createNote': 'collabNote',
|
|
'collab.createPoll': 'collabPoll',
|
|
'collab.votePoll': 'collabPoll',
|
|
'collab.createMessage': 'collabMessage',
|
|
'trips.addMember': 'host',
|
|
'trips.removeMember': 'host',
|
|
'trips.create': 'trip',
|
|
'journal.listMine': 'journey[]',
|
|
'journal.getEntries': 'journalEntry[]',
|
|
'atlas.visited': 'readModel',
|
|
'atlas.bucketList': 'bucketItem[]',
|
|
'rates.get': 'host',
|
|
'vacay.mine': 'vacayPlanData',
|
|
'daynotes.list': 'dayNote[]',
|
|
'daynotes.create': 'dayNote',
|
|
'daynotes.update': 'dayNote',
|
|
'daynotes.delete': 'host',
|
|
'collections.listMine': 'collectionListing',
|
|
'collections.get': 'collectionDetail',
|
|
'collections.create': 'collection',
|
|
'collections.update': 'collection',
|
|
'collections.savePlace': 'readModel',
|
|
'collections.copyToTrip': 'readModel',
|
|
'collections.deletePlace': 'host',
|
|
'atlas.markCountry': 'host',
|
|
'atlas.unmarkCountry': 'host',
|
|
'atlas.markRegion': 'host',
|
|
'atlas.unmarkRegion': 'host',
|
|
'atlas.createBucketItem': 'bucketItem',
|
|
'atlas.deleteBucketItem': 'host',
|
|
'vacay.toggleEntry': 'readModel',
|
|
'vacay.toggleCompanyHoliday': 'readModel',
|
|
'journal.createEntry': 'journalEntry',
|
|
'journal.addEntryPhoto': 'readModel',
|
|
'journal.updateEntry': 'journalEntry',
|
|
'journal.deleteEntry': 'host',
|
|
'journal.createJourney': 'journey',
|
|
'journal.deleteJourney': 'host',
|
|
'weather.get': 'host',
|
|
'categories.list': 'category[]',
|
|
'tags.list': 'tag[]',
|
|
'tags.create': 'tag',
|
|
'tags.update': 'tag',
|
|
'tags.delete': 'host',
|
|
'trips.members': 'user[]',
|
|
'todos.list': 'todo[]',
|
|
'todos.create': 'todo',
|
|
'todos.update': 'todo',
|
|
'todos.delete': 'host',
|
|
'costs.getByTrip': 'budgetItem[]',
|
|
'costs.listMine': 'budgetItem[]',
|
|
'costs.create': 'budgetItem',
|
|
'costs.update': 'budgetItem',
|
|
'costs.delete': 'host',
|
|
'places.create': 'place',
|
|
'places.update': 'place',
|
|
'places.delete': 'host',
|
|
'days.create': 'day',
|
|
'days.update': 'day',
|
|
'days.delete': 'host',
|
|
'itinerary.assign': 'assignment',
|
|
'itinerary.unassign': 'host',
|
|
'trips.update': 'trip',
|
|
'meta.get': 'host',
|
|
'meta.set': 'host',
|
|
'meta.list': 'host',
|
|
'meta.delete': 'host',
|
|
'users.getById': 'user',
|
|
'ws.broadcastToTrip': 'host',
|
|
'ws.broadcastToUser': 'host',
|
|
'notify.send': 'host',
|
|
'ai.complete': 'host',
|
|
'ai.extract': 'host',
|
|
'oauth.getToken': 'host',
|
|
'scheduler.set': 'host',
|
|
'scheduler.cancel': 'host',
|
|
'plugins.call': 'host',
|
|
'events.emit': 'host',
|
|
'settings.get': 'host',
|
|
};
|
|
|
|
/**
|
|
* The plugin-API version this TREK implements. A manifest's `apiVersion` must be a
|
|
* positive integer no greater than this, or the install refuses it.
|
|
*/
|
|
export const PLUGIN_API_VERSION = 1 as const;
|
|
|
|
/**
|
|
* The manifest format rules TREK's install loader enforces
|
|
* (server/src/nest/plugins/protocol/manifest-rules.ts), so `trek-plugin validate`
|
|
* refuses exactly what an install refuses.
|
|
*/
|
|
export const MANIFEST_ID_RE = /^[a-z][a-z0-9-]{2,39}$/;
|
|
export const MANIFEST_RESERVED_IDS: readonly string[] = [
|
|
'registry',
|
|
'install',
|
|
'rescan',
|
|
];
|
|
export const MANIFEST_SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
export const MANIFEST_TYPES: readonly string[] = [
|
|
'integration',
|
|
'page',
|
|
'widget',
|
|
'trip-page',
|
|
];
|
|
export const MANIFEST_ADDON_ID_RE = /^[a-z][a-z0-9_]{1,39}$/;
|
|
export const MANIFEST_HOST_RE = /^(\*\.[a-z0-9-]+(\.[a-z0-9-]+)+|[a-z0-9-]+(\.[a-z0-9-]+)*)$/i;
|
|
export const MANIFEST_WIDGET_SLOTS: readonly string[] = [
|
|
'sidebar',
|
|
'hero',
|
|
'place-detail',
|
|
'day-detail',
|
|
'reservation-detail',
|
|
];
|
|
export const MANIFEST_REPLACEABLE_TABS: readonly string[] = [
|
|
'transports',
|
|
'buchungen',
|
|
'listen',
|
|
'finanzplan',
|
|
'dateien',
|
|
'collab',
|
|
];
|
|
export const MANIFEST_TRIP_PAGE_POSITION_MAX = 50;
|
|
export const MANIFEST_ROUTE_PROFILES_MAX = 3;
|
|
export const MANIFEST_ROUTE_PROFILE_ID_RE = /^[a-z][a-z0-9-]{0,23}$/;
|
|
export const MANIFEST_CAPABILITY_NAME_RE = /^[a-zA-Z][a-zA-Z0-9._-]{0,63}$/;
|
|
export const MANIFEST_MCP_TOOLS_MAX = 8;
|
|
export const MANIFEST_TOOL_NAME_RE = /^[a-z0-9_]{1,48}$/;
|
|
export const MANIFEST_SETTING_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/;
|
|
export const MANIFEST_RESERVED_SETTING_KEYS: readonly string[] = [
|
|
'constructor',
|
|
'prototype',
|
|
'__proto__',
|
|
];
|
|
export const MANIFEST_ACTIONS_MAX = 8;
|
|
|
|
/** Every attribute a settings-field object may carry; the host silently drops anything else. */
|
|
export const SETTING_FIELD_KEYS = [
|
|
'key',
|
|
'label',
|
|
'input_type',
|
|
'placeholder',
|
|
'hint',
|
|
'required',
|
|
'secret',
|
|
'scope',
|
|
'options',
|
|
'oauth',
|
|
'default',
|
|
] as const;
|
|
|
|
/** Events a plugin notification channel may carry. Admin-scoped and in-app-only events are excluded. */
|
|
export const CHANNEL_EVENTS: string[] = [
|
|
'trip_invite',
|
|
'booking_change',
|
|
'trip_reminder',
|
|
'todo_due',
|
|
'vacay_invite',
|
|
'collection_invite',
|
|
'photos_shared',
|
|
'collab_message',
|
|
'packing_tagged',
|
|
'plugin_notification',
|
|
];
|