@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
@@ -1,1224 +0,0 @@
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.7","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 \\"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},"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":"0ccc3936"},"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 \\"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},"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":"0ccc3936"},"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 \\"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},"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":"643e5fb5"},"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 \\"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},"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":"7838f80a"},"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 \\"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},"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":"0ccc3936"},"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."},"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 \\"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},"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":"643e5fb5"},"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."}},"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},"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},"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 \\"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},"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":"0ccc3936"},"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 \\"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},"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":"7838f80a"},"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 \\"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},"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":"0ccc3936"},"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 \\"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},"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":"362ea703"},"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 \\"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},"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":"0ccc3936"},"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 \\"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},"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":"32f5cb15"},"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 \\"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},"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":"0ccc3936"},"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 \\"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},"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":"0ccc3936"},"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"],"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-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#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-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#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-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3617, #3624, #3626, #3627)."]}}],"smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-ledgers","@happyvertical/smrt-profiles","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"],"browser":{"status":"server-only","issues":["#3617","#3624","#3626","#3627"],"via":["@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-CT0O_7wG.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-4iLula-V.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/models/EmailAccount.ts
779
- var __defProp = Object.defineProperty;
780
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
781
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
782
- enumerable: true,
783
- configurable: true,
784
- writable: true,
785
- value
786
- }) : obj[key] = value;
787
- var __decorateClass = (decorators, target, key, kind) => {
788
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
789
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
790
- if (kind && result) __defProp(target, key, result);
791
- return result;
792
- };
793
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
794
- function isMailAuthFailure(error) {
795
- const code = error?.code;
796
- if (code === "EAUTH" || code === "AUTHENTICATIONFAILED") return true;
797
- const message = error instanceof Error ? error.message : String(error);
798
- return /\b(auth(entication|orization)?\s*(failed|failure|error)|invalid credentials|login failed|unauthori[sz]ed|401|invalid_grant)\b/i.test(message);
799
- }
800
- var EmailAccount = class extends Account {
801
- email = "";
802
- syncIntervalMinutes = 60;
803
- constructor(options = {}) {
804
- super(options);
805
- if (options.email !== void 0) this.email = options.email;
806
- if (options.providerType !== void 0) this.providerType = options.providerType;
807
- if (options.syncIntervalMinutes !== void 0) this.syncIntervalMinutes = options.syncIntervalMinutes;
808
- this.channelType = "email";
809
- }
810
- /**
811
- * Options for child rows (folders/emails) created during sync: carries the DB
812
- * connection + tenant context from this account, but strips this account's own
813
- * identity fields. When this account was hydrated from the DB, `this.options`
814
- * holds the account row's `id`/`slug`/`_skipLoad`; spreading those into a new
815
- * child would make every synced row inherit the account's primary key and
816
- * upsert over each other.
817
- */
818
- childOptions() {
819
- const rest = { ...this.options };
820
- delete rest.id;
821
- delete rest.slug;
822
- delete rest._skipLoad;
823
- return rest;
824
- }
825
- /**
826
- * Create a sender for this email account
827
- */
828
- async createSender() {
829
- const client = await this.createClient();
830
- await client.connect();
831
- const { EmailSender } = await import("./EmailSender-B-Rtq9du.js").then((n) => n.n);
832
- return new EmailSender(client, this);
833
- }
834
- /**
835
- * Create an EmailClient from stored settings
836
- * Retrieves credentials from smrt-secrets if credentialSecretId is set
837
- *
838
- * The client factory comes from the messaging provider registry rather than
839
- * a direct `@happyvertical/email` import so the email SDK
840
- * (googleapis/nodemailer) never becomes reachable from provider-neutral
841
- * consumer bundles (#1979). Server code that uses email accounts must
842
- * import '@happyvertical/smrt-messages/providers/email' (or
843
- * '/providers/all') once during startup.
844
- */
845
- async createClient() {
846
- const { getMessagingProvider } = await import("./providers-4iLula-V.js").then((n) => n.i);
847
- const createEmailClient = getMessagingProvider(this.providerType)?.createEmailClient;
848
- 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.`);
849
- const settings = {
850
- ...this.getConfiguration(),
851
- ...await this.getCredentials() ?? {}
852
- };
853
- delete settings.email;
854
- return await createEmailClient({
855
- type: this.providerType,
856
- ...settings
857
- });
858
- }
859
- /**
860
- * Read an immutable body/attachment-byte snapshot for an authorized intake host.
861
- * Does not sync, acknowledge, mark read or advance mailbox checkpoints.
862
- * Metadata-only providers fail explicitly; provider paths are never dereferenced.
863
- */
864
- async readIntakeMessage(locator, maxBytes, imapIdentity) {
865
- if (!this.id || !this.isActive || !locator) throw new Error("Email intake account unavailable");
866
- const client = await this.createClient();
867
- try {
868
- await client.connect();
869
- if (this.providerType === "imap") {
870
- if (!imapIdentity?.folder || !imapIdentity.uid || !Number.isSafeInteger(imapIdentity.uidValidity)) throw new Error("IMAP intake requires folder and immutable UID identity");
871
- if ((await client.selectFolder(imapIdentity.folder)).uidValidity !== imapIdentity.uidValidity) throw new Error("IMAP intake identity changed");
872
- }
873
- const message = await client.getMessage(locator);
874
- if (this.providerType === "imap" && message.id !== imapIdentity?.uid) throw new Error("IMAP intake identity changed");
875
- const { snapshotEmailForIntake } = await import("./intake-snapshot-B03bDtSW.js");
876
- return snapshotEmailForIntake(this.id, message, maxBytes);
877
- } finally {
878
- await client.disconnect();
879
- }
880
- }
881
- /**
882
- * Sync emails from the email server to the database
883
- */
884
- async syncFrom(options = {}) {
885
- return runWithMailSystemAccess(() => this.syncFromScoped(options));
886
- }
887
- async syncFromScoped(options) {
888
- const startTime = Date.now();
889
- const result = {
890
- folders: [],
891
- messagesProcessed: 0,
892
- messagesDownloaded: 0,
893
- messagesSkipped: 0,
894
- errors: [],
895
- duration: 0
896
- };
897
- try {
898
- const client = await this.createClient();
899
- await client.connect();
900
- const foldersToSync = options.folders || ["INBOX"];
901
- result.folders = foldersToSync;
902
- const { EmailCollection } = await import("./EmailCollection-BYeuWWsP.js").then((n) => n.n);
903
- const { EmailFolderCollection } = await import("./EmailFolderCollection-DHZKwe1H.js").then((n) => n.n);
904
- const emailCollection = await EmailCollection.create(this.options);
905
- const folderCollection = await EmailFolderCollection.create(this.options);
906
- if (!this.id) throw new Error("EmailAccount.syncFrom requires a persisted account (missing id)");
907
- const accountId = this.id;
908
- for (const folderName of foldersToSync) try {
909
- let folder = await folderCollection.getByPath(accountId, folderName);
910
- if (!folder) {
911
- const { EmailFolder } = await import("./EmailFolder-UMGpXTQ7.js").then((n) => n.n);
912
- folder = new (ObjectRegistry.resolveEffectiveConstructor(EmailFolder))({
913
- ...this.childOptions(),
914
- accountId,
915
- name: folderName,
916
- path: folderName
917
- });
918
- await folder.initialize();
919
- await folder.save();
920
- }
921
- const fetchOptions = {
922
- folder: folderName,
923
- limit: options.batchSize || 100
924
- };
925
- if (options.since) fetchOptions.since = options.since;
926
- if (options.before) fetchOptions.before = options.before;
927
- const messages = await client.fetch(fetchOptions);
928
- for (const msg of messages) {
929
- result.messagesProcessed++;
930
- try {
931
- const existingEmail = await emailCollection.getByMessageId(accountId, msg.messageId || "");
932
- if (existingEmail && !options.fullSync) {
933
- result.messagesSkipped++;
934
- continue;
935
- }
936
- const { Email } = await import("./Email-DKcIiMxB.js").then((n) => n.n);
937
- let email = existingEmail;
938
- if (!email) {
939
- email = new (ObjectRegistry.resolveEffectiveConstructor(Email))({
940
- ...this.childOptions(),
941
- accountId
942
- });
943
- await email.initialize();
944
- }
945
- email.messageId = msg.messageId || "";
946
- email.threadId = msg.threadId || "";
947
- email.inReplyTo = msg.inReplyTo || "";
948
- email.fromAddress = msg.from?.address || "";
949
- email.fromName = msg.from?.name || "";
950
- email.toAddresses = JSON.stringify(msg.to || []);
951
- email.ccAddresses = JSON.stringify(msg.cc || []);
952
- email.bccAddresses = JSON.stringify(msg.bcc || []);
953
- email.replyToAddress = msg.replyTo?.address || "";
954
- email.replyToName = msg.replyTo?.name || "";
955
- email.subject = msg.subject || "";
956
- email.date = msg.date || null;
957
- email.textBody = msg.text || "";
958
- email.htmlBody = msg.html || "";
959
- email.body = msg.text || "";
960
- email.folderId = folder.id ?? "";
961
- email.folderPath = folderName;
962
- email.labels = JSON.stringify(msg.labels || []);
963
- email.flags = JSON.stringify(msg.flags || []);
964
- email.hasAttachments = msg.attachments && msg.attachments.length > 0 || false;
965
- email.size = msg.size || 0;
966
- email.headers = JSON.stringify(msg.headers || {});
967
- email.updatedAt = /* @__PURE__ */ new Date();
968
- await email.save();
969
- result.messagesDownloaded++;
970
- if (options.onProgress) options.onProgress({
971
- folder: folderName,
972
- processed: result.messagesProcessed,
973
- total: messages.length,
974
- downloaded: result.messagesDownloaded,
975
- skipped: result.messagesSkipped,
976
- errors: result.errors.length
977
- });
978
- } catch (error) {
979
- const err = error instanceof Error ? error : new Error(String(error));
980
- result.errors.push(err);
981
- if (options.onError) options.onError(err, msg);
982
- }
983
- }
984
- const folderId = folder.id ?? "";
985
- folder.messageCount = await emailCollection.countByFolder(folderId);
986
- folder.unreadCount = await emailCollection.countUnreadByFolder(folderId);
987
- await folder.save();
988
- } catch (error) {
989
- const err = error instanceof Error ? error : new Error(String(error));
990
- result.errors.push(err);
991
- if (options.onError) options.onError(err);
992
- }
993
- this.lastSyncAt = /* @__PURE__ */ new Date();
994
- if (!result.errors.length) {
995
- this.connectionStatus = "connected";
996
- this.statusMessage = null;
997
- }
998
- this.updatedAt = /* @__PURE__ */ new Date();
999
- await this.save();
1000
- await client.disconnect();
1001
- } catch (error) {
1002
- const err = error instanceof Error ? error : new Error(String(error));
1003
- result.errors.push(err);
1004
- if (isMailAuthFailure(err)) try {
1005
- await this.markNeedsReconnect(err.message);
1006
- } catch {}
1007
- if (options.onError) options.onError(err);
1008
- }
1009
- result.duration = Date.now() - startTime;
1010
- return result;
1011
- }
1012
- /**
1013
- * Get all folders for this account
1014
- */
1015
- async getFolders() {
1016
- const { EmailFolderCollection } = await import("./EmailFolderCollection-DHZKwe1H.js").then((n) => n.n);
1017
- return await (await EmailFolderCollection.create(this.options)).list({ where: { accountId: this.id } });
1018
- }
1019
- /**
1020
- * Get all emails for this account
1021
- */
1022
- async getEmails(limit) {
1023
- const { EmailCollection } = await import("./EmailCollection-BYeuWWsP.js").then((n) => n.n);
1024
- const collection = await EmailCollection.create(this.options);
1025
- const options = { where: { accountId: this.id } };
1026
- if (limit) options.limit = limit;
1027
- return await collection.list(options);
1028
- }
1029
- /**
1030
- * Get unread email count
1031
- */
1032
- async getUnreadCount() {
1033
- const { EmailCollection } = await import("./EmailCollection-BYeuWWsP.js").then((n) => n.n);
1034
- return await (await EmailCollection.create(this.options)).countUnreadByAccount(this.id ?? "");
1035
- }
1036
- /**
1037
- * Store credentials securely using smrt-secrets (email-specific)
1038
- */
1039
- async setCredentials(credentials, options = {}) {
1040
- await super.setCredentials(credentials, {
1041
- description: options.description || `Email credentials for ${this.name}`,
1042
- category: options.category || "email"
1043
- });
1044
- }
1045
- /**
1046
- * Sync all active email accounts (for job runner)
1047
- *
1048
- * NOTE: This is a class-wide operation, not per-instance. It syncs ALL active
1049
- * accounts, ignoring `this` instance. It exists as an instance method because
1050
- * the TaskRunner dispatches via `objectType: 'EmailAccount', method: 'syncAll'`
1051
- * which requires an instance method signature.
1052
- */
1053
- async syncAll(args) {
1054
- const { EmailAccountCollection } = await Promise.resolve().then(() => EmailAccountCollection_exports);
1055
- return (await EmailAccountCollection.create({ db: this.db })).syncAll(args);
1056
- }
1057
- /**
1058
- * Migrate from plain-text settings to secrets
1059
- */
1060
- async migrateToSecrets() {
1061
- if (this.credentialSecretId) return;
1062
- const settings = this.getSettings();
1063
- if (Object.keys(settings).length === 0) return;
1064
- await this.setCredentials(settings, { description: `Migrated IMAP credentials for ${this.name}` });
1065
- }
1066
- };
1067
- __publicField(EmailAccount, "__smrtPackage__", "@happyvertical/smrt-messages");
1068
- __decorateClass([field({ description: "The email address associated with this mailbox." })], EmailAccount.prototype, "email", 2);
1069
- __decorateClass([field({ description: "The time in minutes between scheduled mailbox checks." })], EmailAccount.prototype, "syncIntervalMinutes", 2);
1070
- EmailAccount = __decorateClass([smrt({
1071
- tableStrategy: "sti",
1072
- api: { include: ["list", "get"] },
1073
- mcp: { include: ["list", "get"] },
1074
- cli: { include: ["list", "get"] }
1075
- })], EmailAccount);
1076
- //#endregion
1077
- //#region src/collections/EmailAccountCollection.ts
1078
- var EmailAccountCollection_exports = /* @__PURE__ */ __exportAll({ EmailAccountCollection: () => EmailAccountCollection });
1079
- var EmailAccountCollection = class extends AccountCollection {
1080
- static _itemClass = EmailAccount;
1081
- /**
1082
- * Get account by email address
1083
- */
1084
- async getByEmail(email) {
1085
- return (await this.list({ where: { email } }))[0] || null;
1086
- }
1087
- /**
1088
- * Get accounts by email provider type
1089
- */
1090
- async getByEmailProviderType(providerType) {
1091
- return await this.list({ where: { providerType } });
1092
- }
1093
- /**
1094
- * Get active email accounts
1095
- */
1096
- async getActive() {
1097
- return await this.list({ where: { isActive: true } });
1098
- }
1099
- /**
1100
- * Get inactive email accounts
1101
- */
1102
- async getInactive() {
1103
- return await this.list({ where: { isActive: false } });
1104
- }
1105
- /**
1106
- * Get accounts that need syncing
1107
- */
1108
- async getNeedingSync(maxAgeMinutes = 60) {
1109
- const allAccounts = await this.getActive();
1110
- const cutoffTime = /* @__PURE__ */ new Date(Date.now() - maxAgeMinutes * 60 * 1e3);
1111
- return allAccounts.filter((account) => !account.lastSyncAt || account.lastSyncAt < cutoffTime);
1112
- }
1113
- /**
1114
- * Search email accounts with filters.
1115
- * Alias: `search()` for backward compatibility.
1116
- */
1117
- async search(query, filters) {
1118
- return this.searchEmailAccounts(query, filters);
1119
- }
1120
- /**
1121
- * Get accounts by email provider type.
1122
- * Alias: `getByProviderType()` for backward compatibility.
1123
- */
1124
- async getByProviderType(providerType) {
1125
- return this.getByEmailProviderType(providerType);
1126
- }
1127
- /**
1128
- * Get email account statistics.
1129
- * Alias: `getStats()` for backward compatibility.
1130
- */
1131
- async getStats() {
1132
- const stats = await this.getEmailStats();
1133
- return {
1134
- total: stats.total,
1135
- active: stats.active,
1136
- inactive: stats.inactive,
1137
- byType: stats.byProvider
1138
- };
1139
- }
1140
- /**
1141
- * Search email accounts with filters
1142
- */
1143
- async searchEmailAccounts(query, filters) {
1144
- let accounts = await this.list({});
1145
- if (query) {
1146
- const lowerQuery = query.toLowerCase();
1147
- accounts = accounts.filter((a) => a.name?.toLowerCase().includes(lowerQuery) || a.email?.toLowerCase().includes(lowerQuery));
1148
- }
1149
- if (filters) {
1150
- if (filters.providerType) accounts = accounts.filter((a) => a.providerType === filters.providerType);
1151
- if (filters.email) {
1152
- const emailLower = filters.email.toLowerCase();
1153
- accounts = accounts.filter((a) => a.email?.toLowerCase().includes(emailLower));
1154
- }
1155
- if (filters.isActive !== void 0) accounts = accounts.filter((a) => a.isActive === filters.isActive);
1156
- }
1157
- return accounts;
1158
- }
1159
- /**
1160
- * Sync all active email accounts
1161
- */
1162
- async syncAll(options) {
1163
- const results = /* @__PURE__ */ new Map();
1164
- const accounts = await this.getActive();
1165
- for (const account of accounts) {
1166
- const ea = account;
1167
- const accountId = ea.id ?? ea.email ?? "unknown";
1168
- try {
1169
- await ea.syncFrom(options);
1170
- results.set(accountId, { success: true });
1171
- } catch (error) {
1172
- results.set(accountId, {
1173
- success: false,
1174
- error: error instanceof Error ? error : new Error(String(error))
1175
- });
1176
- }
1177
- }
1178
- return results;
1179
- }
1180
- /**
1181
- * Get total unread count across all email accounts
1182
- */
1183
- async getTotalUnreadCount() {
1184
- const accounts = await this.getActive();
1185
- let total = 0;
1186
- for (const account of accounts) total += await account.getUnreadCount();
1187
- return total;
1188
- }
1189
- /**
1190
- * Get email account statistics
1191
- */
1192
- async getEmailStats() {
1193
- const accounts = await this.list({});
1194
- const byProvider = {
1195
- smtp: 0,
1196
- imap: 0,
1197
- pop3: 0,
1198
- gmail: 0
1199
- };
1200
- for (const account of accounts) {
1201
- const pt = account.providerType;
1202
- if (pt in byProvider) byProvider[pt]++;
1203
- }
1204
- return {
1205
- total: accounts.length,
1206
- active: accounts.filter((a) => a.isActive).length,
1207
- inactive: accounts.filter((a) => !a.isActive).length,
1208
- byProvider
1209
- };
1210
- }
1211
- async findByTenant(tenantId) {
1212
- return this.list({ where: { tenantId } });
1213
- }
1214
- async findGlobal() {
1215
- return queryGlobal(this);
1216
- }
1217
- async findWithGlobals(tenantId) {
1218
- return queryWithGlobals(this, tenantId, "EmailAccount.findWithGlobals");
1219
- }
1220
- };
1221
- //#endregion
1222
- 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 };
1223
-
1224
- //# sourceMappingURL=EmailAccountCollection-DtCuHcB4.js.map