Skip to content

Commit

Permalink
Fix Circular dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed Nov 6, 2023
1 parent eeac1d1 commit 4f559ab
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 147 deletions.
29 changes: 12 additions & 17 deletions lib/myaccount/emailApi.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { sendRequest } from './request';
import {
IAPIFunction,
import { IAPIFunction } from './types';
import {
BaseTransaction,
EmailTransaction,
EmailChallengeTransaction
} from './types';
} from './transactions';

/**
* @scope: okta.myAccount.email.read
Expand All @@ -13,12 +13,11 @@ export const getEmails: IAPIFunction<EmailTransaction[]> = async (
oktaAuth,
options?
) => {
const transaction = await sendRequest(oktaAuth, {
const transaction = await sendRequest<EmailTransaction, 'plural'>(oktaAuth, {
url: '/idp/myaccount/emails',
method: 'GET',
accessToken: options?.accessToken,
transactionClassName: 'EmailTransaction'
}) as EmailTransaction[];
accessToken: options?.accessToken
}, EmailTransaction);
return transaction;
};

Expand All @@ -34,8 +33,7 @@ export const getEmail: IAPIFunction<EmailTransaction> = async (
url: `/idp/myaccount/emails/${id}`,
method: 'GET',
accessToken,
transactionClassName: 'EmailTransaction'
}) as EmailTransaction;
}, EmailTransaction);
return transaction;
};

Expand All @@ -52,8 +50,7 @@ export const addEmail: IAPIFunction<EmailTransaction> = async (
method: 'POST',
payload,
accessToken,
transactionClassName: 'EmailTransaction'
}) as EmailTransaction;
}, EmailTransaction);
return transaction;
};

Expand All @@ -69,7 +66,7 @@ export const deleteEmail: IAPIFunction<BaseTransaction> = async (
url: `/idp/myaccount/emails/${id}`,
method: 'DELETE',
accessToken
}) as BaseTransaction;
});
return transaction;
};

Expand All @@ -85,8 +82,7 @@ export const sendEmailChallenge: IAPIFunction<EmailChallengeTransaction> = async
url: `/idp/myaccount/emails/${id}/challenge`,
method: 'POST',
accessToken,
transactionClassName: 'EmailChallengeTransaction'
}) as EmailChallengeTransaction;
}, EmailChallengeTransaction);
return transaction;
};

Expand All @@ -102,8 +98,7 @@ export const getEmailChallenge: IAPIFunction<EmailChallengeTransaction> = async
url: `/idp/myaccount/emails/${emailId}/challenge/${challengeId}`,
method: 'POST',
accessToken,
transactionClassName: 'EmailChallengeTransaction'
}) as EmailChallengeTransaction;
}, EmailChallengeTransaction);
return transaction;
};

Expand All @@ -120,6 +115,6 @@ export const verifyEmailChallenge: IAPIFunction<BaseTransaction> = async (
method: 'POST',
payload,
accessToken
}) as BaseTransaction;
});
return transaction;
};
17 changes: 7 additions & 10 deletions lib/myaccount/passwordApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { sendRequest } from './request';
import {
IAPIFunction,
import { IAPIFunction } from './types';
import {
BaseTransaction,
PasswordTransaction
} from './types';
} from './transactions';

/**
* @scope: okta.myAccount.password.read
Expand All @@ -16,8 +16,7 @@ export const getPassword: IAPIFunction<PasswordTransaction> = async (
url: `/idp/myaccount/password`,
method: 'GET',
accessToken: options?.accessToken,
transactionClassName: 'PasswordTransaction'
}) as PasswordTransaction;
}, PasswordTransaction);
return transaction;
};

Expand All @@ -34,8 +33,7 @@ export const enrollPassword: IAPIFunction<PasswordTransaction> = async (
method: 'POST',
payload,
accessToken,
transactionClassName: 'PasswordTransaction'
}) as PasswordTransaction;
}, PasswordTransaction);
return transaction;
};

Expand All @@ -52,8 +50,7 @@ export const updatePassword: IAPIFunction<PasswordTransaction> = async (
method: 'PUT',
payload,
accessToken,
transactionClassName: 'PasswordTransaction'
}) as PasswordTransaction;
}, PasswordTransaction);
return transaction;
};

Expand All @@ -68,6 +65,6 @@ export const deletePassword: IAPIFunction<BaseTransaction> = async (
url: `/idp/myaccount/password`,
method: 'DELETE',
accessToken: options?.accessToken,
}) as BaseTransaction;
});
return transaction;
};
23 changes: 10 additions & 13 deletions lib/myaccount/phoneApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { sendRequest } from './request';
import {
IAPIFunction,
import { IAPIFunction } from './types';
import {
BaseTransaction,
PhoneTransaction
} from './types';
} from './transactions';

/**
* @scope: okta.myAccount.phone.read
Expand All @@ -12,12 +12,11 @@ export const getPhones: IAPIFunction<PhoneTransaction[]> = async (
oktaAuth,
options?
) => {
const transaction = await sendRequest(oktaAuth, {
const transaction = await sendRequest<PhoneTransaction, 'plural'>(oktaAuth, {
url: '/idp/myaccount/phones',
method: 'GET',
accessToken: options?.accessToken,
transactionClassName: 'PhoneTransaction'
}) as PhoneTransaction[];
}, PhoneTransaction);
return transaction;
};

Expand All @@ -33,8 +32,7 @@ export const getPhone: IAPIFunction<PhoneTransaction> = async (
url: `/idp/myaccount/phones/${id}`,
method: 'GET',
accessToken,
transactionClassName: 'PhoneTransaction'
}) as PhoneTransaction;
}, PhoneTransaction);
return transaction;
};

Expand All @@ -51,8 +49,7 @@ export const addPhone: IAPIFunction<PhoneTransaction> = async (
method: 'POST',
payload,
accessToken,
transactionClassName: 'PhoneTransaction'
}) as PhoneTransaction;
}, PhoneTransaction);
return transaction;
};

Expand All @@ -68,7 +65,7 @@ export const deletePhone: IAPIFunction<BaseTransaction> = async (
url: `/idp/myaccount/phones/${id}`,
method: 'DELETE',
accessToken,
}) as BaseTransaction;
});
return transaction;
};

Expand All @@ -85,7 +82,7 @@ export const sendPhoneChallenge: IAPIFunction<BaseTransaction> = async (
method: 'POST',
payload,
accessToken
}) as BaseTransaction;
});
return transaction;
};

Expand All @@ -102,6 +99,6 @@ export const verifyPhoneChallenge: IAPIFunction<BaseTransaction> = async (
method: 'POST',
payload,
accessToken
}) as BaseTransaction;
});
return transaction;
};
15 changes: 6 additions & 9 deletions lib/myaccount/profileApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { sendRequest } from './request';
import {
IAPIFunction,
import { IAPIFunction } from './types';
import {
ProfileTransaction,
ProfileSchemaTransaction
} from './types';
} from './transactions';

/**
* @scope: okta.myAccount.profile.read
Expand All @@ -13,8 +13,7 @@ export const getProfile: IAPIFunction<ProfileTransaction> = async (oktaAuth, opt
url: '/idp/myaccount/profile',
method: 'GET',
accessToken: options?.accessToken,
transactionClassName: 'ProfileTransaction'
}) as ProfileTransaction;
}, ProfileTransaction);
return transaction;
};

Expand All @@ -31,8 +30,7 @@ export const updateProfile: IAPIFunction<ProfileTransaction> = async (
method: 'PUT',
payload,
accessToken,
transactionClassName: 'ProfileTransaction'
}) as ProfileTransaction;
}, ProfileTransaction);
return transaction;
};

Expand All @@ -47,7 +45,6 @@ export const getProfileSchema: IAPIFunction<ProfileSchemaTransaction> = async (
url: '/idp/myaccount/profile/schema',
method: 'GET',
accessToken: options?.accessToken,
transactionClassName: 'ProfileSchemaTransaction'
}) as ProfileSchemaTransaction;
}, ProfileSchemaTransaction);
return transaction;
};
Loading

0 comments on commit 4f559ab

Please sign in to comment.