Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9aa183b
docs: define no-Calendly email scheduling flow
Messias-Olivindo Oct 13, 2026
b1a7d88
docs: plan no-Calendly email scheduling implementation
Messias-Olivindo Oct 14, 2026
74f0622
feat: centralize Calendly scheduling capability
Messias-Olivindo Oct 14, 2026
636fcf7
fix: preserve Calendly reconnection on stale refresh failure
Messias-Olivindo Oct 14, 2026
1791c50
fix: authorize private user profile access
Messias-Olivindo Oct 14, 2026
91f8696
feat: create dated email appointment requests safely
Messias-Olivindo Oct 14, 2026
5f47215
fix: scope active email requests and validate proposed instants
Messias-Olivindo Oct 14, 2026
38b5b50
test: remove fixture histories before restricted processes
Messias-Olivindo Oct 14, 2026
3b12223
fix: confirm email proposals under schedule lock
Messias-Olivindo Oct 14, 2026
a3070df
feat: add safe email scheduling frontend contracts
Messias-Olivindo Oct 14, 2026
5ddfb15
feat: unify no-Calendly email request flow
Messias-Olivindo Oct 14, 2026
2250df1
fix: isolate owned appointment checks by render scope
Messias-Olivindo Oct 14, 2026
bfa6025
feat: confirm proposed times and expose WhatsApp safely
Messias-Olivindo Oct 14, 2026
a062e98
fix: keep delegated Calendly popup inside dialog scope
Messias-Olivindo Oct 14, 2026
94e4f92
test: cover no-Calendly email scheduling end to end
Messias-Olivindo Oct 14, 2026
8429477
test: harden email scheduling E2E gates
Messias-Olivindo Oct 14, 2026
3a7036e
test: fix PostgreSQL fixtures and restore legacy confirmation race
Messias-Olivindo Oct 14, 2026
ef2d8b5
docs: clarify sanitizer boundary in email E2E
Messias-Olivindo Oct 14, 2026
0e68f5f
test: align legacy e2e with health endpoint
Messias-Olivindo Oct 14, 2026
c9c4d89
fix(appointments): block SSRF in Calendly resource sync
Messias-Olivindo Oct 14, 2026
15a6511
fix(catalog): hide specialist PII from public products
Messias-Olivindo Oct 14, 2026
8229f86
fix(appointments): release scheduling process on cancellation
Messias-Olivindo Oct 14, 2026
cfe4779
fix(appointments): scope office listings by company
Messias-Olivindo Oct 14, 2026
0b35e28
fix(processes): enforce scoped authorization
Messias-Olivindo Oct 14, 2026
e607311
fix(appointments): serialize cancellation with process advances
Messias-Olivindo Oct 14, 2026
65ae6b5
fix(appointments): canonicalize Calendly widget URIs
Messias-Olivindo Oct 14, 2026
3a338f6
fix(processes): preserve completed appointments on cancel
Messias-Olivindo Oct 14, 2026
963a4a9
fix(appointments): repair legacy Calendly URIs
Messias-Olivindo Oct 14, 2026
9a38dd0
fix(processes): enforce transition gates and rejection CAS
Messias-Olivindo Oct 14, 2026
733ce64
fix(processes): align status actions with transition policy
Messias-Olivindo Oct 14, 2026
13df782
fix(appointments): serialize Calendly webhooks
Messias-Olivindo Oct 14, 2026
32f64e1
fix(appointments): harden Calendly trust boundary
Messias-Olivindo Oct 14, 2026
47213b2
fix(processes): gate safe rejection actions
Messias-Olivindo Oct 14, 2026
a3e3a83
fix(processes): block rejection with active scheduling
Messias-Olivindo Oct 14, 2026
17b4975
fix(processes): fail closed on meeting lookup
Messias-Olivindo Oct 14, 2026
d2f6b1d
fix(appointments): preserve Calendly retry state
Messias-Olivindo Oct 14, 2026
8fde097
fix(meetings): serialize meeting start with rejection
Messias-Olivindo Oct 14, 2026
3ee4997
fix(meetings): move provider calls outside transactions
Messias-Olivindo Oct 14, 2026
e2deb61
fix(appointments): retry pending Calendly sync
Messias-Olivindo Oct 14, 2026
eecb5d6
fix(processes): surface safe rejection errors
Messias-Olivindo Oct 14, 2026
4a01a3b
fix(meetings): bound provider deadline and recover stale claims
Messias-Olivindo Oct 14, 2026
2efc361
fix(appointments): close Calendly retry races
Messias-Olivindo Oct 14, 2026
1f1b8e2
fix(frontend): harden Calendly completion states
Messias-Olivindo Oct 14, 2026
2909d71
merge: sync develop into no-calendly scheduling flow
Messias-Olivindo Oct 14, 2026
1c446b7
fix(calendly): enforce event ownership and terminal states
Messias-Olivindo Oct 14, 2026
bc0462d
fix(frontend): close scheduling lifecycle gaps
Messias-Olivindo Oct 14, 2026
db39c80
fix(frontend): consume owner-scoped specialist contact
Messias-Olivindo Oct 14, 2026
c52cb79
test(frontend): cover scoped contact fallbacks
Messias-Olivindo Oct 14, 2026
11cf86a
fix(frontend): preserve late Calendly completion
Messias-Olivindo Oct 14, 2026
33935ec
fix(processes): restore negotiation monetary snapshot
Messias-Olivindo Oct 14, 2026
277bf18
test(e2e): cover scoped specialist email
Messias-Olivindo Oct 14, 2026
e4b76c4
Merge pull request #246 from InteliJR/codex/fix-no-calendly-email-flow
Messias-Olivindo Oct 23, 2026
c900427
fix(contracts): preserve active agreement invariants
Messias-Olivindo Oct 23, 2026
85e8a69
feat(admin): complete delegated specialist backend journey
Messias-Olivindo Oct 23, 2026
9fe235b
feat(admin): add specialist journey workspace
Messias-Olivindo Oct 23, 2026
910dc1c
fix(admin): address delegated journey review findings
Messias-Olivindo Oct 23, 2026
2b35cbb
fix(admin): harden specialist catalog synchronization
Messias-Olivindo Oct 23, 2026
a37c274
fix(processes): aceitar especialista representado na listagem
Messias-Olivindo Oct 23, 2026
6b386c2
fix(admin): mostrar nome completo no catálogo assistido
Messias-Olivindo Oct 23, 2026
333ab88
fix(admin): mostrar executor delegado na proposta e estado do contrato
Messias-Olivindo Oct 23, 2026
1ac5153
feat(admin): excluir processo da jornada com auditoria
Messias-Olivindo Oct 26, 2026
a3efec8
Merge pull request #260 from InteliJR/codex/admin-specialist-full-jou…
Messias-Olivindo Oct 26, 2026
be7ab42
feat(contracts): nome e e-mail do vendedor opcionais na criação do co…
Messias-Olivindo Oct 26, 2026
0d72719
Merge pull request #261 from InteliJR/codex/optional-seller-contract
Messias-Olivindo Oct 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Além do `DATABASE_URL`, o projeto depende de variáveis importantes para integr
- `DOCUSIGN_INTEGRATION_KEY`, `DOCUSIGN_USER_ID`, `DOCUSIGN_ACCOUNT_ID`, `DOCUSIGN_PRIVATE_KEY`, `DOCUSIGN_ENV`, `DOCUSIGN_WEBHOOK_SECRET`
- `GOOGLE_DRIVE_API_KEY`
- `MEETING_PROVIDER`, `MEETING_DEMO_FALLBACK_ENABLED`, `JITSI_BASE_URL`
- Calendly OAuth (quando habilitado): `CALENDLY_OAUTH_CLIENT_ID`, `CALENDLY_OAUTH_CLIENT_SECRET`, `CALENDLY_OAUTH_REDIRECT_URI`, `CALENDLY_TOKEN_ENCRYPTION_KEY`, `CALENDLY_WEBHOOK_CALLBACK_URL`, `CALENDLY_WEBHOOK_SIGNING_KEY`
- Calendly OAuth (quando habilitado): `CALENDLY_OAUTH_CLIENT_ID`, `CALENDLY_OAUTH_CLIENT_SECRET`, `CALENDLY_OAUTH_REDIRECT_URI`, `CALENDLY_TOKEN_ENCRYPTION_KEY`; se `CALENDLY_WEBHOOK_CALLBACK_URL` for configurada, `CALENDLY_WEBHOOK_SIGNING_KEY` é obrigatória

