fix(dashboard): F-U-001 add KV / Docs / Files / Dead-letter trigger create forms

Backend triggers_api.rs has long exposed POST /apps/{id}/triggers/{kv,
docs,files,dead_letter}; the dashboard Triggers tab shipped create
forms only for cron / pubsub / email / queue. Listing showed kv/docs/
files/dead_letter rows but operators couldn't create them from the UI.

This commit adds:
- 4 new CreateXxxTriggerInput types in api.ts.
- 4 new api.triggers.createXxx methods.
- 4 new submitCreateXxx functions in apps/[slug]/+page.svelte.
- 4 new <form class="create-form"> sections under the queue form.

KV / Docs / Files share the (script_id, collection_glob, ops[]) shape
with checkbox UI for the per-kind ops (insert/update/delete vs
create/update/delete). Dead-letter takes (script_id, source_filter,
trigger_id_filter, script_id_filter) — all but script_id optional, with
"leaving blank routes every dead-letter to this script" inline help.

`npm run check` clean (only pre-existing tests/e2e/* Playwright errors
remain, documented out-of-scope in the AUDIT.md methodology notes).

AUDIT.md anchor: F-U-001.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-07 20:33:33 +02:00
parent efb644efe9
commit 99558e1987
2 changed files with 355 additions and 0 deletions

View File

@@ -349,6 +349,44 @@ export interface CreatePubsubTriggerInput {
retry_base_ms?: number;
}
// F-U-001: dashboard create surfaces for the four data-plane triggers.
export interface CreateKvTriggerInput {
script_id: string;
collection_glob: string;
ops?: Array<'insert' | 'update' | 'delete'>;
dispatch_mode?: TriggerDispatchMode;
retry_max_attempts?: number;
retry_backoff?: 'exponential' | 'linear' | 'constant';
retry_base_ms?: number;
}
export interface CreateDocsTriggerInput {
script_id: string;
collection_glob: string;
ops?: Array<'create' | 'update' | 'delete'>;
dispatch_mode?: TriggerDispatchMode;
retry_max_attempts?: number;
retry_backoff?: 'exponential' | 'linear' | 'constant';
retry_base_ms?: number;
}
export interface CreateFilesTriggerInput {
script_id: string;
collection_glob: string;
ops?: Array<'create' | 'update' | 'delete'>;
dispatch_mode?: TriggerDispatchMode;
retry_max_attempts?: number;
retry_backoff?: 'exponential' | 'linear' | 'constant';
retry_base_ms?: number;
}
export interface CreateDeadLetterTriggerInput {
script_id: string;
source_filter?: string | null;
trigger_id_filter?: string | null;
script_id_filter?: string | null;
}
// v1.1.9 — queue:receive trigger.
export interface CreateQueueTriggerInput {
script_id: string;
@@ -793,6 +831,28 @@ export const api = {
`/api/v1/admin/apps/${encodeURIComponent(idOrSlug)}/triggers/queue`,
{ method: 'POST', body: JSON.stringify(input) }
),
// F-U-001: matching frontend methods for the four data-plane
// trigger kinds the backend has long supported.
createKv: (idOrSlug: string, input: CreateKvTriggerInput) =>
adminRequest<Trigger>(
`/api/v1/admin/apps/${encodeURIComponent(idOrSlug)}/triggers/kv`,
{ method: 'POST', body: JSON.stringify(input) }
),
createDocs: (idOrSlug: string, input: CreateDocsTriggerInput) =>
adminRequest<Trigger>(
`/api/v1/admin/apps/${encodeURIComponent(idOrSlug)}/triggers/docs`,
{ method: 'POST', body: JSON.stringify(input) }
),
createFiles: (idOrSlug: string, input: CreateFilesTriggerInput) =>
adminRequest<Trigger>(
`/api/v1/admin/apps/${encodeURIComponent(idOrSlug)}/triggers/files`,
{ method: 'POST', body: JSON.stringify(input) }
),
createDeadLetter: (idOrSlug: string, input: CreateDeadLetterTriggerInput) =>
adminRequest<Trigger>(
`/api/v1/admin/apps/${encodeURIComponent(idOrSlug)}/triggers/dead_letter`,
{ method: 'POST', body: JSON.stringify(input) }
),
remove: (idOrSlug: string, triggerId: string) =>
adminRequest<null>(
`/api/v1/admin/apps/${encodeURIComponent(idOrSlug)}/triggers/${triggerId}`,