Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: convert lib/sandboxes and sandboxSync to TS #1328

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

camden11
Copy link
Contributor

@camden11 camden11 commented Jan 10, 2025

Description and Context

This converts lib/sandboxes and lib/sandboxSync to TS

Who to Notify

@brandenrodgers @kemmerle @joe-yeager

@camden11 camden11 marked this pull request as ready for review January 10, 2025 16:58
lib/sandboxes.ts Outdated
Comment on lines 309 to 310
'error' in err &&
err.error instanceof Error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this if statement might be unreachable code. if the isSpecifiedError is true, it is a HubSpotHttpError which doesn't have a error member on it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I wasn't sure if we always knew the shape of HubSpotHttpErrors

@camden11 camden11 changed the title Convert lib/sandboxes and sandboxSync to TS Chore: convert lib/sandboxes and sandboxSync to TS Jan 10, 2025
* @param {Boolean} skipPrompt - Option to skip contact records prompt and return all available sync tasks
* @returns {Array} Adjusted available sync task items
*/
const getSyncTypesWithContactRecordsPrompt = async (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function wasn't being used anywhere

accountName: name,
parentAccountName: uiAccountDescription(accountId),
accountId,
})
);
logger.log('');
} else if (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell, all this code was unreachable. These cases were being handled ahead of time in validateSandboxUsageLimits

joe-yeager
joe-yeager previously approved these changes Jan 10, 2025
: typePrompt.type;

// Check usage limits and exit if parent portal has no available sandboxes for the selected type
try {
console.log('validate usage limit');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover debugging log

lib/sandboxes.ts Outdated
const id = getAccountIdentifier(accountConfig);
const accountId = getAccountId(id);

if (!accountId) {
throw new Error(`${i18nKey}.create.failure.usageLimitFetch`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log needs the i18n() function

lib/sandboxes.ts Outdated
const {
data: { usage },
} = await getSandboxUsageLimits(accountId);
if (!usage) {
throw new Error('Unable to fetch sandbox usage limits. Please try again.');
throw new Error(`${i18nKey}.create.failure.usageLimitFetch`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with i18n()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh good catch on these!

Copy link
Contributor

@brandenrodgers brandenrodgers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and everything lgtm 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants