({
account,
user,
isPublic,
}: {
account: accounts;
user: users;
isPublic: boolean;
})
| 162 | } |
| 163 | |
| 164 | export async function createUserKeyAndPersist({ |
| 165 | account, |
| 166 | user, |
| 167 | isPublic, |
| 168 | }: { |
| 169 | account: accounts; |
| 170 | user: users; |
| 171 | isPublic: boolean; |
| 172 | }) { |
| 173 | const key = createUserKey({ |
| 174 | keyWithSearchPermissions: env.TYPESENSE_SEARCH_ONLY, |
| 175 | accountId: account.id, |
| 176 | userId: user.id, |
| 177 | }); |
| 178 | const settings: SerializedSearchSettings = { |
| 179 | apiKey: key.value, |
| 180 | apiKeyExpiresAt: key.expires_at, |
| 181 | engine: 'typesense', |
| 182 | scope: isPublic ? 'public' : 'private', |
| 183 | }; |
| 184 | await prisma.users.update({ |
| 185 | where: { |
| 186 | id: user.id, |
| 187 | }, |
| 188 | data: { |
| 189 | searchSettings: JSON.stringify(settings), |
| 190 | }, |
| 191 | }); |
| 192 | } |
| 193 | |
| 194 | export async function createAccountKeyAndPersist({ |
| 195 | account, |
no test coverage detected