@jsb188/mday 1.1.8 → 1.1.10
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/package.json +39 -20
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/email.ts +28 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +14 -0
- package/src/constants/log-activityTexts.ts +54 -28
- package/src/constants/log.ts +82 -38
- package/src/constants/organization.ts +11 -2
- package/src/constants/product.ts +9 -33
- package/src/constants/report.ts +29 -10
- package/src/constants/sheet.ts +20 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +12 -0
- package/src/schemas/editLogEntry.ts +90 -44
- package/src/schemas/inboundContact.ts +72 -0
- package/src/schemas/logsQuery.ts +7 -272
- package/src/schemas/organization.ts +11 -174
- package/src/schemas/productsQuery.ts +2 -94
- package/src/schemas/reportsQuery.ts +8 -95
- package/src/types/account.d.ts +78 -0
- package/src/types/dataTable.d.ts +447 -0
- package/src/types/email.d.ts +71 -0
- package/src/types/inboundContact.d.ts +56 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +289 -178
- package/src/types/organization.d.ts +106 -50
- package/src/types/product.d.ts +7 -96
- package/src/types/report.d.ts +239 -152
- package/src/types/sheet.d.ts +298 -0
- package/src/types/storage.d.ts +161 -0
- package/src/types/workflow.d.ts +174 -0
- package/src/utils/dataTable.ts +834 -0
- package/src/utils/email.ts +113 -0
- package/src/utils/log.ts +30 -628
- package/src/utils/organization.ts +227 -44
- package/src/utils/product-calEvent.ts +7 -60
- package/src/utils/report.ts +158 -0
- package/src/utils/sheet.ts +170 -0
- package/src/utils/square.ts +22 -0
- package/src/utils/table-route.ts +146 -0
- package/src/utils/workflow.ts +212 -0
- package/tsconfig.json +12 -0
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/types/action.d.ts +0 -42
- package/src/utils/route-helpers.ts +0 -583
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { InboundEmailBodyFormatEnum } from '../types/email.d.ts';
|
|
2
|
+
|
|
3
|
+
type PostmarkAttachmentLike = {
|
|
4
|
+
Name?: string | null;
|
|
5
|
+
ContentType?: string | null;
|
|
6
|
+
ContentLength?: number | null;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type PostmarkInboundPayloadLike = {
|
|
10
|
+
TextBody?: string | null;
|
|
11
|
+
StrippedTextReply?: string | null;
|
|
12
|
+
HtmlBody?: string | null;
|
|
13
|
+
Attachments?: PostmarkAttachmentLike[] | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Limit optional Postmark text fields before displaying them.
|
|
18
|
+
*/
|
|
19
|
+
export function limitInboundEmailTextValue(value: string | null | undefined, maxLength: number): string | null {
|
|
20
|
+
return value ? value.substring(0, maxLength) : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Strip HTML tags from an inbound email HTML body for plain-text display.
|
|
25
|
+
*/
|
|
26
|
+
export function stripInboundEmailHtmlBody(value: string | null | undefined): string | null {
|
|
27
|
+
return value ? value.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim() : null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Return the preferred raw text source from a saved inbound email payload.
|
|
32
|
+
*/
|
|
33
|
+
export function getInboundEmailPayloadTextBody(
|
|
34
|
+
payload?: PostmarkInboundPayloadLike | null,
|
|
35
|
+
maxBodyLength = 12000,
|
|
36
|
+
): string | null {
|
|
37
|
+
const textBody = limitInboundEmailTextValue(
|
|
38
|
+
typeof payload?.TextBody === 'string' ? payload.TextBody : null,
|
|
39
|
+
maxBodyLength,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return textBody ||
|
|
43
|
+
limitInboundEmailTextValue(
|
|
44
|
+
typeof payload?.StrippedTextReply === 'string' ? payload.StrippedTextReply : null,
|
|
45
|
+
maxBodyLength,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Return the fallback HTML-derived text from a saved inbound email payload.
|
|
51
|
+
*/
|
|
52
|
+
export function getInboundEmailPayloadHtmlText(
|
|
53
|
+
payload?: PostmarkInboundPayloadLike | null,
|
|
54
|
+
maxBodyLength = 12000,
|
|
55
|
+
): string | null {
|
|
56
|
+
return limitInboundEmailTextValue(
|
|
57
|
+
typeof payload?.HtmlBody === 'string'
|
|
58
|
+
? stripInboundEmailHtmlBody(payload.HtmlBody)
|
|
59
|
+
: null,
|
|
60
|
+
maxBodyLength,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Return the display body format derived from a saved inbound email payload.
|
|
66
|
+
*/
|
|
67
|
+
export function getInboundEmailBodyFormat(
|
|
68
|
+
payload?: PostmarkInboundPayloadLike | null,
|
|
69
|
+
): InboundEmailBodyFormatEnum | null {
|
|
70
|
+
if (getInboundEmailPayloadTextBody(payload)) {
|
|
71
|
+
return 'TEXT';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (getInboundEmailPayloadHtmlText(payload)) {
|
|
75
|
+
return 'HTML_TEXT';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Return the display body text derived from a saved inbound email payload.
|
|
83
|
+
*/
|
|
84
|
+
export function getInboundEmailBodyText(
|
|
85
|
+
payload?: PostmarkInboundPayloadLike | null,
|
|
86
|
+
maxBodyLength = 12000,
|
|
87
|
+
): string {
|
|
88
|
+
return getInboundEmailPayloadTextBody(payload, maxBodyLength) ||
|
|
89
|
+
getInboundEmailPayloadHtmlText(payload, maxBodyLength) ||
|
|
90
|
+
'';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Return a compact preview text derived from a saved inbound email payload.
|
|
95
|
+
*/
|
|
96
|
+
export function getInboundEmailPreviewText(
|
|
97
|
+
payload?: PostmarkInboundPayloadLike | null,
|
|
98
|
+
): string {
|
|
99
|
+
return getInboundEmailBodyText(payload, 240).replace(/\s+/g, ' ').trim();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Return safe attachment metadata from a saved inbound email payload.
|
|
104
|
+
*/
|
|
105
|
+
export function getInboundEmailAttachments(payload?: PostmarkInboundPayloadLike | null) {
|
|
106
|
+
return Array.isArray(payload?.Attachments)
|
|
107
|
+
? payload.Attachments.map((attachment) => ({
|
|
108
|
+
name: attachment?.Name || null,
|
|
109
|
+
contentType: attachment?.ContentType || null,
|
|
110
|
+
contentLength: attachment?.ContentLength || null,
|
|
111
|
+
}))
|
|
112
|
+
: [];
|
|
113
|
+
}
|