@cosmicdrift/kumiko-samples 0.374.0 → 0.377.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.
Files changed (199) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +6 -4
  3. package/packages/bundled-features/src/account-security/changes.json +6 -0
  4. package/packages/bundled-features/src/account-security/constants.ts +1 -0
  5. package/packages/bundled-features/src/account-security/index.ts +1 -0
  6. package/packages/bundled-features/src/admin-shell/web/client-plugin.tsx +1 -1
  7. package/packages/bundled-features/src/audit/web/client-plugin.tsx +1 -1
  8. package/packages/bundled-features/src/auth-email-password/mail-notifications.ts +1 -1
  9. package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +1 -1
  10. package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +1 -1
  11. package/packages/bundled-features/src/auth-email-password/web/client-plugin.ts +3 -3
  12. package/packages/bundled-features/src/auth-email-password/web/default-topbar-actions.tsx +1 -1
  13. package/packages/bundled-features/src/auth-email-password/web/index.ts +1 -1
  14. package/packages/bundled-features/src/auth-email-password/web/session.tsx +1 -1
  15. package/packages/bundled-features/src/auth-email-password/web/tenant-menu-items.tsx +1 -1
  16. package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
  17. package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
  18. package/packages/bundled-features/src/auth-foundation/changes.json +6 -0
  19. package/packages/bundled-features/src/auth-foundation/env.ts +27 -0
  20. package/packages/bundled-features/src/auth-foundation/index.ts +1 -0
  21. package/packages/bundled-features/src/billing-foundation/changes.json +6 -0
  22. package/packages/bundled-features/src/billing-foundation/consumer-protection/confirmation-mail.ts +1 -1
  23. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-pages.ts +1 -1
  24. package/packages/bundled-features/src/billing-foundation/contact-card.ts +14 -0
  25. package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +1 -1
  26. package/packages/bundled-features/src/billing-foundation/index.ts +1 -0
  27. package/packages/bundled-features/src/billing-foundation/plan-catalog.ts +1 -0
  28. package/packages/bundled-features/src/billing-foundation/types.ts +12 -0
  29. package/packages/bundled-features/src/billing-foundation/validate-options.ts +16 -0
  30. package/packages/bundled-features/src/billing-foundation/web/billing-contact-plan.tsx +32 -0
  31. package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +5 -15
  32. package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +2 -2
  33. package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
  34. package/packages/bundled-features/src/billing-foundation/web/client-plugin.tsx +1 -1
  35. package/packages/bundled-features/src/billing-foundation/web/localized-params.ts +14 -0
  36. package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +3 -3
  37. package/packages/bundled-features/src/cap-overview/web/client-plugin.tsx +1 -1
  38. package/packages/bundled-features/src/channel-email/changes.json +6 -0
  39. package/packages/bundled-features/src/channel-email/email-channel.ts +2 -1
  40. package/packages/bundled-features/src/compliance-profiles/web/client-plugin.tsx +1 -1
  41. package/packages/bundled-features/src/config/feature.ts +2 -2
  42. package/packages/bundled-features/src/crypto-shredding/changes.json +6 -0
  43. package/packages/bundled-features/src/custom-fields/web/client-plugin.tsx +1 -1
  44. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +1 -1
  45. package/packages/bundled-features/src/delivery/web/client-plugin.tsx +1 -1
  46. package/packages/bundled-features/src/delivery/web/delivery-status-cell.tsx +1 -1
  47. package/packages/bundled-features/src/feature-toggles/web/client-plugin.tsx +1 -1
  48. package/packages/bundled-features/src/file-provider-s3/changes.json +6 -0
  49. package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +45 -0
  50. package/packages/bundled-features/src/file-provider-s3/env-schema.ts +20 -13
  51. package/packages/bundled-features/src/file-provider-s3/index.ts +4 -0
  52. package/packages/bundled-features/src/folders/web/client-plugin.tsx +1 -1
  53. package/packages/bundled-features/src/folders/web/folder-section.tsx +3 -4
  54. package/packages/bundled-features/src/host-routing/README.md +7 -0
  55. package/packages/bundled-features/src/host-routing/changes.json +6 -0
  56. package/packages/bundled-features/src/host-routing/constants.ts +4 -0
  57. package/packages/bundled-features/src/host-routing/dispatch.ts +34 -26
  58. package/packages/bundled-features/src/host-routing/feature.ts +122 -41
  59. package/packages/bundled-features/src/host-routing/host.ts +28 -1
  60. package/packages/bundled-features/src/host-routing/index.ts +3 -0
  61. package/packages/bundled-features/src/host-routing/options.ts +45 -2
  62. package/packages/bundled-features/src/host-routing/redirects.ts +33 -0
  63. package/packages/bundled-features/src/host-routing/tenant-lookup.ts +65 -0
  64. package/packages/bundled-features/src/host-routing/validate-options.ts +48 -1
  65. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +7 -0
  66. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +8 -0
  67. package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +42 -0
  68. package/packages/bundled-features/src/inbound-mail-foundation/index.ts +4 -0
  69. package/packages/bundled-features/src/inbound-mail-foundation/screens.ts +100 -0
  70. package/packages/bundled-features/src/inbound-mail-foundation/types.ts +2 -2
  71. package/packages/bundled-features/src/jobs/web/client-plugin.tsx +1 -1
  72. package/packages/bundled-features/src/legal-pages/changes.json +6 -0
  73. package/packages/bundled-features/src/legal-pages/feature.ts +14 -1
  74. package/packages/bundled-features/src/legal-pages/layout.ts +6 -6
  75. package/packages/bundled-features/src/legal-pages/web/client-plugin.ts +1 -1
  76. package/packages/bundled-features/src/mail-foundation/feature.ts +21 -22
  77. package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +1 -1
  78. package/packages/bundled-features/src/notes-history/web/client-plugin.tsx +1 -1
  79. package/packages/bundled-features/src/page-render/branding.ts +1 -1
  80. package/packages/bundled-features/src/page-render/layout.ts +2 -2
  81. package/packages/bundled-features/src/page-render/markdown.ts +1 -1
  82. package/packages/bundled-features/src/personal-access-tokens/i18n.ts +1 -1
  83. package/packages/bundled-features/src/personal-access-tokens/screens.ts +1 -1
  84. package/packages/bundled-features/src/secrets/feature.ts +4 -4
  85. package/packages/bundled-features/src/seo/sitemap.ts +1 -1
  86. package/packages/bundled-features/src/shared/mail-template-body.ts +1 -1
  87. package/packages/bundled-features/src/shared/purge-files-reaching-subject.ts +127 -2
  88. package/packages/bundled-features/src/tags/web/client-plugin.tsx +1 -1
  89. package/packages/bundled-features/src/template-resolver/changes.json +18 -0
  90. package/packages/bundled-features/src/template-resolver/document-blocks.ts +34 -0
  91. package/packages/bundled-features/src/template-resolver/document-ops.ts +515 -0
  92. package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +9 -0
  93. package/packages/bundled-features/src/template-resolver/feature.ts +4 -0
  94. package/packages/bundled-features/src/template-resolver/handlers/bundle-import.ts +1 -0
  95. package/packages/bundled-features/src/template-resolver/handlers/document-base.ts +86 -0
  96. package/packages/bundled-features/src/template-resolver/handlers/document-blocks.query.ts +48 -0
  97. package/packages/bundled-features/src/template-resolver/handlers/export-bundle.query.ts +11 -3
  98. package/packages/bundled-features/src/template-resolver/handlers/patch-draft.write.ts +125 -0
  99. package/packages/bundled-features/src/template-resolver/handlers/preview.query.ts +2 -1
  100. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +2 -1
  101. package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +22 -1
  102. package/packages/bundled-features/src/template-resolver/handlers/validate.query.ts +24 -9
  103. package/packages/bundled-features/src/template-resolver/{web/placeholder-text.ts → placeholder-text.ts} +1 -1
  104. package/packages/bundled-features/src/template-resolver/qualified-names.ts +2 -0
  105. package/packages/bundled-features/src/template-resolver/seeding.ts +3 -1
  106. package/packages/bundled-features/src/template-resolver/template-bundle.ts +6 -1
  107. package/packages/bundled-features/src/template-resolver/template-preview.ts +24 -8
  108. package/packages/bundled-features/src/template-resolver/template-validation.ts +1 -1
  109. package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -3
  110. package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +1 -1
  111. package/packages/bundled-features/src/template-resolver/web/document-toolbar-blocks.ts +7 -33
  112. package/packages/bundled-features/src/template-resolver/web/i18n.ts +24 -0
  113. package/packages/bundled-features/src/template-resolver/web/placeholder-line-editor.tsx +2 -2
  114. package/packages/bundled-features/src/tenant/web/client-plugin.tsx +1 -1
  115. package/packages/bundled-features/src/tenant/web/member-status-cell.tsx +1 -1
  116. package/packages/bundled-features/src/tier-engine/web/client-plugin.tsx +1 -1
  117. package/packages/bundled-features/src/user-data-rights/changes.json +6 -0
  118. package/packages/bundled-features/src/user-data-rights/env.ts +15 -0
  119. package/packages/bundled-features/src/user-data-rights/feature.ts +4 -2
  120. package/packages/bundled-features/src/user-data-rights/index.ts +1 -0
  121. package/packages/bundled-features/src/user-data-rights/lib/mail-transport-resolver.ts +1 -1
  122. package/packages/bundled-features/src/user-data-rights/lib/storage-provider-resolver.ts +1 -1
  123. package/packages/bundled-features/src/user-data-rights/mail-notifications.ts +1 -1
  124. package/packages/bundled-features/src/user-data-rights/web/client-plugin.tsx +1 -1
  125. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +2 -2
  126. package/packages/bundled-features/src/waitlist/changes.json +6 -0
  127. package/packages/bundled-features/src/waitlist/legacy-migrate.ts +51 -2
  128. package/samples/apps/admin-console/package.json +0 -3
  129. package/samples/apps/admin-console/src/app/client.tsx +1 -1
  130. package/samples/apps/admin-console/src/app/shell.tsx +1 -1
  131. package/samples/apps/config-demo/package.json +1 -3
  132. package/samples/apps/config-demo/src/app/client.tsx +1 -1
  133. package/samples/apps/config-demo/src/app/shell.tsx +2 -2
  134. package/samples/apps/config-demo/src/features/demo/web/index.ts +1 -1
  135. package/samples/apps/config-demo/tsconfig.json +0 -12
  136. package/samples/apps/marketing-demo/package.json +1 -3
  137. package/samples/apps/marketing-demo/src/app/client.tsx +1 -1
  138. package/samples/apps/marketing-demo/src/app/shell.tsx +1 -1
  139. package/samples/apps/marketing-demo/src/features/assets/web/index.ts +1 -1
  140. package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +1 -1
  141. package/samples/apps/showcase/package.json +1 -3
  142. package/samples/apps/showcase/src/app/client.tsx +1 -1
  143. package/samples/apps/showcase/src/app/shell.tsx +1 -1
  144. package/samples/apps/showcase/src/features/demos/web/index.ts +1 -1
  145. package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +1 -1
  146. package/samples/apps/showcase/src/features/demos/web/pages/toast.tsx +1 -1
  147. package/samples/apps/showcase/src/features/items/web/index.ts +1 -1
  148. package/samples/apps/styleguide/package.json +1 -3
  149. package/samples/apps/styleguide/src/app/client.tsx +1 -1
  150. package/samples/apps/styleguide/src/app/shell.tsx +2 -2
  151. package/samples/apps/styleguide/src/features/ai-settings/web.ts +1 -1
  152. package/samples/apps/styleguide/src/features/content/web.tsx +2 -2
  153. package/samples/apps/styleguide/src/features/demo/web.ts +1 -1
  154. package/samples/apps/styleguide/src/features/examples/web.ts +1 -1
  155. package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -1
  156. package/samples/apps/styleguide/src/features/gallery/web/index.ts +1 -1
  157. package/samples/apps/styleguide/src/features/widgets/demo-locale.ts +1 -1
  158. package/samples/apps/styleguide/src/features/widgets/lib/format.ts +1 -1
  159. package/samples/apps/styleguide/src/features/widgets/web/DashboardFilterEcho.tsx +1 -1
  160. package/samples/apps/styleguide/src/features/widgets/web/FormExamples.tsx +1 -1
  161. package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +1 -1
  162. package/samples/apps/styleguide/src/features/widgets/web/index.ts +1 -1
  163. package/samples/apps/styleguide/tsconfig.json +0 -12
  164. package/samples/apps/ui-walkthrough/package.json +1 -3
  165. package/samples/apps/ui-walkthrough/src/app/client.tsx +1 -1
  166. package/samples/apps/ui-walkthrough/src/app/shell.tsx +1 -1
  167. package/samples/apps/ui-walkthrough/src/features/billing/web/index.ts +1 -1
  168. package/samples/apps/ui-walkthrough/src/features/rental/web/index.ts +1 -1
  169. package/samples/apps/ui-walkthrough/src/features/tasks/web/index.ts +1 -1
  170. package/samples/apps/ui-walkthrough/src/features/vehicles/web/index.ts +1 -1
  171. package/samples/apps/use-all-bundled/bin/main.ts +3 -2
  172. package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -0
  173. package/samples/apps/use-all-bundled/e2e-billing-gallery/server.ts +1 -1
  174. package/samples/apps/use-all-bundled/feature-manifest.json +1 -0
  175. package/samples/apps/use-all-bundled/package.json +1 -3
  176. package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
  177. package/samples/apps/use-all-bundled/src/app/dev-app-options.ts +5 -4
  178. package/samples/apps/use-all-bundled/src/app/shell.tsx +1 -1
  179. package/samples/apps/use-all-bundled/src/run-config.ts +10 -1
  180. package/samples/apps/workspaces/package.json +1 -3
  181. package/samples/apps/workspaces/src/app/client.tsx +1 -1
  182. package/samples/apps/workspaces/src/app/shell.tsx +1 -1
  183. package/samples/apps/workspaces/src/features/demo/web/index.ts +1 -1
  184. package/samples/apps/workspaces/src/features/demo-driver/web/index.ts +1 -1
  185. package/samples/recipes/apex-landing/package.json +1 -1
  186. package/samples/recipes/apex-landing/src/feature.ts +1 -1
  187. package/samples/recipes/apex-surface-auth/README.md +1 -1
  188. package/samples/recipes/apex-surface-auth/src/feature.ts +2 -2
  189. package/samples/recipes/compose-stacks/README.md +7 -4
  190. package/samples/recipes/embedded-entity-form/package.json +0 -1
  191. package/samples/recipes/embedded-entity-form/src/web/accept-suggestion-drawer.tsx +1 -1
  192. package/samples/recipes/notes-history-basic/README.md +1 -1
  193. package/samples/recipes/record-detail-layout/package.json +0 -1
  194. package/samples/recipes/tags-basic/README.md +1 -1
  195. package/samples/recipes/user-profile/README.md +1 -1
  196. package/samples/recipes/wizard-form/package.json +0 -1
  197. package/samples/recipes/wizard-form/src/web/index.ts +2 -2
  198. package/samples/recipes/wizard-form/src/web/listing-review-section.tsx +2 -2
  199. package/samples/recipes/writeform-section/package.json +0 -1
