@cosmicdrift/kumiko-samples 0.413.0 → 0.414.0
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/package.json +1 -1
- package/packages/bundled-features/package.json +16 -1
- package/packages/bundled-features/src/admin-shell/changes.json +6 -0
- package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
- package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
- package/packages/bundled-features/src/agent-tools/changes.json +12 -0
- package/packages/bundled-features/src/agent-tools/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
- package/packages/bundled-features/src/agent-tools/types.ts +4 -0
- package/packages/bundled-features/src/audit/event-classification.ts +6 -0
- package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
- package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
- package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
- package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +10 -12
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
- package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
- package/packages/bundled-features/src/billing-foundation/changes.json +37 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/events.ts +49 -10
- package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
- package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
- package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
- package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
- package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
- package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
- package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
- package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
- package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/cap-counter/changes.json +6 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
- package/packages/bundled-features/src/cap-overview/changes.json +6 -0
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
- package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
- package/packages/bundled-features/src/cap-overview/index.ts +1 -0
- package/packages/bundled-features/src/cap-overview/types.ts +11 -1
- package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
- package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
- package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
- package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
- package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
- package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
- package/packages/bundled-features/src/channel-whatsapp/changes.json +8 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -0
- package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
- package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
- package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
- package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +189 -0
- package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
- package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
- package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
- package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +226 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
- package/packages/bundled-features/src/config/changes.json +12 -0
- package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
- package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
- package/packages/bundled-features/src/config/index.ts +1 -0
- package/packages/bundled-features/src/config/read-redaction.ts +6 -3
- package/packages/bundled-features/src/config/table.ts +1 -0
- package/packages/bundled-features/src/config/write-helpers.ts +3 -2
- package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
- package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
- package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
- package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
- package/packages/bundled-features/src/data-retention/changes.json +18 -0
- package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
- package/packages/bundled-features/src/data-retention/feature.ts +4 -7
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
- package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
- package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
- package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
- package/packages/bundled-features/src/delivery/changes.json +6 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
- package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
- package/packages/bundled-features/src/delivery/feature.ts +4 -13
- package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +45 -0
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
- package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
- package/packages/bundled-features/src/delivery/index.ts +3 -1
- package/packages/bundled-features/src/delivery/options.ts +11 -0
- package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
- package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
- package/packages/bundled-features/src/delivery/testing.ts +3 -1
- package/packages/bundled-features/src/delivery/types.ts +1 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
- package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
- package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
- package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
- package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +32 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +18 -0
- package/packages/bundled-features/src/documents/constants.ts +10 -2
- package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
- package/packages/bundled-features/src/documents/feature.ts +28 -6
- package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
- package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
- package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
- package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
- package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
- package/packages/bundled-features/src/documents/screens.ts +8 -3
- package/packages/bundled-features/src/documents/tab.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
- package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
- package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
- package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
- package/packages/bundled-features/src/files/changes.json +7 -0
- package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
- package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
- package/packages/bundled-features/src/helpdesk/changes.json +62 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +41 -0
- package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
- package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
- package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
- package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
- package/packages/bundled-features/src/helpdesk/index.ts +1 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +185 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
- package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
- package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +5 -1
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -16
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +21 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
- package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
- package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
- package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
- package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
- package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
- package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
- package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
- package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
- package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
- package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
- package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
- package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
- package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
- package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
- package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
- package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
- package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
- package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/jobs/events.ts +10 -0
- package/packages/bundled-features/src/jobs/feature.ts +2 -0
- package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
- package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
- package/packages/bundled-features/src/managed-pages/changes.json +12 -0
- package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
- package/packages/bundled-features/src/managed-pages/table.ts +1 -0
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
- package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
- package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
- package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
- package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +198 -0
- package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
- package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
- package/packages/bundled-features/src/presence/changes.json +6 -0
- package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
- package/packages/bundled-features/src/presence/room.ts +21 -7
- package/packages/bundled-features/src/presence/store.ts +79 -21
- package/packages/bundled-features/src/readiness/changes.json +25 -0
- package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
- package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
- package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
- package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
- package/packages/bundled-features/src/readiness/screens.ts +4 -4
- package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
- package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
- package/packages/bundled-features/src/secrets/changes.json +7 -0
- package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
- package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
- package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
- package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
- package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
- package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
- package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
- package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
- package/packages/bundled-features/src/shared/changes.json +6 -0
- package/packages/bundled-features/src/shared/index.ts +6 -1
- package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
- package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
- package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
- package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
- package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
- package/packages/bundled-features/src/shared/send-best-effort.ts +19 -0
- package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
- package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
- package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -0
- package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
- package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +159 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +13 -0
- package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
- package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
- package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
- package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
- package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +36 -0
- package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
- package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
- package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
- package/packages/bundled-features/src/subscription-stripe/changes.json +7 -0
- package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +24 -6
- package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
- package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
- package/packages/bundled-features/src/template-resolver/api.ts +6 -13
- package/packages/bundled-features/src/template-resolver/changes.json +36 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
- package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
- package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
- package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +77 -0
- package/packages/bundled-features/src/template-resolver/table.ts +1 -0
- package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
- package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
- package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
- package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
- package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
- package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
- package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
- package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
- package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
- package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
- package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
- package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
- package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
- package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +126 -0
- package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
- package/packages/bundled-features/src/tenant/changes.json +6 -0
- package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
- package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
- package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
- package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
- package/packages/bundled-features/src/tenant/seeding.ts +4 -2
- package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
- package/packages/bundled-features/src/tenant/testing.ts +1 -1
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +4 -3
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
- package/packages/bundled-features/src/user/changes.json +6 -0
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
- package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
- package/packages/bundled-features/src/user/index.ts +1 -0
- package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
- package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +4 -28
- package/packages/bundled-features/src/waitlist/lib.ts +2 -7
- package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
- package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +5 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
- package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
- package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
- package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
- package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
- package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
- package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
- package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
- package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
- package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
- package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
- package/samples/recipes/chat-channels/README.md +2 -0
- package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
- package/samples/recipes/helpdesk/README.md +9 -5
- package/samples/recipes/helpdesk/src/feature.ts +6 -3
- package/samples/recipes/managed-pages/README.md +5 -1
- package/samples/recipes/managed-pages/package.json +3 -2
- package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
- package/samples/recipes/managed-pages/tsconfig.json +8 -0
- package/samples/recipes/pwa-shell/README.md +52 -0
- package/samples/recipes/pwa-shell/bin/server.ts +12 -0
- package/samples/recipes/pwa-shell/package.json +13 -0
- package/samples/recipes/pwa-shell/src/app.ts +34 -0
- package/samples/recipes/rate-limiting/README.md +3 -3
- package/samples/recipes/record-detail-layout/README.md +33 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +525 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
- package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
- package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
- package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
createTenantDb,
|
|
14
14
|
type DbConnection,
|
|
15
15
|
fetchOne,
|
|
16
|
+
selectMany,
|
|
16
17
|
type TenantDb,
|
|
17
18
|
} from "@cosmicdrift/kumiko-framework/db";
|
|
18
19
|
import {
|
|
@@ -22,11 +23,13 @@ import {
|
|
|
22
23
|
SYSTEM_TENANT_ID,
|
|
23
24
|
type TenantId,
|
|
24
25
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
26
|
+
import { NotFoundError, VersionConflictError } from "@cosmicdrift/kumiko-framework/errors";
|
|
25
27
|
import {
|
|
26
28
|
deleteRowsWithoutReplayableStream,
|
|
27
29
|
getStreamVersion,
|
|
28
30
|
getUnscopedStreamMaxVersionForSeed,
|
|
29
31
|
} from "@cosmicdrift/kumiko-framework/event-store";
|
|
32
|
+
import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
|
|
30
33
|
import type { Dispatcher } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
31
34
|
import { runEventStoreSeed, type SeedIfExists } from "@cosmicdrift/kumiko-framework/seeding";
|
|
32
35
|
import { isPlainObject, propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
@@ -40,6 +43,8 @@ import { variablesFromSchema } from "./template-validation.ts";
|
|
|
40
43
|
import { type ContentFormat, TEXT_BLOCK_KIND, type UpsertKind } from "./web/constants.ts";
|
|
41
44
|
import { TEMPLATE_RESOLVER_FEATURE, TemplateResolverHandlers } from "./web/qualified-names.ts";
|
|
42
45
|
|
|
46
|
+
const log = createFallbackLogger("template-resolver-seeding");
|
|
47
|
+
|
|
43
48
|
/** Drop projection orphans (no events anywhere) so boot seeds can recreate. */
|
|
44
49
|
async function resolveExistingForEventStoreSeed(
|
|
45
50
|
db: DbConnection,
|
|
@@ -389,6 +394,78 @@ export async function seedNotificationTemplates(
|
|
|
389
394
|
});
|
|
390
395
|
}
|
|
391
396
|
}
|
|
397
|
+
if (registry.getFeature(TEMPLATE_RESOLVER_FEATURE) !== undefined) {
|
|
398
|
+
await removeOrphanedNotificationTemplates(db, registry);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// WriteResult errors are plain objects, so the class instances only supply the codes.
|
|
403
|
+
const ALREADY_REMOVED_ERROR_CODES: ReadonlySet<string> = new Set([
|
|
404
|
+
new NotFoundError("template").code,
|
|
405
|
+
new VersionConflictError({ entityId: "", expectedVersion: 0, currentVersion: 0 }).code,
|
|
406
|
+
]);
|
|
407
|
+
|
|
408
|
+
const NOTIFICATION_SLUG_PATTERN = /^([^:]+):notify:[^:]+$/;
|
|
409
|
+
|
|
410
|
+
function isOrphanedNotificationSlug(registry: Registry, slug: string): boolean {
|
|
411
|
+
const feature = NOTIFICATION_SLUG_PATTERN.exec(slug)?.[1];
|
|
412
|
+
if (feature === undefined) return false;
|
|
413
|
+
const notifications = registry.getAllNotifications();
|
|
414
|
+
if (notifications.has(slug)) return false;
|
|
415
|
+
const renamedAway = Array.from(notifications.values()).some((notification) =>
|
|
416
|
+
notification.renamedFrom?.includes(slug),
|
|
417
|
+
);
|
|
418
|
+
return renamedAway || registry.getFeature(feature) !== undefined;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// A removed or renamed notification leaves its seeded system rows behind; they would keep
|
|
422
|
+
// showing up in the template overview. Tenant overrides may hold customer text, so they stay
|
|
423
|
+
// and are only reported. Slugs of unmounted features are not ours to judge.
|
|
424
|
+
async function removeOrphanedNotificationTemplates(
|
|
425
|
+
db: DbConnection,
|
|
426
|
+
registry: Registry,
|
|
427
|
+
): Promise<void> {
|
|
428
|
+
const rows = await selectMany<TemplateResourceRow>(db, templateResourcesTable, {
|
|
429
|
+
kind: "mail",
|
|
430
|
+
});
|
|
431
|
+
const orphans = rows.filter((row) => isOrphanedNotificationSlug(registry, row.slug));
|
|
432
|
+
// skip: nothing orphaned
|
|
433
|
+
if (orphans.length === 0) return;
|
|
434
|
+
|
|
435
|
+
const tdb = createTenantDb({
|
|
436
|
+
db,
|
|
437
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
438
|
+
mode: "system",
|
|
439
|
+
reason: "seeding removes orphaned system notification templates",
|
|
440
|
+
});
|
|
441
|
+
const by = createSystemUser(SYSTEM_TENANT_ID);
|
|
442
|
+
const overrideCountBySlug = new Map<string, number>();
|
|
443
|
+
for (const row of orphans) {
|
|
444
|
+
if (row.tenantId !== SYSTEM_TENANT_ID) {
|
|
445
|
+
overrideCountBySlug.set(row.slug, (overrideCountBySlug.get(row.slug) ?? 0) + 1);
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
const result = await executor.delete({ id: String(row.id) }, by, tdb);
|
|
449
|
+
if (!result.isSuccess && ALREADY_REMOVED_ERROR_CODES.has(result.error.code)) {
|
|
450
|
+
// A replica booting at the same time removed it first.
|
|
451
|
+
log.info("orphaned notification template was already removed", {
|
|
452
|
+
slug: row.slug,
|
|
453
|
+
locale: row.locale,
|
|
454
|
+
});
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (!result.isSuccess) {
|
|
458
|
+
throw new Error(
|
|
459
|
+
`removeOrphanedNotificationTemplates: delete of ${row.slug} (${row.locale}) failed: ${JSON.stringify(result)}`,
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
for (const [slug, count] of overrideCountBySlug) {
|
|
464
|
+
log.warn("tenant template override of a notification that no longer exists is kept", {
|
|
465
|
+
slug,
|
|
466
|
+
count,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
392
469
|
}
|
|
393
470
|
|
|
394
471
|
export type SeedTextBlockOptions = {
|
|
@@ -34,6 +34,7 @@ const renameMailHtmlKind: EntityEventMigration = {
|
|
|
34
34
|
// jsonbField). The application layer parses the JSON and persists it as a string.
|
|
35
35
|
export const templateResourceEntity = createEntity({
|
|
36
36
|
table: "read_template_resources",
|
|
37
|
+
systemRowsReadable: true,
|
|
37
38
|
fields: {
|
|
38
39
|
slug: createTextField({ required: true, personal: false, reason: "technical_reference" }),
|
|
39
40
|
kind: createSelectField({ required: true, options: [...TEMPLATE_KINDS] }),
|
|
@@ -84,7 +84,8 @@ export function toWorkingRow(row: TemplateResourceRow, viewerTenantId: string):
|
|
|
84
84
|
const draft = row.tenantId === viewerTenantId ? parseTemplateDraft(row.draft) : null;
|
|
85
85
|
// Saves and discards of drafts raise row.version; an editor without a draft shows the served number.
|
|
86
86
|
if (draft === null) return { ...row, version: active?.version ?? row.version, active };
|
|
87
|
-
|
|
87
|
+
// An archived row keeps its status, otherwise the editor would show a retired template as a draft.
|
|
88
|
+
return { ...row, ...draft, status: row.status === "archived" ? row.status : "draft", active };
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
// Event changes that turn a row into a served one. Every value is explicit so a
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "@cosmicdrift/kumiko-framework/errors";
|
|
18
18
|
import { fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
|
|
19
19
|
import { createI18n } from "@cosmicdrift/kumiko-framework/i18n";
|
|
20
|
+
import { systemTenantReadDb } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
|
|
20
21
|
import { escapeHtml } from "@cosmicdrift/kumiko-renderer/headless";
|
|
21
22
|
import * as z from "zod";
|
|
22
23
|
import { createEmailAttachmentReader, createTemplateMailRenderer } from "../delivery/index.ts";
|
|
@@ -257,12 +258,22 @@ async function describeAttachments(
|
|
|
257
258
|
refs: readonly MailAttachmentRef[],
|
|
258
259
|
): Promise<{ readonly attachments: PreviewAttachment[]; readonly missing: string[] }> {
|
|
259
260
|
const fileRefIds = refs.flatMap((ref) => (ref.kind === "rendered-pdf" ? [] : [ref.fileRefId]));
|
|
260
|
-
|
|
261
|
+
type SizedFileRef = { id: string; size: number | bigint | string };
|
|
262
|
+
const ownRows =
|
|
261
263
|
fileRefIds.length === 0
|
|
262
264
|
? []
|
|
263
|
-
: await selectMany<
|
|
264
|
-
|
|
265
|
+
: await selectMany<SizedFileRef>(ctx.db, fileRefsTable, { id: fileRefIds });
|
|
266
|
+
// System template resources are invisible to a tenant session; read them through the narrow
|
|
267
|
+
// system-tenant path, only for ids the own tenant does not hold.
|
|
268
|
+
const ownIds = new Set(ownRows.map((row) => row.id));
|
|
269
|
+
const systemIds = fileRefIds.filter((id) => !ownIds.has(id));
|
|
270
|
+
const systemRows =
|
|
271
|
+
systemIds.length === 0
|
|
272
|
+
? []
|
|
273
|
+
: await selectMany<SizedFileRef>(systemTenantReadDb(ctx.db), fileRefsTable, {
|
|
274
|
+
id: systemIds,
|
|
265
275
|
});
|
|
276
|
+
const rows = [...ownRows, ...systemRows];
|
|
266
277
|
const sizeById = new Map(rows.map((row) => [row.id, Number(row.size)]));
|
|
267
278
|
// An inline image is named by its content id because the stored file name is personal data and
|
|
268
279
|
// may be ciphertext; a file attachment carries the name the admin gave it.
|
|
@@ -62,8 +62,6 @@ async function seedTemplate(db: DbConnection, args: SeedTemplateArgs): Promise<v
|
|
|
62
62
|
variableSchema: JSON.stringify(args.variableSchema ?? {}),
|
|
63
63
|
linkedResources: JSON.stringify(args.linkedResources ?? {}),
|
|
64
64
|
parentTemplateId: args.parentTemplateId ?? null,
|
|
65
|
-
insertedById: "conformance",
|
|
66
|
-
modifiedById: "conformance",
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
|
|
@@ -3,7 +3,9 @@ import { createCollectionEntryCreateForm } from "./collection-entry-create-form.
|
|
|
3
3
|
import { makeTreeProvider } from "./content-tree-provider.ts";
|
|
4
4
|
import { DocumentContentEditor } from "./document-editor.tsx";
|
|
5
5
|
import { defaultTranslations } from "./i18n.ts";
|
|
6
|
+
import { SnippetPreviewRenderer } from "./snippet-preview-renderer.tsx";
|
|
6
7
|
import { TextBlockEditor } from "./text-block-editor.tsx";
|
|
8
|
+
import { WebPreviewRenderer } from "./web-preview-renderer.tsx";
|
|
7
9
|
|
|
8
10
|
// `navId` = the QN of the r.nav({ provider: true }) node the app registers for
|
|
9
11
|
// the content tree (e.g. "publicstatus:nav:content"). The app owns the node's
|
|
@@ -27,6 +29,7 @@ export function textBlocksClient(opts?: {
|
|
|
27
29
|
const tenantId = opts?.tenantId;
|
|
28
30
|
return {
|
|
29
31
|
name: "template-resolver",
|
|
32
|
+
contentPreviews: { web: WebPreviewRenderer, text: SnippetPreviewRenderer },
|
|
30
33
|
...(navId !== undefined && {
|
|
31
34
|
navProviders: { [navId]: makeTreeProvider(tenantId) },
|
|
32
35
|
// SSE refresh: every template-resource event re-fires the provider.
|
package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TargetRef } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import type { FieldIssue } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
-
import {
|
|
3
|
+
import { usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { ContentWorkbench } from "./content-workbench.tsx";
|
|
6
6
|
import { useCollectionEntryCreate } from "./use-collection-entry-create.ts";
|
|
7
7
|
|
|
8
8
|
const SLUG_INVALID_ISSUE: FieldIssue = {
|
|
@@ -26,12 +26,10 @@ export function createCollectionEntryCreateForm(
|
|
|
26
26
|
type CreateState = ReturnType<typeof useCollectionEntryCreate>;
|
|
27
27
|
|
|
28
28
|
function CreateFields({ state }: { readonly state: CreateState }): ReactNode {
|
|
29
|
-
const { Field, Input
|
|
29
|
+
const { Field, Input } = usePrimitives();
|
|
30
30
|
const t = useTranslation();
|
|
31
|
-
const { canWrite } = state.editorContext;
|
|
32
31
|
return (
|
|
33
32
|
<>
|
|
34
|
-
{!canWrite && <Banner variant="info">{t("template-resolver.editor.readOnly")}</Banner>}
|
|
35
33
|
<Field
|
|
36
34
|
id="create-entry-slug"
|
|
37
35
|
label={t("template-resolver.editor.slugLabel")}
|
|
@@ -59,13 +57,6 @@ function CreateFields({ state }: { readonly state: CreateState }): ReactNode {
|
|
|
59
57
|
required
|
|
60
58
|
/>
|
|
61
59
|
</Field>
|
|
62
|
-
<ContentField
|
|
63
|
-
editorContext={state.editorContext}
|
|
64
|
-
value={state.content}
|
|
65
|
-
onChange={state.setContent}
|
|
66
|
-
disabled={state.disabled}
|
|
67
|
-
/>
|
|
68
|
-
{state.error !== null && <Banner variant="error">{state.error}</Banner>}
|
|
69
60
|
</>
|
|
70
61
|
);
|
|
71
62
|
}
|
|
@@ -78,29 +69,38 @@ export function CollectionEntryCreateForm({
|
|
|
78
69
|
readonly onClose: () => void;
|
|
79
70
|
readonly tenantId?: string | undefined;
|
|
80
71
|
}): ReactNode {
|
|
81
|
-
const {
|
|
72
|
+
const { Banner } = usePrimitives();
|
|
82
73
|
const t = useTranslation();
|
|
83
74
|
const state = useCollectionEntryCreate(target, tenantId);
|
|
84
75
|
return (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
<ContentWorkbench
|
|
77
|
+
testId="collection-entry-create"
|
|
78
|
+
title={state.headerTitle}
|
|
79
|
+
editorContext={state.editorContext}
|
|
80
|
+
content={state.content}
|
|
81
|
+
onContentChange={state.setContent}
|
|
82
|
+
disabled={state.disabled}
|
|
83
|
+
fields={<CreateFields state={state} />}
|
|
84
|
+
details={[
|
|
85
|
+
{
|
|
86
|
+
label: t("template-resolver.editor.slugLabel"),
|
|
87
|
+
value: state.slug === "" ? "–" : state.slug,
|
|
88
|
+
},
|
|
89
|
+
]}
|
|
90
|
+
banners={
|
|
91
|
+
!state.editorContext.canWrite && (
|
|
92
|
+
<Banner variant="info">{t("template-resolver.editor.readOnly")}</Banner>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
save={{
|
|
96
|
+
busy: state.submitting,
|
|
97
|
+
canSave: !state.createDisabled,
|
|
98
|
+
dirty: state.slug !== "" || state.title !== "" || state.content !== "",
|
|
99
|
+
onSave: () => void state.create(),
|
|
100
|
+
onDiscard: state.reset,
|
|
101
|
+
saveError: state.error,
|
|
102
|
+
saveLabel: t("template-resolver.editor.create"),
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
105
|
);
|
|
106
106
|
}
|
|
@@ -63,6 +63,10 @@ export function isCollectionRefusedKind(
|
|
|
63
63
|
return isOneOf(COLLECTION_REFUSED_KINDS, kind);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// Kinds an editor opens: `notification` is retired (only replay reads it) and `image-snapshot`
|
|
67
|
+
// gets finished html in its request, so neither has a mask to preview in.
|
|
68
|
+
export type EditableTemplateKind = Exclude<TemplateKind, "notification" | "image-snapshot">;
|
|
69
|
+
|
|
66
70
|
export const SLUG_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
67
71
|
export const SLUG_MAX_LENGTH = 80;
|
|
68
72
|
|
|
@@ -95,6 +99,9 @@ export const MAIL_PREVIEW_MAX_BYTES = 10 * 1024 * 1024;
|
|
|
95
99
|
|
|
96
100
|
export const TEST_MAIL_SUBJECT_PREFIX = "[TEST] ";
|
|
97
101
|
|
|
102
|
+
// Notification type of the delivery attempt logged for a send-test mail.
|
|
103
|
+
export const TEST_MAIL_NOTIFICATION_TYPE = "template-resolver:test-mail";
|
|
104
|
+
|
|
98
105
|
// System templates live under the SYSTEM_TENANT_ID sentinel; the client-safe types package is its single source.
|
|
99
106
|
export { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-types/identifiers";
|
|
100
107
|
|
|
@@ -152,7 +152,6 @@ async function postBlockList(
|
|
|
152
152
|
const headers: Record<string, string> = { "content-type": "application/json" };
|
|
153
153
|
const csrf = readCsrfToken();
|
|
154
154
|
if (csrf !== undefined) headers[CSRF_HEADER_NAME] = csrf;
|
|
155
|
-
// kumiko-lint-ignore no-raw-hooks not yet converted to the framework hook set
|
|
156
155
|
const response = await fetch("/api/query", {
|
|
157
156
|
method: "POST",
|
|
158
157
|
headers,
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { PreviewPane, usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
|
|
2
|
+
import {
|
|
3
|
+
EditorWorkbench,
|
|
4
|
+
PageSection,
|
|
5
|
+
RailHint,
|
|
6
|
+
RailRow,
|
|
7
|
+
RailSection,
|
|
8
|
+
Stack,
|
|
9
|
+
type WorkbenchSave,
|
|
10
|
+
} from "@cosmicdrift/kumiko-renderer/web";
|
|
11
|
+
import type { ReactNode } from "react";
|
|
12
|
+
import { DocumentBlocksContext } from "./document-editor.tsx";
|
|
13
|
+
import { previewTargetOfCollectionKind, previewTargetOfKind } from "./preview-targets.ts";
|
|
14
|
+
import type { CollectionEditorContext } from "./use-collection-editor-context.ts";
|
|
15
|
+
|
|
16
|
+
export type ContentDetail = { readonly label: string; readonly value: string };
|
|
17
|
+
|
|
18
|
+
export type ContentWorkbenchProps = {
|
|
19
|
+
readonly testId: string;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
readonly editorContext: CollectionEditorContext;
|
|
22
|
+
readonly content: string;
|
|
23
|
+
readonly onContentChange: (value: string) => void;
|
|
24
|
+
readonly disabled: boolean;
|
|
25
|
+
/** Inputs above the content editor (title, slug). */
|
|
26
|
+
readonly fields: ReactNode;
|
|
27
|
+
/** Read-only facts about the entry, shown in the right rail of both modes. */
|
|
28
|
+
readonly details: readonly ContentDetail[];
|
|
29
|
+
readonly banners?: ReactNode;
|
|
30
|
+
readonly save: WorkbenchSave;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// The text-block and collection-entry masks: title and content on the shared workbench, the
|
|
34
|
+
// preview renderer picked by the kind of what is edited (text-block previews as the web page it
|
|
35
|
+
// ends up in, collection entries as plain text unless their kind says otherwise).
|
|
36
|
+
export function ContentWorkbench({
|
|
37
|
+
testId,
|
|
38
|
+
title,
|
|
39
|
+
editorContext,
|
|
40
|
+
content,
|
|
41
|
+
onContentChange,
|
|
42
|
+
disabled,
|
|
43
|
+
fields,
|
|
44
|
+
details,
|
|
45
|
+
banners,
|
|
46
|
+
save,
|
|
47
|
+
}: ContentWorkbenchProps): ReactNode {
|
|
48
|
+
const t = useTranslation();
|
|
49
|
+
const { Field } = usePrimitives();
|
|
50
|
+
const { ContentEditor, collection, contentFormat, documentBlocks, variableExamples, variables } =
|
|
51
|
+
editorContext;
|
|
52
|
+
const target =
|
|
53
|
+
collection === undefined
|
|
54
|
+
? previewTargetOfKind["text-block"]
|
|
55
|
+
: previewTargetOfCollectionKind(collection.kind);
|
|
56
|
+
const editorId = `${testId}-content`;
|
|
57
|
+
const exampleNames = Object.keys(variableExamples);
|
|
58
|
+
const hasPlaceholders = variables.length > 0;
|
|
59
|
+
|
|
60
|
+
const detailRows = (
|
|
61
|
+
<RailSection title={t("template-resolver.editor.railDetails")}>
|
|
62
|
+
{details.map((detail) => (
|
|
63
|
+
<RailRow key={detail.label} label={detail.label} trailing={detail.value} />
|
|
64
|
+
))}
|
|
65
|
+
</RailSection>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<EditorWorkbench
|
|
70
|
+
testId={testId}
|
|
71
|
+
title={title}
|
|
72
|
+
info={{
|
|
73
|
+
edit: t("template-resolver.editor.infoEdit"),
|
|
74
|
+
preview: t(
|
|
75
|
+
hasPlaceholders
|
|
76
|
+
? "template-resolver.editor.infoPreview"
|
|
77
|
+
: "template-resolver.editor.infoPreviewPlain",
|
|
78
|
+
),
|
|
79
|
+
}}
|
|
80
|
+
banners={banners}
|
|
81
|
+
edit={
|
|
82
|
+
<div className="min-h-0 flex-1 overflow-y-auto" data-testid={`${testId}-scroll`}>
|
|
83
|
+
<PageSection maxWidth="3xl">
|
|
84
|
+
<Stack>
|
|
85
|
+
{fields}
|
|
86
|
+
<Field id={editorId} label={t("template-resolver.editor.contentLabel")}>
|
|
87
|
+
<DocumentBlocksContext.Provider value={documentBlocks}>
|
|
88
|
+
<ContentEditor
|
|
89
|
+
id={editorId}
|
|
90
|
+
value={content}
|
|
91
|
+
onChange={onContentChange}
|
|
92
|
+
variables={variables}
|
|
93
|
+
readOnly={disabled}
|
|
94
|
+
/>
|
|
95
|
+
</DocumentBlocksContext.Provider>
|
|
96
|
+
</Field>
|
|
97
|
+
</Stack>
|
|
98
|
+
</PageSection>
|
|
99
|
+
</div>
|
|
100
|
+
}
|
|
101
|
+
preview={
|
|
102
|
+
<PreviewPane
|
|
103
|
+
target={target}
|
|
104
|
+
content={content}
|
|
105
|
+
editFormat={contentFormat ?? "plain"}
|
|
106
|
+
variables={variableExamples}
|
|
107
|
+
subject={{ kind: "body" }}
|
|
108
|
+
/>
|
|
109
|
+
}
|
|
110
|
+
rail={{
|
|
111
|
+
edit: detailRows,
|
|
112
|
+
preview: (
|
|
113
|
+
<>
|
|
114
|
+
{detailRows}
|
|
115
|
+
{hasPlaceholders && (
|
|
116
|
+
<RailSection title={t("template-resolver.editor.railExamples")}>
|
|
117
|
+
{exampleNames.map((name) => (
|
|
118
|
+
<RailRow
|
|
119
|
+
key={name}
|
|
120
|
+
label={`{{${name}}}`}
|
|
121
|
+
trailing={variableExamples[name] ?? ""}
|
|
122
|
+
/>
|
|
123
|
+
))}
|
|
124
|
+
</RailSection>
|
|
125
|
+
)}
|
|
126
|
+
</>
|
|
127
|
+
),
|
|
128
|
+
...(hasPlaceholders && {
|
|
129
|
+
left: (
|
|
130
|
+
<RailSection title={t("template-resolver.editor.railPlaceholders")}>
|
|
131
|
+
<RailHint>{t("template-resolver.editor.railPlaceholdersHint")}</RailHint>
|
|
132
|
+
{variables.map((name) => (
|
|
133
|
+
<RailRow key={name} label={`{{${name}}}`} />
|
|
134
|
+
))}
|
|
135
|
+
</RailSection>
|
|
136
|
+
),
|
|
137
|
+
}),
|
|
138
|
+
}}
|
|
139
|
+
save={save}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Translate } from "@cosmicdrift/kumiko-renderer/headless";
|
|
2
2
|
import type { Editor, JSONContent } from "@tiptap/core";
|
|
3
3
|
import {
|
|
4
4
|
isAllowedDocumentLinkHref,
|
|
@@ -7,10 +7,7 @@ import {
|
|
|
7
7
|
isDocumentResourceKey,
|
|
8
8
|
} from "./document-schema.ts";
|
|
9
9
|
import { parseDocumentStepsInput } from "./document-steps.ts";
|
|
10
|
-
import { type PanelKind, repeatTableContent } from "./document-tiptap-helpers.ts";
|
|
11
|
-
|
|
12
|
-
type Translate = (key: string, params?: Readonly<Record<string, unknown>>) => string;
|
|
13
|
-
type Primitives = ReturnType<typeof usePrimitives>;
|
|
10
|
+
import { type PanelKind, type Primitives, repeatTableContent } from "./document-tiptap-helpers.ts";
|
|
14
11
|
|
|
15
12
|
export type PanelModel = {
|
|
16
13
|
readonly t: Translate;
|
|
@@ -142,15 +139,13 @@ const INSERT_HANDLERS: Partial<Record<PanelKind, (m: PanelModel) => () => void>>
|
|
|
142
139
|
images: (m) => () => insertAndCloseOf(m)({ type: "images", attrs: { variable: m.selectedName } }),
|
|
143
140
|
};
|
|
144
141
|
|
|
145
|
-
const KINDS_WITHOUT_VARIABLE_GUARD: readonly PanelKind[] = ["link", "image"];
|
|
146
|
-
|
|
147
142
|
export function panelActionProps(m: PanelModel): {
|
|
148
143
|
onInsert?: () => void;
|
|
149
144
|
onRemoveLink?: () => void;
|
|
150
145
|
} {
|
|
151
146
|
const { editor, kind } = m;
|
|
152
147
|
const build = INSERT_HANDLERS[kind];
|
|
153
|
-
const insertAllowed =
|
|
148
|
+
const insertAllowed = !m.noVariables;
|
|
154
149
|
return {
|
|
155
150
|
...(build !== undefined && insertAllowed && { onInsert: build(m) }),
|
|
156
151
|
...(kind === "link" &&
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isDocumentReferenceName } from "./document-reference-name.ts";
|
|
2
|
+
|
|
3
|
+
const PLACEHOLDER_HREF = /^\{\{(.+)\}\}$/;
|
|
4
|
+
const ALLOWED_LINK_SCHEMES = ["https://", "http://", "mailto:", "tel:"] as const;
|
|
5
|
+
|
|
6
|
+
export function isDocumentPlaceholderHref(href: string): boolean {
|
|
7
|
+
const name = PLACEHOLDER_HREF.exec(href)?.[1];
|
|
8
|
+
return name !== undefined && isDocumentReferenceName(name);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const UNSAFE_URL_CHARACTERS = new Set(["<", ">", '"']);
|
|
12
|
+
|
|
13
|
+
function hasUnsafeUrlCharacter(value: string): boolean {
|
|
14
|
+
return Array.from(value).some((character) => {
|
|
15
|
+
const code = character.charCodeAt(0);
|
|
16
|
+
return UNSAFE_URL_CHARACTERS.has(character) || code <= 0x1f || code === 0x7f;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isParsableWebUrl(href: string, protocol: "https:" | "http:"): boolean {
|
|
21
|
+
try {
|
|
22
|
+
return new URL(href).protocol === protocol;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function hasAllowedLinkScheme(href: string): boolean {
|
|
29
|
+
if (href.startsWith("https://")) return isParsableWebUrl(href, "https:");
|
|
30
|
+
if (href.startsWith("http://")) return isParsableWebUrl(href, "http:");
|
|
31
|
+
return ALLOWED_LINK_SCHEMES.some((scheme) => href.startsWith(scheme));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Relative references are matched by their literal leading character so a
|
|
35
|
+
// scheme can never hide in them: a value starting with a letter ("x:y",
|
|
36
|
+
// "javascript:") is not relative. Protocol-relative "//host" and any backslash
|
|
37
|
+
// (browsers read "/\\host" as "//host") would leave the site.
|
|
38
|
+
const RELATIVE_HREF_PREFIXES = ["/", "./", "../", "#", "?"] as const;
|
|
39
|
+
|
|
40
|
+
function isRelativeHref(href: string): boolean {
|
|
41
|
+
if (href.includes("\\") || href.startsWith("//")) return false;
|
|
42
|
+
return RELATIVE_HREF_PREFIXES.some((prefix) => href.startsWith(prefix));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Exact lowercase prefix on the unchanged value: no trim, no case folding, so
|
|
46
|
+
// "JaVaScRiPt:", "HTTPS://" or a leading tab can never slip through as a
|
|
47
|
+
// scheme variant. Markup and control characters are refused outright because
|
|
48
|
+
// downstream parsers (MJML, PDF renderer) re-read the serialized attribute.
|
|
49
|
+
export function isAllowedDocumentUrlHref(href: string): boolean {
|
|
50
|
+
if (hasUnsafeUrlCharacter(href)) return false;
|
|
51
|
+
return hasAllowedLinkScheme(href) || isDocumentPlaceholderHref(href);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Anchors only: other URL attributes (form action, svg href) resolve against the
|
|
55
|
+
// page and must stay on explicit schemes or placeholders.
|
|
56
|
+
export function isAllowedDocumentLinkHref(href: string): boolean {
|
|
57
|
+
return isAllowedDocumentUrlHref(href) || (!hasUnsafeUrlCharacter(href) && isRelativeHref(href));
|
|
58
|
+
}
|
|
@@ -8,69 +8,23 @@ import { Link } from "@tiptap/extension-link";
|
|
|
8
8
|
import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
|
|
9
9
|
import StarterKit from "@tiptap/starter-kit";
|
|
10
10
|
import { createDocumentImagesNode } from "./document-images.ts";
|
|
11
|
+
import {
|
|
12
|
+
isAllowedDocumentLinkHref,
|
|
13
|
+
isAllowedDocumentUrlHref,
|
|
14
|
+
isDocumentPlaceholderHref,
|
|
15
|
+
} from "./document-link-policy.ts";
|
|
11
16
|
import { isDocumentReferenceName } from "./document-reference-name.ts";
|
|
12
17
|
import { createDocumentStepsNode } from "./document-steps.ts";
|
|
13
18
|
import { attributeParseRule } from "./tiptap-attribute-parse-rule.ts";
|
|
14
19
|
|
|
15
|
-
const PLACEHOLDER_HREF = /^\{\{(.+)\}\}$/;
|
|
16
20
|
const RESOURCE_KEY = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
17
|
-
const ALLOWED_LINK_SCHEMES = ["https://", "http://", "mailto:", "tel:"] as const;
|
|
18
21
|
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const UNSAFE_URL_CHARACTERS = new Set(["<", ">", '"']);
|
|
27
|
-
|
|
28
|
-
function hasUnsafeUrlCharacter(value: string): boolean {
|
|
29
|
-
return Array.from(value).some((character) => {
|
|
30
|
-
const code = character.charCodeAt(0);
|
|
31
|
-
return UNSAFE_URL_CHARACTERS.has(character) || code <= 0x1f || code === 0x7f;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function isParsableWebUrl(href: string, protocol: "https:" | "http:"): boolean {
|
|
36
|
-
try {
|
|
37
|
-
return new URL(href).protocol === protocol;
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function hasAllowedLinkScheme(href: string): boolean {
|
|
44
|
-
if (href.startsWith("https://")) return isParsableWebUrl(href, "https:");
|
|
45
|
-
if (href.startsWith("http://")) return isParsableWebUrl(href, "http:");
|
|
46
|
-
return ALLOWED_LINK_SCHEMES.some((scheme) => href.startsWith(scheme));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Relative references are matched by their literal leading character so a
|
|
50
|
-
// scheme can never hide in them: a value starting with a letter ("x:y",
|
|
51
|
-
// "javascript:") is not relative. Protocol-relative "//host" and any backslash
|
|
52
|
-
// (browsers read "/\\host" as "//host") would leave the site.
|
|
53
|
-
const RELATIVE_HREF_PREFIXES = ["/", "./", "../", "#", "?"] as const;
|
|
54
|
-
|
|
55
|
-
function isRelativeHref(href: string): boolean {
|
|
56
|
-
if (href.includes("\\") || href.startsWith("//")) return false;
|
|
57
|
-
return RELATIVE_HREF_PREFIXES.some((prefix) => href.startsWith(prefix));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Exact lowercase prefix on the unchanged value: no trim, no case folding, so
|
|
61
|
-
// "JaVaScRiPt:", "HTTPS://" or a leading tab can never slip through as a
|
|
62
|
-
// scheme variant. Markup and control characters are refused outright because
|
|
63
|
-
// downstream parsers (MJML, PDF renderer) re-read the serialized attribute.
|
|
64
|
-
export function isAllowedDocumentUrlHref(href: string): boolean {
|
|
65
|
-
if (hasUnsafeUrlCharacter(href)) return false;
|
|
66
|
-
return hasAllowedLinkScheme(href) || isDocumentPlaceholderHref(href);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Anchors only: other URL attributes (form action, svg href) resolve against the
|
|
70
|
-
// page and must stay on explicit schemes or placeholders.
|
|
71
|
-
export function isAllowedDocumentLinkHref(href: string): boolean {
|
|
72
|
-
return isAllowedDocumentUrlHref(href) || (!hasUnsafeUrlCharacter(href) && isRelativeHref(href));
|
|
73
|
-
}
|
|
22
|
+
export {
|
|
23
|
+
isAllowedDocumentLinkHref,
|
|
24
|
+
isAllowedDocumentUrlHref,
|
|
25
|
+
isDocumentPlaceholderHref,
|
|
26
|
+
isDocumentReferenceName,
|
|
27
|
+
};
|
|
74
28
|
|
|
75
29
|
export function isDocumentResourceKey(value: string): boolean {
|
|
76
30
|
return RESOURCE_KEY.test(value);
|
|
@@ -6,6 +6,7 @@ import type { TiptapContext } from "./document-tiptap-context.ts";
|
|
|
6
6
|
import {
|
|
7
7
|
buttonTargetLabel,
|
|
8
8
|
findRepeatTable,
|
|
9
|
+
type SelectedBlock,
|
|
9
10
|
toggleRepeatHeader,
|
|
10
11
|
} from "./document-tiptap-helpers.ts";
|
|
11
12
|
|
|
@@ -68,10 +69,7 @@ function repeatBarLabelOf(c: TiptapContext): string {
|
|
|
68
69
|
: t("template-resolver.documentEditor.repeatBarList", { list: repeatListLabel });
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
function renderBlockOptionsBar(
|
|
72
|
-
c: TiptapContext,
|
|
73
|
-
selectedBlock: { readonly type: "resource" | "button"; readonly detail: string },
|
|
74
|
-
): ReactNode {
|
|
72
|
+
function renderBlockOptionsBar(c: TiptapContext, selectedBlock: SelectedBlock): ReactNode {
|
|
75
73
|
const { t, Button, editor } = c;
|
|
76
74
|
return (
|
|
77
75
|
<div className={BUBBLE_BAR_CLASS} data-testid="document-block-options">
|