{"version":3,"file":"send.mjs","names":["emailServices.sendExternal"],"sources":["../../../../src/libs/toolkit/email/send.ts"],"sourcesContent":["import { emailServices } from \"../../../services/index.js\";\nimport type { Email } from \"../../../types/response.js\";\nimport type {\n\tServiceContext,\n\tServiceResponse,\n} from \"../../../utils/services/types.js\";\nimport type { EmailStorageConfig } from \"../../email/storage/types.js\";\nimport type {\n\tEmailAttachment,\n\tEmailPriority,\n\tEmailSubject,\n} from \"../../email/types.js\";\nimport type { ToolkitTenantOptions } from \"../types.js\";\nimport { runToolkitService } from \"../utils.js\";\n\nexport type ToolkitEmailSendInput = ToolkitTenantOptions & {\n\tto: string;\n\tsubject: EmailSubject;\n\ttemplate: string;\n\tcc?: string;\n\tbcc?: string;\n\treplyTo?: string;\n\tpriority?: EmailPriority;\n\tattachments?: EmailAttachment[];\n\tdata: Record<string, unknown>;\n\tstorage?: EmailStorageConfig;\n\tfrom?: {\n\t\temail?: string;\n\t\tname?: string;\n\t};\n};\n\nexport type ToolkitEmailSendResult = {\n\tjobId: string;\n\temail: Email;\n};\n\nconst send = async (\n\tcontext: ServiceContext,\n\tinput: ToolkitEmailSendInput,\n): ServiceResponse<ToolkitEmailSendResult> => {\n\treturn runToolkitService(\n\t\t() =>\n\t\t\temailServices.sendExternal(context, {\n\t\t\t\tto: input.to,\n\t\t\t\tsubject: input.subject,\n\t\t\t\ttemplate: input.template,\n\t\t\t\tcc: input.cc,\n\t\t\t\tbcc: input.bcc,\n\t\t\t\treplyTo: input.replyTo,\n\t\t\t\tpriority: input.priority,\n\t\t\t\tattachments: input.attachments,\n\t\t\t\tdata: input.data,\n\t\t\t\tstorage: input.storage,\n\t\t\t\ttenantKey: input.tenantKey,\n\t\t\t\tfrom: input.from,\n\t\t\t}),\n\t\t{\n\t\t\tname: {\n\t\t\t\tkey: \"core.toolkit.email.send.error.name\",\n\t\t\t\tdefaultMessage: \"Email Toolkit Error\",\n\t\t\t},\n\t\t\tmessage: {\n\t\t\t\tkey: \"core.toolkit.email.send.error.message\",\n\t\t\t\tdefaultMessage: \"Lucid toolkit could not send the email.\",\n\t\t\t},\n\t\t},\n\t);\n};\n\nexport default send;\n"],"mappings":"0GAqCA,MAAM,EAAO,MACZ,EACA,IAEO,MAELA,EAA2B,EAAS,CACnC,GAAI,EAAM,GACV,QAAS,EAAM,QACf,SAAU,EAAM,SAChB,GAAI,EAAM,GACV,IAAK,EAAM,IACX,QAAS,EAAM,QACf,SAAU,EAAM,SAChB,YAAa,EAAM,YACnB,KAAM,EAAM,KACZ,QAAS,EAAM,QACf,UAAW,EAAM,UACjB,KAAM,EAAM,IACb,CAAC,EACF,CACC,KAAM,CACL,IAAK,qCACL,eAAgB,qBACjB,EACA,QAAS,CACR,IAAK,wCACL,eAAgB,yCACjB,CACD,CACD"}