@happyvertical/smrt-messages 0.62.7 → 0.62.9
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 +30 -0
- package/dist/chunks/{AttachmentCollection-nTqD75n8.js → AttachmentCollection-CqMr6vDW.js} +4 -4
- package/dist/chunks/{AttachmentCollection-nTqD75n8.js.map → AttachmentCollection-CqMr6vDW.js.map} +1 -1
- package/dist/chunks/{Email-DKcIiMxB.js → Email-HQRz_jXr.js} +9 -6
- package/dist/chunks/Email-HQRz_jXr.js.map +1 -0
- package/dist/chunks/EmailAccountCollection-D5RrI88X.js +1555 -0
- package/dist/chunks/EmailAccountCollection-D5RrI88X.js.map +1 -0
- package/dist/chunks/{EmailCollection-BYeuWWsP.js → EmailCollection-BitVR0qy.js} +3 -3
- package/dist/chunks/{EmailCollection-BYeuWWsP.js.map → EmailCollection-BitVR0qy.js.map} +1 -1
- package/dist/chunks/{EmailFolder-UMGpXTQ7.js → EmailFolder-94T__o1R.js} +6 -6
- package/dist/chunks/{EmailFolder-UMGpXTQ7.js.map → EmailFolder-94T__o1R.js.map} +1 -1
- package/dist/chunks/{EmailFolderCollection-DHZKwe1H.js → EmailFolderCollection-B6jWiIRV.js} +2 -2
- package/dist/chunks/{EmailFolderCollection-DHZKwe1H.js.map → EmailFolderCollection-B6jWiIRV.js.map} +1 -1
- package/dist/chunks/{Message-M8INXZs5.js → Message-GEH6EbM0.js} +6 -6
- package/dist/chunks/{Message-M8INXZs5.js.map → Message-GEH6EbM0.js.map} +1 -1
- package/dist/chunks/{MessageCollection-CT0O_7wG.js → MessageCollection-CeBjGYG0.js} +2 -2
- package/dist/chunks/{MessageCollection-CT0O_7wG.js.map → MessageCollection-CeBjGYG0.js.map} +1 -1
- package/dist/chunks/{MessagingEndpointCollection-DrNvP8GM.js → MessagingEndpointCollection-CgxxGRXx.js} +2 -2
- package/dist/chunks/{MessagingEndpointCollection-DrNvP8GM.js.map → MessagingEndpointCollection-CgxxGRXx.js.map} +1 -1
- package/dist/chunks/{SlackSender-CjSvwY1K.js → SlackSender-CetlSe6D.js} +2 -2
- package/dist/chunks/{SlackSender-CjSvwY1K.js.map → SlackSender-CetlSe6D.js.map} +1 -1
- package/dist/chunks/{TweetSender-CcLPNNi1.js → TweetSender-Dw-TDxIB.js} +2 -2
- package/dist/chunks/{TweetSender-CcLPNNi1.js.map → TweetSender-Dw-TDxIB.js.map} +1 -1
- package/dist/chunks/{providers-4iLula-V.js → providers-Bz_F_ywF.js} +36 -1
- package/dist/chunks/{providers-4iLula-V.js.map → providers-Bz_F_ywF.js.map} +1 -1
- package/dist/collections/EmailAccountCollection.d.ts.map +1 -1
- package/dist/connect.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -18
- package/dist/index.js.map +1 -1
- package/dist/mail-sync-jobs.d.ts +48 -0
- package/dist/mail-sync-jobs.d.ts.map +1 -0
- package/dist/mail-sync.d.ts +58 -0
- package/dist/mail-sync.d.ts.map +1 -0
- package/dist/manifest.json +158 -34
- package/dist/models/Email.d.ts +1 -0
- package/dist/models/Email.d.ts.map +1 -1
- package/dist/models/EmailAccount.d.ts +29 -2
- package/dist/models/EmailAccount.d.ts.map +1 -1
- package/dist/providers/email.js +3 -2
- package/dist/providers/email.js.map +1 -1
- package/dist/providers/slack.js +2 -2
- package/dist/providers/twitter.js +2 -2
- package/dist/providers.d.ts.map +1 -1
- package/dist/recipes.d.ts +1 -1
- package/dist/smrt-knowledge.json +66 -10
- package/dist/smrt-knowledge.okf.md +3 -2
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -16
- package/dist/chunks/Email-DKcIiMxB.js.map +0 -1
- package/dist/chunks/EmailAccountCollection-DtCuHcB4.js +0 -1224
- package/dist/chunks/EmailAccountCollection-DtCuHcB4.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagingEndpointCollection-
|
|
1
|
+
{"version":3,"file":"MessagingEndpointCollection-CgxxGRXx.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,IA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ACjC,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { n as getMessagingProvider } from "./providers-
|
|
2
|
+
import { n as getMessagingProvider } from "./providers-Bz_F_ywF.js";
|
|
3
3
|
//#region src/senders/SlackSender.ts
|
|
4
4
|
var SlackSender_exports = /* @__PURE__ */ __exportAll({ SlackSender: () => SlackSender });
|
|
5
5
|
var SlackSender = class {
|
|
@@ -59,4 +59,4 @@ var SlackSender = class {
|
|
|
59
59
|
//#endregion
|
|
60
60
|
export { SlackSender_exports as n, SlackSender as t };
|
|
61
61
|
|
|
62
|
-
//# sourceMappingURL=SlackSender-
|
|
62
|
+
//# sourceMappingURL=SlackSender-CetlSe6D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlackSender-
|
|
1
|
+
{"version":3,"file":"SlackSender-CetlSe6D.js","names":[],"sources":["../../src/senders/SlackSender.ts"],"sourcesContent":["/**\n * SlackSender — sends Slack messages via the SDK MessageClient\n *\n * The SDK transport comes from the messaging provider registry (populated by\n * `@happyvertical/smrt-messages/providers/slack`) or constructor injection —\n * never a direct `@happyvertical/messages` import, which would drag the SDK\n * (and transitively googleapis/nodemailer via its email wrapper) into\n * provider-neutral consumer bundles (#1979).\n */\n\nimport type { SlackAccount } from '../models/SlackAccount';\nimport type { SlackMessage } from '../models/SlackMessage';\nimport { getMessagingProvider } from '../providers.js';\nimport type {\n MessageClientFactory,\n MessageSenderInterface,\n MessageSendResult,\n SendMessageOptions,\n} from '../types';\n\nexport class SlackSender implements MessageSenderInterface {\n readonly providerType = 'slack';\n private account: SlackAccount;\n private createMessageClient?: MessageClientFactory;\n\n constructor(\n account: SlackAccount,\n createMessageClient?: MessageClientFactory,\n ) {\n this.account = account;\n this.createMessageClient = createMessageClient;\n }\n\n isReady(): boolean {\n return this.account.isActive;\n }\n\n async send(\n message: SlackMessage,\n _options?: SendMessageOptions,\n ): Promise<MessageSendResult> {\n const createMessageClient =\n this.createMessageClient ??\n getMessagingProvider(this.providerType)?.createMessageClient;\n if (!createMessageClient) {\n return {\n success: false,\n error:\n \"Slack provider has no transport registered. Import '@happyvertical/smrt-messages/providers/slack' (or '/providers/all') during server startup.\",\n sentAt: new Date(),\n };\n }\n\n const credentials = await this.account.getCredentials();\n if (!credentials?.botToken) {\n return {\n success: false,\n error: 'No botToken found in account credentials',\n sentAt: new Date(),\n };\n }\n\n const client = await createMessageClient({\n type: 'slack',\n botToken: credentials.botToken as string,\n });\n\n try {\n await client.connect();\n\n const result = await client.send(\n {\n from: { id: this.account.botUserId, name: this.account.name },\n channelId: message.channelId,\n content: message.body,\n },\n {\n replyTo: message.slackThreadTs || undefined,\n },\n );\n\n await client.disconnect();\n\n return {\n success: result.success,\n providerMessageId: result.messageId,\n providerResponse: result.providerResponse,\n sentAt: result.timestamp ?? new Date(),\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n sentAt: new Date(),\n };\n }\n }\n}\n"],"mappings":";;;;AAoBO,IAAM,cAAN,MAAoD;CAChD,eAAe;CAChB;CACA;CAER,YACE,SACA,qBACA;EACA,KAAK,UAAU;EACf,KAAK,sBAAsB;CAC7B;CAEA,UAAmB;EACjB,OAAO,KAAK,QAAQ;CACtB;CAEA,MAAM,KACJ,SACA,UAC4B;EAC5B,MAAM,sBACJ,KAAK,uBACL,qBAAqB,KAAK,YAAY,CAAA,EAAG;EAC3C,IAAI,CAAC,qBACH,OAAO;GACL,SAAS;GACT,OACE;GACF,wBAAQ,IAAI,KAAK;EACnB;EAGF,MAAM,cAAc,MAAM,KAAK,QAAQ,eAAe;EACtD,IAAI,CAAC,aAAa,UAChB,OAAO;GACL,SAAS;GACT,OAAO;GACP,wBAAQ,IAAI,KAAK;EACnB;EAGF,MAAM,SAAS,MAAM,oBAAoB;GACvC,MAAM;GACN,UAAU,YAAY;EACxB,CAAC;EAED,IAAI;GACF,MAAM,OAAO,QAAQ;GAErB,MAAM,SAAS,MAAM,OAAO,KAC1B;IACE,MAAM;KAAE,IAAI,KAAK,QAAQ;KAAW,MAAM,KAAK,QAAQ;IAAK;IAC5D,WAAW,QAAQ;IACnB,SAAS,QAAQ;GACnB,GACA,EACE,SAAS,QAAQ,iBAAiB,KAAA,EACpC,CACF;GAEA,MAAM,OAAO,WAAW;GAExB,OAAO;IACL,SAAS,OAAO;IAChB,mBAAmB,OAAO;IAC1B,kBAAkB,OAAO;IACzB,QAAQ,OAAO,6BAAa,IAAI,KAAK;GACvC;EACF,SAAS,OAAO;GACd,OAAO;IACL,SAAS;IACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC5D,wBAAQ,IAAI,KAAK;GACnB;EACF;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { n as getMessagingProvider } from "./providers-
|
|
2
|
+
import { n as getMessagingProvider } from "./providers-Bz_F_ywF.js";
|
|
3
3
|
//#region src/senders/TweetSender.ts
|
|
4
4
|
var TweetSender_exports = /* @__PURE__ */ __exportAll({ TweetSender: () => TweetSender });
|
|
5
5
|
var TweetSender = class {
|
|
@@ -61,4 +61,4 @@ var TweetSender = class {
|
|
|
61
61
|
//#endregion
|
|
62
62
|
export { TweetSender_exports as n, TweetSender as t };
|
|
63
63
|
|
|
64
|
-
//# sourceMappingURL=TweetSender-
|
|
64
|
+
//# sourceMappingURL=TweetSender-Dw-TDxIB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TweetSender-
|
|
1
|
+
{"version":3,"file":"TweetSender-Dw-TDxIB.js","names":[],"sources":["../../src/senders/TweetSender.ts"],"sourcesContent":["/**\n * TweetSender — sends tweets via the SDK MessageClient\n *\n * The SDK transport comes from the messaging provider registry (populated by\n * `@happyvertical/smrt-messages/providers/twitter`) or constructor injection —\n * never a direct `@happyvertical/messages` import, which would drag the SDK\n * (and transitively googleapis/nodemailer via its email wrapper) into\n * provider-neutral consumer bundles (#1979).\n */\n\nimport type { Tweet } from '../models/Tweet';\nimport type { TwitterAccount } from '../models/TwitterAccount';\nimport { getMessagingProvider } from '../providers.js';\nimport type {\n MessageClientFactory,\n MessageSenderInterface,\n MessageSendResult,\n SendMessageOptions,\n} from '../types';\n\nexport class TweetSender implements MessageSenderInterface {\n readonly providerType = 'twitter';\n private account: TwitterAccount;\n private createMessageClient?: MessageClientFactory;\n\n constructor(\n account: TwitterAccount,\n createMessageClient?: MessageClientFactory,\n ) {\n this.account = account;\n this.createMessageClient = createMessageClient;\n }\n\n isReady(): boolean {\n return this.account.isActive;\n }\n\n async send(\n message: Tweet,\n _options?: SendMessageOptions,\n ): Promise<MessageSendResult> {\n const createMessageClient =\n this.createMessageClient ??\n getMessagingProvider(this.providerType)?.createMessageClient;\n if (!createMessageClient) {\n return {\n success: false,\n error:\n \"Twitter provider has no transport registered. Import '@happyvertical/smrt-messages/providers/twitter' (or '/providers/all') during server startup.\",\n sentAt: new Date(),\n };\n }\n\n const credentials = await this.account.getCredentials();\n if (\n !credentials?.apiKey ||\n !credentials?.apiSecret ||\n !credentials?.accessToken ||\n !credentials?.accessSecret\n ) {\n return {\n success: false,\n error: 'Missing Twitter API credentials in account',\n sentAt: new Date(),\n };\n }\n\n const client = await createMessageClient({\n type: 'twitter',\n apiKey: credentials.apiKey as string,\n apiSecret: credentials.apiSecret as string,\n accessToken: credentials.accessToken as string,\n accessSecret: credentials.accessSecret as string,\n });\n\n try {\n const sendOptions: Record<string, string> = {};\n if (message.isReply && message.inReplyToMessageId) {\n sendOptions.replyTo = message.inReplyToMessageId;\n }\n\n const result = await client.send(\n {\n from: { id: this.account.twitterUserId, name: this.account.handle },\n content: message.body,\n },\n sendOptions.replyTo ? { replyTo: sendOptions.replyTo } : undefined,\n );\n\n return {\n success: result.success,\n providerMessageId: result.messageId,\n providerResponse: result.providerResponse,\n sentAt: result.timestamp ?? new Date(),\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n sentAt: new Date(),\n };\n }\n }\n}\n"],"mappings":";;;;AAoBO,IAAM,cAAN,MAAoD;CAChD,eAAe;CAChB;CACA;CAER,YACE,SACA,qBACA;EACA,KAAK,UAAU;EACf,KAAK,sBAAsB;CAC7B;CAEA,UAAmB;EACjB,OAAO,KAAK,QAAQ;CACtB;CAEA,MAAM,KACJ,SACA,UAC4B;EAC5B,MAAM,sBACJ,KAAK,uBACL,qBAAqB,KAAK,YAAY,CAAA,EAAG;EAC3C,IAAI,CAAC,qBACH,OAAO;GACL,SAAS;GACT,OACE;GACF,wBAAQ,IAAI,KAAK;EACnB;EAGF,MAAM,cAAc,MAAM,KAAK,QAAQ,eAAe;EACtD,IACE,CAAC,aAAa,UACd,CAAC,aAAa,aACd,CAAC,aAAa,eACd,CAAC,aAAa,cAEd,OAAO;GACL,SAAS;GACT,OAAO;GACP,wBAAQ,IAAI,KAAK;EACnB;EAGF,MAAM,SAAS,MAAM,oBAAoB;GACvC,MAAM;GACN,QAAQ,YAAY;GACpB,WAAW,YAAY;GACvB,aAAa,YAAY;GACzB,cAAc,YAAY;EAC5B,CAAC;EAED,IAAI;GACF,MAAM,cAAsC,CAAC;GAC7C,IAAI,QAAQ,WAAW,QAAQ,oBAC7B,YAAY,UAAU,QAAQ;GAGhC,MAAM,SAAS,MAAM,OAAO,KAC1B;IACE,MAAM;KAAE,IAAI,KAAK,QAAQ;KAAe,MAAM,KAAK,QAAQ;IAAO;IAClE,SAAS,QAAQ;GACnB,GACA,YAAY,UAAU,EAAE,SAAS,YAAY,QAAQ,IAAI,KAAA,CAC3D;GAEA,OAAO;IACL,SAAS,OAAO;IAChB,mBAAmB,OAAO;IAC1B,kBAAkB,OAAO;IACzB,QAAQ,OAAO,6BAAa,IAAI,KAAK;GACvC;EACF,SAAS,OAAO;GACd,OAAO;IACL,SAAS;IACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC5D,wBAAQ,IAAI,KAAK;GACnB;EACF;CACF;AACF"}
|
|
@@ -221,6 +221,41 @@ function ensureBuiltinMessagingProvidersRegistered() {
|
|
|
221
221
|
credentialFields: passwordCredentials,
|
|
222
222
|
endpointFields: emailEndpoint
|
|
223
223
|
});
|
|
224
|
+
registerBuiltinMessagingProvider({
|
|
225
|
+
id: "jmap",
|
|
226
|
+
label: "JMAP",
|
|
227
|
+
channel: "email",
|
|
228
|
+
available: false,
|
|
229
|
+
configurationFields: [{
|
|
230
|
+
id: "email",
|
|
231
|
+
label: "Mailbox address",
|
|
232
|
+
type: "email",
|
|
233
|
+
required: true
|
|
234
|
+
}, {
|
|
235
|
+
id: "url",
|
|
236
|
+
label: "Mail server URL",
|
|
237
|
+
type: "string",
|
|
238
|
+
required: true
|
|
239
|
+
}],
|
|
240
|
+
credentialFields: [
|
|
241
|
+
{
|
|
242
|
+
id: "username",
|
|
243
|
+
label: "Username",
|
|
244
|
+
type: "string"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
id: "password",
|
|
248
|
+
label: "Password",
|
|
249
|
+
type: "password"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
id: "token",
|
|
253
|
+
label: "Access token",
|
|
254
|
+
type: "password"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
endpointFields: emailEndpoint
|
|
258
|
+
});
|
|
224
259
|
registerBuiltinMessagingProvider({
|
|
225
260
|
id: "gmail",
|
|
226
261
|
label: "Gmail",
|
|
@@ -351,4 +386,4 @@ function ensureBuiltinMessagingProvidersRegistered() {
|
|
|
351
386
|
//#endregion
|
|
352
387
|
export { registerMessagingProvider as a, providers_exports as i, getMessagingProvider as n, ZulipSender as o, listMessagingProviders as r, TelegramSender as s, ensureBuiltinMessagingProvidersRegistered as t };
|
|
353
388
|
|
|
354
|
-
//# sourceMappingURL=providers-
|
|
389
|
+
//# sourceMappingURL=providers-Bz_F_ywF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers-4iLula-V.js","names":[],"sources":["../../src/senders/TelegramSender.ts","../../src/senders/ZulipSender.ts","../../src/providers.ts"],"sourcesContent":["import type { Account } from '../models/Account.js';\nimport type { Message } from '../models/Message.js';\nimport type {\n MessageSenderInterface,\n MessageSendResult,\n SendMessageOptions,\n} from '../types.js';\n\nexport class TelegramSender implements MessageSenderInterface {\n readonly providerType = 'telegram';\n\n constructor(\n private readonly account: Account,\n private readonly fetcher: typeof fetch = globalThis.fetch,\n ) {}\n\n isReady(): boolean {\n return this.account.isActive && this.account.hasCredentials;\n }\n\n async send(\n input: unknown,\n _options?: SendMessageOptions,\n ): Promise<MessageSendResult> {\n const message = input as Message;\n const endpoint = await message.getEndpoint();\n if (endpoint?.channel !== 'telegram' || !endpoint.isActive) {\n return failed(\n 'No active Telegram endpoint is associated with this message',\n );\n }\n\n const credentials = await this.account.getCredentials();\n const botToken =\n typeof credentials?.botToken === 'string' ? credentials.botToken : '';\n if (!botToken || !/^[A-Za-z0-9:_-]+$/.test(botToken)) {\n return failed('Telegram bot token is missing or invalid');\n }\n\n const address = endpoint.getAddress<{\n chatId?: string;\n threadId?: string | number;\n }>();\n if (!address.chatId)\n return failed('Telegram endpoint is missing a chat ID');\n\n const payload: Record<string, unknown> = {\n chat_id: address.chatId,\n text: message.body,\n };\n if (address.threadId !== undefined && address.threadId !== '') {\n const threadId = Number(address.threadId);\n if (!Number.isInteger(threadId) || threadId <= 0) {\n return failed('Telegram endpoint has an invalid topic/thread ID');\n }\n payload.message_thread_id = threadId;\n }\n\n try {\n const response = await this.fetcher(\n `https://api.telegram.org/bot${botToken}/sendMessage`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n },\n );\n const result = (await response.json()) as Record<string, unknown>;\n if (!response.ok || result.ok !== true) {\n return failed(\n typeof result.description === 'string'\n ? result.description\n : `Telegram returned ${response.status}`,\n result,\n );\n }\n const responseMessage = result.result as\n | Record<string, unknown>\n | undefined;\n return {\n success: true,\n providerMessageId: String(responseMessage?.message_id ?? ''),\n providerResponse: result,\n sentAt: new Date(),\n };\n } catch (error) {\n return failed(error instanceof Error ? error.message : String(error));\n }\n }\n}\n\nfunction failed(\n error: string,\n providerResponse?: Record<string, unknown>,\n): MessageSendResult {\n return { success: false, error, providerResponse, sentAt: new Date() };\n}\n","import type { Account } from '../models/Account.js';\nimport type { Message } from '../models/Message.js';\nimport type {\n MessageSenderInterface,\n MessageSendResult,\n SendMessageOptions,\n} from '../types.js';\n\nexport class ZulipSender implements MessageSenderInterface {\n readonly providerType = 'zulip';\n\n constructor(\n private readonly account: Account,\n private readonly fetcher: typeof fetch = globalThis.fetch,\n ) {}\n\n isReady(): boolean {\n return this.account.isActive && this.account.hasCredentials;\n }\n\n async send(\n input: unknown,\n _options?: SendMessageOptions,\n ): Promise<MessageSendResult> {\n const message = input as Message;\n const endpoint = await message.getEndpoint();\n if (endpoint?.channel !== 'zulip' || !endpoint.isActive) {\n return failed('No active Zulip endpoint is associated with this message');\n }\n\n const configuration = this.account.getConfiguration();\n const credentials = await this.account.getCredentials();\n const site =\n typeof configuration.site === 'string' ? configuration.site : '';\n const email =\n typeof configuration.email === 'string' ? configuration.email : '';\n const apiKey =\n typeof credentials?.apiKey === 'string' ? credentials.apiKey : '';\n if (!site || !email || !apiKey)\n return failed('Zulip account is not configured');\n\n let apiUrl: URL;\n try {\n apiUrl = new URL('/api/v1/messages', site);\n if (!['http:', 'https:'].includes(apiUrl.protocol)) throw new Error();\n } catch {\n return failed('Zulip site must be a valid HTTP(S) URL');\n }\n\n const address = endpoint.getAddress<{\n type?: string;\n to?: string;\n topic?: string;\n }>();\n if (\n (address.type !== 'stream' && address.type !== 'private') ||\n !address.to\n ) {\n return failed('Zulip endpoint is missing a valid type or destination');\n }\n\n const form = new URLSearchParams({\n type: address.type,\n to: address.to,\n content: message.body,\n });\n if (address.type === 'stream') {\n form.set('topic', address.topic || message.subject || 'Agent message');\n }\n\n try {\n const response = await this.fetcher(apiUrl, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${Buffer.from(`${email}:${apiKey}`).toString('base64')}`,\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: form,\n });\n const payload = (await response.json()) as Record<string, unknown>;\n if (!response.ok || payload.result !== 'success') {\n return failed(\n typeof payload.msg === 'string'\n ? payload.msg\n : `Zulip returned ${response.status}`,\n payload,\n );\n }\n return {\n success: true,\n providerMessageId: String(payload.id ?? ''),\n providerResponse: payload,\n sentAt: new Date(),\n };\n } catch (error) {\n return failed(error instanceof Error ? error.message : String(error));\n }\n }\n}\n\nfunction failed(\n error: string,\n providerResponse?: Record<string, unknown>,\n): MessageSendResult {\n return { success: false, error, providerResponse, sentAt: new Date() };\n}\n","import type { EmailClient, GetEmailClientOptions } from '@happyvertical/email';\nimport type { Account } from './models/Account.js';\nimport { TelegramSender } from './senders/TelegramSender.js';\nimport { ZulipSender } from './senders/ZulipSender.js';\nimport type {\n MessageClientFactory,\n MessageSenderInterface,\n MessagingChannel,\n} from './types.js';\n\nexport type MessagingProviderFieldType =\n | 'string'\n | 'number'\n | 'boolean'\n | 'select'\n | 'url'\n | 'email'\n | 'password';\n\nexport interface MessagingProviderField {\n id: string;\n label: string;\n type: MessagingProviderFieldType;\n required?: boolean;\n description?: string;\n placeholder?: string;\n options?: Array<{ value: string; label: string }>;\n}\n\n/** Public setup contract. Credential values are never represented here. */\nexport interface MessagingProviderDefinition {\n id: string;\n label: string;\n channel: MessagingChannel;\n available: boolean;\n configurationFields: MessagingProviderField[];\n credentialFields: MessagingProviderField[];\n endpointFields: MessagingProviderField[];\n createSender?: (account: Account) => Promise<MessageSenderInterface>;\n /**\n * Creates the SDK email client for this provider. Absent on the builtin\n * metadata-only definitions — registered by the explicit\n * `@happyvertical/smrt-messages/providers/email` entry point so the\n * @happyvertical/email SDK (googleapis/nodemailer) never enters\n * provider-neutral consumer bundles (#1979).\n */\n createEmailClient?: (options: GetEmailClientOptions) => Promise<EmailClient>;\n /**\n * Creates the SDK message client (Slack, Twitter, …) for this provider.\n * Registered by the matching `@happyvertical/smrt-messages/providers/*`\n * entry point; absent until that entry is imported.\n */\n createMessageClient?: MessageClientFactory;\n}\n\n/**\n * Function-valued definition keys. Stripped by MessagingSettingsService before\n * definitions are serialized to setup UIs.\n */\nexport type MessagingProviderFunctionKey =\n | 'createSender'\n | 'createEmailClient'\n | 'createMessageClient';\n\nconst REGISTRY_KEY = Symbol.for('smrt.messaging.providers');\n\nfunction registry(): Map<string, MessagingProviderDefinition> {\n const root = globalThis as typeof globalThis & {\n [REGISTRY_KEY]?: Map<string, MessagingProviderDefinition>;\n };\n root[REGISTRY_KEY] ??= new Map();\n return root[REGISTRY_KEY];\n}\n\nexport function registerMessagingProvider(\n provider: MessagingProviderDefinition,\n): () => void {\n registry().set(provider.id, provider);\n return () => registry().delete(provider.id);\n}\n\nexport function getMessagingProvider(\n id: string,\n): MessagingProviderDefinition | undefined {\n ensureBuiltinMessagingProvidersRegistered();\n return registry().get(id);\n}\n\nexport function listMessagingProviders(\n options: { includeUnavailable?: boolean } = {},\n) {\n ensureBuiltinMessagingProvidersRegistered();\n return [...registry().values()].filter(\n (provider) => options.includeUnavailable || provider.available,\n );\n}\n\nlet builtinsRegistered = false;\n\n/**\n * Registers a builtin definition only when its id is still absent.\n *\n * The registry lives on globalThis (survives HMR and duplicate module\n * instances) while the `builtinsRegistered` flag is module-scoped, so a\n * second module instance re-runs this function against a registry that may\n * already hold upgraded definitions — e.g. the functional client hooks\n * registered by the explicit `providers/*` entry points (#1979). Builtins\n * therefore only fill gaps; they never overwrite an existing definition.\n */\nfunction registerBuiltinMessagingProvider(\n provider: MessagingProviderDefinition,\n): void {\n if (registry().has(provider.id)) return;\n registerMessagingProvider(provider);\n}\n\nexport function ensureBuiltinMessagingProvidersRegistered(): void {\n if (builtinsRegistered) return;\n builtinsRegistered = true;\n\n const emailEndpoint: MessagingProviderField[] = [\n { id: 'email', label: 'Email address', type: 'email', required: true },\n ];\n const serverConfiguration: MessagingProviderField[] = [\n { id: 'email', label: 'From address', type: 'email', required: true },\n { id: 'host', label: 'Mail server', type: 'string', required: true },\n { id: 'port', label: 'Port', type: 'number', required: true },\n {\n id: 'secure',\n label: 'Use TLS',\n type: 'select',\n options: [\n { value: 'true', label: 'Yes' },\n { value: 'false', label: 'No' },\n ],\n },\n ];\n const passwordCredentials: MessagingProviderField[] = [\n { id: 'username', label: 'Username', type: 'string', required: true },\n { id: 'password', label: 'Password', type: 'password', required: true },\n ];\n\n for (const id of ['smtp', 'imap', 'pop3'] as const) {\n registerBuiltinMessagingProvider({\n id,\n label: id.toUpperCase(),\n channel: 'email',\n // IMAP/POP3 remain registered for existing receive/sync accounts but are\n // not valid outbound transports.\n available: id === 'smtp',\n configurationFields: serverConfiguration,\n credentialFields: passwordCredentials,\n endpointFields: emailEndpoint,\n });\n }\n\n registerBuiltinMessagingProvider({\n id: 'gmail',\n label: 'Gmail',\n channel: 'email',\n available: true,\n configurationFields: [\n { id: 'email', label: 'From address', type: 'email', required: true },\n ],\n credentialFields: [\n {\n id: 'clientId',\n label: 'OAuth client ID',\n type: 'string',\n required: true,\n },\n {\n id: 'clientSecret',\n label: 'OAuth client secret',\n type: 'password',\n required: true,\n },\n {\n id: 'refreshToken',\n label: 'OAuth refresh token',\n type: 'password',\n required: true,\n },\n { id: 'accessToken', label: 'OAuth access token', type: 'password' },\n ],\n endpointFields: emailEndpoint,\n });\n\n registerBuiltinMessagingProvider({\n id: 'zulip',\n label: 'Zulip',\n channel: 'zulip',\n available: true,\n configurationFields: [\n { id: 'site', label: 'Zulip site URL', type: 'url', required: true },\n { id: 'email', label: 'Bot email', type: 'email', required: true },\n ],\n credentialFields: [\n { id: 'apiKey', label: 'Bot API key', type: 'password', required: true },\n ],\n endpointFields: [\n {\n id: 'type',\n label: 'Destination type',\n type: 'select',\n required: true,\n options: [\n { value: 'stream', label: 'Stream' },\n { value: 'private', label: 'Private message' },\n ],\n },\n {\n id: 'to',\n label: 'Stream or recipient',\n type: 'string',\n required: true,\n },\n { id: 'topic', label: 'Topic', type: 'string' },\n ],\n createSender: async (account) => new ZulipSender(account),\n });\n\n registerBuiltinMessagingProvider({\n id: 'telegram',\n label: 'Telegram',\n channel: 'telegram',\n available: true,\n configurationFields: [],\n credentialFields: [\n { id: 'botToken', label: 'Bot token', type: 'password', required: true },\n ],\n endpointFields: [\n { id: 'chatId', label: 'Chat ID', type: 'string', required: true },\n { id: 'threadId', label: 'Topic/thread ID', type: 'number' },\n ],\n createSender: async (account) => new TelegramSender(account),\n });\n\n registerBuiltinMessagingProvider({\n id: 'sms',\n label: 'SMS (provider required)',\n channel: 'sms',\n available: false,\n configurationFields: [],\n credentialFields: [],\n endpointFields: [\n {\n id: 'phoneNumber',\n label: 'Phone number',\n type: 'string',\n required: true,\n },\n ],\n });\n}\n"],"mappings":";;AAQO,IAAM,iBAAN,MAAuD;CAG5D,YACmB,SACA,UAAwB,WAAW,OACpD;EAFiB,KAAA,UAAA;EACA,KAAA,UAAA;CAChB;CAFgB;CACA;CAJV,eAAe;CAOxB,UAAmB;EACjB,OAAO,KAAK,QAAQ,YAAY,KAAK,QAAQ;CAC/C;CAEA,MAAM,KACJ,OACA,UAC4B;EAC5B,MAAM,UAAU;EAChB,MAAM,WAAW,MAAM,QAAQ,YAAY;EAC3C,IAAI,UAAU,YAAY,cAAc,CAAC,SAAS,UAChD,OAAO,SACL,6DACF;EAGF,MAAM,cAAc,MAAM,KAAK,QAAQ,eAAe;EACtD,M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GAAE,IAAI;GAAQ,OAAO;GAAkB,MAAM;GAAO,UAAU;EAAK,GACnE;GAAE,IAAI;GAAS,OAAO;GAAa,MAAM;GAAS,UAAU;EAAK,CACnE;EACA,kBAAkB,CAChB;GAAE,IAAI;GAAU,OAAO;GAAe,MAAM;GAAY,UAAU;EAAK,CACzE;EACA,gBAAgB;GACd;IACE,IAAI;IACJ,OAAO;IACP,MAAM;IACN,UAAU;IACV,SAAS,CACP;KAAE,OAAO;KAAU,OAAO;IAAS,GACnC;KAAE,OAAO;KAAW,OAAO;IAAkB,CAC/C;GACF;GACA;IACE,IAAI;IACJ,OAAO;IACP,MAAM;IACN,UAAU;GACZ;GACA;IAAE,IAAI;IAAS,OAAO;IAAS,MAAM;GAAS;EAChD;EACA,cAAc,OAAO,YAAY,IAAI,YAAY,OAAO;CAC1D,CAAC;CAED,iCAAiC;EAC/B,IAAI;EACJ,OAAO;EACP,SAAS;EACT,WAAW;EACX,qBAAqB,CAAC;EACtB,kBAAkB,CAChB;GAAE,IAAI;GAAY,OAAO;GAAa,MAAM;GAAY,UAAU;EAAK,CACzE;EACA,gBAAgB,CACd;GAAE,IAAI;GAAU,OAAO;GAAW,MAAM;GAAU,UAAU;EAAK,GACjE;GAAE,IAAI;GAAY,OAAO;GAAmB,MAAM;EAAS,CAC7D;EACA,cAAc,OAAO,YAAY,IAAI,eAAe,OAAO;CAC7D,CAAC;CAED,iCAAiC;EAC/B,IAAI;EACJ,OAAO;EACP,SAAS;EACT,WAAW;EACX,qBAAqB,CAAC;EACtB,kBAAkB,CAAC;EACnB,gBAAgB,CACd;GACE,IAAI;GACJ,OAAO;GACP,MAAM;GACN,UAAU;EACZ,CACF;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"providers-Bz_F_ywF.js","names":[],"sources":["../../src/senders/TelegramSender.ts","../../src/senders/ZulipSender.ts","../../src/providers.ts"],"sourcesContent":["import type { Account } from '../models/Account.js';\nimport type { Message } from '../models/Message.js';\nimport type {\n MessageSenderInterface,\n MessageSendResult,\n SendMessageOptions,\n} from '../types.js';\n\nexport class TelegramSender implements MessageSenderInterface {\n readonly providerType = 'telegram';\n\n constructor(\n private readonly account: Account,\n private readonly fetcher: typeof fetch = globalThis.fetch,\n ) {}\n\n isReady(): boolean {\n return this.account.isActive && this.account.hasCredentials;\n }\n\n async send(\n input: unknown,\n _options?: SendMessageOptions,\n ): Promise<MessageSendResult> {\n const message = input as Message;\n const endpoint = await message.getEndpoint();\n if (endpoint?.channel !== 'telegram' || !endpoint.isActive) {\n return failed(\n 'No active Telegram endpoint is associated with this message',\n );\n }\n\n const credentials = await this.account.getCredentials();\n const botToken =\n typeof credentials?.botToken === 'string' ? credentials.botToken : '';\n if (!botToken || !/^[A-Za-z0-9:_-]+$/.test(botToken)) {\n return failed('Telegram bot token is missing or invalid');\n }\n\n const address = endpoint.getAddress<{\n chatId?: string;\n threadId?: string | number;\n }>();\n if (!address.chatId)\n return failed('Telegram endpoint is missing a chat ID');\n\n const payload: Record<string, unknown> = {\n chat_id: address.chatId,\n text: message.body,\n };\n if (address.threadId !== undefined && address.threadId !== '') {\n const threadId = Number(address.threadId);\n if (!Number.isInteger(threadId) || threadId <= 0) {\n return failed('Telegram endpoint has an invalid topic/thread ID');\n }\n payload.message_thread_id = threadId;\n }\n\n try {\n const response = await this.fetcher(\n `https://api.telegram.org/bot${botToken}/sendMessage`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n },\n );\n const result = (await response.json()) as Record<string, unknown>;\n if (!response.ok || result.ok !== true) {\n return failed(\n typeof result.description === 'string'\n ? result.description\n : `Telegram returned ${response.status}`,\n result,\n );\n }\n const responseMessage = result.result as\n | Record<string, unknown>\n | undefined;\n return {\n success: true,\n providerMessageId: String(responseMessage?.message_id ?? ''),\n providerResponse: result,\n sentAt: new Date(),\n };\n } catch (error) {\n return failed(error instanceof Error ? error.message : String(error));\n }\n }\n}\n\nfunction failed(\n error: string,\n providerResponse?: Record<string, unknown>,\n): MessageSendResult {\n return { success: false, error, providerResponse, sentAt: new Date() };\n}\n","import type { Account } from '../models/Account.js';\nimport type { Message } from '../models/Message.js';\nimport type {\n MessageSenderInterface,\n MessageSendResult,\n SendMessageOptions,\n} from '../types.js';\n\nexport class ZulipSender implements MessageSenderInterface {\n readonly providerType = 'zulip';\n\n constructor(\n private readonly account: Account,\n private readonly fetcher: typeof fetch = globalThis.fetch,\n ) {}\n\n isReady(): boolean {\n return this.account.isActive && this.account.hasCredentials;\n }\n\n async send(\n input: unknown,\n _options?: SendMessageOptions,\n ): Promise<MessageSendResult> {\n const message = input as Message;\n const endpoint = await message.getEndpoint();\n if (endpoint?.channel !== 'zulip' || !endpoint.isActive) {\n return failed('No active Zulip endpoint is associated with this message');\n }\n\n const configuration = this.account.getConfiguration();\n const credentials = await this.account.getCredentials();\n const site =\n typeof configuration.site === 'string' ? configuration.site : '';\n const email =\n typeof configuration.email === 'string' ? configuration.email : '';\n const apiKey =\n typeof credentials?.apiKey === 'string' ? credentials.apiKey : '';\n if (!site || !email || !apiKey)\n return failed('Zulip account is not configured');\n\n let apiUrl: URL;\n try {\n apiUrl = new URL('/api/v1/messages', site);\n if (!['http:', 'https:'].includes(apiUrl.protocol)) throw new Error();\n } catch {\n return failed('Zulip site must be a valid HTTP(S) URL');\n }\n\n const address = endpoint.getAddress<{\n type?: string;\n to?: string;\n topic?: string;\n }>();\n if (\n (address.type !== 'stream' && address.type !== 'private') ||\n !address.to\n ) {\n return failed('Zulip endpoint is missing a valid type or destination');\n }\n\n const form = new URLSearchParams({\n type: address.type,\n to: address.to,\n content: message.body,\n });\n if (address.type === 'stream') {\n form.set('topic', address.topic || message.subject || 'Agent message');\n }\n\n try {\n const response = await this.fetcher(apiUrl, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${Buffer.from(`${email}:${apiKey}`).toString('base64')}`,\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: form,\n });\n const payload = (await response.json()) as Record<string, unknown>;\n if (!response.ok || payload.result !== 'success') {\n return failed(\n typeof payload.msg === 'string'\n ? payload.msg\n : `Zulip returned ${response.status}`,\n payload,\n );\n }\n return {\n success: true,\n providerMessageId: String(payload.id ?? ''),\n providerResponse: payload,\n sentAt: new Date(),\n };\n } catch (error) {\n return failed(error instanceof Error ? error.message : String(error));\n }\n }\n}\n\nfunction failed(\n error: string,\n providerResponse?: Record<string, unknown>,\n): MessageSendResult {\n return { success: false, error, providerResponse, sentAt: new Date() };\n}\n","import type { EmailClient, GetEmailClientOptions } from '@happyvertical/email';\nimport type { Account } from './models/Account.js';\nimport { TelegramSender } from './senders/TelegramSender.js';\nimport { ZulipSender } from './senders/ZulipSender.js';\nimport type {\n MessageClientFactory,\n MessageSenderInterface,\n MessagingChannel,\n} from './types.js';\n\nexport type MessagingProviderFieldType =\n | 'string'\n | 'number'\n | 'boolean'\n | 'select'\n | 'url'\n | 'email'\n | 'password';\n\nexport interface MessagingProviderField {\n id: string;\n label: string;\n type: MessagingProviderFieldType;\n required?: boolean;\n description?: string;\n placeholder?: string;\n options?: Array<{ value: string; label: string }>;\n}\n\n/** Public setup contract. Credential values are never represented here. */\nexport interface MessagingProviderDefinition {\n id: string;\n label: string;\n channel: MessagingChannel;\n available: boolean;\n configurationFields: MessagingProviderField[];\n credentialFields: MessagingProviderField[];\n endpointFields: MessagingProviderField[];\n createSender?: (account: Account) => Promise<MessageSenderInterface>;\n /**\n * Creates the SDK email client for this provider. Absent on the builtin\n * metadata-only definitions — registered by the explicit\n * `@happyvertical/smrt-messages/providers/email` entry point so the\n * @happyvertical/email SDK (googleapis/nodemailer) never enters\n * provider-neutral consumer bundles (#1979).\n */\n createEmailClient?: (options: GetEmailClientOptions) => Promise<EmailClient>;\n /**\n * Creates the SDK message client (Slack, Twitter, …) for this provider.\n * Registered by the matching `@happyvertical/smrt-messages/providers/*`\n * entry point; absent until that entry is imported.\n */\n createMessageClient?: MessageClientFactory;\n}\n\n/**\n * Function-valued definition keys. Stripped by MessagingSettingsService before\n * definitions are serialized to setup UIs.\n */\nexport type MessagingProviderFunctionKey =\n | 'createSender'\n | 'createEmailClient'\n | 'createMessageClient';\n\nconst REGISTRY_KEY = Symbol.for('smrt.messaging.providers');\n\nfunction registry(): Map<string, MessagingProviderDefinition> {\n const root = globalThis as typeof globalThis & {\n [REGISTRY_KEY]?: Map<string, MessagingProviderDefinition>;\n };\n root[REGISTRY_KEY] ??= new Map();\n return root[REGISTRY_KEY];\n}\n\nexport function registerMessagingProvider(\n provider: MessagingProviderDefinition,\n): () => void {\n registry().set(provider.id, provider);\n return () => registry().delete(provider.id);\n}\n\nexport function getMessagingProvider(\n id: string,\n): MessagingProviderDefinition | undefined {\n ensureBuiltinMessagingProvidersRegistered();\n return registry().get(id);\n}\n\nexport function listMessagingProviders(\n options: { includeUnavailable?: boolean } = {},\n) {\n ensureBuiltinMessagingProvidersRegistered();\n return [...registry().values()].filter(\n (provider) => options.includeUnavailable || provider.available,\n );\n}\n\nlet builtinsRegistered = false;\n\n/**\n * Registers a builtin definition only when its id is still absent.\n *\n * The registry lives on globalThis (survives HMR and duplicate module\n * instances) while the `builtinsRegistered` flag is module-scoped, so a\n * second module instance re-runs this function against a registry that may\n * already hold upgraded definitions — e.g. the functional client hooks\n * registered by the explicit `providers/*` entry points (#1979). Builtins\n * therefore only fill gaps; they never overwrite an existing definition.\n */\nfunction registerBuiltinMessagingProvider(\n provider: MessagingProviderDefinition,\n): void {\n if (registry().has(provider.id)) return;\n registerMessagingProvider(provider);\n}\n\nexport function ensureBuiltinMessagingProvidersRegistered(): void {\n if (builtinsRegistered) return;\n builtinsRegistered = true;\n\n const emailEndpoint: MessagingProviderField[] = [\n { id: 'email', label: 'Email address', type: 'email', required: true },\n ];\n const serverConfiguration: MessagingProviderField[] = [\n { id: 'email', label: 'From address', type: 'email', required: true },\n { id: 'host', label: 'Mail server', type: 'string', required: true },\n { id: 'port', label: 'Port', type: 'number', required: true },\n {\n id: 'secure',\n label: 'Use TLS',\n type: 'select',\n options: [\n { value: 'true', label: 'Yes' },\n { value: 'false', label: 'No' },\n ],\n },\n ];\n const passwordCredentials: MessagingProviderField[] = [\n { id: 'username', label: 'Username', type: 'string', required: true },\n { id: 'password', label: 'Password', type: 'password', required: true },\n ];\n\n for (const id of ['smtp', 'imap', 'pop3'] as const) {\n registerBuiltinMessagingProvider({\n id,\n label: id.toUpperCase(),\n channel: 'email',\n // IMAP/POP3 remain registered for existing receive/sync accounts but are\n // not valid outbound transports.\n available: id === 'smtp',\n configurationFields: serverConfiguration,\n credentialFields: passwordCredentials,\n endpointFields: emailEndpoint,\n });\n }\n\n // JMAP (RFC 8620/8621): receive and sync only. Mailbox changes arrive through\n // the server's change feed (see `EmailAccount.syncChanges()`); sending stays\n // on SMTP, so JMAP is not offered as an outbound transport.\n registerBuiltinMessagingProvider({\n id: 'jmap',\n label: 'JMAP',\n channel: 'email',\n available: false,\n configurationFields: [\n { id: 'email', label: 'Mailbox address', type: 'email', required: true },\n { id: 'url', label: 'Mail server URL', type: 'string', required: true },\n ],\n credentialFields: [\n { id: 'username', label: 'Username', type: 'string' },\n { id: 'password', label: 'Password', type: 'password' },\n { id: 'token', label: 'Access token', type: 'password' },\n ],\n endpointFields: emailEndpoint,\n });\n\n registerBuiltinMessagingProvider({\n id: 'gmail',\n label: 'Gmail',\n channel: 'email',\n available: true,\n configurationFields: [\n { id: 'email', label: 'From address', type: 'email', required: true },\n ],\n credentialFields: [\n {\n id: 'clientId',\n label: 'OAuth client ID',\n type: 'string',\n required: true,\n },\n {\n id: 'clientSecret',\n label: 'OAuth client secret',\n type: 'password',\n required: true,\n },\n {\n id: 'refreshToken',\n label: 'OAuth refresh token',\n type: 'password',\n required: true,\n },\n { id: 'accessToken', label: 'OAuth access token', type: 'password' },\n ],\n endpointFields: emailEndpoint,\n });\n\n registerBuiltinMessagingProvider({\n id: 'zulip',\n label: 'Zulip',\n channel: 'zulip',\n available: true,\n configurationFields: [\n { id: 'site', label: 'Zulip site URL', type: 'url', required: true },\n { id: 'email', label: 'Bot email', type: 'email', required: true },\n ],\n credentialFields: [\n { id: 'apiKey', label: 'Bot API key', type: 'password', required: true },\n ],\n endpointFields: [\n {\n id: 'type',\n label: 'Destination type',\n type: 'select',\n required: true,\n options: [\n { value: 'stream', label: 'Stream' },\n { value: 'private', label: 'Private message' },\n ],\n },\n {\n id: 'to',\n label: 'Stream or recipient',\n type: 'string',\n required: true,\n },\n { id: 'topic', label: 'Topic', type: 'string' },\n ],\n createSender: async (account) => new ZulipSender(account),\n });\n\n registerBuiltinMessagingProvider({\n id: 'telegram',\n label: 'Telegram',\n channel: 'telegram',\n available: true,\n configurationFields: [],\n credentialFields: [\n { id: 'botToken', label: 'Bot token', type: 'password', required: true },\n ],\n endpointFields: [\n { id: 'chatId', label: 'Chat ID', type: 'string', required: true },\n { id: 'threadId', label: 'Topic/thread ID', type: 'number' },\n ],\n createSender: async (account) => new TelegramSender(account),\n });\n\n registerBuiltinMessagingProvider({\n id: 'sms',\n label: 'SMS (provider required)',\n channel: 'sms',\n available: false,\n configurationFields: [],\n credentialFields: [],\n endpointFields: [\n {\n id: 'phoneNumber',\n label: 'Phone number',\n type: 'string',\n required: true,\n },\n ],\n });\n}\n"],"mappings":";;AAQO,IAAM,iBAAN,MAAuD;CAG5D,YACmB,SACA,UAAwB,WAAW,OACpD;EAFiB,KAAA,UAAA;EACA,KAAA,UAAA;CAChB;CAFgB;CACA;CAJV,eAAe;CAOxB,UAAmB;EACjB,OAAO,KAAK,QAAQ,YAAY,KAAK,QAAQ;CAC/C;CAEA,MAAM,KACJ,OACA,UAC4B;EAC5B,MAAM,UAAU;EAChB,MAAM,WAAW,MAAM,QAAQ,YAAY;EAC3C,IAAI,UAAU,YAAY,cAAc,CAAC,SAAS,UAChD,OAAO,SACL,6DACF;EAGF,MAAM,cAAc,MAAM,KAAK,QAAQ,eAAe;EACtD,MAAM,WACJ,OAAO,aAAa,aAAa,WAAW,YAAY,WAAW;EACrE,IAAI,CAAC,YAAY,CAAC,oB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WAAW;EACX,qBAAqB,CAAC;EACtB,kBAAkB,CAAC;EACnB,gBAAgB,CACd;GACE,IAAI;GACJ,OAAO;GACP,MAAM;GACN,UAAU;EACZ,CACF;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailAccountCollection.d.ts","sourceRoot":"","sources":["../../src/collections/EmailAccountCollection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAAwB,CAAC;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,YAAY,EACZ,WAAW,EACZ,MAAM,aAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAExD,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D,gBAAyB,UAAU,sBAAgB;IAEnD;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAK7D;;OAEG;IACG,sBAAsB,CAC1B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,YAAY,EAAE,CAAC;IAI1B;;OAEG;IACY,SAAS,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAInD;;OAEG;IACY,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAIrD;;OAEG;IACG,cAAc,CAAC,aAAa,SAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IASjE;;;OAGG;IACY,MAAM,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,YAAY,EAAE,CAAC;IAI1B;;;OAGG;IACY,iBAAiB,CAC9B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,YAAY,EAAE,CAAC;IAI1B;;;OAGG;IACY,QAAQ,IAAI,OAAO,CAAC;QACjC,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE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IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAIrC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAO1E"}
|
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-D5RrI88X.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";
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import './__smrt-register__.js';
|
|
9
9
|
export { assertMailAccess, canAccessMailAccount, configureMailAccess, decideMailAccess, deniedMailAccountIds, type GrantMailAccessInput, isMailScope, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, type MailAccessAdmin, type MailAccessConfig, type MailAccessDecision, MailAccessError, type MailAccessReason, type MailAccessResolver, type MailAccessResolverContext, MailAccessService, type MailAccessSubject, type MailPrincipal, type MailScope, mailScopePermission, resetMailAccess, runWithMailSystemAccess, } from './access.js';
|
|
10
|
+
export type { MailSyncOptions, MailSyncResult, MailSyncSkipReason, } from './mail-sync.js';
|
|
11
|
+
export { CHANGE_FEED_PROVIDERS, type EnqueueMailSyncOptions, enqueueDueMailSyncs, enqueueMailSync, MAIL_SYNC_QUEUE, mailSyncDedupeKey, } from './mail-sync-jobs.js';
|
|
10
12
|
export { AccountCollection } from "./collections/AccountCollection.js";
|
|
11
13
|
export { AttachmentCollection } from "./collections/AttachmentCollection.js";
|
|
12
14
|
export { MessageCollection } from "./collections/MessageCollection.js";
|
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;AAQhC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,WAAW,EACX,0BAA0B,EAC1B,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,mBAAmB,EACnB,eAAe,EACf,uBAAuB,GACxB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,wBAAwB,CAAC;AAQhC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,WAAW,EACX,0BAA0B,EAC1B,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,mBAAmB,EACnB,eAAe,EACf,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,mBAAmB,E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V,cAAc,EACd,oBAAoB,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;AAMjB,OAAO,EACL,wCAAwC,EACxC,oCAAoC,EACpC,KAAK,kCAAkC,EACvC,KAAK,gCAAgC,EACrC,iCAAiC,GAClC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,6BAA6B,EAClC,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { A as messagingPrincipalFromPermissions, C as runWithMailSystemAccess, D as SEND_MESSAGES_PERMISSION, E as MESSAGING_PERMISSION_DEFINITIONS, O as assertMessagingPermission, S as resetMailAccess, T as MANAGE_MESSAGE_ROUTES_PERMISSION, _ as getEffectiveMailAccessConfigs, b as learnMailAccessOptions, c as MAIL_SCOPES, d as assertHydratedMailAccess, f as assertMailAccess, g as deniedMailAccountIds, h as decideMailAccess, i as AccountCollection, k as ensureMessagingPermissionsRegistered, l as MailAccessError, m as configureMailAccess, o as Account, p as canAccessMailAccount, r as EmailAccount, s as MAIL_ACCOUNT_RESOURCE_TYPE, t as EmailAccountCollection, u as MailAccessService, v as inMailSystemAccess, w as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, x as mailScopePermission, y as isMailScope } from "./chunks/EmailAccountCollection-
|
|
1
|
+
import { A as messagingPrincipalFromPermissions, C as runWithMailSystemAccess, D as SEND_MESSAGES_PERMISSION, E as MESSAGING_PERMISSION_DEFINITIONS, O as assertMessagingPermission, S as resetMailAccess, T as MANAGE_MESSAGE_ROUTES_PERMISSION, _ as getEffectiveMailAccessConfigs, b as learnMailAccessOptions, c as MAIL_SCOPES, d as assertHydratedMailAccess, f as assertMailAccess, g as deniedMailAccountIds, h as decideMailAccess, i as AccountCollection, k as ensureMessagingPermissionsRegistered, l as MailAccessError, m as configureMailAccess, o as Account, p as canAccessMailAccount, r as EmailAccount, s as MAIL_ACCOUNT_RESOURCE_TYPE, t as EmailAccountCollection, u as MailAccessService, v as inMailSystemAccess, w as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, x as mailScopePermission, y as isMailScope } from "./chunks/EmailAccountCollection-D5RrI88X.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-CqMr6vDW.js";
|
|
4
|
+
import { t as EmailFolder } from "./chunks/EmailFolder-94T__o1R.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-
|
|
7
|
-
import { a as registerMessagingProvider, n as getMessagingProvider, o as ZulipSender, r as listMessagingProviders, s as TelegramSender, t as ensureBuiltinMessagingProvidersRegistered } from "./chunks/providers-
|
|
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-
|
|
6
|
+
import { t as Message } from "./chunks/Message-GEH6EbM0.js";
|
|
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-CeBjGYG0.js";
|
|
9
|
+
import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-CgxxGRXx.js";
|
|
10
|
+
import { t as Email } from "./chunks/Email-HQRz_jXr.js";
|
|
11
|
+
import { t as EmailCollection } from "./chunks/EmailCollection-BitVR0qy.js";
|
|
12
|
+
import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-B6jWiIRV.js";
|
|
13
13
|
import { t as EmailSender } from "./chunks/EmailSender-B-Rtq9du.js";
|
|
14
|
-
import { t as SlackSender } from "./chunks/SlackSender-
|
|
15
|
-
import { t as TweetSender } from "./chunks/TweetSender-
|
|
14
|
+
import { t as SlackSender } from "./chunks/SlackSender-CetlSe6D.js";
|
|
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";
|
|
17
17
|
import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy/decorators";
|
|
18
18
|
//#region src/access-enforcement.ts
|
|
@@ -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-CeBjGYG0.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) {
|
|
@@ -153,6 +153,51 @@ function ensureMailAccessEnforcementRegistered() {
|
|
|
153
153
|
GlobalInterceptors.register(createMailAccessInterceptor());
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
|
+
//#region src/mail-sync-jobs.ts
|
|
157
|
+
var MAIL_SYNC_QUEUE = "mail-sync";
|
|
158
|
+
var CHANGE_FEED_PROVIDERS = ["jmap"];
|
|
159
|
+
function mailSyncDedupeKey(accountId) {
|
|
160
|
+
return `mail-sync:${accountId}`;
|
|
161
|
+
}
|
|
162
|
+
function accountClassName() {
|
|
163
|
+
const registered = ObjectRegistry.getClass("EmailAccount") ?? ObjectRegistry.getClassByQualifiedName("@happyvertical/smrt-messages:EmailAccount");
|
|
164
|
+
return registered?.qualifiedName ?? registered?.name ?? "EmailAccount";
|
|
165
|
+
}
|
|
166
|
+
async function enqueueMailSync(account, options = {}) {
|
|
167
|
+
if (!account.id) throw new Error("enqueueMailSync needs a persisted account");
|
|
168
|
+
if (!account.isActive || account.needsReconnect) return null;
|
|
169
|
+
if (!CHANGE_FEED_PROVIDERS.includes(account.providerType)) return null;
|
|
170
|
+
const { SmrtJobCollection } = await import("@happyvertical/smrt-jobs");
|
|
171
|
+
const db = account.db;
|
|
172
|
+
const jobs = await SmrtJobCollection.create({ db });
|
|
173
|
+
const args = {};
|
|
174
|
+
if (options.limit !== void 0) args.limit = options.limit;
|
|
175
|
+
if (options.maxBatches !== void 0) args.maxBatches = options.maxBatches;
|
|
176
|
+
return jobs.enqueueJob({
|
|
177
|
+
dedupeKey: mailSyncDedupeKey(account.id),
|
|
178
|
+
tenantId: account.tenantId ?? null,
|
|
179
|
+
queue: MAIL_SYNC_QUEUE,
|
|
180
|
+
objectType: accountClassName(),
|
|
181
|
+
objectId: account.id,
|
|
182
|
+
method: "syncChanges",
|
|
183
|
+
args,
|
|
184
|
+
runAt: options.runAt,
|
|
185
|
+
priority: options.priority,
|
|
186
|
+
maxAttempts: options.maxAttempts ?? 3,
|
|
187
|
+
timeout: options.timeout ?? 900 * 1e3
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async function enqueueDueMailSyncs(accounts, options = {}) {
|
|
191
|
+
const now = (options.now ?? /* @__PURE__ */ new Date()).getTime();
|
|
192
|
+
const queued = [];
|
|
193
|
+
for (const account of accounts) {
|
|
194
|
+
if (!(!account.lastSyncAt || now - account.lastSyncAt.getTime() >= (account.syncIntervalMinutes || 0) * 6e4)) continue;
|
|
195
|
+
const job = await enqueueMailSync(account, options);
|
|
196
|
+
if (job?.id) queued.push(String(job.id));
|
|
197
|
+
}
|
|
198
|
+
return queued;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
156
201
|
//#region src/models/NotificationDelivery.ts
|
|
157
202
|
var __defProp$11 = Object.defineProperty;
|
|
158
203
|
var __getOwnPropDesc$11 = Object.getOwnPropertyDescriptor;
|
|
@@ -740,7 +785,7 @@ var EmailAttachment = class extends Attachment {
|
|
|
740
785
|
*/
|
|
741
786
|
async getEmail() {
|
|
742
787
|
if (!this.messageId) return null;
|
|
743
|
-
const { EmailCollection } = await import("./chunks/EmailCollection-
|
|
788
|
+
const { EmailCollection } = await import("./chunks/EmailCollection-BitVR0qy.js").then((n) => n.n);
|
|
744
789
|
return await (await EmailCollection.create(this.options)).get({ id: this.messageId });
|
|
745
790
|
}
|
|
746
791
|
};
|
|
@@ -1001,7 +1046,7 @@ var SlackAccount = class extends Account {
|
|
|
1001
1046
|
* Create a sender for this Slack account
|
|
1002
1047
|
*/
|
|
1003
1048
|
async createSender() {
|
|
1004
|
-
const { SlackSender } = await import("./chunks/SlackSender-
|
|
1049
|
+
const { SlackSender } = await import("./chunks/SlackSender-CetlSe6D.js").then((n) => n.n);
|
|
1005
1050
|
return new SlackSender(this);
|
|
1006
1051
|
}
|
|
1007
1052
|
};
|
|
@@ -1260,7 +1305,7 @@ var TwitterAccount = class extends Account {
|
|
|
1260
1305
|
* Create a sender for this Twitter account
|
|
1261
1306
|
*/
|
|
1262
1307
|
async createSender() {
|
|
1263
|
-
const { TweetSender } = await import("./chunks/TweetSender-
|
|
1308
|
+
const { TweetSender } = await import("./chunks/TweetSender-Dw-TDxIB.js").then((n) => n.n);
|
|
1264
1309
|
return new TweetSender(this);
|
|
1265
1310
|
}
|
|
1266
1311
|
};
|
|
@@ -3089,7 +3134,8 @@ var MailboxRecipe = class extends SmrtRecipe {
|
|
|
3089
3134
|
options: [
|
|
3090
3135
|
"imap",
|
|
3091
3136
|
"pop3",
|
|
3092
|
-
"gmail"
|
|
3137
|
+
"gmail",
|
|
3138
|
+
"jmap"
|
|
3093
3139
|
],
|
|
3094
3140
|
required: true
|
|
3095
3141
|
}, {
|
|
@@ -3331,6 +3377,6 @@ ensureBuiltinMessagingProvidersRegistered();
|
|
|
3331
3377
|
ensureMessagingPermissionsRegistered();
|
|
3332
3378
|
ensureMailAccessEnforcementRegistered();
|
|
3333
3379
|
//#endregion
|
|
3334
|
-
export { Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGING_PERMISSION_DEFINITIONS, MailAccessError, MailAccessService, 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, buildNotificationLink, canAccessMailAccount, configureMailAccess, decideMailAccess, deniedMailAccountIds, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, isMailScope, isValidNotificationOptOutScope, listMessagingProviders, mailScopePermission, messageSendTransport, messagingPrincipalFromPermissions, migrateNotificationProfileRecipients, notificationDeliveryCorrelationId, notificationDeliveryMessageId, optOutSuppression, planNotificationProfileRecipients, profileNotificationPolicy, registerMessagingProvider, resetMailAccess, runWithMailSystemAccess };
|
|
3380
|
+
export { Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, CHANGE_FEED_PROVIDERS, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, MAIL_SYNC_QUEUE, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGING_PERMISSION_DEFINITIONS, MailAccessError, MailAccessService, 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, buildNotificationLink, canAccessMailAccount, configureMailAccess, decideMailAccess, deniedMailAccountIds, enqueueDueMailSyncs, enqueueMailSync, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, isMailScope, isValidNotificationOptOutScope, listMessagingProviders, mailScopePermission, mailSyncDedupeKey, messageSendTransport, messagingPrincipalFromPermissions, migrateNotificationProfileRecipients, notificationDeliveryCorrelationId, notificationDeliveryMessageId, optOutSuppression, planNotificationProfileRecipients, profileNotificationPolicy, registerMessagingProvider, resetMailAccess, runWithMailSystemAccess };
|
|
3335
3381
|
|
|
3336
3382
|
//# sourceMappingURL=index.js.map
|