---

Expand Down
3 changes: 3 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ BACKEND_URL=http://localhost:3000
# ===== CALENDLY INTEGRATION =====
# Token de acesso do Calendly para agendamentos (opcional)
CALENDLY_ACCESS_TOKEN=your-calendly-access-token
# Se a URL de callback for configurada, a signing key também é obrigatória.
CALENDLY_WEBHOOK_CALLBACK_URL=
CALENDLY_WEBHOOK_SIGNING_KEY=

# ===== GOOGLE DRIVE IMPORT =====
# Chave de API para listar/baixar imagens de pasta pública do Google Drive
Expand Down
9 changes: 7 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ cp .env.example .env
- `CALENDLY_OAUTH_CLIENT_SECRET`
- `CALENDLY_OAUTH_REDIRECT_URI`
- `CALENDLY_TOKEN_ENCRYPTION_KEY`
- `CALENDLY_WEBHOOK_CALLBACK_URL` (recomendado)
- `CALENDLY_WEBHOOK_SIGNING_KEY` (recomendado)
- `CALENDLY_WEBHOOK_CALLBACK_URL` (opcional; habilita callbacks)
- `CALENDLY_WEBHOOK_SIGNING_KEY` (obrigatório quando `CALENDLY_WEBHOOK_CALLBACK_URL` estiver configurado)

