@adcp/sdk 15.9.0 → 16.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/bin/adcp-identity.js +74 -0
  2. package/bin/adcp.js +2 -0
  3. package/dist/lib/adapters/keyed-account-backend.d.mts +37 -0
  4. package/dist/lib/adapters/keyed-account-backend.d.ts +37 -0
  5. package/dist/lib/adapters/keyed-account-backend.js +121 -0
  6. package/dist/lib/adapters/keyed-account-backend.mjs +94 -0
  7. package/dist/lib/adapters/keyed-account-store.d.mts +28 -0
  8. package/dist/lib/adapters/keyed-account-store.d.ts +28 -0
  9. package/dist/lib/adapters/keyed-account-store.js +227 -0
  10. package/dist/lib/adapters/keyed-account-store.mjs +203 -0
  11. package/dist/lib/core/SingleAgentClient.d.mts +16 -2
  12. package/dist/lib/core/SingleAgentClient.d.ts +16 -2
  13. package/dist/lib/core/SingleAgentClient.js +259 -62
  14. package/dist/lib/core/SingleAgentClient.mjs +261 -57
  15. package/dist/lib/core/TaskExecutor.d.mts +6 -0
  16. package/dist/lib/core/TaskExecutor.d.ts +6 -0
  17. package/dist/lib/core/TaskExecutor.js +66 -5
  18. package/dist/lib/core/TaskExecutor.mjs +71 -5
  19. package/dist/lib/core/postgres-webhook-registration-store.js +32 -5
  20. package/dist/lib/core/postgres-webhook-registration-store.mjs +32 -5
  21. package/dist/lib/core/redis-webhook-registration-store.js +23 -1
  22. package/dist/lib/core/redis-webhook-registration-store.mjs +23 -1
  23. package/dist/lib/core/webhook-registration.d.mts +7 -1
  24. package/dist/lib/core/webhook-registration.d.ts +7 -1
  25. package/dist/lib/core/webhook-registration.js +24 -2
  26. package/dist/lib/core/webhook-registration.mjs +23 -2
  27. package/dist/lib/identity-3.3/index.d.mts +10 -0
  28. package/dist/lib/identity-3.3/index.d.ts +10 -0
  29. package/dist/lib/identity-3.3/index.js +75 -0
  30. package/dist/lib/identity-3.3/index.mjs +46 -0
  31. package/dist/lib/identity-3.3/lifecycle.d.mts +113 -0
  32. package/dist/lib/identity-3.3/lifecycle.d.ts +113 -0
  33. package/dist/lib/identity-3.3/lifecycle.js +267 -0
  34. package/dist/lib/identity-3.3/lifecycle.mjs +240 -0
  35. package/dist/lib/identity-3.3/revocation.d.mts +50 -0
  36. package/dist/lib/identity-3.3/revocation.d.ts +50 -0
  37. package/dist/lib/identity-3.3/revocation.js +238 -0
  38. package/dist/lib/identity-3.3/revocation.mjs +216 -0
  39. package/dist/lib/identity-3.3/schemas.draft.d.mts +2472 -0
  40. package/dist/lib/identity-3.3/schemas.draft.d.ts +2472 -0
  41. package/dist/lib/identity-3.3/schemas.draft.js +1448 -0
  42. package/dist/lib/identity-3.3/schemas.draft.mjs +1428 -0
  43. package/dist/lib/identity-3.3/server.d.mts +34 -0
  44. package/dist/lib/identity-3.3/server.d.ts +34 -0
  45. package/dist/lib/identity-3.3/server.js +219 -0
  46. package/dist/lib/identity-3.3/server.mjs +194 -0
  47. package/dist/lib/identity-3.3/store.d.mts +24 -0
  48. package/dist/lib/identity-3.3/store.d.ts +24 -0
  49. package/dist/lib/identity-3.3/store.js +191 -0
  50. package/dist/lib/identity-3.3/store.mjs +169 -0
  51. package/dist/lib/identity-3.3/trust.d.mts +94 -0
  52. package/dist/lib/identity-3.3/trust.d.ts +94 -0
  53. package/dist/lib/identity-3.3/trust.js +278 -0
  54. package/dist/lib/identity-3.3/trust.mjs +239 -0
  55. package/dist/lib/identity-3.3/types.d.mts +127 -0
  56. package/dist/lib/identity-3.3/types.d.ts +127 -0
  57. package/dist/lib/identity-3.3/types.js +16 -0
  58. package/dist/lib/identity-3.3/types.mjs +0 -0
  59. package/dist/lib/identity-3.3/validation.d.mts +2 -0
  60. package/dist/lib/identity-3.3/validation.d.ts +2 -0
  61. package/dist/lib/identity-3.3/validation.js +125 -0
  62. package/dist/lib/identity-3.3/validation.mjs +91 -0
  63. package/dist/lib/index.d.mts +1 -1
  64. package/dist/lib/index.d.ts +1 -1
  65. package/dist/lib/reporting/azure/index.d.mts +5 -0
  66. package/dist/lib/reporting/azure/index.d.ts +5 -0
  67. package/dist/lib/reporting/azure/index.js +26 -7
  68. package/dist/lib/reporting/azure/index.mjs +26 -7
  69. package/dist/lib/reporting/bigquery/index.d.mts +80 -25
  70. package/dist/lib/reporting/bigquery/index.d.ts +80 -25
  71. package/dist/lib/reporting/bigquery/index.js +184 -81
  72. package/dist/lib/reporting/bigquery/index.mjs +182 -80
  73. package/dist/lib/reporting/gcs/adapter.d.mts +8 -1
  74. package/dist/lib/reporting/gcs/adapter.d.ts +8 -1
  75. package/dist/lib/reporting/gcs/errors.d.mts +6 -0
  76. package/dist/lib/reporting/gcs/errors.d.ts +6 -0
  77. package/dist/lib/reporting/gcs/fence.d.mts +5 -0
  78. package/dist/lib/reporting/gcs/fence.d.ts +5 -0
  79. package/dist/lib/reporting/gcs/index.d.mts +9 -0
  80. package/dist/lib/reporting/gcs/index.d.ts +9 -0
  81. package/dist/lib/reporting/gcs/reader.d.mts +27 -3
  82. package/dist/lib/reporting/gcs/reader.d.ts +27 -3
  83. package/dist/lib/reporting/gcs/row-provider.d.mts +7 -0
  84. package/dist/lib/reporting/gcs/row-provider.d.ts +7 -0
  85. package/dist/lib/reporting/gcs/row-provider.js +34 -14
  86. package/dist/lib/reporting/gcs/row-provider.mjs +34 -14
  87. package/dist/lib/reporting/ledger/change-feed.d.mts +22 -1
  88. package/dist/lib/reporting/ledger/change-feed.d.ts +22 -1
  89. package/dist/lib/reporting/ledger/index.d.mts +11 -0
  90. package/dist/lib/reporting/ledger/index.d.ts +11 -0
  91. package/dist/lib/reporting/ledger/managed-postgres.d.mts +8 -0
  92. package/dist/lib/reporting/ledger/managed-postgres.d.ts +8 -0
  93. package/dist/lib/reporting/ledger/managed-router.d.mts +27 -2
  94. package/dist/lib/reporting/ledger/managed-router.d.ts +27 -2
  95. package/dist/lib/reporting/ledger/managed.d.mts +86 -6
  96. package/dist/lib/reporting/ledger/managed.d.ts +86 -6
  97. package/dist/lib/reporting/ledger/notification-activity.d.mts +65 -3
  98. package/dist/lib/reporting/ledger/notification-activity.d.ts +65 -3
  99. package/dist/lib/reporting/ledger/object-writes.d.mts +64 -5
  100. package/dist/lib/reporting/ledger/object-writes.d.ts +64 -5
  101. package/dist/lib/reporting/ledger/postgres.d.mts +43 -9
  102. package/dist/lib/reporting/ledger/postgres.d.ts +43 -9
  103. package/dist/lib/reporting/ledger/postgres.js +43 -27
  104. package/dist/lib/reporting/ledger/postgres.mjs +43 -27
  105. package/dist/lib/reporting/ledger/row-encoding.d.mts +92 -6
  106. package/dist/lib/reporting/ledger/row-encoding.d.ts +92 -6
  107. package/dist/lib/reporting/ledger/row-encoding.js +8 -4
  108. package/dist/lib/reporting/ledger/row-encoding.mjs +6 -3
  109. package/dist/lib/reporting/ledger/row-storage-errors.d.mts +11 -1
  110. package/dist/lib/reporting/ledger/row-storage-errors.d.ts +11 -1
  111. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +19 -1
  112. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +19 -1
  113. package/dist/lib/reporting/ledger/row-storage-migration.js +133 -18
  114. package/dist/lib/reporting/ledger/row-storage-migration.mjs +133 -18
  115. package/dist/lib/reporting/ledger/row-storage-object.d.mts +103 -12
  116. package/dist/lib/reporting/ledger/row-storage-object.d.ts +103 -12
  117. package/dist/lib/reporting/ledger/row-storage-object.js +106 -31
  118. package/dist/lib/reporting/ledger/row-storage-object.mjs +104 -31
  119. package/dist/lib/reporting/ledger/row-storage.d.mts +87 -20
  120. package/dist/lib/reporting/ledger/row-storage.d.ts +87 -20
  121. package/dist/lib/reporting/ledger/row-storage.js +126 -66
  122. package/dist/lib/reporting/ledger/row-storage.mjs +129 -67
  123. package/dist/lib/reporting/ledger/schedule.d.mts +13 -0
  124. package/dist/lib/reporting/ledger/schedule.d.ts +13 -0
  125. package/dist/lib/reporting/ledger/schedule.js +24 -0
  126. package/dist/lib/reporting/ledger/schedule.mjs +23 -0
  127. package/dist/lib/reporting/ledger/types.d.mts +23 -1
  128. package/dist/lib/reporting/ledger/types.d.ts +23 -1
  129. package/dist/lib/reporting/s3/index.d.mts +5 -0
  130. package/dist/lib/reporting/s3/index.d.ts +5 -0
  131. package/dist/lib/reporting/s3/index.js +37 -14
  132. package/dist/lib/reporting/s3/index.mjs +37 -14
  133. package/dist/lib/reporting/service/index.d.mts +10 -0
  134. package/dist/lib/reporting/service/index.d.ts +10 -0
  135. package/dist/lib/reporting/service/maintenance.d.mts +28 -2
  136. package/dist/lib/reporting/service/maintenance.d.ts +28 -2
  137. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  138. package/dist/lib/server/account-sync-contract.d.mts +14 -0
  139. package/dist/lib/server/account-sync-contract.d.ts +14 -0
  140. package/dist/lib/server/account-sync-contract.js +225 -0
  141. package/dist/lib/server/account-sync-contract.mjs +197 -0
  142. package/dist/lib/server/adcp-server.js +5 -0
  143. package/dist/lib/server/adcp-server.mjs +10 -0
  144. package/dist/lib/server/auth-signature.d.mts +10 -0
  145. package/dist/lib/server/auth-signature.d.ts +10 -0
  146. package/dist/lib/server/auth-signature.js +61 -2
  147. package/dist/lib/server/auth-signature.mjs +65 -2
  148. package/dist/lib/server/auth.d.mts +6 -0
  149. package/dist/lib/server/auth.d.ts +6 -0
  150. package/dist/lib/server/auth.js +6 -0
  151. package/dist/lib/server/auth.mjs +6 -0
  152. package/dist/lib/server/create-adcp-server.d.mts +19 -5
  153. package/dist/lib/server/create-adcp-server.d.ts +19 -5
  154. package/dist/lib/server/create-adcp-server.js +238 -19
  155. package/dist/lib/server/create-adcp-server.mjs +240 -10
  156. package/dist/lib/server/decisioning/account.d.mts +24 -1
  157. package/dist/lib/server/decisioning/account.d.ts +24 -1
  158. package/dist/lib/server/decisioning/index.d.mts +1 -1
  159. package/dist/lib/server/decisioning/index.d.ts +1 -1
  160. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +0 -50
  161. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +0 -50
  162. package/dist/lib/server/decisioning/runtime/from-platform.js +61 -11
  163. package/dist/lib/server/decisioning/runtime/from-platform.mjs +65 -12
  164. package/dist/lib/server/index.d.mts +2 -0
  165. package/dist/lib/server/index.d.ts +2 -0
  166. package/dist/lib/server/index.js +12 -0
  167. package/dist/lib/server/index.mjs +12 -0
  168. package/dist/lib/server/notification-subscriptions/runtime.js +9 -1
  169. package/dist/lib/server/notification-subscriptions/runtime.mjs +9 -1
  170. package/dist/lib/server/notification-subscriptions/types.d.mts +5 -0
  171. package/dist/lib/server/notification-subscriptions/types.d.ts +5 -0
  172. package/dist/lib/server/principal/types.d.mts +1 -1
  173. package/dist/lib/server/principal/types.d.ts +1 -1
  174. package/dist/lib/server/serve.js +5 -0
  175. package/dist/lib/server/serve.mjs +5 -0
  176. package/dist/lib/server/webhook-delivery/recovery.d.mts +1 -0
  177. package/dist/lib/server/webhook-delivery/recovery.d.ts +1 -0
  178. package/dist/lib/server/webhook-delivery/recovery.js +4 -0
  179. package/dist/lib/server/webhook-delivery/recovery.mjs +4 -0
  180. package/dist/lib/server/webhook-emitter.d.mts +10 -0
  181. package/dist/lib/server/webhook-emitter.d.ts +10 -0
  182. package/dist/lib/server/webhook-emitter.js +22 -0
  183. package/dist/lib/server/webhook-emitter.mjs +22 -0
  184. package/dist/lib/signing/agent-context.d.mts +0 -5
  185. package/dist/lib/signing/agent-context.d.ts +0 -5
  186. package/dist/lib/signing/agent-context.js +9 -1
  187. package/dist/lib/signing/agent-context.mjs +9 -1
  188. package/dist/lib/signing/agent-fetch.js +27 -2
  189. package/dist/lib/signing/agent-fetch.mjs +32 -2
  190. package/dist/lib/signing/agent-resolver/canonicalize.d.mts +10 -15
  191. package/dist/lib/signing/agent-resolver/canonicalize.d.ts +10 -15
  192. package/dist/lib/signing/agent-resolver/canonicalize.js +17 -5
  193. package/dist/lib/signing/agent-resolver/canonicalize.mjs +16 -5
  194. package/dist/lib/signing/agent-resolver/index.d.mts +1 -0
  195. package/dist/lib/signing/agent-resolver/index.d.ts +1 -0
  196. package/dist/lib/signing/agent-resolver/index.js +5 -0
  197. package/dist/lib/signing/agent-resolver/index.mjs +3 -0
  198. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +3 -2
  199. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +3 -2
  200. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +30 -3
  201. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +30 -3
  202. package/dist/lib/signing/agent-resolver/strict-json.d.mts +2 -2
  203. package/dist/lib/signing/agent-resolver/strict-json.d.ts +2 -2
  204. package/dist/lib/signing/agent-resolver/strict-json.js +5 -3
  205. package/dist/lib/signing/agent-resolver/strict-json.mjs +5 -3
  206. package/dist/lib/signing/brand-jwks.d.mts +2 -2
  207. package/dist/lib/signing/brand-jwks.d.ts +2 -2
  208. package/dist/lib/signing/brand-jwks.js +4 -4
  209. package/dist/lib/signing/brand-jwks.mjs +4 -4
  210. package/dist/lib/signing/client.d.mts +1 -0
  211. package/dist/lib/signing/client.d.ts +1 -0
  212. package/dist/lib/signing/client.js +5 -0
  213. package/dist/lib/signing/client.mjs +3 -0
  214. package/dist/lib/signing/jwks-https.d.mts +1 -1
  215. package/dist/lib/signing/jwks-https.d.ts +1 -1
  216. package/dist/lib/signing/jwks-https.js +1 -1
  217. package/dist/lib/signing/jwks-https.mjs +1 -1
  218. package/dist/lib/signing/jwks.d.mts +11 -3
  219. package/dist/lib/signing/jwks.d.ts +11 -3
  220. package/dist/lib/signing/jwks.js +1 -1
  221. package/dist/lib/signing/jwks.mjs +1 -1
  222. package/dist/lib/signing/parser.d.mts +1 -1
  223. package/dist/lib/signing/parser.d.ts +1 -1
  224. package/dist/lib/signing/parser.js +5 -3
  225. package/dist/lib/signing/parser.mjs +6 -4
  226. package/dist/lib/signing/revocation.d.mts +4 -1
  227. package/dist/lib/signing/revocation.d.ts +4 -1
  228. package/dist/lib/signing/revocation.js +33 -3
  229. package/dist/lib/signing/revocation.mjs +31 -2
  230. package/dist/lib/signing/server.d.mts +1 -1
  231. package/dist/lib/signing/server.d.ts +1 -1
  232. package/dist/lib/signing/server.js +4 -0
  233. package/dist/lib/signing/server.mjs +4 -0
  234. package/dist/lib/signing/types.d.mts +3 -0
  235. package/dist/lib/signing/types.d.ts +3 -0
  236. package/dist/lib/signing/web-bot-auth.d.mts +117 -0
  237. package/dist/lib/signing/web-bot-auth.d.ts +117 -0
  238. package/dist/lib/signing/web-bot-auth.js +660 -0
  239. package/dist/lib/signing/web-bot-auth.mjs +624 -0
  240. package/dist/lib/testing/client.d.mts +1 -4
  241. package/dist/lib/testing/client.d.ts +1 -4
  242. package/dist/lib/testing/client.js +141 -20
  243. package/dist/lib/testing/client.mjs +137 -19
  244. package/dist/lib/testing/compliance/comply.js +29 -10
  245. package/dist/lib/testing/compliance/comply.mjs +37 -11
  246. package/dist/lib/testing/storyboard/account-sync-contract.d.mts +3 -0
  247. package/dist/lib/testing/storyboard/account-sync-contract.d.ts +3 -0
  248. package/dist/lib/testing/storyboard/account-sync-contract.js +79 -0
  249. package/dist/lib/testing/storyboard/account-sync-contract.mjs +55 -0
  250. package/dist/lib/testing/storyboard/default-invariants.js +2 -0
  251. package/dist/lib/testing/storyboard/default-invariants.mjs +2 -0
  252. package/dist/lib/testing/storyboard/runner.js +23 -8
  253. package/dist/lib/testing/storyboard/runner.mjs +24 -8
  254. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  255. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  256. package/dist/lib/types/adcp.d.mts +4 -0
  257. package/dist/lib/types/adcp.d.ts +4 -0
  258. package/dist/lib/types/schemas.generated.d.ts +6 -6
  259. package/dist/lib/utils/capabilities.d.mts +1 -0
  260. package/dist/lib/utils/capabilities.d.ts +1 -0
  261. package/dist/lib/utils/capabilities.js +5 -0
  262. package/dist/lib/utils/capabilities.mjs +5 -0
  263. package/dist/lib/v2/projection/creative-delivery.d.mts +3 -1
  264. package/dist/lib/v2/projection/creative-delivery.d.ts +3 -1
  265. package/dist/lib/v2/projection/creative-delivery.js +26 -10
  266. package/dist/lib/v2/projection/creative-delivery.mjs +26 -10
  267. package/dist/lib/v2/projection/index.d.mts +1 -1
  268. package/dist/lib/v2/projection/index.d.ts +1 -1
  269. package/dist/lib/v2/projection/legacy-routes.d.mts +24 -2
  270. package/dist/lib/v2/projection/legacy-routes.d.ts +24 -2
  271. package/dist/lib/v2/projection/legacy-routes.js +28 -2
  272. package/dist/lib/v2/projection/legacy-routes.mjs +26 -2
  273. package/dist/lib/validation/schema-loader.d.mts +2 -0
  274. package/dist/lib/validation/schema-loader.d.ts +2 -0
  275. package/dist/lib/validation/schema-loader.js +43 -4
  276. package/dist/lib/validation/schema-loader.mjs +39 -3
  277. package/dist/lib/version.d.mts +3 -3
  278. package/dist/lib/version.d.ts +3 -3
  279. package/dist/lib/version.js +3 -3
  280. package/dist/lib/version.mjs +3 -3
  281. package/docs/TYPE-SUMMARY.md +2 -2
  282. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +4 -0
  283. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +1 -1
  284. package/docs/guides/REPORTING-LEDGER.md +132 -46
  285. package/docs/guides/REPORTING-OPERATIONS.md +25 -4
  286. package/docs/guides/REPORTING-STABILITY.md +76 -0
  287. package/docs/guides/account-resolution.md +101 -0
  288. package/docs/llms.txt +3 -2
  289. package/docs/migration-12-to-13.md +7 -0
  290. package/docs/migration-14.x-rc-worksheet.md +4 -4
  291. package/docs/migration-agent-identity-3.3.md +355 -0
  292. package/docs/migration-agent-resolution-3.3.md +5 -0
  293. package/docs/migration-reporting-row-storage-alignment.md +137 -0
  294. package/examples/storyboards/account-sync-contract.yaml +57 -0
  295. package/package.json +15 -1
