@cosmicdrift/kumiko-framework 0.421.0 → 0.422.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.
|
@@ -77,7 +77,7 @@ type ActionFormPreview = { // Preview panel above the submit button: runs a quer
|
|
|
77
77
|
};
|
|
78
78
|
type ActionFormPreviewList = { // Rows of the preview panel, read from an array in the preview query's result.
|
|
79
79
|
field: string; // Flat field name of an array in the query result; an entry that is no object is skipped.
|
|
80
|
-
columns: { field: string; label: string; type?: ActionFormValueType; }[];
|
|
80
|
+
columns: { field: string; label: string; type?: ActionFormValueType | "file"; }[];
|
|
81
81
|
};
|
|
82
82
|
type ActionFormRedirect = { // Redirect target plus the success-payload field carrying the navigation id.
|
|
83
83
|
screen: string; // Same target forms as the string `redirect`: short screen ID (same-feature) or a fully-qualified cross-feature screen QN.
|
|
@@ -1337,7 +1337,7 @@ type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
|
|
|
1337
1337
|
schema?: z.ZodType;
|
|
1338
1338
|
onSubmit?: (result: SubmitResult<unknown>, values: TValues) => void; // `values` are the form values at the moment the submit succeeded.
|
|
1339
1339
|
payloadMode?: "values" | "changes";
|
|
1340
|
-
buildPayload?: (snapshot: FormSnapshot<TValues
|
|
1340
|
+
buildPayload?: (snapshot: FormSnapshot<TValues>, shapedValues: unknown) => unknown;
|
|
1341
1341
|
serverFieldPathPrefix?: string; // Prefix to strip from server validation issue paths before mapping them onto form fields — see SubmitConfig.serverFieldPathPrefix.
|
|
1342
1342
|
onDelete?: () => Promise<DispatcherError | void> | DispatcherError | void; // Returning the rejected write's error shows it in the form-error banner; returning nothing means the delete went through.
|
|
1343
1343
|
onCancel?: () => void;
|
package/agents/api/types.md
CHANGED
|
@@ -2171,7 +2171,7 @@ type SubmitConfig<TValues extends FormValues = FormValues> = {
|
|
|
2171
2171
|
payloadMode?: SubmitPayloadMode;
|
|
2172
2172
|
stripEmptySeeds?: boolean; // Only applies to payloadMode "values".
|
|
2173
2173
|
omitFields?: string[]; // Top-level payload keys removed right before dispatch, for fields that are shown or validated but must not reach the write handler.
|
|
2174
|
-
buildPayload?: (snapshot: FormSnapshot<TValues
|
|
2174
|
+
buildPayload?: (snapshot: FormSnapshot<TValues>, shapedValues: unknown) => unknown;
|
|
2175
2175
|
serverFieldPathPrefix?: string;
|
|
2176
2176
|
validateScope?: string[]; // Restricts submit()'s internal validate() call to these field names — same contract as validate()'s `scope` param.
|
|
2177
2177
|
};
|
|
@@ -35,7 +35,15 @@ the `table` block renders and behaves as before.
|
|
|
35
35
|
updates every id in one write, bounded by `.max(MAX_BULK_SELECTION)` and
|
|
36
36
|
reading each id through the tenant-scoped executor. The form has a `preview`:
|
|
37
37
|
the `task:set-status-preview` query returns the affected tasks with old and
|
|
38
|
-
new status from the same plan function the handler applies.
|
|
38
|
+
new status from the same plan function the handler applies. A preview list
|
|
39
|
+
column with `type: "file"` shows a FileRef id as file name and download link.
|
|
40
|
+
- `submitThrough`: a screen can open the form with
|
|
41
|
+
`useNavigateWithInitialValues(screen, values, { submitThrough: { handler:
|
|
42
|
+
"task-board:write:task:set-status-via", wrap: { via: "inbox" }, valuesKey:
|
|
43
|
+
"values" } })`. The submit then goes to `task:set-status-via` as
|
|
44
|
+
`{ via, values }`; that handler calls `task:set-status` through
|
|
45
|
+
`ctx.dispatch.write` and returns its data unchanged plus `via`, because the
|
|
46
|
+
form reads its redirect and success facts from the response.
|
|
39
47
|
- `table.grouping`: the server groups the list by status; each header shows the
|
|
40
48
|
group's count and estimate sum, "done" starts collapsed and the view menu
|
|
41
49
|
offers grouping by priority or none.
|
|
@@ -359,6 +367,33 @@ describe("form bulk action handler", () => {
|
|
|
359
367
|
]);
|
|
360
368
|
});
|
|
361
369
|
|
|
370
|
+
test("the submitThrough wrapper applies the inner write and passes its data through", async () => {
|
|
371
|
+
const created = await Promise.all(
|
|
372
|
+
["Via A", "Via B"].map((title) =>
|
|
373
|
+
stack.http.writeOk<{ data: { id: string } }>(
|
|
374
|
+
"task-board:write:task:create",
|
|
375
|
+
{ title },
|
|
376
|
+
user,
|
|
377
|
+
),
|
|
378
|
+
),
|
|
379
|
+
);
|
|
380
|
+
const taskIds = created.map((task) => task.data.id);
|
|
381
|
+
const result = await stack.http.writeOk<{ count: number; via: string }>(
|
|
382
|
+
"task-board:write:task:set-status-via",
|
|
383
|
+
{ via: "inbox", values: { taskIds, status: "done" } },
|
|
384
|
+
user,
|
|
385
|
+
);
|
|
386
|
+
expect(result).toEqual({ count: 2, via: "inbox" });
|
|
387
|
+
const list = await stack.http.queryOk<{ rows: { title: string; status: string }[] }>(
|
|
388
|
+
"task-board:query:task:list",
|
|
389
|
+
{ sort: "title" },
|
|
390
|
+
user,
|
|
391
|
+
);
|
|
392
|
+
expect(list.rows.filter((row) => row.title.startsWith("Via")).map((row) => row.status)).toEqual(
|
|
393
|
+
["done", "done"],
|
|
394
|
+
);
|
|
395
|
+
});
|
|
396
|
+
|
|
362
397
|
test("the preview query shows the same plan the handler applies", async () => {
|
|
363
398
|
const created = await Promise.all(
|
|
364
399
|
["Plan A", "Plan B"].map((title) =>
|
|
@@ -372,13 +407,13 @@ describe("form bulk action handler", () => {
|
|
|
372
407
|
const taskIds = created.map((task) => task.data.id);
|
|
373
408
|
const preview = await stack.http.queryOk<{
|
|
374
409
|
count: number;
|
|
375
|
-
tasks: { title: string; before: string; after: string }[];
|
|
410
|
+
tasks: { title: string; before: string; after: string; attachmentId: null }[];
|
|
376
411
|
}>("task-board:query:task:set-status-preview", { taskIds, status: "blocked" }, user);
|
|
377
412
|
expect(preview).toEqual({
|
|
378
413
|
count: 1,
|
|
379
414
|
tasks: [
|
|
380
|
-
{ title: "Plan A", before: "open", after: "blocked" },
|
|
381
|
-
{ title: "Plan B", before: "blocked", after: "blocked" },
|
|
415
|
+
{ title: "Plan A", before: "open", after: "blocked", attachmentId: null },
|
|
416
|
+
{ title: "Plan B", before: "blocked", after: "blocked", attachmentId: null },
|
|
382
417
|
],
|
|
383
418
|
});
|
|
384
419
|
});
|
|
@@ -722,6 +757,26 @@ export function createTaskBoardFeature(
|
|
|
722
757
|
},
|
|
723
758
|
});
|
|
724
759
|
|
|
760
|
+
// Target of `useNavigateWithInitialValues(screen, values, { submitThrough })`: the form
|
|
761
|
+
// submits `{ ...wrap, [valuesKey]: values }` here. The wrapper returns the inner data
|
|
762
|
+
// unchanged (plus `via`) because the form reads its redirect id and success facts from it.
|
|
763
|
+
r.writeHandler({
|
|
764
|
+
name: "task:set-status-via",
|
|
765
|
+
schema: z.object({
|
|
766
|
+
via: z.string(),
|
|
767
|
+
values: setStatusInput.extend({ note: z.string().optional() }),
|
|
768
|
+
}),
|
|
769
|
+
access: openAccess.access,
|
|
770
|
+
handler: async (event, ctx) => {
|
|
771
|
+
const inner = await ctx.dispatch.write("task-board:write:task:set-status", {
|
|
772
|
+
...event.payload.values,
|
|
773
|
+
});
|
|
774
|
+
if (!inner.isSuccess) return inner;
|
|
775
|
+
const innerData = typeof inner.data === "object" && inner.data !== null ? inner.data : {};
|
|
776
|
+
return { isSuccess: true as const, data: { ...innerData, via: event.payload.via } };
|
|
777
|
+
},
|
|
778
|
+
});
|
|
779
|
+
|
|
725
780
|
// The preview runs the same plan the write handler runs, so the two cannot drift apart.
|
|
726
781
|
r.queryHandler({
|
|
727
782
|
name: "task:set-status-preview",
|
|
@@ -735,7 +790,12 @@ export function createTaskBoardFeature(
|
|
|
735
790
|
if ("missingId" in plan) throw new NotFoundError("task");
|
|
736
791
|
return {
|
|
737
792
|
count: plan.rows.filter((row) => row.before !== row.after).length,
|
|
738
|
-
tasks: plan.rows.map(({ title, before, after }) => ({
|
|
793
|
+
tasks: plan.rows.map(({ title, before, after }) => ({
|
|
794
|
+
title,
|
|
795
|
+
before,
|
|
796
|
+
after,
|
|
797
|
+
attachmentId: null,
|
|
798
|
+
})),
|
|
739
799
|
};
|
|
740
800
|
},
|
|
741
801
|
});
|
|
@@ -768,6 +828,8 @@ export function createTaskBoardFeature(
|
|
|
768
828
|
{ field: "title", label: "Task" },
|
|
769
829
|
{ field: "before", label: "Now" },
|
|
770
830
|
{ field: "after", label: "New" },
|
|
831
|
+
// A FileRef id (null here) is shown with file name and download link.
|
|
832
|
+
{ field: "attachmentId", label: "Attachment", type: "file" },
|
|
771
833
|
],
|
|
772
834
|
},
|
|
773
835
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.422.0",
|
|
4
4
|
"description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"./package.json": "./package.json"
|
|
205
205
|
},
|
|
206
206
|
"dependencies": {
|
|
207
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
207
|
+
"@cosmicdrift/kumiko-types": "0.422.0",
|
|
208
208
|
"bullmq": "^5.81.5",
|
|
209
209
|
"hono": "^4.13.14",
|
|
210
210
|
"i18next": "^26.5.12",
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
228
|
"devDependencies": {
|
|
229
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
229
|
+
"@cosmicdrift/kumiko-testing": "0.422.0",
|
|
230
230
|
"bun-types": "^1.4.4",
|
|
231
231
|
"fflate": "^0.8.3",
|
|
232
232
|
"meilisearch": "^0.62.0",
|