refactor: more database types (#17490)

This commit is contained in:
Jason Rasmussen
2025-04-09 10:24:38 -04:00
committed by GitHub
parent 04b03f2924
commit 8943ec23ba
12 changed files with 123 additions and 148 deletions
+12 -2
View File
@@ -8,6 +8,7 @@ import {
Library,
Memory,
Partner,
Session,
SidecarWriteAsset,
User,
UserAdmin,
@@ -31,7 +32,11 @@ export const newEmbedding = () => {
return '[' + embedding + ']';
};
const authFactory = ({ apiKey, ...user }: Partial<AuthUser> & { apiKey?: Partial<AuthApiKey> } = {}) => {
const authFactory = ({
apiKey,
session,
...user
}: Partial<AuthUser> & { apiKey?: Partial<AuthApiKey>; session?: { id: string } } = {}) => {
const auth: AuthDto = {
user: authUserFactory(user),
};
@@ -40,6 +45,10 @@ const authFactory = ({ apiKey, ...user }: Partial<AuthUser> & { apiKey?: Partial
auth.apiKey = authApiKeyFactory(apiKey);
}
if (session) {
auth.session = { id: session.id };
}
return auth;
};
@@ -76,7 +85,7 @@ const partnerFactory = (partner: Partial<Partner> = {}) => {
};
};
const sessionFactory = () => ({
const sessionFactory = (session: Partial<Session> = {}) => ({
id: newUuid(),
createdAt: newDate(),
updatedAt: newDate(),
@@ -85,6 +94,7 @@ const sessionFactory = () => ({
deviceType: 'mobile',
token: 'abc123',
userId: newUuid(),
...session,
});
const stackFactory = () => ({