@@ -1,53 +1,3 @@
1
- /**
2
- * Build an `AdcpServer` from a `DecisioningPlatform` impl.
3
- *
4
- * v6.0 alpha entry point. Translates the per-specialism platform interface
5
- * into the framework's existing handler-style config and delegates to
6
- * `createAdcpServer()`. This means every framework primitive — idempotency,
7
- * RFC 9421 signing, governance, schema validation, state store, MCP/A2A
8
- * wire mapping, sandbox boundary — applies unchanged. The new code is the
9
- * adapter shim, not a forked runtime.
10
- *
11
- * **Adopter shape (unified hybrid):** each HITL-eligible tool is a single
12
- * method. The method returns the wire success arm (sync fast path) OR
13
- * `ctx.handoffToTask(fn)` to promote the call to a background task (HITL
14
- * slow path). Adopters branch per-call; framework detects the `TaskHandoff`
15
- * marker and dispatches accordingly:
16
- *
17
- * - Sync path: framework awaits the return value in foreground; projects
18
- * it to the wire success arm. `throw new AdcpError(...)` projects to
19
- * the wire `adcp_error` envelope.
20
- * - HITL path: framework detects the `TaskHandoff` marker, allocates
21
- * `taskId`, returns the submitted envelope to the buyer immediately,
22
- * then runs the handoff function in background. The function's return
23
- * value becomes the task's terminal `result`; `taskCtx.reject(...)`
24
- * becomes a business `rejected` result, and thrown `AdcpError` becomes
25
- * the terminal `error`.
26
- *
27
- * Generic thrown errors (`Error`, `TypeError`) fall through to the
28
- * framework's `SERVICE_UNAVAILABLE` mapping.
29
- *
30
- * **Wired surface (6.0):** `SalesPlatform` (14 tools — 3 required core +
31
- * 11 optional; unified hybrid on `create_media_buy` / `sync_creatives`),
32
- * `CreativeBuilderPlatform` (build_creative / sync_creatives unified
33
- * hybrid, optional preview_creative sync-only, optional refineCreative),
34
- * `AudiencePlatform.syncAudiences`, `SignalsPlatform` (get_signals /
35
- * activate_signal), `AccountStore` (reportUsage, getAccountFinancials),
36
- * `ContentStandardsPlatform`, `CampaignGovernancePlatform`,
37
- * `TenantRegistry` (multi-tenant health), `createPostgresTaskRegistry`,
38
- * `tasks/get` wire handler, per-server + module-level `publishStatusChange`.
39
- *
40
- * **Still deferred (rc.1+):** MCP Resources subscription projection for
41
- * `publishStatusChange`. The no-account tool surface (`preview_creative`,
42
- * `list_creative_formats`, `provide_performance_feedback`) is now typed
43
- * via `NoAccountCtx<TCtxMeta>` — handlers receive `ctx.account: Account |
44
- * undefined` and must narrow before reading `ctx_metadata`.
45
- *
46
- * Status: Preview / 6.0. Exported from the canonical `@adcp/sdk/server`
47
- * entry point; the decisioning implementation remains preview until GA.
48
- *
49
- * @public
50
- */
51
1
  import type { AdcpServer } from '../../adcp-server';