@@ -1,5 +1,5 @@
1
- import { escapeHtml, escapeHtmlAttr } from "@cosmicdrift/kumiko-headless";
2
- import { type ApexHead, renderApexHeadTags } from "@cosmicdrift/kumiko-headless/apex";
1
+ import { escapeHtml, escapeHtmlAttr } from "@cosmicdrift/kumiko-renderer/headless";
2
+ import { type ApexHead, renderApexHeadTags } from "@cosmicdrift/kumiko-renderer/headless/apex";
3
3
  import { type BrandingTokens, brandingHeaderHtml, brandingStyleBlock } from "./branding.ts";
4
4
  import { sanitizeTenantCss } from "./css-sanitize.ts";
5
5
 
@@ -1,4 +1,4 @@
1
- import { escapeHtml, isSafeHref } from "@cosmicdrift/kumiko-headless";
1
+ import { escapeHtml, isSafeHref } from "@cosmicdrift/kumiko-renderer/headless";
2
2
  import { Marked } from "marked";
3
3
 
4
4
  // Geteilter, gehärteter Markdown→HTML-Kern für server-gerenderte Public-
@@ -1,5 +1,5 @@
1
1
  import { ACTION_FORM_ENTITY } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import { fieldLabelKey, fieldOptionLabelKey } from "@cosmicdrift/kumiko-headless";
