refactor: use factory and kysely types for partner repository (#16812)

This commit is contained in:
Jason Rasmussen
2025-03-11 16:29:56 -04:00
committed by GitHub
parent 83ed03920e
commit 16fd19994b
11 changed files with 207 additions and 112 deletions
+19 -1
View File
@@ -1,5 +1,5 @@
import { randomUUID } from 'node:crypto';
import { ApiKey, Asset, AuthApiKey, AuthUser, Library, User } from 'src/database';
import { ApiKey, Asset, AuthApiKey, AuthUser, Library, Partner, User } from 'src/database';
import { AuthDto } from 'src/dtos/auth.dto';
import { OnThisDayData } from 'src/entities/memory.entity';
import { AssetStatus, AssetType, MemoryType, Permission } from 'src/enum';
@@ -42,6 +42,23 @@ const authUserFactory = (authUser: Partial<AuthUser> = {}) => ({
...authUser,
});
const partnerFactory = (partner: Partial<Partner> = {}) => {
const sharedBy = userFactory(partner.sharedBy || {});
const sharedWith = userFactory(partner.sharedWith || {});
return {
sharedById: sharedBy.id,
sharedBy,
sharedWithId: sharedWith.id,
sharedWith,
createdAt: newDate(),
updatedAt: newDate(),
updateId: newUpdateId(),
inTimeline: true,
...partner,
};
};
const sessionFactory = () => ({
id: newUuid(),
createdAt: newDate(),
@@ -177,6 +194,7 @@ export const factory = {
authUser: authUserFactory,
library: libraryFactory,
memory: memoryFactory,
partner: partnerFactory,
session: sessionFactory,
stack: stackFactory,
user: userFactory,