dow-prod-tracker/src/hooks
DJP bdb133d49a Phase 5: unified versioning + single-asset-per-revision + holding pen
Reshapes the Revision model around how producers + clients actually
work: one upload per round (image OR video, no references), per-stage
version chain V0.1 → V0.2 → V1 → V1.1 → V1.2 → V2 …, holding pen for
inbound files received while a previous version is in client approval,
and per-pipeline filename matching for inbound ingest.

Schema:
  - Revision: drop roundNumber + multi-key attachments. Add major/minor/
    sentToClient/sentAt/asset (single image-or-video object) + unique
    (deliverableStageId, major, minor).
  - PipelineTemplate: add inboundFilenameRegex (per-pipeline matcher).
  - NEW HoldingPenFile model + HoldingPenSource enum (MANUAL/API/BOX).
  - Empty prod DB → clean ALTER TABLE migration, no backfill.

Send-to-client semantics:
  - The latest internal revision IS the V{n} — promote in place
    (major+=1, minor=0, sentToClient=true). Chain reads V0.1, V0.2, V1,
    V1.1, V1.2, V2, ...
  - sendToClient is the ONLY Box-push trigger. Auto-on-APPROVED removed
    from deliverable-status-service. APPROVED is now an internal "done
    iterating" state, separate from "shipped to client".

Three input channels, one matcher:
  - NEW src/lib/services/inbound-ingest-service.ts — consolidates Box
    webhook, /api/v1/upload, and manual upload-by-filename. One regex
    resolver, one project/deliverable matcher, one routing + notification
    fan-out.
  - box-inbound-service is now a thin wrapper that fetches Box metadata
    and delegates.
  - external-delivery-service.parseInboundFileName takes an optional
    regex override. Default: ^(\d+)_([a-z0-9-]+)(?:_v(\d+))?(?:\.[a-z0-9]+)?$
    captures (1) OMG #, (2) slug, (3) optional version.
  - buildDeliveryNaming now uses {omg}_{slug}_V{major} for Box folders.

Holding pen:
  - When a deliverable is IN_REVIEW (a V{n} is awaiting client decision)
    and a new file arrives via any channel, it lands in HoldingPenFile —
    NOT in the active chain. Producer manually promotes (creates the
    next minor on the chosen stage) or discards.
  - Held files render in a new HoldingPenPanel on the deliverable detail
    page when present. Source pill (MANUAL/API/BOX), parsed identifiers,
    target-stage picker, Promote + Discard buttons.

Per-pipeline regex UI:
  - NEW InboundMatchingRules section in the pipeline editor. Live regex
    compile, sample-filename match test with echoed captures, save with
    server-side regex-compile validation.

Upload simplification:
  - storeRevisionAsset replaces the old processAndStoreImage +
    processAndStoreVideo + multi-key attachment merge. MIME-detects kind,
    preserves PNG alpha flatten + TIFF→PNG + thumbnail for images, and
    keeps the async HLS transcode pipeline for videos.
  - The single revision upload route drops the `type=` parameter.
  - Three legacy components deleted: image-gallery, image-upload-zone,
    video-upload-zone. NEW asset-upload-zone (unified drop zone).

New API:
  - POST /api/stages/:stageId/revisions/:revisionId/send-to-client
  - GET  /api/deliverables/:id/holding-pen
  - POST /api/deliverables/:id/holding-pen/:fileId (promote)
  - DELETE /api/deliverables/:id/holding-pen/:fileId (discard)
  - POST /api/v1/upload (multipart; same matcher as Box webhook)

UI label rollup:
  - src/lib/format-revision-label.ts is the single source of truth.
    Sent revisions render `V{major}`; internal `V{major}.{minor}`.
  - Revision node/timeline, session presenter/builder/summary, revision
    list, stage review panel — all read the helper.
  - Comparison toolbar simplified to cross-revision picker (no more
    reference-vs-current within a single revision).

