Skip to content

feat: add AgencyZoom plugin with 99 operations - #369

Merged
yuvrxj-afk merged 18 commits into
corsairdev:mainfrom
Ayush7614:feat/agencyzoom-plugin
Aug 7, 2026
Merged

feat: add AgencyZoom plugin with 99 operations#369
yuvrxj-afk merged 18 commits into
corsairdev:mainfrom
Ayush7614:feat/agencyzoom-plugin

Conversation

@Ayush7614

@Ayush7614 Ayush7614 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

Adds @corsair-dev/agencyzoom with all 99 AgencyZoom catalog operations over JWT bearer auth (api_key).

Covers leads, customers, opportunities, tasks, email/SMS threads, policies, reference data, and V4 SSO/auth. Includes Zod schemas, error handlers, selective DB cache for leads/customers/tasks, and Jest coverage for plugin shape, auth headers, route mapping, and risk labels.

Claimed integration: https://corsair.dev/oss/agencyzoom

Closes #368

Checklist

  • I have run pnpm lint and all checks pass
  • I have run pnpm typecheck and there are no TypeScript errors
  • I have run pnpm build and all packages build successfully
  • I have run pnpm test and all tests pass
  • I have added or updated tests where applicable
  • I have added or updated necessary documentation

Screenshots / Demos

Screenshot 2026-08-07 at 6 33 26 PM

Additional Notes

Auth: user-supplied JWT from POST /auth/login or V4 SSO.

Summary by CodeRabbit

  • New Features

    • Added AgencyZoom integration with API-key authentication and broad endpoint coverage.
    • Added support for leads, customers, contacts, tasks, opportunities, policies, profiles, email and text threads, service tickets, reference data, and SSO.
    • Added request validation, response schemas, and synchronized lead, customer, and task data.
    • Added rate-limit retries and clear handling for authentication, missing-data, and server errors.
    • Added AgencyZoom as a supported provider.
  • Tests

    • Added comprehensive coverage for authentication, routing, validation, requests, and caching.

@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

@Ayush7614 is attempting to deploy a commit to the corsair Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the core Changes in packages/corsair label Jul 5, 2026
@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds the @corsair-dev/agencyzoom plugin with all 99 operations over JWT bearer auth, covering leads, customers, tasks, opportunities, policies, email/SMS threads, reference data, and V4 SSO. Every issue raised in prior review rounds has been addressed: the audit-log status is now correctly tracked as 'failed' on exceptions, batchDeleteTask cache eviction fires correctly via the riskLevel === 'destructive' guard, leadDataRequests is required, updateTask.taskId is preserved in the request body via bodyPathParams, updateTagsForAPolicy enforces the policy-id requirement with a Zod .refine(), and all unknown/index-signature usages carry the required explanatory comments.

  • Factory & cache: executeAgencyZoomOperation tracks failure status in a let variable and propagates it to logAgencyZoomOperation in the finally block; syncAgencyZoomOperationCache correctly handles POST-based destructive operations by checking riskLevel.
  • Schemas: Concrete Zod output schemas are wired for leads, customers, tasks, and auth endpoints; the shared AgencyZoomSearchInputSchema (with page/pageSize/sort/order) covers all list endpoints.
  • Tests: Good breadth — shape/count checks, schema assertions for edge cases, HTTP call coverage for representative operations across most groups, and explicit cache-eviction unit tests.

Confidence Score: 5/5

  • The plugin is safe to merge. All previously identified correctness issues have been resolved, and no new breaking problems were found.
  • All nine issues from prior review rounds — including the audit-log always-completed status, the POST batch-delete cache eviction, the required leadDataRequests field, the updateTask body taskId exclusion, and the updateTagsForAPolicy validation — have been fixed. The remaining feedback is minor: empty-array guards on two batch schemas and a missing schema assertion for batchCreateContact. None of these affect correctness of deployed operations.
  • No files require special attention; the two suggestions in types.ts are straightforward .min(1) additions to the batch input schemas.

Important Files Changed

