@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,62 @@
|
|
|
1
|
+
// The tenant's retention configuration (compliance profile, retention overrides) decides which
|
|
2
|
+
// entities are blockDelete-held. It is erased in the "tenant-row" phase, after the hold check, because
|
|
3
|
+
// deleting it earlier would change the hold predicate while the tenant still waits on held rows.
|
|
4
|
+
|
|
5
|
+
import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
6
|
+
import {
|
|
7
|
+
createSystemUser,
|
|
8
|
+
type EntityDefinition,
|
|
9
|
+
type TenantDataHookCtx,
|
|
10
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
11
|
+
import {
|
|
12
|
+
tenantComplianceProfileEntity,
|
|
13
|
+
tenantComplianceProfileTable,
|
|
14
|
+
} from "../compliance-profiles/index.ts";
|
|
15
|
+
import {
|
|
16
|
+
tenantRetentionOverrideEntity,
|
|
17
|
+
tenantRetentionOverrideTable,
|
|
18
|
+
} from "../data-retention/index.ts";
|
|
19
|
+
|
|
20
|
+
export const COMPLIANCE_PROFILE_ENTITY_NAME = "tenant-compliance-profile";
|
|
21
|
+
export const RETENTION_OVERRIDE_ENTITY_NAME = "tenant-retention-override";
|
|
22
|
+
|
|
23
|
+
type ExecutorTable = Parameters<typeof createEventStoreExecutor>[0];
|
|
24
|
+
|
|
25
|
+
async function forgetAllTenantRows(
|
|
26
|
+
ctx: TenantDataHookCtx,
|
|
27
|
+
table: ExecutorTable,
|
|
28
|
+
entity: EntityDefinition,
|
|
29
|
+
entityName: string,
|
|
30
|
+
): Promise<void> {
|
|
31
|
+
const executor = createEventStoreExecutor(table, entity, { entityName });
|
|
32
|
+
const user = createSystemUser(ctx.tenantId);
|
|
33
|
+
const rows = await ctx.db.selectMany<{ id: string }>(table, { tenantId: ctx.tenantId });
|
|
34
|
+
for (const row of rows) {
|
|
35
|
+
const forgotten = await executor.forget({ id: row.id }, user, ctx.db);
|
|
36
|
+
if (!forgotten.isSuccess) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`tenant-lifecycle: failed to forget ${entityName} ${row.id} for tenant ${ctx.tenantId}: ${forgotten.error.message}`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function complianceProfileTenantDestroyHook(ctx: TenantDataHookCtx): Promise<void> {
|
|
45
|
+
await forgetAllTenantRows(
|
|
46
|
+
ctx,
|
|
47
|
+
tenantComplianceProfileTable,
|
|
48
|
+
tenantComplianceProfileEntity,
|
|
49
|
+
COMPLIANCE_PROFILE_ENTITY_NAME,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function retentionOverrideTenantDestroyHook(ctx: TenantDataHookCtx): Promise<void> {
|
|
54
|
+
// skip: data-retention is optional, without it the override table does not exist
|
|
55
|
+
if (!ctx.registry.getEntity(RETENTION_OVERRIDE_ENTITY_NAME)) return;
|
|
56
|
+
await forgetAllTenantRows(
|
|
57
|
+
ctx,
|
|
58
|
+
tenantRetentionOverrideTable,
|
|
59
|
+
tenantRetentionOverrideEntity,
|
|
60
|
+
RETENTION_OVERRIDE_ENTITY_NAME,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { DbRunner, TenantDb, WhereObject } from "@cosmicdrift/kumiko-framew
|
|
|
3
3
|
import {
|
|
4
4
|
createEventStoreExecutor,
|
|
5
5
|
createTenantDb,
|
|
6
|
+
fetchOne,
|
|
6
7
|
selectMany,
|
|
7
8
|
WritePurposes,
|
|
8
9
|
} from "@cosmicdrift/kumiko-framework/db";
|
|
@@ -23,7 +24,9 @@ import type { FileProviderResolver } from "@cosmicdrift/kumiko-framework/files";
|
|
|
23
24
|
import type { Logger } from "@cosmicdrift/kumiko-framework/logging";
|
|
24
25
|
import type { SearchAdapter } from "@cosmicdrift/kumiko-framework/search";
|
|
25
26
|
import { getTemporal } from "@cosmicdrift/kumiko-framework/time";
|
|
26
|
-
import {
|
|
27
|
+
import { tenantHasBlockDeleteRows } from "../data-retention/index.ts";
|
|
28
|
+
import type { TenantDestructionHoldProvider } from "../shared/index.ts";
|
|
29
|
+
import { type TenantLifecycleStatus, tenantEntity, tenantTable } from "../tenant/index.ts";
|
|
27
30
|
import {
|
|
28
31
|
DESTRUCTION_STAGE_MAX_PENDING_MS,
|
|
29
32
|
DESTRUCTION_STAGE_MIN_SLICE_MS,
|
|
@@ -202,7 +205,11 @@ async function appendTenantStageEventIdempotent(
|
|
|
202
205
|
return lastEventVersion(events);
|
|
203
206
|
}
|
|
204
207
|
|
|
205
|
-
async function
|
|
208
|
+
async function setTenantLifecycleStatus(
|
|
209
|
+
db: DbRunner,
|
|
210
|
+
tenantId: TenantId,
|
|
211
|
+
status: TenantLifecycleStatus,
|
|
212
|
+
): Promise<void> {
|
|
206
213
|
const user = createSystemUser(tenantId);
|
|
207
214
|
const scopedDb = createTenantDb({
|
|
208
215
|
db,
|
|
@@ -213,7 +220,7 @@ async function markTenantDestroyFailed(db: DbRunner, tenantId: TenantId): Promis
|
|
|
213
220
|
await tenantCrud.update(
|
|
214
221
|
{
|
|
215
222
|
id: tenantId,
|
|
216
|
-
changes: { status
|
|
223
|
+
changes: { status },
|
|
217
224
|
},
|
|
218
225
|
user,
|
|
219
226
|
scopedDb,
|
|
@@ -222,6 +229,17 @@ async function markTenantDestroyFailed(db: DbRunner, tenantId: TenantId): Promis
|
|
|
222
229
|
invalidateTenantLifecycleGate(tenantId);
|
|
223
230
|
}
|
|
224
231
|
|
|
232
|
+
// True while the tenant still owns rows whose blockDelete retention has not run out.
|
|
233
|
+
async function tenantOwnsRetentionHeldRows(args: {
|
|
234
|
+
readonly db: DbRunner;
|
|
235
|
+
readonly registry: Registry;
|
|
236
|
+
readonly tenantId: TenantId;
|
|
237
|
+
readonly now: Temporal.Instant;
|
|
238
|
+
}): Promise<boolean> {
|
|
239
|
+
if (!args.registry.features.has("data-retention")) return false;
|
|
240
|
+
return await tenantHasBlockDeleteRows(args);
|
|
241
|
+
}
|
|
242
|
+
|
|
225
243
|
async function haltPipelineOnAbandon(args: {
|
|
226
244
|
readonly db: DbRunner;
|
|
227
245
|
readonly tenantId: TenantId;
|
|
@@ -252,7 +270,7 @@ async function haltPipelineOnAbandon(args: {
|
|
|
252
270
|
{ stage: args.stage, error: args.error, failedAt: failedAt.toString() },
|
|
253
271
|
versionAfterAbandon,
|
|
254
272
|
);
|
|
255
|
-
await
|
|
273
|
+
await setTenantLifecycleStatus(args.db, args.tenantId, "destroyFailed");
|
|
256
274
|
}
|
|
257
275
|
|
|
258
276
|
async function maybeAppendDestructionCompleted(
|
|
@@ -285,6 +303,7 @@ type StageTickResult = {
|
|
|
285
303
|
readonly halted?: boolean;
|
|
286
304
|
readonly progressed?: boolean;
|
|
287
305
|
readonly pending?: boolean;
|
|
306
|
+
readonly held?: boolean;
|
|
288
307
|
};
|
|
289
308
|
|
|
290
309
|
// `version` differs per caller: the catch path appends against the pre-run
|
|
@@ -379,6 +398,20 @@ export async function runNextDestructionStage(args: {
|
|
|
379
398
|
return { done: isDestructionPipelineComplete(completed) };
|
|
380
399
|
}
|
|
381
400
|
|
|
401
|
+
// Parking is no stage attempt: no stage-started event, no attempt count, no failure.
|
|
402
|
+
if (
|
|
403
|
+
next.name === "tenant-row" &&
|
|
404
|
+
(await tenantOwnsRetentionHeldRows({
|
|
405
|
+
db: args.db,
|
|
406
|
+
registry: args.registry,
|
|
407
|
+
tenantId: args.tenantId,
|
|
408
|
+
now,
|
|
409
|
+
}))
|
|
410
|
+
) {
|
|
411
|
+
await setTenantLifecycleStatus(args.db, args.tenantId, "destroyHeld");
|
|
412
|
+
return { done: false, held: true };
|
|
413
|
+
}
|
|
414
|
+
|
|
382
415
|
const priorAttempts = attemptsByStage.get(next.name) ?? 0;
|
|
383
416
|
const attempt = priorAttempts + 1;
|
|
384
417
|
const ctx: DestructionStageCtx = {
|
|
@@ -392,6 +425,7 @@ export async function runNextDestructionStage(args: {
|
|
|
392
425
|
escapeHatchAuditLog: args.escapeHatchAuditLog,
|
|
393
426
|
actor: args.actor,
|
|
394
427
|
deadlineAt: args.deadlineAt ?? Date.now() + DESTRUCTION_STAGE_TICK_BUDGET_MS,
|
|
428
|
+
now,
|
|
395
429
|
};
|
|
396
430
|
|
|
397
431
|
let version = lastEventVersion(events);
|
|
@@ -482,6 +516,25 @@ export async function hasTenantDestructionWork(
|
|
|
482
516
|
return due > 0 || destroying > 0;
|
|
483
517
|
}
|
|
484
518
|
|
|
519
|
+
// A destroyHeld tenant is not sweep work: the daily retention run releases it once its last held row
|
|
520
|
+
// is gone, and the sweep then runs tenant-row as a fresh first attempt.
|
|
521
|
+
export const tenantDestructionHoldProvider: TenantDestructionHoldProvider = {
|
|
522
|
+
async isParked({ db, tenantId }) {
|
|
523
|
+
return (await tenantStatusOf(db, tenantId)) === "destroyHeld";
|
|
524
|
+
},
|
|
525
|
+
async releaseIfFree({ db, registry, tenantId, now }) {
|
|
526
|
+
if ((await tenantStatusOf(db, tenantId)) !== "destroyHeld") return false;
|
|
527
|
+
if (await tenantOwnsRetentionHeldRows({ db, registry, tenantId, now })) return false;
|
|
528
|
+
await setTenantLifecycleStatus(db, tenantId, "destroying");
|
|
529
|
+
return true;
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
async function tenantStatusOf(db: DbRunner, tenantId: TenantId): Promise<string | undefined> {
|
|
534
|
+
const row = await fetchOne<{ status: string }>(db, tenantTable, { id: tenantId });
|
|
535
|
+
return row?.status;
|
|
536
|
+
}
|
|
537
|
+
|
|
485
538
|
/** Cron entry: start destruction for tenants past grace, then advance stages. */
|
|
486
539
|
export async function runTenantDestructionSweep(args: {
|
|
487
540
|
readonly db: DbRunner;
|
|
@@ -559,7 +612,7 @@ export async function runTenantDestructionSweep(args: {
|
|
|
559
612
|
escapeHatchAuditLog: args.escapeHatchAuditLog,
|
|
560
613
|
actor: args.actor,
|
|
561
614
|
});
|
|
562
|
-
if (!result.error && !result.halted) advanced++;
|
|
615
|
+
if (!result.error && !result.halted && !result.held) advanced++;
|
|
563
616
|
} catch (err) {
|
|
564
617
|
// Isolate the failure to this tenant — an uncaught throw here must not
|
|
565
618
|
// abort the whole sweep tick and starve every other "destroying" tenant
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="temporal-polyfill/global" preserve="true" />
|
|
1
2
|
import {
|
|
2
3
|
configuredPiiSubjectKms,
|
|
3
4
|
type SubjectId,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
isTenantDataExtensionHooks,
|
|
24
25
|
isTenantResourceExtensionHooks,
|
|
25
26
|
type Registry,
|
|
27
|
+
type TenantDataDestroyPhase,
|
|
26
28
|
type TenantDataHookCtx,
|
|
27
29
|
type TenantDestroyHookResult,
|
|
28
30
|
type TenantId,
|
|
@@ -39,6 +41,10 @@ import {
|
|
|
39
41
|
type SearchAdapter,
|
|
40
42
|
} from "@cosmicdrift/kumiko-framework/search";
|
|
41
43
|
import { getTemporal } from "@cosmicdrift/kumiko-framework/time";
|
|
44
|
+
import {
|
|
45
|
+
type DestructionHold,
|
|
46
|
+
holdBlockDeleteRowsForDestruction,
|
|
47
|
+
} from "../data-retention/index.ts";
|
|
42
48
|
import {
|
|
43
49
|
tenantEntity,
|
|
44
50
|
tenantMembershipEntity,
|
|
@@ -67,6 +73,8 @@ export type DestructionStageCtx = {
|
|
|
67
73
|
readonly actor?: string;
|
|
68
74
|
// Epoch ms the stage must hand back by returning { done: false }.
|
|
69
75
|
readonly deadlineAt: number;
|
|
76
|
+
// Sweep clock, so retention cut-offs follow the injected clock instead of wall time.
|
|
77
|
+
readonly now: Temporal.Instant;
|
|
70
78
|
};
|
|
71
79
|
|
|
72
80
|
export type StageRunOutcome = {
|
|
@@ -131,15 +139,33 @@ async function runExtensionDestroyHooks(
|
|
|
131
139
|
return total.outcome();
|
|
132
140
|
}
|
|
133
141
|
|
|
134
|
-
|
|
142
|
+
const NOTHING_HELD: DestructionHold = { entityNames: new Set(), fileRefIds: new Set() };
|
|
143
|
+
|
|
144
|
+
async function runTenantDataHooks(
|
|
145
|
+
ctx: DestructionStageCtx,
|
|
146
|
+
phase: TenantDataDestroyPhase,
|
|
147
|
+
): Promise<StageRunOutcome> {
|
|
135
148
|
const usages = ctx.registry.getExtensionUsages(EXT_TENANT_DATA);
|
|
136
149
|
const total = newOutcomeAccumulator();
|
|
150
|
+
// Rows inside a blockDelete keepFor must outlive the account; their hook is skipped, the rows are
|
|
151
|
+
// anonymized and the fileRefs they point at are handed to the other hooks. Recomputed every tick.
|
|
152
|
+
const hold =
|
|
153
|
+
phase === "app-data" && ctx.registry.features.has("data-retention")
|
|
154
|
+
? await holdBlockDeleteRowsForDestruction({
|
|
155
|
+
db: ctx.db,
|
|
156
|
+
registry: ctx.registry,
|
|
157
|
+
tenantId: ctx.tenantId,
|
|
158
|
+
now: ctx.now,
|
|
159
|
+
})
|
|
160
|
+
: NOTHING_HELD;
|
|
137
161
|
for (const usage of usages) {
|
|
138
162
|
if (!isTenantDataExtensionHooks(usage.options)) {
|
|
139
163
|
throw new Error(
|
|
140
164
|
`${EXT_TENANT_DATA} registration for "${usage.entityName}" has no destroy function`,
|
|
141
165
|
);
|
|
142
166
|
}
|
|
167
|
+
if ((usage.options["phase"] ?? "app-data") !== phase) continue;
|
|
168
|
+
if (hold.entityNames.has(usage.entityName)) continue;
|
|
143
169
|
const destroy = usage.options.destroy;
|
|
144
170
|
const reason = extensionUsageEscapeHatchReason(usage);
|
|
145
171
|
const report = createEscapeHatchReporter({
|
|
@@ -162,6 +188,7 @@ async function runTenantDataHooks(ctx: DestructionStageCtx): Promise<StageRunOut
|
|
|
162
188
|
tenantId: ctx.tenantId,
|
|
163
189
|
deadlineAt: ctx.deadlineAt,
|
|
164
190
|
fileProviderResolver: ctx.fileProviderResolver,
|
|
191
|
+
heldFileRefIds: hold.fileRefIds,
|
|
165
192
|
log: ctx.log,
|
|
166
193
|
};
|
|
167
194
|
total.add(await destroy(hookCtx));
|
|
@@ -245,6 +272,8 @@ async function purgeTenantCache(ctx: DestructionStageCtx): Promise<StageRunOutco
|
|
|
245
272
|
}
|
|
246
273
|
|
|
247
274
|
async function tombstoneTenantRow(ctx: DestructionStageCtx): Promise<StageRunOutcome> {
|
|
275
|
+
const lateHooks = await runTenantDataHooks(ctx, "tenant-row");
|
|
276
|
+
if (!lateHooks.done) return lateHooks;
|
|
248
277
|
const now = getTemporal().Now.instant();
|
|
249
278
|
const user = createSystemUser(ctx.tenantId);
|
|
250
279
|
const db = createTenantDb({
|
|
@@ -315,7 +344,7 @@ export const DESTRUCTION_STAGES: readonly DestructionStage[] = [
|
|
|
315
344
|
{
|
|
316
345
|
name: "app-data",
|
|
317
346
|
maxAttempts: 3,
|
|
318
|
-
run: runTenantDataHooks,
|
|
347
|
+
run: (ctx) => runTenantDataHooks(ctx, "app-data"),
|
|
319
348
|
},
|
|
320
349
|
{
|
|
321
350
|
name: "subject-keys",
|
|
@@ -51,7 +51,7 @@ export async function driveDestructionToCompletion(
|
|
|
51
51
|
});
|
|
52
52
|
const rows = await selectMany(db, tenantTable, { id: tenantId });
|
|
53
53
|
status = String(rows[0]?.["status"]);
|
|
54
|
-
if (status === "destroyed" || status === "destroyFailed") break;
|
|
54
|
+
if (status === "destroyed" || status === "destroyFailed" || status === "destroyHeld") break;
|
|
55
55
|
}
|
|
56
56
|
return status;
|
|
57
57
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Caps lookup for `TierResolverDeps.capsForTier`: an unknown tier name falls back to the default
|
|
2
|
+
* tier (least-privileged by convention), a name missing from the map is a wiring bug and throws. */
|
|
3
|
+
export function capsForTierFromMap<TTier extends string, TCaps>(
|
|
4
|
+
tierMap: Readonly<Record<TTier, { readonly caps: TCaps }>>,
|
|
5
|
+
isTierName: (value: string) => value is TTier,
|
|
6
|
+
defaultTier: TTier,
|
|
7
|
+
): (tier: string) => TCaps {
|
|
8
|
+
return (tier) => {
|
|
9
|
+
const name = isTierName(tier) ? tier : defaultTier;
|
|
10
|
+
const def = tierMap[name];
|
|
11
|
+
if (!def) {
|
|
12
|
+
throw new Error(`tier-map: tier "${name}" not in tier map`);
|
|
13
|
+
}
|
|
14
|
+
return def.caps;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.408.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "capsForTierFromMap",
|
|
6
|
+
"detail": "capsForTierFromMap(tierMap, isTierName, defaultTier) returns a capsForTier function for createTierResolver. An unknown tier name falls back to defaultTier; if the map has no entry for the resolved name it throws. Apps with a hand-written capsForTier over their tier map can switch to it."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.395.0",
|
|
4
10
|
"type": "fix",
|
|
@@ -88,6 +88,21 @@ export type ComposedApp<TCaps extends Readonly<Record<string, unknown>>> = {
|
|
|
88
88
|
* **No production callers, and that is not rot** — see
|
|
89
89
|
* docs/reference/tier-composition-boot-vs-runtime.md for why.
|
|
90
90
|
*/
|
|
91
|
+
function lookupOrThrow<TValue>(
|
|
92
|
+
map: Readonly<Record<string, TValue>>,
|
|
93
|
+
name: string,
|
|
94
|
+
kind: string,
|
|
95
|
+
knownLabel: string,
|
|
96
|
+
): TValue {
|
|
97
|
+
const value = map[name];
|
|
98
|
+
if (!value) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`composeApp: unknown ${kind} "${name}". ${knownLabel}: ${Object.keys(map).join(", ")}`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
|
|
91
106
|
export function composeApp<TCaps extends Readonly<Record<string, unknown>>>(
|
|
92
107
|
input: ComposeAppInput<TCaps>,
|
|
93
108
|
): ComposedApp<TCaps> {
|
|
@@ -99,31 +114,17 @@ export function composeApp<TCaps extends Readonly<Record<string, unknown>>>(
|
|
|
99
114
|
);
|
|
100
115
|
}
|
|
101
116
|
|
|
102
|
-
const addOnDefs = input.addOns.map((name) =>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
throw new Error(
|
|
106
|
-
`composeApp: unknown add-on "${name}". Known add-ons: ` +
|
|
107
|
-
`${Object.keys(input.addOnMap).join(", ")}`,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
return def;
|
|
111
|
-
});
|
|
117
|
+
const addOnDefs = input.addOns.map((name) =>
|
|
118
|
+
lookupOrThrow(input.addOnMap, name, "add-on", "Known add-ons"),
|
|
119
|
+
);
|
|
112
120
|
|
|
113
121
|
const tierFeatureNames = tierDef.features;
|
|
114
122
|
const addOnFeatureNames = addOnDefs.flatMap((d) => d.features);
|
|
115
123
|
const allFeatureNames = [...tierFeatureNames, ...addOnFeatureNames];
|
|
116
124
|
|
|
117
|
-
const additionalFeatures = allFeatureNames.map((name) =>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
throw new Error(
|
|
121
|
-
`composeApp: unknown feature "${name}". Registered features: ` +
|
|
122
|
-
`${Object.keys(input.featureRegistry).join(", ")}`,
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
return feature;
|
|
126
|
-
});
|
|
125
|
+
const additionalFeatures = allFeatureNames.map((name) =>
|
|
126
|
+
lookupOrThrow(input.featureRegistry, name, "feature", "Registered features"),
|
|
127
|
+
);
|
|
127
128
|
|
|
128
129
|
// Dedupe — a feature listed in both the tier and an add-on should only
|
|
129
130
|
// mount once. Order-preserving: first occurrence wins.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// - `TierEngineHandlers` / `TierEngineQueries` — qualified handler names
|
|
9
9
|
|
|
10
10
|
export { tierAssignmentAggregateId } from "./aggregate-id.ts";
|
|
11
|
+
export { capsForTierFromMap } from "./caps-for-tier-from-map.ts";
|
|
11
12
|
export {
|
|
12
13
|
type AddOnDefinition,
|
|
13
14
|
type AddOnMap,
|
|
@@ -510,6 +510,7 @@ export function createUserDataRightsFeature(opts: UserDataRightsOptions = {}): F
|
|
|
510
510
|
// Entry point of the emailed download link; cheap static page, but
|
|
511
511
|
// anonymous and token-bearing, so bound per-IP probing.
|
|
512
512
|
rateLimit: { per: "ip+handler", limit: 30, windowSeconds: 60 },
|
|
513
|
+
// guard:dup-ok the few-shot corpus extractor reads httpRoute handlers only when they are inline
|
|
513
514
|
handler: async (c) => {
|
|
514
515
|
return c.body(TOKEN_EXCHANGE_PAGE_HTML, 200, {
|
|
515
516
|
"content-type": "text/html; charset=utf-8",
|
|
@@ -525,6 +526,7 @@ export function createUserDataRightsFeature(opts: UserDataRightsOptions = {}): F
|
|
|
525
526
|
method: "GET",
|
|
526
527
|
path: "/user-export/by-token.js",
|
|
527
528
|
anonymous: true,
|
|
529
|
+
// guard:dup-ok the few-shot corpus extractor reads httpRoute handlers only when they are inline
|
|
528
530
|
handler: async (c) => {
|
|
529
531
|
return c.body(TOKEN_EXCHANGE_PAGE_JS, 200, {
|
|
530
532
|
"content-type": "application/javascript; charset=utf-8",
|
package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts
CHANGED
|
@@ -56,7 +56,10 @@ export function createConfirmDeletionByTokenHandler(opts: ConfirmDeletionByToken
|
|
|
56
56
|
return defineWriteHandler({
|
|
57
57
|
name: "confirm-deletion-by-token",
|
|
58
58
|
schema: z.object({ token: z.string().min(1) }),
|
|
59
|
-
access: {
|
|
59
|
+
access: {
|
|
60
|
+
roles: ["anonymous", "Member", "User", "TenantAdmin", "SystemAdmin"],
|
|
61
|
+
anySignedIn: true,
|
|
62
|
+
},
|
|
60
63
|
escapeHatch: {
|
|
61
64
|
reason:
|
|
62
65
|
"resolveGracePeriod reads the tenant compliance profile via ctx.dispatch.queryAs(SYSTEM, " +
|
|
@@ -79,6 +79,7 @@ export const downloadByTokenQuery = defineQueryHandler({
|
|
|
79
79
|
access: {
|
|
80
80
|
roles: ["anonymous", "Member", "User", "TenantAdmin", "SystemAdmin"],
|
|
81
81
|
personalData: "public-intake",
|
|
82
|
+
anySignedIn: true,
|
|
82
83
|
},
|
|
83
84
|
agent: { expose: false },
|
|
84
85
|
// Brute-force protection for token-hash probing. This anonymous endpoint uses a
|
package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts
CHANGED
|
@@ -61,7 +61,10 @@ export function createRequestDeletionByEmailHandler(opts: RequestDeletionByEmail
|
|
|
61
61
|
return defineWriteHandler({
|
|
62
62
|
name: "request-deletion-by-email",
|
|
63
63
|
schema: z.object({ email: z.email() }),
|
|
64
|
-
access: {
|
|
64
|
+
access: {
|
|
65
|
+
roles: ["anonymous", "Member", "User", "TenantAdmin", "SystemAdmin"],
|
|
66
|
+
anySignedIn: true,
|
|
67
|
+
},
|
|
65
68
|
description:
|
|
66
69
|
"Mails an account-deletion verification link to the given address, for a user who wants to be erased but can no longer log in; it answers identically whether or not the address belongs to an active account and never returns the link.",
|
|
67
70
|
// Mails a deletion link to any address the caller names.
|
|
@@ -220,6 +220,7 @@ export function sanitizeReasonForLog(reason: string): string {
|
|
|
220
220
|
|
|
221
221
|
// Cross-tenant by design: the due-user and membership reads on the given runner and raw hook
|
|
222
222
|
// statements must see every tenant, whatever RLS scope the caller (job, operator handler) runs in.
|
|
223
|
+
// guard:dup-ok the single runInSystemRowLevelSecurityScope call with this entry point's own reason
|
|
223
224
|
export function runForgetCleanup(args: RunForgetCleanupArgs): Promise<RunForgetCleanupResult> {
|
|
224
225
|
return runInSystemRowLevelSecurityScope(
|
|
225
226
|
"forget cleanup anonymizes users across all tenants",
|
|
@@ -427,6 +428,7 @@ async function processUser(args: {
|
|
|
427
428
|
resolveDeleteBytes: resolveForgetFileBytesDeleter(buildStorageProvider),
|
|
428
429
|
missingStorage: {
|
|
429
430
|
mode: "skip",
|
|
431
|
+
// guard:dup-ok a one-message log callback; only the shape matches other log callbacks
|
|
430
432
|
warn: (tenantId) =>
|
|
431
433
|
// biome-ignore lint/suspicious/noConsole: misconfiguration visibility, same as the fileRef delete hook
|
|
432
434
|
console.warn(
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { postWithDownload } from "@cosmicdrift/kumiko-renderer/web";
|
|
20
20
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
21
21
|
import { type ReactNode, useEffect, useState } from "react";
|
|
22
|
-
import { type SectionStatus, StatusBanner } from "../../shared/web/
|
|
22
|
+
import { type SectionStatus, StatusBanner } from "../../shared/web/index.ts";
|
|
23
23
|
import {
|
|
24
24
|
EXPORT_JOB_STATUS,
|
|
25
25
|
type ExportJobStatus,
|
|
@@ -85,6 +85,7 @@ function collapseUnsafe(s: string): string {
|
|
|
85
85
|
* tenantId and fileRefId have UUID shapes and are safe; fileName is passed
|
|
86
86
|
* through sanitizeZipFilename. Path traversal is guaranteed to be excluded.
|
|
87
87
|
*/
|
|
88
|
+
// guard:dup-ok one sanitized template-literal path; only the shape matches unrelated string builders
|
|
88
89
|
export function buildFileRefZipPath(args: {
|
|
89
90
|
readonly tenantId: TenantId;
|
|
90
91
|
readonly fileRefId: string;
|
package/packages/bundled-features/src/user-data-rights-defaults/hooks/config-value.userdata-hook.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
-
import {
|
|
3
|
-
createSystemUser,
|
|
4
|
-
type UserDataDeleteHook,
|
|
5
|
-
type UserDataExportHook,
|
|
6
|
-
} from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import type { UserDataDeleteHook, UserDataExportHook } from "@cosmicdrift/kumiko-framework/engine";
|
|
7
3
|
import { configValueEntity, configValuesTable } from "../../config/index.ts";
|
|
8
|
-
import { collectErasureFailure, throwIfErasureFailed } from "../../shared/index.ts";
|
|
9
4
|
import { featureMounted } from "./feature-mounted.ts";
|
|
5
|
+
import { forgetOwnRowsDeleteHook } from "./forget-own-rows-delete-hook.ts";
|
|
10
6
|
|
|
11
7
|
// userData-Hooks for config's USER-scoped rows (userId set). Tenant-/system-
|
|
12
8
|
// scope rows carry no per-user subject and stay untouched. Event-sourced
|
|
@@ -34,24 +30,9 @@ export const configValueExportHook: UserDataExportHook = async (ctx) => {
|
|
|
34
30
|
};
|
|
35
31
|
};
|
|
36
32
|
|
|
37
|
-
export const configValueDeleteHook: UserDataDeleteHook =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
userId: ctx.userId,
|
|
44
|
-
});
|
|
45
|
-
const failures: string[] = [];
|
|
46
|
-
for (const row of rows) {
|
|
47
|
-
const id = row["id"]; // @cast-boundary db-row
|
|
48
|
-
if (typeof id !== "string") continue;
|
|
49
|
-
collectErasureFailure(
|
|
50
|
-
await crud.forget({ id }, systemUser, ctx.db),
|
|
51
|
-
"config-value",
|
|
52
|
-
id,
|
|
53
|
-
failures,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
throwIfErasureFailed(failures);
|
|
57
|
-
};
|
|
33
|
+
export const configValueDeleteHook: UserDataDeleteHook = forgetOwnRowsDeleteHook({
|
|
34
|
+
featureName: "config",
|
|
35
|
+
entityName: "config-value",
|
|
36
|
+
table: configValuesTable,
|
|
37
|
+
executor: crud,
|
|
38
|
+
});
|
|
@@ -22,14 +22,17 @@ export const deliveryAttemptExportHook: UserDataExportHook = async (ctx) => {
|
|
|
22
22
|
if (rows.length === 0) return null;
|
|
23
23
|
return {
|
|
24
24
|
entity: "delivery-attempt",
|
|
25
|
-
rows: rows.map(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
rows: rows.map(
|
|
26
|
+
// guard:dup-ok export field selection for this entity; only the object-literal shape matches other mappers
|
|
27
|
+
(r) => ({
|
|
28
|
+
notificationType: r["notificationType"],
|
|
29
|
+
channel: r["channel"],
|
|
30
|
+
status: r["status"],
|
|
31
|
+
recipientAddress: r["recipientAddress"],
|
|
32
|
+
priority: r["priority"],
|
|
33
|
+
createdAt: r["createdAt"],
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
33
36
|
};
|
|
34
37
|
};
|
|
35
38
|
|
package/packages/bundled-features/src/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { EventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import {
|
|
3
|
+
createSystemUser,
|
|
4
|
+
type UserDataDeleteHook,
|
|
5
|
+
type UserDataHookCtx,
|
|
6
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
7
|
+
import { collectErasureFailure, throwIfErasureFailed } from "../../shared/index.ts";
|
|
8
|
+
import { featureMounted } from "./feature-mounted.ts";
|
|
9
|
+
|
|
10
|
+
type OwnRowsTable = Parameters<UserDataHookCtx["db"]["selectMany"]>[0];
|
|
11
|
+
|
|
12
|
+
// Event-sourced rows owned by the user: forgetting goes through the executor so a rebuild replays
|
|
13
|
+
// the erasure.
|
|
14
|
+
export function forgetOwnRowsDeleteHook(source: {
|
|
15
|
+
readonly featureName: string;
|
|
16
|
+
readonly entityName: string;
|
|
17
|
+
readonly table: OwnRowsTable;
|
|
18
|
+
readonly executor: Pick<EventStoreExecutor, "forget">;
|
|
19
|
+
}): UserDataDeleteHook {
|
|
20
|
+
const { featureName, entityName, table, executor } = source;
|
|
21
|
+
return async (ctx) => {
|
|
22
|
+
// skip: source feature not mounted — its table doesn't exist, nothing to erase.
|
|
23
|
+
if (!featureMounted(ctx, featureName)) return;
|
|
24
|
+
const systemUser = createSystemUser(ctx.tenantId);
|
|
25
|
+
const rows = await ctx.db.selectMany<Record<string, unknown>>(table, {
|
|
26
|
+
tenantId: ctx.tenantId,
|
|
27
|
+
userId: ctx.userId,
|
|
28
|
+
});
|
|
29
|
+
const failures: string[] = [];
|
|
30
|
+
for (const row of rows) {
|
|
31
|
+
const id = row["id"]; // @cast-boundary db-row
|
|
32
|
+
if (typeof id !== "string") continue;
|
|
33
|
+
collectErasureFailure(
|
|
34
|
+
await executor.forget({ id }, systemUser, ctx.db),
|
|
35
|
+
entityName,
|
|
36
|
+
id,
|
|
37
|
+
failures,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
throwIfErasureFailed(failures);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
-
import {
|
|
3
|
-
createSystemUser,
|
|
4
|
-
type UserDataDeleteHook,
|
|
5
|
-
type UserDataExportHook,
|
|
6
|
-
} from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import type { UserDataDeleteHook, UserDataExportHook } from "@cosmicdrift/kumiko-framework/engine";
|
|
7
3
|
import {
|
|
8
4
|
notificationPreferenceEntity,
|
|
9
5
|
notificationPreferencesTable,
|
|
10
6
|
} from "../../delivery/index.ts";
|
|
11
|
-
import { collectErasureFailure, throwIfErasureFailed } from "../../shared/index.ts";
|
|
12
7
|
import { featureMounted } from "./feature-mounted.ts";
|
|
8
|
+
import { forgetOwnRowsDeleteHook } from "./forget-own-rows-delete-hook.ts";
|
|
13
9
|
|
|
14
10
|
// userData-Hooks for delivery's notification-preference rows. Event-sourced
|
|
15
11
|
// entity → forget goes through the executor so a rebuild replays the erasure.
|
|
@@ -40,24 +36,9 @@ export const notificationPreferenceExportHook: UserDataExportHook = async (ctx)
|
|
|
40
36
|
};
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
export const notificationPreferenceDeleteHook: UserDataDeleteHook =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
userId: ctx.userId,
|
|
50
|
-
});
|
|
51
|
-
const failures: string[] = [];
|
|
52
|
-
for (const row of rows) {
|
|
53
|
-
const id = row["id"]; // @cast-boundary db-row
|
|
54
|
-
if (typeof id !== "string") continue;
|
|
55
|
-
collectErasureFailure(
|
|
56
|
-
await crud.forget({ id }, systemUser, ctx.db),
|
|
57
|
-
"notification-preference",
|
|
58
|
-
id,
|
|
59
|
-
failures,
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
throwIfErasureFailed(failures);
|
|
63
|
-
};
|
|
39
|
+
export const notificationPreferenceDeleteHook: UserDataDeleteHook = forgetOwnRowsDeleteHook({
|
|
40
|
+
featureName: "delivery",
|
|
41
|
+
entityName: "notification-preference",
|
|
42
|
+
table: notificationPreferencesTable,
|
|
43
|
+
executor: crud,
|
|
44
|
+
});
|