@happyvertical/smrt-messages 0.70.3 → 0.72.0

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.
Files changed (59) hide show
  1. package/AGENTS.md +16 -6
  2. package/README.md +4 -2
  3. package/agents/attachment-storage.md +41 -0
  4. package/agents/send-approval.md +32 -12
  5. package/dist/access.d.ts +18 -1
  6. package/dist/access.d.ts.map +1 -1
  7. package/dist/attachment-storage.d.ts +50 -0
  8. package/dist/attachment-storage.d.ts.map +1 -0
  9. package/dist/chunks/{AttachmentCollection-Di2aRb2k.js → AttachmentCollection-CB5ssbOy.js} +40 -44
  10. package/dist/chunks/AttachmentCollection-CB5ssbOy.js.map +1 -0
  11. package/dist/chunks/{Email-tEYH6ZRw.js → Email--1mF4f-0.js} +6 -6
  12. package/dist/chunks/{Email-tEYH6ZRw.js.map → Email--1mF4f-0.js.map} +1 -1
  13. package/dist/chunks/{EmailAccountCollection-DWo_a-X5.js → EmailAccountCollection-BaWIVvI4.js} +136 -41
  14. package/dist/chunks/EmailAccountCollection-BaWIVvI4.js.map +1 -0
  15. package/dist/chunks/{EmailCollection-_Z2JY26I.js → EmailCollection-Cu7PTw8Y.js} +10 -4
  16. package/dist/chunks/{EmailCollection-_Z2JY26I.js.map → EmailCollection-Cu7PTw8Y.js.map} +1 -1
  17. package/dist/chunks/{EmailFolder-TyoFZVcC.js → EmailFolder-8CRSnmLs.js} +6 -6
  18. package/dist/chunks/{EmailFolder-TyoFZVcC.js.map → EmailFolder-8CRSnmLs.js.map} +1 -1
  19. package/dist/chunks/{EmailFolderCollection-CFtttkx6.js → EmailFolderCollection-e6QeSt5j.js} +2 -2
  20. package/dist/chunks/{EmailFolderCollection-CFtttkx6.js.map → EmailFolderCollection-e6QeSt5j.js.map} +1 -1
  21. package/dist/chunks/{EmailSender-bHwAYzBO.js → EmailSender-CQQMuVDg.js} +10 -4
  22. package/dist/chunks/EmailSender-CQQMuVDg.js.map +1 -0
  23. package/dist/chunks/{Message-DC877Gl7.js → Message-CHDqmhWf.js} +102 -43
  24. package/dist/chunks/Message-CHDqmhWf.js.map +1 -0
  25. package/dist/chunks/{MessageCollection-yZ6RyAtB.js → MessageCollection-B48ZrvCw.js} +7 -3
  26. package/dist/chunks/MessageCollection-B48ZrvCw.js.map +1 -0
  27. package/dist/chunks/{MessagingEndpointCollection-CNwpv_ZW.js → MessagingEndpointCollection-Z9eO6PSl.js} +2 -2
  28. package/dist/chunks/{MessagingEndpointCollection-CNwpv_ZW.js.map → MessagingEndpointCollection-Z9eO6PSl.js.map} +1 -1
  29. package/dist/collections/AttachmentCollection.d.ts.map +1 -1
  30. package/dist/collections/EmailCollection.d.ts.map +1 -1
  31. package/dist/collections/MessageCollection.d.ts.map +1 -1
  32. package/dist/connect.js +1 -1
  33. package/dist/host.browser.d.ts +2 -0
  34. package/dist/host.browser.d.ts.map +1 -1
  35. package/dist/host.browser.js +3 -1
  36. package/dist/host.browser.js.map +1 -1
  37. package/dist/host.d.ts +20 -0
  38. package/dist/host.d.ts.map +1 -1
  39. package/dist/host.js +39 -1
  40. package/dist/host.js.map +1 -1
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +18 -18
  44. package/dist/index.js.map +1 -1
  45. package/dist/manifest.json +1 -1
  46. package/dist/models/Attachment.d.ts +18 -11
  47. package/dist/models/Attachment.d.ts.map +1 -1
  48. package/dist/models/Message.d.ts +24 -12
  49. package/dist/models/Message.d.ts.map +1 -1
  50. package/dist/send-approval.d.ts.map +1 -1
  51. package/dist/senders/EmailSender.d.ts.map +1 -1
  52. package/dist/smrt-knowledge.json +13 -7
  53. package/dist/smrt-knowledge.okf.md +9 -5
  54. package/package.json +12 -12
  55. package/dist/chunks/AttachmentCollection-Di2aRb2k.js.map +0 -1
  56. package/dist/chunks/EmailAccountCollection-DWo_a-X5.js.map +0 -1
  57. package/dist/chunks/EmailSender-bHwAYzBO.js.map +0 -1
  58. package/dist/chunks/Message-DC877Gl7.js.map +0 -1
  59. package/dist/chunks/MessageCollection-yZ6RyAtB.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { $ as messagingPrincipalFromPermissions, A as configureMailAccess, C as MailAccessError, E as assertMailAccess, F as inMailSystemAccess, G as withoutListBounds, H as resetMailAccess, I as isMailScope, J as MESSAGES_ROLE_PERMISSION_MATRIX, K as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, L as isPersonMailPrincipal, M as deniedMailAccountIds, N as getEffectiveMailAccessConfigs, P as getMailAccessConfig, Q as ensureMessagingPermissionsRegistered, S as MAIL_SCOPES, T as assertHydratedMailAccess, U as resolveMailPrincipal, V as mailScopePermission, W as runWithMailSystemAccess, X as SEND_MESSAGES_PERMISSION, Y as MESSAGING_PERMISSION_DEFINITIONS, Z as assertMessagingPermission, _ as resetMailSendApprovals, b as Account, c as HeldSendError, et as seedMessagesRolePermissions, f as auditMailAction, g as mailSendBindingHash, i as AccountCollection, j as decideMailAccess, k as canAccessMailAccount, l as MailSendApprovalService, m as effectiveAgentSendPolicy, o as MailWriteBackUnsupportedError, p as configureMailSendApprovals, q as MANAGE_MESSAGE_ROUTES_PERMISSION, r as EmailAccount, s as APPROVE_HELD_SEND_PERMISSION, t as EmailAccountCollection, v as stampHandledBy, w as MailAccessService, x as MAIL_ACCOUNT_RESOURCE_TYPE, y as threadHandledBy, z as learnMailAccessOptions } from "./chunks/EmailAccountCollection-DWo_a-X5.js";