Filename Overview
packages/agencyzoom/endpoints/factory.ts Core factory wiring for all 99 operations. Previously flagged issues (always-completed log status, unguarded type assertion) are now fixed — failure status is tracked with a let variable, and the headers cast has an explanatory comment.
packages/agencyzoom/endpoints/cache-sync.ts Selective cache sync for leads/customers/tasks. Previously flagged batchDeleteTask eviction bug is resolved: the isDelete guard now checks route.riskLevel === 'destructive' in addition to method === 'DELETE', so POST batch-delete operations correctly evict cached entries.
packages/agencyzoom/endpoints/types.ts All 99 input/output schemas. Previously flagged issues fixed: leadDataRequests is now required, updateTask.taskId is preserved via bodyPathParams, updateTagsForAPolicy uses a .refine() guard, and unknown/index-signature usages carry explanatory comments. Minor gap: batchCreateLead and batchDeleteTask accept empty arrays that would be rejected by the AgencyZoom API.
packages/agencyzoom/endpoints/routes.ts Defines all 99 route definitions. updateTask now correctly declares bodyPathParams: ['taskId'], fixing the previous body-exclusion bug. POST endpoints with destructive semantics (batchDeleteTask, deleteThread) are correctly marked with riskLevel: 'destructive'.
packages/agencyzoom/client.ts HTTP client wrapper with JWT auth. unknown fields now carry required comments per project rules. Auth header injection is safely guarded — empty apiKey omits the Authorization header rather than sending Bearer .
packages/agencyzoom/error-handlers.ts Handles 429, 401/403, 404, 5xx, and a catch-all DEFAULT handler. Rate-limit handler uses exponential backoff with 3 retries. Server errors intentionally return 0 retries because AgencyZoom 5xx can arrive after a mutation committed.
packages/agencyzoom/api.test.ts Test suite with good breadth: schema validation, plugin shape/count, auth header isolation, path resolution, body construction, cache eviction, and HTTP route mapping for representative operations. batchCreateContact (the sole contact group endpoint) has no direct schema assertion test unlike the parallel batchCreateLead.
packages/agencyzoom/index.ts Plugin entry point. keyBuilder correctly returns an empty string for login/SSO bootstrap routes; authenticated routes independently throw AuthMissingError in the factory when no key is present.
packages/agencyzoom/schema/database.ts Zod schemas for the three cached entity types (lead, customer, task) using AgencyZoom wire-case field names with .catchall(z.unknown()) for forward compatibility.
packages/corsair/core/constants.ts agencyzoom added to BaseProviders list as required for a new plugin PR.

Sequence Diagram

sequenceDiagram
    participant Caller as Host App
    participant Plugin as agencyzoom plugin
    participant Factory as executeAgencyZoomOperation
    participant Cache as syncAgencyZoomOperationCache
    participant Client as makeAgencyZoomRequest
    participant API as AgencyZoom API

    Caller->>Plugin: endpoint.leads.createLead(ctx, input)
    Plugin->>Factory: executeAgencyZoomOperation(ctx, input, route)
    Factory->>Factory: check route.requiresAuth + ctx.key
    Factory->>Client: "makeAgencyZoomRequest(path, apiKey, {method,body,query,headers})"
    Client->>API: "POST /leads/create { Bearer JWT }"
    API-->>Client: "201 { id, ... }"
    Client-->>Factory: response
    Factory->>Cache: syncAgencyZoomOperationCache(ctx, route, input, response)
    Note over Cache: GROUP_CACHE_RULES["leads"] matched
    Cache->>Cache: cacheItems() → upsertByEntityId(id, item)
    Cache-->>Factory: done
    Factory->>Factory: logAgencyZoomOperation(ctx, input, route, "completed")
    Factory-->>Caller: response

    Note over Factory,API: On error: status="failed", cache skipped, error rethrown
    Note over Factory,API: requiresAuth:false routes (login/SSO) skip JWT check
Loading

Reviews (12): Last reviewed commit: "docs: note updateTask taskId stays in re..." | Re-trigger Greptile

Comment thread packages/agencyzoom/endpoints/factory.ts Outdated
Comment thread packages/agencyzoom/endpoints/factory.ts Outdated
Comment thread packages/agencyzoom/endpoints/types.ts Outdated
Comment thread packages/agencyzoom/client.ts
@Ayush7614

Copy link
Copy Markdown
Contributor Author

@greptileai

1 similar comment
@Ayush7614

Copy link
Copy Markdown
Contributor Author

@greptileai

