@happyvertical/smrt-messages 0.62.7 → 0.62.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/AGENTS.md +30 -0
  2. package/dist/chunks/{AttachmentCollection-nTqD75n8.js → AttachmentCollection-DhCoruwp.js} +4 -4
  3. package/dist/chunks/{AttachmentCollection-nTqD75n8.js.map → AttachmentCollection-DhCoruwp.js.map} +1 -1
  4. package/dist/chunks/{Email-DKcIiMxB.js → Email-CmNoK1lj.js} +9 -6
  5. package/dist/chunks/Email-CmNoK1lj.js.map +1 -0
  6. package/dist/chunks/EmailAccountCollection-CHizpsxL.js +1555 -0
  7. package/dist/chunks/EmailAccountCollection-CHizpsxL.js.map +1 -0
  8. package/dist/chunks/{EmailCollection-BYeuWWsP.js → EmailCollection-Yo2wBv_1.js} +3 -3
  9. package/dist/chunks/{EmailCollection-BYeuWWsP.js.map → EmailCollection-Yo2wBv_1.js.map} +1 -1
  10. package/dist/chunks/{EmailFolder-UMGpXTQ7.js → EmailFolder-Dks5clxA.js} +6 -6
  11. package/dist/chunks/{EmailFolder-UMGpXTQ7.js.map → EmailFolder-Dks5clxA.js.map} +1 -1
  12. package/dist/chunks/{EmailFolderCollection-DHZKwe1H.js → EmailFolderCollection-nIR4Kpcr.js} +2 -2
  13. package/dist/chunks/{EmailFolderCollection-DHZKwe1H.js.map → EmailFolderCollection-nIR4Kpcr.js.map} +1 -1
  14. package/dist/chunks/{Message-M8INXZs5.js → Message-e99HkbG8.js} +6 -6
  15. package/dist/chunks/{Message-M8INXZs5.js.map → Message-e99HkbG8.js.map} +1 -1
  16. package/dist/chunks/{MessageCollection-CT0O_7wG.js → MessageCollection-t8cLUSNJ.js} +2 -2
  17. package/dist/chunks/{MessageCollection-CT0O_7wG.js.map → MessageCollection-t8cLUSNJ.js.map} +1 -1
  18. package/dist/chunks/{MessagingEndpointCollection-DrNvP8GM.js → MessagingEndpointCollection-CGtAL77R.js} +2 -2
  19. package/dist/chunks/{MessagingEndpointCollection-DrNvP8GM.js.map → MessagingEndpointCollection-CGtAL77R.js.map} +1 -1
  20. package/dist/chunks/{SlackSender-CjSvwY1K.js → SlackSender-CetlSe6D.js} +2 -2
  21. package/dist/chunks/{SlackSender-CjSvwY1K.js.map → SlackSender-CetlSe6D.js.map} +1 -1
  22. package/dist/chunks/{TweetSender-CcLPNNi1.js → TweetSender-Dw-TDxIB.js} +2 -2
  23. package/dist/chunks/{TweetSender-CcLPNNi1.js.map → TweetSender-Dw-TDxIB.js.map} +1 -1
  24. package/dist/chunks/{providers-4iLula-V.js → providers-Bz_F_ywF.js} +36 -1
  25. package/dist/chunks/{providers-4iLula-V.js.map → providers-Bz_F_ywF.js.map} +1 -1
  26. package/dist/collections/EmailAccountCollection.d.ts.map +1 -1
  27. package/dist/connect.js +1 -1
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +64 -18
  31. package/dist/index.js.map +1 -1
  32. package/dist/mail-sync-jobs.d.ts +48 -0
  33. package/dist/mail-sync-jobs.d.ts.map +1 -0
  34. package/dist/mail-sync.d.ts +58 -0
  35. package/dist/mail-sync.d.ts.map +1 -0
  36. package/dist/manifest.json +158 -34
  37. package/dist/models/Email.d.ts +1 -0
  38. package/dist/models/Email.d.ts.map +1 -1
  39. package/dist/models/EmailAccount.d.ts +29 -2
  40. package/dist/models/EmailAccount.d.ts.map +1 -1
  41. package/dist/providers/email.js +3 -2
  42. package/dist/providers/email.js.map +1 -1
  43. package/dist/providers/slack.js +2 -2
  44. package/dist/providers/twitter.js +2 -2
  45. package/dist/providers.d.ts.map +1 -1
  46. package/dist/recipes.d.ts +1 -1
  47. package/dist/smrt-knowledge.json +66 -10
  48. package/dist/smrt-knowledge.okf.md +3 -2
  49. package/dist/types.d.ts +5 -1
  50. package/dist/types.d.ts.map +1 -1
  51. package/package.json +17 -16
  52. package/dist/chunks/Email-DKcIiMxB.js.map +0 -1
  53. package/dist/chunks/EmailAccountCollection-DtCuHcB4.js +0 -1224
  54. package/dist/chunks/EmailAccountCollection-DtCuHcB4.js.map +0 -1
