@happyvertical/smrt-messages 0.55.17 → 0.55.19
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/AGENTS.md +5 -0
- package/README.md +38 -0
- package/dist/chunks/{AccountCollection-BM28F2y8.js → AccountCollection-Dx0lbVLI.js} +2 -2
- package/dist/chunks/{AccountCollection-BM28F2y8.js.map → AccountCollection-Dx0lbVLI.js.map} +1 -1
- package/dist/chunks/{Email-CclqFojc.js → Email-C9hOgH04.js} +28 -3
- package/dist/chunks/Email-C9hOgH04.js.map +1 -0
- package/dist/chunks/{EmailFolder-DtvYtwiz.js → EmailFolder-CuKuqDcO.js} +2 -2
- package/dist/chunks/{EmailFolder-DtvYtwiz.js.map → EmailFolder-CuKuqDcO.js.map} +1 -1
- package/dist/chunks/{Message-CwqRAiRu.js → Message-CO2FQ7ZK.js} +4 -4
- package/dist/chunks/{Message-CwqRAiRu.js.map → Message-CO2FQ7ZK.js.map} +1 -1
- package/dist/chunks/{MessageCollection-DTmvgr8c.js → MessageCollection-BE1dm4Da.js} +2 -2
- package/dist/chunks/{MessageCollection-DTmvgr8c.js.map → MessageCollection-BE1dm4Da.js.map} +1 -1
- package/dist/chunks/__smrt-register__-DOpa0lnF.js +6 -0
- package/dist/chunks/__smrt-register__-DOpa0lnF.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -15
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +3 -3
- package/dist/models/Attachment.d.ts +4 -0
- package/dist/models/Attachment.d.ts.map +1 -1
- package/dist/models/Email.d.ts +13 -1
- package/dist/models/Email.d.ts.map +1 -1
- package/dist/senders/EmailSender.d.ts +12 -2
- package/dist/senders/EmailSender.d.ts.map +1 -1
- package/dist/services/PersonaMessagingService.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +7 -7
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/chunks/Email-CclqFojc.js.map +0 -1
- package/dist/chunks/__smrt-register__-C6vkgxXs.js +0 -6
- package/dist/chunks/__smrt-register__-C6vkgxXs.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,6 @@ export { ZulipSender } from './senders/ZulipSender.js';
|
|
|
46
46
|
export { type MessagingAccountInput, type MessagingAccountView, type MessagingEndpointInput, type MessagingEndpointView, MessagingSettingsService, type PersonaMessageRouteInput, } from './services/MessagingSettingsService.js';
|
|
47
47
|
export { type PersonaMessageSendResult, PersonaMessagingService, } from './services/PersonaMessagingService.js';
|
|
48
48
|
export { type UserNotificationInput, type UserNotificationListOptions, type UserNotificationNotifyResult, type UserNotificationScope, UserNotificationService, } from './services/UserNotificationService.js';
|
|
49
|
-
export type { AccountOptions, AccountSearchFilters, AccountType, AttachmentOptions, EmailAccountOptions, EmailAccountSearchFilters, EmailAttachmentOptions, EmailFolderOptions, EmailFolderSearchFilters, EmailOptions, EmailSearchFilters, KnownMessagingChannel, MessageOptions, MessageSearchFilters, MessageSenderInterface, MessageSendResult, MessageType, MessagingChannel, MessagingEndpointOptions, PersonaMessageRouteOptions, ProviderType, SendEmailOptions, SendMessageOptions, SendPersonaMessageOptions, SendSlackOptions, SendStatus, SendTweetOptions, SlackAccountOptions, SlackMessageOptions, SyncOptions, SyncProgress, SyncResult, TweetOptions, TwitterAccountOptions, } from "./types.js";
|
|
49
|
+
export type { AccountOptions, AccountSearchFilters, AccountType, AttachmentOptions, EmailAccountOptions, EmailAccountSearchFilters, EmailAttachmentOptions, EmailFolderOptions, EmailFolderSearchFilters, EmailOptions, EmailSearchFilters, KnownMessagingChannel, MessageOptions, MessageSearchFilters, MessageSenderInterface, MessageSendResult, MessageType, MessagingChannel, MessagingEndpointOptions, PersonaMessageRouteOptions, ProviderType, SendEmailAttachment, SendEmailOptions, SendMessageOptions, SendPersonaMessageOptions, SendSlackOptions, SendStatus, SendTweetOptions, SlackAccountOptions, SlackMessageOptions, SyncOptions, SyncProgress, SyncResult, TweetOptions, TwitterAccountOptions, } from "./types.js";
|
|
50
50
|
export { MailboxRecipe, NotificationsRecipe } from './recipes.js';
|
|
51
51
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,wBAAwB,CAAC;AAShC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAoC,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAiC,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAqB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAsC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAAyC,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAA+B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAqC,CAAC;AAE5E,OAAO,EAAE,KA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AoB,EACpB,WAAW,EACX,iBAAiB,EAEjB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EAErB,cAAc,EAEd,oBAAoB,EACpB,sBAAsB,EAEtB,iBAAiB,EAEjB,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,0BAA0B,EAC1B,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EAEnB,WAAW,EACX,YAAY,EACZ,UAAU,EAEV,YAAY,EACZ,qBAAqB,GACtB,MAAM,YAAS,CAAC;AAKjB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunks/rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import "./chunks/__smrt-register__-
|
|
2
|
+
import "./chunks/__smrt-register__-DOpa0lnF.js";
|
|
3
3
|
import { a as registerMessagingProvider, n as getMessagingProvider, o as ZulipSender, r as listMessagingProviders, s as TelegramSender, t as ensureBuiltinMessagingProvidersRegistered } from "./chunks/providers-4iLula-V.js";
|
|
4
|
-
import { r as Account, t as AccountCollection } from "./chunks/AccountCollection-
|
|
5
|
-
import { t as Message } from "./chunks/Message-
|
|
6
|
-
import { t as MessageCollection } from "./chunks/MessageCollection-
|
|
7
|
-
import { t as Email } from "./chunks/Email-
|
|
8
|
-
import { t as EmailFolder } from "./chunks/EmailFolder-
|
|
4
|
+
import { r as Account, t as AccountCollection } from "./chunks/AccountCollection-Dx0lbVLI.js";
|
|
5
|
+
import { t as Message } from "./chunks/Message-CO2FQ7ZK.js";
|
|
6
|
+
import { t as MessageCollection } from "./chunks/MessageCollection-BE1dm4Da.js";
|
|
7
|
+
import { t as Email } from "./chunks/Email-C9hOgH04.js";
|
|
8
|
+
import { t as EmailFolder } from "./chunks/EmailFolder-CuKuqDcO.js";
|
|
9
9
|
import { t as SlackSender } from "./chunks/SlackSender-CjSvwY1K.js";
|
|
10
10
|
import { t as TweetSender } from "./chunks/TweetSender-CcLPNNi1.js";
|
|
11
11
|
import { SmrtCollection, SmrtObject, SmrtRecipe, crossPackageRef, field, foreignKey, importOptionalDependency, isUniqueViolationError, smrt } from "@happyvertical/smrt-core";
|
|
@@ -69,6 +69,15 @@ var __decorateClass$12 = (decorators, target, key, kind) => {
|
|
|
69
69
|
return result;
|
|
70
70
|
};
|
|
71
71
|
var __publicField$12 = (obj, key, value) => __defNormalProp$12(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
72
|
+
function splitAbsolutePath(filePath) {
|
|
73
|
+
const windows = /^[A-Za-z]:[\\/]/.test(filePath);
|
|
74
|
+
if (!windows && !filePath.startsWith("/")) return null;
|
|
75
|
+
const cut = windows ? Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\")) : filePath.lastIndexOf("/");
|
|
76
|
+
return {
|
|
77
|
+
dir: filePath.slice(0, cut) || filePath.slice(0, cut + 1),
|
|
78
|
+
base: filePath.slice(cut + 1)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
72
81
|
var Attachment = class extends SmrtObject {
|
|
73
82
|
tenantId = null;
|
|
74
83
|
messageId = "";
|
|
@@ -98,7 +107,7 @@ var Attachment = class extends SmrtObject {
|
|
|
98
107
|
*/
|
|
99
108
|
async getMessage() {
|
|
100
109
|
if (!this.messageId) return null;
|
|
101
|
-
const { MessageCollection } = await import("./chunks/MessageCollection-
|
|
110
|
+
const { MessageCollection } = await import("./chunks/MessageCollection-BE1dm4Da.js").then((n) => n.n);
|
|
102
111
|
return await (await MessageCollection.create(this.options)).get({ id: this.messageId });
|
|
103
112
|
}
|
|
104
113
|
/**
|
|
@@ -157,12 +166,21 @@ var Attachment = class extends SmrtObject {
|
|
|
157
166
|
* The files SDK is loaded through core's bundler-invisible optional-import
|
|
158
167
|
* boundary so it never enters provider-neutral consumer bundles (#1979).
|
|
159
168
|
* Absence of the SDK at runtime degrades to the existing null contract.
|
|
169
|
+
*
|
|
170
|
+
* The local provider joins every path onto its base path (the process cwd
|
|
171
|
+
* by default), so an absolute `filePath` is rooted at its own directory, and
|
|
172
|
+
* the bytes are read raw: decoding a PDF as UTF-8 corrupts it (#3808).
|
|
160
173
|
*/
|
|
161
174
|
async readContent() {
|
|
162
175
|
if (!this.filePath) return null;
|
|
163
176
|
try {
|
|
164
|
-
const { getFilesystem } = await importOptionalDependency("@happyvertical/files", "Import '@happyvertical/smrt-core/filesystem' (or '@happyvertical/smrt-assets/filesystem') during server startup to read externally-stored attachments in bundled builds.");
|
|
165
|
-
|
|
177
|
+
const { getFilesystem, initializeProviders } = await importOptionalDependency("@happyvertical/files", "Import '@happyvertical/smrt-core/filesystem' (or '@happyvertical/smrt-assets/filesystem') during server startup to read externally-stored attachments in bundled builds.");
|
|
178
|
+
await initializeProviders?.();
|
|
179
|
+
const split = splitAbsolutePath(this.filePath);
|
|
180
|
+
const data = await (await getFilesystem(split ? {
|
|
181
|
+
type: "local",
|
|
182
|
+
basePath: split.dir
|
|
183
|
+
} : { type: "local" })).read(split ? split.base : this.filePath, { raw: true });
|
|
166
184
|
return data instanceof Buffer ? data : Buffer.from(data);
|
|
167
185
|
} catch {
|
|
168
186
|
return null;
|
|
@@ -670,7 +688,7 @@ var EmailAccount = class extends Account {
|
|
|
670
688
|
for (const folderName of foldersToSync) try {
|
|
671
689
|
let folder = await folderCollection.getByPath(accountId, folderName);
|
|
672
690
|
if (!folder) {
|
|
673
|
-
const { EmailFolder } = await import("./chunks/EmailFolder-
|
|
691
|
+
const { EmailFolder } = await import("./chunks/EmailFolder-CuKuqDcO.js").then((n) => n.n);
|
|
674
692
|
folder = new EmailFolder({
|
|
675
693
|
...this.childOptions(),
|
|
676
694
|
accountId,
|
|
@@ -695,7 +713,7 @@ var EmailAccount = class extends Account {
|
|
|
695
713
|
result.messagesSkipped++;
|
|
696
714
|
continue;
|
|
697
715
|
}
|
|
698
|
-
const { Email } = await import("./chunks/Email-
|
|
716
|
+
const { Email } = await import("./chunks/Email-C9hOgH04.js").then((n) => n.n);
|
|
699
717
|
let email = existingEmail;
|
|
700
718
|
if (!email) {
|
|
701
719
|
email = new Email({
|
|
@@ -1905,10 +1923,20 @@ var EmailSender = class {
|
|
|
1905
1923
|
isReady() {
|
|
1906
1924
|
return this.client.isConnected();
|
|
1907
1925
|
}
|
|
1908
|
-
async send(message,
|
|
1926
|
+
async send(message, options) {
|
|
1909
1927
|
const toAddresses = message.getToAddresses();
|
|
1910
1928
|
const ccAddresses = message.getCcAddresses();
|
|
1911
1929
|
const bccAddresses = message.getBccAddresses();
|
|
1930
|
+
let attachments;
|
|
1931
|
+
try {
|
|
1932
|
+
attachments = await this.collectAttachments(message, options);
|
|
1933
|
+
} catch (error) {
|
|
1934
|
+
return {
|
|
1935
|
+
success: false,
|
|
1936
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1937
|
+
sentAt: /* @__PURE__ */ new Date()
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1912
1940
|
const emailMessage = {
|
|
1913
1941
|
from: {
|
|
1914
1942
|
name: message.fromName || this.account.name,
|
|
@@ -1929,7 +1957,8 @@ var EmailSender = class {
|
|
|
1929
1957
|
subject: message.subject,
|
|
1930
1958
|
text: message.textBody || message.body,
|
|
1931
1959
|
html: message.htmlBody || void 0,
|
|
1932
|
-
inReplyTo: message.inReplyTo || void 0
|
|
1960
|
+
inReplyTo: message.inReplyTo || void 0,
|
|
1961
|
+
attachments: attachments.length > 0 ? attachments : void 0
|
|
1933
1962
|
};
|
|
1934
1963
|
try {
|
|
1935
1964
|
const result = await this.client.send(emailMessage);
|
|
@@ -1949,6 +1978,47 @@ var EmailSender = class {
|
|
|
1949
1978
|
};
|
|
1950
1979
|
}
|
|
1951
1980
|
}
|
|
1981
|
+
/**
|
|
1982
|
+
* The message's stored `Attachment` rows followed by the send-time bytes.
|
|
1983
|
+
*
|
|
1984
|
+
* Stored rows are listed through the message's own options, so the lookup
|
|
1985
|
+
* runs under the same tenant context as the message. A row's file is read
|
|
1986
|
+
* through `Attachment.readContent()`, the package's one attachment-reading
|
|
1987
|
+
* seam, so the bytes are handed to the transport rather than a path it
|
|
1988
|
+
* would have to resolve itself.
|
|
1989
|
+
*/
|
|
1990
|
+
async collectAttachments(message, options) {
|
|
1991
|
+
const resolved = [];
|
|
1992
|
+
const stored = message.isPersisted ? await message.getAttachments() : [];
|
|
1993
|
+
for (const attachment of stored) {
|
|
1994
|
+
if (message.tenantId && attachment.tenantId && attachment.tenantId !== message.tenantId) throw new Error(`Attachment "${attachment.filename}" belongs to another tenant than its message.`);
|
|
1995
|
+
if (!attachment.filePath) throw new Error(`Attachment "${attachment.filename}" has no stored file to send` + (attachment.sourceUrl ? " (a sourceUrl is not fetched at send time)." : "."));
|
|
1996
|
+
const content = await attachment.readContent();
|
|
1997
|
+
if (!content) throw new Error(`Attachment "${attachment.filename}" could not be read from "${attachment.filePath}": the file is missing or unreadable, or the files SDK is not loaded (see Attachment.readContent()).`);
|
|
1998
|
+
resolved.push({
|
|
1999
|
+
filename: attachment.filename,
|
|
2000
|
+
contentType: attachment.contentType || "application/octet-stream",
|
|
2001
|
+
size: content.length,
|
|
2002
|
+
content,
|
|
2003
|
+
contentId: attachment.contentId || void 0,
|
|
2004
|
+
contentDisposition: attachment.contentDisposition
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
for (const attachment of options?.attachments ?? []) {
|
|
2008
|
+
if (!attachment.filename) throw new Error("A send-time attachment needs a filename.");
|
|
2009
|
+
if (!attachment.content) throw new Error(`Send-time attachment "${attachment.filename}" has no content.`);
|
|
2010
|
+
const content = Buffer.isBuffer(attachment.content) ? attachment.content : Buffer.from(attachment.content.buffer, attachment.content.byteOffset, attachment.content.byteLength);
|
|
2011
|
+
resolved.push({
|
|
2012
|
+
filename: attachment.filename,
|
|
2013
|
+
contentType: attachment.contentType || "application/octet-stream",
|
|
2014
|
+
size: content.length,
|
|
2015
|
+
content,
|
|
2016
|
+
contentId: attachment.contentId,
|
|
2017
|
+
contentDisposition: attachment.contentDisposition ?? "attachment"
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
return resolved;
|
|
2021
|
+
}
|
|
1952
2022
|
};
|
|
1953
2023
|
//#endregion
|
|
1954
2024
|
//#region src/services/MessagingSettingsService.ts
|
|
@@ -2166,6 +2236,7 @@ var PersonaMessagingService = class {
|
|
|
2166
2236
|
if (!account || account.tenantId !== this.options.tenantId || !account.isActive) throw new Error("The selected messaging account is unavailable.");
|
|
2167
2237
|
if (!endpoint || endpoint.tenantId !== this.options.tenantId || !endpoint.isActive) throw new Error("The selected messaging endpoint is unavailable.");
|
|
2168
2238
|
if (account.channelType !== endpoint.channel) throw new Error("The selected messaging route has mismatched channels.");
|
|
2239
|
+
if (input.attachments?.length && endpoint.channel !== "email") throw new Error("Attachments are only supported on email routes.");
|
|
2169
2240
|
let message;
|
|
2170
2241
|
const base = {
|
|
2171
2242
|
db: this.options.db,
|
|
@@ -2184,14 +2255,16 @@ var PersonaMessagingService = class {
|
|
|
2184
2255
|
if (!address.email) throw new Error("Email endpoint has no address.");
|
|
2185
2256
|
const email = new Email({
|
|
2186
2257
|
...base,
|
|
2187
|
-
textBody: base.body
|
|
2258
|
+
textBody: base.body,
|
|
2259
|
+
hasAttachments: Boolean(input.attachments?.length)
|
|
2188
2260
|
});
|
|
2189
2261
|
email.setToAddresses([{ address: address.email }]);
|
|
2190
2262
|
message = email;
|
|
2191
2263
|
} else message = new Message(base);
|
|
2192
2264
|
await message.initialize();
|
|
2193
2265
|
await message.save();
|
|
2194
|
-
const
|
|
2266
|
+
const sendOptions = input.attachments?.length ? { attachments: input.attachments } : void 0;
|
|
2267
|
+
const delivery = await message.send(sendOptions);
|
|
2195
2268
|
return {
|
|
2196
2269
|
routeId: route.id ?? "",
|
|
2197
2270
|
messageId: message.id ?? "",
|