1
+ import { $ as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, A as MailAccessService, B as getMailAccessConfig, D as MAIL_ACCOUNT_RESOURCE_TYPE, E as Account, F as canAccessMailAccount, H as isMailScope, I as configureMailAccess, J as mailScopePermission, K as learnMailAccessOptions, L as decideMailAccess, M as assertMailAccess, O as MAIL_SCOPES, Q as withoutListBounds, R as deniedMailAccountIds, V as inMailSystemAccess, W as isPersonMailPrincipal, X as resolveMailPrincipal, Y as resetMailAccess, Z as runWithMailSystemAccess, _ as resetMailSendApprovals, at as ensureMessagingPermissionsRegistered, b as AttachmentStorageError, c as HeldSendError, et as MANAGE_MESSAGE_ROUTES_PERMISSION, f as auditMailAction, g as mailSendBindingHash, i as AccountCollection, it as assertMessagingPermission, j as assertHydratedMailAccess, k as MailAccessError, l as MailSendApprovalService, m as effectiveAgentSendPolicy, nt as MESSAGING_PERMISSION_DEFINITIONS, o as MailWriteBackUnsupportedError, ot as messagingPrincipalFromPermissions, p as configureMailSendApprovals, r as EmailAccount, rt as SEND_MESSAGES_PERMISSION, s as APPROVE_HELD_SEND_PERMISSION, st as seedMessagesRolePermissions, t as EmailAccountCollection, tt as MESSAGES_ROLE_PERMISSION_MATRIX, v as stampHandledBy, w as resetAttachmentStorage, x as configureAttachmentStorage, y as threadHandledBy, z as getEffectiveMailAccessConfigs } from "./chunks/EmailAccountCollection-BaWIVvI4.js";
2
2
  import { buildSqliteRebuildStatements, isDeepStrictEqual, normalizeIdentityEmail, queryGlobal, queryWithGlobals, readNotificationProfile, withSystemContext, withTenant } from "./host.js";