Ayush7614 and others added 4 commits August 7, 2026 18:26
Implements the AgencyZoom insurance CRM integration with JWT bearer auth,
OpenAPI-mapped routes across leads, customers, opportunities, tasks, and
reference data. Closes corsairdev#368.
Log failed operations with 'failed' status, add type assertion and
unknown-field comments, and consolidate shared Zod schemas for dynamic
AgencyZoom payload fields.
Cache leads, customers, and tasks via ctx.db upserts; rename endpoint
files to kebab-case; remove generator script.
Correct risk labels, keep Authorization authoritative, disable 5xx
retries on mutations, and let search filters pass through schemas.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Dhirenderchoudhary, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4599ee92-6771-4d39-a9b0-446f2ce49b03

📥 Commits

Reviewing files that changed from the base of the PR and between 1a97c51 and f520b0f.

📒 Files selected for processing (6)
  • packages/agencyzoom/api.test.ts
  • packages/agencyzoom/client.ts
  • packages/agencyzoom/endpoints/cache-sync.ts
  • packages/agencyzoom/endpoints/factory.ts
  • packages/agencyzoom/endpoints/routes.ts
  • packages/agencyzoom/endpoints/types.ts
📝 Walkthrough

Walkthrough

The pull request adds an AgencyZoom Corsair plugin with 99 routed operations, typed schemas, API-key and JWT handling, cache synchronization, error classification, package configuration, provider registration, and integration tests.

Changes

AgencyZoom integration

