feat(api): activate the ads public API scope - #1132
Merged
Merged
Conversation
Wire the previously-inert `ads` workspace-token scope to real endpoints: conversion-rule CRUD, CTWA/CTM/CTID funnel and CAPI-delivery reads, conversion export, ad-account reads, and the full messaging-ad campaign lifecycle. Every handler calls the same business-service method its private/UI counterpart uses. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds name/description/globs frontmatter to data-access.md, git.md, and no-dynamic-import.md so the rules are self-describing and glob-scoped for automatic loading; sync-agent-instructions.mjs now strips the frontmatter block before mirroring git.md's body into generated docs.
Closes gaps left by the initial ads public API activation: - read_only tokens can no longer force an uncached Graph refresh via the `refresh` param on campaign/insights/ad-account routes, and gain a narrow POST-for-read allowlist entry for the insights endpoint - creative video upload accepts a lower base64 cap on the public route than the session-gated private one - rule/status mutations return explicit 422s via `safeParse` instead of letting a raw ZodError fall through to a generic 500, and use the correct 201/204 success statuses - CAPI status transitions are now guarded by an explicit pending -> terminal state machine in the service instead of being writable by any caller - worker's send-conversion-event handler calls adsConversionService instead of importing the repository directly, keeping the action/handler -> service -> repository chain intact - export/retarget pagination now derives `hasMore` from the repository's own limit+1 over-fetch instead of `rows.length === limit`, fixing a false "no more pages" result when a page happens to fill exactly - contact-filter CTWA retarget predicate generalizes the channel-omitted legacy-caller behavior from WhatsApp-only to Messenger/Instagram as well
realcodesiman
force-pushed
the
realcodesiman/feat-ads-scope-public-api
branch
from
September 12, 2026 04:04
487109a to
4002107
Compare
Delivers the remaining ads public-API surface and fixes the layering gaps the prior activation left behind: - facebook (workspace-wide Lead Ads) no longer falls through to the any-channel predicate for the `conversations` segment/count, in both the contact-filter query and the funnel service - Facebook Ads Graph cached reads, channel-ad-account resolution, and the merged analytics (funnel + Meta spend) orchestration move from apps/builder into packages/business, closing the "packages/business cannot import the builder's copy" gap that blocked a public handler - retarget-audience sync and messaging-ads disconnect (with token revoke) become business services instead of server-action-only logic - new public endpoints on the `ads` token scope: merged analytics overview/timeseries, single conversion-event read, custom-audience listing, retarget-audience sync, and messaging-ads connection list/disconnect - regression coverage for the facebook/conversations fix and the new services/endpoints
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.
Summary
adsworkspace-token scope shipped in the enum/registry/i18n from day one but had no endpoints wired to it — a token scoped to["ads"]reached nothing.packages/businessservice method its private/UI counterpart already calls, per.agents/rules/data-access.md.Changes
apps/builder/src/features/ads/api/public.ts+schema/public.ts— conversion rules, funnel, CAPI delivery, export, ad-account readsapps/builder/src/features/ads-campaign/api/public.ts+schema/public.ts— messaging-ad campaign lifecycleapps/builder/src/routers/public.ts— mountsadson the public routerpackages/business/src/ads-conversion/service.ts— addsfindOrFail(single-rule read with the standard not-found contract, reused by the newGET /v1/ads/conversion-rules/{id}handler)docs/developer/workspace-api-tokens.md— endpoint-to-scope table and the two invariants specific to this scope (noassertWorkspaceSuperAdminon the token path;createdByalways null for token-created campaigns)ads-public-scope.test.ts(router wiring),ads-public-api.test.ts,ads-campaign-public-api.test.ts(handler behavior, including the missing-session-user regression guard), plusads-conversion-rule.service.test.tscoverage forfindOrFailTest plan
pnpm lintpnpm --filter builder check-typespnpm --filter @chatbotx.io/business check-typespnpm --filter builder test(full suite, 3355 passed)pnpm --filter @chatbotx.io/business test(full suite, 2145 passed)