@cosmicdrift/kumiko-samples 0.406.0 → 0.410.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 +31 -4
- package/packages/bundled-features/src/account-security/feature.ts +9 -1
- package/packages/bundled-features/src/admin-shell/changes.json +6 -0
- package/packages/bundled-features/src/admin-shell/feature.ts +4 -1
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +1 -0
- package/packages/bundled-features/src/agent-tools/changes.json +6 -0
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -0
- package/packages/bundled-features/src/agent-tools/types.ts +4 -0
- package/packages/bundled-features/src/audit/event-classification.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/bootstrap.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/errors.ts +18 -66
- package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -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/web/auth-client.ts +30 -64
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +2 -2
- package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +20 -66
- package/packages/bundled-features/src/auth-email-password/web/index.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/web/read-path-param.ts +8 -0
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +3 -2
- package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +97 -0
- package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +20 -68
- package/packages/bundled-features/src/auth-foundation/boot-checks.ts +22 -15
- package/packages/bundled-features/src/auth-foundation/boot-rules.ts +33 -0
- package/packages/bundled-features/src/auth-mfa/errors.ts +12 -42
- package/packages/bundled-features/src/auth-mfa/feature-exports.ts +6 -45
- package/packages/bundled-features/src/auth-mfa/feature.ts +8 -19
- package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +19 -33
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-notify.ts +1 -0
- package/packages/bundled-features/src/billing-foundation/web/plan-price.ts +20 -7
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -0
- package/packages/bundled-features/src/channel-in-app/changes.json +7 -0
- package/packages/bundled-features/src/channel-in-app/feature.ts +2 -0
- package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +35 -0
- package/packages/bundled-features/src/channel-in-app/in-app-channel.ts +1 -0
- package/packages/bundled-features/src/channel-in-app/tables.ts +5 -1
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +4 -1
- package/packages/bundled-features/src/contact/challenge.ts +41 -0
- package/packages/bundled-features/src/contact/changes.json +33 -0
- package/packages/bundled-features/src/contact/client/contact-client-source.ts +203 -0
- package/packages/bundled-features/src/contact/client/contact-website-client.ts +29 -0
- package/packages/bundled-features/src/contact/client/index.ts +9 -0
- package/packages/bundled-features/src/contact/entity.ts +168 -0
- package/packages/bundled-features/src/contact/feature.ts +174 -0
- package/packages/bundled-features/src/contact/handlers/access.ts +17 -0
- package/packages/bundled-features/src/contact/handlers/attempts.ts +76 -0
- package/packages/bundled-features/src/contact/handlers/challenge.query.ts +44 -0
- package/packages/bundled-features/src/contact/handlers/forward-request.write.ts +98 -0
- package/packages/bundled-features/src/contact/handlers/mark-done.write.ts +40 -0
- package/packages/bundled-features/src/contact/handlers/notify-reporter-in-app.write.ts +48 -0
- package/packages/bundled-features/src/contact/handlers/open-count.query.ts +15 -0
- package/packages/bundled-features/src/contact/handlers/open-count.ts +17 -0
- package/packages/bundled-features/src/contact/handlers/replies.query.ts +29 -0
- package/packages/bundled-features/src/contact/handlers/reply.write.ts +197 -0
- package/packages/bundled-features/src/contact/handlers/report.write.ts +126 -0
- package/packages/bundled-features/src/contact/handlers/request-delivery.query.ts +143 -0
- package/packages/bundled-features/src/contact/handlers/request-detail.query.ts +50 -0
- package/packages/bundled-features/src/contact/handlers/request-list.query.ts +14 -0
- package/packages/bundled-features/src/contact/handlers/send-reply-mail.write.ts +124 -0
- package/packages/bundled-features/src/contact/handlers/send-test.write.ts +45 -0
- package/packages/bundled-features/src/contact/handlers/submit.write.ts +194 -0
- package/packages/bundled-features/src/contact/handlers/take-over-uploads.ts +47 -0
- package/packages/bundled-features/src/contact/i18n.ts +192 -0
- package/packages/bundled-features/src/contact/index.ts +29 -0
- package/packages/bundled-features/src/contact/lib.ts +176 -0
- package/packages/bundled-features/src/contact/mail.ts +401 -0
- package/packages/bundled-features/src/contact/options.ts +95 -0
- package/packages/bundled-features/src/contact/panels.ts +28 -0
- package/packages/bundled-features/src/contact/payloads.ts +106 -0
- package/packages/bundled-features/src/contact/pow.ts +22 -0
- package/packages/bundled-features/src/contact/screens.ts +507 -0
- package/packages/bundled-features/src/contact/subject.ts +13 -0
- package/packages/bundled-features/src/contact/user-agent.ts +39 -0
- package/packages/bundled-features/src/contact/user-data-hooks.ts +180 -0
- package/packages/bundled-features/src/contact/web/constants.ts +160 -0
- package/packages/bundled-features/src/contact/web/index.ts +29 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +5 -16
- package/packages/bundled-features/src/data-retention/changes.json +6 -0
- package/packages/bundled-features/src/data-retention/feature.ts +16 -2
- package/packages/bundled-features/src/data-retention/index.ts +5 -0
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +138 -41
- package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +196 -0
- package/packages/bundled-features/src/delivery/address-opt-out.ts +1 -0
- package/packages/bundled-features/src/delivery/changes.json +7 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +2 -0
- package/packages/bundled-features/src/delivery/delivery-service.ts +29 -5
- package/packages/bundled-features/src/delivery/events.ts +2 -0
- package/packages/bundled-features/src/delivery/feature.ts +3 -2
- package/packages/bundled-features/src/delivery/handlers/attempts-by-keys.query.ts +55 -0
- package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
- package/packages/bundled-features/src/delivery/jobs.ts +5 -0
- package/packages/bundled-features/src/delivery/tables.ts +13 -2
- package/packages/bundled-features/src/delivery/types.ts +3 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +2 -0
- package/packages/bundled-features/src/delivery/web/delivery-channel-cell.tsx +1 -1
- package/packages/bundled-features/src/delivery/web/delivery-error-cell.tsx +1 -1
- package/packages/bundled-features/src/delivery/web/delivery-status-cell.tsx +1 -1
- package/packages/bundled-features/src/delivery/web/delivery-time-cell.tsx +3 -2
- package/packages/bundled-features/src/delivery/web/delivery-type-cell.tsx +1 -1
- package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
- package/packages/bundled-features/src/document-ingest-foundation/boot-checks.ts +14 -9
- package/packages/bundled-features/src/document-ingest-foundation/boot-rules.ts +22 -0
- package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/events.ts +17 -0
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +39 -1
- package/packages/bundled-features/src/document-ingest-foundation/index.ts +10 -0
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +43 -0
- package/packages/bundled-features/src/document-ingest-foundation/tables.ts +43 -0
- 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/files-tenant-data/changes.json +6 -0
- package/packages/bundled-features/src/files-tenant-data/hooks.ts +4 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +8 -9
- package/packages/bundled-features/src/folders/web/folder-section.tsx +1 -1
- package/packages/bundled-features/src/form-draft-user-data/index.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +13 -0
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +6 -6
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +7 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +6 -2
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.query.ts +3 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.ts +19 -0
- package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/sanitize-inbound-html.ts +150 -0
- package/packages/bundled-features/src/inbound-mail-foundation/types.ts +1 -0
- package/packages/bundled-features/src/jobs/job-run-logger.ts +24 -25
- package/packages/bundled-features/src/ledger/handlers/reports.query.ts +46 -31
- package/packages/bundled-features/src/ledger/recurring.ts +1 -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/notes-history/web/notes-section.tsx +3 -1
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +9 -17
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +2 -7
- package/packages/bundled-features/src/secrets/changes.json +6 -0
- package/packages/bundled-features/src/secrets/handlers/delete.write.ts +8 -4
- package/packages/bundled-features/src/secrets/handlers/list.query.ts +6 -3
- package/packages/bundled-features/src/secrets/handlers/set.write.ts +9 -4
- package/packages/bundled-features/src/secrets/secret-scope.ts +33 -0
- package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
- package/packages/bundled-features/src/sessions/changes.json +6 -0
- package/packages/bundled-features/src/sessions/feature.ts +21 -18
- package/packages/bundled-features/src/sessions/handlers/last-activity-probe.query.ts +53 -0
- package/packages/bundled-features/src/sessions/handlers/last-activity-probe.route.ts +39 -0
- package/packages/bundled-features/src/sessions/screens.ts +1 -0
- package/packages/bundled-features/src/sessions/session-callbacks.ts +13 -12
- package/packages/bundled-features/src/sessions/web/i18n.ts +4 -1
- package/packages/bundled-features/src/shared/assert-billing-live.ts +14 -0
- package/packages/bundled-features/src/shared/collect-extension-options.ts +12 -0
- package/packages/bundled-features/src/shared/index.ts +16 -0
- package/packages/bundled-features/src/shared/late-bound-slot.ts +19 -0
- package/packages/bundled-features/src/shared/mail-locale-templates.ts +7 -1
- package/packages/bundled-features/src/shared/price-env-shape.ts +44 -0
- package/packages/bundled-features/src/shared/purge-row-file-refs.ts +1 -1
- package/packages/bundled-features/src/shared/read-feature-export-fn.ts +16 -0
- package/packages/bundled-features/src/shared/signup-handover.ts +3 -4
- package/packages/bundled-features/src/shared/tenant-destruction-hold.ts +49 -0
- package/packages/bundled-features/src/shared/unprocessable.ts +19 -0
- package/packages/bundled-features/src/shared/web/index.ts +3 -0
- package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
- package/packages/bundled-features/src/subscription-paddle/feature.ts +7 -15
- package/packages/bundled-features/src/subscription-paddle/runtime.ts +4 -7
- package/packages/bundled-features/src/subscription-stripe/feature.ts +7 -15
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +4 -7
- package/packages/bundled-features/src/tags/entity.ts +1 -0
- package/packages/bundled-features/src/tags/web/tag-chip.tsx +14 -0
- package/packages/bundled-features/src/tags/web/tag-filter.tsx +4 -5
- package/packages/bundled-features/src/tags/web/tag-manager.tsx +1 -1
- package/packages/bundled-features/src/tags/web/tag-section.tsx +3 -6
- package/packages/bundled-features/src/tags/web/tags-cell.tsx +4 -5
- package/packages/bundled-features/src/template-resolver/compile-document-body.ts +27 -15
- 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 +12 -9
- package/packages/bundled-features/src/template-resolver/handlers/discard-draft.write.ts +1 -0
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +1 -0
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +5 -5
- package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +3 -0
- package/packages/bundled-features/src/template-resolver/linked-resources.ts +11 -6
- package/packages/bundled-features/src/template-resolver/store-template-resource.ts +15 -12
- package/packages/bundled-features/src/template-resolver/web/document-images.ts +6 -6
- package/packages/bundled-features/src/template-resolver/web/document-insert-fields.tsx +41 -36
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -12
- package/packages/bundled-features/src/template-resolver/web/tiptap-attribute-parse-rule.ts +19 -0
- package/packages/bundled-features/src/tenant/i18n.ts +3 -0
- package/packages/bundled-features/src/tenant/schema/tenant.ts +1 -0
- package/packages/bundled-features/src/tenant/web/member-roles-cell.tsx +1 -1
- package/packages/bundled-features/src/tenant/web/member-status-cell.tsx +1 -1
- package/packages/bundled-features/src/tenant-inactivity/changes.json +8 -0
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +260 -0
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +12 -0
- package/packages/bundled-features/src/tenant-inactivity/email-templates.ts +24 -0
- package/packages/bundled-features/src/tenant-inactivity/feature.ts +66 -0
- package/packages/bundled-features/src/tenant-inactivity/handlers/inactivity-state.query.ts +49 -0
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +59 -0
- package/packages/bundled-features/src/tenant-inactivity/inactivity-plan.ts +187 -0
- package/packages/bundled-features/src/tenant-inactivity/index.ts +5 -0
- package/packages/bundled-features/src/tenant-inactivity/keep-token.ts +44 -0
- package/packages/bundled-features/src/tenant-inactivity/mail-notifications.ts +62 -0
- package/packages/bundled-features/src/tenant-inactivity/options.ts +38 -0
- package/packages/bundled-features/src/tenant-inactivity/remote-activity.ts +32 -0
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +71 -0
- package/packages/bundled-features/src/tenant-inactivity/state-table.ts +50 -0
- package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +8 -6
- package/packages/bundled-features/src/tenant-lifecycle/boot-rules.ts +16 -0
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +24 -1
- package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +12 -87
- package/packages/bundled-features/src/tenant-lifecycle/index.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/request-tenant-destruction.ts +108 -0
- package/packages/bundled-features/src/tenant-lifecycle/retention-config-destroy-hooks.ts +62 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +58 -5
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +31 -2
- package/packages/bundled-features/src/tenant-lifecycle/testing.ts +1 -1
- package/packages/bundled-features/src/tier-engine/caps-for-tier-from-map.ts +16 -0
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/compose-app.ts +21 -20
- package/packages/bundled-features/src/tier-engine/index.ts +1 -0
- package/packages/bundled-features/src/user-data-rights/feature.ts +2 -0
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +4 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -0
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +4 -1
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +2 -0
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/zip-path.ts +1 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/config-value.userdata-hook.ts +8 -27
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +11 -8
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.ts +42 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +8 -27
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +2 -6
- package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +2 -3
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +1 -2
- package/samples/apps/styleguide/src/features/widgets/i18n.ts +6 -0
- package/samples/apps/styleguide/src/features/widgets/web/InboxReaderExamples.tsx +158 -0
- package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +2 -0
- package/samples/apps/styleguide/src/features/widgets/web/sample-pdf.ts +28 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +113 -2
- package/samples/apps/use-all-bundled/kumiko/migrations/0063_contact.rebuild.json +4 -0
- package/samples/apps/use-all-bundled/package.json +1 -0
- package/samples/apps/use-all-bundled/src/app/client.tsx +3 -0
- package/samples/apps/use-all-bundled/src/app/screens-feature.ts +46 -2
- package/samples/apps/use-all-bundled/src/run-config.ts +23 -1
- package/samples/recipes/anonymous-access/README.md +2 -0
- package/samples/recipes/anonymous-access/src/feature.ts +7 -1
- package/samples/recipes/contact/README.md +52 -0
- package/samples/recipes/contact/package.json +12 -0
- package/samples/recipes/contact/src/feature.ts +27 -0
- package/samples/recipes/delivery-notifications/src/feature.ts +3 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +9 -1
- package/samples/recipes/search/README.md +2 -0
- package/samples/recipes/search/src/feature.ts +27 -2
- package/samples/recipes/secrets-demo/README.md +1 -0
- package/samples/recipes/secrets-demo/src/feature.ts +56 -0
- package/samples/recipes/tenant-inactivity/README.md +21 -0
- package/samples/recipes/tenant-inactivity/package.json +12 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Recipe: contact
|
|
2
|
+
|
|
3
|
+
Public contact form backend. The `contact` bundled feature stores questions, contact
|
|
4
|
+
requests and problem reports from website visitors and notifies every SystemAdmin (mail,
|
|
5
|
+
Telegram only when the app turns it on). The notification names only the kind, the app and a link into the inbox:
|
|
6
|
+
no name, address, phone, subject or message. Telegram is a third party where nothing can be
|
|
7
|
+
shredded or recalled, so it gets the same minimal text. Website senders get a fixed
|
|
8
|
+
acknowledgement that repeats nothing they typed; signed-in admin reports get a copy.
|
|
9
|
+
SystemAdmins reply from the admin. Phone is off and Telegram is not mounted unless the app
|
|
10
|
+
turns them on (`fields.phone`, `telegram: true`).
|
|
11
|
+
|
|
12
|
+
**What the recipe demonstrates:**
|
|
13
|
+
- Mounting `createContactFeature` with its companions (delivery, user-data-rights, files)
|
|
14
|
+
- The anonymous flow: `contact:query:challenge` hands out a proof-of-work challenge,
|
|
15
|
+
`contact:write:submit` verifies it; spam gets the same 200 body and stores nothing
|
|
16
|
+
- The browser client at `GET /contact/client.js` (`window.KumikoContact.load()` / `submit()`)
|
|
17
|
+
|
|
18
|
+
## Layout
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
samples/recipes/contact/
|
|
22
|
+
├── package.json
|
|
23
|
+
├── README.md
|
|
24
|
+
└── src/
|
|
25
|
+
├── feature.ts # createContactFeature options
|
|
26
|
+
└── __tests__/
|
|
27
|
+
└── feature.integration.test.ts # challenge query + client route
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The behavior (submit, silent drops, replies, Telegram, GDPR export and erasure, retention) is
|
|
31
|
+
covered by the integration tests next to the feature in
|
|
32
|
+
`packages/bundled-features/src/contact/__tests__/`.
|
|
33
|
+
|
|
34
|
+
## Run tests
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
bun test --config=bunfig.integration.toml samples/recipes/contact
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Integration into a real app
|
|
41
|
+
|
|
42
|
+
1. Mount `createContactFeature({ appName })` plus delivery, a mail channel, `user-data-rights`,
|
|
43
|
+
`files` with a file provider and `config`.
|
|
44
|
+
2. Run `kumiko schema generate` (new tables, plus the delivery `idempotency_key` column).
|
|
45
|
+
3. SystemAdmins set `contact:config:reply-to` in the admin.
|
|
46
|
+
4. Embed `/contact/client.js` on the website; the form is yours. A website served by another
|
|
47
|
+
server can serve the same script from `CONTACT_CLIENT_SOURCE` and type its calls with
|
|
48
|
+
`ContactWebsiteClient`, both from `@cosmicdrift/kumiko-bundled-features/contact/client`.
|
|
49
|
+
|
|
50
|
+
Telegram is optional and off by default: notifications go by mail to SystemAdmins only. An app
|
|
51
|
+
that turns it on (`telegram: true`) also mounts `channel-telegram` and `secrets` for the bot
|
|
52
|
+
token, and SystemAdmins set `contact:config:telegram-chat`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cosmicdrift/kumiko-sample-contact",
|
|
3
|
+
"description": "Public contact form backend: the contact bundled feature with its required companions (delivery, user-data-rights, files) and the anonymous browser client.",
|
|
4
|
+
"private": true,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@cosmicdrift/kumiko-bundled-features": "workspace:*",
|
|
7
|
+
"@cosmicdrift/kumiko-framework": "workspace:*"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@cosmicdrift/kumiko-testing": "workspace:*"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Contact sample
|
|
2
|
+
//
|
|
3
|
+
// A public website form (question, contact request, problem report) that lands with the
|
|
4
|
+
// SystemAdmins: mail, optional Telegram, a copy to the sender. Spam is handled without a
|
|
5
|
+
// captcha: honeypot field, single-use proof-of-work challenge, minimum submit time, per-IP
|
|
6
|
+
// and per-email rate limits. Rejected submits answer 200 with the normal body.
|
|
7
|
+
//
|
|
8
|
+
// The website embeds the anonymous client the feature serves itself:
|
|
9
|
+
// <script src="https://api.example.com/contact/client.js"></script>
|
|
10
|
+
// const { kinds, phone } = await window.KumikoContact.load();
|
|
11
|
+
// const result = await window.KumikoContact.submit({ kind, name, email, message, locale });
|
|
12
|
+
// // result.kind: "sent" | "rate-limited" (retryAfterSeconds) | "failed"
|
|
13
|
+
//
|
|
14
|
+
// Prerequisites the app wires itself:
|
|
15
|
+
// - `anonymousAccess` (defaultTenantId = SYSTEM_TENANT_ID) so the form needs no login
|
|
16
|
+
// - delivery with a mail channel (channel-telegram only with `telegram: true`, off by default)
|
|
17
|
+
// - a file provider, because the entities carry file fields
|
|
18
|
+
// - `kumiko schema generate` for the new tables
|
|
19
|
+
|
|
20
|
+
import { createContactFeature } from "@cosmicdrift/kumiko-bundled-features/contact";
|
|
21
|
+
|
|
22
|
+
export const contactFeature = createContactFeature({
|
|
23
|
+
appName: "Sample App",
|
|
24
|
+
fields: { phone: "optional" },
|
|
25
|
+
// Lowered only to keep the sample test fast; the default (19 bits, 3 seconds) suits production.
|
|
26
|
+
spamProtection: { proofOfWorkBits: 8, minSubmitSeconds: 0 },
|
|
27
|
+
});
|
|
@@ -99,6 +99,9 @@ export const supportFeature = defineFeature("support", (r) => {
|
|
|
99
99
|
const ticketId = created.data.id;
|
|
100
100
|
await ctx.notify(TICKET_ASSIGNED, {
|
|
101
101
|
to: assigneeId,
|
|
102
|
+
// Known key per ticket: dedups a replayed handler and lets an admin screen ask
|
|
103
|
+
// channel-in-app:query:read-state-by-keys whether the assignee has seen it.
|
|
104
|
+
idempotencyKey: `ticket-assigned:${ticketId}`,
|
|
102
105
|
data: {
|
|
103
106
|
ticketId,
|
|
104
107
|
title: event.payload.title,
|
|
@@ -77,7 +77,15 @@ export function createOrderDeskFeature(): FeatureDefinition {
|
|
|
77
77
|
id: "order-detail",
|
|
78
78
|
type: "projectionDetail",
|
|
79
79
|
query: "order-desk:query:order:detail",
|
|
80
|
-
header: {
|
|
80
|
+
header: {
|
|
81
|
+
title: "customerName",
|
|
82
|
+
// Parts are joined by a separator; `format` formats the raw field value.
|
|
83
|
+
subtitle: [
|
|
84
|
+
"orderNumber",
|
|
85
|
+
{ field: "placedAt", format: { format: "date", dateStyle: "medium" } },
|
|
86
|
+
],
|
|
87
|
+
status: "status",
|
|
88
|
+
},
|
|
81
89
|
metrics: [
|
|
82
90
|
{ field: "totalAmount", label: "order-desk.metric.totalAmount" },
|
|
83
91
|
{ field: "outstandingAmount", label: "order-desk.metric.outstandingAmount" },
|
|
@@ -6,6 +6,8 @@ Tenant-scoped full-text search (Meilisearch / in-memory adapter).
|
|
|
6
6
|
|
|
7
7
|
- `searchable` / `searchWeight` on fields
|
|
8
8
|
- Handler reads via `ctx.services.searchAdapter`
|
|
9
|
+
- `createLongTextField({ personal: "tenant", find: "fuzzy" })`: a long body is searchable, decrypted for the index (Meilisearch splits it into pieces)
|
|
10
|
+
- Trash list: `softDelete` entity, list with `onlyDeleted: true`, restore via `article:restore`
|
|
9
11
|
|
|
10
12
|
## Source
|
|
11
13
|
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
// Search Sample
|
|
2
|
-
// Shows: searchable fields, searchWeight, search via InMemory SearchAdapter
|
|
2
|
+
// Shows: searchable fields, searchWeight, search via InMemory SearchAdapter, a longText field
|
|
3
|
+
// with find: "fuzzy" (chunked in Meilisearch) and a trash list (onlyDeleted) for restore.
|
|
3
4
|
// Each handler builds its executor inline so `ctx.services.searchAdapter` is read fresh
|
|
4
5
|
// per call — tests swap the adapter between runs.
|
|
5
6
|
|
|
6
7
|
import { buildEntityTable, createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
createEntity,
|
|
10
|
+
createLongTextField,
|
|
11
|
+
createTextField,
|
|
12
|
+
defineEntityQueryHandler,
|
|
13
|
+
defineEntityWriteHandler,
|
|
14
|
+
defineFeature,
|
|
15
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
8
16
|
import { z } from "zod";
|
|
9
17
|
|
|
10
18
|
export const productEntity = createEntity({
|
|
@@ -23,10 +31,27 @@ export const productEntity = createEntity({
|
|
|
23
31
|
searchWeight: 10,
|
|
24
32
|
});
|
|
25
33
|
|
|
34
|
+
// A long body is searched like any text field; softDelete gives the trash list and restore.
|
|
35
|
+
export const articleEntity = createEntity({
|
|
36
|
+
table: "read_sample_articles",
|
|
37
|
+
softDelete: true,
|
|
38
|
+
fields: {
|
|
39
|
+
title: createTextField({ personal: false, reason: "is_business_data", required: true }),
|
|
40
|
+
body: createLongTextField({ personal: "tenant", find: "fuzzy" }),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
26
44
|
const productTable = buildEntityTable("product", productEntity);
|
|
27
45
|
|
|
28
46
|
export const productFeature = defineFeature("shop", (r) => {
|
|
29
47
|
r.entity({ name: "product", ...productEntity });
|
|
48
|
+
r.entity({ name: "article", ...articleEntity });
|
|
49
|
+
|
|
50
|
+
const articleAccess = { access: { roles: ["Admin"] } };
|
|
51
|
+
for (const verb of ["create", "delete", "restore"] as const) {
|
|
52
|
+
r.writeHandler(defineEntityWriteHandler(`article:${verb}`, articleEntity, articleAccess));
|
|
53
|
+
}
|
|
54
|
+
r.queryHandler(defineEntityQueryHandler("article:list", articleEntity, articleAccess));
|
|
30
55
|
|
|
31
56
|
r.writeHandler({
|
|
32
57
|
name: "product:create",
|
|
@@ -6,6 +6,7 @@ Tenant-owned secrets with envelope encryption, DEK cache, and KEK rotation.
|
|
|
6
6
|
|
|
7
7
|
- `r.secret` + `ctx.services.secrets.get` (audited reads)
|
|
8
8
|
- Charge-style handler that never returns the plaintext key
|
|
9
|
+
- A system-scope secret edited on a `configEdit` screen (`secretKeys`) with a handler button row (`actions`)
|
|
9
10
|
|
|
10
11
|
## Source
|
|
11
12
|
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { requireSecretsContext } from "@cosmicdrift/kumiko-bundled-features/secrets";
|
|
7
7
|
import {
|
|
8
|
+
access,
|
|
9
|
+
createTextField,
|
|
8
10
|
defineFeature,
|
|
9
11
|
defineWriteHandler,
|
|
10
12
|
type FeatureDefinition,
|
|
@@ -66,6 +68,26 @@ const chargeWrite = defineWriteHandler({
|
|
|
66
68
|
},
|
|
67
69
|
});
|
|
68
70
|
|
|
71
|
+
// Platform-wide secret edited on a configEdit screen. The declaration keeps scope "tenant" (the
|
|
72
|
+
// only declared scope); the screen's scope "system" stores one value for the whole platform under
|
|
73
|
+
// the system tenant, and only a SystemAdmin may write it.
|
|
74
|
+
export let WEBHOOK_SIGNING_KEY: SecretKeyHandle;
|
|
75
|
+
|
|
76
|
+
const webhookSendTestWrite = defineWriteHandler({
|
|
77
|
+
name: "webhook-send-test",
|
|
78
|
+
schema: z.object({}),
|
|
79
|
+
access: { roles: access.systemAdmin },
|
|
80
|
+
handler: async (event, ctx) => {
|
|
81
|
+
const secrets = requireSecretsContext(
|
|
82
|
+
{ secrets: ctx.services.secrets, user: ctx.user },
|
|
83
|
+
"billing:write:webhook-send-test",
|
|
84
|
+
);
|
|
85
|
+
const key = await secrets.get(event.user.tenantId, WEBHOOK_SIGNING_KEY);
|
|
86
|
+
if (!key) return failUnprocessable("webhook_key_missing");
|
|
87
|
+
return { isSuccess: true, data: { signed: true } };
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
69
91
|
export function createBillingFeature(): FeatureDefinition {
|
|
70
92
|
return defineFeature("billing", (r) => {
|
|
71
93
|
// Typed declaration of the secret this feature needs. Admin UIs can
|
|
@@ -86,6 +108,40 @@ export function createBillingFeature(): FeatureDefinition {
|
|
|
86
108
|
},
|
|
87
109
|
scope: "tenant",
|
|
88
110
|
});
|
|
111
|
+
WEBHOOK_SIGNING_KEY = r.secret("webhook.signingKey", {
|
|
112
|
+
label: { de: "Webhook-Signaturschlüssel", en: "Webhook signing key" },
|
|
113
|
+
scope: "tenant",
|
|
114
|
+
});
|
|
89
115
|
r.writeHandler(chargeWrite);
|
|
116
|
+
r.writeHandler(webhookSendTestWrite);
|
|
117
|
+
r.screen({
|
|
118
|
+
id: "webhook-settings",
|
|
119
|
+
type: "configEdit",
|
|
120
|
+
dormant: true,
|
|
121
|
+
scope: "system",
|
|
122
|
+
configKeys: {},
|
|
123
|
+
secretKeys: { signingKey: WEBHOOK_SIGNING_KEY.name },
|
|
124
|
+
fields: {
|
|
125
|
+
signingKey: createTextField({
|
|
126
|
+
writeOnly: true,
|
|
127
|
+
maxLength: 200,
|
|
128
|
+
personal: false,
|
|
129
|
+
reason: "is_business_data",
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
layout: { variant: "settings-list", sections: [{ fields: ["signingKey"] }] },
|
|
133
|
+
// A button row calls a handler with {} on the stored values; it is disabled while the
|
|
134
|
+
// form has unsaved changes.
|
|
135
|
+
actions: [
|
|
136
|
+
{
|
|
137
|
+
id: "send-test",
|
|
138
|
+
handler: "billing:write:webhook-send-test",
|
|
139
|
+
label: "billing.webhook.test.label",
|
|
140
|
+
buttonLabel: "billing.webhook.test.button",
|
|
141
|
+
afterField: "signingKey",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
access: { roles: access.systemAdmin },
|
|
145
|
+
});
|
|
90
146
|
});
|
|
91
147
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Sample: Tenant Inactivity
|
|
2
|
+
|
|
3
|
+
Opt-in deletion of abandoned free accounts. Mount `createTenantInactivityFeature` next to `sessions`, `tenant-lifecycle` and `delivery`; a daily job tracks the last activity per tenant, warns the tenant owners by mail and finally files the normal deletion request.
|
|
4
|
+
|
|
5
|
+
## What you learn here
|
|
6
|
+
|
|
7
|
+
- **One rule for everybody, or one per tier**: `{ rule }` applies to every tenant; `{ resolveTier, rulesByTier }` returns `null` for a tier to exempt it (paid plans).
|
|
8
|
+
- **Warning cycle**: with `warnings: [{ days: 30 }, { days: 7 }]` the owners get one mail 30 and one 7 days before the deadline. On the deadline the job calls the same core as the owner's `request-destruction` handler, so the wait period comes from the compliance profile and the owner can still cancel.
|
|
9
|
+
- **Activity restarts the cycle**: a new session counts, and so does the keep-account link in the mail (`keepAccountTokenSecret` signs it; without a secret the mail links to `keepAccountUrl` only). Other apps of the same account report through `activitySources`; `fetchRemoteAppLastActivity` reads the opt-in `lastActivityProbeSecret` route of a remote sessions feature.
|
|
10
|
+
- **No write per request**: the state is only written by the daily job; the state query (`tenant-inactivity:query:state`) shows `exempt`, `lastActivityAt`, `warningsSent`, `nextStep` and `nextStepAt`.
|
|
11
|
+
|
|
12
|
+
## Feature composition
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
sessions, tenant, tenant-lifecycle, delivery (required)
|
|
16
|
+
tenant-inactivity <- this sample
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Tests
|
|
20
|
+
|
|
21
|
+
`src/__tests__/feature.integration.test.ts` runs the job against a manual clock and reads the outlook through the state query. The full mail and deletion flow is covered in `bundled-features/src/tenant-inactivity/__tests__`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cosmicdrift/kumiko-sample-tenant-inactivity",
|
|
3
|
+
"description": "tenant-inactivity: warn abandoned free accounts, then file the regular tenant-lifecycle deletion request; tier-based exemption and a keep-account link.",
|
|
4
|
+
"private": true,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@cosmicdrift/kumiko-bundled-features": "workspace:*",
|
|
7
|
+
"@cosmicdrift/kumiko-framework": "workspace:*"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@cosmicdrift/kumiko-testing": "workspace:*"
|
|
11
|
+
}
|
|
12
|
+
}
|