@cosmicdrift/kumiko-framework 0.248.0 → 0.249.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.249.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.249.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.249.0",
|
|
218
218
|
"bun-types": "^1.3.13",
|
|
219
219
|
"pino-pretty": "^13.1.3"
|
|
220
220
|
},
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { evalFieldCondition } from "../screen-helpers";
|
|
3
|
+
import type { FieldCondition } from "../types/screen";
|
|
4
|
+
|
|
5
|
+
describe("evalFieldCondition()", () => {
|
|
6
|
+
test("boolean forms pass through unchanged", () => {
|
|
7
|
+
expect(evalFieldCondition(true, {})).toBe(true);
|
|
8
|
+
expect(evalFieldCondition(false, {})).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("eq matches when the field equals the given value", () => {
|
|
12
|
+
const cond: FieldCondition = { field: "status", eq: "active" };
|
|
13
|
+
expect(evalFieldCondition(cond, { status: "active" })).toBe(true);
|
|
14
|
+
expect(evalFieldCondition(cond, { status: "archived" })).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("ne matches when the field differs from the given value", () => {
|
|
18
|
+
const cond: FieldCondition = { field: "status", ne: "archived" };
|
|
19
|
+
expect(evalFieldCondition(cond, { status: "active" })).toBe(true);
|
|
20
|
+
expect(evalFieldCondition(cond, { status: "archived" })).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("in matches when the field is one of the given values", () => {
|
|
24
|
+
const cond: FieldCondition = { field: "status", in: ["draft", "active"] };
|
|
25
|
+
expect(evalFieldCondition(cond, { status: "active" })).toBe(true);
|
|
26
|
+
expect(evalFieldCondition(cond, { status: "archived" })).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("notIn matches when the field is none of the given values", () => {
|
|
30
|
+
const cond: FieldCondition = { field: "status", notIn: ["draft", "archived"] };
|
|
31
|
+
expect(evalFieldCondition(cond, { status: "active" })).toBe(true);
|
|
32
|
+
expect(evalFieldCondition(cond, { status: "draft" })).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("empty in is always false", () => {
|
|
36
|
+
const cond: FieldCondition = { field: "status", in: [] };
|
|
37
|
+
expect(evalFieldCondition(cond, { status: "active" })).toBe(false);
|
|
38
|
+
expect(evalFieldCondition(cond, {})).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("empty notIn is always true", () => {
|
|
42
|
+
const cond: FieldCondition = { field: "status", notIn: [] };
|
|
43
|
+
expect(evalFieldCondition(cond, { status: "active" })).toBe(true);
|
|
44
|
+
expect(evalFieldCondition(cond, {})).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("a missing field is undefined — in false, notIn true", () => {
|
|
48
|
+
const values: Record<string, unknown> = {};
|
|
49
|
+
expect(evalFieldCondition({ field: "status", in: ["active"] }, values)).toBe(false);
|
|
50
|
+
expect(evalFieldCondition({ field: "status", notIn: ["active"] }, values)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -21,9 +21,10 @@ function throwIfFunction(value: unknown, message: string): void {
|
|
|
21
21
|
// rowActions/toolbarActions carry row-context extractors (payload/params),
|
|
22
22
|
// static visibility conditions and navigate entityId — all declarative-DSL-
|
|
23
23
|
// only fields (RowFieldExtractor's `{ pick }`/`{ map }`, FieldCondition's
|
|
24
|
-
// `{ field, eq }`/`{ field, ne }
|
|
25
|
-
// does not type-check against these
|
|
26
|
-
// here via a leaked `any`/`as any`,
|
|
24
|
+
// `{ field, eq }`/`{ field, ne }`/`{ field, in }`/`{ field, notIn }`, plain
|
|
25
|
+
// strings). A function literal here does not type-check against these
|
|
26
|
+
// structural DSL types — it only reaches here via a leaked `any`/`as any`,
|
|
27
|
+
// which this runtime check backstops.
|
|
27
28
|
const ACTION_FUNCTION_FIELDS = ["payload", "params", "entityId", "visible"] as const;
|
|
28
29
|
|
|
29
30
|
function validateActionNoFunctions(
|
|
@@ -38,7 +39,7 @@ function validateActionNoFunctions(
|
|
|
38
39
|
record[field],
|
|
39
40
|
`[Feature ${featureName}] Screen "${screenId}" ${actionKind} "${action.id}" ${field} ` +
|
|
40
41
|
`is a function — ${FUNCTION_DROPPED_HINT} Use the declarative DSL ({ pick }, { map }, ` +
|
|
41
|
-
`"fieldName", { field, eq }) instead.`,
|
|
42
|
+
`"fieldName", { field, eq }/{ field, in }) instead.`,
|
|
42
43
|
);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -78,7 +79,7 @@ function validateEditFieldNoFunctions(
|
|
|
78
79
|
record[key],
|
|
79
80
|
`[Feature ${featureName}] Screen "${screenId}" (${screenType}) field "${normalized.field}" ` +
|
|
80
81
|
`${key} is a function — ${FUNCTION_DROPPED_HINT} Use a FieldCondition ` +
|
|
81
|
-
`(boolean or { field, eq }/{ field, ne }) instead.`,
|
|
82
|
+
`(boolean or { field, eq }/{ field, ne }/{ field, in }/{ field, notIn }) instead.`,
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
85
|
throwIfFunction(
|
|
@@ -56,6 +56,8 @@ export function evalFieldCondition(cond: FieldCondition, values: Record<string,
|
|
|
56
56
|
if (typeof cond === "boolean") return cond;
|
|
57
57
|
const val = values[cond.field];
|
|
58
58
|
if ("eq" in cond) return val === cond.eq;
|
|
59
|
+
if ("in" in cond) return cond.in.includes(val);
|
|
60
|
+
if ("notIn" in cond) return !cond.notIn.includes(val);
|
|
59
61
|
return val !== cond.ne;
|
|
60
62
|
}
|
|
61
63
|
|