# Introduction Avoid having multiple `isDefined` definition across our pacakges Also avoid importing `isDefined` from `twenty-ui` which exposes a huge barrel for a such little util function ## In a nutshell Removed own `isDefined.ts` definition from `twenty-ui` `twenty-front` and `twenty-server` to move it to `twenty-shared`. Updated imports for each packages, and added explicit dependencies to `twenty-shared` if not already in place Related PR https://github.com/twentyhq/twenty/pull/9941
21 lines
640 B
TypeScript
21 lines
640 B
TypeScript
import { isDefined } from 'twenty-shared';
|
|
import {
|
|
ExchangeAuthCodeInput,
|
|
ExchangeAuthCodeResponse,
|
|
Tokens,
|
|
} from '~/db/types/auth.types';
|
|
import { EXCHANGE_AUTHORIZATION_CODE } from '~/graphql/auth/mutations';
|
|
import { callMutation } from '~/utils/requestDb';
|
|
|
|
export const exchangeAuthorizationCode = async (
|
|
exchangeAuthCodeInput: ExchangeAuthCodeInput,
|
|
): Promise<Tokens | null> => {
|
|
const data = await callMutation<ExchangeAuthCodeResponse>(
|
|
EXCHANGE_AUTHORIZATION_CODE,
|
|
exchangeAuthCodeInput,
|
|
);
|
|
if (isDefined(data?.exchangeAuthorizationCode))
|
|
return data.exchangeAuthorizationCode;
|
|
else return null;
|
|
};
|