3
- import { r as Attachment, t as AttachmentCollection } from "./chunks/AttachmentCollection-Di2aRb2k.js";
4
- import { t as EmailFolder } from "./chunks/EmailFolder-TyoFZVcC.js";
3
+ import { r as Attachment, t as AttachmentCollection } from "./chunks/AttachmentCollection-CB5ssbOy.js";
4
+ import { t as EmailFolder } from "./chunks/EmailFolder-8CRSnmLs.js";
5
5
  import { d as withProtectedNotificationHandoff, f as PROFILE_NOTIFICATION_POLICY_PREFIX, l as protectedNotificationMetadata, m as profileNotificationPolicy, p as assertNotificationRecipientIdentity, t as ProtectedNotificationHandoffError } from "./chunks/protected-notification-handoff-mvaEZVp7.js";
6
- import { t as Message } from "./chunks/Message-DC877Gl7.js";
6
+ import { n as saveQueuedForSend, t as Message } from "./chunks/Message-CHDqmhWf.js";
7
7
  import { a as registerMessagingProvider, n as getMessagingProvider, o as ZulipSender, r as listMessagingProviders, s as TelegramSender, t as ensureBuiltinMessagingProvidersRegistered } from "./chunks/providers-Bz_F_ywF.js";
8
- import { t as MessageCollection } from "./chunks/MessageCollection-yZ6RyAtB.js";
9
- import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-CNwpv_ZW.js";
10
- import { t as Email } from "./chunks/Email-tEYH6ZRw.js";
11
- import { t as EmailCollection } from "./chunks/EmailCollection-_Z2JY26I.js";
12
- import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-CFtttkx6.js";
13
- import { t as EmailSender } from "./chunks/EmailSender-bHwAYzBO.js";
8
+ import { t as MessageCollection } from "./chunks/MessageCollection-B48ZrvCw.js";
9
+ import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-Z9eO6PSl.js";
10
+ import { t as Email } from "./chunks/Email--1mF4f-0.js";
11
+ import { t as EmailCollection } from "./chunks/EmailCollection-Cu7PTw8Y.js";
12
+ import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-e6QeSt5j.js";
13
+ import { t as EmailSender } from "./chunks/EmailSender-CQQMuVDg.js";
14
14
  import { t as SlackSender } from "./chunks/SlackSender-CetlSe6D.js";
15
15
  import { t as TweetSender } from "./chunks/TweetSender-Dw-TDxIB.js";
16
16
  import { GlobalInterceptors, ObjectRegistry, SmrtCollection, SmrtObject, SmrtRecipe, crossPackageRef, detectEngine, field, foreignKey, isUniqueViolationError, smrt, usesEmbeddedRevisionFallback, withEmbeddedWriteQueue } from "@happyvertical/smrt-core";
@@ -98,7 +98,7 @@ function createMailAccessInterceptor() {
98
98
  const row = instance;
99
99
  row.accountId = null;
100
100
  if (!row.messageId || !row.options) return;
101
- const { MessageCollection } = await import("./chunks/MessageCollection-yZ6RyAtB.js").then((n) => n.n);
101
+ const { MessageCollection } = await import("./chunks/MessageCollection-B48ZrvCw.js").then((n) => n.n);
102
102
  row.accountId = (await runWithMailSystemAccess(async () => (await MessageCollection.create(row.options)).get({ id: row.messageId })))?.accountId || null;
103
103
  },
