@cosmicdrift/kumiko-samples 0.387.0 → 0.389.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 +8 -1
- package/packages/bundled-features/src/agent-tools/changes.json +12 -0
- package/packages/bundled-features/src/agent-tools/index.ts +1 -1
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +48 -32
- package/packages/bundled-features/src/audit/changes.json +12 -0
- package/packages/bundled-features/src/audit/feature.ts +1 -0
- package/packages/bundled-features/src/audit/handlers/audit-events.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/changes.json +12 -0
- package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/handlers/signup-request.write.ts +4 -0
- package/packages/bundled-features/src/auth-email-password/handlers/token-request-handler.ts +8 -0
- package/packages/bundled-features/src/auth-email-password/magic-link-mail.ts +16 -3
- package/packages/bundled-features/src/auth-email-password/signup-activation.ts +2 -0
- package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +8 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +23 -21
- package/packages/bundled-features/src/auth-email-password/web/default-auth-pages-gate.tsx +6 -3
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +11 -1
- package/packages/bundled-features/src/auth-email-password/web/index.ts +5 -0
- package/packages/bundled-features/src/auth-email-password/web/login-screen.tsx +16 -5
- package/packages/bundled-features/src/auth-email-password/web/reset-password-screen.tsx +7 -1
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +35 -0
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +6 -1
- package/packages/bundled-features/src/auth-email-password/web/signup-complete-screen.tsx +11 -3
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +12 -2
- package/packages/bundled-features/src/auth-mfa/changes.json +12 -0
- package/packages/bundled-features/src/auth-mfa/config.ts +3 -7
- package/packages/bundled-features/src/auth-mfa/feature-exports.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/feature.ts +6 -0
- package/packages/bundled-features/src/auth-mfa/mfa-status-checker.ts +8 -5
- package/packages/bundled-features/src/auth-mfa/web/i18n.ts +6 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +68 -0
- package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +23 -13
- package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +23 -13
- package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +15 -6
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +65 -18
- package/packages/bundled-features/src/billing-foundation/changes.json +55 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +32 -42
- package/packages/bundled-features/src/billing-foundation/consumer-protection/confirmation-mail.ts +8 -2
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/issue-confirmation.ts +14 -3
- package/packages/bundled-features/src/billing-foundation/consumer-protection/mail-notifications.ts +3 -4
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-receipt-limit.ts +12 -6
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +35 -19
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-request.ts +12 -8
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +14 -8
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-texts.ts +5 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/withdrawal-period.ts +8 -10
- package/packages/bundled-features/src/billing-foundation/events.ts +1 -0
- package/packages/bundled-features/src/billing-foundation/feature.ts +3 -1
- package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +71 -6
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +1 -0
- package/packages/bundled-features/src/billing-foundation/handlers/plan-switch-preview.query.ts +65 -0
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +9 -2
- package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +44 -8
- package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +72 -82
- package/packages/bundled-features/src/billing-foundation/handlers/sync-subscription.write.ts +14 -1
- package/packages/bundled-features/src/billing-foundation/i18n.ts +22 -0
- package/packages/bundled-features/src/billing-foundation/index.ts +2 -0
- package/packages/bundled-features/src/billing-foundation/plan-catalog.ts +62 -27
- package/packages/bundled-features/src/billing-foundation/plan-switch.ts +84 -0
- package/packages/bundled-features/src/billing-foundation/types.ts +80 -1
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +19 -0
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +119 -47
- package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +89 -42
- package/packages/bundled-features/src/billing-foundation/web/constants.ts +4 -0
- package/packages/bundled-features/src/billing-foundation/web/plan-price.ts +55 -0
- package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +224 -0
- package/packages/bundled-features/src/cap-counter/cap-reservation.ts +25 -8
- package/packages/bundled-features/src/cap-counter/changes.json +30 -0
- package/packages/bundled-features/src/cap-counter/enforce-cap.ts +2 -1
- package/packages/bundled-features/src/cap-counter/feature.ts +1 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +8 -1
- package/packages/bundled-features/src/cap-overview/feature.ts +1 -0
- package/packages/bundled-features/src/channel-email/changes.json +6 -0
- package/packages/bundled-features/src/channel-email/feature.ts +1 -1
- package/packages/bundled-features/src/config/changes.json +18 -0
- package/packages/bundled-features/src/config/handlers/cascade.query.ts +4 -2
- package/packages/bundled-features/src/config/handlers/set.write.ts +19 -2
- package/packages/bundled-features/src/config/handlers/values.query.ts +4 -2
- package/packages/bundled-features/src/config/write-helpers.ts +27 -8
- package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +11 -10
- package/packages/bundled-features/src/custom-fields/lib/parse-serialized-field.ts +1 -1
- package/packages/bundled-features/src/delivery/changes.json +42 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +9 -3
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +2 -2
- package/packages/bundled-features/src/delivery/delivery-service.ts +35 -5
- package/packages/bundled-features/src/delivery/feature.ts +1 -0
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +20 -1
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +1 -1
- package/packages/bundled-features/src/delivery/index.ts +5 -0
- package/packages/bundled-features/src/delivery/system-channel-context.ts +33 -0
- package/packages/bundled-features/src/delivery/unsubscribe-link.ts +3 -1
- package/packages/bundled-features/src/delivery/unsubscribe-page-strings.ts +1 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +6 -0
- package/packages/bundled-features/src/delivery/unsubscribe.ts +36 -15
- package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +84 -0
- package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/events.ts +15 -0
- package/packages/bundled-features/src/document-ingest-foundation/index.ts +11 -0
- package/packages/bundled-features/src/feature-toggles/feature.ts +1 -0
- package/packages/bundled-features/src/file-foundation/index.ts +1 -0
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +7 -1
- package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +0 -2
- package/packages/bundled-features/src/files/README.md +1 -1
- package/packages/bundled-features/src/form-draft/changes.json +6 -0
- package/packages/bundled-features/src/form-draft/db/queries/cleanup.ts +2 -2
- package/packages/bundled-features/src/form-draft/decrypt-draft.ts +4 -1
- package/packages/bundled-features/src/host-routing/README.md +1 -1
- package/packages/bundled-features/src/host-routing/changes.json +12 -0
- package/packages/bundled-features/src/host-routing/dispatch.ts +16 -17
- package/packages/bundled-features/src/host-routing/options.ts +2 -1
- package/packages/bundled-features/src/host-routing/validate-options.ts +5 -0
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +18 -0
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/update-account.write.ts +17 -5
- package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +0 -1
- package/packages/bundled-features/src/inbound-mail-foundation/screens.ts +0 -3
- package/packages/bundled-features/src/inbound-mail-foundation/types.ts +4 -3
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +32 -16
- package/packages/bundled-features/src/jobs/changes.json +13 -0
- package/packages/bundled-features/src/jobs/feature.ts +15 -4
- package/packages/bundled-features/src/jobs/handlers/tenant-failures.query.ts +45 -40
- package/packages/bundled-features/src/jobs/handlers/tenant-runs.query.ts +63 -59
- package/packages/bundled-features/src/jobs/job-run-logger.ts +5 -4
- package/packages/bundled-features/src/ledger/web/index.ts +1 -1
- package/packages/bundled-features/src/legal-pages/README.md +1 -1
- package/packages/bundled-features/src/legal-pages/seed.ts +5 -2
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-foundation/feature.ts +5 -3
- package/packages/bundled-features/src/mail-transport-smtp/changes.json +6 -0
- package/packages/bundled-features/src/mail-transport-smtp/config-keys.ts +1 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +9 -11
- package/packages/bundled-features/src/managed-pages/changes.json +6 -0
- package/packages/bundled-features/src/managed-pages/constants.ts +1 -0
- package/packages/bundled-features/src/managed-pages/feature.ts +3 -1
- package/packages/bundled-features/src/managed-pages/index.ts +1 -0
- package/packages/bundled-features/src/notes-history/handlers/add-note.write.ts +1 -1
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -1
- package/packages/bundled-features/src/renderer-pdf/changes.json +6 -0
- package/packages/bundled-features/src/renderer-pdf/render-table-pdf.ts +27 -10
- package/packages/bundled-features/src/secrets/changes.json +6 -0
- package/packages/bundled-features/src/secrets/write-gate.ts +9 -2
- package/packages/bundled-features/src/sessions/changes.json +7 -0
- package/packages/bundled-features/src/sessions/feature.ts +8 -2
- package/packages/bundled-features/src/sessions/index.ts +1 -1
- package/packages/bundled-features/src/sessions/session-callbacks.ts +1 -9
- package/packages/bundled-features/src/shared/decrypt-stored-pii.ts +10 -0
- package/packages/bundled-features/src/shared/index.ts +1 -1
- package/packages/bundled-features/src/shared/mail-template-body.ts +10 -3
- package/packages/bundled-features/src/shared/purge-files-reaching-subject.ts +24 -2
- package/packages/bundled-features/src/shared/run-in-sub-transaction.ts +5 -5
- package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +17 -3
- package/packages/bundled-features/src/step-dispatcher/feature.ts +1 -0
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +2 -1
- package/packages/bundled-features/src/subscription-dodo/changes.json +14 -0
- package/packages/bundled-features/src/subscription-dodo/client.ts +45 -0
- package/packages/bundled-features/src/subscription-dodo/constants.ts +24 -0
- package/packages/bundled-features/src/subscription-dodo/feature.ts +207 -0
- package/packages/bundled-features/src/subscription-dodo/index.ts +16 -0
- package/packages/bundled-features/src/subscription-dodo/plugin-methods.ts +345 -0
- package/packages/bundled-features/src/subscription-dodo/runtime.ts +126 -0
- package/packages/bundled-features/src/subscription-dodo/verify-webhook.ts +262 -0
- package/packages/bundled-features/src/subscription-stripe/changes.json +12 -0
- package/packages/bundled-features/src/subscription-stripe/feature.ts +1 -0
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +7 -6
- package/packages/bundled-features/src/tags/feature.ts +1 -0
- package/packages/bundled-features/src/template-resolver/api.ts +31 -4
- package/packages/bundled-features/src/template-resolver/changes.json +84 -0
- package/packages/bundled-features/src/template-resolver/compile-document-body.ts +1 -0
- package/packages/bundled-features/src/template-resolver/document-ops.ts +20 -1
- package/packages/bundled-features/src/template-resolver/feature.ts +4 -4
- package/packages/bundled-features/src/template-resolver/handlers/bundle-import.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/copy-locale.write.ts +27 -5
- package/packages/bundled-features/src/template-resolver/handlers/diff-to-system.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/document-base.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/find-by-id.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/layout-source.query.ts +36 -11
- package/packages/bundled-features/src/template-resolver/handlers/list.query.ts +18 -19
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +45 -10
- package/packages/bundled-features/src/template-resolver/handlers/patch-draft.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/send-test-status.query.ts +22 -19
- package/packages/bundled-features/src/template-resolver/handlers/tenant-override-counts.query.ts +9 -5
- package/packages/bundled-features/src/template-resolver/handlers/tenant-override-selection.ts +8 -6
- package/packages/bundled-features/src/template-resolver/handlers/tenant-overrides.query.ts +44 -5
- package/packages/bundled-features/src/template-resolver/handlers/usage.query.ts +37 -26
- package/packages/bundled-features/src/template-resolver/handlers/validate.query.ts +7 -2
- package/packages/bundled-features/src/template-resolver/seeding.ts +42 -17
- package/packages/bundled-features/src/template-resolver/store-template-resource.ts +74 -12
- package/packages/bundled-features/src/template-resolver/template-delivery-policy.ts +0 -11
- package/packages/bundled-features/src/template-resolver/template-meta.ts +12 -4
- package/packages/bundled-features/src/template-resolver/template-preview.ts +11 -3
- package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -5
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +6 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/mail-layout-constants.ts +8 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
- package/packages/bundled-features/src/tenant/changes.json +6 -0
- package/packages/bundled-features/src/tenant/feature.ts +1 -0
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +9 -3
- package/packages/bundled-features/src/tenant/handlers/team-list.query.ts +3 -3
- package/packages/bundled-features/src/tenant/handlers/tenant-directory.query.ts +7 -4
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +12 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +5 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +5 -1
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +35 -1
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/handlers/set-tenant-tier.write.ts +4 -1
- package/packages/bundled-features/src/tier-engine/web/constants.ts +3 -3
- package/packages/bundled-features/src/user/feature.ts +1 -0
- package/packages/bundled-features/src/user-data-rights/changes.json +12 -0
- package/packages/bundled-features/src/user-data-rights/feature.ts +1 -0
- package/packages/bundled-features/src/user-data-rights/index.ts +6 -1
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +3 -4
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +2 -1
- package/packages/bundled-features/src/user-data-rights/web/constants.ts +6 -0
- package/packages/bundled-features/src/user-data-rights/web/index.ts +1 -0
- package/packages/bundled-features/src/waitlist/changes.json +36 -0
- package/packages/bundled-features/src/waitlist/feature.ts +1 -0
- package/packages/bundled-features/src/waitlist/handlers/export-purge.write.ts +2 -1
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +28 -9
- package/packages/bundled-features/src/waitlist/import.ts +28 -3
- package/packages/bundled-features/src/waitlist/legacy-migrate.ts +24 -4
- package/packages/bundled-features/src/waitlist/link-on-signup.ts +20 -10
- package/packages/bundled-features/src/waitlist/options.ts +5 -1
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +1 -1
- package/samples/apps/styleguide/src/app/client.tsx +2 -0
- package/samples/apps/styleguide/src/app/seed.ts +6 -4
- package/samples/apps/styleguide/src/app/server.ts +4 -1
- package/samples/apps/styleguide/src/features/widgets/feature.ts +15 -4
- package/samples/apps/styleguide/src/features/widgets/i18n.ts +11 -0
- package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +24 -0
- package/samples/apps/styleguide/src/features/workboard/feature.ts +185 -0
- package/samples/apps/styleguide/src/features/workboard/i18n.ts +27 -0
- package/samples/apps/styleguide/src/features/workboard/seed.ts +121 -0
- package/samples/apps/styleguide/src/features/workboard/web.ts +13 -0
- package/samples/apps/ui-walkthrough/src/features/rental/i18n.ts +2 -0
- package/samples/apps/ui-walkthrough/src/features/rental/screens.ts +9 -0
- package/samples/apps/use-all-bundled/bin/main.ts +2 -0
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-constants.ts +5 -0
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +90 -15
- package/samples/apps/use-all-bundled/e2e-billing-gallery/server.ts +16 -6
- package/samples/apps/use-all-bundled/feature-manifest.json +136 -3
- package/samples/apps/use-all-bundled/kumiko/schema.ts +2 -0
- package/samples/apps/use-all-bundled/kumiko.config.ts +2 -0
- package/samples/apps/use-all-bundled/package.json +2 -1
- package/samples/apps/use-all-bundled/src/app/dev-app-options.ts +2 -0
- package/samples/apps/use-all-bundled/src/app/notes-feature.ts +2 -0
- package/samples/apps/use-all-bundled/src/bundled-lists.ts +15 -0
- package/samples/apps/use-all-bundled/src/run-config.ts +9 -3
- package/samples/recipes/auth-mfa/README.md +5 -0
- package/samples/recipes/auth-mfa/package.json +5 -2
- package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +49 -0
- package/samples/recipes/auth-mfa/tsconfig.json +8 -0
- package/samples/recipes/env-composition/README.md +3 -1
- package/samples/recipes/env-composition/src/env.ts +2 -0
- package/samples/recipes/golden-path/src/feature.ts +2 -1
- package/samples/recipes/legal-pages/README.md +1 -1
- package/samples/recipes/lifecycle-hooks/README.md +4 -0
- package/samples/recipes/lifecycle-hooks/src/feature.ts +26 -1
- package/samples/recipes/list-table-options/README.md +50 -0
- package/samples/recipes/list-table-options/package.json +11 -0
- package/samples/recipes/list-table-options/src/feature.ts +221 -0
- package/samples/recipes/pdf-audit-export/src/feature.ts +2 -1
- package/samples/recipes/rate-limiting/README.md +18 -0
- package/samples/recipes/rate-limiting/src/feature.ts +12 -0
- package/samples/recipes/state-machine/src/events.ts +3 -2
- package/samples/recipes/tenant-isolation/README.md +1 -0
- package/samples/recipes/tenant-isolation/src/feature.ts +36 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/stored-user-email.ts +0 -12
|
@@ -11,8 +11,14 @@ export function mailTextWithSlotsHtml(text: string): string {
|
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
type MailParagraphOptions = { readonly showIf?: string };
|
|
15
|
+
|
|
16
|
+
function paragraphOpenTag(options: MailParagraphOptions | undefined): string {
|
|
17
|
+
return options?.showIf === undefined ? "<p>" : `<p data-if="${escapeHtmlAttr(options.showIf)}">`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function mailParagraph(text: string, options?: MailParagraphOptions): string {
|
|
21
|
+
return `${paragraphOpenTag(options)}${mailTextWithSlotsHtml(text)}</p>`;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export function mailHeading(text: string): string {
|
|
@@ -27,8 +33,9 @@ export function mailParagraphWithLink(
|
|
|
27
33
|
text: string,
|
|
28
34
|
linkLabel: string,
|
|
29
35
|
linkVariable: string,
|
|
36
|
+
options?: MailParagraphOptions,
|
|
30
37
|
): string {
|
|
31
|
-
return
|
|
38
|
+
return `${paragraphOpenTag(options)}${mailTextWithSlotsHtml(text)} <a href="{{${escapeHtmlAttr(linkVariable)}}}">${escapeHtml(linkLabel)}</a></p>`;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
// One table row per list entry; the cell shows the entry's `field`.
|
|
@@ -112,6 +112,29 @@ function fieldsResolvingToSubject(
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// A user owning many records must not load them all at once; the id cursor keeps each page
|
|
116
|
+
// bounded while rows purged in place stay out of the way.
|
|
117
|
+
export const PURGE_CANDIDATE_PAGE_SIZE = 200;
|
|
118
|
+
|
|
119
|
+
async function* candidateRowsPaged(
|
|
120
|
+
db: DbRunner,
|
|
121
|
+
table: FileEntity["table"],
|
|
122
|
+
where: WhereObject,
|
|
123
|
+
): AsyncGenerator<Record<string, unknown>> {
|
|
124
|
+
let cursor: unknown;
|
|
125
|
+
for (;;) {
|
|
126
|
+
const pageWhere: WhereObject = cursor === undefined ? where : { ...where, id: { gt: cursor } };
|
|
127
|
+
const page = await selectMany<Record<string, unknown>>(db, table, pageWhere, {
|
|
128
|
+
orderBy: { col: "id", direction: "asc" },
|
|
129
|
+
limit: PURGE_CANDIDATE_PAGE_SIZE,
|
|
130
|
+
});
|
|
131
|
+
yield* page;
|
|
132
|
+
// skip: a short page is the last one
|
|
133
|
+
if (page.length < PURGE_CANDIDATE_PAGE_SIZE) return;
|
|
134
|
+
cursor = page[page.length - 1]?.["id"];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
115
138
|
const fileRefExecutor = createEventStoreExecutor(fileRefsTable, fileRefEntity, {
|
|
116
139
|
entityName: "fileRef",
|
|
117
140
|
});
|
|
@@ -165,8 +188,7 @@ export async function purgeFilesReachingSubject(args: {
|
|
|
165
188
|
for (const fileEntity of fileEntities) {
|
|
166
189
|
const seenRowIds = new Set<string>();
|
|
167
190
|
for (const where of candidateWheres(subject, recordTenantId, fileEntity)) {
|
|
168
|
-
|
|
169
|
-
for (const row of rows) {
|
|
191
|
+
for await (const row of candidateRowsPaged(db, fileEntity.table, where)) {
|
|
170
192
|
const rowId = String(row["id"]);
|
|
171
193
|
const tenantId = parseTenantId(row["tenantId"]);
|
|
172
194
|
// skip: a row without a tenant cannot own tenant-scoped file refs
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
|
|
3
3
|
// Per-unit sub-transaction (one user, one purged row), nesting-aware across both db shapes:
|
|
4
|
-
// - top-level connection (
|
|
5
|
-
// -
|
|
4
|
+
// - top-level connection (Bun.SQL pool) → `.begin` (BEGIN)
|
|
5
|
+
// - TransactionSQL (inside the dispatcher's outer tx, where every
|
|
6
6
|
// writeHandler already runs) → `.savepoint` (SAVEPOINT)
|
|
7
|
-
// A
|
|
8
|
-
// threw
|
|
7
|
+
// A transaction handle cannot begin another transaction, so the previous unconditional `.begin`
|
|
8
|
+
// threw on every user when invoked through the dispatcher
|
|
9
9
|
// (the cron path) → zero deletions in production, while direct-connection tests
|
|
10
10
|
// stayed green. Selecting the available method makes the sub-tx work in both
|
|
11
11
|
// contexts; on throw the savepoint rolls back just this user (others survive).
|
|
@@ -21,7 +21,7 @@ export async function runInSubTransaction<T>(
|
|
|
21
21
|
savepoint?: (f: (tx: DbRunner) => Promise<T>) => Promise<T>;
|
|
22
22
|
};
|
|
23
23
|
// savepoint-first: empirically (Bun 1.3.14, not re-checked on 1.4.0) the
|
|
24
|
-
// surfaces are NOT mutually exclusive — a
|
|
24
|
+
// surfaces are NOT mutually exclusive — a TransactionSQL exposes begin AND
|
|
25
25
|
// savepoint, only the top-level connection has begin alone. begin-first
|
|
26
26
|
// picked the nested BEGIN inside a tx (the incident class above);
|
|
27
27
|
// savepoint-first hits the savepoint there and falls back to begin top-level.
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.389.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "Mail steps do not retry permanent rejections or throws",
|
|
6
|
+
"detail": "MailDispatchResult failures take an optional smtpCode; 5xx is permanent and recorded after the first attempt. A throwing mail runner is not retried, since the message may already be sent. A mail runner that wants a retry after a transport error should return a failure without smtpCode instead of throwing."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.388.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "Deliver job validates its payload at the trigger",
|
|
12
|
+
"detail": "The deliver job now declares its payload schema, so a manual trigger with an invalid payload is rejected up front instead of throwing inside the handler and consuming all retries."
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"version": "0.365.1",
|
|
4
16
|
"type": "fix",
|
|
@@ -54,9 +54,17 @@ type DeliveryResult =
|
|
|
54
54
|
| { readonly ok: true; readonly status: number }
|
|
55
55
|
| { readonly ok: false; readonly error: string; readonly retryable: boolean };
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const SMTP_PERMANENT_REJECTION_MIN = 500;
|
|
58
|
+
const SMTP_PERMANENT_REJECTION_MAX = 599;
|
|
59
|
+
|
|
60
|
+
// Without an SMTP code the adapter gave nothing to classify, so the failure counts as transient.
|
|
58
61
|
function mailResultAsDelivery(result: MailDispatchResult): DeliveryResult {
|
|
59
|
-
|
|
62
|
+
if (result.ok) return result;
|
|
63
|
+
const isPermanent =
|
|
64
|
+
result.smtpCode !== undefined &&
|
|
65
|
+
result.smtpCode >= SMTP_PERMANENT_REJECTION_MIN &&
|
|
66
|
+
result.smtpCode <= SMTP_PERMANENT_REJECTION_MAX;
|
|
67
|
+
return { ok: false, error: result.error, retryable: !isPermanent };
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
export type DeliverDispatchRequestArgs = {
|
|
@@ -205,7 +213,13 @@ async function sendDispatch(
|
|
|
205
213
|
aggregateId: target.aggregateId,
|
|
206
214
|
errorName: err instanceof Error ? err.name : "unknown",
|
|
207
215
|
});
|
|
208
|
-
|
|
216
|
+
// A mail adapter has no idempotency key: a throw after the provider accepted the message
|
|
217
|
+
// would send it again, so only the webhook (which carries one) is retried.
|
|
218
|
+
return {
|
|
219
|
+
ok: false,
|
|
220
|
+
error: DISPATCH_THREW_ERROR,
|
|
221
|
+
retryable: dispatchSpec.stepKind === "webhook.send",
|
|
222
|
+
};
|
|
209
223
|
}
|
|
210
224
|
}
|
|
211
225
|
|
|
@@ -75,6 +75,7 @@ export function createStepDispatcherFeature(): FeatureDefinition {
|
|
|
75
75
|
retries: DELIVER_RETRIES,
|
|
76
76
|
backoff: "exponential",
|
|
77
77
|
maxPerTenant: { limit: DELIVER_MAX_PER_TENANT, onLimit: "defer" },
|
|
78
|
+
schema: deliverJobPayloadSchema,
|
|
78
79
|
escapeHatch: { reason: DELIVER_ESCAPE_HATCH_REASON },
|
|
79
80
|
},
|
|
80
81
|
async (payload, ctx) => {
|
|
@@ -15,7 +15,8 @@ export type MailSpec = z.infer<typeof mailSpecSchema>;
|
|
|
15
15
|
|
|
16
16
|
export type MailDispatchResult =
|
|
17
17
|
| { readonly ok: true; readonly status: number }
|
|
18
|
-
|
|
18
|
+
// smtpCode is the adapter's SMTP reply code; a 5xx is a permanent rejection and is not retried.
|
|
19
|
+
| { readonly ok: false; readonly error: string; readonly smtpCode?: number };
|
|
19
20
|
|
|
20
21
|
let mailRunner: (spec: MailSpec) => Promise<MailDispatchResult> = async () => ({
|
|
21
22
|
ok: false,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.388.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "New subscription provider for Dodo Payments",
|
|
6
|
+
"detail": "createSubscriptionDodoFeature() registers the \"dodo\" subscription provider (Merchant of Record). It verifies Standard Webhooks signatures, maps Dodo events to the foundation events, creates hosted checkouts and portal sessions, and switches plans in the app through previewPlanSwitch and applyPlanSwitch. Config keys are api-key, webhook-secret, billing-live and environment. Plan switches need a Product Collection in Dodo."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.388.0",
|
|
10
|
+
"type": "improvement",
|
|
11
|
+
"title": "dodoEnvSchema declares the Dodo product id slots",
|
|
12
|
+
"detail": "dodoEnvSchema({ prices: [\"PRO\"] }) adds one optional DODO_PRODUCT_PRO slot per plan next to the API key and webhook key, and checks the pdt_ prefix. It is the counterpart to stripeEnvSchema."
|
|
13
|
+
}
|
|
14
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Thin JSON-over-fetch client for the Dodo Payments REST API. All traffic goes
|
|
2
|
+
// through the injected `send`, which defaults to the SSRF-safe egress in
|
|
3
|
+
// feature.ts and is replaced by a mock in tests.
|
|
4
|
+
|
|
5
|
+
import { parseJsonOrThrow } from "@cosmicdrift/kumiko-framework/utils";
|
|
6
|
+
|
|
7
|
+
export type DodoSend = (url: string, init?: RequestInit) => Promise<Response>;
|
|
8
|
+
|
|
9
|
+
export type DodoRequest = {
|
|
10
|
+
readonly method: "GET" | "POST" | "PATCH";
|
|
11
|
+
/** Path segments interpolated into it must already be encodeURIComponent'ed. */
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly query?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly body?: unknown;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type DodoTarget = { readonly baseUrl: string; readonly apiKey: string };
|
|
18
|
+
|
|
19
|
+
// Never carries the response body or the key: both can hold customer data or secrets.
|
|
20
|
+
export class DodoHttpError extends Error {
|
|
21
|
+
readonly status: number;
|
|
22
|
+
constructor(request: DodoRequest, status: number) {
|
|
23
|
+
super(`subscription-dodo: ${request.method} ${request.path} failed with status ${status}`);
|
|
24
|
+
this.name = "DodoHttpError";
|
|
25
|
+
this.status = status;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createDodoHttp(send: DodoSend) {
|
|
30
|
+
return async (target: DodoTarget, request: DodoRequest): Promise<unknown> => {
|
|
31
|
+
const query = request.query ? `?${new URLSearchParams(request.query).toString()}` : "";
|
|
32
|
+
const response = await send(`${target.baseUrl}${request.path}${query}`, {
|
|
33
|
+
method: request.method,
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${target.apiKey}`,
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
...(request.body !== undefined && { "Content-Type": "application/json" }),
|
|
38
|
+
},
|
|
39
|
+
...(request.body !== undefined && { body: JSON.stringify(request.body) }),
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok) throw new DodoHttpError(request, response.status);
|
|
42
|
+
const text = await response.text();
|
|
43
|
+
return text.length === 0 ? null : parseJsonOrThrow<unknown>(text, "subscription-dodo response");
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const SUBSCRIPTION_DODO_FEATURE = "subscription-dodo" as const;
|
|
2
|
+
|
|
3
|
+
// Must match the path segment in the webhook URL `/api/subscription/webhook/dodo`.
|
|
4
|
+
export const DODO_PROVIDER_NAME = "dodo" as const;
|
|
5
|
+
|
|
6
|
+
// Config-key short-names, qualified to `subscription-dodo:config:<name>` at
|
|
7
|
+
// registry-build. api-key + webhook-secret are backing:"secrets".
|
|
8
|
+
export const DODO_API_KEY_CONFIG = "api-key" as const;
|
|
9
|
+
export const DODO_WEBHOOK_SECRET_CONFIG = "webhook-secret" as const;
|
|
10
|
+
export const DODO_BILLING_LIVE_CONFIG = "billingLive" as const;
|
|
11
|
+
export const DODO_ENVIRONMENT_CONFIG = "environment" as const;
|
|
12
|
+
|
|
13
|
+
// Separate from billingLive on purpose: staging runs Dodo's test API with
|
|
14
|
+
// billingLive on, production flips both.
|
|
15
|
+
export const DodoEnvironments = {
|
|
16
|
+
test: "test",
|
|
17
|
+
live: "live",
|
|
18
|
+
} as const;
|
|
19
|
+
export type DodoEnvironment = (typeof DodoEnvironments)[keyof typeof DodoEnvironments];
|
|
20
|
+
|
|
21
|
+
export const DODO_BASE_URLS: Readonly<Record<DodoEnvironment, string>> = {
|
|
22
|
+
test: "https://test.dodopayments.com",
|
|
23
|
+
live: "https://live.dodopayments.com",
|
|
24
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// kumiko-feature-version: 1
|
|
2
|
+
//
|
|
3
|
+
// subscription-dodo — Dodo Payments (merchant of record) plugin for the
|
|
4
|
+
// billing-foundation plugin API. Credentials, the billing-live master switch and
|
|
5
|
+
// the API environment (test | live) are config keys resolved at call time, like
|
|
6
|
+
// subscription-stripe. `apiKey` / `webhookSecret` options are env→secrets bridge
|
|
7
|
+
// fallbacks.
|
|
8
|
+
|
|
9
|
+
import type { SubscriptionProviderPlugin } from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
|
|
10
|
+
import {
|
|
11
|
+
access,
|
|
12
|
+
createSystemConfig,
|
|
13
|
+
defineFeature,
|
|
14
|
+
type FeatureDefinition,
|
|
15
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
16
|
+
import { type FeatureWithEnvSchema, featureWithEnvSchema } from "@cosmicdrift/kumiko-framework/env";
|
|
17
|
+
import { egress } from "@cosmicdrift/kumiko-framework/http";
|
|
18
|
+
import * as z from "zod";
|
|
19
|
+
import type { DodoSend } from "./client.ts";
|
|
20
|
+
import {
|
|
21
|
+
DODO_API_KEY_CONFIG,
|
|
22
|
+
DODO_BILLING_LIVE_CONFIG,
|
|
23
|
+
DODO_ENVIRONMENT_CONFIG,
|
|
24
|
+
DODO_PROVIDER_NAME,
|
|
25
|
+
DODO_WEBHOOK_SECRET_CONFIG,
|
|
26
|
+
DodoEnvironments,
|
|
27
|
+
SUBSCRIPTION_DODO_FEATURE,
|
|
28
|
+
} from "./constants.ts";
|
|
29
|
+
import {
|
|
30
|
+
createDodoApplyPlanSwitch,
|
|
31
|
+
createDodoCancelSubscription,
|
|
32
|
+
createDodoCheckoutSession,
|
|
33
|
+
createDodoPortalSession,
|
|
34
|
+
createDodoPreviewPlanSwitch,
|
|
35
|
+
createDodoPriceCache,
|
|
36
|
+
createDodoResumeSubscription,
|
|
37
|
+
createDodoRetrievePrices,
|
|
38
|
+
createDodoRetrieveSubscription,
|
|
39
|
+
} from "./plugin-methods.ts";
|
|
40
|
+
import { createDodoRuntimes } from "./runtime.ts";
|
|
41
|
+
import { verifyAndParseDodoWebhook } from "./verify-webhook.ts";
|
|
42
|
+
|
|
43
|
+
/** Bridge contract: both fields are optional fallbacks for the secrets store. */
|
|
44
|
+
export const subscriptionDodoEnvSchema = z.object({
|
|
45
|
+
DODO_PAYMENTS_API_KEY: z
|
|
46
|
+
.string()
|
|
47
|
+
.min(1)
|
|
48
|
+
.describe("Dodo Payments API key. Bridge-fallback — prefer the secret.")
|
|
49
|
+
.meta({ kumiko: { pulumi: { secret: true } } })
|
|
50
|
+
.optional(),
|
|
51
|
+
DODO_PAYMENTS_WEBHOOK_KEY: z
|
|
52
|
+
.string()
|
|
53
|
+
.min(1)
|
|
54
|
+
.describe(
|
|
55
|
+
"Dodo Payments webhook signing key (`whsec_...`). Bridge-fallback — prefer the secret.",
|
|
56
|
+
)
|
|
57
|
+
.meta({ kumiko: { pulumi: { secret: true } } })
|
|
58
|
+
.optional(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
type DodoProductEnvShape<TPrice extends string> = {
|
|
62
|
+
[Key in `DODO_PRODUCT_${TPrice}`]: z.ZodOptional<z.ZodString>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Dodo env block plus one `DODO_PRODUCT_<NAME>` slot per plan product the app
|
|
66
|
+
* maps to a tier, e.g. `dodoEnvSchema({ prices: ["PRO", "TEAM"] })`.
|
|
67
|
+
* Shares its bridge fields with `subscriptionDodoEnvSchema`, so spreading
|
|
68
|
+
* it into `composeEnvSchema({ extend })` next to the mounted feature is no
|
|
69
|
+
* key clash. */
|
|
70
|
+
export function dodoEnvSchema<const TPrice extends string>(options: {
|
|
71
|
+
readonly prices: readonly TPrice[];
|
|
72
|
+
}) {
|
|
73
|
+
const productShape = Object.fromEntries(
|
|
74
|
+
options.prices.map((price) => [
|
|
75
|
+
`DODO_PRODUCT_${price}`,
|
|
76
|
+
z
|
|
77
|
+
.string()
|
|
78
|
+
.regex(/^pdt_/, `DODO_PRODUCT_${price} must start with 'pdt_'`)
|
|
79
|
+
.optional()
|
|
80
|
+
.describe(`Dodo Payments product id (\`pdt_...\`) of the ${price} plan.`),
|
|
81
|
+
]),
|
|
82
|
+
// @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
|
|
83
|
+
) as DodoProductEnvShape<TPrice>;
|
|
84
|
+
return z.object({ ...subscriptionDodoEnvSchema.shape, ...productShape });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type SubscriptionDodoOptions = {
|
|
88
|
+
/** Bridge-fallback API key; the `api-key` config key wins when set. */
|
|
89
|
+
readonly apiKey?: string;
|
|
90
|
+
/** Bridge-fallback webhook secret; the `webhook-secret` config key wins when set. */
|
|
91
|
+
readonly webhookSecret?: string;
|
|
92
|
+
/** Dodo product id → app tier name. Products absent here drop the event. */
|
|
93
|
+
readonly priceToTier?: Readonly<Record<string, string>>;
|
|
94
|
+
/** Product ids a mode:"payment" checkout may target; empty = one-off checkouts closed. */
|
|
95
|
+
readonly oneOffPriceIds?: readonly string[];
|
|
96
|
+
/** HTTP transport; defaults to the SSRF-safe external egress. Test seam. */
|
|
97
|
+
readonly send?: DodoSend;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Validated once at feature-build time so a typo fails app startup instead of
|
|
101
|
+
// silently widening or narrowing the one-off allowlist at request time.
|
|
102
|
+
function validateOneOffPriceIds(priceIds: readonly string[]): void {
|
|
103
|
+
const seen = new Set<string>();
|
|
104
|
+
for (const priceId of priceIds) {
|
|
105
|
+
if (priceId.length === 0) {
|
|
106
|
+
throw new Error("subscription-dodo: oneOffPriceIds must not contain an empty string");
|
|
107
|
+
}
|
|
108
|
+
if (seen.has(priceId)) {
|
|
109
|
+
throw new Error(`subscription-dodo: duplicate oneOffPriceIds entry "${priceId}"`);
|
|
110
|
+
}
|
|
111
|
+
seen.add(priceId);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function createSubscriptionDodoFeature(
|
|
116
|
+
options: SubscriptionDodoOptions = {},
|
|
117
|
+
): FeatureWithEnvSchema<FeatureDefinition, typeof subscriptionDodoEnvSchema.shape> {
|
|
118
|
+
validateOneOffPriceIds(options.oneOffPriceIds ?? []);
|
|
119
|
+
const feature: FeatureDefinition = defineFeature(SUBSCRIPTION_DODO_FEATURE, (r) => {
|
|
120
|
+
r.describe(
|
|
121
|
+
'Dodo Payments provider plugin for `billing-foundation`. Dodo acts as merchant of record: it sells to the customer and issues invoice and VAT, so the consumer-protection texts for this provider come from `consumerProtection.providerTexts`. Reads its API key and webhook secret from system config keys with `backing:"secrets"` (envelope-encrypted in the secrets store under the system tenant), plus a `billingLive` master switch and an `environment` key (test | live). `environment` is its own key because Dodo serves test and live mode from different API hosts and a live key must never hit the test host or the other way round; `billingLive` only decides whether checkouts are offered at all. All four are runtime config, so keys rotate and prod goes live without a redeploy, and the `mask` on each derives the sysadmin settings screen and nav. Mount via `createSubscriptionDodoFeature({ priceToTier })`; the optional `apiKey`/`webhookSecret` options are env to secrets bridge fallbacks (`DODO_PAYMENTS_API_KEY`, `DODO_PAYMENTS_WEBHOOK_KEY`). The plugin always mounts; `createCheckoutSession` throws `feature_disabled` unless `billingLive` is true. Webhooks arrive at `/api/subscription/webhook/dodo` and are verified per the Standard Webhooks spec (HMAC-SHA256 over id, timestamp and the raw body, 5 minute tolerance); events for products outside `priceToTier` or without tenant metadata are dropped. Implements hosted checkout, customer portal, cancel and resume, `retrievePrices` (10-minute TTL cache), `retrieveSubscription` for the sync job, and an in-app plan switch: `previewPlanSwitch` shows the proration before the customer confirms, `applyPlanSwitch` changes the plan without a hosted page and waits for the `plan_changed` webhook to move the tier. A plan switch in Dodo requires all plan products to belong to one Product Collection.',
|
|
122
|
+
);
|
|
123
|
+
r.uiHints({
|
|
124
|
+
displayLabel: "Billing · Dodo Payments",
|
|
125
|
+
category: "billing",
|
|
126
|
+
recommended: false,
|
|
127
|
+
});
|
|
128
|
+
r.requires({ features: ["billing-foundation"] });
|
|
129
|
+
r.requires({ features: ["config"] });
|
|
130
|
+
r.requires({ features: ["secrets"] });
|
|
131
|
+
r.envSchema(subscriptionDodoEnvSchema);
|
|
132
|
+
|
|
133
|
+
const configKeys = r.config({
|
|
134
|
+
keys: {
|
|
135
|
+
[DODO_API_KEY_CONFIG]: createSystemConfig("text", {
|
|
136
|
+
backing: "secrets",
|
|
137
|
+
write: access.systemAdmin,
|
|
138
|
+
read: access.admin,
|
|
139
|
+
mask: { title: "subscription-dodo.api-key", icon: "key", order: 1 },
|
|
140
|
+
}),
|
|
141
|
+
[DODO_WEBHOOK_SECRET_CONFIG]: createSystemConfig("text", {
|
|
142
|
+
backing: "secrets",
|
|
143
|
+
write: access.systemAdmin,
|
|
144
|
+
read: access.admin,
|
|
145
|
+
mask: { title: "subscription-dodo.webhook-secret", icon: "shield", order: 2 },
|
|
146
|
+
}),
|
|
147
|
+
[DODO_ENVIRONMENT_CONFIG]: createSystemConfig("select", {
|
|
148
|
+
default: DodoEnvironments.test,
|
|
149
|
+
options: [DodoEnvironments.test, DodoEnvironments.live],
|
|
150
|
+
write: access.systemAdmin,
|
|
151
|
+
read: access.admin,
|
|
152
|
+
mask: { title: "subscription-dodo.environment", icon: "server", order: 3 },
|
|
153
|
+
}),
|
|
154
|
+
[DODO_BILLING_LIVE_CONFIG]: createSystemConfig("boolean", {
|
|
155
|
+
default: false,
|
|
156
|
+
write: access.privileged,
|
|
157
|
+
read: access.admin,
|
|
158
|
+
mask: { title: "subscription-dodo.billing-live", icon: "rocket", order: 4 },
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
r.translations({
|
|
164
|
+
keys: {
|
|
165
|
+
"subscription-dodo.api-key": { en: "Dodo Payments API key" },
|
|
166
|
+
"subscription-dodo.webhook-secret": { en: "Dodo Payments webhook secret" },
|
|
167
|
+
"subscription-dodo.environment": { en: "Dodo Payments environment" },
|
|
168
|
+
"subscription-dodo.billing-live": { en: "Live billing" },
|
|
169
|
+
"subscription-dodo.settings": { en: "Dodo Payments" },
|
|
170
|
+
"screen:subscription-dodo-system.title": { en: "Dodo Payments" },
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const priceToTier = options.priceToTier ?? {};
|
|
175
|
+
const runtimes = createDodoRuntimes({
|
|
176
|
+
apiKeyHandle: configKeys[DODO_API_KEY_CONFIG],
|
|
177
|
+
webhookSecretHandle: configKeys[DODO_WEBHOOK_SECRET_CONFIG],
|
|
178
|
+
billingLiveHandle: configKeys[DODO_BILLING_LIVE_CONFIG],
|
|
179
|
+
environmentHandle: configKeys[DODO_ENVIRONMENT_CONFIG],
|
|
180
|
+
send: options.send ?? egress({ kind: "external" }),
|
|
181
|
+
fallback: {
|
|
182
|
+
...(options.apiKey !== undefined && { apiKey: options.apiKey }),
|
|
183
|
+
...(options.webhookSecret !== undefined && { webhookSecret: options.webhookSecret }),
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const plugin: SubscriptionProviderPlugin = {
|
|
188
|
+
displayName: "Dodo Payments",
|
|
189
|
+
verifyAndParseWebhook: verifyAndParseDodoWebhook(runtimes.webhook, { priceToTier }),
|
|
190
|
+
createCheckoutSession: createDodoCheckoutSession(runtimes.ctx),
|
|
191
|
+
createPortalSession: createDodoPortalSession(runtimes.ctx),
|
|
192
|
+
cancelSubscription: createDodoCancelSubscription(runtimes.ctx),
|
|
193
|
+
resumeSubscription: createDodoResumeSubscription(runtimes.ctx),
|
|
194
|
+
priceToTier,
|
|
195
|
+
oneOffPriceIds: options.oneOffPriceIds ?? [],
|
|
196
|
+
isBillingEnabled: runtimes.ctx.isBillingEnabled,
|
|
197
|
+
retrievePrices: createDodoRetrievePrices(runtimes.ctx, createDodoPriceCache()),
|
|
198
|
+
retrieveSubscription: createDodoRetrieveSubscription(runtimes.ctx, { priceToTier }),
|
|
199
|
+
previewPlanSwitch: createDodoPreviewPlanSwitch(runtimes.ctx),
|
|
200
|
+
applyPlanSwitch: createDodoApplyPlanSwitch(runtimes.ctx),
|
|
201
|
+
};
|
|
202
|
+
r.useExtension("subscriptionProvider", DODO_PROVIDER_NAME, plugin);
|
|
203
|
+
|
|
204
|
+
return { configKeys };
|
|
205
|
+
});
|
|
206
|
+
return featureWithEnvSchema(feature, subscriptionDodoEnvSchema);
|
|
207
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Public API of the subscription-dodo bundled feature. The webhook verifier,
|
|
2
|
+
// client and plugin methods are internal to feature.ts.
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
DODO_BASE_URLS,
|
|
6
|
+
DODO_PROVIDER_NAME,
|
|
7
|
+
type DodoEnvironment,
|
|
8
|
+
DodoEnvironments,
|
|
9
|
+
SUBSCRIPTION_DODO_FEATURE,
|
|
10
|
+
} from "./constants.ts";
|
|
11
|
+
export {
|
|
12
|
+
createSubscriptionDodoFeature,
|
|
13
|
+
dodoEnvSchema,
|
|
14
|
+
type SubscriptionDodoOptions,
|
|
15
|
+
subscriptionDodoEnvSchema,
|
|
16
|
+
} from "./feature.ts";
|