feat(form-builder): admin UI completion — server filters, KPIs, resource expansion (WS-6 sessie 3c)

Closes the four production gaps that emerged from sessie 3b's admin UI.
What we ship here is final: no further rework planned before production.

Backend
- IndexFailuresRequest validates state/search/failed_at_from/failed_at_to/
  listener_class. orgIndex + platformIndex apply them via a single
  applyIndexFilters() helper. Search runs case-insensitive `LIKE` on
  exception_message; SQL wildcards in user input are escaped.
- New /kpis aggregate endpoint per scope (orgKpis, platformKpis) returns
  open / resolved_30d / dismissed_30d / total_submissions in O(1) COUNTs.
  Replaces sessie 3b's client-side bucketing of an oversized list.
- Resource expansion: organisation_name, form_schema_label,
  resolved_by_user_name, dismissed_by_user_name, exception_trace,
  retry_history[]. Eager-loading via indexEagerLoads()/detailEagerLoads()
  prevents N+1 (verified by query-count assertion in test).
- New 2026_04_28_181000 migration adds exception_trace (longtext nullable)
  to form_submission_action_failures. ApplyBindingsOnFormSubmit listener
  now captures $e->getTraceAsString() at failure time.
- New FormSubmissionActionFailureRetryAttemptResource exposes per-attempt
  data (timestamp, actor name, outcome, exception details) inside
  retry_history[]. Index payloads omit the field via whenLoaded() to keep
  list responses lean.

Frontend (apps/app)
- Types updated to mirror the expanded resource shape and the new KPI
  endpoint contract. FormFailuresKpis is now { open, resolved_30d,
  dismissed_30d, total_submissions } (server-aggregate).
- useFormFailures composable forwards all 5 server filters via
  buildIndexParams() (strips empty/whitespace). useFormFailuresKpis hits
  the dedicated /kpis endpoint per scope.
- FormFailuresTable replaces client-side bucketing with server-side
  filtering, adds listener_class + date-range filter inputs, and renames
  the 4th KPI tile to "Submissions" (was "Totaal").
- FormFailureDetail renders organisation_name + form_schema_label in the
  header, surfaces an expandable stack-trace card, names the resolved/
  dismissed actor in the timeline, and replaces the "v1 placeholder"
  retry-history card with a full per-attempt timeline.

ESLint config gap (apps/app)
- New .eslintrc.cjs adapted from the Vuexy reference, minus Vuexy-internal
  rules. `pnpm lint` now runs successfully (was previously broken — the
  package.json script referenced a missing config). The 80 baseline
  violations across the codebase are pre-existing and out of scope for
  this session.

Tests + gates
- 24 new backend tests across filter, kpis, and resource-shape suites.
  Backend: 1462 → 1486 passing, 0 → 0 failing. Larastan clean. Rector
  dry-run unchanged at 354 (pre-Task-1 baseline from f18b55b).
- 3 new vitest tests in apps/app (filter wiring, KPI endpoint, KPI tile
  values from /kpis). Vitest: 38 → 41 passing. tsc clean. Portal
  unchanged (113 vitest, tsc clean).
- 5 backfill rollback tests bumped --step counts +1 for the new migration.
- Ws6FoundationMigrationTest down/up chain now includes exception_trace
  before the parent table is restored.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-28 23:29:58 +02:00
parent b47e096a55
commit 192353f4bc
31 changed files with 1557 additions and 230 deletions

View File

@@ -628,13 +628,13 @@ DROP TABLE IF EXISTS `form_submission_action_failure_retry_attempts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_submission_action_failure_retry_attempts` (
`id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
`form_submission_action_failure_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
`id` char(26) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`form_submission_action_failure_id` char(26) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`attempted_at` timestamp NOT NULL,
`attempted_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`outcome` enum('succeeded','failed') COLLATE utf8mb4_unicode_ci NOT NULL,
`exception_class` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`exception_message` text COLLATE utf8mb4_unicode_ci,
`attempted_by_user_id` char(26) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`outcome` enum('succeeded','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`exception_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`exception_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -655,6 +655,7 @@ CREATE TABLE `form_submission_action_failures` (
`failed_at` timestamp NOT NULL,
`exception_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`exception_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`exception_trace` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
`context` json NOT NULL,
`retry_count` tinyint unsigned NOT NULL DEFAULT '0',
`resolved_at` timestamp NULL DEFAULT NULL,
@@ -1753,21 +1754,22 @@ INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (104,'2026_04_24_20
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (105,'2026_04_25_015838_create_telescope_entries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (106,'2026_04_25_100000_create_form_field_bindings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (107,'2026_04_25_100001_drop_binding_json_columns',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (140,'2026_04_25_110000_create_form_field_validation_rules_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (141,'2026_04_25_110001_backfill_form_field_validation_rules',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (142,'2026_04_25_120000_create_form_field_configs_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (143,'2026_04_25_120001_backfill_form_field_configs',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (144,'2026_04_25_120002_drop_validation_rules_json_columns',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (145,'2026_04_25_140000_extend_form_submissions_with_apply_status',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (146,'2026_04_25_140100_create_form_submission_action_failures',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (147,'2026_04_26_100000_create_form_field_conditional_logic_groups_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (148,'2026_04_26_100001_create_form_field_conditional_logic_conditions_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (149,'2026_04_26_100002_backfill_form_field_conditional_logic',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (150,'2026_04_26_100003_drop_conditional_logic_json_column',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (151,'2026_04_26_120000_add_default_crowd_type_id_to_form_schemas',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (152,'2026_04_27_100000_create_form_field_options_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (153,'2026_04_27_100001_backfill_form_field_options',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (154,'2026_04_27_100002_drop_form_field_options_json_columns',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (155,'2026_04_28_100000_restore_default_crowd_type_id_foreign_key',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (156,'2026_04_28_140000_add_kvk_number_to_companies_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (157,'2026_04_28_180000_create_form_submission_action_failure_retry_attempts_table',4);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (108,'2026_04_25_110000_create_form_field_validation_rules_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (109,'2026_04_25_110001_backfill_form_field_validation_rules',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (110,'2026_04_25_120000_create_form_field_configs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (111,'2026_04_25_120001_backfill_form_field_configs',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (112,'2026_04_25_120002_drop_validation_rules_json_columns',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (113,'2026_04_25_140000_extend_form_submissions_with_apply_status',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (114,'2026_04_25_140100_create_form_submission_action_failures',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (115,'2026_04_26_100000_create_form_field_conditional_logic_groups_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (116,'2026_04_26_100001_create_form_field_conditional_logic_conditions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (117,'2026_04_26_100002_backfill_form_field_conditional_logic',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (118,'2026_04_26_100003_drop_conditional_logic_json_column',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (119,'2026_04_26_120000_add_default_crowd_type_id_to_form_schemas',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (120,'2026_04_27_100000_create_form_field_options_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (121,'2026_04_27_100001_backfill_form_field_options',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (122,'2026_04_27_100002_drop_form_field_options_json_columns',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (123,'2026_04_28_100000_restore_default_crowd_type_id_foreign_key',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (124,'2026_04_28_140000_add_kvk_number_to_companies_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (125,'2026_04_28_180000_create_form_submission_action_failure_retry_attempts_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (126,'2026_04_28_181000_add_exception_trace_to_form_submission_action_failures',2);