@cosmicdrift/kumiko-framework 0.275.0 → 0.276.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-framework",
3
- "version": "0.275.0",
3
+ "version": "0.276.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>",
@@ -198,7 +198,7 @@
198
198
  "./package.json": "./package.json"
199
199
  },
200
200
  "dependencies": {
201
- "@cosmicdrift/kumiko-types": "0.275.0",
201
+ "@cosmicdrift/kumiko-types": "0.276.0",
202
202
  "bullmq": "^5.76.7",
203
203
  "bun-types": "^1.3.13",
204
204
  "hono": "^4.13.1",
@@ -214,7 +214,7 @@
214
214
  "zod": "^4.4.3"
215
215
  },
216
216
  "devDependencies": {
217
- "@cosmicdrift/kumiko-dispatcher-live": "0.275.0",
217
+ "@cosmicdrift/kumiko-dispatcher-live": "0.276.0",
218
218
  "bun-types": "^1.3.13",
219
219
  "pino-pretty": "^13.1.3"
220
220
  },
package/src/changes.json CHANGED
@@ -1,4 +1,11 @@
1
1
  [
2
+ {
3
+ "version": "0.276.0",
4
+ "type": "improvement",
5
+ "title": "entityEdit and actionForm screens accept `slots.titleAction`, rendered on the right of the form title.",
6
+ "detail": "`ScreenSlots.titleAction` mounts an `extensionSectionComponents` entry in the form title row (same props as `slots.header`: screenId, entityName, entityId, values). `FormProps.titleAction` carries it to the primitives; the web `DefaultForm` renders it right-aligned next to title and subtitle in `<testId>-title-action`, in both the card and the chromeless layout. Native primitives may ignore it.",
7
+ "migration": "No action required — purely additive."
8
+ },
2
9
  {
3
10
  "version": "0.275.0",
4
11
  "type": "breaking",
@@ -6,6 +13,13 @@
6
13
  "detail": "Job handlers no longer receive the unfiltered boot `DbConnection` as `ctx.db`. `JobContext.db` is now a `TenantDb` in \"tenant\" mode, bound to the job's resolved tenant (`_tenantId`, `payload.tenantId`, or `SYSTEM_TENANT_ID` for tenant-less cron jobs). Reads see that tenant plus `SYSTEM_TENANT_ID` reference rows, and writes are scoped to it. `JobDefinition` gains `escapeHatch?: { reason }`: it grants `ctx.db.unsafeRaw(reason)` for that job and reports an `\"unsafe-raw\"` escape-hatch audit event through `_escapeHatchAuditSink` (deduplicated like handler grants). Without it, `ctx.db.unsafeRaw` throws `AccessDeniedError`. `r.systemScope()` features keep `ctx.systemDb` unchanged. `r.job` throws at registration for an `escapeHatch` with an empty reason. Framework `soft-delete` cleanup jobs run on the tenant-filtered `TenantDb` without a grant. Bundled cross-tenant jobs now declare `escapeHatch`: auth-mfa reencrypt, sessions cleanup, form-draft cleanup, secrets rotate, files-tenant-data sweep-orphaned-derivatives, data-retention retention-cleanup, inbound-mail-retention, tenant-lifecycle run-tenant-destruction, and user-data-rights run-export-jobs/run-forget-cleanup. The systemScope features config, jobs and workflow-runner use `ctx.systemDb.unsafeRaw`. The exported `rotateJob` (secrets) and `sweepOrphanedDerivativesJob` (files-tenant-data) take the raw `DbConnection` as a third argument.",
7
14
  "migration": "Jobs that only read and write their own tenant through `ctx.db` method calls or `selectMany/fetchOne/insertOne/updateMany/deleteMany(ctx.db, ...)` need no change. A job that treated `ctx.db` as a `DbConnection` (casts, `asRawClient`, `countWhere`, `upsert*`, `incrementCounter`, `createTenantDb(ctx.db, ...)`, `runProjectionsForEvent(..., ctx.db)`, or `\"raw\" in db ? db.raw : db`) must declare the grant and fetch the runner explicitly. Use `r.job({ name, trigger, escapeHatch: { reason: \"<why>\" }, handler: async (payload, ctx) => work(ctx.db.unsafeRaw(\"<why>\")) })`; keep the `unsafeRaw` call inside the inline `handler` next to `escapeHatch` so `guard-escape-hatch-declared` recognizes the declaration. `r.systemScope()` features use `ctx.systemDb.unsafeRaw(reason)` instead. WARNING: a job that is not migrated but passes a foreign `where.tenantId` through `ctx.db` does not fail; the filter silently narrows it to the job's own tenant (`SYSTEM_TENANT_ID` for tenant-less cron jobs), so cross-tenant sweeps silently read nothing. Audit every cross-tenant job. Hand-built `JobContext` objects in tests need `db: createTenantDb(conn, tenantId)` (plus `systemDb` for systemScope jobs). Direct callers of `rotateJob`/`sweepOrphanedDerivativesJob` pass the raw connection as the third argument."
8
15
  },
16
+ {
17
+ "version": "0.274.0",
18
+ "type": "improvement",
19
+ "title": "A money field can declare `currency: { kind: \"tenant\" }` to source its currency from the tenant-settings config key.",
20
+ "detail": "`createMoneyField` accepts an optional `currency: MoneyCurrencySource` — a discriminated union (exported from `@cosmicdrift/kumiko-framework/engine/types`), currently only `{ kind: \"tenant\" }`, left room for #2839's later `literal`/`field` variants. The declaration reaches the client app schema (`buildAppSchema`'s field projection). In an entityEdit form (create and update), a rendered money field that declares `{ kind: \"tenant\" }` reads the tenant's currency via the existing `config:query:values` query (key `tenant-settings:config:currency`) instead of `entity.defaultCurrency ?? \"EUR\"`: an empty value's initial amount and currency come from the tenant's setting, and the form waits for that query rather than momentarily showing/submitting `EUR` while it is in flight. A field's already-stored value always keeps its own currency, unaffected by the declaration. A field without the declaration is unchanged.",
21
+ "migration": "No action required — purely additive; a money field without `currency` declared keeps today's `entity.defaultCurrency ?? \"EUR\"` behavior."
22
+ },
9
23
  {
10
24
  "version": "0.274.0",
11
25
  "type": "breaking",
@@ -622,6 +622,28 @@ describe("buildAppSchema", () => {
622
622
  expect("defaultCurrency" in app.features[0]!.entities["thing"]!).toBe(false);
623
623
  });
624
624
 
625
+ test("money field's `currency: { kind: 'tenant' }` declaration survives the projection (fw#2933)", () => {
626
+ const entity = {
627
+ defaultCurrency: "USD",
628
+ fields: {
629
+ price: { type: "money", currency: { kind: "tenant" } },
630
+ cost: { type: "money" },
631
+ },
632
+ } as unknown as EntityDefinition;
633
+
634
+ const f = defineFeature("ent", (r) => {
635
+ r.entity("thing", entity);
636
+ });
637
+ const app = buildAppSchema(createRegistry([f]));
638
+ const projected = app.features[0]!.entities["thing"] as unknown as {
639
+ fields: Record<string, Record<string, unknown>>;
640
+ };
641
+
642
+ expect(projected.fields["price"]?.["currency"]).toEqual({ kind: "tenant" });
643
+ expect(projected.fields["cost"]?.["currency"]).toBeUndefined();
644
+ expect(JSON.parse(JSON.stringify(projected))).toEqual(projected);
645
+ });
646
+
625
647
  test("text format, timestamp locatedBy, file accept/maxSize, image variants and decimal scale survive the projection", () => {
626
648
  // Regression: all of these are read by the edit view-model (password
627
649
  // masking, wall-clock input, upload constraints, preview variant, derived
@@ -497,6 +497,11 @@ function projectField(fieldDef: FieldDefinition): FieldDefinition {
497
497
  out["variants"] = def["variants"];
498
498
  // decimal, incl. embedded sub-fields: rounding of derived embedded-list cells.
499
499
  if (typeof def["scale"] === "number") out["scale"] = def["scale"];
500
+ // money: declared currency source (MoneyCurrencySource, fw#2933) — without
501
+ // it the renderer can't tell a "currency: { kind: 'tenant' }" field apart
502
+ // from an undeclared one and always falls back to entity.defaultCurrency.
503
+ if (isPlainObject(def["currency"]) && isJsonSafeValue(def["currency"]))
504
+ out["currency"] = def["currency"];
500
505
  // embedded lists: row-count bounds, computed cells, totals row, and the
501
506
  // sibling-money-field totals check (fw#2497).
502
507
  if (typeof def["minItems"] === "number") out["minItems"] = def["minItems"];
@@ -97,6 +97,15 @@ export type { ConcurrencyMode };
97
97
  const _concurrencyModeExhaustive: Record<ConcurrencyMode, unknown> = ConcurrencyModes;
98
98
  void _concurrencyModeExhaustive;
99
99
 
100
+ // --- Money Currency Sources ---
101
+ // Canonical definition lives in kumiko-types/fields (client-safe, next to
102
+ // MoneyCurrencySource) so renderer code can import it without pulling in
103
+ // runtime-only engine code (fw#2937). Re-exported here for server callers
104
+ // already importing framework/engine (bundled-features/src/tenant-settings/
105
+ // constants.ts TenantSettingsConfig.currency reuses this same constant, so
106
+ // the two stay in sync by construction).
107
+ export { TENANT_CURRENCY_CONFIG_KEY } from "@cosmicdrift/kumiko-types/fields";
108
+
100
109
  // --- SSE Channels ---
101
110
 
102
111
  export function tenantChannel(tenantId: TenantId): string {
@@ -44,6 +44,7 @@ export {
44
44
  OnDeleteStrategies,
45
45
  SystemHookNames,
46
46
  SystemHookPriorities,
47
+ TENANT_CURRENCY_CONFIG_KEY,
47
48
  tenantChannel,
48
49
  } from "./constants";
49
50
  export type { App, AppConfig } from "./create-app";
@@ -119,6 +119,7 @@ export type {
119
119
  LocatedTimestampFieldDef,
120
120
  LongTextFieldDef,
121
121
  LongTextFindability,
122
+ MoneyCurrencySource,
122
123
  MoneyFieldDef,
123
124
  MultiSelectFieldDef,
124
125
  NumberFieldDef,