@cosmicdrift/kumiko-framework 0.360.0 → 0.362.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 (85) hide show
  1. package/dist/api/server.js +14 -1
  2. package/dist/crypto/index.d.ts +1 -1
  3. package/dist/crypto/index.js +1 -1
  4. package/dist/crypto/owner-transition-rekey.d.ts +2 -0
  5. package/dist/crypto/owner-transition-rekey.js +30 -0
  6. package/dist/crypto/pii-field-encryption.d.ts +1 -0
  7. package/dist/crypto/pii-field-encryption.js +5 -0
  8. package/dist/crypto/subject-resolver.d.ts +2 -0
  9. package/dist/crypto/subject-resolver.js +14 -1
  10. package/dist/db/apply-entity-event.js +0 -5
  11. package/dist/db/eagerload.js +2 -2
  12. package/dist/db/entity-field-encryption.js +3 -2
  13. package/dist/db/entity-table-meta.js +3 -3
  14. package/dist/db/event-store-executor-context.d.ts +1 -0
  15. package/dist/db/event-store-executor-context.js +9 -2
  16. package/dist/db/event-store-executor-write.js +31 -5
  17. package/dist/db/event-store-executor.d.ts +2 -1
  18. package/dist/db/event-store-executor.js +1 -0
  19. package/dist/db/index.d.ts +3 -3
  20. package/dist/db/index.js +2 -2
  21. package/dist/db/migrate-generator.d.ts +1 -0
  22. package/dist/db/migrate-generator.js +12 -0
  23. package/dist/db/queries/backfill-pii.d.ts +2 -0
  24. package/dist/db/queries/backfill-pii.js +120 -15
  25. package/dist/db/table-builder.d.ts +3 -1
  26. package/dist/db/table-builder.js +3 -6
  27. package/dist/engine/boot-validator/access-declarations.js +29 -18
  28. package/dist/engine/boot-validator/card-meta-overflow.js +5 -2
  29. package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
  30. package/dist/engine/boot-validator/entity-handler.js +38 -1
  31. package/dist/engine/boot-validator/index.js +2 -1
  32. package/dist/engine/boot-validator/query-output-columns.js +3 -0
  33. package/dist/engine/boot-validator/screens.d.ts +1 -1
  34. package/dist/engine/boot-validator/screens.js +89 -14
  35. package/dist/engine/build-app-schema.js +1 -0
  36. package/dist/engine/define-handler.js +1 -3
  37. package/dist/engine/factories.d.ts +2 -0
  38. package/dist/engine/feature-ast/extractors/round3.d.ts +2 -2
  39. package/dist/engine/feature-ast/extractors/round3.js +4 -4
  40. package/dist/engine/index.d.ts +1 -1
  41. package/dist/engine/schema-builder.js +2 -2
  42. package/dist/engine/screen-helpers.d.ts +1 -0
  43. package/dist/engine/screen-helpers.js +9 -0
  44. package/dist/engine/soft-delete-cleanup.js +12 -1
  45. package/dist/engine/types/index.d.ts +1 -1
  46. package/dist/errors/classes.d.ts +7 -0
  47. package/dist/errors/classes.js +12 -0
  48. package/dist/errors/index.d.ts +1 -1
  49. package/dist/errors/index.js +1 -1
  50. package/dist/files/assert-file-refs-belong-to-tenant.d.ts +8 -0
  51. package/dist/files/assert-file-refs-belong-to-tenant.js +50 -0
  52. package/dist/files/bind-pending-file-refs.d.ts +1 -0
  53. package/dist/files/bind-pending-file-refs.js +13 -13
  54. package/dist/files/bind-referenced-files.write.d.ts +16 -0
  55. package/dist/files/bind-referenced-files.write.js +109 -0
  56. package/dist/files/dispose-removed-file-refs.d.ts +8 -0
  57. package/dist/files/dispose-removed-file-refs.js +51 -0
  58. package/dist/files/feature.d.ts +1 -0
  59. package/dist/files/feature.js +2 -0
  60. package/dist/files/file-ref-entity.d.ts +1 -1
  61. package/dist/files/file-ref-entity.js +1 -1
  62. package/dist/files/file-routes.d.ts +4 -1
  63. package/dist/files/file-routes.js +37 -6
  64. package/dist/files/purge-expired-file-ref-bytes.d.ts +14 -0
  65. package/dist/files/purge-expired-file-ref-bytes.js +34 -0
  66. package/dist/files/record-write-check.d.ts +22 -0
  67. package/dist/files/record-write-check.js +64 -0
  68. package/dist/files/types.d.ts +1 -0
  69. package/dist/files/types.js +3 -0
  70. package/dist/i18n/required-surface-keys.js +10 -0
  71. package/dist/migrations/pii-event-backfill.d.ts +1 -0
  72. package/dist/migrations/pii-event-backfill.js +16 -2
  73. package/dist/pipeline/cascade-handler.js +17 -2
  74. package/dist/pipeline/dispatch-write.js +6 -6
  75. package/dist/pipeline/write-origin.js +2 -2
  76. package/dist/schema-cli.js +12 -6
  77. package/dist/search/reindex-entity.js +3 -4
  78. package/dist/stack/test-stack.d.ts +3 -1
  79. package/dist/stack/test-stack.js +1 -0
  80. package/dist/ui-types/card-column-roles.d.ts +5 -0
  81. package/dist/ui-types/card-column-roles.js +22 -4
  82. package/dist/ui-types/index.d.ts +3 -3
  83. package/dist/ui-types/index.js +2 -2
  84. package/package.json +4 -4
  85. package/src/changes.json +134 -0
