@cosmicdrift/kumiko-samples 0.413.1 → 0.415.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/signup-token-store.ts +2 -3
- 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 +12 -13
- 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/changes.json +6 -0
- 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 +61 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +19 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +67 -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 +51 -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 +9 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +183 -17
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +35 -10
- 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 +9 -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 +32 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +94 -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 +210 -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 +247 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/changes.json +5 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +2 -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 +12 -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 +2 -5
- 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 +12 -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 +54 -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/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +1 -0
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +34 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +24 -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 +33 -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/form-draft/feature.ts +1 -0
- package/packages/bundled-features/src/helpdesk/changes.json +56 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +42 -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 +5 -12
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +4 -10
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +5 -12
- 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 +187 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +55 -37
- 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 +9 -2
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +23 -2
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +73 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +24 -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 +23 -9
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +79 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message-schema.ts +18 -5
- 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/normalize-inbound-message.ts +22 -8
- 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/sanitize-inbound-html.ts +2 -5
- 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 +204 -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 +12 -0
- package/packages/bundled-features/src/shared/hmac-signature.ts +4 -2
- package/packages/bundled-features/src/shared/index.ts +7 -1
- package/packages/bundled-features/src/shared/normalize-email.ts +3 -0
- 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 +29 -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 +18 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +50 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +42 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +61 -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 +161 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +19 -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 +57 -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 +13 -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 +38 -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 +48 -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 +107 -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 +132 -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/changes.json +6 -0
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +36 -17
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +7 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +22 -2
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +24 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -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/feature.ts +1 -0
- 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/reject.write.ts +1 -1
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +5 -29
- package/packages/bundled-features/src/waitlist/import.ts +2 -1
- package/packages/bundled-features/src/waitlist/lib.ts +2 -11
- package/packages/bundled-features/src/waitlist/link-on-signup.ts +2 -2
- 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/changes.json +6 -0
- 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 +7 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/admin-console/src/app/shell.tsx +1 -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/crypto-shredding-hr/README.md +11 -0
- package/samples/recipes/crypto-shredding-hr/src/feature.ts +27 -0
- package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
- 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 +556 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +529 -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
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
// In-memory order data shared by the real query handlers (feature.ts) and the e2e
|
|
2
|
+
// mock dispatcher, so the browser fixture answers exactly what the server would.
|
|
3
|
+
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
export const ORDER_DETAIL_SCREEN_QN = "order-desk:screen:order-detail";
|
|
7
|
+
|
|
8
|
+
export const NAMED_FILTER_IDS = ["action-needed", "reminder-due", "ending-soon"] as const;
|
|
9
|
+
export type OrderNamedFilterId = (typeof NAMED_FILTER_IDS)[number];
|
|
10
|
+
|
|
11
|
+
const AGGREGATE_MEASURE_KINDS = ["sum", "avg", "count", "min", "max"] as const;
|
|
12
|
+
|
|
13
|
+
export const orderListSchema = z.object({
|
|
14
|
+
namedFilter: z.enum(NAMED_FILTER_IDS).optional(),
|
|
15
|
+
search: z.string().optional(),
|
|
16
|
+
sort: z.string().optional(),
|
|
17
|
+
sortDirection: z.enum(["asc", "desc"]).optional(),
|
|
18
|
+
limit: z.number().int().positive().max(200).optional(),
|
|
19
|
+
offset: z.number().int().nonnegative().optional(),
|
|
20
|
+
totalCount: z.boolean().optional(),
|
|
21
|
+
aggregate: z
|
|
22
|
+
.object({
|
|
23
|
+
groupBy: z.string().optional(),
|
|
24
|
+
measures: z
|
|
25
|
+
.array(z.object({ field: z.string(), kind: z.enum(AGGREGATE_MEASURE_KINDS) }))
|
|
26
|
+
.default([]),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type OrderListPayload = z.infer<typeof orderListSchema>;
|
|
32
|
+
|
|
33
|
+
// The list sends its narrowing (named filter, search) to the summary query as well; limit and paging never reach it.
|
|
34
|
+
export const orderSummarySchema = z.object({
|
|
35
|
+
namedFilter: z.enum(NAMED_FILTER_IDS).optional(),
|
|
36
|
+
search: z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type OrderSummaryPayload = z.infer<typeof orderSummarySchema>;
|
|
40
|
+
|
|
41
|
+
type RowTone = "ok" | "warn" | "bad" | "critical" | "neutral";
|
|
42
|
+
type UrgencyTone = "negative" | "warn" | "neutral" | "positive";
|
|
43
|
+
|
|
44
|
+
export type OrderRow = {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly orderNumber: string;
|
|
47
|
+
readonly customerName: string;
|
|
48
|
+
readonly tone: RowTone;
|
|
49
|
+
readonly urgency: number;
|
|
50
|
+
readonly urgencyLabel: string;
|
|
51
|
+
readonly urgencyTone: UrgencyTone;
|
|
52
|
+
readonly nextStep: string;
|
|
53
|
+
readonly nextStepDue: string;
|
|
54
|
+
readonly nextStepReason: string;
|
|
55
|
+
readonly nextStepReasonTitle?: string;
|
|
56
|
+
readonly nextStepReasonOpen?: boolean;
|
|
57
|
+
readonly openAmount: number;
|
|
58
|
+
readonly status: "processing" | "shipped" | "closing" | "delivered";
|
|
59
|
+
readonly actionLabel: string;
|
|
60
|
+
readonly canRemind: boolean;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const ORDER_ROWS: readonly OrderRow[] = [
|
|
64
|
+
{
|
|
65
|
+
id: "o1",
|
|
66
|
+
orderNumber: "SO-10482",
|
|
67
|
+
customerName: "Aiko Tanaka",
|
|
68
|
+
tone: "bad",
|
|
69
|
+
urgency: 92,
|
|
70
|
+
urgencyLabel: "Critical",
|
|
71
|
+
urgencyTone: "negative",
|
|
72
|
+
nextStep: "Send payment reminder",
|
|
73
|
+
nextStepDue: "by Friday",
|
|
74
|
+
nextStepReason: "312 EUR is 14 days overdue.\nTwo earlier mails stayed unanswered.",
|
|
75
|
+
nextStepReasonTitle: "Rule 10 · Payment overdue.",
|
|
76
|
+
nextStepReasonOpen: true,
|
|
77
|
+
openAmount: 312,
|
|
78
|
+
status: "processing",
|
|
79
|
+
actionLabel: "Send reminder",
|
|
80
|
+
canRemind: true,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "o2",
|
|
84
|
+
orderNumber: "SO-10483",
|
|
85
|
+
customerName: "Jonas Weber",
|
|
86
|
+
tone: "ok",
|
|
87
|
+
urgency: 0,
|
|
88
|
+
urgencyLabel: "",
|
|
89
|
+
urgencyTone: "neutral",
|
|
90
|
+
nextStep: "",
|
|
91
|
+
nextStepDue: "",
|
|
92
|
+
nextStepReason: "",
|
|
93
|
+
openAmount: 0,
|
|
94
|
+
status: "delivered",
|
|
95
|
+
actionLabel: "",
|
|
96
|
+
canRemind: false,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "o3",
|
|
100
|
+
orderNumber: "SO-10484",
|
|
101
|
+
customerName: "Maria Lopez",
|
|
102
|
+
tone: "warn",
|
|
103
|
+
urgency: 74,
|
|
104
|
+
urgencyLabel: "Overdue",
|
|
105
|
+
urgencyTone: "negative",
|
|
106
|
+
nextStep: "Confirm the delivery slot",
|
|
107
|
+
nextStepDue: "Tuesday",
|
|
108
|
+
nextStepReason: "The carrier asked twice for a date.",
|
|
109
|
+
openAmount: 180,
|
|
110
|
+
status: "shipped",
|
|
111
|
+
actionLabel: "Open order",
|
|
112
|
+
canRemind: false,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "o4",
|
|
116
|
+
orderNumber: "SO-10485",
|
|
117
|
+
customerName: "Tom Becker",
|
|
118
|
+
tone: "warn",
|
|
119
|
+
urgency: 61,
|
|
120
|
+
urgencyLabel: "Urgent",
|
|
121
|
+
urgencyTone: "warn",
|
|
122
|
+
nextStep: "Call about the backorder",
|
|
123
|
+
nextStepDue: "tomorrow",
|
|
124
|
+
nextStepReason: "Two of five items are backordered.\nThe customer expects a full delivery.",
|
|
125
|
+
openAmount: 540,
|
|
126
|
+
status: "processing",
|
|
127
|
+
actionLabel: "Open order",
|
|
128
|
+
canRemind: false,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "o5",
|
|
132
|
+
orderNumber: "SO-10486",
|
|
133
|
+
customerName: "Priya Nair",
|
|
134
|
+
tone: "neutral",
|
|
135
|
+
urgency: 35,
|
|
136
|
+
urgencyLabel: "Due",
|
|
137
|
+
urgencyTone: "neutral",
|
|
138
|
+
nextStep: "Review the credit limit",
|
|
139
|
+
nextStepDue: "next week",
|
|
140
|
+
nextStepReason: "The open balance grew past the agreed limit.",
|
|
141
|
+
openAmount: 1190,
|
|
142
|
+
status: "closing",
|
|
143
|
+
actionLabel: "Open order",
|
|
144
|
+
canRemind: false,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "o6",
|
|
148
|
+
orderNumber: "SO-10487",
|
|
149
|
+
customerName: "Lars Hansen",
|
|
150
|
+
tone: "ok",
|
|
151
|
+
urgency: 0,
|
|
152
|
+
urgencyLabel: "",
|
|
153
|
+
urgencyTone: "neutral",
|
|
154
|
+
nextStep: "",
|
|
155
|
+
nextStepDue: "",
|
|
156
|
+
nextStepReason: "",
|
|
157
|
+
openAmount: 0,
|
|
158
|
+
status: "delivered",
|
|
159
|
+
actionLabel: "",
|
|
160
|
+
canRemind: false,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: "o7",
|
|
164
|
+
orderNumber: "SO-10488",
|
|
165
|
+
customerName: "Emma Rossi",
|
|
166
|
+
tone: "bad",
|
|
167
|
+
urgency: 80,
|
|
168
|
+
urgencyLabel: "Overdue",
|
|
169
|
+
urgencyTone: "negative",
|
|
170
|
+
nextStep: "Send payment reminder",
|
|
171
|
+
nextStepDue: "Thursday",
|
|
172
|
+
nextStepReason: "180 EUR is 9 days overdue.",
|
|
173
|
+
openAmount: 180,
|
|
174
|
+
status: "processing",
|
|
175
|
+
actionLabel: "Send reminder",
|
|
176
|
+
canRemind: true,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: "o8",
|
|
180
|
+
orderNumber: "SO-10489",
|
|
181
|
+
customerName: "Kenji Mori",
|
|
182
|
+
tone: "ok",
|
|
183
|
+
urgency: 0,
|
|
184
|
+
urgencyLabel: "",
|
|
185
|
+
urgencyTone: "neutral",
|
|
186
|
+
nextStep: "",
|
|
187
|
+
nextStepDue: "",
|
|
188
|
+
nextStepReason: "",
|
|
189
|
+
openAmount: 95,
|
|
190
|
+
status: "closing",
|
|
191
|
+
actionLabel: "",
|
|
192
|
+
canRemind: false,
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
|
|
196
|
+
const NAMED_FILTER_PREDICATES: Readonly<Record<OrderNamedFilterId, (row: OrderRow) => boolean>> = {
|
|
197
|
+
"action-needed": (row) => row.nextStep !== "",
|
|
198
|
+
"reminder-due": (row) => row.canRemind && row.nextStepDue === "today",
|
|
199
|
+
"ending-soon": (row) => row.status === "closing",
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
203
|
+
|
|
204
|
+
function matchesSearch(row: OrderRow, search: string | undefined): boolean {
|
|
205
|
+
if (search === undefined || search === "") return true;
|
|
206
|
+
const needle = search.toLowerCase();
|
|
207
|
+
return (
|
|
208
|
+
row.orderNumber.toLowerCase().includes(needle) ||
|
|
209
|
+
row.customerName.toLowerCase().includes(needle)
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function fieldValue(row: OrderRow, field: string): unknown {
|
|
214
|
+
return Object.entries(row).find(([key]) => key === field)?.[1];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function compareRows(
|
|
218
|
+
field: string,
|
|
219
|
+
direction: "asc" | "desc",
|
|
220
|
+
): (a: OrderRow, b: OrderRow) => number {
|
|
221
|
+
const sign = direction === "asc" ? 1 : -1;
|
|
222
|
+
return (a, b) => {
|
|
223
|
+
const left = fieldValue(a, field);
|
|
224
|
+
const right = fieldValue(b, field);
|
|
225
|
+
if (typeof left === "number" && typeof right === "number") return sign * (left - right);
|
|
226
|
+
return sign * String(left).localeCompare(String(right));
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function filteredRows(payload: OrderListPayload): readonly OrderRow[] {
|
|
231
|
+
const predicate =
|
|
232
|
+
payload.namedFilter === undefined ? undefined : NAMED_FILTER_PREDICATES[payload.namedFilter];
|
|
233
|
+
return ORDER_ROWS.filter(
|
|
234
|
+
(row) => (predicate === undefined || predicate(row)) && matchesSearch(row, payload.search),
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function numericValues(rows: readonly OrderRow[], field: string): number[] {
|
|
239
|
+
return rows.flatMap((row) => {
|
|
240
|
+
const value = fieldValue(row, field);
|
|
241
|
+
return typeof value === "number" ? [value] : [];
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function measureOf(
|
|
246
|
+
kind: (typeof AGGREGATE_MEASURE_KINDS)[number],
|
|
247
|
+
rows: readonly OrderRow[],
|
|
248
|
+
field: string,
|
|
249
|
+
): number | null {
|
|
250
|
+
if (kind === "count") return rows.length;
|
|
251
|
+
const values = numericValues(rows, field);
|
|
252
|
+
if (values.length === 0) return null;
|
|
253
|
+
const sum = values.reduce((total, value) => total + value, 0);
|
|
254
|
+
if (kind === "sum") return sum;
|
|
255
|
+
if (kind === "avg") return sum / values.length;
|
|
256
|
+
return kind === "min" ? Math.min(...values) : Math.max(...values);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export type OrderListAnswer =
|
|
260
|
+
| {
|
|
261
|
+
readonly groups: readonly {
|
|
262
|
+
readonly key: null;
|
|
263
|
+
readonly count: number;
|
|
264
|
+
readonly measures: readonly (number | null)[];
|
|
265
|
+
}[];
|
|
266
|
+
}
|
|
267
|
+
| {
|
|
268
|
+
readonly rows: readonly (OrderRow & {
|
|
269
|
+
readonly narrowOpen: string;
|
|
270
|
+
readonly narrowStatus: string;
|
|
271
|
+
readonly actionScreen?: string;
|
|
272
|
+
readonly actionParams?: { readonly entityId: string };
|
|
273
|
+
})[];
|
|
274
|
+
readonly nextCursor: null;
|
|
275
|
+
readonly total?: number;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export function answerOrderList(payload: OrderListPayload): OrderListAnswer {
|
|
279
|
+
const matching = filteredRows(payload);
|
|
280
|
+
if (payload.aggregate !== undefined) {
|
|
281
|
+
return {
|
|
282
|
+
groups: [
|
|
283
|
+
{
|
|
284
|
+
key: null,
|
|
285
|
+
count: matching.length,
|
|
286
|
+
measures: payload.aggregate.measures.map((m) => measureOf(m.kind, matching, m.field)),
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
const ordered =
|
|
292
|
+
payload.sort === undefined
|
|
293
|
+
? matching
|
|
294
|
+
: [...matching].sort(compareRows(payload.sort, payload.sortDirection ?? "asc"));
|
|
295
|
+
const offset = payload.offset ?? 0;
|
|
296
|
+
const rows = ordered.slice(offset, offset + (payload.limit ?? DEFAULT_PAGE_SIZE)).map((row) => ({
|
|
297
|
+
...row,
|
|
298
|
+
narrowOpen: `${euro(row.openAmount)} open`,
|
|
299
|
+
narrowStatus: row.status,
|
|
300
|
+
nextStepShort: row.nextStepDue === "" ? "" : `${row.nextStepDue} · ${euro(row.openAmount)}`,
|
|
301
|
+
...(row.nextStep !== "" && {
|
|
302
|
+
actionScreen: ORDER_DETAIL_SCREEN_QN,
|
|
303
|
+
actionParams: { entityId: row.id },
|
|
304
|
+
}),
|
|
305
|
+
}));
|
|
306
|
+
return {
|
|
307
|
+
rows,
|
|
308
|
+
nextCursor: null,
|
|
309
|
+
...(payload.totalCount === true && { total: matching.length }),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export function answerOrderSummary(payload: OrderSummaryPayload) {
|
|
314
|
+
const matching = filteredRows(payload);
|
|
315
|
+
const overdue = matching.filter((row) => row.urgencyTone === "negative");
|
|
316
|
+
return {
|
|
317
|
+
items: [
|
|
318
|
+
{ label: "Orders", value: matching.length, column: "orderNumber" },
|
|
319
|
+
{
|
|
320
|
+
label: "Open",
|
|
321
|
+
value: euro(matching.reduce((total, row) => total + row.openAmount, 0)),
|
|
322
|
+
column: "openAmount",
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
label: "Overdue",
|
|
326
|
+
value: euro(overdue.reduce((total, row) => total + row.openAmount, 0)),
|
|
327
|
+
tone: "bad",
|
|
328
|
+
column: "urgencyLabel",
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function actionNeededRows(limit: number): readonly OrderRow[] {
|
|
335
|
+
return ORDER_ROWS.filter(NAMED_FILTER_PREDICATES["action-needed"])
|
|
336
|
+
.sort(compareRows("urgency", "desc"))
|
|
337
|
+
.slice(0, limit);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const NOW_LIST_LIMIT = 4;
|
|
341
|
+
|
|
342
|
+
export function answerNowList() {
|
|
343
|
+
return {
|
|
344
|
+
rows: actionNeededRows(NOW_LIST_LIMIT).map((row) => ({
|
|
345
|
+
...row,
|
|
346
|
+
nextStepShort: `${row.nextStepDue} · ${euro(row.openAmount)}`,
|
|
347
|
+
actionScreen: ORDER_DETAIL_SCREEN_QN,
|
|
348
|
+
actionParams: { entityId: row.id },
|
|
349
|
+
})),
|
|
350
|
+
total: actionNeededRows(ORDER_ROWS.length).length,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// The params of the "reminder due" empty state; null while no order is waiting for a reminder.
|
|
355
|
+
export function answerNextReminder(): { readonly customer: string; readonly due: string } | null {
|
|
356
|
+
const next = ORDER_ROWS.find((row) => row.canRemind);
|
|
357
|
+
return next === undefined ? null : { customer: next.customerName, due: next.nextStepDue };
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function answerBriefing() {
|
|
361
|
+
const open = actionNeededRows(ORDER_ROWS.length);
|
|
362
|
+
const [first] = open;
|
|
363
|
+
return {
|
|
364
|
+
blocks: [
|
|
365
|
+
{
|
|
366
|
+
kind: "paragraph",
|
|
367
|
+
emphasis: "lead",
|
|
368
|
+
text: `${open.length} orders need you today.${
|
|
369
|
+
first === undefined
|
|
370
|
+
? ""
|
|
371
|
+
: ` Most pressing is ${first.orderNumber} from ${first.customerName}.`
|
|
372
|
+
}`,
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
kind: "hint",
|
|
376
|
+
text: "Sorted by urgency. Open an order and let the assistant prepare the step.",
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
narrowBlocks: [
|
|
380
|
+
{ kind: "paragraph", emphasis: "lead", text: `${open.length} orders need you today.` },
|
|
381
|
+
{ kind: "hint", text: "Tuesday, 3 November · as of 06:00" },
|
|
382
|
+
],
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const DEADLINES = [
|
|
387
|
+
{ id: "d1", due: "2026-11-06T09:00:00Z", title: "Reminder SO-10482", orderId: "o1" },
|
|
388
|
+
{ id: "d2", due: "2026-11-05T14:00:00Z", title: "Call Tom Becker", orderId: "o4" },
|
|
389
|
+
{ id: "d3", due: "2026-11-10T10:30:00Z", title: "Credit review SO-10486", orderId: "o5" },
|
|
390
|
+
{ id: "d4", due: "2026-11-12T08:00:00Z", title: "Delivery slot SO-10484", orderId: "o3" },
|
|
391
|
+
] as const;
|
|
392
|
+
|
|
393
|
+
export function answerDeadlines() {
|
|
394
|
+
return {
|
|
395
|
+
rows: [...DEADLINES]
|
|
396
|
+
.sort((a, b) => a.due.localeCompare(b.due))
|
|
397
|
+
.map((deadline) => ({
|
|
398
|
+
id: deadline.id,
|
|
399
|
+
due: deadline.due,
|
|
400
|
+
title: deadline.title,
|
|
401
|
+
screen: ORDER_DETAIL_SCREEN_QN,
|
|
402
|
+
params: { entityId: deadline.orderId },
|
|
403
|
+
})),
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const CUSTOMERS = [
|
|
408
|
+
{
|
|
409
|
+
id: "c1",
|
|
410
|
+
customerName: "Aiko Tanaka",
|
|
411
|
+
openCount: 3,
|
|
412
|
+
openTone: "negative",
|
|
413
|
+
tone: "bad",
|
|
414
|
+
orderId: "o1",
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
id: "c2",
|
|
418
|
+
customerName: "Priya Nair",
|
|
419
|
+
openCount: 2,
|
|
420
|
+
openTone: "warn",
|
|
421
|
+
tone: "warn",
|
|
422
|
+
orderId: "o5",
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
id: "c3",
|
|
426
|
+
customerName: "Tom Becker",
|
|
427
|
+
openCount: 1,
|
|
428
|
+
openTone: "neutral",
|
|
429
|
+
tone: "neutral",
|
|
430
|
+
orderId: "o4",
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
id: "c4",
|
|
434
|
+
customerName: "Jonas Weber",
|
|
435
|
+
openCount: 0,
|
|
436
|
+
openTone: "positive",
|
|
437
|
+
tone: "ok",
|
|
438
|
+
orderId: "o2",
|
|
439
|
+
},
|
|
440
|
+
] as const;
|
|
441
|
+
|
|
442
|
+
export function answerCustomers() {
|
|
443
|
+
return {
|
|
444
|
+
rows: CUSTOMERS.map((customer) => ({
|
|
445
|
+
id: customer.id,
|
|
446
|
+
customerName: customer.customerName,
|
|
447
|
+
openCount: customer.openCount,
|
|
448
|
+
openTone: customer.openTone,
|
|
449
|
+
tone: customer.tone,
|
|
450
|
+
screen: ORDER_DETAIL_SCREEN_QN,
|
|
451
|
+
params: { entityId: customer.orderId },
|
|
452
|
+
})),
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function euro(amount: number): string {
|
|
457
|
+
return `€ ${amount.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export function answerMoney() {
|
|
461
|
+
const open = ORDER_ROWS.reduce((total, row) => total + row.openAmount, 0);
|
|
462
|
+
const overdue = ORDER_ROWS.filter((row) => row.urgencyTone === "negative").reduce(
|
|
463
|
+
(total, row) => total + row.openAmount,
|
|
464
|
+
0,
|
|
465
|
+
);
|
|
466
|
+
return {
|
|
467
|
+
open: euro(open),
|
|
468
|
+
overdue: euro(overdue),
|
|
469
|
+
collected: euro(1860),
|
|
470
|
+
openOrders: String(ORDER_ROWS.filter((row) => row.openAmount > 0).length),
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export function answerOrderDetail(id: string) {
|
|
475
|
+
return {
|
|
476
|
+
id,
|
|
477
|
+
customerName: "Aiko Tanaka",
|
|
478
|
+
orderNumber: "SO-10482",
|
|
479
|
+
shortTitle: "SO-10482",
|
|
480
|
+
status: "processing",
|
|
481
|
+
totalAmount: "€ 1,248.00",
|
|
482
|
+
totalNote: "2 payments",
|
|
483
|
+
outstandingAmount: "€ 312.00",
|
|
484
|
+
outstandingNote: "14 days overdue",
|
|
485
|
+
outstandingLabel: "Outstanding since 01.12.",
|
|
486
|
+
outstandingTone: "bad",
|
|
487
|
+
itemCount: "3",
|
|
488
|
+
itemsCount: 3,
|
|
489
|
+
paymentsCount: 2,
|
|
490
|
+
placedAt: "2026-08-21",
|
|
491
|
+
shippingAddress: "Karl-Marx-Straße 12, 12043 Berlin",
|
|
492
|
+
billingAddress: "Karl-Marx-Straße 12, 12043 Berlin",
|
|
493
|
+
salesRep: "Jonas Weber",
|
|
494
|
+
path: [{ label: "Orders" }, { label: "Aiko Tanaka" }, { label: "SO-10482" }],
|
|
495
|
+
summaryLine: "Waiting for the second payment",
|
|
496
|
+
summaryShort: "Second payment open.",
|
|
497
|
+
summaryTone: "warn",
|
|
498
|
+
narrowSubtitle: "SO-10482 · placed 21 Aug",
|
|
499
|
+
notice: { title: "Payment overdue", text: "312 EUR is 14 days overdue", tone: "bad" },
|
|
500
|
+
steps: [
|
|
501
|
+
{
|
|
502
|
+
id: "remind",
|
|
503
|
+
title: "Send payment reminder",
|
|
504
|
+
detail: "by Friday",
|
|
505
|
+
narrowDetail: "Fri",
|
|
506
|
+
tone: "warn",
|
|
507
|
+
whyOpen: true,
|
|
508
|
+
whyTitle: "Rule 10 · Payment overdue.",
|
|
509
|
+
why: "The invoice is 14 days overdue.\nTwo earlier mails stayed unanswered.\nThe credit limit is 1,500 EUR.",
|
|
510
|
+
canPrepare: true,
|
|
511
|
+
},
|
|
512
|
+
{ id: "escalate", title: "Escalate to accounting", canPrepare: false },
|
|
513
|
+
{ id: "credit", title: "Review the credit limit", canPrepare: false },
|
|
514
|
+
{ id: "handover", title: "Plan the handover", canPrepare: false },
|
|
515
|
+
{ id: "close", title: "Close the order", canPrepare: false },
|
|
516
|
+
],
|
|
517
|
+
progress: [
|
|
518
|
+
{
|
|
519
|
+
title: "Order to cash",
|
|
520
|
+
currentIndex: 1,
|
|
521
|
+
steps: [
|
|
522
|
+
{ id: "placed", label: "Placed", done: true, detail: "21 Aug" },
|
|
523
|
+
{ id: "paid", label: "Paid", done: false, detail: "312 EUR open" },
|
|
524
|
+
{ id: "shipped", label: "Shipped", done: false },
|
|
525
|
+
],
|
|
526
|
+
},
|
|
527
|
+
],
|
|
528
|
+
};
|
|
529
|
+
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ExtensionSectionProps,
|
|
3
|
-
usePrimitives,
|
|
4
|
-
useTranslation,
|
|
5
|
-
} from "@cosmicdrift/kumiko-renderer";
|
|
6
|
-
import { type ReactNode, useMemo, useState } from "react";
|
|
7
|
-
import { DocumentContentEditor } from "../../template-resolver/web/index.ts";
|
|
8
|
-
import { effectiveBodyFormat } from "./constants.ts";
|
|
9
|
-
import { detectLossyMarkdown, type LossyMarkdownFeature } from "./lossy-markdown.ts";
|
|
10
|
-
import { markdownToDocumentHtml } from "./markdown-to-document.ts";
|
|
11
|
-
|
|
12
|
-
const LOSSY_LABEL_KEYS: Readonly<Record<LossyMarkdownFeature, string>> = {
|
|
13
|
-
image: "managed-pages:body.lossy.image",
|
|
14
|
-
blockquote: "managed-pages:body.lossy.blockquote",
|
|
15
|
-
code: "managed-pages:body.lossy.code",
|
|
16
|
-
deepHeading: "managed-pages:body.lossy.deepHeading",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const BODY_EDITOR_ID = "managed-pages-page-body";
|
|
20
|
-
|
|
21
|
-
function stringValue(value: unknown): string {
|
|
22
|
-
return typeof value === "string" ? value : "";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// A Markdown body is converted for display only: nothing is patched until the
|
|
26
|
-
// user edits, so merely opening a page never turns it into a document.
|
|
27
|
-
export function PageBodySection({ values, patch }: ExtensionSectionProps): ReactNode {
|
|
28
|
-
const t = useTranslation();
|
|
29
|
-
const { Banner } = usePrimitives();
|
|
30
|
-
const body = stringValue(values?.["body"]);
|
|
31
|
-
const isMarkdown = effectiveBodyFormat(values?.["bodyFormat"]) === "markdown";
|
|
32
|
-
const [editedHtml, setEditedHtml] = useState<string | null>(null);
|
|
33
|
-
const [lossyAtFirstEdit, setLossyAtFirstEdit] = useState<readonly LossyMarkdownFeature[] | null>(
|
|
34
|
-
null,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const pristine = editedHtml === null;
|
|
38
|
-
const convertedHtml = useMemo(
|
|
39
|
-
() => (isMarkdown ? markdownToDocumentHtml(body) : body),
|
|
40
|
-
[isMarkdown, body],
|
|
41
|
-
);
|
|
42
|
-
const liveLossy = useMemo(
|
|
43
|
-
() => (pristine && isMarkdown ? detectLossyMarkdown(body) : []),
|
|
44
|
-
[pristine, isMarkdown, body],
|
|
45
|
-
);
|
|
46
|
-
const lossy = lossyAtFirstEdit ?? liveLossy;
|
|
47
|
-
|
|
48
|
-
const handleChange = (next: string): void => {
|
|
49
|
-
if (pristine) setLossyAtFirstEdit(liveLossy);
|
|
50
|
-
setEditedHtml(next);
|
|
51
|
-
patch?.({ body: next, bodyFormat: "document" });
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<>
|
|
56
|
-
{lossy.length > 0 && (
|
|
57
|
-
<Banner variant="warning">
|
|
58
|
-
{t("managed-pages:body.lossy.warning", {
|
|
59
|
-
features: lossy.map((feature) => t(LOSSY_LABEL_KEYS[feature])).join(", "),
|
|
60
|
-
})}
|
|
61
|
-
</Banner>
|
|
62
|
-
)}
|
|
63
|
-
<DocumentContentEditor
|
|
64
|
-
id={BODY_EDITOR_ID}
|
|
65
|
-
value={editedHtml ?? convertedHtml}
|
|
66
|
-
onChange={handleChange}
|
|
67
|
-
variables={[]}
|
|
68
|
-
readOnly={false}
|
|
69
|
-
/>
|
|
70
|
-
</>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Paddle.js runs with a public client token and can open checkouts with any
|
|
2
|
-
// `customData` from the browser, so `custom_data.tenantId` alone proves nothing.
|
|
3
|
-
// The binding is an HMAC only the server can produce: webhooks whose tenantId
|
|
4
|
-
// does not carry a valid binding are ignored.
|
|
5
|
-
|
|
6
|
-
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
7
|
-
import { parseProviderConsentId } from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
|
|
8
|
-
|
|
9
|
-
const BINDING_CONTEXT = "kumiko-paddle-tenant:v1:";
|
|
10
|
-
|
|
11
|
-
export function signTenantBinding(key: string, tenantId: string): string {
|
|
12
|
-
return createHmac("sha256", key).update(`${BINDING_CONTEXT}${tenantId}`).digest("base64url");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function isValidTenantBinding(key: string, tenantId: string, binding: string): boolean {
|
|
16
|
-
const expected = Buffer.from(signTenantBinding(key, tenantId));
|
|
17
|
-
const candidate = Buffer.from(binding);
|
|
18
|
-
return candidate.length === expected.length && timingSafeEqual(candidate, expected);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type BoundTenant = { readonly tenantId: string; readonly consentId?: string };
|
|
22
|
-
|
|
23
|
-
/** Null unless `customData` names a tenant together with a binding that `key` signed. */
|
|
24
|
-
export function boundTenantOf(
|
|
25
|
-
customData: Readonly<Record<string, unknown>> | null | undefined,
|
|
26
|
-
key: string,
|
|
27
|
-
): BoundTenant | null {
|
|
28
|
-
const tenantId = customData?.["tenantId"];
|
|
29
|
-
const binding = customData?.["tenantBinding"];
|
|
30
|
-
if (typeof tenantId !== "string" || tenantId.length === 0) return null;
|
|
31
|
-
if (typeof binding !== "string" || !isValidTenantBinding(key, tenantId, binding)) return null;
|
|
32
|
-
const consentId = parseProviderConsentId(customData?.["consentId"]);
|
|
33
|
-
return { tenantId, ...(consentId !== undefined && { consentId }) };
|
|
34
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ContentPreview, usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
|
|
2
|
-
import { type ReactNode, useId, useState } from "react";
|
|
3
|
-
import { DocumentBlocksContext } from "./document-editor.tsx";
|
|
4
|
-
import type { CollectionEditorContext } from "./use-collection-editor-context.ts";
|
|
5
|
-
|
|
6
|
-
export type ContentFieldProps = {
|
|
7
|
-
readonly editorContext: CollectionEditorContext;
|
|
8
|
-
readonly value: string;
|
|
9
|
-
readonly onChange: (value: string) => void;
|
|
10
|
-
readonly disabled: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// The content input shared by the edit and create forms: the collection's editor
|
|
14
|
-
// plus a toggle to its preview with the example variables substituted.
|
|
15
|
-
export function ContentField({
|
|
16
|
-
editorContext,
|
|
17
|
-
value,
|
|
18
|
-
onChange,
|
|
19
|
-
disabled,
|
|
20
|
-
}: ContentFieldProps): ReactNode {
|
|
21
|
-
const { Field, Button } = usePrimitives();
|
|
22
|
-
const t = useTranslation();
|
|
23
|
-
const contentEditorId = useId();
|
|
24
|
-
const [previewing, setPreviewing] = useState(false);
|
|
25
|
-
const { ContentEditor, contentFormat, documentBlocks, variableExamples, variables } =
|
|
26
|
-
editorContext;
|
|
27
|
-
return (
|
|
28
|
-
<Field
|
|
29
|
-
id={contentEditorId}
|
|
30
|
-
label={t("template-resolver.editor.contentLabel")}
|
|
31
|
-
labelAppendix={
|
|
32
|
-
<Button
|
|
33
|
-
type="button"
|
|
34
|
-
variant="secondary"
|
|
35
|
-
size="sm"
|
|
36
|
-
onClick={() => setPreviewing((p) => !p)}
|
|
37
|
-
>
|
|
38
|
-
{previewing ? t("kumiko.contentEditor.editMode") : t("kumiko.contentEditor.preview")}
|
|
39
|
-
</Button>
|
|
40
|
-
}
|
|
41
|
-
>
|
|
42
|
-
{previewing ? (
|
|
43
|
-
<ContentPreview
|
|
44
|
-
content={value}
|
|
45
|
-
variables={variableExamples}
|
|
46
|
-
contentFormat={contentFormat}
|
|
47
|
-
/>
|
|
48
|
-
) : (
|
|
49
|
-
<DocumentBlocksContext.Provider value={documentBlocks}>
|
|
50
|
-
<ContentEditor
|
|
51
|
-
id={contentEditorId}
|
|
52
|
-
value={value}
|
|
53
|
-
onChange={onChange}
|
|
54
|
-
variables={variables}
|
|
55
|
-
readOnly={disabled}
|
|
56
|
-
/>
|
|
57
|
-
</DocumentBlocksContext.Provider>
|
|
58
|
-
)}
|
|
59
|
-
</Field>
|
|
60
|
-
);
|
|
61
|
-
}
|