@cosmicdrift/kumiko-framework 0.247.0 → 0.248.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.
|
|
3
|
+
"version": "0.248.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.
|
|
201
|
+
"@cosmicdrift/kumiko-types": "0.248.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.
|
|
217
|
+
"@cosmicdrift/kumiko-dispatcher-live": "0.248.0",
|
|
218
218
|
"bun-types": "^1.3.13",
|
|
219
219
|
"pino-pretty": "^13.1.3"
|
|
220
220
|
},
|
|
@@ -359,6 +359,91 @@ describe("validateBoot — nav validation", () => {
|
|
|
359
359
|
});
|
|
360
360
|
});
|
|
361
361
|
|
|
362
|
+
// fw#2750: createAction + actions[] entries carry the same screen-XOR-target
|
|
363
|
+
// polymorphism as the node itself — the validator must reject the same
|
|
364
|
+
// classes of mistake for actions that it already rejects for nodes.
|
|
365
|
+
describe("validateBoot — nav action validation (fw#2750)", () => {
|
|
366
|
+
test("createAction with neither screen nor target fails boot", () => {
|
|
367
|
+
const feature = defineFeature("shop", (r) => {
|
|
368
|
+
r.nav({
|
|
369
|
+
id: "catalog",
|
|
370
|
+
label: "x",
|
|
371
|
+
createAction: { icon: "plus", label: "New" },
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
expect(() => validateBoot([feature])).toThrow(/createAction.*must set exactly one/);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
test("createAction with both screen and target fails boot", () => {
|
|
378
|
+
const feature = defineFeature("shop", (r) => {
|
|
379
|
+
r.entity("product", productEntity());
|
|
380
|
+
r.screen({
|
|
381
|
+
id: "products",
|
|
382
|
+
type: "entityList",
|
|
383
|
+
entity: "product",
|
|
384
|
+
columns: ["name"],
|
|
385
|
+
});
|
|
386
|
+
r.nav({
|
|
387
|
+
id: "catalog",
|
|
388
|
+
label: "x",
|
|
389
|
+
createAction: {
|
|
390
|
+
icon: "plus",
|
|
391
|
+
label: "New",
|
|
392
|
+
screen: "shop:screen:products",
|
|
393
|
+
target: { featureId: "shop", action: "create" },
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
expect(() => validateBoot([feature])).toThrow(/createAction.*must set exactly one/);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test("actions[] entry referencing an unregistered screen fails boot", () => {
|
|
401
|
+
const feature = defineFeature("shop", (r) => {
|
|
402
|
+
r.nav({
|
|
403
|
+
id: "catalog",
|
|
404
|
+
label: "x",
|
|
405
|
+
actions: [{ icon: "edit", label: "Edit", screen: "shop:screen:does-not-exist" }],
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
expect(() => validateBoot([feature])).toThrow(
|
|
409
|
+
/actions\[0\] references screen "shop:screen:does-not-exist"/,
|
|
410
|
+
);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test("createAction with a target-only action still passes boot (regression)", () => {
|
|
414
|
+
const feature = defineFeature("shop", (r) => {
|
|
415
|
+
r.nav({
|
|
416
|
+
id: "catalog",
|
|
417
|
+
label: "x",
|
|
418
|
+
createAction: {
|
|
419
|
+
icon: "plus",
|
|
420
|
+
label: "New",
|
|
421
|
+
target: { featureId: "shop", action: "create" },
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
expect(() => validateBoot([feature])).not.toThrow();
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test("createAction with a screen-only action referencing a registered screen passes boot", () => {
|
|
429
|
+
const feature = defineFeature("shop", (r) => {
|
|
430
|
+
r.entity("product", productEntity());
|
|
431
|
+
r.screen({
|
|
432
|
+
id: "products",
|
|
433
|
+
type: "entityList",
|
|
434
|
+
entity: "product",
|
|
435
|
+
columns: ["name"],
|
|
436
|
+
});
|
|
437
|
+
r.nav({
|
|
438
|
+
id: "catalog",
|
|
439
|
+
label: "x",
|
|
440
|
+
createAction: { icon: "plus", label: "New", screen: "shop:screen:products" },
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
expect(() => validateBoot([feature])).not.toThrow();
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
|
|
362
447
|
describe("nav access inversion warning (fw#2640)", () => {
|
|
363
448
|
test("leaf role-gate disjoint from its parent section's → warns but boot still succeeds", () => {
|
|
364
449
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
@@ -63,6 +63,42 @@ export function validateNavs(
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
if (navDef.createAction !== undefined) {
|
|
67
|
+
validateTreeAction(feature.name, navId, "createAction", navDef.createAction, allScreenQns);
|
|
68
|
+
}
|
|
69
|
+
for (const [i, action] of (navDef.actions ?? []).entries()) {
|
|
70
|
+
validateTreeAction(feature.name, navId, `actions[${i}]`, action, allScreenQns);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// A TreeAction (createAction or an actions[] entry) navigates via `screen`
|
|
76
|
+
// XOR dispatches via `target` — same polymorphism as the node's own
|
|
77
|
+
// `screen`/`target`. Without this check an action with neither is a
|
|
78
|
+
// Hover-Icon that does nothing; one with both is ambiguous about which
|
|
79
|
+
// click-mode wins.
|
|
80
|
+
function validateTreeAction(
|
|
81
|
+
featureName: string,
|
|
82
|
+
navId: string,
|
|
83
|
+
actionPath: string,
|
|
84
|
+
action: { readonly screen?: string; readonly target?: unknown },
|
|
85
|
+
allScreenQns: ReadonlySet<string>,
|
|
86
|
+
): void {
|
|
87
|
+
const { screen, target } = action;
|
|
88
|
+
const hasScreen = screen !== undefined;
|
|
89
|
+
const hasTarget = target !== undefined;
|
|
90
|
+
if (hasScreen === hasTarget) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`[Feature ${featureName}] Nav entry "${navId}" ${actionPath} must set exactly one of ` +
|
|
93
|
+
`"screen"/"target" (${hasScreen ? "both are set" : "neither is set"}).`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (screen !== undefined && !allScreenQns.has(screen)) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`[Feature ${featureName}] Nav entry "${navId}" ${actionPath} references screen ` +
|
|
99
|
+
`"${screen}" which is not registered. Expected a qualified name of the form ` +
|
|
100
|
+
`"<feature>:screen:<id>" pointing at an r.screen() declaration.`,
|
|
101
|
+
);
|
|
66
102
|
}
|
|
67
103
|
}
|
|
68
104
|
|