@@ -10,7 +10,7 @@
10
10
  import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
11
11
  import { join, resolve as resolvePath } from "node:path";
12
12
  import { configureBlindIndexKey, configurePiiSubjectKms, resolveKmsWiringAsync, } from "./crypto/index.js";
13
- import { assertValidMigrationName, baselineMigrations, createDbConnection, diffReplayAgainstSnapshot, fetchAppliedMigrations, findCommentedDropTables, generateMigration, isRetiredFrameworkTable, loadMigrationsFromDir, loadSnapshotJson, readMigrationSqlTexts, rebuildTablesFromDiff, replayMigrationsDir, runMigrationsFromDir, tableExists, writeRebuildMarker, writeSnapshotJson, } from "./db/index.js";
13
+ import { assertUniqueTableNames, assertValidMigrationName, baselineMigrations, createDbConnection, diffReplayAgainstSnapshot, fetchAppliedMigrations, findCommentedDropTables, generateMigration, isRetiredFrameworkTable, loadMigrationsFromDir, loadSnapshotJson, readMigrationSqlTexts, rebuildTablesFromDiff, replayMigrationsDir, runMigrationsFromDir, tableExists, writeRebuildMarker, writeSnapshotJson, } from "./db/index.js";
14
14
  import { validateBoot } from "./engine/boot-validator.js";
15
15
  import { createRegistry } from "./engine/registry.js";
16
16
  import { createEventsTable } from "./event-store/index.js";
@@ -29,10 +29,9 @@ async function loadSchemaModFromApp(schemaFile) {
29
29
  if (!Array.isArray(mod.ENTITY_METAS)) {
30
30
  throw new Error(`Schema file ${schemaFile} muss \`export const ENTITY_METAS: EntityTableMeta[]\` haben.`);
31
31
  }
32
- return {
33
- entityMetas: mod.ENTITY_METAS,
34
- features: mod.FEATURES,
35
- };
32
+ const entityMetas = mod.ENTITY_METAS;
33
+ assertUniqueTableNames(entityMetas);
34
+ return { entityMetas, features: mod.FEATURES };
36
35
  }
