[Debt] Centralize repeated WebUI API client request helpers #249

Closed
opened 2026-07-13 17:21:07 +02:00 by zemion · 1 comment
Owner

Created from add-ideas/govoplan#3 after triaging /mnt/DATA/git/govoplan/audit-reports/govoplan-full-20260711-1857/jscpd/jscpd-report.json.

Evidence

jscpd reports repeated TypeScript API-client code in core WebUI, especially:

  • webui/src/api/mail.ts: lines 171-216 and 338-392
  • webui/src/api/mail.ts: lines 108-142 and 198-232
  • webui/src/api/admin.ts: lines 44-73 and webui/src/api/privacyRetention.ts: lines 2-31

The repeated code is request/response plumbing, query construction, and typed fetch handling. This makes endpoint changes easy to update inconsistently.

Desired Shape

Introduce or extend shared core WebUI API helpers for common query string construction, empty-result handling, and typed fetch wrappers. Keep module-specific API semantics in the owning API files.

Acceptance Criteria

  • Common request/query/list plumbing is centralized in a stable core WebUI helper.
  • admin, mail, and privacyRetention API wrappers retain their public TypeScript function signatures unless deliberately migrated.
  • npm run test:module-capabilities and relevant WebUI build/test commands pass.
  • jscpd no longer reports the listed API helper clones.
Created from add-ideas/govoplan#3 after triaging `/mnt/DATA/git/govoplan/audit-reports/govoplan-full-20260711-1857/jscpd/jscpd-report.json`. ## Evidence jscpd reports repeated TypeScript API-client code in core WebUI, especially: - `webui/src/api/mail.ts`: lines 171-216 and 338-392 - `webui/src/api/mail.ts`: lines 108-142 and 198-232 - `webui/src/api/admin.ts`: lines 44-73 and `webui/src/api/privacyRetention.ts`: lines 2-31 The repeated code is request/response plumbing, query construction, and typed fetch handling. This makes endpoint changes easy to update inconsistently. ## Desired Shape Introduce or extend shared core WebUI API helpers for common query string construction, empty-result handling, and typed fetch wrappers. Keep module-specific API semantics in the owning API files. ## Acceptance Criteria - Common request/query/list plumbing is centralized in a stable core WebUI helper. - `admin`, `mail`, and `privacyRetention` API wrappers retain their public TypeScript function signatures unless deliberately migrated. - `npm run test:module-capabilities` and relevant WebUI build/test commands pass. - jscpd no longer reports the listed API helper clones.
Author
Owner

Codex State: done

Summary

  • Added shared core WebUI helpers for query serialization, path construction, typed list unwrapping, and POST/POST+JSON requests.
  • Moved shared admin overview/permission/tenant WebUI API contracts into core and re-exported them from admin/access without changing caller-facing names.
  • Moved shared mail profile/policy/test/mock mailbox DTO contracts into core and made mail/campaign re-export them while keeping endpoint behavior in the owning modules.
  • Updated privacy retention, admin/access admin, mail, and campaign API wrappers to use the shared helpers/contracts.

Changed Files

  • webui/src/api/client.ts
  • webui/src/api/adminCommon.ts
  • webui/src/api/mailContracts.ts
  • webui/src/api/privacyRetention.ts
  • webui/src/index.ts
  • webui/src/types.ts
  • ../govoplan-admin/webui/src/api/admin.ts
  • ../govoplan-access/webui/src/api/admin.ts
  • ../govoplan-mail/webui/src/api/client.ts
  • ../govoplan-mail/webui/src/api/mail.ts
  • ../govoplan-campaign/webui/src/api/client.ts
  • ../govoplan-campaign/webui/src/api/mail.ts

Verification

  • npm run test:module-capabilities
  • npm run build
  • npx --yes jscpd --absolute --min-tokens 80 ... touched API/catalog files: Found 0 clones
  • git diff --check in core/access/admin/mail/campaign
## Codex State: done ### Summary - Added shared core WebUI helpers for query serialization, path construction, typed list unwrapping, and POST/POST+JSON requests. - Moved shared admin overview/permission/tenant WebUI API contracts into core and re-exported them from admin/access without changing caller-facing names. - Moved shared mail profile/policy/test/mock mailbox DTO contracts into core and made mail/campaign re-export them while keeping endpoint behavior in the owning modules. - Updated privacy retention, admin/access admin, mail, and campaign API wrappers to use the shared helpers/contracts. ### Changed Files - `webui/src/api/client.ts` - `webui/src/api/adminCommon.ts` - `webui/src/api/mailContracts.ts` - `webui/src/api/privacyRetention.ts` - `webui/src/index.ts` - `webui/src/types.ts` - `../govoplan-admin/webui/src/api/admin.ts` - `../govoplan-access/webui/src/api/admin.ts` - `../govoplan-mail/webui/src/api/client.ts` - `../govoplan-mail/webui/src/api/mail.ts` - `../govoplan-campaign/webui/src/api/client.ts` - `../govoplan-campaign/webui/src/api/mail.ts` ### Verification - `npm run test:module-capabilities` - `npm run build` - `npx --yes jscpd --absolute --min-tokens 80 ... touched API/catalog files: Found 0 clones` - `git diff --check in core/access/admin/mail/campaign`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: add-ideas/govoplan-core#249
No description provided.