O backend não cria assinaturas de webhook sem `CALENDLY_WEBHOOK_SIGNING_KEY` e
rejeita callbacks quando a chave estiver ausente. A chave gerada pelo Calendly
na criação do aplicativo OAuth deve ser copiada para o backend. Ela valida os
callbacks localmente e não é reenviada no payload da subscription OAuth.

> Observação: `CALENDLY_ACCESS_TOKEN` pode existir como fallback simples, mas o fluxo recomendado no projeto atual é OAuth por especialista.

Expand Down
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"seed": "ts-node prisma/seed.ts"
"seed": "ts-node prisma/seed.ts",
"seed:email-scheduling-e2e": "ts-node prisma/seed-email-scheduling-e2e.ts"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.911.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE "DelegatedActionAudit" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"actor_id" UUID NOT NULL,
"actor_role" "UserRole" NOT NULL,
"represented_specialist_id" UUID NOT NULL,
"action" VARCHAR(80) NOT NULL,
"resource_type" VARCHAR(80) NOT NULL,
"resource_id" VARCHAR(128) NOT NULL,
"metadata" JSONB,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "DelegatedActionAudit_pkey" PRIMARY KEY ("id")
);

CREATE INDEX "DelegatedActionAudit_actor_id_created_at_idx"
ON "DelegatedActionAudit"("actor_id", "created_at");
CREATE INDEX "DelegatedActionAudit_represented_specialist_id_created_at_idx"
ON "DelegatedActionAudit"("represented_specialist_id", "created_at");
CREATE INDEX "DelegatedActionAudit_resource_type_resource_id_idx"
ON "DelegatedActionAudit"("resource_type", "resource_id");
CREATE INDEX "DelegatedActionAudit_action_created_at_idx"
ON "DelegatedActionAudit"("action", "created_at");
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALTER TABLE "ProductImportJob"
ADD COLUMN "created_by_id" UUID,
ADD COLUMN "mode" VARCHAR(20) NOT NULL DEFAULT 'ADDITIVE',
ADD COLUMN "sync_confirmed" BOOLEAN NOT NULL DEFAULT false;

