refactor: more database types (#17490)
This commit is contained in:
@@ -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 = () => ({
|
||||
|
||||
Reference in New Issue
Block a user