({
account,
}: {
account: accounts;
})
| 192 | } |
| 193 | |
| 194 | export async function createAccountKeyAndPersist({ |
| 195 | account, |
| 196 | }: { |
| 197 | account: accounts; |
| 198 | }) { |
| 199 | const isPublic = account.type === 'PUBLIC'; |
| 200 | |
| 201 | const key = isPublic |
| 202 | ? createAccountKey({ |
| 203 | keyWithSearchPermissions: env.TYPESENSE_SEARCH_ONLY, |
| 204 | accountId: account.id, |
| 205 | }) |
| 206 | : undefined; |
| 207 | |
| 208 | const settings: SerializedSearchSettings = { |
| 209 | engine: 'typesense', |
| 210 | scope: isPublic ? 'public' : 'private', |
| 211 | apiKey: key?.value || 'private', |
| 212 | apiKeyExpiresAt: key?.expires_at, |
| 213 | }; |
| 214 | |
| 215 | await prisma.accounts.update({ |
| 216 | where: { |
| 217 | id: account.id, |
| 218 | }, |
| 219 | data: { |
| 220 | searchSettings: JSON.stringify(settings), |
| 221 | }, |
| 222 | }); |
| 223 | } |
no test coverage detected