@cosmicdrift/kumiko-samples 0.405.0 → 0.409.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 +26 -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/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/contact/challenge.ts +41 -0
- package/packages/bundled-features/src/contact/changes.json +27 -0
- package/packages/bundled-features/src/contact/client/contact-client-source.ts +203 -0
- package/packages/bundled-features/src/contact/entity.ts +168 -0
- package/packages/bundled-features/src/contact/feature.ts +171 -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 +189 -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 +506 -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/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/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/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/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-tenant.query.ts +11 -8
- 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 +56 -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 +30 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +6 -0
- package/packages/bundled-features/src/tenant-lifecycle/events.ts +2 -0
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +25 -2
- package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +12 -87
- package/packages/bundled-features/src/tenant-lifecycle/index.ts +6 -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 +131 -11
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +39 -4
- 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/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/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 +134 -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/playwright.config.ts +2 -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 +38 -4
- package/samples/recipes/contact/README.md +46 -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/lane-routing/README.md +1 -0
- package/samples/recipes/lane-routing/src/feature.ts +8 -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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { assertBillingLive } from "./assert-billing-live.ts";
|
|
1
2
|
export { collectErasureFailure, throwIfErasureFailed } from "./assert-erased.ts";
|
|
2
3
|
export { assertNoWhereRuleInOwnershipWrite } from "./assert-no-where-rule-in-ownership-write.ts";
|
|
3
4
|
export {
|
|
@@ -24,6 +25,7 @@ export { hmacSignatureMatches, signHmacSha256Base64Url } from "./hmac-signature.
|
|
|
24
25
|
export { isIdentityV3Hash, verifyIdentityV3Hash } from "./identity-v3-hash.ts";
|
|
25
26
|
export { isTenantDb } from "./is-tenant-db.ts";
|
|
26
27
|
export { isUniqueConstraintFailure } from "./is-unique-constraint-failure.ts";
|
|
28
|
+
export { createLateBoundSlot, type LateBoundSlot } from "./late-bound-slot.ts";
|
|
27
29
|
export { createLockoutCounter, type LockoutCounterState } from "./lockout-counter.ts";
|
|
28
30
|
export { createMailLocaleTemplates } from "./mail-locale-templates.ts";
|
|
29
31
|
export {
|
|
@@ -40,6 +42,12 @@ export {
|
|
|
40
42
|
parentRowIsVisible,
|
|
41
43
|
} from "./parent-visibility.ts";
|
|
42
44
|
export { hashPassword, verifyDummyPassword, verifyPassword } from "./password-hashing.ts";
|
|
45
|
+
export {
|
|
46
|
+
type PriceEnvProvider,
|
|
47
|
+
type PriceEnvShape,
|
|
48
|
+
priceEnvSchema,
|
|
49
|
+
priceEnvShape,
|
|
50
|
+
} from "./price-env-shape.ts";
|
|
43
51
|
export {
|
|
44
52
|
type DeleteFileBytes,
|
|
45
53
|
FileSweepError,
|
|
@@ -47,6 +55,7 @@ export {
|
|
|
47
55
|
purgeFilesReachingSubject,
|
|
48
56
|
} from "./purge-files-reaching-subject.ts";
|
|
49
57
|
export {
|
|
58
|
+
collectFileRefIds,
|
|
50
59
|
collectSingleFileHolders,
|
|
51
60
|
type FileFieldPlan,
|
|
52
61
|
type FileRefPurgeOutcome,
|
|
@@ -55,6 +64,7 @@ export {
|
|
|
55
64
|
type SingleFileHolder,
|
|
56
65
|
} from "./purge-row-file-refs.ts";
|
|
57
66
|
export { rateLimitedTextResponse } from "./rate-limited-text-response.ts";
|
|
67
|
+
export { readFeatureExportFn } from "./read-feature-export-fn.ts";
|
|
58
68
|
export {
|
|
59
69
|
redactBotTokens,
|
|
60
70
|
redactEmailAddresses,
|
|
@@ -114,4 +124,10 @@ export {
|
|
|
114
124
|
} from "./stream-tenant-derived-state.ts";
|
|
115
125
|
export type { SystemQueryFn } from "./system-query.ts";
|
|
116
126
|
export { createTenantDbCache } from "./tenant-db-cache.ts";
|
|
127
|
+
export {
|
|
128
|
+
EXT_TENANT_DESTRUCTION_HOLD,
|
|
129
|
+
findTenantDestructionHoldProvider,
|
|
130
|
+
type TenantDestructionHoldProvider,
|
|
131
|
+
} from "./tenant-destruction-hold.ts";
|
|
117
132
|
export { type BurnResult, burnToken, unburnToken } from "./token-burn-store.ts";
|
|
133
|
+
export { unprocessable } from "./unprocessable.ts";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The unbind only clears the slot while it still holds this value, so a stack that stops later
|
|
2
|
+
// cannot unbind a newer stack sharing the same feature instance.
|
|
3
|
+
export type LateBoundSlot<TValue> = {
|
|
4
|
+
readonly bind: (value: TValue) => () => void;
|
|
5
|
+
readonly current: () => TValue | undefined;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function createLateBoundSlot<TValue>(): LateBoundSlot<TValue> {
|
|
9
|
+
let bound: TValue | undefined;
|
|
10
|
+
return {
|
|
11
|
+
bind: (value) => {
|
|
12
|
+
bound = value;
|
|
13
|
+
return () => {
|
|
14
|
+
if (bound === value) bound = undefined;
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
current: () => bound,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -11,6 +11,8 @@ type MailLocaleTemplateConfig<Kind extends string> = {
|
|
|
11
11
|
readonly notificationTypes: Readonly<Record<Kind, string>>;
|
|
12
12
|
readonly subjectKey: (kind: Kind) => string;
|
|
13
13
|
readonly bodyFor: (kind: Kind, locale: string) => string;
|
|
14
|
+
// Subject placeholder -> template variable; defaults to the app name only.
|
|
15
|
+
readonly subjectSlots?: (kind: Kind) => Readonly<Record<string, string>>;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export function createMailLocaleTemplates<Kind extends string>(
|
|
@@ -51,7 +53,11 @@ export function createMailLocaleTemplates<Kind extends string>(
|
|
|
51
53
|
{
|
|
52
54
|
body: config.bodyFor(kind, locale),
|
|
53
55
|
meta: {
|
|
54
|
-
subject: mailT(
|
|
56
|
+
subject: mailT(
|
|
57
|
+
locale,
|
|
58
|
+
kindSubjectKey,
|
|
59
|
+
config.subjectSlots?.(kind) ?? { app: "{{appName}}" },
|
|
60
|
+
),
|
|
55
61
|
category: "transactional" as const,
|
|
56
62
|
},
|
|
57
63
|
},
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
export type PriceEnvProvider<TEnvPrefix extends string> = {
|
|
4
|
+
readonly envPrefix: TEnvPrefix;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly priceIdPrefix: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type PriceEnvShape<TEnvPrefix extends string, TPrice extends string> = {
|
|
10
|
+
[Key in `${TEnvPrefix}_PRICE_${TPrice}`]: z.ZodOptional<z.ZodString>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function priceEnvShape<const TEnvPrefix extends string, const TPrice extends string>(
|
|
14
|
+
provider: PriceEnvProvider<TEnvPrefix>,
|
|
15
|
+
prices: readonly TPrice[],
|
|
16
|
+
): PriceEnvShape<TEnvPrefix, TPrice> {
|
|
17
|
+
const { envPrefix, label, priceIdPrefix } = provider;
|
|
18
|
+
return Object.fromEntries(
|
|
19
|
+
prices.map((price) => [
|
|
20
|
+
`${envPrefix}_PRICE_${price}`,
|
|
21
|
+
z
|
|
22
|
+
.string()
|
|
23
|
+
.regex(
|
|
24
|
+
new RegExp(`^${priceIdPrefix}`),
|
|
25
|
+
`${envPrefix}_PRICE_${price} must start with '${priceIdPrefix}'`,
|
|
26
|
+
)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe(`${label} price id (\`${priceIdPrefix}...\`) of the ${price} plan.`),
|
|
29
|
+
]),
|
|
30
|
+
// @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
|
|
31
|
+
) as PriceEnvShape<TEnvPrefix, TPrice>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function priceEnvSchema<
|
|
35
|
+
TBaseShape extends z.ZodRawShape,
|
|
36
|
+
const TEnvPrefix extends string,
|
|
37
|
+
const TPrice extends string,
|
|
38
|
+
>(
|
|
39
|
+
base: z.ZodObject<TBaseShape>,
|
|
40
|
+
provider: PriceEnvProvider<TEnvPrefix>,
|
|
41
|
+
prices: readonly TPrice[],
|
|
42
|
+
) {
|
|
43
|
+
return z.object({ ...base.shape, ...priceEnvShape(provider, prices) });
|
|
44
|
+
}
|
|
@@ -66,7 +66,7 @@ export function collectSingleFileHolders(registry: Registry): readonly SingleFil
|
|
|
66
66
|
// Every fileRef-id a row's file-fields reference: single fields hold the id in
|
|
67
67
|
// their own column, plural fields resolve via file_refs (tenantId, entityType,
|
|
68
68
|
// entityId, fieldName).
|
|
69
|
-
async function collectFileRefIds(
|
|
69
|
+
export async function collectFileRefIds(
|
|
70
70
|
db: DbRunner,
|
|
71
71
|
tenantId: TenantId,
|
|
72
72
|
entityName: string,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export function readFeatureExportFn<TFn extends (...args: never[]) => unknown>(
|
|
4
|
+
feature: FeatureDefinition,
|
|
5
|
+
exportName: string,
|
|
6
|
+
): TFn | undefined {
|
|
7
|
+
const exports = feature.exports;
|
|
8
|
+
if (exports && typeof exports === "object" && exportName in exports) {
|
|
9
|
+
const candidate = Reflect.get(exports, exportName);
|
|
10
|
+
if (typeof candidate === "function") {
|
|
11
|
+
// @cast-boundary feature-exports — feature.exports is untyped by design
|
|
12
|
+
return candidate as TFn;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
14
14
|
import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
15
15
|
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
16
|
+
import { findExtensionOptions } from "./collect-extension-options.ts";
|
|
16
17
|
|
|
17
18
|
export const EXT_SIGNUP_HANDOVER = "signupHandover" as const;
|
|
18
19
|
|
|
@@ -44,6 +45,7 @@ export type SignupHandoverProvider = {
|
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
|
|
48
|
+
// guard:dup-ok type guard over this provider's own two members; only the guard shape is shared
|
|
47
49
|
export function isSignupHandoverProvider(options: unknown): options is SignupHandoverProvider {
|
|
48
50
|
return (
|
|
49
51
|
isPlainObject(options) &&
|
|
@@ -53,10 +55,7 @@ export function isSignupHandoverProvider(options: unknown): options is SignupHan
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
export function findSignupHandoverProvider(registry: Registry): SignupHandoverProvider | undefined {
|
|
56
|
-
|
|
57
|
-
if (isSignupHandoverProvider(usage.options)) return usage.options;
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
58
|
+
return findExtensionOptions(registry, EXT_SIGNUP_HANDOVER, isSignupHandoverProvider);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
declare module "@cosmicdrift/kumiko-framework/engine" {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// data-retention deletes the last retention-held rows of a tenant whose destruction is parked, and
|
|
2
|
+
// has to hand the tenant back to the destroy sweep afterwards. The status belongs to
|
|
3
|
+
// tenant-lifecycle, which already imports data-retention, so data-retention reaches it through this
|
|
4
|
+
// extension point instead of importing it back.
|
|
5
|
+
|
|
6
|
+
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
7
|
+
import type { Registry, TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
8
|
+
import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
9
|
+
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
10
|
+
import { findExtensionOptions } from "./collect-extension-options.ts";
|
|
11
|
+
|
|
12
|
+
export const EXT_TENANT_DESTRUCTION_HOLD = "tenantDestructionHold" as const;
|
|
13
|
+
|
|
14
|
+
export type TenantDestructionHoldProvider = {
|
|
15
|
+
isParked(args: { readonly db: DbRunner; readonly tenantId: TenantId }): Promise<boolean>;
|
|
16
|
+
/** Hands a parked tenant back to the destroy sweep once nothing holds it; true only when it did. */
|
|
17
|
+
releaseIfFree(args: {
|
|
18
|
+
readonly db: DbRunner;
|
|
19
|
+
readonly registry: Registry;
|
|
20
|
+
readonly tenantId: TenantId;
|
|
21
|
+
readonly now: Temporal.Instant;
|
|
22
|
+
}): Promise<boolean>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function isTenantDestructionHoldProvider(
|
|
26
|
+
options: unknown,
|
|
27
|
+
): options is TenantDestructionHoldProvider {
|
|
28
|
+
return (
|
|
29
|
+
isPlainObject(options) &&
|
|
30
|
+
typeof options["isParked"] === "function" &&
|
|
31
|
+
typeof options["releaseIfFree"] === "function"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function findTenantDestructionHoldProvider(
|
|
36
|
+
registry: Registry,
|
|
37
|
+
): TenantDestructionHoldProvider | undefined {
|
|
38
|
+
return findExtensionOptions(
|
|
39
|
+
registry,
|
|
40
|
+
EXT_TENANT_DESTRUCTION_HOLD,
|
|
41
|
+
isTenantDestructionHoldProvider,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare module "@cosmicdrift/kumiko-framework/engine" {
|
|
46
|
+
interface KumikoExtensionOptionsMap {
|
|
47
|
+
[EXT_TENANT_DESTRUCTION_HOLD]: TenantDestructionHoldProvider;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UnprocessableError,
|
|
3
|
+
type WriteFailure,
|
|
4
|
+
writeFailure,
|
|
5
|
+
} from "@cosmicdrift/kumiko-framework/errors";
|
|
6
|
+
|
|
7
|
+
type UnprocessableDetails = NonNullable<
|
|
8
|
+
ConstructorParameters<typeof UnprocessableError>[1]
|
|
9
|
+
>["details"];
|
|
10
|
+
|
|
11
|
+
export function unprocessable(
|
|
12
|
+
reason: string,
|
|
13
|
+
i18nKey: string,
|
|
14
|
+
details?: UnprocessableDetails,
|
|
15
|
+
): WriteFailure {
|
|
16
|
+
return writeFailure(
|
|
17
|
+
new UnprocessableError(reason, details === undefined ? { i18nKey } : { i18nKey, details }),
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -20,6 +20,7 @@ import { type FeatureWithEnvSchema, featureWithEnvSchema } from "@cosmicdrift/ku
|
|
|
20
20
|
import { egress } from "@cosmicdrift/kumiko-framework/http";
|
|
21
21
|
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
22
22
|
import * as z from "zod";
|
|
23
|
+
import { priceEnvSchema } from "../shared/index.ts";
|
|
23
24
|
import { makeCheckoutConfigQuery } from "./checkout-config.query.ts";
|
|
24
25
|
import {
|
|
25
26
|
createPaddleCancelSubscription,
|
|
@@ -78,9 +79,11 @@ export const subscriptionPaddleEnvSchema = z.object({
|
|
|
78
79
|
.optional(),
|
|
79
80
|
});
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const PADDLE_PRICE_ENV = {
|
|
83
|
+
envPrefix: "PADDLE",
|
|
84
|
+
label: "Paddle",
|
|
85
|
+
priceIdPrefix: "pri_",
|
|
86
|
+
} as const;
|
|
84
87
|
|
|
85
88
|
/** Paddle env block plus one `PADDLE_PRICE_<NAME>` slot per plan price the app
|
|
86
89
|
* maps to a tier, e.g. `paddleEnvSchema({ prices: ["PRO", "TEAM"] })`.
|
|
@@ -90,18 +93,7 @@ type PaddlePriceEnvShape<TPrice extends string> = {
|
|
|
90
93
|
export function paddleEnvSchema<const TPrice extends string>(options: {
|
|
91
94
|
readonly prices: readonly TPrice[];
|
|
92
95
|
}) {
|
|
93
|
-
|
|
94
|
-
options.prices.map((price) => [
|
|
95
|
-
`PADDLE_PRICE_${price}`,
|
|
96
|
-
z
|
|
97
|
-
.string()
|
|
98
|
-
.regex(/^pri_/, `PADDLE_PRICE_${price} must start with 'pri_'`)
|
|
99
|
-
.optional()
|
|
100
|
-
.describe(`Paddle price id (\`pri_...\`) of the ${price} plan.`),
|
|
101
|
-
]),
|
|
102
|
-
// @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
|
|
103
|
-
) as PaddlePriceEnvShape<TPrice>;
|
|
104
|
-
return z.object({ ...subscriptionPaddleEnvSchema.shape, ...priceShape });
|
|
96
|
+
return priceEnvSchema(subscriptionPaddleEnvSchema, PADDLE_PRICE_ENV, options.prices);
|
|
105
97
|
}
|
|
106
98
|
|
|
107
99
|
export type SubscriptionPaddleOptions = {
|
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
type HandlerContext,
|
|
18
18
|
SYSTEM_TENANT_ID,
|
|
19
19
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
20
|
-
import {
|
|
20
|
+
import { UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
|
|
21
21
|
import type { SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
|
|
22
|
+
import { assertBillingLive } from "../shared/index.ts";
|
|
22
23
|
import { createPaddleHttp, type PaddleRequest, type PaddleSend } from "./client.ts";
|
|
23
24
|
import {
|
|
24
25
|
PADDLE_BASE_URLS,
|
|
@@ -154,12 +155,8 @@ export function createPaddleRuntimes(deps: PaddleRuntimeDeps): PaddleRuntimes {
|
|
|
154
155
|
},
|
|
155
156
|
request,
|
|
156
157
|
),
|
|
157
|
-
assertBillingLive:
|
|
158
|
-
|
|
159
|
-
if (live !== true) {
|
|
160
|
-
throw new FeatureDisabledError(SUBSCRIPTION_PADDLE_FEATURE, handlerName);
|
|
161
|
-
}
|
|
162
|
-
},
|
|
158
|
+
assertBillingLive: (ctx, handlerName = "create-checkout-session") =>
|
|
159
|
+
assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_PADDLE_FEATURE, handlerName),
|
|
163
160
|
isBillingEnabled: async (ctx) => {
|
|
164
161
|
const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
|
|
165
162
|
if (live !== true) return false;
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
45
45
|
import { type FeatureWithEnvSchema, featureWithEnvSchema } from "@cosmicdrift/kumiko-framework/env";
|
|
46
46
|
import * as z from "zod";
|
|
47
|
+
import { priceEnvSchema } from "../shared/index.ts";
|
|
47
48
|
import {
|
|
48
49
|
STRIPE_API_KEY_CONFIG,
|
|
49
50
|
STRIPE_BILLING_LIVE_CONFIG,
|
|
@@ -92,9 +93,11 @@ export const subscriptionStripeEnvSchema = z.object({
|
|
|
92
93
|
.optional(),
|
|
93
94
|
});
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const STRIPE_PRICE_ENV = {
|
|
97
|
+
envPrefix: "STRIPE",
|
|
98
|
+
label: "Stripe",
|
|
99
|
+
priceIdPrefix: "price_",
|
|
100
|
+
} as const;
|
|
98
101
|
|
|
99
102
|
/** Stripe env block plus one `STRIPE_PRICE_<NAME>` slot per price the app
|
|
100
103
|
* maps to a tier, e.g. `stripeEnvSchema({ prices: ["PRO", "TEAM"] })`.
|
|
@@ -104,18 +107,7 @@ type StripePriceEnvShape<TPrice extends string> = {
|
|
|
104
107
|
export function stripeEnvSchema<const TPrice extends string>(options: {
|
|
105
108
|
readonly prices: readonly TPrice[];
|
|
106
109
|
}) {
|
|
107
|
-
|
|
108
|
-
options.prices.map((price) => [
|
|
109
|
-
`STRIPE_PRICE_${price}`,
|
|
110
|
-
z
|
|
111
|
-
.string()
|
|
112
|
-
.regex(/^price_/, `STRIPE_PRICE_${price} must start with 'price_'`)
|
|
113
|
-
.optional()
|
|
114
|
-
.describe(`Stripe price id (\`price_...\`) of the ${price} plan.`),
|
|
115
|
-
]),
|
|
116
|
-
// @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
|
|
117
|
-
) as StripePriceEnvShape<TPrice>;
|
|
118
|
-
return z.object({ ...subscriptionStripeEnvSchema.shape, ...priceShape });
|
|
110
|
+
return priceEnvSchema(subscriptionStripeEnvSchema, STRIPE_PRICE_ENV, options.prices);
|
|
119
111
|
}
|
|
120
112
|
|
|
121
113
|
export type SubscriptionStripeOptions = {
|
|
@@ -32,9 +32,10 @@ import {
|
|
|
32
32
|
type HandlerContext,
|
|
33
33
|
SYSTEM_TENANT_ID,
|
|
34
34
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
35
|
-
import {
|
|
35
|
+
import { UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
|
|
36
36
|
import type { SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
|
|
37
37
|
import Stripe from "stripe";
|
|
38
|
+
import { assertBillingLive } from "../shared/index.ts";
|
|
38
39
|
import { SUBSCRIPTION_STRIPE_FEATURE } from "./constants.ts";
|
|
39
40
|
|
|
40
41
|
const API_KEY_HINT =
|
|
@@ -137,12 +138,8 @@ export function createStripeRuntimes(deps: StripeRuntimeDeps): StripeRuntimes {
|
|
|
137
138
|
ctx: {
|
|
138
139
|
// @wrapper-known semantic-alias
|
|
139
140
|
clientForCtx: async (ctx) => clientFor(await ctxApiKey(ctx)),
|
|
140
|
-
assertBillingLive:
|
|
141
|
-
|
|
142
|
-
if (live !== true) {
|
|
143
|
-
throw new FeatureDisabledError(SUBSCRIPTION_STRIPE_FEATURE, handlerName);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
141
|
+
assertBillingLive: (ctx, handlerName = "create-checkout-session") =>
|
|
142
|
+
assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_STRIPE_FEATURE, handlerName),
|
|
146
143
|
isBillingEnabled: async (ctx) => {
|
|
147
144
|
const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
|
|
148
145
|
if (live !== true) return false;
|
|
@@ -55,6 +55,7 @@ export const tagEntity = createEntity({
|
|
|
55
55
|
// Cross-entity views compose in the read-layer (no JOIN):
|
|
56
56
|
// - tags of an entity → list assignments filter { field: "entityId", op: "eq" }
|
|
57
57
|
// - entities with a tag → list assignments filter { field: "tagId", op: "eq" }
|
|
58
|
+
// guard:dup-ok own table and fields; a shared definition would couple the schemas and migrations of tags and folders
|
|
58
59
|
export function createTagAssignmentEntity(
|
|
59
60
|
access?: EntityDefinition["access"],
|
|
60
61
|
parents?: readonly string[],
|
|
@@ -47,6 +47,20 @@ const BASE_STYLE: CSSProperties = {
|
|
|
47
47
|
|
|
48
48
|
const NEUTRAL = { backgroundColor: "#e5e7eb", color: "#374151" } as const;
|
|
49
49
|
|
|
50
|
+
export function TagChipById({
|
|
51
|
+
id,
|
|
52
|
+
byId,
|
|
53
|
+
}: {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly byId: ReadonlyMap<
|
|
56
|
+
string,
|
|
57
|
+
{ readonly name: string; readonly color?: string | null | undefined }
|
|
58
|
+
>;
|
|
59
|
+
}): ReactNode {
|
|
60
|
+
const tag = byId.get(id);
|
|
61
|
+
return <TagChip name={tag?.name ?? id} color={tag?.color} />;
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
export function TagChip({
|
|
51
65
|
name,
|
|
52
66
|
color,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "@cosmicdrift/kumiko-renderer";
|
|
21
21
|
import { type ReactNode, useState } from "react";
|
|
22
22
|
import { TagsQueries } from "./constants.ts";
|
|
23
|
-
import {
|
|
23
|
+
import { TagChipById } from "./tag-chip.tsx";
|
|
24
24
|
import { TagPicker } from "./tag-picker.tsx";
|
|
25
25
|
|
|
26
26
|
// Tags chosen but zero matching entities → filter to a value that matches no row
|
|
@@ -78,10 +78,9 @@ export function TagFilter({
|
|
|
78
78
|
<Button variant="secondary" onClick={() => setOpen(true)} testId="tag-filter-open">
|
|
79
79
|
{t("tags.filter.label")}
|
|
80
80
|
</Button>
|
|
81
|
-
{selected.map((id) =>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})}
|
|
81
|
+
{selected.map((id) => (
|
|
82
|
+
<TagChipById key={id} id={id} byId={byId} />
|
|
83
|
+
))}
|
|
85
84
|
{selected.length > 0 && (
|
|
86
85
|
<Button variant="secondary" onClick={() => applyFilter([])} testId="tag-filter-clear">
|
|
87
86
|
{t("tags.filter.clear")}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@cosmicdrift/kumiko-renderer";
|
|
18
18
|
import { pluralKey } from "@cosmicdrift/kumiko-renderer/headless";
|
|
19
19
|
import { type ReactNode, useState } from "react";
|
|
20
|
-
import { useDispatchedWrites } from "../../shared/web/
|
|
20
|
+
import { useDispatchedWrites } from "../../shared/web/index.ts";
|
|
21
21
|
import { TagsHandlers, TagsQueries } from "./constants.ts";
|
|
22
22
|
import { TagChip } from "./tag-chip.tsx";
|
|
23
23
|
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
import { usePrimitives, useQuery, useTranslation } from "@cosmicdrift/kumiko-renderer";
|
|
15
15
|
import { type ReactNode, useState } from "react";
|
|
16
|
-
import { useDispatchedWrites } from "../../shared/web/
|
|
16
|
+
import { useDispatchedWrites } from "../../shared/web/index.ts";
|
|
17
17
|
import { TagsHandlers, TagsQueries } from "./constants.ts";
|
|
18
|
-
import {
|
|
18
|
+
import { TagChipById } from "./tag-chip.tsx";
|
|
19
19
|
import { TagPicker } from "./tag-picker.tsx";
|
|
20
20
|
|
|
21
21
|
type TagRow = { readonly id: string; readonly name: string; readonly color?: string | null };
|
|
@@ -130,10 +130,7 @@ export function TagSection({
|
|
|
130
130
|
{assignedIds.length === 0 ? (
|
|
131
131
|
<Text variant="small">{t("tags.section.none")}</Text>
|
|
132
132
|
) : (
|
|
133
|
-
assignedIds.map((id) => {
|
|
134
|
-
const tag = byId.get(id);
|
|
135
|
-
return <TagChip key={id} name={tag?.name ?? id} color={tag?.color} />;
|
|
136
|
-
})
|
|
133
|
+
assignedIds.map((id) => <TagChipById key={id} id={id} byId={byId} />)
|
|
137
134
|
)}
|
|
138
135
|
<Button
|
|
139
136
|
variant="secondary"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { type ColumnRendererProps, useQuery } from "@cosmicdrift/kumiko-renderer";
|
|
18
18
|
import type { ReactNode } from "react";
|
|
19
19
|
import { TagsQueries } from "./constants.ts";
|
|
20
|
-
import {
|
|
20
|
+
import { TagChipById } from "./tag-chip.tsx";
|
|
21
21
|
|
|
22
22
|
type TagRow = { readonly id: string; readonly name: string; readonly color?: string | null };
|
|
23
23
|
type AssignmentRow = { readonly tagId: string; readonly entityId: string };
|
|
@@ -36,10 +36,9 @@ export function TagsCell({ row }: ColumnRendererProps): ReactNode {
|
|
|
36
36
|
if (tagIds.length === 0) return null;
|
|
37
37
|
return (
|
|
38
38
|
<div className="flex flex-wrap gap-1" data-testid="tags-cell">
|
|
39
|
-
{tagIds.map((id) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})}
|
|
39
|
+
{tagIds.map((id) => (
|
|
40
|
+
<TagChipById key={id} id={id} byId={byId} />
|
|
41
|
+
))}
|
|
43
42
|
</div>
|
|
44
43
|
);
|
|
45
44
|
}
|
|
@@ -259,28 +259,40 @@ function appendStyle(element: ScanElement, style: string): void {
|
|
|
259
259
|
element.setAttribute("style", existing === null ? style : `${existing};${style}`);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
function collectUniqueValidAttributes(
|
|
263
|
+
html: string,
|
|
264
|
+
selector: string,
|
|
265
|
+
attribute: string,
|
|
266
|
+
isValid: (value: string) => boolean,
|
|
267
|
+
): readonly string[] {
|
|
264
268
|
return withParsedDocument(html, (root) => {
|
|
265
|
-
const
|
|
266
|
-
for (const element of Array.from(root.querySelectorAll(
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
+
const values = new Set<string>();
|
|
270
|
+
for (const element of Array.from(root.querySelectorAll(selector))) {
|
|
271
|
+
const value = element.getAttribute(attribute) ?? "";
|
|
272
|
+
if (isValid(value)) values.add(value);
|
|
269
273
|
}
|
|
270
|
-
return [...
|
|
274
|
+
return [...values];
|
|
271
275
|
});
|
|
272
276
|
}
|
|
273
277
|
|
|
278
|
+
// Unique valid resource keys in document order.
|
|
279
|
+
export function collectDocumentResourceKeys(html: string): readonly string[] {
|
|
280
|
+
return collectUniqueValidAttributes(
|
|
281
|
+
html,
|
|
282
|
+
"img[data-resource]",
|
|
283
|
+
"data-resource",
|
|
284
|
+
isDocumentResourceKey,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
274
288
|
// Unique valid names of the images blocks in document order.
|
|
275
289
|
export function collectDocumentImageVariables(html: string): readonly string[] {
|
|
276
|
-
return
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return [...names];
|
|
283
|
-
});
|
|
290
|
+
return collectUniqueValidAttributes(
|
|
291
|
+
html,
|
|
292
|
+
"div[data-images]",
|
|
293
|
+
"data-images",
|
|
294
|
+
isDocumentReferenceName,
|
|
295
|
+
);
|
|
284
296
|
}
|
|
285
297
|
|
|
286
298
|
function rewriteImagesBlock(
|
|
@@ -44,14 +44,17 @@ export const byTenantQuery = defineQueryHandler({
|
|
|
44
44
|
const policy = deliveryPolicyOf(ctx.registry);
|
|
45
45
|
const served = await filterDeliveredTo(ctx.db, policy, query.user, rows);
|
|
46
46
|
return {
|
|
47
|
-
blocks: served.map(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
blocks: served.map(
|
|
48
|
+
// guard:dup-ok block field selection; only the object-literal shape matches other mappers
|
|
49
|
+
(row) => ({
|
|
50
|
+
slug: row.slug,
|
|
51
|
+
locale: row.locale,
|
|
52
|
+
title: row.title,
|
|
53
|
+
content: row.content,
|
|
54
|
+
folder: row.folder,
|
|
55
|
+
modifiedAt: row.modifiedAt,
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
55
58
|
};
|
|
56
59
|
},
|
|
57
60
|
});
|
|
@@ -65,6 +65,7 @@ export function makeDiscardDraftWrite(policy: TemplateEditPolicy) {
|
|
|
65
65
|
"Throws away the open draft of one template resource of the caller's tenant so the editor shows the active version again; the served version is untouched. Refused with no_draft when there is no draft. Outside the templates the app lists in tenantEditable only a SystemAdmin may use it.",
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
+
// guard:dup-ok one configured createDiscardDraftHandler instance; only name, scope and description differ
|
|
68
69
|
export function makeDiscardDraftSystemWrite(policy: TemplateEditPolicy) {
|
|
69
70
|
return createDiscardDraftHandler(
|
|
70
71
|
policy,
|
|
@@ -320,6 +320,7 @@ function withUsage(
|
|
|
320
320
|
let usedBy: OverviewUsage[] = [];
|
|
321
321
|
if (draft.kind === "mail" || draft.kind === "mail-layout") {
|
|
322
322
|
usedBy = collectTemplateUsage(registry, draft.slug, draft.kind, effectiveLayouts).map(
|
|
323
|
+
// guard:dup-ok usage field selection; only the object-literal shape matches other mappers
|
|
323
324
|
(entry) => ({
|
|
324
325
|
qualifiedName: entry.qualifiedName,
|
|
325
326
|
feature: entry.feature,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
+
import { unprocessable } from "../../shared/index.ts";
|
|
4
5
|
import {
|
|
5
6
|
refuseTemplateEdit,
|
|
6
7
|
type TemplateEditPolicy,
|
|
@@ -20,11 +21,10 @@ const TEST_MAIL_RATE_LIMIT = { limit: 10, windowSeconds: 3600 } as const;
|
|
|
20
21
|
|
|
21
22
|
// Transport errors can carry provider responses or the address, so the client only gets a fixed code.
|
|
22
23
|
function testMailFailed(code: "channel_error" | "not_sent") {
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}),
|
|
24
|
+
return unprocessable(
|
|
25
|
+
TemplateResolverErrors.testMailFailed,
|
|
26
|
+
"templateResolver.errors.testMail.failed",
|
|
27
|
+
{ code },
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|