@vrplatform/email 1.0.2-stage.445 → 1.0.2-stage.44505332089
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 +38 -3
- package/build/main/templates/OwnerStatementEmailTemplate.js +138 -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 +13 -0
- package/build/main/templates/Tax1099EmailTemplate.js +61 -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 +28 -3
- package/build/main/utils/send-email.js +142 -22
- 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 +38 -3
- package/build/module/templates/OwnerStatementEmailTemplate.js +137 -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 +13 -0
- package/build/module/templates/Tax1099EmailTemplate.js +56 -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 +28 -3
- package/build/module/utils/send-email.js +108 -22
- 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 +324 -14
- package/src/templates/SecondFactorResetEmailTemplate.tsx +71 -0
- package/src/templates/Tax1099ConsentWithdrawnEmailTemplate.tsx +56 -0
- package/src/templates/Tax1099EmailTemplate.tsx +100 -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 +184 -28
|
@@ -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,14 +1,65 @@
|
|
|
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
|
+
|
|
24
|
+
type EmailDeliveryFailureDetails = {
|
|
25
|
+
httpStatus: number;
|
|
26
|
+
postmarkErrorCode?: number;
|
|
27
|
+
provider: 'postmark';
|
|
28
|
+
providerCategory: 'inactiveRecipient' | 'rejected';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type EmailDeliveryErrorDetails =
|
|
32
|
+
| EmailDeliveryFailureDetails
|
|
33
|
+
| {
|
|
34
|
+
failureCount: number;
|
|
35
|
+
failures: EmailDeliveryFailureDetails[];
|
|
36
|
+
};
|
|
37
|
+
|
|
1
38
|
export class EmailDeliveryError extends Error {
|
|
2
39
|
constructor(
|
|
3
40
|
message: string,
|
|
4
|
-
public readonly details?:
|
|
5
|
-
public readonly expected = false
|
|
41
|
+
public readonly details?: EmailDeliveryErrorDetails,
|
|
42
|
+
public readonly expected = false,
|
|
43
|
+
public readonly retryable = true
|
|
6
44
|
) {
|
|
7
45
|
super(message);
|
|
8
46
|
this.name = 'EmailDeliveryError';
|
|
9
47
|
}
|
|
10
48
|
}
|
|
11
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
|
+
|
|
12
63
|
export async function sendEmail(
|
|
13
64
|
data: {
|
|
14
65
|
to: string;
|
|
@@ -16,6 +67,10 @@ export async function sendEmail(
|
|
|
16
67
|
text: string;
|
|
17
68
|
html: string;
|
|
18
69
|
replyTo?: string;
|
|
70
|
+
tag?: string;
|
|
71
|
+
metadata?: Record<string, string>;
|
|
72
|
+
from?: string;
|
|
73
|
+
headers?: Record<string, string>;
|
|
19
74
|
},
|
|
20
75
|
options: {
|
|
21
76
|
fetch?: (
|
|
@@ -26,7 +81,12 @@ export async function sendEmail(
|
|
|
26
81
|
}
|
|
27
82
|
) {
|
|
28
83
|
if (!options.postmarkToken) {
|
|
29
|
-
throw new EmailDeliveryError(
|
|
84
|
+
throw new EmailDeliveryError(
|
|
85
|
+
'Postmark is not configured',
|
|
86
|
+
undefined,
|
|
87
|
+
false,
|
|
88
|
+
false
|
|
89
|
+
);
|
|
30
90
|
}
|
|
31
91
|
|
|
32
92
|
const response = await (options.fetch ?? fetch)(
|
|
@@ -39,48 +99,144 @@ export async function sendEmail(
|
|
|
39
99
|
'X-Postmark-Server-Token': options.postmarkToken,
|
|
40
100
|
},
|
|
41
101
|
body: JSON.stringify({
|
|
42
|
-
From: 'VRPlatform <notifications@vrplatform.app>',
|
|
102
|
+
From: data.from ?? 'VRPlatform <notifications@vrplatform.app>',
|
|
43
103
|
To: data.to,
|
|
44
104
|
Subject: data.subject,
|
|
45
105
|
ReplyTo: data.replyTo,
|
|
46
106
|
TextBody: data.text,
|
|
47
107
|
HtmlBody: data.html,
|
|
48
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,
|
|
49
117
|
}),
|
|
50
118
|
}
|
|
51
119
|
);
|
|
52
120
|
|
|
53
121
|
const providerResponse: unknown = await response.json().catch(() => ({}));
|
|
54
|
-
const
|
|
55
|
-
providerResponse
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
122
|
+
const postmarkErrorCode =
|
|
123
|
+
parseOptional(postmarkResponseErrorCodeSchema, providerResponse) ??
|
|
124
|
+
parseOptional(
|
|
125
|
+
postmarkHeaderErrorCodeSchema,
|
|
126
|
+
response.headers.get('X-PM-ApiErrorCode')
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
!response.ok ||
|
|
131
|
+
(postmarkErrorCode !== undefined && postmarkErrorCode !== 0)
|
|
132
|
+
) {
|
|
133
|
+
const inactiveRecipient =
|
|
134
|
+
response.status === 422 && postmarkErrorCode === 406;
|
|
135
|
+
const details: EmailDeliveryFailureDetails = {
|
|
136
|
+
provider: 'postmark',
|
|
137
|
+
providerCategory: inactiveRecipient ? 'inactiveRecipient' : 'rejected',
|
|
138
|
+
httpStatus: response.status,
|
|
139
|
+
...(postmarkErrorCode !== undefined ? { postmarkErrorCode } : {}),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
if (inactiveRecipient) {
|
|
67
143
|
throw new EmailDeliveryError(
|
|
68
144
|
'Postmark recipient is inactive',
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
statusText: response.statusText,
|
|
73
|
-
},
|
|
74
|
-
true
|
|
145
|
+
details,
|
|
146
|
+
true,
|
|
147
|
+
false
|
|
75
148
|
);
|
|
76
149
|
}
|
|
77
150
|
|
|
78
|
-
throw new EmailDeliveryError(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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 } : {}),
|
|
82
166
|
});
|
|
83
167
|
}
|
|
84
168
|
|
|
85
|
-
return {
|
|
169
|
+
return {
|
|
170
|
+
httpStatus: response.status,
|
|
171
|
+
messageId: result.data.MessageID,
|
|
172
|
+
submittedAt: result.data.SubmittedAt,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export async function settleEmailDeliveries(deliveries: Promise<unknown>[]) {
|
|
177
|
+
const failures = (await Promise.allSettled(deliveries)).filter(
|
|
178
|
+
(result) => result.status === 'rejected'
|
|
179
|
+
);
|
|
180
|
+
if (failures.length === 0) return;
|
|
181
|
+
|
|
182
|
+
const unexpectedDeliveryError = failures.find(
|
|
183
|
+
(failure) =>
|
|
184
|
+
failure.reason instanceof EmailDeliveryError && !failure.reason.expected
|
|
185
|
+
)?.reason;
|
|
186
|
+
const allExpected = failures.every(
|
|
187
|
+
(failure) =>
|
|
188
|
+
failure.reason instanceof EmailDeliveryError && failure.reason.expected
|
|
189
|
+
);
|
|
190
|
+
const firstDeliveryError = failures.find(
|
|
191
|
+
(failure) => failure.reason instanceof EmailDeliveryError
|
|
192
|
+
)?.reason;
|
|
193
|
+
const failureDetails = failures.flatMap((failure) => {
|
|
194
|
+
if (
|
|
195
|
+
!(failure.reason instanceof EmailDeliveryError) ||
|
|
196
|
+
!failure.reason.details ||
|
|
197
|
+
!('provider' in failure.reason.details)
|
|
198
|
+
) {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
const { httpStatus, postmarkErrorCode, provider, providerCategory } =
|
|
202
|
+
failure.reason.details;
|
|
203
|
+
return [
|
|
204
|
+
{
|
|
205
|
+
httpStatus,
|
|
206
|
+
provider,
|
|
207
|
+
providerCategory,
|
|
208
|
+
...(postmarkErrorCode !== undefined ? { postmarkErrorCode } : {}),
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const details: EmailDeliveryErrorDetails = {
|
|
214
|
+
failureCount: failures.length,
|
|
215
|
+
failures: failureDetails,
|
|
216
|
+
};
|
|
217
|
+
if (unexpectedDeliveryError instanceof EmailDeliveryError) {
|
|
218
|
+
if (unexpectedDeliveryError.message === 'Postmark is not configured') {
|
|
219
|
+
throw new EmailDeliveryError(
|
|
220
|
+
'Postmark is not configured',
|
|
221
|
+
details,
|
|
222
|
+
false,
|
|
223
|
+
false
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
throw new EmailDeliveryError(
|
|
227
|
+
'Postmark rejected the email',
|
|
228
|
+
details,
|
|
229
|
+
false,
|
|
230
|
+
unexpectedDeliveryError.retryable
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
if (allExpected && firstDeliveryError instanceof EmailDeliveryError) {
|
|
234
|
+
throw new EmailDeliveryError(
|
|
235
|
+
'Postmark recipient is inactive',
|
|
236
|
+
details,
|
|
237
|
+
true,
|
|
238
|
+
false
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
throw new EmailDeliveryError('Email delivery failed', details);
|
|
86
242
|
}
|