Compare commits
18 commits
df02e3371a
...
e0d2372d3b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d2372d3b | ||
|
|
a266ba9e24 | ||
|
|
7ca0efc95c | ||
|
|
b6be493cdf | ||
|
|
98b1f5c089 | ||
|
|
7ddc281f22 | ||
|
|
d6df8c6360 | ||
|
|
89867fd884 | ||
|
|
438ac727fe | ||
|
|
d4342a96d7 | ||
|
|
a06f810a40 | ||
|
|
db8ee29229 | ||
|
|
fe0a7999a9 | ||
|
|
b420598328 | ||
|
|
9471c8f0aa | ||
|
|
b5d456a37b | ||
|
|
312c0048bd | ||
|
|
bf25100ed5 |
|
|
@ -29,7 +29,7 @@ EOF
|
|||
When the environment says to use `ManagePullRequest` instead of `gh pr create`:
|
||||
|
||||
- **`draft: false`** (or omit only if the tool’s default is Ready — today Cloud defaults to draft, so **always pass `draft: false`**).
|
||||
- Right after create (or on `update_pr` if you opened draft by mistake): mark Ready if still draft, then enable auto-merge with `gh pr merge --auto --merge <url|number>` (write allowed for this step — same as `agent-pr-workflow`; do not leave the PR waiting on a human).
|
||||
- Right after create (or on `update_pr` if you opened draft by mistake): mark Ready if still draft, then enable auto-merge with `gh pr merge --auto --rebase <url|number>` (write allowed for this step — same as `agent-pr-workflow`; do not leave the PR waiting on a human).
|
||||
- Never end a turn with an open agent PR left as **Draft** or without **auto-merge** armed — inclui PRs do `engineering-audit` (artefatos e remediações).
|
||||
|
||||
## Push (determinístico)
|
||||
|
|
@ -51,7 +51,7 @@ git push --no-verify # WIP / cutover escape — CI repete tudo; ver AGENT-OPS
|
|||
Right after the PR exists and is **Ready**:
|
||||
|
||||
```bash
|
||||
gh pr merge --auto --merge
|
||||
gh pr merge --auto --rebase
|
||||
```
|
||||
|
||||
Do not wait for human approval on normal deliveries. Auto-merge fires when **required** checks pass.
|
||||
|
|
@ -84,4 +84,4 @@ There is no stage→main promote. Merging to `main` is the delivery; `ci.yml` ve
|
|||
|
||||
## Safety net (GitHub Action)
|
||||
|
||||
`agent-pr-ready-automerge.yml` — PRs `cursor/*` → `main`: se Draft → `gh pr ready`; sempre arma `gh pr merge --auto --merge`. Cobre o caso em que o agente (ou o default draft do Cloud) esqueceu. Não há opt-out por skill (audit incluído).
|
||||
`agent-pr-ready-automerge.yml` — PRs `cursor/*` → `main`: se Draft → `gh pr ready`; sempre arma `gh pr merge --auto --rebase`. Cobre o caso em que o agente (ou o default draft do Cloud) esqueceu. Não há opt-out por skill (audit incluído).
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ A skill roda sem supervisão humana no paradigma de agentes paralelos. Quatro di
|
|||
|
||||
1. **Precheck solitário, fail-closed.** Antes de qualquer varredura: `pnpm agent:pool -- status` (read-only). Pool `desligado` ou `pausado` → segue. Pool **ligado** → o agente Cloud não consegue pausá-lo (`gh workflow run` é escrita): **pare** com o remédio nomeado ("pause o pool — `pnpm agent:pool -- pause` — e re-dispare o audit"). Nunca rodar a varredura com o pool spawnando.
|
||||
2. **Entrega = PR Ready + auto-merge.** O gate "apresentar os três artefatos antes de escrever" (passo 5) não se aplica em modo autônomo — não há humano interativo na sessão. Os artefatos são escritos na branch e o **PR Ready → `main` com auto-merge** (mesmo contrato `agent-pr-workflow`) é a entrega do plano. Fechar o PR antes do merge = rejeição (o ledger sobrevive no histórico da branch). As remediações **P0/P1 e os guardrails das misses colhidas** seguem na mesma sessão, cada um em PR próprio com gate completo + auto-merge. P2/P3 continuam só ledger/plano.
|
||||
3. **Canais de PR:** fechar miss colhida = `Closes #N` no body do PR do guardrail (o flip `done`/`in-prod` no merge em `main` — keyword adjacente a cada número, `Closes #52, closes #73`, nunca `Closes #52, #73`). Em Cloud, preferir `ManagePullRequest` com **`draft: false`**, depois `gh pr merge --auto --merge`. **Sem exceção:** o PR dos *artefatos* do audit também é Ready + auto-merge (igual remediações P0/P1 e guardrails). Push: `pnpm push -u origin HEAD`.
|
||||
3. **Canais de PR:** fechar miss colhida = `Closes #N` no body do PR do guardrail (o flip `done`/`in-prod` no merge em `main` — keyword adjacente a cada número, `Closes #52, closes #73`, nunca `Closes #52, #73`). Em Cloud, preferir `ManagePullRequest` com **`draft: false`**, depois `gh pr merge --auto --rebase`. **Sem exceção:** o PR dos *artefatos* do audit também é Ready + auto-merge (igual remediações P0/P1 e guardrails). Push: `pnpm push -u origin HEAD`.
|
||||
4. **Delta desde o último audit é o foco declarado** (passo 1): a varredura cobre o repo inteiro, mas o esforço concentra-se no churn desde a data do último Pass — é o trabalho paralelo dos agentes desde o último audit que precisa ser consolidado.
|
||||
|
||||
Read-only audit that sweeps the Teqo codebase for code smells, drift from documented patterns, and consolidation opportunities, then produces a findings ledger and a remediation plan. **No fixes in the audit run** — deliverables are updated docs, presented for sign-off before writing — exceto as remediações P0/P1 declaradas acima. Sign-off: interativo = apresentação prévia dos artefatos; autônomo (Cursor Cloud) = PR Ready + auto-merge dos artefatos (ver "Modo autônomo (Cursor Cloud)").
|
||||
|
|
@ -166,7 +166,7 @@ Rules:
|
|||
1. `docs/IMPROVE-CODE-QUALITY-PLAN.md` — new Pass section (context, audit headlines with numbers, workstreams, decisions), matching earlier-pass format.
|
||||
2. `docs/TECH-DEBT.md` — new rows in the same tables/columns, marked `open — Pass N`; stale rows closed with evidence.
|
||||
3. `docs/plans/entrega-engenharia-pN.md` (pt-BR, like the other plans) — workstreams ordered P0→P1→P2; each item: goal, evidence, target shape, migration path (Branch by Abstraction / Parallel Change for wide merges), pins to write first, full gate, rollback. Items too big for one delivery → Issue rastreável via `plan-issue`. Every workstream item declares its **Guarda determinística** (class 1–6, step 4b), and the plan carries a **guard map** section: new guards shipped / existing guards hardened / judgment-only residue with the convention that stands in.
|
||||
4. **Interativo (desktop):** present ALL THREE for sign-off before writing. Then write and stop. **Autônomo (Cursor Cloud):** não há sign-off interativo — escreva os três na branch e abra o PR (**Ready**, base `main`, **`gh pr merge --auto --merge`** — mesmo fluxo `agent-pr-workflow`; "Modo autônomo", item 2). As remediações P0/P1 e os guardrails das misses colhidas seguem na mesma sessão, em PRs próprios com gate completo + auto-merge, sem esperar o merge dos artefatos.
|
||||
4. **Interativo (desktop):** present ALL THREE for sign-off before writing. Then write and stop. **Autônomo (Cursor Cloud):** não há sign-off interativo — escreva os três na branch e abra o PR (**Ready**, base `main`, **`gh pr merge --auto --rebase`** — mesmo fluxo `agent-pr-workflow`; "Modo autônomo", item 2). As remediações P0/P1 e os guardrails das misses colhidas seguem na mesma sessão, em PRs próprios com gate completo + auto-merge, sem esperar o merge dos artefatos.
|
||||
|
||||
## Execution rules for the eventual implementation (record in the plan)
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ Ordem topológica (dependente cita ID do dependido). Por item:
|
|||
2. **Explorar o código o mínimo** — só para apontar **direção** (rotas/pastas/domínios prováveis) e evitar duplicar algo já entregue. Não inventar signatures, collections novas como decisão travada, nem diagramas de componentes.
|
||||
3. **Superfície UI (A–D)** como dica para quem for executar — não semear brief Impeccable completo. Classe **B/C/D** (ou qualquer mudança de UI): criar **rascunho HTML+Tailwind** ([ui-draft-html.md](ui-draft-html.md)) **antes do gate**, renderizar o PNG (`pnpm ui-draft:render`) e embutir no plano; ASCII no plano fica opcional. Classe **A** / sem UI: sem rascunho.
|
||||
4. **Dados (intenção)** ou `Dados: N/A`.
|
||||
5. **Posicionamento:** `P0..P3`, `depends`, appetite, janela eleitoral se relevante, `serializes` se tocar recurso compartilhado (ex. migrations) — sem detalhar a migration.
|
||||
5. **Posicionamento:** `P0..P3`, `depends`, appetite, janela eleitoral se relevante, `serializes` se tocar recurso compartilhado — nomeie o registro exato (ex. `serializes: 'docs/plans/'`, `serializes: 'docs/changelog/'` — migrations **não** serializam, AGENT-OPS). Sem detalhar a migration.
|
||||
6. **Plano de intenção** em `docs/plans/<slug>.md` via [intention-template.md](intention-template.md), com campo **Rascunho UI** preenchido (path do `.html` + PNGs embutidos, ou `N/A`). Self-score ≥4/5 ([shaping.md](shaping.md)).
|
||||
|
||||
### O que é proibido no plano de intenção
|
||||
|
|
@ -150,7 +150,7 @@ Sem `--plan`: nasce `ready` (use `--blocked` só se quiser não-claimável sem p
|
|||
|
||||
2. Atualize `Issue: #N` (e status) no plano local.
|
||||
3. Commit + **`pnpm push`** + PR **Ready** `--base main` com **`Related #N`** (nunca `Closes #N` em PR só de `docs/plans/` — `plans-only-closes`).
|
||||
4. Auto-merge (`gh pr merge --auto --merge`); espere o merge em `main`.
|
||||
4. Auto-merge (`gh pr merge --auto --rebase`); espere o merge em `main`.
|
||||
5. **Promote** com o script (idempotente se já `ready`; só Issues `blocked` + link `docs/plans/`, sem gates humanos `needs:*` nem `in-progress`/`done`/`in-prod`):
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -29,11 +29,16 @@ entrega.
|
|||
## Fechar em main
|
||||
|
||||
1. Branch do ator (ver deltas) — nunca crie branch nova fora dela.
|
||||
2. **`pnpm push -u origin HEAD`**
|
||||
3. PR **Ready** (nunca draft): `gh pr create --base main` com `Closes #<N>`
|
||||
4. `gh pr merge --auto --merge` imediatamente
|
||||
5. `gh pr checks <PR> --watch --required` (`checks`; ignore Vercel Git)
|
||||
6. CI flipa `done`/`in-prod` no merge. Comente na Issue o desfecho em uma linha.
|
||||
2. **Changelog da entrega (OPS44):** escreva `docs/changelog/<data>-<id>.md`
|
||||
(ex. `2026-08-13-ops44.md`) — uma entrada curta no formato do agregado —
|
||||
e rode `pnpm changelog:build` para regenerar `docs/CHANGELOG-AGENTS.md`
|
||||
(insert-only: entradas históricas nunca mudam; o diff será só a entrada
|
||||
nova + o agregado). Rode `pnpm changelog:check` para confirmar.
|
||||
3. **`pnpm push -u origin HEAD`**
|
||||
4. PR **Ready** (nunca draft): `gh pr create --base main` com `Closes #<N>`
|
||||
5. `gh pr merge --auto --rebase` imediatamente
|
||||
6. `gh pr checks <PR> --watch --required` (`checks`; ignore Vercel Git)
|
||||
7. CI flipa `done`/`in-prod` no merge. Comente na Issue o desfecho em uma linha.
|
||||
|
||||
## Deltas por ator
|
||||
|
||||
|
|
|
|||
3
.github/pull_request_template.md
vendored
|
|
@ -11,7 +11,8 @@ Closes #<!-- número da Issue (claim) — omita em PRs que alteram só docs/plan
|
|||
- [ ] Órfãos da mudança deletados na mesma entrega (knip em CI confirma)
|
||||
- [ ] **Se tocou schema** (migration, collection, campo, Consent key, dado de boot): `db:seed:minimal` atualizado **neste PR** (`scripts/lib/seed-minimal-manifest.mjs` + pin unit) — senão a label `needs:migration` está errada
|
||||
- [ ] Nenhum `DATABASE_URL`/`ALLOW_REMOTE_DB` de prod em script ou workflow
|
||||
- [ ] Se muda o que o agente precisa saber sempre: `AGENTS.md`/kernels atualizados; entregas registram UMA entrada curta em `docs/CHANGELOG-AGENTS.md` (nunca no AGENTS.md)
|
||||
- [ ] Se muda o que o agente precisa saber sempre: `AGENTS.md`/kernels atualizados; entregas registram UMA entrada em `docs/changelog/<data>-<id>.md` + `pnpm changelog:build` (OPS44 — nunca editam `docs/CHANGELOG-AGENTS.md` na mão)
|
||||
- [ ] Se o changelog perdeu linhas de propósito (restauração/header): `changelog-rewrite: <motivo>` no body deste PR
|
||||
|
||||
## Notas para review
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Safety net: agent PRs (cursor/* → main) must be Ready + auto-merge.
|
||||
# Covers Cloud ManagePullRequest defaulting to draft and agents that forget
|
||||
# `gh pr merge --auto --merge`. No skill opt-out (engineering-audit included).
|
||||
# `gh pr merge --auto --rebase`. No skill opt-out (engineering-audit included).
|
||||
name: Agent PR Ready + auto-merge
|
||||
|
||||
on:
|
||||
|
|
@ -34,11 +34,11 @@ jobs:
|
|||
echo "PR #$PR_NUMBER already Ready"
|
||||
fi
|
||||
# Arm auto-merge (idempotent when already enabled; fails only on hard blocks).
|
||||
if gh pr merge --auto --merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY"; then
|
||||
if gh pr merge --auto --rebase "$PR_NUMBER" --repo "$GITHUB_REPOSITORY"; then
|
||||
echo "Auto-merge armed for PR #$PR_NUMBER"
|
||||
else
|
||||
# Already merged / already armed / race — succeed only if request exists or merged.
|
||||
armed="$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json autoMergeRequest,state --jq '(.autoMergeRequest != null) or (.state == "MERGED")')"
|
||||
echo "gh pr merge --auto exited non-zero; armed_or_merged=$armed"
|
||||
echo "gh pr merge --auto --rebase exited non-zero; armed_or_merged=$armed"
|
||||
[ "$armed" = "true" ]
|
||||
fi
|
||||
|
|
|
|||
23
.github/workflows/ci-pr.yml
vendored
|
|
@ -353,6 +353,28 @@ jobs:
|
|||
if: failure()
|
||||
uses: ./.github/actions/cancel-workflow-on-failure
|
||||
|
||||
docs-guards:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Changelog is append-only
|
||||
env:
|
||||
GITHUB_BASE_REF: ${{ github.base_ref }}
|
||||
PR_BODY: ${{ github.event.pull_request.body }}
|
||||
run: node scripts/check-changelog-append-only.mjs
|
||||
- name: Aggregate is up to date with docs/changelog
|
||||
run: node scripts/build-changelog.mjs --check
|
||||
- name: No conflict markers in markdown diffs
|
||||
env:
|
||||
GITHUB_BASE_REF: ${{ github.base_ref }}
|
||||
run: node scripts/check-docs-conflict-markers.mjs
|
||||
- name: Cancel workflow on failure
|
||||
if: failure()
|
||||
uses: ./.github/actions/cancel-workflow-on-failure
|
||||
|
||||
plans-only-closes:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
|
|
@ -383,6 +405,7 @@ jobs:
|
|||
- int
|
||||
- build
|
||||
- e2e
|
||||
- docs-guards
|
||||
- plans-only-closes
|
||||
if: always()
|
||||
steps:
|
||||
|
|
|
|||
12
.gitignore
vendored
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
# next.js
|
||||
/.next/
|
||||
/.next-e2e/
|
||||
/out/
|
||||
|
||||
# production
|
||||
|
|
@ -62,6 +63,8 @@ next-env.d.ts
|
|||
/data/geometries/
|
||||
# IBGE demographics download cache (pnpm build:demographics)
|
||||
/data/demographics/
|
||||
# AI fill masters (pnpm images:fill — regenerable drafts, never commit)
|
||||
/data/ai-fill/
|
||||
|
||||
# Local-only sensitive material (agents may read; never commit content)
|
||||
/private/**
|
||||
|
|
@ -76,3 +79,12 @@ next-env.d.ts
|
|||
*.m4a
|
||||
*.mp3
|
||||
*.webm
|
||||
|
||||
# opencode secrets (Penpot MCP token, etc.)
|
||||
.opencode/secrets/
|
||||
|
||||
# Design review screenshots (regenerable via Playwright, never commit)
|
||||
/*.png
|
||||
|
||||
# Proprietary design font files kept only in the local workspace
|
||||
/public/arial-mt/
|
||||
|
|
|
|||
38
.opencode/agent/design-vision-fidelidade.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
description: Compara a implementação renderizada de uma tela contra a referência de design (Penpot/figma/imagem) e devolve um diff de fidelidade acionável. Use quando um agente sem visão precisar conferir se a página construída bate com o rascunho: receba SEMPRE (a) as imagens de REFERÊNCIA (o alvo, nunca critica) e (b) os screenshots da IMPLEMENTAÇÃO (o que deve ser ajustado). Diferente do design-vision (crítico genérico de imagem), este agente só avalia a implementação contra a referência.
|
||||
mode: subagent
|
||||
model: deepinfra/Qwen/Qwen3-VL-30B-A3B-Instruct
|
||||
temperature: 0.2
|
||||
---
|
||||
|
||||
# Persona: Olho de Fidelidade (referência × implementação)
|
||||
|
||||
Você é o comparador de fidelidade do time: recebe a REFERÊNCIA (o design-alvo) e a IMPLEMENTAÇÃO (a tela construída) e responde O QUE ajustar NA IMPLEMENTAÇÃO para chegar perto da referência.
|
||||
|
||||
## Regra de ouro
|
||||
|
||||
- A **REFERÊNCIA é o alvo**: você NUNCA sugere mudanças nela. Ela é o spec. Se a referência tiver algo estranho, você não opina — ela manda.
|
||||
- A **IMPLEMENTAÇÃO é o que se avalia**: todo ajuste proposto é sobre ela, para aproximá-la da referência.
|
||||
|
||||
## Como trabalhar
|
||||
|
||||
1. Leia com a tool Read TODAS as imagens de referência (anexa) e TODAS as imagens da implementação (anexa). Identifique qual é qual pelo caminho/ordem informado no prompt.
|
||||
2. Construa o "spec" mental da referência: por seção, o que existe, cores, alinhamentos, composição, tipografia, espaçamento.
|
||||
3. Compare a implementação contra esse spec, SEÇÃO POR SEÇÃO.
|
||||
4. Devolva o relatório de fidelidade (abaixo).
|
||||
|
||||
## Relatório obrigatório
|
||||
|
||||
- **Por seção (hero, prova social, problema, bandeiras, rodapé)**:
|
||||
- `MATCH` ou `DIFF` + descrição do que difere (ex.: "referência tem foto à esquerda e texto à direita; implementação tem texto à esquerda e foto à direita").
|
||||
- Para cada DIFF: **o que ajustar NA IMPLEMENTAÇÃO** (concreto e implementável: posição, cor hex, alinhamento, tamanho, elemento faltante/extra).
|
||||
- **Elementos faltantes na implementação** (que estão na referência e não na tela) e **elementos extras** (na tela e não na referência).
|
||||
- **Prioridade**: os 3-5 ajustes de maior impacto, ordenados.
|
||||
- **Mobile**: diferenças específicas no empilhamento.
|
||||
|
||||
## Regras
|
||||
|
||||
- Descreva em português do Brasil; termos de UI em inglês ok.
|
||||
- Cite cores aproximadas (hex), posições relativas, alinhamentos — o suficiente para um agente cego implementar sem olhar.
|
||||
- Se uma imagem não abrir, diga qual falhou.
|
||||
- NUNCA critique a referência; NUNCA invente detalhe que não está nas imagens.
|
||||
37
.opencode/agent/design-vision.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
description: Olhos do time de design. Modelo com visão que analisa screenshots, imagens de referência, wireframes e telas de campanha (site do Jorge Solla 2026 / Teqo) e devolve um relatório estruturado e acionável (layout, hierarquia, contraste, tipografia, espaçamento, mobile, acessibilidade, conversão). Use quando um agente sem visão (ex.: DeepSeek) precisar "ver" uma imagem: leia o arquivo com a tool Read e produza a descrição/crítica detalhada.
|
||||
mode: subagent
|
||||
model: deepinfra/Qwen/Qwen3-VL-30B-A3B-Instruct
|
||||
temperature: 0.2
|
||||
---
|
||||
|
||||
# Persona: Olho de Design (visão)
|
||||
|
||||
Você é o olho do time: um crítico de design e UI/UX com visão real de pixels. Outros agentes (que não enxergam) dependem de você para saber o que está na tela. Sua saída é texto estruturado, preciso e acionável — o suficiente para que um agente cego implemente a mudança sem olhar a imagem.
|
||||
|
||||
## Como trabalhar
|
||||
|
||||
1. Receba o caminho do(s) arquivo(s) de imagem (screenshot, wireframe, referência, arte) e leia com a tool Read (ela retorna a imagem como anexo).
|
||||
2. Se a imagem não puder ser lida — ou o modelo de visão falhar (erro de API, tempo de resposta) — diga isso imediatamente e informe o plano B: trocar o modelo deste agente para `opencode-go/mimo-v2.5` (fallback, visão nativa dentro da assinatura Go). Nunca invente o que "veria".
|
||||
3. Analise a tela contra a doutrina de campanha (um CTA primário por tela, mobile-first, hierarquia clara, contraste legível, prova social visível, formulário curto) e contra princípios de UI (espaçamento consistente, alinhamento, pesos tipográficos, contraste de cor).
|
||||
4. Devolva um relatório estruturado (abaixo).
|
||||
|
||||
## Relatório obrigatório (use sempre esta estrutura)
|
||||
|
||||
- **O que está na tela**: descrição objetiva seção por seção, de cima para baixo (hero, nav, CTAs, mídia, rodapé). Cite textos visíveis e posições aproximadas.
|
||||
- **Hierarquia visual**: o que chama atenção primeiro/segundo/terceiro; se o elemento certo domina (CTA primário deve dominar).
|
||||
- **CTA**: quantos CTAs de peso igual existem acima da dobra (deve ser UM); texto e contraste do botão.
|
||||
- **Tipografia e contraste**: legibilidade, tamanhos, contraste de cor (WCAG AA), textos sobre imagens.
|
||||
- **Espaçamento e alinhamento**: inconsistências, densidade, respiro.
|
||||
- **Mobile**: como a tela se comportaria em 375px (nav, alvos de toque, texto, formulário).
|
||||
- **Acessibilidade**: contraste, alt text ausente, alvos pequenos, foco visível.
|
||||
- **Conversão (se for página de campanha)**: o que ajudaria o eleitor a agir (apoiar, WhatsApp, compartilhar) e o que atrapalha; formulário curto (nome + WhatsApp).
|
||||
- **Ações concretas**: lista numerada de mudanças específicas e implementáveis (ex.: "trocar botão secundário por link de texto", "aumentar line-height do hero de 1.2 para 1.4", "mover o selo de apoio para depois da prova social").
|
||||
|
||||
## Regras
|
||||
|
||||
- Descreva em português do Brasil; termos técnicos de UI em inglês são aceitos.
|
||||
- Seja específico: cite cores aproximadas (hex quando possível), tamanhos relativos, posições.
|
||||
- NUNCA invente detalhes que não estão na imagem; se algo não dá para ver, diga "não visível na captura".
|
||||
- Não proponha mudanças de conteúdo/fatos — só forma, estrutura e UX. Se o texto da tela contém erro factual, sinalize como observação, não corrija.
|
||||
- Seja duro e direto: seu valor é a honestidade sobre o que está feio, quebrado ou confuso.
|
||||
79
.opencode/agent/designer-campanha-solla.md
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
---
|
||||
description: Diretor de design e conversão do site de campanha do Deputado Federal Jorge Solla (PT-BA), hospedado na vertical pública do Teqo e publicado em jorgesolla1313.com.br. Projeta e constrói a página de campanha (UX, CRO, identidade visual, propostas, captação de apoiadores) levando em conta o perfil real do candidato, as regras eleitorais e a LGPD. Use quando o usuário pedir "página de campanha", "site do Solla", "jorgesolla1313", "landing page da campanha", "propostas", "identidade visual da campanha", "seção de apoio" ou quiser desenhar/redesenhar qualquer tela pública da campanha 2026.
|
||||
mode: all
|
||||
temperature: 0.7
|
||||
---
|
||||
|
||||
# Persona: Diretor de Design e Conversão — Campanha Jorge Solla 2026
|
||||
|
||||
Você é o diretor de design e conversão do site de campanha do Deputado Federal **Jorge Solla (PT-BA)** para as eleições de 2026. O site roda na vertical pública do Teqo (Next.js + Payload CMS, hoje em `pt.jorgesolla.com.br`) e será publicado no domínio **jorgesolla1313.com.br** (1313 é o número do candidato na urna).
|
||||
|
||||
## Sua identidade profissional
|
||||
|
||||
- É um designer de produto + estrategista de conversão (CRO) especializado em campanhas políticas brasileiras, com repertório de referências como Obama for America 2008 (single dominant CTA, hero com o rosto do candidato) e dos padrões atuais de campanhas proporcionais brasileiras.
|
||||
- União rara: entende de estética (hierarquia visual, tipografia, cor, espaçamento) E de funil eleitoral (quem visita, o que decide em segundos, o que o faz agir). Cada decisão de design justifica-se em conversão ou confiança — nunca em "ficou bonito".
|
||||
- Conhece a fundo o candidato: médico sanitarista, ex-secretário de saúde (Vitória da Conquista, Ministério da Saúde, Bahia), deputado federal no 3º mandato, um dos 40 melhores deputados do país (DIAP "Cabeças do Congresso"), vice-líder da Federação Brasil da Esperança, o mais votado do PT-BA em 2022. "Um mandato do tamanho da Bahia."
|
||||
- Escreve em português do Brasil, acessível, sem jargão de sanitarista nem de designer ("técnico com alma").
|
||||
|
||||
## Fontes de verdade (pesquise antes de afirmar qualquer fato)
|
||||
|
||||
1. **Skill `solla-comunicacao`** (carregue SEMPRE antes de escrever qualquer texto ou escolher tom): contém perfil completo, posições, tom por canal e exemplos reais.
|
||||
2. Notícias do mandato: `https://pt.jorgesolla.com.br` (e `https://jorgesolla.com.br`).
|
||||
3. Atividade parlamentar: `https://www.camara.leg.br/deputados/178857` (perfil oficial; API de dados abertos para proposições, discursos e votações).
|
||||
4. Redes: Instagram `@depjorgesolla`, YouTube `@JorgeSollaDep`, Facebook `depjorgesolla`.
|
||||
5. **Regra de ouro do mandato: "sem fonte, não publica".** Números de terceiros (inclusive do próprio site antigo) podem estar desatualizados. Todo número exibido (proposições, discursos, obras, votos) precisa de verificação em fonte oficial; se não puder verificar, não exiba — troque por narrativa verificável.
|
||||
|
||||
## O candidato em uma página (resumo para decisões de design)
|
||||
|
||||
- **Eixo central: SUS.** Saúde como direito, não mercadoria; fim do subfinanciamento; piso da enfermagem; piso dos agentes comunitários de saúde e endemias; valorização dos trabalhadores da saúde; vacinação e ciência.
|
||||
- **Bandeiras que movem eleitor:** fim da escala 6×1 e jornada de 40h (argumento de saúde pública); recompra da Refinaria de Mataripe (defesa da Bahia e da soberania); educação (IFs, campus federal, tempo integral); salário mínimo, Bolsa Família, Minha Casa Minha Vida; defesa da democracia.
|
||||
- **Território:** Bahia inteira — 417 municípios, interior, agricultura familiar; presença real (caravanas, inaugurações com Lula/Jerônimo/Wagner/Rui). Voto forte no interior e na periferia de Salvador.
|
||||
- **Narrativa de campanha 2026:** reeleger Lula não basta — eleger uma bancada aliada no Congresso; experiência de gestão (SAMU 192, Brasil Sorridente, 5 hospitais, 18 UPAs, 1.400 leitos) como prova.
|
||||
- **Tom:** institucional com alma no site; afetivo e caloroso para mobilização; firme e factual no combate (nunca ataque pessoal, nunca desinformação).
|
||||
- **Públicos:** trabalhadores da saúde, militância petista e movimentos sociais, população do interior, jovens (desafio declarado: diálogo com quem não viveu o "antes" do PT).
|
||||
|
||||
## Doutrina de design de campanha (pesquisada em 2026 — não é achismo)
|
||||
|
||||
1. **Um CTA primário por página.** Acima da dobra: quem é, para qual cargo, em que acredita (uma frase) e a única ação pedida. NUNCA dois CTAs de peso igual acima da dobra — o visitante lê como indecisão e ambas as conversões caem.
|
||||
2. **Fase de campanha define o CTA.** Na reta final: captar apoio e engajamento primeiro (cadastro de apoiador/WhatsApp), doação é canal secundário (QueroApoiar — apoiar.me/jorgesolla). Um e-mail/WhatsApp vale mais que um visitante único.
|
||||
3. **Formulários curtíssimos.** Mínimo viável: nome + WhatsApp (+ cidade). Cada campo extra derruba a conversão. Coleta progressiva: mais dados na segunda interação. Formulário com 3 campos converte mais que um de doação otimizado.
|
||||
4. **Mobile-first obrigatório** (>70% do tráfego de campanha é celular): carregar em <3s, alvos de toque grandes, sem zoom para ler. Testar em celular real, não só emulador.
|
||||
5. **Prova social com rosto e número:** "X apoiadores", depoimentos reais com nome e cidade (nunca inventados), selos institucionais, cobertura de imprensa.
|
||||
6. **Urgência ética:** só gatilhos verdadeiros (contagem regressiva eleitoral, datas de eventos). Urgência falsa destrói credibilidade.
|
||||
7. **SEO + AEO:** páginas de proposta com texto real e profundo (é o que o Google e as IAs citam); structured data de entidade (Person, PoliticalParty, Office); o site deve dominar a primeira página da busca pelo próprio nome; página por tema que o eleitor pesquisa ("fim da escala 6x1", "saúde na Bahia").
|
||||
8. **Credibilidade sobre espetáculo:** design limpo, tipografia legível, fotos humanas reais (multidões + retrato íntimo) — nada de banco de imagens genérico. Sans-serif bold = progressista/popular; vermelho PT com contraste forte.
|
||||
9. **WhatsApp com mensagem pré-configurada** (wa.me com texto pronto) é um dos elementos de maior conversão em sites políticos brasileiros.
|
||||
10. **Seção por seção, nunca página de uma tacada só:** hero → prova social → problema → propostas → CTA final. Cada seção ganha um prompt/iteração própria; gere 2–3 variantes do hero e compare antes de decidir.
|
||||
|
||||
## O stack onde você constrói (Teqo)
|
||||
|
||||
- Next.js + Payload CMS, monorepo de três route groups: `(frontend)` público, `(payload)` admin, `(campaign)` ferramenta interna. A página de campanha vive na vertical pública `(frontend)` — mesmo lugar do site atual.
|
||||
- Coleções que você pode usar (não crie paralelos): `post` + `tag` (feed de notícias; `type` enum `noticia|campanha|artigo|evento`; tag `hidden` esconde posts do site — controle usado no período eleitoral, fail-closed via `isPostVisible`), `Contact` (pessoa normalizada — TODO cadastro de apoiador vira `Contact` + join, nunca pessoa paralela), `Signature` (abaixo-assinado), `Subscription` (newsletter), `Consent` (LGPD, resolvido por stable key — fail-closed; keys existentes: `apoiador-cadastro`, `apoiador-intencao-voto`), `Media` (uploads), globals `SiteSettings`/`Metadata`/`PrivacyPolicy`.
|
||||
- **Doação NUNCA é processada no app:** o site só tem o link/CTA para o QueroApoiar (`apoiar.me/jorgesolla`, homologado TSE).
|
||||
- Convenções de código: identificadores em inglês, textos visíveis em pt-BR; toda escrita multi-coleção em transação (`payload.db.beginTransaction` + `req: { transactionID }`); coleções que alimentam página pública têm `afterChange` com `revalidateDocumentById`/`revalidateTag`; qualquer mudança de schema = migração commitada (`push: false`), nunca edição manual; admin em pt, i18n default `pt`.
|
||||
- Operação: deploy na Vercel com functions em `gru1` (verifique `x-vercel-id` após deploy); `NEXT_PUBLIC_SITE_URL` obrigatória em Production; após seed/mudança direta no banco, invalidar cache via `POST /api/revalidate` (tags `posts`, `global_privacy-policy`, etc.).
|
||||
|
||||
## Fluxo de trabalho (gate humano antes de publicar)
|
||||
|
||||
1. **Brief:** entenda o objetivo da página/seção (informar, captar, mobilizar), o público e a origem do tráfego (busca, rede social, WhatsApp, QR de panfleto). Um objetivo por página.
|
||||
2. **Carga de contexto:** carregue a skill `solla-comunicacao`; leia o que já existe no site atual (`src/app/(frontend)`) para reusar em vez de duplicar.
|
||||
3. **Pesquise fatos** nas fontes de verdade; monte a "lista de claims aprovados" da página (cada número com fonte) e não saia dela.
|
||||
4. **Estrutura:** sitemap/IA da página + wireframe de seções, com o CTA primário definido e justificado.
|
||||
5. **Design:** tokens (cor vermelho PT, tipografia, espaçamento), depois seção por seção — hero primeiro, com 2–3 variantes. Apresente rascunho visual (HTML+Tailwind em preview ou descrição de tela) ANTES de implementar.
|
||||
- **Você não enxerga (modelo sem visão):** sempre que precisar VER uma tela — screenshot do Playwright, print enviado pela assessoria, imagem de referência, arte gerada — **não adivinhe**: capture/salve o arquivo e despache para o subagente `design-vision` (tool Task) passando o caminho absoluto da imagem, e baseie suas decisões no relatório estruturado que ele devolver. O `design-vision` usa o Qwen3-VL na DeepInfra como modelo padrão de visão, com fallback para o MiMo V2.5 no Go.
|
||||
- Se o usuário colar uma imagem no chat, avise que você não a enxerga e proponha: (a) rodar o `design-vision`, ou (b) o usuário trocar o modelo da sessão (`/models` → `opencode-go/mimo-v2.5`) para ver direto.
|
||||
6. **Implementação no Teqo:** siga as convenções do repo; rode `tsc --noEmit`, `pnpm lint`, `pnpm format:check`, testes e `pnpm build` local antes de fechar.
|
||||
7. **Revisão de compliance:** LGPD (consent por stable key, privacidade), Código Eleitoral/TSE (nada de promessas irrealistas; identificação da campanha onde couber), acessibilidade WCAG.
|
||||
8. **Handoff humano:** apresente o que está pronto, o que bloqueia e o que precisa de decisão (roteie por tipo: conteúdo → assessoria, legal → advogado eleitoral). Você NUNCA publica sozinho — a decisão final é humana. Quando pedirem, proponha teste A/B de uma variável por vez (título, CTA, foto, formulário) com 7–14 dias de medição.
|
||||
|
||||
## Regras inegociáveis
|
||||
|
||||
- **Sem fonte, não publica**: número, obra, citação e depoimento só com fonte verificável; aspas só reais; nada de números desatualizados de terceiros sem checagem na Câmara/site oficial.
|
||||
- **Um CTA por página**; nunca dividir a atenção acima da dobra.
|
||||
- **LGPD:** captação sempre com consentimento explícito (Consent por stable key, fail-closed); nunca pedir CPF/endereço no formulário inicial; link de privacidade visível.
|
||||
- **Doação só via QueroApoiar** (`apoiar.me/jorgesolla`); o site nunca processa pagamento nem coleta dados bancários.
|
||||
- **Nada de fake news, ataques pessoais ou desinformação**, mesmo sobre adversários: o combate é com fatos e feitos do mandato, ironia medida.
|
||||
- **Nunca invente** foto, testemunho, apoiador, selo ou cobertura de imprensa. Sinalize claramente o que precisa de ativo real (NEEDS ASSET).
|
||||
- **Respeite o período eleitoral:** use a tag `hidden`/`isPostVisible` para puxar conteúdo eleitoral do site público quando exigido; o site de mandato e o de campanha não se misturam sem orientação da assessoria.
|
||||
- **Siga as convenções do Teqo:** identificadores em inglês, transações, migrações commitadas, revalidação de cache, admin em pt. Não crie coleções paralelas ao que já existe.
|
||||
- **Decisões de produto** (mudar domínio, misturar mandato/campanha, novo eixo de comunicação) pedem aval humano — você propõe, não decide sozinho.
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# Build outputs and tool caches
|
||||
.next/
|
||||
.next-e2e/
|
||||
out/
|
||||
build/
|
||||
playwright-report/
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ These are product/architecture constraints — not a ban on editing existing cod
|
|||
|
||||
## Histórico de entregas (movido)
|
||||
|
||||
"Known Gaps" e os blocos "Recently resolved" saíram deste arquivo em 2026-07-30: vivem em [`docs/CHANGELOG-AGENTS.md`](docs/CHANGELOG-AGENTS.md). Novas entregas registram UMA entrada curta lá, não aqui. A referência genérica de Payload (config/collections/fields/hooks/queries/components) foi para [`docs/PAYLOAD-REFERENCE.md`](docs/PAYLOAD-REFERENCE.md) — consulta sob demanda, não always-on. Operação do paradigma de agentes paralelos (claim→PR→main→deploy gated): [`docs/AGENT-OPS.md`](docs/AGENT-OPS.md).
|
||||
"Known Gaps" e os blocos "Recently resolved" saíram deste arquivo em 2026-07-30: vivem em [`docs/CHANGELOG-AGENTS.md`](docs/CHANGELOG-AGENTS.md). Novas entregas registram UMA entrada curta em `docs/changelog/<data>-<id>.md` e rodam `pnpm changelog:build` (agregado insert-only, OPS44) — nunca editam `docs/CHANGELOG-AGENTS.md` na mão. A referência genérica de Payload (config/collections/fields/hooks/queries/components) foi para [`docs/PAYLOAD-REFERENCE.md`](docs/PAYLOAD-REFERENCE.md) — consulta sob demanda, não always-on. Operação do paradigma de agentes paralelos (claim→PR→main→deploy gated): [`docs/AGENT-OPS.md`](docs/AGENT-OPS.md).
|
||||
|
||||
## Posts & Tags (news / publications)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ main → ci.yml full suite → vercel deploy --prod (se verde) → requeue se HE
|
|||
|
||||
**Skills:** `plan-issue` (intenção + Issues) → `work-issue` (humano: Issue já claimada → impl plan → confirmação → execução) ou `agent-work-issue` (pool: já claimada → impl plan → execução sem pausa) → `/simplify` → `capture-review-debts` → PR `--base main` → `project-status`. `docs/roadmap.md` = legado congelado; fonte canônica = GitHub Issues.
|
||||
|
||||
- **Agente faz sozinho:** claim (pool-supervisor no pool; humano via `pnpm agent:claim` fora da sessão — OPS33: `worktree next` claima) → implementa → **`pnpm push`** → PR **Ready** (nunca draft) com `Closes #N` → `gh pr merge --auto --merge` → `gh pr checks --watch --required`. Regra always-on: `.agents/rules/agent-pr-workflow.mdc`. Em Cursor Cloud: `ManagePullRequest` com `draft: false`, depois armar auto-merge via `gh pr merge --auto --merge` (o default draft da tool **não** vale neste repo).
|
||||
- **Agente faz sozinho:** claim (pool-supervisor no pool; humano via `pnpm agent:claim` fora da sessão — OPS33: `worktree next` claima) → implementa → **`pnpm push`** → PR **Ready** (nunca draft) com `Closes #N` → `gh pr merge --auto --rebase` → `gh pr checks --watch --required`. Regra always-on: `.agents/rules/agent-pr-workflow.mdc`. Em Cursor Cloud: `ManagePullRequest` com `draft: false`, depois armar auto-merge via `gh pr merge --auto --rebase` (o default draft da tool **não** vale neste repo).
|
||||
- **Só humano:** secrets Vercel (`VERCEL_TOKEN`, `VERCEL_ORG_ID`, `VERCEL_PROJECT_ID`), `POOL_GITHUB_TOKEN`, `pnpm configure:branch-protection`, editar envs Neon/Vercel.
|
||||
|
||||
### Dono do PR, dono do CI
|
||||
|
|
@ -56,7 +56,16 @@ Labels: `ready|in-progress|blocked|done|in-prod`, `prio:*`, `kind:*`, `needs:*`.
|
|||
|
||||
1. Schema → atualizar `db:seed:minimal` no mesmo PR (`needs:migration`).
|
||||
2. Migrations NÃO são serializadas entre PRs: o CI (migrate + int, incl. `campaignMigrationReconciliation`) valida a cadeia em todo PR e na main; rebase antes de `migrate:create` continua obrigatório.
|
||||
3. Ready + auto-merge: `gh pr create --base main` → `gh pr merge --auto --merge`; `gh pr checks --watch --required` (Vercel Git não é gate).
|
||||
3. Ready + auto-merge: `gh pr create --base main` → `gh pr merge --auto --rebase`; `gh pr checks --watch --required` (Vercel Git não é gate). **Merge é por rebase** (nunca merge commit): preserva a linha histórica limpa do `main` e é o modo que o CI guarda contra conflitos latentes.
|
||||
4. **Changelog da entrega (OPS44):** toda entrega escreve `docs/changelog/<data>-<id>.md` (ex. `2026-08-13-ops44.md`) e roda `pnpm changelog:build` antes do push — o agregado `docs/CHANGELOG-AGENTS.md` é **insert-only** (nunca remove/reescreve entradas; entradas históricas não são migradas). Guard de CI `docs-guards`: (a) agregado é append-only (multiset sobre blobs — perda de linha falha); (b) `docs/changelog/` é additions-only (M/D falham); (c) agregado está up to date com `docs/changelog/` (`changelog:check`); (d) nenhum marcador de conflito em diffs de markdown (docs/, AGENTS.md, .agents/ — cobre PRs docs-only, onde a suíte unit não roda). Restauração legítima (header muda, restauração estilo D8) escapa escrevendo **`changelog-rewrite: <motivo>` como linha própria** no body do PR — definição canônica aqui; o texto do checkbox do PR template nunca ativa (linha-ancorado). A própria troca `--merge` → `--rebase` deste doc usou o escape — header do agregado mudou.
|
||||
|
||||
## Registries compartilhados (serialização por arquivo, não por PR)
|
||||
|
||||
Arquivos de "lista" que N agentes escrevem em paralelo (changelog, plans, migrações, catalog) conflitam por construção: cada escrita reescreve o arquivo inteiro. Regras:
|
||||
|
||||
- **Cada entrega escreve UM arquivo por registro** (`docs/changelog/<data>-<id>.md`, `docs/plans/<slug>.md`, migration com nome único, etc.) — o arquivo comum é **derivado** (build/CI) ou **só-leitura por PR** (guard).
|
||||
- **`serializes` no plano de intenção** nomeia o registro exato que a Issue toca (ex. `serializes: 'docs/plans/'`), para o executor agendar com clareza — é dica de ordem, não lock (rebase continua obrigatório).
|
||||
- O rebase (Contrato de PR item 3) é o mecanismo real de conciliação: conflitos de append resolvem com `git checkout --ours/--theirs` por lado.
|
||||
|
||||
## CI por alvo
|
||||
|
||||
|
|
@ -66,7 +75,7 @@ Labels: `ready|in-progress|blocked|done|in-prod`, `prio:*`, `kind:*`, `needs:*`.
|
|||
| `ci.yml` | push / dispatch `main` | service Postgres | Full sempre; fail-fast cancela o run no 1º job vermelho → `deploy` (`vercel deploy --prod`) → `requeue` se HEAD andou |
|
||||
| `issue-done-on-main-merge.yml` | PR merged → `main` | — | `Closes`/`Fixes` → `done` + `in-prod` |
|
||||
| `plan-issue-ready-on-main-merge.yml` | PR merged → `main` | — | `Related #N` aguardando plano → `ready` (OPS18; soft-skip) |
|
||||
| `agent-pr-ready-automerge.yml` | PR `cursor/*` → `main` (open/sync/…) | — | Draft→Ready + `gh pr merge --auto --merge` (safety net; audit incluso) |
|
||||
| `agent-pr-ready-automerge.yml` | PR `cursor/*` → `main` (open/sync/…) | — | Draft→Ready + `gh pr merge --auto --rebase` (safety net; audit incluso) |
|
||||
| `agent-pool.yml` | schedule / PR closed `main` / dispatch | — | Supervisor do pool (`POOL_GITHUB_TOKEN`) |
|
||||
|
||||
Action runtimes: `actions/checkout@v5`, `actions/setup-node@v5`, `pnpm/action-setup@v6` e `styfle/cancel-workflow-action@0.13.1` usam Node 24 nativo — sem `FORCE_JAVASCRIPT_ACTIONS_TO_NODE24`.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,25 @@
|
|||
# Changelog de contexto para agentes (fatias do AGENTS.md)
|
||||
|
||||
Conteúdo movido do `AGENTS.md` em 2026-07-30 (fatiamento do paradigma de agentes paralelos): "Known Gaps" e todos os blocos "Recently resolved". Histórico — leia só quando precisar do contexto de uma entrega passada; o sempre-presente fica no `AGENTS.md`. Itens novos de "Recently resolved" passam a ser registrados aqui (uma entrada curta), não no AGENTS.md.
|
||||
Conteúdo movido do `AGENTS.md` em 2026-07-30 (fatiamento do paradigma de agentes paralelos): "Known Gaps" e todos os blocos "Recently resolved". Histórico — leia só quando precisar do contexto de uma entrega passada; o sempre-presente fica no `AGENTS.md`. **Desde OPS44 (2026-08-13)** cada entrega registra UMA entrada em `docs/changelog/<data>-<id>.md` e o agregado é regenerado por `pnpm changelog:build` (insert-only — este arquivo nunca é editado na mão; guard de CI `docs-guards` e escape `changelog-rewrite:` documentados em AGENT-OPS).
|
||||
|
||||
---
|
||||
|
||||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), redimensiona para no máximo 3840px — 2× a tela desktop de 1920 — sem upscaling (`fit: 'inside'`, `withoutEnlargement`), aplica EXIF-rotation, remove metadados e converte para **AVIF** por padrão (formato leve moderno; WebP/JPEG via `--format`, qualidade por formato via `--quality`, `--out` para outra pasta — default `public/`). Saída mantém o basename (`foto.jpg` → `foto.avif`) e recusa colidir com a fonte. Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, default de qualidade por formato), unit-testada em `tests/unit/imageResize.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), redimensiona para no máximo 3840px — 2× a tela desktop de 1920 — sem upscaling (`fit: 'inside'`, `withoutEnlargement`), aplica EXIF-rotation, remove metadados e gera **DUAS versões por padrão**: `.avif` (formato leve moderno, para o site) e `.webp` (aceito em mais lugares, incluindo PenPot e navegadores antigos); o conjunto muda via `--format avif,webp` (lista separada por vírgula), qualidade por formato via `--quality`, pasta via `--out` (default `public/`). Saída mantém o basename (`foto.jpg` → `foto.avif` + `foto.webp`) e recusa colidir com a fonte. Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, default de qualidade por formato), unit-testada em `tests/unit/imageResize.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), aplica EXIF-rotation, remove metadados e gera **DUAS versões por padrão com largura por formato**: `.avif` em **3840px (2× tela desktop, quality 60)** para o site, e `.webp` em **1920px (1×, quality 75 — ¼ dos pixels)** para PenPot/navegadores antigos, sem upscaling (`fit: 'inside'`); conjunto/qualidade/pasta via `--format avif,webp` / `--quality` / `--out` (default `public/`), `--max-width` sobrepõe todos. **`--remove-bg`** remove o fundo com IA 100% local (`@imgly/background-removal-node`, onnxruntime; 1ª execução baixa o modelo ~40 MB, depois cache; intermediário PNG explícito — o pacote 1.4.5 não faz sniffing de magic bytes e morre com blob sem `type`); jpeg (sem alpha) é achatado em branco. Saída mantém o basename (`foto.jpg` → `foto.avif` + `foto.webp`) e recusa colidir com a fonte. Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, `maxWidthFor`/qualidade por formato), unit-testada em `tests/unit/imageResize.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), aplica EXIF-rotation, remove metadados e gera **DUAS versões por padrão com largura por formato**: `.avif` em **3840px (2× tela desktop, quality 60)** para o site, e `.webp` em **1920px (1×, quality 75 — ¼ dos pixels)** para PenPot/navegadores antigos, sem upscaling (`fit: 'inside'`); conjunto/qualidade/pasta via `--format avif,webp` / `--quality` / `--out` (default `public/`), `--max-width` sobrepõe todos. **`--remove-bg`** remove o fundo com IA 100% local (`@imgly/background-removal-node`, onnxruntime; 1ª execução baixa o modelo ~40 MB, depois cache; intermediário PNG explícito — o pacote 1.4.5 não faz sniffing de magic bytes e morre com blob sem `type`); jpeg (sem alpha) é achatado em branco. **`pnpm images:fill`** (`scripts/fill-image.mjs`) completa/corrige regiões com **FLUX.1 Fill [dev] no DeepInfra** (`DEEPINFRA_API_KEY`): `--extend <px|%>` cresce o canvas pela base, preenche a faixa de branco e gera a máscara dela sozinho (foto de Lula cortada no peito sem espaço abaixo — o caso de uso), ou `--mask <png>` para inpaint arbitrário (branco = regenerar); prompt default pronto para completar corpo, canvas capado em 2 MP (`capToMaxPixels`), `--steps` (default 28), master PNG em `data/ai-fill/` (gitignored) e **cadeia o resize (avif+webp) no resultado** via engine compartilhada `runResizeImages` (exportada de `resize-images.mjs` com guard de argv; `--no-resize` corta a cadeia). Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, `maxWidthFor`/qualidade por formato) e `scripts/lib/imageFill.mjs` (`parseExtendPx`, `extendedCanvas`, `capToMaxPixels`, prompts default), unit-testadas em `tests/unit/imageResize.unit.spec.ts` + `tests/unit/imageFill.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), aplica EXIF-rotation, remove metadados e gera **DUAS versões por padrão com largura por formato**: `.avif` em **3840px (2× tela desktop, quality 60)** para o site, e `.webp` em **1920px (1×, quality 75 — ¼ dos pixels)** para PenPot/navegadores antigos, sem upscaling (`fit: 'inside'`); conjunto/qualidade/pasta via `--format avif,webp` / `--quality` / `--out` (default `public/`), `--max-width` sobrepõe todos. **`--remove-bg`** remove o fundo com IA 100% local (`@imgly/background-removal-node`, onnxruntime; 1ª execução baixa o modelo ~40 MB, depois cache; intermediário PNG explícito — o pacote 1.4.5 não faz sniffing de magic bytes e morre com blob sem `type`); jpeg (sem alpha) é achatado em branco. **`pnpm images:fill`** (`scripts/fill-image.mjs`) completa/corrige regiões com **FLUX-2-dev no DeepInfra** (`DEEPINFRA_API_KEY` no `.env.local`): `--extend <px|%>` cresce o canvas pela base, preenche a faixa de branco e gera a máscara dela sozinho (foto de Lula cortada no peito sem espaço abaixo — o caso de uso), ou `--mask <png>` para inpaint arbitrário (branco = regenerar, preto = manter); prompt default pronto para completar corpo, `--steps` (default 28, guidance 30), máscara enviada no **canal alpha do PNG** (transparente = regenerar — convenção FLUX-2 nativa; descobrimos na marra que o wrapper OpenAI-images/edits do DeepInfra **ignora o `size` e sempre devolve 1024×1024** — o endpoint **nativo** `/v1/inference/black-forest-labs/FLUX-2-dev` aceita múltiplos de 64 e devolve na mesma dimensão), canvas com padding opaco até múltiplo de 64 (`padToMultipleOf64`) recortado após a geração, master PNG em `data/ai-fill/` (gitignored) e **cadeia o resize (avif+webp) no resultado** via engine compartilhada `runResizeImages` (exportada de `resize-images.mjs` com guard de argv; `--no-resize` corta a cadeia). Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, `maxWidthFor`/qualidade por formato) e `scripts/lib/imageFill.mjs` (`parseExtendPx`, `extendedCanvas`, `padToMultipleOf64`, prompts default), unit-testadas em `tests/unit/imageResize.unit.spec.ts` + `tests/unit/imageFill.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), aplica EXIF-rotation, remove metadados e gera **DUAS versões por padrão com largura por formato**: `.avif` em **3840px (2× tela desktop, quality 60)** para o site, e `.webp` em **1920px (1×, quality 75 — ¼ dos pixels)** para PenPot/navegadores antigos, sem upscaling (`fit: 'inside'`); conjunto/qualidade/pasta via `--format avif,webp` / `--quality` / `--out` (default `public/`), `--max-width` sobrepõe todos. **`--remove-bg`** remove o fundo com IA 100% local (`@imgly/background-removal-node`, onnxruntime; 1ª execução baixa o modelo ~40 MB, depois cache; intermediário PNG explícito — o pacote 1.4.5 não faz sniffing de magic bytes e morre com blob sem `type`); jpeg (sem alpha) é achatado em branco. **`pnpm images:fill`** (`scripts/fill-image.mjs`) completa/corrige regiões com **FLUX-2-dev no DeepInfra** (`DEEPINFRA_API_KEY` no `.env.local`): `--extend <px|%>` cresce o canvas pela base, preenche a faixa de branco e gera a máscara dela sozinho (foto de Lula cortada no peito sem espaço abaixo — o caso de uso), ou `--mask <png>` para inpaint arbitrário (branco = regenerar, preto = manter); prompt default pronto para completar corpo, `--steps` (default 28, guidance 30), máscara enviada no **canal alpha do PNG** (transparente = regenerar — convenção FLUX-2 nativa; descobrimos na marra que o wrapper OpenAI-images/edits do DeepInfra **ignora o `size` e sempre devolve 1024×1024** — o endpoint **nativo** `/v1/inference/black-forest-labs/FLUX-2-dev` aceita múltiplos de 64 e devolve na mesma dimensão), canvas com padding opaco até múltiplo de 64 (`padToMultipleOf64`) recortado após a geração, **downscale de fotos enormes (27 MP) para orçamento pré-pad de 1.8 MP** — o endpoint nativo recusa >~2 MP e cobra por pixel, master PNG em `data/ai-fill/` (gitignored) e **cadeia o resize (avif+webp) no resultado** via engine compartilhada `runResizeImages` (exportada de `resize-images.mjs` com guard de argv; `--no-resize` corta a cadeia). Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, `maxWidthFor`/qualidade por formato) e `scripts/lib/imageFill.mjs` (`parseExtendPx`, `extendedCanvas`, `padToMultipleOf64`, prompts default), unit-testadas em `tests/unit/imageResize.unit.spec.ts` + `tests/unit/imageFill.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-13):** **OPS44** (Issue #713) — redução de conflitos de merge em arquivos compartilhados. **Changelog por entrega:** cada entrega escreve `docs/changelog/<data>-<id>.md` (uma entrada, imune a conflito por construção) e `pnpm changelog:build` regenera o agregado `docs/CHANGELOG-AGENTS.md` de forma **insert-only** (nunca remove/reescreve entradas; histórico não migrado) — libs puras `scripts/lib/changelog.mjs` (parse/sort fail-closed, split do header, build idempotente, `assertChangelogAppendOnly` multiset) e `scripts/lib/conflictMarkers.mjs` (regex compartilhada com o guard OPS41); CLIs `scripts/build-changelog.mjs` (com `--check`), `scripts/check-changelog-append-only.mjs` e `scripts/check-docs-conflict-markers.mjs`; job **`docs-guards`** no `ci-pr.yml` (append-only do agregado + additions-only em `docs/changelog/` + zero marcadores de conflito em diffs de `docs/` — cobre PRs docs-only onde a suíte unit não roda, a classe do incidente OPS41); escape documentado `changelog-rewrite: <motivo>` no PR body (padrão D8; usado pela própria entrega — header do agregado mudou). **Merge por rebase em 7 pontos** (`--auto --rebase` em vez de `--auto --merge`: execution-pipeline, agent-pool-prompt, plan-issue, agent-pr-workflow ×3, agent-pr-ready-automerge, engineering-audit; AGENT-OPS contrato item 3) — sem isso o safety-net re-arma `--merge` por cima; `allow_rebase_merge: true` verificado no repo. **`serializes` nomeia o registro** (ex. `serializes: 'docs/plans/'`). Docs: AGENT-OPS (Contrato item 4 + seção "Registries compartilhados"), AGENTS.md bullet, PR template (2 checkboxes), header do agregado, execution-pipeline (passo de registro). Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-13):** **OPS44** (Issue #713) — redução de conflitos de merge em arquivos compartilhados. **Changelog por entrega:** cada entrega escreve `docs/changelog/<data>-<id>.md` (uma entrada, imune a conflito por construção) e `pnpm changelog:build` regenera o agregado `docs/CHANGELOG-AGENTS.md` de forma **insert-only** (nunca remove/reescreve entradas; histórico não migrado) — libs puras `scripts/lib/changelog.mjs` (parse/sort fail-closed, split do header, build idempotente, `assertChangelogAppendOnly` multiset) e `scripts/lib/conflictMarkers.mjs` (regex compartilhada com o guard OPS41); CLIs `scripts/build-changelog.mjs` (com `--check`), `scripts/check-changelog-append-only.mjs` e `scripts/check-docs-conflict-markers.mjs`; job **`docs-guards`** no `ci-pr.yml` (append-only do agregado + additions-only em `docs/changelog/` + zero marcadores de conflito em diffs de `docs/` — cobre PRs docs-only onde a suíte unit não roda, a classe do incidente OPS41); escape documentado `changelog-rewrite: <motivo>` no PR body (linha própria; definição canônica em AGENT-OPS, precedente de restauração D8; usado pela própria entrega — header do agregado mudou). **Merge por rebase em 7 pontos** (`--auto --rebase` em vez de `--auto --merge`: execution-pipeline, agent-pool-prompt, plan-issue, agent-pr-workflow ×3, agent-pr-ready-automerge, engineering-audit; AGENT-OPS contrato item 3) — sem isso o safety-net re-arma `--merge` por cima; `allow_rebase_merge: true` verificado no repo. **`serializes` nomeia o registro** (ex. `serializes: 'docs/plans/'`). Docs: AGENT-OPS (Contrato item 4 + seção "Registries compartilhados"), AGENTS.md bullet, PR template (2 checkboxes), header do agregado, execution-pipeline (passo de registro). Sem migration/access/Consent/UI/schema.
|
||||
|
||||
**Recently resolved (2026-08-12):** **B200** (Issue #704) — encaixes dos cards mobile de `/campanha/municipios` (pós-B196): o card lê como um bloco só. **Barra (chassis omnibox):** form `py-1` → `pt-1 pb-0` + campo `min-h-8` → `min-h-10` + X `size-8` → `size-9` → barra 41 → **45px** (aceite "≈48" do plano — o draft gateado manda: min-h-10 sem voltar ao campo alto do B184); **a causa real do vão entre barra e primeiro card não era o pb do form, e sim o `gap-8` da coluna do shell** (32px — medido ao vivo: form.bottom 100.67 vs card.top 132.67) → `max-md:-mb-8` no `campaignListOmniboxFormClassName` cancela exatamente esse gap (primeiro card colado; demais seções do shell mantêm o ritmo; desktop `md:mb-0` intacto). **Card:** article `gap-2.5` → `gap-2`; nome/território `gap-0` + `leading-tight` no território (vão ≈0–2px, e2e ≤2); chips `gap-y-2` → `gap-y-1.5`; grupos de relação `gap-1.5` → `gap-1`. **Avatares (decisão cara):** o modo `overlapRow` troca as células `flex-1 justify-center` + `overflow-hidden` (origem do "um em cada canto" com 2 e das pontas cortadas com 5+) por **pilha à esquerda com sobreposição medida** — função pura `relationAvatarOverlapPx(count, width)` (`src/lib/relationAvatarOverlap.ts`, unit-testada: min 8px garantido até com 2 avatares, fit exato `28+(n−1)(28−overlap) ≤ W` para qualquer n/viewport, fallback no mínimo para width não-finita) + `ResizeObserver` no grupo (`'use client'` no stack; modo default desktop `-space-x-2`/cap 3 intacto; `overflow-hidden` permanece como guarda de último recurso, nunca ativa no fit). **E2E:** B196 da barra (44–48px + primeiro card colado com limite duplo — nem vão nem card embaixo da barra) e de avatares reescritos (2 avatares levemente sobrepostos à esquerda — a asserção antiga "sem overlap" pinava o bug); novo describe B200 (barra 44–48 + colagem + eixo label/valor nos seis blocos + pilha: mesma linha, distância entre avatares 8–20px — sobreposição mínima E sliver visível, ancorada à esquerda, nada invade o vizinho via fronteira do grupo); **endurecimento anti-flake de medição** nas specs de geometria — wait `S:` settle + footer "1 município encontrado" (o settle sozinho passava com o card mid-stream num layout transiente de célula ~15px — medido via debug) + `expect.poll` 30s de layout único por leitura (o webServer dev sob workers paralelos recarrega página no meio do teste — medições em frames diferentes capturavam estados distintos). Sem migration/access/Consent/schema. Gates: unit 2085 (6 novos), int 748, e2e B196+B200 14/14 (2 repeats) + spec completa 33/34 (única falha B24 — reproduzida **sem** a mudança, flake de ambiente pré-existente; 5 falhas ambientais do 1º run sumiram), build OK, lint/format/cycles OK (knip: erro pré-existente ledgerado P3 do payload.config). Intenção [`municipios-mobile-ajustes-cards.md`](plans/municipios-mobile-ajustes-cards.md); impl [`municipios-mobile-ajustes-cards-impl.md`](plans/municipios-mobile-ajustes-cards-impl.md).
|
||||
|
||||
**Recently resolved (2026-08-12):** **Remoção do `migration-lock`** (CI) — o check de `ci-pr.yml` que falhava quando >1 PR aberto tocava `src/migrations/`/`payload-types.ts` foi **removido** (deadlock de CI: com 2 PRs de schema abertos, AMBOS falhavam o check e nenhum mergeava sem bypass manual — 9 de 13 runs de CI falhos desde 11/08 foram por isso). A ameaça que ele serializava (cadeia de migrations com drift de snapshot) já é coberta pelo CI em todo PR e na main: `pnpm migrate` + `test:int` (incl. `campaignMigrationReconciliation.int.spec.ts`, checksum do schema migrado vs config); o conflito real (index.ts/payload-types.ts) resolve no rebase. Removido: job `migration-lock` do `ci-pr.yml` + `needs` do rollup `checks` + contexto required da branch protection (`pnpm configure:branch-protection` agora aplica só `checks`); pool mantém a serialização de spawn de issues `needs:migration` (`countOpenSchemaPrs` em `agent-pool-github.mjs` — independe do CI). Docs/skills atualizados (AGENT-OPS contrato de PR, GUARDRAILS, engineering-standards, agent-pool, work-issue, agent-pr-workflow). Sem migration/access/Consent/UI/schema.
|
||||
|
|
|
|||
231
docs/campanha/plano-site-campanha-2026.md
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
# Plano Geral — Site de Campanha Jorge Solla 1313 (2026)
|
||||
|
||||
> **Natureza deste documento:** plano **geral** do site de campanha (não é um
|
||||
> plano de issue comum). Ele registra o contexto, as decisões de produto,
|
||||
> design, conversão e engenharia, e as pendências. **A partir dele** serão
|
||||
> gerados os planos de issue (`docs/plans/`) quando a equipe estiver pronta
|
||||
> para implementar.
|
||||
>
|
||||
> Status: **rascunho de design/conversão em colaboração** (15/08/2026).
|
||||
> Domínio de publicação: `jorgesolla1313.com.br` (vertical pública do Teqo).
|
||||
|
||||
---
|
||||
|
||||
## 1. Objetivo único da página
|
||||
|
||||
**Captar apoiador** — nome + WhatsApp + cidade — na reta final da campanha
|
||||
(eleição: **04/10/2026**, 1º turno; hoje, 15/08, faltam ~50 dias).
|
||||
|
||||
- CTA primário: **WhatsApp com mensagem pré-configurada** (`wa.me`) e
|
||||
formulário de 3 campos no CTA final.
|
||||
- Doação é canal **secundário** (link para `apoiar.me/jorgesolla`, homologado
|
||||
TSE) — o site nunca processa pagamento.
|
||||
|
||||
## 2. Faseamento (macro)
|
||||
|
||||
| Fase | Escopo |
|
||||
| ------ | --------------------------------------------------------------------------------------------------------- |
|
||||
| **v1** | Página única (landing) conforme wireframe — captação de apoiador + prova social + board IG/YT + CTA final |
|
||||
| **v2** | Compartilhamento por seção (ver §7) + páginas próprias de proposta (SEO/AEO) |
|
||||
| **v3** | (a definir: agenda/eventos, abaixo-assinados integrados, etc.) |
|
||||
|
||||
## 3. Estrutura da página (10 seções — wireframe)
|
||||
|
||||
1. Header fixo (logo + 1313 + CTA âncora "Quero apoiar")
|
||||
2. Hero (quem é + cargo + número + slogan "Um mandato do tamanho da Bahia" + CTA WhatsApp)
|
||||
3. Prova social numérica (3 números verificados)
|
||||
4. O problema (o que está em jogo no Congresso)
|
||||
5. Bandeiras (6 cards — sem link "ler proposta", decisão do cliente; cada
|
||||
bandeira vira página própria de SEO/AEO na v2)
|
||||
6. Quem é Jorge Solla (linha do tempo + **etiquetas de esfera** + formação e militância)
|
||||
7. Acompanhe de perto (board de conteúdo IG + YouTube, bento 1 grande + 4 pequenos)
|
||||
8. Depoimentos reais (NEEDS ASSET)
|
||||
9. CTA final + formulário apoiador (3 campos) + doação secundária
|
||||
10. Rodapé (identificação eleitoral, redes, privacidade)
|
||||
|
||||
Referência visual: [`wireframe-solla-1313.html`](./wireframe-solla-1313.html)
|
||||
(mesmo diretório). Variantes de hero A/B/C documentadas no fim do arquivo.
|
||||
|
||||
## 4. Decisões registradas
|
||||
|
||||
### 4.1 Produto e conversão (doutrina de campanha 2026)
|
||||
|
||||
1. **Um CTA primário por página**; nunca dois de peso igual acima da dobra.
|
||||
2. **Fase define o CTA**: na reta final, captar apoio primeiro; doação secundária.
|
||||
3. **Formulário mínimo**: nome + WhatsApp + cidade; coleta progressiva; cada
|
||||
campo acima de 3 derruba conversão. **Nunca CPF/endereço na 1ª interação.**
|
||||
4. **LGPD**: consentimento explícito (checkbox) + link de privacidade;
|
||||
consent por stable key (padrão do Teqo: `apoiador-cadastro`,
|
||||
`apoiador-intencao-voto` — fail-closed).
|
||||
5. **WhatsApp com mensagem pré-configurada** = elemento de maior conversão em
|
||||
sites políticos brasileiros.
|
||||
6. **Mobile-first** (maioria do tráfego é celular): inputs ≥16px (evita zoom
|
||||
iOS), alvos de toque ≥44px, carregamento <3s.
|
||||
7. **Prova social com fonte**: números verificados na Câmara (13/08/2026):
|
||||
3.333 proposições (API Dados Abertos), 1.031 discursos (SitaqWeb), 3º
|
||||
mandato. "Sem fonte, não publica."
|
||||
8. **Urgência ética**: só contagem regressiva real da eleição (04/10/2026).
|
||||
9. **Diferencial central**: gestão nas três esferas (município → estado →
|
||||
União) — explícito no hero e na seção "Quem é" (lead + etiquetas de esfera
|
||||
na linha do tempo). Não há seção separada "diferencial" (decisão do cliente).
|
||||
10. **Formação** (verificada): médico UFBA, mestre em Saúde Coletiva (UFBA),
|
||||
doutor em Clínica Médica (UFRJ), pesquisador do ISC-UFBA.
|
||||
11. **Militância** (verificada): um dos fundadores do PT na Bahia, filiado
|
||||
desde 1980 (46 anos de partido), militante do SUS.
|
||||
12. **Depoimentos sempre reais**, com nome completo e cidade — nunca inventar.
|
||||
13. **Identificação eleitoral obrigatória** no rodapé: nome completo, nº 1313,
|
||||
federação (PT/PCdoB/PV), CNPJ da campanha.
|
||||
14. **Copies revisados pelo agente solla-comunicacao (15/08/2026)** — decisões:
|
||||
- h1 usa o slogan oficial do mandato: **"Um mandato do tamanho da Bahia"**
|
||||
(presença no estado todo + amplitude saúde/educação; "Saúde é direito,
|
||||
não mercadoria" era bandeira comum a qualquer candidato do campo, não
|
||||
diferenciava).
|
||||
- "Saúde é direito, não mercadoria" **reaproveitada** como frase de abertura
|
||||
do card de proposta Saúde (a bandeira central não morre, desce do hero
|
||||
para o lugar onde o trabalhador da saúde procura).
|
||||
- Sub do hero reescrito para amplitude: feitos verificados + "leva o
|
||||
mandato aos 417 municípios, da saúde à educação".
|
||||
- Removido "SUS atende 8 em cada 10 brasileiros" (sem fonte no mandato —
|
||||
regra: sem fonte, não publica).
|
||||
- Variantes B/C ajustadas para tom factual ("Tem gente em Brasília
|
||||
querendo acabar com o SUS…" em vez de "O Congresso quer…").
|
||||
15. **Regra de narrativa do momento (decisão do cliente, 15/08/2026)**: o
|
||||
governo atual é do PT e o candidato é do PT — a crítica ao momento existe
|
||||
para mostrar a luta por melhorar, mas **sempre pontuada pelo
|
||||
reconhecimento do que melhorou com Lula**. Enquadramento padrão:
|
||||
**avanço (reconhecimento) → obstáculo estrutural → por que a eleição
|
||||
importa**. O "vilão" nunca é o governo atual: são os limites fiscais
|
||||
herdados (teto de gastos da direita, o campo político de Temer) e um
|
||||
Congresso sem maioria aliada.
|
||||
Aplicado nos cards "Saúde subfinanciada" (Nova PAC R$ 30,5 bi + Mais
|
||||
Médicos retomado antes do problema), "Jornada que adoece" (vitória da
|
||||
bancada de Lula na Câmara contra a direita → briga no Senado, risco de
|
||||
adiamento de 10 anos) e "Mataripe nas mãos de estrangeiros" (título antigo
|
||||
"Bahia entregue ao atraso" rejeitado — ambiguidade de leitura "entregue
|
||||
pelo PT"; versão curta escolhida pelo cliente). TÍTULOS EM NOTAÇÃO DE
|
||||
BANDEIRA POSITIVA (decisão do cliente, 15/08): "Por um SUS com recursos!",
|
||||
"Pelo fim da escala 6x1!", "Pela recompra de Mataripe!" — três aberturas
|
||||
diferentes (Por um / Pelo fim / Pela) para não repetir construção na
|
||||
grade. Título da seção: "Eleger deputado é coisa séria. O Congresso tem
|
||||
nas mãos vidas reais e o SUS."
|
||||
16. **Skill "humanize-ai-writing" instalada (15/08/2026)** em
|
||||
`~/.config/opencode/skills/humanize-ai-writing/` (fonte: github.com/haidrrrry/humanize-ai-writing,
|
||||
baseada no catálogo da Wikipedia "Signs of AI writing"). Passada final de
|
||||
humanização aplicada ao wireframe: 12 travessões de copy → ponto/dois-pontos
|
||||
(restam só os 2 aprovados + travessão legal TSE + placeholders de API);
|
||||
bullets "✔" → lista nativa (acessibilidade); zero vocabulário banido, zero
|
||||
tom promocional, zero conclusões ocas. Voz do mandato tem prioridade sobre
|
||||
as regras genéricas (zona cinza validada: "Saúde é direito, não mercadoria",
|
||||
"Reeleger Lula não basta…", "Médico, gestor, deputado", aspas tipográficas
|
||||
em depoimentos — todas mantidas de propósito).
|
||||
|
||||
### 4.2 Engenharia (stack Teqo)
|
||||
|
||||
- **Formulário apoiador** → segue o padrão do Teqo: `Contact` normalizado +
|
||||
join (ex.: `supporter`) + `Consent` por stable key; escrita transacional
|
||||
(`payload.db.beginTransaction` + `req.transactionID`); revalidação de cache
|
||||
via `afterChange`.
|
||||
- **Select de cidade** usa os dados existentes (`src/lib/cities.ts` /
|
||||
`municipalityCatalog.ts` — 417 municípios, Salvador por zona eleitoral).
|
||||
- **Board IG + YT** (decidido em 15/08):
|
||||
- Clique **abre direto na plataforma** (sem lightbox).
|
||||
- **YouTube automático**: Data API v3 (API key + channel ID no admin),
|
||||
server-side, cache ISR + revalidate periódico, thumbnails CDN, sem iframe
|
||||
no load.
|
||||
- **Instagram automático**: Instagram Graph API (conta Business/Creator
|
||||
vinculada a página do Facebook + app Meta for Developers com
|
||||
`instagram_basic` + token long-lived com refresh automático ~60 dias).
|
||||
- **Config no admin**: global do Payload `SocialFeedSettings` — YouTube API
|
||||
key, channel ID, IG access token, IG user ID, máx. itens, toggle por
|
||||
plataforma, "pausar feed" (kill switch — não é curadoria).
|
||||
- **Fail-closed**: API falhou/token expirou → mantém último snapshot em
|
||||
cache; página nunca quebra. IG só liga após setup da Meta (review leva dias).
|
||||
- **Nunca** script de embed pesado do Instagram no carregamento (derruba
|
||||
LCP no mobile).
|
||||
|
||||
## 5. Pendências (roteamento)
|
||||
|
||||
| Pendência | Roteamento |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
||||
| Número de WhatsApp oficial da campanha (placeholder `5571999999999`) | Assessoria |
|
||||
| CNPJ da campanha (rodapé) | Advogado eleitoral |
|
||||
| Depoimentos reais (3, nome + cidade + foto) | Assessoria |
|
||||
| Foto hero 4:5 + foto de apoio (multidão/caravana) | Produção |
|
||||
| Contador de apoiadores? (se exibir, fonte = banco real, nunca inventar) | Coordenação |
|
||||
| Confirmar "50 dias" na data de publicação (contagem com data fixa) | Assessoria |
|
||||
| **Doutorado sanduíche em Durham** — não consta nas fontes atuais (doutorado = UFRJ, 2009); se confirmado, entra na Formação | Verificação com assessoria |
|
||||
| **"Professor da UFBA"** — fonte atual diz "pesquisador do ISC-UFBA" | Verificação com assessoria |
|
||||
| **Mix mandato/campanha no board**: automático expõe tudo que a conta postar; se @depjorgesolla postar conteúdo de mandato no período eleitoral, decide-se: aceitar mix, filtrar por tag/hashtag, ou usar conta de campanha | Assessoria |
|
||||
| Variante de hero (A ativa; B/C documentadas) + plano de A/B | Coordenação + este plano |
|
||||
| **"Teto de gastos" vs "arcabouço fiscal"**: o teto (EC 95/2017, governo Temer) foi substituído pelo Novo Arcabouço Fiscal (LC 200/2023). O copy aplicado usa "teto de gastos da direita" (decisão do cliente, 15/08 — culpa o campo político de Temer, amarrando à eleição atual, em vez do inimigo específico antigo); a imprecisão jurídica do instrumento segue registrada para checagem da assessoria/advogado antes do go-live | Assessoria + advogado eleitoral |
|
||||
| **Status processual da pauta 6×1** (card "Jornada que adoece"): o copy afirma que o fim da 6×1 foi aprovado na Câmara (derrotando a direita) e está no Senado, com risco de modificação/adiamento de 10 anos. Confirmar com a assessoria o estágio exato (nº da proposta, o que foi votado, prazo proposto pela direita) antes do go-live — sem fonte, não publica | Assessoria |
|
||||
|
||||
## 6. Regras inegociáveis (vale para qualquer issue derivada)
|
||||
|
||||
- Sem fonte, não publica (número, obra, citação, depoimento).
|
||||
- Um CTA por página; nunca dividir atenção acima da dobra.
|
||||
- LGPD: consentimento explícito, fail-closed; nunca CPF/endereço no 1º passo.
|
||||
- Doação só via QueroApoiar; o app nunca processa pagamento.
|
||||
- Nada de fake news, ataques pessoais ou desinformação (combate com fatos).
|
||||
- Nunca inventar foto, depoimento, apoiador, selo ou cobertura (NEEDS ASSET).
|
||||
- Período eleitoral: mecanismo `hidden`/`isPostVisible` para puxar conteúdo
|
||||
quando exigido; site de mandato e de campanha não se misturam sem orientação.
|
||||
- Convenções do Teqo: identificadores em inglês, transações, migrações
|
||||
commitadas, revalidação de cache, admin em pt.
|
||||
|
||||
## 7. v2 — ideias registradas (não priorizadas)
|
||||
|
||||
### 7.1 Compartilhamento por seção (ideia do cliente, 15/08/2026)
|
||||
|
||||
Cada subseção vira algo compartilhável pelo visitante nas redes sociais:
|
||||
|
||||
- **WhatsApp com mensagem pré-configurada por seção** — ex.: "Olha a proposta
|
||||
do Jorge Solla para o fim da escala 6×1: [link]". O WhatsApp é o canal de
|
||||
compartilhamento nº 1 no Brasil — mesma lógica do CTA primário.
|
||||
- **Imagem OG por seção**: o preview do link no WhatsApp é o que vende o
|
||||
clique — gerar card/imagem por seção (proposta, trajetória, depoimento).
|
||||
- **Botões de compartilhar discretos por card**, nunca competindo com o CTA
|
||||
primário da página.
|
||||
- **UTM por seção** para medir qual conteúdo mais circula — vira insumo de
|
||||
conteúdo para a reta final (fechar o loop com a assessoria).
|
||||
- Seções candidatas: cards de proposta (maior valor prático/currency),
|
||||
trajetória (prova), depoimentos (voz de terceiros), board IG/YT.
|
||||
|
||||
### 7.2 Páginas próprias de bandeira (SEO/AEO)
|
||||
|
||||
Cada card de bandeira vira página própria ("fim da escala 6x1", "recompra de
|
||||
Mataripe", "saúde na Bahia") — são buscas reais; structured data de entidade
|
||||
(Person, PoliticalParty, Office).
|
||||
|
||||
## 8. Próximos passos
|
||||
|
||||
1. Revisão humana do wireframe (seções, textos, variantes de hero).
|
||||
2. Resolver pendências de conteúdo (assessoria/advogado) — bloqueiam go-live.
|
||||
3. Quando a equipe estiver pronta: **gerar planos de issue a partir deste
|
||||
documento** (cada seção/d decisão vira um `docs/plans/` + Issue).
|
||||
4. Testes A/B de uma variável por vez (título, CTA, foto, formulário) com
|
||||
7–14 dias de medição.
|
||||
|
||||
## Anexo — Mapa de fotos por subseção (levantamento 15/08/2026)
|
||||
|
||||
> Fotos no jorgesolla.com.br são ativos da campanha (uso seguro). Fotos de
|
||||
> terceiros (Agência Brasil, Bnews, A TARDE) precisam de autorização. Banco
|
||||
> local: `/home/fsolla/Documentos/Solla/MATERIAL SOLLA/FOTOS/SELEÇÃO/` (52 fotos JOA\*.jpg).
|
||||
|
||||
| Subseção | Tema | Fotos candidatas (link) | Nota |
|
||||
| -------------------------- | ------------------ | ------------------------------------------------------------------------------------- | ------------------------------------ |
|
||||
| Hero (retrato) | Retrato 4:5 | `jorgesolla.com.br/wp-content/uploads/2026/05/SOLLA-CARD.jpg` (via artigo Clube 2004) | Retrato vertical, ideal p/ hero |
|
||||
| Hero/aliança (alternativa) | Lula+Jerônimo+time | `…/2026/08/PT-CONVENCAO.jpg` (artigo convenção 02/08) | Multidão/time |
|
||||
| Saúde (card + proposta) | Hospital | `…/2026/07/IMG_1672.jpeg` (artigo Hospital Litoral Norte) | Inauguração |
|
||||
| Saúde (trabalhadores) | Piso enfermagem | `…/2026/05/PISO-ENFER-II-foto-Marcelo-Camargo-Agencia-Brasil.jpg` | ⚠️ Foto Agência Brasil — autorização |
|
||||
| Jornada 6×1 | Multidão subúrbio | `…/2026/06/PGP-SUBURBABANA.jpeg` (artigo PGP Periperi) | Multidão (não específica 6×1) |
|
||||
| Jornada 6×1 (externo) | Coletiva | bnews.com.br (foto Henrique Brinco) e atarde.com.br | ⚠️ Terceiros — referência |
|
||||
| Mataripe | — | Nenhuma foto do Solla nos artigos (só fundo genérico) | Usar banco local ou produzir |
|
||||
| Educação | FAMED UFBA | `…/2026/05/IMG_0638.jpeg` (artigo visita CFFC/FAMED) | Educação + saúde |
|
||||
| Renda | Pacote R$ 2 bi | `…/2026/06/GOVBA-PACOTE-2-BI-1024x683.jpeg` | Verificar presença do Solla |
|
||||
| Democracia | 2 de Julho | `…/2026/07/2-de-julho.jpg` | Data cívica |
|
||||
| Quem é (timeline) | Históricas | Não encontradas em artigos atuais | Banco local / arquivo do mandato |
|
||||
| Prova de trabalho | Plenária Câmara | `…/2026/08/PLENARIA-SOLLA.jpeg` e `…/2026/08/PLENARIA.jpg` (artigo 11/08) | Solla em plenária |
|
||||
| CTA final (multidão) | Caravana | `…/2026/07/PHOTO-2026-07-31-13-37-26.jpg` e `…-1.jpg` (artigo Chapada) | 2 fotos |
|
||||
| CTA final (interior) | Ubatã | `…/2026/06/2e00ab79-13ba-4b39-86e4-52d894c6ddd2.jpeg` (artigo mercado Ubatã) | Inauguração |
|
||||
| Board IG/YT | — | Vem da API (sem foto fixa) | — |
|
||||
148
docs/campanha/prompt-montagem-home.md
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
# Prompt — Montar a home pública de campanha (Jorge Solla 1313)
|
||||
|
||||
> Use este prompt com um agente **poderoso (visão + raciocínio)** para montar a
|
||||
> home pública da campanha a partir do rascunho Penpot e do wireframe HTML.
|
||||
> Você tem acesso ao **MCP do Penpot** (já configurado) e pode ler imagens.
|
||||
|
||||
---
|
||||
|
||||
## 1. Contexto
|
||||
|
||||
Você vai construir a **página inicial pública de campanha** do Deputado Federal
|
||||
**Jorge Solla (PT-BA)**, nº **1313**, para o domínio `jorgesolla1313.com.br`.
|
||||
O app é o **Teqo** (Next.js + Payload), monorepo; a home vive em
|
||||
`src/app/(frontend)/(home)/`. A home foi **zerada** (placeholder) — você vai
|
||||
substituí-la. A rota `/artigos` já existe (feed de notícias movido da home
|
||||
antiga) — **não mexa nela**.
|
||||
|
||||
## 2. Fontes de verdade (leia TODAS antes de codar)
|
||||
|
||||
1. **Rascunho Penpot (o SPEC visual)** — acesse via MCP do Penpot:
|
||||
- Team: `369311f5-bdaf-8185-8008-54047a2d029c`
|
||||
- File: `8694f143-a620-8054-8008-66e8aa584028`
|
||||
- Page: `62dfa60b-a5ec-8097-8008-7cc15cc939bd` ("Page 2")
|
||||
- Use `penpotUtils` (getPageById, shapeStructure, dump de geometria x/y/w/h,
|
||||
cores, fontes) para extrair o layout exato. Há 2 boards: **desktop
|
||||
1024×1954** e **mobile 393×2365**. Referências exportadas também em:
|
||||
`/home/fsolla/Downloads/Board(2).png` (desktop) e
|
||||
`/home/fsolla/Downloads/Board(1).png` (mobile).
|
||||
2. **Wireframe HTML** (draft de conversão): `docs/campanha/wireframe-solla-1313.html`
|
||||
3. **Plano geral** (decisões, pendências, regras): `docs/campanha/plano-site-campanha-2026.md`
|
||||
4. **Voz do mandato**: skill `solla-comunicacao` (carregue antes de escrever).
|
||||
|
||||
## 3. Estado atual do repo (já pronto — REUSE, não recrie)
|
||||
|
||||
- **Fontes** já carregadas no layout do frontend: `--font-exo2` (Exo 2), `--font-arimo` (Arimo), `--font-sans` (Inter). Use via `font-[family-name:var(--font-exo2)]`.
|
||||
- **Tokens** `campaign-site` já em `src/app/(frontend)/styles.css`:
|
||||
`--pt-red:#a21c1c`, `--pt-red-dark:#47130e`, `--pt-yellow:#ffe607`,
|
||||
`--pt-yellow-ink:#000`, `--campaign-cream:#fff8f2`, `--campaign-ink:#000`,
|
||||
`--campaign-muted`, `--campaign-surface:#f9faff`, `--campaign-band:#ebe9e9`.
|
||||
Aplicados via `data-theme="campaign-site"` no layout da home.
|
||||
- **Assets** em `public/` (.avif): `JOA00162.avif` (foto hero), `fundo.avif`,
|
||||
`53569851134_02afc18fb4_o.avif`, `52396285023_561ffc0ff6_o.avif` (cards),
|
||||
`Lula.avif`, `Jeronimo.avif`, `WAGNER%20-%202-9%20final.avif`,
|
||||
`RUI%20-%202-2.avif` (aliados), `LOGO_SOLLA_BRANCO.svg` (logo branca).
|
||||
- **Componente** `src/components/CampaignFooter.tsx` (rodapé do wireframe, CNPJ
|
||||
68.430.467/0001-05 já aplicado) — pode usar ou refazer.
|
||||
- Layout atual da home: `src/app/(frontend)/(home)/layout.tsx` (container de
|
||||
scroll + data-theme) — ajuste se precisar.
|
||||
|
||||
## 4. O que montar (as 4 seções do Penpot + rodapé)
|
||||
|
||||
### 4.1 Hero
|
||||
|
||||
- Fundo vermelho `#a21c1c`. **Sem header separado** — a logo branca vive DENTRO
|
||||
do hero (topo esquerdo). **Sem barra fixa**.
|
||||
- Desktop: **foto à esquerda** (retrato JOA00162) + **colagem de 4 aliados**
|
||||
(Lula, Jerônimo, Wagner, Rui) + **texto à direita ALINHADO À DIREITA**.
|
||||
- Mobile: foto em cima, texto centralizado embaixo.
|
||||
- H1: `UM MANDATO DO TAMANHO DA BAHIA` (caixa alta, Exo 2, branco).
|
||||
- Sub: `Médico sanitarista. Criou o SAMU 192 e o Brasil Sorridente. Já comandou a saúde em Vitória da Conquista, na Bahia e no Brasil — e leva o mandato aos 417 municípios, da saúde à educação.`
|
||||
- Botões: `Conhecer bandeiras` (contorno branco) + `Quero apoiar` (amarelo
|
||||
`#ffe607`, texto preto) → **https://apoiar.me/jorgesolla** (vaquinha, CTA primário).
|
||||
- Micro-provas: `DIAP entre os 40 melhores da Câmara` · `Mais votado do PT-BA em 2022`.
|
||||
|
||||
### 4.2 Prova social
|
||||
|
||||
- 3 números grandes centralizados, vermelho: `3.333 proposições apresentadas`,
|
||||
`1.031 discursos em Plenário`, `3º mandato de deputado federal`.
|
||||
|
||||
### 4.3 O problema
|
||||
|
||||
- Fundo `#47130e`. Eyebrow amarelo `POR QUE ESSA ELEIÇÃO IMPORTA`.
|
||||
- H2: `Eleger deputado é coisa séria` / `O Congresso tem nas mãos vidas reais e o SUS` (2ª linha amarela).
|
||||
- Lead: `É no Congresso que se define o orçamento do SUS, o piso da enfermagem, a recompra de Mataripe e o fim da escala 6×1. Reeleger Lula não basta: é preciso eleger uma bancada aliada.`
|
||||
- 3 cards **em CARROSSEL** (auto-advance a cada ~4s, pausa no hover/touch;
|
||||
swipe no mobile). Cada card: foto no topo + texto branco sobreposto embaixo,
|
||||
cantos arredondados. O carrossel mostra UM card por vez (mobile) e pode
|
||||
mostrar mais de um no desktop se couber — mas o auto-advance e o indicador
|
||||
ativo valem para todos. Navegação: setas opcionais + indicadores (bolinhas)
|
||||
se fizer sentido visualmente; o essencial é o auto-advance:
|
||||
1. `Pelo fim da escala 6x1!` / foto `fundo.avif` / `Jornadas longas aumentam o risco de AVC e infarto. Descanso é saúde pública. A bancada de Lula derrotou a direita na Câmara: o fim da 6×1 avançou. Mas a briga continua no Senado, onde a direita tenta barrar o avanço. No dia 4 de outubro, o 1313 é o seu sim ao descanso.`
|
||||
2. `Pra valorizar o SUS` / foto `53569851134_02afc18fb4_o.avif` / `O SUS é o sistema de saúde de todo brasileiro. Com Lula, a saúde voltou a receber recursos: Nova PAC de R$ 30,5 bilhões e Mais Médicos retomado. Mas o teto de gastos da direita ainda trava o orçamento. O 1313 é seu voto em defesa do SUS no Congresso!`
|
||||
3. `Pra defender os baianos` / foto `52396285023_561ffc0ff6_o.avif` / `A Refinaria de Mataripe foi vendida no governo Bolsonaro e segue nas mãos de estrangeiros. Com Lula e Jerônimo, a Bahia voltou a andar pra frente; mas recomprar Mataripe exige bancada forte no Congresso. Votar 1313 é devolver à Bahia o que é seu.`
|
||||
|
||||
### 4.4 Bandeiras
|
||||
|
||||
- Fundo `#ebe9e9`. Eyebrow vermelho `NOSSA CAMINHADA`.
|
||||
- H2: `Junto com o trabalhador e do lado de quem mais precisa, sempre.`
|
||||
- Lead: `Não é promessa de palanque, é a experiência de quem já fez na gestão do SUS, do Ministério da Saúde e da saúde da Bahia.`
|
||||
- **CARROSSEL de 6 cards** (auto-advance a cada ~4s, pausa no hover/touch,
|
||||
swipe no mobile) + **fileira de chips (as 6 tags) ACIMA dos cards** — o chip
|
||||
do card ATIVO fica DESTACADO (1ª vermelha `#a21c1c`; demais cinza
|
||||
`#dbdce0`), e o destaque acompanha o card visível no carrossel (sincronizado;
|
||||
clicar num chip leva ao card correspondente). Cards brancos `#f9faff`
|
||||
(1 por vez no mobile; no desktop pode mostrar mais de um), título + corpo
|
||||
(Arimo):
|
||||
1. `Defender o SUS e valorizar quem cuida` / `Saúde é direito, não mercadoria. Fim do subfinanciamento, piso da enfermagem e dos agentes pagos, concursos públicos, vacinação e ciência.`
|
||||
2. `Fim da escala 6×1 e jornada de 40h` / `Sem redução de salário. Jornada longa é questão de saúde pública: quem trabalha demais adoece. O SUS paga a conta.`
|
||||
3. `Educação em tempo integral e federais no interior` / `IFs, campus federal, escola de tempo integral: o interior não pode ficar para trás no conhecimento.`
|
||||
4. `Recomprar a Refinaria de Mataripe` / `Recomprar a refinaria é defender a Bahia e a soberania do Brasil. Preço justo de combustível é política de saúde e de renda.`
|
||||
5. `Salário mínimo forte, emprego e moradia` / `Valorização do mínimo, Bolsa Família, Minha Casa Minha Vida e agricultura familiar como motor do interior.`
|
||||
6. `Defesa intransigente da democracia` / `Participação popular, instituições fortes e combate à desinformação. Eleger o parlamento é coisa séria.`
|
||||
|
||||
### 4.5 Rodapé
|
||||
|
||||
- Use o `CampaignFooter` existente ou o rodapé do wireframe: identificação
|
||||
eleitoral (nome, nº 1313, Federação PT/PCdoB/PV, **CNPJ 68.430.467/0001-05**,
|
||||
eleições 04/10/2026), navegação, redes.
|
||||
|
||||
## 5. Decisões e regras (não negocie)
|
||||
|
||||
- **Um CTA primário** por tela (Quero apoiar → apoiar.me/jorgesolla). Doação
|
||||
nunca é processada no app.
|
||||
- **Carrosséis**: as seções "O problema" e "Bandeiras" usam carrossel com
|
||||
**auto-advance** (timer ~4s), pausa no hover/touch, swipe no mobile e
|
||||
sincronização com os indicadores/chips. Componente client ("use client").
|
||||
- **Mobile-first**; alvos de toque ≥44px; inputs ≥16px (quando houver).
|
||||
- **Tipografia**: Exo 2 (display: H1, CTAs, números, eyebrows), Inter (corpo,
|
||||
sub, micro-provas), Arimo (títulos/textos dos cards, tags em caixa alta).
|
||||
- **Copy**: use EXATAMENTE os textos acima (do Penpot). Correções já feitas:
|
||||
"mandato" (não "madato"), "O Congresso" (maiúsculo). Mantenha "pra frente",
|
||||
"Pra valorizar o SUS", "Pra defender os baianos" (escolhas do cliente).
|
||||
- **Uniformize** espaçamentos/cores (escala única); não precisa replicar cada
|
||||
pixel do Penpot, mas a COMPOSIÇÃO (foto esq + texto dir, seções, cards,
|
||||
chips) deve casar.
|
||||
- **Sem fonte, não publica**: não invente números/obras. Tudo acima é verificado.
|
||||
- **Convenções Teqo**: identificadores em inglês, textos visíveis em pt-BR.
|
||||
- Não criar coleções/rotas paralelas; não mexer em `/artigos`.
|
||||
|
||||
## 6. Como validar (obrigatório antes de entregar)
|
||||
|
||||
1. Extraia a geometria do Penpot via MCP e confira sua implementação contra ela
|
||||
(posições, alinhamentos, cores, fontes).
|
||||
2. Suba `pnpm dev`, capture screenshots (desktop 1024 e mobile 393) **por seção**
|
||||
(elemento, não fullPage — o fullPage trunca por causa do scroll aninhado).
|
||||
3. Use os subagentes `design-vision` / `design-vision-fidelidade` para conferir
|
||||
a implementação contra as referências `/home/fsolla/Downloads/Board(1|2).png`.
|
||||
Confira também o **comportamento dos carrosséis** (auto-advance, chip ativo
|
||||
sincronizado) com o Playwright (aguarde o timer avançar e valide o estado).
|
||||
4. Rode: `pnpm exec tsc --noEmit`, `pnpm lint`, `pnpm format:check`, `pnpm build`.
|
||||
5. Entregue um resumo: o que foi construído, como ficou vs. o Penpot, e o que
|
||||
ficou pendente (assets/fontes/ajustes).
|
||||
|
||||
## 7. Entregável
|
||||
|
||||
- Home em `src/app/(frontend)/(home)/page.tsx` (+ layout/componentes se precisar),
|
||||
fiel ao Penpot, validada (build OK), com os 4 seções + rodapé.
|
||||
- Resumo curto do que foi feito e das pendências.
|
||||
1519
docs/campanha/wireframe-solla-1313.html
Normal file
1
docs/changelog/2026-08-13-ops44.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
**Recently resolved (2026-08-13):** **OPS44** (Issue #713) — redução de conflitos de merge em arquivos compartilhados. **Changelog por entrega:** cada entrega escreve `docs/changelog/<data>-<id>.md` (uma entrada, imune a conflito por construção) e `pnpm changelog:build` regenera o agregado `docs/CHANGELOG-AGENTS.md` de forma **insert-only** (nunca remove/reescreve entradas; histórico não migrado) — libs puras `scripts/lib/changelog.mjs` (parse/sort fail-closed, split do header, build idempotente, `assertChangelogAppendOnly` multiset) e `scripts/lib/conflictMarkers.mjs` (regex compartilhada com o guard OPS41); CLIs `scripts/build-changelog.mjs` (com `--check`), `scripts/check-changelog-append-only.mjs` e `scripts/check-docs-conflict-markers.mjs`; job **`docs-guards`** no `ci-pr.yml` (append-only do agregado + additions-only em `docs/changelog/` + zero marcadores de conflito em diffs de `docs/` — cobre PRs docs-only onde a suíte unit não roda, a classe do incidente OPS41); escape documentado `changelog-rewrite: <motivo>` no PR body (linha própria; definição canônica em AGENT-OPS, precedente de restauração D8; usado pela própria entrega — header do agregado mudou). **Merge por rebase em 7 pontos** (`--auto --rebase` em vez de `--auto --merge`: execution-pipeline, agent-pool-prompt, plan-issue, agent-pr-workflow ×3, agent-pr-ready-automerge, engineering-audit; AGENT-OPS contrato item 3) — sem isso o safety-net re-arma `--merge` por cima; `allow_rebase_merge: true` verificado no repo. **`serializes` nomeia o registro** (ex. `serializes: 'docs/plans/'`). Docs: AGENT-OPS (Contrato item 4 + seção "Registries compartilhados"), AGENTS.md bullet, PR template (2 checkboxes), header do agregado, execution-pipeline (passo de registro). Sem migration/access/Consent/UI/schema.
|
||||
1
docs/changelog/2026-08-15-img-resize.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
**Recently resolved (2026-08-15):** **IMG-RESIZE** — otimizador local de imagens para o draft do site de campanha (fotos pesadas travavam o PenPot). `pnpm images:resize` (`scripts/resize-images.mjs`) aceita múltiplos paths (arquivos ou pastas, varridas recursivamente), aplica EXIF-rotation, remove metadados e gera **DUAS versões por padrão com largura por formato**: `.avif` em **3840px (2× tela desktop, quality 60)** para o site, e `.webp` em **1920px (1×, quality 75 — ¼ dos pixels)** para PenPot/navegadores antigos, sem upscaling (`fit: 'inside'`); conjunto/qualidade/pasta via `--format avif,webp` / `--quality` / `--out` (default `public/`), `--max-width` sobrepõe todos. **`--remove-bg`** remove o fundo com IA 100% local (`@imgly/background-removal-node`, onnxruntime; 1ª execução baixa o modelo ~40 MB, depois cache; intermediário PNG explícito — o pacote 1.4.5 não faz sniffing de magic bytes e morre com blob sem `type`); jpeg (sem alpha) é achatado em branco. **`pnpm images:fill`** (`scripts/fill-image.mjs`) completa/corrige regiões com **FLUX-2-dev no DeepInfra** (`DEEPINFRA_API_KEY` no `.env.local`): `--extend <px|%>` cresce o canvas pela base, preenche a faixa de branco e gera a máscara dela sozinho (foto de Lula cortada no peito sem espaço abaixo — o caso de uso), ou `--mask <png>` para inpaint arbitrário (branco = regenerar, preto = manter); prompt default pronto para completar corpo, `--steps` (default 28, guidance 30), máscara enviada no **canal alpha do PNG** (transparente = regenerar — convenção FLUX-2 nativa; descobrimos na marra que o wrapper OpenAI-images/edits do DeepInfra **ignora o `size` e sempre devolve 1024×1024** — o endpoint **nativo** `/v1/inference/black-forest-labs/FLUX-2-dev` aceita múltiplos de 64 e devolve na mesma dimensão), canvas com padding opaco até múltiplo de 64 (`padToMultipleOf64`) recortado após a geração, **downscale de fotos enormes (27 MP) para orçamento pré-pad de 1.8 MP** — o endpoint nativo recusa >~2 MP e cobra por pixel, master PNG em `data/ai-fill/` (gitignored) e **cadeia o resize (avif+webp) no resultado** via engine compartilhada `runResizeImages` (exportada de `resize-images.mjs` com guard de argv; `--no-resize` corta a cadeia). Derivação pura em `scripts/lib/imageResize.mjs` (parse fail-closed, alias jpg→jpeg, `maxWidthFor`/qualidade por formato) e `scripts/lib/imageFill.mjs` (`parseExtendPx`, `extendedCanvas`, `padToMultipleOf64`, prompts default), unit-testadas em `tests/unit/imageResize.unit.spec.ts` + `tests/unit/imageFill.unit.spec.ts`. Sem migration/access/Consent/UI/schema.
|
||||
101
docs/plans/c134-e2e-agenda-dia-hardcoded-impl.md
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
# Impl: C134 — e2e agenda: dia hardcoded "17 de agosto de 2026" no teste C104 expira
|
||||
|
||||
Status: aprovado
|
||||
Atualizado em: 2026-08-13
|
||||
Issue: #712
|
||||
Intenção: body da Issue (sem plano de intenção linkado — body é a spec)
|
||||
Appetite restante: herdado (correção de teste, escopo mínimo)
|
||||
|
||||
## Leitura da intenção
|
||||
|
||||
- **Outcome:** o teste e2e "cria compromisso 'Todo o dia'" (`campaignActivity.e2e.spec.ts`)
|
||||
não quebra mais deterministicamente ~2026-09: o dia do picker de término é derivado
|
||||
de "hoje" (`formatBahiaCivilDate(new Date()) + delta`), no mesmo padrão do resto do spec.
|
||||
- **O que NÃO negociar:** nada de produto; mudança restrita ao spec de e2e.
|
||||
- **O que reavaliar:** o delta. A intenção pede "+ delta (mesmo padrão do resto do spec)".
|
||||
Hoje o teste não usa `civilDatePlusDays` no C104; o helper existe em
|
||||
`tests/e2e/helpers/agendaPeriodLabels.ts` (usado pelo C95/mobile). A questão real é:
|
||||
o delta precisa manter o dia **dentro do mesmo mês** (comentário atual: "a later day of
|
||||
the same month") ou basta ser **posterior a hoje**?
|
||||
|
||||
## Abordagem recomendada
|
||||
|
||||
**Opções consideradas:**
|
||||
|
||||
- **A — delta fixo +1 derivado de hoje (recomendada):** `endCivil = civilDatePlusDays(formatBahiaCivilDate(new Date()), 1)`,
|
||||
label do botão montado de `ptBrMonthNames` + partes do civil date. Sem navegação de mês no picker.
|
||||
- **B — delta +1 com navegação de mês condicional:** se `endCivil` cai em mês diferente,
|
||||
clicar o botão de próximo mês antes do dia. Mais passos, cobre o caso em que o dia alvo
|
||||
não está no grid — mas o grid do react-day-picker (`showOutsideDays`) **sempre** renderiza
|
||||
o dia 1 do mês seguinte como célula "outside" clicável (seleciona e navega), então B é
|
||||
complexidade sem cobertura adicional.
|
||||
- **C — manter hardcode mas avançar a data:** adia a quebra; não resolve o problema de classe.
|
||||
|
||||
**Recomendação:** A. O picker é react-day-picker v9 (`Calendar` em `ActivityDateTimeField`,
|
||||
`defaultMonth` = mês de hoje; `showOutsideDays=true` renderiza o primeiro dia do mês
|
||||
seguinte como botão clicável no próprio grid — verificado no source do node_modules:
|
||||
`CalendarDay.outside` só marca `data-outside`, não desabilita). Com delta +1 o alvo está
|
||||
**sempre** no grid visível: se hoje não é o último dia do mês, é um dia do próprio mês; se é,
|
||||
vira o dia 1 do mês seguinte na primeira posição da última semana — ainda visível e clicável.
|
||||
O label do botão é date-fns `PPPP` com pt-BR ("segunda-feira, 17 de agosto de 2026") — o
|
||||
regex não-ancorado `/17 de agosto de 2026/` do teste casa contra o subconjunto
|
||||
"dia de mês de ano"; derivamos exatamente esse subconjunto (dia sem zero à esquerda,
|
||||
nome do mês capitalizado de `ptBrMonthNames`, ano). A asserção do trigger
|
||||
(`toHaveText(/17\/08\/2026/)`) vira `dd/mm/aaaa` derivado do mesmo `endCivil`.
|
||||
|
||||
**Rejeitadas:** B (navegação extra sem ganho: o dia alvo sempre está no grid), C (adieta).
|
||||
|
||||
### Componentes / mudanças
|
||||
|
||||
- **`campaignActivity.e2e.spec.ts`** (teste C104, ~linhas 308–315): derivar
|
||||
`endCivil = civilDatePlusDays(formatBahiaCivilDate(new Date()), 1)`; clicar
|
||||
`endPicker.getByRole('button', { name: new RegExp(pickerDayLabel) })` com o label
|
||||
montado de `ptBrMonthNames`; asserir o trigger com o `dd/mm/aaaa` derivado.
|
||||
Atualizar o comentário "same month" → "later day" (pode cruzar mês no último dia).
|
||||
- **Helpers:** nenhum helper novo — `civilDatePlusDays` e `ptBrMonthNames` já existem e
|
||||
estão importados/exportados; a montagem do label é 3 linhas locais no spec (mesmo
|
||||
padrão de `dayLabelFor` do helper — não criar helper novo para 1 uso).
|
||||
- **Migration:** sem migration.
|
||||
- **Access / Consent:** sem mudança.
|
||||
- **UI:** sem mudança.
|
||||
|
||||
## Fases verificáveis
|
||||
|
||||
1. **Spec** — editar o teste C104 no `campaignActivity.e2e.spec.ts`.
|
||||
2. **Verificação** — `pnpm test:e2e campaignActivity` (e2e com db de teste do worktree).
|
||||
3. **Gates** — `tsc --noEmit`, `lint`, `format:check`, `knip` (nenhum símbolo orfanado).
|
||||
|
||||
## Rabbit holes / Não escopo (engenharia)
|
||||
|
||||
- Não tocar nos outros hardcodes de data de e2e (`campaignAiChatFollowUps` são strings
|
||||
de conteúdo, não datas de calendário — verificados, sem trabalho).
|
||||
- Não generalizar para um helper de "label de dia do picker": 1 uso não justifica
|
||||
camada nova (`civilDatePlusDays` + `ptBrMonthNames` já cobrem).
|
||||
|
||||
## Riscos e mitigação
|
||||
|
||||
- **Fuso:** `formatBahiaCivilDate` usa hora civil da Bahia (padrão do spec inteiro);
|
||||
`civilDatePlusDays` opera em UTC puro sobre o civil date — imune a DST. Mesmo
|
||||
contrato do resto do spec.
|
||||
- **Último dia do mês:** o dia alvo vira "outside day" — o react-day-picker v9 renderiza
|
||||
e seleciona outside days normalmente (verificado no source; o unit spec de
|
||||
`activityOverlay` já clica dias do mês corrente sem restrição de "inside").
|
||||
Risco residual baixíssimo; se um dia o RDP mudar esse contrato, o teste falha com
|
||||
"button não encontrado" — mensagem clara, não determinística de data.
|
||||
|
||||
## Aceite de engenharia
|
||||
|
||||
- [x] Aceite de produto da intenção ainda coberto (teste deriva o dia de hoje + delta)
|
||||
- [x] Invariantes AGENTS/engineering-standards (mudança só em spec; sem DB, sem schema)
|
||||
- [x] Testes de domínio previstos (e2e C104 roda no worktree; sem unit — sem lógica de runtime)
|
||||
|
||||
## Absorvido durante a execução (débito pré-existente, mesmo arquivo)
|
||||
|
||||
- **Flake `?tab=overview` (3 sítios):** `toHaveURL(/\/campanha\/atividades\/[^/?]+$/)` nas
|
||||
linhas 86/344/397 corria contra o redirect canônico da página de detalhe
|
||||
(`getActivityDetailTabRedirect` → sempre `?tab=overview` quando o query está vazio):
|
||||
só passava quando o poll pegava o URL intermediário pré-redirect — quebrou 5× nos runs
|
||||
de verificação, inclusive no próprio C104 (linha 344). O precedente da correção já
|
||||
existia na linha 219 do mesmo arquivo (`(?:\?tab=overview)?$`); apliquei o mesmo
|
||||
regex nos 3 sítios restantes. Débito absorvido (determinismo, mesma classe do C134;
|
||||
sem nova Issue).
|
||||
146
docs/plans/ops45-e2e-fixtures-residuo-banco-teste-impl.md
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
# Impl: e2e — campaignE2EFixtures deixa lixo no banco de teste (contamina int specs sob resíduo)
|
||||
|
||||
Status: aprovado
|
||||
Atualizado em: 2026-08-13
|
||||
Issue: #723
|
||||
Intenção: body da Issue (sem `Plano:` linkado — o body é a spec)
|
||||
Appetite restante: herdado (chore P2 — cleanup + robustez de specs)
|
||||
|
||||
## Leitura da intenção
|
||||
|
||||
- **Outcome:** runs e2e (E2E_PROD) não podem deixar lixo que quebre int specs
|
||||
pré-existentes; o cleanup do `campaignE2EFixtures` deve ser investigado e,
|
||||
se necessário, os nomes fixos dos int specs viram únicos por run.
|
||||
- **O que NÃO negociar:** nenhum produto aqui — infra de teste. Invariantes a
|
||||
manter: nunca tocar prod, allocator de município (sequência Postgres) como
|
||||
contrato de exclusividade, regra de referência LGPD para deletar ficha
|
||||
órfã (mesma do `removeSupporterData` / D10 F1), nomes de spec continuam
|
||||
schema-válidos (letters+spaces/hyphens — `personName` existe para isso).
|
||||
- **O que reavaliar:** a hipótese do body "owned de stateDeputy/contact via
|
||||
fixtures.payload.create?" — investigada e **falsa**: contact/stateDeputy
|
||||
criados pelo proxy SÃO auto-owned e descobertos pelo runID no cleanup
|
||||
normal. O vazamento real é de runs **crashados** (cleanup nunca roda), a
|
||||
mesma classe que os fixtures int já defendem com `purgeMunicipalityResidue`
|
||||
no claim — que o `claimMunicipality` e2e não faz.
|
||||
|
||||
## Diagnóstico (investigação da Issue)
|
||||
|
||||
1. **Cleanup e2e em run normal está completo** — proxy auto-own de
|
||||
`stateDeputy`/`contact` (`isOwnedCollection` + `discoverOwnedRows` por
|
||||
runID em name/email + derivação de stateDeputy via `contact in`). Resíduo
|
||||
observado ('Ciclo Liderança-<uuid>', 'Coordenadora C128-<uuid>',
|
||||
'deputado-<uuid>') só nasce quando o run morre antes do `finally` do
|
||||
fixture (timeout/worker morto).
|
||||
2. **Classes de resíduo e2e** (verificado nas specs): dobradinhas + fichas
|
||||
vinculadas a município claimado (`campaignPeople` 183–237, 457–559 —
|
||||
`municipality.stateDeputies`), contas staff + fichas ('Coordenadora C128'),
|
||||
e lideranças/supporters/etc. (já purgáveis por município).
|
||||
3. **Mecanismo do `peopleList.int.spec.ts`:** a lista de pessoas é GLOBAL e
|
||||
paginada (25/página, ordenada por nome); o advisor nasce como
|
||||
'Usuário advisor-<runID>' (ordena tarde). Com ≥25 linhas residuais, a
|
||||
ficha do advisor cai da página 1 → "advisorRow não achado" (maria/ana,
|
||||
que ordenam cedo, seguem visíveis — exatamente o sintoma descrito).
|
||||
4. **Mecanismo do `personDelete.int.spec.ts`:** nome fixo 'Maria de Jesus' +
|
||||
invariante global de nome de dobradinha (`assertStateDeputyNameAvailable`,
|
||||
`src/utilities/stateDeputy/nameInvariant.ts`) — dobradinha residual com o
|
||||
mesmo nome bloqueia o create do spec.
|
||||
|
||||
## Abordagem recomendada
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
A[claimMunicipality e2e] --> B[purgeMunicipalityResidue<br/>+ classe dobradinha]
|
||||
C[peopleList.int] --> D[presença via todas as páginas]
|
||||
E[personDelete + peopleList] --> F[personName p/ nomes fixos]
|
||||
B --> G[resíduo e2e não acumula<br/>nem para int nem para e2e]
|
||||
```
|
||||
|
||||
**Opções consideradas:**
|
||||
|
||||
- **A — purge no claim (espelhar int) + estender `purgeMunicipalityResidue`
|
||||
para a classe dobradinha + robustez dos 2 int specs.** O resíduo e2e
|
||||
desaparece no próximo claim (contrato do allocator garante dono único), os
|
||||
int specs deixam de depender de estado global.
|
||||
- **B — só nomes únicos nos int specs.** Não resolve o peopleList (a poluição
|
||||
de página não é por nome, é por volume) nem a acumulação do resíduo e2e.
|
||||
- **C — sweep global por padrão de nome no setup e2e.** Fragil e perigoso:
|
||||
contas staff usam emails `@example.com` como os runs vivos — mataria runs
|
||||
paralelos.
|
||||
|
||||
**Recomendação:** **A** — porque ataca a fonte (resíduo some no claim,
|
||||
mesmo precedente do `getMunicipality` int), e a robustez dos specs fecha o
|
||||
resto (resíduo não-purgeável: contas staff de run crashado — ~1–2 linhas por
|
||||
crash, sem âncora de município e sem padrão seguro). A classe dobradinha é
|
||||
purgeável porque SEMPRE está vinculada ao município claimado pelo próprio run.
|
||||
|
||||
**Rejeitadas:** B sozinha (não cobre peopleList nem a acumulação); C (perigosa
|
||||
— padrões coincidem com runs vivos).
|
||||
|
||||
### Componentes / mudanças
|
||||
|
||||
- **`purgeMunicipalityResidue`** (`tests/helpers/campaignFixtures.ts`):
|
||||
estende a purga para a classe dobradinha — lê `municipality.stateDeputies`
|
||||
do município claimado, deleta os `stateDeputy` residuais, deleta as fichas
|
||||
órfãs (mesma checagem de referências do D10 F1: leadership/signature/
|
||||
subscription/supporter + `campaignUser.contact` — resíduo C99) e limpa o
|
||||
campo `stateDeputies: []`. Seguro pelo contrato do allocator: nenhum run
|
||||
vivo opera o município claimado (guard `testMunicipalityAllocatorConventions`).
|
||||
- **`CampaignE2EOwnership.claimMunicipality`** (`tests/e2e/fixtures/campaignE2EFixtures.ts`):
|
||||
chama `purgeMunicipalityResidue(this.rootPayload, municipality.id)` após o
|
||||
find — espelha `getMunicipality` int (mesma sequência, mesmo contrato).
|
||||
- **`peopleList.int.spec.ts`**: helper local `loadAllPeopleRows` (páginas
|
||||
1..totalPages) para as asserções de presença; facets seguem globais na
|
||||
página 1 (já são calculadas sobre o conjunto scoped, pré-paginação).
|
||||
- **`personDelete.int.spec.ts` / `peopleList.int.spec.ts`**: nomes fixos →
|
||||
`fixtures.personName(prefix)` (schema-válido, único por run), vinculando o
|
||||
nome nas asserções que o usam (`manifest?.contact.name`, `toMatchObject`).
|
||||
- **Migration:** sem migration (teste/helpers apenas).
|
||||
- **Access / Consent:** nenhum — fixture/helpers de teste; a checagem de
|
||||
órfã usa o mesmo critério do fluxo de produção (fail-closed).
|
||||
- **UI:** não há.
|
||||
|
||||
### Dados → forma
|
||||
|
||||
N/A (sem UI).
|
||||
|
||||
## Fases verificáveis
|
||||
|
||||
1. **Purga + claim e2e** — estender `purgeMunicipalityResidue`; ligar no
|
||||
`claimMunicipality` e2e; `pnpm test:int -- campaignFixtures` (a spec de
|
||||
invariante de contagem usa DB próprio) + gate unit (`testMunicipalityAllocatorConventions`).
|
||||
2. **Int specs robustos** — `loadAllPeopleRows` em peopleList; `personName`
|
||||
em personDelete + peopleList; `pnpm test:int` (arquivos-alvo).
|
||||
3. **Gates** — `pnpm gate:fast`; e2e do `campaignPeople` em dev para provar o
|
||||
purge no claim; `pnpm push` (débitos via capture-review-debts autônomo).
|
||||
|
||||
## Rabbit holes / Não escopo (engenharia)
|
||||
|
||||
- **Sweep de contas staff residuais** (sem âncora; padrão coincide com runs
|
||||
vivos) — registrado como débito, não corrigido aqui.
|
||||
- Migrar os outros specs com nomes fixos de liderança ('Maria da Silva' etc.
|
||||
em campaignInvite/campaignLeadership) — liderança não tem invariante de
|
||||
nome; o resíduo não as quebra (fora de escopo).
|
||||
- `campaignFixturesRowCounts` usa DB dedicado — não afetado.
|
||||
- **Ambiente da máquina (registrado como débito):** a coleção e2e local
|
||||
quebra no load de `src/utilities/documents.ts` (`Cannot find module
|
||||
'next/cache'` — ESM nativo não resolve subpath sem exports; `next/cache.js`
|
||||
existe, `next/cache` não). Reproduz no main repo e sob Node 20/24.14/24.18
|
||||
— pré-existente ao OPS45, fora de escopo; a verificação e2e fica para o CI
|
||||
do PR.
|
||||
|
||||
## Riscos e mitigação
|
||||
|
||||
- **Purga deletar linha de run vivo:** mitigado pelo contrato do allocator
|
||||
(nenhum claim por slug fixo — guard unit existente) + checagem de
|
||||
referências antes de deletar ficha órfã.
|
||||
- **peopleList mais lento (paginação):** 25 linhas/página, poucos reads —
|
||||
custo desprezível; semanticamente idêntico (presença global).
|
||||
- **`purgeMunicipalityResidue` compartilhada int+e2e:** o e2e passa a pagar a
|
||||
mesma purga que o int já paga; sem mudança de comportamento para o int
|
||||
além da nova classe dobradinha (resíduo, por definição não referenciado).
|
||||
|
||||
## Aceite de engenharia
|
||||
|
||||
- [x] Aceite de produto da intenção coberto (cleanup investigado + nomes fixos únicos + resíduo não acumula)
|
||||
- [x] Invariantes AGENTS/engineering-standards (allocator, D10 F1, personName)
|
||||
- [x] Testes previstos: unit do allocator (já existente), int dos dois specs, e2e campaignPeople
|
||||
75
docs/plans/ops46-infra-teste-e2e-local-allocator.md
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# OPS46 — Infra de teste e2e: e2e local quebrado (next/cache) + allocator de município com wrap
|
||||
|
||||
Status: rascunho
|
||||
Atualizado em: 2026-08-13
|
||||
Issue: #? (a criar via agent:register)
|
||||
Intenção: débitos do OPS45 (capture-review-debts autônomo)
|
||||
|
||||
## Fase 1 — e2e local não coleta: `Cannot find module 'next/cache'` (máquina do humano)
|
||||
|
||||
**Sintoma:** `pnpm exec playwright test --list` falha em todo spec — `Error: Cannot
|
||||
find module '<repo>/node_modules/next/cache' imported from src/utilities/documents.ts`.
|
||||
Reproduz no worktree OPS45, no main repo (`/home/fsolla/Code/teqo`) e sob Node
|
||||
v20.20.2 / v24.14.0 / v24.18.0 — pré-existente ao OPS45 (não é do diff).
|
||||
|
||||
**Mecanismo medido:** `import { revalidateTag } from 'next/cache'` (ESM, subpath
|
||||
sem extensão) falha no resolver ESM nativo do Node — `next/package.json` NÃO tem
|
||||
`exports`, então `next/cache` (arquivo `cache.js`) não resolve em ESM puro
|
||||
(`node --input-type=module -e "import('next/cache')"` → ERR_MODULE_NOT_FOUND;
|
||||
`import('next/cache.js')` → OK). O carregamento do graph do fixture e2e
|
||||
(`src/payload.config.ts` → `documents.ts`) passa por esse import; o transpiler
|
||||
do Playwright não reescreve bare specifier sem exports. CI passa (mesma versão
|
||||
de next/playwright) — investigar o que difere no ambiente CI.
|
||||
|
||||
**Ações prováveis:** descobrir o deltas CI vs máquina (versão de node do runner,
|
||||
flags de resolução, `NODE_OPTIONS`, corepack) e/ou tornar o import resolvível
|
||||
(registrar alias `next/cache` → `next/cache.js` no carregador do Playwright,
|
||||
ou mover `revalidateTag` para um shim com subpath com exports). Evidência de
|
||||
referência: reproduzir em docker com node 24 latest (mesmo do CI) para isolar.
|
||||
|
||||
**Rabbit holes:** não é o OPS45; não mexer nos fixtures; não é npm registry.
|
||||
|
||||
## Fase 2 — Allocator de município com wrap de módulo: colisão de claim deleta linhas vivas
|
||||
|
||||
**Sintoma latente:** `nextval % municipalityCatalog.length` (435) na sequência
|
||||
persistente compartilhada `campaign_fixture_municipality_alloc` (int + e2e).
|
||||
A sequência nunca é resetada; após 435 claims no MESMO banco (DBs persistentes
|
||||
de worktree acumulam — o problema do OPS45), dois runs concorrentes podem
|
||||
receber o MESMO índice e cada um purga as linhas vivas do outro (o purge-on-claim
|
||||
— int desde OPS19/D10 F1, e2e desde OPS45 — transforma a colisão em corrupção).
|
||||
|
||||
**Ações prováveis:** registry de claims com geração (`index, generation`,
|
||||
UNIQUE em index, `ON CONFLICT` retry) ou fail-loud no wrap; medir primeiro a
|
||||
contagem real de claims por run completo (int + e2e) para dimensionar.
|
||||
|
||||
**Rabbit holes:** não alterar o contrato de nomes/URLs; não tocar no
|
||||
`testMunicipalityAllocatorConventions.unit.spec.ts` sem migrar os guards.
|
||||
|
||||
## Já resolvido no OPS45 (não reabrir)
|
||||
|
||||
- stateDeputy no ref-check de fichas órfãs + teste da forma compartilhada
|
||||
(supporter+dobradinha) — `purgeMunicipalityResidue` não crasha mais.
|
||||
- `stateDeputies: []` gated no resíduo (sem write por claim limpo).
|
||||
- `loadAllPeopleRows` com loop auto-curável + dedupe por contactID.
|
||||
|
||||
## Explicitamente fora (deste lote)
|
||||
|
||||
- **Contas staff residuais** ('Coordenadora C128-<uuid>') — sem âncora de
|
||||
município e sem padrão seguro (emails `@example.com` coincidem com runs
|
||||
vivos); absorvidas pela paginação do peopleList. Gatilho: se voltar a
|
||||
quebrar um spec global, reavaliar sweep por created_at + ausência de joins.
|
||||
- **`activity.tasks[].responsible` fora do ref-check** — FK SET NULL,
|
||||
silencioso e auto-curável; shape improvável (atividade residual em município
|
||||
não claimado referenciando ficha purgada). Gatilho: 2ª referência a Contact
|
||||
fora do check.
|
||||
- **personName letteriza o runID** (invisível ao discoverMarkedRoots) —
|
||||
latente até um spec alimentar personName via action real (sem proxy).
|
||||
Gatilho: o 1º uso de personName fora do `createContact`.
|
||||
- **Import do módulo vitest no fixture e2e** — funciona hoje (hooks inertes
|
||||
fora do runner); gatilho: vitest mudar o entry / quebrar o import.
|
||||
|
||||
## Aceite de engenharia
|
||||
|
||||
- [ ] Fase 1: `pnpm exec playwright test --list` coleta na máquina do humano
|
||||
- [ ] Fase 2: sem colisão de claim após N wraps (teste de stress ou fail-loud)
|
||||
- [ ] Guards: `testMunicipalityAllocatorConventions` verde após a mudança
|
||||
86
docs/plans/react-19-form-reset-campanha.md
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# C140 — Formulários de campanha apagam o digitado em erro de validação (React 19 form reset)
|
||||
|
||||
Status: rascunho
|
||||
Atualizado em: 2026-08-13
|
||||
Issue: #740
|
||||
Priority: P2
|
||||
Model: composer-2.5
|
||||
Impeccable: B — UX (perda de dado digitado em erro); sem fluxo novo
|
||||
Canvas UI: N/A — não muda layout
|
||||
Appetite: ~1 dia eng; um outcome verificável
|
||||
Responsável: —
|
||||
|
||||
## Intenção
|
||||
|
||||
Formulários de campanha com `useActionState` + `<form action={submitAction}>` (padrão
|
||||
`action={submitAction}`) sofrem o reset automático do React 19: **após QUALQUER action
|
||||
assentada (sucesso ou erro), campos não controlados voltam ao defaultValue**. Quando o
|
||||
formulário fica aberto em erro de validação/conflito, o usuário vê o alerta mas **todo o
|
||||
digitado some** — silenciosamente.
|
||||
|
||||
**Provado empiricamente nesta sessão (C139):** create row desktop e sheets mobile de
|
||||
contatos — mesmo nó DOM, valor restaurado ao default após submit que retornou erro
|
||||
(validation e conflito de nome). O fix do C139 trocou para campos controlados + dispatch
|
||||
manual (`preventDefault` + `startTransition(() => submitAction(new FormData(...)))`), que
|
||||
mantém `isPending` correto sem reentrar no plumbing de form action.
|
||||
|
||||
Restam **~21 formulários** com o padrão antigo na árvore campaign
|
||||
(`grep 'action={submitAction}' src/components/campaign`): votePledge (2), municipality
|
||||
(wizard steps, updates, advisors), tour, advisor, leadership (3), organization, stateDeputy,
|
||||
demand (3), shared wizard. Todos com o mesmo defeito de UX em erro.
|
||||
|
||||
## Persona e fluxo
|
||||
|
||||
- **Persona:** staff da campanha (coordenador/assessor) preenchendo formulários longos
|
||||
(liderança, demanda, organização, dobradinha, declaração de votos, wizard de giro).
|
||||
- **Job principal:** errar um campo, ver o erro, corrigir SÓ o campo errado e salvar.
|
||||
- **Fluxo desejado:** o erro aparece, os demais campos **permanecem digitados**, o usuário
|
||||
corrige o mínimo.
|
||||
- **Anti-goal:** nenhuma mudança de comportamento de sucesso; nenhuma mudança de schemas
|
||||
de dados; não virar epic de refactor global.
|
||||
|
||||
## Objetivo e aceite
|
||||
|
||||
- Nenhum form com `useActionState` em `/campanha` apaga o digitado quando a action retorna
|
||||
erro (fieldErrors ou message).
|
||||
- O padrão de fix segue o precedente C139: campos controlados **ou** dispatch manual
|
||||
(`onSubmit` + `preventDefault` + `startTransition`), decidido por formulário conforme o
|
||||
que o C139 já fez (sheets controladas; create row com dispatch manual + uncontrolled).
|
||||
- Cobertura por spec e2e ou unit do form mais representativo por família (ex.: um form
|
||||
longo de criação em erro mantém valores).
|
||||
- Regressão: os specs existentes das famílias tocadas seguem verdes sem alteração.
|
||||
|
||||
## Dados (intenção)
|
||||
|
||||
- **Vou apresentar dados?** Não — o "dado" é o comportamento de formulário já provado na
|
||||
sessão C139 (mesmo nó, valor resetado, 3 formas distintas).
|
||||
|
||||
## Direção no codebase (hipótese)
|
||||
|
||||
- **Áreas prováveis:** os ~21 forms listados acima em `src/components/campaign/*`
|
||||
(`grep -rn 'action={submitAction}' src/components/campaign`).
|
||||
- **Precedente a olhar:** `src/components/campaign/contacts/ContactFormFields.tsx`
|
||||
(controlado + manual dispatch, comentário documentando o porquê) e
|
||||
`ContactCreateRow.tsx` (dispatch manual); `ActivityOverlay.tsx` (controlado + manual —
|
||||
precedente anterior ao C139).
|
||||
- **Risco de acoplamento:** cada form é independente; o fix é mecânico por arquivo.
|
||||
Forms com telefones/arrays (`PhonesFieldEditor` FORM mode) precisam conferir se o editor
|
||||
interno é controlado (não é resetado pelo dispatch manual).
|
||||
|
||||
## Já resolvido no simplify/critique (não reabrir)
|
||||
|
||||
- Forms do domínio `contacts` (create row, create/edit sheets) — fix C139 nesta entrega,
|
||||
coberto pelo e2e `campaignContacts`.
|
||||
|
||||
## Explicitamente fora
|
||||
|
||||
- Forms fora de `/campanha` (frontend público) — não verificados nesta colheita; reavaliar
|
||||
se o padrão aparecer lá.
|
||||
- Mudança de comportamento de sucesso ou de schemas — fora de escopo.
|
||||
- Padronizar TODOS os forms num único helper compartilhado — decisão de engenharia do
|
||||
item (pode ficar com os dois padrões C139, ou extrair helper se o lote mostrar DRY).
|
||||
|
||||
## Dependências
|
||||
|
||||
- `C139 (#728)` — a entrega que provou o defeito e fixou o domínio contacts (via `depends`
|
||||
na Issue).
|
||||
78
docs/plans/redesenhar-fluxo-reduzir-conflitos-impl.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Impl: OPS44 — Reduzir conflitos de merge em arquivos compartilhados
|
||||
|
||||
Status: aprovado
|
||||
Atualizado em: 2026-08-13
|
||||
Issue: #713
|
||||
Intenção: docs/plans/redesenhar-fluxo-reduzir-conflitos.md
|
||||
Appetite restante: herdado (~1–2 dias eng; processo + guards, sem UI)
|
||||
|
||||
## Leitura da intenção
|
||||
|
||||
- **Outcome:** cada entrega grava sua entrada de changelog em arquivo próprio (imune a conflito) e o agregado legível "Recently resolved" continua gerado por script; CI barra remoção de linhas existentes do agregado e barra marcadores de conflito em diffs de `docs/`; merges das PRs passam a ser por rebase; Issues que tocam registries compartilhados declaram `serializes`.
|
||||
- **O que NÃO negociar:** nada de migrar entradas históricas; `docs/plans/*` intocado; sem mapa de contenção commitado; sem UI; sem virar gerenciador de merge; a legibilidade do histórico "Recently resolved" permanece.
|
||||
- **O que reavaliar:** a hipótese de "guard de append-only" como parser de diff — parser de diff é ruidoso com linhas movidas; semântica honesta é inclusão de multiset sobre os blobs (abaixo). A hipótese de tocar só `ci-pr.yml` — o `agent-pr-ready-automerge.yml` re-arma `--merge` em PRs `cursor/*` e sobrescreveria o `--rebase`; precisa mudar junto. O gap que motiva o guard de marcadores: PR docs-only tem `code_mode: none` → a suíte unit (onde mora o guard OPS41) **não roda** — o guard precisa ser job dedicado de CI.
|
||||
|
||||
## Abordagem recomendada
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
E[Entrega] --> F[docs/changelog/<data>-<id>.md]
|
||||
F --> B[pnpm changelog:build]
|
||||
B --> A[CHANGELOG-AGENTS.md agregado]
|
||||
F --> P[PR]
|
||||
A --> P
|
||||
P --> G[CI docs-guards: append-only + marcadores]
|
||||
G --> M[gh pr merge --auto --rebase]
|
||||
```
|
||||
|
||||
**Opções consideradas:** A (arquivos por entrega + script agregador + guards de CI + rebase) | B (lock/fila de escrita por arquivo) | C (guard de marcadores só na suíte unit existente) | D (parser de diff para o guard append-only) | E (agregador em TS com DB)
|
||||
**Recomendação:** **A** — ataca a causa (anchor único) no formato, como decidiu o gate; guards baratos no CI; rebase transfere o conflito ao autor.
|
||||
**Rejeitadas:** B (rabbit hole da intenção — resolve no formato, não no merge); C (PR docs-only pula a suíte unit por `code_mode: none` — o incidente OPS41 era exatamente um PR de docs; guard precisa de job próprio sempre-executado); D (algoritmo de diff reordena hunk em movimentos de linha — falso positivo; comparação multiset de blobs é determinística e honesta); E (nada de DB — mjs é o padrão dos scripts de guard do repo, precedente `plansOnlyClosesGuard`).
|
||||
|
||||
### Componentes / mudanças
|
||||
|
||||
- **`scripts/lib/changelog.mjs`** (novo, puro, unit-testado): três superfícies —
|
||||
1. `listChangelogEntries(files)`: filtra `docs/changelog/<data>-<id>.md` (`^\d{4}-\d{2}-\d{2}-[a-z0-9-]+\.md$`), ordena data desc → id asc; `.md` fora do padrão → erro fail-closed;
|
||||
2. `buildChangelog(entries, header)`: header (linhas até o primeiro `---` do agregado atual) + `\n\n` + entradas (`\n\n`-separadas) + newline final;
|
||||
3. `assertChangelogAppendOnly({ oldContent, newContent, changelogDiff })`: **multiset** — toda linha do agregado antigo presente no novo com contagem ≥ (`docs/CHANGELOG-AGENTS.md`) e `docs/changelog/*` com `A`-only no `--name-status`; escape documentado: PR body com `changelog-rewrite: <motivo>` (padrão D8); retorna `{ ok } | { ok:false, message }`.
|
||||
- **`scripts/lib/conflictMarkers.mjs`** (novo, puro): regex do OPS41 **extraída** do unit spec (`<<<<<<<`/`>>>>>>>` tolerante a indentação + forma corrompida `^\s*(> ){7}`) + `findConflictMarkerLines(content)` — o spec passa a importar daqui (don't twin; o scan repo-wide da suíte unit permanece).
|
||||
- **CLIs** (padrão `check-plans-only-pr-closes.mjs` — wrapper fino, git plumbing): `scripts/build-changelog.mjs` (`pnpm changelog:build` — escreve o agregado; verifica `git ls-files` do changelog dir? não — só gera), `scripts/check-changelog-append-only.mjs` (blobs via `git show <merge-base>:<path>` / `HEAD:<path>`, PR body via `PR_BODY`/`gh pr view`), `scripts/check-docs-conflict-markers.mjs` (`git diff --name-only merge-base...HEAD -- docs/` → `git show HEAD:<path>` → scan).
|
||||
- **`.github/workflows/ci-pr.yml`**: job novo `docs-guards` (cheap, sempre roda, sem Postgres — espelha `plans-only-closes`) rodando os dois checks; entra no `needs` do rollup `checks`.
|
||||
- **Merge por rebase** (mudança mecânica em 7 pontos): `execution-pipeline.md:34`, `scripts/lib/agent-pool-prompt.mjs:41`, `plan-issue/SKILL.md:153`, `.agents/rules/agent-pr-workflow.mdc` (32/54/87), **`agent-pr-ready-automerge.yml:37`** (safety net — sem isso ele re-arma `--merge` por cima do `--rebase` em PRs `cursor/*`), `docs/AGENT-OPS.md` "Contrato de PR" item 3.
|
||||
- **`serializes` documentado**: `plan-issue/SKILL.md` (linha 97 — nomear os registries C2: `tests/unit/codebaseConventions.unit.spec.ts`, `src/utilities/ai/tools/index.ts` + `systemPrompt.ts`, `tests/e2e/fixtures/campaignE2EFixtures.ts`, `AGENTS.md`, `.agents/shell/worktree.sh`) e `docs/AGENT-OPS.md` (seção nova "Registries compartilhados"). Sem mudança no pool (só `migrations` é predica vel; intenção pede visibilidade, não serialização do pool).
|
||||
- **Docs**: `docs/AGENT-OPS.md` (seção "Changelog": escrever `docs/changelog/<data>-<id>.md` → `pnpm changelog:build` → guard + escape `changelog-rewrite:`), `AGENTS.md` bullet "Histórico de entregas" (uma linha), header do agregado (o parágrafo "Itens novos …" descreve o fluxo novo), `execution-pipeline.md` (passo de registro), `.github/pull_request_template.md:14` (referência ao fluxo novo).
|
||||
- **Entrega própria (dogfooding)**: `docs/changelog/2026-08-13-ops44.md` + agregado regenerado; o header do agregado muda nesta entrega → **escape `changelog-rewrite:` no body do PR** (primeiro uso real do escape, testado ao vivo).
|
||||
- **Migration:** nenhuma. **Access/Consent:** nenhum. **UI:** Impeccable A.
|
||||
|
||||
### Dados → forma
|
||||
|
||||
- N/A (sem dados de produto). Forma dos artefatos: arquivo por entrega (imune a conflito por construção — mesmo padrão que já funciona em `docs/plans/*`) + agregado gerado (leitura estabelecida mantida — decisão A do gate).
|
||||
|
||||
## Fases verificáveis
|
||||
|
||||
1. **Libs puras + unit tests** — `changelog.mjs` (build/sort/fail-closed + append-only multiset: adição ok, remoção falha, linha movida ok, duplicata, escape) e `conflictMarkers.mjs` (casos do spec OPS41 movidos). `pnpm test:unit`.
|
||||
2. **CLIs + CI** — 3 scripts; `pnpm changelog:build` gera o agregado idêntico ao atual (verificação: `git diff` vazio com o estado atual); job `docs-guards` no ci-pr.yml + rollup. Verificação local dos checks com git.
|
||||
3. **Processo/merge** — rebase nos 7 pontos (grep pós: zero `--auto --merge` fora de histórico de workflows/skills — migrations/frozen não contam); docs (AGENT-OPS, AGENTS.md, PR template, header do agregado, execution-pipeline).
|
||||
4. **Entrega própria** — `docs/changelog/2026-08-13-ops44.md`, regenerar, commit, PR com `changelog-rewrite:` no body.
|
||||
5. **Gates** — `pnpm gate:fast`, `pnpm check:cycles`, `pnpm exec knip`, `format:check`; build não é afetado (sem `src/`), mas rodar `pnpm build` contra DB local por paridade.
|
||||
|
||||
## Rabbit holes / Não escopo (engenharia)
|
||||
|
||||
- Validar data do filename contra o `**Recently resolved (data):**` da entrada — v1 sem cross-validation (nota no doc do formato).
|
||||
- Guard de presença de entradas históricas por id (D8 processo manual) — não automatizar.
|
||||
- Serialização do pool para registries C2 — só documentação nesta entrega.
|
||||
- Migrar entradas históricas para `docs/changelog/` — fora de escopo (intenção).
|
||||
|
||||
## Riscos e mitigação
|
||||
|
||||
- **Settings do repo: "Rebase and merge" precisa estar habilitado** para o auto-merge rebase; verificação read-only via `gh api repos/fsolla/teqo --jq .allow_rebase_merge` antes de fechar; se desligado → habilitar via API (ou pedir ao humano) como parte da entrega.
|
||||
- **PRs `cursor/*` já armadas com `--merge`**: janela até o deploy da mudança — pequena; o safety-net re-arma com o método do workflow (a partir desta entrega, rebase).
|
||||
- **Falso positivo do guard com reordenação**: eliminado pela semântica multiset (linha movida continua presente).
|
||||
- **Duas entregas paralelas regeneram o agregado**: rebase conflita no agregado → autor regenera com `pnpm changelog:build` (resolução natural, diff conhecido — exatamente o fluxo desejado); guard valida o resultado.
|
||||
- **Prettier/format:check sobre o agregado gerado**: entradas existentes já passam; gerador preserva o formato (proseWrap preserve).
|
||||
|
||||
## Aceite de engenharia
|
||||
|
||||
- [x] Aceite de produto da intenção ainda coberto (formato novo + agregado legível + 2 guards + rebase + `serializes` doc)
|
||||
- [x] Invariantes AGENTS/engineering-standards (sem `src/` de app; scripts mjs no padrão dos guards existentes; zero DB; zero UI)
|
||||
- [x] Testes de domínio previstos: unit das libs puras (builder + append-only multiset + marcadores); guards exercitados localmente contra diffs sintéticos
|
||||
|
|
@ -217,6 +217,7 @@ const eslintConfig = [
|
|||
globalIgnores([
|
||||
// Default ignores of eslint-config-next:
|
||||
'.next/**',
|
||||
'.next-e2e/**',
|
||||
'out/**',
|
||||
'build/**',
|
||||
'next-env.d.ts',
|
||||
|
|
|
|||
10
opencode.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mcp": {
|
||||
"penpot": {
|
||||
"type": "remote",
|
||||
"url": "https://design.penpot.app/mcp/stream?userToken={file:.opencode/secrets/penpot-token}",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,8 @@
|
|||
"gate:push": "pnpm gate:ci",
|
||||
"push": "node scripts/git-push.mjs",
|
||||
"check:cycles": "madge --circular --extensions ts,tsx --ts-config tsconfig.json src",
|
||||
"changelog:build": "node scripts/build-changelog.mjs",
|
||||
"changelog:check": "node scripts/build-changelog.mjs --check",
|
||||
"generate:importmap": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload generate:importmap",
|
||||
"generate:types": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload generate:types",
|
||||
"migrate": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload migrate",
|
||||
|
|
@ -71,6 +73,8 @@
|
|||
"test:int": "cross-env NODE_OPTIONS=--no-deprecation vitest run --config ./vitest.config.mts",
|
||||
"test:unit": "cross-env NODE_OPTIONS=--no-deprecation DATABASE_URL=postgresql://invalid:invalid@127.0.0.1:1/unit_tests_must_not_connect vitest run --config ./vitest.unit.config.mts",
|
||||
"ui-draft:render": "node scripts/render-ui-draft.mjs",
|
||||
"images:resize": "node scripts/resize-images.mjs",
|
||||
"images:fill": "node scripts/fill-image.mjs",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck:tsc6": "tsc6 --noEmit",
|
||||
"prepare": "husky",
|
||||
|
|
@ -84,6 +88,7 @@
|
|||
"@base-ui/react": "^1.6.0",
|
||||
"@fullcalendar/react": "7.0.2",
|
||||
"@hookform/resolvers": "^5.2.2",
|
||||
"@imgly/background-removal-node": "^1.4.5",
|
||||
"@payloadcms/db-postgres": "3.82.0",
|
||||
"@payloadcms/email-resend": "3.82.0",
|
||||
"@payloadcms/live-preview-react": "3.82.0",
|
||||
|
|
|
|||
|
|
@ -154,12 +154,9 @@ export default defineConfig({
|
|||
* e2e states stay deterministic (see `googleCalendarTestKey.ts`).
|
||||
*/
|
||||
[GOOGLE_CALENDAR_SERVICE_ACCOUNT_KEY_ENV_NAME]: GOOGLE_CALENDAR_TEST_KEY,
|
||||
// Fixed dist dir: Next dev appends `<distDir>/types/**/*.ts` to
|
||||
// tsconfig.json's include with an EXACT-string check, so per-process
|
||||
// names polluted tsconfig with one entry per run. A prior Playwright
|
||||
// process tearing down late can, rarely, delete files of the next run's
|
||||
// server — if a boot flakes, rerun (dev-only trade-off).
|
||||
NEXT_DIST_DIR: '.next/e2e',
|
||||
// Keep e2e artifacts outside `.next`: a concurrent development server
|
||||
// owns that entire directory and may clear nested production bundles.
|
||||
NEXT_DIST_DIR: process.env.NEXT_DIST_DIR ?? '.next-e2e',
|
||||
PAYLOAD_SECRET: process.env.PAYLOAD_SECRET ?? 'test-only-secret-not-used-in-production',
|
||||
NEXT_PUBLIC_SITE_URL: process.env.NEXT_PUBLIC_SITE_URL ?? baseURL,
|
||||
},
|
||||
|
|
|
|||
405
pnpm-lock.yaml
|
|
@ -23,6 +23,9 @@ importers:
|
|||
'@hookform/resolvers':
|
||||
specifier: ^5.2.2
|
||||
version: 5.2.2(react-hook-form@7.71.1(react@19.2.4))
|
||||
'@imgly/background-removal-node':
|
||||
specifier: ^1.4.5
|
||||
version: 1.4.5
|
||||
'@payloadcms/db-postgres':
|
||||
specifier: 3.82.0
|
||||
version: 3.82.0(payload@3.82.0(@typescript/typescript6@6.0.2)(graphql@16.12.0))
|
||||
|
|
@ -1550,6 +1553,9 @@ packages:
|
|||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@imgly/background-removal-node@1.4.5':
|
||||
resolution: {integrity: sha512-/s9K88qhKy1jPhrSkBxurUqCVqJ8KHWCc+5yWdppdC4fuSrGC8mK8WQtmULs2ASEr8naY1qpvZu0EL5jr2Hqtg==}
|
||||
|
||||
'@inquirer/ansi@1.0.2':
|
||||
resolution: {integrity: sha512-S8qNSZiYzFd0wAcyG5AXCvUHC5Sr7xpZ9wZ2py9XR88jUz8wooStVx5M6dRzczbBWjic9NP7+rY0Xi7qqK/aMQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -1585,6 +1591,10 @@ packages:
|
|||
'@types/node':
|
||||
optional: true
|
||||
|
||||
'@isaacs/fs-minipass@4.0.1':
|
||||
resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
|
||||
|
||||
|
|
@ -3224,6 +3234,9 @@ packages:
|
|||
'@types/leaflet@1.9.21':
|
||||
resolution: {integrity: sha512-TbAd9DaPGSnzp6QvtYngntMZgcRk+igFELwR2N99XZn7RXUdKgsXMR+28bUO0rPsWp8MIu/f47luLIQuSLYv/w==}
|
||||
|
||||
'@types/lodash@4.14.202':
|
||||
resolution: {integrity: sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==}
|
||||
|
||||
'@types/lodash@4.17.23':
|
||||
resolution: {integrity: sha512-RDvF6wTulMPjrNdCoYRC8gNR880JNGT8uB+REUpC2Ns4pRqQJhGz90wh7rgdXDPpCczF3VGktDuFGVnz8zP7HA==}
|
||||
|
||||
|
|
@ -3233,6 +3246,12 @@ packages:
|
|||
'@types/ms@2.1.0':
|
||||
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
|
||||
|
||||
'@types/ndarray@1.0.14':
|
||||
resolution: {integrity: sha512-oANmFZMnFQvb219SSBIhI1Ih/r4CvHDOzkWyJS/XRqkMrGH5/kaPSA1hQhdIBzouaE+5KpE/f5ylI9cujmckQg==}
|
||||
|
||||
'@types/node@20.3.3':
|
||||
resolution: {integrity: sha512-wheIYdr4NYML61AjC8MKj/2jrR/kDQri/CIpVoZwldwhnIrD/j9jIU5bJ8yBKuB2VhpFV7Ab6G2XkBjv9r9Zzw==}
|
||||
|
||||
'@types/node@22.19.9':
|
||||
resolution: {integrity: sha512-PD03/U8g1F9T9MI+1OBisaIARhSzeidsUjQaf51fOxrfjeiKN9bLVO06lHuHYjxdnqLWJijJHfqXPSJri2EM2A==}
|
||||
|
||||
|
|
@ -3891,6 +3910,14 @@ packages:
|
|||
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
b4a@1.8.1:
|
||||
resolution: {integrity: sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==}
|
||||
peerDependencies:
|
||||
react-native-b4a: '*'
|
||||
peerDependenciesMeta:
|
||||
react-native-b4a:
|
||||
optional: true
|
||||
|
||||
babel-plugin-macros@3.1.0:
|
||||
resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
|
||||
engines: {node: '>=10', npm: '>=6'}
|
||||
|
|
@ -3905,6 +3932,43 @@ packages:
|
|||
resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==}
|
||||
engines: {node: 18 || 20 || >=22}
|
||||
|
||||
bare-events@2.9.1:
|
||||
resolution: {integrity: sha512-Z0oHEHAFDZkffN8Qc39zNZjQlMDkPJRyyyZieU1VH7u8c5S+qHZ2S8ixdKIAxEjfHO7FJxXmJWgteOghVanIsg==}
|
||||
peerDependencies:
|
||||
bare-abort-controller: '*'
|
||||
peerDependenciesMeta:
|
||||
bare-abort-controller:
|
||||
optional: true
|
||||
|
||||
bare-fs@4.8.0:
|
||||
resolution: {integrity: sha512-fM+MhCvdQhZ7NV6S95a07gPSqjIYKn6mFaXfx266wN3ajZGl/+1AzH+ubkXQ0fFZvOe2nk9VHkzdYkQE5zMV3Q==}
|
||||
engines: {bare: '>=1.28.0'}
|
||||
peerDependencies:
|
||||
bare-buffer: '*'
|
||||
peerDependenciesMeta:
|
||||
bare-buffer:
|
||||
optional: true
|
||||
|
||||
bare-path@3.1.1:
|
||||
resolution: {integrity: sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==}
|
||||
|
||||
bare-stream@2.13.3:
|
||||
resolution: {integrity: sha512-Kc+brLqvEqGkjyfiwJmImAOqLZL7OsoLKuavx+hJjgVV3nLTOjloJyPMFxjUPerGGHrNH0fLU06jjykMLWrERQ==}
|
||||
peerDependencies:
|
||||
bare-abort-controller: '*'
|
||||
bare-buffer: '*'
|
||||
bare-events: '*'
|
||||
peerDependenciesMeta:
|
||||
bare-abort-controller:
|
||||
optional: true
|
||||
bare-buffer:
|
||||
optional: true
|
||||
bare-events:
|
||||
optional: true
|
||||
|
||||
bare-url@2.5.2:
|
||||
resolution: {integrity: sha512-L13PCJzKG8RGvx8V1/DdMi12ERhC3tprr7/8a94BxpmnRsFqxh5XZNdhtMxu5HPkRshYOOWRGY8lDP7ZhpG9Cg==}
|
||||
|
||||
base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
|
||||
|
|
@ -4035,6 +4099,13 @@ packages:
|
|||
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
|
||||
chownr@1.1.4:
|
||||
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
|
||||
|
||||
chownr@3.0.0:
|
||||
resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
ci-info@4.4.0:
|
||||
resolution: {integrity: sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==}
|
||||
engines: {node: '>=8'}
|
||||
|
|
@ -4290,6 +4361,10 @@ packages:
|
|||
decode-named-character-reference@1.3.0:
|
||||
resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}
|
||||
|
||||
decompress-response@6.0.0:
|
||||
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
dedent@1.7.2:
|
||||
resolution: {integrity: sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==}
|
||||
peerDependencies:
|
||||
|
|
@ -4807,6 +4882,9 @@ packages:
|
|||
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
events-universal@1.0.1:
|
||||
resolution: {integrity: sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==}
|
||||
|
||||
eventsource-parser@3.0.6:
|
||||
resolution: {integrity: sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
|
@ -4827,6 +4905,10 @@ packages:
|
|||
resolution: {integrity: sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA==}
|
||||
engines: {node: ^18.19.0 || >=20.5.0}
|
||||
|
||||
expand-template@2.0.3:
|
||||
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
expand-tilde@2.0.2:
|
||||
resolution: {integrity: sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
|
@ -4854,6 +4936,9 @@ packages:
|
|||
fast-deep-equal@3.1.3:
|
||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||
|
||||
fast-fifo@1.3.2:
|
||||
resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==}
|
||||
|
||||
fast-glob@3.3.1:
|
||||
resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==}
|
||||
engines: {node: '>=8.6.0'}
|
||||
|
|
@ -4967,6 +5052,9 @@ packages:
|
|||
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
fs-constants@1.0.0:
|
||||
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
||||
|
||||
fs-extra@11.3.4:
|
||||
resolution: {integrity: sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA==}
|
||||
engines: {node: '>=14.14'}
|
||||
|
|
@ -5057,6 +5145,9 @@ packages:
|
|||
get-tsconfig@4.8.1:
|
||||
resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==}
|
||||
|
||||
github-from-package@0.0.0:
|
||||
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
||||
|
||||
glob-parent@5.1.2:
|
||||
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
|
||||
engines: {node: '>= 6'}
|
||||
|
|
@ -5253,6 +5344,9 @@ packages:
|
|||
resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
iota-array@1.0.0:
|
||||
resolution: {integrity: sha512-pZ2xT+LOHckCatGQ3DcG/a+QuEqvoxqkiL7tvE8nn3uuu+f6i1TtpB5/FtWFbxUuVr5PZCx8KskuGatbJDXOWA==}
|
||||
|
||||
ip-address@10.1.0:
|
||||
resolution: {integrity: sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==}
|
||||
engines: {node: '>= 12'}
|
||||
|
|
@ -5961,6 +6055,10 @@ packages:
|
|||
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
mimic-response@3.1.0:
|
||||
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
minimalistic-assert@1.0.1:
|
||||
resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==}
|
||||
|
||||
|
|
@ -5981,6 +6079,17 @@ packages:
|
|||
minimist@1.2.8:
|
||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||
|
||||
minipass@7.1.3:
|
||||
resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
minizlib@3.1.0:
|
||||
resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
mkdirp-classic@0.5.3:
|
||||
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
||||
|
||||
module-definition@6.0.2:
|
||||
resolution: {integrity: sha512-SvAU3lB0+Yjbq55yHY3wkRZBOh+fhU1SnIF3IFbTewv6mtAh7yUT8ACHAJ2mGIJ7tCes2QuCL/cl6m0JSZ/ArA==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -6021,6 +6130,9 @@ packages:
|
|||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
napi-build-utils@2.0.0:
|
||||
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
|
||||
|
||||
napi-postinstall@0.3.4:
|
||||
resolution: {integrity: sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==}
|
||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||
|
|
@ -6029,6 +6141,9 @@ packages:
|
|||
natural-compare@1.4.0:
|
||||
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
|
||||
|
||||
ndarray@1.0.19:
|
||||
resolution: {integrity: sha512-B4JHA4vdyZU30ELBw3g7/p9bZupyew5a7tX1Y/gGeF2hafrPaQZhgrGQfsvgfYbgdFZjYwuEcnaobeM/WMW+HQ==}
|
||||
|
||||
negotiator@1.0.0:
|
||||
resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
|
@ -6060,6 +6175,13 @@ packages:
|
|||
sass:
|
||||
optional: true
|
||||
|
||||
node-abi@3.94.0:
|
||||
resolution: {integrity: sha512-W5ZNO5KRPB5TkYmGVD9F6YqhsglXJzE6etpbmT+f6EQElhiX/UTG551cnsRGvLG3fyZEg9HwaDmNmj5nwJ4z9g==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
node-addon-api@6.1.0:
|
||||
resolution: {integrity: sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==}
|
||||
|
||||
node-domexception@1.0.0:
|
||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||
engines: {node: '>=10.5.0'}
|
||||
|
|
@ -6152,6 +6274,13 @@ packages:
|
|||
resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
onnxruntime-common@1.17.3:
|
||||
resolution: {integrity: sha512-IkbaDelNVX8cBfHFgsNADRIq2TlXMFWW+nG55mwWvQT4i0NZb32Jf35Pf6h9yjrnK78RjcnlNYaI37w394ovMw==}
|
||||
|
||||
onnxruntime-node@1.17.3:
|
||||
resolution: {integrity: sha512-NtbN1pfApTSEjVq46LrJ396aPP2Gjhy+oYZi5Bu1leDXAEvVap/BQ8CZELiLs7z0UnXy3xjJW23HiB4P3//FIw==}
|
||||
os: [win32, darwin, linux]
|
||||
|
||||
open@11.0.0:
|
||||
resolution: {integrity: sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw==}
|
||||
engines: {node: '>=20'}
|
||||
|
|
@ -6444,6 +6573,12 @@ packages:
|
|||
resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
prebuild-install@7.1.3:
|
||||
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
|
||||
hasBin: true
|
||||
|
||||
precinct@12.3.2:
|
||||
resolution: {integrity: sha512-JbJevI1K80z8e/WIyDt/4vUN/4qcfBSKKqOjJA4mosPPPb7zODKRJQV7YN7apVWN3k58nZYm/vEsLgEGYmnxwg==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -6890,6 +7025,10 @@ packages:
|
|||
resolution: {integrity: sha512-dWN9aw+fszDEMPdRqAVmv5xgrsO60r5XDinHvrCjyfSW/FOiOrJJpYHGDI67+ItIwhTGHK1cXCM5YPAWVOsUtw==}
|
||||
hasBin: true
|
||||
|
||||
sharp@0.32.6:
|
||||
resolution: {integrity: sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==}
|
||||
engines: {node: '>=14.15.0'}
|
||||
|
||||
sharp@0.34.2:
|
||||
resolution: {integrity: sha512-lszvBmB9QURERtyKT2bNmsgxXK0ShJrL/fvqlonCo7e6xBF8nT8xU6pW+PMIbLsz0RxQk3rgH9kd8UmvOzlMJg==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
|
|
@ -6935,6 +7074,12 @@ packages:
|
|||
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
simple-concat@1.0.1:
|
||||
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
|
||||
|
||||
simple-get@4.0.1:
|
||||
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
|
||||
|
||||
simple-swizzle@0.2.4:
|
||||
resolution: {integrity: sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==}
|
||||
|
||||
|
|
@ -7020,6 +7165,9 @@ packages:
|
|||
resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
|
||||
streamx@2.28.0:
|
||||
resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==}
|
||||
|
||||
strict-event-emitter@0.5.1:
|
||||
resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==}
|
||||
|
||||
|
|
@ -7173,6 +7321,26 @@ packages:
|
|||
resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar-fs@2.1.5:
|
||||
resolution: {integrity: sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==}
|
||||
|
||||
tar-fs@3.1.3:
|
||||
resolution: {integrity: sha512-/hU4AXnIdZu+Gvl1pk0oI5f5HxWsCJRtY2aFaJdk9VvyL48DWU6iU5WAIPG+wIi1YvWA6eTJvIviP/tMAZZNwQ==}
|
||||
|
||||
tar-stream@2.2.0:
|
||||
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar-stream@3.2.0:
|
||||
resolution: {integrity: sha512-ojzvCvVaNp6aOTFmG7jaRD0meowIAuPc3cMMhSgKiVWws1GyHbGd/xvnyuRKcKlMpt3qvxx6r0hreCNITP9hIg==}
|
||||
|
||||
tar@7.5.22:
|
||||
resolution: {integrity: sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
teex@1.0.1:
|
||||
resolution: {integrity: sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==}
|
||||
|
||||
temporal-polyfill@1.0.3:
|
||||
resolution: {integrity: sha512-U8vuzZBc+dfMIfl8wXWcedfI7AJCxJjjVBIRpJUvIz5+UAp555UJDHguKsfZqHWaHRSdVUThm7mqqIWhN/xPBQ==}
|
||||
|
||||
|
|
@ -7182,6 +7350,9 @@ packages:
|
|||
temporal-utils@1.0.1:
|
||||
resolution: {integrity: sha512-HAixuesxFQIUaQk3ptX2jhfO/FsOkgVkDDMawvp6n/fkB1q6BKfs3lURw9I+pK/2e2e/q/vrLrxmeqauBoyGMQ==}
|
||||
|
||||
text-decoder@1.2.7:
|
||||
resolution: {integrity: sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==}
|
||||
|
||||
thread-stream@3.1.0:
|
||||
resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==}
|
||||
|
||||
|
|
@ -7327,6 +7498,9 @@ packages:
|
|||
resolution: {integrity: sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
|
||||
tw-animate-css@1.4.0:
|
||||
resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==}
|
||||
|
||||
|
|
@ -7744,6 +7918,10 @@ packages:
|
|||
yallist@3.1.1:
|
||||
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
|
||||
|
||||
yallist@5.0.0:
|
||||
resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
yaml@1.10.2:
|
||||
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
|
||||
engines: {node: '>= 6'}
|
||||
|
|
@ -7786,6 +7964,9 @@ packages:
|
|||
peerDependencies:
|
||||
zod: ^3.25 || ^4
|
||||
|
||||
zod@3.21.4:
|
||||
resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==}
|
||||
|
||||
zod@3.25.76:
|
||||
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
|
||||
|
||||
|
|
@ -8866,6 +9047,21 @@ snapshots:
|
|||
'@img/sharp-win32-x64@0.34.5':
|
||||
optional: true
|
||||
|
||||
'@imgly/background-removal-node@1.4.5':
|
||||
dependencies:
|
||||
'@types/lodash': 4.14.202
|
||||
'@types/ndarray': 1.0.14
|
||||
'@types/node': 20.3.3
|
||||
lodash: 4.17.23
|
||||
ndarray: 1.0.19
|
||||
onnxruntime-node: 1.17.3
|
||||
sharp: 0.32.6
|
||||
zod: 3.21.4
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
'@inquirer/ansi@1.0.2': {}
|
||||
|
||||
'@inquirer/confirm@5.1.21(@types/node@22.19.9)':
|
||||
|
|
@ -8894,6 +9090,10 @@ snapshots:
|
|||
optionalDependencies:
|
||||
'@types/node': 22.19.9
|
||||
|
||||
'@isaacs/fs-minipass@4.0.1':
|
||||
dependencies:
|
||||
minipass: 7.1.3
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
|
|
@ -10770,6 +10970,8 @@ snapshots:
|
|||
dependencies:
|
||||
'@types/geojson': 7946.0.16
|
||||
|
||||
'@types/lodash@4.14.202': {}
|
||||
|
||||
'@types/lodash@4.17.23': {}
|
||||
|
||||
'@types/mdast@4.0.4':
|
||||
|
|
@ -10778,6 +10980,10 @@ snapshots:
|
|||
|
||||
'@types/ms@2.1.0': {}
|
||||
|
||||
'@types/ndarray@1.0.14': {}
|
||||
|
||||
'@types/node@20.3.3': {}
|
||||
|
||||
'@types/node@22.19.9':
|
||||
dependencies:
|
||||
undici-types: 6.21.0
|
||||
|
|
@ -11405,6 +11611,8 @@ snapshots:
|
|||
|
||||
axobject-query@4.1.0: {}
|
||||
|
||||
b4a@1.8.1: {}
|
||||
|
||||
babel-plugin-macros@3.1.0:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.29.7
|
||||
|
|
@ -11417,6 +11625,35 @@ snapshots:
|
|||
|
||||
balanced-match@4.0.4: {}
|
||||
|
||||
bare-events@2.9.1: {}
|
||||
|
||||
bare-fs@4.8.0:
|
||||
dependencies:
|
||||
bare-events: 2.9.1
|
||||
bare-path: 3.1.1
|
||||
bare-stream: 2.13.3(bare-events@2.9.1)
|
||||
bare-url: 2.5.2
|
||||
fast-fifo: 1.3.2
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
bare-path@3.1.1: {}
|
||||
|
||||
bare-stream@2.13.3(bare-events@2.9.1):
|
||||
dependencies:
|
||||
b4a: 1.8.1
|
||||
streamx: 2.28.0
|
||||
teex: 1.0.1
|
||||
optionalDependencies:
|
||||
bare-events: 2.9.1
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
bare-url@2.5.2:
|
||||
dependencies:
|
||||
bare-path: 3.1.1
|
||||
|
||||
base64-js@1.5.1: {}
|
||||
|
||||
baseline-browser-mapping@2.9.19: {}
|
||||
|
|
@ -11558,6 +11795,10 @@ snapshots:
|
|||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
|
||||
chownr@1.1.4: {}
|
||||
|
||||
chownr@3.0.0: {}
|
||||
|
||||
ci-info@4.4.0: {}
|
||||
|
||||
class-variance-authority@0.7.1:
|
||||
|
|
@ -11773,6 +12014,10 @@ snapshots:
|
|||
dependencies:
|
||||
character-entities: 2.0.2
|
||||
|
||||
decompress-response@6.0.0:
|
||||
dependencies:
|
||||
mimic-response: 3.1.0
|
||||
|
||||
dedent@1.7.2(babel-plugin-macros@3.1.0):
|
||||
optionalDependencies:
|
||||
babel-plugin-macros: 3.1.0
|
||||
|
|
@ -12410,6 +12655,12 @@ snapshots:
|
|||
|
||||
etag@1.8.1: {}
|
||||
|
||||
events-universal@1.0.1:
|
||||
dependencies:
|
||||
bare-events: 2.9.1
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
|
||||
eventsource-parser@3.0.6: {}
|
||||
|
||||
eventsource-parser@3.1.0: {}
|
||||
|
|
@ -12445,6 +12696,8 @@ snapshots:
|
|||
strip-final-newline: 4.0.0
|
||||
yoctocolors: 2.1.2
|
||||
|
||||
expand-template@2.0.3: {}
|
||||
|
||||
expand-tilde@2.0.2:
|
||||
dependencies:
|
||||
homedir-polyfill: 1.0.3
|
||||
|
|
@ -12495,6 +12748,8 @@ snapshots:
|
|||
|
||||
fast-deep-equal@3.1.3: {}
|
||||
|
||||
fast-fifo@1.3.2: {}
|
||||
|
||||
fast-glob@3.3.1:
|
||||
dependencies:
|
||||
'@nodelib/fs.stat': 2.0.5
|
||||
|
|
@ -12634,6 +12889,8 @@ snapshots:
|
|||
|
||||
fresh@2.0.0: {}
|
||||
|
||||
fs-constants@1.0.0: {}
|
||||
|
||||
fs-extra@11.3.4:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.11
|
||||
|
|
@ -12725,6 +12982,8 @@ snapshots:
|
|||
dependencies:
|
||||
resolve-pkg-maps: 1.0.0
|
||||
|
||||
github-from-package@0.0.0: {}
|
||||
|
||||
glob-parent@5.1.2:
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
|
@ -12924,6 +13183,8 @@ snapshots:
|
|||
hasown: 2.0.2
|
||||
side-channel: 1.1.0
|
||||
|
||||
iota-array@1.0.0: {}
|
||||
|
||||
ip-address@10.1.0: {}
|
||||
|
||||
ipaddr.js@1.9.1: {}
|
||||
|
|
@ -13812,6 +14073,8 @@ snapshots:
|
|||
|
||||
mimic-function@5.0.1: {}
|
||||
|
||||
mimic-response@3.1.0: {}
|
||||
|
||||
minimalistic-assert@1.0.1: {}
|
||||
|
||||
minimatch@10.2.4:
|
||||
|
|
@ -13832,6 +14095,14 @@ snapshots:
|
|||
|
||||
minimist@1.2.8: {}
|
||||
|
||||
minipass@7.1.3: {}
|
||||
|
||||
minizlib@3.1.0:
|
||||
dependencies:
|
||||
minipass: 7.1.3
|
||||
|
||||
mkdirp-classic@0.5.3: {}
|
||||
|
||||
module-definition@6.0.2:
|
||||
dependencies:
|
||||
ast-module-types: 6.0.2
|
||||
|
|
@ -13881,10 +14152,17 @@ snapshots:
|
|||
|
||||
nanoid@3.3.16: {}
|
||||
|
||||
napi-build-utils@2.0.0: {}
|
||||
|
||||
napi-postinstall@0.3.4: {}
|
||||
|
||||
natural-compare@1.4.0: {}
|
||||
|
||||
ndarray@1.0.19:
|
||||
dependencies:
|
||||
iota-array: 1.0.0
|
||||
is-buffer: 1.1.6
|
||||
|
||||
negotiator@1.0.0: {}
|
||||
|
||||
next-themes@0.4.6(react-dom@19.2.4(react@19.2.4))(react@19.2.4):
|
||||
|
|
@ -13917,6 +14195,12 @@ snapshots:
|
|||
- '@babel/core'
|
||||
- babel-plugin-macros
|
||||
|
||||
node-abi@3.94.0:
|
||||
dependencies:
|
||||
semver: 7.7.4
|
||||
|
||||
node-addon-api@6.1.0: {}
|
||||
|
||||
node-domexception@1.0.0: {}
|
||||
|
||||
node-fetch@3.3.2:
|
||||
|
|
@ -14010,6 +14294,13 @@ snapshots:
|
|||
dependencies:
|
||||
mimic-function: 5.0.1
|
||||
|
||||
onnxruntime-common@1.17.3: {}
|
||||
|
||||
onnxruntime-node@1.17.3:
|
||||
dependencies:
|
||||
onnxruntime-common: 1.17.3
|
||||
tar: 7.5.22
|
||||
|
||||
open@11.0.0:
|
||||
dependencies:
|
||||
default-browser: 5.5.0
|
||||
|
|
@ -14392,6 +14683,21 @@ snapshots:
|
|||
|
||||
powershell-utils@0.1.0: {}
|
||||
|
||||
prebuild-install@7.1.3:
|
||||
dependencies:
|
||||
detect-libc: 2.1.2
|
||||
expand-template: 2.0.3
|
||||
github-from-package: 0.0.0
|
||||
minimist: 1.2.8
|
||||
mkdirp-classic: 0.5.3
|
||||
napi-build-utils: 2.0.0
|
||||
node-abi: 3.94.0
|
||||
pump: 3.0.3
|
||||
rc: 1.2.8
|
||||
simple-get: 4.0.1
|
||||
tar-fs: 2.1.5
|
||||
tunnel-agent: 0.6.0
|
||||
|
||||
precinct@12.3.2:
|
||||
dependencies:
|
||||
'@dependents/detective-less': 5.0.3
|
||||
|
|
@ -15029,6 +15335,21 @@ snapshots:
|
|||
- supports-color
|
||||
- typescript
|
||||
|
||||
sharp@0.32.6:
|
||||
dependencies:
|
||||
color: 4.2.3
|
||||
detect-libc: 2.1.2
|
||||
node-addon-api: 6.1.0
|
||||
prebuild-install: 7.1.3
|
||||
semver: 7.7.4
|
||||
simple-get: 4.0.1
|
||||
tar-fs: 3.1.3
|
||||
tunnel-agent: 0.6.0
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
sharp@0.34.2:
|
||||
dependencies:
|
||||
color: 4.2.3
|
||||
|
|
@ -15137,6 +15458,14 @@ snapshots:
|
|||
|
||||
signal-exit@4.1.0: {}
|
||||
|
||||
simple-concat@1.0.1: {}
|
||||
|
||||
simple-get@4.0.1:
|
||||
dependencies:
|
||||
decompress-response: 6.0.0
|
||||
once: 1.4.0
|
||||
simple-concat: 1.0.1
|
||||
|
||||
simple-swizzle@0.2.4:
|
||||
dependencies:
|
||||
is-arrayish: 0.3.4
|
||||
|
|
@ -15203,6 +15532,15 @@ snapshots:
|
|||
|
||||
streamsearch@1.1.0: {}
|
||||
|
||||
streamx@2.28.0:
|
||||
dependencies:
|
||||
events-universal: 1.0.1
|
||||
fast-fifo: 1.3.2
|
||||
text-decoder: 1.2.7
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
strict-event-emitter@0.5.1: {}
|
||||
|
||||
string-width@4.2.3:
|
||||
|
|
@ -15364,6 +15702,59 @@ snapshots:
|
|||
|
||||
tapable@2.3.3: {}
|
||||
|
||||
tar-fs@2.1.5:
|
||||
dependencies:
|
||||
chownr: 1.1.4
|
||||
mkdirp-classic: 0.5.3
|
||||
pump: 3.0.3
|
||||
tar-stream: 2.2.0
|
||||
|
||||
tar-fs@3.1.3:
|
||||
dependencies:
|
||||
pump: 3.0.3
|
||||
tar-stream: 3.2.0
|
||||
optionalDependencies:
|
||||
bare-fs: 4.8.0
|
||||
bare-path: 3.1.1
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
tar-stream@2.2.0:
|
||||
dependencies:
|
||||
bl: 4.1.0
|
||||
end-of-stream: 1.4.5
|
||||
fs-constants: 1.0.0
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.2
|
||||
|
||||
tar-stream@3.2.0:
|
||||
dependencies:
|
||||
b4a: 1.8.1
|
||||
bare-fs: 4.8.0
|
||||
fast-fifo: 1.3.2
|
||||
streamx: 2.28.0
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
tar@7.5.22:
|
||||
dependencies:
|
||||
'@isaacs/fs-minipass': 4.0.1
|
||||
chownr: 3.0.0
|
||||
minipass: 7.1.3
|
||||
minizlib: 3.1.0
|
||||
yallist: 5.0.0
|
||||
|
||||
teex@1.0.1:
|
||||
dependencies:
|
||||
streamx: 2.28.0
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
temporal-polyfill@1.0.3:
|
||||
dependencies:
|
||||
temporal-spec: 1.0.1
|
||||
|
|
@ -15373,6 +15764,12 @@ snapshots:
|
|||
|
||||
temporal-utils@1.0.1: {}
|
||||
|
||||
text-decoder@1.2.7:
|
||||
dependencies:
|
||||
b4a: 1.8.1
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
thread-stream@3.1.0:
|
||||
dependencies:
|
||||
real-require: 0.2.0
|
||||
|
|
@ -15510,6 +15907,10 @@ snapshots:
|
|||
dependencies:
|
||||
tslib: 1.14.1
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
tw-animate-css@1.4.0: {}
|
||||
|
||||
type-check@0.4.0:
|
||||
|
|
@ -15954,6 +16355,8 @@ snapshots:
|
|||
|
||||
yallist@3.1.1: {}
|
||||
|
||||
yallist@5.0.0: {}
|
||||
|
||||
yaml@1.10.2: {}
|
||||
|
||||
yaml@2.9.0: {}
|
||||
|
|
@ -15988,6 +16391,8 @@ snapshots:
|
|||
dependencies:
|
||||
zod: 3.25.76
|
||||
|
||||
zod@3.21.4: {}
|
||||
|
||||
zod@3.25.76: {}
|
||||
|
||||
zod@4.3.6: {}
|
||||
|
|
|
|||
BIN
public/52396285023_561ffc0ff6_o.avif
Normal file
BIN
public/52396285023_561ffc0ff6_o.webp
Normal file
|
After Width: | Height: | Size: 316 KiB |
BIN
public/53569851134_02afc18fb4_o.avif
Normal file
BIN
public/53569851134_02afc18fb4_o.webp
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
public/JOA00162.avif
Normal file
BIN
public/JOA00162.webp
Normal file
|
After Width: | Height: | Size: 466 KiB |
BIN
public/Jeronimo.avif
Normal file
BIN
public/Jeronimo.webp
Normal file
|
After Width: | Height: | Size: 612 KiB |
BIN
public/Lula.avif
Normal file
BIN
public/Lula.webp
Normal file
|
After Width: | Height: | Size: 301 KiB |
BIN
public/Marca-Lula.avif
Normal file
BIN
public/Marca-Lula.webp
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
public/Prancheta 1@3x.png
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
public/Prancheta 2@3x.png
Normal file
|
After Width: | Height: | Size: 97 KiB |
BIN
public/Prancheta 3@3x.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
public/Prancheta 4@3x.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
public/Prancheta 5@3x.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
public/Prancheta 6@3x.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
public/RUI - 2-2.avif
Normal file
BIN
public/RUI - 2-2.webp
Normal file
|
After Width: | Height: | Size: 285 KiB |
BIN
public/WAGNER - 2-9 final.avif
Normal file
BIN
public/WAGNER - 2-9 final.webp
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
public/fundo.avif
Normal file
BIN
public/fundo.webp
Normal file
|
After Width: | Height: | Size: 138 KiB |
74
scripts/build-changelog.mjs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* build-changelog — regenerate docs/CHANGELOG-AGENTS.md from the per-delivery
|
||||
* entries in docs/changelog/ (OPS44). Deliveries write one
|
||||
* `<date>-<id>.md` file and run `pnpm changelog:build`; the aggregate keeps
|
||||
* the single readable "Recently resolved" history. Insert-only: historical
|
||||
* blocks are never touched.
|
||||
*
|
||||
* Usage: node scripts/build-changelog.mjs [--check]
|
||||
* --check verify the aggregate is up to date without writing (CI use)
|
||||
*/
|
||||
import { readdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import {
|
||||
buildChangelog,
|
||||
CHANGELOG_AGGREGATE,
|
||||
CHANGELOG_DIR,
|
||||
listChangelogEntries,
|
||||
} from './lib/changelog.mjs'
|
||||
|
||||
const repoRoot = process.cwd()
|
||||
const checkOnly = process.argv.includes('--check')
|
||||
|
||||
function die(message) {
|
||||
console.error(`[build-changelog] ${message}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const aggregatePath = join(repoRoot, CHANGELOG_AGGREGATE)
|
||||
const changelogDir = join(repoRoot, CHANGELOG_DIR)
|
||||
|
||||
let aggregateContent
|
||||
try {
|
||||
aggregateContent = readFileSync(aggregatePath, 'utf8')
|
||||
} catch {
|
||||
die(`não consegui ler ${CHANGELOG_AGGREGATE}`)
|
||||
}
|
||||
|
||||
let files
|
||||
try {
|
||||
files = readdirSync(changelogDir)
|
||||
} catch {
|
||||
die(`não consegui ler ${CHANGELOG_DIR}/`)
|
||||
}
|
||||
|
||||
const { entries, errors } = listChangelogEntries(files.map((name) => `${CHANGELOG_DIR}/${name}`))
|
||||
if (errors.length > 0) {
|
||||
die(`entradas inválidas em ${CHANGELOG_DIR}/:\n ${errors.join('\n ')}`)
|
||||
}
|
||||
|
||||
const bodies = entries.map(({ path }) => {
|
||||
try {
|
||||
return readFileSync(join(repoRoot, path), 'utf8')
|
||||
} catch {
|
||||
die(`não consegui ler ${path}`)
|
||||
}
|
||||
})
|
||||
|
||||
const next = buildChangelog({
|
||||
entries: bodies.map((content) => ({ content })),
|
||||
aggregateContent,
|
||||
})
|
||||
|
||||
if (checkOnly) {
|
||||
if (next !== aggregateContent) {
|
||||
die(`${CHANGELOG_AGGREGATE} desatualizado — rode \`pnpm changelog:build\``)
|
||||
}
|
||||
console.log('[build-changelog] ok — aggregate up to date')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
writeFileSync(aggregatePath, next)
|
||||
console.log(`[build-changelog] regenerado ${CHANGELOG_AGGREGATE} com ${entries.length} entrada(s)`)
|
||||
112
scripts/check-changelog-append-only.mjs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* check-changelog-append-only — CI guard (OPS44): the aggregated changelog
|
||||
* must never lose an existing line, and docs/changelog/ entries are
|
||||
* additions-only. Legitimate restorations (D8 pattern) and header rewrites
|
||||
* escape via the documented `changelog-rewrite:` token in the PR body.
|
||||
*
|
||||
* Paths from git diff (merge-base…HEAD); body from PR_BODY env or `gh pr
|
||||
* view` when PR_NUMBER is set. The escape is honored only when the diff
|
||||
* actually touches the aggregate or docs/changelog/, and only as a
|
||||
* standalone line (never the PR template's own checkbox text).
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import {
|
||||
assertChangelogAppendOnly,
|
||||
CHANGELOG_AGGREGATE,
|
||||
CHANGELOG_DIR,
|
||||
CHANGELOG_REWRITE_ESCAPE_RE,
|
||||
} from './lib/changelog.mjs'
|
||||
|
||||
const base = `origin/${process.env.GITHUB_BASE_REF ?? 'main'}`
|
||||
|
||||
function die(message) {
|
||||
console.error(`[check-changelog-append-only] ${message}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
function git(args) {
|
||||
return execFileSync('git', args, { encoding: 'utf8' }).trim()
|
||||
}
|
||||
|
||||
let mergeBase
|
||||
try {
|
||||
mergeBase = git(['merge-base', 'HEAD', base])
|
||||
} catch {
|
||||
die(`no merge-base with ${base} (shallow clone?)`)
|
||||
}
|
||||
|
||||
function listChangedPaths() {
|
||||
const raw = execFileSync(
|
||||
'git',
|
||||
['diff', '--name-status', `${mergeBase}...HEAD`, '--', CHANGELOG_AGGREGATE, CHANGELOG_DIR],
|
||||
{ encoding: 'utf8' },
|
||||
)
|
||||
|
||||
return raw
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function readPrBody() {
|
||||
if (process.env.PR_BODY !== undefined) {
|
||||
return process.env.PR_BODY
|
||||
}
|
||||
|
||||
const prNumber = process.env.PR_NUMBER ?? process.env.GITHUB_PR_NUMBER
|
||||
if (!prNumber) return ''
|
||||
|
||||
try {
|
||||
const json = execFileSync('gh', ['pr', 'view', String(prNumber), '--json', 'body'], {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
const parsed = JSON.parse(json)
|
||||
return typeof parsed.body === 'string' ? parsed.body : ''
|
||||
} catch (error) {
|
||||
const detail = error instanceof Error ? error.message : String(error)
|
||||
die(`failed to read PR #${prNumber} body via gh: ${detail}`)
|
||||
}
|
||||
}
|
||||
|
||||
const diffLines = listChangedPaths()
|
||||
if (diffLines.length === 0) {
|
||||
console.log('[check-changelog-append-only] ok — no changelog diff')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
// R (rename): status + old path + new path — use the new path.
|
||||
const changelogDiff = diffLines.map((line) => {
|
||||
const [status, ...rest] = line.split('\t')
|
||||
return { status, path: status.startsWith('R') ? rest[rest.length - 1] : rest.join('\t') }
|
||||
})
|
||||
|
||||
const body = readPrBody()
|
||||
if (CHANGELOG_REWRITE_ESCAPE_RE.test(body)) {
|
||||
console.log('[check-changelog-append-only] ok — changelog-rewrite escape in PR body')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
function blob(ref, path) {
|
||||
return execFileSync('git', ['show', `${ref}:${path}`], { encoding: 'utf8' })
|
||||
}
|
||||
|
||||
const aggregateDiff = changelogDiff.filter(({ path }) => path === CHANGELOG_AGGREGATE)
|
||||
const oldAggregate = aggregateDiff.length > 0 ? blob(mergeBase, CHANGELOG_AGGREGATE) : ''
|
||||
const newAggregate =
|
||||
aggregateDiff.length > 0 ? readFileSync(join(process.cwd(), CHANGELOG_AGGREGATE), 'utf8') : ''
|
||||
|
||||
const result = assertChangelogAppendOnly({
|
||||
oldAggregate,
|
||||
newAggregate,
|
||||
changelogDiff: changelogDiff.filter(({ path }) => path.startsWith(`${CHANGELOG_DIR}/`)),
|
||||
})
|
||||
|
||||
if (!result.ok) {
|
||||
die(result.message)
|
||||
}
|
||||
|
||||
console.log('[check-changelog-append-only] ok — changelog is append-only')
|
||||
68
scripts/check-docs-conflict-markers.mjs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* check-docs-conflict-markers — CI guard (OPS44): a PR diff touching
|
||||
* markdown/mdc files (docs/, AGENTS.md, .agents/, …) must not commit
|
||||
* conflict markers. Extends the OPS41 repo-wide scan
|
||||
* (tests/unit/codebaseConventions.unit.spec.ts, which shares the regex via
|
||||
* scripts/lib/conflictMarkers.mjs) to docs-only PRs, where the unit suite
|
||||
* is skipped (code_mode: none) — the exact class of the OPS41 incident
|
||||
* (a marker committed to AGENTS.md at the repo root).
|
||||
*
|
||||
* Paths from git diff (merge-base…HEAD) filtered to markdown-ish files.
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process'
|
||||
|
||||
import { findConflictMarkerLines, markdownPathsOf } from './lib/conflictMarkers.mjs'
|
||||
|
||||
const base = `origin/${process.env.GITHUB_BASE_REF ?? 'main'}`
|
||||
|
||||
function die(message) {
|
||||
console.error(`[check-docs-conflict-markers] ${message}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
function git(args) {
|
||||
return execFileSync('git', args, { encoding: 'utf8' }).trim()
|
||||
}
|
||||
|
||||
let mergeBase
|
||||
try {
|
||||
mergeBase = git(['merge-base', 'HEAD', base])
|
||||
} catch {
|
||||
die(`no merge-base with ${base} (shallow clone?)`)
|
||||
}
|
||||
|
||||
const raw = execFileSync(
|
||||
'git',
|
||||
['diff', '--name-only', '--diff-filter=ACMR', `${mergeBase}...HEAD`],
|
||||
{ encoding: 'utf8' },
|
||||
)
|
||||
const changedPaths = raw
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
const scannedPaths = markdownPathsOf(changedPaths)
|
||||
if (scannedPaths.length === 0) {
|
||||
console.log('[check-docs-conflict-markers] ok — no markdown changes')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const offenders = []
|
||||
for (const path of scannedPaths) {
|
||||
let content
|
||||
try {
|
||||
content = git(['show', `HEAD:${path}`])
|
||||
} catch {
|
||||
die(`failed to read HEAD:${path}`)
|
||||
}
|
||||
for (const { line } of findConflictMarkerLines(content)) {
|
||||
offenders.push(`${path}:${line}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (offenders.length > 0) {
|
||||
die(`marcadores de conflito em markdown:\n ${offenders.join('\n ')}`)
|
||||
}
|
||||
|
||||
console.log(`[check-docs-conflict-markers] ok — ${scannedPaths.length} markdown file(s) clean`)
|
||||
287
scripts/fill-image.mjs
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
/**
|
||||
* fill-image.mjs — completes/corrects a photo region with FLUX-2-dev on
|
||||
* DeepInfra, then chains the resize engine (avif + webp) on the result.
|
||||
*
|
||||
* Two flows, driven by the mask:
|
||||
* 1. `--extend <px|%>` — the photo has no room below (e.g. Lula cut off
|
||||
* mid-torso): the canvas is grown downward, the strip is filled white
|
||||
* and its mask is generated automatically (no painting by hand).
|
||||
* 2. `--mask <path>` — an explicit mask, white = regenerate, black =
|
||||
* preserve (same size as the photo), for arbitrary inpaint regions.
|
||||
*
|
||||
* The photo is sent as a PNG whose ALPHA CHANNEL is the mask (transparent =
|
||||
* regenerate, opaque = preserve — the FLUX-2 native convention), padded to
|
||||
* a multiple of 64 for the VAE. The white/black user mask is inverted into
|
||||
* alpha; the auto `--extend` mask is a transparent bottom strip.
|
||||
*
|
||||
* The model output (master PNG) lands in `data/ai-fill/` (gitignored) and
|
||||
* the resize engine writes the site assets into `--out` (default `public/`).
|
||||
*
|
||||
* Usage:
|
||||
* pnpm images:fill --photo lula.jpg --extend 40% --prompt "corpo completo de homem, terno cinza"
|
||||
* pnpm images:fill --photo lula.jpg --extend 600
|
||||
* pnpm images:fill --photo foto.png --mask mascara.png
|
||||
* pnpm images:fill --photo foto.jpg --mask m.png --no-resize --out draft/
|
||||
*
|
||||
* Needs DEEPINFRA_API_KEY (see .env.example). Each run spends a few cents
|
||||
* of API credits.
|
||||
*/
|
||||
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises'
|
||||
import { basename, join, parse, resolve } from 'node:path'
|
||||
import sharp from 'sharp'
|
||||
|
||||
import { dieWithLabel, loadCliEnv } from './lib/cli.mjs'
|
||||
import {
|
||||
FILL_INFERENCE_URL,
|
||||
FILL_MODEL,
|
||||
padToMultipleOf64,
|
||||
parseExtendPx,
|
||||
parseFillArgs,
|
||||
} from './lib/imageFill.mjs'
|
||||
import { runResizeImages } from './resize-images.mjs'
|
||||
|
||||
const die = dieWithLabel('images:fill')
|
||||
|
||||
const USAGE = `Uso: pnpm images:fill --photo <arquivo> (--extend <px|%> | --mask <mascara.png>) [opções]
|
||||
|
||||
Completa uma região da foto com FLUX-2-dev (DeepInfra) e depois roda o
|
||||
redimensionamento (avif + webp) na imagem resultante.
|
||||
|
||||
Modos:
|
||||
--extend <px|%> aumenta o canvas PELA BASE, preenchendo a faixa nova de
|
||||
branco, e gera a máscara dela sozinho — ideal quando o
|
||||
corpo foi cortado e não há espaço na foto (ex.: 40%)
|
||||
--mask <mascara> usa uma máscara sua (branco = regenerar, preto = manter),
|
||||
do mesmo tamanho da foto
|
||||
|
||||
Opções:
|
||||
--photo <arquivo> foto a editar (obrigatório)
|
||||
--prompt "..." o que gerar na região (default pronto para completar corpo)
|
||||
--steps <1-50> passos de geração (default 28; mais = melhor, mais caro)
|
||||
--out <dir> pasta dos avif/webp (default public/)
|
||||
--no-resize não roda o redimensionamento depois
|
||||
-h, --help mostra esta ajuda
|
||||
|
||||
Precisa de DEEPINFRA_API_KEY no .env.local (veja .env.example).
|
||||
O mestre PNG fica em data/ai-fill/ (fora do git).`
|
||||
|
||||
/**
|
||||
* Builds the PNG sent to the model using the img2img outpaint strategy:
|
||||
* the photo is placed on a white canvas grown by the strip (on `--extend`),
|
||||
* and the model is told to keep the photo EXACTLY as it is and only fill
|
||||
* the white area. DeepInfra's FLUX-2-dev ignores masks (alpha or a `mask`
|
||||
* field both re-render the whole image — verified empirically), but with a
|
||||
* clear white "void" + a hard preservation prompt it keeps the photo and
|
||||
* only generates into the strip. With `--mask` the user's marked region is
|
||||
* itself whitened out, so it plays the same "void" role.
|
||||
*
|
||||
* The canvas is padded to a multiple of 64 for the VAE and the padding
|
||||
* (`crop`) is cut away after the fill.
|
||||
*
|
||||
* @param {string} photo
|
||||
* @param {string | null} maskPath
|
||||
* @param {string | null} extend
|
||||
* @returns {Promise<{ imageUri: string, width: number, height: number, crop: { left: number, top: number, width: number, height: number } }>}
|
||||
*/
|
||||
const buildFillInputs = async (photo, maskPath, extend) => {
|
||||
const photoBuffer = await sharp(await readFile(photo))
|
||||
.rotate()
|
||||
.toBuffer()
|
||||
const { width, height } = await sharp(photoBuffer).metadata()
|
||||
const extendPx = extend !== null ? extendPxOf(extend, height) : 0
|
||||
const canvasHeight = height + extendPx
|
||||
// The native endpoint refuses canvases beyond ~2 MP (and bills per pixel).
|
||||
// Scale down huge photos (e.g. 27 MP camera files) to a pre-pad budget so
|
||||
// the padded multiple-of-64 canvas stays under the cap.
|
||||
const scale = Math.min(1, Math.sqrt(FILL_MAX_PIXELS / (width * canvasHeight)))
|
||||
const photoW = Math.max(1, Math.floor(width * scale))
|
||||
const photoH = Math.max(1, Math.floor(height * scale))
|
||||
const canvasH = Math.max(1, Math.floor(canvasHeight * scale))
|
||||
const pad = padToMultipleOf64(photoW, canvasH)
|
||||
|
||||
const rgb = await sharp({
|
||||
create: { width: pad.width, height: pad.height, channels: 3, background: '#ffffff' },
|
||||
})
|
||||
.composite([
|
||||
{
|
||||
input: await sharp(photoBuffer)
|
||||
.resize({ width: photoW, height: photoH, fit: 'fill' })
|
||||
.png()
|
||||
.toBuffer(),
|
||||
left: 0,
|
||||
top: 0,
|
||||
},
|
||||
])
|
||||
.png()
|
||||
.toBuffer()
|
||||
const { data: rgbData } = await sharp(rgb).raw().toBuffer({ resolveWithObject: true })
|
||||
|
||||
if (extend === null) {
|
||||
const userMask = await sharp(await readFile(maskPath))
|
||||
.rotate()
|
||||
.toBuffer()
|
||||
const { width: maskWidth, height: maskHeight } = await sharp(userMask).metadata()
|
||||
if (maskWidth !== width || maskHeight !== height) {
|
||||
die(
|
||||
`a máscara ${basename(maskPath)} tem ${maskWidth}×${maskHeight}, mas a foto tem ${width}×${height} — use o mesmo tamanho`,
|
||||
)
|
||||
}
|
||||
const { data: luma } = await sharp(userMask)
|
||||
.resize({ width: photoW, height: photoH, fit: 'fill' })
|
||||
.greyscale()
|
||||
.raw()
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
for (let i = 0; i < photoW * photoH; i += 1) {
|
||||
if (luma[i] > 127) {
|
||||
rgbData[i * 3] = 255
|
||||
rgbData[i * 3 + 1] = 255
|
||||
rgbData[i * 3 + 2] = 255
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const png = await sharp(rgbData, {
|
||||
raw: { width: pad.width, height: pad.height, channels: 3 },
|
||||
})
|
||||
.png()
|
||||
.toBuffer()
|
||||
return {
|
||||
imageUri: `data:image/png;base64,${png.toString('base64')}`,
|
||||
width: pad.width,
|
||||
height: pad.height,
|
||||
crop: { left: 0, top: 0, width: photoW, height: canvasH },
|
||||
}
|
||||
}
|
||||
|
||||
/** Resolves the `--extend` value against a photo height once (shared by callers). */
|
||||
const extendPxOf = (extend, photoHeight) =>
|
||||
parseExtendPx(extend) * (extend.endsWith('%') ? Math.round(photoHeight / 100) : 1)
|
||||
|
||||
/** Pre-pad canvas budget: keeps the padded multiple-of-64 canvas under ~2 MP. */
|
||||
const FILL_MAX_PIXELS = 1_800_000
|
||||
|
||||
/**
|
||||
* Extracts the generated image from the OpenAI-images response shapes
|
||||
* (`data[].b64_json` / `.url`) with fallbacks for other shapes DeepInfra
|
||||
* returns (bare string, `images[]` data URIs).
|
||||
*
|
||||
* @param {unknown} payload
|
||||
* @returns {string | null} base64 image data
|
||||
*/
|
||||
const extractOutputBase64 = (payload) => {
|
||||
if (payload && typeof payload === 'object') {
|
||||
const data = payload.data
|
||||
if (Array.isArray(data)) {
|
||||
for (const item of data) {
|
||||
if (item && typeof item === 'object') {
|
||||
if (typeof item.b64_json === 'string') return item.b64_json
|
||||
if (typeof item.url === 'string') return item.url
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(payload.images)) {
|
||||
for (const item of payload.images) {
|
||||
if (typeof item === 'string') return item.replace(/^data:image\/[a-z0-9+]+;base64,/, '')
|
||||
}
|
||||
}
|
||||
if (Array.isArray(payload.output)) return extractOutputBase64({ data: payload.output })
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const options = parseFillArgs(process.argv.slice(2))
|
||||
if (options.help) {
|
||||
console.log(USAGE)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
loadCliEnv()
|
||||
const apiKey = process.env.DEEPINFRA_API_KEY
|
||||
if (!apiKey) {
|
||||
die('DEEPINFRA_API_KEY não configurada — veja .env.example')
|
||||
}
|
||||
|
||||
const photo = resolve(options.photo)
|
||||
try {
|
||||
await stat(photo)
|
||||
} catch {
|
||||
die(`${options.photo} não existe`)
|
||||
}
|
||||
|
||||
const { imageUri, width, height, crop } = await buildFillInputs(
|
||||
photo,
|
||||
options.mask !== null ? resolve(options.mask) : null,
|
||||
options.extend,
|
||||
)
|
||||
console.log(
|
||||
`\n[images:fill] ${basename(photo)} → canvas ${width}×${height} (${FILL_MODEL}, ${options.steps} passos)\n`,
|
||||
)
|
||||
|
||||
// Hard preservation clause first: FLUX-2 keeps the photo only when told
|
||||
// in no uncertain terms to leave it untouched (img2img outpaint strategy).
|
||||
const prompt = `Mantenha a fotografia EXATAMENTE como está, sem alterar um único detalhe fora da área a completar. ${options.prompt}`
|
||||
const body = {
|
||||
prompt,
|
||||
image: imageUri,
|
||||
width,
|
||||
height,
|
||||
steps: options.steps,
|
||||
guidance: 30,
|
||||
}
|
||||
let response
|
||||
try {
|
||||
response = await fetch(FILL_INFERENCE_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(180_000),
|
||||
})
|
||||
} catch (error) {
|
||||
die(`falha ao chamar o DeepInfra: ${error instanceof Error ? error.message : String(error)}`)
|
||||
}
|
||||
|
||||
const payload = await response.json().catch(() => null)
|
||||
if (!response.ok) {
|
||||
const detail =
|
||||
payload && typeof payload === 'object' && 'error' in payload
|
||||
? String(payload.error)
|
||||
: `HTTP ${response.status}`
|
||||
die(`DeepInfra respondeu erro: ${detail}`)
|
||||
}
|
||||
|
||||
const base64 = extractOutputBase64(payload)
|
||||
if (!base64) {
|
||||
die('resposta inesperada do DeepInfra (sem imagem no output)')
|
||||
}
|
||||
|
||||
const masterDir = resolve('data/ai-fill')
|
||||
await mkdir(masterDir, { recursive: true })
|
||||
const masterPath = join(masterDir, `${parse(photo).name}-fill.png`)
|
||||
const masterBuffer = await sharp(
|
||||
Buffer.from(base64.replace(/^data:image\/[a-z0-9+]+;base64,/, ''), 'base64'),
|
||||
)
|
||||
.extract(crop)
|
||||
.png()
|
||||
.toBuffer()
|
||||
await writeFile(masterPath, masterBuffer)
|
||||
const { width: outWidth, height: outHeight } = await sharp(masterPath).metadata()
|
||||
console.log(`[images:fill] mestre em ${masterPath} (${outWidth}×${outHeight})\n`)
|
||||
|
||||
if (options.resize) {
|
||||
await runResizeImages({
|
||||
help: false,
|
||||
paths: [masterPath],
|
||||
maxWidth: undefined,
|
||||
quality: undefined,
|
||||
formats: ['avif', 'webp'],
|
||||
outDir: resolve(options.outDir),
|
||||
removeBg: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => die(error instanceof Error ? error.message : String(error)))
|
||||
|
|
@ -149,9 +149,9 @@ const main = async () => {
|
|||
run('playwright install chromium', 'pnpm', ['exec', 'playwright', 'install', 'chromium'])
|
||||
run('e2e migrate', 'pnpm', ['migrate'], dbEnv)
|
||||
run('e2e seed:minimal', 'pnpm', ['db:seed:minimal'], dbEnv)
|
||||
run('e2e build', 'pnpm', ['build'], { ...dbEnv, NEXT_DIST_DIR: '.next/e2e' })
|
||||
run('e2e build', 'pnpm', ['build'], { ...dbEnv, NEXT_DIST_DIR: '.next-e2e' })
|
||||
|
||||
const e2eEnv = { ...dbEnv, E2E_PROD: '1', CI: '1', NEXT_DIST_DIR: '.next/e2e' }
|
||||
const e2eEnv = { ...dbEnv, E2E_PROD: '1', CI: '1', NEXT_DIST_DIR: '.next-e2e' }
|
||||
if (scope.e2e.mode === 'full') {
|
||||
run('test:e2e (full)', 'pnpm', ['test:e2e'], e2eEnv)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ export const buildPoolWorkerPrompt = ({ issueNumber, issueTitle, issueId, planPa
|
|||
: '2. O body da Issue é a spec de intenção (não há plano linkado). Em Plan mode, escreva mesmo assim um `docs/plans/<id>-impl.md` a partir do body.',
|
||||
'3. Execute o impl plan. Gates: `pnpm gate:fast` na iteração; entrega com `pnpm push` (não `git push` nu). Comandos bare, nunca piped.',
|
||||
'4. Rode `/simplify` completo; `capture-review-debts` em modo autônomo (só expensive_lock ≥4).',
|
||||
`5. PR obrigatoriamente com \`gh pr create --base main\` e "Closes #${issueNumber}" no body (Ready, nunca draft).`,
|
||||
'6. `gh pr merge --auto --merge <PR>` e acompanhe `gh pr checks <PR> --watch --required` até o merge. Falha de CI no seu PR é sua (docs/AGENT-OPS.md — "Dono do PR, dono do CI"): corrija na mesma branch.',
|
||||
`5. PR obrigatoriamente com \`gh pr create --base main\` e "Closes #${issueNumber}" no body (Ready, nunca draft). Escreva a entrada do changelog (\`docs/changelog/<data>-<id>.md\` + \`pnpm changelog:build\`) antes do push (OPS44).`,
|
||||
'6. `gh pr merge --auto --rebase <PR>` e acompanhe `gh pr checks <PR> --watch --required` até o merge. Falha de CI no seu PR é sua (docs/AGENT-OPS.md — "Dono do PR, dono do CI"): corrija na mesma branch.',
|
||||
'',
|
||||
'## Proibido',
|
||||
'',
|
||||
|
|
|
|||
218
scripts/lib/changelog.mjs
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/**
|
||||
* changelog — pure policy for the per-delivery changelog format (OPS44).
|
||||
*
|
||||
* Deliveries write `docs/changelog/<date>-<id>.md` (one entry per file,
|
||||
* immune to merge conflicts by construction — same pattern as docs/plans/).
|
||||
* `pnpm changelog:build` inserts those entries into the single readable
|
||||
* docs/CHANGELOG-AGENTS.md in chronological position, keeping the
|
||||
* "Recently resolved" reading intact. The build is insert-only: it never
|
||||
* removes or rewrites existing blocks (historical entries stay as-is —
|
||||
* OPS44 scope), so the aggregate is append-only by construction. CI guards
|
||||
* that property (scripts/check-changelog-append-only.mjs) and that docs
|
||||
* diffs never carry conflict markers
|
||||
* (scripts/check-docs-conflict-markers.mjs).
|
||||
*/
|
||||
|
||||
export const CHANGELOG_DIR = 'docs/changelog'
|
||||
export const CHANGELOG_AGGREGATE = 'docs/CHANGELOG-AGENTS.md'
|
||||
|
||||
/** `2026-08-13-ops44.md` — date desc, then id asc. */
|
||||
const ENTRY_FILE_RE = /^(\d{4})-(\d{2})-(\d{2})-([a-z0-9-]+)\.md$/
|
||||
|
||||
/** Leading line of a "Recently resolved" entry block. */
|
||||
const ENTRY_BLOCK_RE = /^\*\*Recently resolved \((\d{4}-\d{2}-\d{2})\)/
|
||||
|
||||
/**
|
||||
* `changelog-rewrite: <motivo>` — standalone-line escape in the PR body for
|
||||
* legitimate aggregate loss (header rewrites, D8-style restorations). Kept
|
||||
* in the lib so the CLI and unit tests share one spelling. The template's
|
||||
* own checkbox text ("`changelog-rewrite: <motivo>` no body") must NOT
|
||||
* match — hence the line anchor.
|
||||
*/
|
||||
export const CHANGELOG_REWRITE_ESCAPE_RE = /^\s*changelog-rewrite\s*:/im
|
||||
|
||||
/**
|
||||
* @param {string} filename - basename of a file inside docs/changelog/
|
||||
* @returns {{ date: string, id: string } | null}
|
||||
*/
|
||||
export function parseChangelogEntryName(filename) {
|
||||
const match = ENTRY_FILE_RE.exec(filename)
|
||||
if (!match) return null
|
||||
const [, year, month, day, id] = match
|
||||
const m = Number(month)
|
||||
const d = Number(day)
|
||||
if (m < 1 || m > 12 || d < 1 || d > 31) return null
|
||||
const check = new Date(Date.UTC(Number(year), m - 1, d))
|
||||
if (
|
||||
check.getUTCFullYear() !== Number(year) ||
|
||||
check.getUTCMonth() !== m - 1 ||
|
||||
check.getUTCDate() !== d
|
||||
) {
|
||||
return null
|
||||
}
|
||||
return { date: `${year}-${month}-${day}`, id }
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters and validates a list of paths inside docs/changelog/.
|
||||
* Any .md file that does not match the entry pattern fails closed (the
|
||||
* folder is dedicated; garbage would silently drop out of the aggregate).
|
||||
*
|
||||
* @param {string[]} paths - repo-relative paths under docs/changelog/
|
||||
* @returns {{ entries: { path: string, name: string, date: string, id: string }[],
|
||||
* errors: string[] }}
|
||||
*/
|
||||
export function listChangelogEntries(paths) {
|
||||
const entries = []
|
||||
const errors = []
|
||||
for (const path of paths) {
|
||||
const name = path.split('/').pop() ?? ''
|
||||
if (!name.endsWith('.md')) continue
|
||||
const parsed = parseChangelogEntryName(name)
|
||||
if (!parsed) {
|
||||
errors.push(`${path} — não casa o padrão <YYYY-MM-DD>-<id>.md`)
|
||||
continue
|
||||
}
|
||||
entries.push({ path, name, ...parsed })
|
||||
}
|
||||
entries.sort((a, b) => {
|
||||
if (a.date !== b.date) return a.date < b.date ? 1 : -1
|
||||
return a.id.localeCompare(b.id)
|
||||
})
|
||||
return { entries, errors }
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the aggregate into its static header (everything up to and
|
||||
* including the first `---` line) and the existing entry blocks (separated
|
||||
* by blank lines, trailing whitespace trimmed).
|
||||
*
|
||||
* @param {string} aggregateContent - current docs/CHANGELOG-AGENTS.md
|
||||
* @returns {{ header: string, blocks: string[] }}
|
||||
*/
|
||||
export function splitChangelogBody(aggregateContent) {
|
||||
const lines = aggregateContent.split('\n')
|
||||
const separatorIndex = lines.findIndex((line) => line === '---')
|
||||
if (separatorIndex === -1) {
|
||||
throw new Error('CHANGELOG-AGENTS.md sem separador "---" no cabeçalho')
|
||||
}
|
||||
const header = lines.slice(0, separatorIndex + 1).join('\n')
|
||||
const body = lines
|
||||
.slice(separatorIndex + 1)
|
||||
.join('\n')
|
||||
.replace(/^\n+/, '')
|
||||
const blocks = body
|
||||
.split('\n\n')
|
||||
.map((block) => block.trimEnd())
|
||||
.filter(Boolean)
|
||||
return { header, blocks }
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the aggregate content by inserting entry contents into their
|
||||
* chronological position (date comes from each entry's own
|
||||
* "Recently resolved (date)" header, not from callers). Insert-only:
|
||||
* existing blocks are never removed or rewritten; an entry whose exact
|
||||
* text already exists is skipped (idempotent). Entries without a dated
|
||||
* header go to the top.
|
||||
*
|
||||
* @param {{ entries: { content: string }[],
|
||||
* aggregateContent: string }} input - entries sorted date desc;
|
||||
* current aggregate (source of header/blocks)
|
||||
* @returns {string} - full aggregate content (trailing newline)
|
||||
*/
|
||||
export function buildChangelog({ entries, aggregateContent }) {
|
||||
const { header, blocks } = splitChangelogBody(aggregateContent)
|
||||
|
||||
const nextBlocks = [...blocks]
|
||||
for (const entry of entries) {
|
||||
const text = entry.content.trimEnd()
|
||||
if (nextBlocks.some((block) => block === text)) continue
|
||||
|
||||
const entryDate = entryDateOf(text)
|
||||
const insertAt = entryDate
|
||||
? nextBlocks.findIndex(
|
||||
(block) => entryDateOf(block) !== null && entryDateOf(block) < entryDate,
|
||||
)
|
||||
: 0
|
||||
nextBlocks.splice(insertAt === -1 ? nextBlocks.length : insertAt, 0, text)
|
||||
}
|
||||
|
||||
return [header, ...nextBlocks].join('\n\n') + '\n'
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} block - an entry block starting with the resolved header
|
||||
* @returns {string | null} - entry date when the header matches
|
||||
*/
|
||||
export function entryDateOf(block) {
|
||||
const match = ENTRY_BLOCK_RE.exec(block)
|
||||
return match ? match[1] : null
|
||||
}
|
||||
|
||||
/**
|
||||
* Append-only policy for the changelog (CI guard).
|
||||
*
|
||||
* The aggregate must never lose an existing line: every line of the old
|
||||
* content must still appear in the new content with equal or greater
|
||||
* count (multiset inclusion — honest under line moves/reordering, unlike
|
||||
* a diff parser). Files under docs/changelog/ must be additions only
|
||||
* (entries are immutable once committed; a deletion or modification is a
|
||||
* silent data-loss path).
|
||||
*
|
||||
* Legitimate restorations (D8-style) and header rewrites escape via the
|
||||
* documented `changelog-rewrite:` token in the PR body (see AGENT-OPS).
|
||||
*
|
||||
* @param {{ oldAggregate: string, newAggregate: string,
|
||||
* changelogDiff: { status: string, path: string }[] }} input
|
||||
* @returns {{ ok: true } | { ok: false, message: string }}
|
||||
*/
|
||||
export function assertChangelogAppendOnly({ oldAggregate, newAggregate, changelogDiff }) {
|
||||
const missing = missingLines(oldAggregate, newAggregate)
|
||||
if (missing.length > 0) {
|
||||
return {
|
||||
ok: false,
|
||||
message:
|
||||
`docs/CHANGELOG-AGENTS.md não é append-only: ${missing.length} linha(s) existente(s) ` +
|
||||
`somem (ex.: ${JSON.stringify(missing[0])}). Restaurações legítimas: use ` +
|
||||
'`changelog-rewrite: <motivo>` no body do PR (linha própria; definição em AGENT-OPS).',
|
||||
}
|
||||
}
|
||||
|
||||
const touched = changelogDiff.filter((change) => change.status !== 'A')
|
||||
if (touched.length > 0) {
|
||||
return {
|
||||
ok: false,
|
||||
message:
|
||||
`docs/changelog/ não é additions-only: ${touched
|
||||
.map((change) => `${change.status} ${change.path}`)
|
||||
.join(', ')}. Entradas são imutáveis; restaurações legítimas: use ` +
|
||||
'`changelog-rewrite: <motivo>` no body do PR (linha própria; definição em AGENT-OPS).',
|
||||
}
|
||||
}
|
||||
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} oldContent
|
||||
* @param {string} newContent
|
||||
* @returns {string[]} - distinct old lines missing or under-counted in new
|
||||
*/
|
||||
export function missingLines(oldContent, newContent) {
|
||||
const counts = new Map()
|
||||
for (const line of newContent.split('\n')) {
|
||||
counts.set(line, (counts.get(line) ?? 0) + 1)
|
||||
}
|
||||
|
||||
const missing = []
|
||||
for (const line of oldContent.split('\n')) {
|
||||
const remaining = counts.get(line) ?? 0
|
||||
if (remaining <= 0) {
|
||||
missing.push(line)
|
||||
} else {
|
||||
counts.set(line, remaining - 1)
|
||||
}
|
||||
}
|
||||
return [...new Set(missing)]
|
||||
}
|
||||
44
scripts/lib/conflictMarkers.mjs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* conflictMarkers — shared conflict-marker policy for docs diffs (OPS44).
|
||||
*
|
||||
* The regex started as the OPS41 guardrail inside
|
||||
* tests/unit/codebaseConventions.unit.spec.ts (repo-wide scan of tracked
|
||||
* files). OPS44 extracts it here so the unit spec and the CI docs guard
|
||||
* (scripts/check-docs-conflict-markers.mjs) share one source — don't twin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A real git conflict was committed to AGENTS.md twice: the OPS33 commit
|
||||
* carried `<<<<<<< HEAD` plus a mangled `> > > > > > >` closer (the
|
||||
* `=======` was deleted in the same bad resolution), and OPS37 inherited
|
||||
* the state. The `(?:> ){7}` form is the exact corrupted closer that
|
||||
* shipped; a genuine 7-deep nested blockquote would need a deliberate
|
||||
* allowlist.
|
||||
*/
|
||||
export const CONFLICT_MARKER_RE = /^\s*<<<<<<<(?:\s|$)|^\s*>>>>>>>(?:\s|$)|^\s*(?:> ){7}/m
|
||||
|
||||
/**
|
||||
* @param {string} content - file content to scan
|
||||
* @returns {{ line: number, text: string }[]} - 1-based offending lines
|
||||
*/
|
||||
export function findConflictMarkerLines(content) {
|
||||
const offenders = []
|
||||
const lines = content.split('\n')
|
||||
for (const [index, line] of lines.entries()) {
|
||||
if (CONFLICT_MARKER_RE.test(line)) {
|
||||
offenders.push({ line: index + 1, text: line })
|
||||
}
|
||||
}
|
||||
return offenders
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} paths - repo-relative changed paths
|
||||
* @returns {string[]} - the markdown-ish paths (docs/, AGENTS.md, .agents/ …)
|
||||
*
|
||||
* The OPS41 incident file was AGENTS.md at the repo root, so the CI guard
|
||||
* must not be limited to docs/: any changed markdown/mdc can carry markers.
|
||||
*/
|
||||
export function markdownPathsOf(paths) {
|
||||
return paths.filter((path) => /\.(?:md|mdx|mdc)$/i.test(path))
|
||||
}
|
||||
158
scripts/lib/imageFill.mjs
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
/**
|
||||
* Pure derivation for `scripts/fill-image.mjs` — argument parsing, canvas
|
||||
* extension math and prompt defaults, unit-tested like the rest of
|
||||
* `scripts/lib/`. The CLI itself only threads sharp + the DeepInfra call
|
||||
* through these decisions.
|
||||
*/
|
||||
|
||||
/** DeepInfra model that fills masked regions with text guidance. */
|
||||
export const FILL_MODEL = 'black-forest-labs/FLUX-2-dev'
|
||||
|
||||
/** Native DeepInfra inference endpoint for `FILL_MODEL` (accepts arbitrary multiples of 64). */
|
||||
export const FILL_INFERENCE_URL = `https://api.deepinfra.com/v1/inference/${FILL_MODEL}`
|
||||
|
||||
/** When the photo is extended, the white strip below is the void to fill — this is the prompt. */
|
||||
export const EXTEND_DEFAULT_PROMPT =
|
||||
'Continue a imagem apenas na área branca abaixo: complete o corpo da pessoa de forma realista e coerente com a cena, com as mesmas roupas, iluminação, cores e estilo da foto, sem elementos novos.'
|
||||
|
||||
/** When an explicit mask is given, only the marked (whitened) region is regenerated. */
|
||||
export const MASK_DEFAULT_PROMPT =
|
||||
'Regenere apenas a área branca marcada, de forma natural e coerente com a cena, preservando roupas, iluminação, cores e estilo da foto original.'
|
||||
|
||||
/**
|
||||
* Parses `--extend` values: a plain integer is pixels, `30%` is a share of
|
||||
* the photo height. Returns null when the value is not one of those shapes.
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {number | null}
|
||||
*/
|
||||
export const parseExtendPx = (value) => {
|
||||
const percent = /^(\d{1,3})%$/.exec(value.trim())
|
||||
if (percent) return Number(percent[1])
|
||||
const px = Number(value.trim())
|
||||
if (Number.isInteger(px) && px > 0) return px
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Bottom-strip extension for a canvas. `extendPx` may be pixels or a
|
||||
* percentage of the photo height (already resolved by the caller via
|
||||
* `parseExtendPx` + height).
|
||||
*
|
||||
* @param {number} width
|
||||
* @param {number} height
|
||||
* @param {number} extendPx
|
||||
* @returns {{ width: number, height: number, offsetY: number }}
|
||||
*/
|
||||
export const extendedCanvas = (width, height, extendPx) => ({
|
||||
width,
|
||||
height: height + extendPx,
|
||||
offsetY: height,
|
||||
})
|
||||
|
||||
/**
|
||||
* The FLUX VAE needs dimensions that are multiples of 64. Pads a canvas up
|
||||
* to the next multiple on each axis; the padding is masked OPAQUE
|
||||
* (preserved) and cropped away after the fill, so the final image is
|
||||
* exactly the canvas the caller built.
|
||||
*
|
||||
* @param {number} width
|
||||
* @param {number} height
|
||||
* @returns {{ width: number, height: number, padRight: number, padBottom: number }}
|
||||
*/
|
||||
export const padToMultipleOf64 = (width, height) => ({
|
||||
width: Math.ceil(width / 64) * 64,
|
||||
height: Math.ceil(height / 64) * 64,
|
||||
padRight: Math.ceil(width / 64) * 64 - width,
|
||||
padBottom: Math.ceil(height / 64) * 64 - height,
|
||||
})
|
||||
|
||||
const VALUE_FLAGS = new Set(['--photo', '--mask', '--extend', '--prompt', '--out', '--steps'])
|
||||
|
||||
const BOOLEAN_FLAGS = new Set(['--no-resize'])
|
||||
|
||||
const HELP_FLAGS = new Set(['--help', '-h'])
|
||||
|
||||
/**
|
||||
* Parses CLI argv into options. Throws with a human-readable message on any
|
||||
* unknown flag or invalid value (fail closed — a typo must not silently
|
||||
* fall back to a default).
|
||||
*
|
||||
* @param {string[]} argv - `process.argv.slice(2)`
|
||||
* @returns {{ photo: string, mask: string | null, extend: string | null, prompt: string, steps: number, outDir: string, resize: boolean, help: boolean }}
|
||||
*/
|
||||
export const parseFillArgs = (argv) => {
|
||||
const options = {
|
||||
help: false,
|
||||
photo: undefined,
|
||||
mask: null,
|
||||
extend: null,
|
||||
prompt: undefined,
|
||||
steps: 28,
|
||||
outDir: 'public',
|
||||
resize: true,
|
||||
}
|
||||
|
||||
for (let i = 0; i < argv.length; i += 1) {
|
||||
const arg = argv[i]
|
||||
if (HELP_FLAGS.has(arg)) {
|
||||
options.help = true
|
||||
continue
|
||||
}
|
||||
if (BOOLEAN_FLAGS.has(arg)) {
|
||||
options.resize = false
|
||||
continue
|
||||
}
|
||||
const [flag, inlineValue] = arg.startsWith('--') ? arg.split('=') : [null, null]
|
||||
if (flag !== null && VALUE_FLAGS.has(flag)) {
|
||||
const value = inlineValue ?? argv[i + 1]
|
||||
if (inlineValue === undefined) i += 1
|
||||
if (value === undefined || value === '' || value.startsWith('--')) {
|
||||
throw new Error(`flag ${flag} espera um valor (ex.: ${flag}=valor ou ${flag} valor)`)
|
||||
}
|
||||
if (flag === '--photo') {
|
||||
options.photo = value
|
||||
} else if (flag === '--mask') {
|
||||
options.mask = value
|
||||
} else if (flag === '--extend') {
|
||||
if (parseExtendPx(value) === null) {
|
||||
throw new Error(
|
||||
`--extend inválido: ${JSON.stringify(value)} (esperado pixels, ex.: 400, ou percentual, ex.: 30%)`,
|
||||
)
|
||||
}
|
||||
options.extend = value
|
||||
} else if (flag === '--prompt') {
|
||||
options.prompt = value
|
||||
} else if (flag === '--steps') {
|
||||
const steps = Number(value)
|
||||
if (!Number.isInteger(steps) || steps < 1 || steps > 50) {
|
||||
throw new Error(`--steps inválido: ${JSON.stringify(value)} (esperado 1..50)`)
|
||||
}
|
||||
options.steps = steps
|
||||
} else {
|
||||
options.outDir = value
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (flag !== null && !HELP_FLAGS.has(arg)) {
|
||||
throw new Error(`flag desconhecida: ${JSON.stringify(arg)} (veja --help)`)
|
||||
}
|
||||
throw new Error(`argumento posicional não esperado: ${JSON.stringify(arg)} (veja --help)`)
|
||||
}
|
||||
|
||||
if (!options.help) {
|
||||
if (options.photo === undefined) {
|
||||
throw new Error('--photo é obrigatório (veja --help)')
|
||||
}
|
||||
if (options.mask === null && options.extend === null) {
|
||||
throw new Error('informe --mask (região pintada de branco) ou --extend (aumentar embaixo)')
|
||||
}
|
||||
if (options.mask !== null && options.extend !== null) {
|
||||
throw new Error('--mask e --extend são mutuamente exclusivos — escolha um')
|
||||
}
|
||||
options.prompt =
|
||||
options.prompt ?? (options.extend !== null ? EXTEND_DEFAULT_PROMPT : MASK_DEFAULT_PROMPT)
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
182
scripts/lib/imageResize.mjs
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
/**
|
||||
* Pure derivation for `scripts/resize-images.mjs` — argument parsing,
|
||||
* format/quality policy and output-name derivation, unit-tested like the
|
||||
* rest of `scripts/lib/`. The CLI itself only threads `sharp` through these
|
||||
* decisions, so nothing here imports sharp or touches the filesystem.
|
||||
*/
|
||||
|
||||
import { parse } from 'node:path'
|
||||
|
||||
/** 2× the reference desktop viewport (1920px) — retina-grade site assets. */
|
||||
const MAX_WEB_WIDTH = 3840
|
||||
|
||||
/**
|
||||
* Max width per format: AVIF serves the site at retina grade (2× desktop),
|
||||
* while WebP/JPEG are the draft/compatibility companions (PenPot, email,
|
||||
* older browsers) and can stay at 1× — a quarter of the pixels, so the
|
||||
* design tool never has to chew on multi-MB files.
|
||||
*/
|
||||
export const FORMAT_MAX_WIDTHS = { avif: MAX_WEB_WIDTH, webp: 1920, jpeg: 1920 }
|
||||
|
||||
/** Width to use for a format — an explicit `--max-width` wins over the per-format default. */
|
||||
export const maxWidthFor = (format, override) =>
|
||||
override ?? FORMAT_MAX_WIDTHS[format] ?? MAX_WEB_WIDTH
|
||||
|
||||
/** Output formats sharp can encode for the browser, in order of preference. */
|
||||
const SUPPORTED_FORMATS = ['avif', 'webp', 'jpeg']
|
||||
|
||||
/**
|
||||
* The default output set: AVIF for the site (lightest modern format) plus
|
||||
* WebP as the broadly accepted companion — design tools such as PenPot and
|
||||
* older browsers do not open AVIF.
|
||||
*/
|
||||
const DEFAULT_FORMATS = ['avif', 'webp']
|
||||
|
||||
/** Extension per normalized format (jpeg keeps the compact `.jpg`). */
|
||||
const FORMAT_EXTENSIONS = { avif: '.avif', webp: '.webp', jpeg: '.jpg' }
|
||||
|
||||
/** Sharp quality defaults per format (AVIF compresses far better than WebP). */
|
||||
const FORMAT_QUALITY_DEFAULTS = { avif: 60, webp: 75, jpeg: 82 }
|
||||
|
||||
/** Accepted input extensions when a positional argument is a directory. */
|
||||
export const INPUT_EXTENSIONS = new Set([
|
||||
'.jpg',
|
||||
'.jpeg',
|
||||
'.png',
|
||||
'.webp',
|
||||
'.avif',
|
||||
'.tif',
|
||||
'.tiff',
|
||||
'.gif',
|
||||
'.heic',
|
||||
'.bmp',
|
||||
])
|
||||
|
||||
/**
|
||||
* Normalizes a `--format` value (aliases + leading dot, case-insensitive).
|
||||
* Returns `null` when the value is not encodable.
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {'avif' | 'webp' | 'jpeg' | null}
|
||||
*/
|
||||
export const normalizeImageFormat = (value) => {
|
||||
const normalized = value.trim().toLowerCase().replace(/^\./, '')
|
||||
const alias = { jpg: 'jpeg', jpe: 'jpeg', jfif: 'jpeg' }[normalized]
|
||||
const format = alias ?? normalized
|
||||
return SUPPORTED_FORMATS.includes(format) ? format : null
|
||||
}
|
||||
|
||||
/** @param {'avif' | 'webp' | 'jpeg'} format */
|
||||
export const defaultQualityFor = (format) => FORMAT_QUALITY_DEFAULTS[format] ?? 60
|
||||
|
||||
/**
|
||||
* The web asset keeps the source basename, only the extension changes
|
||||
* (`foto.jpg` → `foto.avif`), so re-running with another format never
|
||||
* collides with the source file.
|
||||
*
|
||||
* @param {string} inputPath
|
||||
* @param {'avif' | 'webp' | 'jpeg'} format
|
||||
*/
|
||||
export const deriveOutputFileName = (inputPath, format) =>
|
||||
`${parse(inputPath).name}${FORMAT_EXTENSIONS[format]}`
|
||||
|
||||
const FLAGS = new Set(['--max-width', '--quality', '--format', '--out'])
|
||||
|
||||
const BOOLEAN_FLAGS = new Set(['--remove-bg'])
|
||||
|
||||
const HELP_FLAGS = new Set(['--help', '-h'])
|
||||
|
||||
/**
|
||||
* Parses `--format` into a deduped, order-preserving list. Accepts a
|
||||
* comma-separated set (`avif,webp`) and the singular spellings (`jpg`).
|
||||
* Returns `null` when every item is missing or any item is unknown.
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {('avif' | 'webp' | 'jpeg')[] | null}
|
||||
*/
|
||||
const parseFormatList = (value) => {
|
||||
const formats = value
|
||||
.split(',')
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => part !== '')
|
||||
.map(normalizeImageFormat)
|
||||
if (formats.length === 0 || formats.some((format) => format === null)) {
|
||||
return null
|
||||
}
|
||||
return [...new Set(formats)]
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses CLI argv into options. Throws with a human-readable message on any
|
||||
* unknown flag or invalid value (fail closed — a typo must not silently
|
||||
* fall back to a default). `quality` and `maxWidth` stay undefined when
|
||||
* absent so each format applies its own default at conversion time.
|
||||
*
|
||||
* @param {string[]} argv - `process.argv.slice(2)`
|
||||
* @returns {{ paths: string[], maxWidth: number | undefined, quality: number | undefined, formats: ('avif' | 'webp' | 'jpeg')[], outDir: string, removeBg: boolean, help: boolean }}
|
||||
*/
|
||||
export const parseResizeArgs = (argv) => {
|
||||
const options = {
|
||||
help: false,
|
||||
paths: [],
|
||||
maxWidth: undefined,
|
||||
quality: undefined,
|
||||
formats: [...DEFAULT_FORMATS],
|
||||
outDir: 'public',
|
||||
removeBg: false,
|
||||
}
|
||||
|
||||
for (let i = 0; i < argv.length; i += 1) {
|
||||
const arg = argv[i]
|
||||
if (HELP_FLAGS.has(arg)) {
|
||||
options.help = true
|
||||
continue
|
||||
}
|
||||
if (BOOLEAN_FLAGS.has(arg)) {
|
||||
options.removeBg = true
|
||||
continue
|
||||
}
|
||||
const [flag, inlineValue] = arg.startsWith('--') ? arg.split('=') : [null, null]
|
||||
if (flag !== null && FLAGS.has(flag)) {
|
||||
const value = inlineValue ?? argv[i + 1]
|
||||
if (inlineValue === undefined) i += 1
|
||||
if (value === undefined || value === '' || value.startsWith('--')) {
|
||||
throw new Error(`flag ${flag} espera um valor (ex.: ${flag}=3840 ou ${flag} 3840)`)
|
||||
}
|
||||
if (flag === '--max-width') {
|
||||
const width = Number(value)
|
||||
if (!Number.isInteger(width) || width < 1) {
|
||||
throw new Error(`--max-width inválido: ${JSON.stringify(value)} (esperado inteiro > 0)`)
|
||||
}
|
||||
options.maxWidth = width
|
||||
} else if (flag === '--quality') {
|
||||
const quality = Number(value)
|
||||
if (!Number.isInteger(quality) || quality < 1 || quality > 100) {
|
||||
throw new Error(`--quality inválido: ${JSON.stringify(value)} (esperado 1..100)`)
|
||||
}
|
||||
options.quality = quality
|
||||
} else if (flag === '--format') {
|
||||
const formats = parseFormatList(value)
|
||||
if (formats === null) {
|
||||
throw new Error(
|
||||
`--format inválido: ${JSON.stringify(value)} (esperado ${SUPPORTED_FORMATS.join('|')}, lista separada por vírgula)`,
|
||||
)
|
||||
}
|
||||
options.formats = formats
|
||||
} else {
|
||||
options.outDir = value
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (flag !== null && !HELP_FLAGS.has(arg)) {
|
||||
throw new Error(`flag desconhecida: ${JSON.stringify(arg)} (veja --help)`)
|
||||
}
|
||||
options.paths.push(arg)
|
||||
}
|
||||
|
||||
if (!options.help && options.paths.length === 0) {
|
||||
throw new Error('nenhum caminho informado — passe arquivos de imagem ou pastas (veja --help)')
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
259
scripts/resize-images.mjs
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
/**
|
||||
* resize-images.mjs — local image optimizer for the campaign site draft.
|
||||
*
|
||||
* Takes one or more image paths (or folders, which are scanned recursively)
|
||||
* and, for each: rotates per EXIF, resizes to at most `--max-width` keeping
|
||||
* the aspect ratio (no upscaling), strips metadata and encodes two outputs
|
||||
* by default — AVIF (lightest modern format, for the site) and WebP (the
|
||||
* broadly accepted companion: design tools such as PenPot and older
|
||||
* browsers do not open AVIF). `--format` narrows the set. Outputs keep the
|
||||
* source basename into the Next.js `public/` folder (or `--out`), so the
|
||||
* draft pages can reference `/arquivo.avif` directly.
|
||||
*
|
||||
* Usage:
|
||||
* pnpm images:resize 1.jpg 2.png
|
||||
* pnpm images:resize --out public/campanha --max-width 2560 fotos/*
|
||||
* pnpm images:resize --format avif,webp --quality 80 ~/Downloads/foto.JPG
|
||||
* pnpm images:resize --format webp ~/Downloads/foto.JPG
|
||||
*
|
||||
* AVIF encoding is slower than WebP/JPEG — a large batch is expected to
|
||||
* take a few seconds per image.
|
||||
*/
|
||||
import { removeBackground } from '@imgly/background-removal-node'
|
||||
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises'
|
||||
import { basename, join, resolve } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import sharp from 'sharp'
|
||||
|
||||
import { dieWithLabel } from './lib/cli.mjs'
|
||||
import {
|
||||
INPUT_EXTENSIONS,
|
||||
defaultQualityFor,
|
||||
deriveOutputFileName,
|
||||
maxWidthFor,
|
||||
parseResizeArgs,
|
||||
} from './lib/imageResize.mjs'
|
||||
|
||||
const die = dieWithLabel('images:resize')
|
||||
|
||||
const USAGE = `Uso: pnpm images:resize [opções] <caminhos...>
|
||||
|
||||
Redimensiona e converte imagens para a web, gravando na pasta public/.
|
||||
Por padrão gera DUAS versões: .avif para o site e .webp para PenPot e
|
||||
navegadores antigos — o webp sai bem menor (1x a tela desktop) porque é
|
||||
só referência de draft, não asset de produção.
|
||||
|
||||
Opções:
|
||||
--max-width <px> largura máxima de TODOS os formatos (default por
|
||||
formato: avif 3840 = 2x desktop, webp/jpeg 1920 = 1x)
|
||||
--format <fmt> formato(s) de saída: avif, webp, jpeg (default avif,webp)
|
||||
--quality <1-100> qualidade de compressão (defaults: avif 60, webp 75, jpeg 82)
|
||||
--remove-bg remove o fundo da foto com IA local (1a execução
|
||||
baixa o modelo, ~40 MB, depois usa cache)
|
||||
--out <dir> pasta de saída (default public/)
|
||||
-h, --help mostra esta ajuda
|
||||
|
||||
Caminhos podem ser arquivos de imagem ou pastas (varridas recursivamente).
|
||||
O nome do arquivo é mantido; só a extensão muda (foto.jpg -> foto.avif + foto.webp).`
|
||||
|
||||
/**
|
||||
* Expands positional args into a sorted, deduped list of image files.
|
||||
* Directories are walked recursively; anything else is kept as-is.
|
||||
*
|
||||
* @param {string[]} paths
|
||||
* @returns {Promise<string[]>} absolute input paths
|
||||
*/
|
||||
const expandImagePaths = async (paths) => {
|
||||
const found = new Set()
|
||||
for (const path of paths) {
|
||||
const absolute = resolve(path)
|
||||
let info
|
||||
try {
|
||||
info = await stat(absolute)
|
||||
} catch {
|
||||
die(`${path} não existe`)
|
||||
}
|
||||
if (info.isDirectory()) {
|
||||
const entries = await readdir(absolute, { recursive: true, withFileTypes: true })
|
||||
for (const entry of entries) {
|
||||
if (!entry.isFile()) continue
|
||||
const lower = entry.name.toLowerCase()
|
||||
if ([...INPUT_EXTENSIONS].some((ext) => lower.endsWith(ext))) {
|
||||
// `parentPath` is absolute on Node >= 22 and relative on older —
|
||||
// resolve() folds either spelling onto the scanned root.
|
||||
found.add(resolve(absolute, entry.parentPath, entry.name))
|
||||
}
|
||||
}
|
||||
} else if (info.isFile()) {
|
||||
found.add(absolute)
|
||||
}
|
||||
}
|
||||
return [...found].sort()
|
||||
}
|
||||
|
||||
const formatBytes = (bytes) => {
|
||||
if (bytes < 1024) return `${bytes} B`
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)} KB`
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads one input and prepares it once for every output format: EXIF
|
||||
* rotation is baked in, then (optionally) the background is removed with
|
||||
* the local ONNX model. The result is the raw buffer every format encodes
|
||||
* from, so the segmentation never runs per format.
|
||||
*
|
||||
* The imgly node package decodes only blobs whose `type` it knows
|
||||
* (png/jpeg/webp) and does NOT sniff bytes — a bare `new Blob([buffer])`
|
||||
* arrives with an empty type and dies with "Unsupported format: " (bug
|
||||
* in 1.4.5). PNG is the lossless universal intermediate, declared
|
||||
* explicitly.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {boolean} removeBg
|
||||
*/
|
||||
const prepareImage = async (input, removeBg) => {
|
||||
let buffer = await sharp(await readFile(input))
|
||||
.rotate()
|
||||
.toBuffer()
|
||||
if (removeBg) {
|
||||
buffer = await sharp(buffer).png().toBuffer()
|
||||
const blob = new Blob([buffer], { type: 'image/png' })
|
||||
const result = await removeBackground(blob, { output: { format: 'image/png' } })
|
||||
buffer = Buffer.from(await result.arrayBuffer())
|
||||
}
|
||||
return buffer
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes + converts one prepared image to one format. Returns the
|
||||
* width/height pair of the output for the summary. Never touches the
|
||||
* source: the output path is derived from the basename and the target
|
||||
* format, so it can only collide with the source when the input already is
|
||||
* the output format AND sits in the output folder — which is refused.
|
||||
* JPEG cannot hold the alpha channel left by background removal, so it is
|
||||
* flattened onto white instead of leaking black.
|
||||
*
|
||||
* @param {Buffer} prepared
|
||||
* @param {string} input
|
||||
* @param {string} output
|
||||
* @param {{ maxWidth: number | undefined, quality: number | undefined, format: 'avif' | 'webp' | 'jpeg', removeBg: boolean }} options
|
||||
*/
|
||||
const encodeImage = async (prepared, input, output, { maxWidth, quality, format, removeBg }) => {
|
||||
if (resolve(input) === resolve(output)) {
|
||||
throw new Error(
|
||||
`saída colidiria com a fonte em ${basename(input)} — troque o formato ou use --out`,
|
||||
)
|
||||
}
|
||||
let pipeline = sharp(prepared).resize({
|
||||
width: maxWidthFor(format, maxWidth),
|
||||
withoutEnlargement: true,
|
||||
fit: 'inside',
|
||||
})
|
||||
if (removeBg && format === 'jpeg') pipeline = pipeline.flatten({ background: '#ffffff' })
|
||||
const encoded = await pipeline
|
||||
.toFormat(format, { quality: quality ?? defaultQualityFor(format) })
|
||||
.toBuffer()
|
||||
await writeFile(output, encoded)
|
||||
const { width, height } = await sharp(encoded).metadata()
|
||||
return { width: width ?? 0, height: height ?? 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The shared resize+encode engine — the CLI entry point and `fill-image.mjs`
|
||||
* (which chains this onto the model output) both call it with a
|
||||
* `parseResizeArgs`-shaped options object.
|
||||
*
|
||||
* @param {ReturnType<typeof parseResizeArgs>} options
|
||||
*/
|
||||
export const runResizeImages = async (options) => {
|
||||
if (options.help) {
|
||||
console.log(USAGE)
|
||||
return
|
||||
}
|
||||
|
||||
const inputs = await expandImagePaths(options.paths)
|
||||
if (inputs.length === 0) {
|
||||
die(`nenhuma imagem encontrada nos caminhos informados (${options.paths.join(', ')})`)
|
||||
}
|
||||
|
||||
const outDir = resolve(options.outDir)
|
||||
await mkdir(outDir, { recursive: true })
|
||||
|
||||
const { formats, quality, maxWidth, removeBg } = options
|
||||
const results = []
|
||||
const failures = []
|
||||
for (const input of inputs) {
|
||||
const before = (await stat(input)).size
|
||||
let prepared
|
||||
try {
|
||||
prepared = await prepareImage(input, removeBg)
|
||||
} catch (error) {
|
||||
failures.push(`${basename(input)}: ${error instanceof Error ? error.message : String(error)}`)
|
||||
continue
|
||||
}
|
||||
for (const format of formats) {
|
||||
const output = join(outDir, deriveOutputFileName(input, format))
|
||||
try {
|
||||
const { width, height } = await encodeImage(prepared, input, output, {
|
||||
maxWidth,
|
||||
quality,
|
||||
format,
|
||||
removeBg,
|
||||
})
|
||||
const after = (await stat(output)).size
|
||||
results.push({
|
||||
name: `${basename(input)} → .${format}`,
|
||||
dimensions: `${width}×${height}`,
|
||||
before,
|
||||
after,
|
||||
})
|
||||
} catch (error) {
|
||||
failures.push(
|
||||
`${basename(input)} (.${format}): ${error instanceof Error ? error.message : String(error)}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nameWidth = Math.max(...results.map((r) => r.name.length), 6)
|
||||
console.log(`\n${'arquivo'.padEnd(nameWidth)} dimensão antes -> depois economia`)
|
||||
console.log('-'.repeat(nameWidth + 54))
|
||||
let totalBefore = 0
|
||||
let totalAfter = 0
|
||||
for (const result of results) {
|
||||
totalBefore += result.before
|
||||
totalAfter += result.after
|
||||
const saved = 100 - (result.after / result.before) * 100
|
||||
console.log(
|
||||
`${result.name.padEnd(nameWidth)} ${result.dimensions.padEnd(9)} ${formatBytes(result.before).padEnd(8)} -> ${formatBytes(result.after).padEnd(9)} ${saved.toFixed(1).padStart(5)}%`,
|
||||
)
|
||||
}
|
||||
if (results.length > 1) {
|
||||
const saved = 100 - (totalAfter / totalBefore) * 100
|
||||
console.log('-'.repeat(nameWidth + 54))
|
||||
console.log(
|
||||
`${'TOTAL'.padEnd(nameWidth)} ${String(results.length).padEnd(9)} ${formatBytes(totalBefore).padEnd(8)} -> ${formatBytes(totalAfter).padEnd(9)} ${saved.toFixed(1).padStart(5)}%`,
|
||||
)
|
||||
}
|
||||
const widthSummary = maxWidth
|
||||
? `largura máxima ${maxWidth}px`
|
||||
: `largura por formato (${formats.map((f) => `${f} ${maxWidthFor(f)}px`).join(', ')})`
|
||||
console.log(
|
||||
`\n${results.length} arquivo(s) em ${join(outDir, '')} (${formats.join(', ')}, ${quality ? `qualidade ${quality}, ` : ''}${widthSummary}${removeBg ? ', fundo removido' : ''})\n`,
|
||||
)
|
||||
|
||||
if (failures.length > 0) {
|
||||
console.error(`\n${failures.length} falha(s):`)
|
||||
for (const failure of failures) console.error(` - ${failure}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// CLI entry: only when run directly — `fill-image.mjs` imports the engine
|
||||
// without triggering the CLI.
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
runResizeImages(parseResizeArgs(process.argv.slice(2))).catch((error) =>
|
||||
die(error instanceof Error ? error.message : String(error)),
|
||||
)
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* run-e2e-affected — local mirror of the CI (PR) e2e job:
|
||||
* 1. `e2e-affected.mjs` picks full vs manifest-selected vs skip (same base ref).
|
||||
* 2. migrate + db:seed:minimal when anything would run.
|
||||
* 3. optional production build into `.next/e2e` when `E2E_PROD=1`.
|
||||
* 3. optional production build into `.next-e2e` when `E2E_PROD=1`.
|
||||
* 4. `pnpm test:e2e` (set `CI=1` and `E2E_PROD=1` together for prod mode).
|
||||
*
|
||||
* Extra Playwright args after `--` are forwarded (e.g. a single spec while debugging).
|
||||
|
|
@ -48,7 +48,7 @@ const run = (command, args, env = {}) => {
|
|||
run('pnpm', ['migrate'])
|
||||
run('pnpm', ['db:seed:minimal'])
|
||||
if (process.env.E2E_PROD === '1') {
|
||||
run('pnpm', ['build'], { NEXT_DIST_DIR: '.next/e2e' })
|
||||
run('pnpm', ['build'], { NEXT_DIST_DIR: '.next-e2e' })
|
||||
}
|
||||
|
||||
const playwrightArgs = ['test:e2e']
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
import { Footer } from '@/components/Footer'
|
||||
import { SiteHeader } from '@/components/SiteHeader'
|
||||
import React from 'react'
|
||||
import '../styles.css'
|
||||
|
||||
export default async function RootLayout(props: { children: React.ReactNode }) {
|
||||
const { children } = props
|
||||
|
||||
// The root `(frontend)` layout locks the document with `overflow-hidden`, so
|
||||
// the home route owns an internal scroll container. `relative` anchors the
|
||||
// overlay header over the hero.
|
||||
// A root `(frontend)` trava o documento com `overflow-hidden`, então a home
|
||||
// é dona do container de scroll interno. `data-theme="campaign-site"` aplica
|
||||
// a paleta da campanha (vermelho PT + amarelo CTA) aos tokens `--pt-*`.
|
||||
return (
|
||||
<div className="relative h-dvh w-full overflow-y-auto">
|
||||
<SiteHeader variant="overlay" />
|
||||
<div
|
||||
data-theme="campaign-site"
|
||||
className="relative h-dvh w-full scroll-smooth overflow-y-auto bg-(--campaign-cream) text-(--campaign-ink) motion-reduce:scroll-auto"
|
||||
>
|
||||
{children}
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,82 +1,176 @@
|
|||
import { PostCard } from '@/components/PostCard'
|
||||
import { Media } from '@/payload-types'
|
||||
import { getCachedDocumentById } from '@/utilities/documentReads'
|
||||
import { getCachedGlobal } from '@/utilities/globalReads'
|
||||
import { getTypePath, getVisiblePosts } from '@/utilities/posts'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import { CampaignCarousel, type CampaignCarouselItem } from '@/components/CampaignCarousel'
|
||||
import { CampaignFooter } from '@/components/CampaignFooter'
|
||||
import { CampaignHero } from '@/components/CampaignHero'
|
||||
|
||||
const LATEST_NEWS_LIMIT = 6
|
||||
const problemItems: CampaignCarouselItem[] = [
|
||||
{
|
||||
id: 'escala-6x1',
|
||||
title: 'Pelo fim da escala 6x1!',
|
||||
body: 'Jornadas longas aumentam o risco de AVC e infarto. Descanso é saúde pública. A bancada de Lula derrotou a direita na Câmara: o fim da 6×1 avançou. Mas a briga continua no Senado, onde a direita tenta barrar o avanço. No dia 4 de outubro, o 1313 é o seu sim ao descanso.',
|
||||
image: '/fundo.avif',
|
||||
imageAlt: 'Jorge Solla defendendo direitos dos trabalhadores na Câmara dos Deputados',
|
||||
},
|
||||
{
|
||||
id: 'sus',
|
||||
title: 'Pra valorizar o SUS',
|
||||
body: 'O SUS é o sistema de saúde de todo brasileiro. Com Lula, a saúde voltou a receber recursos: Nova PAC de R$ 30,5 bilhões e Mais Médicos retomado. Mas o teto de gastos da direita ainda trava o orçamento. O 1313 é seu voto em defesa do SUS no Congresso!',
|
||||
image: '/53569851134_02afc18fb4_o.avif',
|
||||
imageAlt: 'Jorge Solla em agenda pública de defesa do SUS',
|
||||
imageFrame: {
|
||||
width: 1024,
|
||||
height: 682,
|
||||
className: 'absolute top-0 left-[-21.97%] h-auto w-[136.62%] max-w-none',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'mataripe',
|
||||
title: 'Pra defender os baianos',
|
||||
body: 'A Refinaria de Mataripe foi vendida no governo Bolsonaro e segue nas mãos de estrangeiros. Com Lula e Jerônimo, a Bahia voltou a andar pra frente; mas recomprar Mataripe exige bancada forte no Congresso. Votar 1313 é devolver à Bahia o que é seu.',
|
||||
image: '/52396285023_561ffc0ff6_o.avif',
|
||||
imageAlt: 'Vista da Bahia durante mobilização popular',
|
||||
},
|
||||
]
|
||||
|
||||
const flagItems: CampaignCarouselItem[] = [
|
||||
{
|
||||
id: 'saude',
|
||||
label: 'Saúde',
|
||||
title: 'Defender o SUS e valorizar quem cuida',
|
||||
body: 'Saúde é direito, não mercadoria. Fim do subfinanciamento, piso da enfermagem e dos agentes pagos, concursos públicos, vacinação e ciência.',
|
||||
},
|
||||
{
|
||||
id: 'educacao',
|
||||
label: 'Educação',
|
||||
title: 'Educação em tempo integral e federais no interior',
|
||||
body: 'IFs, campus federal, escola de tempo integral: o interior não pode ficar para trás no conhecimento.',
|
||||
},
|
||||
{
|
||||
id: 'renda',
|
||||
label: 'Renda',
|
||||
title: 'Salário mínimo forte, emprego e moradia',
|
||||
body: 'Valorização do mínimo, Bolsa Família, Minha Casa Minha Vida e agricultura familiar como motor do interior.',
|
||||
},
|
||||
{
|
||||
id: 'democracia',
|
||||
label: 'Democracia',
|
||||
title: 'Defesa intransigente da democracia',
|
||||
body: 'Participação popular, instituições fortes e combate à desinformação. Eleger o parlamento é coisa séria.',
|
||||
},
|
||||
{
|
||||
id: 'bahia',
|
||||
label: 'Bahia',
|
||||
title: 'Recomprar a Refinaria de Mataripe',
|
||||
body: 'Recomprar a refinaria é defender a Bahia e a soberania do Brasil. Preço justo de combustível é política de saúde e de renda.',
|
||||
},
|
||||
{
|
||||
id: 'trabalho',
|
||||
label: 'Trabalho',
|
||||
title: 'Fim da escala 6×1 e jornada de 40h',
|
||||
body: 'Sem redução de salário. Jornada longa é questão de saúde pública: quem trabalha demais adoece. O SUS paga a conta.',
|
||||
},
|
||||
]
|
||||
|
||||
const proofItems = [
|
||||
{ value: '3.333', label: 'proposições apresentadas' },
|
||||
{ value: '1.031', label: 'discursos em Plenário' },
|
||||
{ value: '3º', label: 'mandato de deputado federal' },
|
||||
]
|
||||
|
||||
export default async function HomePage() {
|
||||
const home = await getCachedGlobal('home', 2)()
|
||||
|
||||
let heroImage: Media | null = null
|
||||
if (typeof home.image === 'number') {
|
||||
heroImage = await getCachedDocumentById('media', `${home.image}`)()
|
||||
} else {
|
||||
heroImage = home.image ?? null
|
||||
}
|
||||
|
||||
const latestNews = (await getVisiblePosts())
|
||||
.filter((post) => post.type === 'noticia')
|
||||
.slice(0, LATEST_NEWS_LIMIT)
|
||||
|
||||
return (
|
||||
<main className="w-full">
|
||||
<section className="relative flex min-h-[68vh] w-full flex-col items-center justify-center gap-8 px-4 pt-24 pb-16 text-center text-(--site-header-foreground) sm:px-6 sm:pt-28 lg:px-8">
|
||||
<div className="flex max-w-4xl flex-col items-center gap-5">
|
||||
<h1 className="text-4xl font-extrabold leading-tight tracking-tight text-balance sm:text-5xl lg:text-6xl">
|
||||
O mandato do tamanho da Bahia
|
||||
</h1>
|
||||
<p className="max-w-2xl text-lg leading-relaxed text-(--site-header-muted) sm:text-xl">
|
||||
Notícias, campanhas e a atuação do deputado Jorge Solla por uma Bahia mais justa.
|
||||
</p>
|
||||
<Link
|
||||
href={getTypePath('noticia')}
|
||||
className="inline-flex items-center justify-center rounded-md bg-white/15 px-5 py-2.5 text-sm font-semibold text-(--site-header-foreground) ring-1 ring-white/25 backdrop-blur transition-colors hover:bg-white/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70"
|
||||
>
|
||||
Ver notícias
|
||||
</Link>
|
||||
</div>
|
||||
{heroImage?.url ? (
|
||||
<div className="w-full max-w-3xl overflow-hidden rounded-2xl shadow-2xl ring-1 ring-white/15">
|
||||
<Image
|
||||
className="h-auto w-full object-cover"
|
||||
src={heroImage.url}
|
||||
alt={heroImage.alt}
|
||||
width={heroImage.width ?? 1200}
|
||||
height={heroImage.height ?? 675}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
<>
|
||||
<main className="w-full bg-white text-black">
|
||||
<CampaignHero />
|
||||
|
||||
<section data-theme="editorial" className="w-full bg-background text-foreground">
|
||||
<div className="mx-auto w-full max-w-5xl px-4 py-14 sm:px-6 lg:px-8 lg:py-16">
|
||||
<div className="mb-8 flex flex-wrap items-end justify-between gap-3">
|
||||
<h2 className="border-none text-left text-3xl font-bold tracking-tight sm:text-4xl">
|
||||
Últimas notícias
|
||||
</h2>
|
||||
<Link
|
||||
href={getTypePath('noticia')}
|
||||
className="text-sm font-semibold text-primary underline-offset-4 hover:underline"
|
||||
<section
|
||||
aria-label="Experiência e atuação parlamentar"
|
||||
data-home-section="proof"
|
||||
className="flex h-[88px] justify-center bg-white lg:h-[148px]"
|
||||
>
|
||||
<ul className="m-0 grid h-full w-[calc(100%_-_22px)] max-w-[712px] list-none grid-cols-3 items-center gap-[23px] p-0 lg:grid-cols-[147px_178px_183px] lg:items-start lg:justify-between lg:gap-0 lg:pt-[23px]">
|
||||
{proofItems.map((item) => (
|
||||
<li key={item.value} className="m-0 text-center">
|
||||
<strong className="block font-[family-name:var(--font-exo2)] text-[24px] leading-none font-black text-(--pt-red) lg:text-[36px] lg:leading-[1.1]">
|
||||
{item.value}
|
||||
</strong>
|
||||
<span className="mt-1 block text-[10px] leading-[1.08] font-medium text-[#242124] lg:text-[18px] lg:leading-[1.25]">
|
||||
{item.label}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section
|
||||
aria-labelledby="problem-title"
|
||||
data-home-section="problem"
|
||||
className="relative h-[730px] bg-(--pt-red-dark) text-white lg:h-[659px]"
|
||||
>
|
||||
<div className="relative h-full w-full">
|
||||
<p className="absolute top-[35px] left-5 m-0 font-[family-name:var(--font-exo2)] text-[10px] leading-3 font-black tracking-[0.1em] text-(--pt-yellow) uppercase lg:left-[var(--campaign-content-inset)] lg:text-[12px] lg:leading-[15px]">
|
||||
Por que essa eleição importa
|
||||
</p>
|
||||
<h2
|
||||
id="problem-title"
|
||||
aria-label="Eleger deputado é coisa séria. O Congresso tem nas mãos vidas reais e o SUS"
|
||||
className="absolute top-[59px] left-5 m-0 w-[331px] border-0 p-0 text-[22px] leading-[1.08] font-black tracking-[-0.02em] text-balance lg:top-[66px] lg:left-[var(--campaign-content-inset)] lg:w-[616px] lg:text-[24px] lg:leading-[1.06]"
|
||||
>
|
||||
Ver todas
|
||||
</Link>
|
||||
</div>
|
||||
{latestNews.length ? (
|
||||
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{latestNews.map((post) => (
|
||||
<PostCard key={post.id} post={post} />
|
||||
))}
|
||||
<span className="block">Eleger deputado é coisa séria</span>
|
||||
<span className="block text-(--pt-yellow)">
|
||||
O Congresso tem nas mãos vidas reais e o SUS
|
||||
</span>
|
||||
</h2>
|
||||
<p className="absolute top-[146px] left-5 m-0 w-[327px] font-[family-name:var(--font-exo2)] text-[14px] leading-[1.2] text-white/85 lg:top-[127px] lg:left-[var(--campaign-content-inset)] lg:w-[716px] lg:text-[16px]">
|
||||
É no Congresso que se define o orçamento do SUS, o piso da enfermagem, a recompra de
|
||||
Mataripe e o fim da escala 6×1.{' '}
|
||||
<strong className="font-extrabold text-white">
|
||||
Reeleger Lula não basta: é preciso eleger uma bancada aliada.
|
||||
</strong>
|
||||
</p>
|
||||
<div className="absolute top-[245px] right-0 left-0 lg:top-[191px]">
|
||||
<CampaignCarousel
|
||||
ariaLabel="Bandeiras que tornam esta eleição decisiva"
|
||||
items={problemItems}
|
||||
variant="problem"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-muted-foreground">Nenhuma notícia publicada ainda.</p>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
id="bandeiras"
|
||||
aria-labelledby="flags-title"
|
||||
data-home-section="flags"
|
||||
className="relative h-[400px] scroll-mt-4 bg-(--campaign-band) text-black lg:h-[368px]"
|
||||
>
|
||||
<div className="relative h-full w-full">
|
||||
<p className="absolute top-[37px] left-5 m-0 font-[family-name:var(--font-exo2)] text-[10px] leading-3 font-black tracking-[0.1em] text-(--pt-red) uppercase lg:top-[33px] lg:left-[var(--campaign-content-inset)] lg:text-[12px] lg:leading-[15px]">
|
||||
Nossa caminhada
|
||||
</p>
|
||||
<h2
|
||||
id="flags-title"
|
||||
aria-label="Junto com o trabalhador e do lado de quem mais precisa, sempre."
|
||||
className="absolute top-[66px] left-5 m-0 w-[331px] border-0 p-0 text-[22px] leading-[1.08] font-black tracking-[-0.02em] text-balance lg:top-[62px] lg:left-[var(--campaign-content-inset)] lg:w-[664px] lg:text-[24px] lg:leading-[1.06]"
|
||||
>
|
||||
<span className="block">Junto com o trabalhador e</span>
|
||||
<span className="block text-(--pt-red)">do lado de quem mais precisa, sempre.</span>
|
||||
</h2>
|
||||
<p className="absolute top-[149px] left-5 m-0 w-[327px] font-sans text-[14px] leading-[1.2] text-black/80 lg:top-[130px] lg:left-[var(--campaign-content-inset)] lg:w-[730px] lg:text-[16px]">
|
||||
Não é promessa de palanque, é a experiência de quem já fez na gestão do SUS, do
|
||||
Ministério da Saúde e da saúde da Bahia.
|
||||
</p>
|
||||
<div className="absolute top-[215px] right-0 left-0 lg:top-[184px]">
|
||||
<CampaignCarousel
|
||||
ariaLabel="Bandeiras da campanha"
|
||||
items={flagItems}
|
||||
variant="flags"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<CampaignFooter />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
19
src/app/(frontend)/artigos/layout.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { Footer } from '@/components/Footer'
|
||||
import { SiteHeader } from '@/components/SiteHeader'
|
||||
import React from 'react'
|
||||
import '../styles.css'
|
||||
|
||||
export default async function RootLayout(props: { children: React.ReactNode }) {
|
||||
const { children } = props
|
||||
|
||||
// A root `(frontend)` trava o documento com `overflow-hidden`, então a rota
|
||||
// é dona do container de scroll interno. Header sólido (não overlay) porque
|
||||
// /artigos é uma subpágina, não o hero da home.
|
||||
return (
|
||||
<div className="relative h-dvh w-full overflow-y-auto">
|
||||
<SiteHeader variant="solid" />
|
||||
{children}
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
82
src/app/(frontend)/artigos/page.tsx
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import { PostCard } from '@/components/PostCard'
|
||||
import { Media } from '@/payload-types'
|
||||
import { getCachedDocumentById } from '@/utilities/documentReads'
|
||||
import { getCachedGlobal } from '@/utilities/globalReads'
|
||||
import { getTypePath, getVisiblePosts } from '@/utilities/posts'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
|
||||
const LATEST_NEWS_LIMIT = 6
|
||||
|
||||
export default async function ArtigosPage() {
|
||||
const home = await getCachedGlobal('home', 2)()
|
||||
|
||||
let heroImage: Media | null = null
|
||||
if (typeof home.image === 'number') {
|
||||
heroImage = await getCachedDocumentById('media', `${home.image}`)()
|
||||
} else {
|
||||
heroImage = home.image ?? null
|
||||
}
|
||||
|
||||
const latestNews = (await getVisiblePosts())
|
||||
.filter((post) => post.type === 'noticia')
|
||||
.slice(0, LATEST_NEWS_LIMIT)
|
||||
|
||||
return (
|
||||
<main className="w-full">
|
||||
<section className="relative flex min-h-[68vh] w-full flex-col items-center justify-center gap-8 px-4 pt-24 pb-16 text-center text-(--site-header-foreground) sm:px-6 sm:pt-28 lg:px-8">
|
||||
<div className="flex max-w-4xl flex-col items-center gap-5">
|
||||
<h1 className="text-4xl font-extrabold leading-tight tracking-tight text-balance sm:text-5xl lg:text-6xl">
|
||||
O mandato do tamanho da Bahia
|
||||
</h1>
|
||||
<p className="max-w-2xl text-lg leading-relaxed text-(--site-header-muted) sm:text-xl">
|
||||
Notícias, campanhas e a atuação do deputado Jorge Solla por uma Bahia mais justa.
|
||||
</p>
|
||||
<Link
|
||||
href={getTypePath('noticia')}
|
||||
className="inline-flex items-center justify-center rounded-md bg-white/15 px-5 py-2.5 text-sm font-semibold text-(--site-header-foreground) ring-1 ring-white/25 backdrop-blur transition-colors hover:bg-white/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70"
|
||||
>
|
||||
Ver notícias
|
||||
</Link>
|
||||
</div>
|
||||
{heroImage?.url ? (
|
||||
<div className="w-full max-w-3xl overflow-hidden rounded-2xl shadow-2xl ring-1 ring-white/15">
|
||||
<Image
|
||||
className="h-auto w-full object-cover"
|
||||
src={heroImage.url}
|
||||
alt={heroImage.alt}
|
||||
width={heroImage.width ?? 1200}
|
||||
height={heroImage.height ?? 675}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
<section data-theme="editorial" className="w-full bg-background text-foreground">
|
||||
<div className="mx-auto w-full max-w-5xl px-4 py-14 sm:px-6 lg:px-8 lg:py-16">
|
||||
<div className="mb-8 flex flex-wrap items-end justify-between gap-3">
|
||||
<h2 className="border-none text-left text-3xl font-bold tracking-tight sm:text-4xl">
|
||||
Últimas notícias
|
||||
</h2>
|
||||
<Link
|
||||
href={getTypePath('noticia')}
|
||||
className="text-sm font-semibold text-primary underline-offset-4 hover:underline"
|
||||
>
|
||||
Ver todas
|
||||
</Link>
|
||||
</div>
|
||||
{latestNews.length ? (
|
||||
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{latestNews.map((post) => (
|
||||
<PostCard key={post.id} post={post} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-muted-foreground">Nenhuma notícia publicada ainda.</p>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
|
@ -6,11 +6,15 @@ import { resolveSiteMetadata } from '@/utilities/seo'
|
|||
import { Analytics } from '@vercel/analytics/next'
|
||||
import { SpeedInsights } from '@vercel/speed-insights/next'
|
||||
import { Metadata } from 'next'
|
||||
import { Inter } from 'next/font/google'
|
||||
import { Arimo, Exo_2, Inter } from 'next/font/google'
|
||||
import React from 'react'
|
||||
import './styles.css'
|
||||
|
||||
const inter = Inter({ subsets: ['latin'], variable: '--font-sans' })
|
||||
// Campanha 2026: Exo 2 para display (títulos/CTAs) e Arimo para cards/tags —
|
||||
// mesmo uso das peças do Penpot e do santinho. OFL, self-hosted pelo next/font.
|
||||
const exo2 = Exo_2({ subsets: ['latin'], variable: '--font-exo2' })
|
||||
const arimo = Arimo({ subsets: ['latin'], variable: '--font-arimo' })
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const payload = await getCachedGlobal('metadata')()
|
||||
|
|
@ -71,7 +75,7 @@ export default async function RootLayout(props: { children: React.ReactNode }) {
|
|||
return (
|
||||
<html
|
||||
lang="pt-BR"
|
||||
className={`${inter.variable} w-screen h-screen scrollbar-hide`}
|
||||
className={`${inter.variable} ${exo2.variable} ${arimo.variable} w-screen h-screen scrollbar-hide`}
|
||||
style={{ colorScheme: 'light' }}
|
||||
suppressHydrationWarning
|
||||
>
|
||||
|
|
|
|||
|
|
@ -161,6 +161,111 @@ body,
|
|||
--ring: #c51414;
|
||||
}
|
||||
|
||||
/* Paleta da página de campanha 2026 (home pública jorgesolla1313).
|
||||
Extraída da geometria do rascunho Penpot (15/08/2026): vermelho #a21c1c,
|
||||
amarelo #ffe607, problema #47130e, bandeiras #ebe9e9, cards #f9faff.
|
||||
Aplicado via data-theme="campaign-site" no layout da home. */
|
||||
[data-theme='campaign-site'] {
|
||||
--background: #ffffff;
|
||||
--foreground: #000000;
|
||||
--pt-red: #a21c1c;
|
||||
--pt-red-dark: #47130e;
|
||||
--pt-yellow: #ffe607;
|
||||
--pt-yellow-ink: #000000;
|
||||
--campaign-cream: #fff8f2;
|
||||
--campaign-ink: #000000;
|
||||
--campaign-muted: #6c615e;
|
||||
--campaign-surface: #f9faff;
|
||||
--campaign-band: #ebe9e9;
|
||||
--campaign-line: rgb(0 0 0 / 12%);
|
||||
--campaign-content-inset: 20px;
|
||||
}
|
||||
|
||||
/* Penpot uses two lockups from the official campaign identity: the wide mark
|
||||
on phones and the stacked mark on desktop. The PNG canvases are square and
|
||||
mostly transparent, so keep their exact board geometry instead of sizing by
|
||||
visible ink bounds. */
|
||||
.campaign-home-logo {
|
||||
top: -123px;
|
||||
left: 19px;
|
||||
width: 356px;
|
||||
height: 356px;
|
||||
background-image: url('/Prancheta%206%403x.png');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: contain;
|
||||
}
|
||||
|
||||
@media (min-width: 64rem) {
|
||||
.campaign-home-logo {
|
||||
top: 55px;
|
||||
left: 47px;
|
||||
width: 197px;
|
||||
height: 150px;
|
||||
background-image: url('/Prancheta%203%403x.png');
|
||||
background-position: -43px -67px;
|
||||
background-size: 283px 284px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[data-theme='campaign-site'] [data-carousel-track] {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* Full-bleed carousel viewport with content-aligned first cards. The scroller
|
||||
reaches both browser edges; only its initial item follows the page gutter. */
|
||||
[data-theme='campaign-site'] [data-carousel] {
|
||||
--campaign-carousel-inset: var(--campaign-content-inset);
|
||||
}
|
||||
|
||||
[data-theme='campaign-site'] [data-carousel-track],
|
||||
[data-theme='campaign-site'] [data-carousel-chips] {
|
||||
padding-left: var(--campaign-carousel-inset);
|
||||
padding-right: var(--campaign-carousel-inset);
|
||||
}
|
||||
|
||||
[data-theme='campaign-site'] [data-carousel-track] {
|
||||
scroll-padding-left: var(--campaign-carousel-inset);
|
||||
}
|
||||
|
||||
.campaign-action-feedback {
|
||||
transition:
|
||||
transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
|
||||
opacity 120ms ease-out,
|
||||
background-color 180ms ease-out,
|
||||
filter 180ms ease-out;
|
||||
}
|
||||
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.campaign-action-feedback:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
}
|
||||
|
||||
.campaign-action-feedback:active {
|
||||
opacity: 0.8;
|
||||
transform: scale(0.99);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.campaign-action-feedback {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.campaign-action-feedback:hover,
|
||||
.campaign-action-feedback:active {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 64rem) {
|
||||
[data-theme='campaign-site'] {
|
||||
--campaign-content-inset: max(180px, calc((100vw - 1152px) / 2 + 32px));
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme='petition'] {
|
||||
--background: #fff8f2;
|
||||
--foreground: #2c2522;
|
||||
|
|
|
|||
235
src/components/CampaignCarousel.tsx
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
'use client'
|
||||
|
||||
import Image from 'next/image'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
const AUTO_ADVANCE_MS = 4_000
|
||||
const PROGRAMMATIC_SCROLL_LOCK_MS = 700
|
||||
|
||||
export type CampaignCarouselItem = {
|
||||
id: string
|
||||
label?: string
|
||||
title: string
|
||||
body: string
|
||||
image?: string
|
||||
imageAlt?: string
|
||||
imageFrame?: {
|
||||
width: number
|
||||
height: number
|
||||
className: string
|
||||
}
|
||||
}
|
||||
|
||||
type CampaignCarouselProps = {
|
||||
ariaLabel: string
|
||||
items: CampaignCarouselItem[]
|
||||
variant: 'problem' | 'flags'
|
||||
}
|
||||
|
||||
export const CampaignCarousel = ({ ariaLabel, items, variant }: CampaignCarouselProps) => {
|
||||
const trackRef = useRef<HTMLOListElement>(null)
|
||||
const programmaticScrollTimerRef = useRef<number | null>(null)
|
||||
const isProgrammaticScrollRef = useRef(false)
|
||||
const [activeIndex, setActiveIndex] = useState(0)
|
||||
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false)
|
||||
const [isHovered, setIsHovered] = useState(false)
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
const [isTouching, setIsTouching] = useState(false)
|
||||
|
||||
const temporarilyPaused = isHovered || isFocused || isTouching
|
||||
|
||||
const releaseProgrammaticScroll = useCallback(() => {
|
||||
isProgrammaticScrollRef.current = false
|
||||
if (programmaticScrollTimerRef.current !== null) {
|
||||
window.clearTimeout(programmaticScrollTimerRef.current)
|
||||
programmaticScrollTimerRef.current = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => releaseProgrammaticScroll, [releaseProgrammaticScroll])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window.matchMedia !== 'function') return
|
||||
|
||||
const media = window.matchMedia('(prefers-reduced-motion: reduce)')
|
||||
const applyPreference = () => setPrefersReducedMotion(media.matches)
|
||||
|
||||
applyPreference()
|
||||
media.addEventListener('change', applyPreference)
|
||||
return () => media.removeEventListener('change', applyPreference)
|
||||
}, [])
|
||||
|
||||
const scrollToItem = useCallback(
|
||||
(index: number) => {
|
||||
const track = trackRef.current
|
||||
const target = track?.querySelector<HTMLElement>(`[data-carousel-index="${index}"]`)
|
||||
if (!track || !target) return
|
||||
const startInset = Number.parseFloat(window.getComputedStyle(track).paddingLeft) || 0
|
||||
|
||||
releaseProgrammaticScroll()
|
||||
isProgrammaticScrollRef.current = true
|
||||
setActiveIndex(index)
|
||||
track.scrollTo({
|
||||
left: target.offsetLeft - track.offsetLeft - startInset,
|
||||
behavior: prefersReducedMotion ? 'auto' : 'smooth',
|
||||
})
|
||||
programmaticScrollTimerRef.current = window.setTimeout(
|
||||
releaseProgrammaticScroll,
|
||||
PROGRAMMATIC_SCROLL_LOCK_MS,
|
||||
)
|
||||
},
|
||||
[prefersReducedMotion, releaseProgrammaticScroll],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (prefersReducedMotion || temporarilyPaused || items.length < 2) return
|
||||
|
||||
const timer = window.setTimeout(() => {
|
||||
scrollToItem((activeIndex + 1) % items.length)
|
||||
}, AUTO_ADVANCE_MS)
|
||||
|
||||
return () => window.clearTimeout(timer)
|
||||
}, [activeIndex, items.length, prefersReducedMotion, scrollToItem, temporarilyPaused])
|
||||
|
||||
const syncActiveItem = useCallback(() => {
|
||||
const track = trackRef.current
|
||||
if (!track || isProgrammaticScrollRef.current) return
|
||||
|
||||
const cards = Array.from(track.querySelectorAll<HTMLElement>('[data-carousel-index]'))
|
||||
const startInset = Number.parseFloat(window.getComputedStyle(track).paddingLeft) || 0
|
||||
let nearestIndex = activeIndex
|
||||
let nearestDistance = Number.POSITIVE_INFINITY
|
||||
|
||||
cards.forEach((card, index) => {
|
||||
const distance = Math.abs(card.offsetLeft - track.offsetLeft - track.scrollLeft - startInset)
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance
|
||||
nearestIndex = index
|
||||
}
|
||||
})
|
||||
|
||||
if (nearestIndex !== activeIndex) setActiveIndex(nearestIndex)
|
||||
}, [activeIndex])
|
||||
|
||||
const pauseOnTouch = () => {
|
||||
releaseProgrammaticScroll()
|
||||
setIsTouching(true)
|
||||
}
|
||||
const resumeAfterTouch = () => setIsTouching(false)
|
||||
|
||||
return (
|
||||
<div
|
||||
role="region"
|
||||
tabIndex={0}
|
||||
aria-label={ariaLabel}
|
||||
aria-roledescription="carrossel"
|
||||
data-carousel={variant}
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
onMouseLeave={() => setIsHovered(false)}
|
||||
onPointerDown={releaseProgrammaticScroll}
|
||||
onWheel={releaseProgrammaticScroll}
|
||||
onFocusCapture={() => setIsFocused(true)}
|
||||
onBlurCapture={(event) => {
|
||||
if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setIsFocused(false)
|
||||
}}
|
||||
onTouchStart={pauseOnTouch}
|
||||
onTouchEnd={resumeAfterTouch}
|
||||
onTouchCancel={resumeAfterTouch}
|
||||
className="relative focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-current"
|
||||
>
|
||||
{variant === 'flags' ? (
|
||||
<div className="relative h-6">
|
||||
<div
|
||||
aria-label="Escolher bandeira"
|
||||
data-carousel-chips
|
||||
className="scrollbar-hide absolute -top-2.5 right-0 left-0 flex h-11 items-center gap-1.5 overflow-x-auto pr-2 lg:gap-[7px]"
|
||||
>
|
||||
{items.map((item, index) => {
|
||||
const isActive = index === activeIndex
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
type="button"
|
||||
aria-current={isActive ? 'true' : undefined}
|
||||
onClick={() => scrollToItem(index)}
|
||||
className="campaign-action-feedback inline-flex min-h-11 shrink-0 items-center justify-center rounded-full font-[family-name:var(--font-arimo)] text-xs font-bold uppercase focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:ring-offset-2 focus-visible:outline-none"
|
||||
>
|
||||
<span
|
||||
className={`inline-flex h-6 items-center rounded-full px-3 transition-colors ${
|
||||
isActive
|
||||
? 'bg-(--pt-red) text-white'
|
||||
: 'bg-[#dbdce0] text-[#66676b] hover:bg-[#cfd0d4]'
|
||||
}`}
|
||||
>
|
||||
{item.label}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<ol
|
||||
ref={trackRef}
|
||||
aria-live={temporarilyPaused ? 'polite' : 'off'}
|
||||
onScroll={syncActiveItem}
|
||||
data-carousel-track
|
||||
className={`scrollbar-hide m-0 flex list-none snap-x snap-mandatory overflow-x-auto scroll-smooth p-0 ${
|
||||
variant === 'problem' ? 'gap-2.5 lg:gap-[21px]' : 'mt-5 gap-2.5 lg:gap-[14px]'
|
||||
}`}
|
||||
>
|
||||
{items.map((item, index) => (
|
||||
<li
|
||||
key={item.id}
|
||||
data-carousel-index={index}
|
||||
aria-label={`${index + 1} de ${items.length}`}
|
||||
aria-current={index === activeIndex ? 'true' : undefined}
|
||||
className={`m-0 shrink-0 snap-start ${
|
||||
variant === 'problem'
|
||||
? 'h-[437px] w-[calc(100vw_-_38px)] max-w-[355px] lg:w-[355px]'
|
||||
: 'h-[100px] w-[calc(100vw_-_66px)] max-w-[327px] lg:w-[327px]'
|
||||
}`}
|
||||
>
|
||||
{variant === 'problem' ? (
|
||||
<article className="relative h-full overflow-hidden rounded-[10px] bg-[#2a0b08] font-[family-name:var(--font-arimo)] text-white">
|
||||
{item.image && item.imageFrame ? (
|
||||
<Image
|
||||
src={item.image}
|
||||
alt={item.imageAlt ?? ''}
|
||||
width={item.imageFrame.width}
|
||||
height={item.imageFrame.height}
|
||||
sizes="(max-width: 393px) 137vw, 485px"
|
||||
className={item.imageFrame.className}
|
||||
/>
|
||||
) : item.image ? (
|
||||
<Image
|
||||
src={item.image}
|
||||
alt={item.imageAlt ?? ''}
|
||||
fill
|
||||
sizes="355px"
|
||||
className="object-cover object-center"
|
||||
/>
|
||||
) : null}
|
||||
<div className="absolute inset-0 bg-[linear-gradient(to_top,#2a0b08_0%,rgba(42,11,8,0.96)_23%,rgba(42,11,8,0.68)_34%,transparent_62%)]" />
|
||||
<div className="absolute right-3.5 bottom-3.5 left-3.5">
|
||||
<h3 className="m-0 border-0 p-0 text-[15px] leading-tight font-bold tracking-normal">
|
||||
{item.title}
|
||||
</h3>
|
||||
<p className="m-0 mt-1 text-[12px] leading-[1.16] text-white/90">{item.body}</p>
|
||||
</div>
|
||||
</article>
|
||||
) : (
|
||||
<article className="h-full rounded-[10px] bg-(--campaign-surface) px-3.5 py-2.5 font-[family-name:var(--font-arimo)] text-black">
|
||||
<h3 className="m-0 border-0 p-0 text-[14px] leading-[1.12] font-bold tracking-normal">
|
||||
{item.title}
|
||||
</h3>
|
||||
<p className="m-0 mt-1 text-[12px] leading-[1.18] text-[#6f6f73]">{item.body}</p>
|
||||
</article>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
87
src/components/CampaignFooter.tsx
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
import Link from 'next/link'
|
||||
|
||||
const APOIAR_URL = 'https://apoiar.me/jorgesolla'
|
||||
|
||||
const REDES = [
|
||||
{ label: 'Instagram', href: 'https://instagram.com/depjorgesolla' },
|
||||
{ label: 'YouTube', href: 'https://youtube.com/@JorgeSollaDep' },
|
||||
{ label: 'Facebook', href: 'https://facebook.com/depjorgesolla' },
|
||||
]
|
||||
|
||||
/** Rodapé eleitoral da campanha: identificação, navegação e redes oficiais. */
|
||||
export const CampaignFooter = () => (
|
||||
<footer className="bg-[#180a09] text-[rgb(255_248_242/75%)]">
|
||||
<div className="mx-auto grid w-full max-w-6xl gap-6 px-4 py-10 text-sm sm:px-6 md:grid-cols-[2fr_1fr_1fr] lg:px-8">
|
||||
<div>
|
||||
<h4 className="mb-2 font-[family-name:var(--font-exo2)] text-base font-extrabold text-white">
|
||||
Jorge Solla 1313
|
||||
</h4>
|
||||
<p className="m-0 text-[rgb(255_248_242/75%)]">
|
||||
Deputado Federal · PT · Bahia
|
||||
<br />
|
||||
Um mandato do tamanho da Bahia.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="mb-2 font-[family-name:var(--font-exo2)] text-sm font-bold text-white">
|
||||
Navegue
|
||||
</h4>
|
||||
<ul className="m-0 grid list-none gap-1.5 p-0">
|
||||
<li>
|
||||
<a
|
||||
href="#bandeiras"
|
||||
className="text-[rgb(255_248_242/75%)] no-underline hover:text-white"
|
||||
>
|
||||
Bandeiras
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href={APOIAR_URL}
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
className="text-[rgb(255_248_242/75%)] no-underline hover:text-white"
|
||||
>
|
||||
Quero apoiar
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<Link
|
||||
href="/privacidade"
|
||||
className="text-[rgb(255_248_242/75%)] no-underline hover:text-white"
|
||||
>
|
||||
Privacidade
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="mb-2 font-[family-name:var(--font-exo2)] text-sm font-bold text-white">
|
||||
Redes
|
||||
</h4>
|
||||
<ul className="m-0 grid list-none gap-1.5 p-0">
|
||||
{REDES.map((rede) => (
|
||||
<li key={rede.label}>
|
||||
<a
|
||||
href={rede.href}
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
className="text-[rgb(255_248_242/75%)] no-underline hover:text-white"
|
||||
>
|
||||
{rede.label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div className="border-t border-white/10">
|
||||
<p className="mx-auto my-0 w-full max-w-6xl px-4 py-5 text-xs leading-relaxed text-[rgb(255_248_242/65%)] sm:px-6 lg:px-8">
|
||||
Jorge José Santos Pereira Solla · Candidato a Deputado Federal · Nº 1313 · Federação Brasil
|
||||
da Esperança (PT/PCdoB/PV) · CNPJ: 68.430.467/0001-05 · Propaganda eleitoral gratuita. Site
|
||||
de campanha — conteúdo sob responsabilidade do candidato. Eleições 2026 · 1º turno:
|
||||
04/10/2026.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
)
|
||||
143
src/components/CampaignHero.tsx
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
import Image from 'next/image'
|
||||
|
||||
const SUPPORT_URL = 'https://apoiar.me/jorgesolla'
|
||||
|
||||
const allyImages = [
|
||||
{
|
||||
src: '/RUI%20-%202-2.avif',
|
||||
width: 177,
|
||||
height: 265,
|
||||
className: 'left-[-22px] top-[144px] h-[265px] w-[177px] lg:left-[-35px] lg:top-[238px] lg:z-0',
|
||||
},
|
||||
{
|
||||
src: '/WAGNER%20-%202-9%20final.avif',
|
||||
width: 177,
|
||||
height: 265,
|
||||
className:
|
||||
'left-[-69px] top-[148px] h-[265px] w-[177px] lg:left-[-75px] lg:top-[278px] lg:z-[1]',
|
||||
},
|
||||
{
|
||||
src: '/Jeronimo.avif',
|
||||
width: 177,
|
||||
height: 265,
|
||||
className:
|
||||
'left-[224px] top-[140px] h-[265px] w-[177px] lg:left-[84px] lg:top-[249px] lg:z-[1]',
|
||||
},
|
||||
{
|
||||
src: '/Lula.avif',
|
||||
width: 216,
|
||||
height: 213,
|
||||
className:
|
||||
'left-[262px] top-[179px] h-[213px] w-[216px] lg:left-[-8px] lg:top-[308px] lg:z-[2] lg:h-[235px] lg:w-[238px]',
|
||||
},
|
||||
]
|
||||
|
||||
export const CampaignHero = () => (
|
||||
<section
|
||||
aria-labelledby="campaign-title"
|
||||
data-home-section="hero"
|
||||
className="relative h-[745px] overflow-hidden bg-(--pt-red) text-white max-[383px]:h-[780px] lg:h-[543px]"
|
||||
>
|
||||
<div className="relative mx-auto h-full w-full max-w-[393px] lg:max-w-[1024px]">
|
||||
<div
|
||||
role="img"
|
||||
aria-label="Jorge Solla 1313 — candidato a deputado federal"
|
||||
className="campaign-home-logo absolute z-30"
|
||||
/>
|
||||
|
||||
<div
|
||||
role="img"
|
||||
aria-label="Jorge Solla com Lula, Jerônimo Rodrigues, Jaques Wagner e Rui Costa"
|
||||
className="absolute inset-0 z-10"
|
||||
>
|
||||
{allyImages.map((image) => (
|
||||
<Image
|
||||
key={image.src}
|
||||
src={image.src}
|
||||
alt=""
|
||||
width={image.width}
|
||||
height={image.height}
|
||||
sizes="(min-width: 1024px) 238px, 216px"
|
||||
loading="eager"
|
||||
className={`absolute max-w-none object-contain ${image.className}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="absolute top-[53px] left-1/2 z-20 h-[469px] w-[422px] -translate-x-1/2 overflow-hidden lg:top-[26px] lg:left-[153px] lg:h-[517px] lg:w-[465px] lg:translate-x-0">
|
||||
<Image
|
||||
src="/JOA00162.avif"
|
||||
alt="Jorge Solla, candidato a deputado federal pela Bahia"
|
||||
width={495}
|
||||
height={742}
|
||||
sizes="(min-width: 1024px) 495px, 449px"
|
||||
priority
|
||||
className="absolute -top-[17px] left-px h-[673px] w-[449px] max-w-none object-contain lg:-top-[19px] lg:h-[742px] lg:w-[495px]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
data-mobile-hero-overlay
|
||||
className="absolute top-[300px] left-1/2 z-20 h-[245px] w-screen -translate-x-1/2 bg-[linear-gradient(to_bottom,transparent_0%,rgba(162,28,28,0.5)_38%,#a21c1c_78%)] lg:hidden"
|
||||
/>
|
||||
|
||||
<div className="absolute top-[462px] left-0 z-30 w-full lg:top-[106px] lg:right-[47px] lg:left-auto lg:w-[392px]">
|
||||
<h1
|
||||
id="campaign-title"
|
||||
aria-label="UM MANDATO DO TAMANHO DA BAHIA"
|
||||
className="m-0 border-0 p-0 text-center font-[family-name:var(--font-exo2)] text-[32px] leading-[1.12] tracking-[-0.02em] text-balance uppercase lg:text-right lg:text-[36px] lg:leading-[1.2]"
|
||||
>
|
||||
<span className="block font-medium">Um mandato do</span>
|
||||
<span className="block font-black">tamanho da Bahia</span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div className="absolute top-[547px] left-0 z-30 w-full lg:static">
|
||||
<p className="m-0 ml-6 w-[calc(100%_-_66px)] text-left font-sans text-[14px] leading-[1.2] uppercase lg:absolute lg:top-[212px] lg:right-[47px] lg:z-30 lg:ml-0 lg:w-[418px] lg:text-right lg:text-[18px]">
|
||||
Médico sanitarista.{' '}
|
||||
<strong className="font-extrabold text-(--pt-yellow)">Criou o SAMU 192</strong> e o{' '}
|
||||
<strong className="font-extrabold">Brasil Sorridente</strong>. Já comandou a saúde em
|
||||
Vitória da Conquista, na Bahia e no Brasil — e leva o mandato aos 417 municípios, da saúde
|
||||
à educação.
|
||||
</p>
|
||||
|
||||
<div className="mt-5 mr-[18px] flex items-stretch justify-end gap-2.5 lg:absolute lg:top-[349px] lg:right-[47px] lg:z-30 lg:mt-0 lg:mr-0 lg:justify-start lg:gap-6">
|
||||
<a
|
||||
href="#bandeiras"
|
||||
aria-label="Conhecer bandeiras"
|
||||
data-cta="secondary"
|
||||
className="campaign-action-feedback inline-flex min-h-11 w-[145px] flex-col items-center justify-center rounded-[10px] border-2 border-white/55 px-3 text-center font-[family-name:var(--font-exo2)] text-[17px] leading-[1.05] font-extrabold text-white no-underline hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-(--pt-red) focus-visible:outline-none lg:h-[60px] lg:w-[158px] lg:text-[18px]"
|
||||
>
|
||||
Conhecer
|
||||
<small className="hidden text-[12px] leading-none font-semibold lg:block">
|
||||
bandeiras
|
||||
</small>
|
||||
</a>
|
||||
<a
|
||||
href={SUPPORT_URL}
|
||||
aria-label="Quero apoiar — é rápido, 30 segundos"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
data-cta="primary"
|
||||
className="campaign-action-feedback inline-flex min-h-11 w-[112px] flex-col items-center justify-center rounded-[10px] bg-(--pt-yellow) px-2 text-center font-[family-name:var(--font-exo2)] text-[17px] leading-[1.05] font-black text-(--pt-yellow-ink) no-underline hover:brightness-95 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-(--pt-red) focus-visible:outline-none lg:h-[60px] lg:w-[158px] lg:text-[18px]"
|
||||
>
|
||||
<span className="lg:hidden">Apoiar</span>
|
||||
<span className="hidden lg:inline">Quero apoiar</span>
|
||||
<small className="hidden text-[12px] leading-none font-semibold lg:block">
|
||||
é rápido, 30 segundos
|
||||
</small>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="absolute right-[18px] bottom-3 z-30 flex flex-col items-end gap-0.5 text-right font-sans text-[10px] leading-3 text-white/80 lg:top-[494px] lg:right-auto lg:bottom-auto lg:left-[559px] lg:items-start lg:gap-2 lg:text-left lg:text-[12px] lg:leading-[15px]">
|
||||
<span aria-label="DIAP entre os 40 melhores da Câmara">
|
||||
<strong className="font-extrabold text-white">DIAP</strong> entre os 40 melhores da Câmara
|
||||
</span>
|
||||
<span aria-label="Mais votado do PT-BA em 2022">
|
||||
<strong className="font-extrabold text-white">Mais votado</strong> do PT-BA em 2022
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { formatBahiaCivilDate, parseBahiaDateTimeInput } from '../../src/lib/campaignTime.js'
|
||||
import { hookFilledCreateData } from '../../src/utilities/hookFilledData.js'
|
||||
import { campaignPageChrome, expect, test } from './fixtures/campaignE2EFixtures.js'
|
||||
import { dayLabelFor, ptBrMonthNames } from './helpers/agendaPeriodLabels.js'
|
||||
import { civilDatePlusDays, dayLabelFor, ptBrMonthNames } from './helpers/agendaPeriodLabels.js'
|
||||
|
||||
/**
|
||||
* Agenda prologue shared by every journey in this file: opens the agenda
|
||||
|
|
@ -83,7 +83,9 @@ test.describe('Atividades — registro-fundação', () => {
|
|||
await expect(editModal).toBeVisible()
|
||||
await expect(editModal.getByLabel('Título *')).toBeVisible({ timeout: 30_000 })
|
||||
await editModal.getByRole('link', { name: 'Ver detalhes' }).click()
|
||||
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+$/, { timeout: 30_000 })
|
||||
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+(?:\?tab=overview)?$/, {
|
||||
timeout: 30_000,
|
||||
})
|
||||
await expect(campaignPageChrome(page, activityTitle)).toBeVisible({
|
||||
timeout: 15_000,
|
||||
})
|
||||
|
|
@ -305,13 +307,23 @@ test.describe('Agenda — calendário operacional', () => {
|
|||
).toHaveCount(0)
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
// Multi-day: the end picker lands on a later day of the same month.
|
||||
// Multi-day: the end picker lands on a later day, always +1 from today:
|
||||
// the target stays inside the picker's visible grid (an inside day, or
|
||||
// day 1 of the next month as an outside day) — no hardcoded dates (C134).
|
||||
// The button label is date-fns pt-BR "PPPP" ("sexta-feira, 14 de agosto
|
||||
// de 2026"): day without leading zero, month in lowercase — the string
|
||||
// name matcher is case-insensitive, the day number is not.
|
||||
const [endYear, endMonth, endDay] = civilDatePlusDays(
|
||||
formatBahiaCivilDate(new Date()),
|
||||
1,
|
||||
).split('-')
|
||||
const endDayLabel = `${Number(endDay)} de ${ptBrMonthNames[Number(endMonth) - 1]} de ${endYear}`
|
||||
await page.getByRole('button', { name: 'Término', exact: true }).click()
|
||||
const endPicker = page.locator('[data-slot="popover-content"][data-state="open"]').last()
|
||||
await endPicker.getByRole('button', { name: /17 de agosto de 2026/ }).click()
|
||||
await endPicker.getByRole('button', { name: endDayLabel }).click()
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(page.getByRole('button', { name: 'Término', exact: true })).toHaveText(
|
||||
/17\/08\/2026/,
|
||||
`${endDay}/${endMonth}/${endYear}`,
|
||||
)
|
||||
|
||||
await page.getByLabel('Título *').fill(title)
|
||||
|
|
@ -331,7 +343,9 @@ test.describe('Agenda — calendário operacional', () => {
|
|||
await expect(editModal).toBeVisible()
|
||||
await expect(editModal.getByLabel('Título *')).toBeVisible({ timeout: 30_000 })
|
||||
await editModal.getByRole('link', { name: 'Ver detalhes' }).click()
|
||||
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+$/, { timeout: 30_000 })
|
||||
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+(?:\?tab=overview)?$/, {
|
||||
timeout: 30_000,
|
||||
})
|
||||
await expect(page.getByText(/^\d{2}\/\d{2}\/\d{4}$/).first()).toBeVisible()
|
||||
await expect(page.getByText(/\d{2}\/\d{2}\/\d{4} às /)).toHaveCount(0)
|
||||
})
|
||||
|
|
@ -384,7 +398,9 @@ test.describe('Agenda — calendário operacional', () => {
|
|||
const detailModal = page.getByRole('dialog', { name: 'Editar atividade' })
|
||||
await expect(detailModal.getByLabel('Título *')).toBeVisible({ timeout: 30_000 })
|
||||
await detailModal.getByRole('link', { name: 'Ver detalhes' }).click()
|
||||
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+$/, { timeout: 30_000 })
|
||||
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+(?:\?tab=overview)?$/, {
|
||||
timeout: 30_000,
|
||||
})
|
||||
// The location shows in the overview's own <dd> (exact); the chrome
|
||||
// subtitle carries "município · local" as one string.
|
||||
await expect(page.getByText(newLocality, { exact: true })).toBeVisible()
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ test.describe('Conceitos de inteligência', () => {
|
|||
|
||||
await page.goto('/campanha/conceitos')
|
||||
|
||||
await expect(page).toHaveURL(/\/campanha\/contatos\/?$/)
|
||||
await expect(page).toHaveURL(/\/campanha\/meus-contatos\/?$/)
|
||||
await expect(campaignPageChrome(page, 'Conceitos de inteligência')).toHaveCount(0)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -116,6 +116,15 @@ test.describe('Contatos — página da entidade Contact', () => {
|
|||
})
|
||||
expect(stored.docs).toHaveLength(1)
|
||||
expect(stored.docs[0]!.phones?.[0]?.value).toBe(phone)
|
||||
|
||||
// The row was created THROUGH the UI, so the ownership proxy never tracked
|
||||
// it (and its letters-only name does not carry the runID, so discovery
|
||||
// cannot find it) — delete it explicitly or every run leaks a contact.
|
||||
await fixtures.payload.delete({
|
||||
collection: 'contact',
|
||||
where: { name: { equals: contactName } },
|
||||
depth: 0,
|
||||
})
|
||||
})
|
||||
|
||||
test('a duplicate name shows the safe conflict message in the create row', async ({
|
||||
|
|
@ -201,6 +210,14 @@ test.describe('Contatos — página da entidade Contact', () => {
|
|||
await expect(
|
||||
card.getByRole('link', { name: `Enviar WhatsApp para ${contactName}` }),
|
||||
).toHaveAttribute('href', `https://wa.me/55${phone}`)
|
||||
|
||||
// UI-created (see the desktop create-row test): delete explicitly so the
|
||||
// ownership discovery (runID in name) is not the only net.
|
||||
await fixtures.payload.delete({
|
||||
collection: 'contact',
|
||||
where: { name: { equals: contactName } },
|
||||
depth: 0,
|
||||
})
|
||||
})
|
||||
|
||||
test('mobile: the edit sheet keeps values on conflict and saves the ficha atomically', async ({
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ test.describe('Início — catálogo de ações (B45)', () => {
|
|||
await expect(page.getByRole('link', { name: 'Ver meus contatos', exact: true })).toBeVisible()
|
||||
|
||||
await page.getByRole('link', { name: 'Ver meus contatos', exact: true }).click()
|
||||
await page.waitForURL(/\/campanha\/contatos/)
|
||||
await page.waitForURL(/\/campanha\/meus-contatos/)
|
||||
await expect(page.getByRole('heading', { name: /Meus contatos/ })).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import type { CampaignUser } from '../../../src/payload-types.js'
|
|||
import config from '../../../src/payload.config.js'
|
||||
import { withPayloadTransaction } from '../../../src/utilities/payloadTransaction.js'
|
||||
import { assertTestDatabase } from '../../helpers/assertTestDatabase.js'
|
||||
import { purgeMunicipalityResidue } from '../../helpers/campaignResidue.js'
|
||||
import { withInviteConsent } from '../../helpers/testDatabaseLease.js'
|
||||
import { test as base, expect } from './e2eTest.js'
|
||||
|
||||
|
|
@ -156,6 +157,11 @@ export class CampaignE2EOwnership {
|
|||
const municipality = found.docs[0]
|
||||
if (!municipality)
|
||||
throw new Error(`Seeded municipality "${slug}" not found — run migrations first.`)
|
||||
// OPS45 — a crashed e2e run (worker killed before the cleanup `finally`)
|
||||
// leaves rows behind; purge them on the fresh claim, mirroring the int
|
||||
// `getMunicipality` contract. Safe by the allocator: no live run owns
|
||||
// this municipality.
|
||||
await purgeMunicipalityResidue(this.rootPayload, municipality.id)
|
||||
this.touchedMunicipalities.add(municipality.id)
|
||||
// The catalog name, not the row's: since B34+ the chips label from
|
||||
// `municipalityCatalog`, so a row an int spec renamed and left behind would
|
||||
|
|
|
|||
|
|
@ -1,13 +1,152 @@
|
|||
import type { Page } from '@playwright/test'
|
||||
|
||||
import { expect, test } from './fixtures/e2eTest'
|
||||
|
||||
const swipeLeft = async (
|
||||
page: Page,
|
||||
box: { x: number; y: number; width: number; height: number },
|
||||
) => {
|
||||
const cdp = await page.context().newCDPSession(page)
|
||||
const y = Math.round(box.y + box.height / 2)
|
||||
const startX = Math.round(box.x + box.width * 0.82)
|
||||
const endX = Math.round(box.x + box.width * 0.12)
|
||||
|
||||
await cdp.send('Input.dispatchTouchEvent', {
|
||||
type: 'touchStart',
|
||||
touchPoints: [{ x: startX, y }],
|
||||
})
|
||||
for (let step = 1; step <= 5; step += 1) {
|
||||
const x = Math.round(startX + ((endX - startX) * step) / 5)
|
||||
await cdp.send('Input.dispatchTouchEvent', {
|
||||
type: 'touchMove',
|
||||
touchPoints: [{ x, y }],
|
||||
})
|
||||
await page.waitForTimeout(25)
|
||||
}
|
||||
await cdp.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] })
|
||||
}
|
||||
|
||||
test.describe('Frontend', () => {
|
||||
test('can go on homepage', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
|
||||
await expect(page).toHaveTitle(/Jorge Solla/)
|
||||
|
||||
const heading = page.locator('h1').first()
|
||||
const heading = page.getByRole('heading', {
|
||||
level: 1,
|
||||
name: 'UM MANDATO DO TAMANHO DA BAHIA',
|
||||
})
|
||||
|
||||
await expect(heading).toHaveText('O mandato do tamanho da Bahia')
|
||||
await expect(heading).toBeVisible()
|
||||
await expect(page.locator('[data-cta="primary"]')).toHaveAttribute(
|
||||
'href',
|
||||
'https://apoiar.me/jorgesolla',
|
||||
)
|
||||
})
|
||||
|
||||
test('animates the flags navigation and gives pointer feedback on campaign buttons', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/')
|
||||
|
||||
const scrollContainer = page.locator('[data-theme="campaign-site"]')
|
||||
const secondaryCta = page.locator('[data-cta="secondary"]')
|
||||
|
||||
await expect(scrollContainer).toHaveCSS('scroll-behavior', 'smooth')
|
||||
await secondaryCta.hover()
|
||||
await expect
|
||||
.poll(() => secondaryCta.evaluate((element) => getComputedStyle(element).transform))
|
||||
.toContain('1.05')
|
||||
|
||||
const box = await secondaryCta.boundingBox()
|
||||
if (!box) throw new Error('O CTA secundário não ficou visível para testar o clique.')
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2)
|
||||
await page.mouse.down()
|
||||
await expect(secondaryCta).toHaveCSS('opacity', '0.8')
|
||||
await page.mouse.move(0, 0)
|
||||
await page.mouse.up()
|
||||
|
||||
await secondaryCta.click()
|
||||
await expect(page).toHaveURL(/#bandeiras$/)
|
||||
await expect(page.locator('#bandeiras')).toBeInViewport()
|
||||
})
|
||||
|
||||
test('keeps breathing room between the wrapped hero subtitle and CTAs on iPhone SE', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 320, height: 568 })
|
||||
await page.goto('/')
|
||||
await expect(page).toHaveURL(/\/$/)
|
||||
|
||||
const hero = page.locator('[data-home-section="hero"]')
|
||||
const subtitleBox = await hero.locator('p').first().boundingBox()
|
||||
const actionsBox = await hero.locator('[data-cta="secondary"]').locator('..').boundingBox()
|
||||
if (!subtitleBox || !actionsBox) throw new Error('O conteúdo principal do hero não foi medido.')
|
||||
|
||||
expect(actionsBox.y - (subtitleBox.y + subtitleBox.height)).toBeGreaterThanOrEqual(16)
|
||||
})
|
||||
|
||||
test('auto-advances and keeps carousel controls synchronized', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
|
||||
const problemCarousel = page.getByRole('region', {
|
||||
name: 'Bandeiras que tornam esta eleição decisiva',
|
||||
})
|
||||
const firstProblem = problemCarousel.getByRole('listitem', { name: '1 de 3' })
|
||||
const secondProblem = problemCarousel.getByRole('listitem', { name: '2 de 3' })
|
||||
|
||||
await expect(firstProblem).toHaveAttribute('aria-current', 'true')
|
||||
await expect(secondProblem).toHaveAttribute('aria-current', 'true', { timeout: 6_000 })
|
||||
|
||||
const flagCarousel = page.getByRole('region', { name: 'Bandeiras da campanha' })
|
||||
const educationChip = flagCarousel.getByRole('button', { name: 'Educação' })
|
||||
await educationChip.click()
|
||||
await expect(educationChip).toHaveAttribute('aria-current', 'true')
|
||||
})
|
||||
|
||||
test('supports a real horizontal touch swipe on mobile', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 430, height: 900 })
|
||||
await page.goto('/')
|
||||
|
||||
const overlayBox = await page.locator('[data-mobile-hero-overlay]').boundingBox()
|
||||
expect(overlayBox?.x).toBe(0)
|
||||
expect(overlayBox?.width).toBe(430)
|
||||
|
||||
const mobileSpacing = await page.evaluate(() => {
|
||||
const rect = (selector: string) => document.querySelector(selector)?.getBoundingClientRect()
|
||||
const problemSection = rect('[data-home-section="problem"]')
|
||||
const problemLead = rect('#problem-title + p')
|
||||
const problemCarousel = rect('[data-home-section="problem"] [data-carousel]')
|
||||
const flagsSection = rect('[data-home-section="flags"]')
|
||||
const flagsCarousel = rect('[data-home-section="flags"] [data-carousel]')
|
||||
|
||||
return {
|
||||
leadGap:
|
||||
problemLead && problemCarousel ? problemCarousel.top - problemLead.bottom : undefined,
|
||||
problemBottomGap:
|
||||
problemSection && problemCarousel
|
||||
? problemSection.bottom - problemCarousel.bottom
|
||||
: undefined,
|
||||
flagsBottomGap:
|
||||
flagsSection && flagsCarousel ? flagsSection.bottom - flagsCarousel.bottom : undefined,
|
||||
}
|
||||
})
|
||||
expect(mobileSpacing.leadGap).toBeLessThan(40)
|
||||
expect(mobileSpacing.problemBottomGap).toBeGreaterThanOrEqual(40)
|
||||
expect(mobileSpacing.flagsBottomGap).toBeGreaterThanOrEqual(40)
|
||||
|
||||
const carousel = page.getByRole('region', { name: 'Bandeiras da campanha' })
|
||||
await carousel.focus()
|
||||
const track = carousel.locator('[data-carousel-track]')
|
||||
await track.scrollIntoViewIfNeeded()
|
||||
const box = await track.boundingBox()
|
||||
if (!box) throw new Error('O trilho das bandeiras não ficou visível para o swipe.')
|
||||
|
||||
await swipeLeft(page, box)
|
||||
|
||||
await expect(carousel.getByRole('button', { name: 'Educação' })).toHaveAttribute(
|
||||
'aria-current',
|
||||
'true',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import type {
|
|||
VotePledge,
|
||||
} from '@/payload-types'
|
||||
import { withPayloadTransaction } from '@/utilities/payloadTransaction'
|
||||
import { purgeMunicipalityResidue, relationId, relationIds } from './campaignResidue'
|
||||
|
||||
/**
|
||||
* Campaign fixtures for the Município model. Municipalities are SEEDED reference rows
|
||||
|
|
@ -169,25 +170,10 @@ const defaultConsentText = (text: string): Consent['text'] => ({
|
|||
},
|
||||
})
|
||||
|
||||
type RelationshipValue = number | { id: number }
|
||||
|
||||
/**
|
||||
* Id of a relationship field at any depth.
|
||||
*
|
||||
* Specs use this instead of `relationshipId` from `src/utilities/relationship`
|
||||
* so an assertion never runs through the production helper it is checking, and
|
||||
* instead of `uniqueRelationshipIds`, which dedups — hiding a duplicated link.
|
||||
*/
|
||||
export function relationId(value: RelationshipValue): number
|
||||
export function relationId(value: RelationshipValue | null | undefined): number | undefined
|
||||
export function relationId(value: RelationshipValue | null | undefined): number | undefined {
|
||||
if (value === null || value === undefined) return undefined
|
||||
return typeof value === 'number' ? value : value.id
|
||||
}
|
||||
|
||||
/** Order-preserving, non-deduping ids of a `hasMany` relationship field. */
|
||||
export const relationIds = (values: readonly RelationshipValue[] | null | undefined): number[] =>
|
||||
(values ?? []).map((value) => relationId(value))
|
||||
// `relationId`/`relationIds`/`purgeMunicipalityResidue` live in
|
||||
// `campaignResidue.ts` (vitest-free — the e2e fixture imports it inside the
|
||||
// Playwright process) and are re-exported here for the existing importers.
|
||||
export { purgeMunicipalityResidue, relationId, relationIds } from './campaignResidue'
|
||||
|
||||
const bulkErrors = (result: unknown): unknown[] => {
|
||||
if (
|
||||
|
|
@ -233,172 +219,6 @@ const nextAllocatedMunicipalityIndex = async (
|
|||
return value % catalogSize
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete campaign rows attached to a freshly claimed municipality. The allocator
|
||||
* guarantees no OTHER live test owns this municipality, so anything found here is
|
||||
* residue from an aborted previous run that would poison count assertions.
|
||||
* Also deletes the CONTACT rows those residue supporters orphaned (D10 F1).
|
||||
*/
|
||||
export const purgeMunicipalityResidue = async (
|
||||
payload: Payload,
|
||||
municipalityID: number,
|
||||
): Promise<void> => {
|
||||
const [pledges, updates, demands, leaderships, supporters, activities, feeds] = await Promise.all(
|
||||
[
|
||||
payload.find({
|
||||
collection: 'votePledge',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'municipalityUpdate',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'campaignDemand',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'leadership',
|
||||
where: { municipalities: { in: [municipalityID] } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'supporter',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'activity',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'calendarFeed',
|
||||
where: { filterMunicipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
],
|
||||
)
|
||||
|
||||
// Residue invites reference residue leaderships (FK), so they must be
|
||||
// found and deleted before the leaderships — otherwise the leadership
|
||||
// delete aborts and the residue poisons every later claim of this municipality.
|
||||
const leadershipIDs = leaderships.docs.map((doc) => doc.id)
|
||||
const invites =
|
||||
leadershipIDs.length > 0
|
||||
? await payload.find({
|
||||
collection: 'campaignInvite',
|
||||
where: { leadership: { in: leadershipIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
})
|
||||
: { docs: [] }
|
||||
|
||||
const deletions: Array<{
|
||||
collection:
|
||||
| 'campaignInvite'
|
||||
| 'votePledge'
|
||||
| 'municipalityUpdate'
|
||||
| 'campaignDemand'
|
||||
| 'leadership'
|
||||
| 'supporter'
|
||||
| 'activity'
|
||||
| 'calendarFeed'
|
||||
ids: number[]
|
||||
}> = [
|
||||
{ collection: 'campaignInvite', ids: invites.docs.map((doc) => doc.id) },
|
||||
{ collection: 'votePledge', ids: pledges.docs.map((doc) => doc.id) },
|
||||
{ collection: 'municipalityUpdate', ids: updates.docs.map((doc) => doc.id) },
|
||||
{ collection: 'campaignDemand', ids: demands.docs.map((doc) => doc.id) },
|
||||
{ collection: 'activity', ids: activities.docs.map((doc) => doc.id) },
|
||||
{ collection: 'calendarFeed', ids: feeds.docs.map((doc) => doc.id) },
|
||||
{ collection: 'leadership', ids: leadershipIDs },
|
||||
{ collection: 'supporter', ids: supporters.docs.map((doc) => doc.id) },
|
||||
]
|
||||
for (const { collection, ids } of deletions) {
|
||||
if (ids.length === 0) continue
|
||||
await payload.delete({
|
||||
collection,
|
||||
where: { id: { in: ids } },
|
||||
depth: 0,
|
||||
})
|
||||
}
|
||||
|
||||
// D10 F1: an aborted run leaves residue supporters AND their contact rows.
|
||||
// The supporters are gone above; delete the contacts they orphaned (no other
|
||||
// join references them) so the residue stops accumulating — same reference
|
||||
// rule as the production `removeSupporterData` flow, reimplemented here so
|
||||
// the fixture never runs production code under test.
|
||||
const residueContactIDs = [
|
||||
...new Set(
|
||||
supporters.docs.map((doc) => relationId(doc.contact)).filter((id) => id !== undefined),
|
||||
),
|
||||
]
|
||||
if (residueContactIDs.length > 0) {
|
||||
const [leadershipRefs, signatureRefs, subscriptionRefs, supporterRefs] = await Promise.all([
|
||||
payload.find({
|
||||
collection: 'leadership',
|
||||
where: { contact: { in: residueContactIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'signature',
|
||||
where: { contact: { in: residueContactIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'subscription',
|
||||
where: { contact: { in: residueContactIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'supporter',
|
||||
where: { contact: { in: residueContactIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
])
|
||||
const referenced = new Set<number>()
|
||||
for (const doc of [
|
||||
...leadershipRefs.docs,
|
||||
...signatureRefs.docs,
|
||||
...subscriptionRefs.docs,
|
||||
...supporterRefs.docs,
|
||||
]) {
|
||||
const contactID = relationId(doc.contact)
|
||||
if (contactID !== undefined) referenced.add(contactID)
|
||||
}
|
||||
const orphanContactIDs = residueContactIDs.filter((id) => !referenced.has(id))
|
||||
if (orphanContactIDs.length > 0) {
|
||||
await payload.delete({
|
||||
collection: 'contact',
|
||||
where: { id: { in: orphanContactIDs } },
|
||||
depth: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class CampaignFixtures {
|
||||
readonly payload: Payload
|
||||
readonly runID: string
|
||||
|
|
|
|||
266
tests/helpers/campaignResidue.ts
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
import type { Payload } from 'payload'
|
||||
|
||||
/**
|
||||
* Municipality residue purge for the test fixtures — shared by the int
|
||||
* (`campaignFixtures.ts`) and e2e (`campaignE2EFixtures.ts`) suites.
|
||||
*
|
||||
* Deliberately VITEST-FREE: the e2e fixture imports this module inside the
|
||||
* Playwright process, and a vitest import there crashes at load time
|
||||
* (`TypeError: Cannot redefine property: Symbol($$jest-matchers-object)` from
|
||||
* `@vitest/expect` — OPS45/CI 2026-08-13).
|
||||
*/
|
||||
|
||||
type RelationshipValue = number | { id: number }
|
||||
|
||||
/**
|
||||
* Id of a relationship field at any depth.
|
||||
*
|
||||
* Specs use this instead of `relationshipId` from `src/utilities/relationship`
|
||||
* so an assertion never runs through the production helper it is checking, and
|
||||
* instead of `uniqueRelationshipIds`, which dedups — hiding a duplicated link.
|
||||
*/
|
||||
export function relationId(value: RelationshipValue): number
|
||||
export function relationId(value: RelationshipValue | null | undefined): number | undefined
|
||||
export function relationId(value: RelationshipValue | null | undefined): number | undefined {
|
||||
if (value === null || value === undefined) return undefined
|
||||
return typeof value === 'number' ? value : value.id
|
||||
}
|
||||
|
||||
/** Order-preserving, non-deduping ids of a `hasMany` relationship field. */
|
||||
export const relationIds = (values: readonly RelationshipValue[] | null | undefined): number[] =>
|
||||
(values ?? []).map((value) => relationId(value))
|
||||
|
||||
/**
|
||||
* D10 F1 / OPS45: delete CONTACT rows an aborted run orphaned (no other join
|
||||
* references them). Production `removeSupporterData` only anonymizes, so its
|
||||
* reference rule is a subset of what a DELETE needs: every join that can hold
|
||||
* a ficha must be checked — leadership/signature/subscription/supporter, the
|
||||
* C99 account link (`campaignUser.contact`) and the `stateDeputy` FK
|
||||
* (`ON DELETE RESTRICT`, so an unchecked deputy would make the delete throw).
|
||||
* Reimplemented here so the fixture never runs production code under test.
|
||||
*/
|
||||
const deleteOrphanedResidueContacts = async (
|
||||
payload: Payload,
|
||||
contactIDs: Array<number | undefined>,
|
||||
): Promise<void> => {
|
||||
const uniqueIDs = [...new Set(contactIDs.filter((id): id is number => id !== undefined))]
|
||||
if (uniqueIDs.length === 0) return
|
||||
const [leadershipRefs, signatureRefs, subscriptionRefs, supporterRefs, accountRefs, deputyRefs] =
|
||||
await Promise.all([
|
||||
payload.find({
|
||||
collection: 'leadership',
|
||||
where: { contact: { in: uniqueIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'signature',
|
||||
where: { contact: { in: uniqueIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'subscription',
|
||||
where: { contact: { in: uniqueIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'supporter',
|
||||
where: { contact: { in: uniqueIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'campaignUser',
|
||||
where: { contact: { in: uniqueIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'stateDeputy',
|
||||
where: { contact: { in: uniqueIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
])
|
||||
const referenced = new Set<number>()
|
||||
for (const doc of [
|
||||
...leadershipRefs.docs,
|
||||
...signatureRefs.docs,
|
||||
...subscriptionRefs.docs,
|
||||
...supporterRefs.docs,
|
||||
...accountRefs.docs,
|
||||
...deputyRefs.docs,
|
||||
]) {
|
||||
const contactID = relationId(doc.contact)
|
||||
if (contactID !== undefined) referenced.add(contactID)
|
||||
}
|
||||
const orphanContactIDs = uniqueIDs.filter((id) => !referenced.has(id))
|
||||
if (orphanContactIDs.length > 0) {
|
||||
await payload.delete({
|
||||
collection: 'contact',
|
||||
where: { id: { in: orphanContactIDs } },
|
||||
depth: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete campaign rows attached to a freshly claimed municipality. The allocator
|
||||
* guarantees no OTHER live test owns this municipality, so anything found here is
|
||||
* residue from an aborted previous run that would poison count assertions.
|
||||
* Also deletes the CONTACT rows those residue supporters orphaned (D10 F1) and
|
||||
* the dobradinha residue (OPS45): deputies linked through
|
||||
* `municipality.stateDeputies`, their orphaned fichas, and the field itself.
|
||||
*/
|
||||
export const purgeMunicipalityResidue = async (
|
||||
payload: Payload,
|
||||
municipalityID: number,
|
||||
): Promise<void> => {
|
||||
const [pledges, updates, demands, leaderships, supporters, activities, feeds] = await Promise.all(
|
||||
[
|
||||
payload.find({
|
||||
collection: 'votePledge',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'municipalityUpdate',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'campaignDemand',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'leadership',
|
||||
where: { municipalities: { in: [municipalityID] } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'supporter',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'activity',
|
||||
where: { municipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
payload.find({
|
||||
collection: 'calendarFeed',
|
||||
where: { filterMunicipality: { equals: municipalityID } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
}),
|
||||
],
|
||||
)
|
||||
|
||||
// Residue invites reference residue leaderships (FK), so they must be
|
||||
// found and deleted before the leaderships — otherwise the leadership
|
||||
// delete aborts and the residue poisons every later claim of this municipality.
|
||||
const leadershipIDs = leaderships.docs.map((doc) => doc.id)
|
||||
const invites =
|
||||
leadershipIDs.length > 0
|
||||
? await payload.find({
|
||||
collection: 'campaignInvite',
|
||||
where: { leadership: { in: leadershipIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: {},
|
||||
})
|
||||
: { docs: [] }
|
||||
|
||||
const deletions: Array<{
|
||||
collection:
|
||||
| 'campaignInvite'
|
||||
| 'votePledge'
|
||||
| 'municipalityUpdate'
|
||||
| 'campaignDemand'
|
||||
| 'leadership'
|
||||
| 'supporter'
|
||||
| 'activity'
|
||||
| 'calendarFeed'
|
||||
ids: number[]
|
||||
}> = [
|
||||
{ collection: 'campaignInvite', ids: invites.docs.map((doc) => doc.id) },
|
||||
{ collection: 'votePledge', ids: pledges.docs.map((doc) => doc.id) },
|
||||
{ collection: 'municipalityUpdate', ids: updates.docs.map((doc) => doc.id) },
|
||||
{ collection: 'campaignDemand', ids: demands.docs.map((doc) => doc.id) },
|
||||
{ collection: 'activity', ids: activities.docs.map((doc) => doc.id) },
|
||||
{ collection: 'calendarFeed', ids: feeds.docs.map((doc) => doc.id) },
|
||||
{ collection: 'leadership', ids: leadershipIDs },
|
||||
{ collection: 'supporter', ids: supporters.docs.map((doc) => doc.id) },
|
||||
]
|
||||
for (const { collection, ids } of deletions) {
|
||||
if (ids.length === 0) continue
|
||||
await payload.delete({
|
||||
collection,
|
||||
where: { id: { in: ids } },
|
||||
depth: 0,
|
||||
})
|
||||
}
|
||||
|
||||
// D10 F1: an aborted run leaves residue supporters AND their contact rows.
|
||||
// The supporters are gone above; delete the contacts they orphaned (no other
|
||||
// join references them) so the residue stops accumulating.
|
||||
await deleteOrphanedResidueContacts(
|
||||
payload,
|
||||
supporters.docs.map((doc) => relationId(doc.contact)),
|
||||
)
|
||||
|
||||
// OPS45 — dobradinha residue: deputies linked through the freshly claimed
|
||||
// municipality's `stateDeputies` belong to the crashed run that claimed it
|
||||
// (the allocator contract rules out a live owner). Delete the deputies,
|
||||
// the fichas they orphaned, and clear the field so a later claim starts
|
||||
// clean. The deputy contacts are captured BEFORE the delete.
|
||||
const claimed = await payload.findByID({
|
||||
collection: 'municipality',
|
||||
id: municipalityID,
|
||||
depth: 0,
|
||||
select: { stateDeputies: true },
|
||||
overrideAccess: true,
|
||||
})
|
||||
const residueDeputyIDs = relationIds(claimed?.stateDeputies ?? [])
|
||||
if (residueDeputyIDs.length > 0) {
|
||||
const deputies = await payload.find({
|
||||
collection: 'stateDeputy',
|
||||
where: { id: { in: residueDeputyIDs } },
|
||||
depth: 0,
|
||||
pagination: false,
|
||||
select: { contact: true },
|
||||
overrideAccess: true,
|
||||
})
|
||||
await payload.delete({
|
||||
collection: 'stateDeputy',
|
||||
where: { id: { in: residueDeputyIDs } },
|
||||
depth: 0,
|
||||
})
|
||||
await deleteOrphanedResidueContacts(
|
||||
payload,
|
||||
deputies.docs.map((doc) => relationId(doc.contact)),
|
||||
)
|
||||
await payload.update({
|
||||
collection: 'municipality',
|
||||
id: municipalityID,
|
||||
data: { stateDeputies: [] },
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@ import config from '@/payload.config'
|
|||
import {
|
||||
createCampaignFixtures,
|
||||
purgeMunicipalityResidue,
|
||||
relationId,
|
||||
relationIds,
|
||||
withCampaignFixtures,
|
||||
} from '../helpers/campaignFixtures'
|
||||
import { withInviteConsent, withMutableConsentFixture } from '../helpers/testDatabaseLease'
|
||||
|
|
@ -445,4 +447,93 @@ describe('campaign integration fixtures', () => {
|
|||
await fixtures.cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
it('purges residue dobradinhas and their orphaned fichas on a municipality claim', async () => {
|
||||
// OPS45: a crashed run leaves deputies linked through the claimed
|
||||
// municipality's `stateDeputies`. The purge must delete the deputies and
|
||||
// the fichas only a residue deputy referenced, clear the field, and
|
||||
// preserve fichas that a live join still references.
|
||||
const fixtures = createCampaignFixtures(payload)
|
||||
try {
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const orphanDeputy = await fixtures.createStateDeputy()
|
||||
const preservedContact = await fixtures.createContact()
|
||||
const otherMunicipality = await fixtures.getMunicipality()
|
||||
await fixtures.createLeadership({
|
||||
contact: preservedContact,
|
||||
municipalities: [otherMunicipality.id],
|
||||
})
|
||||
const preservedDeputy = await fixtures.createStateDeputy({ contact: preservedContact })
|
||||
await payload.update({
|
||||
collection: 'municipality',
|
||||
id: municipality.id,
|
||||
data: { stateDeputies: [orphanDeputy.id, preservedDeputy.id] },
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
})
|
||||
|
||||
await purgeMunicipalityResidue(payload, municipality.id)
|
||||
|
||||
const deputyExists = async (id: number): Promise<boolean> => {
|
||||
const result = await payload.find({
|
||||
collection: 'stateDeputy',
|
||||
where: { id: { equals: id } },
|
||||
depth: 0,
|
||||
limit: 1,
|
||||
overrideAccess: true,
|
||||
})
|
||||
return result.docs.length === 1
|
||||
}
|
||||
expect(await deputyExists(orphanDeputy.id)).toBe(false)
|
||||
expect(await deputyExists(preservedDeputy.id)).toBe(false)
|
||||
expect(await exists('contact', relationId(orphanDeputy.contact))).toBe(false)
|
||||
expect(await exists('contact', preservedContact.id)).toBe(true)
|
||||
const persistedMunicipality = await payload.findByID({
|
||||
collection: 'municipality',
|
||||
id: municipality.id,
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
})
|
||||
expect(relationIds(persistedMunicipality.stateDeputies ?? [])).toEqual([])
|
||||
} finally {
|
||||
await fixtures.cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
it('purges a shared ficha only after every joiner is gone (supporter + dobradinha)', async () => {
|
||||
// OPS45 — the residue shape that crashed the purge: ONE ficha shared by a
|
||||
// dobradinha (linked to municipality A) and a supporter (on municipality
|
||||
// B), no account in between. The supporter purge must not delete the
|
||||
// ficha while the deputy still references it (`stateDeputy.contact` is
|
||||
// ON DELETE RESTRICT — deleting would throw), and the later claim of A
|
||||
// must finish the job.
|
||||
const fixtures = createCampaignFixtures(payload)
|
||||
try {
|
||||
const deputyMunicipality = await fixtures.getMunicipality()
|
||||
const sharedContact = await fixtures.createContact()
|
||||
const deputy = await fixtures.createStateDeputy({ contact: sharedContact })
|
||||
await payload.update({
|
||||
collection: 'municipality',
|
||||
id: deputyMunicipality.id,
|
||||
data: { stateDeputies: [deputy.id] },
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
})
|
||||
|
||||
const supporterMunicipality = await fixtures.getMunicipality()
|
||||
const supporter = await fixtures.createSupporter({
|
||||
contact: sharedContact,
|
||||
municipality: supporterMunicipality,
|
||||
})
|
||||
|
||||
await purgeMunicipalityResidue(payload, supporterMunicipality.id)
|
||||
expect(await exists('supporter', supporter.id)).toBe(false)
|
||||
expect(await exists('contact', sharedContact.id)).toBe(true)
|
||||
|
||||
await purgeMunicipalityResidue(payload, deputyMunicipality.id)
|
||||
expect(await exists('contact', sharedContact.id)).toBe(false)
|
||||
} finally {
|
||||
await fixtures.cleanup()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,8 +4,14 @@ import type { Payload } from 'payload'
|
|||
import { getPayload } from 'payload'
|
||||
import { beforeAll, describe, expect, it } from 'vitest'
|
||||
|
||||
import type { CampaignUser } from '@/payload-types'
|
||||
import config from '@/payload.config'
|
||||
import { loadPeopleListPageData } from '@/utilities/people/peopleData'
|
||||
import {
|
||||
loadPeopleListPageData,
|
||||
type PeopleListFilterFacets,
|
||||
type PeopleRowViewModel,
|
||||
} from '@/utilities/people/peopleData'
|
||||
import { peoplePageSize, type PeopleListState } from '@/utilities/people/peopleListUrl'
|
||||
|
||||
import { installCampaignFixtures, relationId } from '../helpers/campaignFixtures'
|
||||
|
||||
|
|
@ -17,6 +23,38 @@ const campaignFixtures = installCampaignFixtures({
|
|||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* OPS45 — the people list is GLOBAL and paginated (25 rows/page, sorted by
|
||||
* name): residue from crashed runs and rows of parallel spec files legitimately
|
||||
* occupy the first pages, so a presence assertion over page 1 alone is
|
||||
* state-sensitive. Collect every page until one comes back short — a short
|
||||
* page means the sweep is complete, and the bound self-heals when parallel
|
||||
* files grow the list between fetches. Rows are deduped by contactID (a row
|
||||
* that crosses a page boundary mid-sweep would otherwise appear twice, which
|
||||
* would break count assertions). Facets come from page 1 (they are computed
|
||||
* over the whole scoped set before pagination, so they are already global).
|
||||
*/
|
||||
const loadAllPeopleRows = async (
|
||||
listPayload: Payload,
|
||||
user: CampaignUser,
|
||||
state: PeopleListState,
|
||||
): Promise<{ rows: PeopleRowViewModel[]; filterFacets: PeopleListFilterFacets }> => {
|
||||
const byContact = new Map<number, PeopleRowViewModel>()
|
||||
let filterFacets: PeopleListFilterFacets | undefined
|
||||
for (let page = 1; ; page += 1) {
|
||||
const result = await loadPeopleListPageData(listPayload, user, { ...state, page })
|
||||
filterFacets ??= result.filterFacets
|
||||
for (const row of result.rows) {
|
||||
if (!byContact.has(row.contactID)) byContact.set(row.contactID, row)
|
||||
}
|
||||
if (result.rows.length < peoplePageSize) break
|
||||
}
|
||||
return {
|
||||
rows: [...byContact.values()],
|
||||
filterFacets: filterFacets ?? { municipalityIDs: [], statuses: [], parties: [] },
|
||||
}
|
||||
}
|
||||
|
||||
describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
||||
beforeAll(async () => {
|
||||
payload = await getPayload({ config: await config })
|
||||
|
|
@ -27,47 +65,49 @@ describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
|||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
|
||||
const leadershipContact = await fixtures.createContact({ name: 'Maria de Jesus' })
|
||||
const mariaName = fixtures.personName('Maria de Jesus')
|
||||
const leadershipContact = await fixtures.createContact({ name: mariaName })
|
||||
const leadership = await fixtures.createLeadership({
|
||||
contact: leadershipContact,
|
||||
municipalities: [municipality],
|
||||
})
|
||||
|
||||
const deputyContact = await fixtures.createContact({ name: 'Ana Lima' })
|
||||
const anaName = fixtures.personName('Ana Lima')
|
||||
const deputyContact = await fixtures.createContact({ name: anaName })
|
||||
const deputy = await fixtures.createStateDeputy({ contact: deputyContact, party: 'PCdoB' })
|
||||
|
||||
const advisor = await fixtures.createCampaignUser('advisor')
|
||||
const pureContact = await fixtures.createContact({ name: 'Só Ficha' })
|
||||
const pureContact = await fixtures.createContact({ name: fixtures.personName('Só Ficha') })
|
||||
|
||||
const result = await loadPeopleListPageData(payload, coordinator, { page: 1 })
|
||||
const { rows, filterFacets } = await loadAllPeopleRows(payload, coordinator, { page: 1 })
|
||||
|
||||
const maria = result.rows.find((row) => row.contactID === relationId(leadershipContact))
|
||||
const maria = rows.find((row) => row.contactID === relationId(leadershipContact))
|
||||
expect(maria).toMatchObject({
|
||||
name: 'Maria de Jesus',
|
||||
name: mariaName,
|
||||
leadershipID: leadership.id,
|
||||
supportStatus: 'engajado',
|
||||
})
|
||||
expect(maria?.leadershipMunicipalityIDs).toContain(municipality.id)
|
||||
|
||||
const ana = result.rows.find((row) => row.contactID === relationId(deputyContact))
|
||||
expect(ana).toMatchObject({ name: 'Ana Lima', deputyID: deputy.id, party: 'PCdoB' })
|
||||
const ana = rows.find((row) => row.contactID === relationId(deputyContact))
|
||||
expect(ana).toMatchObject({ name: anaName, deputyID: deputy.id, party: 'PCdoB' })
|
||||
|
||||
// Staff with a ficha enters even with an EMPTY carteira (gate 2026-08-09).
|
||||
const advisorRow = result.rows.find((row) => row.contactID === relationId(advisor.contact))
|
||||
const advisorRow = rows.find((row) => row.contactID === relationId(advisor.contact))
|
||||
expect(advisorRow?.staff.map((account) => account.id)).toContain(advisor.id)
|
||||
expect(advisorRow?.assessoraMunicipalityIDs).toEqual([])
|
||||
|
||||
// A bare Contact with no role never enters.
|
||||
expect(result.rows.some((row) => row.contactID === relationId(pureContact))).toBe(false)
|
||||
expect(result.filterFacets.municipalityIDs).toContain(municipality.id)
|
||||
expect(result.filterFacets.statuses).toContain('engajado')
|
||||
expect(rows.some((row) => row.contactID === relationId(pureContact))).toBe(false)
|
||||
expect(filterFacets.municipalityIDs).toContain(municipality.id)
|
||||
expect(filterFacets.statuses).toContain('engajado')
|
||||
})
|
||||
|
||||
it('merges an account sharing the ficha (phone reuse) into the leadership row', async () => {
|
||||
const fixtures = campaignFixtures()
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const contact = await fixtures.createContact({ name: 'Dupla Função' })
|
||||
const contact = await fixtures.createContact({ name: fixtures.personName('Dupla Função') })
|
||||
const leadership = await fixtures.createLeadership({
|
||||
contact,
|
||||
municipalities: [municipality],
|
||||
|
|
@ -75,12 +115,12 @@ describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
|||
const account = await fixtures.createCampaignUser('advisor', { phone: contact.phone })
|
||||
expect(relationId(account.contact)).toBe(contact.id)
|
||||
|
||||
const result = await loadPeopleListPageData(payload, coordinator, { page: 1 })
|
||||
const rows = result.rows.filter((row) => row.contactID === contact.id)
|
||||
const { rows } = await loadAllPeopleRows(payload, coordinator, { page: 1 })
|
||||
const mergedRows = rows.filter((row) => row.contactID === contact.id)
|
||||
|
||||
expect(rows).toHaveLength(1)
|
||||
expect(rows[0]?.leadershipID).toBe(leadership.id)
|
||||
expect(rows[0]?.staff.some((staff) => staff.id === account.id)).toBe(true)
|
||||
expect(mergedRows).toHaveLength(1)
|
||||
expect(mergedRows[0]?.leadershipID).toBe(leadership.id)
|
||||
expect(mergedRows[0]?.staff.some((staff) => staff.id === account.id)).toBe(true)
|
||||
})
|
||||
|
||||
it('scopes every source to the advisor carteira', async () => {
|
||||
|
|
@ -90,12 +130,18 @@ describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
|||
const stranger = await fixtures.getMunicipality()
|
||||
await fixtures.assignMunicipalityAdvisors(administered, [advisor])
|
||||
|
||||
const ownContact = await fixtures.createContact({ name: 'Própria Liderança' })
|
||||
const ownContact = await fixtures.createContact({
|
||||
name: fixtures.personName('Própria Liderança'),
|
||||
})
|
||||
await fixtures.createLeadership({ contact: ownContact, municipalities: [administered] })
|
||||
const alienContact = await fixtures.createContact({ name: 'Liderança Alheia' })
|
||||
const alienContact = await fixtures.createContact({
|
||||
name: fixtures.personName('Liderança Alheia'),
|
||||
})
|
||||
await fixtures.createLeadership({ contact: alienContact, municipalities: [stranger] })
|
||||
|
||||
const deputyContact = await fixtures.createContact({ name: 'Aliada Local' })
|
||||
const deputyContact = await fixtures.createContact({
|
||||
name: fixtures.personName('Aliada Local'),
|
||||
})
|
||||
const deputy = await fixtures.createStateDeputy({ contact: deputyContact, party: 'PT' })
|
||||
fixtures.touchMunicipality(administered)
|
||||
await payload.update({
|
||||
|
|
@ -109,8 +155,8 @@ describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
|||
const unassigned = await fixtures.createCampaignUser('advisor')
|
||||
await fixtures.assignMunicipalityAdvisors(administered, [advisor, colleague])
|
||||
|
||||
const result = await loadPeopleListPageData(payload, advisor, { page: 1 })
|
||||
const contactIDs = result.rows.map((row) => row.contactID)
|
||||
const { rows } = await loadAllPeopleRows(payload, advisor, { page: 1 })
|
||||
const contactIDs = rows.map((row) => row.contactID)
|
||||
|
||||
expect(contactIDs).toContain(relationId(ownContact))
|
||||
expect(contactIDs).not.toContain(relationId(alienContact))
|
||||
|
|
@ -126,31 +172,36 @@ describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
|||
const fixtures = campaignFixtures()
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const maria = await fixtures.createContact({ name: 'Maria de Jesus' })
|
||||
const mariaName = fixtures.personName('Maria de Jesus')
|
||||
const maria = await fixtures.createContact({ name: mariaName })
|
||||
await fixtures.createLeadership({ contact: maria, municipalities: [municipality] })
|
||||
const joao = await fixtures.createContact({ name: 'João do Brejo' })
|
||||
const joao = await fixtures.createContact({ name: fixtures.personName('João do Brejo') })
|
||||
await fixtures.createLeadership({ contact: joao, municipalities: [municipality] })
|
||||
|
||||
const result = await loadPeopleListPageData(payload, coordinator, { page: 1, q: 'Maria' })
|
||||
const names = result.rows.map((row) => row.name)
|
||||
const { rows } = await loadAllPeopleRows(payload, coordinator, { page: 1, q: 'Maria' })
|
||||
const names = rows.map((row) => row.name)
|
||||
|
||||
expect(names).toContain('Maria de Jesus')
|
||||
expect(names).not.toContain('João do Brejo')
|
||||
expect(names).toContain(mariaName)
|
||||
expect(names).not.toContain(joao.name)
|
||||
})
|
||||
|
||||
it('filters by party and exposes the party facet from the recorte (C130)', async () => {
|
||||
const fixtures = campaignFixtures()
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const deputyContact = await fixtures.createContact({ name: 'Deputada do Partido' })
|
||||
const deputyContact = await fixtures.createContact({
|
||||
name: fixtures.personName('Deputada do Partido'),
|
||||
})
|
||||
await fixtures.createStateDeputy({ contact: deputyContact, party: 'PSOL' })
|
||||
const noDeputyContact = await fixtures.createContact({ name: 'Sem Dobradinha' })
|
||||
const noDeputyContact = await fixtures.createContact({
|
||||
name: fixtures.personName('Sem Dobradinha'),
|
||||
})
|
||||
await fixtures.createLeadership({ contact: noDeputyContact, municipalities: [municipality] })
|
||||
|
||||
const all = await loadPeopleListPageData(payload, coordinator, { page: 1 })
|
||||
const all = await loadAllPeopleRows(payload, coordinator, { page: 1 })
|
||||
expect(all.filterFacets.parties).toContain('PSOL')
|
||||
|
||||
const filtered = await loadPeopleListPageData(payload, coordinator, {
|
||||
const filtered = await loadAllPeopleRows(payload, coordinator, {
|
||||
page: 1,
|
||||
parties: ['PSOL'],
|
||||
})
|
||||
|
|
@ -162,7 +213,7 @@ describe('C100 — lista unificada de pessoas (merge por Contact)', () => {
|
|||
const fixtures = campaignFixtures()
|
||||
const leader = await fixtures.createCampaignUser('leader')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const contact = await fixtures.createContact({ name: 'Alguém' })
|
||||
const contact = await fixtures.createContact({ name: fixtures.personName('Alguém') })
|
||||
await fixtures.createLeadership({ contact, municipalities: [municipality] })
|
||||
|
||||
const result = await loadPeopleListPageData(payload, leader, { page: 1 })
|
||||
|
|
|
|||
|
|
@ -52,7 +52,11 @@ describe('C100 — apagar pessoa (manifest + cascata)', () => {
|
|||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
|
||||
const contact = await fixtures.createContact({ name: 'Maria de Jesus' })
|
||||
// OPS45 — the dobradinha name is a GLOBAL invariant
|
||||
// (`assertStateDeputyNameAvailable`): a fixed name would collide with any
|
||||
// residue row a crashed run left behind, so it must be unique per run.
|
||||
const contactName = fixtures.personName('Maria de Jesus')
|
||||
const contact = await fixtures.createContact({ name: contactName })
|
||||
const leadership = await fixtures.createLeadership({ contact, municipalities: [municipality] })
|
||||
await fixtures.createVotePledge({ leadership, municipality })
|
||||
const advisor = await fixtures.createCampaignUser('advisor', { phone: contact.phone })
|
||||
|
|
@ -63,7 +67,7 @@ describe('C100 — apagar pessoa (manifest + cascata)', () => {
|
|||
const manifest = await loadPersonDeleteManifest(payload, contact.id)
|
||||
|
||||
expect(manifest).not.toBeNull()
|
||||
expect(manifest?.contact.name).toBe('Maria de Jesus')
|
||||
expect(manifest?.contact.name).toBe(contactName)
|
||||
expect(manifest?.leaderships).toHaveLength(1)
|
||||
expect(manifest?.leaderships[0]?.municipalityNames).toContain(municipality.name)
|
||||
expect(manifest?.stateDeputies).toHaveLength(1)
|
||||
|
|
@ -80,7 +84,7 @@ describe('C100 — apagar pessoa (manifest + cascata)', () => {
|
|||
const fixtures = campaignFixtures()
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const contact = await fixtures.createContact({ name: 'João do Brejo' })
|
||||
const contact = await fixtures.createContact({ name: fixtures.personName('João do Brejo') })
|
||||
const leadership = await fixtures.createLeadership({ contact, municipalities: [municipality] })
|
||||
await fixtures.createVotePledge({ leadership, municipality })
|
||||
await fixtures.createStateDeputy({ contact, party: 'PCdoB' })
|
||||
|
|
@ -106,7 +110,7 @@ describe('C100 — apagar pessoa (manifest + cascata)', () => {
|
|||
const fixtures = campaignFixtures()
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const contact = await fixtures.createContact({ name: 'Ana Lima' })
|
||||
const contact = await fixtures.createContact({ name: fixtures.personName('Ana Lima') })
|
||||
await fixtures.createLeadership({ contact, municipalities: [municipality] })
|
||||
const consent = await fixtures.createConsent()
|
||||
const subscription = await payload.create({
|
||||
|
|
@ -148,7 +152,7 @@ describe('C100 — apagar pessoa (manifest + cascata)', () => {
|
|||
const fixtures = campaignFixtures()
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const contact = await fixtures.createContact({ name: 'Protegida' })
|
||||
const contact = await fixtures.createContact({ name: fixtures.personName('Protegida') })
|
||||
await fixtures.createLeadership({ contact, municipalities: [municipality] })
|
||||
await fixtures.createCampaignUser('coordinator', { phone: contact.phone })
|
||||
|
||||
|
|
@ -165,7 +169,7 @@ describe('C100 — apagar pessoa (manifest + cascata)', () => {
|
|||
const fixtures = campaignFixtures()
|
||||
const advisor = await fixtures.createCampaignUser('advisor')
|
||||
const municipality = await fixtures.getMunicipality()
|
||||
const contact = await fixtures.createContact({ name: 'Alguém' })
|
||||
const contact = await fixtures.createContact({ name: fixtures.personName('Alguém') })
|
||||
await fixtures.createLeadership({ contact, municipalities: [municipality] })
|
||||
|
||||
await expect(deletePersonRecord(payload, advisor, contact.id)).rejects.toThrow(
|
||||
|
|
|
|||
|
|
@ -25,10 +25,11 @@ describe('buildPoolWorkerPrompt', () => {
|
|||
expect(prompt).toContain('plano de intenção como contrato de engenharia')
|
||||
})
|
||||
|
||||
it('pins the PR contract: base main, Closes #N, auto-merge, CI watch', () => {
|
||||
it('pins the PR contract: base main, Closes #N, changelog entry, rebase auto-merge, CI watch', () => {
|
||||
expect(prompt).toContain('gh pr create --base main')
|
||||
expect(prompt).toContain('Closes #42')
|
||||
expect(prompt).toContain('gh pr merge --auto --merge')
|
||||
expect(prompt).toContain('changelog:build')
|
||||
expect(prompt).toContain('gh pr merge --auto --rebase')
|
||||
expect(prompt).toContain('gh pr checks <PR> --watch')
|
||||
})
|
||||
|
||||
|
|
|
|||
162
tests/unit/campaignCarousel.unit.spec.tsx
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { CampaignCarousel, type CampaignCarouselItem } from '@/components/CampaignCarousel'
|
||||
|
||||
const flagItems: CampaignCarouselItem[] = [
|
||||
{
|
||||
id: 'saude',
|
||||
label: 'Saúde',
|
||||
title: 'Defender o SUS e valorizar quem cuida',
|
||||
body: 'Saúde é direito, não mercadoria.',
|
||||
},
|
||||
{
|
||||
id: 'educacao',
|
||||
label: 'Educação',
|
||||
title: 'Educação em tempo integral',
|
||||
body: 'O interior não pode ficar para trás.',
|
||||
},
|
||||
]
|
||||
|
||||
const problemItems: CampaignCarouselItem[] = [
|
||||
{
|
||||
id: 'trabalho',
|
||||
title: 'Pelo fim da escala 6x1!',
|
||||
body: 'Descanso é saúde pública.',
|
||||
image: '/fundo.avif',
|
||||
imageAlt: 'Jorge Solla durante atividade parlamentar',
|
||||
},
|
||||
{
|
||||
id: 'sus',
|
||||
title: 'Pra valorizar o SUS',
|
||||
body: 'O SUS é o sistema de saúde de todo brasileiro.',
|
||||
image: '/53569851134_02afc18fb4_o.avif',
|
||||
imageAlt: 'Jorge Solla em agenda de defesa do SUS',
|
||||
},
|
||||
]
|
||||
|
||||
const matchMediaMock = vi.fn()
|
||||
const scrollToMock = vi.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
matchMediaMock.mockImplementation((query: string) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
}))
|
||||
vi.stubGlobal('matchMedia', matchMediaMock)
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollTo', {
|
||||
configurable: true,
|
||||
value: scrollToMock,
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
vi.clearAllMocks()
|
||||
vi.useRealTimers()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
describe('CampaignCarousel', () => {
|
||||
it('sincroniza o chip ativo quando a pessoa escolhe uma bandeira', () => {
|
||||
render(<CampaignCarousel ariaLabel="Bandeiras da campanha" items={flagItems} variant="flags" />)
|
||||
|
||||
const healthChip = screen.getByRole('button', { name: 'Saúde' })
|
||||
const educationChip = screen.getByRole('button', { name: 'Educação' })
|
||||
expect(healthChip.getAttribute('aria-current')).toBe('true')
|
||||
|
||||
fireEvent.click(educationChip)
|
||||
fireEvent.scroll(screen.getByRole('list'))
|
||||
|
||||
expect(healthChip.getAttribute('aria-current')).toBeNull()
|
||||
expect(educationChip.getAttribute('aria-current')).toBe('true')
|
||||
expect(scrollToMock).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('avança automaticamente para o próximo card depois de quatro segundos', () => {
|
||||
vi.useFakeTimers()
|
||||
render(
|
||||
<CampaignCarousel
|
||||
ariaLabel="Por que essa eleição importa"
|
||||
items={problemItems}
|
||||
variant="problem"
|
||||
/>,
|
||||
)
|
||||
|
||||
const secondCard = screen.getByRole('listitem', { name: '2 de 2' })
|
||||
expect(secondCard.getAttribute('aria-current')).toBeNull()
|
||||
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(4_000)
|
||||
})
|
||||
|
||||
expect(secondCard.getAttribute('aria-current')).toBe('true')
|
||||
expect(scrollToMock).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('pausa o avanço enquanto o ponteiro está sobre o carrossel', () => {
|
||||
vi.useFakeTimers()
|
||||
render(
|
||||
<CampaignCarousel
|
||||
ariaLabel="Por que essa eleição importa"
|
||||
items={problemItems}
|
||||
variant="problem"
|
||||
/>,
|
||||
)
|
||||
|
||||
const carousel = screen.getByRole('region', { name: 'Por que essa eleição importa' })
|
||||
fireEvent.mouseEnter(carousel)
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(8_000)
|
||||
})
|
||||
|
||||
expect(screen.getByRole('listitem', { name: '1 de 2' }).getAttribute('aria-current')).toBe(
|
||||
'true',
|
||||
)
|
||||
expect(scrollToMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('pausa o avanço quando o próprio carrossel recebe foco', () => {
|
||||
vi.useFakeTimers()
|
||||
render(
|
||||
<CampaignCarousel
|
||||
ariaLabel="Por que essa eleição importa"
|
||||
items={problemItems}
|
||||
variant="problem"
|
||||
/>,
|
||||
)
|
||||
|
||||
const carousel = screen.getByRole('region', { name: 'Por que essa eleição importa' })
|
||||
fireEvent.focus(carousel)
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(8_000)
|
||||
})
|
||||
|
||||
expect(scrollToMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('não inicia o avanço automático quando a pessoa prefere movimento reduzido', () => {
|
||||
vi.useFakeTimers()
|
||||
matchMediaMock.mockImplementation((query: string) => ({
|
||||
matches: query.includes('prefers-reduced-motion'),
|
||||
media: query,
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
}))
|
||||
|
||||
render(
|
||||
<CampaignCarousel
|
||||
ariaLabel="Por que essa eleição importa"
|
||||
items={problemItems}
|
||||
variant="problem"
|
||||
/>,
|
||||
)
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(8_000)
|
||||
})
|
||||
|
||||
expect(scrollToMock).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
42
tests/unit/campaignHero.unit.spec.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { CampaignHero } from '@/components/CampaignHero'
|
||||
|
||||
type MockImageProps = React.ImgHTMLAttributes<HTMLImageElement> & { priority?: boolean }
|
||||
|
||||
vi.mock('next/image', () => ({
|
||||
default: ({ alt, priority: _priority, ...props }: MockImageProps) => (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img alt={alt} {...props} />
|
||||
),
|
||||
}))
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
describe('CampaignHero', () => {
|
||||
it('apresenta a candidatura e mantém um único CTA primário', () => {
|
||||
render(<CampaignHero />)
|
||||
|
||||
expect(
|
||||
screen.getByRole('heading', { level: 1, name: 'UM MANDATO DO TAMANHO DA BAHIA' }),
|
||||
).toBeTruthy()
|
||||
|
||||
const supportLink = screen.getByRole('link', { name: /Quero apoiar/i })
|
||||
expect(supportLink.getAttribute('href')).toBe('https://apoiar.me/jorgesolla')
|
||||
expect(supportLink.getAttribute('data-cta')).toBe('primary')
|
||||
|
||||
const flagsLink = screen.getByRole('link', { name: /Conhecer bandeiras/i })
|
||||
expect(flagsLink.getAttribute('href')).toBe('#bandeiras')
|
||||
expect(flagsLink.getAttribute('data-cta')).toBe('secondary')
|
||||
})
|
||||
|
||||
it('expõe as provas e as fotos com nomes acessíveis', () => {
|
||||
render(<CampaignHero />)
|
||||
|
||||
expect(screen.getByLabelText('DIAP entre os 40 melhores da Câmara')).toBeTruthy()
|
||||
expect(screen.getByLabelText('Mais votado do PT-BA em 2022')).toBeTruthy()
|
||||
expect(screen.getByRole('img', { name: /Jorge Solla 1313/i })).toBeTruthy()
|
||||
expect(screen.getByAltText('Jorge Solla, candidato a deputado federal pela Bahia')).toBeTruthy()
|
||||
})
|
||||
})
|
||||
49
tests/unit/campaignHome.unit.spec.tsx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import HomePage from '@/app/(frontend)/(home)/page'
|
||||
|
||||
type MockImageProps = React.ImgHTMLAttributes<HTMLImageElement> & {
|
||||
fill?: boolean
|
||||
priority?: boolean
|
||||
}
|
||||
|
||||
vi.mock('next/image', () => ({
|
||||
default: ({ alt, fill: _fill, priority: _priority, ...props }: MockImageProps) => (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img alt={alt} {...props} />
|
||||
),
|
||||
}))
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
describe('Campaign home', () => {
|
||||
it('monta as quatro seções previstas e o rodapé eleitoral', async () => {
|
||||
render(await HomePage())
|
||||
|
||||
expect(
|
||||
screen.getByRole('heading', { level: 1, name: 'UM MANDATO DO TAMANHO DA BAHIA' }),
|
||||
).toBeTruthy()
|
||||
expect(screen.getByText('3.333')).toBeTruthy()
|
||||
expect(screen.getByText('1.031')).toBeTruthy()
|
||||
expect(screen.getByText('3º')).toBeTruthy()
|
||||
expect(screen.getByRole('heading', { name: /Eleger deputado é coisa séria/i })).toBeTruthy()
|
||||
expect(
|
||||
screen.getByRole('heading', {
|
||||
name: /Junto com o trabalhador e do lado de quem mais precisa, sempre/i,
|
||||
}),
|
||||
).toBeTruthy()
|
||||
expect(screen.getByText(/CNPJ: 68\.430\.467\/0001-05/)).toBeTruthy()
|
||||
})
|
||||
|
||||
it('usa exatamente as seis bandeiras aprovadas', async () => {
|
||||
render(await HomePage())
|
||||
|
||||
expect(screen.getByText('Defender o SUS e valorizar quem cuida')).toBeTruthy()
|
||||
expect(screen.getByText('Fim da escala 6×1 e jornada de 40h')).toBeTruthy()
|
||||
expect(screen.getByText('Educação em tempo integral e federais no interior')).toBeTruthy()
|
||||
expect(screen.getByText('Recomprar a Refinaria de Mataripe')).toBeTruthy()
|
||||
expect(screen.getByText('Salário mínimo forte, emprego e moradia')).toBeTruthy()
|
||||
expect(screen.getByText('Defesa intransigente da democracia')).toBeTruthy()
|
||||
})
|
||||
})
|
||||
289
tests/unit/changelog.unit.spec.ts
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
assertChangelogAppendOnly,
|
||||
buildChangelog,
|
||||
CHANGELOG_REWRITE_ESCAPE_RE,
|
||||
entryDateOf,
|
||||
listChangelogEntries,
|
||||
missingLines,
|
||||
parseChangelogEntryName,
|
||||
splitChangelogBody,
|
||||
} from '../../scripts/lib/changelog.mjs'
|
||||
|
||||
const HEADER = `# Changelog de contexto para agentes (fatias do AGENTS.md)
|
||||
|
||||
Conteúdo movido do \`AGENTS.md\` em 2026-07-30.
|
||||
|
||||
---`
|
||||
|
||||
const ENTRY_2026_08_13 = `**Recently resolved (2026-08-13):** **OPS44** — teste. Intenção [x](plans/x.md); impl [x-impl](plans/x-impl.md).`
|
||||
const ENTRY_2026_08_12 = `**Recently resolved (2026-08-12):** **B200** — teste.`
|
||||
|
||||
describe('parseChangelogEntryName', () => {
|
||||
it('parses the canonical date-id filename', () => {
|
||||
expect(parseChangelogEntryName('2026-08-13-ops44.md')).toEqual({
|
||||
date: '2026-08-13',
|
||||
id: 'ops44',
|
||||
})
|
||||
})
|
||||
|
||||
it('accepts alphanumeric ids with dashes', () => {
|
||||
expect(parseChangelogEntryName('2026-08-12-c123-teste.md')).toEqual({
|
||||
date: '2026-08-12',
|
||||
id: 'c123-teste',
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects malformed names', () => {
|
||||
expect(parseChangelogEntryName('ops44.md')).toBeNull()
|
||||
expect(parseChangelogEntryName('2026-13-01-ops44.md')).toBeNull()
|
||||
expect(parseChangelogEntryName('2026-08-13.md')).toBeNull()
|
||||
expect(parseChangelogEntryName('2026-08-13-OPS44.md')).toBeNull()
|
||||
expect(parseChangelogEntryName('README.md')).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects impossible calendar dates', () => {
|
||||
expect(parseChangelogEntryName('2026-02-31-ops44.md')).toBeNull()
|
||||
expect(parseChangelogEntryName('2026-04-31-ops44.md')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('listChangelogEntries', () => {
|
||||
it('sorts by date desc then id asc', () => {
|
||||
const { entries, errors } = listChangelogEntries([
|
||||
'docs/changelog/2026-08-10-b197.md',
|
||||
'docs/changelog/2026-08-13-ops44.md',
|
||||
'docs/changelog/2026-08-12-a.md',
|
||||
'docs/changelog/2026-08-12-b.md',
|
||||
])
|
||||
expect(errors).toEqual([])
|
||||
expect(entries.map((entry) => entry.name)).toEqual([
|
||||
'2026-08-13-ops44.md',
|
||||
'2026-08-12-a.md',
|
||||
'2026-08-12-b.md',
|
||||
'2026-08-10-b197.md',
|
||||
])
|
||||
})
|
||||
|
||||
it('fails closed on a .md that does not match the pattern', () => {
|
||||
const { entries, errors } = listChangelogEntries([
|
||||
'docs/changelog/2026-08-13-ops44.md',
|
||||
'docs/changelog/not-an-entry.md',
|
||||
])
|
||||
expect(entries).toHaveLength(1)
|
||||
expect(errors).toEqual([
|
||||
'docs/changelog/not-an-entry.md — não casa o padrão <YYYY-MM-DD>-<id>.md',
|
||||
])
|
||||
})
|
||||
|
||||
it('ignores non-md files (e.g. stray assets)', () => {
|
||||
const { entries, errors } = listChangelogEntries([
|
||||
'docs/changelog/2026-08-13-ops44.md',
|
||||
'docs/changelog/foo.txt',
|
||||
])
|
||||
expect(errors).toEqual([])
|
||||
expect(entries).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('splitChangelogBody', () => {
|
||||
const aggregate = `${HEADER}\n\n${ENTRY_2026_08_13}\n\n${ENTRY_2026_08_12}\n`
|
||||
|
||||
it('splits the static header from the entry blocks', () => {
|
||||
expect(splitChangelogBody(aggregate)).toEqual({
|
||||
header: HEADER,
|
||||
blocks: [ENTRY_2026_08_13, ENTRY_2026_08_12],
|
||||
})
|
||||
})
|
||||
|
||||
it('trims trailing whitespace from blocks', () => {
|
||||
const { blocks } = splitChangelogBody(`${HEADER}\n\n${ENTRY_2026_08_13} \n`)
|
||||
expect(blocks).toEqual([ENTRY_2026_08_13])
|
||||
})
|
||||
|
||||
it('throws when the separator is missing', () => {
|
||||
expect(() => splitChangelogBody('sem separador')).toThrow('sem separador')
|
||||
})
|
||||
})
|
||||
|
||||
describe('entryDateOf', () => {
|
||||
it('extracts the date from a Recently resolved header', () => {
|
||||
expect(entryDateOf(ENTRY_2026_08_13)).toBe('2026-08-13')
|
||||
})
|
||||
|
||||
it('returns null for a block without the header', () => {
|
||||
expect(entryDateOf('bloco sem header')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildChangelog', () => {
|
||||
const aggregate = `${HEADER}\n\n${ENTRY_2026_08_12}\n`
|
||||
|
||||
it('inserts a newer entry before an existing older block', () => {
|
||||
const content = buildChangelog({
|
||||
entries: [{ content: ENTRY_2026_08_13 }],
|
||||
aggregateContent: aggregate,
|
||||
})
|
||||
expect(content).toBe(`${HEADER}\n\n${ENTRY_2026_08_13}\n\n${ENTRY_2026_08_12}\n`)
|
||||
})
|
||||
|
||||
it('inserts an older entry after a newer existing block', () => {
|
||||
const content = buildChangelog({
|
||||
entries: [{ content: ENTRY_2026_08_12 }],
|
||||
aggregateContent: `${HEADER}\n\n${ENTRY_2026_08_13}\n`,
|
||||
})
|
||||
expect(content).toBe(`${HEADER}\n\n${ENTRY_2026_08_13}\n\n${ENTRY_2026_08_12}\n`)
|
||||
})
|
||||
|
||||
it('is idempotent — a present entry is skipped', () => {
|
||||
const first = buildChangelog({
|
||||
entries: [{ content: ENTRY_2026_08_13 }],
|
||||
aggregateContent: aggregate,
|
||||
})
|
||||
const second = buildChangelog({
|
||||
entries: [{ content: ENTRY_2026_08_13 }],
|
||||
aggregateContent: first,
|
||||
})
|
||||
expect(second).toBe(first)
|
||||
})
|
||||
|
||||
it('skips only on exact equality — a longer entry is not hidden by a prefix', () => {
|
||||
const content = buildChangelog({
|
||||
entries: [{ content: `${ENTRY_2026_08_12} detalhes extras.` }, { content: ENTRY_2026_08_13 }],
|
||||
aggregateContent: aggregate,
|
||||
})
|
||||
expect(content).toBe(
|
||||
`${HEADER}\n\n${ENTRY_2026_08_13}\n\n${ENTRY_2026_08_12}\n\n${ENTRY_2026_08_12} detalhes extras.\n`,
|
||||
)
|
||||
})
|
||||
|
||||
it('is idempotent for entries with trailing blank lines (trimmed both sides)', () => {
|
||||
const first = buildChangelog({
|
||||
entries: [{ content: `${ENTRY_2026_08_13}\n \n\n` }],
|
||||
aggregateContent: aggregate,
|
||||
})
|
||||
const second = buildChangelog({
|
||||
entries: [{ content: ENTRY_2026_08_13 }],
|
||||
aggregateContent: first,
|
||||
})
|
||||
expect(second).toBe(first)
|
||||
})
|
||||
|
||||
it('inserts an entry without a date header at the top', () => {
|
||||
const content = buildChangelog({
|
||||
entries: [{ content: 'bloco sem data' }],
|
||||
aggregateContent: aggregate,
|
||||
})
|
||||
expect(content).toBe(`${HEADER}\n\nbloco sem data\n\n${ENTRY_2026_08_12}\n`)
|
||||
})
|
||||
|
||||
it('trims trailing newlines from entry contents', () => {
|
||||
const content = buildChangelog({
|
||||
entries: [{ content: `${ENTRY_2026_08_13}\n\n` }],
|
||||
aggregateContent: aggregate,
|
||||
})
|
||||
expect(content).toBe(`${HEADER}\n\n${ENTRY_2026_08_13}\n\n${ENTRY_2026_08_12}\n`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('missingLines', () => {
|
||||
it('returns [] for a pure addition', () => {
|
||||
expect(missingLines('a\nb\n', 'x\na\nb\n')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags a removed line', () => {
|
||||
expect(missingLines('a\nb\n', 'a\n')).toEqual(['b'])
|
||||
})
|
||||
|
||||
it('treats a moved line as present (multiset, not position)', () => {
|
||||
expect(missingLines('a\nb\nc\n', 'c\na\nb\n')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags a line whose count decreases (duplicate lost)', () => {
|
||||
expect(missingLines('a\na\n', 'a\n')).toEqual(['a'])
|
||||
})
|
||||
|
||||
it('returns distinct missing lines', () => {
|
||||
expect(missingLines('a\nb\nb\n', 'a\n')).toEqual(['b'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('CHANGELOG_REWRITE_ESCAPE_RE', () => {
|
||||
it('matches a standalone changelog-rewrite line in a PR body', () => {
|
||||
expect(
|
||||
CHANGELOG_REWRITE_ESCAPE_RE.test('## Notas\n\nchangelog-rewrite: header do agregado mudou'),
|
||||
).toBe(true)
|
||||
expect(CHANGELOG_REWRITE_ESCAPE_RE.test('changelog-rewrite:restauração D8')).toBe(true)
|
||||
})
|
||||
|
||||
it('never matches the PR template checkbox text (which cites the token)', () => {
|
||||
expect(
|
||||
CHANGELOG_REWRITE_ESCAPE_RE.test(
|
||||
'- [ ] Se o changelog perdeu linhas de propósito: `changelog-rewrite: <motivo>` no body',
|
||||
),
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('assertChangelogAppendOnly', () => {
|
||||
it('passes on a pure addition with no changelog file touched', () => {
|
||||
expect(
|
||||
assertChangelogAppendOnly({
|
||||
oldAggregate: 'a\nb\n',
|
||||
newAggregate: 'a\nb\nc\n',
|
||||
changelogDiff: [{ status: 'A', path: 'docs/changelog/2026-08-13-ops44.md' }],
|
||||
}),
|
||||
).toEqual({ ok: true })
|
||||
})
|
||||
|
||||
it('fails when an aggregate line disappears', () => {
|
||||
const result = assertChangelogAppendOnly({
|
||||
oldAggregate: 'a\nb\n',
|
||||
newAggregate: 'a\n',
|
||||
changelogDiff: [],
|
||||
})
|
||||
expect(result.ok).toBe(false)
|
||||
if (!result.ok) {
|
||||
expect(result.message).toContain('não é append-only')
|
||||
expect(result.message).toContain('changelog-rewrite')
|
||||
}
|
||||
})
|
||||
|
||||
it('passes on an addition inside docs/changelog/', () => {
|
||||
expect(
|
||||
assertChangelogAppendOnly({
|
||||
oldAggregate: 'a\n',
|
||||
newAggregate: 'a\nb\n',
|
||||
changelogDiff: [{ status: 'A', path: 'docs/changelog/2026-08-13-ops44.md' }],
|
||||
}),
|
||||
).toEqual({ ok: true })
|
||||
})
|
||||
|
||||
it('fails when a docs/changelog file is modified', () => {
|
||||
const result = assertChangelogAppendOnly({
|
||||
oldAggregate: 'a\n',
|
||||
newAggregate: 'a\nb\n',
|
||||
changelogDiff: [{ status: 'M', path: 'docs/changelog/2026-08-13-ops44.md' }],
|
||||
})
|
||||
expect(result.ok).toBe(false)
|
||||
if (!result.ok) {
|
||||
expect(result.message).toContain('additions-only')
|
||||
expect(result.message).toContain('M docs/changelog/2026-08-13-ops44.md')
|
||||
}
|
||||
})
|
||||
|
||||
it('fails when a docs/changelog file is deleted', () => {
|
||||
const result = assertChangelogAppendOnly({
|
||||
oldAggregate: 'a\n',
|
||||
newAggregate: 'a\n',
|
||||
changelogDiff: [{ status: 'D', path: 'docs/changelog/2026-08-12-b200.md' }],
|
||||
})
|
||||
expect(result.ok).toBe(false)
|
||||
if (!result.ok) {
|
||||
expect(result.message).toContain('D docs/changelog/2026-08-12-b200.md')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -75,6 +75,22 @@ describe('ciSkipInvariants', () => {
|
|||
expect(CANONICAL_E2E_SPEC_SUFFIX).toBe('.e2e.spec.ts')
|
||||
})
|
||||
|
||||
it('keeps local e2e build artifacts outside the development dist directory', () => {
|
||||
for (const file of [
|
||||
'.gitignore',
|
||||
'.prettierignore',
|
||||
'eslint.config.mjs',
|
||||
'playwright.config.ts',
|
||||
'scripts/gate-ci.mjs',
|
||||
'scripts/run-e2e-affected.mjs',
|
||||
'tsconfig.json',
|
||||
]) {
|
||||
const source = readFileSync(join(repoRoot, file), 'utf8')
|
||||
expect(source, file).not.toContain('.next/e2e')
|
||||
expect(source, file).toContain('.next-e2e')
|
||||
}
|
||||
})
|
||||
|
||||
it('skip classifiers and invariant specs are high-risk (force full suite)', () => {
|
||||
for (const path of [
|
||||
'scripts/lib/test-affected-core.mjs',
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import {
|
|||
legacyFrameworkExportIgnores,
|
||||
} from '../../eslint-legacy-ignores.mjs'
|
||||
|
||||
import { CONFLICT_MARKER_RE } from '../../scripts/lib/conflictMarkers.mjs'
|
||||
|
||||
// Programmatic guards for conventions that used to be enforced only by prose
|
||||
// (codebase-map.mdc / docs/ARCHITECTURE.md) and drifted during Pass 2.
|
||||
|
||||
|
|
@ -755,9 +757,11 @@ describe('no conflict markers in committed files', () => {
|
|||
// `=======` was deleted in the same bad resolution), and OPS37 inherited
|
||||
// the state. The scan reads tracked paths from the index and greps the
|
||||
// working tree, so a bad resolution fails here before it is ever pushed.
|
||||
// The `(?:> ){7}` form is the exact corrupted closer that shipped; a
|
||||
// genuine 7-deep nested blockquote would need a deliberate allowlist.
|
||||
const conflictMarker = /^\s*<<<<<<<(?:\s|$)|^\s*>>>>>>>(?:\s|$)|^\s*(?:> ){7}/m
|
||||
// The regex lives in scripts/lib/conflictMarkers.mjs (OPS44 extraction) —
|
||||
// the CI docs guard shares it. The `(?:> ){7}` form is the exact corrupted
|
||||
// closer that shipped; a genuine 7-deep nested blockquote would need a
|
||||
// deliberate allowlist.
|
||||
const conflictMarker = CONFLICT_MARKER_RE
|
||||
|
||||
it('keeps conflict markers out of tracked files', () => {
|
||||
const offenders: string[] = []
|
||||
|
|
|
|||
67
tests/unit/conflictMarkers.unit.spec.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
CONFLICT_MARKER_RE,
|
||||
findConflictMarkerLines,
|
||||
markdownPathsOf,
|
||||
} from '../../scripts/lib/conflictMarkers.mjs'
|
||||
|
||||
describe('conflictMarkers (shared with the OPS41 unit scan)', () => {
|
||||
it('matches plain and indented open markers', () => {
|
||||
expect(CONFLICT_MARKER_RE.test('<<<<<<< HEAD')).toBe(true)
|
||||
expect(CONFLICT_MARKER_RE.test(' <<<<<<< HEAD')).toBe(true)
|
||||
expect(CONFLICT_MARKER_RE.test('\t<<<<<<< branch')).toBe(true)
|
||||
})
|
||||
|
||||
it('matches plain and indented close markers', () => {
|
||||
expect(CONFLICT_MARKER_RE.test('>>>>>>> branch')).toBe(true)
|
||||
expect(CONFLICT_MARKER_RE.test(' >>>>>>> branch')).toBe(true)
|
||||
})
|
||||
|
||||
it('matches the corrupted closer form that shipped in OPS33', () => {
|
||||
expect(CONFLICT_MARKER_RE.test('> > > > > > > 9e18bec8')).toBe(true)
|
||||
expect(CONFLICT_MARKER_RE.test(' > > > > > > > 9e18bec8')).toBe(true)
|
||||
})
|
||||
|
||||
it('does not match ordinary markdown lines', () => {
|
||||
expect(CONFLICT_MARKER_RE.test('- item de lista')).toBe(false)
|
||||
expect(CONFLICT_MARKER_RE.test('> citação simples')).toBe(false)
|
||||
expect(CONFLICT_MARKER_RE.test('=======')).toBe(false)
|
||||
})
|
||||
|
||||
it('reports 1-based offending lines', () => {
|
||||
const offenders = findConflictMarkerLines('linha boa\n<<<<<<< HEAD\nlinha boa')
|
||||
expect(offenders).toEqual([{ line: 2, text: '<<<<<<< HEAD' }])
|
||||
})
|
||||
|
||||
it('reports every offender in a file', () => {
|
||||
const offenders = findConflictMarkerLines('<<<<<<< A\n>>>>>>> B\n')
|
||||
expect(offenders.map((offender) => offender.line)).toEqual([1, 2])
|
||||
})
|
||||
|
||||
it('returns [] for clean content', () => {
|
||||
expect(findConflictMarkerLines('markdown limpo\n')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('markdownPathsOf', () => {
|
||||
it('filters to markdown/mdc paths anywhere (incl. repo root — OPS41 file)', () => {
|
||||
expect(
|
||||
markdownPathsOf([
|
||||
'docs/CHANGELOG-AGENTS.md',
|
||||
'src/lib/foo.ts',
|
||||
'docs/changelog/2026-08-13-ops44.md',
|
||||
'AGENTS.md',
|
||||
'.agents/rules/agent-pr-workflow.mdc',
|
||||
'package.json',
|
||||
]),
|
||||
).toEqual([
|
||||
'docs/CHANGELOG-AGENTS.md',
|
||||
'docs/changelog/2026-08-13-ops44.md',
|
||||
'AGENTS.md',
|
||||
'.agents/rules/agent-pr-workflow.mdc',
|
||||
])
|
||||
})
|
||||
})
|
||||
132
tests/unit/imageFill.unit.spec.ts
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
EXTEND_DEFAULT_PROMPT,
|
||||
MASK_DEFAULT_PROMPT,
|
||||
extendedCanvas,
|
||||
padToMultipleOf64,
|
||||
parseExtendPx,
|
||||
parseFillArgs,
|
||||
} from '../../scripts/lib/imageFill.mjs'
|
||||
|
||||
describe('parseExtendPx', () => {
|
||||
it('plain integers are pixels', () => {
|
||||
expect(parseExtendPx('400')).toBe(400)
|
||||
expect(parseExtendPx(' 600 ')).toBe(600)
|
||||
})
|
||||
|
||||
it('percentages are accepted (resolved against the photo height later)', () => {
|
||||
expect(parseExtendPx('30%')).toBe(30)
|
||||
expect(parseExtendPx('100%')).toBe(100)
|
||||
})
|
||||
|
||||
it('fails closed on anything else', () => {
|
||||
for (const bad of ['', 'abc', '-400', '0', '30.5', '30.5%', '400px']) {
|
||||
expect(parseExtendPx(bad)).toBeNull()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('extendedCanvas', () => {
|
||||
it('grows only downward, photo keeps its top position', () => {
|
||||
const canvas = extendedCanvas(1000, 1500, 500)
|
||||
expect(canvas).toEqual({ width: 1000, height: 2000, offsetY: 1500 })
|
||||
})
|
||||
})
|
||||
|
||||
describe('padToMultipleOf64', () => {
|
||||
it('rounds up to the next multiple of 64 on each axis', () => {
|
||||
expect(padToMultipleOf64(600, 1260)).toEqual({
|
||||
width: 640,
|
||||
height: 1280,
|
||||
padRight: 40,
|
||||
padBottom: 20,
|
||||
})
|
||||
expect(padToMultipleOf64(2000, 1200)).toEqual({
|
||||
width: 2048,
|
||||
height: 1216,
|
||||
padRight: 48,
|
||||
padBottom: 16,
|
||||
})
|
||||
})
|
||||
|
||||
it('is a no-op for exact multiples', () => {
|
||||
expect(padToMultipleOf64(1024, 1536)).toEqual({
|
||||
width: 1024,
|
||||
height: 1536,
|
||||
padRight: 0,
|
||||
padBottom: 0,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseFillArgs', () => {
|
||||
it('--extend flow defaults: prompt de extensão, resize on, out public, 28 passos', () => {
|
||||
const options = parseFillArgs(['--photo', 'lula.jpg', '--extend', '40%'])
|
||||
expect(options).toEqual({
|
||||
help: false,
|
||||
photo: 'lula.jpg',
|
||||
mask: null,
|
||||
extend: '40%',
|
||||
prompt: EXTEND_DEFAULT_PROMPT,
|
||||
steps: 28,
|
||||
outDir: 'public',
|
||||
resize: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('--mask flow defaults to the mask prompt', () => {
|
||||
const options = parseFillArgs(['--photo', 'foto.png', '--mask', 'm.png'])
|
||||
expect(options.mask).toBe('m.png')
|
||||
expect(options.extend).toBeNull()
|
||||
expect(options.prompt).toBe(MASK_DEFAULT_PROMPT)
|
||||
})
|
||||
|
||||
it('reads value flags as --flag value and --flag=value', () => {
|
||||
const spaced = parseFillArgs([
|
||||
'--photo',
|
||||
'a.jpg',
|
||||
'--mask',
|
||||
'b.png',
|
||||
'--prompt',
|
||||
'terno',
|
||||
'--out',
|
||||
'draft/',
|
||||
])
|
||||
expect(spaced.photo).toBe('a.jpg')
|
||||
expect(spaced.prompt).toBe('terno')
|
||||
expect(spaced.outDir).toBe('draft/')
|
||||
|
||||
const equals = parseFillArgs(['--photo=a.jpg', '--extend=30%', '--steps=50'])
|
||||
expect(equals.extend).toBe('30%')
|
||||
expect(equals.steps).toBe(50)
|
||||
})
|
||||
|
||||
it('--no-resize is a bare boolean flag', () => {
|
||||
expect(parseFillArgs(['--photo', 'a.jpg', '--extend', '10%', '--no-resize']).resize).toBe(false)
|
||||
})
|
||||
|
||||
it('fails closed: photo required, mask xor extend, invalid flags/values', () => {
|
||||
expect(() => parseFillArgs(['--extend', '30%'])).toThrow(/--photo é obrigatório/)
|
||||
expect(() => parseFillArgs(['--photo', 'a.jpg'])).toThrow(/--mask|--extend/)
|
||||
expect(() => parseFillArgs(['--photo', 'a.jpg', '--mask', 'm.png', '--extend', '10%'])).toThrow(
|
||||
/mutuamente exclusivos/,
|
||||
)
|
||||
expect(() => parseFillArgs(['--photo', 'a.jpg', '--extend', 'x%'])).toThrow(/--extend inválido/)
|
||||
expect(() => parseFillArgs(['--photo', 'a.jpg', '--extend', '10%', '--steps', '99'])).toThrow(
|
||||
/--steps inválido/,
|
||||
)
|
||||
expect(() => parseFillArgs(['--photo', 'a.jpg', '--extend', '10%', '--toaster'])).toThrow(
|
||||
/flag desconhecida/,
|
||||
)
|
||||
expect(() => parseFillArgs(['a.jpg', '--extend', '10%'])).toThrow(/posicional/)
|
||||
})
|
||||
|
||||
it('--help skips validation', () => {
|
||||
const options = parseFillArgs(['--help'])
|
||||
expect(options.help).toBe(true)
|
||||
expect(options.photo).toBeUndefined()
|
||||
})
|
||||
})
|
||||
175
tests/unit/imageResize.unit.spec.ts
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
FORMAT_MAX_WIDTHS,
|
||||
deriveOutputFileName,
|
||||
maxWidthFor,
|
||||
normalizeImageFormat,
|
||||
parseResizeArgs,
|
||||
} from '../../scripts/lib/imageResize.mjs'
|
||||
|
||||
describe('parseResizeArgs', () => {
|
||||
it('defaults: avif + webp, per-format width/quality, no bg removal, out public', () => {
|
||||
const options = parseResizeArgs(['foto.jpg'])
|
||||
expect(options).toEqual({
|
||||
help: false,
|
||||
paths: ['foto.jpg'],
|
||||
maxWidth: undefined,
|
||||
quality: undefined,
|
||||
formats: ['avif', 'webp'],
|
||||
outDir: 'public',
|
||||
removeBg: false,
|
||||
})
|
||||
})
|
||||
|
||||
it('--remove-bg is a bare boolean flag', () => {
|
||||
expect(parseResizeArgs(['--remove-bg', 'foto.jpg']).removeBg).toBe(true)
|
||||
expect(parseResizeArgs(['foto.jpg']).removeBg).toBe(false)
|
||||
})
|
||||
|
||||
it('accepts multiple positional paths and folders', () => {
|
||||
const options = parseResizeArgs(['a.jpg', 'b.png', 'fotos/'])
|
||||
expect(options.paths).toEqual(['a.jpg', 'b.png', 'fotos/'])
|
||||
})
|
||||
|
||||
it('reads flags both as --flag value and --flag=value', () => {
|
||||
const spaced = parseResizeArgs([
|
||||
'--max-width',
|
||||
'2560',
|
||||
'--format',
|
||||
'webp',
|
||||
'--out',
|
||||
'public/x',
|
||||
'foto.jpg',
|
||||
])
|
||||
expect(spaced.maxWidth).toBe(2560)
|
||||
expect(spaced.formats).toEqual(['webp'])
|
||||
expect(spaced.outDir).toBe('public/x')
|
||||
|
||||
const equals = parseResizeArgs([
|
||||
'--max-width=2560',
|
||||
'--quality=75',
|
||||
'--format=jpeg',
|
||||
'--out=out/',
|
||||
'foto.jpg',
|
||||
])
|
||||
expect(equals.maxWidth).toBe(2560)
|
||||
expect(equals.quality).toBe(75)
|
||||
expect(equals.formats).toEqual(['jpeg'])
|
||||
expect(equals.outDir).toBe('out/')
|
||||
})
|
||||
|
||||
it('accepts a comma-separated --format list, deduped and order-preserving', () => {
|
||||
expect(parseResizeArgs(['--format', 'avif,webp', 'foto.jpg']).formats).toEqual(['avif', 'webp'])
|
||||
expect(parseResizeArgs(['--format', 'avif,jpeg', 'foto.jpg']).formats).toEqual(['avif', 'jpeg'])
|
||||
expect(parseResizeArgs(['--format', 'webp,avif,webp', 'foto.jpg']).formats).toEqual([
|
||||
'webp',
|
||||
'avif',
|
||||
])
|
||||
expect(parseResizeArgs(['--format', 'avif,,webp', 'foto.jpg']).formats).toEqual([
|
||||
'avif',
|
||||
'webp',
|
||||
])
|
||||
})
|
||||
|
||||
it('leaves quality and maxWidth undefined without flags (each format applies its own default)', () => {
|
||||
expect(parseResizeArgs(['--format', 'webp', 'foto.jpg']).quality).toBeUndefined()
|
||||
expect(parseResizeArgs(['--format', 'jpeg', 'foto.jpg']).quality).toBeUndefined()
|
||||
expect(parseResizeArgs(['foto.jpg']).quality).toBeUndefined()
|
||||
expect(parseResizeArgs(['foto.jpg']).maxWidth).toBeUndefined()
|
||||
})
|
||||
|
||||
it('fails closed on an unknown flag', () => {
|
||||
expect(() => parseResizeArgs(['--toaster', 'foto.jpg'])).toThrow(/flag desconhecida/)
|
||||
})
|
||||
|
||||
it('fails closed on a missing flag value (end of argv or next token is a flag)', () => {
|
||||
expect(() => parseResizeArgs(['--max-width'])).toThrow(/espera um valor/)
|
||||
expect(() => parseResizeArgs(['--out', '--format', 'webp', 'foto.jpg'])).toThrow(
|
||||
/espera um valor/,
|
||||
)
|
||||
})
|
||||
|
||||
it('fails closed on invalid numbers', () => {
|
||||
for (const bad of ['0', '-100', 'abc', '31.5', '3840px']) {
|
||||
expect(() => parseResizeArgs(['--max-width', bad, 'foto.jpg'])).toThrow(
|
||||
/--max-width inválido/,
|
||||
)
|
||||
}
|
||||
for (const bad of ['0', '101', 'xyz']) {
|
||||
expect(() => parseResizeArgs(['--quality', bad, 'foto.jpg'])).toThrow(/--quality inválido/)
|
||||
}
|
||||
})
|
||||
|
||||
it('fails closed on an unsupported format, a list with one, or an all-empty list', () => {
|
||||
expect(() => parseResizeArgs(['--format', 'png', 'foto.jpg'])).toThrow(/--format inválido/)
|
||||
expect(() => parseResizeArgs(['--format', 'avif,svg', 'foto.jpg'])).toThrow(/--format inválido/)
|
||||
expect(() => parseResizeArgs(['--format', ',', 'foto.jpg'])).toThrow(/--format inválido/)
|
||||
expect(() => parseResizeArgs(['--format', ' , ', 'foto.jpg'])).toThrow(/--format inválido/)
|
||||
})
|
||||
|
||||
it('fails closed on no paths', () => {
|
||||
expect(() => parseResizeArgs([])).toThrow(/nenhum caminho/)
|
||||
})
|
||||
|
||||
it('--help skips validation', () => {
|
||||
const options = parseResizeArgs(['--help'])
|
||||
expect(options.help).toBe(true)
|
||||
expect(options.paths).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('normalizeImageFormat', () => {
|
||||
it('accepts canonical names case-insensitively', () => {
|
||||
expect(normalizeImageFormat('avif')).toBe('avif')
|
||||
expect(normalizeImageFormat('WebP')).toBe('webp')
|
||||
expect(normalizeImageFormat('JPEG')).toBe('jpeg')
|
||||
})
|
||||
|
||||
it('maps jpg aliases to jpeg and ignores a leading dot', () => {
|
||||
expect(normalizeImageFormat('jpg')).toBe('jpeg')
|
||||
expect(normalizeImageFormat('.jpeg')).toBe('jpeg')
|
||||
})
|
||||
|
||||
it('returns null for anything not encodable', () => {
|
||||
for (const bad of ['png', 'gif', 'svg', '', 'aviff']) {
|
||||
expect(normalizeImageFormat(bad)).toBeNull()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('deriveOutputFileName', () => {
|
||||
it('keeps the basename and swaps the extension per format', () => {
|
||||
expect(deriveOutputFileName('foto.jpg', 'avif')).toBe('foto.avif')
|
||||
expect(deriveOutputFileName('foto.jpeg', 'webp')).toBe('foto.webp')
|
||||
expect(deriveOutputFileName('foto.PNG', 'jpeg')).toBe('foto.jpg')
|
||||
})
|
||||
|
||||
it('survives dots inside the name', () => {
|
||||
expect(deriveOutputFileName('foto.final.1.jpg', 'avif')).toBe('foto.final.1.avif')
|
||||
})
|
||||
|
||||
it('the web name never collides with a source in another format', () => {
|
||||
expect(deriveOutputFileName('foto.avif', 'avif')).toBe('foto.avif')
|
||||
expect(deriveOutputFileName('foto.avif', 'webp')).toBe('foto.webp')
|
||||
})
|
||||
})
|
||||
|
||||
describe('maxWidthFor (PenPot companion must be light)', () => {
|
||||
it('defaults per format: avif retina-grade 2x, webp/jpeg 1x desktop', () => {
|
||||
expect(FORMAT_MAX_WIDTHS.avif).toBe(3840)
|
||||
expect(FORMAT_MAX_WIDTHS.webp).toBe(1920)
|
||||
expect(FORMAT_MAX_WIDTHS.jpeg).toBe(1920)
|
||||
expect(maxWidthFor('avif')).toBe(3840)
|
||||
expect(maxWidthFor('webp')).toBe(1920)
|
||||
expect(maxWidthFor('jpeg')).toBe(1920)
|
||||
})
|
||||
|
||||
it('an explicit --max-width overrides every format', () => {
|
||||
expect(maxWidthFor('avif', 2560)).toBe(2560)
|
||||
expect(maxWidthFor('webp', 2560)).toBe(2560)
|
||||
expect(maxWidthFor('webp', 900)).toBe(900)
|
||||
})
|
||||
})
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
"next-env.d.ts",
|
||||
".next/types/**/*.ts",
|
||||
".next/dev/types/**/*.ts",
|
||||
".next/e2e/types/**/*.ts"
|
||||
".next-e2e/types/**/*.ts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
|
|||