Skip to content

feat(assets): asset extensions + per-ad-group multi-scope (split 1/4 of #34)#50

Open
illia-sapryga wants to merge 6 commits into
kLOsk:mainfrom
illia-sapryga:feat/asset-extensions-multiscope
Open

feat(assets): asset extensions + per-ad-group multi-scope (split 1/4 of #34)#50
illia-sapryga wants to merge 6 commits into
kLOsk:mainfrom
illia-sapryga:feat/asset-extensions-multiscope

Conversation

@illia-sapryga

Copy link
Copy Markdown
Contributor

Split 1/4 of #34 — asset extensions + per-ad-group multi-scope

This is the first of the four-way split you asked for in #34, rebuilt fresh on current main (not a rebase — fresh, curated commits) and registering only its own tools, so nothing references the GTM/ServiceTitan modules that aren't in this PR.

What's here

Multi-scope refactor (existing tools gain an optional ad_group_id — ad-group / campaign / customer scope, most-specific wins):

  • draft_callouts, draft_structured_snippets

New draft tools:

  • draft_call_asset (per-ad-group call assets, E.164 normalization, optional call-conversion + ad schedule)
  • draft_price_asset, draft_promotion, draft_location_asset (LOCATION_SYNC/GBP), draft_business_name_asset
  • add_ad_schedule (AD_SCHEDULE campaign criteria)

New editors:

  • update_callout, update_sitelink, update_call_asset (in-place field-mask patches)
  • update_structured_snippet, update_promotion (immutable-asset swaps: create+link new, unlink old)
  • link_asset_to_customer (promote an existing asset to account level)

v0.12 runtime compliance

  • All wrappers resolve config via current_config() — the stale-_config grep test in test_server.py passes.
  • Impl functions take config first; new operations added to the _execute_plan dispatch; handlers (client, cid, changes).
  • List/dict params use the coercion aliases (_StrList/_DictList/_DictListOpt).
  • draft_image_assets keeps main's deployment_mode() == "server" guard (untouched — the old branch never added ad-group scope to image assets, so it stays campaign-only here).

One fix pulled forward

_normalize_phone_e164 is introduced in this PR (call assets), so I fixed the bug you flagged for split (c) here rather than ship it: it now strips exactly one domestic trunk zero (not every leading zero), keeps Italy's leading zero, and maps a leading 00 international prefix to +. Tests cover all three.

Notes / intentional asymmetries (match the source branch)

  • update_promotion is campaign/customer scope only (no ad-group); update_structured_snippet supports all three.
  • add_geo_exclusions was not included — it's a targeting tool, and main already has add_negative_locations.

Tests & hygiene

  • 473 passing (+59 new in tests/test_ads_extensions.py, covering preview validation and apply-layer mutate ops across campaign / ad-group / customer scope).
  • PII scrubbed — all test phone numbers are 555-01xx, business names are placeholders, URLs are example.com.

Splits (b) conversion-action CRUD, (c) conversion uploads (folding #43), and (d) RSA update (folding #42) will follow in order.

https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s

Add an optional ad_group_id to draft_callouts and draft_structured_snippets
so an asset can link at ad-group, campaign, or customer scope (most-specific
wins). Generalize the campaign-only _apply_campaign_assets into _apply_assets,
which builds AdGroupAsset / CampaignAsset / CustomerAsset links depending on
scope. The old _apply_campaign_assets remains as a campaign-scope alias.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
draft_call_asset creates a CallAsset at ad-group / campaign / customer scope,
canonicalizing the phone number to E.164 and optionally wiring a resource-level
call conversion action and ad-schedule windows. add_ad_schedule adds
AD_SCHEDULE CampaignCriterion records. Shared _normalize_phone_e164 and
_validate_ad_schedule helpers back both tools plus the promotion tools to come.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
PromotionAsset and PriceAsset draft tools linked at ad-group / campaign /
customer scope, with full field validation (one-of money/percent, mutually
exclusive code/orders-over, ISO dates, reachable URLs, 3-8 unique price
offerings). Promotion/price enum vocabularies are pulled from the SDK so they
don't drift across API versions. update_promotion swaps the immutable asset:
create new + link, then unlink the old link found via _find_asset_link.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
update_callout, update_sitelink, and update_call_asset patch mutable
CalloutAsset / SitelinkAsset / CallAsset fields in place via a partial field
mask (only the fields the caller passes). update_structured_snippet swaps the
immutable snippet asset (create new + link at the same scope, then unlink the
old link) across ad-group / campaign / customer scope.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
…omer

draft_location_asset creates a LOCATION_SYNC AssetSet backed by a linked
Google Business Profile and links it at customer or campaign scope.
draft_business_name_asset creates a TEXT asset linked as BUSINESS_NAME.
link_asset_to_customer promotes existing assets to account level by creating
CustomerAsset link rows (no new Asset rows), validating each field_type
against the CustomerAsset-legal set.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
_normalize_phone_e164 stripped every leading zero and ignored the "00"
international access prefix. Now it removes exactly one domestic trunk
zero, keeps Italy's leading zero, and maps a leading "00" to "+".
Addresses the maintainer's split-(c) note early, since (a) is where this
helper is first introduced (call assets).

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant