@cosmicdrift/kumiko-framework 0.121.0 → 0.121.1

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.121.0",
3
+ "version": "0.121.1",
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>",
@@ -185,7 +185,7 @@
185
185
  "zod": "^4.4.3"
186
186
  },
187
187
  "devDependencies": {
188
- "@cosmicdrift/kumiko-dispatcher-live": "0.121.0",
188
+ "@cosmicdrift/kumiko-dispatcher-live": "0.121.1",
189
189
  "bun-types": "^1.3.13",
190
190
  "pino-pretty": "^13.1.3"
191
191
  },
@@ -111,6 +111,35 @@ describe("buildAppSchema", () => {
111
111
  expect(idField?.["type"]).toBe("text"); // type kommt durch
112
112
  });
113
113
 
114
+ test("Reference-Field: entity + labelField + multiple überleben die Projection", () => {
115
+ // Regression: ohne diese Properties im Client-Schema baut der ReferenceInput
116
+ // die Options-Query als `<feature>:query::list` (leeres refEntity) → 404 →
117
+ // Dropdown zeigt „Keine Treffer" obwohl die referenzierte Entity Rows hat.
118
+ const entity = {
119
+ fields: {
120
+ name: { type: "text" },
121
+ parentId: { type: "reference", entity: "component", labelField: "name" },
122
+ tags: { type: "reference", entity: "tag", labelField: "label", multiple: true },
123
+ },
124
+ } as unknown as EntityDefinition;
125
+
126
+ const f = defineFeature("ent", (r) => {
127
+ r.entity("thing", entity);
128
+ });
129
+ const app = buildAppSchema(createRegistry([f]));
130
+ const fields = (
131
+ app.features[0]?.entities["thing"] as unknown as {
132
+ fields: Record<string, Record<string, unknown>>;
133
+ }
134
+ ).fields;
135
+
136
+ expect(fields["parentId"]?.["type"]).toBe("reference");
137
+ expect(fields["parentId"]?.["entity"]).toBe("component");
138
+ expect(fields["parentId"]?.["labelField"]).toBe("name");
139
+ expect(fields["tags"]?.["entity"]).toBe("tag");
140
+ expect(fields["tags"]?.["multiple"]).toBe(true);
141
+ });
142
+
114
143
  test("JSON-Safety: literal Defaults bleiben erhalten", () => {
115
144
  const entity = {
116
145
  fields: {
@@ -343,6 +343,13 @@ function projectField(fieldDef: FieldDefinition): FieldDefinition {
343
343
  if (isLiteral(def["default"])) out["default"] = def["default"];
344
344
  // Select: options-Liste ist plain JSON, durchschicken.
345
345
  if (Array.isArray(def["options"])) out["options"] = def["options"];
346
+ // Reference: entity-Target + labelField + multiple müssen zum Renderer.
347
+ // Der ReferenceInput baut die Options-Query aus refEntity/refFeature und
348
+ // resolved das Label über labelField — ohne diese Properties fällt das
349
+ // Dropdown leer aus (QN wird `<feature>:query::list` → 404).
350
+ if (typeof def["entity"] === "string") out["entity"] = def["entity"];
351
+ if (typeof def["labelField"] === "string") out["labelField"] = def["labelField"];
352
+ if (typeof def["multiple"] === "boolean") out["multiple"] = def["multiple"];
346
353
  return out as FieldDefinition; // @cast-boundary schema-walk
347
354
  }
348
355