@cosmicdrift/kumiko-samples 0.417.0 → 0.418.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 +1 -1
- package/packages/bundled-features/package.json +1 -1
- package/packages/bundled-features/src/agent-tools/api-docs/schema-fields.ts +14 -0
- package/packages/bundled-features/src/agent-tools/changes.json +6 -0
- package/packages/bundled-features/src/auth-email-password/index.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/signup-activation.ts +2 -5
- package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +0 -6
- package/packages/bundled-features/src/cap-counter/changes.json +6 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +46 -13
- package/packages/bundled-features/src/channel-whatsapp/changes.json +1 -1
- package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +13 -1
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +23 -6
- package/packages/bundled-features/src/signature/README.md +4 -4
- package/packages/bundled-features/src/signature/changes.json +18 -0
- package/packages/bundled-features/src/signature/entity.ts +3 -1
- package/packages/bundled-features/src/signature/feature.ts +16 -3
- package/packages/bundled-features/src/signature/handlers/lifecycle.write.ts +33 -1
- package/packages/bundled-features/src/signature/i18n.ts +1 -0
- package/packages/bundled-features/src/signature/list-cursor-seal.ts +59 -0
- package/packages/bundled-features/src/signature/options.ts +2 -2
- package/packages/bundled-features/src/signature/payloads.ts +14 -2
- package/packages/bundled-features/src/signature/png.ts +25 -4
- package/packages/bundled-features/src/signature/subject-queries.ts +47 -7
- package/packages/bundled-features/src/signature/sweep.ts +32 -8
- package/packages/bundled-features/src/signature/web/constants.ts +12 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +1 -1
- package/packages/bundled-features/src/subscription-stripe/changes.json +6 -0
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +2 -0
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +21 -16
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +7 -3
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +6 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +90 -42
- package/samples/apps/use-all-bundled/feature-manifest.json +2 -1
- package/samples/recipes/crypto-shredding-hr/README.md +1 -1
- package/samples/recipes/crypto-shredding-hr/src/feature.ts +1 -1
- package/samples/recipes/list-table-options/README.md +9 -3
- package/samples/recipes/list-table-options/src/feature.ts +123 -3
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
entityListSchema,
|
|
16
16
|
type FeatureDefinition,
|
|
17
17
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
18
|
-
import
|
|
18
|
+
import { failNotFound, NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
|
|
19
|
+
import { type ListTableOptions, MAX_BULK_SELECTION } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
19
20
|
import { z } from "zod";
|
|
20
21
|
|
|
21
22
|
export const taskEntity = createEntity({
|
|
@@ -60,6 +61,39 @@ export const openAccess = {
|
|
|
60
61
|
},
|
|
61
62
|
} as const;
|
|
62
63
|
|
|
64
|
+
const setStatusInput = z.object({
|
|
65
|
+
taskIds: z.array(z.uuid()).min(1).max(MAX_BULK_SELECTION),
|
|
66
|
+
status: z.enum(taskEntity.fields.status.options),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
type StatusPlanRow = {
|
|
70
|
+
readonly id: string;
|
|
71
|
+
readonly version: number;
|
|
72
|
+
readonly title: string;
|
|
73
|
+
readonly before: string;
|
|
74
|
+
readonly after: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// The one rule behind the status form: the write handler applies it and the preview query shows it.
|
|
78
|
+
async function planStatusChanges(
|
|
79
|
+
taskIds: readonly string[],
|
|
80
|
+
status: string,
|
|
81
|
+
loadTask: (id: string) => Promise<Readonly<Record<string, unknown>> | null | undefined>,
|
|
82
|
+
): Promise<{ readonly rows: readonly StatusPlanRow[] } | { readonly missingId: string }> {
|
|
83
|
+
const rows: StatusPlanRow[] = [];
|
|
84
|
+
for (const id of taskIds) {
|
|
85
|
+
const task = await loadTask(id);
|
|
86
|
+
if (!task) return { missingId: id };
|
|
87
|
+
rows.push({
|
|
88
|
+
id,
|
|
89
|
+
version: Number(task["version"]),
|
|
90
|
+
title: String(task["title"]),
|
|
91
|
+
before: String(task["status"]),
|
|
92
|
+
after: status,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return { rows };
|
|
96
|
+
}
|
|
63
97
|
// Overridable so a test can feed the boot validator a block that must be rejected.
|
|
64
98
|
export function createTaskBoardFeature(
|
|
65
99
|
taskTable: ListTableOptions = {
|
|
@@ -143,8 +177,17 @@ export function createTaskBoardFeature(
|
|
|
143
177
|
visible: { field: "status", ne: "done" },
|
|
144
178
|
},
|
|
145
179
|
],
|
|
146
|
-
// Row checkboxes and a selection bar;
|
|
147
|
-
bulkActions: [
|
|
180
|
+
// Row checkboxes and a selection bar; delete writes once per row, set-status once for all.
|
|
181
|
+
bulkActions: [
|
|
182
|
+
{ id: "delete", rowAction: "delete" },
|
|
183
|
+
{
|
|
184
|
+
id: "set-status",
|
|
185
|
+
label: "Set status",
|
|
186
|
+
icon: "pencil",
|
|
187
|
+
screen: "task-set-status",
|
|
188
|
+
idsField: "taskIds",
|
|
189
|
+
},
|
|
190
|
+
],
|
|
148
191
|
access: openAccess.access,
|
|
149
192
|
});
|
|
150
193
|
|
|
@@ -240,6 +283,83 @@ export function createTaskBoardFeature(
|
|
|
240
283
|
},
|
|
241
284
|
});
|
|
242
285
|
|
|
286
|
+
// One write for the whole selection: the bulk action below opens this form and `taskIds`
|
|
287
|
+
// arrives as a string array. The client cap is no protection, so the schema bounds the list
|
|
288
|
+
// and every id is read through the tenant-scoped executor before anything is written.
|
|
289
|
+
r.writeHandler({
|
|
290
|
+
name: "task:set-status",
|
|
291
|
+
schema: setStatusInput.extend({ note: z.string().optional() }),
|
|
292
|
+
access: openAccess.access,
|
|
293
|
+
handler: async (event, ctx) => {
|
|
294
|
+
const { taskIds, status, note } = event.payload;
|
|
295
|
+
const plan = await planStatusChanges(taskIds, status, (id) =>
|
|
296
|
+
taskExecutor.detail({ id }, event.user, ctx.db),
|
|
297
|
+
);
|
|
298
|
+
if ("missingId" in plan) return failNotFound("task", plan.missingId);
|
|
299
|
+
const changed = plan.rows.filter((row) => row.before !== row.after);
|
|
300
|
+
for (const row of changed) {
|
|
301
|
+
const result = await taskExecutor.update(
|
|
302
|
+
{ id: row.id, version: row.version, changes: { status, note } },
|
|
303
|
+
event.user,
|
|
304
|
+
ctx.db,
|
|
305
|
+
);
|
|
306
|
+
if (!result.isSuccess) return result;
|
|
307
|
+
}
|
|
308
|
+
return { isSuccess: true as const, data: { count: changed.length } };
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// The preview runs the same plan the write handler runs, so the two cannot drift apart.
|
|
313
|
+
r.queryHandler({
|
|
314
|
+
name: "task:set-status-preview",
|
|
315
|
+
schema: setStatusInput,
|
|
316
|
+
access: openAccess.access,
|
|
317
|
+
handler: async (query, ctx) => {
|
|
318
|
+
const { taskIds, status } = query.payload;
|
|
319
|
+
const plan = await planStatusChanges(taskIds, status, (id) =>
|
|
320
|
+
taskExecutor.detail({ id }, query.user, ctx.db),
|
|
321
|
+
);
|
|
322
|
+
if ("missingId" in plan) throw new NotFoundError("task");
|
|
323
|
+
return {
|
|
324
|
+
count: plan.rows.filter((row) => row.before !== row.after).length,
|
|
325
|
+
tasks: plan.rows.map(({ title, before, after }) => ({ title, before, after })),
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
r.screen({
|
|
331
|
+
id: "task-set-status",
|
|
332
|
+
type: "actionForm",
|
|
333
|
+
dormant: true,
|
|
334
|
+
handler: "task-board:write:task:set-status",
|
|
335
|
+
listScreenId: "task-list",
|
|
336
|
+
redirect: "task-list",
|
|
337
|
+
fields: {
|
|
338
|
+
taskIds: { type: "multiSelect", options: [], display: "count" },
|
|
339
|
+
status: createSelectField({
|
|
340
|
+
options: ["open", "inProgress", "blocked", "done"] as const,
|
|
341
|
+
required: true,
|
|
342
|
+
}),
|
|
343
|
+
note: createTextField({ personal: false, reason: "is_business_data" }),
|
|
344
|
+
},
|
|
345
|
+
layout: { sections: [{ fields: ["taskIds", "status", "note"] }] },
|
|
346
|
+
// Which tasks change and from what to what, shown before the user submits.
|
|
347
|
+
preview: {
|
|
348
|
+
query: "task-board:query:task:set-status-preview",
|
|
349
|
+
fields: ["taskIds", "status"],
|
|
350
|
+
title: "Preview",
|
|
351
|
+
facts: [{ field: "count", label: "Tasks that change" }],
|
|
352
|
+
list: {
|
|
353
|
+
field: "tasks",
|
|
354
|
+
columns: [
|
|
355
|
+
{ field: "title", label: "Task" },
|
|
356
|
+
{ field: "before", label: "Now" },
|
|
357
|
+
{ field: "after", label: "New" },
|
|
358
|
+
],
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
|
|
243
363
|
r.nav({ id: "tasks", label: "task-board:nav.tasks", icon: "list", order: 10 });
|
|
244
364
|
r.nav({
|
|
245
365
|
id: "task-list",
|