The deliverable annotation review page is a temporary stub (links back
to the deliverable detail page where the in-row controls live). The
full annotation overlay + comparison surface will be rebuilt against
the single-asset model in a follow-up.

Run on next deploy:
  docker compose -p loreal-prod-tracker exec app npx prisma migrate deploy

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 19:37:06 -04:00
..
use-annotation-state.ts Phase 1: Dow-customized Prisma schema + strip HP-only features 2026-04-20 18:35:14 -04:00
use-annotations.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-attachments.ts Attachments panel — files + external links per deliverable 2026-04-21 15:25:48 -04:00
use-automations.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-bookings.ts Assign + book hours in one shot from the stage card 2026-04-21 15:31:20 -04:00
use-briefs.ts Add Briefs intake + all three upstream webhooks 2026-04-21 12:05:47 -04:00
use-chat.ts Make Ollama primary AI provider, Claude as paid fallback 2026-04-08 14:06:35 -04:00
use-client-teams.ts Phase 6e: ClientTeam + Pod CRUD — settings pages and APIs 2026-04-20 19:25:29 -04:00
use-comments.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-current-user.ts Gate New Project / New Brief / Add Deliverable behind ADMIN role 2026-04-21 14:37:45 -04:00
use-custom-fields.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-deliverables.ts Deliverables board: drag highlight, pipeline filter, "in pipelines" footer 2026-04-22 12:53:40 -04:00
use-feedback.ts L'Oréal rebuild: restore review workflow, full rename, /api/v1, Box integration 2026-05-12 17:51:53 -04:00
use-holding-pen.ts Phase 5: unified versioning + single-asset-per-revision + holding pen 2026-05-12 19:37:06 -04:00
use-image-viewer.ts feat: add visual review tool with image viewer and upload infrastructure (A1) 2026-03-17 22:16:05 -05:00
use-invitations.ts Fix deploy port clash + wire admin invite → add-user flow 2026-04-20 19:06:47 -04:00
use-my-work.ts Add /hp-prod-tracker basePath for path-based hosting 2026-04-07 21:47:30 -04:00
use-notification-rules.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-notifications.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-permissions.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-pipelines.ts Pipeline editor: rework paths (pass/fail loops) now configurable in the browser 2026-04-21 13:19:43 -04:00
use-pods.ts Phase 6e: ClientTeam + Pod CRUD — settings pages and APIs 2026-04-20 19:25:29 -04:00
use-projects.ts Board drag-and-drop with forward/rework pipeline rules 2026-04-21 12:45:17 -04:00
use-review-sessions.ts L'Oréal rebuild: restore review workflow, full rename, /api/v1, Box integration 2026-05-12 17:51:53 -04:00
use-revision-history.ts Phase 5: unified versioning + single-asset-per-revision + holding pen 2026-05-12 19:37:06 -04:00
use-revisions.ts Phase 5: unified versioning + single-asset-per-revision + holding pen 2026-05-12 19:37:06 -04:00
use-semantic-search.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-skills.ts Add /hp-prod-tracker basePath for path-based hosting 2026-04-07 21:47:30 -04:00
use-timeline-scroll.ts feat(timeline): implement drag-to-pan and keyboard navigation for timeline views 2026-03-04 15:06:11 -06:00
use-timeline.ts Add /hp-prod-tracker basePath for path-based hosting 2026-04-07 21:47:30 -04:00
use-users.ts Add /hp-prod-tracker basePath for path-based hosting 2026-04-07 21:47:30 -04:00
use-video-player.ts Add video player component with HLS streaming and review page integration (A7.2) 2026-03-17 23:52:40 -05:00
use-weekly-report.ts Fix fetchJson in 17 hooks to use basePath prefix 2026-04-07 22:09:41 -04:00
use-workload.ts Add /hp-prod-tracker basePath for path-based hosting 2026-04-07 21:47:30 -04:00