import { ConnectedServiceCredentialRecordV1Schema, } from './connectedServiceSchemas.js';
export function buildConnectedServiceCredentialRecord(params) {
    const base = {
        v: 1,
        serviceId: params.serviceId,
        profileId: params.profileId,
        createdAt: params.now,
        updatedAt: params.now,
        expiresAt: params.kind === 'oauth' ? (params.expiresAt ?? null) : null,
    };
    const record = params.kind === 'oauth'
        ? {
            ...base,
            kind: 'oauth',
            oauth: {
                accessToken: params.oauth.accessToken,
                refreshToken: params.oauth.refreshToken,
                idToken: params.oauth.idToken,
                scope: params.oauth.scope,
                tokenType: params.oauth.tokenType,
                providerAccountId: params.oauth.providerAccountId,
                providerEmail: params.oauth.providerEmail,
                raw: null,
            },
            token: null,
        }
        : {
            ...base,
            kind: 'token',
            oauth: null,
            token: {
                token: params.token.token,
                providerAccountId: params.token.providerAccountId,
                providerEmail: params.token.providerEmail,
                raw: null,
            },
        };
    return ConnectedServiceCredentialRecordV1Schema.parse(record);
}
//# sourceMappingURL=buildConnectedServiceCredentialRecord.js.map