@cosmicdrift/kumiko-headless 0.15.0 → 0.16.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-headless",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Headless UI logic for Kumiko — Dispatcher contract, Form-Controller, View-Model, Nav-Resolver. Plattform- und React-frei; jeder Renderer (renderer, renderer-web, renderer-native, …) komponiert darauf.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -29,17 +29,13 @@
29
29
  // ---------------------------------------------------------------------------
30
30
 
31
31
  // A validation failure issue pinned to a specific payload field. Paths follow
32
- // the same dotted convention the server uses (see kumiko errors/classes.ts),
32
+ // the same dotted convention the server uses (see kumiko errors/field-issue.ts),
33
33
  // so form-controllers can map `tasks.2.title` back to the right sub-line's
34
34
  // input without any translation.
35
+ import type { FieldIssue } from "@cosmicdrift/kumiko-framework/errors";
35
36
  import type { Store } from "../store";
36
37
 
37
- export type FieldIssue = {
38
- readonly path: string;
39
- readonly code: string;
40
- readonly i18nKey: string;
41
- readonly params?: Readonly<Record<string, unknown>>;
42
- };
38
+ export type { FieldIssue };
43
39
 
44
40
  // Everything the UI needs to show or retry a failed call. `code` + `httpStatus`
45
41
  // are the structured hooks (Toast picks icon/colour, Form-Controller filters
@@ -0,0 +1,32 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { buildOptionLabels, fieldLabelKey, fieldOptionLabelKey } from "../list";
3
+
4
+ describe("fieldLabelKey", () => {
5
+ test("follows feature:entity:field convention", () => {
6
+ expect(fieldLabelKey("billing", "invoice", "amount")).toBe(
7
+ "billing:entity:invoice:field:amount",
8
+ );
9
+ });
10
+ });
11
+
12
+ describe("fieldOptionLabelKey", () => {
13
+ test("appends option value segment", () => {
14
+ expect(fieldOptionLabelKey("billing", "invoice", "status", "paid")).toBe(
15
+ "billing:entity:invoice:field:status:option:paid",
16
+ );
17
+ });
18
+ });
19
+
20
+ describe("buildOptionLabels", () => {
21
+ test("maps option values to translated labels with fallback to raw value", () => {
22
+ const labels = buildOptionLabels(
23
+ (key) => (key.endsWith(":option:draft") ? "Draft" : key),
24
+ "tasks",
25
+ "task",
26
+ "status",
27
+ ["draft", "done"],
28
+ );
29
+ expect(labels["draft"]).toBe("Draft");
30
+ expect(labels["done"]).toBe("done");
31
+ });
32
+ });