Layer / File(s) Summary
Routes, schemas, and endpoint contracts
packages/agencyzoom/endpoints/routes.ts, packages/agencyzoom/endpoints/types.ts, packages/agencyzoom/endpoints/index.ts, packages/agencyzoom/schema/*
Defines AgencyZoom routes, request and response schemas, database entities, endpoint registries, and route-derived metadata.
Client, plugin wiring, and package setup
packages/agencyzoom/client.ts, packages/agencyzoom/index.ts, packages/agencyzoom/error-handlers.ts, packages/agencyzoom/package.json, packages/agencyzoom/tsconfig.json, packages/agencyzoom/tsup.config.ts, packages/agencyzoom/jest.config.json, packages/corsair/core/constants.ts
Adds the authenticated HTTP client, plugin factory, error handlers, build configuration, package metadata, test configuration, and provider registration.
Operation execution and cache synchronization
packages/agencyzoom/endpoints/factory.ts, packages/agencyzoom/endpoints/cache-sync.ts
Resolves paths and parameters, constructs requests, enforces authentication, logs operations, and synchronizes lead, customer, and task caches.
Endpoint handlers and registries
packages/agencyzoom/endpoints/{auth,contact,customers,email-threads,leads,life,opportunities,policies,profile,reference-data,service-tickets,tasks,text-threads,v4sso}.ts
Adds grouped endpoint wrappers for authentication, CRM resources, tasks, messaging, reference data, service tickets, profile updates, and SSO.
Integration validation
packages/agencyzoom/api.test.ts
Tests plugin structure, schemas, authentication, request headers and bodies, route resolution, cache deletion, and destructive endpoint mappings.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • corsairdev/corsair#353: Adds a provider plugin with analogous client, endpoint, schema, authentication, error-handler, package, and provider-registration structures.
  • corsairdev/corsair#482: Adds a first-class provider plugin and provider-name registration pattern.

Suggested labels: plugin

Suggested reviewers: devjain32

Sequence Diagram(s)

sequenceDiagram
  participant CorsairEndpoint
  participant executeAgencyZoomOperation
  participant makeAgencyZoomRequest
  participant AgencyZoomAPI
  participant AgencyZoomCache
  CorsairEndpoint->>executeAgencyZoomOperation: Submit route and input
  executeAgencyZoomOperation->>makeAgencyZoomRequest: Resolve path, query, body, and API key
  makeAgencyZoomRequest->>AgencyZoomAPI: Send authenticated request
  AgencyZoomAPI-->>makeAgencyZoomRequest: Return response or error
  makeAgencyZoomRequest-->>executeAgencyZoomOperation: Return operation result
  executeAgencyZoomOperation->>AgencyZoomCache: Synchronize cached entities
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the AgencyZoom plugin and its 99 operations, which matches the primary change.
Linked Issues check ✅ Passed The implementation covers the 99 requested AgencyZoom operations, JWT authentication, schemas, error handling, caching, and no webhook triggers.
Out of Scope Changes check ✅ Passed The changes support the AgencyZoom plugin objectives, including package setup, provider registration, endpoint implementation, schemas, tests, and configuration.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Keep R1 scope to plugin + constants + lockfile; satisfy CI format.
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Plugin PR scorecard — packages/agencyzoom

Check Status Notes
R1 — Scope: plugin files only
R2 — Tests with assertions
R3 — Description complete
R3 — Linked issue / claim
R4 — Demo video / recording

Rules: PLUGIN_PR_RULES.md · re-runs on every push

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Hey @Ayush7614, thanks for the contribution! 🏴‍☠️ Before a maintainer reviews, please fix the items below — the review re-runs automatically on your next push.

Must fix

  • P1 packages/agencyzoom/endpoints/factory.tsOperation always logged as "completed" on failure
    logAgencyZoomOperation is called in a finally block with a hardcoded 'completed' status, so any request that throws (4xx, 5xx, network error) will still be recorded as completed. This means failed operations appear as successful in audit/observability logs, making it impossible to distinguish succeeded calls from errored ones after the fact. The log call and the error recovery should use separate status values based on whether the try block returned normally or threw.
Optional improvements (P2)
  • P2 packages/agencyzoom/endpoints/factory.tsType assertion without justification
    — violates the project rule requiring a comment when a type assertion is used in the plugins folder instead of directly using the passed type. The input.headers field is typed as unknown via the index signature on AgencyZoomEndpointInput, but the assertion to Record<string, string> silently drops any type-safety guarantee. A comment explaining why a direct type is not feasible here is required.
        	return makeAgencyZoomRequest(resolvePath(route.path, input, route), ctx.key, {
        		method: route.method,
        		body: requestBody(route, input),
        		query: buildQuery(route, input),
        		// input.headers is `unknown` via the AgencyZoomEndpointInput index signature;
        		// asserted here because callers supply string-valued header maps validated by per-op Zod schemas.
        		headers: input.headers as Record<string, string> | undefined,
        	});

Rule Used: What: Type assertions in the plugins folder must b... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  • P2 packages/agencyzoom/endpoints/types.tsunknown index signature without explanation
    — the rule requires every use of any or unknown to carry a comment explaining why stricter typing is not feasible. This index signature lets callers pass arbitrary keys through to the body/query builders, but no comment documents the intent. The same applies to the other z.array(z.unknown()) and z.record(z.string(), z.unknown()) calls spread across this file that lack per-field comments (e.g. tagIds, leadDataRequests, contactDataRequests).
export type AgencyZoomEndpointInput = AgencyZoomEndpointInputs[keyof AgencyZoomEndpointInputs] & {
	// Index signature required: factory helpers (resolvePath, buildQuery, requestBody) access
	// fields by dynamic string keys; stricter per-key typing is not feasible across all 99 ops.
	[key: string]: unknown;
};

Rule Used: What: All uses of any or unknown must be accom... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  • P2 packages/agencyzoom/client.ts:9unknown field without explanatory comment
    — the rule requires a comment alongside every unknown usage. body is typed as unknown to accept arbitrary API payloads, but there is no comment recording that rationale.
	// body is `unknown` because AgencyZoom response error payloads vary by endpoint and are not schema-validated here.
	public readonly body?: unknown;

Rule Used: What: All uses of any or unknown must be accom... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

If anything remains after your next push, a bot commit will clean it up; a maintainer always does the final review and merge.

@github-actions github-actions Bot added the bot:round-1 Review bot posted consolidated findings label Aug 7, 2026
Assert method/URL for deletes Greptile flagged so miswired paths fail CI.
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

Comment thread packages/agencyzoom/endpoints/cache-sync.ts Outdated
@github-actions github-actions Bot added the bot:round-2 Review bot pushed an automated fix label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Remaining findings are being fixed by a bot commit — it will be re-reviewed automatically.

Point getAListOfRecycleEvents at /leads/{leadId}/recycle-events and
evict task cache for POST destructive deletes like batchDeleteTask.
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

Comment thread packages/agencyzoom/endpoints/types.ts Outdated
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Maintainer review needed

Automated rounds are exhausted. Remaining findings:

  • P1 packages/agencyzoom/endpoints/types.tstaskId silently dropped from updateTask body
    The updateTask route declares pathParams: ['taskId'], so the factory's requestBody helper filters taskId out before building the JSON body. But the route's own description explicitly states the request body "must also contain taskId". A call like tasks.updateTask(ctx, { taskId: 123, title: 'Call' }) produces PUT /tasks/123 with body { title: 'Call' } — the required taskId is missing from the body and the AgencyZoom API will reject it.

The only working path today is to use the explicit body-override field: { taskId: 123, body: { taskId: 123, title: 'Call' } }, but the schema gives no indication of this.

Rule Used: Every endpoint must validate inputs and outputs wi... (source)

  • P1 packages/agencyzoom/endpoints/types.tsupdateTagsForAPolicy schema marks required fields as optional
    The route description says the endpoint requires tagNames and identification by either policyId or amsPolicyId. All three fields are .optional() in UpdateTagsForAPolicyInputSchema, so calling updateTagsForAPolicy(ctx, {}) passes Zod validation cleanly but sends an empty body to the AgencyZoom API — resulting in a silent 4xx failure at runtime. The same pattern was fixed for batchCreateLead (leadDataRequests now required); updateTagsForAPolicy has the same gap. At minimum tagNames should be .string() (non-optional), and a discriminated-union or .refine() should enforce that at least one of policyId/amsPolicyId is present.

Rule Used: Every endpoint must validate inputs and outputs wi... (source)

@github-actions github-actions Bot added the needs-maintainer Automated rounds exhausted - human review needed label Aug 7, 2026
Allow login/SSO without a prior JWT, omit Bearer when empty, and map
concrete Zod responses for auth/leads/customers/tasks/opportunities.
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

Comment thread packages/agencyzoom/endpoints/types.ts
Dhirenderchoudhary and others added 4 commits August 7, 2026 19:12
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Match AgencyZoom wire-case firstname/lastname and reject empty
batchCreateLead payloads missing leadDataRequests.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (3)
packages/agencyzoom/endpoints/types.ts (2)

1794-1797: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a compile-time check that both registries cover every route key.

AgencyZoomEndpointInputSchemas and AgencyZoomEndpointOutputSchemas are plain object literals. packages/agencyzoom/endpoints/index.ts indexes them by route.key at Lines 54-55. If a route is added to agencyZoomRoutes without a matching schema entry, the lookup returns undefined at runtime instead of failing the build.

Add a satisfies constraint keyed off the route union to catch this at compile time.

♻️ Proposed guard
+import type { AgencyZoomRoutes } from './routes';
+
+type AgencyZoomRouteKey = AgencyZoomRoutes[number]['key'];
+
 export const AgencyZoomEndpointInputSchemas = {
 	authenticateForJwtviaV4Sso: AuthenticateForJwtviaV4SsoInputSchema,
-} as const;
+} as const satisfies Record<AgencyZoomRouteKey, z.ZodType>;

Apply the same satisfies clause to AgencyZoomEndpointOutputSchemas.

Also applies to: 1905-1908

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/agencyzoom/endpoints/types.ts` around lines 1794 - 1797, Update the
AgencyZoomEndpointInputSchemas and AgencyZoomEndpointOutputSchemas registry
declarations to use a satisfies constraint keyed by the agencyZoomRoutes
route-key union, ensuring every route key has a corresponding schema entry while
preserving the existing schema values and inferred types.

1226-1232: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace .passthrough() with .loose() for consistency with Zod 4.

Every other object schema in this file uses .loose() (Lines 17, 33, 42, 55, 68, 80, 88). This schema uses .passthrough(). Zod 4 treats .passthrough() as a deprecated alias of the loose mode. Use one API across the file.

♻️ Proposed change
 const AgencyZoomSearchInputSchema = z
 	.object({
 		body: AgencyZoomOptionalBodySchema,
 		query: AgencyZoomQueryParamsSchema,
 		headers: z.record(z.string(), z.string()).optional(),
 	})
-	.passthrough();
+	.loose();

Run the following check to confirm the declared Zod version and to find other .passthrough() uses in the package:

#!/bin/bash
# Description: Confirm the Zod version and locate deprecated .passthrough() usage.
set -euo pipefail

fd -t f 'package.json' packages/agencyzoom --exec jq '{deps: .dependencies, peer: .peerDependencies, dev: .devDependencies}' {}

echo '--- passthrough vs loose usage ---'
rg -n --type=ts '\.passthrough\(\)|\.loose\(\)' packages/agencyzoom
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/agencyzoom/endpoints/types.ts` around lines 1226 - 1232, Update
AgencyZoomSearchInputSchema to use Zod 4’s .loose() instead of .passthrough(),
matching the object schemas throughout the file while preserving the schema’s
handling of unknown fields.
packages/agencyzoom/endpoints/routes.ts (1)

904-914: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider labeling POST search operations as read.

searchCustomers, searchLeads, and searchTasks only retrieve data. They use POST because AgencyZoom accepts filters in the body. The catalog assigns riskLevel: 'write' to them. The same file assigns riskLevel: 'read' to textDetailThread at Line 1009, which is also a POST retrieval. The classification is therefore inconsistent.

Risk labels gate agent confirmation prompts. A write label on a pure read forces unnecessary approvals. The same applies to searchEmailThreads, searchSmsThreads, searchLeadsCount, searchLifeAndHealthLeads, searchBusinessClassifications, serviceTicketList, getThreadDetails, and getLeadFiles.

If the project intends to label every POST as write, then textDetailThread needs the same label for consistency.

Also applies to: 928-938, 976-986

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/agencyzoom/endpoints/routes.ts` around lines 904 - 914, Update the
riskLevel classification for the POST-based retrieval operations
searchCustomers, searchLeads, and searchTasks from write to read, and apply the
same read classification to the other listed read-only operations:
searchEmailThreads, searchSmsThreads, searchLeadsCount,
searchLifeAndHealthLeads, searchBusinessClassifications, serviceTicketList,
getThreadDetails, and getLeadFiles. Preserve write labels only for operations
that mutate data.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/agencyzoom/client.ts`:
- Around line 45-50: Update the header construction in the client request flow
to remove caller-provided Content-Type and Authorization entries using
case-insensitive matching before spreading or adding plugin-owned headers.
Preserve all unrelated caller headers, then add the plugin’s JSON Content-Type
and conditional Bearer Authorization values so no differently cased reserved
header remains.

In `@packages/agencyzoom/endpoints/cache-sync.ts`:
- Around line 119-123: Update the delete path in the cache-sync handler around
cacheDeleteEntityIds and client.deleteByEntityId to normalize the explicit
input.body into the identifier lookup before iterating. Ensure requests using
body fields such as taskIds resolve their destructive identifiers and delete the
corresponding local cache entries.

In `@packages/agencyzoom/endpoints/factory.ts`:
- Around line 93-109: Update requestBody to exclude all path-parameter aliases
in addition to canonical names: for each entry in route.pathParams, add
camelToSnake(pathParam) and PATH_PARAM_ALIASES[pathParam] to the excluded path
parameter set before filtering input fields. Preserve the existing
query-parameter, control-key, and undefined-value filtering.

In `@packages/agencyzoom/endpoints/routes.ts`:
- Around line 843-853: Swap the descriptions for markThreadAsUnreadApiEndpoint
and unreadThread so each matches its route: the /email-thread/unread-thread
endpoint must describe marking an email thread, while /text-thread/unread-thread
must describe marking a text thread. Preserve the existing behavior and other
route metadata.

In `@packages/agencyzoom/schema/database.ts`:
- Around line 3-20: Align the cache schemas in
packages/agencyzoom/schema/database.ts with their API counterparts: in
AgencyZoomLead and AgencyZoomCustomer (lines 3-20), rename firstName and
lastName to firstname and lastname; in AgencyZoomTask (lines 22-29), widen
status to accept strings or numbers, matching AgencyZoomLeadSchema,
AgencyZoomCustomerSchema, and AgencyZoomTaskSchema in
packages/agencyzoom/endpoints/types.ts.

---

Nitpick comments:
In `@packages/agencyzoom/endpoints/routes.ts`:
- Around line 904-914: Update the riskLevel classification for the POST-based
retrieval operations searchCustomers, searchLeads, and searchTasks from write to
read, and apply the same read classification to the other listed read-only
operations: searchEmailThreads, searchSmsThreads, searchLeadsCount,
searchLifeAndHealthLeads, searchBusinessClassifications, serviceTicketList,
getThreadDetails, and getLeadFiles. Preserve write labels only for operations
that mutate data.

In `@packages/agencyzoom/endpoints/types.ts`:
- Around line 1794-1797: Update the AgencyZoomEndpointInputSchemas and
AgencyZoomEndpointOutputSchemas registry declarations to use a satisfies
constraint keyed by the agencyZoomRoutes route-key union, ensuring every route
key has a corresponding schema entry while preserving the existing schema values
and inferred types.
- Around line 1226-1232: Update AgencyZoomSearchInputSchema to use Zod 4’s
.loose() instead of .passthrough(), matching the object schemas throughout the
file while preserving the schema’s handling of unknown fields.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 82433ea1-8392-452f-ab1b-e9f1266156b6

📥 Commits

Reviewing files that changed from the base of the PR and between fb236ff and 5d29246.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (30)
  • packages/agencyzoom/api.test.ts
  • packages/agencyzoom/client.ts
  • packages/agencyzoom/endpoints/auth.ts
  • packages/agencyzoom/endpoints/cache-sync.ts
  • packages/agencyzoom/endpoints/contact.ts
  • packages/agencyzoom/endpoints/customers.ts
  • packages/agencyzoom/endpoints/email-threads.ts
  • packages/agencyzoom/endpoints/factory.ts
  • packages/agencyzoom/endpoints/index.ts
  • packages/agencyzoom/endpoints/leads.ts
  • packages/agencyzoom/endpoints/life.ts
  • packages/agencyzoom/endpoints/opportunities.ts
  • packages/agencyzoom/endpoints/policies.ts
  • packages/agencyzoom/endpoints/profile.ts
  • packages/agencyzoom/endpoints/reference-data.ts
  • packages/agencyzoom/endpoints/routes.ts
  • packages/agencyzoom/endpoints/service-tickets.ts
  • packages/agencyzoom/endpoints/tasks.ts
  • packages/agencyzoom/endpoints/text-threads.ts
  • packages/agencyzoom/endpoints/types.ts
  • packages/agencyzoom/endpoints/v4sso.ts
  • packages/agencyzoom/error-handlers.ts
  • packages/agencyzoom/index.ts
  • packages/agencyzoom/jest.config.json
  • packages/agencyzoom/package.json
  • packages/agencyzoom/schema/database.ts
  • packages/agencyzoom/schema/index.ts
  • packages/agencyzoom/tsconfig.json
  • packages/agencyzoom/tsup.config.ts
  • packages/corsair/core/constants.ts

Comment thread packages/agencyzoom/client.ts Outdated
Comment thread packages/agencyzoom/endpoints/cache-sync.ts
Comment thread packages/agencyzoom/endpoints/factory.ts Outdated
Comment thread packages/agencyzoom/endpoints/routes.ts
Comment thread packages/agencyzoom/schema/database.ts
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/agencyzoom/api.test.ts (1)

76-86: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert the non-empty leadDataRequests contract.

The test rejects only {}. It does not verify that { leadDataRequests: [] } is rejected. Add that assertion to prevent a regression that accepts empty batch requests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/agencyzoom/api.test.ts` around lines 76 - 86, Extend the test for
the leads.batchCreateLead input schema to assert that parsing {
leadDataRequests: [] } throws, while preserving the existing missing-field
rejection and valid non-empty request assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/agencyzoom/api.test.ts`:
- Around line 76-86: Extend the test for the leads.batchCreateLead input schema
to assert that parsing { leadDataRequests: [] } throws, while preserving the
existing missing-field rejection and valid non-empty request assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3575bdc8-5b51-436e-a0b9-7a0258999e14

📥 Commits

Reviewing files that changed from the base of the PR and between 5d29246 and 1a97c51.

📒 Files selected for processing (2)
  • packages/agencyzoom/api.test.ts
  • packages/agencyzoom/schema/database.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/agencyzoom/schema/database.ts

@Dhirenderchoudhary Dhirenderchoudhary removed the needs-maintainer Automated rounds exhausted - human review needed label Aug 7, 2026
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

Comment thread packages/agencyzoom/endpoints/types.ts Outdated
Comment thread packages/agencyzoom/endpoints/types.ts Outdated
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

@yuvrxj-afk
yuvrxj-afk merged commit f409244 into corsairdev:main Aug 7, 2026
9 of 11 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 9, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:round-1 Review bot posted consolidated findings bot:round-2 Review bot pushed an automated fix core Changes in packages/corsair

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Integration request]: AgencyZoom

3 participants