Repository navigation
feat(admin): ft admin crm para el CRM maestro (solo equipo) - #50
Open
LucasLeguizamo wants to merge 8 commits into
Open
LucasLeguizamo wants to merge 8 commits into
LucasLeguizamo wants to merge 8 commits into
Conversation
Copia local de admin-openapi.json desde free-admin (rama feat/crm-admin-api, todavía sin desplegar): suma las rutas /crm/*. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLo4Mwi7Ms4TBuo1JffkU5
configureAdminClient manda Authorization: Bearer cuando FT_ADMIN_TOKEN está definida y cae a la cookie de sesión SUPER_ADMIN si no. El servidor ya acepta el PAT; con Bearer presente no vuelve a la cookie, así que un token malo es 401. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLo4Mwi7Ms4TBuo1JffkU5
Suma ft admin crm (contrato admin 1.7.0): campaigns list/get/cancel, batches next/stop, events search/dates, options, quota, preview y launch. - launch corre primero el preview con el mismo filtro y remitente, muestra total, alcance por correo y WhatsApp y días estimados, y recién después confirma; cancel y batches muestran la campaña antes de confirmar. Sin TTY y sin --yes, fallan. - Ninguna escritura se reintenta sola. - OUTSIDE_SEND_WINDOW dice cuándo abre la ventana y sugiere --ignore-window; DUPLICATE_CAMPAIGN muestra el existingId; QUOTA_EXHAUSTED lee Retry-After. - unwrap ya no revienta cuando details es un objeto y no una lista. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLo4Mwi7Ms4TBuo1JffkU5
Resincroniza admin-openapi.json 1.7.0 (free-admin 1b84d09b): POST /crm/campaigns acepta ignoreSendWindow, las escrituras y el preview pueden responder 413 PAYLOAD_TOO_LARGE y AdminCrmAudienceFilter exige version. - launch --ignore-window manda ignoreSendWindow: true; OUTSIDE_SEND_WINDOW en launch muestra cuándo abre la ventana y sugiere el flag, como batches next. - El 413 se explica (tope de 256 KB) con o sin envelope JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLo4Mwi7Ms4TBuo1JffkU5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fo7cm7S4yTPG5LztA8pEVi
Copiado de free-admin main (18de8ae). Frente al 1.7.0 de #1055: mismas operaciones, campos y códigos de error del CRM; agrega el rol MERCH_MANAGER, los nullables pasan de anyOf a type: [T, null] y los date-time exigen segundos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fo7cm7S4yTPG5LztA8pEVi
…ro v2 validado - Las 4 escrituras pasan por crmWriteOnce: un 5xx o una conexión caída se reporta como resultado desconocido y apunta a campaigns list, nunca a "retry with backoff". - RATE_LIMITED (429) con su siguiente paso. - preview/launch rechazan un filtro sin version 2 antes de mandar nada. - destructive-confirm cubre las 4 escrituras: sin TTY (también con CI=true), con TTY y respuesta no/sí, preview con el tamaño de la audiencia antes de preguntar, y un solo envío ante 500/503/429/conexión caída. - Changeset y README a admin 1.8.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fo7cm7S4yTPG5LztA8pEVi
…nt, no crash on odd 2xx
- Every CRM write confirmation names the API host ("... against
admin.appfreeticket.com?") so a staging token aimed at prod shows.
- `launch --yes` requires `--expect-count <N>` and stops before writing if
the preview reach differs; optional (but enforced) without --yes.
- A 2xx with an unexpected body no longer crashes on `body.data.id`: it
warns that the write probably went through and exits 0.
- Tests: sweep of admin-openapi.json (x-ft-destructive / x-ft-mcp.expose
false) against CRM_WRITES; static check that every postCrm* write is
called only inside crmWriteOnce(() =>; real admin SDK + fake fetch 503
sends exactly one POST on launch and batches next; "n" prompt answer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fo7cm7S4yTPG5LztA8pEVi
LucasLeguizamo
marked this pull request as ready for review
November 3, 2026 21:56
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comandos
ft admin crm …contra/api/admin/crm. Solo SUPER_ADMIN.Contrato: admin 1.8.0, el
admin-openapi.jsonque está commiteado en free-adminmain(18de8ae). El CRM de free-admin#1055 ya está mergeado ahí. Frente al 1.7.0 de la rama #1055, el CRM no cambió: tiene las mismas 11 operaciones, los mismosoperationId, campos, filtro de audiencia ({ version: 2, … }abierto) y códigos de error. Lo que sí cambia en 1.8.0:MERCH_MANAGERenAdminMe/AdminUser/AdminUserUpdate;anyOfatype: [T, "null"], sin efecto en los tipos generados;date-timedeAdminWorkspaceUpdate/AdminTokenCreateexigen segundos;AdminWorkspaceCreate.No hay operaciones admin nuevas fuera del CRM desde 1.5.1. No verifiqué contra producción si 1.8.0 ya está desplegado.
Qué cambia
campaigns list|get,events search|dates,options,quota,preview --filter @filter.json.launch --data @campaign.json [--ignore-window],batches next <id> [--ignore-window],batches stop <id>ycampaigns cancel <id>. Mandan mensajes reales. El contrato las marcax-ft-mcp: {expose:false}, así que no salen por MCP. En el CLI quedan con estas reglas:launchcorre el preview con el mismo filtro y sender, y muestra el tamaño de la audiencia y el alcance real antes de preguntar. Si la audiencia está vacía, frena.--yes, también conCI=true.campaigns listen vez de sugerir "retry with backoff"."version": 2se rechaza antes de mandar nada.OUTSIDE_SEND_WINDOW(con la hora de apertura en Bogotá),QUOTA_EXHAUSTED,DUPLICATE_CAMPAIGN(conexistingId),RATE_LIMITED,INVALID_STATE,WHATSAPP_*, los 422 por campo y el 413.FT_ADMIN_TOKEN:ft adminacepta un PAT porAuthorization: Bearer.origin/main(waitlist, contrato 1.24) y sincronización deadmin-openapi.jsona 1.8.0.Diagrama de flujo
flowchart TD A[ft admin crm launch --data] --> B{filter.version == 2?} B -- no --> X[exit 1, sin requests] B -- sí --> C[POST /crm/audience/preview] C --> D[muestra audiencia y alcance en stderr] D --> E{total == 0?} E -- sí --> X E -- no --> F{--yes?} F -- sí --> H[POST /crm/campaigns, una sola vez] F -- no --> G{TTY?} G -- no --> X2[Refusing: no TTY, exit 1] G -- sí --> P{respuesta y?} P -- no --> X3[Aborted, exit 1] P -- sí --> H H --> R{respuesta} R -- 201 --> OK[campaña creada] R -- error con nombre --> N[hint específico, sin reintento] R -- 5xx o conexión caída --> U[resultado desconocido: revisar campaigns list]Cómo probar
pnpm install && pnpm generate && pnpm lint && pnpm typecheck && pnpm test && pnpm build→ 139/139 tests.src/destructive-confirm.test.tscubre las 4 escrituras:FT_ADMIN_TOKEN=ft_admin_… ft admin crm campaigns listft admin crm preview --filter @filter.json🤖 Generated with Claude Code
https://claude.ai/code/session_01Fo7cm7S4yTPG5LztA8pEVi