@vrplatform/email 1.0.2-457 → 1.0.2-46615499325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main/components/ActionEmailTemplate.d.ts +3 -1
- package/build/main/components/ActionEmailTemplate.js +9 -13
- package/build/main/components/ActionEmailTemplate.js.map +1 -1
- package/build/main/components/Button.js.map +1 -1
- package/build/main/components/EmailContainer.d.ts +4 -1
- package/build/main/components/EmailContainer.js +4 -3
- package/build/main/components/EmailContainer.js.map +1 -1
- package/build/main/components/EmailHeading.d.ts +8 -0
- package/build/main/components/EmailHeading.js +21 -0
- package/build/main/components/EmailHeading.js.map +1 -0
- package/build/main/components/index.d.ts +1 -0
- package/build/main/components/index.js +1 -0
- package/build/main/components/index.js.map +1 -1
- package/build/main/components/utils/parse-email-html.js +13 -4
- package/build/main/components/utils/parse-email-html.js.map +1 -1
- package/build/main/const.d.ts +4 -4
- package/build/main/index.d.ts +1 -1
- package/build/main/index.js +2 -3
- package/build/main/index.js.map +1 -1
- package/build/main/render.d.ts +2 -0
- package/build/main/render.js +24 -0
- package/build/main/render.js.map +1 -0
- package/build/main/templates/BankAccountChangedEmailTemplate.d.ts +12 -0
- package/build/main/templates/BankAccountChangedEmailTemplate.js +12 -0
- package/build/main/templates/BankAccountChangedEmailTemplate.js.map +1 -0
- package/build/main/templates/BankAccountChangedTeamAdminEmailTemplate.d.ts +17 -0
- package/build/main/templates/BankAccountChangedTeamAdminEmailTemplate.js +12 -0
- package/build/main/templates/BankAccountChangedTeamAdminEmailTemplate.js.map +1 -0
- package/build/main/templates/BankDetailsRequestEmailTemplate.d.ts +17 -0
- package/build/main/templates/BankDetailsRequestEmailTemplate.js +15 -0
- package/build/main/templates/BankDetailsRequestEmailTemplate.js.map +1 -0
- package/build/main/templates/InviteOwnerEmailTemplate.d.ts +2 -2
- package/build/main/templates/InviteOwnerEmailTemplate.js +1 -1
- package/build/main/templates/InviteOwnerEmailTemplate.js.map +1 -1
- package/build/main/templates/InvitePmEmailTemplate.d.ts +2 -1
- package/build/main/templates/InvitePmEmailTemplate.js +4 -7
- package/build/main/templates/InvitePmEmailTemplate.js.map +1 -1
- package/build/main/templates/OwnerStatementEmailTemplate.d.ts +41 -3
- package/build/main/templates/OwnerStatementEmailTemplate.js +147 -10
- package/build/main/templates/OwnerStatementEmailTemplate.js.map +1 -1
- package/build/main/templates/SecondFactorResetEmailTemplate.d.ts +11 -0
- package/build/main/templates/SecondFactorResetEmailTemplate.js +19 -0
- package/build/main/templates/SecondFactorResetEmailTemplate.js.map +1 -0
- package/build/main/templates/Tax1099ConsentWithdrawnEmailTemplate.d.ts +9 -0
- package/build/main/templates/Tax1099ConsentWithdrawnEmailTemplate.js +22 -0
- package/build/main/templates/Tax1099ConsentWithdrawnEmailTemplate.js.map +1 -0
- package/build/main/templates/Tax1099EmailTemplate.d.ts +15 -0
- package/build/main/templates/Tax1099EmailTemplate.js +64 -0
- package/build/main/templates/Tax1099EmailTemplate.js.map +1 -0
- package/build/main/templates/TeamApiTokenCreatedEmailTemplate.d.ts +10 -0
- package/build/main/templates/TeamApiTokenCreatedEmailTemplate.js +12 -0
- package/build/main/templates/TeamApiTokenCreatedEmailTemplate.js.map +1 -0
- package/build/main/templates/TeamInviteOutsideDomainEmailTemplate.d.ts +11 -0
- package/build/main/templates/TeamInviteOutsideDomainEmailTemplate.js +12 -0
- package/build/main/templates/TeamInviteOutsideDomainEmailTemplate.js.map +1 -0
- package/build/main/templates/TeamRoleGrantedEmailTemplate.d.ts +12 -0
- package/build/main/templates/TeamRoleGrantedEmailTemplate.js +12 -0
- package/build/main/templates/TeamRoleGrantedEmailTemplate.js.map +1 -0
- package/build/main/templates/TenantDeletionEmailTemplate.js +2 -6
- package/build/main/templates/TenantDeletionEmailTemplate.js.map +1 -1
- package/build/main/templates/TenantSuspensionEmailTemplate.js +2 -6
- package/build/main/templates/TenantSuspensionEmailTemplate.js.map +1 -1
- package/build/main/templates/YearEndStatementEmailTemplate.d.ts +23 -0
- package/build/main/templates/YearEndStatementEmailTemplate.js +37 -0
- package/build/main/templates/YearEndStatementEmailTemplate.js.map +1 -0
- package/build/main/templates/index.d.ts +10 -0
- package/build/main/templates/index.js +12 -0
- package/build/main/templates/index.js.map +1 -1
- package/build/main/theme.js.map +1 -1
- package/build/main/types.d.ts +3 -0
- package/build/main/types.js.map +1 -1
- package/build/main/utils/find-postmark-email.d.ts +8 -0
- package/build/main/utils/find-postmark-email.js +88 -0
- package/build/main/utils/find-postmark-email.js.map +1 -0
- package/build/main/utils/index.d.ts +1 -0
- package/build/main/utils/index.js +1 -0
- package/build/main/utils/index.js.map +1 -1
- package/build/main/utils/send-email.d.ts +15 -2
- package/build/main/utils/send-email.js +99 -26
- package/build/main/utils/send-email.js.map +1 -1
- package/build/module/components/ActionEmailTemplate.d.ts +3 -1
- package/build/module/components/ActionEmailTemplate.js +9 -13
- package/build/module/components/ActionEmailTemplate.js.map +1 -1
- package/build/module/components/EmailContainer.d.ts +4 -1
- package/build/module/components/EmailContainer.js +5 -4
- package/build/module/components/EmailContainer.js.map +1 -1
- package/build/module/components/EmailHeading.d.ts +8 -0
- package/build/module/components/EmailHeading.js +17 -0
- package/build/module/components/EmailHeading.js.map +1 -0
- package/build/module/components/index.d.ts +1 -0
- package/build/module/components/index.js +1 -0
- package/build/module/components/index.js.map +1 -1
- package/build/module/components/utils/parse-email-html.js +13 -4
- package/build/module/components/utils/parse-email-html.js.map +1 -1
- package/build/module/const.d.ts +4 -4
- package/build/module/index.d.ts +1 -1
- package/build/module/index.js +1 -1
- package/build/module/index.js.map +1 -1
- package/build/module/render.d.ts +2 -0
- package/build/module/render.js +20 -0
- package/build/module/render.js.map +1 -0
- package/build/module/templates/BankAccountChangedEmailTemplate.d.ts +12 -0
- package/build/module/templates/BankAccountChangedEmailTemplate.js +8 -0
- package/build/module/templates/BankAccountChangedEmailTemplate.js.map +1 -0
- package/build/module/templates/BankAccountChangedTeamAdminEmailTemplate.d.ts +17 -0
- package/build/module/templates/BankAccountChangedTeamAdminEmailTemplate.js +8 -0
- package/build/module/templates/BankAccountChangedTeamAdminEmailTemplate.js.map +1 -0
- package/build/module/templates/BankDetailsRequestEmailTemplate.d.ts +17 -0
- package/build/module/templates/BankDetailsRequestEmailTemplate.js +11 -0
- package/build/module/templates/BankDetailsRequestEmailTemplate.js.map +1 -0
- package/build/module/templates/InviteOwnerEmailTemplate.d.ts +2 -2
- package/build/module/templates/InviteOwnerEmailTemplate.js +1 -1
- package/build/module/templates/InviteOwnerEmailTemplate.js.map +1 -1
- package/build/module/templates/InvitePmEmailTemplate.d.ts +2 -1
- package/build/module/templates/InvitePmEmailTemplate.js +4 -7
- package/build/module/templates/InvitePmEmailTemplate.js.map +1 -1
- package/build/module/templates/OwnerStatementEmailTemplate.d.ts +41 -3
- package/build/module/templates/OwnerStatementEmailTemplate.js +146 -10
- package/build/module/templates/OwnerStatementEmailTemplate.js.map +1 -1
- package/build/module/templates/SecondFactorResetEmailTemplate.d.ts +11 -0
- package/build/module/templates/SecondFactorResetEmailTemplate.js +15 -0
- package/build/module/templates/SecondFactorResetEmailTemplate.js.map +1 -0
- package/build/module/templates/Tax1099ConsentWithdrawnEmailTemplate.d.ts +9 -0
- package/build/module/templates/Tax1099ConsentWithdrawnEmailTemplate.js +18 -0
- package/build/module/templates/Tax1099ConsentWithdrawnEmailTemplate.js.map +1 -0
- package/build/module/templates/Tax1099EmailTemplate.d.ts +15 -0
- package/build/module/templates/Tax1099EmailTemplate.js +59 -0
- package/build/module/templates/Tax1099EmailTemplate.js.map +1 -0
- package/build/module/templates/TeamApiTokenCreatedEmailTemplate.d.ts +10 -0
- package/build/module/templates/TeamApiTokenCreatedEmailTemplate.js +8 -0
- package/build/module/templates/TeamApiTokenCreatedEmailTemplate.js.map +1 -0
- package/build/module/templates/TeamInviteOutsideDomainEmailTemplate.d.ts +11 -0
- package/build/module/templates/TeamInviteOutsideDomainEmailTemplate.js +8 -0
- package/build/module/templates/TeamInviteOutsideDomainEmailTemplate.js.map +1 -0
- package/build/module/templates/TeamRoleGrantedEmailTemplate.d.ts +12 -0
- package/build/module/templates/TeamRoleGrantedEmailTemplate.js +8 -0
- package/build/module/templates/TeamRoleGrantedEmailTemplate.js.map +1 -0
- package/build/module/templates/TenantDeletionEmailTemplate.js +3 -7
- package/build/module/templates/TenantDeletionEmailTemplate.js.map +1 -1
- package/build/module/templates/TenantSuspensionEmailTemplate.js +3 -7
- package/build/module/templates/TenantSuspensionEmailTemplate.js.map +1 -1
- package/build/module/templates/YearEndStatementEmailTemplate.d.ts +23 -0
- package/build/module/templates/YearEndStatementEmailTemplate.js +32 -0
- package/build/module/templates/YearEndStatementEmailTemplate.js.map +1 -0
- package/build/module/templates/index.d.ts +10 -0
- package/build/module/templates/index.js +12 -0
- package/build/module/templates/index.js.map +1 -1
- package/build/module/types.d.ts +3 -0
- package/build/module/types.js.map +1 -1
- package/build/module/utils/find-postmark-email.d.ts +8 -0
- package/build/module/utils/find-postmark-email.js +52 -0
- package/build/module/utils/find-postmark-email.js.map +1 -0
- package/build/module/utils/index.d.ts +1 -0
- package/build/module/utils/index.js +1 -0
- package/build/module/utils/index.js.map +1 -1
- package/build/module/utils/send-email.d.ts +15 -2
- package/build/module/utils/send-email.js +66 -26
- package/build/module/utils/send-email.js.map +1 -1
- package/package.json +8 -7
- package/src/components/ActionEmailTemplate.tsx +14 -16
- package/src/components/EmailContainer.tsx +20 -4
- package/src/components/EmailHeading.tsx +36 -0
- package/src/components/index.ts +1 -0
- package/src/components/utils/parse-email-html.ts +20 -6
- package/src/index.ts +1 -1
- package/src/render.ts +24 -0
- package/src/templates/BankAccountChangedEmailTemplate.tsx +53 -0
- package/src/templates/BankAccountChangedTeamAdminEmailTemplate.tsx +55 -0
- package/src/templates/BankDetailsRequestEmailTemplate.tsx +63 -0
- package/src/templates/InviteOwnerEmailTemplate.tsx +1 -0
- package/src/templates/InvitePmEmailTemplate.tsx +5 -7
- package/src/templates/OwnerStatementEmailTemplate.tsx +336 -14
- package/src/templates/SecondFactorResetEmailTemplate.tsx +71 -0
- package/src/templates/Tax1099ConsentWithdrawnEmailTemplate.tsx +57 -0
- package/src/templates/Tax1099EmailTemplate.tsx +106 -0
- package/src/templates/TeamApiTokenCreatedEmailTemplate.tsx +50 -0
- package/src/templates/TeamInviteOutsideDomainEmailTemplate.tsx +52 -0
- package/src/templates/TeamRoleGrantedEmailTemplate.tsx +54 -0
- package/src/templates/TenantDeletionEmailTemplate.tsx +9 -10
- package/src/templates/TenantSuspensionEmailTemplate.tsx +9 -10
- package/src/templates/YearEndStatementEmailTemplate.tsx +66 -0
- package/src/templates/index.ts +14 -0
- package/src/types.ts +3 -0
- package/src/utils/find-postmark-email.ts +80 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/send-email.ts +103 -28
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Heading } from '@react-email/heading';
|
|
2
|
+
import { Text } from '@react-email/text';
|
|
3
|
+
import { Button } from '../components/Button';
|
|
4
|
+
import { EmailContainer } from '../components/EmailContainer';
|
|
5
|
+
import { THEME_COLORS } from '../theme';
|
|
6
|
+
import type { EmailBaseProps } from '../types';
|
|
7
|
+
|
|
8
|
+
export type TeamApiTokenCreatedEmailTemplateProps = {
|
|
9
|
+
mode: EmailBaseProps['mode'];
|
|
10
|
+
tenant: EmailBaseProps['tenant'];
|
|
11
|
+
hint: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
createdBy: string | null;
|
|
14
|
+
href: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const TeamApiTokenCreatedEmailTemplate = ({
|
|
18
|
+
mode,
|
|
19
|
+
tenant,
|
|
20
|
+
hint,
|
|
21
|
+
createdAt,
|
|
22
|
+
createdBy,
|
|
23
|
+
href,
|
|
24
|
+
}: TeamApiTokenCreatedEmailTemplateProps) => (
|
|
25
|
+
<EmailContainer
|
|
26
|
+
title={`New API key on ${tenant.name}`}
|
|
27
|
+
shortDescription={`An API key ending in ${hint} was created on ${tenant.name}.`}
|
|
28
|
+
tenant={tenant}
|
|
29
|
+
mode={mode}
|
|
30
|
+
>
|
|
31
|
+
<Heading style={{ fontSize: 28, fontWeight: 600, marginBottom: '50px' }}>
|
|
32
|
+
New API key on your team
|
|
33
|
+
</Heading>
|
|
34
|
+
<Text>
|
|
35
|
+
An API key ending in <b>{hint}</b> was created on {tenant.name} on{' '}
|
|
36
|
+
{createdAt}
|
|
37
|
+
{createdBy ? ` by ${createdBy}` : ''}. Anyone holding it can read and
|
|
38
|
+
change your team's data.
|
|
39
|
+
</Text>
|
|
40
|
+
<Text>
|
|
41
|
+
If you did not expect this key, revoke it and review the team members.
|
|
42
|
+
</Text>
|
|
43
|
+
<Button
|
|
44
|
+
href={href}
|
|
45
|
+
mode={mode}
|
|
46
|
+
label="Review API keys"
|
|
47
|
+
themeColors={THEME_COLORS.vrplatform!}
|
|
48
|
+
/>
|
|
49
|
+
</EmailContainer>
|
|
50
|
+
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Heading } from '@react-email/heading';
|
|
2
|
+
import { Text } from '@react-email/text';
|
|
3
|
+
import { Button } from '../components/Button';
|
|
4
|
+
import { EmailContainer } from '../components/EmailContainer';
|
|
5
|
+
import { THEME_COLORS } from '../theme';
|
|
6
|
+
import type { EmailBaseProps } from '../types';
|
|
7
|
+
|
|
8
|
+
export type TeamInviteOutsideDomainEmailTemplateProps = {
|
|
9
|
+
mode: EmailBaseProps['mode'];
|
|
10
|
+
tenant: EmailBaseProps['tenant'];
|
|
11
|
+
invitedEmail: string;
|
|
12
|
+
invitedBy: string | null;
|
|
13
|
+
invitedAt: string;
|
|
14
|
+
roles: string;
|
|
15
|
+
href: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const TeamInviteOutsideDomainEmailTemplate = ({
|
|
19
|
+
mode,
|
|
20
|
+
tenant,
|
|
21
|
+
invitedEmail,
|
|
22
|
+
invitedBy,
|
|
23
|
+
invitedAt,
|
|
24
|
+
roles,
|
|
25
|
+
href,
|
|
26
|
+
}: TeamInviteOutsideDomainEmailTemplateProps) => (
|
|
27
|
+
<EmailContainer
|
|
28
|
+
title={`${invitedEmail} was invited to ${tenant.name}`}
|
|
29
|
+
shortDescription={`${invitedEmail} was invited to ${tenant.name} with an outside email address.`}
|
|
30
|
+
tenant={tenant}
|
|
31
|
+
mode={mode}
|
|
32
|
+
>
|
|
33
|
+
<Heading style={{ fontSize: 28, fontWeight: 600, marginBottom: '50px' }}>
|
|
34
|
+
A new member was invited
|
|
35
|
+
</Heading>
|
|
36
|
+
<Text>
|
|
37
|
+
{invitedBy ?? 'An API key'} invited <b>{invitedEmail}</b> to {tenant.name}{' '}
|
|
38
|
+
as <b>{roles}</b> on {invitedAt}. The address is outside the email domains
|
|
39
|
+
of your team and your accounting partner, or it is a free-mail address.
|
|
40
|
+
</Text>
|
|
41
|
+
<Text>
|
|
42
|
+
If you do not know this person, remove the member and check who invited
|
|
43
|
+
them.
|
|
44
|
+
</Text>
|
|
45
|
+
<Button
|
|
46
|
+
href={href}
|
|
47
|
+
mode={mode}
|
|
48
|
+
label="Review team members"
|
|
49
|
+
themeColors={THEME_COLORS.vrplatform!}
|
|
50
|
+
/>
|
|
51
|
+
</EmailContainer>
|
|
52
|
+
);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Heading } from '@react-email/heading';
|
|
2
|
+
import { Text } from '@react-email/text';
|
|
3
|
+
import { Button } from '../components/Button';
|
|
4
|
+
import { EmailContainer } from '../components/EmailContainer';
|
|
5
|
+
import { THEME_COLORS } from '../theme';
|
|
6
|
+
import type { EmailBaseProps } from '../types';
|
|
7
|
+
|
|
8
|
+
export type TeamRoleGrantedEmailTemplateProps = {
|
|
9
|
+
mode: EmailBaseProps['mode'];
|
|
10
|
+
tenant: EmailBaseProps['tenant'];
|
|
11
|
+
member: string;
|
|
12
|
+
roles: string;
|
|
13
|
+
grantedAt: string;
|
|
14
|
+
grantedBy: string | null;
|
|
15
|
+
partnerName: string | null;
|
|
16
|
+
href: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const TeamRoleGrantedEmailTemplate = ({
|
|
20
|
+
mode,
|
|
21
|
+
tenant,
|
|
22
|
+
member,
|
|
23
|
+
roles,
|
|
24
|
+
grantedAt,
|
|
25
|
+
grantedBy,
|
|
26
|
+
partnerName,
|
|
27
|
+
href,
|
|
28
|
+
}: TeamRoleGrantedEmailTemplateProps) => (
|
|
29
|
+
<EmailContainer
|
|
30
|
+
title={`${member} received ${roles}`}
|
|
31
|
+
shortDescription={`${member} received ${roles} on ${tenant.name}.`}
|
|
32
|
+
tenant={tenant}
|
|
33
|
+
mode={mode}
|
|
34
|
+
>
|
|
35
|
+
<Heading style={{ fontSize: 28, fontWeight: 600, marginBottom: '50px' }}>
|
|
36
|
+
New {roles} on your team
|
|
37
|
+
</Heading>
|
|
38
|
+
<Text>
|
|
39
|
+
<b>{member}</b> received <b>{roles}</b> on {tenant.name} on {grantedAt}
|
|
40
|
+
{grantedBy ? ` from ${grantedBy}` : ''}
|
|
41
|
+
{partnerName ? `, acting through your partner ${partnerName}` : ''}.
|
|
42
|
+
</Text>
|
|
43
|
+
<Text>
|
|
44
|
+
If you did not expect this change, review the team members and remove the
|
|
45
|
+
role.
|
|
46
|
+
</Text>
|
|
47
|
+
<Button
|
|
48
|
+
href={href}
|
|
49
|
+
mode={mode}
|
|
50
|
+
label="Review team members"
|
|
51
|
+
themeColors={THEME_COLORS.vrplatform!}
|
|
52
|
+
/>
|
|
53
|
+
</EmailContainer>
|
|
54
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Heading } from '@react-email/heading';
|
|
2
1
|
import { Text } from '@react-email/text';
|
|
3
|
-
import { EmailContainer } from '../components';
|
|
2
|
+
import { EmailContainer, EmailHeading } from '../components';
|
|
3
|
+
import { THEME_COLORS } from '../theme';
|
|
4
4
|
import type { EmailBaseProps } from '../types';
|
|
5
5
|
|
|
6
6
|
export type TenantDeletionEmailTemplateProps = {
|
|
@@ -25,15 +25,14 @@ export const TenantDeletionEmailTemplate = ({
|
|
|
25
25
|
}}
|
|
26
26
|
mode={mode}
|
|
27
27
|
>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fontWeight: 600,
|
|
32
|
-
marginBottom: '50px',
|
|
33
|
-
}}
|
|
28
|
+
<EmailHeading
|
|
29
|
+
eyebrow="Team deleted"
|
|
30
|
+
themeColors={THEME_COLORS.vrplatform}
|
|
34
31
|
>
|
|
35
|
-
|
|
36
|
-
</
|
|
32
|
+
Your team was deleted
|
|
33
|
+
</EmailHeading>
|
|
34
|
+
|
|
35
|
+
<Text>{user.firstName ? `Dear ${user.firstName},` : 'Hi there,'}</Text>
|
|
37
36
|
|
|
38
37
|
<Text>
|
|
39
38
|
We wanted to inform you that the team account "{tenant.name}" has been
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Heading } from '@react-email/heading';
|
|
2
1
|
import { Text } from '@react-email/text';
|
|
3
|
-
import { EmailContainer } from '../components';
|
|
2
|
+
import { EmailContainer, EmailHeading } from '../components';
|
|
3
|
+
import { THEME_COLORS } from '../theme';
|
|
4
4
|
import type { EmailBaseProps } from '../types';
|
|
5
5
|
|
|
6
6
|
export type TenantSuspensionEmailTemplateProps = {
|
|
@@ -25,15 +25,14 @@ export const TenantSuspensionEmailTemplate = ({
|
|
|
25
25
|
}}
|
|
26
26
|
mode={mode}
|
|
27
27
|
>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fontWeight: 600,
|
|
32
|
-
marginBottom: '50px',
|
|
33
|
-
}}
|
|
28
|
+
<EmailHeading
|
|
29
|
+
eyebrow="Team suspended"
|
|
30
|
+
themeColors={THEME_COLORS.vrplatform}
|
|
34
31
|
>
|
|
35
|
-
|
|
36
|
-
</
|
|
32
|
+
Your team access is suspended
|
|
33
|
+
</EmailHeading>
|
|
34
|
+
|
|
35
|
+
<Text>{user.firstName ? `Dear ${user.firstName},` : 'Hi there,'}</Text>
|
|
37
36
|
|
|
38
37
|
<Text>
|
|
39
38
|
We're reaching out to inform you that as of today, access to your team{' '}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EMAIL_ACTION_LINK_COMPONENT,
|
|
3
|
+
EMAIL_DATE_COMPONENT,
|
|
4
|
+
EMAIL_USER_NAME_COMPONENT,
|
|
5
|
+
} from '../extensions';
|
|
6
|
+
import type {
|
|
7
|
+
ActionEmailData,
|
|
8
|
+
ActionEmailTemplateProps,
|
|
9
|
+
} from '../components/ActionEmailTemplate';
|
|
10
|
+
import { OwnerStatementEmailTemplate } from './OwnerStatementEmailTemplate';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default text of the `yearEndStatement` email: an owner's year-end statement
|
|
14
|
+
* of a fiscal year is published. Owners open it by a no-login link, viewers
|
|
15
|
+
* in the owner portal. Settings > Emails shows it; its text is fixed.
|
|
16
|
+
*/
|
|
17
|
+
export const getDefaultYearEndStatementEmailData = (
|
|
18
|
+
mode: 'tag' | 'text',
|
|
19
|
+
args: {
|
|
20
|
+
appName: string;
|
|
21
|
+
href: string;
|
|
22
|
+
userName: string;
|
|
23
|
+
/** The fiscal year, such as `2025`. */
|
|
24
|
+
year: string;
|
|
25
|
+
/** The months it covers, such as `Jan 2025 - Dec 2025`. */
|
|
26
|
+
period: string;
|
|
27
|
+
}
|
|
28
|
+
): ActionEmailData => {
|
|
29
|
+
const href = mode === 'tag' ? EMAIL_ACTION_LINK_COMPONENT : args.href;
|
|
30
|
+
const period = mode === 'tag' ? EMAIL_DATE_COMPONENT : args.period;
|
|
31
|
+
const userName = mode === 'tag' ? EMAIL_USER_NAME_COMPONENT : args.userName;
|
|
32
|
+
return {
|
|
33
|
+
subject:
|
|
34
|
+
mode === 'tag'
|
|
35
|
+
? 'Your year-end statement is ready'
|
|
36
|
+
: `Your ${args.year} year-end statement`,
|
|
37
|
+
shortDescription:
|
|
38
|
+
mode === 'tag'
|
|
39
|
+
? 'Your year-end statement is ready to view.'
|
|
40
|
+
: `Your ${args.year} year-end statement is ready to view.`,
|
|
41
|
+
header: 'Your year-end statement is ready',
|
|
42
|
+
bodyOne: `<p>Hi ${userName},</p><p>${args.appName} published your year-end statement for ${period}. It sums up your owner statements of the year. Open it with the button below.</p>`,
|
|
43
|
+
buttonText: 'View year-end statement',
|
|
44
|
+
bodyTwo: `<p style="color:#737373;font-size:13px">If the button doesn't work, copy this link into your browser: ${href}</p>`,
|
|
45
|
+
href: args.href,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const YearEndStatementEmailTemplate = ({
|
|
50
|
+
period,
|
|
51
|
+
listings,
|
|
52
|
+
...props
|
|
53
|
+
}: Omit<ActionEmailTemplateProps, 'listing' | 'month'> & {
|
|
54
|
+
/** The months the statement covers, such as `Jan 2025 - Dec 2025`. */
|
|
55
|
+
period: string;
|
|
56
|
+
/** The owner's listings in the year, such as `Lake House, Casita`. */
|
|
57
|
+
listings?: string;
|
|
58
|
+
/** Requests a new no-login link once the emailed one has expired. */
|
|
59
|
+
renewHref?: string;
|
|
60
|
+
}) =>
|
|
61
|
+
OwnerStatementEmailTemplate({
|
|
62
|
+
...props,
|
|
63
|
+
listing: undefined,
|
|
64
|
+
month: period,
|
|
65
|
+
yearEnd: { listings },
|
|
66
|
+
});
|
package/src/templates/index.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
// Teams
|
|
2
|
+
export * from './SecondFactorResetEmailTemplate';
|
|
3
|
+
export * from './TeamApiTokenCreatedEmailTemplate';
|
|
4
|
+
export * from './TeamInviteOutsideDomainEmailTemplate';
|
|
5
|
+
export * from './TeamRoleGrantedEmailTemplate';
|
|
2
6
|
export * from './TenantSuspensionEmailTemplate';
|
|
3
7
|
export * from './TenantDeletionEmailTemplate';
|
|
4
8
|
|
|
5
9
|
// Owner Statements
|
|
6
10
|
export * from './OwnerStatementEmailTemplate';
|
|
11
|
+
export * from './YearEndStatementEmailTemplate';
|
|
12
|
+
|
|
13
|
+
// Payment setup
|
|
14
|
+
export * from './BankAccountChangedEmailTemplate';
|
|
15
|
+
export * from './BankAccountChangedTeamAdminEmailTemplate';
|
|
16
|
+
export * from './BankDetailsRequestEmailTemplate';
|
|
17
|
+
|
|
18
|
+
// 1099s
|
|
19
|
+
export * from './Tax1099ConsentWithdrawnEmailTemplate';
|
|
20
|
+
export * from './Tax1099EmailTemplate';
|
|
7
21
|
|
|
8
22
|
// Invitations
|
|
9
23
|
export * from './InviteOwnerEmailTemplate';
|
package/src/types.ts
CHANGED
|
@@ -2,10 +2,13 @@ export type EmailBaseProps = {
|
|
|
2
2
|
mode: 'edit' | 'preview' | 'send';
|
|
3
3
|
tenant: {
|
|
4
4
|
name: string;
|
|
5
|
+
showPlatformBranding?: boolean;
|
|
5
6
|
logo: string | undefined | null;
|
|
6
7
|
};
|
|
7
8
|
listing: string | undefined;
|
|
8
9
|
month: string | undefined;
|
|
10
|
+
/** Opt-out link shown below the email body */
|
|
11
|
+
unsubscribeHref?: string;
|
|
9
12
|
user: {
|
|
10
13
|
firstName: string | undefined;
|
|
11
14
|
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { day } from '@vrplatform/utils';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
import { EmailDeliveryError } from './send-email';
|
|
4
|
+
|
|
5
|
+
const postmarkMessagesResponseSchema = z.object({
|
|
6
|
+
TotalCount: z.number().int().nonnegative(),
|
|
7
|
+
Messages: z.array(
|
|
8
|
+
z.object({
|
|
9
|
+
MessageID: z.string().min(1),
|
|
10
|
+
ReceivedAt: z.string().refine((value) => day(value).isValid()),
|
|
11
|
+
Metadata: z.object({ deliveryId: z.string() }).passthrough(),
|
|
12
|
+
})
|
|
13
|
+
),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export async function findPostmarkEmail(
|
|
17
|
+
deliveryId: string,
|
|
18
|
+
options: {
|
|
19
|
+
fetch?: (
|
|
20
|
+
input: string | URL | Request,
|
|
21
|
+
init?: RequestInit
|
|
22
|
+
) => Promise<Response>;
|
|
23
|
+
postmarkToken?: string;
|
|
24
|
+
}
|
|
25
|
+
) {
|
|
26
|
+
if (!options.postmarkToken) {
|
|
27
|
+
throw new EmailDeliveryError(
|
|
28
|
+
'Postmark is not configured',
|
|
29
|
+
undefined,
|
|
30
|
+
false,
|
|
31
|
+
false
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const url = new URL('https://api.postmarkapp.com/messages/outbound');
|
|
36
|
+
url.searchParams.set('count', '1');
|
|
37
|
+
url.searchParams.set('offset', '0');
|
|
38
|
+
url.searchParams.set('messagestream', 'outbound');
|
|
39
|
+
url.searchParams.set('metadata_deliveryId', deliveryId);
|
|
40
|
+
const response = await (options.fetch ?? fetch)(url, {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
headers: {
|
|
43
|
+
Accept: 'application/json',
|
|
44
|
+
'X-Postmark-Server-Token': options.postmarkToken,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const providerResponse: unknown = await response.json().catch(() => ({}));
|
|
48
|
+
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
throw new EmailDeliveryError(
|
|
51
|
+
'Postmark message lookup failed',
|
|
52
|
+
{
|
|
53
|
+
provider: 'postmark',
|
|
54
|
+
providerCategory: 'rejected',
|
|
55
|
+
httpStatus: response.status,
|
|
56
|
+
},
|
|
57
|
+
false,
|
|
58
|
+
response.status === 429 || response.status >= 500
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const result = postmarkMessagesResponseSchema.safeParse(providerResponse);
|
|
63
|
+
if (!result.success) {
|
|
64
|
+
throw new EmailDeliveryError('Postmark returned an invalid response');
|
|
65
|
+
}
|
|
66
|
+
if (result.data.TotalCount === 0) return undefined;
|
|
67
|
+
|
|
68
|
+
const message = result.data.Messages.find(
|
|
69
|
+
({ Metadata }) => Metadata.deliveryId === deliveryId
|
|
70
|
+
);
|
|
71
|
+
if (!message) {
|
|
72
|
+
throw new EmailDeliveryError('Postmark returned an invalid response');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
httpStatus: response.status,
|
|
77
|
+
messageId: message.MessageID,
|
|
78
|
+
submittedAt: message.ReceivedAt,
|
|
79
|
+
};
|
|
80
|
+
}
|
package/src/utils/index.ts
CHANGED
package/src/utils/send-email.ts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
import { day } from '@vrplatform/utils';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
|
|
4
|
+
const postmarkErrorCodeSchema = z.number().int().nonnegative();
|
|
5
|
+
const postmarkResponseErrorCodeSchema = z
|
|
6
|
+
.object({ ErrorCode: postmarkErrorCodeSchema })
|
|
7
|
+
.transform(({ ErrorCode }) => ErrorCode);
|
|
8
|
+
const postmarkHeaderErrorCodeSchema = z
|
|
9
|
+
.string()
|
|
10
|
+
.regex(/^\d+$/)
|
|
11
|
+
.transform(Number)
|
|
12
|
+
.pipe(postmarkErrorCodeSchema);
|
|
13
|
+
const postmarkSuccessResponseSchema = z.object({
|
|
14
|
+
ErrorCode: z.literal(0),
|
|
15
|
+
MessageID: z.string().min(1),
|
|
16
|
+
SubmittedAt: z.string().refine((value) => day(value).isValid()),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function parseOptional<T>(schema: z.ZodType<T>, value: unknown) {
|
|
20
|
+
const result = schema.safeParse(value);
|
|
21
|
+
if (result.success) return result.data;
|
|
22
|
+
}
|
|
23
|
+
|
|
1
24
|
type EmailDeliveryFailureDetails = {
|
|
2
25
|
httpStatus: number;
|
|
3
26
|
postmarkErrorCode?: number;
|
|
@@ -16,13 +39,27 @@ export class EmailDeliveryError extends Error {
|
|
|
16
39
|
constructor(
|
|
17
40
|
message: string,
|
|
18
41
|
public readonly details?: EmailDeliveryErrorDetails,
|
|
19
|
-
public readonly expected = false
|
|
42
|
+
public readonly expected = false,
|
|
43
|
+
public readonly retryable = true
|
|
20
44
|
) {
|
|
21
45
|
super(message);
|
|
22
46
|
this.name = 'EmailDeliveryError';
|
|
23
47
|
}
|
|
24
48
|
}
|
|
25
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Formats a verified sender address with a display name for the From header.
|
|
52
|
+
* Registrations store bare addresses; recipients should still see the company
|
|
53
|
+
* name the way they see `VRPlatform <notifications@vrplatform.app>`.
|
|
54
|
+
*/
|
|
55
|
+
export function formatSenderIdentity(
|
|
56
|
+
name: string | null | undefined,
|
|
57
|
+
address: string
|
|
58
|
+
) {
|
|
59
|
+
const display = (name ?? '').replace(/[\r\n"<>]/g, '').trim();
|
|
60
|
+
return display ? `"${display}" <${address}>` : address;
|
|
61
|
+
}
|
|
62
|
+
|
|
26
63
|
export async function sendEmail(
|
|
27
64
|
data: {
|
|
28
65
|
to: string;
|
|
@@ -30,6 +67,10 @@ export async function sendEmail(
|
|
|
30
67
|
text: string;
|
|
31
68
|
html: string;
|
|
32
69
|
replyTo?: string;
|
|
70
|
+
tag?: string;
|
|
71
|
+
metadata?: Record<string, string>;
|
|
72
|
+
from?: string;
|
|
73
|
+
headers?: Record<string, string>;
|
|
33
74
|
},
|
|
34
75
|
options: {
|
|
35
76
|
fetch?: (
|
|
@@ -40,7 +81,12 @@ export async function sendEmail(
|
|
|
40
81
|
}
|
|
41
82
|
) {
|
|
42
83
|
if (!options.postmarkToken) {
|
|
43
|
-
throw new EmailDeliveryError(
|
|
84
|
+
throw new EmailDeliveryError(
|
|
85
|
+
'Postmark is not configured',
|
|
86
|
+
undefined,
|
|
87
|
+
false,
|
|
88
|
+
false
|
|
89
|
+
);
|
|
44
90
|
}
|
|
45
91
|
|
|
46
92
|
const response = await (options.fetch ?? fetch)(
|
|
@@ -53,39 +99,37 @@ export async function sendEmail(
|
|
|
53
99
|
'X-Postmark-Server-Token': options.postmarkToken,
|
|
54
100
|
},
|
|
55
101
|
body: JSON.stringify({
|
|
56
|
-
From: 'VRPlatform <notifications@vrplatform.app>',
|
|
102
|
+
From: data.from ?? 'VRPlatform <notifications@vrplatform.app>',
|
|
57
103
|
To: data.to,
|
|
58
104
|
Subject: data.subject,
|
|
59
105
|
ReplyTo: data.replyTo,
|
|
60
106
|
TextBody: data.text,
|
|
61
107
|
HtmlBody: data.html,
|
|
62
108
|
MessageStream: 'outbound',
|
|
109
|
+
Tag: data.tag,
|
|
110
|
+
Metadata: data.metadata,
|
|
111
|
+
Headers: data.headers
|
|
112
|
+
? Object.entries(data.headers).map(([Name, Value]) => ({
|
|
113
|
+
Name,
|
|
114
|
+
Value,
|
|
115
|
+
}))
|
|
116
|
+
: undefined,
|
|
63
117
|
}),
|
|
64
118
|
}
|
|
65
119
|
);
|
|
66
120
|
|
|
67
121
|
const providerResponse: unknown = await response.json().catch(() => ({}));
|
|
68
|
-
const responseErrorCode =
|
|
69
|
-
providerResponse !== null &&
|
|
70
|
-
typeof providerResponse === 'object' &&
|
|
71
|
-
'ErrorCode' in providerResponse &&
|
|
72
|
-
typeof providerResponse.ErrorCode === 'number'
|
|
73
|
-
? providerResponse.ErrorCode
|
|
74
|
-
: undefined;
|
|
75
|
-
const headerErrorCode = response.headers.get('X-PM-ApiErrorCode');
|
|
76
|
-
const errorCode =
|
|
77
|
-
responseErrorCode ??
|
|
78
|
-
(headerErrorCode && /^\d+$/.test(headerErrorCode)
|
|
79
|
-
? Number(headerErrorCode)
|
|
80
|
-
: undefined);
|
|
81
122
|
const postmarkErrorCode =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
123
|
+
parseOptional(postmarkResponseErrorCodeSchema, providerResponse) ??
|
|
124
|
+
parseOptional(
|
|
125
|
+
postmarkHeaderErrorCodeSchema,
|
|
126
|
+
response.headers.get('X-PM-ApiErrorCode')
|
|
127
|
+
);
|
|
87
128
|
|
|
88
|
-
if (
|
|
129
|
+
if (
|
|
130
|
+
!response.ok ||
|
|
131
|
+
(postmarkErrorCode !== undefined && postmarkErrorCode !== 0)
|
|
132
|
+
) {
|
|
89
133
|
const inactiveRecipient =
|
|
90
134
|
response.status === 422 && postmarkErrorCode === 406;
|
|
91
135
|
const details: EmailDeliveryFailureDetails = {
|
|
@@ -99,14 +143,34 @@ export async function sendEmail(
|
|
|
99
143
|
throw new EmailDeliveryError(
|
|
100
144
|
'Postmark recipient is inactive',
|
|
101
145
|
details,
|
|
102
|
-
true
|
|
146
|
+
true,
|
|
147
|
+
false
|
|
103
148
|
);
|
|
104
149
|
}
|
|
105
150
|
|
|
106
|
-
throw new EmailDeliveryError(
|
|
151
|
+
throw new EmailDeliveryError(
|
|
152
|
+
'Postmark rejected the email',
|
|
153
|
+
details,
|
|
154
|
+
false,
|
|
155
|
+
response.status === 429 || response.status >= 500
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const result = postmarkSuccessResponseSchema.safeParse(providerResponse);
|
|
160
|
+
if (!result.success) {
|
|
161
|
+
throw new EmailDeliveryError('Postmark returned an invalid response', {
|
|
162
|
+
provider: 'postmark',
|
|
163
|
+
providerCategory: 'rejected',
|
|
164
|
+
httpStatus: response.status,
|
|
165
|
+
...(postmarkErrorCode !== undefined ? { postmarkErrorCode } : {}),
|
|
166
|
+
});
|
|
107
167
|
}
|
|
108
168
|
|
|
109
|
-
return {
|
|
169
|
+
return {
|
|
170
|
+
httpStatus: response.status,
|
|
171
|
+
messageId: result.data.MessageID,
|
|
172
|
+
submittedAt: result.data.SubmittedAt,
|
|
173
|
+
};
|
|
110
174
|
}
|
|
111
175
|
|
|
112
176
|
export async function settleEmailDeliveries(deliveries: Promise<unknown>[]) {
|
|
@@ -152,15 +216,26 @@ export async function settleEmailDeliveries(deliveries: Promise<unknown>[]) {
|
|
|
152
216
|
};
|
|
153
217
|
if (unexpectedDeliveryError instanceof EmailDeliveryError) {
|
|
154
218
|
if (unexpectedDeliveryError.message === 'Postmark is not configured') {
|
|
155
|
-
throw new EmailDeliveryError(
|
|
219
|
+
throw new EmailDeliveryError(
|
|
220
|
+
'Postmark is not configured',
|
|
221
|
+
details,
|
|
222
|
+
false,
|
|
223
|
+
false
|
|
224
|
+
);
|
|
156
225
|
}
|
|
157
|
-
throw new EmailDeliveryError(
|
|
226
|
+
throw new EmailDeliveryError(
|
|
227
|
+
'Postmark rejected the email',
|
|
228
|
+
details,
|
|
229
|
+
false,
|
|
230
|
+
unexpectedDeliveryError.retryable
|
|
231
|
+
);
|
|
158
232
|
}
|
|
159
233
|
if (allExpected && firstDeliveryError instanceof EmailDeliveryError) {
|
|
160
234
|
throw new EmailDeliveryError(
|
|
161
235
|
'Postmark recipient is inactive',
|
|
162
236
|
details,
|
|
163
|
-
true
|
|
237
|
+
true,
|
|
238
|
+
false
|
|
164
239
|
);
|
|
165
240
|
}
|
|
166
241
|
throw new EmailDeliveryError('Email delivery failed', details);
|