@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,116 @@
|
|
|
1
|
+
import type { ResolvedBlock, ResolvedEmail } from "../types";
|
|
2
|
+
|
|
3
|
+
const ESCAPES: Record<string, string> = {
|
|
4
|
+
"&": "&",
|
|
5
|
+
"<": "<",
|
|
6
|
+
">": ">",
|
|
7
|
+
'"': """,
|
|
8
|
+
"'": "'",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const escapeHtml = (value: string): string =>
|
|
12
|
+
value.replace(/[&<>"']/g, (char) => ESCAPES[char] ?? char);
|
|
13
|
+
|
|
14
|
+
const SAFE_SCHEMES = ["http:", "https:", "mailto:"];
|
|
15
|
+
const BLOCKED_HREF = "#";
|
|
16
|
+
const SCHEME_PATTERN = /^\s*([a-z][a-z0-9+.-]*):/i;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A link target can be an interpolated variable, so it is data the sender does
|
|
20
|
+
* not control. Escaping the entities keeps it inside the attribute; this keeps
|
|
21
|
+
* the scheme to one a mail client may follow. A target with no scheme is
|
|
22
|
+
* relative (or still an unresolved token) and passes through.
|
|
23
|
+
*/
|
|
24
|
+
export const safeUrl = (value: string): string => {
|
|
25
|
+
const scheme = SCHEME_PATTERN.exec(value);
|
|
26
|
+
if (!scheme) return value;
|
|
27
|
+
return SAFE_SCHEMES.includes(scheme[1]!.toLowerCase() + ":")
|
|
28
|
+
? value
|
|
29
|
+
: BLOCKED_HREF;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const FONT =
|
|
33
|
+
"font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif";
|
|
34
|
+
const TEXT_COLOR = "#4c545c";
|
|
35
|
+
const HEADING_COLOR = "#16181b";
|
|
36
|
+
const BORDER_COLOR = "#e7e9ec";
|
|
37
|
+
const MUTED_COLOR = "#98a0a8";
|
|
38
|
+
const SURFACE_COLOR = "#f7f8fa";
|
|
39
|
+
const BUTTON_STYLE =
|
|
40
|
+
"display:inline-block;padding:12px 22px;border-radius:6px;background:#111417;color:#ffffff;text-decoration:none;font-weight:600";
|
|
41
|
+
const CONTENT_WIDTH = 600;
|
|
42
|
+
|
|
43
|
+
type BlockHtml = (block: ResolvedBlock) => string;
|
|
44
|
+
|
|
45
|
+
const link = (label: string, href: string): string =>
|
|
46
|
+
href
|
|
47
|
+
? `<a href="${escapeHtml(safeUrl(href))}" style="color:${TEXT_COLOR}">${escapeHtml(label)}</a>`
|
|
48
|
+
: "";
|
|
49
|
+
|
|
50
|
+
const cellStyle = (weight: string, color: string): string =>
|
|
51
|
+
`${FONT};font-size:13px;font-weight:${weight};padding:11px 14px;color:${color}`;
|
|
52
|
+
|
|
53
|
+
const TEXT_RENDERERS: Record<string, BlockHtml> = {
|
|
54
|
+
heading: (block) =>
|
|
55
|
+
block.type === "heading"
|
|
56
|
+
? `<h1 style="${FONT};font-size:${block.size}px;color:${HEADING_COLOR};text-align:${block.align};margin:0 0 12px">${escapeHtml(block.text)}</h1>`
|
|
57
|
+
: "",
|
|
58
|
+
paragraph: (block) =>
|
|
59
|
+
block.type === "paragraph"
|
|
60
|
+
? `<p style="${FONT};font-size:14px;line-height:1.6;color:${TEXT_COLOR};text-align:${block.align};margin:0 0 18px">${escapeHtml(block.text)}</p>`
|
|
61
|
+
: "",
|
|
62
|
+
code: (block) =>
|
|
63
|
+
block.type === "code"
|
|
64
|
+
? `<div style="${FONT};font-size:27px;letter-spacing:.32em;text-align:center;padding:18px;border:1px dashed ${BORDER_COLOR};border-radius:8px;margin:0 0 16px">${escapeHtml(block.text)}</div>`
|
|
65
|
+
: "",
|
|
66
|
+
button: (block) =>
|
|
67
|
+
block.type === "button"
|
|
68
|
+
? `<div style="text-align:${block.align};margin:0 0 18px"><a href="${escapeHtml(safeUrl(block.href))}" style="${FONT};${BUTTON_STYLE}">${escapeHtml(block.text)}</a></div>`
|
|
69
|
+
: "",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const LAYOUT_RENDERERS: Record<string, BlockHtml> = {
|
|
73
|
+
hero: (block) =>
|
|
74
|
+
block.type === "hero" && block.imageUrl
|
|
75
|
+
? `<img src="${escapeHtml(safeUrl(block.imageUrl))}" alt="${escapeHtml(block.alt)}" style="display:block;width:100%;border-radius:8px;margin:0 0 20px">`
|
|
76
|
+
: "",
|
|
77
|
+
list: (block) =>
|
|
78
|
+
block.type === "list"
|
|
79
|
+
? `<table role="presentation" width="100%" style="border:1px solid ${BORDER_COLOR};border-radius:8px;margin:0 0 18px">${block.rows
|
|
80
|
+
.map(
|
|
81
|
+
(row) =>
|
|
82
|
+
`<tr><td style="${cellStyle("400", TEXT_COLOR)}">${escapeHtml(row.label)}</td><td align="right" style="${cellStyle("400", HEADING_COLOR)}">${escapeHtml(row.value)}</td></tr>`,
|
|
83
|
+
)
|
|
84
|
+
.join("")}</table>`
|
|
85
|
+
: "",
|
|
86
|
+
total: (block) =>
|
|
87
|
+
block.type === "total"
|
|
88
|
+
? `<table role="presentation" width="100%" style="margin:0 0 18px"><tr><td style="${cellStyle("600", HEADING_COLOR)};background:${SURFACE_COLOR}">${escapeHtml(block.label)}</td><td align="right" style="${cellStyle("600", HEADING_COLOR)};background:${SURFACE_COLOR}">${escapeHtml(block.value)}</td></tr></table>`
|
|
89
|
+
: "",
|
|
90
|
+
divider: () =>
|
|
91
|
+
`<hr style="border:0;border-top:1px solid ${BORDER_COLOR};margin:10px 0 18px">`,
|
|
92
|
+
footer: (block) =>
|
|
93
|
+
block.type === "footer"
|
|
94
|
+
? `<div style="${FONT};font-size:11px;line-height:1.6;color:${MUTED_COLOR};border-top:1px solid ${BORDER_COLOR};padding:16px 0 0">${escapeHtml(block.text)}<br>${[
|
|
95
|
+
link(block.unsubscribeLabel, block.unsubscribeUrl),
|
|
96
|
+
link(block.preferencesLabel, block.preferencesUrl),
|
|
97
|
+
]
|
|
98
|
+
.filter(Boolean)
|
|
99
|
+
.join(" · ")}</div>`
|
|
100
|
+
: "",
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const RENDERERS: Record<ResolvedBlock["type"], BlockHtml> = {
|
|
104
|
+
...TEXT_RENDERERS,
|
|
105
|
+
...LAYOUT_RENDERERS,
|
|
106
|
+
} as Record<ResolvedBlock["type"], BlockHtml>;
|
|
107
|
+
|
|
108
|
+
export function renderFallbackHtml(
|
|
109
|
+
email: ResolvedEmail,
|
|
110
|
+
locale: string,
|
|
111
|
+
): string {
|
|
112
|
+
const body = email.blocks
|
|
113
|
+
.map((block) => RENDERERS[block.type](block))
|
|
114
|
+
.join("");
|
|
115
|
+
return `<!DOCTYPE html><html lang="${escapeHtml(locale)}"><head><meta charset="utf-8"><title>${escapeHtml(email.subject)}</title></head><body style="margin:0;background:${SURFACE_COLOR}"><span style="display:none;max-height:0;overflow:hidden">${escapeHtml(email.preheader)}</span><table role="presentation" width="100%"><tr><td align="center" style="padding:26px"><table role="presentation" width="${CONTENT_WIDTH}" style="max-width:${CONTENT_WIDTH}px;background:#ffffff;border-radius:10px"><tr><td style="padding:26px">${body}</td></tr></table></td></tr></table></body></html>`;
|
|
116
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const PATH_SEPARATOR = ".";
|
|
2
|
+
const ARRAY_SUFFIX = "[]";
|
|
3
|
+
|
|
4
|
+
export function normalizePath(path: string): string {
|
|
5
|
+
const trimmed = path.trim();
|
|
6
|
+
return trimmed.endsWith(ARRAY_SUFFIX)
|
|
7
|
+
? trimmed.slice(0, -ARRAY_SUFFIX.length)
|
|
8
|
+
: trimmed;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Segments that would leave the data and walk the prototype chain. A path is
|
|
13
|
+
* authored rather than recipient-supplied, but `{{constructor}}` still resolved
|
|
14
|
+
* to the Object constructor and stringified its source into the e-mail.
|
|
15
|
+
*/
|
|
16
|
+
const RESERVED_SEGMENTS = ["__proto__", "constructor", "prototype"];
|
|
17
|
+
|
|
18
|
+
function readSegment(current: unknown, segment: string): unknown {
|
|
19
|
+
if (current === null || current === undefined) return undefined;
|
|
20
|
+
if (typeof current !== "object") return undefined;
|
|
21
|
+
if (RESERVED_SEGMENTS.includes(segment)) return undefined;
|
|
22
|
+
return (current as Record<string, unknown>)[segment];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getPath(data: unknown, path: string): unknown {
|
|
26
|
+
return normalizePath(path)
|
|
27
|
+
.split(PATH_SEPARATOR)
|
|
28
|
+
.reduce<unknown>(readSegment, data);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isPresent(value: unknown): boolean {
|
|
32
|
+
return value !== undefined && value !== null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { SYSTEM_VARIABLE_PATHS } from "../constants";
|
|
2
|
+
import type {
|
|
3
|
+
Block,
|
|
4
|
+
IfBlock,
|
|
5
|
+
ListBlock,
|
|
6
|
+
LocaleContent,
|
|
7
|
+
ResolvedBlock,
|
|
8
|
+
ResolvedEmail,
|
|
9
|
+
ResolvedListRow,
|
|
10
|
+
} from "../types";
|
|
11
|
+
import { evaluateCondition } from "./conditions";
|
|
12
|
+
import { getPath, isPresent } from "./paths";
|
|
13
|
+
import { interpolate } from "./tokens";
|
|
14
|
+
|
|
15
|
+
type Data = Record<string, unknown>;
|
|
16
|
+
|
|
17
|
+
interface ResolveState {
|
|
18
|
+
data: Data;
|
|
19
|
+
missing: Set<string>;
|
|
20
|
+
hidden: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type BlockResolver = (block: Block, state: ResolveState) => ResolvedBlock[];
|
|
24
|
+
|
|
25
|
+
function text(state: ResolveState, value: string): string {
|
|
26
|
+
const result = interpolate(value, state.data);
|
|
27
|
+
for (const path of result.missing) state.missing.add(path);
|
|
28
|
+
return result.text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function systemUrl(state: ResolveState, path: string): string {
|
|
32
|
+
const value = getPath(state.data, path);
|
|
33
|
+
return isPresent(value) ? String(value) : "";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function cell(item: unknown, path: string): string {
|
|
37
|
+
const value = getPath(item, path);
|
|
38
|
+
return isPresent(value) ? String(value) : "";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function listRows(block: ListBlock, state: ResolveState): ResolvedListRow[] {
|
|
42
|
+
const source = getPath(state.data, block.source);
|
|
43
|
+
if (!Array.isArray(source)) {
|
|
44
|
+
state.missing.add(block.source);
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return source.map((item) => ({
|
|
48
|
+
label: cell(item, block.labelPath),
|
|
49
|
+
value: cell(item, block.valuePath),
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function branch(block: IfBlock, state: ResolveState): ResolvedBlock[] {
|
|
54
|
+
const isTrue = evaluateCondition(block.condition, state.data);
|
|
55
|
+
const chosen = isTrue ? block.children : (block.elseChildren ?? []);
|
|
56
|
+
const skipped = isTrue ? (block.elseChildren ?? []) : block.children;
|
|
57
|
+
for (const child of skipped) state.hidden.push(child.id);
|
|
58
|
+
return resolveBlocks(chosen, state);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const RESOLVERS: Record<Block["type"], BlockResolver> = {
|
|
62
|
+
hero: (block, state) =>
|
|
63
|
+
block.type === "hero"
|
|
64
|
+
? [
|
|
65
|
+
{
|
|
66
|
+
id: block.id,
|
|
67
|
+
type: "hero",
|
|
68
|
+
imageUrl: text(state, block.imageUrl),
|
|
69
|
+
alt: text(state, block.alt),
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
: [],
|
|
73
|
+
heading: (block, state) =>
|
|
74
|
+
block.type === "heading"
|
|
75
|
+
? [
|
|
76
|
+
{
|
|
77
|
+
id: block.id,
|
|
78
|
+
type: "heading",
|
|
79
|
+
text: text(state, block.text),
|
|
80
|
+
align: block.align,
|
|
81
|
+
size: block.size,
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
: [],
|
|
85
|
+
paragraph: (block, state) =>
|
|
86
|
+
block.type === "paragraph"
|
|
87
|
+
? [
|
|
88
|
+
{
|
|
89
|
+
id: block.id,
|
|
90
|
+
type: "paragraph",
|
|
91
|
+
text: text(state, block.text),
|
|
92
|
+
align: block.align,
|
|
93
|
+
},
|
|
94
|
+
]
|
|
95
|
+
: [],
|
|
96
|
+
code: (block, state) =>
|
|
97
|
+
block.type === "code"
|
|
98
|
+
? [{ id: block.id, type: "code", text: text(state, block.text) }]
|
|
99
|
+
: [],
|
|
100
|
+
list: (block, state) =>
|
|
101
|
+
block.type === "list"
|
|
102
|
+
? [{ id: block.id, type: "list", rows: listRows(block, state) }]
|
|
103
|
+
: [],
|
|
104
|
+
total: (block, state) =>
|
|
105
|
+
block.type === "total"
|
|
106
|
+
? [
|
|
107
|
+
{
|
|
108
|
+
id: block.id,
|
|
109
|
+
type: "total",
|
|
110
|
+
label: text(state, block.label),
|
|
111
|
+
value: text(state, block.value),
|
|
112
|
+
},
|
|
113
|
+
]
|
|
114
|
+
: [],
|
|
115
|
+
button: (block, state) =>
|
|
116
|
+
block.type === "button"
|
|
117
|
+
? [
|
|
118
|
+
{
|
|
119
|
+
id: block.id,
|
|
120
|
+
type: "button",
|
|
121
|
+
text: text(state, block.text),
|
|
122
|
+
href: text(state, block.href),
|
|
123
|
+
align: block.align,
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
: [],
|
|
127
|
+
if: (block, state) => (block.type === "if" ? branch(block, state) : []),
|
|
128
|
+
divider: (block) => [{ id: block.id, type: "divider" }],
|
|
129
|
+
footer: (block, state) =>
|
|
130
|
+
block.type === "footer"
|
|
131
|
+
? [
|
|
132
|
+
{
|
|
133
|
+
id: block.id,
|
|
134
|
+
type: "footer",
|
|
135
|
+
text: text(state, block.text),
|
|
136
|
+
unsubscribeLabel: block.unsubscribeLabel,
|
|
137
|
+
preferencesLabel: block.preferencesLabel,
|
|
138
|
+
unsubscribeUrl: systemUrl(state, "unsubscribeUrl"),
|
|
139
|
+
preferencesUrl: systemUrl(state, "preferencesUrl"),
|
|
140
|
+
},
|
|
141
|
+
]
|
|
142
|
+
: [],
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
function resolveBlocks(blocks: Block[], state: ResolveState): ResolvedBlock[] {
|
|
146
|
+
return blocks.flatMap((block) => {
|
|
147
|
+
// Visibility decides before the block is resolved, not after. Resolving
|
|
148
|
+
// first recorded the block's unresolved paths in `state.missing` even
|
|
149
|
+
// though it was then discarded — and `blockOnMissingVariables` refuses a
|
|
150
|
+
// send on that set, so a hidden block could block a send over a variable
|
|
151
|
+
// it never rendered.
|
|
152
|
+
if (block.visibleIf && !evaluateCondition(block.visibleIf, state.data)) {
|
|
153
|
+
state.hidden.push(block.id);
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
return RESOLVERS[block.type](block, state);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const isUserPath = (path: string): boolean =>
|
|
161
|
+
!SYSTEM_VARIABLE_PATHS.includes(path);
|
|
162
|
+
|
|
163
|
+
export function resolveEmail(
|
|
164
|
+
content: LocaleContent,
|
|
165
|
+
data: Data,
|
|
166
|
+
): ResolvedEmail {
|
|
167
|
+
const state: ResolveState = { data, missing: new Set(), hidden: [] };
|
|
168
|
+
const subject = text(state, content.subject);
|
|
169
|
+
const preheader = text(state, content.preheader);
|
|
170
|
+
const blocks = resolveBlocks(content.blocks, state);
|
|
171
|
+
return {
|
|
172
|
+
subject,
|
|
173
|
+
preheader,
|
|
174
|
+
blocks,
|
|
175
|
+
missing: [...state.missing].filter(isUserPath).sort(),
|
|
176
|
+
hiddenBlockIds: state.hidden,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getPath, isPresent } from "./paths";
|
|
2
|
+
|
|
3
|
+
export const TOKEN_PATTERN = /\{\{\s*([A-Za-z0-9_.[\]]+)\s*\}\}/g;
|
|
4
|
+
|
|
5
|
+
export interface InterpolationResult {
|
|
6
|
+
text: string;
|
|
7
|
+
missing: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function extractTokens(text: string): string[] {
|
|
11
|
+
const found = new Set<string>();
|
|
12
|
+
for (const match of text.matchAll(TOKEN_PATTERN))
|
|
13
|
+
found.add(match[1] as string);
|
|
14
|
+
return [...found];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function formatValue(value: unknown): string {
|
|
18
|
+
return value instanceof Date ? value.toISOString() : String(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function interpolate(
|
|
22
|
+
text: string,
|
|
23
|
+
data: Record<string, unknown>,
|
|
24
|
+
): InterpolationResult {
|
|
25
|
+
const missing = new Set<string>();
|
|
26
|
+
const output = text.replace(TOKEN_PATTERN, (token, path: string) => {
|
|
27
|
+
const value = getPath(data, path);
|
|
28
|
+
if (!isPresent(value)) {
|
|
29
|
+
missing.add(path);
|
|
30
|
+
return token;
|
|
31
|
+
}
|
|
32
|
+
return formatValue(value);
|
|
33
|
+
});
|
|
34
|
+
return { text: output, missing: [...missing] };
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Block, IfBlock } from "../types";
|
|
2
|
+
|
|
3
|
+
export type BlockVisitor = (block: Block, depth: number) => void;
|
|
4
|
+
|
|
5
|
+
const isIfBlock = (block: Block): block is IfBlock => block.type === "if";
|
|
6
|
+
|
|
7
|
+
export function walkBlocks(
|
|
8
|
+
blocks: Block[],
|
|
9
|
+
visit: BlockVisitor,
|
|
10
|
+
depth = 0,
|
|
11
|
+
): void {
|
|
12
|
+
for (const block of blocks) {
|
|
13
|
+
visit(block, depth);
|
|
14
|
+
if (!isIfBlock(block)) continue;
|
|
15
|
+
walkBlocks(block.children, visit, depth + 1);
|
|
16
|
+
walkBlocks(block.elseChildren ?? [], visit, depth + 1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./tenant-export";
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import type { Table } from "@antelopejs/interface-database";
|
|
3
|
+
import { GetModel } from "@antelopejs/interface-database-decorators";
|
|
4
|
+
import {
|
|
5
|
+
Hook,
|
|
6
|
+
type HookHandler,
|
|
7
|
+
RegisterTenantDataExportContributor,
|
|
8
|
+
type TenantExportArchive,
|
|
9
|
+
UnregisterHook,
|
|
10
|
+
} from "@antelopejs/interface-dms/hooks";
|
|
11
|
+
import { MODULE_ID } from "../constants";
|
|
12
|
+
import { SettingsModel, TemplateModel } from "../db";
|
|
13
|
+
import type { MailingSettingsValues } from "../types";
|
|
14
|
+
|
|
15
|
+
export type ExportedSettings = Omit<MailingSettingsValues, "webhookSecret">;
|
|
16
|
+
|
|
17
|
+
export type ExportPageLoader<T> = (
|
|
18
|
+
offset: number,
|
|
19
|
+
size: number,
|
|
20
|
+
) => Promise<T[]>;
|
|
21
|
+
|
|
22
|
+
interface RowCodec<T> {
|
|
23
|
+
fromDatabase(row: unknown): T | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ExportedCollection {
|
|
27
|
+
entry: string;
|
|
28
|
+
load: ExportPageLoader<object>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** How many rows one archive entry reads at a time while it streams. */
|
|
32
|
+
export const TENANT_EXPORT_PAGE_SIZE = 200;
|
|
33
|
+
|
|
34
|
+
const TEMPLATES_ENTRY = "templates.json";
|
|
35
|
+
const SETTINGS_ENTRY = "settings.json";
|
|
36
|
+
|
|
37
|
+
const ARRAY_OPEN = "[";
|
|
38
|
+
const ARRAY_CLOSE = "]";
|
|
39
|
+
const ROW_SEPARATOR = ",";
|
|
40
|
+
const NO_SEPARATOR = "";
|
|
41
|
+
const FIRST_OFFSET = 0;
|
|
42
|
+
|
|
43
|
+
export async function* jsonArrayChunks<T>(
|
|
44
|
+
load: ExportPageLoader<T>,
|
|
45
|
+
signal: AbortSignal,
|
|
46
|
+
pageSize: number = TENANT_EXPORT_PAGE_SIZE,
|
|
47
|
+
): AsyncGenerator<string> {
|
|
48
|
+
yield ARRAY_OPEN;
|
|
49
|
+
let offset = FIRST_OFFSET;
|
|
50
|
+
let separator = NO_SEPARATOR;
|
|
51
|
+
for (;;) {
|
|
52
|
+
signal.throwIfAborted();
|
|
53
|
+
const page = await load(offset, pageSize);
|
|
54
|
+
for (const row of page) {
|
|
55
|
+
yield `${separator}${JSON.stringify(row)}`;
|
|
56
|
+
separator = ROW_SEPARATOR;
|
|
57
|
+
}
|
|
58
|
+
if (page.length < pageSize) break;
|
|
59
|
+
offset += page.length;
|
|
60
|
+
}
|
|
61
|
+
yield ARRAY_CLOSE;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function exportedSettings(
|
|
65
|
+
tenantId: string,
|
|
66
|
+
): Promise<ExportedSettings | null> {
|
|
67
|
+
const row = await GetModel(SettingsModel, tenantId).getSingleton();
|
|
68
|
+
if (!row) return null;
|
|
69
|
+
return {
|
|
70
|
+
fallbackLocale: row.fallbackLocale,
|
|
71
|
+
logRetentionDays: row.logRetentionDays,
|
|
72
|
+
blockOnMissingVariables: row.blockOnMissingVariables,
|
|
73
|
+
senderName: row.senderName,
|
|
74
|
+
senderEmail: row.senderEmail,
|
|
75
|
+
replyTo: row.replyTo,
|
|
76
|
+
categories: JSON.parse(
|
|
77
|
+
row.json_categories,
|
|
78
|
+
) as ExportedSettings["categories"],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function loadPage<T extends object>(
|
|
83
|
+
table: Table<T>,
|
|
84
|
+
codec: RowCodec<T>,
|
|
85
|
+
offset: number,
|
|
86
|
+
size: number,
|
|
87
|
+
): Promise<T[]> {
|
|
88
|
+
const rows = await table.slice(offset, size).run();
|
|
89
|
+
return rows
|
|
90
|
+
.map((row) => codec.fromDatabase(row))
|
|
91
|
+
.filter((row): row is T => row !== undefined);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function exportedCollections(tenantId: string): ExportedCollection[] {
|
|
95
|
+
const templates = GetModel(TemplateModel, tenantId);
|
|
96
|
+
return [
|
|
97
|
+
{
|
|
98
|
+
entry: TEMPLATES_ENTRY,
|
|
99
|
+
load: (offset, size) =>
|
|
100
|
+
loadPage(templates.table, TemplateModel, offset, size),
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const contributeTenantExport: HookHandler<
|
|
106
|
+
Hook.TENANT_DATA_EXPORT
|
|
107
|
+
> = async (tenantId, archive: TenantExportArchive, signal: AbortSignal) => {
|
|
108
|
+
for (const collection of exportedCollections(tenantId)) {
|
|
109
|
+
signal.throwIfAborted();
|
|
110
|
+
await archive.addStream(
|
|
111
|
+
collection.entry,
|
|
112
|
+
Readable.from(jsonArrayChunks(collection.load, signal), {
|
|
113
|
+
objectMode: false,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
signal.throwIfAborted();
|
|
118
|
+
await archive.addJson(SETTINGS_ENTRY, await exportedSettings(tenantId));
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export function registerTenantExport(): void {
|
|
122
|
+
RegisterTenantDataExportContributor(MODULE_ID, contributeTenantExport);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function unregisterTenantExport(): void {
|
|
126
|
+
UnregisterHook(Hook.TENANT_DATA_EXPORT, contributeTenantExport);
|
|
127
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "./permissions";
|
|
2
|
+
import "./db";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { ImplementInterface } from "@antelopejs/interface-core";
|
|
5
|
+
import { Logging } from "@antelopejs/interface-core/logging";
|
|
6
|
+
import { AddFrontendModule } from "@antelopejs/interface-dms/page";
|
|
7
|
+
import type { ScheduledTask } from "node-cron";
|
|
8
|
+
import {
|
|
9
|
+
registerAutomationNodes,
|
|
10
|
+
unregisterAutomationNodes,
|
|
11
|
+
} from "./automation";
|
|
12
|
+
import { type DmsMailingConfig, setConfig } from "./config";
|
|
13
|
+
import { FRONTEND_MODULE_NAME } from "./constants";
|
|
14
|
+
import { RETENTION_CRON_NAME, scheduleRetention, stopRetention } from "./crons";
|
|
15
|
+
import { registerTenantExport, unregisterTenantExport } from "./hooks";
|
|
16
|
+
import { registerRealtimeTopics } from "./realtime";
|
|
17
|
+
|
|
18
|
+
export * from "./data";
|
|
19
|
+
export * from "./data-types";
|
|
20
|
+
export * from "./pages";
|
|
21
|
+
export * from "./quick-actions";
|
|
22
|
+
export * from "./routes";
|
|
23
|
+
export type { DmsMailingConfig } from "./config";
|
|
24
|
+
|
|
25
|
+
let retentionTask: ScheduledTask | undefined;
|
|
26
|
+
|
|
27
|
+
export async function construct(config: DmsMailingConfig = {}): Promise<void> {
|
|
28
|
+
setConfig(config);
|
|
29
|
+
ImplementInterface(
|
|
30
|
+
await import("@antelopejs/interface-dms-mailing"),
|
|
31
|
+
await import("./implementations/dms-mailing"),
|
|
32
|
+
);
|
|
33
|
+
registerAutomationNodes();
|
|
34
|
+
registerTenantExport();
|
|
35
|
+
registerRealtimeTopics();
|
|
36
|
+
await AddFrontendModule({
|
|
37
|
+
name: FRONTEND_MODULE_NAME,
|
|
38
|
+
sourcePath: path.join(__dirname, "../frontend-vue"),
|
|
39
|
+
renderer: { name: "vue", version: "3" },
|
|
40
|
+
options: { dmsMailing: {} },
|
|
41
|
+
priority: 0,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function destroy(): void {
|
|
46
|
+
unregisterAutomationNodes();
|
|
47
|
+
unregisterTenantExport();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function start(): void {
|
|
51
|
+
retentionTask = scheduleRetention();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function stop(): Promise<void> {
|
|
55
|
+
const task = retentionTask;
|
|
56
|
+
retentionTask = undefined;
|
|
57
|
+
try {
|
|
58
|
+
await stopRetention(task);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
Logging.Error(`Cron '${RETENTION_CRON_NAME}' failed to stop:`, error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PageController, RegisterPage } from "@antelopejs/interface-dms/page";
|
|
2
|
+
import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
|
|
3
|
+
import { DefaultLayout } from "@antelopejs/interface-dms/base/layouts";
|
|
4
|
+
import { MAILING_TEMPLATES_MANAGE_PERMISSION, MODULE_ID } from "../constants";
|
|
5
|
+
|
|
6
|
+
const EDITOR_PAGE_ORDER = 2;
|
|
7
|
+
|
|
8
|
+
@RegisterPage()
|
|
9
|
+
export class MailingEditorController extends PageController(
|
|
10
|
+
"editor",
|
|
11
|
+
{
|
|
12
|
+
displayName: "$dms_mailing.editor.title",
|
|
13
|
+
description: "$dms_mailing.editor.description",
|
|
14
|
+
icon: "i-ph-pencil-simple",
|
|
15
|
+
module: MODULE_ID,
|
|
16
|
+
order: EDITOR_PAGE_ORDER,
|
|
17
|
+
hidden: true,
|
|
18
|
+
permission: { id: MAILING_TEMPLATES_MANAGE_PERMISSION },
|
|
19
|
+
},
|
|
20
|
+
DefaultLayout({ fullWidth: true }),
|
|
21
|
+
) {
|
|
22
|
+
static editor = CustomComponent("DmsMailingEditor");
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// `./module` is imported first so RegisterModule fires before any
|
|
2
|
+
// @RegisterPage decorator runs: pages look their module up synchronously
|
|
3
|
+
// when the decorator is invoked at import time.
|
|
4
|
+
import "./module";
|
|
5
|
+
|
|
6
|
+
export * from "./module";
|
|
7
|
+
export * from "./overview";
|
|
8
|
+
export * from "./editor";
|
|
9
|
+
export * from "./sends";
|
|
10
|
+
export * from "./settings";
|
|
11
|
+
export * from "./templates";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RegisterModule } from "@antelopejs/interface-dms/page";
|
|
2
|
+
|
|
3
|
+
export const mailingModule = RegisterModule({
|
|
4
|
+
id: "mailing",
|
|
5
|
+
title: "$dms_mailing.title",
|
|
6
|
+
description: "$dms_mailing.description",
|
|
7
|
+
icon: "i-ph-envelope-simple",
|
|
8
|
+
landingPage: "overview",
|
|
9
|
+
});
|