@happyvertical/smrt-messages 0.62.14 → 0.64.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.
- package/dist/chunks/{AttachmentCollection-C0K7lITr.js → AttachmentCollection-C22O2GBe.js} +4 -4
- package/dist/chunks/{AttachmentCollection-C0K7lITr.js.map → AttachmentCollection-C22O2GBe.js.map} +1 -1
- package/dist/chunks/{Email-DWF2VG_4.js → Email-D9Kucvql.js} +185 -9
- package/dist/chunks/Email-D9Kucvql.js.map +1 -0
- package/dist/chunks/EmailAccountCollection-C3DBapV6.js +2472 -0
- package/dist/chunks/EmailAccountCollection-C3DBapV6.js.map +1 -0
- package/dist/chunks/{EmailCollection-8HeBXd0F.js → EmailCollection-DkcvN_Wu.js} +3 -3
- package/dist/chunks/{EmailCollection-8HeBXd0F.js.map → EmailCollection-DkcvN_Wu.js.map} +1 -1
- package/dist/chunks/{EmailFolder-Cl4sKRMB.js → EmailFolder-pYtOL92O.js} +6 -6
- package/dist/chunks/{EmailFolder-Cl4sKRMB.js.map → EmailFolder-pYtOL92O.js.map} +1 -1
- package/dist/chunks/{EmailFolderCollection-L0na2e1L.js → EmailFolderCollection-CZ9QoAZi.js} +2 -2
- package/dist/chunks/{EmailFolderCollection-L0na2e1L.js.map → EmailFolderCollection-CZ9QoAZi.js.map} +1 -1
- package/dist/chunks/{EmailSender-BiAI0LWU.js → EmailSender-CWImZKmx.js} +2 -2
- package/dist/chunks/{EmailSender-BiAI0LWU.js.map → EmailSender-CWImZKmx.js.map} +1 -1
- package/dist/chunks/{Message-CuvACyOv.js → Message-BkDh68z5.js} +69 -8
- package/dist/chunks/Message-BkDh68z5.js.map +1 -0
- package/dist/chunks/{MessageCollection-DOErodD3.js → MessageCollection-DPRfidhT.js} +2 -2
- package/dist/chunks/{MessageCollection-DOErodD3.js.map → MessageCollection-DPRfidhT.js.map} +1 -1
- package/dist/chunks/{MessagingEndpointCollection-CE3kQKQU.js → MessagingEndpointCollection-ByUH1RQh.js} +2 -2
- package/dist/chunks/{MessagingEndpointCollection-CE3kQKQU.js.map → MessagingEndpointCollection-ByUH1RQh.js.map} +1 -1
- package/dist/connect.js +1 -1
- package/dist/html-to-text.d.ts +13 -0
- package/dist/html-to-text.d.ts.map +1 -0
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +4 -4
- package/dist/models/Email.d.ts +5 -0
- package/dist/models/Email.d.ts.map +1 -1
- package/dist/models/Message.d.ts +2 -0
- package/dist/models/Message.d.ts.map +1 -1
- package/dist/models/SlackMessage.d.ts +10 -0
- package/dist/models/SlackMessage.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +6 -6
- package/dist/smrt-knowledge.okf.md +1 -1
- package/package.json +12 -12
- package/dist/chunks/Email-DWF2VG_4.js.map +0 -1
- package/dist/chunks/EmailAccountCollection-OLTzu2T0.js +0 -2472
- package/dist/chunks/EmailAccountCollection-OLTzu2T0.js.map +0 -1
- package/dist/chunks/Message-CuvACyOv.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageCollection-DOErodD3.js","names":[],"sources":["../../src/collections/MessageCollection.ts"],"sourcesContent":["/**\n * MessageCollection - Unified collection for polymorphic message queries\n *\n * Queries the messages table with STI, returning correct subclass instances.\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { queryGlobal, queryWithGlobals } from '../host.js';\nimport { Message } from '../models/Message';\nimport type { MessageSearchFilters } from '../types';\n\nexport class MessageCollection extends SmrtCollection<Message> {\n static readonly _itemClass = Message;\n\n /**\n * Search messages with filters\n */\n async search(\n query: string,\n filters?: MessageSearchFilters,\n ): Promise<Message[]> {\n let messages = await this.list({});\n\n // Filter by query\n if (query) {\n const lowerQuery = query.toLowerCase();\n messages = messages.filter(\n (m) =>\n m.subject?.toLowerCase().includes(lowerQuery) ||\n m.body?.toLowerCase().includes(lowerQuery) ||\n m.fromAddress?.toLowerCase().includes(lowerQuery) ||\n m.fromName?.toLowerCase().includes(lowerQuery),\n );\n }\n\n // Apply filters\n if (filters) {\n if (filters.accountIds && filters.accountIds.length > 0) {\n messages = messages.filter((m) =>\n filters.accountIds?.includes(m.accountId),\n );\n }\n if (filters.messageType) {\n messages = messages.filter((m) => {\n const metaType = (m as { _meta_type?: string })._meta_type || '';\n return metaType.includes(filters.messageType as string);\n });\n }\n if (filters.from) {\n const fromLower = filters.from.toLowerCase();\n messages = messages.filter(\n (m) =>\n m.fromAddress?.toLowerCase().includes(fromLower) ||\n m.fromName?.toLowerCase().includes(fromLower),\n );\n }\n if (filters.to) {\n const toLower = filters.to.toLowerCase();\n messages = messages.filter((m) =>\n m.toAddresses?.toLowerCase().includes(toLower),\n );\n }\n if (filters.isRead !== undefined) {\n messages = messages.filter((m) => m.isRead === filters.isRead);\n }\n if (filters.isFlagged !== undefined) {\n messages = messages.filter((m) => m.isFlagged === filters.isFlagged);\n }\n if (filters.sinceDate) {\n messages = messages.filter(\n (m) => m.date && m.date >= (filters.sinceDate as Date),\n );\n }\n if (filters.beforeDate) {\n messages = messages.filter(\n (m) => m.date && m.date < (filters.beforeDate as Date),\n );\n }\n if (filters.query) {\n const q = filters.query.toLowerCase();\n messages = messages.filter(\n (m) =>\n m.subject?.toLowerCase().includes(q) ||\n m.body?.toLowerCase().includes(q),\n );\n }\n }\n\n return messages;\n }\n\n /**\n * Get messages by multiple accounts\n */\n async getByAccounts(accountIds: string[]): Promise<Message[]> {\n const allMessages = await this.list({});\n return allMessages.filter((m) => accountIds.includes(m.accountId));\n }\n\n /**\n * Get messages by STI type.\n *\n * Accepts either the full discriminator (e.g. \"@happyvertical/smrt-messages:Email\")\n * or the short type name (e.g. \"Email\").\n */\n async getByType(messageType: string): Promise<Message[]> {\n if (messageType.includes(':') || messageType.startsWith('@')) {\n return await this.list({ where: { _meta_type: messageType } });\n }\n const allMessages = await this.list({});\n return allMessages.filter((m) => {\n const metaType = (m as { _meta_type?: string })._meta_type || '';\n return metaType.endsWith(`:${messageType}`);\n });\n }\n\n /**\n * Get unread messages\n */\n async getUnread(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { isRead: false };\n if (accountId) {\n where.accountId = accountId;\n }\n return await this.list({ where });\n }\n\n /**\n * Get flagged messages\n */\n async getFlagged(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { isFlagged: true };\n if (accountId) {\n where.accountId = accountId;\n }\n return await this.list({ where });\n }\n\n /**\n * Get recent messages\n */\n async getRecent(limit = 20, accountId?: string): Promise<Message[]> {\n const allMessages = await this.list({\n where: accountId ? { accountId } : undefined,\n });\n\n return allMessages\n .sort((a, b) => {\n const dateA = a.date?.getTime() || 0;\n const dateB = b.date?.getTime() || 0;\n return dateB - dateA;\n })\n .slice(0, limit);\n }\n\n /**\n * Get messages by thread\n */\n async getByThread(threadId: string): Promise<Message[]> {\n return await this.list({ where: { threadId } });\n }\n\n /**\n * Mark multiple messages as read\n */\n async markAllRead(messageIds: string[]): Promise<void> {\n for (const id of messageIds) {\n const message = await this.get({ id });\n if (message) {\n await message.markRead();\n }\n }\n }\n\n /**\n * Get message statistics for an account\n */\n async getAccountStats(accountId: string): Promise<{\n total: number;\n unread: number;\n flagged: number;\n byType: Record<string, number>;\n }> {\n const messages = await this.list({ where: { accountId } });\n const byType: Record<string, number> = {};\n\n for (const msg of messages) {\n const metaType = (msg as { _meta_type?: string })._meta_type || 'Unknown';\n const shortType = metaType.split(':').pop() || metaType;\n byType[shortType] = (byType[shortType] || 0) + 1;\n }\n\n return {\n total: messages.length,\n unread: messages.filter((m) => !m.isRead).length,\n flagged: messages.filter((m) => m.isFlagged).length,\n byType,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Send / Draft Queries\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * Get draft messages\n */\n async getDrafts(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'draft' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get sent messages\n */\n async getSent(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'sent' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get scheduled messages\n */\n async getScheduled(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'scheduled' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get messages that failed to send\n */\n async getFailedSends(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'failed' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get outbox (pending + sending + scheduled)\n */\n async getOutbox(accountId?: string): Promise<Message[]> {\n const allMessages = await this.list({\n where: accountId ? { accountId } : undefined,\n });\n return allMessages.filter(\n (m) =>\n m.sendStatus === 'pending' ||\n m.sendStatus === 'sending' ||\n m.sendStatus === 'scheduled',\n );\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Tenant Helper Methods\n // ─────────────────────────────────────────────────────────────────────────\n\n async findByTenant(tenantId: string): Promise<Message[]> {\n return this.list({ where: { tenantId } });\n }\n\n // Message is the @TenantScoped STI base, so an explicit `tenant_id IS NULL`\n // filter via list() throws and unflagged raw SQL is blocked under an active\n // tenant context (#1596). Route through the raw helpers — no `_meta_type`\n // scope so the base collection still returns ALL message subtypes.\n async findGlobal(): Promise<Message[]> {\n return queryGlobal<Message>(this);\n }\n\n async findWithGlobals(tenantId: string): Promise<Message[]> {\n return queryWithGlobals<Message>(this, tenantId, 'Message.findWithGlobals');\n }\n}\n"],"mappings":";;;;;;AAWO,IAAM,oBAAN,cAAgC,eAAwB;CAC7D,OAAgB,aAAa;;;;CAK7B,MAAM,OACJ,OACA,SACoB;EACpB,IAAI,WAAW,MAAM,KAAK,KAAK,CAAC,CAAC;EAGjC,IAAI,OAAO;GACT,MAAM,aAAa,MAAM,YAAY;GACrC,WAAW,SAAS,QACjB,MACC,EAAE,SAAS,YAAY,CAAA,C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;CAKA,MAAM,UAAU,WAAwC;EAItD,QAAO,MAHmB,KAAK,KAAK,EAClC,OAAO,YAAY,EAAE,UAAU,IAAI,KAAA,EACrC,CAAC,EAAA,CACkB,QAChB,MACC,EAAE,eAAe,aACjB,EAAE,eAAe,aACjB,EAAE,eAAe,WACrB;CACF;CAMA,MAAM,aAAa,UAAsC;EACvD,OAAO,KAAK,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;CAC1C;CAMA,MAAM,aAAiC;EACrC,OAAO,YAAqB,IAAI;CAClC;CAEA,MAAM,gBAAgB,UAAsC;EAC1D,OAAO,iBAA0B,MAAM,UAAU,yBAAyB;CAC5E;AACF"}
|
|
1
|
+
{"version":3,"file":"MessageCollection-DPRfidhT.js","names":[],"sources":["../../src/collections/MessageCollection.ts"],"sourcesContent":["/**\n * MessageCollection - Unified collection for polymorphic message queries\n *\n * Queries the messages table with STI, returning correct subclass instances.\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { queryGlobal, queryWithGlobals } from '../host.js';\nimport { Message } from '../models/Message';\nimport type { MessageSearchFilters } from '../types';\n\nexport class MessageCollection extends SmrtCollection<Message> {\n static readonly _itemClass = Message;\n\n /**\n * Search messages with filters\n */\n async search(\n query: string,\n filters?: MessageSearchFilters,\n ): Promise<Message[]> {\n let messages = await this.list({});\n\n // Filter by query\n if (query) {\n const lowerQuery = query.toLowerCase();\n messages = messages.filter(\n (m) =>\n m.subject?.toLowerCase().includes(lowerQuery) ||\n m.body?.toLowerCase().includes(lowerQuery) ||\n m.fromAddress?.toLowerCase().includes(lowerQuery) ||\n m.fromName?.toLowerCase().includes(lowerQuery),\n );\n }\n\n // Apply filters\n if (filters) {\n if (filters.accountIds && filters.accountIds.length > 0) {\n messages = messages.filter((m) =>\n filters.accountIds?.includes(m.accountId),\n );\n }\n if (filters.messageType) {\n messages = messages.filter((m) => {\n const metaType = (m as { _meta_type?: string })._meta_type || '';\n return metaType.includes(filters.messageType as string);\n });\n }\n if (filters.from) {\n const fromLower = filters.from.toLowerCase();\n messages = messages.filter(\n (m) =>\n m.fromAddress?.toLowerCase().includes(fromLower) ||\n m.fromName?.toLowerCase().includes(fromLower),\n );\n }\n if (filters.to) {\n const toLower = filters.to.toLowerCase();\n messages = messages.filter((m) =>\n m.toAddresses?.toLowerCase().includes(toLower),\n );\n }\n if (filters.isRead !== undefined) {\n messages = messages.filter((m) => m.isRead === filters.isRead);\n }\n if (filters.isFlagged !== undefined) {\n messages = messages.filter((m) => m.isFlagged === filters.isFlagged);\n }\n if (filters.sinceDate) {\n messages = messages.filter(\n (m) => m.date && m.date >= (filters.sinceDate as Date),\n );\n }\n if (filters.beforeDate) {\n messages = messages.filter(\n (m) => m.date && m.date < (filters.beforeDate as Date),\n );\n }\n if (filters.query) {\n const q = filters.query.toLowerCase();\n messages = messages.filter(\n (m) =>\n m.subject?.toLowerCase().includes(q) ||\n m.body?.toLowerCase().includes(q),\n );\n }\n }\n\n return messages;\n }\n\n /**\n * Get messages by multiple accounts\n */\n async getByAccounts(accountIds: string[]): Promise<Message[]> {\n const allMessages = await this.list({});\n return allMessages.filter((m) => accountIds.includes(m.accountId));\n }\n\n /**\n * Get messages by STI type.\n *\n * Accepts either the full discriminator (e.g. \"@happyvertical/smrt-messages:Email\")\n * or the short type name (e.g. \"Email\").\n */\n async getByType(messageType: string): Promise<Message[]> {\n if (messageType.includes(':') || messageType.startsWith('@')) {\n return await this.list({ where: { _meta_type: messageType } });\n }\n const allMessages = await this.list({});\n return allMessages.filter((m) => {\n const metaType = (m as { _meta_type?: string })._meta_type || '';\n return metaType.endsWith(`:${messageType}`);\n });\n }\n\n /**\n * Get unread messages\n */\n async getUnread(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { isRead: false };\n if (accountId) {\n where.accountId = accountId;\n }\n return await this.list({ where });\n }\n\n /**\n * Get flagged messages\n */\n async getFlagged(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { isFlagged: true };\n if (accountId) {\n where.accountId = accountId;\n }\n return await this.list({ where });\n }\n\n /**\n * Get recent messages\n */\n async getRecent(limit = 20, accountId?: string): Promise<Message[]> {\n const allMessages = await this.list({\n where: accountId ? { accountId } : undefined,\n });\n\n return allMessages\n .sort((a, b) => {\n const dateA = a.date?.getTime() || 0;\n const dateB = b.date?.getTime() || 0;\n return dateB - dateA;\n })\n .slice(0, limit);\n }\n\n /**\n * Get messages by thread\n */\n async getByThread(threadId: string): Promise<Message[]> {\n return await this.list({ where: { threadId } });\n }\n\n /**\n * Mark multiple messages as read\n */\n async markAllRead(messageIds: string[]): Promise<void> {\n for (const id of messageIds) {\n const message = await this.get({ id });\n if (message) {\n await message.markRead();\n }\n }\n }\n\n /**\n * Get message statistics for an account\n */\n async getAccountStats(accountId: string): Promise<{\n total: number;\n unread: number;\n flagged: number;\n byType: Record<string, number>;\n }> {\n const messages = await this.list({ where: { accountId } });\n const byType: Record<string, number> = {};\n\n for (const msg of messages) {\n const metaType = (msg as { _meta_type?: string })._meta_type || 'Unknown';\n const shortType = metaType.split(':').pop() || metaType;\n byType[shortType] = (byType[shortType] || 0) + 1;\n }\n\n return {\n total: messages.length,\n unread: messages.filter((m) => !m.isRead).length,\n flagged: messages.filter((m) => m.isFlagged).length,\n byType,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Send / Draft Queries\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * Get draft messages\n */\n async getDrafts(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'draft' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get sent messages\n */\n async getSent(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'sent' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get scheduled messages\n */\n async getScheduled(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'scheduled' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get messages that failed to send\n */\n async getFailedSends(accountId?: string): Promise<Message[]> {\n const where: Record<string, unknown> = { sendStatus: 'failed' };\n if (accountId) where.accountId = accountId;\n return await this.list({ where });\n }\n\n /**\n * Get outbox (pending + sending + scheduled)\n */\n async getOutbox(accountId?: string): Promise<Message[]> {\n const allMessages = await this.list({\n where: accountId ? { accountId } : undefined,\n });\n return allMessages.filter(\n (m) =>\n m.sendStatus === 'pending' ||\n m.sendStatus === 'sending' ||\n m.sendStatus === 'scheduled',\n );\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Tenant Helper Methods\n // ─────────────────────────────────────────────────────────────────────────\n\n async findByTenant(tenantId: string): Promise<Message[]> {\n return this.list({ where: { tenantId } });\n }\n\n // Message is the @TenantScoped STI base, so an explicit `tenant_id IS NULL`\n // filter via list() throws and unflagged raw SQL is blocked under an active\n // tenant context (#1596). Route through the raw helpers — no `_meta_type`\n // scope so the base collection still returns ALL message subtypes.\n async findGlobal(): Promise<Message[]> {\n return queryGlobal<Message>(this);\n }\n\n async findWithGlobals(tenantId: string): Promise<Message[]> {\n return queryWithGlobals<Message>(this, tenantId, 'Message.findWithGlobals');\n }\n}\n"],"mappings":";;;;;;AAWO,IAAM,oBAAN,cAAgC,eAAwB;CAC7D,OAAgB,aAAa;;;;CAK7B,MAAM,OACJ,OACA,SACoB;EACpB,IAAI,WAAW,MAAM,KAAK,KAAK,CAAC,CAAC;EAGjC,IAAI,OAAO;GACT,MAAM,aAAa,MAAM,YAAY;GACrC,WAAW,SAAS,QACjB,MACC,EAAE,SAAS,YAAY,CAAA,CAAE,SAAS,UAAU,KAC5C,EAAE,MAAM,YAAY,CAAA,CAAE,SAAS,UAAU,KACzC,EAAE,aAAa,YAAY,CAAA,CAAE,SAAS,UAAU,KAChD,EAAE,UAAU,YAAY,CAAA,CAAE,SAAS,UAAU,CACjD;EACF;EAGA,IAAI,SAAS;GACX,IAAI,QAAQ,cAAc,QAAQ,WAAW,SAAS,GACpD,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K,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;CAC1C;CAMA,MAAM,aAAiC;EACrC,OAAO,YAAqB,IAAI;CAClC;CAEA,MAAM,gBAAgB,UAAsC;EAC1D,OAAO,iBAA0B,MAAM,UAAU,yBAAyB;CAC5E;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import "./EmailAccountCollection-
|
|
2
|
+
import "./EmailAccountCollection-C3DBapV6.js";
|
|
3
3
|
import { SmrtCollection, SmrtObject, crossPackageRef, field, smrt } from "@happyvertical/smrt-core";
|
|
4
4
|
import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy/decorators";
|
|
5
5
|
//#region src/models/MessagingEndpoint.ts
|
|
@@ -94,4 +94,4 @@ var MessagingEndpointCollection = class extends SmrtCollection {
|
|
|
94
94
|
//#endregion
|
|
95
95
|
export { MessagingEndpointCollection_exports as n, MessagingEndpoint as r, MessagingEndpointCollection as t };
|
|
96
96
|
|
|
97
|
-
//# sourceMappingURL=MessagingEndpointCollection-
|
|
97
|
+
//# sourceMappingURL=MessagingEndpointCollection-ByUH1RQh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagingEndpointCollection-
|
|
1
|
+
{"version":3,"file":"MessagingEndpointCollection-ByUH1RQh.js","names":[],"sources":["../../src/models/MessagingEndpoint.ts","../../src/collections/MessagingEndpointCollection.ts"],"sourcesContent":["import type { SmrtObjectOptions } from '@happyvertical/smrt-core';\n// Register the package manifest before this module's @smrt() decorator\n// runs, whichever chunk the library build places it in (#3098).\nimport '../__smrt-register__.js';\nimport {\n crossPackageRef,\n field,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy/decorators';\nimport type { MessagingChannel, MessagingEndpointOptions } from '../types.js';\n\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'messaging_endpoints',\n api: { include: ['list', 'get'] },\n mcp: { include: ['list', 'get'] },\n cli: { include: ['list', 'get'] },\n conflictColumns: ['tenant_id', 'channel', 'label'],\n})\nexport class MessagingEndpoint extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-messages\";\n @tenantId()\n tenantId = '';\n\n @crossPackageRef('@happyvertical/smrt-profiles:Profile', { nullable: true })\n profileId: string | null = null;\n\n @field({ required: true, requiredFor: 'identity' })\n label = '';\n\n @field({ required: true })\n channel: MessagingChannel = 'email';\n\n /** Provider-specific destination JSON. Hidden from generated read surfaces. */\n @field({ required: true, sensitive: true })\n address = '{}';\n\n isActive = true;\n verifiedAt: Date | null = null;\n createdAt = new Date();\n updatedAt = new Date();\n\n constructor(options: MessagingEndpointOptions = {}) {\n super(options as SmrtObjectOptions);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.profileId !== undefined) this.profileId = options.profileId;\n if (options.label !== undefined) this.label = options.label;\n if (options.channel !== undefined) this.channel = options.channel;\n if (options.address !== undefined) this.address = options.address;\n if (options.isActive !== undefined) this.isActive = options.isActive;\n if (options.verifiedAt !== undefined) this.verifiedAt = options.verifiedAt;\n if (options.createdAt !== undefined) this.createdAt = options.createdAt;\n if (options.updatedAt !== undefined) this.updatedAt = options.updatedAt;\n }\n\n getAddress<T extends Record<string, unknown> = Record<string, unknown>>(): T {\n try {\n return JSON.parse(this.address) as T;\n } catch {\n return {} as T;\n }\n }\n\n setAddress(address: Record<string, unknown>): void {\n this.address = JSON.stringify(address);\n }\n\n getMaskedAddress(): string {\n const address = this.getAddress();\n const visible =\n address.email ??\n address.chatId ??\n address.to ??\n address.stream ??\n address.phoneNumber;\n if (typeof visible !== 'string' && typeof visible !== 'number')\n return '••••';\n const value = String(visible);\n if (value.includes('@')) {\n const [name, domain] = value.split('@');\n return `${name.slice(0, 2)}•••@${domain}`;\n }\n return value.length <= 4 ? '••••' : `••••${value.slice(-4)}`;\n }\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport { MessagingEndpoint } from '../models/MessagingEndpoint.js';\n\nexport class MessagingEndpointCollection extends SmrtCollection<MessagingEndpoint> {\n static readonly _itemClass = MessagingEndpoint;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBO,IAAM,oBAAN,cAAgC,WAAW;CAEhD,WAAW;CAGX,YAA2B;CAG3B,QAAQ;CAGR,UAA4B;CAI5B,UAAU;CAEV,WAAW;CACX,aAA0B;CAC1B,4BAAY,IAAI,KAAK;CACrB,4BAAY,IAAI,KAAK;CAErB,YAAY,UAAoC,CAAC,GAAG;EAClD,MAAM,OAA4B;EAClC,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,WAAW,QAAQ;EAC5D,IAAI,QAAQ,cAAc,KAAA,GAAW,KAAK,YAAY,QAAQ;EAC9D,IAAI,QAAQ,UAAU,KAAA,GAAW,KAAK,QAAQ,QAAQ;EACtD,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,UAAU,QAAQ;EAC1D,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,UAAU,QAAQ;EAC1D,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,WAAW,QAAQ;EAC5D,IAAI,QAAQ,eAAe,KAAA,GAAW,KAAK,aAAa,QAAQ;EAChE,IAAI,QAAQ,cAAc,KAAA,GAAW,KAAK,YAAY,QAAQ;EAC9D,IAAI,QAAQ,cAAc,KAAA,GAAW,KAAK,YAAY,QAAQ;CAChE;CAEA,aAA6E;EAC3E,IAAI;GACF,OAAO,KAAK,MAAM,KAAK,OAAO;EAChC,QAAQ;GACN,OAAO,CAAC;EACV;CACF;CAEA,WAAW,SAAwC;EACjD,KAAK,UAAU,KAAK,UAAU,OAAO;CACvC;CAEA,mBAA2B;EACzB,MAAM,UAAU,KAAK,WAAW;EAChC,MAAM,UACJ,QAAQ,SACR,QAAQ,UACR,QAAQ,MACR,QAAQ,UACR,QAAQ;EACV,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,OAAO;EACT,MAAM,QAAQ,OAAO,OAAO;EAC5B,IAAI,MAAM,SAAS,GAAG,GAAG;GACvB,MAAM,CAAC,MAAM,UAAU,MAAM,MAAM,GAAG;GACtC,OAAO,GAAG,KAAK,MAAM,GAAG,CAAC,EAAC,qBAAO;EACnC;EACA,OAAO,MAAM,UAAU,IAAI,SAAS,2BAAO,MAAM,MAAM,EAAE;CAC3D;AACF;AAhEoD,cAAvC,mBAA8C,mBAAkB,8BAAA;AAE3E,gBAAA,CADC,SAAS,CAAA,GADC,kBAEX,WAAA,YAAA,CAAA;AAGA,gBAAA,CADC,gBAAgB,wCAAwC,EAAE,UAAU,KAAK,CAAC,CAAA,GAJhE,kBAKX,WAAA,aAAA,CAAA;AAGA,gBAAA,CADC,MAAM;CAAE,UAAU;CAAM,aAAa;AAAW,CAAC,CAAA,GAPvC,kBAQX,WAAA,SAAA,CAAA;AAGA,gBAAA,CADC,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAVd,kBAWX,WAAA,WAAA,CAAA;AAIA,gBAAA,CADC,MAAM;CAAE,UAAU;CAAM,WAAW;AAAK,CAAC,CAAA,GAd/B,kBAeX,WAAA,WAAA,CAAA;AAfW,oBAAN,gBAAA,CARN,aAAa,EAAE,MAAM,WAAW,CAAC,GACjC,KAAK;CACJ,WAAW;CACX,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,iBAAiB;EAAC;EAAa;EAAW;CAAO;AACnD,CAAC,CAAA,GACY,iBAAA;;;;AClBN,IAAM,8BAAN,cAA0C,eAAkC;CACjF,OAAgB,aAAa;AAC/B"}
|
package/dist/connect.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as EmailAccount, t as EmailAccountCollection } from "./chunks/EmailAccountCollection-
|
|
1
|
+
import { r as EmailAccount, t as EmailAccountCollection } from "./chunks/EmailAccountCollection-C3DBapV6.js";
|
|
2
2
|
import { withTenant } from "./host.js";
|
|
3
3
|
import { ObjectRegistry } from "@happyvertical/smrt-core";
|
|
4
4
|
import { ConnectError, ConnectStateCollection, beginConnect, buildOAuth2AuthorizeUrl, consumeConnect, discoverOidcEndpoints, exchangeOAuth2Code, fetchOidcUserInfo } from "@happyvertical/smrt-secrets/connect";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear-time HTML to plain text for quoting HTML-only mail in drafts.
|
|
3
|
+
*
|
|
4
|
+
* Single forward scan, no backtracking regexes, input capped at
|
|
5
|
+
* HTML_TO_TEXT_MAX_INPUT. Markup is never passed through: tags are dropped,
|
|
6
|
+
* and the content of script/style/head/title/template/noscript elements and
|
|
7
|
+
* comments is dropped. Text hidden by CSS (display:none etc.) is NOT detected
|
|
8
|
+
* and remains in the output.
|
|
9
|
+
*/
|
|
10
|
+
export declare const HTML_TO_TEXT_MAX_INPUT: number;
|
|
11
|
+
export declare const HTML_TO_TEXT_TRUNCATED = "[\u2026truncated]";
|
|
12
|
+
export declare function htmlToText(html: string): string;
|
|
13
|
+
//# sourceMappingURL=html-to-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-to-text.d.ts","sourceRoot":"","sources":["../src/html-to-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAa,CAAC;AAmEjD,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAmC1D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuF/C"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { A as deniedMailAccountIds, B as runWithMailSystemAccess, C as MailAccessError, D as canAccessMailAccount, E as assertMailAccess, F as isPersonMailPrincipal, G as MESSAGING_PERMISSION_DEFINITIONS, H as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, I as learnMailAccessOptions, J as ensureMessagingPermissionsRegistered, K as SEND_MESSAGES_PERMISSION, L as mailScopePermission, M as getMailAccessConfig, N as inMailSystemAccess, O as configureMailAccess, P as isMailScope, R as resetMailAccess, S as MAIL_SCOPES, T as assertHydratedMailAccess, U as MANAGE_MESSAGE_ROUTES_PERMISSION, V as withoutListBounds, W as MESSAGES_ROLE_PERMISSION_MATRIX, X as seedMessagesRolePermissions, Y as messagingPrincipalFromPermissions, _ as resetMailSendApprovals, b as Account, c as HeldSendError, f as auditMailAction, g as mailSendBindingHash, i as AccountCollection, j as getEffectiveMailAccessConfigs, k as decideMailAccess, l as MailSendApprovalService, m as effectiveAgentSendPolicy, o as MailWriteBackUnsupportedError, p as configureMailSendApprovals, q as assertMessagingPermission, 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 resolveMailPrincipal } from "./chunks/EmailAccountCollection-
|
|
1
|
+
import { A as deniedMailAccountIds, B as runWithMailSystemAccess, C as MailAccessError, D as canAccessMailAccount, E as assertMailAccess, F as isPersonMailPrincipal, G as MESSAGING_PERMISSION_DEFINITIONS, H as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, I as learnMailAccessOptions, J as ensureMessagingPermissionsRegistered, K as SEND_MESSAGES_PERMISSION, L as mailScopePermission, M as getMailAccessConfig, N as inMailSystemAccess, O as configureMailAccess, P as isMailScope, R as resetMailAccess, S as MAIL_SCOPES, T as assertHydratedMailAccess, U as MANAGE_MESSAGE_ROUTES_PERMISSION, V as withoutListBounds, W as MESSAGES_ROLE_PERMISSION_MATRIX, X as seedMessagesRolePermissions, Y as messagingPrincipalFromPermissions, _ as resetMailSendApprovals, b as Account, c as HeldSendError, f as auditMailAction, g as mailSendBindingHash, i as AccountCollection, j as getEffectiveMailAccessConfigs, k as decideMailAccess, l as MailSendApprovalService, m as effectiveAgentSendPolicy, o as MailWriteBackUnsupportedError, p as configureMailSendApprovals, q as assertMessagingPermission, 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 resolveMailPrincipal } from "./chunks/EmailAccountCollection-C3DBapV6.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-
|
|
4
|
-
import { t as EmailFolder } from "./chunks/EmailFolder-
|
|
3
|
+
import { r as Attachment, t as AttachmentCollection } from "./chunks/AttachmentCollection-C22O2GBe.js";
|
|
4
|
+
import { t as EmailFolder } from "./chunks/EmailFolder-pYtOL92O.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-
|
|
6
|
+
import { t as Message } from "./chunks/Message-BkDh68z5.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-
|
|
9
|
-
import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-
|
|
10
|
-
import { t as Email } from "./chunks/Email-
|
|
11
|
-
import { t as EmailCollection } from "./chunks/EmailCollection-
|
|
12
|
-
import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-
|
|
13
|
-
import { t as EmailSender } from "./chunks/EmailSender-
|
|
8
|
+
import { t as MessageCollection } from "./chunks/MessageCollection-DPRfidhT.js";
|
|
9
|
+
import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-ByUH1RQh.js";
|
|
10
|
+
import { t as Email } from "./chunks/Email-D9Kucvql.js";
|
|
11
|
+
import { t as EmailCollection } from "./chunks/EmailCollection-DkcvN_Wu.js";
|
|
12
|
+
import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-CZ9QoAZi.js";
|
|
13
|
+
import { t as EmailSender } from "./chunks/EmailSender-CWImZKmx.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-
|
|
101
|
+
const { MessageCollection } = await import("./chunks/MessageCollection-DPRfidhT.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-
|
|
175
|
+
const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-C3DBapV6.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-
|
|
181
|
+
const { EmailCollection } = await import("./chunks/EmailCollection-DkcvN_Wu.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-
|
|
206
|
+
const { Email: EmailClass } = await import("./chunks/Email-D9Kucvql.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-
|
|
986
|
+
const { EmailCollection } = await import("./chunks/EmailCollection-DkcvN_Wu.js").then((n) => n.n);
|
|
987
987
|
return await (await EmailCollection.create(this.options)).get({ id: this.messageId });
|
|
988
988
|
}
|
|
989
989
|
};
|
|
@@ -1296,6 +1296,25 @@ var SlackMessage = class extends Message {
|
|
|
1296
1296
|
if (options.blocks !== void 0) this.blocks = options.blocks;
|
|
1297
1297
|
}
|
|
1298
1298
|
/**
|
|
1299
|
+
* Reply in the same channel and thread. `channelId` is routing identity
|
|
1300
|
+
* (SlackSender posts to it), so it is restored after the base draft reset;
|
|
1301
|
+
* a reply to a top-level message starts that message's thread.
|
|
1302
|
+
*/
|
|
1303
|
+
createReply(options) {
|
|
1304
|
+
const reply = super.createReply(options);
|
|
1305
|
+
reply.channelId = this.channelId;
|
|
1306
|
+
reply.channelName = this.channelName;
|
|
1307
|
+
reply.slackThreadTs = this.slackThreadTs || this.slackTs;
|
|
1308
|
+
return reply;
|
|
1309
|
+
}
|
|
1310
|
+
/** Forward into the same channel, outside the original's thread. */
|
|
1311
|
+
createForward() {
|
|
1312
|
+
const forward = super.createForward();
|
|
1313
|
+
forward.channelId = this.channelId;
|
|
1314
|
+
forward.channelName = this.channelName;
|
|
1315
|
+
return forward;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1299
1318
|
* Get reactions as parsed array
|
|
1300
1319
|
*/
|
|
1301
1320
|
getReactions() {
|
|
@@ -2670,7 +2689,7 @@ var CorrespondentService = class {
|
|
|
2670
2689
|
return result;
|
|
2671
2690
|
}
|
|
2672
2691
|
async ownAddresses(accountIds) {
|
|
2673
|
-
const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-
|
|
2692
|
+
const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-C3DBapV6.js").then((n) => n.n);
|
|
2674
2693
|
const accounts = await EmailAccountCollection.create({ db: this.options.db });
|
|
2675
2694
|
const out = [];
|
|
2676
2695
|
for (const id of accountIds) {
|