@@ -0,0 +1,1555 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { createAccountSecretService, createHandoffContext, getCurrentTenant, queryGlobal, queryWithGlobals, withTenant } from "../host.js";
3
+ import { ObjectRegistry, SmrtCollection, SmrtObject, crossPackageRef, field, smrt } from "@happyvertical/smrt-core";
4
+ import { registerPermissionDefinitions } from "@happyvertical/smrt-users/permission-registry";
5
+ import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy/decorators";
6
+ //#region src/__smrt-register__.ts
7
+ ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-messages","packageVersion":"0.62.8","objects":{"@happyvertical/smrt-messages:AccountCollection":{"name":"accountcollection","className":"AccountCollection","qualifiedName":"@happyvertical/smrt-messages:AccountCollection","collection":"accounts","filePath":"src/collections/AccountCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"getActive":{"name":"getActive","async":true,"parameters":[],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"getInactive":{"name":"getInactive","async":true,"parameters":[],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"getByProviderType":{"name":"getByProviderType","async":true,"parameters":[{"name":"providerType","type":"string","optional":false}],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"getByType":{"name":"getByType","async":true,"parameters":[{"name":"accountType","type":"string","optional":false}],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"AccountSearchFilters","optional":true}],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"getStats":{"name":"getStats","async":true,"parameters":[],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Account","exportName":"AccountCollection","collectionExportName":"AccountCollectionCollection","collectionOf":"@happyvertical/smrt-messages:Account","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:AttachmentCollection":{"name":"attachmentcollection","className":"AttachmentCollection","qualifiedName":"@happyvertical/smrt-messages:AttachmentCollection","collection":"attachments","filePath":"src/collections/AttachmentCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"backfillAccountIds":{"name":"backfillAccountIds","async":true,"parameters":[],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getByMessage":{"name":"getByMessage","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getByContentType":{"name":"getByContentType","async":true,"parameters":[{"name":"contentType","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getImages":{"name":"getImages","async":true,"parameters":[{"name":"messageId","type":"string","optional":true}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getPdfs":{"name":"getPdfs","async":true,"parameters":[{"name":"messageId","type":"string","optional":true}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getInline":{"name":"getInline","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getRegular":{"name":"getRegular","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getWithExternalFiles":{"name":"getWithExternalFiles","async":true,"parameters":[],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getTotalSize":{"name":"getTotalSize","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getLargest":{"name":"getLargest","async":true,"parameters":[{"name":"limit","type":"any","optional":true}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"searchByFilename":{"name":"searchByFilename","async":true,"parameters":[{"name":"query","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getByExtension":{"name":"getByExtension","async":true,"parameters":[{"name":"extension","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getStats":{"name":"getStats","async":true,"parameters":[],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"deleteByMessage":{"name":"deleteByMessage","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Attachment","exportName":"AttachmentCollection","collectionExportName":"AttachmentCollectionCollection","collectionOf":"@happyvertical/smrt-messages:Attachment","inheritedExposure":["api","mcp"],"schema":{"tableName":"attachments","ddl":"CREATE TABLE IF NOT EXISTS \\"attachments\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"message_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"filename\\" TEXT,\\n \\"content_type\\" TEXT,\\n \\"size\\" INTEGER NOT NULL DEFAULT 0,\\n \\"content_id\\" TEXT,\\n \\"content_disposition\\" TEXT DEFAULT 'attachment',\\n \\"file_path\\" TEXT,\\n \\"source_url\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"filename":{"type":"TEXT","notNull":false,"unique":false},"content_type":{"type":"TEXT","notNull":false,"unique":false},"size":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"content_id":{"type":"TEXT","notNull":false,"unique":false},"content_disposition":{"type":"TEXT","notNull":false,"unique":false,"default":"attachment"},"file_path":{"type":"TEXT","notNull":false,"unique":false},"source_url":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"attachments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"attachments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"attachments_message_id_idx","columns":["message_id"]},{"name":"attachments_account_id_idx","columns":["account_id"]}],"version":"3f32531c"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:BlacklistCollection":{"name":"blacklistcollection","className":"BlacklistCollection","qualifiedName":"@happyvertical/smrt-messages:BlacklistCollection","collection":"blacklists","filePath":"src/collections/BlacklistCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"isBlacklisted":{"name":"isBlacklisted","async":true,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"getMatchingEntry":{"name":"getMatchingEntry","async":true,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"Promise<Blacklist | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]}},"extends":"SmrtCollection","extendsTypeArg":"Blacklist","exportName":"BlacklistCollection","collectionExportName":"BlacklistCollectionCollection","collectionOf":"@happyvertical/smrt-messages:Blacklist","inheritedExposure":["api"],"schema":{"tableName":"blacklists","ddl":"CREATE TABLE IF NOT EXISTS \\"blacklists\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"pattern\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'email',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"auto_archive\\" BOOLEAN DEFAULT TRUE,\\n \\"tenant_id\\" UUID NOT NULL\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"pattern":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"email"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"auto_archive":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false}},"indexes":[{"name":"blacklists_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"blacklists_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"478c8724"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailAccountCollection":{"name":"emailaccountcollection","className":"EmailAccountCollection","qualifiedName":"@happyvertical/smrt-messages:EmailAccountCollection","collection":"accounts","filePath":"src/collections/EmailAccountCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"getActive":{"name":"getActive","async":true,"parameters":[],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"getInactive":{"name":"getInactive","async":true,"parameters":[],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"getByProviderType":{"name":"getByProviderType","async":true,"parameters":[{"name":"providerType","type":"string","optional":false}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"getByType":{"name":"getByType","async":true,"parameters":[{"name":"accountType","type":"string","optional":false}],"returnType":"Promise<Account[]>","isStatic":false,"isPublic":true},"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"EmailAccountSearchFilters","optional":true}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"getStats":{"name":"getStats","async":true,"parameters":[],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"getByEmail":{"name":"getByEmail","async":true,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"Promise<EmailAccount | null>","isStatic":false,"isPublic":true},"getByEmailProviderType":{"name":"getByEmailProviderType","async":true,"parameters":[{"name":"providerType","type":"ProviderType","optional":false}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"getNeedingSync":{"name":"getNeedingSync","async":true,"parameters":[{"name":"maxAgeMinutes","type":"any","optional":true}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"searchEmailAccounts":{"name":"searchEmailAccounts","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"EmailAccountSearchFilters","optional":true}],"returnType":"Promise<EmailAccount[]>","isStatic":false,"isPublic":true},"syncAll":{"name":"syncAll","async":true,"parameters":[{"name":"options","type":"SyncOptions","optional":true}],"returnType":"Promise<Map<string, object>>","isStatic":false,"isPublic":true},"getTotalUnreadCount":{"name":"getTotalUnreadCount","async":true,"parameters":[],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getEmailStats":{"name":"getEmailStats","async":true,"parameters":[],"returnType":"Promise<object>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"accounts","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"AccountCollection","exportName":"EmailAccountCollection","collectionExportName":"EmailAccountCollectionCollection","collectionOf":"@happyvertical/smrt-messages:EmailAccount","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailAttachmentCollection":{"name":"emailattachmentcollection","className":"EmailAttachmentCollection","qualifiedName":"@happyvertical/smrt-messages:EmailAttachmentCollection","collection":"emailattachments","filePath":"src/collections/EmailAttachmentCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"backfillAccountIds":{"name":"backfillAccountIds","async":true,"parameters":[],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getByMessage":{"name":"getByMessage","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getByContentType":{"name":"getByContentType","async":true,"parameters":[{"name":"contentType","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getImages":{"name":"getImages","async":true,"parameters":[{"name":"emailId","type":"string","optional":true}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"getPdfs":{"name":"getPdfs","async":true,"parameters":[{"name":"emailId","type":"string","optional":true}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"getInline":{"name":"getInline","async":true,"parameters":[{"name":"emailId","type":"string","optional":false}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"getRegular":{"name":"getRegular","async":true,"parameters":[{"name":"emailId","type":"string","optional":false}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"getWithExternalFiles":{"name":"getWithExternalFiles","async":true,"parameters":[],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getTotalSize":{"name":"getTotalSize","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"getLargest":{"name":"getLargest","async":true,"parameters":[{"name":"limit","type":"any","optional":true}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"searchByFilename":{"name":"searchByFilename","async":true,"parameters":[{"name":"query","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getByExtension":{"name":"getByExtension","async":true,"parameters":[{"name":"extension","type":"string","optional":false}],"returnType":"Promise<Attachment[]>","isStatic":false,"isPublic":true},"getStats":{"name":"getStats","async":true,"parameters":[],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"deleteByMessage":{"name":"deleteByMessage","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"getByEmail":{"name":"getByEmail","async":true,"parameters":[{"name":"emailId","type":"string","optional":false}],"returnType":"Promise<EmailAttachment[]>","isStatic":false,"isPublic":true},"deleteByEmail":{"name":"deleteByEmail","async":true,"parameters":[{"name":"emailId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","delete"]},"mcp":{"include":["list","get"]}},"extends":"AttachmentCollection","exportName":"EmailAttachmentCollection","collectionExportName":"EmailAttachmentCollectionCollection","collectionOf":"@happyvertical/smrt-messages:EmailAttachment","inheritedExposure":["api","mcp"],"schema":{"tableName":"email_attachments","ddl":"CREATE TABLE IF NOT EXISTS \\"email_attachments\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"message_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"filename\\" TEXT,\\n \\"content_type\\" TEXT,\\n \\"size\\" INTEGER NOT NULL DEFAULT 0,\\n \\"content_id\\" TEXT,\\n \\"content_disposition\\" TEXT DEFAULT 'attachment',\\n \\"file_path\\" TEXT,\\n \\"source_url\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"filename":{"type":"TEXT","notNull":false,"unique":false},"content_type":{"type":"TEXT","notNull":false,"unique":false},"size":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"content_id":{"type":"TEXT","notNull":false,"unique":false},"content_disposition":{"type":"TEXT","notNull":false,"unique":false,"default":"attachment"},"file_path":{"type":"TEXT","notNull":false,"unique":false},"source_url":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"email_attachments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"email_attachments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"email_attachments_message_id_idx","columns":["message_id"]},{"name":"email_attachments_account_id_idx","columns":["account_id"]}],"version":"ebed0053"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailCollection":{"name":"emailcollection","className":"EmailCollection","qualifiedName":"@happyvertical/smrt-messages:EmailCollection","collection":"messages","filePath":"src/collections/EmailCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"EmailSearchFilters","optional":true}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getByAccounts":{"name":"getByAccounts","async":true,"parameters":[{"name":"accountIds","type":"string[]","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getByType":{"name":"getByType","async":true,"parameters":[{"name":"messageType","type":"string","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getUnread":{"name":"getUnread","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getFlagged":{"name":"getFlagged","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getRecent":{"name":"getRecent","async":true,"parameters":[{"name":"limit","type":"any","optional":true},{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getByThread":{"name":"getByThread","async":true,"parameters":[{"name":"threadId","type":"string","optional":false}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"markAllRead":{"name":"markAllRead","async":true,"parameters":[{"name":"messageIds","type":"string[]","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getAccountStats":{"name":"getAccountStats","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"getDrafts":{"name":"getDrafts","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getSent":{"name":"getSent","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getScheduled":{"name":"getScheduled","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getFailedSends":{"name":"getFailedSends","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getOutbox":{"name":"getOutbox","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getByMessageId":{"name":"getByMessageId","async":true,"parameters":[{"name":"accountId","type":"string","optional":false},{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Email | null>","isStatic":false,"isPublic":true},"getByAccount":{"name":"getByAccount","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getByFolder":{"name":"getByFolder","async":true,"parameters":[{"name":"folderId","type":"string","optional":false}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getWithAttachments":{"name":"getWithAttachments","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"countByFolder":{"name":"countByFolder","async":true,"parameters":[{"name":"folderId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"countUnreadByFolder":{"name":"countUnreadByFolder","async":true,"parameters":[{"name":"folderId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"countUnreadByAccount":{"name":"countUnreadByAccount","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"searchEmails":{"name":"searchEmails","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"EmailSearchFilters","optional":true}],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"markFolderRead":{"name":"markFolderRead","async":true,"parameters":[{"name":"folderId","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deleteByFolder":{"name":"deleteByFolder","async":true,"parameters":[{"name":"folderId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"messages","api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"MessageCollection","exportName":"EmailCollection","collectionExportName":"EmailCollectionCollection","collectionOf":"@happyvertical/smrt-messages:Email","inheritedExposure":["api","mcp"],"schema":{"tableName":"messages","ddl":"CREATE TABLE IF NOT EXISTS \\"messages\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"persona_id\\" UUID,\\n \\"endpoint_id\\" UUID,\\n \\"correlation_id\\" TEXT,\\n \\"thread_id\\" TEXT,\\n \\"subject\\" TEXT,\\n \\"body\\" TEXT,\\n \\"from_address\\" TEXT,\\n \\"from_name\\" TEXT,\\n \\"to_addresses\\" TEXT,\\n \\"date\\" TIMESTAMP,\\n \\"is_read\\" BOOLEAN DEFAULT FALSE,\\n \\"is_flagged\\" BOOLEAN DEFAULT FALSE,\\n \\"has_attachments\\" BOOLEAN DEFAULT FALSE,\\n \\"size\\" INTEGER DEFAULT 0,\\n \\"metadata\\" TEXT,\\n \\"send_status\\" TEXT DEFAULT 'draft',\\n \\"sent_at\\" TIMESTAMP,\\n \\"send_error\\" TEXT,\\n \\"retry_count\\" INTEGER DEFAULT 0,\\n \\"max_retries\\" INTEGER DEFAULT 3,\\n \\"scheduled_send_at\\" TIMESTAMP,\\n \\"in_reply_to_message_id\\" UUID,\\n \\"message_id\\" TEXT,\\n \\"in_reply_to\\" TEXT,\\n \\"provider_message_id\\" TEXT,\\n \\"cc_addresses\\" TEXT,\\n \\"bcc_addresses\\" TEXT,\\n \\"reply_to_address\\" TEXT,\\n \\"reply_to_name\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"html_body\\" TEXT,\\n \\"folder_id\\" TEXT,\\n \\"folder_path\\" TEXT,\\n \\"labels\\" TEXT,\\n \\"flags\\" TEXT,\\n \\"is_answered\\" BOOLEAN DEFAULT FALSE,\\n \\"is_draft\\" BOOLEAN DEFAULT FALSE,\\n \\"raw_message\\" TEXT,\\n \\"headers\\" TEXT,\\n \\"channel_id\\" TEXT,\\n \\"channel_name\\" TEXT,\\n \\"slack_ts\\" TEXT,\\n \\"slack_thread_ts\\" TEXT,\\n \\"reactions\\" TEXT,\\n \\"is_edited\\" BOOLEAN DEFAULT FALSE,\\n \\"message_type\\" TEXT,\\n \\"blocks\\" TEXT,\\n \\"tweet_id\\" TEXT,\\n \\"retweet_count\\" INTEGER DEFAULT 0,\\n \\"like_count\\" INTEGER DEFAULT 0,\\n \\"reply_count\\" INTEGER DEFAULT 0,\\n \\"is_retweet\\" BOOLEAN DEFAULT FALSE,\\n \\"is_reply\\" BOOLEAN DEFAULT FALSE,\\n \\"media_urls\\" TEXT,\\n \\"hashtags\\" TEXT,\\n \\"mentions\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"correlation_id":{"type":"TEXT","notNull":false},"thread_id":{"type":"TEXT","notNull":false},"subject":{"type":"TEXT","notNull":false},"body":{"type":"TEXT","notNull":false},"from_address":{"type":"TEXT","notNull":false},"from_name":{"type":"TEXT","notNull":false},"to_addresses":{"type":"TEXT","notNull":false},"date":{"type":"TIMESTAMP","notNull":false},"is_read":{"type":"BOOLEAN","notNull":false,"default":false},"is_flagged":{"type":"BOOLEAN","notNull":false,"default":false},"has_attachments":{"type":"BOOLEAN","notNull":false,"default":false},"size":{"type":"INTEGER","notNull":false,"default":0},"metadata":{"type":"TEXT","notNull":false},"send_status":{"type":"TEXT","notNull":false,"default":"draft"},"sent_at":{"type":"TIMESTAMP","notNull":false},"send_error":{"type":"TEXT","notNull":false},"retry_count":{"type":"INTEGER","notNull":false,"default":0},"max_retries":{"type":"INTEGER","notNull":false,"default":3},"scheduled_send_at":{"type":"TIMESTAMP","notNull":false},"in_reply_to_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"TEXT","notNull":false},"in_reply_to":{"type":"TEXT","notNull":false},"provider_message_id":{"type":"TEXT","notNull":false},"cc_addresses":{"type":"TEXT","notNull":false},"bcc_addresses":{"type":"TEXT","notNull":false},"reply_to_address":{"type":"TEXT","notNull":false},"reply_to_name":{"type":"TEXT","notNull":false},"text_body":{"type":"TEXT","notNull":false},"html_body":{"type":"TEXT","notNull":false},"folder_id":{"type":"TEXT","notNull":false},"folder_path":{"type":"TEXT","notNull":false},"labels":{"type":"TEXT","notNull":false},"flags":{"type":"TEXT","notNull":false},"is_answered":{"type":"BOOLEAN","notNull":false,"default":false},"is_draft":{"type":"BOOLEAN","notNull":false,"default":false},"raw_message":{"type":"TEXT","notNull":false},"headers":{"type":"TEXT","notNull":false},"channel_id":{"type":"TEXT","notNull":false},"channel_name":{"type":"TEXT","notNull":false},"slack_ts":{"type":"TEXT","notNull":false},"slack_thread_ts":{"type":"TEXT","notNull":false},"reactions":{"type":"TEXT","notNull":false},"is_edited":{"type":"BOOLEAN","notNull":false,"default":false},"message_type":{"type":"TEXT","notNull":false},"blocks":{"type":"TEXT","notNull":false},"tweet_id":{"type":"TEXT","notNull":false},"retweet_count":{"type":"INTEGER","notNull":false,"default":0},"like_count":{"type":"INTEGER","notNull":false,"default":0},"reply_count":{"type":"INTEGER","notNull":false,"default":0},"is_retweet":{"type":"BOOLEAN","notNull":false,"default":false},"is_reply":{"type":"BOOLEAN","notNull":false,"default":false},"media_urls":{"type":"TEXT","notNull":false},"hashtags":{"type":"TEXT","notNull":false},"mentions":{"type":"TEXT","notNull":false}},"indexes":[{"name":"messages_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"messages_meta_type_idx","columns":["_meta_type"]},{"name":"messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messages_account_id_idx","columns":["account_id"]},{"name":"messages_persona_id_idx","columns":["persona_id"]},{"name":"messages_endpoint_id_idx","columns":["endpoint_id"]},{"name":"messages_in_reply_to_message_id_idx","columns":["in_reply_to_message_id"]}],"checks":[{"name":"smrt_ck_d0024f738cf4","columns":["is_answered"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_answered\\" IS NOT NULL"},{"name":"smrt_ck_0adcd2453c81","columns":["is_draft"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_draft\\" IS NOT NULL"},{"name":"smrt_ck_428e155c9609","columns":["is_edited"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:SlackMessage') OR \\"is_edited\\" IS NOT NULL"},{"name":"smrt_ck_a17af99e85e3","columns":["is_reply"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_reply\\" IS NOT NULL"},{"name":"smrt_ck_3e30563cba58","columns":["is_retweet"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_retweet\\" IS NOT NULL"},{"name":"smrt_ck_bab2c772ebe6","columns":["like_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"like_count\\" IS NOT NULL"},{"name":"smrt_ck_c6ad8d47bbc8","columns":["reply_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"reply_count\\" IS NOT NULL"},{"name":"smrt_ck_43a00e1c098d","columns":["retweet_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"retweet_count\\" IS NOT NULL"}],"version":"f48614e6"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailFolderCollection":{"name":"emailfoldercollection","className":"EmailFolderCollection","qualifiedName":"@happyvertical/smrt-messages:EmailFolderCollection","collection":"emailfolders","filePath":"src/collections/EmailFolderCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"getByPath":{"name":"getByPath","async":true,"parameters":[{"name":"accountId","type":"string","optional":false},{"name":"path","type":"string","optional":false}],"returnType":"Promise<EmailFolder | null>","isStatic":false,"isPublic":true},"getByAccount":{"name":"getByAccount","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"getInbox":{"name":"getInbox","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder | null>","isStatic":false,"isPublic":true},"getSent":{"name":"getSent","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder | null>","isStatic":false,"isPublic":true},"getDrafts":{"name":"getDrafts","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder | null>","isStatic":false,"isPublic":true},"getTrash":{"name":"getTrash","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder | null>","isStatic":false,"isPublic":true},"getSpam":{"name":"getSpam","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder | null>","isStatic":false,"isPublic":true},"getSystemFolders":{"name":"getSystemFolders","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"getUserFolders":{"name":"getUserFolders","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"getSubscribed":{"name":"getSubscribed","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"getWithUnread":{"name":"getWithUnread","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"EmailFolderSearchFilters","optional":true}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"refreshAllCounts":{"name":"refreshAllCounts","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getAccountStats":{"name":"getAccountStats","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"createSystemFolders":{"name":"createSystemFolders","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<EmailFolder[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"EmailFolder","exportName":"EmailFolderCollection","collectionExportName":"EmailFolderCollectionCollection","collectionOf":"@happyvertical/smrt-messages:EmailFolder","inheritedExposure":["api","mcp"],"schema":{"tableName":"email_folders","ddl":"CREATE TABLE IF NOT EXISTS \\"email_folders\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"path\\" TEXT,\\n \\"delimiter\\" TEXT,\\n \\"special_use\\" TEXT,\\n \\"message_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"unread_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"subscribed\\" BOOLEAN NOT NULL DEFAULT TRUE\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"name":{"type":"TEXT","notNull":false,"unique":false},"path":{"type":"TEXT","notNull":false,"unique":false},"delimiter":{"type":"TEXT","notNull":false,"unique":false},"special_use":{"type":"TEXT","notNull":false,"unique":false},"message_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"unread_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"subscribed":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"email_folders_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"email_folders_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"email_folders_account_id_idx","columns":["account_id"]}],"version":"cfea127c"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:MessageCollection":{"name":"messagecollection","className":"MessageCollection","qualifiedName":"@happyvertical/smrt-messages:MessageCollection","collection":"messages","filePath":"src/collections/MessageCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"filters","type":"MessageSearchFilters","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getByAccounts":{"name":"getByAccounts","async":true,"parameters":[{"name":"accountIds","type":"string[]","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getByType":{"name":"getByType","async":true,"parameters":[{"name":"messageType","type":"string","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getUnread":{"name":"getUnread","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getFlagged":{"name":"getFlagged","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getRecent":{"name":"getRecent","async":true,"parameters":[{"name":"limit","type":"any","optional":true},{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getByThread":{"name":"getByThread","async":true,"parameters":[{"name":"threadId","type":"string","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"markAllRead":{"name":"markAllRead","async":true,"parameters":[{"name":"messageIds","type":"string[]","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getAccountStats":{"name":"getAccountStats","async":true,"parameters":[{"name":"accountId","type":"string","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true},"getDrafts":{"name":"getDrafts","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getSent":{"name":"getSent","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getScheduled":{"name":"getScheduled","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getFailedSends":{"name":"getFailedSends","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getOutbox":{"name":"getOutbox","async":true,"parameters":[{"name":"accountId","type":"string","optional":true}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"findGlobal":{"name":"findGlobal","async":true,"parameters":[],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"findWithGlobals":{"name":"findWithGlobals","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"Message","exportName":"MessageCollection","collectionExportName":"MessageCollectionCollection","collectionOf":"@happyvertical/smrt-messages:Message","inheritedExposure":["api","mcp"],"schema":{"tableName":"messages","ddl":"CREATE TABLE IF NOT EXISTS \\"messages\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"persona_id\\" UUID,\\n \\"endpoint_id\\" UUID,\\n \\"correlation_id\\" TEXT,\\n \\"thread_id\\" TEXT,\\n \\"subject\\" TEXT,\\n \\"body\\" TEXT,\\n \\"from_address\\" TEXT,\\n \\"from_name\\" TEXT,\\n \\"to_addresses\\" TEXT,\\n \\"date\\" TIMESTAMP,\\n \\"is_read\\" BOOLEAN DEFAULT FALSE,\\n \\"is_flagged\\" BOOLEAN DEFAULT FALSE,\\n \\"has_attachments\\" BOOLEAN DEFAULT FALSE,\\n \\"size\\" INTEGER DEFAULT 0,\\n \\"metadata\\" TEXT,\\n \\"send_status\\" TEXT DEFAULT 'draft',\\n \\"sent_at\\" TIMESTAMP,\\n \\"send_error\\" TEXT,\\n \\"retry_count\\" INTEGER DEFAULT 0,\\n \\"max_retries\\" INTEGER DEFAULT 3,\\n \\"scheduled_send_at\\" TIMESTAMP,\\n \\"in_reply_to_message_id\\" UUID,\\n \\"message_id\\" TEXT,\\n \\"in_reply_to\\" TEXT,\\n \\"provider_message_id\\" TEXT,\\n \\"cc_addresses\\" TEXT,\\n \\"bcc_addresses\\" TEXT,\\n \\"reply_to_address\\" TEXT,\\n \\"reply_to_name\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"html_body\\" TEXT,\\n \\"folder_id\\" TEXT,\\n \\"folder_path\\" TEXT,\\n \\"labels\\" TEXT,\\n \\"flags\\" TEXT,\\n \\"is_answered\\" BOOLEAN DEFAULT FALSE,\\n \\"is_draft\\" BOOLEAN DEFAULT FALSE,\\n \\"raw_message\\" TEXT,\\n \\"headers\\" TEXT,\\n \\"channel_id\\" TEXT,\\n \\"channel_name\\" TEXT,\\n \\"slack_ts\\" TEXT,\\n \\"slack_thread_ts\\" TEXT,\\n \\"reactions\\" TEXT,\\n \\"is_edited\\" BOOLEAN DEFAULT FALSE,\\n \\"message_type\\" TEXT,\\n \\"blocks\\" TEXT,\\n \\"tweet_id\\" TEXT,\\n \\"retweet_count\\" INTEGER DEFAULT 0,\\n \\"like_count\\" INTEGER DEFAULT 0,\\n \\"reply_count\\" INTEGER DEFAULT 0,\\n \\"is_retweet\\" BOOLEAN DEFAULT FALSE,\\n \\"is_reply\\" BOOLEAN DEFAULT FALSE,\\n \\"media_urls\\" TEXT,\\n \\"hashtags\\" TEXT,\\n \\"mentions\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"correlation_id":{"type":"TEXT","notNull":false},"thread_id":{"type":"TEXT","notNull":false},"subject":{"type":"TEXT","notNull":false},"body":{"type":"TEXT","notNull":false},"from_address":{"type":"TEXT","notNull":false},"from_name":{"type":"TEXT","notNull":false},"to_addresses":{"type":"TEXT","notNull":false},"date":{"type":"TIMESTAMP","notNull":false},"is_read":{"type":"BOOLEAN","notNull":false,"default":false},"is_flagged":{"type":"BOOLEAN","notNull":false,"default":false},"has_attachments":{"type":"BOOLEAN","notNull":false,"default":false},"size":{"type":"INTEGER","notNull":false,"default":0},"metadata":{"type":"TEXT","notNull":false},"send_status":{"type":"TEXT","notNull":false,"default":"draft"},"sent_at":{"type":"TIMESTAMP","notNull":false},"send_error":{"type":"TEXT","notNull":false},"retry_count":{"type":"INTEGER","notNull":false,"default":0},"max_retries":{"type":"INTEGER","notNull":false,"default":3},"scheduled_send_at":{"type":"TIMESTAMP","notNull":false},"in_reply_to_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"TEXT","notNull":false},"in_reply_to":{"type":"TEXT","notNull":false},"provider_message_id":{"type":"TEXT","notNull":false},"cc_addresses":{"type":"TEXT","notNull":false},"bcc_addresses":{"type":"TEXT","notNull":false},"reply_to_address":{"type":"TEXT","notNull":false},"reply_to_name":{"type":"TEXT","notNull":false},"text_body":{"type":"TEXT","notNull":false},"html_body":{"type":"TEXT","notNull":false},"folder_id":{"type":"TEXT","notNull":false},"folder_path":{"type":"TEXT","notNull":false},"labels":{"type":"TEXT","notNull":false},"flags":{"type":"TEXT","notNull":false},"is_answered":{"type":"BOOLEAN","notNull":false,"default":false},"is_draft":{"type":"BOOLEAN","notNull":false,"default":false},"raw_message":{"type":"TEXT","notNull":false},"headers":{"type":"TEXT","notNull":false},"channel_id":{"type":"TEXT","notNull":false},"channel_name":{"type":"TEXT","notNull":false},"slack_ts":{"type":"TEXT","notNull":false},"slack_thread_ts":{"type":"TEXT","notNull":false},"reactions":{"type":"TEXT","notNull":false},"is_edited":{"type":"BOOLEAN","notNull":false,"default":false},"message_type":{"type":"TEXT","notNull":false},"blocks":{"type":"TEXT","notNull":false},"tweet_id":{"type":"TEXT","notNull":false},"retweet_count":{"type":"INTEGER","notNull":false,"default":0},"like_count":{"type":"INTEGER","notNull":false,"default":0},"reply_count":{"type":"INTEGER","notNull":false,"default":0},"is_retweet":{"type":"BOOLEAN","notNull":false,"default":false},"is_reply":{"type":"BOOLEAN","notNull":false,"default":false},"media_urls":{"type":"TEXT","notNull":false},"hashtags":{"type":"TEXT","notNull":false},"mentions":{"type":"TEXT","notNull":false}},"indexes":[{"name":"messages_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"messages_meta_type_idx","columns":["_meta_type"]},{"name":"messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messages_account_id_idx","columns":["account_id"]},{"name":"messages_persona_id_idx","columns":["persona_id"]},{"name":"messages_endpoint_id_idx","columns":["endpoint_id"]},{"name":"messages_in_reply_to_message_id_idx","columns":["in_reply_to_message_id"]}],"checks":[{"name":"smrt_ck_d0024f738cf4","columns":["is_answered"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_answered\\" IS NOT NULL"},{"name":"smrt_ck_0adcd2453c81","columns":["is_draft"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_draft\\" IS NOT NULL"},{"name":"smrt_ck_428e155c9609","columns":["is_edited"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:SlackMessage') OR \\"is_edited\\" IS NOT NULL"},{"name":"smrt_ck_a17af99e85e3","columns":["is_reply"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_reply\\" IS NOT NULL"},{"name":"smrt_ck_3e30563cba58","columns":["is_retweet"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_retweet\\" IS NOT NULL"},{"name":"smrt_ck_bab2c772ebe6","columns":["like_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"like_count\\" IS NOT NULL"},{"name":"smrt_ck_c6ad8d47bbc8","columns":["reply_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"reply_count\\" IS NOT NULL"},{"name":"smrt_ck_43a00e1c098d","columns":["retweet_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"retweet_count\\" IS NOT NULL"}],"version":"d8da74ce"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:MessagingEndpointCollection":{"name":"messagingendpointcollection","className":"MessagingEndpointCollection","qualifiedName":"@happyvertical/smrt-messages:MessagingEndpointCollection","collection":"messagingendpoints","filePath":"src/collections/MessagingEndpointCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{},"decoratorConfig":{"tableName":"messaging_endpoints","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"MessagingEndpoint","exportName":"MessagingEndpointCollection","collectionExportName":"MessagingEndpointCollectionCollection","collectionOf":"@happyvertical/smrt-messages:MessagingEndpoint","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"messaging_endpoints","ddl":"CREATE TABLE IF NOT EXISTS \\"messaging_endpoints\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"profile_id\\" UUID,\\n \\"label\\" TEXT NOT NULL,\\n \\"channel\\" TEXT NOT NULL DEFAULT 'email',\\n \\"address\\" TEXT NOT NULL,\\n \\"is_active\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"verified_at\\" TIMESTAMP\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"label":{"type":"TEXT","notNull":true,"unique":false},"channel":{"type":"TEXT","notNull":true,"unique":false,"default":"email"},"address":{"type":"TEXT","notNull":true,"unique":false},"is_active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"verified_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"messaging_endpoints_tenant_id_channel_idx","columns":["tenant_id","channel","label"],"unique":true},{"name":"messaging_endpoints_slug_context_idx","columns":["slug","context"]},{"name":"messaging_endpoints_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messaging_endpoints_profile_id_idx","columns":["profile_id"]}],"version":"b4466849"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:NotificationDeliveryCollection":{"name":"notificationdeliverycollection","className":"NotificationDeliveryCollection","qualifiedName":"@happyvertical/smrt-messages:NotificationDeliveryCollection","collection":"notificationdeliveries","filePath":"src/collections/NotificationDeliveryCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{},"decoratorConfig":{"tableName":"notification_deliveries","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"NotificationDelivery","exportName":"NotificationDeliveryCollection","collectionExportName":"NotificationDeliveryCollectionCollection","collectionOf":"@happyvertical/smrt-messages:NotificationDelivery","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"notification_deliveries","ddl":"CREATE TABLE IF NOT EXISTS \\"notification_deliveries\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"recipient_user_id\\" UUID,\\n \\"recipient_profile_id\\" UUID,\\n \\"recipient_kind\\" TEXT NOT NULL DEFAULT 'user',\\n \\"channel\\" TEXT NOT NULL DEFAULT 'email',\\n \\"source_ref\\" TEXT NOT NULL,\\n \\"kind\\" TEXT NOT NULL,\\n \\"required_dispatch_policy\\" TEXT,\\n \\"dispatch_policy_binding\\" JSON,\\n \\"subject\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"href\\" TEXT,\\n \\"recipient_address\\" TEXT NOT NULL,\\n \\"recipient_name\\" TEXT,\\n \\"account_id\\" UUID,\\n \\"message_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'pending',\\n \\"state_version\\" INTEGER NOT NULL DEFAULT 0,\\n \\"transition_id\\" TEXT,\\n \\"attempts\\" INTEGER NOT NULL DEFAULT 0,\\n \\"max_attempts\\" INTEGER NOT NULL DEFAULT 5,\\n \\"next_attempt_at\\" TEXT,\\n \\"lease_token\\" TEXT,\\n \\"lease_expires_at\\" TIMESTAMP,\\n \\"handed_off_at\\" TIMESTAMP,\\n \\"delivered_at\\" TIMESTAMP,\\n \\"provider_message_id\\" TEXT,\\n \\"last_error\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"recipient_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recipient_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recipient_kind":{"type":"TEXT","notNull":true,"unique":false,"default":"user"},"channel":{"type":"TEXT","notNull":true,"unique":false,"default":"email"},"source_ref":{"type":"TEXT","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false},"required_dispatch_policy":{"type":"TEXT","notNull":false,"unique":false},"dispatch_policy_binding":{"type":"JSON","notNull":false,"unique":false},"subject":{"type":"TEXT","notNull":false,"unique":false},"text_body":{"type":"TEXT","notNull":false,"unique":false},"href":{"type":"TEXT","notNull":false,"unique":false},"recipient_address":{"type":"TEXT","notNull":true,"unique":false},"recipient_name":{"type":"TEXT","notNull":false,"unique":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"pending"},"state_version":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"transition_id":{"type":"TEXT","notNull":false,"unique":false},"attempts":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"max_attempts":{"type":"INTEGER","notNull":true,"unique":false,"default":5},"next_attempt_at":{"type":"TEXT","notNull":false,"unique":false},"lease_token":{"type":"TEXT","notNull":false,"unique":false},"lease_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"handed_off_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"delivered_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"provider_message_id":{"type":"TEXT","notNull":false,"unique":false},"last_error":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"notification_deliveries_tenant_id_recipient_kind_idx","columns":["tenant_id","recipient_kind","recipient_user_id","recipient_profile_id","channel","source_ref"],"unique":true,"nullsNotDistinct":true},{"name":"notification_deliveries_slug_context_idx","columns":["slug","context"]},{"name":"notification_deliveries_user_identity","columns":["tenant_id","recipient_user_id","channel","source_ref"],"unique":true},{"name":"notification_deliveries_profile_identity","columns":["tenant_id","recipient_profile_id","channel","source_ref"],"unique":true},{"name":"notification_deliveries_due_idx","columns":["status","next_attempt_at"]},{"name":"notification_deliveries_lease_idx","columns":["status","lease_expires_at"]},{"name":"notification_deliveries_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"notification_deliveries_recipient_user_id_idx","columns":["recipient_user_id"]},{"name":"notification_deliveries_recipient_profile_id_idx","columns":["recipient_profile_id"]},{"name":"notification_deliveries_account_id_idx","columns":["account_id"]},{"name":"notification_deliveries_message_id_idx","columns":["message_id"]}],"version":"547f434f"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:NotificationOptOutCollection":{"name":"notificationoptoutcollection","className":"NotificationOptOutCollection","qualifiedName":"@happyvertical/smrt-messages:NotificationOptOutCollection","collection":"notificationoptouts","filePath":"src/collections/NotificationOptOutCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{},"decoratorConfig":{"tableName":"notification_opt_outs","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"NotificationOptOut","exportName":"NotificationOptOutCollection","collectionExportName":"NotificationOptOutCollectionCollection","collectionOf":"@happyvertical/smrt-messages:NotificationOptOut","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"notification_opt_outs","ddl":"CREATE TABLE IF NOT EXISTS \\"notification_opt_outs\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"recipient_user_id\\" UUID NOT NULL,\\n \\"channel\\" TEXT NOT NULL DEFAULT 'email',\\n \\"scope\\" TEXT NOT NULL,\\n \\"opted_out_at\\" TIMESTAMP,\\n \\"updated_by\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"recipient_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"channel":{"type":"TEXT","notNull":true,"unique":false,"default":"email"},"scope":{"type":"TEXT","notNull":true,"unique":false},"opted_out_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"updated_by":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"notification_opt_outs_tenant_id_recipient_user_id_idx","columns":["tenant_id","recipient_user_id","channel","scope"],"unique":true},{"name":"notification_opt_outs_slug_context_idx","columns":["slug","context"]},{"name":"notification_opt_outs_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"notification_opt_outs_recipient_user_id_idx","columns":["recipient_user_id"]}],"version":"a13e93c1"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:PersonaMessageRouteCollection":{"name":"personamessageroutecollection","className":"PersonaMessageRouteCollection","qualifiedName":"@happyvertical/smrt-messages:PersonaMessageRouteCollection","collection":"personamessageroutes","filePath":"src/collections/PersonaMessageRouteCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"forPersona":{"name":"forPersona","async":true,"parameters":[{"name":"personaId","type":"string","optional":false}],"returnType":"Promise<PersonaMessageRoute[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"persona_message_routes","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"PersonaMessageRoute","exportName":"PersonaMessageRouteCollection","collectionExportName":"PersonaMessageRouteCollectionCollection","collectionOf":"@happyvertical/smrt-messages:PersonaMessageRoute","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"persona_message_routes","ddl":"CREATE TABLE IF NOT EXISTS \\"persona_message_routes\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"persona_id\\" UUID NOT NULL,\\n \\"account_id\\" UUID NOT NULL,\\n \\"endpoint_id\\" UUID NOT NULL,\\n \\"purpose\\" TEXT NOT NULL,\\n \\"priority\\" INTEGER NOT NULL DEFAULT 0,\\n \\"enabled\\" BOOLEAN NOT NULL DEFAULT TRUE\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"purpose":{"type":"TEXT","notNull":true,"unique":false},"priority":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"enabled":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"persona_message_routes_tenant_id_persona_id_idx","columns":["tenant_id","persona_id","account_id","endpoint_id","purpose"],"unique":true},{"name":"persona_message_routes_slug_context_idx","columns":["slug","context"]},{"name":"persona_message_routes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"persona_message_routes_persona_id_idx","columns":["persona_id"]},{"name":"persona_message_routes_account_id_idx","columns":["account_id"]},{"name":"persona_message_routes_endpoint_id_idx","columns":["endpoint_id"]}],"version":"3caf446e"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:UserNotificationCollection":{"name":"usernotificationcollection","className":"UserNotificationCollection","qualifiedName":"@happyvertical/smrt-messages:UserNotificationCollection","collection":"usernotifications","filePath":"src/collections/UserNotificationCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{},"decoratorConfig":{"tableName":"user_notifications","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"UserNotification","exportName":"UserNotificationCollection","collectionExportName":"UserNotificationCollectionCollection","collectionOf":"@happyvertical/smrt-messages:UserNotification","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"user_notifications","ddl":"CREATE TABLE IF NOT EXISTS \\"user_notifications\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"recipient_user_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT,\\n \\"title\\" TEXT,\\n \\"body\\" TEXT,\\n \\"href\\" TEXT,\\n \\"severity\\" TEXT DEFAULT 'info',\\n \\"source_ref\\" TEXT NOT NULL,\\n \\"occurred_at\\" TEXT,\\n \\"read_at\\" TIMESTAMP,\\n \\"dismissed_at\\" TIMESTAMP\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"recipient_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false},"title":{"type":"TEXT","notNull":false,"unique":false},"body":{"type":"TEXT","notNull":false,"unique":false},"href":{"type":"TEXT","notNull":false,"unique":false},"severity":{"type":"TEXT","notNull":false,"unique":false,"default":"info"},"source_ref":{"type":"TEXT","notNull":true,"unique":false},"occurred_at":{"type":"TEXT","notNull":false,"unique":false},"read_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"dismissed_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"user_notifications_tenant_id_recipient_user_id_idx","columns":["tenant_id","recipient_user_id","source_ref"],"unique":true},{"name":"user_notifications_slug_context_idx","columns":["slug","context"]},{"name":"user_notifications_recipient_occurred_idx","columns":["tenant_id","recipient_user_id","occurred_at"]},{"name":"user_notifications_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"user_notifications_recipient_user_id_idx","columns":["recipient_user_id"]}],"version":"812ca772"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:WhitelistCollection":{"name":"whitelistcollection","className":"WhitelistCollection","qualifiedName":"@happyvertical/smrt-messages:WhitelistCollection","collection":"whitelists","filePath":"src/collections/WhitelistCollection.ts","packageName":"@happyvertical/smrt-messages","fields":{},"methods":{"isWhitelisted":{"name":"isWhitelisted","async":true,"parameters":[{"name":"email","type":"string","optional":false},{"name":"category","type":"string","optional":true}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"getMatchingEntry":{"name":"getMatchingEntry","async":true,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"Promise<Whitelist | null>","isStatic":false,"isPublic":true},"getByCategory":{"name":"getByCategory","async":true,"parameters":[{"name":"category","type":"string","optional":false}],"returnType":"Promise<Whitelist[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]}},"extends":"SmrtCollection","extendsTypeArg":"Whitelist","exportName":"WhitelistCollection","collectionExportName":"WhitelistCollectionCollection","collectionOf":"@happyvertical/smrt-messages:Whitelist","inheritedExposure":["api"],"schema":{"tableName":"whitelists","ddl":"CREATE TABLE IF NOT EXISTS \\"whitelists\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"pattern\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'email',\\n \\"category\\" TEXT,\\n \\"description\\" TEXT DEFAULT '',\\n \\"tenant_id\\" UUID NOT NULL\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"pattern":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"email"},"category":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false}},"indexes":[{"name":"whitelists_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"whitelists_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"eb5b558d"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Account":{"name":"account","className":"Account","qualifiedName":"@happyvertical/smrt-messages:Account","collection":"accounts","filePath":"src/models/Account.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The display name for this connected messaging account."},"required":false,"description":"The display name for this connected messaging account."},"providerType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The service that connects this account to your application."},"required":false,"description":"The service that connects this account to your application."},"channelType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of messaging this account supports, such as email or chat."},"required":false,"description":"The kind of messaging this account supports, such as email or chat."},"credentialSecretId":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this account is enabled for messaging."},"required":true,"default":true,"description":"Whether this account is enabled for messaging."},"ownerUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The person who owns this account and decides who else may use it."},"required":false,"related":"@happyvertical/smrt-users:User","description":"The person who owns this account and decides who else may use it."},"label":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A short name shown beside this account, such as Support or Personal."},"required":false,"description":"A short name shown beside this account, such as Support or Personal."},"connectionStatus":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"required":false,"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"statusMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Why the account needs attention, in plain words."},"required":false,"description":"Why the account needs attention, in plain words."},"lastSyncAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this account last checked for new messages."},"required":false,"description":"When this account last checked for new messages."},"settings":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"configuration":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The public connection settings for this account; credentials are stored separately."},"required":false,"description":"The public connection settings for this account; credentials are stored separately."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was added."},"required":false,"description":"When this account was added."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was last changed."},"required":false,"description":"When this account was last changed."}},"methods":{"getSettings":{"name":"getSettings","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setSettings":{"name":"setSettings","async":false,"parameters":[{"name":"settings","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getConfiguration":{"name":"getConfiguration","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setConfiguration":{"name":"setConfiguration","async":false,"parameters":[{"name":"configuration","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markNeedsReconnect":{"name":"markNeedsReconnect","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markConnected":{"name":"markConnected","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"activate":{"name":"activate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deactivate":{"name":"deactivate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"setCredentials":{"name":"setCredentials","async":true,"parameters":[{"name":"credentials","type":"Record<string, unknown>","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"removeCredentials":{"name":"removeCredentials","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"createSender":{"name":"createSender","async":true,"parameters":[],"returnType":"Promise<MessageSenderInterface>","isStatic":false,"isPublic":true},"getCredentials":{"name":"getCredentials","async":true,"parameters":[],"returnType":"Promise<Record<string, unknown> | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context","_meta_type"]},"extends":"SmrtObject","exportName":"Account","collectionExportName":"AccountCollection","displayLabelField":"name","validationRules":[{"field":"isActive","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Attachment":{"name":"attachment","className":"Attachment","qualifiedName":"@happyvertical/smrt-messages:Attachment","collection":"attachments","filePath":"src/models/Attachment.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"messageId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Message"},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Account"},"filename":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"contentType":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"size":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"contentId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"contentDisposition":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"attachment","enum":["attachment","inline"]},"filePath":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"sourceUrl":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"createdAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getMessage":{"name":"getMessage","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"isImage":{"name":"isImage","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPdf":{"name":"isPdf","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isInline":{"name":"isInline","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getExtension":{"name":"getExtension","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true},"getFormattedSize":{"name":"getFormattedSize","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true},"hasExternalFile":{"name":"hasExternalFile","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"readContent":{"name":"readContent","async":true,"parameters":[],"returnType":"Promise<Buffer | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","delete"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Attachment","collectionExportName":"AttachmentCollection","validationRules":[{"field":"size","rule":"required","fieldType":"integer"}],"schema":{"tableName":"attachments","ddl":"CREATE TABLE IF NOT EXISTS \\"attachments\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"message_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"filename\\" TEXT,\\n \\"content_type\\" TEXT,\\n \\"size\\" INTEGER NOT NULL DEFAULT 0,\\n \\"content_id\\" TEXT,\\n \\"content_disposition\\" TEXT DEFAULT 'attachment',\\n \\"file_path\\" TEXT,\\n \\"source_url\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"filename":{"type":"TEXT","notNull":false,"unique":false},"content_type":{"type":"TEXT","notNull":false,"unique":false},"size":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"content_id":{"type":"TEXT","notNull":false,"unique":false},"content_disposition":{"type":"TEXT","notNull":false,"unique":false,"default":"attachment"},"file_path":{"type":"TEXT","notNull":false,"unique":false},"source_url":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"attachments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"attachments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"attachments_message_id_idx","columns":["message_id"]},{"name":"attachments_account_id_idx","columns":["account_id"]}],"version":"3f32531c"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Blacklist":{"name":"blacklist","className":"Blacklist","qualifiedName":"@happyvertical/smrt-messages:Blacklist","collection":"blacklists","description":"Block entries for email filtering","filePath":"src/models/Blacklist.ts","packageName":"@happyvertical/smrt-messages","fields":{"pattern":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"type":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"email","enum":["email","domain","regex"]},"reason":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"autoArchive":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":false,"default":true},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"mode":"required","field":"tenantId","autoFilter":true,"autoPopulate":true,"allowSuperAdminBypass":false},"generated":true,"source":"tenantScoped_decorator","sqlType":"UUID"},"required":true}},"methods":{"matches":{"name":"matches","async":false,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"cli":{"skipApiCheck":true},"tenantScoped":true,"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Blacklist","collectionExportName":"BlacklistCollection","validationRules":[],"schema":{"tableName":"blacklists","ddl":"CREATE TABLE IF NOT EXISTS \\"blacklists\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"pattern\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'email',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"auto_archive\\" BOOLEAN DEFAULT TRUE,\\n \\"tenant_id\\" UUID NOT NULL\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"pattern":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"email"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"auto_archive":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false}},"indexes":[{"name":"blacklists_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"blacklists_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"478c8724"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Email":{"name":"email","className":"Email","qualifiedName":"@happyvertical/smrt-messages:Email","collection":"messages","filePath":"src/models/Email.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The connected account used to receive or send this message."},"required":false,"related":"Account","description":"The connected account used to receive or send this message."},"personaId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","description","related","required"],"required":false,"description":"The assistant identity associated with this message, when one was used.","nullable":true},"required":false,"related":"@happyvertical/smrt-personas:AgentPersona","description":"The assistant identity associated with this message, when one was used."},"endpointId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The saved destination used to deliver this message."},"required":false,"related":"MessagingEndpoint","description":"The saved destination used to deliver this message."},"correlationId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A tracking reference that connects this message to related activity."},"required":false,"description":"A tracking reference that connects this message to related activity."},"threadId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The conversation this message belongs to."},"required":false,"description":"The conversation this message belongs to."},"subject":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The subject shown in the message list."},"required":false,"description":"The subject shown in the message list."},"body":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The message content in plain text."},"required":false,"description":"The message content in plain text."},"fromAddress":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The address the message was sent from."},"required":false,"description":"The address the message was sent from."},"fromName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The sender name shown beside their address."},"required":false,"description":"The sender name shown beside their address."},"toAddresses":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The people or addresses receiving this message."},"required":false,"description":"The people or addresses receiving this message."},"date":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was sent or received."},"required":false,"description":"When the message was sent or received."},"isRead":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message has been marked as read."},"required":true,"default":false,"description":"Whether this message has been marked as read."},"isFlagged":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message is flagged for follow-up."},"required":true,"default":false,"description":"Whether this message is flagged for follow-up."},"hasAttachments":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether files are attached to this message."},"required":true,"default":false,"description":"Whether files are attached to this message."},"size":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The size of the message in bytes."},"required":true,"default":0,"description":"The size of the message in bytes."},"metadata":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Additional details supplied by the messaging connection."},"required":false,"description":"Additional details supplied by the messaging connection."},"sendStatus":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here."},"required":false,"default":"draft","description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here.","enum":["draft","pending","sending","sent","failed","scheduled"]},"sentAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was successfully sent."},"required":false,"description":"When the message was successfully sent."},"sendError":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The reason the latest send attempt failed."},"required":false,"description":"The reason the latest send attempt failed."},"retryCount":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"How many times delivery has been retried."},"required":true,"default":0,"description":"How many times delivery has been retried."},"maxRetries":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The maximum number of delivery retries allowed."},"required":true,"default":3,"description":"The maximum number of delivery retries allowed."},"scheduledSendAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this message is scheduled to be sent."},"required":false,"description":"When this message is scheduled to be sent."},"inReplyToMessageId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The earlier message this one replies to."},"required":false,"related":"Message","description":"The earlier message this one replies to."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was recorded."},"required":false,"description":"When this message was recorded."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was last changed."},"required":false,"description":"When this message was last changed."},"messageId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The email reference assigned by the sender for tracking replies."},"required":false,"description":"The email reference assigned by the sender for tracking replies."},"inReplyTo":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The sender-assigned reference of the email being replied to."},"required":false,"description":"The sender-assigned reference of the email being replied to."},"providerMessageId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The mail server's own id for this email, used to keep mailbox sync from storing it twice."},"required":false,"description":"The mail server's own id for this email, used to keep mailbox sync from storing it twice."},"ccAddresses":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Recipients receiving a visible copy of this email."},"required":false,"description":"Recipients receiving a visible copy of this email."},"bccAddresses":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Recipients receiving a copy without appearing in the visible recipient list."},"required":false,"description":"Recipients receiving a copy without appearing in the visible recipient list."},"replyToAddress":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The address replies should be sent to."},"required":false,"description":"The address replies should be sent to."},"replyToName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The name associated with the reply address."},"required":false,"description":"The name associated with the reply address."},"textBody":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The plain-text version of the email."},"required":false,"description":"The plain-text version of the email."},"htmlBody":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The formatted version of the email."},"required":false,"description":"The formatted version of the email."},"folderId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The mailbox folder reference supplied by the email connection."},"required":false,"description":"The mailbox folder reference supplied by the email connection."},"folderPath":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The location of this email within the mailbox folders."},"required":false,"description":"The location of this email within the mailbox folders."},"labels":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Labels applied to this email by the mailbox provider."},"required":false,"description":"Labels applied to this email by the mailbox provider."},"flags":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Mailbox markers such as read, answered, or flagged."},"required":false,"description":"Mailbox markers such as read, answered, or flagged."},"isAnswered":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this email has been replied to."},"required":true,"default":false,"description":"Whether this email has been replied to."},"isDraft":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this email is saved as an unfinished draft."},"required":true,"default":false,"description":"Whether this email is saved as an unfinished draft."},"rawMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The original email content as received from the mail server."},"required":false,"description":"The original email content as received from the mail server."},"headers":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Delivery and routing details included with the email."},"required":false,"description":"Delivery and routing details included with the email."}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getToAddresses":{"name":"getToAddresses","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"setToAddresses":{"name":"setToAddresses","async":false,"parameters":[{"name":"addresses","type":"Array<object>","optional":false,"memberTypes":["string"]}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"data","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markRead":{"name":"markRead","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markUnread":{"name":"markUnread","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"toggleFlagged":{"name":"toggleFlagged","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isUnread":{"name":"isUnread","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getPreview":{"name":"getPreview","async":false,"parameters":[{"name":"maxLength","type":"any","optional":true}],"returnType":"string","isStatic":false,"isPublic":true},"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getAccount":{"name":"getAccount","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getEndpoint":{"name":"getEndpoint","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getThreadMessages":{"name":"getThreadMessages","async":true,"parameters":[],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getAttachments":{"name":"getAttachments","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"send":{"name":"send","async":true,"parameters":[{"name":"options","type":"SendEmailOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"isSendOutcomeUnknown":{"name":"isSendOutcomeUnknown","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"abandonSendAttempt":{"name":"abandonSendAttempt","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"retrySend":{"name":"retrySend","async":true,"parameters":[{"name":"options","type":"SendEmailOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"createReply":{"name":"createReply","async":false,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["boolean"]}],"returnType":"Email","isStatic":false,"isPublic":true},"createForward":{"name":"createForward","async":false,"parameters":[],"returnType":"Email","isStatic":false,"isPublic":true},"getCcAddresses":{"name":"getCcAddresses","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"getBccAddresses":{"name":"getBccAddresses","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"getLabels":{"name":"getLabels","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"setLabels":{"name":"setLabels","async":false,"parameters":[{"name":"labels","type":"string[]","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getFlags":{"name":"getFlags","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"setFlags":{"name":"setFlags","async":false,"parameters":[{"name":"flags","type":"string[]","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getHeaders":{"name":"getHeaders","async":false,"parameters":[],"returnType":"Record<string, string | string[]>","isStatic":false,"isPublic":true},"setHeaders":{"name":"setHeaders","async":false,"parameters":[{"name":"headers","type":"Record<string, string | string[]>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getFolder":{"name":"getFolder","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getThreadEmails":{"name":"getThreadEmails","async":true,"parameters":[],"returnType":"Promise<Email[]>","isStatic":false,"isPublic":true},"getReferences":{"name":"getReferences","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"widenParentExposure":{"api":["create","update","delete"]},"tableName":"messages"},"extends":"Message","exportName":"Email","collectionExportName":"EmailCollection","validationRules":[{"field":"isRead","rule":"required","fieldType":"boolean"},{"field":"isFlagged","rule":"required","fieldType":"boolean"},{"field":"hasAttachments","rule":"required","fieldType":"boolean"},{"field":"size","rule":"required","fieldType":"integer"},{"field":"retryCount","rule":"required","fieldType":"integer"},{"field":"maxRetries","rule":"required","fieldType":"integer"},{"field":"isAnswered","rule":"required","fieldType":"boolean"},{"field":"isDraft","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"messages","ddl":"CREATE TABLE IF NOT EXISTS \\"messages\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"persona_id\\" UUID,\\n \\"endpoint_id\\" UUID,\\n \\"correlation_id\\" TEXT,\\n \\"thread_id\\" TEXT,\\n \\"subject\\" TEXT,\\n \\"body\\" TEXT,\\n \\"from_address\\" TEXT,\\n \\"from_name\\" TEXT,\\n \\"to_addresses\\" TEXT,\\n \\"date\\" TIMESTAMP,\\n \\"is_read\\" BOOLEAN DEFAULT FALSE,\\n \\"is_flagged\\" BOOLEAN DEFAULT FALSE,\\n \\"has_attachments\\" BOOLEAN DEFAULT FALSE,\\n \\"size\\" INTEGER DEFAULT 0,\\n \\"metadata\\" TEXT,\\n \\"send_status\\" TEXT DEFAULT 'draft',\\n \\"sent_at\\" TIMESTAMP,\\n \\"send_error\\" TEXT,\\n \\"retry_count\\" INTEGER DEFAULT 0,\\n \\"max_retries\\" INTEGER DEFAULT 3,\\n \\"scheduled_send_at\\" TIMESTAMP,\\n \\"in_reply_to_message_id\\" UUID,\\n \\"message_id\\" TEXT,\\n \\"in_reply_to\\" TEXT,\\n \\"provider_message_id\\" TEXT,\\n \\"cc_addresses\\" TEXT,\\n \\"bcc_addresses\\" TEXT,\\n \\"reply_to_address\\" TEXT,\\n \\"reply_to_name\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"html_body\\" TEXT,\\n \\"folder_id\\" TEXT,\\n \\"folder_path\\" TEXT,\\n \\"labels\\" TEXT,\\n \\"flags\\" TEXT,\\n \\"is_answered\\" BOOLEAN DEFAULT FALSE,\\n \\"is_draft\\" BOOLEAN DEFAULT FALSE,\\n \\"raw_message\\" TEXT,\\n \\"headers\\" TEXT,\\n \\"channel_id\\" TEXT,\\n \\"channel_name\\" TEXT,\\n \\"slack_ts\\" TEXT,\\n \\"slack_thread_ts\\" TEXT,\\n \\"reactions\\" TEXT,\\n \\"is_edited\\" BOOLEAN DEFAULT FALSE,\\n \\"message_type\\" TEXT,\\n \\"blocks\\" TEXT,\\n \\"tweet_id\\" TEXT,\\n \\"retweet_count\\" INTEGER DEFAULT 0,\\n \\"like_count\\" INTEGER DEFAULT 0,\\n \\"reply_count\\" INTEGER DEFAULT 0,\\n \\"is_retweet\\" BOOLEAN DEFAULT FALSE,\\n \\"is_reply\\" BOOLEAN DEFAULT FALSE,\\n \\"media_urls\\" TEXT,\\n \\"hashtags\\" TEXT,\\n \\"mentions\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"correlation_id":{"type":"TEXT","notNull":false},"thread_id":{"type":"TEXT","notNull":false},"subject":{"type":"TEXT","notNull":false},"body":{"type":"TEXT","notNull":false},"from_address":{"type":"TEXT","notNull":false},"from_name":{"type":"TEXT","notNull":false},"to_addresses":{"type":"TEXT","notNull":false},"date":{"type":"TIMESTAMP","notNull":false},"is_read":{"type":"BOOLEAN","notNull":false,"default":false},"is_flagged":{"type":"BOOLEAN","notNull":false,"default":false},"has_attachments":{"type":"BOOLEAN","notNull":false,"default":false},"size":{"type":"INTEGER","notNull":false,"default":0},"metadata":{"type":"TEXT","notNull":false},"send_status":{"type":"TEXT","notNull":false,"default":"draft"},"sent_at":{"type":"TIMESTAMP","notNull":false},"send_error":{"type":"TEXT","notNull":false},"retry_count":{"type":"INTEGER","notNull":false,"default":0},"max_retries":{"type":"INTEGER","notNull":false,"default":3},"scheduled_send_at":{"type":"TIMESTAMP","notNull":false},"in_reply_to_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"TEXT","notNull":false},"in_reply_to":{"type":"TEXT","notNull":false},"provider_message_id":{"type":"TEXT","notNull":false},"cc_addresses":{"type":"TEXT","notNull":false},"bcc_addresses":{"type":"TEXT","notNull":false},"reply_to_address":{"type":"TEXT","notNull":false},"reply_to_name":{"type":"TEXT","notNull":false},"text_body":{"type":"TEXT","notNull":false},"html_body":{"type":"TEXT","notNull":false},"folder_id":{"type":"TEXT","notNull":false},"folder_path":{"type":"TEXT","notNull":false},"labels":{"type":"TEXT","notNull":false},"flags":{"type":"TEXT","notNull":false},"is_answered":{"type":"BOOLEAN","notNull":false,"default":false},"is_draft":{"type":"BOOLEAN","notNull":false,"default":false},"raw_message":{"type":"TEXT","notNull":false},"headers":{"type":"TEXT","notNull":false},"channel_id":{"type":"TEXT","notNull":false},"channel_name":{"type":"TEXT","notNull":false},"slack_ts":{"type":"TEXT","notNull":false},"slack_thread_ts":{"type":"TEXT","notNull":false},"reactions":{"type":"TEXT","notNull":false},"is_edited":{"type":"BOOLEAN","notNull":false,"default":false},"message_type":{"type":"TEXT","notNull":false},"blocks":{"type":"TEXT","notNull":false},"tweet_id":{"type":"TEXT","notNull":false},"retweet_count":{"type":"INTEGER","notNull":false,"default":0},"like_count":{"type":"INTEGER","notNull":false,"default":0},"reply_count":{"type":"INTEGER","notNull":false,"default":0},"is_retweet":{"type":"BOOLEAN","notNull":false,"default":false},"is_reply":{"type":"BOOLEAN","notNull":false,"default":false},"media_urls":{"type":"TEXT","notNull":false},"hashtags":{"type":"TEXT","notNull":false},"mentions":{"type":"TEXT","notNull":false}},"indexes":[{"name":"messages_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"messages_meta_type_idx","columns":["_meta_type"]},{"name":"messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messages_account_id_idx","columns":["account_id"]},{"name":"messages_persona_id_idx","columns":["persona_id"]},{"name":"messages_endpoint_id_idx","columns":["endpoint_id"]},{"name":"messages_in_reply_to_message_id_idx","columns":["in_reply_to_message_id"]}],"checks":[{"name":"smrt_ck_d0024f738cf4","columns":["is_answered"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_answered\\" IS NOT NULL"},{"name":"smrt_ck_0adcd2453c81","columns":["is_draft"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_draft\\" IS NOT NULL"},{"name":"smrt_ck_428e155c9609","columns":["is_edited"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:SlackMessage') OR \\"is_edited\\" IS NOT NULL"},{"name":"smrt_ck_a17af99e85e3","columns":["is_reply"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_reply\\" IS NOT NULL"},{"name":"smrt_ck_3e30563cba58","columns":["is_retweet"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_retweet\\" IS NOT NULL"},{"name":"smrt_ck_bab2c772ebe6","columns":["like_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"like_count\\" IS NOT NULL"},{"name":"smrt_ck_c6ad8d47bbc8","columns":["reply_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"reply_count\\" IS NOT NULL"},{"name":"smrt_ck_43a00e1c098d","columns":["retweet_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"retweet_count\\" IS NOT NULL"}],"version":"f48614e6"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailAccount":{"name":"emailaccount","className":"EmailAccount","qualifiedName":"@happyvertical/smrt-messages:EmailAccount","collection":"accounts","filePath":"src/models/EmailAccount.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The display name for this connected messaging account."},"required":false,"description":"The display name for this connected messaging account."},"providerType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The service that connects this account to your application."},"required":false,"description":"The service that connects this account to your application."},"channelType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of messaging this account supports, such as email or chat."},"required":false,"description":"The kind of messaging this account supports, such as email or chat."},"credentialSecretId":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this account is enabled for messaging."},"required":true,"default":true,"description":"Whether this account is enabled for messaging."},"ownerUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The person who owns this account and decides who else may use it."},"required":false,"related":"@happyvertical/smrt-users:User","description":"The person who owns this account and decides who else may use it."},"label":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A short name shown beside this account, such as Support or Personal."},"required":false,"description":"A short name shown beside this account, such as Support or Personal."},"connectionStatus":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"required":false,"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"statusMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Why the account needs attention, in plain words."},"required":false,"description":"Why the account needs attention, in plain words."},"lastSyncAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this account last checked for new messages."},"required":false,"description":"When this account last checked for new messages."},"settings":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"configuration":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The public connection settings for this account; credentials are stored separately."},"required":false,"description":"The public connection settings for this account; credentials are stored separately."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was added."},"required":false,"description":"When this account was added."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was last changed."},"required":false,"description":"When this account was last changed."},"email":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The email address associated with this mailbox."},"required":false,"description":"The email address associated with this mailbox."},"syncIntervalMinutes":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The time in minutes between scheduled mailbox checks."},"required":true,"default":60,"description":"The time in minutes between scheduled mailbox checks."},"syncCursor":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly","description"],"description":"Where the next mailbox check resumes.","sensitive":true,"readonly":true},"required":false,"description":"Where the next mailbox check resumes.","sensitive":true,"readonly":true}},"methods":{"getSettings":{"name":"getSettings","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setSettings":{"name":"setSettings","async":false,"parameters":[{"name":"settings","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getConfiguration":{"name":"getConfiguration","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setConfiguration":{"name":"setConfiguration","async":false,"parameters":[{"name":"configuration","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markNeedsReconnect":{"name":"markNeedsReconnect","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markConnected":{"name":"markConnected","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"activate":{"name":"activate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deactivate":{"name":"deactivate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"setCredentials":{"name":"setCredentials","async":true,"parameters":[{"name":"credentials","type":"Record<string, unknown>","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"removeCredentials":{"name":"removeCredentials","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"createSender":{"name":"createSender","async":true,"parameters":[],"returnType":"Promise<MessageSenderInterface>","isStatic":false,"isPublic":true},"getCredentials":{"name":"getCredentials","async":true,"parameters":[],"returnType":"Promise<Record<string, unknown> | null>","isStatic":false,"isPublic":true},"childOptions":{"name":"childOptions","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"createClient":{"name":"createClient","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"readIntakeMessage":{"name":"readIntakeMessage","async":true,"parameters":[{"name":"locator","type":"string","optional":false},{"name":"maxBytes","type":"number","optional":false},{"name":"imapIdentity","type":"object","optional":true,"memberTypes":["string","number"]}],"returnType":"any","isStatic":false,"isPublic":true},"syncFrom":{"name":"syncFrom","async":true,"parameters":[{"name":"options","type":"SyncOptions","optional":true}],"returnType":"Promise<SyncResult>","isStatic":false,"isPublic":true},"syncChanges":{"name":"syncChanges","async":true,"parameters":[{"name":"options","type":"MailSyncOptions","optional":true}],"returnType":"Promise<MailSyncResult>","isStatic":false,"isPublic":true},"fetchThread":{"name":"fetchThread","async":true,"parameters":[{"name":"threadId","type":"string","optional":false}],"returnType":"any","isStatic":false,"isPublic":true},"getFolders":{"name":"getFolders","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getEmails":{"name":"getEmails","async":true,"parameters":[{"name":"limit","type":"number","optional":true}],"returnType":"any","isStatic":false,"isPublic":true},"getUnreadCount":{"name":"getUnreadCount","async":true,"parameters":[],"returnType":"Promise<number>","isStatic":false,"isPublic":true},"syncAll":{"name":"syncAll","async":true,"parameters":[{"name":"args","type":"Record<string, unknown>","optional":true}],"returnType":"Promise<Map<string, object>>","isStatic":false,"isPublic":true},"migrateToSecrets":{"name":"migrateToSecrets","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tableName":"accounts"},"extends":"Account","exportName":"EmailAccount","collectionExportName":"EmailAccountCollection","displayLabelField":"name","validationRules":[{"field":"isActive","rule":"required","fieldType":"boolean"},{"field":"syncIntervalMinutes","rule":"required","fieldType":"integer"}],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailAttachment":{"name":"emailattachment","className":"EmailAttachment","qualifiedName":"@happyvertical/smrt-messages:EmailAttachment","collection":"emailattachments","filePath":"src/models/EmailAttachment.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"messageId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Message"},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Account"},"filename":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"contentType":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"size":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"contentId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"contentDisposition":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"attachment","enum":["attachment","inline"]},"filePath":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"sourceUrl":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"createdAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getMessage":{"name":"getMessage","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"isImage":{"name":"isImage","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isPdf":{"name":"isPdf","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isInline":{"name":"isInline","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getExtension":{"name":"getExtension","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true},"getFormattedSize":{"name":"getFormattedSize","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true},"hasExternalFile":{"name":"hasExternalFile","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"readContent":{"name":"readContent","async":true,"parameters":[],"returnType":"Promise<Buffer | null>","isStatic":false,"isPublic":true},"getEmail":{"name":"getEmail","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","delete"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"conflictColumns":["tenant_id","slug","context"]},"extends":"Attachment","exportName":"EmailAttachment","collectionExportName":"EmailAttachmentCollection","validationRules":[{"field":"size","rule":"required","fieldType":"integer"}],"schema":{"tableName":"email_attachments","ddl":"CREATE TABLE IF NOT EXISTS \\"email_attachments\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"message_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"filename\\" TEXT,\\n \\"content_type\\" TEXT,\\n \\"size\\" INTEGER NOT NULL DEFAULT 0,\\n \\"content_id\\" TEXT,\\n \\"content_disposition\\" TEXT DEFAULT 'attachment',\\n \\"file_path\\" TEXT,\\n \\"source_url\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"filename":{"type":"TEXT","notNull":false,"unique":false},"content_type":{"type":"TEXT","notNull":false,"unique":false},"size":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"content_id":{"type":"TEXT","notNull":false,"unique":false},"content_disposition":{"type":"TEXT","notNull":false,"unique":false,"default":"attachment"},"file_path":{"type":"TEXT","notNull":false,"unique":false},"source_url":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"email_attachments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"email_attachments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"email_attachments_message_id_idx","columns":["message_id"]},{"name":"email_attachments_account_id_idx","columns":["account_id"]}],"version":"ebed0053"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:EmailFolder":{"name":"emailfolder","className":"EmailFolder","qualifiedName":"@happyvertical/smrt-messages:EmailFolder","collection":"emailfolders","filePath":"src/models/EmailFolder.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Account"},"name":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"path":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"delimiter":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"specialUse":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"messageCount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"unreadCount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"subscribed":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":true,"default":true},"createdAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"updatedAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getAccount":{"name":"getAccount","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getEmails":{"name":"getEmails","async":true,"parameters":[{"name":"limit","type":"number","optional":true}],"returnType":"any","isStatic":false,"isPublic":true},"getUnreadEmails":{"name":"getUnreadEmails","async":true,"parameters":[{"name":"limit","type":"number","optional":true}],"returnType":"any","isStatic":false,"isPublic":true},"refreshCounts":{"name":"refreshCounts","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isInbox":{"name":"isInbox","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSent":{"name":"isSent","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isDrafts":{"name":"isDrafts","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isTrash":{"name":"isTrash","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSpam":{"name":"isSpam","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"isSystemFolder":{"name":"isSystemFolder","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"subscribe":{"name":"subscribe","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"unsubscribe":{"name":"unsubscribe","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"EmailFolder","collectionExportName":"EmailFolderCollection","displayLabelField":"name","validationRules":[{"field":"messageCount","rule":"required","fieldType":"integer"},{"field":"unreadCount","rule":"required","fieldType":"integer"},{"field":"subscribed","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"email_folders","ddl":"CREATE TABLE IF NOT EXISTS \\"email_folders\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"path\\" TEXT,\\n \\"delimiter\\" TEXT,\\n \\"special_use\\" TEXT,\\n \\"message_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"unread_count\\" INTEGER NOT NULL DEFAULT 0,\\n \\"subscribed\\" BOOLEAN NOT NULL DEFAULT TRUE\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"name":{"type":"TEXT","notNull":false,"unique":false},"path":{"type":"TEXT","notNull":false,"unique":false},"delimiter":{"type":"TEXT","notNull":false,"unique":false},"special_use":{"type":"TEXT","notNull":false,"unique":false},"message_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"unread_count":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"subscribed":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"email_folders_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"email_folders_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"email_folders_account_id_idx","columns":["account_id"]}],"version":"cfea127c"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Message":{"name":"message","className":"Message","qualifiedName":"@happyvertical/smrt-messages:Message","collection":"messages","filePath":"src/models/Message.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","nullable","__tenancy","required"],"sqlType":"UUID","nullable":true,"required":false},"required":false},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The connected account used to receive or send this message."},"required":false,"related":"Account","description":"The connected account used to receive or send this message."},"personaId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","description","related","required"],"description":"The assistant identity associated with this message, when one was used.","nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-personas:AgentPersona","description":"The assistant identity associated with this message, when one was used."},"endpointId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The saved destination used to deliver this message."},"required":false,"related":"MessagingEndpoint","description":"The saved destination used to deliver this message."},"correlationId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A tracking reference that connects this message to related activity."},"required":false,"description":"A tracking reference that connects this message to related activity."},"threadId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The conversation this message belongs to."},"required":false,"description":"The conversation this message belongs to."},"subject":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The subject shown in the message list."},"required":false,"description":"The subject shown in the message list."},"body":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The message content in plain text."},"required":false,"description":"The message content in plain text."},"fromAddress":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The address the message was sent from."},"required":false,"description":"The address the message was sent from."},"fromName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The sender name shown beside their address."},"required":false,"description":"The sender name shown beside their address."},"toAddresses":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The people or addresses receiving this message."},"required":false,"description":"The people or addresses receiving this message."},"date":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was sent or received."},"required":false,"description":"When the message was sent or received."},"isRead":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message has been marked as read."},"required":true,"default":false,"description":"Whether this message has been marked as read."},"isFlagged":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message is flagged for follow-up."},"required":true,"default":false,"description":"Whether this message is flagged for follow-up."},"hasAttachments":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether files are attached to this message."},"required":true,"default":false,"description":"Whether files are attached to this message."},"size":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The size of the message in bytes."},"required":true,"default":0,"description":"The size of the message in bytes."},"metadata":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Additional details supplied by the messaging connection."},"required":false,"description":"Additional details supplied by the messaging connection."},"sendStatus":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here."},"required":false,"default":"draft","description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here.","enum":["draft","pending","sending","sent","failed","scheduled"]},"sentAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was successfully sent."},"required":false,"description":"When the message was successfully sent."},"sendError":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The reason the latest send attempt failed."},"required":false,"description":"The reason the latest send attempt failed."},"retryCount":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"How many times delivery has been retried."},"required":true,"default":0,"description":"How many times delivery has been retried."},"maxRetries":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The maximum number of delivery retries allowed."},"required":true,"default":3,"description":"The maximum number of delivery retries allowed."},"scheduledSendAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this message is scheduled to be sent."},"required":false,"description":"When this message is scheduled to be sent."},"inReplyToMessageId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The earlier message this one replies to."},"required":false,"related":"Message","description":"The earlier message this one replies to."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was recorded."},"required":false,"description":"When this message was recorded."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was last changed."},"required":false,"description":"When this message was last changed."}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getToAddresses":{"name":"getToAddresses","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"setToAddresses":{"name":"setToAddresses","async":false,"parameters":[{"name":"addresses","type":"Array<object>","optional":false,"memberTypes":["string"]}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"data","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markRead":{"name":"markRead","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markUnread":{"name":"markUnread","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"toggleFlagged":{"name":"toggleFlagged","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isUnread":{"name":"isUnread","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getPreview":{"name":"getPreview","async":false,"parameters":[{"name":"maxLength","type":"any","optional":true}],"returnType":"string","isStatic":false,"isPublic":true},"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getAccount":{"name":"getAccount","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getEndpoint":{"name":"getEndpoint","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getThreadMessages":{"name":"getThreadMessages","async":true,"parameters":[],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getAttachments":{"name":"getAttachments","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"send":{"name":"send","async":true,"parameters":[{"name":"options","type":"SendMessageOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"isSendOutcomeUnknown":{"name":"isSendOutcomeUnknown","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"abandonSendAttempt":{"name":"abandonSendAttempt","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"retrySend":{"name":"retrySend","async":true,"parameters":[{"name":"options","type":"SendMessageOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"createReply":{"name":"createReply","async":false,"parameters":[{"name":"_options","type":"object","optional":true,"memberTypes":["boolean"]}],"returnType":"Message","isStatic":false,"isPublic":true},"createForward":{"name":"createForward","async":false,"parameters":[],"returnType":"Message","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context","_meta_type"]},"extends":"SmrtObject","exportName":"Message","collectionExportName":"MessageCollection","validationRules":[{"field":"isRead","rule":"required","fieldType":"boolean"},{"field":"isFlagged","rule":"required","fieldType":"boolean"},{"field":"hasAttachments","rule":"required","fieldType":"boolean"},{"field":"size","rule":"required","fieldType":"integer"},{"field":"retryCount","rule":"required","fieldType":"integer"},{"field":"maxRetries","rule":"required","fieldType":"integer"}],"schema":{"tableName":"messages","ddl":"CREATE TABLE IF NOT EXISTS \\"messages\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"persona_id\\" UUID,\\n \\"endpoint_id\\" UUID,\\n \\"correlation_id\\" TEXT,\\n \\"thread_id\\" TEXT,\\n \\"subject\\" TEXT,\\n \\"body\\" TEXT,\\n \\"from_address\\" TEXT,\\n \\"from_name\\" TEXT,\\n \\"to_addresses\\" TEXT,\\n \\"date\\" TIMESTAMP,\\n \\"is_read\\" BOOLEAN DEFAULT FALSE,\\n \\"is_flagged\\" BOOLEAN DEFAULT FALSE,\\n \\"has_attachments\\" BOOLEAN DEFAULT FALSE,\\n \\"size\\" INTEGER DEFAULT 0,\\n \\"metadata\\" TEXT,\\n \\"send_status\\" TEXT DEFAULT 'draft',\\n \\"sent_at\\" TIMESTAMP,\\n \\"send_error\\" TEXT,\\n \\"retry_count\\" INTEGER DEFAULT 0,\\n \\"max_retries\\" INTEGER DEFAULT 3,\\n \\"scheduled_send_at\\" TIMESTAMP,\\n \\"in_reply_to_message_id\\" UUID,\\n \\"message_id\\" TEXT,\\n \\"in_reply_to\\" TEXT,\\n \\"provider_message_id\\" TEXT,\\n \\"cc_addresses\\" TEXT,\\n \\"bcc_addresses\\" TEXT,\\n \\"reply_to_address\\" TEXT,\\n \\"reply_to_name\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"html_body\\" TEXT,\\n \\"folder_id\\" TEXT,\\n \\"folder_path\\" TEXT,\\n \\"labels\\" TEXT,\\n \\"flags\\" TEXT,\\n \\"is_answered\\" BOOLEAN DEFAULT FALSE,\\n \\"is_draft\\" BOOLEAN DEFAULT FALSE,\\n \\"raw_message\\" TEXT,\\n \\"headers\\" TEXT,\\n \\"channel_id\\" TEXT,\\n \\"channel_name\\" TEXT,\\n \\"slack_ts\\" TEXT,\\n \\"slack_thread_ts\\" TEXT,\\n \\"reactions\\" TEXT,\\n \\"is_edited\\" BOOLEAN DEFAULT FALSE,\\n \\"message_type\\" TEXT,\\n \\"blocks\\" TEXT,\\n \\"tweet_id\\" TEXT,\\n \\"retweet_count\\" INTEGER DEFAULT 0,\\n \\"like_count\\" INTEGER DEFAULT 0,\\n \\"reply_count\\" INTEGER DEFAULT 0,\\n \\"is_retweet\\" BOOLEAN DEFAULT FALSE,\\n \\"is_reply\\" BOOLEAN DEFAULT FALSE,\\n \\"media_urls\\" TEXT,\\n \\"hashtags\\" TEXT,\\n \\"mentions\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"correlation_id":{"type":"TEXT","notNull":false},"thread_id":{"type":"TEXT","notNull":false},"subject":{"type":"TEXT","notNull":false},"body":{"type":"TEXT","notNull":false},"from_address":{"type":"TEXT","notNull":false},"from_name":{"type":"TEXT","notNull":false},"to_addresses":{"type":"TEXT","notNull":false},"date":{"type":"TIMESTAMP","notNull":false},"is_read":{"type":"BOOLEAN","notNull":false,"default":false},"is_flagged":{"type":"BOOLEAN","notNull":false,"default":false},"has_attachments":{"type":"BOOLEAN","notNull":false,"default":false},"size":{"type":"INTEGER","notNull":false,"default":0},"metadata":{"type":"TEXT","notNull":false},"send_status":{"type":"TEXT","notNull":false,"default":"draft"},"sent_at":{"type":"TIMESTAMP","notNull":false},"send_error":{"type":"TEXT","notNull":false},"retry_count":{"type":"INTEGER","notNull":false,"default":0},"max_retries":{"type":"INTEGER","notNull":false,"default":3},"scheduled_send_at":{"type":"TIMESTAMP","notNull":false},"in_reply_to_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"TEXT","notNull":false},"in_reply_to":{"type":"TEXT","notNull":false},"provider_message_id":{"type":"TEXT","notNull":false},"cc_addresses":{"type":"TEXT","notNull":false},"bcc_addresses":{"type":"TEXT","notNull":false},"reply_to_address":{"type":"TEXT","notNull":false},"reply_to_name":{"type":"TEXT","notNull":false},"text_body":{"type":"TEXT","notNull":false},"html_body":{"type":"TEXT","notNull":false},"folder_id":{"type":"TEXT","notNull":false},"folder_path":{"type":"TEXT","notNull":false},"labels":{"type":"TEXT","notNull":false},"flags":{"type":"TEXT","notNull":false},"is_answered":{"type":"BOOLEAN","notNull":false,"default":false},"is_draft":{"type":"BOOLEAN","notNull":false,"default":false},"raw_message":{"type":"TEXT","notNull":false},"headers":{"type":"TEXT","notNull":false},"channel_id":{"type":"TEXT","notNull":false},"channel_name":{"type":"TEXT","notNull":false},"slack_ts":{"type":"TEXT","notNull":false},"slack_thread_ts":{"type":"TEXT","notNull":false},"reactions":{"type":"TEXT","notNull":false},"is_edited":{"type":"BOOLEAN","notNull":false,"default":false},"message_type":{"type":"TEXT","notNull":false},"blocks":{"type":"TEXT","notNull":false},"tweet_id":{"type":"TEXT","notNull":false},"retweet_count":{"type":"INTEGER","notNull":false,"default":0},"like_count":{"type":"INTEGER","notNull":false,"default":0},"reply_count":{"type":"INTEGER","notNull":false,"default":0},"is_retweet":{"type":"BOOLEAN","notNull":false,"default":false},"is_reply":{"type":"BOOLEAN","notNull":false,"default":false},"media_urls":{"type":"TEXT","notNull":false},"hashtags":{"type":"TEXT","notNull":false},"mentions":{"type":"TEXT","notNull":false}},"indexes":[{"name":"messages_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"messages_meta_type_idx","columns":["_meta_type"]},{"name":"messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messages_account_id_idx","columns":["account_id"]},{"name":"messages_persona_id_idx","columns":["persona_id"]},{"name":"messages_endpoint_id_idx","columns":["endpoint_id"]},{"name":"messages_in_reply_to_message_id_idx","columns":["in_reply_to_message_id"]}],"checks":[{"name":"smrt_ck_d0024f738cf4","columns":["is_answered"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_answered\\" IS NOT NULL"},{"name":"smrt_ck_0adcd2453c81","columns":["is_draft"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_draft\\" IS NOT NULL"},{"name":"smrt_ck_428e155c9609","columns":["is_edited"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:SlackMessage') OR \\"is_edited\\" IS NOT NULL"},{"name":"smrt_ck_a17af99e85e3","columns":["is_reply"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_reply\\" IS NOT NULL"},{"name":"smrt_ck_3e30563cba58","columns":["is_retweet"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_retweet\\" IS NOT NULL"},{"name":"smrt_ck_bab2c772ebe6","columns":["like_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"like_count\\" IS NOT NULL"},{"name":"smrt_ck_c6ad8d47bbc8","columns":["reply_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"reply_count\\" IS NOT NULL"},{"name":"smrt_ck_43a00e1c098d","columns":["retweet_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"retweet_count\\" IS NOT NULL"}],"version":"d8da74ce"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:MessagingEndpoint":{"name":"messagingendpoint","className":"MessagingEndpoint","qualifiedName":"@happyvertical/smrt-messages:MessagingEndpoint","collection":"messagingendpoints","filePath":"src/models/MessagingEndpoint.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"profileId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-profiles:Profile"},"label":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"channel":{"type":"text","_meta":{"__statedOptions":["required","default"],"required":true},"required":true,"default":"email"},"address":{"type":"text","_meta":{"__statedOptions":["required","sensitive"],"required":true,"sensitive":true},"required":true,"sensitive":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":true,"default":true},"verifiedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"createdAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"updatedAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"getAddress":{"name":"getAddress","async":false,"parameters":[],"returnType":"T","isStatic":false,"isPublic":true},"setAddress":{"name":"setAddress","async":false,"parameters":[{"name":"address","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getMaskedAddress":{"name":"getMaskedAddress","async":false,"parameters":[],"returnType":"string","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"messaging_endpoints","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"conflictColumns":["tenant_id","channel","label"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"MessagingEndpoint","collectionExportName":"MessagingEndpointCollection","displayLabelField":"label","validationRules":[{"field":"label","rule":"required","fieldType":"text"},{"field":"channel","rule":"required","fieldType":"text"},{"field":"address","rule":"required","fieldType":"text"},{"field":"isActive","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"messaging_endpoints","ddl":"CREATE TABLE IF NOT EXISTS \\"messaging_endpoints\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"profile_id\\" UUID,\\n \\"label\\" TEXT NOT NULL,\\n \\"channel\\" TEXT NOT NULL DEFAULT 'email',\\n \\"address\\" TEXT NOT NULL,\\n \\"is_active\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"verified_at\\" TIMESTAMP\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"label":{"type":"TEXT","notNull":true,"unique":false},"channel":{"type":"TEXT","notNull":true,"unique":false,"default":"email"},"address":{"type":"TEXT","notNull":true,"unique":false},"is_active":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"verified_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"messaging_endpoints_tenant_id_channel_idx","columns":["tenant_id","channel","label"],"unique":true},{"name":"messaging_endpoints_slug_context_idx","columns":["slug","context"]},{"name":"messaging_endpoints_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messaging_endpoints_profile_id_idx","columns":["profile_id"]}],"version":"b4466849"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:NotificationDelivery":{"name":"notificationdelivery","className":"NotificationDelivery","qualifiedName":"@happyvertical/smrt-messages:NotificationDelivery","collection":"notificationdeliveries","description":"One durable, source-keyed notification delivery to one person over one external channel (the outbox row behind NotificationOutboxService).","filePath":"src/models/NotificationDelivery.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"recipientUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-users:User"},"recipientProfileId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-profiles:Profile"},"recipientKind":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default","enum"],"required":true,"requiredFor":"identity"},"required":true,"default":"user","enum":["user","profile"]},"channel":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default","enum"],"required":true,"requiredFor":"identity"},"required":true,"default":"email","enum":["email"]},"sourceRef":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"idempotency"},"required":true},"kind":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"requiredDispatchPolicy":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"dispatchPolicyBinding":{"type":"json","_meta":{"__statedOptions":[]},"required":false},"subject":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"textBody":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"href":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"recipientAddress":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"recipientName":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Account"},"messageId":{"type":"foreignKey","_meta":{"__statedOptions":["related"]},"required":false,"related":"Message"},"status":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"pending","enum":["pending","sending","sent","failed","uncertain","cancelled"]},"stateVersion":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"transitionId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"attempts":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"maxAttempts":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":5},"nextAttemptAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"leaseToken":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"leaseExpiresAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"handedOffAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"deliveredAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"providerMessageId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"lastError":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"transition":{"name":"transition","async":true,"parameters":[{"name":"changes","type":"NotificationDeliveryTransition","optional":false,"resolvedType":"Partial<Pick<NotificationDelivery, 'messageId' | 'status' | 'attempts' | 'nextAttemptAt' | 'leaseToken' | 'leaseExpiresAt' | 'handedOffAt' | 'deliveredAt' | 'providerMessageId' | 'lastError'>>"},{"name":"expected","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"notification_deliveries","api":false,"mcp":false,"cli":false,"conflictColumns":["tenant_id","recipient_kind","recipient_user_id","recipient_profile_id","channel","source_ref"],"indexes":[{"name":"notification_deliveries_user_identity","columns":["tenantId","recipientUserId","channel","sourceRef"],"unique":true},{"name":"notification_deliveries_profile_identity","columns":["tenantId","recipientProfileId","channel","sourceRef"],"unique":true},{"name":"notification_deliveries_due_idx","columns":["status","nextAttemptAt"]},{"name":"notification_deliveries_lease_idx","columns":["status","leaseExpiresAt"]}],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"NotificationDelivery","collectionExportName":"NotificationDeliveryCollection","validationRules":[{"field":"recipientKind","rule":"required","fieldType":"text"},{"field":"channel","rule":"required","fieldType":"text"},{"field":"sourceRef","rule":"required","fieldType":"text"},{"field":"kind","rule":"required","fieldType":"text"},{"field":"recipientAddress","rule":"required","fieldType":"text"},{"field":"stateVersion","rule":"required","fieldType":"integer"},{"field":"attempts","rule":"required","fieldType":"integer"},{"field":"maxAttempts","rule":"required","fieldType":"integer"}],"schema":{"tableName":"notification_deliveries","ddl":"CREATE TABLE IF NOT EXISTS \\"notification_deliveries\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"recipient_user_id\\" UUID,\\n \\"recipient_profile_id\\" UUID,\\n \\"recipient_kind\\" TEXT NOT NULL DEFAULT 'user',\\n \\"channel\\" TEXT NOT NULL DEFAULT 'email',\\n \\"source_ref\\" TEXT NOT NULL,\\n \\"kind\\" TEXT NOT NULL,\\n \\"required_dispatch_policy\\" TEXT,\\n \\"dispatch_policy_binding\\" JSON,\\n \\"subject\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"href\\" TEXT,\\n \\"recipient_address\\" TEXT NOT NULL,\\n \\"recipient_name\\" TEXT,\\n \\"account_id\\" UUID,\\n \\"message_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'pending',\\n \\"state_version\\" INTEGER NOT NULL DEFAULT 0,\\n \\"transition_id\\" TEXT,\\n \\"attempts\\" INTEGER NOT NULL DEFAULT 0,\\n \\"max_attempts\\" INTEGER NOT NULL DEFAULT 5,\\n \\"next_attempt_at\\" TEXT,\\n \\"lease_token\\" TEXT,\\n \\"lease_expires_at\\" TIMESTAMP,\\n \\"handed_off_at\\" TIMESTAMP,\\n \\"delivered_at\\" TIMESTAMP,\\n \\"provider_message_id\\" TEXT,\\n \\"last_error\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"recipient_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recipient_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"recipient_kind":{"type":"TEXT","notNull":true,"unique":false,"default":"user"},"channel":{"type":"TEXT","notNull":true,"unique":false,"default":"email"},"source_ref":{"type":"TEXT","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false},"required_dispatch_policy":{"type":"TEXT","notNull":false,"unique":false},"dispatch_policy_binding":{"type":"JSON","notNull":false,"unique":false},"subject":{"type":"TEXT","notNull":false,"unique":false},"text_body":{"type":"TEXT","notNull":false,"unique":false},"href":{"type":"TEXT","notNull":false,"unique":false},"recipient_address":{"type":"TEXT","notNull":true,"unique":false},"recipient_name":{"type":"TEXT","notNull":false,"unique":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"pending"},"state_version":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"transition_id":{"type":"TEXT","notNull":false,"unique":false},"attempts":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"max_attempts":{"type":"INTEGER","notNull":true,"unique":false,"default":5},"next_attempt_at":{"type":"TEXT","notNull":false,"unique":false},"lease_token":{"type":"TEXT","notNull":false,"unique":false},"lease_expires_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"handed_off_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"delivered_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"provider_message_id":{"type":"TEXT","notNull":false,"unique":false},"last_error":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"notification_deliveries_tenant_id_recipient_kind_idx","columns":["tenant_id","recipient_kind","recipient_user_id","recipient_profile_id","channel","source_ref"],"unique":true,"nullsNotDistinct":true},{"name":"notification_deliveries_slug_context_idx","columns":["slug","context"]},{"name":"notification_deliveries_user_identity","columns":["tenant_id","recipient_user_id","channel","source_ref"],"unique":true},{"name":"notification_deliveries_profile_identity","columns":["tenant_id","recipient_profile_id","channel","source_ref"],"unique":true},{"name":"notification_deliveries_due_idx","columns":["status","next_attempt_at"]},{"name":"notification_deliveries_lease_idx","columns":["status","lease_expires_at"]},{"name":"notification_deliveries_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"notification_deliveries_recipient_user_id_idx","columns":["recipient_user_id"]},{"name":"notification_deliveries_recipient_profile_id_idx","columns":["recipient_profile_id"]},{"name":"notification_deliveries_account_id_idx","columns":["account_id"]},{"name":"notification_deliveries_message_id_idx","columns":["message_id"]}],"version":"547f434f"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:NotificationOptOut":{"name":"notificationoptout","className":"NotificationOptOut","qualifiedName":"@happyvertical/smrt-messages:NotificationOptOut","collection":"notificationoptouts","description":"One person's opt-out of one notification channel for one scope, in one tenant: the preference store behind the outbox's isSuppressed hook.","filePath":"src/models/NotificationOptOut.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"recipientUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"@happyvertical/smrt-users:User"},"channel":{"type":"text","_meta":{"__statedOptions":["required","default","enum"],"required":true},"required":true,"default":"email","enum":["email"]},"scope":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"optedOutAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updatedBy":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{},"decoratorConfig":{"tableName":"notification_opt_outs","api":false,"mcp":false,"cli":false,"conflictColumns":["tenant_id","recipient_user_id","channel","scope"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"NotificationOptOut","collectionExportName":"NotificationOptOutCollection","validationRules":[{"field":"recipientUserId","rule":"required","fieldType":"crossPackageRef"},{"field":"channel","rule":"required","fieldType":"text"},{"field":"scope","rule":"required","fieldType":"text"}],"schema":{"tableName":"notification_opt_outs","ddl":"CREATE TABLE IF NOT EXISTS \\"notification_opt_outs\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"recipient_user_id\\" UUID NOT NULL,\\n \\"channel\\" TEXT NOT NULL DEFAULT 'email',\\n \\"scope\\" TEXT NOT NULL,\\n \\"opted_out_at\\" TIMESTAMP,\\n \\"updated_by\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"recipient_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"channel":{"type":"TEXT","notNull":true,"unique":false,"default":"email"},"scope":{"type":"TEXT","notNull":true,"unique":false},"opted_out_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"updated_by":{"type":"TEXT","notNull":false,"unique":false}},"indexes":[{"name":"notification_opt_outs_tenant_id_recipient_user_id_idx","columns":["tenant_id","recipient_user_id","channel","scope"],"unique":true},{"name":"notification_opt_outs_slug_context_idx","columns":["slug","context"]},{"name":"notification_opt_outs_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"notification_opt_outs_recipient_user_id_idx","columns":["recipient_user_id"]}],"version":"a13e93c1"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:PersonaMessageRoute":{"name":"personamessageroute","className":"PersonaMessageRoute","qualifiedName":"@happyvertical/smrt-messages:PersonaMessageRoute","collection":"personamessageroutes","filePath":"src/models/PersonaMessageRoute.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"personaId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"@happyvertical/smrt-personas:AgentPersona"},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"Account"},"endpointId":{"type":"foreignKey","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"MessagingEndpoint"},"purpose":{"type":"text","_meta":{"__statedOptions":["required"],"required":true},"required":true},"priority":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"enabled":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":true,"default":true},"createdAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"updatedAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{},"decoratorConfig":{"tableName":"persona_message_routes","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"conflictColumns":["tenant_id","persona_id","account_id","endpoint_id","purpose"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"PersonaMessageRoute","collectionExportName":"PersonaMessageRouteCollection","validationRules":[{"field":"personaId","rule":"required","fieldType":"crossPackageRef"},{"field":"accountId","rule":"required","fieldType":"foreignKey"},{"field":"endpointId","rule":"required","fieldType":"foreignKey"},{"field":"purpose","rule":"required","fieldType":"text"},{"field":"priority","rule":"required","fieldType":"integer"},{"field":"enabled","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"persona_message_routes","ddl":"CREATE TABLE IF NOT EXISTS \\"persona_message_routes\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"persona_id\\" UUID NOT NULL,\\n \\"account_id\\" UUID NOT NULL,\\n \\"endpoint_id\\" UUID NOT NULL,\\n \\"purpose\\" TEXT NOT NULL,\\n \\"priority\\" INTEGER NOT NULL DEFAULT 0,\\n \\"enabled\\" BOOLEAN NOT NULL DEFAULT TRUE\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"purpose":{"type":"TEXT","notNull":true,"unique":false},"priority":{"type":"INTEGER","notNull":true,"unique":false,"default":0},"enabled":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true}},"indexes":[{"name":"persona_message_routes_tenant_id_persona_id_idx","columns":["tenant_id","persona_id","account_id","endpoint_id","purpose"],"unique":true},{"name":"persona_message_routes_slug_context_idx","columns":["slug","context"]},{"name":"persona_message_routes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"persona_message_routes_persona_id_idx","columns":["persona_id"]},{"name":"persona_message_routes_account_id_idx","columns":["account_id"]},{"name":"persona_message_routes_endpoint_id_idx","columns":["endpoint_id"]}],"version":"3caf446e"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:SlackAccount":{"name":"slackaccount","className":"SlackAccount","qualifiedName":"@happyvertical/smrt-messages:SlackAccount","collection":"accounts","filePath":"src/models/SlackAccount.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The display name for this connected messaging account."},"required":false,"description":"The display name for this connected messaging account."},"providerType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The service that connects this account to your application."},"required":false,"description":"The service that connects this account to your application."},"channelType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of messaging this account supports, such as email or chat."},"required":false,"description":"The kind of messaging this account supports, such as email or chat."},"credentialSecretId":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this account is enabled for messaging."},"required":true,"default":true,"description":"Whether this account is enabled for messaging."},"ownerUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The person who owns this account and decides who else may use it."},"required":false,"related":"@happyvertical/smrt-users:User","description":"The person who owns this account and decides who else may use it."},"label":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A short name shown beside this account, such as Support or Personal."},"required":false,"description":"A short name shown beside this account, such as Support or Personal."},"connectionStatus":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"required":false,"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"statusMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Why the account needs attention, in plain words."},"required":false,"description":"Why the account needs attention, in plain words."},"lastSyncAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this account last checked for new messages."},"required":false,"description":"When this account last checked for new messages."},"settings":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"configuration":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The public connection settings for this account; credentials are stored separately."},"required":false,"description":"The public connection settings for this account; credentials are stored separately."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was added."},"required":false,"description":"When this account was added."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was last changed."},"required":false,"description":"When this account was last changed."},"workspaceId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The identifier of the connected workspace."},"required":false,"description":"The identifier of the connected workspace."},"workspaceName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The name of the connected workspace."},"required":false,"description":"The name of the connected workspace."},"botUserId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The bot user your application posts as in this workspace."},"required":false,"description":"The bot user your application posts as in this workspace."}},"methods":{"getSettings":{"name":"getSettings","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setSettings":{"name":"setSettings","async":false,"parameters":[{"name":"settings","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getConfiguration":{"name":"getConfiguration","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setConfiguration":{"name":"setConfiguration","async":false,"parameters":[{"name":"configuration","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markNeedsReconnect":{"name":"markNeedsReconnect","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markConnected":{"name":"markConnected","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"activate":{"name":"activate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deactivate":{"name":"deactivate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"setCredentials":{"name":"setCredentials","async":true,"parameters":[{"name":"credentials","type":"Record<string, unknown>","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"removeCredentials":{"name":"removeCredentials","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"createSender":{"name":"createSender","async":true,"parameters":[],"returnType":"Promise<MessageSenderInterface>","isStatic":false,"isPublic":true},"getCredentials":{"name":"getCredentials","async":true,"parameters":[],"returnType":"Promise<Record<string, unknown> | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tableName":"accounts"},"extends":"Account","exportName":"SlackAccount","collectionExportName":"SlackAccountCollection","displayLabelField":"name","validationRules":[{"field":"isActive","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:SlackMessage":{"name":"slackmessage","className":"SlackMessage","qualifiedName":"@happyvertical/smrt-messages:SlackMessage","collection":"messages","filePath":"src/models/SlackMessage.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The connected account used to receive or send this message."},"required":false,"related":"Account","description":"The connected account used to receive or send this message."},"personaId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","description","related","required"],"required":false,"description":"The assistant identity associated with this message, when one was used.","nullable":true},"required":false,"related":"@happyvertical/smrt-personas:AgentPersona","description":"The assistant identity associated with this message, when one was used."},"endpointId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The saved destination used to deliver this message."},"required":false,"related":"MessagingEndpoint","description":"The saved destination used to deliver this message."},"correlationId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A tracking reference that connects this message to related activity."},"required":false,"description":"A tracking reference that connects this message to related activity."},"threadId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The conversation this message belongs to."},"required":false,"description":"The conversation this message belongs to."},"subject":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The subject shown in the message list."},"required":false,"description":"The subject shown in the message list."},"body":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The message content in plain text."},"required":false,"description":"The message content in plain text."},"fromAddress":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The address the message was sent from."},"required":false,"description":"The address the message was sent from."},"fromName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The sender name shown beside their address."},"required":false,"description":"The sender name shown beside their address."},"toAddresses":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The people or addresses receiving this message."},"required":false,"description":"The people or addresses receiving this message."},"date":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was sent or received."},"required":false,"description":"When the message was sent or received."},"isRead":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message has been marked as read."},"required":true,"default":false,"description":"Whether this message has been marked as read."},"isFlagged":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message is flagged for follow-up."},"required":true,"default":false,"description":"Whether this message is flagged for follow-up."},"hasAttachments":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether files are attached to this message."},"required":true,"default":false,"description":"Whether files are attached to this message."},"size":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The size of the message in bytes."},"required":true,"default":0,"description":"The size of the message in bytes."},"metadata":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Additional details supplied by the messaging connection."},"required":false,"description":"Additional details supplied by the messaging connection."},"sendStatus":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here."},"required":false,"default":"draft","description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here.","enum":["draft","pending","sending","sent","failed","scheduled"]},"sentAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was successfully sent."},"required":false,"description":"When the message was successfully sent."},"sendError":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The reason the latest send attempt failed."},"required":false,"description":"The reason the latest send attempt failed."},"retryCount":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"How many times delivery has been retried."},"required":true,"default":0,"description":"How many times delivery has been retried."},"maxRetries":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The maximum number of delivery retries allowed."},"required":true,"default":3,"description":"The maximum number of delivery retries allowed."},"scheduledSendAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this message is scheduled to be sent."},"required":false,"description":"When this message is scheduled to be sent."},"inReplyToMessageId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The earlier message this one replies to."},"required":false,"related":"Message","description":"The earlier message this one replies to."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was recorded."},"required":false,"description":"When this message was recorded."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was last changed."},"required":false,"description":"When this message was last changed."},"channelId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The identifier of the channel this message is in."},"required":false,"description":"The identifier of the channel this message is in."},"channelName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The name of the channel this message was posted in."},"required":false,"description":"The name of the channel this message was posted in."},"slackTs":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The workspace's own reference for this message."},"required":false,"description":"The workspace's own reference for this message."},"slackThreadTs":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The workspace's own reference for the thread this message belongs to."},"required":false,"description":"The workspace's own reference for the thread this message belongs to."},"reactions":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The reactions people added to this message."},"required":false,"description":"The reactions people added to this message."},"isEdited":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message was edited after posting."},"required":true,"default":false,"description":"Whether this message was edited after posting."},"messageType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of message, such as one from a person or a bot."},"required":false,"description":"The kind of message, such as one from a person or a bot."},"blocks":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The rich layout of the message as the workspace stores it."},"required":false,"description":"The rich layout of the message as the workspace stores it."}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getToAddresses":{"name":"getToAddresses","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"setToAddresses":{"name":"setToAddresses","async":false,"parameters":[{"name":"addresses","type":"Array<object>","optional":false,"memberTypes":["string"]}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"data","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markRead":{"name":"markRead","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markUnread":{"name":"markUnread","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"toggleFlagged":{"name":"toggleFlagged","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isUnread":{"name":"isUnread","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getPreview":{"name":"getPreview","async":false,"parameters":[{"name":"maxLength","type":"any","optional":true}],"returnType":"string","isStatic":false,"isPublic":true},"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getAccount":{"name":"getAccount","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getEndpoint":{"name":"getEndpoint","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getThreadMessages":{"name":"getThreadMessages","async":true,"parameters":[],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getAttachments":{"name":"getAttachments","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"send":{"name":"send","async":true,"parameters":[{"name":"options","type":"SendMessageOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"isSendOutcomeUnknown":{"name":"isSendOutcomeUnknown","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"abandonSendAttempt":{"name":"abandonSendAttempt","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"retrySend":{"name":"retrySend","async":true,"parameters":[{"name":"options","type":"SendMessageOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"createReply":{"name":"createReply","async":false,"parameters":[{"name":"_options","type":"object","optional":true,"memberTypes":["boolean"]}],"returnType":"Message","isStatic":false,"isPublic":true},"createForward":{"name":"createForward","async":false,"parameters":[],"returnType":"Message","isStatic":false,"isPublic":true},"getReactions":{"name":"getReactions","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"getBlocks":{"name":"getBlocks","async":false,"parameters":[],"returnType":"Record<string, unknown>[]","isStatic":false,"isPublic":true},"isInThread":{"name":"isInThread","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getTotalReactions":{"name":"getTotalReactions","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get","create"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"widenParentExposure":{"api":["create"]},"tableName":"messages"},"extends":"Message","exportName":"SlackMessage","collectionExportName":"SlackMessageCollection","validationRules":[{"field":"isRead","rule":"required","fieldType":"boolean"},{"field":"isFlagged","rule":"required","fieldType":"boolean"},{"field":"hasAttachments","rule":"required","fieldType":"boolean"},{"field":"size","rule":"required","fieldType":"integer"},{"field":"retryCount","rule":"required","fieldType":"integer"},{"field":"maxRetries","rule":"required","fieldType":"integer"},{"field":"isEdited","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"messages","ddl":"CREATE TABLE IF NOT EXISTS \\"messages\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"persona_id\\" UUID,\\n \\"endpoint_id\\" UUID,\\n \\"correlation_id\\" TEXT,\\n \\"thread_id\\" TEXT,\\n \\"subject\\" TEXT,\\n \\"body\\" TEXT,\\n \\"from_address\\" TEXT,\\n \\"from_name\\" TEXT,\\n \\"to_addresses\\" TEXT,\\n \\"date\\" TIMESTAMP,\\n \\"is_read\\" BOOLEAN DEFAULT FALSE,\\n \\"is_flagged\\" BOOLEAN DEFAULT FALSE,\\n \\"has_attachments\\" BOOLEAN DEFAULT FALSE,\\n \\"size\\" INTEGER DEFAULT 0,\\n \\"metadata\\" TEXT,\\n \\"send_status\\" TEXT DEFAULT 'draft',\\n \\"sent_at\\" TIMESTAMP,\\n \\"send_error\\" TEXT,\\n \\"retry_count\\" INTEGER DEFAULT 0,\\n \\"max_retries\\" INTEGER DEFAULT 3,\\n \\"scheduled_send_at\\" TIMESTAMP,\\n \\"in_reply_to_message_id\\" UUID,\\n \\"message_id\\" TEXT,\\n \\"in_reply_to\\" TEXT,\\n \\"provider_message_id\\" TEXT,\\n \\"cc_addresses\\" TEXT,\\n \\"bcc_addresses\\" TEXT,\\n \\"reply_to_address\\" TEXT,\\n \\"reply_to_name\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"html_body\\" TEXT,\\n \\"folder_id\\" TEXT,\\n \\"folder_path\\" TEXT,\\n \\"labels\\" TEXT,\\n \\"flags\\" TEXT,\\n \\"is_answered\\" BOOLEAN DEFAULT FALSE,\\n \\"is_draft\\" BOOLEAN DEFAULT FALSE,\\n \\"raw_message\\" TEXT,\\n \\"headers\\" TEXT,\\n \\"channel_id\\" TEXT,\\n \\"channel_name\\" TEXT,\\n \\"slack_ts\\" TEXT,\\n \\"slack_thread_ts\\" TEXT,\\n \\"reactions\\" TEXT,\\n \\"is_edited\\" BOOLEAN DEFAULT FALSE,\\n \\"message_type\\" TEXT,\\n \\"blocks\\" TEXT,\\n \\"tweet_id\\" TEXT,\\n \\"retweet_count\\" INTEGER DEFAULT 0,\\n \\"like_count\\" INTEGER DEFAULT 0,\\n \\"reply_count\\" INTEGER DEFAULT 0,\\n \\"is_retweet\\" BOOLEAN DEFAULT FALSE,\\n \\"is_reply\\" BOOLEAN DEFAULT FALSE,\\n \\"media_urls\\" TEXT,\\n \\"hashtags\\" TEXT,\\n \\"mentions\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"correlation_id":{"type":"TEXT","notNull":false},"thread_id":{"type":"TEXT","notNull":false},"subject":{"type":"TEXT","notNull":false},"body":{"type":"TEXT","notNull":false},"from_address":{"type":"TEXT","notNull":false},"from_name":{"type":"TEXT","notNull":false},"to_addresses":{"type":"TEXT","notNull":false},"date":{"type":"TIMESTAMP","notNull":false},"is_read":{"type":"BOOLEAN","notNull":false,"default":false},"is_flagged":{"type":"BOOLEAN","notNull":false,"default":false},"has_attachments":{"type":"BOOLEAN","notNull":false,"default":false},"size":{"type":"INTEGER","notNull":false,"default":0},"metadata":{"type":"TEXT","notNull":false},"send_status":{"type":"TEXT","notNull":false,"default":"draft"},"sent_at":{"type":"TIMESTAMP","notNull":false},"send_error":{"type":"TEXT","notNull":false},"retry_count":{"type":"INTEGER","notNull":false,"default":0},"max_retries":{"type":"INTEGER","notNull":false,"default":3},"scheduled_send_at":{"type":"TIMESTAMP","notNull":false},"in_reply_to_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"TEXT","notNull":false},"in_reply_to":{"type":"TEXT","notNull":false},"provider_message_id":{"type":"TEXT","notNull":false},"cc_addresses":{"type":"TEXT","notNull":false},"bcc_addresses":{"type":"TEXT","notNull":false},"reply_to_address":{"type":"TEXT","notNull":false},"reply_to_name":{"type":"TEXT","notNull":false},"text_body":{"type":"TEXT","notNull":false},"html_body":{"type":"TEXT","notNull":false},"folder_id":{"type":"TEXT","notNull":false},"folder_path":{"type":"TEXT","notNull":false},"labels":{"type":"TEXT","notNull":false},"flags":{"type":"TEXT","notNull":false},"is_answered":{"type":"BOOLEAN","notNull":false,"default":false},"is_draft":{"type":"BOOLEAN","notNull":false,"default":false},"raw_message":{"type":"TEXT","notNull":false},"headers":{"type":"TEXT","notNull":false},"channel_id":{"type":"TEXT","notNull":false},"channel_name":{"type":"TEXT","notNull":false},"slack_ts":{"type":"TEXT","notNull":false},"slack_thread_ts":{"type":"TEXT","notNull":false},"reactions":{"type":"TEXT","notNull":false},"is_edited":{"type":"BOOLEAN","notNull":false,"default":false},"message_type":{"type":"TEXT","notNull":false},"blocks":{"type":"TEXT","notNull":false},"tweet_id":{"type":"TEXT","notNull":false},"retweet_count":{"type":"INTEGER","notNull":false,"default":0},"like_count":{"type":"INTEGER","notNull":false,"default":0},"reply_count":{"type":"INTEGER","notNull":false,"default":0},"is_retweet":{"type":"BOOLEAN","notNull":false,"default":false},"is_reply":{"type":"BOOLEAN","notNull":false,"default":false},"media_urls":{"type":"TEXT","notNull":false},"hashtags":{"type":"TEXT","notNull":false},"mentions":{"type":"TEXT","notNull":false}},"indexes":[{"name":"messages_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"messages_meta_type_idx","columns":["_meta_type"]},{"name":"messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messages_account_id_idx","columns":["account_id"]},{"name":"messages_persona_id_idx","columns":["persona_id"]},{"name":"messages_endpoint_id_idx","columns":["endpoint_id"]},{"name":"messages_in_reply_to_message_id_idx","columns":["in_reply_to_message_id"]}],"checks":[{"name":"smrt_ck_d0024f738cf4","columns":["is_answered"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_answered\\" IS NOT NULL"},{"name":"smrt_ck_0adcd2453c81","columns":["is_draft"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_draft\\" IS NOT NULL"},{"name":"smrt_ck_428e155c9609","columns":["is_edited"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:SlackMessage') OR \\"is_edited\\" IS NOT NULL"},{"name":"smrt_ck_a17af99e85e3","columns":["is_reply"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_reply\\" IS NOT NULL"},{"name":"smrt_ck_3e30563cba58","columns":["is_retweet"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_retweet\\" IS NOT NULL"},{"name":"smrt_ck_bab2c772ebe6","columns":["like_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"like_count\\" IS NOT NULL"},{"name":"smrt_ck_c6ad8d47bbc8","columns":["reply_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"reply_count\\" IS NOT NULL"},{"name":"smrt_ck_43a00e1c098d","columns":["retweet_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"retweet_count\\" IS NOT NULL"}],"version":"63b1a1ae"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:TelegramAccount":{"name":"telegramaccount","className":"TelegramAccount","qualifiedName":"@happyvertical/smrt-messages:TelegramAccount","collection":"accounts","filePath":"src/models/TelegramAccount.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The display name for this connected messaging account."},"required":false,"description":"The display name for this connected messaging account."},"providerType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The service that connects this account to your application."},"required":false,"description":"The service that connects this account to your application."},"channelType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of messaging this account supports, such as email or chat."},"required":false,"description":"The kind of messaging this account supports, such as email or chat."},"credentialSecretId":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this account is enabled for messaging."},"required":true,"default":true,"description":"Whether this account is enabled for messaging."},"ownerUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The person who owns this account and decides who else may use it."},"required":false,"related":"@happyvertical/smrt-users:User","description":"The person who owns this account and decides who else may use it."},"label":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A short name shown beside this account, such as Support or Personal."},"required":false,"description":"A short name shown beside this account, such as Support or Personal."},"connectionStatus":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"required":false,"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"statusMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Why the account needs attention, in plain words."},"required":false,"description":"Why the account needs attention, in plain words."},"lastSyncAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this account last checked for new messages."},"required":false,"description":"When this account last checked for new messages."},"settings":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"configuration":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The public connection settings for this account; credentials are stored separately."},"required":false,"description":"The public connection settings for this account; credentials are stored separately."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was added."},"required":false,"description":"When this account was added."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was last changed."},"required":false,"description":"When this account was last changed."}},"methods":{"getSettings":{"name":"getSettings","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setSettings":{"name":"setSettings","async":false,"parameters":[{"name":"settings","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getConfiguration":{"name":"getConfiguration","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setConfiguration":{"name":"setConfiguration","async":false,"parameters":[{"name":"configuration","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markNeedsReconnect":{"name":"markNeedsReconnect","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markConnected":{"name":"markConnected","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"activate":{"name":"activate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deactivate":{"name":"deactivate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"setCredentials":{"name":"setCredentials","async":true,"parameters":[{"name":"credentials","type":"Record<string, unknown>","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"removeCredentials":{"name":"removeCredentials","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"createSender":{"name":"createSender","async":true,"parameters":[],"returnType":"Promise<MessageSenderInterface>","isStatic":false,"isPublic":true},"getCredentials":{"name":"getCredentials","async":true,"parameters":[],"returnType":"Promise<Record<string, unknown> | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tableName":"accounts"},"extends":"Account","exportName":"TelegramAccount","collectionExportName":"TelegramAccountCollection","displayLabelField":"name","validationRules":[{"field":"isActive","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Tweet":{"name":"tweet","className":"Tweet","qualifiedName":"@happyvertical/smrt-messages:Tweet","collection":"messages","filePath":"src/models/Tweet.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"accountId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The connected account used to receive or send this message."},"required":false,"related":"Account","description":"The connected account used to receive or send this message."},"personaId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","description","related","required"],"required":false,"description":"The assistant identity associated with this message, when one was used.","nullable":true},"required":false,"related":"@happyvertical/smrt-personas:AgentPersona","description":"The assistant identity associated with this message, when one was used."},"endpointId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The saved destination used to deliver this message."},"required":false,"related":"MessagingEndpoint","description":"The saved destination used to deliver this message."},"correlationId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A tracking reference that connects this message to related activity."},"required":false,"description":"A tracking reference that connects this message to related activity."},"threadId":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The conversation this message belongs to."},"required":false,"description":"The conversation this message belongs to."},"subject":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The subject shown in the message list."},"required":false,"description":"The subject shown in the message list."},"body":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The message content in plain text."},"required":false,"description":"The message content in plain text."},"fromAddress":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The address the message was sent from."},"required":false,"description":"The address the message was sent from."},"fromName":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The sender name shown beside their address."},"required":false,"description":"The sender name shown beside their address."},"toAddresses":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The people or addresses receiving this message."},"required":false,"description":"The people or addresses receiving this message."},"date":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was sent or received."},"required":false,"description":"When the message was sent or received."},"isRead":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message has been marked as read."},"required":true,"default":false,"description":"Whether this message has been marked as read."},"isFlagged":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this message is flagged for follow-up."},"required":true,"default":false,"description":"Whether this message is flagged for follow-up."},"hasAttachments":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether files are attached to this message."},"required":true,"default":false,"description":"Whether files are attached to this message."},"size":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The size of the message in bytes."},"required":true,"default":0,"description":"The size of the message in bytes."},"metadata":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Additional details supplied by the messaging connection."},"required":false,"description":"Additional details supplied by the messaging connection."},"sendStatus":{"type":"text","_meta":{"__statedOptions":["description","default","enum"],"description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here."},"required":false,"default":"draft","description":"The latest sending state: draft, sending, sent, or failed. Received mail may also show draft here.","enum":["draft","pending","sending","sent","failed","scheduled"]},"sentAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When the message was successfully sent."},"required":false,"description":"When the message was successfully sent."},"sendError":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The reason the latest send attempt failed."},"required":false,"description":"The reason the latest send attempt failed."},"retryCount":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"How many times delivery has been retried."},"required":true,"default":0,"description":"How many times delivery has been retried."},"maxRetries":{"type":"integer","_meta":{"__statedOptions":["description","default"],"description":"The maximum number of delivery retries allowed."},"required":true,"default":3,"description":"The maximum number of delivery retries allowed."},"scheduledSendAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this message is scheduled to be sent."},"required":false,"description":"When this message is scheduled to be sent."},"inReplyToMessageId":{"type":"foreignKey","_meta":{"__statedOptions":["description","related"],"description":"The earlier message this one replies to."},"required":false,"related":"Message","description":"The earlier message this one replies to."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was recorded."},"required":false,"description":"When this message was recorded."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this message was last changed."},"required":false,"description":"When this message was last changed."},"tweetId":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"retweetCount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"likeCount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"replyCount":{"type":"integer","_meta":{"__statedOptions":["default"]},"required":true,"default":0},"isRetweet":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":true,"default":false},"isReply":{"type":"boolean","_meta":{"__statedOptions":["default"]},"required":true,"default":false},"mediaUrls":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"hashtags":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"mentions":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["Date | string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getToAddresses":{"name":"getToAddresses","async":false,"parameters":[],"returnType":"Array<object>","isStatic":false,"isPublic":true},"setToAddresses":{"name":"setToAddresses","async":false,"parameters":[{"name":"addresses","type":"Array<object>","optional":false,"memberTypes":["string"]}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"data","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markRead":{"name":"markRead","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markUnread":{"name":"markUnread","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"toggleFlagged":{"name":"toggleFlagged","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"isUnread":{"name":"isUnread","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getPreview":{"name":"getPreview","async":false,"parameters":[{"name":"maxLength","type":"any","optional":true}],"returnType":"string","isStatic":false,"isPublic":true},"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getAccount":{"name":"getAccount","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getEndpoint":{"name":"getEndpoint","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"getThreadMessages":{"name":"getThreadMessages","async":true,"parameters":[],"returnType":"Promise<Message[]>","isStatic":false,"isPublic":true},"getAttachments":{"name":"getAttachments","async":true,"parameters":[],"returnType":"any","isStatic":false,"isPublic":true},"send":{"name":"send","async":true,"parameters":[{"name":"options","type":"SendMessageOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"isSendOutcomeUnknown":{"name":"isSendOutcomeUnknown","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"abandonSendAttempt":{"name":"abandonSendAttempt","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"retrySend":{"name":"retrySend","async":true,"parameters":[{"name":"options","type":"SendMessageOptions","optional":true}],"returnType":"Promise<MessageSendResult>","isStatic":false,"isPublic":true},"createReply":{"name":"createReply","async":false,"parameters":[{"name":"_options","type":"object","optional":true,"memberTypes":["boolean"]}],"returnType":"Message","isStatic":false,"isPublic":true},"createForward":{"name":"createForward","async":false,"parameters":[],"returnType":"Message","isStatic":false,"isPublic":true},"getMediaUrls":{"name":"getMediaUrls","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getHashtags":{"name":"getHashtags","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getMentions":{"name":"getMentions","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getEngagement":{"name":"getEngagement","async":false,"parameters":[],"returnType":"number","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get","create"]},"mcp":{"include":["list","get"]},"cli":{"skipApiCheck":true},"widenParentExposure":{"api":["create"]},"tableName":"messages"},"extends":"Message","exportName":"Tweet","collectionExportName":"TweetCollection","validationRules":[{"field":"isRead","rule":"required","fieldType":"boolean"},{"field":"isFlagged","rule":"required","fieldType":"boolean"},{"field":"hasAttachments","rule":"required","fieldType":"boolean"},{"field":"size","rule":"required","fieldType":"integer"},{"field":"retryCount","rule":"required","fieldType":"integer"},{"field":"maxRetries","rule":"required","fieldType":"integer"},{"field":"retweetCount","rule":"required","fieldType":"integer"},{"field":"likeCount","rule":"required","fieldType":"integer"},{"field":"replyCount","rule":"required","fieldType":"integer"},{"field":"isRetweet","rule":"required","fieldType":"boolean"},{"field":"isReply","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"messages","ddl":"CREATE TABLE IF NOT EXISTS \\"messages\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"account_id\\" UUID,\\n \\"persona_id\\" UUID,\\n \\"endpoint_id\\" UUID,\\n \\"correlation_id\\" TEXT,\\n \\"thread_id\\" TEXT,\\n \\"subject\\" TEXT,\\n \\"body\\" TEXT,\\n \\"from_address\\" TEXT,\\n \\"from_name\\" TEXT,\\n \\"to_addresses\\" TEXT,\\n \\"date\\" TIMESTAMP,\\n \\"is_read\\" BOOLEAN DEFAULT FALSE,\\n \\"is_flagged\\" BOOLEAN DEFAULT FALSE,\\n \\"has_attachments\\" BOOLEAN DEFAULT FALSE,\\n \\"size\\" INTEGER DEFAULT 0,\\n \\"metadata\\" TEXT,\\n \\"send_status\\" TEXT DEFAULT 'draft',\\n \\"sent_at\\" TIMESTAMP,\\n \\"send_error\\" TEXT,\\n \\"retry_count\\" INTEGER DEFAULT 0,\\n \\"max_retries\\" INTEGER DEFAULT 3,\\n \\"scheduled_send_at\\" TIMESTAMP,\\n \\"in_reply_to_message_id\\" UUID,\\n \\"message_id\\" TEXT,\\n \\"in_reply_to\\" TEXT,\\n \\"provider_message_id\\" TEXT,\\n \\"cc_addresses\\" TEXT,\\n \\"bcc_addresses\\" TEXT,\\n \\"reply_to_address\\" TEXT,\\n \\"reply_to_name\\" TEXT,\\n \\"text_body\\" TEXT,\\n \\"html_body\\" TEXT,\\n \\"folder_id\\" TEXT,\\n \\"folder_path\\" TEXT,\\n \\"labels\\" TEXT,\\n \\"flags\\" TEXT,\\n \\"is_answered\\" BOOLEAN DEFAULT FALSE,\\n \\"is_draft\\" BOOLEAN DEFAULT FALSE,\\n \\"raw_message\\" TEXT,\\n \\"headers\\" TEXT,\\n \\"channel_id\\" TEXT,\\n \\"channel_name\\" TEXT,\\n \\"slack_ts\\" TEXT,\\n \\"slack_thread_ts\\" TEXT,\\n \\"reactions\\" TEXT,\\n \\"is_edited\\" BOOLEAN DEFAULT FALSE,\\n \\"message_type\\" TEXT,\\n \\"blocks\\" TEXT,\\n \\"tweet_id\\" TEXT,\\n \\"retweet_count\\" INTEGER DEFAULT 0,\\n \\"like_count\\" INTEGER DEFAULT 0,\\n \\"reply_count\\" INTEGER DEFAULT 0,\\n \\"is_retweet\\" BOOLEAN DEFAULT FALSE,\\n \\"is_reply\\" BOOLEAN DEFAULT FALSE,\\n \\"media_urls\\" TEXT,\\n \\"hashtags\\" TEXT,\\n \\"mentions\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"account_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"accounts","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"persona_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"endpoint_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messaging_endpoints","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"correlation_id":{"type":"TEXT","notNull":false},"thread_id":{"type":"TEXT","notNull":false},"subject":{"type":"TEXT","notNull":false},"body":{"type":"TEXT","notNull":false},"from_address":{"type":"TEXT","notNull":false},"from_name":{"type":"TEXT","notNull":false},"to_addresses":{"type":"TEXT","notNull":false},"date":{"type":"TIMESTAMP","notNull":false},"is_read":{"type":"BOOLEAN","notNull":false,"default":false},"is_flagged":{"type":"BOOLEAN","notNull":false,"default":false},"has_attachments":{"type":"BOOLEAN","notNull":false,"default":false},"size":{"type":"INTEGER","notNull":false,"default":0},"metadata":{"type":"TEXT","notNull":false},"send_status":{"type":"TEXT","notNull":false,"default":"draft"},"sent_at":{"type":"TIMESTAMP","notNull":false},"send_error":{"type":"TEXT","notNull":false},"retry_count":{"type":"INTEGER","notNull":false,"default":0},"max_retries":{"type":"INTEGER","notNull":false,"default":3},"scheduled_send_at":{"type":"TIMESTAMP","notNull":false},"in_reply_to_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"foreignKey":{"table":"messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"message_id":{"type":"TEXT","notNull":false},"in_reply_to":{"type":"TEXT","notNull":false},"provider_message_id":{"type":"TEXT","notNull":false},"cc_addresses":{"type":"TEXT","notNull":false},"bcc_addresses":{"type":"TEXT","notNull":false},"reply_to_address":{"type":"TEXT","notNull":false},"reply_to_name":{"type":"TEXT","notNull":false},"text_body":{"type":"TEXT","notNull":false},"html_body":{"type":"TEXT","notNull":false},"folder_id":{"type":"TEXT","notNull":false},"folder_path":{"type":"TEXT","notNull":false},"labels":{"type":"TEXT","notNull":false},"flags":{"type":"TEXT","notNull":false},"is_answered":{"type":"BOOLEAN","notNull":false,"default":false},"is_draft":{"type":"BOOLEAN","notNull":false,"default":false},"raw_message":{"type":"TEXT","notNull":false},"headers":{"type":"TEXT","notNull":false},"channel_id":{"type":"TEXT","notNull":false},"channel_name":{"type":"TEXT","notNull":false},"slack_ts":{"type":"TEXT","notNull":false},"slack_thread_ts":{"type":"TEXT","notNull":false},"reactions":{"type":"TEXT","notNull":false},"is_edited":{"type":"BOOLEAN","notNull":false,"default":false},"message_type":{"type":"TEXT","notNull":false},"blocks":{"type":"TEXT","notNull":false},"tweet_id":{"type":"TEXT","notNull":false},"retweet_count":{"type":"INTEGER","notNull":false,"default":0},"like_count":{"type":"INTEGER","notNull":false,"default":0},"reply_count":{"type":"INTEGER","notNull":false,"default":0},"is_retweet":{"type":"BOOLEAN","notNull":false,"default":false},"is_reply":{"type":"BOOLEAN","notNull":false,"default":false},"media_urls":{"type":"TEXT","notNull":false},"hashtags":{"type":"TEXT","notNull":false},"mentions":{"type":"TEXT","notNull":false}},"indexes":[{"name":"messages_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"messages_meta_type_idx","columns":["_meta_type"]},{"name":"messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"messages_account_id_idx","columns":["account_id"]},{"name":"messages_persona_id_idx","columns":["persona_id"]},{"name":"messages_endpoint_id_idx","columns":["endpoint_id"]},{"name":"messages_in_reply_to_message_id_idx","columns":["in_reply_to_message_id"]}],"checks":[{"name":"smrt_ck_d0024f738cf4","columns":["is_answered"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_answered\\" IS NOT NULL"},{"name":"smrt_ck_0adcd2453c81","columns":["is_draft"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Email') OR \\"is_draft\\" IS NOT NULL"},{"name":"smrt_ck_428e155c9609","columns":["is_edited"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:SlackMessage') OR \\"is_edited\\" IS NOT NULL"},{"name":"smrt_ck_a17af99e85e3","columns":["is_reply"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_reply\\" IS NOT NULL"},{"name":"smrt_ck_3e30563cba58","columns":["is_retweet"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"is_retweet\\" IS NOT NULL"},{"name":"smrt_ck_bab2c772ebe6","columns":["like_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"like_count\\" IS NOT NULL"},{"name":"smrt_ck_c6ad8d47bbc8","columns":["reply_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"reply_count\\" IS NOT NULL"},{"name":"smrt_ck_43a00e1c098d","columns":["retweet_count"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:Tweet') OR \\"retweet_count\\" IS NOT NULL"}],"version":"28598df2"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:TwitterAccount":{"name":"twitteraccount","className":"TwitterAccount","qualifiedName":"@happyvertical/smrt-messages:TwitterAccount","collection":"accounts","filePath":"src/models/TwitterAccount.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The display name for this connected messaging account."},"required":false,"description":"The display name for this connected messaging account."},"providerType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The service that connects this account to your application."},"required":false,"description":"The service that connects this account to your application."},"channelType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of messaging this account supports, such as email or chat."},"required":false,"description":"The kind of messaging this account supports, such as email or chat."},"credentialSecretId":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this account is enabled for messaging."},"required":true,"default":true,"description":"Whether this account is enabled for messaging."},"ownerUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The person who owns this account and decides who else may use it."},"required":false,"related":"@happyvertical/smrt-users:User","description":"The person who owns this account and decides who else may use it."},"label":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A short name shown beside this account, such as Support or Personal."},"required":false,"description":"A short name shown beside this account, such as Support or Personal."},"connectionStatus":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"required":false,"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"statusMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Why the account needs attention, in plain words."},"required":false,"description":"Why the account needs attention, in plain words."},"lastSyncAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this account last checked for new messages."},"required":false,"description":"When this account last checked for new messages."},"settings":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"configuration":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The public connection settings for this account; credentials are stored separately."},"required":false,"description":"The public connection settings for this account; credentials are stored separately."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was added."},"required":false,"description":"When this account was added."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was last changed."},"required":false,"description":"When this account was last changed."},"handle":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"twitterUserId":{"type":"text","_meta":{"__statedOptions":[]},"required":false}},"methods":{"getSettings":{"name":"getSettings","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setSettings":{"name":"setSettings","async":false,"parameters":[{"name":"settings","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getConfiguration":{"name":"getConfiguration","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setConfiguration":{"name":"setConfiguration","async":false,"parameters":[{"name":"configuration","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markNeedsReconnect":{"name":"markNeedsReconnect","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markConnected":{"name":"markConnected","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"activate":{"name":"activate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deactivate":{"name":"deactivate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"setCredentials":{"name":"setCredentials","async":true,"parameters":[{"name":"credentials","type":"Record<string, unknown>","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"removeCredentials":{"name":"removeCredentials","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"createSender":{"name":"createSender","async":true,"parameters":[],"returnType":"Promise<MessageSenderInterface>","isStatic":false,"isPublic":true},"getCredentials":{"name":"getCredentials","async":true,"parameters":[],"returnType":"Promise<Record<string, unknown> | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tableName":"accounts"},"extends":"Account","exportName":"TwitterAccount","collectionExportName":"TwitterAccountCollection","displayLabelField":"name","validationRules":[{"field":"isActive","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:UserNotification":{"name":"usernotification","className":"UserNotification","qualifiedName":"@happyvertical/smrt-messages:UserNotification","collection":"usernotifications","description":"One in-app notification for one person, with its own read state.","filePath":"src/models/UserNotification.ts","packageName":"@happyvertical/smrt-messages","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"recipientUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["required","requiredFor","related"],"required":true,"requiredFor":"identity"},"required":true,"related":"@happyvertical/smrt-users:User"},"kind":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"title":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"body":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"href":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"severity":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"info","enum":["info","success","warning","error"]},"sourceRef":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"idempotency"},"required":true},"occurredAt":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"readAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"dismissedAt":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false}},"methods":{},"decoratorConfig":{"tableName":"user_notifications","api":false,"mcp":false,"cli":false,"conflictColumns":["tenant_id","recipient_user_id","source_ref"],"indexes":[{"name":"user_notifications_recipient_occurred_idx","columns":["tenantId","recipientUserId","occurredAt"]}],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"UserNotification","collectionExportName":"UserNotificationCollection","displayLabelField":"title","validationRules":[{"field":"recipientUserId","rule":"required","fieldType":"crossPackageRef"},{"field":"sourceRef","rule":"required","fieldType":"text"}],"schema":{"tableName":"user_notifications","ddl":"CREATE TABLE IF NOT EXISTS \\"user_notifications\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"recipient_user_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT,\\n \\"title\\" TEXT,\\n \\"body\\" TEXT,\\n \\"href\\" TEXT,\\n \\"severity\\" TEXT DEFAULT 'info',\\n \\"source_ref\\" TEXT NOT NULL,\\n \\"occurred_at\\" TEXT,\\n \\"read_at\\" TIMESTAMP,\\n \\"dismissed_at\\" TIMESTAMP\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"recipient_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":false,"unique":false},"title":{"type":"TEXT","notNull":false,"unique":false},"body":{"type":"TEXT","notNull":false,"unique":false},"href":{"type":"TEXT","notNull":false,"unique":false},"severity":{"type":"TEXT","notNull":false,"unique":false,"default":"info"},"source_ref":{"type":"TEXT","notNull":true,"unique":false},"occurred_at":{"type":"TEXT","notNull":false,"unique":false},"read_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"dismissed_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"user_notifications_tenant_id_recipient_user_id_idx","columns":["tenant_id","recipient_user_id","source_ref"],"unique":true},{"name":"user_notifications_slug_context_idx","columns":["slug","context"]},{"name":"user_notifications_recipient_occurred_idx","columns":["tenant_id","recipient_user_id","occurred_at"]},{"name":"user_notifications_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"user_notifications_recipient_user_id_idx","columns":["recipient_user_id"]}],"version":"812ca772"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:Whitelist":{"name":"whitelist","className":"Whitelist","qualifiedName":"@happyvertical/smrt-messages:Whitelist","collection":"whitelists","description":"Allow-only entries for email filtering","filePath":"src/models/Whitelist.ts","packageName":"@happyvertical/smrt-messages","fields":{"pattern":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"type":{"type":"text","_meta":{"__statedOptions":["default","enum"]},"required":false,"default":"email","enum":["email","domain","regex"]},"category":{"type":"text","_meta":{"__statedOptions":[]},"required":false},"description":{"type":"text","_meta":{"__statedOptions":["default"]},"required":false,"default":""},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"mode":"required","field":"tenantId","autoFilter":true,"autoPopulate":true,"allowSuperAdminBypass":false},"generated":true,"source":"tenantScoped_decorator","sqlType":"UUID"},"required":true}},"methods":{"matches":{"name":"matches","async":false,"parameters":[{"name":"email","type":"string","optional":false}],"returnType":"boolean","isStatic":false,"isPublic":true}},"decoratorConfig":{"api":{"include":["list","get","create","update","delete"]},"cli":{"skipApiCheck":true},"tenantScoped":true,"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"Whitelist","collectionExportName":"WhitelistCollection","validationRules":[],"schema":{"tableName":"whitelists","ddl":"CREATE TABLE IF NOT EXISTS \\"whitelists\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"pattern\\" TEXT DEFAULT '',\\n \\"type\\" TEXT DEFAULT 'email',\\n \\"category\\" TEXT,\\n \\"description\\" TEXT DEFAULT '',\\n \\"tenant_id\\" UUID NOT NULL\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"pattern":{"type":"TEXT","notNull":false,"unique":false,"default":""},"type":{"type":"TEXT","notNull":false,"unique":false,"default":"email"},"category":{"type":"TEXT","notNull":false,"unique":false},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false}},"indexes":[{"name":"whitelists_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"whitelists_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"eb5b558d"},"importPath":"@happyvertical/smrt-messages"},"@happyvertical/smrt-messages:ZulipAccount":{"name":"zulipaccount","className":"ZulipAccount","qualifiedName":"@happyvertical/smrt-messages:ZulipAccount","collection":"accounts","filePath":"src/models/ZulipAccount.ts","packageName":"@happyvertical/smrt-messages","fields":{"created_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"updated_at":{"type":"datetime","_meta":{"__statedOptions":[]},"required":false},"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true},"__statedOptions":["sqlType","nullable","__tenancy","required"],"required":false,"sqlType":"UUID","nullable":true},"required":false},"name":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The display name for this connected messaging account."},"required":false,"description":"The display name for this connected messaging account."},"providerType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The service that connects this account to your application."},"required":false,"description":"The service that connects this account to your application."},"channelType":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The kind of messaging this account supports, such as email or chat."},"required":false,"description":"The kind of messaging this account supports, such as email or chat."},"credentialSecretId":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"isActive":{"type":"boolean","_meta":{"__statedOptions":["description","default"],"description":"Whether this account is enabled for messaging."},"required":true,"default":true,"description":"Whether this account is enabled for messaging."},"ownerUserId":{"type":"crossPackageRef","_meta":{"__statedOptions":["description","related"],"description":"The person who owns this account and decides who else may use it."},"required":false,"related":"@happyvertical/smrt-users:User","description":"The person who owns this account and decides who else may use it."},"label":{"type":"text","_meta":{"__statedOptions":["description"],"description":"A short name shown beside this account, such as Support or Personal."},"required":false,"description":"A short name shown beside this account, such as Support or Personal."},"connectionStatus":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"required":false,"description":"Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."},"statusMessage":{"type":"text","_meta":{"__statedOptions":["description"],"description":"Why the account needs attention, in plain words."},"required":false,"description":"Why the account needs attention, in plain words."},"lastSyncAt":{"type":"datetime","_meta":{"__statedOptions":["description"],"description":"When this account last checked for new messages."},"required":false,"description":"When this account last checked for new messages."},"settings":{"type":"text","_meta":{"__statedOptions":["sensitive","readonly"],"sensitive":true,"readonly":true},"required":false,"sensitive":true,"readonly":true},"configuration":{"type":"text","_meta":{"__statedOptions":["description"],"description":"The public connection settings for this account; credentials are stored separately."},"required":false,"description":"The public connection settings for this account; credentials are stored separately."},"createdAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was added."},"required":false,"description":"When this account was added."},"updatedAt":{"type":"text","_meta":{"__statedOptions":["description"],"description":"When this account was last changed."},"required":false,"description":"When this account was last changed."}},"methods":{"getSettings":{"name":"getSettings","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setSettings":{"name":"setSettings","async":false,"parameters":[{"name":"settings","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getConfiguration":{"name":"getConfiguration","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setConfiguration":{"name":"setConfiguration","async":false,"parameters":[{"name":"configuration","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"markNeedsReconnect":{"name":"markNeedsReconnect","async":true,"parameters":[{"name":"reason","type":"string","optional":false}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"markConnected":{"name":"markConnected","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"activate":{"name":"activate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"deactivate":{"name":"deactivate","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"setCredentials":{"name":"setCredentials","async":true,"parameters":[{"name":"credentials","type":"Record<string, unknown>","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["string"]}],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"removeCredentials":{"name":"removeCredentials","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"createSender":{"name":"createSender","async":true,"parameters":[],"returnType":"Promise<MessageSenderInterface>","isStatic":false,"isPublic":true},"getCredentials":{"name":"getCredentials","async":true,"parameters":[],"returnType":"Promise<Record<string, unknown> | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableStrategy":"sti","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]},"tableName":"accounts"},"extends":"Account","exportName":"ZulipAccount","collectionExportName":"ZulipAccountCollection","displayLabelField":"name","validationRules":[{"field":"isActive","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"accounts","ddl":"CREATE TABLE IF NOT EXISTS \\"accounts\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"_meta_type\\" TEXT NOT NULL,\\n \\"_meta_data\\" JSON,\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"name\\" TEXT,\\n \\"provider_type\\" TEXT,\\n \\"channel_type\\" TEXT,\\n \\"credential_secret_id\\" TEXT,\\n \\"is_active\\" BOOLEAN DEFAULT TRUE,\\n \\"owner_user_id\\" UUID,\\n \\"label\\" TEXT,\\n \\"connection_status\\" TEXT,\\n \\"status_message\\" TEXT,\\n \\"last_sync_at\\" TIMESTAMP,\\n \\"settings\\" TEXT,\\n \\"configuration\\" TEXT,\\n \\"email\\" TEXT,\\n \\"sync_interval_minutes\\" INTEGER DEFAULT 60,\\n \\"sync_cursor\\" TEXT,\\n \\"workspace_id\\" TEXT,\\n \\"workspace_name\\" TEXT,\\n \\"bot_user_id\\" TEXT,\\n \\"handle\\" TEXT,\\n \\"twitter_user_id\\" TEXT\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"_meta_type":{"type":"TEXT","notNull":true},"_meta_data":{"type":"JSON","notNull":false},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false},"name":{"type":"TEXT","notNull":false},"provider_type":{"type":"TEXT","notNull":false},"channel_type":{"type":"TEXT","notNull":false},"credential_secret_id":{"type":"TEXT","notNull":false},"is_active":{"type":"BOOLEAN","notNull":false,"default":true},"owner_user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false},"label":{"type":"TEXT","notNull":false},"connection_status":{"type":"TEXT","notNull":false},"status_message":{"type":"TEXT","notNull":false},"last_sync_at":{"type":"TIMESTAMP","notNull":false},"settings":{"type":"TEXT","notNull":false},"configuration":{"type":"TEXT","notNull":false},"email":{"type":"TEXT","notNull":false},"sync_interval_minutes":{"type":"INTEGER","notNull":false,"default":60},"sync_cursor":{"type":"TEXT","notNull":false},"workspace_id":{"type":"TEXT","notNull":false},"workspace_name":{"type":"TEXT","notNull":false},"bot_user_id":{"type":"TEXT","notNull":false},"handle":{"type":"TEXT","notNull":false},"twitter_user_id":{"type":"TEXT","notNull":false}},"indexes":[{"name":"accounts_slug_context_meta_type_idx","columns":["tenant_id","slug","context","_meta_type"],"unique":true,"nullsNotDistinct":true},{"name":"accounts_meta_type_idx","columns":["_meta_type"]},{"name":"accounts_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"accounts_owner_user_id_idx","columns":["owner_user_id"]}],"checks":[{"name":"smrt_ck_1f9c5f0ee488","columns":["sync_interval_minutes"],"expression":"_meta_type NOT IN ('@happyvertical/smrt-messages:EmailAccount') OR \\"sync_interval_minutes\\" IS NOT NULL"}],"version":"ed7f2dff"},"importPath":"@happyvertical/smrt-messages"}},"moduleType":"smrt","recipes":[{"id":"messages.mailbox","className":"MailboxRecipe","label":"Mailbox","summary":"Read and compose email from your connected accounts.","synonyms":["email","inbox","mail"],"models":["@happyvertical/smrt-messages:Email","@happyvertical/smrt-messages:EmailAccount"],"nav":[{"label":"Mailbox","model":"@happyvertical/smrt-messages:Email","icon":"folder","description":"Read email from your connected accounts.","key":"mailbox","noun":"email"},{"label":"Failed sends","model":"@happyvertical/smrt-messages:Email","icon":"fileText","description":"Review email whose last send attempt failed.","key":"failed-sends","noun":"email","filter":{"field":"sendStatus","value":"failed"}}],"requires":[],"group":{"id":"messages","label":"Messaging","summary":"Choose email and personal updates independently."},"section":{"id":"messages","label":"Messaging","icon":"folder","description":"Read email and keep up with updates addressed to you."},"options":{"@happyvertical/smrt-messages:Email":{"fields":{"created_at":{"help":"When this email was first recorded."},"updated_at":{"help":"When this email record was last changed."}}},"@happyvertical/smrt-messages:EmailAccount":{"fields":{"created_at":{"help":"When this mailbox connection was first recorded."},"updated_at":{"help":"When this mailbox connection was last changed."}}}},"help":{"markdown":"## Your mailbox\\nRead messages, open a conversation, or compose an email using a connected account.\\nChoose the sender account, add recipients, and check the subject and message before sending.\\n\\n## Failed sends\\nUse Failed sends to review email whose last send attempt failed. Returning to the mailbox shows all email again.\\nCheck the failure and sender connection before retrying through your application. This view does not resend email automatically.\\n\\n## Preview\\nThe playground uses fictional messages. Sending and saving are mocked and never contact a mail server.\\n\\n## Connect an account\\nYour application administrator connects an authorized email provider on the server. Real sending and mailbox synchronization require that connection; a preview does not verify delivery.\\n","fieldRefs":[]},"surfaces":[{"kind":"route","path":"/messages/mailbox","export":"@happyvertical/smrt-messages/svelte#MessageList","label":"Mailbox"},{"kind":"playground","export":"@happyvertical/smrt-messages/svelte#MailboxDemo","label":"Mailbox with mocked sending"}],"providers":[{"id":"email-inbox","kind":"email","options":["imap","pop3","gmail","jmap"],"required":true},{"id":"email-send","kind":"email","options":["smtp","gmail"],"required":false}],"runtime":"both","demoSeed":{"data":{"accounts":[{"id":"demo-account","name":"Demo Inbox","providerType":"email","email":"you@example.com","isActive":true}],"messages":[{"id":"demo-welcome","type":"email","accountId":"demo-account","subject":"Welcome to your mailbox","body":"Fictional mail. Sending is mocked; nothing leaves this browser.","senderName":"Demo colleague","senderAddress":"colleague@example.com","recipientAddresses":[{"address":"you@example.com"}],"date":"2026-01-01T12:00:00Z","isRead":false,"isFlagged":false,"hasAttachments":false}]}},"demo":{"mode":"server","reasons":["Needs a server because its package depends on @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3626, #3627)."]}},{"id":"messages.notifications","className":"NotificationsRecipe","label":"Notifications","summary":"See updates addressed to you and mark them read.","synonyms":["alerts","notification bell"],"models":["@happyvertical/smrt-messages:UserNotification"],"nav":[],"requires":[],"group":{"id":"messages","label":"Messaging","summary":"Choose email and personal updates independently."},"section":{"id":"messages","label":"Messaging","icon":"folder","description":"Read email and keep up with updates addressed to you."},"help":{"markdown":"## Notifications\\nOpen the notification bell to see updates addressed to you. Unread updates have a visible marker.\\nChoose Mark read for one update or Mark all read for every unread update in your authorized accounts.\\nFollow a notification link to open its related record when one is available.\\n\\n## Availability\\nNotifications are scoped to the signed-in person. Your application connects the notification provider and may enable live updates. If loading fails, try again after the connection returns.\\n","fieldRefs":[]},"surfaces":[{"kind":"shell-widget","slot":"header.end","export":"@happyvertical/smrt-svelte/notifications#NotificationBell","label":"Notifications"}],"providers":[{"id":"notifications","kind":"notifications","options":["user-notification-service"],"required":true}],"runtime":"both","demoSeed":{"data":{"items":[{"id":"demo-notification","title":"You were mentioned","body":"A fictional update for the demo user.","occurredAt":"2026-01-01T12:00:00Z","severity":"info","readAt":null}]}},"demo":{"mode":"server","reasons":["Needs a server because its package depends on @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3626, #3627)."]}},{"id":"messages.slack","className":"SlackRecipe","label":"Slack","summary":"Read Slack messages from your connected workspaces.","synonyms":["slack","slack messages","slack channels","workspace chat","team chat"],"models":["@happyvertical/smrt-messages:SlackMessage","@happyvertical/smrt-messages:SlackAccount"],"nav":[{"label":"Slack messages","model":"@happyvertical/smrt-messages:SlackMessage","icon":"folder","description":"Read messages from your connected workspaces by channel.","key":"slack-messages","noun":"message"},{"label":"Slack workspaces","model":"@happyvertical/smrt-messages:SlackAccount","icon":"users","description":"The workspaces your application is connected to.","noun":"workspace"}],"requires":[],"group":{"id":"messages","label":"Messaging","summary":"Choose email and personal updates independently."},"section":{"id":"messages","label":"Messaging","icon":"folder","description":"Read email and keep up with updates addressed to you."},"options":{"@happyvertical/smrt-messages:SlackMessage":{"fields":{"channelName":{"label":"Channel","order":1},"body":{"label":"Message","order":2},"threadId":{"label":"Thread","order":3},"sendStatus":{"label":"Sent status","order":4},"accountId":{"label":"Workspace","order":5},"fromName":{"label":"From","visibility":"advanced"},"fromAddress":{"visibility":"advanced"},"toAddresses":{"visibility":"advanced"},"subject":{"visibility":"advanced"},"date":{"visibility":"advanced"},"isRead":{"visibility":"advanced"},"isFlagged":{"visibility":"advanced"},"isEdited":{"label":"Edited","visibility":"advanced"},"messageType":{"label":"Message kind","visibility":"advanced"},"reactions":{"visibility":"advanced"},"hasAttachments":{"visibility":"advanced"},"channelId":{"visibility":"advanced"},"sentAt":{"visibility":"advanced"},"sendError":{"visibility":"advanced"},"scheduledSendAt":{"visibility":"advanced"},"inReplyToMessageId":{"label":"Replying to","visibility":"advanced"},"personaId":{"visibility":"advanced"},"endpointId":{"visibility":"advanced"},"retryCount":{"visibility":"hidden"},"maxRetries":{"visibility":"hidden"},"size":{"visibility":"hidden"},"correlationId":{"visibility":"hidden"},"slackTs":{"visibility":"hidden"},"slackThreadTs":{"visibility":"hidden"},"blocks":{"visibility":"hidden"},"metadata":{"visibility":"hidden"},"tenantId":{"visibility":"hidden"},"created_at":{"help":"When this message was first recorded."},"updated_at":{"help":"When this message record was last changed."}}},"@happyvertical/smrt-messages:SlackAccount":{"fields":{"name":{"order":1},"workspaceName":{"label":"Workspace","order":2},"isActive":{"label":"Enabled","order":3},"lastSyncAt":{"label":"Last checked","order":4},"workspaceId":{"visibility":"advanced"},"credentialSecretId":{"visibility":"hidden"},"settings":{"visibility":"hidden"},"botUserId":{"label":"Bot user","visibility":"advanced"},"providerType":{"visibility":"advanced"},"channelType":{"visibility":"advanced"},"configuration":{"visibility":"advanced"},"tenantId":{"visibility":"hidden"},"created_at":{"help":"When this workspace connection was first recorded."},"updated_at":{"help":"When this workspace connection was last changed."}}}},"help":{"markdown":"## Overview\\n\\nSlack shows the messages from the workspaces your application is connected to,\\nin one place beside your email. Each message keeps the channel it was posted\\nin, the thread it belongs to, the reactions people added and whether it was\\nedited, so you can catch up on a conversation without opening Slack.\\n\\n## Tasks\\n\\nWorkspaces are connected by your application administrator on the server.\\nMessages arrive from those connected workspaces; here you read them and see\\nwhere each one stands.\\n\\n### Find a message in a channel\\n\\n1. Open Slack messages.\\n2. Look at the **{field:SlackMessage.channelName}** to find the channel you want.\\n3. Open a message to read the **{field:SlackMessage.body}** and see who it is from.\\n\\n### Follow a thread\\n\\n1. Open a message that is part of a conversation.\\n2. Use its **{field:SlackMessage.threadId}** to find the other messages in the same thread.\\n3. Read them oldest first; the **{field:SlackMessage.reactions}** show how people responded.\\n\\n### See whether a message was changed\\n\\n1. Open the message.\\n2. Check **{field:SlackMessage.isEdited}** to see whether it was edited after it was posted.\\n\\n### Draft a message\\n\\n1. Open Slack messages and choose **New**.\\n2. Type the **{field:SlackMessage.channelName}** it is for and the **{field:SlackMessage.body}**.\\n3. Save. This records the draft; your application sends it through the connected workspace, and the **{field:SlackMessage.sendStatus}** shows where it stands.\\n\\n### See which workspaces are connected\\n\\n1. Open Slack workspaces.\\n2. Look at the **{field:SlackAccount.workspaceName}** and whether it is **{field:SlackAccount.isActive}**.\\n3. Check **{field:SlackAccount.lastSyncAt}** to see when messages were last collected. Connecting or changing a workspace is done by your application administrator, not here.\\n","fieldRefs":["SlackAccount.isActive","SlackAccount.lastSyncAt","SlackAccount.workspaceName","SlackMessage.body","SlackMessage.channelName","SlackMessage.isEdited","SlackMessage.reactions","SlackMessage.sendStatus","SlackMessage.threadId"]},"demo":{"mode":"server","reasons":["Needs a server because its package depends on @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3626, #3627)."]}}],"smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-jobs","@happyvertical/smrt-ledgers","@happyvertical/smrt-profiles","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"],"browser":{"status":"server-only","issues":["#3615","#3617","#3624","#3626","#3627"],"via":["@happyvertical/smrt-jobs","@happyvertical/smrt-profiles","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"]},"stampsConstructors":true}`));
8
+ //#endregion
9
+ //#region src/permissions.ts
10
+ var SEND_MESSAGES_PERMISSION = "messages.send";
11
+ var MANAGE_MESSAGE_ROUTES_PERMISSION = "messages.manage-routes";
12
+ var MANAGE_MESSAGE_CREDENTIALS_PERMISSION = "messages.manage-credentials";
13
+ var READ_MAIL_PERMISSION = "messages.read";
14
+ var TRIAGE_MAIL_PERMISSION = "messages.triage";
15
+ var DRAFT_MAIL_PERMISSION = "messages.draft";
16
+ var MESSAGING_PERMISSION_DEFINITIONS = [
17
+ {
18
+ slug: SEND_MESSAGES_PERMISSION,
19
+ category: "messages",
20
+ name: "Send Messages",
21
+ description: "Allows send on messages"
22
+ },
23
+ {
24
+ slug: MANAGE_MESSAGE_ROUTES_PERMISSION,
25
+ category: "messages",
26
+ name: "Manage Message Routes",
27
+ description: "Manage persona messaging endpoints and route bindings"
28
+ },
29
+ {
30
+ slug: MANAGE_MESSAGE_CREDENTIALS_PERMISSION,
31
+ category: "messages",
32
+ name: "Manage Message Credentials",
33
+ description: "Create accounts and replace write-only provider credentials"
34
+ },
35
+ {
36
+ slug: TRIAGE_MAIL_PERMISSION,
37
+ category: "messages",
38
+ name: "Triage Mail",
39
+ description: "Archive, flag and file mail; a mail account grant narrows this per account"
40
+ },
41
+ {
42
+ slug: DRAFT_MAIL_PERMISSION,
43
+ category: "messages",
44
+ name: "Draft Mail",
45
+ description: "Write mail drafts; a mail account grant narrows this per account"
46
+ },
47
+ {
48
+ slug: "messages.manage-access",
49
+ category: "messages",
50
+ name: "Manage Mail Access",
51
+ description: "Grant or revoke per-account mail access; only an account owner or a delegating grantee may use it on that account"
52
+ }
53
+ ];
54
+ function messagingPrincipalFromPermissions(permissions, options = {}) {
55
+ const granted = new Set(permissions);
56
+ return {
57
+ ...options,
58
+ can: (slug) => granted.has(slug)
59
+ };
60
+ }
61
+ function assertMessagingPermission(principal, tenantId, permission) {
62
+ if (principal.tenantId && principal.tenantId !== tenantId) throw new Error("Messaging principal does not belong to this tenant.");
63
+ if (!principal.can(permission)) throw new Error(`Missing required permission '${permission}'.`);
64
+ }
65
+ var registered = false;
66
+ function ensureMessagingPermissionsRegistered() {
67
+ if (registered) return;
68
+ registered = true;
69
+ registerPermissionDefinitions(MESSAGING_PERMISSION_DEFINITIONS);
70
+ }
71
+ //#endregion
72
+ //#region src/access.ts
73
+ var MAIL_SCOPES = [
74
+ "read",
75
+ "triage",
76
+ "draft",
77
+ "send"
78
+ ];
79
+ var MAIL_ACCOUNT_RESOURCE_TYPE = "messages:account";
80
+ var SCOPE_PERMISSIONS = {
81
+ read: READ_MAIL_PERMISSION,
82
+ triage: TRIAGE_MAIL_PERMISSION,
83
+ draft: DRAFT_MAIL_PERMISSION,
84
+ send: "messages.send"
85
+ };
86
+ function mailScopePermission(scope) {
87
+ return SCOPE_PERMISSIONS[scope];
88
+ }
89
+ function isMailScope(value) {
90
+ return MAIL_SCOPES.includes(value);
91
+ }
92
+ var STATE_KEY = /* @__PURE__ */ Symbol.for("@happyvertical/smrt-messages:mail-access");
93
+ function state() {
94
+ const holder = globalThis;
95
+ let current = holder[STATE_KEY];
96
+ if (!current) {
97
+ current = {
98
+ config: null,
99
+ learned: /* @__PURE__ */ new Map(),
100
+ system: createHandoffContext()
101
+ };
102
+ holder[STATE_KEY] = current;
103
+ }
104
+ return current;
105
+ }
106
+ function configureMailAccess(config) {
107
+ state().config = {
108
+ ...config,
109
+ options: withoutListBounds(config.options)
110
+ };
111
+ }
112
+ function resetMailAccess() {
113
+ state().config = null;
114
+ state().learned.clear();
115
+ }
116
+ function withoutListBounds(options) {
117
+ return {
118
+ ...options,
119
+ defaultListLimit: void 0,
120
+ maxListLimit: void 0
121
+ };
122
+ }
123
+ function learnMailAccessOptions(options) {
124
+ const current = state();
125
+ if (current.config || !options) return;
126
+ const key = options.db ?? options;
127
+ current.learned.delete(key);
128
+ current.learned.set(key, withoutListBounds(options));
129
+ if (current.learned.size > 16) {
130
+ const oldest = current.learned.keys().next().value;
131
+ current.learned.delete(oldest);
132
+ }
133
+ }
134
+ function getEffectiveMailAccessConfigs() {
135
+ const current = state();
136
+ if (current.config) return [current.config];
137
+ return [...current.learned.values()].map((options) => ({ options }));
138
+ }
139
+ function getEffectiveMailAccessConfig() {
140
+ const current = state();
141
+ if (current.config) return current.config;
142
+ const latest = [...current.learned.values()].pop();
143
+ return latest ? { options: latest } : null;
144
+ }
145
+ function runWithMailSystemAccess(fn) {
146
+ return state().system.run(true, fn);
147
+ }
148
+ function inMailSystemAccess() {
149
+ return state().system.getStore() === true;
150
+ }
151
+ var MailAccessError = class extends Error {
152
+ constructor(scope, reason) {
153
+ super(`Mail access denied for scope '${scope}'.`);
154
+ this.scope = scope;
155
+ this.reason = reason;
156
+ this.name = "MailAccessError";
157
+ }
158
+ scope;
159
+ reason;
160
+ status = 403;
161
+ };
162
+ async function resolvePrincipal(config) {
163
+ if (!config.resolvePrincipal) return null;
164
+ const principal = await config.resolvePrincipal({ tenantId: getCurrentTenant()?.tenantId ?? null });
165
+ if (!principal || typeof principal.id !== "string" || !principal.id || typeof principal.userId !== "string" || !principal.userId || typeof principal.tenantId !== "string" || !principal.tenantId) return null;
166
+ return principal;
167
+ }
168
+ async function hasGrant(config, principal, account, scope) {
169
+ const { checkResourceOperationPermission } = await import("@happyvertical/smrt-users");
170
+ const accountId = account.id ?? "";
171
+ const tenantId = account.tenantId ?? "";
172
+ if (!accountId || !tenantId) return false;
173
+ return (await checkResourceOperationPermission({
174
+ ...config.options,
175
+ collection: "messages",
176
+ action: scope,
177
+ tenantId,
178
+ userId: principal.userId,
179
+ allowSuperAdminBypass: false,
180
+ allowSystemContextBypass: false,
181
+ resource: {
182
+ tenantId,
183
+ resourceType: MAIL_ACCOUNT_RESOURCE_TYPE,
184
+ resourceId: accountId
185
+ },
186
+ verifyResource: (resource) => resource.tenantId === tenantId && resource.resourceType === "messages:account" && resource.resourceId === accountId
187
+ })).allowed;
188
+ }
189
+ async function decideMailAccess(account, scope, principalOverride) {
190
+ if (inMailSystemAccess()) return {
191
+ allowed: true,
192
+ reason: "system"
193
+ };
194
+ const config = getEffectiveMailAccessConfig();
195
+ const owned = Boolean(account.ownerUserId);
196
+ if (!config) return owned ? {
197
+ allowed: false,
198
+ reason: "not_configured"
199
+ } : {
200
+ allowed: true,
201
+ reason: "unowned"
202
+ };
203
+ const principal = principalOverride !== void 0 ? principalOverride : await resolvePrincipal(config);
204
+ if (!principal) return owned ? {
205
+ allowed: false,
206
+ reason: "no_principal"
207
+ } : {
208
+ allowed: true,
209
+ reason: "unowned"
210
+ };
211
+ if (account.tenantId && principal.tenantId !== account.tenantId) return {
212
+ allowed: false,
213
+ reason: "tenant_mismatch"
214
+ };
215
+ const currentTenant = getCurrentTenant()?.tenantId;
216
+ if (currentTenant && currentTenant !== principal.tenantId) return {
217
+ allowed: false,
218
+ reason: "tenant_mismatch"
219
+ };
220
+ if (principal.scopes && !principal.scopes.includes(scope)) return {
221
+ allowed: false,
222
+ reason: "ceiling"
223
+ };
224
+ if (principal.accountIds && (!account.id || !principal.accountIds.includes(account.id))) return {
225
+ allowed: false,
226
+ reason: "ceiling"
227
+ };
228
+ if (!owned) return {
229
+ allowed: true,
230
+ reason: "unowned"
231
+ };
232
+ if (account.ownerUserId === principal.userId) return {
233
+ allowed: true,
234
+ reason: "owner"
235
+ };
236
+ try {
237
+ return await hasGrant(config, principal, account, scope) ? {
238
+ allowed: true,
239
+ reason: "grant"
240
+ } : {
241
+ allowed: false,
242
+ reason: "denied"
243
+ };
244
+ } catch {
245
+ return {
246
+ allowed: false,
247
+ reason: "denied"
248
+ };
249
+ }
250
+ }
251
+ async function canAccessMailAccount(account, scope) {
252
+ return (await decideMailAccess(account, scope)).allowed;
253
+ }
254
+ async function assertMailAccess(account, scope) {
255
+ const decision = await decideMailAccess(account, scope);
256
+ if (!decision.allowed) throw new MailAccessError(scope, decision.reason);
257
+ }
258
+ async function deniedMailAccountIds(scope) {
259
+ if (inMailSystemAccess()) return [];
260
+ const { AccountCollection } = await Promise.resolve().then(() => AccountCollection_exports);
261
+ const denied = /* @__PURE__ */ new Set();
262
+ for (const config of getEffectiveMailAccessConfigs()) {
263
+ let accounts;
264
+ try {
265
+ accounts = await runWithMailSystemAccess(async () => (await AccountCollection.create(config.options)).list({}));
266
+ } catch (error) {
267
+ if (!state().config && /CLIENT_CLOSED/.test(String(error))) {
268
+ state().learned.delete(config.options.db ?? config.options);
269
+ continue;
270
+ }
271
+ throw error;
272
+ }
273
+ const principal = await resolvePrincipal(config);
274
+ for (const account of accounts) {
275
+ if (!account.id) continue;
276
+ if (!(await decideMailAccess({
277
+ id: account.id,
278
+ tenantId: account.tenantId,
279
+ ownerUserId: account.ownerUserId
280
+ }, scope, principal)).allowed) denied.add(account.id);
281
+ }
282
+ }
283
+ return [...denied];
284
+ }
285
+ async function accountReadable(accountId, options) {
286
+ if (inMailSystemAccess()) return true;
287
+ learnMailAccessOptions(options);
288
+ if (!accountId) return true;
289
+ const config = getEffectiveMailAccessConfig();
290
+ if (!config) return true;
291
+ const { AccountCollection } = await Promise.resolve().then(() => AccountCollection_exports);
292
+ const account = await runWithMailSystemAccess(async () => (await AccountCollection.create(config.options)).get({ id: accountId }));
293
+ if (!account) return false;
294
+ return (await decideMailAccess({
295
+ id: account.id,
296
+ tenantId: account.tenantId,
297
+ ownerUserId: account.ownerUserId
298
+ }, "read")).allowed;
299
+ }
300
+ async function assertHydratedMailAccess(row) {
301
+ if (inMailSystemAccess()) return;
302
+ const options = row.options;
303
+ let accountId = row.accountId || null;
304
+ if (!accountId && row.messageId && options) {
305
+ const { MessageCollection } = await import("./MessageCollection-t8cLUSNJ.js").then((n) => n.n);
306
+ const message = await runWithMailSystemAccess(async () => (await MessageCollection.create(options)).get({ id: row.messageId }));
307
+ if (!message) throw new MailAccessError("read", "denied");
308
+ accountId = message.accountId || null;
309
+ }
310
+ if (!await accountReadable(accountId, options)) throw new MailAccessError("read", "denied");
311
+ }
312
+ var MailAccessService = class {
313
+ constructor(options, actor) {
314
+ this.options = options;
315
+ this.actor = actor;
316
+ }
317
+ options;
318
+ actor;
319
+ async account(accountId) {
320
+ const { AccountCollection } = await Promise.resolve().then(() => AccountCollection_exports);
321
+ const { withTenant } = await import("../host.js");
322
+ return withTenant({ tenantId: this.actor.tenantId }, async () => {
323
+ const account = await (await AccountCollection.create(withoutListBounds(this.options))).get({ id: accountId });
324
+ if (!account || account.tenantId !== this.actor.tenantId) throw new Error("Mail account was not found in this tenant.");
325
+ return account;
326
+ });
327
+ }
328
+ /** Tenant RBAC ceiling for administering mail access (grants, owner). */
329
+ async assertManageAccess() {
330
+ const { assertOperationPermission } = await import("@happyvertical/smrt-users");
331
+ await assertOperationPermission({
332
+ ...this.options,
333
+ collection: "messages",
334
+ action: "manage-access",
335
+ tenantId: this.actor.tenantId,
336
+ userId: this.actor.userId,
337
+ allowSuperAdminBypass: false,
338
+ allowSystemContextBypass: false,
339
+ onDeny: "throw"
340
+ });
341
+ }
342
+ /** The new owner must be a real, active member of this tenant. */
343
+ async assertTenantMember(userId) {
344
+ if (!(await (await (await import("@happyvertical/smrt-users")).MembershipCollection.create(this.options)).list({
345
+ where: {
346
+ tenantId: this.actor.tenantId,
347
+ userId,
348
+ status: "active"
349
+ },
350
+ limit: 1
351
+ })).length) throw new Error("The new owner must be an active member of this tenant.");
352
+ }
353
+ async inTenant(fn) {
354
+ const { withTenant } = await import("../host.js");
355
+ return withTenant({ tenantId: this.actor.tenantId }, fn);
356
+ }
357
+ resourceFor(accountId) {
358
+ return {
359
+ tenantId: this.actor.tenantId,
360
+ resourceType: MAIL_ACCOUNT_RESOURCE_TYPE,
361
+ resourceId: accountId
362
+ };
363
+ }
364
+ async grantsApi() {
365
+ const users = await import("@happyvertical/smrt-users");
366
+ const verifyResource = (resource) => resource.tenantId === this.actor.tenantId && resource.resourceType === "messages:account";
367
+ return {
368
+ users,
369
+ verifyResource
370
+ };
371
+ }
372
+ grant(input) {
373
+ return this.inTenant(() => this.grantImpl(input));
374
+ }
375
+ revoke(grantId) {
376
+ return this.inTenant(() => this.revokeImpl(grantId));
377
+ }
378
+ list(accountId) {
379
+ return this.inTenant(() => this.listImpl(accountId));
380
+ }
381
+ setOwner(accountId, ownerUserId) {
382
+ return this.inTenant(() => this.setOwnerImpl(accountId, ownerUserId));
383
+ }
384
+ async grantImpl(input) {
385
+ if (!isMailScope(input.scope)) throw new Error("Unknown mail scope.");
386
+ const account = await this.account(input.accountId);
387
+ if (!account.ownerUserId) throw new Error("Set an owner on this mail account before sharing it.");
388
+ if (input.userId === this.actor.userId && !input.parentGrantId) throw new Error("A mail grant must name another user.");
389
+ const isOwner = account.ownerUserId === this.actor.userId;
390
+ if (!isOwner && !input.parentGrantId) throw new Error("Only the account owner can grant mail access.");
391
+ if (isOwner && input.parentGrantId) throw new Error("An owner grants directly, not by delegation.");
392
+ if (!isOwner && (input.effect === "deny" || input.canDelegate === true)) throw new Error("A delegate can only pass on a plain, non-delegable grant.");
393
+ const { users, verifyResource } = await this.grantsApi();
394
+ return new users.ResourceGrantService(this.options).create({
395
+ actor: {
396
+ collection: "messages",
397
+ action: "manage-access",
398
+ tenantId: this.actor.tenantId,
399
+ userId: this.actor.userId,
400
+ allowSuperAdminBypass: false,
401
+ allowSystemContextBypass: false
402
+ },
403
+ authorization: {
404
+ collection: "messages",
405
+ action: input.scope,
406
+ tenantId: this.actor.tenantId,
407
+ userId: this.actor.userId,
408
+ allowSuperAdminBypass: false,
409
+ allowSystemContextBypass: false,
410
+ resource: this.resourceFor(input.accountId),
411
+ verifyResource
412
+ },
413
+ grant: {
414
+ ...this.resourceFor(input.accountId),
415
+ userId: input.userId,
416
+ permission: mailScopePermission(input.scope),
417
+ effect: input.effect ?? "grant",
418
+ canDelegate: input.canDelegate ?? false,
419
+ parentGrantId: input.parentGrantId ?? null
420
+ }
421
+ });
422
+ }
423
+ /** Revoke a grant. Delegated children stop working with their ancestor. */
424
+ async revokeImpl(grantId) {
425
+ const { users, verifyResource } = await this.grantsApi();
426
+ const grant = await (await users.ResourceGrantCollection.create(withoutListBounds(this.options))).get({ id: grantId });
427
+ if (!grant || grant.tenantId !== this.actor.tenantId || grant.resourceType !== "messages:account") throw new Error("Mail grant not found.");
428
+ if ((await this.account(grant.resourceId)).ownerUserId !== this.actor.userId) throw new Error("Only the account owner can revoke mail access.");
429
+ await new users.ResourceGrantService(this.options).revoke(grantId, {
430
+ actor: {
431
+ collection: "messages",
432
+ action: "manage-access",
433
+ tenantId: this.actor.tenantId,
434
+ userId: this.actor.userId,
435
+ allowSuperAdminBypass: false,
436
+ allowSystemContextBypass: false
437
+ },
438
+ verifyResource
439
+ });
440
+ }
441
+ /** Owner-only listing of who holds what on one account. */
442
+ async listImpl(accountId) {
443
+ if ((await this.account(accountId)).ownerUserId !== this.actor.userId) throw new Error("Only the account owner can list mail access.");
444
+ await this.assertManageAccess();
445
+ const { users } = await this.grantsApi();
446
+ return (await (await users.ResourceGrantCollection.create(withoutListBounds(this.options))).list({ where: {
447
+ tenantId: this.actor.tenantId,
448
+ resourceType: MAIL_ACCOUNT_RESOURCE_TYPE,
449
+ resourceId: accountId
450
+ } })).filter((grant) => grant.isActive());
451
+ }
452
+ /**
453
+ * Set or change the owner. An owned account changes hands only by its
454
+ * owner. An unowned account can be claimed by a tenant administrator
455
+ * holding `messages.manage-credentials` (the migration path from
456
+ * tenant-wide to owned).
457
+ */
458
+ async setOwnerImpl(accountId, ownerUserId) {
459
+ const account = await this.account(accountId);
460
+ if (account.ownerUserId) {
461
+ if (account.ownerUserId !== this.actor.userId) throw new Error("Only the account owner can transfer ownership.");
462
+ await this.assertManageAccess();
463
+ } else {
464
+ const { assertOperationPermission } = await import("@happyvertical/smrt-users");
465
+ await assertOperationPermission({
466
+ ...this.options,
467
+ collection: "messages",
468
+ action: "manage-credentials",
469
+ tenantId: this.actor.tenantId,
470
+ userId: this.actor.userId,
471
+ allowSuperAdminBypass: false,
472
+ allowSystemContextBypass: false,
473
+ onDeny: "throw"
474
+ });
475
+ }
476
+ await this.assertTenantMember(ownerUserId);
477
+ account.ownerUserId = ownerUserId;
478
+ account.updatedAt = /* @__PURE__ */ new Date();
479
+ await account.save();
480
+ }
481
+ };
482
+ //#endregion
483
+ //#region src/models/Account.ts
484
+ var __defProp$1 = Object.defineProperty;
485
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
486
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
487
+ enumerable: true,
488
+ configurable: true,
489
+ writable: true,
490
+ value
491
+ }) : obj[key] = value;
492
+ var __decorateClass$1 = (decorators, target, key, kind) => {
493
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
494
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
495
+ if (kind && result) __defProp$1(target, key, result);
496
+ return result;
497
+ };
498
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
499
+ var Account = class extends SmrtObject {
500
+ tenantId = null;
501
+ name = "";
502
+ providerType = "";
503
+ channelType = "";
504
+ credentialSecretId = null;
505
+ isActive = true;
506
+ ownerUserId = null;
507
+ label = null;
508
+ connectionStatus = null;
509
+ statusMessage = null;
510
+ lastSyncAt = null;
511
+ settings = "";
512
+ configuration = "{}";
513
+ createdAt = /* @__PURE__ */ new Date();
514
+ updatedAt = /* @__PURE__ */ new Date();
515
+ constructor(options = {}) {
516
+ super(options);
517
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
518
+ if (options.name !== void 0) this.name = options.name;
519
+ if (options.providerType !== void 0) this.providerType = options.providerType;
520
+ if (options.channelType !== void 0) this.channelType = options.channelType;
521
+ if (options.credentialSecretId !== void 0) this.credentialSecretId = options.credentialSecretId || null;
522
+ if (options.isActive !== void 0) this.isActive = options.isActive;
523
+ if (options.ownerUserId !== void 0) this.ownerUserId = options.ownerUserId || null;
524
+ if (options.label !== void 0) this.label = options.label || null;
525
+ if (options.connectionStatus !== void 0) this.connectionStatus = options.connectionStatus || null;
526
+ if (options.statusMessage !== void 0) this.statusMessage = options.statusMessage || null;
527
+ if (options.lastSyncAt !== void 0) this.lastSyncAt = options.lastSyncAt || null;
528
+ if (options.settings !== void 0) this.settings = options.settings;
529
+ if (options.configuration !== void 0) this.configuration = options.configuration;
530
+ if (options.createdAt) this.createdAt = options.createdAt;
531
+ if (options.updatedAt) this.updatedAt = options.updatedAt;
532
+ }
533
+ /**
534
+ * Get settings as parsed object
535
+ */
536
+ getSettings() {
537
+ if (!this.settings) return {};
538
+ try {
539
+ return JSON.parse(this.settings);
540
+ } catch {
541
+ return {};
542
+ }
543
+ }
544
+ /**
545
+ * Set settings from object
546
+ */
547
+ setSettings(settings) {
548
+ this.settings = JSON.stringify(settings);
549
+ }
550
+ getConfiguration() {
551
+ try {
552
+ return JSON.parse(this.configuration || "{}");
553
+ } catch {
554
+ return {};
555
+ }
556
+ }
557
+ setConfiguration(configuration) {
558
+ this.configuration = JSON.stringify(configuration);
559
+ }
560
+ get hasCredentials() {
561
+ return Boolean(this.credentialSecretId || this.settings);
562
+ }
563
+ /** Whether this account needs its sign-in entered again. */
564
+ get needsReconnect() {
565
+ return this.connectionStatus === "needs_reconnect";
566
+ }
567
+ /**
568
+ * Record that the server refused this account's sign-in, so the host can ask
569
+ * the owner to reconnect instead of failing every sync silently.
570
+ */
571
+ async markNeedsReconnect(reason) {
572
+ this.connectionStatus = "needs_reconnect";
573
+ this.statusMessage = reason.slice(0, 200);
574
+ this.updatedAt = /* @__PURE__ */ new Date();
575
+ await this.save();
576
+ }
577
+ /** Record a working sign-in (after connect, reconnect, or a good sync). */
578
+ async markConnected() {
579
+ if (this.connectionStatus === "connected" && !this.statusMessage) return;
580
+ this.connectionStatus = "connected";
581
+ this.statusMessage = null;
582
+ this.updatedAt = /* @__PURE__ */ new Date();
583
+ await this.save();
584
+ }
585
+ /**
586
+ * Activate account
587
+ */
588
+ async activate() {
589
+ this.isActive = true;
590
+ this.updatedAt = /* @__PURE__ */ new Date();
591
+ await this.save();
592
+ }
593
+ /**
594
+ * Deactivate account
595
+ */
596
+ async deactivate() {
597
+ this.isActive = false;
598
+ this.updatedAt = /* @__PURE__ */ new Date();
599
+ await this.save();
600
+ }
601
+ /**
602
+ * Store credentials securely using smrt-secrets
603
+ */
604
+ async setCredentials(credentials, options = {}) {
605
+ if (!this.id) throw new Error("Account must be persisted before storing credentials.");
606
+ const secretService = await createAccountSecretService(this.db);
607
+ const secretName = `${this.channelType || "messaging"}-account-${this.id}`;
608
+ const secretValue = JSON.stringify(credentials);
609
+ const tenantId2 = this.requireCredentialTenantId("store credentials");
610
+ await secretService.storeForTenant(tenantId2, this.credentialSecretId || secretName, secretValue, {
611
+ description: options.description || `Credentials for ${this.name}`,
612
+ category: options.category || "messaging"
613
+ });
614
+ this.credentialSecretId ||= secretName;
615
+ this.updatedAt = /* @__PURE__ */ new Date();
616
+ await this.withCredentialTenantContext(() => this.save());
617
+ }
618
+ /**
619
+ * Delete the stored credential from smrt-secrets (used when the account is
620
+ * removed, so a removed mailbox never leaves a live secret behind).
621
+ */
622
+ async removeCredentials() {
623
+ if (!this.credentialSecretId) return;
624
+ const tenantId2 = this.requireCredentialTenantId("remove credentials");
625
+ const secretService = await createAccountSecretService(this.db);
626
+ const name = this.credentialSecretId;
627
+ await withTenant({ tenantId: tenantId2 }, () => secretService.delete(name));
628
+ this.credentialSecretId = null;
629
+ }
630
+ /**
631
+ * Create a sender for this account.
632
+ * Subclasses must override to return a concrete sender.
633
+ */
634
+ async createSender() {
635
+ const { getMessagingProvider } = await import("./providers-Bz_F_ywF.js").then((n) => n.i);
636
+ const provider = getMessagingProvider(this.providerType);
637
+ if (!provider?.createSender) throw new Error(`createSender() not implemented for account type '${this.providerType}'`);
638
+ return provider.createSender(this);
639
+ }
640
+ /**
641
+ * Retrieve stored credentials
642
+ */
643
+ async getCredentials() {
644
+ if (!this.credentialSecretId) return this.getSettings();
645
+ const tenantId2 = this.requireCredentialTenantId("retrieve credentials");
646
+ const secretService = await createAccountSecretService(this.db);
647
+ try {
648
+ const secret = await secretService.retrieveForTenant(tenantId2, this.credentialSecretId);
649
+ return JSON.parse(secret.value);
650
+ } catch {
651
+ return null;
652
+ }
653
+ }
654
+ getCredentialTenantId() {
655
+ return this.tenantId || getCurrentTenant()?.tenantId || null;
656
+ }
657
+ requireCredentialTenantId(action) {
658
+ const tenantId2 = this.getCredentialTenantId();
659
+ if (!tenantId2) throw new Error(`Tenant context required to ${action}.`);
660
+ return tenantId2;
661
+ }
662
+ async withCredentialTenantContext(fn) {
663
+ const tenantId2 = this.getCredentialTenantId();
664
+ if (!tenantId2 || getCurrentTenant()?.tenantId === tenantId2) return fn();
665
+ return withTenant({ tenantId: tenantId2 }, fn);
666
+ }
667
+ };
668
+ __publicField$1(Account, "__smrtPackage__", "@happyvertical/smrt-messages");
669
+ __decorateClass$1([tenantId({ nullable: true })], Account.prototype, "tenantId", 2);
670
+ __decorateClass$1([field({ description: "The display name for this connected messaging account." })], Account.prototype, "name", 2);
671
+ __decorateClass$1([field({ description: "The service that connects this account to your application." })], Account.prototype, "providerType", 2);
672
+ __decorateClass$1([field({ description: "The kind of messaging this account supports, such as email or chat." })], Account.prototype, "channelType", 2);
673
+ __decorateClass$1([field({
674
+ sensitive: true,
675
+ readonly: true
676
+ })], Account.prototype, "credentialSecretId", 2);
677
+ __decorateClass$1([field({ description: "Whether this account is enabled for messaging." })], Account.prototype, "isActive", 2);
678
+ __decorateClass$1([crossPackageRef("@happyvertical/smrt-users:User"), field({ description: "The person who owns this account and decides who else may use it." })], Account.prototype, "ownerUserId", 2);
679
+ __decorateClass$1([field({ description: "A short name shown beside this account, such as Support or Personal." })], Account.prototype, "label", 2);
680
+ __decorateClass$1([field({ description: "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it." })], Account.prototype, "connectionStatus", 2);
681
+ __decorateClass$1([field({ description: "Why the account needs attention, in plain words." })], Account.prototype, "statusMessage", 2);
682
+ __decorateClass$1([field({ description: "When this account last checked for new messages." })], Account.prototype, "lastSyncAt", 2);
683
+ __decorateClass$1([field({
684
+ sensitive: true,
685
+ readonly: true
686
+ })], Account.prototype, "settings", 2);
687
+ __decorateClass$1([field({ description: "The public connection settings for this account; credentials are stored separately." })], Account.prototype, "configuration", 2);
688
+ __decorateClass$1([field({ description: "When this account was added." })], Account.prototype, "createdAt", 2);
689
+ __decorateClass$1([field({ description: "When this account was last changed." })], Account.prototype, "updatedAt", 2);
690
+ Account = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
691
+ tableStrategy: "sti",
692
+ api: { include: ["list", "get"] },
693
+ mcp: { include: ["list", "get"] },
694
+ cli: { include: ["list", "get"] }
695
+ })], Account);
696
+ //#endregion
697
+ //#region src/collections/AccountCollection.ts
698
+ var AccountCollection_exports = /* @__PURE__ */ __exportAll({ AccountCollection: () => AccountCollection });
699
+ var AccountCollection = class extends SmrtCollection {
700
+ static _itemClass = Account;
701
+ /**
702
+ * Get active accounts
703
+ */
704
+ async getActive() {
705
+ return await this.list({ where: { isActive: true } });
706
+ }
707
+ /**
708
+ * Get inactive accounts
709
+ */
710
+ async getInactive() {
711
+ return await this.list({ where: { isActive: false } });
712
+ }
713
+ /**
714
+ * Get accounts by provider type
715
+ */
716
+ async getByProviderType(providerType) {
717
+ return await this.list({ where: { providerType } });
718
+ }
719
+ /**
720
+ * Get accounts by STI type.
721
+ *
722
+ * Accepts either the full discriminator (e.g. "@happyvertical/smrt-messages:EmailAccount")
723
+ * or the short type name (e.g. "EmailAccount").
724
+ */
725
+ async getByType(accountType) {
726
+ if (accountType.includes(":") || accountType.startsWith("@")) return await this.list({ where: { _meta_type: accountType } });
727
+ return (await this.list({})).filter((a) => {
728
+ return (a._meta_type || "").endsWith(`:${accountType}`);
729
+ });
730
+ }
731
+ /**
732
+ * Search accounts with filters
733
+ */
734
+ async search(query, filters) {
735
+ let accounts = await this.list({});
736
+ if (query) {
737
+ const lowerQuery = query.toLowerCase();
738
+ accounts = accounts.filter((a) => a.name?.toLowerCase().includes(lowerQuery));
739
+ }
740
+ if (filters) {
741
+ if (filters.providerType) accounts = accounts.filter((a) => a.providerType === filters.providerType);
742
+ if (filters.isActive !== void 0) accounts = accounts.filter((a) => a.isActive === filters.isActive);
743
+ if (filters.accountType) accounts = accounts.filter((a) => {
744
+ return (a._meta_type || "").includes(filters.accountType);
745
+ });
746
+ }
747
+ return accounts;
748
+ }
749
+ /**
750
+ * Get account statistics
751
+ */
752
+ async getStats() {
753
+ const accounts = await this.list({});
754
+ const byType = {};
755
+ for (const account of accounts) {
756
+ const metaType = account._meta_type || "Unknown";
757
+ const shortType = metaType.split(":").pop() || metaType;
758
+ byType[shortType] = (byType[shortType] || 0) + 1;
759
+ }
760
+ return {
761
+ total: accounts.length,
762
+ active: accounts.filter((a) => a.isActive).length,
763
+ inactive: accounts.filter((a) => !a.isActive).length,
764
+ byType
765
+ };
766
+ }
767
+ async findByTenant(tenantId) {
768
+ return this.list({ where: { tenantId } });
769
+ }
770
+ async findGlobal() {
771
+ return queryGlobal(this);
772
+ }
773
+ async findWithGlobals(tenantId) {
774
+ return queryWithGlobals(this, tenantId, "Account.findWithGlobals");
775
+ }
776
+ };
777
+ //#endregion
778
+ //#region src/mail-sync.ts
779
+ var mail_sync_exports = /* @__PURE__ */ __exportAll({
780
+ applyServerMessage: () => applyServerMessage,
781
+ syncMailChanges: () => syncMailChanges
782
+ });
783
+ var DEFAULT_LIMIT = 100;
784
+ var DEFAULT_MAX_BATCHES = 500;
785
+ var PRUNE_PAGE = 500;
786
+ var lanes = /* @__PURE__ */ new Map();
787
+ async function inLane(accountId, run) {
788
+ const next = (lanes.get(accountId) ?? Promise.resolve()).then(run, run);
789
+ const tail = next.catch(() => void 0);
790
+ lanes.set(accountId, tail);
791
+ try {
792
+ return await next;
793
+ } finally {
794
+ if (lanes.get(accountId) === tail) lanes.delete(accountId);
795
+ }
796
+ }
797
+ function applyServerMessage(email, msg, location, options = {}) {
798
+ email.messageId = msg.messageId || "";
799
+ email.threadId = msg.threadId || "";
800
+ email.inReplyTo = msg.inReplyTo || "";
801
+ email.fromAddress = msg.from?.address || "";
802
+ email.fromName = msg.from?.name || "";
803
+ email.toAddresses = JSON.stringify(msg.to || []);
804
+ email.ccAddresses = JSON.stringify(msg.cc || []);
805
+ email.bccAddresses = JSON.stringify(msg.bcc || []);
806
+ email.replyToAddress = msg.replyTo?.address || "";
807
+ email.replyToName = msg.replyTo?.name || "";
808
+ email.subject = msg.subject || "";
809
+ email.date = msg.date || null;
810
+ if (!(options.keepBodies && msg.text === void 0 && msg.html === void 0)) {
811
+ email.textBody = msg.text || "";
812
+ email.htmlBody = msg.html || "";
813
+ email.body = msg.text || "";
814
+ }
815
+ email.folderId = location.folderId;
816
+ email.folderPath = location.folderPath;
817
+ email.labels = JSON.stringify(msg.labels || []);
818
+ email.flags = JSON.stringify(msg.flags || []);
819
+ email.hasAttachments = msg.attachments && msg.attachments.length > 0 || false;
820
+ email.size = msg.size || 0;
821
+ email.headers = JSON.stringify(msg.headers || {});
822
+ email.updatedAt = /* @__PURE__ */ new Date();
823
+ if (options.deriveState) {
824
+ const flags = new Set((msg.flags || []).map((f) => f.toLowerCase()));
825
+ email.isRead = flags.has("\\seen");
826
+ email.isFlagged = flags.has("\\flagged");
827
+ email.isAnswered = flags.has("\\answered");
828
+ email.isDraft = flags.has("\\draft");
829
+ }
830
+ }
831
+ async function ensureFolder(ctx, path, details = {}) {
832
+ let folder = await ctx.folders.getByPath(ctx.accountId, path);
833
+ if (!folder) {
834
+ const { EmailFolder: EmailFolderModel } = await import("./EmailFolder-Dks5clxA.js").then((n) => n.n);
835
+ folder = new (ObjectRegistry.resolveEffectiveConstructor(EmailFolderModel))({
836
+ ...ctx.childOptions,
837
+ accountId: ctx.accountId,
838
+ name: details.name || path,
839
+ path
840
+ });
841
+ await folder.initialize();
842
+ }
843
+ if (details.name !== void 0) folder.name = details.name;
844
+ if (details.delimiter !== void 0) folder.delimiter = details.delimiter;
845
+ folder.specialUse = details.specialUse ?? folder.specialUse ?? "";
846
+ if (details.subscribed !== void 0) folder.subscribed = details.subscribed;
847
+ folder.updatedAt = /* @__PURE__ */ new Date();
848
+ await folder.save();
849
+ const id = folder.id ?? "";
850
+ ctx.folderIds.set(path, id);
851
+ return id;
852
+ }
853
+ async function folderIdFor(ctx, path) {
854
+ if (!path) return "";
855
+ return ctx.folderIds.get(path) ?? await ensureFolder(ctx, path);
856
+ }
857
+ async function findByProviderId(ctx, providerMessageId) {
858
+ return await ctx.emails.list({ where: {
859
+ accountId: ctx.accountId,
860
+ providerMessageId
861
+ } });
862
+ }
863
+ async function upsertMessage(ctx, msg, touched, isChange) {
864
+ if (!msg.id) throw new Error("Mail change feed returned a message without an id");
865
+ const [existing] = await findByProviderId(ctx, msg.id);
866
+ const folderPath = msg.folder ?? msg.folders?.[0] ?? "";
867
+ const folderId = await folderIdFor(ctx, folderPath);
868
+ let email = existing;
869
+ if (!email) {
870
+ const { Email: EmailModel } = await import("./Email-CmNoK1lj.js").then((n) => n.n);
871
+ email = new (ObjectRegistry.resolveEffectiveConstructor(EmailModel))({
872
+ ...ctx.childOptions,
873
+ accountId: ctx.accountId
874
+ });
875
+ await email.initialize();
876
+ } else if (email.folderId) touched.add(email.folderId);
877
+ email.providerMessageId = msg.id;
878
+ applyServerMessage(email, msg.labels?.length || !msg.folders?.length ? msg : {
879
+ ...msg,
880
+ labels: msg.folders
881
+ }, {
882
+ folderId,
883
+ folderPath
884
+ }, {
885
+ keepBodies: isChange,
886
+ deriveState: true
887
+ });
888
+ await email.save();
889
+ if (folderId) touched.add(folderId);
890
+ }
891
+ async function removeMessages(ctx, ids, touched) {
892
+ let removed = 0;
893
+ for (const id of ids) for (const email of await findByProviderId(ctx, id)) {
894
+ if (email.folderId) touched.add(email.folderId);
895
+ await email.delete();
896
+ removed++;
897
+ }
898
+ return removed;
899
+ }
900
+ async function pruneUnseen(ctx, seen, touched) {
901
+ let removed = 0;
902
+ for (let offset = 0;; offset += PRUNE_PAGE) {
903
+ const page = await ctx.emails.list({
904
+ where: { accountId: ctx.accountId },
905
+ limit: PRUNE_PAGE,
906
+ offset
907
+ });
908
+ for (const email of page) {
909
+ if (!email.providerMessageId || seen.has(email.providerMessageId)) continue;
910
+ if (email.folderId) touched.add(email.folderId);
911
+ await email.delete();
912
+ removed++;
913
+ offset--;
914
+ }
915
+ if (page.length < PRUNE_PAGE) return removed;
916
+ }
917
+ }
918
+ async function refreshCounts(ctx, folderIds) {
919
+ for (const folderId of folderIds) {
920
+ const folder = await ctx.folders.get({ id: folderId });
921
+ if (!folder) continue;
922
+ folder.messageCount = await ctx.emails.countByFolder(folderId);
923
+ folder.unreadCount = await ctx.emails.countUnreadByFolder(folderId);
924
+ await folder.save();
925
+ }
926
+ }
927
+ async function reconcileAllCounts(ctx) {
928
+ const folders = await ctx.folders.list({ where: { accountId: ctx.accountId } });
929
+ await refreshCounts(ctx, new Set(folders.map((f) => f.id).filter((id) => !!id)));
930
+ }
931
+ async function applyBatch(ctx, batch, seen) {
932
+ const touched = /* @__PURE__ */ new Set();
933
+ for (const folder of batch.folders ?? []) await ensureFolder(ctx, folder.path, folder);
934
+ for (const msg of batch.added) {
935
+ await upsertMessage(ctx, msg, touched, false);
936
+ if (seen && msg.id) seen.add(msg.id);
937
+ }
938
+ for (const msg of batch.changed) {
939
+ await upsertMessage(ctx, msg, touched, true);
940
+ if (seen && msg.id) seen.add(msg.id);
941
+ }
942
+ const removed = await removeMessages(ctx, batch.removed, touched);
943
+ return {
944
+ added: batch.added.length,
945
+ changed: batch.changed.length,
946
+ removed,
947
+ touched
948
+ };
949
+ }
950
+ function mirrorAccountState(from, to) {
951
+ to.syncCursor = from.syncCursor;
952
+ to.lastSyncAt = from.lastSyncAt;
953
+ to.connectionStatus = from.connectionStatus;
954
+ to.statusMessage = from.statusMessage;
955
+ to.isActive = from.isActive;
956
+ to.updatedAt = from.updatedAt;
957
+ to.updated_at = from.updated_at;
958
+ }
959
+ async function persistCursor(account, cursor) {
960
+ account.syncCursor = cursor;
961
+ account.updatedAt = /* @__PURE__ */ new Date();
962
+ await account.save();
963
+ }
964
+ async function rethrowAfterAuthCheck(account, error, isAuthFailure) {
965
+ const err = error instanceof Error ? error : new Error(String(error));
966
+ if (isAuthFailure(err)) {
967
+ await account.markNeedsReconnect(err.message).catch(() => void 0);
968
+ err.retryable = false;
969
+ }
970
+ throw err;
971
+ }
972
+ async function syncMailChanges(source, options = {}, deps) {
973
+ if (!source.id) throw new Error("EmailAccount.syncChanges requires a persisted account");
974
+ const accountId = source.id;
975
+ return inLane(accountId, async () => {
976
+ const startedAt = Date.now();
977
+ const result = {
978
+ status: "synced",
979
+ batches: 0,
980
+ added: 0,
981
+ changed: 0,
982
+ removed: 0,
983
+ resynced: false,
984
+ hasMore: false,
985
+ duration: 0
986
+ };
987
+ const skip = (reason) => ({
988
+ ...result,
989
+ status: "skipped",
990
+ skipped: reason,
991
+ duration: Date.now() - startedAt
992
+ });
993
+ const { EmailAccountCollection } = await Promise.resolve().then(() => EmailAccountCollection_exports);
994
+ const account = await (await EmailAccountCollection.create(deps.childOptions)).get({ id: accountId }) ?? source;
995
+ try {
996
+ return await runLane(account);
997
+ } finally {
998
+ if (account !== source) mirrorAccountState(account, source);
999
+ }
1000
+ async function runLane(account2) {
1001
+ if (!account2.isActive) return skip("inactive");
1002
+ if (account2.needsReconnect) return skip("needs-reconnect");
1003
+ const limit = options.limit ?? DEFAULT_LIMIT;
1004
+ const maxBatches = options.maxBatches ?? DEFAULT_MAX_BATCHES;
1005
+ const client = await deps.createClient(account2);
1006
+ try {
1007
+ await client.connect();
1008
+ if (typeof client.getChanges !== "function") return skip("unsupported");
1009
+ const { EmailCollection: EmailCollectionClass } = await import("./EmailCollection-Yo2wBv_1.js").then((n) => n.n);
1010
+ const { EmailFolderCollection: FolderCollectionClass } = await import("./EmailFolderCollection-nIR4Kpcr.js").then((n) => n.n);
1011
+ const ctx = {
1012
+ account: account2,
1013
+ accountId,
1014
+ emails: await EmailCollectionClass.create(deps.childOptions),
1015
+ folders: await FolderCollectionClass.create(deps.childOptions),
1016
+ childOptions: deps.childOptions,
1017
+ folderIds: /* @__PURE__ */ new Map()
1018
+ };
1019
+ await reconcileAllCounts(ctx);
1020
+ let cursor = account2.syncCursor || void 0;
1021
+ let seen = cursor === void 0 ? /* @__PURE__ */ new Set() : null;
1022
+ while (result.batches < maxBatches) {
1023
+ const next = await client.getChanges({
1024
+ cursor,
1025
+ limit,
1026
+ includeBodies: true
1027
+ });
1028
+ if (next.status === "resync-required") {
1029
+ if (result.resynced) throw new Error(`Mail server asked for a second resync in one run (${next.reason})`);
1030
+ result.resynced = true;
1031
+ cursor = void 0;
1032
+ seen = /* @__PURE__ */ new Set();
1033
+ await persistCursor(account2, null);
1034
+ continue;
1035
+ }
1036
+ const applied = await applyBatch(ctx, next, seen);
1037
+ result.batches++;
1038
+ result.added += applied.added;
1039
+ result.changed += applied.changed;
1040
+ result.removed += applied.removed;
1041
+ if (seen && next.initial && !next.hasMore) result.removed += await pruneUnseen(ctx, seen, applied.touched);
1042
+ await refreshCounts(ctx, applied.touched);
1043
+ await persistCursor(account2, next.cursor);
1044
+ cursor = next.cursor;
1045
+ if (!next.hasMore) break;
1046
+ if (result.batches >= maxBatches) result.hasMore = true;
1047
+ }
1048
+ account2.lastSyncAt = /* @__PURE__ */ new Date();
1049
+ account2.connectionStatus = "connected";
1050
+ account2.statusMessage = null;
1051
+ account2.updatedAt = /* @__PURE__ */ new Date();
1052
+ await account2.save();
1053
+ result.duration = Date.now() - startedAt;
1054
+ return result;
1055
+ } catch (error) {
1056
+ return rethrowAfterAuthCheck(account2, error, deps.isAuthFailure);
1057
+ } finally {
1058
+ await client.disconnect().catch(() => void 0);
1059
+ }
1060
+ }
1061
+ });
1062
+ }
1063
+ //#endregion
1064
+ //#region src/models/EmailAccount.ts
1065
+ var __defProp = Object.defineProperty;
1066
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1067
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
1068
+ enumerable: true,
1069
+ configurable: true,
1070
+ writable: true,
1071
+ value
1072
+ }) : obj[key] = value;
1073
+ var __decorateClass = (decorators, target, key, kind) => {
1074
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
1075
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1076
+ if (kind && result) __defProp(target, key, result);
1077
+ return result;
1078
+ };
1079
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1080
+ function isMailAuthFailure(error) {
1081
+ const code = error?.code;
1082
+ if (code === "EAUTH" || code === "AUTHENTICATIONFAILED") return true;
1083
+ const message = error instanceof Error ? error.message : String(error);
1084
+ return /\b(auth(entication|orization)?\s*(failed|failure|error)|invalid credentials|login failed|unauthori[sz]ed|401|invalid_grant)\b/i.test(message);
1085
+ }
1086
+ var EmailAccount = class extends Account {
1087
+ email = "";
1088
+ syncIntervalMinutes = 60;
1089
+ syncCursor = null;
1090
+ constructor(options = {}) {
1091
+ super(options);
1092
+ if (options.email !== void 0) this.email = options.email;
1093
+ if (options.providerType !== void 0) this.providerType = options.providerType;
1094
+ if (options.syncIntervalMinutes !== void 0) this.syncIntervalMinutes = options.syncIntervalMinutes;
1095
+ if (options.syncCursor !== void 0) this.syncCursor = options.syncCursor || null;
1096
+ this.channelType = "email";
1097
+ }
1098
+ /**
1099
+ * Options for child rows (folders/emails) created during sync: carries the DB
1100
+ * connection + tenant context from this account, but strips this account's own
1101
+ * identity fields. When this account was hydrated from the DB, `this.options`
1102
+ * holds the account row's `id`/`slug`/`_skipLoad`; spreading those into a new
1103
+ * child would make every synced row inherit the account's primary key and
1104
+ * upsert over each other. Internal: the mail sync engine reuses it.
1105
+ */
1106
+ childOptions() {
1107
+ const rest = { ...this.options };
1108
+ delete rest.id;
1109
+ delete rest.slug;
1110
+ delete rest._skipLoad;
1111
+ return rest;
1112
+ }
1113
+ /**
1114
+ * Create a sender for this email account
1115
+ */
1116
+ async createSender() {
1117
+ const client = await this.createClient();
1118
+ await client.connect();
1119
+ const { EmailSender } = await import("./EmailSender-B-Rtq9du.js").then((n) => n.n);
1120
+ return new EmailSender(client, this);
1121
+ }
1122
+ /**
1123
+ * Create an EmailClient from stored settings
1124
+ * Retrieves credentials from smrt-secrets if credentialSecretId is set
1125
+ *
1126
+ * The client factory comes from the messaging provider registry rather than
1127
+ * a direct `@happyvertical/email` import so the email SDK
1128
+ * (googleapis/nodemailer) never becomes reachable from provider-neutral
1129
+ * consumer bundles (#1979). Server code that uses email accounts must
1130
+ * import '@happyvertical/smrt-messages/providers/email' (or
1131
+ * '/providers/all') once during startup.
1132
+ */
1133
+ async createClient() {
1134
+ const { getMessagingProvider } = await import("./providers-Bz_F_ywF.js").then((n) => n.i);
1135
+ const createEmailClient = getMessagingProvider(this.providerType)?.createEmailClient;
1136
+ if (!createEmailClient) throw new Error(`Email provider '${this.providerType}' has no client implementation registered. Import '@happyvertical/smrt-messages/providers/email' (or '/providers/all') during server startup to enable outbound email and mailbox sync.`);
1137
+ const settings = {
1138
+ ...this.getConfiguration(),
1139
+ ...await this.getCredentials() ?? {}
1140
+ };
1141
+ delete settings.email;
1142
+ if (this.providerType === "jmap") {
1143
+ const { token, username, password } = settings;
1144
+ for (const key of [
1145
+ "token",
1146
+ "username",
1147
+ "password"
1148
+ ]) delete settings[key];
1149
+ if (settings.auth === void 0) {
1150
+ if (typeof token === "string" && token) settings.auth = {
1151
+ type: "bearer",
1152
+ token
1153
+ };
1154
+ else if (typeof username === "string" && typeof password === "string") settings.auth = {
1155
+ user: username,
1156
+ pass: password
1157
+ };
1158
+ }
1159
+ }
1160
+ return await createEmailClient({
1161
+ type: this.providerType,
1162
+ ...settings
1163
+ });
1164
+ }
1165
+ /**
1166
+ * Read an immutable body/attachment-byte snapshot for an authorized intake host.
1167
+ * Does not sync, acknowledge, mark read or advance mailbox checkpoints.
1168
+ * Metadata-only providers fail explicitly; provider paths are never dereferenced.
1169
+ */
1170
+ async readIntakeMessage(locator, maxBytes, imapIdentity) {
1171
+ if (!this.id || !this.isActive || !locator) throw new Error("Email intake account unavailable");
1172
+ const client = await this.createClient();
1173
+ try {
1174
+ await client.connect();
1175
+ if (this.providerType === "imap") {
1176
+ if (!imapIdentity?.folder || !imapIdentity.uid || !Number.isSafeInteger(imapIdentity.uidValidity)) throw new Error("IMAP intake requires folder and immutable UID identity");
1177
+ if ((await client.selectFolder(imapIdentity.folder)).uidValidity !== imapIdentity.uidValidity) throw new Error("IMAP intake identity changed");
1178
+ }
1179
+ const message = await client.getMessage(locator);
1180
+ if (this.providerType === "imap" && message.id !== imapIdentity?.uid) throw new Error("IMAP intake identity changed");
1181
+ const { snapshotEmailForIntake } = await import("./intake-snapshot-B03bDtSW.js");
1182
+ return snapshotEmailForIntake(this.id, message, maxBytes);
1183
+ } finally {
1184
+ await client.disconnect();
1185
+ }
1186
+ }
1187
+ /**
1188
+ * Sync emails from the email server to the database
1189
+ */
1190
+ async syncFrom(options = {}) {
1191
+ return runWithMailSystemAccess(() => this.syncFromScoped(options));
1192
+ }
1193
+ async syncFromScoped(options) {
1194
+ const startTime = Date.now();
1195
+ const result = {
1196
+ folders: [],
1197
+ messagesProcessed: 0,
1198
+ messagesDownloaded: 0,
1199
+ messagesSkipped: 0,
1200
+ errors: [],
1201
+ duration: 0
1202
+ };
1203
+ try {
1204
+ const client = await this.createClient();
1205
+ await client.connect();
1206
+ const foldersToSync = options.folders || ["INBOX"];
1207
+ result.folders = foldersToSync;
1208
+ const { EmailCollection } = await import("./EmailCollection-Yo2wBv_1.js").then((n) => n.n);
1209
+ const { EmailFolderCollection } = await import("./EmailFolderCollection-nIR4Kpcr.js").then((n) => n.n);
1210
+ const emailCollection = await EmailCollection.create(this.options);
1211
+ const folderCollection = await EmailFolderCollection.create(this.options);
1212
+ if (!this.id) throw new Error("EmailAccount.syncFrom requires a persisted account (missing id)");
1213
+ const accountId = this.id;
1214
+ for (const folderName of foldersToSync) try {
1215
+ let folder = await folderCollection.getByPath(accountId, folderName);
1216
+ if (!folder) {
1217
+ const { EmailFolder } = await import("./EmailFolder-Dks5clxA.js").then((n) => n.n);
1218
+ folder = new (ObjectRegistry.resolveEffectiveConstructor(EmailFolder))({
1219
+ ...this.childOptions(),
1220
+ accountId,
1221
+ name: folderName,
1222
+ path: folderName
1223
+ });
1224
+ await folder.initialize();
1225
+ await folder.save();
1226
+ }
1227
+ const fetchOptions = {
1228
+ folder: folderName,
1229
+ limit: options.batchSize || 100
1230
+ };
1231
+ if (options.since) fetchOptions.since = options.since;
1232
+ if (options.before) fetchOptions.before = options.before;
1233
+ const messages = await client.fetch(fetchOptions);
1234
+ for (const msg of messages) {
1235
+ result.messagesProcessed++;
1236
+ try {
1237
+ const existingEmail = await emailCollection.getByMessageId(accountId, msg.messageId || "");
1238
+ if (existingEmail && !options.fullSync) {
1239
+ result.messagesSkipped++;
1240
+ continue;
1241
+ }
1242
+ const { Email } = await import("./Email-CmNoK1lj.js").then((n) => n.n);
1243
+ let email = existingEmail;
1244
+ if (!email) {
1245
+ email = new (ObjectRegistry.resolveEffectiveConstructor(Email))({
1246
+ ...this.childOptions(),
1247
+ accountId
1248
+ });
1249
+ await email.initialize();
1250
+ }
1251
+ applyServerMessage(email, msg, {
1252
+ folderId: folder.id ?? "",
1253
+ folderPath: folderName
1254
+ });
1255
+ await email.save();
1256
+ result.messagesDownloaded++;
1257
+ if (options.onProgress) options.onProgress({
1258
+ folder: folderName,
1259
+ processed: result.messagesProcessed,
1260
+ total: messages.length,
1261
+ downloaded: result.messagesDownloaded,
1262
+ skipped: result.messagesSkipped,
1263
+ errors: result.errors.length
1264
+ });
1265
+ } catch (error) {
1266
+ const err = error instanceof Error ? error : new Error(String(error));
1267
+ result.errors.push(err);
1268
+ if (options.onError) options.onError(err, msg);
1269
+ }
1270
+ }
1271
+ const folderId = folder.id ?? "";
1272
+ folder.messageCount = await emailCollection.countByFolder(folderId);
1273
+ folder.unreadCount = await emailCollection.countUnreadByFolder(folderId);
1274
+ await folder.save();
1275
+ } catch (error) {
1276
+ const err = error instanceof Error ? error : new Error(String(error));
1277
+ result.errors.push(err);
1278
+ if (options.onError) options.onError(err);
1279
+ }
1280
+ this.lastSyncAt = /* @__PURE__ */ new Date();
1281
+ if (!result.errors.length) {
1282
+ this.connectionStatus = "connected";
1283
+ this.statusMessage = null;
1284
+ }
1285
+ this.updatedAt = /* @__PURE__ */ new Date();
1286
+ await this.save();
1287
+ await client.disconnect();
1288
+ } catch (error) {
1289
+ const err = error instanceof Error ? error : new Error(String(error));
1290
+ result.errors.push(err);
1291
+ if (isMailAuthFailure(err)) try {
1292
+ await this.markNeedsReconnect(err.message);
1293
+ } catch {}
1294
+ if (options.onError) options.onError(err);
1295
+ }
1296
+ result.duration = Date.now() - startTime;
1297
+ return result;
1298
+ }
1299
+ /**
1300
+ * Sync new, changed and deleted mail since the last run, from the server's
1301
+ * change feed (JMAP). The feed cursor is saved on `syncCursor` only after
1302
+ * each batch has been applied; replaying a batch is harmless; a rejected
1303
+ * cursor restarts with a full pass. One run per account at a time.
1304
+ *
1305
+ * Closed accounts (inactive, or needing reconnection) are skipped. A server
1306
+ * that refuses the sign-in marks the account `needs_reconnect` and throws an
1307
+ * error flagged `retryable: false`. Every other failure throws and leaves the
1308
+ * cursor where it was, so the job can simply retry.
1309
+ *
1310
+ * This is the method the sync job runs (`enqueueMailSync`).
1311
+ */
1312
+ async syncChanges(options = {}) {
1313
+ return runWithMailSystemAccess(async () => {
1314
+ const { syncMailChanges } = await Promise.resolve().then(() => mail_sync_exports);
1315
+ return syncMailChanges(this, options, {
1316
+ createClient: (account) => account.createClient(),
1317
+ childOptions: this.childOptions(),
1318
+ isAuthFailure: isMailAuthFailure
1319
+ });
1320
+ });
1321
+ }
1322
+ /**
1323
+ * Every message in one server-side conversation, oldest first, read straight
1324
+ * from the mail server (providers with native threads, such as JMAP).
1325
+ * Returns null when the provider has no thread lookup.
1326
+ */
1327
+ async fetchThread(threadId) {
1328
+ const client = await this.createClient();
1329
+ try {
1330
+ await client.connect();
1331
+ if (typeof client.getThread !== "function") return null;
1332
+ return await client.getThread(threadId);
1333
+ } finally {
1334
+ await client.disconnect().catch(() => void 0);
1335
+ }
1336
+ }
1337
+ /**
1338
+ * Get all folders for this account
1339
+ */
1340
+ async getFolders() {
1341
+ const { EmailFolderCollection } = await import("./EmailFolderCollection-nIR4Kpcr.js").then((n) => n.n);
1342
+ return await (await EmailFolderCollection.create(this.options)).list({ where: { accountId: this.id } });
1343
+ }
1344
+ /**
1345
+ * Get all emails for this account
1346
+ */
1347
+ async getEmails(limit) {
1348
+ const { EmailCollection } = await import("./EmailCollection-Yo2wBv_1.js").then((n) => n.n);
1349
+ const collection = await EmailCollection.create(this.options);
1350
+ const options = { where: { accountId: this.id } };
1351
+ if (limit) options.limit = limit;
1352
+ return await collection.list(options);
1353
+ }
1354
+ /**
1355
+ * Get unread email count
1356
+ */
1357
+ async getUnreadCount() {
1358
+ const { EmailCollection } = await import("./EmailCollection-Yo2wBv_1.js").then((n) => n.n);
1359
+ return await (await EmailCollection.create(this.options)).countUnreadByAccount(this.id ?? "");
1360
+ }
1361
+ /**
1362
+ * Store credentials securely using smrt-secrets (email-specific)
1363
+ */
1364
+ async setCredentials(credentials, options = {}) {
1365
+ await super.setCredentials(credentials, {
1366
+ description: options.description || `Email credentials for ${this.name}`,
1367
+ category: options.category || "email"
1368
+ });
1369
+ }
1370
+ /**
1371
+ * Sync all active email accounts (for job runner)
1372
+ *
1373
+ * NOTE: This is a class-wide operation, not per-instance. It syncs ALL active
1374
+ * accounts, ignoring `this` instance. It exists as an instance method because
1375
+ * the TaskRunner dispatches via `objectType: 'EmailAccount', method: 'syncAll'`
1376
+ * which requires an instance method signature.
1377
+ */
1378
+ async syncAll(args) {
1379
+ const { EmailAccountCollection } = await Promise.resolve().then(() => EmailAccountCollection_exports);
1380
+ return (await EmailAccountCollection.create({ db: this.db })).syncAll(args);
1381
+ }
1382
+ /**
1383
+ * Migrate from plain-text settings to secrets
1384
+ */
1385
+ async migrateToSecrets() {
1386
+ if (this.credentialSecretId) return;
1387
+ const settings = this.getSettings();
1388
+ if (Object.keys(settings).length === 0) return;
1389
+ await this.setCredentials(settings, { description: `Migrated IMAP credentials for ${this.name}` });
1390
+ }
1391
+ };
1392
+ __publicField(EmailAccount, "__smrtPackage__", "@happyvertical/smrt-messages");
1393
+ __decorateClass([field({ description: "The email address associated with this mailbox." })], EmailAccount.prototype, "email", 2);
1394
+ __decorateClass([field({ description: "The time in minutes between scheduled mailbox checks." })], EmailAccount.prototype, "syncIntervalMinutes", 2);
1395
+ __decorateClass([field({
1396
+ sensitive: true,
1397
+ readonly: true,
1398
+ description: "Where the next mailbox check resumes."
1399
+ })], EmailAccount.prototype, "syncCursor", 2);
1400
+ EmailAccount = __decorateClass([smrt({
1401
+ tableStrategy: "sti",
1402
+ api: { include: ["list", "get"] },
1403
+ mcp: { include: ["list", "get"] },
1404
+ cli: { include: ["list", "get"] }
1405
+ })], EmailAccount);
1406
+ //#endregion
1407
+ //#region src/collections/EmailAccountCollection.ts
1408
+ var EmailAccountCollection_exports = /* @__PURE__ */ __exportAll({ EmailAccountCollection: () => EmailAccountCollection });
1409
+ var EmailAccountCollection = class extends AccountCollection {
1410
+ static _itemClass = EmailAccount;
1411
+ /**
1412
+ * Get account by email address
1413
+ */
1414
+ async getByEmail(email) {
1415
+ return (await this.list({ where: { email } }))[0] || null;
1416
+ }
1417
+ /**
1418
+ * Get accounts by email provider type
1419
+ */
1420
+ async getByEmailProviderType(providerType) {
1421
+ return await this.list({ where: { providerType } });
1422
+ }
1423
+ /**
1424
+ * Get active email accounts
1425
+ */
1426
+ async getActive() {
1427
+ return await this.list({ where: { isActive: true } });
1428
+ }
1429
+ /**
1430
+ * Get inactive email accounts
1431
+ */
1432
+ async getInactive() {
1433
+ return await this.list({ where: { isActive: false } });
1434
+ }
1435
+ /**
1436
+ * Get accounts that need syncing
1437
+ */
1438
+ async getNeedingSync(maxAgeMinutes = 60) {
1439
+ const allAccounts = await this.getActive();
1440
+ const cutoffTime = /* @__PURE__ */ new Date(Date.now() - maxAgeMinutes * 60 * 1e3);
1441
+ return allAccounts.filter((account) => !account.lastSyncAt || account.lastSyncAt < cutoffTime);
1442
+ }
1443
+ /**
1444
+ * Search email accounts with filters.
1445
+ * Alias: `search()` for backward compatibility.
1446
+ */
1447
+ async search(query, filters) {
1448
+ return this.searchEmailAccounts(query, filters);
1449
+ }
1450
+ /**
1451
+ * Get accounts by email provider type.
1452
+ * Alias: `getByProviderType()` for backward compatibility.
1453
+ */
1454
+ async getByProviderType(providerType) {
1455
+ return this.getByEmailProviderType(providerType);
1456
+ }
1457
+ /**
1458
+ * Get email account statistics.
1459
+ * Alias: `getStats()` for backward compatibility.
1460
+ */
1461
+ async getStats() {
1462
+ const stats = await this.getEmailStats();
1463
+ return {
1464
+ total: stats.total,
1465
+ active: stats.active,
1466
+ inactive: stats.inactive,
1467
+ byType: stats.byProvider
1468
+ };
1469
+ }
1470
+ /**
1471
+ * Search email accounts with filters
1472
+ */
1473
+ async searchEmailAccounts(query, filters) {
1474
+ let accounts = await this.list({});
1475
+ if (query) {
1476
+ const lowerQuery = query.toLowerCase();
1477
+ accounts = accounts.filter((a) => a.name?.toLowerCase().includes(lowerQuery) || a.email?.toLowerCase().includes(lowerQuery));
1478
+ }
1479
+ if (filters) {
1480
+ if (filters.providerType) accounts = accounts.filter((a) => a.providerType === filters.providerType);
1481
+ if (filters.email) {
1482
+ const emailLower = filters.email.toLowerCase();
1483
+ accounts = accounts.filter((a) => a.email?.toLowerCase().includes(emailLower));
1484
+ }
1485
+ if (filters.isActive !== void 0) accounts = accounts.filter((a) => a.isActive === filters.isActive);
1486
+ }
1487
+ return accounts;
1488
+ }
1489
+ /**
1490
+ * Sync all active email accounts
1491
+ */
1492
+ async syncAll(options) {
1493
+ const results = /* @__PURE__ */ new Map();
1494
+ const accounts = await this.getActive();
1495
+ for (const account of accounts) {
1496
+ const ea = account;
1497
+ const accountId = ea.id ?? ea.email ?? "unknown";
1498
+ try {
1499
+ await ea.syncFrom(options);
1500
+ results.set(accountId, { success: true });
1501
+ } catch (error) {
1502
+ results.set(accountId, {
1503
+ success: false,
1504
+ error: error instanceof Error ? error : new Error(String(error))
1505
+ });
1506
+ }
1507
+ }
1508
+ return results;
1509
+ }
1510
+ /**
1511
+ * Get total unread count across all email accounts
1512
+ */
1513
+ async getTotalUnreadCount() {
1514
+ const accounts = await this.getActive();
1515
+ let total = 0;
1516
+ for (const account of accounts) total += await account.getUnreadCount();
1517
+ return total;
1518
+ }
1519
+ /**
1520
+ * Get email account statistics
1521
+ */
1522
+ async getEmailStats() {
1523
+ const accounts = await this.list({});
1524
+ const byProvider = {
1525
+ smtp: 0,
1526
+ imap: 0,
1527
+ pop3: 0,
1528
+ gmail: 0,
1529
+ jmap: 0
1530
+ };
1531
+ for (const account of accounts) {
1532
+ const pt = account.providerType;
1533
+ if (pt in byProvider) byProvider[pt]++;
1534
+ }
1535
+ return {
1536
+ total: accounts.length,
1537
+ active: accounts.filter((a) => a.isActive).length,
1538
+ inactive: accounts.filter((a) => !a.isActive).length,
1539
+ byProvider
1540
+ };
1541
+ }
1542
+ async findByTenant(tenantId) {
1543
+ return this.list({ where: { tenantId } });
1544
+ }
1545
+ async findGlobal() {
1546
+ return queryGlobal(this);
1547
+ }
1548
+ async findWithGlobals(tenantId) {
1549
+ return queryWithGlobals(this, tenantId, "EmailAccount.findWithGlobals");
1550
+ }
1551
+ };
1552
+ //#endregion
1553
+ export { messagingPrincipalFromPermissions as A, runWithMailSystemAccess as C, SEND_MESSAGES_PERMISSION as D, MESSAGING_PERMISSION_DEFINITIONS as E, assertMessagingPermission as O, resetMailAccess as S, MANAGE_MESSAGE_ROUTES_PERMISSION as T, getEffectiveMailAccessConfigs as _, AccountCollection_exports as a, learnMailAccessOptions as b, MAIL_SCOPES as c, assertHydratedMailAccess as d, assertMailAccess as f, deniedMailAccountIds as g, decideMailAccess as h, AccountCollection as i, ensureMessagingPermissionsRegistered as k, MailAccessError as l, configureMailAccess as m, EmailAccountCollection_exports as n, Account as o, canAccessMailAccount as p, EmailAccount as r, MAIL_ACCOUNT_RESOURCE_TYPE as s, EmailAccountCollection as t, MailAccessService as u, inMailSystemAccess as v, MANAGE_MESSAGE_CREDENTIALS_PERMISSION as w, mailScopePermission as x, isMailScope as y };
1554
+
1555
+ //# sourceMappingURL=EmailAccountCollection-CHizpsxL.js.map