-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
8d7f7bb
to
92377c5
Compare
Size Change: +15 B (0%) Total Size: 1.53 MB ℹ️ View Unchanged
|
92377c5
to
7d230d7
Compare
7d230d7
to
0888a30
Compare
e7787e8
to
52a17e0
Compare
75dc2c6
to
cccfd74
Compare
@@ -249,7 +249,7 @@ export class SupportWorkers extends GuStack { | |||
"CreatePaymentMethod" | |||
).addCatch(failureHandler, catchProps); | |||
|
|||
const createSalesforceContactLambda = createScalaLambda( | |||
const createSalesforceContactLambda = createTypescriptLambda( |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
cccfd74
to
7a97cfe
Compare
Seen on PROD (merged by @rupertbates 9 minutes and 57 seconds ago)
Sentry Release: support-client-side, support |
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:
Trello Card
How to test