52
2
  import { type AdcpServerConfig, type HandlerContext } from '../../create-adcp-server';
53
3
  import type { DecisioningPlatform, RequiredPlatformsFor, RequiredCapabilitiesFor } from '../platform';
@@ -26,6 +26,8 @@ __export(from_platform_exports, {
26
26
  getHydratedLegacyFormatIds: () => getHydratedLegacyFormatIds
27
27
  });
28
28
  module.exports = __toCommonJS(from_platform_exports);
29
+ var import_schema_loader = require('../../../validation/schema-loader.js');
30
+ var import_account_sync_contract = require('../../account-sync-contract.js');
29
31
  var import_account_provisioning = require('../../account-provisioning.js');
30
32
  var import_account_reference_warnings = require('../../account-reference-warnings.js');
31
33
  var import_node_crypto = require("node:crypto");
@@ -1351,6 +1353,11 @@ function warnIfTruncatedMultiIdResponse(toolName, idFieldName, requestedIds, res
1351
1353
  );
1352
1354
  }
1353
1355
  function createAdcpServerFromPlatform(platform, opts) {
1356
+ if (Boolean(opts.identity33) !== (0, import_schema_loader.isIdentity33SchemaScope)())
1357
+ return (0, import_schema_loader.withIdentity33SchemaScope)(() => {
1358
+ const instance = createAdcpServerFromPlatform(platform, opts);
1359
+ return opts.identity33 ? (0, import_schema_loader.bindIdentity33SchemaScope)(instance) : instance;
1360
+ }, Boolean(opts.identity33));
1354
1361
  const runtimeLegacyOptions = opts;
1355
1362
  const legacyHandlers = {
1356
1363
  mediaBuy: opts.legacyHandlers?.mediaBuy ?? runtimeLegacyOptions.mediaBuy,
@@ -1702,7 +1709,10 @@ function createAdcpServerFromPlatform(platform, opts) {
1702
1709
  const account = assertResolvedAccountMatchesRef(
1703
1710
  platform.accounts.resolution,
1704
1711
  ref,
1705
- await platform.accounts.resolve(ref, toResolveCtx(ctx, ctx.toolName, ctx.input)),
1712
+ await platform.accounts.resolve(
1713
+ ref,
1714
+ toResolveCtx(ctx, ctx.toolName, ctx.toolName === "sync_accounts" ? structuredClone(ctx.input) : ctx.input)
1715
+ ),
1706
1716
  fwLogger,
1707
1717
  implicitIdentityPolicy
1708
1718
  );
@@ -1753,7 +1763,10 @@ function createAdcpServerFromPlatform(platform, opts) {
1753
1763
  let resolvedAccountId;
1754
1764
  const compactAccountRequired = import_create_adcp_server.COMPACT_MEDIA_BUY_MUTATION_TOOLS.has(ctx.toolName) && authenticatedPrincipalFor(ctx) !== void 0;
1755
1765
  try {
1756
- const account = await platform.accounts.resolve(void 0, toResolveCtx(ctx, ctx.toolName, ctx.input));
1766
+ const account = await platform.accounts.resolve(
1767
+ void 0,
1768
+ toResolveCtx(ctx, ctx.toolName, ctx.toolName === "sync_accounts" ? structuredClone(ctx.input) : ctx.input)
1769
+ );
1757
1770
  resolved = account != null;
1758
1771
  resolvedAccountId = account?.id;
1759
1772
  if (account == null && compactAccountRequired) {
@@ -3147,6 +3160,7 @@ async function emitTaskWebhook(opts, source) {
3147
3160
  try {
3148
3161
  const result = await opts.emitWebhook({
3149
3162
  url: opts.pushNotificationUrl,
3163
+ ...opts.pushNotificationSigningProfile && { signingProfile: opts.pushNotificationSigningProfile },
3150
3164
  payload: wirePayload,
3151
3165
  delivery_id: resolveWebhookDeliveryId(opts, taskId)
3152
3166
  });
@@ -3465,6 +3479,11 @@ function extractPushConfig(params, _logger, opts = {}) {
3465
3479
  });
3466
3480
  }
3467
3481
  const cfgObj = cfg;
3482
+ if (cfgObj.signing_profile !== void 0 && !["adcp/webhook-signing/v1", "web-bot-auth"].includes(cfgObj.signing_profile))
3483
+ throw new import_async_outcome.AdcpError("INVALID_REQUEST", {
3484
+ message: "Unsupported webhook signing profile",
3485
+ field: "push_notification_config.signing_profile"
3486
+ });
3468
3487
  const rawUrl = cfgObj.url;
3469
3488
  const rawToken = cfgObj.token;
3470
3489
  const rawOperationId = cfgObj.operation_id;
@@ -3517,6 +3536,9 @@ function extractPushConfig(params, _logger, opts = {}) {
3517
3536
  operationId = rawOperationId;
3518
3537
  }
3519
3538
  return {
3539
+ ...cfgObj.signing_profile !== void 0 && {
3540
+ signingProfile: cfgObj.signing_profile
3541
+ },
3520
3542
  ...url !== void 0 && { url },
3521
3543
  ...token !== void 0 && { token },
3522
3544
  ...operationId !== void 0 && { operationId }
@@ -3657,6 +3679,7 @@ function buildProposalNegotiationHandlers(platform, taskRegistry, taskWebhookEmi
3657
3679
  accountId: reqCtx.account.id,
3658
3680
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
3659
3681
  pushNotificationUrl: push.url,
3682
+ pushNotificationSigningProfile: push.signingProfile,
3660
3683
  pushNotificationToken: push.token,
3661
3684
  pushNotificationOperationId: push.operationId,
3662
3685
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -3720,6 +3743,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
3720
3743
  accountId,
3721
3744
  ownerScope: taskOwnerScopeFor(ctx, accountId),
3722
3745
  pushNotificationUrl: push.url,
3746
+ pushNotificationSigningProfile: push.signingProfile,
3723
3747
  pushNotificationToken: push.token,
3724
3748
  pushNotificationOperationId: push.operationId,
3725
3749
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -3812,6 +3836,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
3812
3836
  accountId: reqCtx.account.id,
3813
3837
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
3814
3838
  pushNotificationUrl: push.url,
3839
+ pushNotificationSigningProfile: push.signingProfile,
3815
3840
  pushNotificationToken: push.token,
3816
3841
  pushNotificationOperationId: push.operationId,
3817
3842
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -3914,6 +3939,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
3914
3939
  accountId,
3915
3940
  ownerScope: taskOwnerScopeFor(ctx, accountId),
3916
3941
  pushNotificationUrl: push.url,
3942
+ pushNotificationSigningProfile: push.signingProfile,
3917
3943
  pushNotificationToken: push.token,
3918
3944
  pushNotificationOperationId: push.operationId,
3919
3945
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4018,6 +4044,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
4018
4044
  accountId: reqCtx.account.id,
4019
4045
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4020
4046
  pushNotificationUrl: push.url,
4047
+ pushNotificationSigningProfile: push.signingProfile,
4021
4048
  pushNotificationToken: push.token,
4022
4049
  pushNotificationOperationId: push.operationId,
4023
4050
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4121,6 +4148,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
4121
4148
  accountId: reqCtx.account.id,
4122
4149
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4123
4150
  pushNotificationUrl: push.url,
4151
+ pushNotificationSigningProfile: push.signingProfile,
4124
4152
  pushNotificationToken: push.token,
4125
4153
  pushNotificationOperationId: push.operationId,
4126
4154
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4171,6 +4199,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
4171
4199
  accountId: reqCtx.account.id,
4172
4200
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4173
4201
  pushNotificationUrl: push.url,
4202
+ pushNotificationSigningProfile: push.signingProfile,
4174
4203
  pushNotificationToken: push.token,
4175
4204
  pushNotificationOperationId: push.operationId,
4176
4205
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4478,6 +4507,7 @@ function buildCreativeHandlers(platform, taskRegistry, taskWebhookEmit, observab
4478
4507
  accountId: reqCtx.account.id,
4479
4508
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4480
4509
  pushNotificationUrl: push.url,
4510
+ pushNotificationSigningProfile: push.signingProfile,
4481
4511
  pushNotificationToken: push.token,
4482
4512
  pushNotificationOperationId: push.operationId,
4483
4513
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4673,6 +4703,7 @@ function buildSignalsHandlers(platform, taskRegistry, taskWebhookEmit, observabi
4673
4703
  accountId,
4674
4704
  ownerScope: taskOwnerScopeFor(ctx, accountId),
4675
4705
  pushNotificationUrl: push.url,
4706
+ pushNotificationSigningProfile: push.signingProfile,
4676
4707
  pushNotificationToken: push.token,
4677
4708
  pushNotificationOperationId: push.operationId,
4678
4709
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -5417,29 +5448,48 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
5417
5448
  const handlers = {};
5418
5449
  if (accounts.upsert) {
5419
5450
  handlers.syncAccounts = async (params, ctx) => {
5451
+ const dryRun = params.dry_run === true;
5452
+ const originalCount = (params.accounts ?? []).length;
5420
5453
  const resolveCtx = toResolveCtx(ctx, "sync_accounts", params);
5421
5454
  const policy = enforceSyncAccountsCommercialPolicy(platform, params, resolveCtx);
5455
+ const requested = structuredClone(policy.acceptedEntries);
5456
+ const indices = (params.accounts ?? []).map((_, index) => index).filter((index) => !policy.failedRows.has(index));
5422
5457
  if ((0, import_account.normalizeAccountResolution)(accounts.resolution) === "derived") {
5423
- await assertDerivedSyncAccountEntriesReachable(accounts, policy.acceptedEntries, resolveCtx, logger);
5458
+ await assertDerivedSyncAccountEntriesReachable(
5459
+ accounts,
5460
+ requested,
5461
+ toResolveCtx(ctx, "sync_accounts", structuredClone(policy.acceptedParams)),
5462
+ logger
5463
+ );
5424
5464
  }
5425
5465
  const dispatchCtx = policy.failedRows.size === 0 ? resolveCtx : toResolveCtx(ctx, "sync_accounts", policy.acceptedParams);
5426
5466
  return projectSync(
5427
- () => policy.acceptedEntries.length > 0 ? accounts.upsert(policy.acceptedEntries, dispatchCtx) : Promise.resolve([]),
5428
- (rows) => {
5429
- if (rows.length !== policy.acceptedEntries.length) {
5467
+ async () => {
5468
+ const existing = await (0, import_account_sync_contract.existingSyncAccounts)(accounts, requested, dispatchCtx, logger);
5469
+ const writeParams = structuredClone(policy.acceptedParams);
5470
+ const entries = writeParams.accounts;
5471
+ const rows = entries.length > 0 ? await accounts.upsert(entries, {
5472
+ ...toResolveCtx(ctx, "sync_accounts", writeParams),
5473
+ existing: existing.map(
5474
+ (account) => account ? { ...account, billing: account.billing && { ...account.billing } } : null
5475
+ )
5476
+ }) : [];
5477
+ if (rows.length !== requested.length) {
5430
5478
  throw new Error(
5431
- `sync_accounts accounts.upsert returned ${rows.length} ${rows.length === 1 ? "row" : "rows"} for ${policy.acceptedEntries.length} accepted account ${policy.acceptedEntries.length === 1 ? "entry" : "entries"}`
5479
+ `sync_accounts accounts.upsert returned ${rows.length} ${rows.length === 1 ? "row" : "rows"} for ${requested.length} accepted account ${requested.length === 1 ? "entry" : "entries"}`
5432
5480
  );
5433
5481
  }
5482
+ return (0, import_account_sync_contract.checkSyncAccountRows)(accounts, requested, existing, rows, indices, dispatchCtx, logger);
5483
+ },
5484
+ (rows) => {
5434
5485
  if (policy.failedRows.size === 0) {
5435
5486
  return {
5436
- ...params.dry_run === true && { dry_run: true },
5487
+ ...dryRun && { dry_run: true },
5437
5488
  accounts: rows.map(import_account.toWireSyncAccountRow)
5438
5489
  };
5439
5490
  }
5440
5491
  const combined = [];
5441
5492
  let acceptedIndex = 0;
5442
- const originalCount = (params.accounts ?? []).length;
5443
5493
  for (let index = 0; index < originalCount; index += 1) {
5444
5494
  const failed = policy.failedRows.get(index);
5445
5495
  if (failed !== void 0) {
@@ -5450,7 +5500,7 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
5450
5500
  }
5451
5501
  }
5452
5502
  return {
5453
- ...params.dry_run === true && { dry_run: true },
5503
+ ...dryRun && { dry_run: true },
5454
5504
  accounts: combined.map(import_account.toWireSyncAccountRow)
5455
5505
  };
5456
5506
  }
@@ -5476,7 +5526,7 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
5476
5526
  const page = await accounts.list(filter, resolveCtx);
5477
5527
  const response = {
5478
5528
  status: "completed",
5479
- accounts: page.items.map(import_account.toWireAccount),
5529
+ accounts: await (0, import_account_sync_contract.projectAccountList)(accounts, page.items, resolveCtx, logger),
5480
5530
  pagination: {
5481
5531
  has_more: page.nextCursor != null,
5482
5532
  ...page.nextCursor != null && { cursor: page.nextCursor },
@@ -1,3 +1,9 @@
1
+ import {
2
+ isIdentity33SchemaScope,
3
+ withIdentity33SchemaScope,
4
+ bindIdentity33SchemaScope
5
+ } from "../../../validation/schema-loader.mjs";
6
+ import { existingSyncAccounts, checkSyncAccountRows, projectAccountList } from "../../account-sync-contract.mjs";
1
7
  import { isAccountProvisioningTask } from "../../account-provisioning.mjs";
2
8
  import { warnAccountReferenceDeprecation } from "../../account-reference-warnings.mjs";
3
9
  import { randomUUID } from "node:crypto";
@@ -13,7 +19,6 @@ import {
13
19
  normalizeAccountResolution,
14
20
  refAccountId,
15
21
  refHasNaturalKey,
16
- toWireAccount,
17
22
  toWireSyncAccountRow,
18
23
  toWireSyncGovernanceRow
19
24
  } from "../account.mjs";
@@ -1380,6 +1385,11 @@ function warnIfTruncatedMultiIdResponse(toolName, idFieldName, requestedIds, res
1380
1385
  );
1381
1386
  }
1382
1387
  function createAdcpServerFromPlatform(platform, opts) {
1388
+ if (Boolean(opts.identity33) !== isIdentity33SchemaScope())
1389
+ return withIdentity33SchemaScope(() => {
1390
+ const instance = createAdcpServerFromPlatform(platform, opts);
1391
+ return opts.identity33 ? bindIdentity33SchemaScope(instance) : instance;
1392
+ }, Boolean(opts.identity33));
1383
1393
  const runtimeLegacyOptions = opts;
1384
1394
  const legacyHandlers = {
1385
1395
  mediaBuy: opts.legacyHandlers?.mediaBuy ?? runtimeLegacyOptions.mediaBuy,
@@ -1731,7 +1741,10 @@ function createAdcpServerFromPlatform(platform, opts) {
1731
1741
  const account = assertResolvedAccountMatchesRef(
1732
1742
  platform.accounts.resolution,
1733
1743
  ref,
1734
- await platform.accounts.resolve(ref, toResolveCtx(ctx, ctx.toolName, ctx.input)),
1744
+ await platform.accounts.resolve(
1745
+ ref,
1746
+ toResolveCtx(ctx, ctx.toolName, ctx.toolName === "sync_accounts" ? structuredClone(ctx.input) : ctx.input)
1747
+ ),
1735
1748
  fwLogger,
1736
1749
  implicitIdentityPolicy
1737
1750
  );
@@ -1782,7 +1795,10 @@ function createAdcpServerFromPlatform(platform, opts) {
1782
1795
  let resolvedAccountId;
1783
1796
  const compactAccountRequired = COMPACT_MEDIA_BUY_MUTATION_TOOLS.has(ctx.toolName) && authenticatedPrincipalFor(ctx) !== void 0;
1784
1797
  try {
1785
- const account = await platform.accounts.resolve(void 0, toResolveCtx(ctx, ctx.toolName, ctx.input));
1798
+ const account = await platform.accounts.resolve(
1799
+ void 0,
1800
+ toResolveCtx(ctx, ctx.toolName, ctx.toolName === "sync_accounts" ? structuredClone(ctx.input) : ctx.input)
1801
+ );
1786
1802
  resolved = account != null;
1787
1803
  resolvedAccountId = account?.id;
1788
1804
  if (account == null && compactAccountRequired) {
@@ -3176,6 +3192,7 @@ async function emitTaskWebhook(opts, source) {
3176
3192
  try {
3177
3193
  const result = await opts.emitWebhook({
3178
3194
  url: opts.pushNotificationUrl,
3195
+ ...opts.pushNotificationSigningProfile && { signingProfile: opts.pushNotificationSigningProfile },
3179
3196
  payload: wirePayload,
3180
3197
  delivery_id: resolveWebhookDeliveryId(opts, taskId)
3181
3198
  });
@@ -3494,6 +3511,11 @@ function extractPushConfig(params, _logger, opts = {}) {
3494
3511
  });
3495
3512
  }
3496
3513
  const cfgObj = cfg;
3514
+ if (cfgObj.signing_profile !== void 0 && !["adcp/webhook-signing/v1", "web-bot-auth"].includes(cfgObj.signing_profile))
3515
+ throw new AdcpError("INVALID_REQUEST", {
3516
+ message: "Unsupported webhook signing profile",
3517
+ field: "push_notification_config.signing_profile"
3518
+ });
3497
3519
  const rawUrl = cfgObj.url;
3498
3520
  const rawToken = cfgObj.token;
3499
3521
  const rawOperationId = cfgObj.operation_id;
@@ -3546,6 +3568,9 @@ function extractPushConfig(params, _logger, opts = {}) {
3546
3568
  operationId = rawOperationId;
3547
3569
  }
3548
3570
  return {
3571
+ ...cfgObj.signing_profile !== void 0 && {
3572
+ signingProfile: cfgObj.signing_profile
3573
+ },
3549
3574
  ...url !== void 0 && { url },
3550
3575
  ...token !== void 0 && { token },
3551
3576
  ...operationId !== void 0 && { operationId }
@@ -3686,6 +3711,7 @@ function buildProposalNegotiationHandlers(platform, taskRegistry, taskWebhookEmi
3686
3711
  accountId: reqCtx.account.id,
3687
3712
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
3688
3713
  pushNotificationUrl: push.url,
3714
+ pushNotificationSigningProfile: push.signingProfile,
3689
3715
  pushNotificationToken: push.token,
3690
3716
  pushNotificationOperationId: push.operationId,
3691
3717
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -3749,6 +3775,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
3749
3775
  accountId,
3750
3776
  ownerScope: taskOwnerScopeFor(ctx, accountId),
3751
3777
  pushNotificationUrl: push.url,
3778
+ pushNotificationSigningProfile: push.signingProfile,
3752
3779
  pushNotificationToken: push.token,
3753
3780
  pushNotificationOperationId: push.operationId,
3754
3781
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -3841,6 +3868,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
3841
3868
  accountId: reqCtx.account.id,
3842
3869
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
3843
3870
  pushNotificationUrl: push.url,
3871
+ pushNotificationSigningProfile: push.signingProfile,
3844
3872
  pushNotificationToken: push.token,
3845
3873
  pushNotificationOperationId: push.operationId,
3846
3874
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -3943,6 +3971,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
3943
3971
  accountId,
3944
3972
  ownerScope: taskOwnerScopeFor(ctx, accountId),
3945
3973
  pushNotificationUrl: push.url,
3974
+ pushNotificationSigningProfile: push.signingProfile,
3946
3975
  pushNotificationToken: push.token,
3947
3976
  pushNotificationOperationId: push.operationId,
3948
3977
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4047,6 +4076,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
4047
4076
  accountId: reqCtx.account.id,
4048
4077
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4049
4078
  pushNotificationUrl: push.url,
4079
+ pushNotificationSigningProfile: push.signingProfile,
4050
4080
  pushNotificationToken: push.token,
4051
4081
  pushNotificationOperationId: push.operationId,
4052
4082
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4150,6 +4180,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
4150
4180
  accountId: reqCtx.account.id,
4151
4181
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4152
4182
  pushNotificationUrl: push.url,
4183
+ pushNotificationSigningProfile: push.signingProfile,
4153
4184
  pushNotificationToken: push.token,
4154
4185
  pushNotificationOperationId: push.operationId,
4155
4186
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4200,6 +4231,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
4200
4231
  accountId: reqCtx.account.id,
4201
4232
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4202
4233
  pushNotificationUrl: push.url,
4234
+ pushNotificationSigningProfile: push.signingProfile,
4203
4235
  pushNotificationToken: push.token,
4204
4236
  pushNotificationOperationId: push.operationId,
4205
4237
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4507,6 +4539,7 @@ function buildCreativeHandlers(platform, taskRegistry, taskWebhookEmit, observab
4507
4539
  accountId: reqCtx.account.id,
4508
4540
  ownerScope: taskOwnerScopeFor(ctx, reqCtx.account.id),
4509
4541
  pushNotificationUrl: push.url,
4542
+ pushNotificationSigningProfile: push.signingProfile,
4510
4543
  pushNotificationToken: push.token,
4511
4544
  pushNotificationOperationId: push.operationId,
4512
4545
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -4702,6 +4735,7 @@ function buildSignalsHandlers(platform, taskRegistry, taskWebhookEmit, observabi
4702
4735
  accountId,
4703
4736
  ownerScope: taskOwnerScopeFor(ctx, accountId),
4704
4737
  pushNotificationUrl: push.url,
4738
+ pushNotificationSigningProfile: push.signingProfile,
4705
4739
  pushNotificationToken: push.token,
4706
4740
  pushNotificationOperationId: push.operationId,
4707
4741
  servedAdcpVersion: ctx.servedAdcpVersion,
@@ -5446,29 +5480,48 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
5446
5480
  const handlers = {};
5447
5481
  if (accounts.upsert) {
5448
5482
  handlers.syncAccounts = async (params, ctx) => {
5483
+ const dryRun = params.dry_run === true;
5484
+ const originalCount = (params.accounts ?? []).length;
5449
5485
  const resolveCtx = toResolveCtx(ctx, "sync_accounts", params);
5450
5486
  const policy = enforceSyncAccountsCommercialPolicy(platform, params, resolveCtx);
5487
+ const requested = structuredClone(policy.acceptedEntries);
5488
+ const indices = (params.accounts ?? []).map((_, index) => index).filter((index) => !policy.failedRows.has(index));
5451
5489
  if (normalizeAccountResolution(accounts.resolution) === "derived") {
5452
- await assertDerivedSyncAccountEntriesReachable(accounts, policy.acceptedEntries, resolveCtx, logger);
5490
+ await assertDerivedSyncAccountEntriesReachable(
5491
+ accounts,
5492
+ requested,
5493
+ toResolveCtx(ctx, "sync_accounts", structuredClone(policy.acceptedParams)),
5494
+ logger
5495
+ );
5453
5496
  }
5454
5497
  const dispatchCtx = policy.failedRows.size === 0 ? resolveCtx : toResolveCtx(ctx, "sync_accounts", policy.acceptedParams);
5455
5498
  return projectSync(
5456
- () => policy.acceptedEntries.length > 0 ? accounts.upsert(policy.acceptedEntries, dispatchCtx) : Promise.resolve([]),
5457
- (rows) => {
5458
- if (rows.length !== policy.acceptedEntries.length) {
5499
+ async () => {
5500
+ const existing = await existingSyncAccounts(accounts, requested, dispatchCtx, logger);
5501
+ const writeParams = structuredClone(policy.acceptedParams);
5502
+ const entries = writeParams.accounts;
5503
+ const rows = entries.length > 0 ? await accounts.upsert(entries, {
5504
+ ...toResolveCtx(ctx, "sync_accounts", writeParams),
5505
+ existing: existing.map(
5506
+ (account) => account ? { ...account, billing: account.billing && { ...account.billing } } : null
5507
+ )
5508
+ }) : [];
5509
+ if (rows.length !== requested.length) {
5459
5510
  throw new Error(
5460
- `sync_accounts accounts.upsert returned ${rows.length} ${rows.length === 1 ? "row" : "rows"} for ${policy.acceptedEntries.length} accepted account ${policy.acceptedEntries.length === 1 ? "entry" : "entries"}`
5511
+ `sync_accounts accounts.upsert returned ${rows.length} ${rows.length === 1 ? "row" : "rows"} for ${requested.length} accepted account ${requested.length === 1 ? "entry" : "entries"}`
5461
5512
  );
5462
5513
  }
5514
+ return checkSyncAccountRows(accounts, requested, existing, rows, indices, dispatchCtx, logger);
5515
+ },
5516
+ (rows) => {
5463
5517
  if (policy.failedRows.size === 0) {
5464
5518
  return {
5465
- ...params.dry_run === true && { dry_run: true },
5519
+ ...dryRun && { dry_run: true },
5466
5520
  accounts: rows.map(toWireSyncAccountRow)
5467
5521
  };
5468
5522
  }
5469
5523
  const combined = [];
5470
5524
  let acceptedIndex = 0;
5471
- const originalCount = (params.accounts ?? []).length;
5472
5525
  for (let index = 0; index < originalCount; index += 1) {
5473
5526
  const failed = policy.failedRows.get(index);
5474
5527
  if (failed !== void 0) {
@@ -5479,7 +5532,7 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
5479
5532
  }
5480
5533
  }
5481
5534
  return {
5482
- ...params.dry_run === true && { dry_run: true },
5535
+ ...dryRun && { dry_run: true },
5483
5536
  accounts: combined.map(toWireSyncAccountRow)
5484
5537
  };
5485
5538
  }
@@ -5505,7 +5558,7 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
5505
5558
  const page = await accounts.list(filter, resolveCtx);
5506
5559
  const response = {
5507
5560
  status: "completed",
5508
- accounts: page.items.map(toWireAccount),
5561
+ accounts: await projectAccountList(accounts, page.items, resolveCtx, logger),
5509
5562
  pagination: {
5510
5563
  has_more: page.nextCursor != null,
5511
5564
  ...page.nextCursor != null && { cursor: page.nextCursor },
@@ -99,6 +99,8 @@ export type { TranslationMap, UpstreamAuth, AuthContext, UpstreamCallOptions, Up
99
99
  export { InMemoryImplicitAccountStore, defaultImplicitKeyFn, type ImplicitAccountStoreOptions, } from '../adapters/implicit-account-store.mjs';
100
100
  export { createOAuthPassthroughResolver, type OAuthPassthroughResolverOptions, } from '../adapters/oauth-passthrough-resolver.mjs';
101
101
  export { createRosterAccountStore, type RosterAccountStoreOptions } from '../adapters/roster-account-store.mjs';
102
+ export { createKeyedAccountStore, type KeyedAccountStoreOptions } from '../adapters/keyed-account-store.mjs';
103
+ export { memoryKeyedAccountBackend, pgKeyedAccountBackend, redisKeyedAccountBackend, getKeyedAccountMigration, type KeyedAccountBackend, type KeyedAccountRecord, type KeyedAccountSnapshot, type PgKeyedAccountBackendOptions, type KeyedAccountRedisClient, } from '../adapters/keyed-account-backend.mjs';
102
104
  export { createDerivedAccountStore, type DerivedAccountStoreOptions, type DerivedAccountStoreBaseOptions, type DerivedSingletonAccountStoreOptions, type DerivedRosterAccountStoreOptions, } from '../adapters/derived-account-store.mjs';
103
105
  export { ConformanceClient, WebSocketTransport, type ConformanceClientOptions, type ConformanceStatus, } from './socket-mode/index.mjs';
104
106
  export { mediaBuyActionResolver } from './media-buy-action-resolver.mjs';
@@ -99,6 +99,8 @@ export type { TranslationMap, UpstreamAuth, AuthContext, UpstreamCallOptions, Up
99
99
  export { InMemoryImplicitAccountStore, defaultImplicitKeyFn, type ImplicitAccountStoreOptions, } from '../adapters/implicit-account-store';
100
100
  export { createOAuthPassthroughResolver, type OAuthPassthroughResolverOptions, } from '../adapters/oauth-passthrough-resolver';
101
101
  export { createRosterAccountStore, type RosterAccountStoreOptions } from '../adapters/roster-account-store';
102
+ export { createKeyedAccountStore, type KeyedAccountStoreOptions } from '../adapters/keyed-account-store';
103
+ export { memoryKeyedAccountBackend, pgKeyedAccountBackend, redisKeyedAccountBackend, getKeyedAccountMigration, type KeyedAccountBackend, type KeyedAccountRecord, type KeyedAccountSnapshot, type PgKeyedAccountBackendOptions, type KeyedAccountRedisClient, } from '../adapters/keyed-account-backend';
102
104
  export { createDerivedAccountStore, type DerivedAccountStoreOptions, type DerivedAccountStoreBaseOptions, type DerivedSingletonAccountStoreOptions, type DerivedRosterAccountStoreOptions, } from '../adapters/derived-account-store';
103
105
  export { ConformanceClient, WebSocketTransport, type ConformanceClientOptions, type ConformanceStatus, } from './socket-mode';
104
106
  export { mediaBuyActionResolver } from './media-buy-action-resolver';
@@ -116,6 +116,7 @@ __export(server_exports, {
116
116
  createGovernanceAgentJwksResolver: () => import_governance2.createGovernanceAgentJwksResolver,
117
117
  createGovernanceEnforcementMiddleware: () => import_governance2.createGovernanceEnforcementMiddleware,
118
118
  createIdempotencyStore: () => import_idempotency.createIdempotencyStore,
119
+ createKeyedAccountStore: () => import_keyed_account_store.createKeyedAccountStore,
119
120
  createLazyBackend: () => import_idempotency.createLazyBackend,
120
121
  createMediaBuyStore: () => import_media_buy_store.createMediaBuyStore,
121
122
  createOAuthPassthroughResolver: () => import_oauth_passthrough_resolver.createOAuthPassthroughResolver,
@@ -154,6 +155,7 @@ __export(server_exports, {
154
155
  getAdcpStateMigration: () => import_postgres_state_store.getAdcpStateMigration,
155
156
  getCtxMetadataMigration: () => import_ctx_metadata.getCtxMetadataMigration,
156
157
  getIdempotencyMigration: () => import_idempotency.getIdempotencyMigration,
158
+ getKeyedAccountMigration: () => import_keyed_account_backend.getKeyedAccountMigration,
157
159
  getMcpTasksMigration: () => import_postgres_task_store.getMcpTasksMigration,
158
160
  getNotificationSubscriptionMigration: () => import_notification_subscriptions.getNotificationSubscriptionMigration,
159
161
  getServeRequestContext: () => import_auth.getServeRequestContext,
@@ -217,6 +219,7 @@ __export(server_exports, {
217
219
  mediaBuyActionResolver: () => import_media_buy_action_resolver.mediaBuyActionResolver,
218
220
  memoryBackend: () => import_idempotency.memoryBackend,
219
221
  memoryCtxMetadataStore: () => import_ctx_metadata.memoryCtxMetadataStore,
222
+ memoryKeyedAccountBackend: () => import_keyed_account_backend.memoryKeyedAccountBackend,
220
223
  memoryNotificationSubscriptionStore: () => import_notification_subscriptions.memoryNotificationSubscriptionStore,
221
224
  memoryWebhookDeliveryRecoveryBackend: () => import_webhook_delivery.memoryWebhookDeliveryRecoveryBackend,
222
225
  memoryWebhookDeliveryStore: () => import_webhook_emitter.memoryWebhookDeliveryStore,
@@ -232,6 +235,7 @@ __export(server_exports, {
232
235
  patchWithRetry: () => import_state_store.patchWithRetry,
233
236
  pgBackend: () => import_idempotency.pgBackend,
234
237
  pgCtxMetadataStore: () => import_ctx_metadata.pgCtxMetadataStore,
238
+ pgKeyedAccountBackend: () => import_keyed_account_backend.pgKeyedAccountBackend,
235
239
  pgNotificationSubscriptionStore: () => import_notification_subscriptions.pgNotificationSubscriptionStore,
236
240
  pgWebhookDeliveryRecoveryBackend: () => import_webhook_delivery.pgWebhookDeliveryRecoveryBackend,
237
241
  pgWebhookDeliveryStore: () => import_webhook_delivery.pgWebhookDeliveryStore,
@@ -246,6 +250,7 @@ __export(server_exports, {
246
250
  proposalTermsDigest: () => import_verification.proposalTermsDigest,
247
251
  redisBackend: () => import_idempotency.redisBackend,
248
252
  redisCtxMetadataStore: () => import_ctx_metadata.redisCtxMetadataStore,
253
+ redisKeyedAccountBackend: () => import_keyed_account_backend.redisKeyedAccountBackend,
249
254
  redisWebhookDeliveryRecoveryBackend: () => import_webhook_delivery.redisWebhookDeliveryRecoveryBackend,
250
255
  redisWebhookDeliveryStore: () => import_webhook_delivery.redisWebhookDeliveryStore,
251
256
  registerAdcpTaskTool: () => import_tasks.registerAdcpTaskTool,
@@ -343,6 +348,8 @@ var import_upstream_helpers = require('./upstream-helpers.js');
343
348
  var import_implicit_account_store = require('../adapters/implicit-account-store.js');
344
349
  var import_oauth_passthrough_resolver = require('../adapters/oauth-passthrough-resolver.js');
345
350
  var import_roster_account_store = require('../adapters/roster-account-store.js');
351
+ var import_keyed_account_store = require('../adapters/keyed-account-store.js');
352
+ var import_keyed_account_backend = require('../adapters/keyed-account-backend.js');
346
353
  var import_derived_account_store = require('../adapters/derived-account-store.js');
347
354
  var import_socket_mode = require('./socket-mode/index.js');
348
355
  var import_media_buy_action_resolver = require('./media-buy-action-resolver.js');
@@ -445,6 +452,7 @@ var import_media_buy_action_resolver = require('./media-buy-action-resolver.js')
445
452
  createGovernanceAgentJwksResolver,
446
453
  createGovernanceEnforcementMiddleware,
447
454
  createIdempotencyStore,
455
+ createKeyedAccountStore,
448
456
  createLazyBackend,
449
457
  createMediaBuyStore,
450
458
  createOAuthPassthroughResolver,
@@ -483,6 +491,7 @@ var import_media_buy_action_resolver = require('./media-buy-action-resolver.js')
483
491
  getAdcpStateMigration,
484
492
  getCtxMetadataMigration,
485
493
  getIdempotencyMigration,
494
+ getKeyedAccountMigration,
486
495
  getMcpTasksMigration,
487
496
  getNotificationSubscriptionMigration,
488
497
  getServeRequestContext,
@@ -546,6 +555,7 @@ var import_media_buy_action_resolver = require('./media-buy-action-resolver.js')
546
555
  mediaBuyActionResolver,
547
556
  memoryBackend,
548
557
  memoryCtxMetadataStore,
558
+ memoryKeyedAccountBackend,
549
559
  memoryNotificationSubscriptionStore,
550
560
  memoryWebhookDeliveryRecoveryBackend,
551
561
  memoryWebhookDeliveryStore,
@@ -561,6 +571,7 @@ var import_media_buy_action_resolver = require('./media-buy-action-resolver.js')
561
571
  patchWithRetry,
562
572
  pgBackend,
563
573
  pgCtxMetadataStore,
574
+ pgKeyedAccountBackend,
564
575
  pgNotificationSubscriptionStore,
565
576
  pgWebhookDeliveryRecoveryBackend,
566
577
  pgWebhookDeliveryStore,
@@ -575,6 +586,7 @@ var import_media_buy_action_resolver = require('./media-buy-action-resolver.js')
575
586
  proposalTermsDigest,
576
587
  redisBackend,
577
588
  redisCtxMetadataStore,
589
+ redisKeyedAccountBackend,
578
590
  redisWebhookDeliveryRecoveryBackend,
579
591
  redisWebhookDeliveryStore,
580
592
  registerAdcpTaskTool,
@@ -287,6 +287,13 @@ import {
287
287
  createOAuthPassthroughResolver
288
288
  } from "../adapters/oauth-passthrough-resolver.mjs";
289
289
  import { createRosterAccountStore } from "../adapters/roster-account-store.mjs";
290
+ import { createKeyedAccountStore } from "../adapters/keyed-account-store.mjs";
291
+ import {
292
+ memoryKeyedAccountBackend,
293
+ pgKeyedAccountBackend,
294
+ redisKeyedAccountBackend,
295
+ getKeyedAccountMigration
296
+ } from "../adapters/keyed-account-backend.mjs";
290
297
  import {
291
298
  createDerivedAccountStore
292
299
  } from "../adapters/derived-account-store.mjs";
@@ -393,6 +400,7 @@ export {
393
400
  createGovernanceAgentJwksResolver,
394
401
  createGovernanceEnforcementMiddleware,
395
402
  createIdempotencyStore,
403
+ createKeyedAccountStore,
396
404
  createLazyBackend,
397
405
  createMediaBuyStore,
398
406
  createOAuthPassthroughResolver,
@@ -431,6 +439,7 @@ export {
431
439
  getAdcpStateMigration,
432
440
  getCtxMetadataMigration,
433
441
  getIdempotencyMigration,
442
+ getKeyedAccountMigration,
434
443
  getMcpTasksMigration,
435
444
  getNotificationSubscriptionMigration,
436
445
  getServeRequestContext,
@@ -494,6 +503,7 @@ export {
494
503
  mediaBuyActionResolver,
495
504
  memoryBackend,
496
505
  memoryCtxMetadataStore,
506
+ memoryKeyedAccountBackend,
497
507
  memoryNotificationSubscriptionStore,
498
508
  memoryWebhookDeliveryRecoveryBackend,
499
509
  memoryWebhookDeliveryStore,
@@ -509,6 +519,7 @@ export {
509
519
  patchWithRetry,
510
520
  pgBackend,
511
521
  pgCtxMetadataStore,
522
+ pgKeyedAccountBackend,
512
523
  pgNotificationSubscriptionStore,
513
524
  pgWebhookDeliveryRecoveryBackend,
514
525
  pgWebhookDeliveryStore,
@@ -523,6 +534,7 @@ export {
523
534
  proposalTermsDigest,
524
535
  redisBackend,
525
536
  redisCtxMetadataStore,
537
+ redisKeyedAccountBackend,
526
538
  redisWebhookDeliveryRecoveryBackend,
527
539
  redisWebhookDeliveryStore,
528
540
  registerAdcpTaskTool,