(req: Request, res: Response)
| 101 | } |
| 102 | |
| 103 | private async triggerAccountPermissionSync(req: Request, res: Response) { |
| 104 | if (env.PERMISSION_SYNC_ENABLED !== 'true' || !await hasEntitlement('permission-syncing')) { |
| 105 | res.status(403).json({ error: 'Permission syncing is not enabled.' }); |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | const schema = z.object({ |
| 110 | accountId: z.string(), |
| 111 | }).strict(); |
| 112 | |
| 113 | const parsed = schema.safeParse(req.body); |
| 114 | if (!parsed.success) { |
| 115 | res.status(400).json({ error: parsed.error.message }); |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | const { accountId } = parsed.data; |
| 120 | const account = await this.prisma.account.findUnique({ |
| 121 | where: { id: accountId }, |
| 122 | }); |
| 123 | |
| 124 | if (!account) { |
| 125 | res.status(404).json({ error: 'Account not found' }); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | if (!doesIdpSupportPermissionSyncing(account.providerType)) { |
| 130 | res.status(400).json({ error: `Provider '${account.providerType}' does not support permission syncing.` }); |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | const jobId = await this.accountPermissionSyncer.schedulePermissionSyncForAccount(account); |
| 135 | res.status(200).json({ jobId }); |
| 136 | } |
| 137 | |
| 138 | private async experimental_addGithubRepo(req: Request, res: Response) { |
| 139 | const schema = z.object({ |
nothing calls this directly
no test coverage detected