-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
95 additions
and
217 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { createClient } from "@supabase/supabase-js"; | ||
import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from "$env/static/public"; | ||
|
||
import type { Database } from "$lib/supabase.types"; | ||
import type { Database } from "$lib/types/supabase"; | ||
|
||
export const supabase = createClient<Database>(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
apps/aitino/src/lib/loads.ts → apps/aitino/src/lib/types/loads.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
// Contains types for +page.server.ts files data properties | ||
|
||
import * as models from "./models"; | ||
import * as models from "$lib/types/models"; | ||
|
||
export type SessionLoad = { | ||
maeveId: string | null; | ||
sessionId: string | null; | ||
messages: models.Message[]; | ||
reply: string; | ||
}; | ||
|
||
export type MaeveLoad = { | ||
maeve: models.Maeve; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { Edge, Node } from "@xyflow/svelte"; | ||
|
||
export type Message = { | ||
id: string; | ||
session_id: string; | ||
recipient: string; | ||
content: string; | ||
role: string; | ||
name: string; | ||
created_at: string; | ||
}; | ||
|
||
export type Maeve = { | ||
id: string; | ||
profile_id: string; | ||
reciever_id: string; | ||
title: string; | ||
description: string; | ||
nodes: Node[]; | ||
edges: Edge[]; | ||
created_at: string; | ||
}; | ||
|
||
export type Session = { | ||
id: string; | ||
maeve_id: string; | ||
user_id: string; | ||
created_at: string; | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,28 @@ | ||
import type { Edge, Node } from "@xyflow/svelte"; | ||
|
||
import * as db from "$lib/server/db"; | ||
import { getNodesCount } from "$lib/utils.js"; | ||
import type { MaeveLoad } from "$lib/types/loads"; | ||
import { error } from "@sveltejs/kit"; | ||
|
||
export const load = async ({ locals: { userId } }) => { | ||
const { data, error: err } = await db.getMaeve(userId); | ||
if (err) { | ||
throw error(500, "Failed attempt at retrieving maeve. Please reload the page."); | ||
} | ||
|
||
if (data.length === 0) { | ||
return { | ||
user_id: userId, | ||
title: "Untitled maeve", | ||
description: "No description", | ||
const data: MaeveLoad = { | ||
maeve: { | ||
id: "", | ||
profile_id: userId, | ||
reciever_id: "", | ||
title: "", | ||
description: "", | ||
nodes: [], | ||
edges: [], | ||
count: { | ||
agents: 0, | ||
prompts: 0 | ||
} | ||
}; | ||
} | ||
created_at: "" | ||
} | ||
}; | ||
|
||
const nodes = data[0].nodes as Node[]; | ||
const maeves = await db.getMaeves(userId); | ||
|
||
return { | ||
...data[0], | ||
nodes, | ||
edges: data[0].edges as Edge[], | ||
count: getNodesCount(nodes) | ||
}; | ||
if (maeves.length !== 0) { | ||
data.maeve = maeves[0]; | ||
} | ||
|
||
return data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import * as db from "$lib/server/db"; | ||
import type { SessionLoad } from "$lib/loads"; | ||
import type { SessionLoad } from "$lib/types/loads"; | ||
|
||
export const load = async () => { | ||
export const load = async ({ locals: { userId } }) => { | ||
const data: SessionLoad = { | ||
maeveId: localStorage.getItem("maeveId"), | ||
sessionId: localStorage.getItem("sessionId"), | ||
maeveId: null, | ||
sessionId: null, | ||
messages: [], | ||
reply: localStorage.getItem("currentReply") || "" | ||
reply: "" | ||
}; | ||
|
||
const maeves = await db.getMaeves(userId); | ||
if (maeves.length === 0) { | ||
return data; | ||
} | ||
data.maeveId = maeves[0].id; | ||
data.messages = await db.getMessages(data.sessionId); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pnpm dlx supabase gen types typescript --project-id "$PROJECT_REF" --schema public >src/lib/types/supabase.ts |