Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions apps/mcp/src/__tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe("Plant tools", () => {
it("list_plants output has correct shape", async () => {
const { mockClient } = createMockDb();
const { data } = await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null)
Expand Down Expand Up @@ -288,7 +288,7 @@ describe("Plant tools", () => {
it("list_plants queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null)
Expand All @@ -300,7 +300,7 @@ describe("Plant tools", () => {
it("get_plant queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("*")
.eq("id", "plant-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -332,7 +332,7 @@ describe("Plant tools", () => {

// Simulate the handler logic
const { data: plant, error: plantError } = await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", "plant-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -363,7 +363,7 @@ describe("Plant tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: plant, error: checkError } = await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", "plant-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -568,7 +568,7 @@ describe("Care tools", () => {
it("list_care_schedules queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
let query = (mockClient as any)
.from("care_schedules")
.from("opensprout_care_schedules")
.select("*")
.eq("user_id", userId)
.eq("active", true)
Expand All @@ -583,7 +583,7 @@ describe("Care tools", () => {
it("list_care_logs queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
await (mockClient as any)
.from("care_logs")
.from("opensprout_care_logs")
.select("*")
.eq("user_id", userId)
.eq("plant_id", "plant-1")
Expand All @@ -597,7 +597,7 @@ describe("Care tools", () => {
it("list_task_instances queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
await (mockClient as any)
.from("task_instances")
.from("opensprout_task_instances")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null)
Expand Down Expand Up @@ -625,7 +625,7 @@ describe("Care tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: plant, error: plantError } = await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", "plant-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -655,7 +655,7 @@ describe("Care tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: plant, error: plantError } = await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", "plant-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -685,7 +685,7 @@ describe("Care tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: task, error: taskError } = await (mockClient as any)
.from("task_instances")
.from("opensprout_task_instances")
.select("id")
.eq("id", "task-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -715,7 +715,7 @@ describe("Care tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: task, error: taskError } = await (mockClient as any)
.from("task_instances")
.from("opensprout_task_instances")
.select("id")
.eq("id", "task-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -843,7 +843,7 @@ describe("Journal tools", () => {
it("list_journal_entries queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
await (mockClient as any)
.from("journal_entries")
.from("opensprout_journal_entries")
.select("*")
.eq("user_id", userId)
.eq("plant_id", "plant-1")
Expand All @@ -857,7 +857,7 @@ describe("Journal tools", () => {
it("get_journal_entry queries with .eq('user_id', userId)", async () => {
const { mockClient, mockQuery } = createMockDb();
await (mockClient as any)
.from("journal_entries")
.from("opensprout_journal_entries")
.select("*")
.eq("id", "entry-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -886,7 +886,7 @@ describe("Journal tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: plant, error: plantError } = await (mockClient as any)
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", "plant-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -916,7 +916,7 @@ describe("Journal tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: entry, error: checkError } = await (mockClient as any)
.from("journal_entries")
.from("opensprout_journal_entries")
.select("id")
.eq("id", "entry-1")
.eq("user_id", userId)
Expand Down Expand Up @@ -946,7 +946,7 @@ describe("Journal tools", () => {
(mockClient as any).from.mockReturnValue(ownershipChain);

const { data: entry, error: checkError } = await (mockClient as any)
.from("journal_entries")
.from("opensprout_journal_entries")
.select("id")
.eq("id", "entry-1")
.eq("user_id", userId)
Expand Down
4 changes: 2 additions & 2 deletions apps/mcp/src/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function authenticateToken(

// Look up the token hash
const { data: records, error: lookupError } = await (admin
.from("mcp_tokens") as any)
.from("opensprout_mcp_tokens") as any)
.select("user_id, id, revoked_at")
.eq("token_hash", tokenHash);

Expand All @@ -94,7 +94,7 @@ export async function authenticateToken(
}

// Update last_used_at
await (admin.from("mcp_tokens") as any)
await (admin.from("opensprout_mcp_tokens") as any)
.update({ last_used_at: new Date().toISOString() } as any)
.eq("id", record.id);

Expand Down
34 changes: 17 additions & 17 deletions apps/mcp/src/tools/care.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function registerCareTools(
},
async ({ plantId }) => {
let query = getClient()
.from("care_schedules")
.from("opensprout_care_schedules")
.select("*")
.eq("user_id", userId)
.eq("active", true)
Expand Down Expand Up @@ -63,7 +63,7 @@ export function registerCareTools(
},
async ({ plantId, limit }) => {
const { data, error } = await getClient()
.from("care_logs")
.from("opensprout_care_logs")
.select("*")
.eq("user_id", userId)
.eq("plant_id", plantId)
Expand Down Expand Up @@ -95,7 +95,7 @@ export function registerCareTools(
},
async ({ plantId, status }) => {
let query = getClient()
.from("task_instances")
.from("opensprout_task_instances")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null);
Expand Down Expand Up @@ -137,7 +137,7 @@ export function registerCareTools(

// Ownership check: verify plant belongs to this user
const { data: plant, error: plantError } = await c
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", plantId)
.eq("user_id", userId)
Expand All @@ -146,7 +146,7 @@ export function registerCareTools(
if (plantError || !plant) throw new Error("Plant not found or access denied");

const { data: log, error: logError } = await c
.from("care_logs")
.from("opensprout_care_logs")
.insert({
plant_id: plantId,
user_id: userId,
Expand All @@ -161,7 +161,7 @@ export function registerCareTools(

if (taskInstanceId) {
await c
.from("task_instances")
.from("opensprout_task_instances")
.update({
status: "done",
completed_at: new Date().toISOString(),
Expand All @@ -188,7 +188,7 @@ export function registerCareTools(
const c = getClient() as any;

const { data: tasks, error: taskError } = await c
.from("task_instances")
.from("opensprout_task_instances")
.select("*")
.eq("id", taskId)
.eq("user_id", userId)
Expand All @@ -203,7 +203,7 @@ export function registerCareTools(
const now = new Date().toISOString();

const { data: log, error: logError } = await c
.from("care_logs")
.from("opensprout_care_logs")
.insert({
plant_id: task.plant_id,
user_id: userId,
Expand All @@ -217,7 +217,7 @@ export function registerCareTools(
if (logError) throw new Error("Failed to create care log for task completion: " + logError.message);

await c
.from("task_instances")
.from("opensprout_task_instances")
.update({
status: "done",
completed_at: now,
Expand Down Expand Up @@ -258,7 +258,7 @@ export function registerCareTools(

// Verify plant ownership
const { data: plant, error: plantError } = await c
.from("plants")
.from("opensprout_plants")
.select("id")
.eq("id", plantId)
.eq("user_id", userId)
Expand All @@ -270,7 +270,7 @@ export function registerCareTools(
}

const { data, error } = await c
.from("care_schedules")
.from("opensprout_care_schedules")
.insert({
plant_id: plantId,
user_id: userId,
Expand Down Expand Up @@ -306,7 +306,7 @@ export function registerCareTools(

// Ownership check
const { data: task, error: taskError } = await c
.from("task_instances")
.from("opensprout_task_instances")
.select("id")
.eq("id", taskId)
.eq("user_id", userId)
Expand All @@ -318,7 +318,7 @@ export function registerCareTools(
}

const { error } = await c
.from("task_instances")
.from("opensprout_task_instances")
.update({
status: "skipped",
skipped_at: new Date().toISOString(),
Expand Down Expand Up @@ -351,8 +351,8 @@ export function registerCareTools(
async ({ days }) => {
const futureDate = new Date(Date.now() + days * 86400000).toISOString();
const { data, error } = await getClient()
.from("task_instances")
.select("*, plants!inner(name, location)")
.from("opensprout_task_instances")
.select("*, opensprout_plants!inner(name, location)")
.eq("user_id", userId)
.eq("status", "pending")
.is("deleted_at", null)
Expand Down Expand Up @@ -381,7 +381,7 @@ export function registerCareTools(

// Ownership check
const { data: task, error: taskError } = await c
.from("task_instances")
.from("opensprout_task_instances")
.select("id")
.eq("id", taskId)
.eq("user_id", userId)
Expand All @@ -393,7 +393,7 @@ export function registerCareTools(
}

const { error } = await c
.from("task_instances")
.from("opensprout_task_instances")
.update({
status: "snoozed",
snoozed_until: until,
Expand Down
10 changes: 5 additions & 5 deletions apps/mcp/src/tools/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ export function registerExportTools(
const [plants, careSchedules, careLogs, taskInstances, journalEntries] =
await Promise.all([
c
.from("plants")
.from("opensprout_plants")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null),
c
.from("care_schedules")
.from("opensprout_care_schedules")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null),
c
.from("care_logs")
.from("opensprout_care_logs")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null),
c
.from("task_instances")
.from("opensprout_task_instances")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null),
c
.from("journal_entries")
.from("opensprout_journal_entries")
.select("*")
.eq("user_id", userId)
.is("deleted_at", null),
Expand Down
Loading
Loading