* move types to types file * Create salesforce routing form components * Save salesforce data to routing form * Fixes * Add event type service * Change commenting * Pass data from routing form to CRM * Init Salesforce routing form booking form handler * Salesforce find user associated with lookup field * Add looking up the contact owner * If salesforce is disabled then don't change the Salesforce option * Small refactor * Refactor getting event type app metadata * Refactor eventType service * Type fix * Clean up * Add translations Co-authored-by: Alex van Andel <emrysal@users.noreply.github.com> --------- Co-authored-by: Alex van Andel <emrysal@users.noreply.github.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { prisma } from "@calcom/prisma";
|
|
import { safeCredentialSelect } from "@calcom/prisma/selects/credential";
|
|
|
|
type CredentialCreateInput = {
|
|
type: string;
|
|
key: any;
|
|
userId: number;
|
|
appId: string;
|
|
};
|
|
|
|
export class CredentialRepository {
|
|
static async create(data: CredentialCreateInput) {
|
|
return await prisma.credential.create({ data: { ...data } });
|
|
}
|
|
|
|
/**
|
|
* Doesn't retrieve key field as that has credentials
|
|
*/
|
|
static async findFirstByIdWithUser({ id }: { id: number }) {
|
|
return await prisma.credential.findFirst({ where: { id }, select: safeCredentialSelect });
|
|
}
|
|
|
|
/**
|
|
* Includes 'key' field which is sensitive data.
|
|
*/
|
|
static async findFirstByIdWithKeyAndUser({ id }: { id: number }) {
|
|
return await prisma.credential.findFirst({
|
|
where: { id },
|
|
select: { ...safeCredentialSelect, key: true },
|
|
});
|
|
}
|
|
|
|
static async findFirstByUserIdAndType({ userId, type }: { userId: number; type: string }) {
|
|
return await prisma.credential.findFirst({ where: { userId, type } });
|
|
}
|
|
|
|
static async deleteById({ id }: { id: number }) {
|
|
await prisma.credential.delete({ where: { id } });
|
|
}
|
|
}
|