refactor: consolidate duplicated helpers, types, and test fixtures #212
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-199-consolidate-duplicated-helpers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replace copy-pasted helpers with single shared functions, standardize divergent type patterns, fix stale naming/URL drift, and consolidate duplicated test fixtures. No behavior change beyond consolidation.
Types crate (mokosh-types): extract a
compute_sla_statusfree fn shared byTicket::sla_statusand the tickets service row mapping; movedefault_true()to onepub(crate)location and reference it ascrate::default_true; switchContactStatusto the Option-returningfrom_strpattern its peers use; drop the unusedModuleConfig/UpdateModuleConfigRequest; makeJwtClaims.roleaUserRole(its snake_case serde keeps wire compat); give time-entry DTOsBillingStatus/ApprovalStatusenums instead of bareString.Auth HTTP (mokosh-auth-http): add
handlers::sharedholdingTokenBundle,DEFAULT_FIRST_PARTY_SCOPE,looks_like_email,token_hash_prefix, and onerequire_adminguard; rewire auth/tenants/invites/signup/password_reset/audit/feedback/users handlers onto it.Auth storage (mokosh-auth-storage): extract a
retry_serializablehelper in conv.rs and route all nine SERIALIZABLE retry sites through it; use the sharedip_to_inetin trusted_device.Other: parse directly to
GrantTypein the OIDC token endpoint (drop the localTokenGrant); addAeadError::Encryptand use it inencrypt(); include[::1]inis_local_issuer; use{ workspace = true }for argon2/rand_core in mokosh-auth-crypto; use theRequireManagerextractor forlist_users; set the Forgejo repository URL; update stalemokosh-clientsreferences tomokosh-apps.Tests: move
seed_companyand adec()Decimal parser intotests/common/mod.rs; add therust_decimaldev-dep (and the sqlxrust_decimalfeature) and bindDecimalinseed_time_entryinstead offormat!()SQL; usecommon::DEFAULT_TENANT_IDin notifications_backfill; extendcommon::seed_userwith atenant_idarg and drop auth.rs'sinsert_user_in_tenant.#PMS-199
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Replace copy-pasted helpers with single shared functions, standardize divergent type patterns, fix stale naming/URL drift, and consolidate duplicated test fixtures. No behavior change beyond consolidation. Types crate (mokosh-types): extract a `compute_sla_status` free fn shared by `Ticket::sla_status` and the tickets service row mapping; move `default_true()` to one `pub(crate)` location and reference it as `crate::default_true`; switch `ContactStatus` to the Option-returning `from_str` pattern its peers use; drop the unused `ModuleConfig`/`UpdateModuleConfigRequest`; make `JwtClaims.role` a `UserRole` (its snake_case serde keeps wire compat); give time-entry DTOs `BillingStatus`/`ApprovalStatus` enums instead of bare `String`. Auth HTTP (mokosh-auth-http): add `handlers::shared` holding `TokenBundle`, `DEFAULT_FIRST_PARTY_SCOPE`, `looks_like_email`, `token_hash_prefix`, and one `require_admin` guard; rewire auth/tenants/invites/signup/password_reset/audit/feedback/users handlers onto it. Auth storage (mokosh-auth-storage): extract a `retry_serializable` helper in conv.rs and route all nine SERIALIZABLE retry sites through it; use the shared `ip_to_inet` in trusted_device. Other: parse directly to `GrantType` in the OIDC token endpoint (drop the local `TokenGrant`); add `AeadError::Encrypt` and use it in `encrypt()`; include `[::1]` in `is_local_issuer`; use `{ workspace = true }` for argon2/rand_core in mokosh-auth-crypto; use the `RequireManager` extractor for `list_users`; set the Forgejo repository URL; update stale `mokosh-clients` references to `mokosh-apps`. Tests: move `seed_company` and a `dec()` Decimal parser into `tests/common/mod.rs`; add the `rust_decimal` dev-dep (and the sqlx `rust_decimal` feature) and bind `Decimal` in `seed_time_entry` instead of `format!()` SQL; use `common::DEFAULT_TENANT_ID` in notifications_backfill; extend `common::seed_user` with a `tenant_id` arg and drop auth.rs's `insert_user_in_tenant`. #PMS-199 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>