104
104
  async afterList(className, results, context) {
@@ -172,13 +172,13 @@ var MailDraftService = class {
172
172
  }
173
173
  options;
174
174
  async account(accountId) {
175
- const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-DWo_a-X5.js").then((n) => n.n);
175
+ const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-BaWIVvI4.js").then((n) => n.n);
176
176
  const account = await runWithMailSystemAccess(async () => (await EmailAccountCollection.create(withoutListBounds(this.options))).get({ id: accountId }));
177
177
  if (!account?.id) throw new MailDraftError("Mail account not found.", 404);
178
178
  return account;
179
179
  }
180
180
  async stored(id) {
181
- const { EmailCollection } = await import("./chunks/EmailCollection-_Z2JY26I.js").then((n) => n.n);
181
+ const { EmailCollection } = await import("./chunks/EmailCollection-Cu7PTw8Y.js").then((n) => n.n);
182
182
  return await runWithMailSystemAccess(async () => (await EmailCollection.create(this.options)).get({ id }));
183
183
  }
184
184
  /** Create or update a draft. Returns the saved draft. */
@@ -203,7 +203,7 @@ var MailDraftService = class {
203
203
  draft = original.createReply({ replyAll: input.replyAll === true });
204
204
  await draft.initialize();
205
205
  } else {
206
- const { Email: EmailClass } = await import("./chunks/Email-tEYH6ZRw.js").then((n) => n.n);
206
+ const { Email: EmailClass } = await import("./chunks/Email--1mF4f-0.js").then((n) => n.n);
207
207
  draft = new (ObjectRegistry.resolveEffectiveConstructor(EmailClass))({
208
208
  ...this.options,
209
209
  tenantId: account.tenantId,
@@ -983,7 +983,7 @@ var EmailAttachment = class extends Attachment {
983
983
  */
984
984
  async getEmail() {
985
985
  if (!this.messageId) return null;
986
- const { EmailCollection } = await import("./chunks/EmailCollection-_Z2JY26I.js").then((n) => n.n);
986
+ const { EmailCollection } = await import("./chunks/EmailCollection-Cu7PTw8Y.js").then((n) => n.n);
987
987
  return await (await EmailCollection.create(this.options)).get({ id: this.messageId });
988
988
  }
989
989
  };
@@ -2689,7 +2689,7 @@ var CorrespondentService = class {
2689
2689
  return result;
2690
2690
  }
2691
2691
  async ownAddresses(accountIds) {
2692
- const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-DWo_a-X5.js").then((n) => n.n);
2692
+ const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-BaWIVvI4.js").then((n) => n.n);
2693
2693
  const accounts = await EmailAccountCollection.create({ db: this.options.db });
2694
2694
  const out = [];
2695
2695
  for (const id of accountIds) {
@@ -3978,7 +3978,7 @@ var PersonaMessagingService = class {
3978
3978
  message = email;
3979
3979
  } else message = new (ObjectRegistry.resolveEffectiveConstructor(Message))(base);
3980
3980
  await message.initialize();
3981
- await message.save();
3981
+ await saveQueuedForSend(message);
3982
3982
  const sendOptions = input.attachments?.length ? { attachments: input.attachments } : void 0;
3983
3983
  const delivery = await message.send(sendOptions);
3984
3984
  return {
@@ -4464,6 +4464,6 @@ ensureBuiltinMessagingProvidersRegistered();
4464
4464
  ensureMessagingPermissionsRegistered();
4465
4465
  ensureMailAccessEnforcementRegistered();
4466
4466
  //#endregion
4467
- export { APPROVE_HELD_SEND_PERMISSION, Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, CHANGE_FEED_PROVIDERS, Correspondent, CorrespondentCollection, CorrespondentService, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, HeldSendError, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, MAIL_SYNC_QUEUE, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGES_ROLE_PERMISSION_MATRIX, MESSAGING_PERMISSION_DEFINITIONS, MailAccessError, MailAccessService, MailDraftError, MailDraftService, MailSearchService, MailSendApprovalService, MailWriteBackUnsupportedError, MailboxRecipe, Message, MessageCollection, MessagingEndpoint, MessagingEndpointCollection, MessagingSettingsService, NOTIFICATION_DELIVERY_CHANNELS, NOTIFICATION_OPT_OUT_ALL_SCOPE, NOTIFICATION_OPT_OUT_SCOPE_PATTERN, NotificationDelivery, NotificationDeliveryCollection, NotificationOptOut, NotificationOptOutCollection, NotificationOptOutDeniedError, NotificationOptOutService, NotificationOutboxDeniedError, NotificationOutboxService, NotificationsRecipe, PROFILE_NOTIFICATION_POLICY_PREFIX, PersonaMessageRoute, PersonaMessageRouteCollection, PersonaMessagingService, SEND_MESSAGES_PERMISSION, SlackAccount, SlackMessage, SlackRecipe, SlackSender, TelegramAccount, TelegramSender, Tweet, TweetSender, TwitterAccount, USER_NOTIFICATION_SEVERITIES, UserNotification, UserNotificationCollection, UserNotificationService, Whitelist, WhitelistCollection, ZulipAccount, ZulipSender, assertMailAccess, assertMessagingPermission, assertNotificationProfileRecipientSchema, auditMailAction, buildNotificationLink, canAccessMailAccount, configureMailAccess, configureMailSendApprovals, decideMailAccess, deniedMailAccountIds, effectiveAgentSendPolicy, enqueueDueMailSyncs, enqueueMailSync, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, isMailScope, isPersonMailPrincipal, isValidNotificationOptOutScope, listMessagingProviders, mailScopePermission, mailSendBindingHash, mailSyncDedupeKey, messageSendTransport, messagingPrincipalFromPermissions, migrateNotificationProfileRecipients, normalizeCorrespondentAddress, notificationDeliveryCorrelationId, notificationDeliveryMessageId, optOutSuppression, planNotificationProfileRecipients, profileNotificationPolicy, readableMailAccounts, registerMessagingProvider, resetMailAccess, resetMailSendApprovals, resolveMailPrincipal, runWithMailSystemAccess, seedMessagesRolePermissions, stampHandledBy, threadHandledBy };
4467
+ export { APPROVE_HELD_SEND_PERMISSION, Account, AccountCollection, Attachment, AttachmentCollection, AttachmentStorageError, Blacklist, BlacklistCollection, CHANGE_FEED_PROVIDERS, Correspondent, CorrespondentCollection, CorrespondentService, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, HeldSendError, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, MAIL_SYNC_QUEUE, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGES_ROLE_PERMISSION_MATRIX, MESSAGING_PERMISSION_DEFINITIONS, MailAccessError, MailAccessService, MailDraftError, MailDraftService, MailSearchService, MailSendApprovalService, MailWriteBackUnsupportedError, MailboxRecipe, Message, MessageCollection, MessagingEndpoint, MessagingEndpointCollection, MessagingSettingsService, NOTIFICATION_DELIVERY_CHANNELS, NOTIFICATION_OPT_OUT_ALL_SCOPE, NOTIFICATION_OPT_OUT_SCOPE_PATTERN, NotificationDelivery, NotificationDeliveryCollection, NotificationOptOut, NotificationOptOutCollection, NotificationOptOutDeniedError, NotificationOptOutService, NotificationOutboxDeniedError, NotificationOutboxService, NotificationsRecipe, PROFILE_NOTIFICATION_POLICY_PREFIX, PersonaMessageRoute, PersonaMessageRouteCollection, PersonaMessagingService, SEND_MESSAGES_PERMISSION, SlackAccount, SlackMessage, SlackRecipe, SlackSender, TelegramAccount, TelegramSender, Tweet, TweetSender, TwitterAccount, USER_NOTIFICATION_SEVERITIES, UserNotification, UserNotificationCollection, UserNotificationService, Whitelist, WhitelistCollection, ZulipAccount, ZulipSender, assertMailAccess, assertMessagingPermission, assertNotificationProfileRecipientSchema, auditMailAction, buildNotificationLink, canAccessMailAccount, configureAttachmentStorage, configureMailAccess, configureMailSendApprovals, decideMailAccess, deniedMailAccountIds, effectiveAgentSendPolicy, enqueueDueMailSyncs, enqueueMailSync, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, isMailScope, isPersonMailPrincipal, isValidNotificationOptOutScope, listMessagingProviders, mailScopePermission, mailSendBindingHash, mailSyncDedupeKey, messageSendTransport, messagingPrincipalFromPermissions, migrateNotificationProfileRecipients, normalizeCorrespondentAddress, notificationDeliveryCorrelationId, notificationDeliveryMessageId, optOutSuppression, planNotificationProfileRecipients, profileNotificationPolicy, readableMailAccounts, registerMessagingProvider, resetAttachmentStorage, resetMailAccess, resetMailSendApprovals, resolveMailPrincipal, runWithMailSystemAccess, seedMessagesRolePermissions, stampHandledBy, threadHandledBy };
4468
4468
 
4469
4469
  //# sourceMappingURL=index.js.map