Skip to content

Migrate the CreateSalesforceContact Lambda to Typescript #7140

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

Merged
merged 8 commits into from
Jul 16, 2025

Conversation

rupertbates
Copy link
Member

@rupertbates rupertbates commented Jul 10, 2025

What are you doing in this PR?

This PR follows on from #7017 and is the next step in moving support-workers from Scala to Typescript.

This is a simpler lambda than the CreatePaymentMethod lambda and most of the schemas and model classes were already in place so this PR is smaller than previous ones.

TODO:

  • Check error handling, particularly readonly mode

Trello Card

How to test

  • Deploy this branch of support-workers to CODE
  • Run smoke tests against CODE
  • All the resulting support-workers executions should succeed

@rupertbates rupertbates force-pushed the rb/createSalesforceContact branch from 8d7f7bb to 92377c5 Compare July 10, 2025 13:32
Copy link
Contributor

github-actions bot commented Jul 10, 2025

Size Change: +15 B (0%)

Total Size: 1.53 MB

ℹ️ View Unchanged
Filename Size Change
./support-frontend/public/compiled-assets/javascripts/[countryGroupId]/events/router.js 101 kB +2 B (0%)
./support-frontend/public/compiled-assets/javascripts/[countryGroupId]/router.js 124 kB +3 B (0%)
./support-frontend/public/compiled-assets/javascripts/ausMomentMap.js 109 kB +2 B (0%)
./support-frontend/public/compiled-assets/javascripts/contributionsRedirectStyles.js 20 B 0 B
./support-frontend/public/compiled-assets/javascripts/downForMaintenancePage.js 71.6 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/error404Page.js 71.5 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/error500Page.js 71.5 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/favicons.js 618 B 0 B
./support-frontend/public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 96.9 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/payPalErrorPage.js 70.4 kB 0 B
./support-frontend/public/compiled-assets/javascripts/payPalErrorPageStyles.js 20 B 0 B
./support-frontend/public/compiled-assets/javascripts/promotionTerms.js 78 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/subscriptionsLandingPage.js 103 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/unsupportedBrowserStyles.js 20 B 0 B
./support-frontend/public/compiled-assets/javascripts/weeklySubscriptionCheckoutPage.js 162 kB +1 B (0%)
./support-frontend/public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 96.2 kB +1 B (0%)
./support-frontend/public/compiled-assets/webpack/142.js 7.75 kB 0 B
./support-frontend/public/compiled-assets/webpack/241.js 4.25 kB 0 B
./support-frontend/public/compiled-assets/webpack/249.js 34.8 kB 0 B
./support-frontend/public/compiled-assets/webpack/340.js 4.99 kB 0 B
./support-frontend/public/compiled-assets/webpack/491.js 4.36 kB 0 B
./support-frontend/public/compiled-assets/webpack/589.js 24.6 kB 0 B
./support-frontend/public/compiled-assets/webpack/655.js 3.52 kB 0 B
./support-frontend/public/compiled-assets/webpack/709.js 109 kB 0 B
./support-frontend/public/compiled-assets/webpack/747.js 3.35 kB 0 B
./support-frontend/public/compiled-assets/webpack/760.js 5.8 kB 0 B
./support-frontend/public/compiled-assets/webpack/785.js 13.1 kB 0 B
./support-frontend/public/compiled-assets/webpack/8.js 20.1 kB 0 B
./support-frontend/public/compiled-assets/webpack/801.js 2.18 kB 0 B
./support-frontend/public/compiled-assets/webpack/826.js 14.6 kB 0 B
./support-frontend/public/compiled-assets/webpack/855.js 7.13 kB 0 B
./support-frontend/public/compiled-assets/webpack/916.js 8.9 kB 0 B
./support-frontend/public/compiled-assets/webpack/checkout.js 19.7 kB 0 B
./support-frontend/public/compiled-assets/webpack/GuardianAdLiteLanding.js 8.44 kB 0 B
./support-frontend/public/compiled-assets/webpack/LandingPage.js 15.9 kB 0 B
./support-frontend/public/compiled-assets/webpack/oneTimeCheckout.js 7.38 kB 0 B
./support-frontend/public/compiled-assets/webpack/StudentLandingPage.js 12.4 kB 0 B
./support-frontend/public/compiled-assets/webpack/ThankYou.js 43.7 kB 0 B

