Files
calendar/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials.ts
T
MorganandGitHub 524c0d81a7 chore: rename DWD to DelegationCredential (#19744)
* Revert "Revert "chore: rename DWD to DelegationCredential (#19703)" (#19734)"

This reverts commit 340b5ab061.

* chore: fix schema and types for now

* fix: domainWideDelegationCredentialId error type
2025-03-05 10:42:20 -03:00

26 lines
1006 B
TypeScript

import async from "async";
import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
import { buildAllCredentials } from "@calcom/lib/delegationCredential/server";
import type { CredentialForCalendarService } from "@calcom/types/Credential";
import { refreshCredential } from "./refreshCredential";
/**
* Refreshes the given set of credentials.
*
* @param credentials
*/
export async function refreshCredentials(
credentials: Array<CredentialForCalendarService>
): Promise<Array<CredentialForCalendarService>> {
const nonDelegationCredentials = credentials.filter(
(cred) => !isDelegationCredential({ credentialId: cred.id })
);
const delegationCredentials = credentials.filter((cred) =>
isDelegationCredential({ credentialId: cred.id })
);
const refreshedDbCredentials = await async.mapLimit(nonDelegationCredentials, 5, refreshCredential);
return buildAllCredentials({ delegationCredentials, existingCredentials: refreshedDbCredentials });
}