2
+ import { fieldLabelKey, fieldOptionLabelKey } from "@cosmicdrift/kumiko-renderer/headless";
3
3
  import { PAT_FEATURE } from "./constants.ts";
4
4
  import type { PatScopeConfig } from "./scopes.ts";
5
5
 
@@ -5,7 +5,7 @@ import {
5
5
  type SecretMintScreenDefinition,
6
6
  } from "@cosmicdrift/kumiko-framework/engine";
7
7
  import { ACTION_FORM_ENTITY } from "@cosmicdrift/kumiko-framework/ui-types";
8
- import { fieldOptionLabelKeyPrefix } from "@cosmicdrift/kumiko-headless";
8
+ import { fieldOptionLabelKeyPrefix } from "@cosmicdrift/kumiko-renderer/headless";
9
9
  import {
10
10
  PAT_FEATURE,
11
11
  PAT_MINT_SCREEN_ID,
@@ -79,11 +79,11 @@ export const JOIN_REQUEST_TRANSACTION_REASON =
79
79
  // FileProviderContext-Pfade (S3-Plugin im Worker) liefern dieselben
80
80
  // zwei Felder, also reicht die schmale ctx-shape — kein voller
81
81
  // HandlerContext-Import noetig.
82
- // Handler contexts carry the caller as ctx.user, provider contexts set _userId (takes precedence).
82
+ // Handler contexts carry the caller as ctx.user, provider contexts set auditUserId (takes precedence).
83
83
  export function requireSecretsContext(
84
84
  ctx: {
85
85
  readonly secrets?: SecretsContext;
86
- readonly _userId?: string | undefined;
86
+ readonly auditUserId?: string | undefined;
87
87
  readonly user?: { readonly id: string };
88
88
  },
89
89
  handlerName: string,
@@ -95,10 +95,10 @@ export function requireSecretsContext(
95
95
  "createSecretsContext({db, masterKeyProvider, registry}) via extraContext.secrets at boot.",
96
96
  });
97
97
  }