CREATE INDEX "ProductImportJob_created_by_id_idx"
ON "ProductImportJob"("created_by_id");

ALTER TABLE "ProductImportJob"
ADD CONSTRAINT "ProductImportJob_mode_check"
CHECK ("mode" IN ('ADDITIVE', 'SYNCHRONIZE'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE UNIQUE INDEX "NegotiationProposal_one_pending_per_process_idx"
ON "NegotiationProposal"("process_id")
WHERE "status" = 'PENDING';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "ProductImportJob"
ADD COLUMN "sync_preview_snapshot" JSONB;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE "ProductImportJob"
ADD COLUMN "processing_lease_token" UUID,
ADD COLUMN "processing_lease_expires_at" TIMESTAMP(3);

CREATE INDEX "ProductImportJob_status_processing_lease_expires_at_idx"
ON "ProductImportJob"("status", "processing_lease_expires_at");
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE "Process"
ADD COLUMN "removed_at" TIMESTAMP(3),
ADD COLUMN "removed_by" UUID,
ADD COLUMN "removal_reason" VARCHAR(1000);

CREATE INDEX "Process_removed_at_idx" ON "Process"("removed_at");
32 changes: 32 additions & 0 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ model Process {
negotiation_product_value Decimal? @db.Decimal(15, 2)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
removed_at DateTime?
removed_by String? @db.Uuid
removal_reason String? @db.VarChar(1000)

car Car? @relation(fields: [car_id], references: [id])
boat Boat? @relation(fields: [boat_id], references: [id])
Expand Down Expand Up @@ -902,6 +905,7 @@ model Process {
@@index([product_id])
@@index([created_at])
@@index([status, updated_at])
@@index([removed_at])
}

// MeetingSession: sessão de videoconferência criada na plataforma para um processo
Expand Down Expand Up @@ -958,6 +962,26 @@ model ProcessRejection {
@@index([rejected_at])
}

// Trilha aditiva de ações executadas por um ator em nome de um especialista.
// IDs são intencionalmente mantidos sem FK/onDelete para preservar a prova
// mesmo quando o recurso operacional for removido por regras legadas.
model DelegatedActionAudit {
id String @id @default(uuid()) @db.Uuid
actor_id String @db.Uuid
actor_role UserRole
represented_specialist_id String @db.Uuid
action String @db.VarChar(80)
resource_type String @db.VarChar(80)
resource_id String @db.VarChar(128)
metadata Json?
created_at DateTime @default(now())

@@index([actor_id, created_at])
@@index([represented_specialist_id, created_at])
@@index([resource_type, resource_id])
@@index([action, created_at])
}

// ─────────────────────────────────────────────────────────────────────────────
// ▸ PROPOSTAS DE NEGOCIAÇÃO
// ─────────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -1318,6 +1342,10 @@ model ProductImportJob {
id String @id @default(uuid()) @db.Uuid
product_type ProductType
specialist_id String @db.Uuid
created_by_id String? @db.Uuid
mode String @default("ADDITIVE") @db.VarChar(20)
sync_confirmed Boolean @default(false)
sync_preview_snapshot Json?
status ProductImportJobStatus @default(PENDING)
total_items Int @default(0)
processed_items Int @default(0)
Expand All @@ -1330,14 +1358,18 @@ model ProductImportJob {
started_at DateTime?
finished_at DateTime?
error_message String?
processing_lease_token String? @db.Uuid
processing_lease_expires_at DateTime?
created_at DateTime @default(now())
updated_at DateTime @updatedAt

specialist User @relation(fields: [specialist_id], references: [id], onDelete: Cascade)
items ProductImportJobItem[]

@@index([specialist_id])
@@index([created_by_id])
@@index([status])
@@index([status, processing_lease_expires_at])
@@index([product_type])
@@index([created_at])
}
Expand Down
Loading
Loading