Sendgrid-nodejs: MailDataRequired에 MailContentκ°€ ν•„μš”ν•©λ‹ˆκΉŒ?

에 λ§Œλ“  2020λ…„ 03μ›” 07일  Β·  19μ½”λ©˜νŠΈ  Β·  좜처: sendgrid/sendgrid-nodejs

문제 μš”μ•½

Typescriptλ₯Ό μ‚¬μš©ν•˜λ©΄ μ½˜ν…μΈ  ν•„λ“œ 없이 이메일을 μž‘μ„±ν•  수 μ—†κΈ° λ•Œλ¬Έμ— λ¬Έμ œκ°€ λ°œμƒν•©λ‹ˆλ‹€. MailDataRequired λ§žμŠ΅λ‹ˆκΉŒ?

μ΄λ©”μΌλ‘œ μ½˜ν…μΈ λ₯Ό 보낸 적이 μ—†μŠ΅λ‹ˆλ‹€. ꡐ체만 κ°€λŠ₯ν•©λ‹ˆλ‹€. μ½˜ν…μΈ /ν…œν”Œλ¦Ώμ€ μ„œλ²„μ— μžˆμŠ΅λ‹ˆλ‹€.

μ½”λ“œ 쑰각

export type MailDataRequired = MailData & (
    { text: string } | { html: string } | { templateId: string } | { content: MailContent[] & { 0: MailContent } });

μ˜ˆμ™Έ/둜그

# paste exception/log here

기술적 μ„ΈλΆ€ 사항:

  • sendgrid-nodejs 버전: @sendgrid/client@^6.5.3
duplicate

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

BTW: 6.5.0μ—λŠ” 이 μ΄μƒν•œ { 0: MailContent } μš”κ΅¬ 사항이 μ—†λŠ” 것 κ°™μ§€λ§Œ μ—¬μ „νžˆ μ½˜ν…μΈ κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

λͺ¨λ“  19 λŒ“κΈ€

BTW: 6.5.0μ—λŠ” 이 μ΄μƒν•œ { 0: MailContent } μš”κ΅¬ 사항이 μ—†λŠ” 것 κ°™μ§€λ§Œ μ—¬μ „νžˆ μ½˜ν…μΈ κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

이것도 보고. λ‚΄ νŒ¨ν‚€μ§€λ₯Ό μ—…λ°μ΄νŠΈν–ˆκ³  이제 이것에 λŒ€ν•΄ ν™•μ‹ ν•˜μ§€ λͺ»ν•©λ‹ˆλ‹€.

λ‚΄κ°€ μ‹€μˆ˜ν•˜μ§€ μ•ŠλŠ” ν•œ 이것을 https://github.com/sendgrid/sendgrid-nodejs/issues/1056 의 볡제본으둜 κ°„μ£Όν•©λ‹ˆλ‹€.

6.5.4 λ¦΄λ¦¬μŠ€μ— λ„μž…λœ 1041μ—λŠ” text , html λ˜λŠ” content . λ‚˜μ€‘μ— templateId μžμ²΄λ„ ν—ˆμš©λ˜μ–΄μ•Ό ν•œλ‹€κ³  μ§€μ ν–ˆμŠ΅λ‹ˆλ‹€. 이것은 λΆ€ν’ˆ #1053으둜 μˆ˜μ •λ˜μ—ˆμ§€λ§Œ 아직 λ¦΄λ¦¬μŠ€λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

@childish-sambino 이것은 6.5.4 μ—μ„œ μ—¬μ „νžˆ λ¬Έμ œμž…λ‹ˆλ‹€. μœ ν˜•μ€ λ‹€μŒκ³Ό 같이 μ •μ˜λ©λ‹ˆλ‹€.

type MailDataRequired = MailData & (
  { text: string } | { html: string } | { content: MailContent[] & { 0: MailContent } });

content λ₯Ό ν•„μˆ˜ μ†μ„±μœΌλ‘œ λ§Œλ“œλŠ” 것인데, MailData μ—μ„œ 쑰건뢀 μ†μ„±μœΌλ‘œ μ •μ˜ν•  λ•Œ κ·Έ μ΄μœ κ°€ μžˆλ‚˜μš”? λ‚˜λŠ” 그것을 μ „λ‹¬ν•˜μ—¬ 그것을 κ³ μ³€λ‹€.

{...mailData, content: undefined}

6.5.4 λ¦΄λ¦¬μŠ€μ— λ„μž…λœ 1041μ—λŠ” text , html λ˜λŠ” content .

@rodrigomf24 mailData μ—λŠ” κ·Έ 쀑 ν•˜λ‚˜κ°€ μ—†μŠ΅λ‹ˆκΉŒ?

@childish-sambino μ•„λ‹ˆ κ·Έλƒ₯ templateId 및 dynamicTemplateData

@rodrigomf24

λ‚˜μ€‘μ— templateId μžμ²΄λ„ ν—ˆμš©λ˜μ–΄μ•Ό ν•œλ‹€κ³  μ§€μ ν–ˆμŠ΅λ‹ˆλ‹€. 이것은 λΆ€ν’ˆ #1053으둜 μˆ˜μ •λ˜μ—ˆμ§€λ§Œ 아직 λ¦΄λ¦¬μŠ€λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