37
36
  function nextSequenceNumber(migrationsDir) {
38
37
  if (!existsSync(migrationsDir))
@@ -134,7 +133,14 @@ export async function runSchemaCli(argv, appCwd, out, options = {}) {
134
133
  out.err(" export const ENTITY_METAS: EntityTableMeta[] = [...]");
135
134
  return 1;
136
135
  }
137
- const { entityMetas: metas } = await loadSchemaModFromApp(schemaFile);
136
+ let metas;
137
+ try {
138
+ ({ entityMetas: metas } = await loadSchemaModFromApp(schemaFile));
139
+ }
140
+ catch (e) {
141
+ out.err(` ${e instanceof Error ? e.message : String(e)}`);
142
+ return 1;
143
+ }
138
144
  const snapshotPath = join(migrationsDir, SNAPSHOT_FILENAME);
139
145
  const prevSnapshot = existsSync(snapshotPath) ? loadSnapshotJson(snapshotPath) : null;
140
146
  const result = generateMigration({
@@ -13,10 +13,9 @@ function quoteIdent(name) {
13
13
  }
14
14
  // Read-table state, forward-mapped from entity.fields (fieldName →
15
15
  // toSnakeCase(fieldName)). SELECT * + forward-map instead of building an
16
- // explicit column list: some field types (files/images) emit no column at
17
- // all, others (locatedTimestamp, money) emit companion columns under a
18
- // different name — an explicit alias list breaks on those. Missing columns
19
- // are just skipped, matching what a `.created` event payload would carry.
16
+ // explicit column list: some field types (locatedTimestamp, money) emit
17
+ // companion columns under a different name — an explicit alias list breaks on
18
+ // those. Missing columns are just skipped, matching what a `.created` event payload would carry.
20
19
  function rowToState(row, fieldNames) {
21
20
  const state = {};
22
21
  for (const fieldName of fieldNames) {
@@ -7,7 +7,7 @@ import type { ErrorDocsConfig } from "../errors/docs-url.js";
7
7
  import { type JobRunner, type JobRunnerOptions } from "../jobs/index.js";
8
8
  import type { Lifecycle } from "../lifecycle/index.js";
9
9
  import { type ObservabilityProvider } from "../observability/index.js";
10
- import type { Dispatcher, EventDispatcher } from "../pipeline/index.js";
10
+ import type { Dispatcher, EventDispatcher, SystemHooks } from "../pipeline/index.js";
11
11
  import { type ClosableCacheSyncBus } from "../redis/cache-sync-bus.js";
12
12
  import type { SearchAdapter } from "../search/types.js";
13
13
  import { type EventCollector } from "./event-collector.js";
@@ -37,6 +37,8 @@ export type TestStackOptions = {
37
37
  features: readonly FeatureDefinition[];
38
38
  /** System hooks to wire up. Default: all (sse, search) */
39
39
  systemHooks?: ("sse" | "search")[];
40
+ /** Pipeline system hooks handed to buildServer, e.g. the cascade-delete preDelete hook. None by default. */
41
+ lifecycleSystemHooks?: SystemHooks;
40
42
  /** Search config per tenant — defaults to tenant 1 with all text fields */
41
43
  searchConfig?: {
42
44
  tenantId: TenantId;
@@ -287,6 +287,7 @@ export async function setupTestStack(options) {
287
287
  context: rateLimitFallback ? { ...appContext, rateLimit: rateLimitFallback } : appContext,
288
288
  jwtSecret,
289
289
  ...(options.observability ? { observability: options.observability } : {}),
290
+ ...(options.lifecycleSystemHooks && { systemHooks: options.lifecycleSystemHooks }),
290
291
  dispatcherOptions: {
291
292
  idempotency,
292
293
  cacheSync,
@@ -5,10 +5,15 @@ export type CardRoleColumn = {
5
5
  readonly type?: string;
6
6
  readonly renderer?: unknown;
7
7
  readonly hideOnNarrow?: boolean;
8
+ readonly fileDisplay?: {
9
+ readonly kind: string;
10
+ };
8
11
  };
9
12
  export type CardColumnRoles<C extends CardRoleColumn> = {
13
+ readonly image: C | undefined;
10
14
  readonly title: C | undefined;
11
15
  readonly status: C | undefined;
12
16
  readonly meta: readonly C[];
13
17
  };
18
+ export declare function cardFileDisplayKind(type: string | undefined, renderer: unknown): "image" | "file" | undefined;
14
19
  export declare function cardColumnRoles<C extends CardRoleColumn>(columns: readonly C[]): CardColumnRoles<C>;
@@ -1,9 +1,27 @@
1
1
  export const CARD_META_MAX = 3;
2
+ // An explicit `{ format: "image" | "file" }` renderer wins over the field type, the
3
+ // same precedence as the list view model's file display.
4
+ export function cardFileDisplayKind(type, renderer) {
5
+ if (typeof renderer === "object" && renderer !== null && "format" in renderer) {
6
+ if (renderer.format === "image")
7
+ return "image";
8
+ if (renderer.format === "file")
9
+ return "file";
10
+ }
11
+ if (type === "image" || type === "images")
12
+ return "image";
13
+ if (type === "file" || type === "files")
14
+ return "file";
15
+ return undefined;
16
+ }
2
17
  // One rule for the narrow-layout list card, shared by the renderer and the
3
18
  // boot validator so the validator counts exactly what the card would draw.
19
+ // The first image column is the card's leading preview, neither title nor meta.
4
20
  export function cardColumnRoles(columns) {
5
- const title = columns.find((col) => col.highlighted === true) ?? columns[0];
6
- const status = columns.find((col) => col !== title && col.type === "select" && col.renderer === undefined);
7
- const meta = columns.filter((col) => col !== title && col !== status && col.hideOnNarrow !== true);
8
- return { title, status, meta };
21
+ const image = columns.find((col) => col.fileDisplay?.kind === "image");
22
+ const textColumns = columns.filter((col) => col !== image);
23
+ const title = textColumns.find((col) => col.highlighted === true) ?? textColumns[0];
24
+ const status = textColumns.find((col) => col !== title && col.type === "select" && col.renderer === undefined);
25
+ const meta = textColumns.filter((col) => col !== title && col !== status && col.hideOnNarrow !== true);
26
+ return { image, title, status, meta };
9
27
  }
@@ -4,12 +4,12 @@ export { computeDerivedCellValue, roundDerivedCellValue } from "../engine/embedd
4
4
  export type { ParsedRefTarget } from "../engine/parse-ref-target.js";
5
5
  export { parseRefTarget } from "../engine/parse-ref-target.js";
6
6
  export type { FieldsOrGroupsSection, UnavailableSelectOption } from "../engine/screen-helpers.js";
7
- export { availableSelectOptions, evalFieldCondition, explicitListScreenId, findUnavailableSelectOptions, isExtensionEditSection, isFieldsEditSection, isFormatSpec, isWriteFormEditSection, normalizeEditField, normalizeListColumn, resolveNavParentScreen, sectionFieldSpecs, } from "../engine/screen-helpers.js";
7
+ export { availableSelectOptions, evalFieldCondition, explicitListScreenId, findUnavailableSelectOptions, isExtensionEditSection, isFieldsEditSection, isFormatSpec, isRecordLocked, isWriteFormEditSection, normalizeEditField, normalizeListColumn, resolveNavParentScreen, sectionFieldSpecs, } from "../engine/screen-helpers.js";
8
8
  export type { BooleanFieldDef, DateFieldDef, EmbeddedDerivedCellDef, EntityDefinition, FieldDefinition, FileFieldDef, FilesFieldDef, ImageFieldDef, ImagesFieldDef, NumberFieldDef, OptionsQueryPayload, OptionsQueryPayloadValue, SelectFieldDef, SelectOptionTone, TextFieldDef, } from "../engine/types/fields.js";
9
9
  export type { AccessRule, OpenToAllAccessRule, OpenToAllDeclaration, OpenToAllPersonalData, RoleAccessPersonalData, RoleAccessRule, } from "../engine/types/handlers.js";
10
10
  export { isOpenToAllGranted, isUiAccessGranted } from "../engine/types/handlers.js";
11
11
  export type { IconKey, NavDefinition, NavIconKey } from "../engine/types/nav.js";
12
- export type { ActionFormFooterAction, ActionFormRedirect, ActionFormScreenDefinition, ConfigEditScreenDefinition, CustomScreenDefinition, CustomScreenRoute, DashboardChartKind, DashboardChartMarkerKind, DashboardChartPanel, DashboardChartRangeOption, DashboardChartRanges, DashboardChartTone, DashboardCustomPanel, DashboardDateParam, DashboardFeedPanel, DashboardFilterDefinition, DashboardI18nText, DashboardListPanel, DashboardMoneyParam, DashboardPanelDefinition, DashboardPanelEmptyState, DashboardPanelGate, DashboardPanelQueryOptions, DashboardPanelSpan, DashboardPanelVisibility, DashboardProgressListPanel, DashboardScopeDefinition, DashboardScreenDefinition, DashboardScreenPanel, DashboardStatGroupPanel, DashboardStatPanel, DashboardText, DashboardTextParam, DashboardTimeRangeDefinition, DashboardValueFormat, EditExtensionSection, EditFieldSpec, EditFieldsSection, EditLayout, EditRelatedListSection, EditSectionSpec, EditWriteFormSection, EntityEditAction, EntityEditActionPlacement, EntityEditScreenDefinition, EntityListExpandableRow, EntityListFacetConfig, EntityListFacetExtraOption, EntityListScreenDefinition, EntityWriteExcludedFields, FieldCondition, FieldIconKey, FieldRenderer, FormWidth, ListBadgeTone, ListColumnDisplay, ListColumnSpec, ListFacetSpec, ListSortSpec, MetricNavigate, MetricSpec, PlatformComponent, ProjectionDetailScreenDefinition, ProjectionListScreenDefinition, RecordHeaderSubtitlePart, RelatedListGroupBy, RelatedListRowTone, RelatedListToolbarAction, RowAction, RowActionDisplay, RowActionDrawer, RowActionMode, RowActionNavigate, RowActionWriteHandler, RowFieldExtractor, ScreenDefinition, ScreenFilter, ScreenFilterOp, ScreenSlots, SecretMintConfirmStep, SecretMintScreenDefinition, SecretReveal, SecretRevealField, SecretsEditScreenDefinition, SecretsEditSection, ToolbarAction, } from "../engine/types/screen.js";
12
+ export type { ActionFormFooterAction, ActionFormRedirect, ActionFormScreenDefinition, ConfigEditScreenDefinition, CustomScreenDefinition, CustomScreenRoute, DashboardChartKind, DashboardChartMarkerKind, DashboardChartPanel, DashboardChartRangeOption, DashboardChartRanges, DashboardChartTone, DashboardCustomPanel, DashboardDateParam, DashboardFeedPanel, DashboardFilterDefinition, DashboardI18nText, DashboardListPanel, DashboardMoneyParam, DashboardPanelDefinition, DashboardPanelEmptyState, DashboardPanelGate, DashboardPanelQueryOptions, DashboardPanelSpan, DashboardPanelVisibility, DashboardProgressListPanel, DashboardScopeDefinition, DashboardScreenDefinition, DashboardScreenPanel, DashboardStatGroupPanel, DashboardStatPanel, DashboardText, DashboardTextParam, DashboardTimeRangeDefinition, DashboardValueFormat, EditExtensionSection, EditFieldPrefill, EditFieldSpec, EditFieldsSection, EditLayout, EditRelatedListSection, EditSectionSpec, EditWriteFormSection, EmbeddedListEditSpec, EntityEditAction, EntityEditActionPlacement, EntityEditScreenDefinition, EntityListExpandableRow, EntityListFacetConfig, EntityListFacetExtraOption, EntityListScreenDefinition, EntityWriteExcludedFields, FieldCondition, FieldIconKey, FieldRenderer, FormWidth, ListBadgeTone, ListColumnDisplay, ListColumnSpec, ListEmptyStateSpec, ListFacetSpec, ListSortSpec, MetricNavigate, MetricSpec, PlatformComponent, ProjectionDetailScreenDefinition, ProjectionListScreenDefinition, RecordHeaderSubtitlePart, RelatedListGroupBy, RelatedListRowTone, RelatedListToolbarAction, RowAction, RowActionDisplay, RowActionDrawer, RowActionMode, RowActionNavigate, RowActionWriteHandler, RowFieldExtractor, ScreenDefinition, ScreenFilter, ScreenFilterOp, ScreenSlots, SecretMintConfirmStep, SecretMintScreenDefinition, SecretReveal, SecretRevealField, SecretsEditScreenDefinition, SecretsEditSection, ToolbarAction, } from "../engine/types/screen.js";
13
13
  export { metricField, relatedListGroupHeaderLabel, relatedListGroupKey, } from "../engine/types/screen.js";
14
14
  export type { TargetRef } from "../engine/types/target-ref.js";
15
15
  export type { TreeAction, TreeNode, TreeNodeState } from "../engine/types/tree-node.js";
@@ -17,7 +17,7 @@ export type { WorkspaceDefinition } from "../engine/types/workspace.js";
17
17
  export { ACTION_FORM_ENTITY, handlerFieldLabelKey, handlerTitleKey, PROJECTION_DETAIL_ENTITY, WRITE_FORM_SECTION_ENTITY, } from "../i18n/required-surface-keys.js";
18
18
  export type { AppSchema, FeatureSchema, QualifiedContentCollection, WorkspaceSchema, } from "./app-schema.js";
19
19
  export type { CardColumnRoles, CardRoleColumn } from "./card-column-roles.js";
20
- export { CARD_META_MAX, cardColumnRoles } from "./card-column-roles.js";
20
+ export { CARD_META_MAX, cardColumnRoles, cardFileDisplayKind } from "./card-column-roles.js";
21
21
  export { type Formality, formalLocaleTag } from "./formality.js";
22
22
  export type { ListRowMetaColumnType, ListRowMetaReference, ReferenceLookupSource, SystemReferenceLabel, } from "./list-row-meta.js";
23
23
  export { LIST_ROW_META_COLUMNS, LIST_ROW_META_REFERENCES, REFERENCE_LOOKUP_SOURCES, SYSTEM_REFERENCE_LABELS, } from "./list-row-meta.js";
@@ -22,11 +22,11 @@
22
22
  export { NO_WIDGET_FIELD_TYPES } from "@cosmicdrift/kumiko-types/fields";
23
23
  export { computeDerivedCellValue, roundDerivedCellValue } from "../engine/embedded-derived.js";
24
24
  export { parseRefTarget } from "../engine/parse-ref-target.js";
25
- export { availableSelectOptions, evalFieldCondition, explicitListScreenId, findUnavailableSelectOptions, isExtensionEditSection, isFieldsEditSection, isFormatSpec, isWriteFormEditSection, normalizeEditField, normalizeListColumn, resolveNavParentScreen, sectionFieldSpecs, } from "../engine/screen-helpers.js";
25
+ export { availableSelectOptions, evalFieldCondition, explicitListScreenId, findUnavailableSelectOptions, isExtensionEditSection, isFieldsEditSection, isFormatSpec, isRecordLocked, isWriteFormEditSection, normalizeEditField, normalizeListColumn, resolveNavParentScreen, sectionFieldSpecs, } from "../engine/screen-helpers.js";
26
26
  export { isOpenToAllGranted, isUiAccessGranted } from "../engine/types/handlers.js";
27
27
  export { metricField, relatedListGroupHeaderLabel, relatedListGroupKey, } from "../engine/types/screen.js";
28
28
  export { ACTION_FORM_ENTITY, handlerFieldLabelKey, handlerTitleKey, PROJECTION_DETAIL_ENTITY, WRITE_FORM_SECTION_ENTITY, } from "../i18n/required-surface-keys.js";
29
- export { CARD_META_MAX, cardColumnRoles } from "./card-column-roles.js";
29
+ export { CARD_META_MAX, cardColumnRoles, cardFileDisplayKind } from "./card-column-roles.js";
30
30
  export { formalLocaleTag } from "./formality.js";
31
31
  export { LIST_ROW_META_COLUMNS, LIST_ROW_META_REFERENCES, REFERENCE_LOOKUP_SOURCES, SYSTEM_REFERENCE_LABELS, } from "./list-row-meta.js";
32
32
  export { resolveTranslationValue, translationValueOtherText, } from "./plural.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-framework",
3
- "version": "0.360.0",
3
+ "version": "0.362.0",
4
4
  "description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -210,8 +210,8 @@
210
210
  "./package.json": "./package.json"
211
211
  },
212
212
  "dependencies": {
213
- "@cosmicdrift/kumiko-http": "0.360.0",
214
- "@cosmicdrift/kumiko-types": "0.360.0",
213
+ "@cosmicdrift/kumiko-http": "0.362.0",
214
+ "@cosmicdrift/kumiko-types": "0.362.0",
215
215
  "bullmq": "^5.76.7",
216
216
  "bun-types": "^1.3.13",
217
217
  "hono": "^4.13.1",
@@ -227,7 +227,7 @@
227
227
  "zod": "^4.4.3"
228
228
  },
229
229
  "devDependencies": {
230
- "@cosmicdrift/kumiko-dispatcher-live": "0.360.0",
230
+ "@cosmicdrift/kumiko-dispatcher-live": "0.362.0",
231
231
  "bun-types": "^1.3.13",
232
232
  "pino-pretty": "^13.1.3"
233
233
  },
package/src/changes.json CHANGED
@@ -1,4 +1,138 @@
1
1
  [
2
+ {
3
+ "version": "0.362.0",
4
+ "type": "fix",
5
+ "title": "Client schema carries entity lockedWhen",
6
+ "detail": "buildAppSchema projects lockedWhen, so an entityEdit screen shows a locked record read-only without a screen-level readOnly."
7
+ },
8
+ {
9
+ "version": "0.362.0",
10
+ "type": "fix",
11
+ "title": "r.secret options with function values (redact) no longer fail to parse",
12
+ "detail": "r.secret(...) options that contain arrow or function expressions (for example redact: () => \"••••••••\") were reported as \"options could not be read as a plain object\", which turned the whole feature into a legacy corpus entry. The functions are now kept verbatim as raw references, option keys stay visible and a parse to render round-trip keeps them (multi-line function bodies may be re-indented). Function values in other patterns (entity, nav, metric, job) are still rejected on purpose.",
13
+ "migration": "Consumers that ship a checked-in few-shot corpus (Enterprise) should regenerate it on the next framework bump; its drift test enforces that."
14
+ },
15
+ {
16
+ "version": "0.362.0",
17
+ "type": "improvement",
18
+ "title": "Binding of referenced files only for the record creator's own uploads",
19
+ "detail": "files:write:bind-referenced-files now binds a file only if the record creator uploaded it (or the system generated it), so foreign references cannot expose private uploads."
20
+ },
21
+ {
22
+ "version": "0.362.0",
23
+ "type": "improvement",
24
+ "title": "files:write:bind-referenced-files binds a record's referenced files",
25
+ "detail": "System-only handler that binds the files a record references through its declared file fields (legacy uploads with entityId null, records created without a save lifecycle) so record readers can open them. Skips files bound elsewhere, of another tenant or missing. Callable from es-ops seeds via ctx.systemWriteAs; pages with limit and nextAfterId."
26
+ },
27
+ {
28
+ "version": "0.362.0",
29
+ "type": "breaking",
30
+ "title": "Optional number fields in entity forms start empty instead of 0",
31
+ "migration": "An optional number field without default no longer starts at 0 in entityEdit create/edit, and an untouched one is not sent. If a screen relied on the implicit 0, declare default: 0 on the field."
32
+ },
33
+ {
34
+ "version": "0.362.0",
35
+ "type": "improvement",
36
+ "title": "unclaimedUploadReaders option for createFilesFeature",
37
+ "detail": "Roles listed in unclaimedUploadReaders may read (not delete) uploads that have no entityType and entityId, for documents referenced without a file field."
38
+ },
39
+ {
40
+ "version": "0.362.0",
41
+ "type": "fix",
42
+ "title": "Query handlers may declare personalData public-intake",
43
+ "detail": "The personal-data write gate computed the public-intake exemption only for write handlers, so an anonymous query handler that wrote personal data (directly or through a nested write) was always rejected, and the boot validator refused access.personalData on query handlers. Query handlers now follow the same rules as write handlers: access.personalData \"public-intake\" requires the anonymous role and an active rateLimit (not disabled). openToAll.personalData stays write-only, stream handlers still cannot declare personalData.",
44
+ "migration": "No consumer change; anonymous query handlers that write personal data now declare access.personalData: \"public-intake\" instead of failing at the write gate."
45
+ },
46
+ {
47
+ "version": "0.361.0",
48
+ "type": "improvement",
49
+ "title": "Boot check for edit field prefill",
50
+ "detail": "validateBoot allows today only on date fields, currentUser displayName and email only on text fields and id on text or reference fields."
51
+ },
52
+ {
53
+ "version": "0.361.0",
54
+ "type": "improvement",
55
+ "title": "Boot check for the entityEdit readOnly condition",
56
+ "detail": "validateBoot rejects a screen readOnly condition whose field is not a field of the screen's entity."
57
+ },
58
+ {
59
+ "version": "0.361.0",
60
+ "type": "improvement",
61
+ "title": "Boot check for embeddedList on edit fields",
62
+ "detail": "validateBoot requires the field to be an embedded list and every readOnlyCells entry to be a sub-field."
63
+ },
64
+ {
65
+ "version": "0.361.0",
66
+ "type": "improvement",
67
+ "title": "Locked records reject executor writes",
68
+ "detail": "The event-store executor checks entity.lockedWhen against the loaded row in update and delete and fails with RecordLockedError (409, code record_locked, i18n key errors.recordLocked); a missing condition field counts as locked. Create, restore, forget, framework-system-user writes that name a writePurpose and the write that sets the lock pass. validateBoot rejects a lockedWhen field that is unknown, personal, encrypted or not a plain scalar type."
69
+ },
70
+ {
71
+ "version": "0.361.0",
72
+ "type": "breaking",
73
+ "title": "POST /files checks write access to the target record",
74
+ "detail": "createRecordWriteCheck loads the stored row tenant-scoped and applies update-handler access, entity access.write, field write access and lockedWhen before the upload is stored. Results map to 404, 403 and 409 record_locked. Uploads with an entityId and no check wired are refused.",
75
+ "migration": "Grant the uploader the entity's update right for records they attach files to, or upload without an entityId and bind the file on save. Entities without a generic :update handler no longer accept uploads with an entityId. Code that used entityId as a free slot without a stored record must create the record first."
76
+ },
77
+ {
78
+ "version": "0.361.0",
79
+ "type": "breaking",
80
+ "title": "Unbound uploads are private to the uploader (security)",
81
+ "detail": "The default file access guard denies every operation on a file with no entityType or no entityId unless the caller is the uploader or has a role in privilegedRoles; the file routes answer 404 as for any denied file. Before, files without entityType were readable by the whole tenant and pending uploads until a record claimed them. bindPendingFileRefs now also runs for updates and binds the file ids named in the update's changes for file, image, files and images fields (same entityType and fieldName, entityId null, insertedById = caller), so createFileRefFromBytes with attachTo but no entityId plus a following update write attaches the file to the record.",
82
+ "migration": "Code that shows a file without entityType to other users (tenant logo, avatar, mail attachment, import preview, AI-agent output) must upload it with entityType and fieldName of a file field on a record and save the record, so readers of that record can read it; or keep it uploader-only, run the read as a role in privilegedRoles, or set a custom accessGuard in the files feature options. Apps that set accessGuard keep their own decision. Code that reads another user's pending upload before the record is saved must bind the file first or run as the uploader. Known case: solon's document upload (`document/web/upload-file.ts`) posts without entityType and the later document record (created by the ingest job, not the uploader) stores the id in its `fileId` field, so other users no longer read the original; solon must upload with entityType and fieldName of `fileId` and bind the file when the record is created, because a different creator cannot claim the pending upload."
83
+ },
84
+ {
85
+ "version": "0.361.0",
86
+ "type": "fix",
87
+ "title": "Personal file/image fields are no longer encrypted",
88
+ "detail": "collectPiiSubjectFields still lists file, image, files and images fields with a personal annotation (forget and retention use it), but the new collectPiiEncryptedFields leaves them out and every encrypt, decrypt, backfill and store-gate path now uses it. The column holds only the fileRef uuid; the binary is erased by the file-ref user-data hook."
89
+ },
90
+ {
91
+ "version": "0.361.0",
92
+ "type": "fix",
93
+ "title": "Personal fields are re-keyed to the new owner on owner change",
94
+ "detail": "On absent to X and X to Y, the executor writes the personal fields (personal: { of: ownerField }) of the row under the new owner's key into the update event, so the projection, a rebuild and every event from the transition on agree and only the current owner's forget decides erasure. As a result <entity>.updated changes can contain personal fields the caller did not send. X to absent keeps the values under X so the last owner's forget still erases them. The created event from before an owner existed stays tenant-keyed in the immutable log. The new backfill option rekeyTenantKeyedOwnerFields moves such tenant-keyed values under the owner the projection or payload names (never via whenAbsent, a projection row of another tenant is ignored, other tenants' keys are not touched, a forgotten owner yields the erased sentinel). The boot PII backfill passes it, and its fingerprint now includes a transform version, so each deployment runs one full pass and afterwards only catch-up passes near the cursor. A created event whose owner transition happens after that full pass is not rescanned and stays tenant-keyed until someone runs backfillEventPiiEncryption(db, registry, { resolveOwnerFromProjection: true, rekeyTenantKeyedOwnerFields: true }) followed by a projection rebuild, or the transform version is bumped.",
95
+ "migration": "No consumer code change. The boot backfill runs in the background (startPiiEventBackfillOnBoot, it does not block readiness, KUMIKO_SKIP_PII_BACKFILL=1 turns it off). On the first boot after the bump it does one full scan of kumiko_events and rebuilds the affected projections. Consumers reading updated.changes must not treat a personal field there as a user edit when the owner field changed in the same event."
96
+ },
97
+ {
98
+ "version": "0.361.0",
99
+ "type": "breaking",
100
+ "title": "Plural file fields have a projection column",
101
+ "detail": "files and images fields get a jsonb NOT NULL DEFAULT '[]' column on the entity table (entity-table-meta, buildEntityTable row type readonly string[]) and applyEntityEvent no longer strips them from updated events. Detail and list queries return the ordered id arrays; before, they never carried the field, so an edit form of a saved record showed no files. kumiko schema generate emits an in-place ADD COLUMN for existing tables and no .rebuild.json, so existing rows hold [] until their projection is rebuilt from the events.",
102
+ "migration": "Run kumiko schema generate and apply the migration. Existing rows keep [] until the entity projection is rebuilt, so add a rebuild marker before applying: create <NNNN_migration-name>.rebuild.json next to the generated SQL with {\"version\":1,\"tables\":[\"<table name from the ALTER TABLE statement>\"]}; kumiko schema apply then rebuilds the projection. Without the marker, call enqueueProjectionRebuild(\"<feature>:projection:<entity>-entity\", { db, registry, jobRunner }) from @cosmicdrift/kumiko-framework/migrations once per entity. Known consumers: solon protocol (attachmentFileIds) and the Wartungs-Demo (photos). Code that read the ids of a plural file field from the event log or from file_refs can read the row field instead."
103
+ },
104
+ {
105
+ "version": "0.361.0",
106
+ "type": "improvement",
107
+ "title": "Files removed from a record are deleted",
108
+ "detail": "disposeRemovedFileRefs runs next to bindPendingFileRefs for every save that is not a create. For each file field named in changes it soft-deletes the fileRefs present in previous but not in the saved row, when entityType, entityId and fieldName match this record. The binary is removed by the soft-delete cleanup job after retention, or by forget."
109
+ },
110
+ {
111
+ "version": "0.361.0",
112
+ "type": "breaking",
113
+ "title": "Schema generate rejects a table listed twice in ENTITY_METAS",
114
+ "detail": "When ENTITY_METAS contained the same tableName twice, the migration diff kept only the last definition and compared it against the previous snapshot entry, so a new index was written to .snapshot.json but no CREATE INDEX reached the migration SQL. kumiko-schema generate, kumiko-schema validate and programmatic generateMigration now throw (generate and validate exit 1 with a message naming every duplicated table) before any file is written.",
115
+ "migration": "Remove hand-added metas for tables a feature already registers from kumiko/schema.ts. Known: phronexsis kumiko/schema.ts appends IN_APP_MESSAGES_META next to collectTableMetas(FEATURES); drop it (and its comment), then run kumiko-schema generate — the existing in_app_messages_tenant_user_created_idx comes out as CREATE INDEX IF NOT EXISTS (no-op) and the two legacy indexes as commented review drops. The duplicate in_app_messages entry in .snapshot.json disappears with that generate."
116
+ },
117
+ {
118
+ "version": "0.361.0",
119
+ "type": "fix",
120
+ "title": "Soft-delete cleanup removes the bytes of expired fileRefs",
121
+ "detail": "softDeleteCleanupJob handles the fileRef entity through purgeExpiredFileRefsWithBytes, which deletes the original and its derivatives via the file provider and then only the rows whose bytes are gone. Failures are logged and retried on the next run."
122
+ },
123
+ {
124
+ "version": "0.361.0",
125
+ "type": "improvement",
126
+ "title": "setupTestStack option lifecycleSystemHooks",
127
+ "detail": "Passes the given SystemHooks to buildServer, so tests can exercise pipeline lifecycle hooks like createCascadeDeleteHook through the real HTTP stack."
128
+ },
129
+ {
130
+ "version": "0.361.0",
131
+ "type": "breaking",
132
+ "title": "Writes with file ids from another tenant are rejected",
133
+ "detail": "A create or update that puts a file id into a file or image field now fails with a ValidationError (code invalid_element, path = field name) when the id is not a UUID, does not exist, or belongs to another tenant. That includes files stored under the SYSTEM tenant. On update only the changed fields are checked. The check runs for every write that returns a save result, inside the transaction, before pending file refs are bound. System users created for a tenant pass with that tenant's own files.",
134
+ "migration": "Check seeds, imports and handlers that copy file ids across tenants or reference files uploaded as SYSTEM. Upload the file in the target tenant (or copy it there) before writing its id. A custom handler that writes through an executor directly, without returning a save result, is not covered and needs its own check."
135
+ },
2
136
  {
3
137
  "version": "0.360.0",
4
138
  "type": "breaking",