98
- const userId = ctx._userId ?? ctx.user?.id;
98
+ const userId = ctx.auditUserId ?? ctx.user?.id;
99
99
  if (!userId) {
100
100
  throw new InternalError({
101
- message: `[${handlerName}] ctx._userId missing (and no ctx.user) — cannot audit secret reads without a caller identity.`,
101
+ message: `[${handlerName}] ctx.auditUserId missing (and no ctx.user) — cannot audit secret reads without a caller identity.`,
102
102
  });
103
103
  }
104
104
  const withAudit = (raw: SecretsContext): SecretsContext => ({
@@ -1,4 +1,4 @@
1
- import { escapeXml } from "@cosmicdrift/kumiko-headless";
1
+ import { escapeXml } from "@cosmicdrift/kumiko-renderer/headless";
2
2
 
3
3
  export type SitemapEntry = {
4
4
  readonly loc: string;
@@ -1,4 +1,4 @@
1
- import { escapeHtml, escapeHtmlAttr } from "@cosmicdrift/kumiko-headless";
1
+ import { escapeHtml, escapeHtmlAttr } from "@cosmicdrift/kumiko-renderer/headless";
2
2
 
3
3
  const SLOT_PATTERN = /\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
4
4
 
@@ -16,9 +16,14 @@ import {
16
16
  type EntityDefinition,
17
17
  parseTenantId,
18
18
  type Registry,
19
+ SYSTEM_USER_ID,
19
20
  type TenantId,
20
21
  } from "@cosmicdrift/kumiko-framework/engine";
21
- import { fileRefEntity, fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
22
+ import {
23
+ FILE_REF_ENTITY_NAME,
24
+ fileRefEntity,
25
+ fileRefsTable,
26
+ } from "@cosmicdrift/kumiko-framework/files";
22
27
  import {
23
28
  collectSingleFileHolders,
24
29
  type FileRefPurgeOutcome,
@@ -155,7 +160,8 @@ export async function purgeFilesReachingSubject(args: {
155
160
  const storageByTenant = new Map<TenantId, Promise<DeleteFileBytes | undefined>>();
156
161
  let firstFailure: FileSweepError | undefined;
157
162
 
158
- for (const fileEntity of collectFileEntities(registry)) {
163
+ const fileEntities = collectFileEntities(registry);
164
+ for (const fileEntity of fileEntities) {
159
165
  const seenRowIds = new Set<string>();
160
166
  for (const where of candidateWheres(subject, recordTenantId, fileEntity)) {
161
167
  const rows = await selectMany<Record<string, unknown>>(db, fileEntity.table, where);
@@ -202,5 +208,124 @@ export async function purgeFilesReachingSubject(args: {
202
208
  }
203
209
  }
204
210
  }
211
+ // Runs even after an entity-sweep failure: one failed row must not leave the pending uploads.
212
+ const pendingFailure = await purgePendingUploadsOfUser({
213
+ db,
214
+ registry,
215
+ subject,
216
+ fileFieldKeys: pendingFieldKeys(fileEntities),
217
+ fileHolders,
218
+ storageByTenant,
219
+ resolveDeleteBytes,
220
+ missingStorage,
221
+ });
222
+ firstFailure ??= pendingFailure;
205
223
  if (firstFailure) throw firstFailure;
206
224
  }
225
+
226
+ const pendingFieldKey = (entityType: unknown, fieldName: unknown) =>
227
+ `${entityType}\u0000${fieldName}`;
228
+
229
+ function pendingFieldKeys(fileEntities: readonly FileEntity[]): ReadonlySet<string> {
230
+ const keys = new Set<string>();
231
+ for (const { entityName, fileFields } of fileEntities) {
232
+ for (const fieldName of fileFields) keys.add(pendingFieldKey(entityName, fieldName));
233
+ }
234
+ return keys;
235
+ }
236
+
237
+ async function isFileRefHeldByRecord(
238
+ db: DbRunner,
239
+ holders: readonly SingleFileHolder[],
240
+ tenantId: TenantId,
241
+ fileRefId: string,
242
+ ): Promise<boolean> {
243
+ for (const holder of holders) {
244
+ for (const field of holder.singleFields) {
245
+ const where: WhereObject = { [field]: fileRefId };
246
+ if (holder.tableHasTenantId) where["tenantId"] = tenantId;
247
+ if ((await selectMany(db, holder.table, where, { limit: 1 })).length > 0) return true;
248
+ }
249
+ }
250
+ return false;
251
+ }
252
+
253
+ // An upload the user made but never bound to a record has no entity row to find it through, so
254
+ // the uploader id is the only link. Only refs that originate from a registered entity file
255
+ // field count as pending uploads: config saves (a tenant logo) and server-made files never
256
+ // bind and must outlive the uploader. A legacy unbound ref a record's single file column still
257
+ // names is not pending but in use and stays with that record.
258
+ async function purgePendingUploadsOfUser(args: {
259
+ readonly db: DbRunner;
260
+ readonly registry: Registry;
261
+ readonly subject: SubjectId;
262
+ readonly fileFieldKeys: ReadonlySet<string>;
263
+ readonly fileHolders: readonly SingleFileHolder[];
264
+ readonly storageByTenant: Map<TenantId, Promise<DeleteFileBytes | undefined>>;
265
+ readonly resolveDeleteBytes: (tenantId: TenantId) => Promise<DeleteFileBytes | undefined>;
266
+ readonly missingStorage: MissingStoragePolicy;
267
+ }): Promise<FileSweepError | undefined> {
268
+ const { db, registry, subject, fileFieldKeys } = args;
269
+ // skip: only a user uploads files without binding them to a record
270
+ if (subject.kind !== "user") return undefined;
271
+ // skip: the system user is not a person; its server-made files are not pending uploads
272
+ if (subject.userId === SYSTEM_USER_ID) return undefined;
273
+ // skip: without the files feature there is no file_refs table to sweep
274
+ if (registry.getEntity(FILE_REF_ENTITY_NAME) === undefined) return undefined;
275
+ const pending = await selectMany<Record<string, unknown>>(db, fileRefsTable, {
276
+ insertedById: subject.userId,
277
+ entityId: null,
278
+ });
279
+ let firstFailure: FileSweepError | undefined;
280
+ for (const fileRef of pending) {
281
+ // skip: not uploaded for a registered entity file field (config, server-made, unknown origin)
282
+ if (!fileFieldKeys.has(pendingFieldKey(fileRef["entityType"], fileRef["fieldName"]))) continue;
283
+ firstFailure ??= await purgePendingFileRef(args, fileRef);
284
+ }
285
+ return firstFailure;
286
+ }
287
+
288
+ async function purgePendingFileRef(
289
+ args: {
290
+ readonly db: DbRunner;
291
+ readonly fileHolders: readonly SingleFileHolder[];
292
+ readonly storageByTenant: Map<TenantId, Promise<DeleteFileBytes | undefined>>;
293
+ readonly resolveDeleteBytes: (tenantId: TenantId) => Promise<DeleteFileBytes | undefined>;
294
+ readonly missingStorage: MissingStoragePolicy;
295
+ },
296
+ fileRef: Record<string, unknown>,
297
+ ): Promise<FileSweepError | undefined> {
298
+ const { db, fileHolders, storageByTenant, resolveDeleteBytes, missingStorage } = args;
299
+ const tenantId = parseTenantId(fileRef["tenantId"]);
300
+ const fileRefId = String(fileRef["id"]);
301
+ const storageKey = fileRef["storageKey"];
302
+ // skip: a ref without tenant or key has no bytes this sweep could address
303
+ if (tenantId === null || typeof storageKey !== "string" || storageKey === "") return undefined;
304
+ // skip: a record still uses this file
305
+ if (await isFileRefHeldByRecord(db, fileHolders, tenantId, fileRefId)) return undefined;
306
+
307
+ let storagePromise = storageByTenant.get(tenantId);
308
+ if (storagePromise === undefined) {
309
+ storagePromise = resolveDeleteBytes(tenantId);
310
+ storageByTenant.set(tenantId, storagePromise);
311
+ }
312
+ const deleteBytes = await storagePromise;
313
+ if (deleteBytes === undefined) {
314
+ if (missingStorage.mode === "skip") {
315
+ missingStorage.warn(tenantId);
316
+ return undefined;
317
+ }
318
+ return new FileSweepError("missing_file_storage", FILE_REF_ENTITY_NAME);
319
+ }
320
+ if ((await deleteBytesFailingClosed(deleteBytes, storageKey)).length > 0) {
321
+ return new FileSweepError("file_delete_failed", FILE_REF_ENTITY_NAME);
322
+ }
323
+ const forgotten = await fileRefExecutor.forget(
324
+ { id: fileRefId },
325
+ createSystemUser(tenantId),
326
+ createTenantDb({ db, tenantId, mode: "system" }),
327
+ );
328
+ return forgotten.isSuccess
329
+ ? undefined
330
+ : new FileSweepError("file_delete_failed", FILE_REF_ENTITY_NAME);
331
+ }
@@ -1,6 +1,6 @@
1
1
  // @runtime client
2
2
 
3
- import type { ClientFeatureDefinition } from "@cosmicdrift/kumiko-renderer-web";
3
+ import type { ClientFeatureDefinition } from "@cosmicdrift/kumiko-renderer/web";
4
4
  import {
5
5
  TAGS_COLUMN_RENDERER_NAME,
6
6
  TAGS_FEATURE_NAME,
@@ -1,4 +1,22 @@
1
1
  [
2
+ {
3
+ "version": "0.377.0",
4
+ "type": "improvement",
5
+ "title": "seedSystemTemplateBundle sets a title per template",
6
+ "detail": "Bundle locale entries accept an optional title, written to the template resource and exported again by the bundle export. SeedSystemTemplateOptions gets title. The template overview shows it instead of the slug."
7
+ },
8
+ {
9
+ "version": "0.375.0",
10
+ "type": "improvement",
11
+ "title": "Preview and test mail render with the values of a picked record",
12
+ "detail": "`template-resolver:query:preview` and `template-resolver:write:send-test` accept an optional `variables` object that replaces the declared example values for the named variables. The values are checked against the template's variable schema like a real send (unknown names and wrong types are rejected as `variables.<name>` validation errors); variables not passed keep their example. The mail editor now passes the values picked through the preview record picker into the preview and the test mail instead of only listing them."
13
+ },
14
+ {
15
+ "version": "0.375.0",
16
+ "type": "improvement",
17
+ "title": "Read a mail or PDF template as blocks and change it with structured operations",
18
+ "detail": "The query `template-resolver:query:document-blocks` returns a document template as blocks with stable ids (b0, b1, ...), its meta, variables, allowed block types and uploaded image keys, plus a `base` (scope and version). The write `template-resolver:write:patch-draft` applies up to 50 operations (insertBlock, replaceText, removeBlock, setResource, setMeta, setVariable) to that state and stores the result as the caller's tenant draft; an active version keeps being served until publish. Block ids refer to the state that was read. If the template changed since `base` was read, the call fails with `version_conflict` and writes nothing; a patch that removes a required placeholder or sets variables a notification declares is refused. `writeTemplateRow` accepts an optional `expectedVersion`. The universal helpers `placeholder-text` and the toolbar block sets moved out of `web/` without changing the web exports."
19
+ },
2
20
  {
3
21
  "version": "0.372.0",
4
22
  "type": "improvement",
@@ -0,0 +1,34 @@
1
+ // @runtime client
2
+ export type DocumentToolbarBlock =
3
+ | "image"
4
+ | "table"
5
+ | "button"
6
+ | "divider"
7
+ | "repeat"
8
+ | "pageBreak"
9
+ | "align"
10
+ | "steps";
11
+
12
+ export const MAIL_DOCUMENT_BLOCKS = [
13
+ "image",
14
+ "table",
15
+ "button",
16
+ "divider",
17
+ "repeat",
18
+ "steps",
19
+ ] as const satisfies readonly DocumentToolbarBlock[];
20
+
21
+ export const PDF_DOCUMENT_BLOCKS = [
22
+ "align",
23
+ "image",
24
+ "table",
25
+ "divider",
26
+ "repeat",
27
+ "steps",
28
+ "pageBreak",
29
+ ] as const satisfies readonly DocumentToolbarBlock[];
30
+
31
+ /** Block set for a template-resource kind; every kind except "document-pdf" gets the mail set. */
32
+ export function documentBlocksForKind(kind: string | undefined): readonly DocumentToolbarBlock[] {
33
+ return kind === "document-pdf" ? PDF_DOCUMENT_BLOCKS : MAIL_DOCUMENT_BLOCKS;
34
+ }