이 μˆ˜μ • 사항이 릴리슀 λ˜μ—ˆμŠ΅λ‹ˆκΉŒ?

방금 버전 7.0.0을 μ–»μ—ˆμ§€λ§Œ μ—¬μ „νžˆ 이 였λ₯˜κ°€ ν‘œμ‹œλ©λ‹ˆλ‹€.

TSError: β¨― Unable to compile TypeScript: src/email-templates/verification-email-template.ts(15,25): error TS2769: No overload matches this call. Overload 1 of 2, '(data: MailDataRequired, isMultiple?: boolean | undefined, cb?: ((err: Error | ResponseError, result: [ClientResponse, {}]) => void) | undefined): Promise<...>', gave the following error.

이것이 7.0.0μ—μ„œ λ³€κ²½λœ 경우 send api에 λŒ€ν•œ μ΅œμ‹  λ¬Έμ„œλŠ” 어디에 μžˆμŠ΅λ‹ˆκΉŒ? μ—¬κΈ°μ—μ„œ 많이 찾을 수 μ—†μŠ΅λ‹ˆλ‹€. @childish-sambino

감사 ν•΄μš”.

예, 이것은 6.5.5 μ—μ„œ λ¦΄λ¦¬μŠ€λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

@childish-sambino @sendgrid/mail νŒ¨ν‚€μ§€μ—μ„œλ„ MailDataRequired 을 λ‚΄λ³΄λ‚΄λŠ” 것에 λŒ€ν•΄ μ–΄λ–»κ²Œ μƒκ°ν•˜μ‹­λ‹ˆκΉŒ?

@isaachinman λ‚˜λŠ” 그것에 λŒ€ν•΄ μ•„λ¬΄λŸ° λ¬Έμ œκ°€ μ—†μŠ΅λ‹ˆλ‹€. PR을 μ œμΆœν•˜κ³  μ‹Άλ‹€λ©΄ κ²€ν† ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

@childish-sambino μ£Όμœ„λ₯Ό λ‘˜λŸ¬λ³΄μ•˜λŠ”λ° export = 의 λͺ¨λ“ˆ μ ‘κ·Ό 방식이 μ—¬κΈ°μ—μ„œ μ‚¬μš© λ˜λŠ” 것에 μ΅μˆ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μ£Όμš” λ³€κ²½ 사항을 λ„μž…ν•˜μ§€ μ•Šκ³  이것이 μ–΄λ–»κ²Œ ν™•μž₯될 수 μžˆλŠ”μ§€ ν™•μ‹€ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

μ˜¬λ°”λ₯Έ λ°©ν–₯으둜 μ•ˆλ‚΄ν•΄ μ£Όμ‹œλ©΄ 기꺼이 λ„μ™€λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€.

이 쀄을 μ—…λ°μ΄νŠΈν•  수 μžˆλ‹€κ³  μƒκ°ν•˜μ‹­μ‹œμ˜€. https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/mail/src/mail.d.ts#L37

μ•„λ§ˆλ„ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

declare const mail: MailService & { MailService: typeof MailService, MailDataRequired: typeof MailDataRequired };

μ•„λ‹ˆμš”, MailDataRequired λŠ” 이미 μœ ν˜•μ΄λ―€λ‘œ μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. declare const μ‚¬μš©ν•˜λ©΄ 상황이 μ•½κ°„ λ³΅μž‘ν•΄μ§‘λ‹ˆλ‹€.

그럼 κ·Έλƒ₯ , MailDataRequired: MailDataRequired }; ?

μ•„λ‹ˆμš”, μ œκ°€ λ§ν•˜λŠ” 것은 문자 κ·ΈλŒ€λ‘œ κΈ°λ³Έ 내보내기에 MailDataRequired 속성을 μΆ”κ°€ν•œλ‹€λŠ” κ²ƒμž…λ‹ˆλ‹€. 졜근 μ œμ•ˆμ„ μ‹œλ„ν•˜λ©΄ refers to a value, but is being used as a type 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€.

이런 μ’…λ₯˜μ˜ λͺ¨λ“ˆ μ ‘κ·Ό λ°©μ‹μœΌλ‘œ μœ ν˜•μ„ κ΄€λ¦¬ν•˜λŠ” λ‹€λ₯Έ νŒ¨ν‚€μ§€λ₯Ό λ³Έ 적이 μ—†μœΌλ―€λ‘œ μ‹€μ œλ‘œ μ œμ•ˆν•  수 μ—†μŠ΅λ‹ˆλ‹€. λͺ…λͺ…λœ 내보내기λ₯Ό μ§€μ›ν•˜λŠ” 방법이 ν•„μš”ν•©λ‹ˆλ‹€.

일반적으둜 λ‹€μŒκ³Ό 같은 λ‚΄μš©μ΄ ν‘œμ‹œλ  κ²ƒμœΌλ‘œ μ˜ˆμƒλ©λ‹ˆλ‹€.

export default mail
export { MailDataRequired }

@isaachinman 이것을 (ν•΄ν‚Ή) μˆ˜μ •ν•΄μ•Ό ν•œλ‹€κ³  μƒκ°ν•˜μ‹­μ‹œμ˜€: https://github.com/sendgrid/sendgrid-nodejs/pull/1102

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