mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 14:21:46 +00:00
Merge branch 'dev' into feature/naver-support
This commit is contained in:
@@ -638,3 +638,93 @@ export function createTag(
|
||||
const result = db.prepare('INSERT INTO tags (user_id, name, color) VALUES (?, ?, ?)').run(userId, name, color);
|
||||
return db.prepare('SELECT * FROM tags WHERE id = ?').get(result.lastInsertRowid) as { id: number; user_id: number; name: string; color: string };
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Journeys
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
let _journeySeq = 0;
|
||||
|
||||
export interface TestJourney {
|
||||
id: number;
|
||||
user_id: number;
|
||||
title: string;
|
||||
subtitle: string | null;
|
||||
status: string;
|
||||
cover_image: string | null;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export function createJourney(
|
||||
db: Database.Database,
|
||||
userId: number,
|
||||
overrides: Partial<{ title: string; subtitle: string; status: string }> = {}
|
||||
): TestJourney {
|
||||
_journeySeq++;
|
||||
const title = overrides.title ?? `Test Journey ${_journeySeq}`;
|
||||
const now = Date.now();
|
||||
const result = db.prepare(
|
||||
'INSERT INTO journeys (user_id, title, subtitle, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)'
|
||||
).run(userId, title, overrides.subtitle ?? null, overrides.status ?? 'active', now, now);
|
||||
|
||||
const journeyId = result.lastInsertRowid as number;
|
||||
|
||||
// Auto-add owner as contributor
|
||||
db.prepare(
|
||||
"INSERT INTO journey_contributors (journey_id, user_id, role, added_at) VALUES (?, ?, 'owner', ?)"
|
||||
).run(journeyId, userId, now);
|
||||
|
||||
return db.prepare('SELECT * FROM journeys WHERE id = ?').get(journeyId) as TestJourney;
|
||||
}
|
||||
|
||||
export interface TestJourneyEntry {
|
||||
id: number;
|
||||
journey_id: number;
|
||||
author_id: number;
|
||||
type: string;
|
||||
entry_date: string;
|
||||
title: string | null;
|
||||
story: string | null;
|
||||
}
|
||||
|
||||
export function createJourneyEntry(
|
||||
db: Database.Database,
|
||||
journeyId: number,
|
||||
authorId: number,
|
||||
overrides: Partial<{ type: string; entry_date: string; title: string; story: string; location_name: string; mood: string; weather: string }> = {}
|
||||
): TestJourneyEntry {
|
||||
const now = Date.now();
|
||||
const result = db.prepare(`
|
||||
INSERT INTO journey_entries (journey_id, author_id, type, entry_date, title, story, location_name, mood, weather, visibility, sort_order, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'private', 0, ?, ?)
|
||||
`).run(
|
||||
journeyId, authorId,
|
||||
overrides.type ?? 'entry',
|
||||
overrides.entry_date ?? '2026-01-15',
|
||||
overrides.title ?? null,
|
||||
overrides.story ?? null,
|
||||
overrides.location_name ?? null,
|
||||
overrides.mood ?? null,
|
||||
overrides.weather ?? null,
|
||||
now, now
|
||||
);
|
||||
return db.prepare('SELECT * FROM journey_entries WHERE id = ?').get(result.lastInsertRowid) as TestJourneyEntry;
|
||||
}
|
||||
|
||||
export function addJourneyContributor(
|
||||
db: Database.Database,
|
||||
journeyId: number,
|
||||
userId: number,
|
||||
role: 'editor' | 'viewer' = 'editor'
|
||||
): void {
|
||||
db.prepare(
|
||||
'INSERT OR IGNORE INTO journey_contributors (journey_id, user_id, role, added_at) VALUES (?, ?, ?, ?)'
|
||||
).run(journeyId, userId, role, Date.now());
|
||||
}
|
||||
|
||||
export function linkTripToJourney(db: Database.Database, journeyId: number, tripId: number): void {
|
||||
db.prepare(
|
||||
'INSERT OR IGNORE INTO journey_trips (journey_id, trip_id, linked_at) VALUES (?, ?, ?)'
|
||||
).run(journeyId, tripId, Date.now());
|
||||
}
|
||||
|
||||
@@ -28,15 +28,19 @@ export interface McpHarnessOptions {
|
||||
withResources?: boolean;
|
||||
/** Register read-write tools (default: true) */
|
||||
withTools?: boolean;
|
||||
/** OAuth scopes to restrict tools; null = full access (default: null) */
|
||||
scopes?: string[] | null;
|
||||
/** Whether the session is authenticated via a static API token (default: false) */
|
||||
isStaticToken?: boolean;
|
||||
}
|
||||
|
||||
export async function createMcpHarness(options: McpHarnessOptions): Promise<McpHarness> {
|
||||
const { userId, withResources = true, withTools = true } = options;
|
||||
const { userId, withResources = true, withTools = true, scopes = null, isStaticToken = false } = options;
|
||||
|
||||
const server = new McpServer({ name: 'trek-test', version: '1.0.0' });
|
||||
|
||||
if (withResources) registerResources(server, userId);
|
||||
if (withTools) registerTools(server, userId);
|
||||
if (withTools) registerTools(server, userId, scopes ?? null, isStaticToken);
|
||||
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
@@ -67,6 +67,13 @@ const RESET_TABLES = [
|
||||
'share_tokens',
|
||||
'trip_members',
|
||||
'trips',
|
||||
// Journey
|
||||
'journey_share_tokens',
|
||||
'journey_photos',
|
||||
'journey_entries',
|
||||
'journey_contributors',
|
||||
'journey_trips',
|
||||
'journeys',
|
||||
// Vacay
|
||||
'vacay_entries',
|
||||
'vacay_company_holidays',
|
||||
|
||||
Reference in New Issue
Block a user