Skip to content

refactor(platforms): google adapter + registry changes recovered from worktree - #21

Merged
oratis merged 1 commit into
mainfrom
wip/platform-adapter-recovery
Aug 8, 2026
Merged

refactor(platforms): google adapter + registry changes recovered from worktree#21
oratis merged 1 commit into
mainfrom
wip/platform-adapter-recovery

Conversation

@oratis

@oratis oratis commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Recovered from an uncommitted worktree on main during a cross-project sweep.

Contents — platform adapter layer (adapter.ts, google-adapter.ts, google.ts, registry.ts) plus the agent/snapshot, cron/agent, cron/daily and reports/sync routes.

⚠️ This PR exists so the work isn't lost, not because it was reviewed. It was authored earlier and left uncommitted on main; please review the diff before merging. Secret-scanned clean.

🤖 Generated with Claude Code

…itted worktree

Found uncommitted on `main` during a cross-project worktree sweep — it lived
only on one machine, so it is committed here to be visible and reviewable
rather than lost.

Touches the platform adapter layer (adapter.ts, google-adapter.ts, google.ts,
registry.ts) and the agent/report cron + snapshot routes.

Not reviewed for correctness by the sweep. Secret-scanned clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oratis

oratis commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Review — ✅ 合并

这是这批抢救 PR 里唯一一个真正有价值的功能改动,而且写得不错。

内容:Google Ads MCC 的正确处理

核心洞察写在注释里,是对的:MCC(管理账户)自己没有 campaign,所以把它当 customer 去拉报表必然拿不到数据。改法是把 MCC 降格为纯 login-customer-id 上下文,改为迭代 workspace 显式关联的 customer ID:

// Normalized (dash-stripped) MCC id. Used purely as login-customer-id
// context — never iterated as a customer for report queries, because the
// MCC is a manager and has no campaigns of its own.
private mccId: string

几个细节做对了:

  • linkedAccountIds 加在 AdapterFactoryInput 上而非 Google 专属类型,注释还写明 TikTok / Meta business manager 后续可复用同一约定 —— 抽象层次选对了
  • 构造时统一 replace(/[-\s]/g,'') 归一化,并 filter(id => id !== this.mccId) 把 MCC 自身从迭代集合里剔掉
  • 保留了 auto-discover 回退路径(空数组 → 走 customer_client → 再退 listAccessibleCustomers),不是硬切

验证

npm test 414 passed / 32 files
tsc --noEmit 69 errors —— 但 main 上是同样的 69 个
PR 新引入的类型错误 0(错误集合逐条 diff,完全相同)

那 69 个基线错误是 Prisma 生成客户端过期Property 'competitorCreative' does not exist on type 'PrismaClient' 一类,40 处),与本 PR 无关 —— 但值得单独跑一次 prisma generate 清掉,否则 typecheck 一直是红的、失去把关意义。

一处提醒

reports/sync/route.ts 里那两个 'os' does not exist in type ReportUpdateInput 也是同一个 Prisma 过期问题(os 字段在 schema 里但生成物没有),不是这个 PR 的锅。

合并。

@oratis
oratis merged commit 4e02638 into main Aug 8, 2026
2 checks passed
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