Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.8 KB

File metadata and controls

50 lines (40 loc) · 1.8 KB

CreatePartnerUsecase

Purpose

Create a new partner record ready for backoffice operations and frontoffice visibility rules.

Trigger / entry point

  • Invoked by GraphQL mutation partner_create.

Inputs

Name Required Type Description
name Yes string Partner display name.
category Yes PartnerCategory Enum category (RECOVERY, NUTRITION, EQUIPMENT, TRAINING, TECH_WEARABLES).
shortDescription Yes string Card description.
websiteUrl Yes string Absolute http(s) URL.
promoCode No string Optional promo code.
logoImageName Yes string Logo filename reference.
coverImageName Yes string Cover filename reference.
displayOrder Yes number Frontoffice display order.
isActive No boolean Visibility toggle; defaults to true.
session Yes UsecaseSession Actor context (actorId = session user id).

Preconditions

  • Required fields must be non-empty after trim.
  • websiteUrl must match allowed absolute URL format.
  • displayOrder must be a non-negative integer.

Main flow

  1. Validates and normalizes incoming payload.
  2. Delegates creation to repository with automatic slug generation.
  3. Initializes linkClickCount at 0.

Outputs / side effects

  • Persists a new partner entity in MongoDB.
  • Returns created partner model.

Error cases / edge cases

  • Throws ERRORS.CONFLICT_ERROR when slug uniqueness collides after retries.
  • Normalizes unexpected failures to ERRORS.CREATE_PARTNER_USECASE.

Dependencies

  • bddService
  • loggerService

Related files

  • api/src/usecases/partner/create-partner.usecase.ts

Notes / limitations

  • Slug is backend-generated and not user-editable through standard inputs.