compressed-size-action

@rupertbates rupertbates force-pushed the rb/createSalesforceContact branch from 92377c5 to 7d230d7 Compare July 10, 2025 13:36
Copy link
Contributor

github-actions bot commented Jul 10, 2025

@rupertbates rupertbates force-pushed the rb/createSalesforceContact branch from 7d230d7 to 0888a30 Compare July 10, 2025 13:57
Copy link
Contributor

github-actions bot commented Jul 10, 2025

@rupertbates rupertbates force-pushed the rb/createSalesforceContact branch 2 times, most recently from e7787e8 to 52a17e0 Compare July 11, 2025 14:29
@rupertbates rupertbates changed the title createSalesforceContactLambda Migrate the CreateSalesforceContactLambda to Typescript Jul 11, 2025
@rupertbates rupertbates force-pushed the rb/createSalesforceContact branch 2 times, most recently from 75dc2c6 to cccfd74 Compare July 14, 2025 16:16
@rupertbates rupertbates changed the title Migrate the CreateSalesforceContactLambda to Typescript Migrate the CreateSalesforceContact Lambda to Typescript Jul 14, 2025
@@ -249,7 +249,7 @@ export class SupportWorkers extends GuStack {
"CreatePaymentMethod"
).addCatch(failureHandler, catchProps);

const createSalesforceContactLambda = createScalaLambda(
const createSalesforceContactLambda = createTypescriptLambda(
Copy link
Member

Choose a reason for hiding this comment

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

Great that this is a one line change in the CDK!

case 'Contribution':
return {
productSpecificState: {
productType: 'Contribution',
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth using state.product.productType to avoid duplicating the value? Applies to each branch of this switch statement, and is consistent with how we're retrieving other fields from state.

Copy link
Member Author

@rupertbates rupertbates Jul 15, 2025

Choose a reason for hiding this comment

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

Actually there is a difference unfortunately, productType: 'DigitalPack' & createZuoraSubscriptionProductState.productType: 'DigitalSubscription' don't match up. It would be good to refactor that out at some point but not in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ohh sorry I didn't spot that, yeah sounds like a future thing 👍

salesForceContact: contactRecords.buyer,
similarProductsConsent: state.similarProductsConsent,
},
...state,
Copy link
Member

Choose a reason for hiding this comment

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

There are a couple of pieces which are common to all branches of this switch - nesting the product specific state under productSpecificState and merging with state at the top level. Would it be worth building up the product specific state separately, and then doing the common pieces in one place which applies to all products?

Copy link
Member Author

@rupertbates rupertbates Jul 15, 2025

Choose a reason for hiding this comment

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

I had a go at doing this but ran into difficulties convincing TS that the product returned from the sub function was the same type as the one in the calling function. It didn't save much code anyway because we still need the specific productType as mentioned in a previous comment, so I've left it as is.

@@ -5,21 +5,23 @@ export const countrySchema = z.enum(isoCountries);

export const addressSchema = z.object({
lineOne: z.string().nullable(),
lineTwo: z.string().nullable(),
lineTwo: z.string().nullish(),
Copy link
Member

Choose a reason for hiding this comment

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

So this can be null or undefined, unlike the others which can only be null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I want to rework how we're using null and undefined across the whole model in a separate PR because Scala writes options as null but I think it would be neater and more idiomatic to use undefined in the Typescript.

Nullish should let us do that I think but I didn't want to confuse this PR with too many changes.

@rupertbates rupertbates force-pushed the rb/createSalesforceContact branch from cccfd74 to 7a97cfe Compare July 15, 2025 09:21
@rupertbates rupertbates merged commit 21e0295 into main Jul 16, 2025
18 checks passed
@rupertbates rupertbates deleted the rb/createSalesforceContact branch July 16, 2025 10:50
@prout-bot
Copy link

Seen on PROD (merged by @rupertbates 9 minutes and 57 seconds ago)

Sentry Release: support-client-side, support

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

Successfully merging this pull request may close these issues.

3 participants