@antelopejs/dms-mailing 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +162 -0
- package/dist/antelope-modules.d.ts +32 -0
- package/dist/antelope-modules.js +36 -0
- package/dist/antelope-modules.js.map +1 -0
- package/dist/automation/email-event-trigger.d.ts +16 -0
- package/dist/automation/email-event-trigger.js +70 -0
- package/dist/automation/email-event-trigger.js.map +1 -0
- package/dist/automation/index.d.ts +4 -0
- package/dist/automation/index.js +39 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/send-template-action.d.ts +13 -0
- package/dist/automation/send-template-action.js +71 -0
- package/dist/automation/send-template-action.js.map +1 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +28 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -0
- package/dist/crons/index.d.ts +1 -0
- package/dist/crons/index.js +18 -0
- package/dist/crons/index.js.map +1 -0
- package/dist/crons/retention.d.ts +18 -0
- package/dist/crons/retention.js +107 -0
- package/dist/crons/retention.js.map +1 -0
- package/dist/data/body.d.ts +1 -0
- package/dist/data/body.js +18 -0
- package/dist/data/body.js.map +1 -0
- package/dist/data/index.d.ts +3 -0
- package/dist/data/index.js +20 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/sends-table.d.ts +28 -0
- package/dist/data/sends-table.js +161 -0
- package/dist/data/sends-table.js.map +1 -0
- package/dist/data/templates-table.d.ts +31 -0
- package/dist/data/templates-table.js +173 -0
- package/dist/data/templates-table.js.map +1 -0
- package/dist/data-types/categories-type.d.ts +35 -0
- package/dist/data-types/categories-type.js +37 -0
- package/dist/data-types/categories-type.js.map +1 -0
- package/dist/data-types/category-type.d.ts +8 -0
- package/dist/data-types/category-type.js +43 -0
- package/dist/data-types/category-type.js.map +1 -0
- package/dist/data-types/index.d.ts +2 -0
- package/dist/data-types/index.js +19 -0
- package/dist/data-types/index.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +19 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/models/index.d.ts +4 -0
- package/dist/db/models/index.js +21 -0
- package/dist/db/models/index.js.map +1 -0
- package/dist/db/models/send-events.model.d.ts +27 -0
- package/dist/db/models/send-events.model.js +35 -0
- package/dist/db/models/send-events.model.js.map +1 -0
- package/dist/db/models/sends.model.d.ts +32 -0
- package/dist/db/models/sends.model.js +115 -0
- package/dist/db/models/sends.model.js.map +1 -0
- package/dist/db/models/settings.model.d.ts +23 -0
- package/dist/db/models/settings.model.js +13 -0
- package/dist/db/models/settings.model.js.map +1 -0
- package/dist/db/models/templates.model.d.ts +23 -0
- package/dist/db/models/templates.model.js +13 -0
- package/dist/db/models/templates.model.js.map +1 -0
- package/dist/db/tables/index.d.ts +4 -0
- package/dist/db/tables/index.js +21 -0
- package/dist/db/tables/index.js.map +1 -0
- package/dist/db/tables/send-events.table.d.ts +10 -0
- package/dist/db/tables/send-events.table.js +44 -0
- package/dist/db/tables/send-events.table.js.map +1 -0
- package/dist/db/tables/sends.table.d.ts +26 -0
- package/dist/db/tables/sends.table.js +113 -0
- package/dist/db/tables/sends.table.js.map +1 -0
- package/dist/db/tables/settings.table.d.ts +15 -0
- package/dist/db/tables/settings.table.js +68 -0
- package/dist/db/tables/settings.table.js.map +1 -0
- package/dist/db/tables/templates.table.d.ts +18 -0
- package/dist/db/tables/templates.table.js +81 -0
- package/dist/db/tables/templates.table.js.map +1 -0
- package/dist/engine/conditions.d.ts +2 -0
- package/dist/engine/conditions.js +20 -0
- package/dist/engine/conditions.js.map +1 -0
- package/dist/engine/coverage.d.ts +4 -0
- package/dist/engine/coverage.js +45 -0
- package/dist/engine/coverage.js.map +1 -0
- package/dist/engine/fallback-html.d.ts +4 -0
- package/dist/engine/fallback-html.js +84 -0
- package/dist/engine/fallback-html.js.map +1 -0
- package/dist/engine/index.d.ts +7 -0
- package/dist/engine/index.js +24 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/paths.d.ts +3 -0
- package/dist/engine/paths.js +32 -0
- package/dist/engine/paths.js.map +1 -0
- package/dist/engine/resolve.d.ts +4 -0
- package/dist/engine/resolve.js +139 -0
- package/dist/engine/resolve.js.map +1 -0
- package/dist/engine/tokens.d.ts +7 -0
- package/dist/engine/tokens.js +29 -0
- package/dist/engine/tokens.js.map +1 -0
- package/dist/engine/walk.d.ts +3 -0
- package/dist/engine/walk.js +14 -0
- package/dist/engine/walk.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +18 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/tenant-export.d.ts +14 -0
- package/dist/hooks/tenant-export.js +84 -0
- package/dist/hooks/tenant-export.js.map +1 -0
- package/dist/implementations/dms-mailing/index.d.ts +2 -0
- package/dist/implementations/dms-mailing/index.js +8 -0
- package/dist/implementations/dms-mailing/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/editor.d.ts +9 -0
- package/dist/pages/editor.js +30 -0
- package/dist/pages/editor.js.map +1 -0
- package/dist/pages/index.d.ts +7 -0
- package/dist/pages/index.js +24 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/module.d.ts +1 -0
- package/dist/pages/module.js +12 -0
- package/dist/pages/module.js.map +1 -0
- package/dist/pages/overview.d.ts +14 -0
- package/dist/pages/overview.js +92 -0
- package/dist/pages/overview.js.map +1 -0
- package/dist/pages/sends.d.ts +13 -0
- package/dist/pages/sends.js +125 -0
- package/dist/pages/sends.js.map +1 -0
- package/dist/pages/settings/form.d.ts +1 -0
- package/dist/pages/settings/form.js +68 -0
- package/dist/pages/settings/form.js.map +1 -0
- package/dist/pages/settings/index.d.ts +2 -0
- package/dist/pages/settings/index.js +19 -0
- package/dist/pages/settings/index.js.map +1 -0
- package/dist/pages/settings/page.d.ts +10 -0
- package/dist/pages/settings/page.js +35 -0
- package/dist/pages/settings/page.js.map +1 -0
- package/dist/pages/templates.d.ts +10 -0
- package/dist/pages/templates.js +140 -0
- package/dist/pages/templates.js.map +1 -0
- package/dist/permissions.d.ts +1 -0
- package/dist/permissions.js +37 -0
- package/dist/permissions.js.map +1 -0
- package/dist/quick-actions.d.ts +2 -0
- package/dist/quick-actions.js +18 -0
- package/dist/quick-actions.js.map +1 -0
- package/dist/realtime.d.ts +4 -0
- package/dist/realtime.js +44 -0
- package/dist/realtime.js.map +1 -0
- package/dist/routes/events.d.ts +9 -0
- package/dist/routes/events.js +63 -0
- package/dist/routes/events.js.map +1 -0
- package/dist/routes/index.d.ts +7 -0
- package/dist/routes/index.js +24 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/metrics.d.ts +54 -0
- package/dist/routes/metrics.js +235 -0
- package/dist/routes/metrics.js.map +1 -0
- package/dist/routes/period.d.ts +5 -0
- package/dist/routes/period.js +36 -0
- package/dist/routes/period.js.map +1 -0
- package/dist/routes/provider.d.ts +13 -0
- package/dist/routes/provider.js +41 -0
- package/dist/routes/provider.js.map +1 -0
- package/dist/routes/sends.d.ts +31 -0
- package/dist/routes/sends.js +178 -0
- package/dist/routes/sends.js.map +1 -0
- package/dist/routes/settings.d.ts +14 -0
- package/dist/routes/settings.js +72 -0
- package/dist/routes/settings.js.map +1 -0
- package/dist/routes/templates.d.ts +61 -0
- package/dist/routes/templates.js +230 -0
- package/dist/routes/templates.js.map +1 -0
- package/dist/services/attention.d.ts +23 -0
- package/dist/services/attention.js +104 -0
- package/dist/services/attention.js.map +1 -0
- package/dist/services/categories.d.ts +34 -0
- package/dist/services/categories.js +34 -0
- package/dist/services/categories.js.map +1 -0
- package/dist/services/events.d.ts +10 -0
- package/dist/services/events.js +89 -0
- package/dist/services/events.js.map +1 -0
- package/dist/services/metrics.d.ts +34 -0
- package/dist/services/metrics.js +103 -0
- package/dist/services/metrics.js.map +1 -0
- package/dist/services/notify.d.ts +20 -0
- package/dist/services/notify.js +63 -0
- package/dist/services/notify.js.map +1 -0
- package/dist/services/permissions.d.ts +2 -0
- package/dist/services/permissions.js +15 -0
- package/dist/services/permissions.js.map +1 -0
- package/dist/services/provider.d.ts +6 -0
- package/dist/services/provider.js +25 -0
- package/dist/services/provider.js.map +1 -0
- package/dist/services/render.d.ts +6 -0
- package/dist/services/render.js +21 -0
- package/dist/services/render.js.map +1 -0
- package/dist/services/send.d.ts +49 -0
- package/dist/services/send.js +259 -0
- package/dist/services/send.js.map +1 -0
- package/dist/services/settings.d.ts +4 -0
- package/dist/services/settings.js +61 -0
- package/dist/services/settings.js.map +1 -0
- package/dist/services/status.d.ts +3 -0
- package/dist/services/status.js +16 -0
- package/dist/services/status.js.map +1 -0
- package/dist/services/templates.d.ts +17 -0
- package/dist/services/templates.js +92 -0
- package/dist/services/templates.js.map +1 -0
- package/dist/test/antelope.test.d.ts +2 -0
- package/dist/test/antelope.test.js +179 -0
- package/dist/test/antelope.test.js.map +1 -0
- package/dist/test/helpers/http.d.ts +4 -0
- package/dist/test/helpers/http.js +28 -0
- package/dist/test/helpers/http.js.map +1 -0
- package/dist/test/helpers/owner.d.ts +5 -0
- package/dist/test/helpers/owner.js +30 -0
- package/dist/test/helpers/owner.js.map +1 -0
- package/dist/test/integration/events.test.d.ts +1 -0
- package/dist/test/integration/events.test.js +132 -0
- package/dist/test/integration/events.test.js.map +1 -0
- package/dist/test/integration/retention.test.d.ts +1 -0
- package/dist/test/integration/retention.test.js +291 -0
- package/dist/test/integration/retention.test.js.map +1 -0
- package/dist/test/integration/sends.test.d.ts +1 -0
- package/dist/test/integration/sends.test.js +157 -0
- package/dist/test/integration/sends.test.js.map +1 -0
- package/dist/test/integration/settings.test.d.ts +1 -0
- package/dist/test/integration/settings.test.js +45 -0
- package/dist/test/integration/settings.test.js.map +1 -0
- package/dist/test/integration/setup.test.d.ts +1 -0
- package/dist/test/integration/setup.test.js +32 -0
- package/dist/test/integration/setup.test.js.map +1 -0
- package/dist/test/integration/templates.test.d.ts +1 -0
- package/dist/test/integration/templates.test.js +167 -0
- package/dist/test/integration/templates.test.js.map +1 -0
- package/dist/test/integration/tenant-export.test.d.ts +1 -0
- package/dist/test/integration/tenant-export.test.js +85 -0
- package/dist/test/integration/tenant-export.test.js.map +1 -0
- package/dist/test/unit/attention.test.d.ts +1 -0
- package/dist/test/unit/attention.test.js +109 -0
- package/dist/test/unit/attention.test.js.map +1 -0
- package/dist/test/unit/automation.test.d.ts +1 -0
- package/dist/test/unit/automation.test.js +104 -0
- package/dist/test/unit/automation.test.js.map +1 -0
- package/dist/test/unit/categories.test.d.ts +1 -0
- package/dist/test/unit/categories.test.js +38 -0
- package/dist/test/unit/categories.test.js.map +1 -0
- package/dist/test/unit/engine/conditions.test.d.ts +1 -0
- package/dist/test/unit/engine/conditions.test.js +23 -0
- package/dist/test/unit/engine/conditions.test.js.map +1 -0
- package/dist/test/unit/engine/coverage.test.d.ts +1 -0
- package/dist/test/unit/engine/coverage.test.js +106 -0
- package/dist/test/unit/engine/coverage.test.js.map +1 -0
- package/dist/test/unit/engine/fallback-html.test.d.ts +1 -0
- package/dist/test/unit/engine/fallback-html.test.js +78 -0
- package/dist/test/unit/engine/fallback-html.test.js.map +1 -0
- package/dist/test/unit/engine/paths.test.d.ts +1 -0
- package/dist/test/unit/engine/paths.test.js +33 -0
- package/dist/test/unit/engine/paths.test.js.map +1 -0
- package/dist/test/unit/engine/resolve.test.d.ts +1 -0
- package/dist/test/unit/engine/resolve.test.js +157 -0
- package/dist/test/unit/engine/resolve.test.js.map +1 -0
- package/dist/test/unit/engine/tokens.test.d.ts +1 -0
- package/dist/test/unit/engine/tokens.test.js +26 -0
- package/dist/test/unit/engine/tokens.test.js.map +1 -0
- package/dist/test/unit/events.test.d.ts +1 -0
- package/dist/test/unit/events.test.js +13 -0
- package/dist/test/unit/events.test.js.map +1 -0
- package/dist/test/unit/metrics.test.d.ts +1 -0
- package/dist/test/unit/metrics.test.js +108 -0
- package/dist/test/unit/metrics.test.js.map +1 -0
- package/dist/test/unit/notify.test.d.ts +1 -0
- package/dist/test/unit/notify.test.js +49 -0
- package/dist/test/unit/notify.test.js.map +1 -0
- package/dist/test/unit/period.test.d.ts +1 -0
- package/dist/test/unit/period.test.js +44 -0
- package/dist/test/unit/period.test.js.map +1 -0
- package/dist/test/unit/provider.test.d.ts +1 -0
- package/dist/test/unit/provider.test.js +47 -0
- package/dist/test/unit/provider.test.js.map +1 -0
- package/dist/test/unit/realtime.test.d.ts +1 -0
- package/dist/test/unit/realtime.test.js +13 -0
- package/dist/test/unit/realtime.test.js.map +1 -0
- package/dist/test/unit/render.test.d.ts +1 -0
- package/dist/test/unit/render.test.js +23 -0
- package/dist/test/unit/render.test.js.map +1 -0
- package/dist/test/unit/retention.test.d.ts +1 -0
- package/dist/test/unit/retention.test.js +66 -0
- package/dist/test/unit/retention.test.js.map +1 -0
- package/dist/test/unit/send-batch.test.d.ts +1 -0
- package/dist/test/unit/send-batch.test.js +46 -0
- package/dist/test/unit/send-batch.test.js.map +1 -0
- package/dist/test/unit/send.test.d.ts +1 -0
- package/dist/test/unit/send.test.js +120 -0
- package/dist/test/unit/send.test.js.map +1 -0
- package/dist/test/unit/smoke.test.d.ts +1 -0
- package/dist/test/unit/smoke.test.js +10 -0
- package/dist/test/unit/smoke.test.js.map +1 -0
- package/dist/test/unit/status.test.d.ts +1 -0
- package/dist/test/unit/status.test.js +16 -0
- package/dist/test/unit/status.test.js.map +1 -0
- package/dist/test/unit/templates.test.d.ts +1 -0
- package/dist/test/unit/templates.test.js +48 -0
- package/dist/test/unit/templates.test.js.map +1 -0
- package/dist/test/unit/tenant-export.test.d.ts +1 -0
- package/dist/test/unit/tenant-export.test.js +59 -0
- package/dist/test/unit/tenant-export.test.js.map +1 -0
- package/dist/test/unit/webhook-secret.test.d.ts +1 -0
- package/dist/test/unit/webhook-secret.test.js +42 -0
- package/dist/test/unit/webhook-secret.test.js.map +1 -0
- package/dist/types/blocks.d.ts +2 -0
- package/dist/types/blocks.js +3 -0
- package/dist/types/blocks.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/resolved.d.ts +68 -0
- package/dist/types/resolved.js +3 -0
- package/dist/types/resolved.js.map +1 -0
- package/dist/types/sends.d.ts +14 -0
- package/dist/types/sends.js +19 -0
- package/dist/types/sends.js.map +1 -0
- package/dist/types/settings.d.ts +16 -0
- package/dist/types/settings.js +11 -0
- package/dist/types/settings.js.map +1 -0
- package/dist/validation/settings.schema.d.ts +63 -0
- package/dist/validation/settings.schema.js +29 -0
- package/dist/validation/settings.schema.js.map +1 -0
- package/dist/validation/templates.schema.d.ts +248 -0
- package/dist/validation/templates.schema.js +126 -0
- package/dist/validation/templates.schema.js.map +1 -0
- package/frontend-vue/.editorconfig +12 -0
- package/frontend-vue/.prettierrc +11 -0
- package/frontend-vue/app/components/AttentionCard.vue +78 -0
- package/frontend-vue/app/components/CategoriesInput.vue +126 -0
- package/frontend-vue/app/components/CategoryInput.vue +67 -0
- package/frontend-vue/app/components/Editor.vue +63 -0
- package/frontend-vue/app/components/FunnelCard.vue +66 -0
- package/frontend-vue/app/components/HtmlPreviewModal.vue +20 -0
- package/frontend-vue/app/components/NewTemplateModal.vue +158 -0
- package/frontend-vue/app/components/ProviderChip.vue +39 -0
- package/frontend-vue/app/components/SendDrawer.vue +298 -0
- package/frontend-vue/app/components/TemplateCard.vue +127 -0
- package/frontend-vue/app/components/TemplateDrawer.vue +394 -0
- package/frontend-vue/app/components/TemplateGallery.vue +112 -0
- package/frontend-vue/app/components/TemplatePreviewFrame.vue +103 -0
- package/frontend-vue/app/components/TestSendModal.vue +162 -0
- package/frontend-vue/app/components/TokenText.vue +26 -0
- package/frontend-vue/app/components/blocks/Button.vue +19 -0
- package/frontend-vue/app/components/blocks/Code.vue +17 -0
- package/frontend-vue/app/components/blocks/Divider.vue +3 -0
- package/frontend-vue/app/components/blocks/Footer.vue +22 -0
- package/frontend-vue/app/components/blocks/Heading.vue +18 -0
- package/frontend-vue/app/components/blocks/Hero.vue +32 -0
- package/frontend-vue/app/components/blocks/List.vue +33 -0
- package/frontend-vue/app/components/blocks/Paragraph.vue +18 -0
- package/frontend-vue/app/components/blocks/Total.vue +18 -0
- package/frontend-vue/app/components/editor/EditorBlock.vue +121 -0
- package/frontend-vue/app/components/editor/EditorBlockList.vue +44 -0
- package/frontend-vue/app/components/editor/EditorBlockSettings.vue +186 -0
- package/frontend-vue/app/components/editor/EditorCanvas.vue +91 -0
- package/frontend-vue/app/components/editor/EditorConditionFields.vue +88 -0
- package/frontend-vue/app/components/editor/EditorDataPanel.vue +128 -0
- package/frontend-vue/app/components/editor/EditorDraftBar.vue +35 -0
- package/frontend-vue/app/components/editor/EditorIfBlock.vue +120 -0
- package/frontend-vue/app/components/editor/EditorMissingLocale.vue +62 -0
- package/frontend-vue/app/components/editor/EditorPalette.vue +62 -0
- package/frontend-vue/app/components/editor/EditorRail.vue +58 -0
- package/frontend-vue/app/components/editor/EditorSubjectSettings.vue +37 -0
- package/frontend-vue/app/components/editor/EditorTemplateSettings.vue +87 -0
- package/frontend-vue/app/components/editor/EditorTestSendModal.vue +66 -0
- package/frontend-vue/app/components/editor/EditorToolbar.vue +155 -0
- package/frontend-vue/app/components/editor/EditorVariables.vue +163 -0
- package/frontend-vue/app/components/editor/EditorWorkspace.vue +189 -0
- package/frontend-vue/app/composables/useEditorContext.ts +44 -0
- package/frontend-vue/app/composables/useMailingApi.ts +197 -0
- package/frontend-vue/app/composables/useMailingPeriodData.ts +39 -0
- package/frontend-vue/app/composables/useTemplateDrawer.ts +90 -0
- package/frontend-vue/app/composables/useTemplateEditor.ts +228 -0
- package/frontend-vue/app/emails/EmailMailingTemplate.vue +24 -0
- package/frontend-vue/app/emails/components/MailingBlocks.vue +117 -0
- package/frontend-vue/app/plugins/template-gallery-display.client.ts +14 -0
- package/frontend-vue/app/types/component.ts +29 -0
- package/frontend-vue/app/types/mailing.ts +365 -0
- package/frontend-vue/app/utils/blocks/components.ts +14 -0
- package/frontend-vue/app/utils/blocks/dnd.ts +15 -0
- package/frontend-vue/app/utils/blocks/factory.ts +100 -0
- package/frontend-vue/app/utils/blocks/fields.ts +58 -0
- package/frontend-vue/app/utils/blocks/index.ts +5 -0
- package/frontend-vue/app/utils/blocks/tree.ts +74 -0
- package/frontend-vue/app/utils/categories.ts +54 -0
- package/frontend-vue/app/utils/clone.ts +3 -0
- package/frontend-vue/app/utils/conditions.ts +50 -0
- package/frontend-vue/app/utils/editor-route.ts +18 -0
- package/frontend-vue/app/utils/gallery.ts +41 -0
- package/frontend-vue/app/utils/locales.ts +41 -0
- package/frontend-vue/app/utils/paths.ts +84 -0
- package/frontend-vue/app/utils/period.ts +23 -0
- package/frontend-vue/app/utils/testData.ts +10 -0
- package/frontend-vue/app/utils/timeline.ts +68 -0
- package/frontend-vue/app/utils/tokens.ts +24 -0
- package/frontend-vue/app/utils/variables.ts +48 -0
- package/frontend-vue/dms.email.ts +9 -0
- package/frontend-vue/dms.frontend.ts +29 -0
- package/frontend-vue/eslint.config.mjs +13 -0
- package/frontend-vue/i18n/locales/mailing-en-GB.json +397 -0
- package/frontend-vue/i18n/locales/mailing-fr-FR.json +397 -0
- package/frontend-vue/package.json +32 -0
- package/frontend-vue/pnpm-lock.yaml +6446 -0
- package/frontend-vue/pnpm-workspace.yaml +2 -0
- package/frontend-vue/tests/block-components.test.ts +14 -0
- package/frontend-vue/tests/block-fields.test.ts +23 -0
- package/frontend-vue/tests/blocks-factory.test.ts +28 -0
- package/frontend-vue/tests/blocks-tree.test.ts +49 -0
- package/frontend-vue/tests/categories.test.ts +64 -0
- package/frontend-vue/tests/conditions.test.ts +36 -0
- package/frontend-vue/tests/dnd.test.ts +11 -0
- package/frontend-vue/tests/editor-block-list.test.ts +54 -0
- package/frontend-vue/tests/editor-route.test.ts +23 -0
- package/frontend-vue/tests/email-render-cases.json +77 -0
- package/frontend-vue/tests/gallery.test.ts +39 -0
- package/frontend-vue/tests/i18n-editor.test.ts +21 -0
- package/frontend-vue/tests/i18n.test.ts +83 -0
- package/frontend-vue/tests/locales.test.ts +38 -0
- package/frontend-vue/tests/mailing-api.test.ts +10 -0
- package/frontend-vue/tests/paths.test.ts +128 -0
- package/frontend-vue/tests/period.test.ts +13 -0
- package/frontend-vue/tests/smoke.test.ts +8 -0
- package/frontend-vue/tests/template-editor.test.ts +65 -0
- package/frontend-vue/tests/test-data.test.ts +15 -0
- package/frontend-vue/tests/timeline.test.ts +29 -0
- package/frontend-vue/tests/tokens.test.ts +12 -0
- package/frontend-vue/tests/variables.test.ts +46 -0
- package/frontend-vue/vitest.config.ts +10 -0
- package/package.json +94 -0
- package/src/antelope-modules.ts +48 -0
- package/src/automation/email-event-trigger.ts +112 -0
- package/src/automation/index.ts +33 -0
- package/src/automation/send-template-action.ts +100 -0
- package/src/config.ts +15 -0
- package/src/constants.ts +42 -0
- package/src/crons/index.ts +1 -0
- package/src/crons/retention.ts +126 -0
- package/src/data/body.ts +14 -0
- package/src/data/index.ts +3 -0
- package/src/data/sends-table.ts +154 -0
- package/src/data/templates-table.ts +202 -0
- package/src/data-types/categories-type.ts +29 -0
- package/src/data-types/category-type.ts +44 -0
- package/src/data-types/index.ts +2 -0
- package/src/db/index.ts +2 -0
- package/src/db/models/index.ts +4 -0
- package/src/db/models/send-events.model.ts +46 -0
- package/src/db/models/sends.model.ts +147 -0
- package/src/db/models/settings.model.ts +12 -0
- package/src/db/models/templates.model.ts +12 -0
- package/src/db/tables/index.ts +4 -0
- package/src/db/tables/send-events.table.ts +31 -0
- package/src/db/tables/sends.table.ts +85 -0
- package/src/db/tables/settings.table.ts +49 -0
- package/src/db/tables/templates.table.ts +70 -0
- package/src/engine/conditions.ts +30 -0
- package/src/engine/coverage.ts +67 -0
- package/src/engine/fallback-html.ts +116 -0
- package/src/engine/index.ts +7 -0
- package/src/engine/paths.ts +33 -0
- package/src/engine/resolve.ts +178 -0
- package/src/engine/tokens.ts +35 -0
- package/src/engine/walk.ts +18 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/tenant-export.ts +127 -0
- package/src/implementations/dms-mailing/index.ts +2 -0
- package/src/index.ts +62 -0
- package/src/pages/editor.ts +23 -0
- package/src/pages/index.ts +11 -0
- package/src/pages/module.ts +9 -0
- package/src/pages/overview.ts +175 -0
- package/src/pages/sends.ts +174 -0
- package/src/pages/settings/form.ts +67 -0
- package/src/pages/settings/index.ts +2 -0
- package/src/pages/settings/page.ts +34 -0
- package/src/pages/templates.ts +141 -0
- package/src/permissions.ts +44 -0
- package/src/quick-actions.ts +20 -0
- package/src/realtime.ts +53 -0
- package/src/routes/events.ts +57 -0
- package/src/routes/index.ts +7 -0
- package/src/routes/metrics.ts +243 -0
- package/src/routes/period.ts +46 -0
- package/src/routes/provider.ts +31 -0
- package/src/routes/sends.ts +215 -0
- package/src/routes/settings.ts +66 -0
- package/src/routes/templates.ts +256 -0
- package/src/services/attention.ts +151 -0
- package/src/services/categories.ts +43 -0
- package/src/services/events.ts +121 -0
- package/src/services/metrics.ts +175 -0
- package/src/services/notify.ts +90 -0
- package/src/services/permissions.ts +42 -0
- package/src/services/provider.ts +46 -0
- package/src/services/render.ts +33 -0
- package/src/services/send.ts +409 -0
- package/src/services/settings.ts +74 -0
- package/src/services/status.ts +16 -0
- package/src/services/templates.ts +157 -0
- package/src/test/antelope.test.ts +188 -0
- package/src/test/helpers/http.ts +23 -0
- package/src/test/helpers/owner.ts +37 -0
- package/src/test/integration/events.test.ts +136 -0
- package/src/test/integration/retention.test.ts +363 -0
- package/src/test/integration/sends.test.ts +200 -0
- package/src/test/integration/settings.test.ts +50 -0
- package/src/test/integration/setup.test.ts +35 -0
- package/src/test/integration/templates.test.ts +229 -0
- package/src/test/integration/tenant-export.test.ts +125 -0
- package/src/test/unit/attention.test.ts +129 -0
- package/src/test/unit/automation.test.ts +130 -0
- package/src/test/unit/categories.test.ts +51 -0
- package/src/test/unit/engine/conditions.test.ts +35 -0
- package/src/test/unit/engine/coverage.test.ts +118 -0
- package/src/test/unit/engine/fallback-html.test.ts +86 -0
- package/src/test/unit/engine/paths.test.ts +39 -0
- package/src/test/unit/engine/resolve.test.ts +176 -0
- package/src/test/unit/engine/tokens.test.ts +26 -0
- package/src/test/unit/events.test.ts +19 -0
- package/src/test/unit/metrics.test.ts +170 -0
- package/src/test/unit/notify.test.ts +71 -0
- package/src/test/unit/period.test.ts +64 -0
- package/src/test/unit/provider.test.ts +57 -0
- package/src/test/unit/realtime.test.ts +11 -0
- package/src/test/unit/render.test.ts +23 -0
- package/src/test/unit/retention.test.ts +91 -0
- package/src/test/unit/send-batch.test.ts +72 -0
- package/src/test/unit/send.test.ts +161 -0
- package/src/test/unit/smoke.test.ts +8 -0
- package/src/test/unit/status.test.ts +14 -0
- package/src/test/unit/templates.test.ts +52 -0
- package/src/test/unit/tenant-export.test.ts +88 -0
- package/src/test/unit/webhook-secret.test.ts +50 -0
- package/src/types/blocks.ts +31 -0
- package/src/types/index.ts +4 -0
- package/src/types/resolved.ts +89 -0
- package/src/types/sends.ts +44 -0
- package/src/types/settings.ts +24 -0
- package/src/validation/settings.schema.ts +33 -0
- package/src/validation/templates.schema.ts +145 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { MailingSend } from "../db";
|
|
2
|
+
import {
|
|
3
|
+
BUSINESS_AUDIENCE,
|
|
4
|
+
OPERATIONAL_AUDIENCE,
|
|
5
|
+
type SendAudience,
|
|
6
|
+
type SendStatus,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
const AUDIENCE_KEEPS: Record<SendAudience, (send: MailingSend) => boolean> = {
|
|
10
|
+
[BUSINESS_AUDIENCE]: (send) => !send.isTest,
|
|
11
|
+
[OPERATIONAL_AUDIENCE]: () => true,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const AUDIENCE_BY_NAME: Record<string, SendAudience> = {
|
|
15
|
+
[BUSINESS_AUDIENCE]: BUSINESS_AUDIENCE,
|
|
16
|
+
[OPERATIONAL_AUDIENCE]: OPERATIONAL_AUDIENCE,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Named audience behind a query value; anything unknown is the business view. */
|
|
20
|
+
export function readAudience(raw: string | null | undefined): SendAudience {
|
|
21
|
+
return AUDIENCE_BY_NAME[raw ?? ""] ?? BUSINESS_AUDIENCE;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function forAudience(
|
|
25
|
+
sends: MailingSend[],
|
|
26
|
+
audience: SendAudience,
|
|
27
|
+
): MailingSend[] {
|
|
28
|
+
return sends.filter(AUDIENCE_KEEPS[audience]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Totals {
|
|
32
|
+
sends: number;
|
|
33
|
+
queued: number;
|
|
34
|
+
sent: number;
|
|
35
|
+
delivered: number;
|
|
36
|
+
opened: number;
|
|
37
|
+
clicked: number;
|
|
38
|
+
bounced: number;
|
|
39
|
+
failed: number;
|
|
40
|
+
spam: number;
|
|
41
|
+
unsubscribed: number;
|
|
42
|
+
deliverability: number;
|
|
43
|
+
openRate: number;
|
|
44
|
+
clickRate: number;
|
|
45
|
+
latencyMedian: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface SeriesPoint {
|
|
49
|
+
x: string;
|
|
50
|
+
y: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface DateRange {
|
|
54
|
+
from: Date;
|
|
55
|
+
to: Date;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const PERCENT = 100;
|
|
59
|
+
const DAY_MS = 86_400_000;
|
|
60
|
+
const DAY_KEY_LENGTH = 10;
|
|
61
|
+
const DELTA_PRECISION = 1;
|
|
62
|
+
const DELIVERED_LIKE: SendStatus[] = [
|
|
63
|
+
"delivered",
|
|
64
|
+
"opened",
|
|
65
|
+
"clicked",
|
|
66
|
+
"unsubscribed",
|
|
67
|
+
"spam",
|
|
68
|
+
];
|
|
69
|
+
const OPENED_LIKE: SendStatus[] = ["opened", "clicked"];
|
|
70
|
+
|
|
71
|
+
export const ratio = (part: number, whole: number): number =>
|
|
72
|
+
whole ? (part / whole) * PERCENT : 0;
|
|
73
|
+
|
|
74
|
+
const countIf = (
|
|
75
|
+
sends: MailingSend[],
|
|
76
|
+
predicate: (send: MailingSend) => boolean,
|
|
77
|
+
): number => sends.filter(predicate).length;
|
|
78
|
+
|
|
79
|
+
const byStatus =
|
|
80
|
+
(status: SendStatus) =>
|
|
81
|
+
(send: MailingSend): boolean =>
|
|
82
|
+
send.status === status;
|
|
83
|
+
|
|
84
|
+
function median(values: number[]): number {
|
|
85
|
+
if (!values.length) return 0;
|
|
86
|
+
const sorted = [...values].sort((left, right) => left - right);
|
|
87
|
+
return sorted[Math.floor(sorted.length / 2)] as number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function aggregate(sends: MailingSend[]): Totals {
|
|
91
|
+
const delivered = countIf(sends, (send) =>
|
|
92
|
+
DELIVERED_LIKE.includes(send.status),
|
|
93
|
+
);
|
|
94
|
+
const opened = countIf(sends, (send) => OPENED_LIKE.includes(send.status));
|
|
95
|
+
const clicked = countIf(sends, byStatus("clicked"));
|
|
96
|
+
return {
|
|
97
|
+
sends: sends.length,
|
|
98
|
+
queued: countIf(sends, byStatus("queued")),
|
|
99
|
+
sent: countIf(sends, byStatus("sent")),
|
|
100
|
+
delivered,
|
|
101
|
+
opened,
|
|
102
|
+
clicked,
|
|
103
|
+
bounced: countIf(sends, byStatus("bounced")),
|
|
104
|
+
failed: countIf(sends, byStatus("failed")),
|
|
105
|
+
spam: countIf(sends, byStatus("spam")),
|
|
106
|
+
unsubscribed: countIf(sends, byStatus("unsubscribed")),
|
|
107
|
+
deliverability: ratio(delivered, sends.length),
|
|
108
|
+
openRate: ratio(opened, delivered),
|
|
109
|
+
clickRate: ratio(clicked, delivered),
|
|
110
|
+
latencyMedian: median(sends.map((send) => send.latencyMs)),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function deltaPercent(current: number, previous: number): number {
|
|
115
|
+
if (!previous) return 0;
|
|
116
|
+
return Number(
|
|
117
|
+
(((current - previous) / previous) * PERCENT).toFixed(DELTA_PRECISION),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const dayKey = (date: Date): string =>
|
|
122
|
+
date.toISOString().slice(0, DAY_KEY_LENGTH);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* One point per day of the window, counted from the window's own boundaries.
|
|
126
|
+
*
|
|
127
|
+
* The DMS period selector cuts on *local* midnights, so a UTC+2 tenant asks for
|
|
128
|
+
* 2026-09-03T22:00Z → 2026-09-10T21:59:59.999Z. Buckets are therefore offsets
|
|
129
|
+
* from `from` rather than UTC calendar days, and each is labelled by the date at
|
|
130
|
+
* its middle, which lands on the tenant's own day for every offset strictly
|
|
131
|
+
* inside ±12 h — every inhabited zone but UTC+13/+14, where the label falls a
|
|
132
|
+
* day early. The boundaries alone cannot settle it: local midnight at UTC+13 and
|
|
133
|
+
* at UTC−11 arrive at the same instant, so the midpoint picks the reading
|
|
134
|
+
* closest to UTC.
|
|
135
|
+
*
|
|
136
|
+
* Counting whole buckets also keeps the last day: cutting the walk at `to` used
|
|
137
|
+
* to drop it, so a send made today was missing from the chart while the KPI
|
|
138
|
+
* still counted it.
|
|
139
|
+
*/
|
|
140
|
+
export function dailySeries(
|
|
141
|
+
sends: MailingSend[],
|
|
142
|
+
from: Date,
|
|
143
|
+
to: Date,
|
|
144
|
+
): SeriesPoint[] {
|
|
145
|
+
const start = from.getTime();
|
|
146
|
+
const span = to.getTime() - start;
|
|
147
|
+
const dayCount = Math.max(1, Math.ceil(span / DAY_MS));
|
|
148
|
+
const counts: number[] = Array.from({ length: dayCount }, () => 0);
|
|
149
|
+
for (const send of sends) {
|
|
150
|
+
const offset = new Date(send.createdAt).getTime() - start;
|
|
151
|
+
if (offset < 0 || offset >= dayCount * DAY_MS) continue;
|
|
152
|
+
const index = Math.floor(offset / DAY_MS);
|
|
153
|
+
counts[index] = (counts[index] ?? 0) + 1;
|
|
154
|
+
}
|
|
155
|
+
return counts.map((y, index) => ({
|
|
156
|
+
x: dayKey(new Date(start + index * DAY_MS + DAY_MS / 2)),
|
|
157
|
+
y,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function domainOf(email: string): string {
|
|
162
|
+
return email.slice(email.lastIndexOf("@") + 1).toLowerCase();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function groupBy<T>(
|
|
166
|
+
items: T[],
|
|
167
|
+
key: (item: T) => string,
|
|
168
|
+
): Map<string, T[]> {
|
|
169
|
+
const groups = new Map<string, T[]>();
|
|
170
|
+
for (const item of items) {
|
|
171
|
+
const id = key(item);
|
|
172
|
+
groups.set(id, [...(groups.get(id) ?? []), item]);
|
|
173
|
+
}
|
|
174
|
+
return groups;
|
|
175
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Logging } from "@antelopejs/interface-core/logging";
|
|
2
|
+
import { GetModel } from "@antelopejs/interface-database-decorators";
|
|
3
|
+
import { TenantMemberModel } from "@antelopejs/interface-dms/db";
|
|
4
|
+
import {
|
|
5
|
+
GeneralSubject,
|
|
6
|
+
Notification,
|
|
7
|
+
} from "@antelopejs/interface-dms/notifications";
|
|
8
|
+
import type { NotificationData } from "@antelopejs/interface-dms/notifications/types";
|
|
9
|
+
import { PROBLEM_STATUSES, type SendEventType } from "../types";
|
|
10
|
+
|
|
11
|
+
export interface BounceNotificationInput {
|
|
12
|
+
sendId: string;
|
|
13
|
+
templateSlug: string;
|
|
14
|
+
recipientEmail: string;
|
|
15
|
+
type: SendEventType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IdempotentNotificationTarget {
|
|
19
|
+
toUsersIdempotently(userIds: string[], idempotencyKey: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BounceNotificationData extends NotificationData {
|
|
23
|
+
linkTo: string;
|
|
24
|
+
params: Record<string, string | number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const SENDS_PROBLEMS_LINK = "/modules/mailing/sends?tab=problems";
|
|
28
|
+
const IDEMPOTENCY_KEY_SEPARATOR = ":";
|
|
29
|
+
const BOUNCE_ICON = "i-ph-warning";
|
|
30
|
+
const BOUNCE_TITLE = "$dms_mailing.notifications.bounce_title";
|
|
31
|
+
const BOUNCE_DESCRIPTION = "$dms_mailing.notifications.bounce_description";
|
|
32
|
+
|
|
33
|
+
export function shouldNotify(type: SendEventType): boolean {
|
|
34
|
+
return PROBLEM_STATUSES.includes(type);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function bounceNotification(
|
|
38
|
+
input: BounceNotificationInput,
|
|
39
|
+
): BounceNotificationData {
|
|
40
|
+
return {
|
|
41
|
+
icon: BOUNCE_ICON,
|
|
42
|
+
title: BOUNCE_TITLE,
|
|
43
|
+
description: BOUNCE_DESCRIPTION,
|
|
44
|
+
subject: GeneralSubject,
|
|
45
|
+
linkTo: SENDS_PROBLEMS_LINK,
|
|
46
|
+
params: { slug: input.templateSlug, email: input.recipientEmail },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function bounceIdempotencyKey(input: BounceNotificationInput): string {
|
|
51
|
+
return `${input.sendId}${IDEMPOTENCY_KEY_SEPARATOR}${input.type}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function deliverBounceNotification(
|
|
55
|
+
target: IdempotentNotificationTarget,
|
|
56
|
+
userIds: string[],
|
|
57
|
+
input: BounceNotificationInput,
|
|
58
|
+
): Promise<void> {
|
|
59
|
+
return target.toUsersIdempotently(userIds, bounceIdempotencyKey(input));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function tenantOwnerIds(tenantId: string): Promise<string[]> {
|
|
63
|
+
const owners = await GetModel(TenantMemberModel, tenantId).listOwners();
|
|
64
|
+
return owners.map((owner) => owner.userId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function notifyBounce(
|
|
68
|
+
tenantId: string,
|
|
69
|
+
input: BounceNotificationInput,
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
if (!shouldNotify(input.type)) return;
|
|
72
|
+
try {
|
|
73
|
+
const userIds = await tenantOwnerIds(tenantId);
|
|
74
|
+
if (userIds.length === 0) return;
|
|
75
|
+
const data = bounceNotification(input);
|
|
76
|
+
const notification = Notification()
|
|
77
|
+
.icon(data.icon)
|
|
78
|
+
.title(data.title)
|
|
79
|
+
.description(data.description)
|
|
80
|
+
.subject(data.subject)
|
|
81
|
+
.linkTo(data.linkTo)
|
|
82
|
+
.params(data.params)
|
|
83
|
+
.build();
|
|
84
|
+
await deliverBounceNotification(notification, userIds, input);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
Logging.Error(
|
|
87
|
+
`[dms-mailing] Failed to notify the bounce of "${input.recipientEmail}": ${String(error)}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { assert } from "@antelopejs/interface-api-util";
|
|
2
|
+
import { GetModel } from "@antelopejs/interface-database-decorators";
|
|
3
|
+
import { RoleModel, TenantMemberModel } from "@antelopejs/interface-dms/db";
|
|
4
|
+
import {
|
|
5
|
+
GetEffectiveUserPermissions,
|
|
6
|
+
HasPermission,
|
|
7
|
+
} from "@antelopejs/interface-dms/permissions";
|
|
8
|
+
import type { User } from "@antelopejs/interface-dms/auth/db";
|
|
9
|
+
import { HTTP_FORBIDDEN, MAILING_SEND_PERMISSION } from "../constants";
|
|
10
|
+
|
|
11
|
+
const MISSING_SEND_PERMISSION = "$dms_mailing.errors.missing_send_permission";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Refuses a caller who may read the mailing pages but was not granted
|
|
15
|
+
* `mailing.send`.
|
|
16
|
+
*
|
|
17
|
+
* `@AuthUserWithPermission` only accepts a page, component or action as its
|
|
18
|
+
* target, and derives the permission from the component tree — it cannot be
|
|
19
|
+
* pointed at a standalone registered permission. The sends controller is
|
|
20
|
+
* therefore gated on the page's *read* permission, and the routes that actually
|
|
21
|
+
* reach recipients add this check on top. It mirrors what the DMS guard does
|
|
22
|
+
* once it has resolved a permission id.
|
|
23
|
+
*/
|
|
24
|
+
export async function assertSendPermission(
|
|
25
|
+
user: User,
|
|
26
|
+
tenantId: string,
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
const member = await GetModel(TenantMemberModel, tenantId).getByUser(
|
|
29
|
+
user._id,
|
|
30
|
+
);
|
|
31
|
+
const permissions = await GetEffectiveUserPermissions(
|
|
32
|
+
user,
|
|
33
|
+
tenantId,
|
|
34
|
+
member?.roleIds ?? [],
|
|
35
|
+
GetModel(RoleModel, tenantId),
|
|
36
|
+
);
|
|
37
|
+
assert(
|
|
38
|
+
await HasPermission(permissions, MAILING_SEND_PERMISSION),
|
|
39
|
+
HTTP_FORBIDDEN,
|
|
40
|
+
MISSING_SEND_PERMISSION,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GetCapabilities,
|
|
3
|
+
type ProviderCapabilities,
|
|
4
|
+
} from "@antelopejs/interface-email";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How long a capability read stays good. The provider card and the Overview's
|
|
8
|
+
* attention list both ask on every request, and for a hosted provider
|
|
9
|
+
* `GetCapabilities` is a network call — but what it answers only changes when
|
|
10
|
+
* the project is reconfigured, so a short window costs nothing.
|
|
11
|
+
*/
|
|
12
|
+
export const CAPABILITIES_TTL_MS = 60_000;
|
|
13
|
+
|
|
14
|
+
type CapabilityLoader = () => Promise<ProviderCapabilities>;
|
|
15
|
+
|
|
16
|
+
interface CacheEntry {
|
|
17
|
+
at: number;
|
|
18
|
+
value: ProviderCapabilities | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let entry: CacheEntry | undefined;
|
|
22
|
+
|
|
23
|
+
/** Drops the memo so the next read hits the provider. For tests and teardown. */
|
|
24
|
+
export function resetCapabilitiesCache(): void {
|
|
25
|
+
entry = undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The provider's capabilities, or `null` when it cannot be reached. A failure
|
|
30
|
+
* is memoised too: an unreachable provider must not be retried once per request
|
|
31
|
+
* while the dashboard polls.
|
|
32
|
+
*/
|
|
33
|
+
export async function readCapabilities(
|
|
34
|
+
load: CapabilityLoader = GetCapabilities,
|
|
35
|
+
now: number = Date.now(),
|
|
36
|
+
): Promise<ProviderCapabilities | null> {
|
|
37
|
+
if (entry && now - entry.at < CAPABILITIES_TTL_MS) return entry.value;
|
|
38
|
+
try {
|
|
39
|
+
const value = await load();
|
|
40
|
+
entry = { at: now, value };
|
|
41
|
+
return value;
|
|
42
|
+
} catch {
|
|
43
|
+
entry = { at: now, value: null };
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Logging } from "@antelopejs/interface-core/logging";
|
|
2
|
+
import {
|
|
3
|
+
GenerateHtml,
|
|
4
|
+
RegisterHtmlTemplate,
|
|
5
|
+
} from "@antelopejs/interface-dms/html-render";
|
|
6
|
+
import { getConfig } from "../config";
|
|
7
|
+
import { EMAIL_TEMPLATE_NAME } from "../constants";
|
|
8
|
+
import { renderFallbackHtml } from "../engine";
|
|
9
|
+
import type { ResolvedEmail } from "../types";
|
|
10
|
+
|
|
11
|
+
/** Props the `EmailMailingTemplate` Vue component receives from the DMS renderer. */
|
|
12
|
+
export interface MailingEmailProps {
|
|
13
|
+
locale: string;
|
|
14
|
+
email: ResolvedEmail;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const MailingEmailTemplate =
|
|
18
|
+
RegisterHtmlTemplate<MailingEmailProps>(EMAIL_TEMPLATE_NAME);
|
|
19
|
+
|
|
20
|
+
export async function renderEmailHtml(
|
|
21
|
+
email: ResolvedEmail,
|
|
22
|
+
locale: string,
|
|
23
|
+
): Promise<string> {
|
|
24
|
+
if (!getConfig().useHtmlRender) return renderFallbackHtml(email, locale);
|
|
25
|
+
try {
|
|
26
|
+
return await GenerateHtml(MailingEmailTemplate, { locale, email });
|
|
27
|
+
} catch (error) {
|
|
28
|
+
Logging.Warn(
|
|
29
|
+
`[dms-mailing] html-render unavailable, using fallback: ${String(error)}`,
|
|
30
|
+
);
|
|
31
|
+
return renderFallbackHtml(email, locale);
|
|
32
|
+
}
|
|
33
|
+
}
|