@adcp/sdk 17.0.0-beta.1 → 17.0.0-beta.2

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 (239) hide show
  1. package/dist/lib/adapters/keyed-account-store.js +1 -1
  2. package/dist/lib/adapters/keyed-account-store.mjs +1 -1
  3. package/dist/lib/adapters/version/3.0/brand-fields.d.mts +7 -1
  4. package/dist/lib/adapters/version/3.0/brand-fields.d.ts +7 -1
  5. package/dist/lib/adapters/version/3.0/brand-fields.js +139 -3
  6. package/dist/lib/adapters/version/3.0/brand-fields.mjs +136 -2
  7. package/dist/lib/adapters/version/3.0/index.js +6 -0
  8. package/dist/lib/adapters/version/3.0/index.mjs +7 -1
  9. package/dist/lib/adapters/version/types.d.mts +5 -0
  10. package/dist/lib/adapters/version/types.d.ts +5 -0
  11. package/dist/lib/canonical-references/index.js +2 -0
  12. package/dist/lib/canonical-references/index.mjs +2 -0
  13. package/dist/lib/client/account-changes.d.mts +3 -1
  14. package/dist/lib/client/account-changes.d.ts +3 -1
  15. package/dist/lib/client/account-changes.js +22 -2
  16. package/dist/lib/client/account-changes.mjs +22 -2
  17. package/dist/lib/conformance/oracle.js +3 -2
  18. package/dist/lib/conformance/oracle.mjs +3 -2
  19. package/dist/lib/core/AgentClient.d.mts +165 -1
  20. package/dist/lib/core/AgentClient.d.ts +165 -1
  21. package/dist/lib/core/AgentClient.js +446 -8
  22. package/dist/lib/core/AgentClient.mjs +446 -8
  23. package/dist/lib/core/ConversationTypes.d.mts +8 -0
  24. package/dist/lib/core/ConversationTypes.d.ts +8 -0
  25. package/dist/lib/core/ProtocolResponseParser.d.mts +1 -1
  26. package/dist/lib/core/ProtocolResponseParser.d.ts +1 -1
  27. package/dist/lib/core/ProtocolResponseParser.js +28 -18
  28. package/dist/lib/core/ProtocolResponseParser.mjs +11 -1
  29. package/dist/lib/core/SingleAgentClient.d.mts +115 -2
  30. package/dist/lib/core/SingleAgentClient.d.ts +115 -2
  31. package/dist/lib/core/SingleAgentClient.js +547 -67
  32. package/dist/lib/core/SingleAgentClient.mjs +534 -54
  33. package/dist/lib/core/TaskExecutor.d.mts +7 -0
  34. package/dist/lib/core/TaskExecutor.d.ts +7 -0
  35. package/dist/lib/core/TaskExecutor.js +18 -5
  36. package/dist/lib/core/TaskExecutor.mjs +18 -5
  37. package/dist/lib/core/task-status.d.mts +2 -0
  38. package/dist/lib/core/task-status.d.ts +2 -0
  39. package/dist/lib/core/task-status.js +11 -2
  40. package/dist/lib/core/task-status.mjs +9 -1
  41. package/dist/lib/identity-3.3/trust.d.mts +1 -4
  42. package/dist/lib/identity-3.3/trust.d.ts +1 -4
  43. package/dist/lib/identity-3.3/trust.js +34 -21
  44. package/dist/lib/identity-3.3/trust.mjs +34 -21
  45. package/dist/lib/identity-3.3/validation.js +5 -3
  46. package/dist/lib/identity-3.3/validation.mjs +6 -4
  47. package/dist/lib/index.d.mts +6 -52
  48. package/dist/lib/index.d.ts +6 -52
  49. package/dist/lib/index.js +11 -0
  50. package/dist/lib/index.mjs +7 -0
  51. package/dist/lib/media-buy/compatibility.js +6 -1
  52. package/dist/lib/media-buy/compatibility.mjs +6 -1
  53. package/dist/lib/protocols/mcp-scope.d.mts +3 -0
  54. package/dist/lib/protocols/mcp-scope.d.ts +3 -0
  55. package/dist/lib/protocols/mcp-scope.js +8 -3
  56. package/dist/lib/protocols/mcp-scope.mjs +8 -3
  57. package/dist/lib/reporting/inspection.js +1 -0
  58. package/dist/lib/reporting/inspection.mjs +1 -0
  59. package/dist/lib/reporting/ledger/coverage.d.mts +5 -0
  60. package/dist/lib/reporting/ledger/coverage.d.ts +5 -0
  61. package/dist/lib/reporting/ledger/coverage.js +37 -3
  62. package/dist/lib/reporting/ledger/coverage.mjs +36 -3
  63. package/dist/lib/reporting/ledger/handler.js +7 -4
  64. package/dist/lib/reporting/ledger/handler.mjs +7 -4
  65. package/dist/lib/reporting/ledger/producer.js +215 -69
  66. package/dist/lib/reporting/ledger/producer.mjs +217 -70
  67. package/dist/lib/reporting/ledger/schedule.d.mts +2 -2
  68. package/dist/lib/reporting/ledger/schedule.d.ts +2 -2
  69. package/dist/lib/reporting/ledger/schedule.js +8 -5
  70. package/dist/lib/reporting/ledger/schedule.mjs +8 -5
  71. package/dist/lib/reporting/ledger/status-ingest.d.mts +1 -1
  72. package/dist/lib/reporting/ledger/status-ingest.d.ts +1 -1
  73. package/dist/lib/reporting/ledger/status-ingest.js +4 -3
  74. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -3
  75. package/dist/lib/reporting/ledger/types.d.mts +36 -1
  76. package/dist/lib/reporting/ledger/types.d.ts +36 -1
  77. package/dist/lib/reporting/service/index.d.mts +14 -1
  78. package/dist/lib/reporting/service/index.d.ts +14 -1
  79. package/dist/lib/reporting/service/index.js +24 -12
  80. package/dist/lib/reporting/service/index.mjs +24 -12
  81. package/dist/lib/schemas/browser.d.mts +2 -0
  82. package/dist/lib/schemas/browser.d.ts +2 -0
  83. package/dist/lib/schemas/browser.js +3 -0
  84. package/dist/lib/schemas/browser.mjs +2 -0
  85. package/dist/lib/schemas/index.d.mts +5 -3
  86. package/dist/lib/schemas/index.d.ts +5 -3
  87. package/dist/lib/schemas/index.js +5 -0
  88. package/dist/lib/schemas/index.mjs +4 -0
  89. package/dist/lib/server/account-response-identity.d.mts +17 -0
  90. package/dist/lib/server/account-response-identity.d.ts +17 -0
  91. package/dist/lib/server/account-response-identity.js +52 -0
  92. package/dist/lib/server/account-response-identity.mjs +28 -0
  93. package/dist/lib/server/account-sync-contract.js +2 -2
  94. package/dist/lib/server/account-sync-contract.mjs +2 -2
  95. package/dist/lib/server/create-adcp-server.js +33 -20
  96. package/dist/lib/server/create-adcp-server.mjs +36 -12
  97. package/dist/lib/server/decisioning/account.d.mts +36 -10
  98. package/dist/lib/server/decisioning/account.d.ts +36 -10
  99. package/dist/lib/server/decisioning/account.js +33 -14
  100. package/dist/lib/server/decisioning/account.mjs +33 -14
  101. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +5 -5
  102. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +5 -5
  103. package/dist/lib/server/decisioning/runtime/from-platform.js +4 -4
  104. package/dist/lib/server/decisioning/runtime/from-platform.mjs +4 -4
  105. package/dist/lib/server/media-buy-store.d.mts +26 -12
  106. package/dist/lib/server/media-buy-store.d.ts +26 -12
  107. package/dist/lib/server/media-buy-store.js +69 -21
  108. package/dist/lib/server/media-buy-store.mjs +69 -21
  109. package/dist/lib/server/notification-subscriptions/runtime.d.mts +1 -1
  110. package/dist/lib/server/notification-subscriptions/runtime.d.ts +1 -1
  111. package/dist/lib/server/notification-subscriptions/runtime.js +4 -0
  112. package/dist/lib/server/notification-subscriptions/runtime.mjs +4 -0
  113. package/dist/lib/server/responses.js +9 -1
  114. package/dist/lib/server/responses.mjs +9 -1
  115. package/dist/lib/signing/agent-fetch.d.mts +1 -1
  116. package/dist/lib/signing/agent-fetch.d.ts +1 -1
  117. package/dist/lib/signing/agent-fetch.js +3 -3
  118. package/dist/lib/signing/agent-fetch.mjs +3 -3
  119. package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +60 -14
  120. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +60 -14
  121. package/dist/lib/testing/storyboard/compliance.d.mts +2 -5
  122. package/dist/lib/testing/storyboard/compliance.d.ts +2 -5
  123. package/dist/lib/testing/storyboard/compliance.js +62 -13
  124. package/dist/lib/testing/storyboard/compliance.mjs +63 -14
  125. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
  126. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
  127. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +11 -0
  128. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +10 -0
  129. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  130. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  131. package/dist/lib/types/accept-proposal.d.ts +20 -28
  132. package/dist/lib/types/asset-instances.d.mts +1 -1
  133. package/dist/lib/types/asset-instances.d.ts +1 -1
  134. package/dist/lib/types/buy-products.d.ts +20 -28
  135. package/dist/lib/types/check-governance.d.ts +20 -28
  136. package/dist/lib/types/comply-test-controller.d.ts +20 -28
  137. package/dist/lib/types/control-media-buy.d.ts +20 -28
  138. package/dist/lib/types/core.generated.d.mts +273 -184
  139. package/dist/lib/types/core.generated.d.ts +273 -184
  140. package/dist/lib/types/create-media-buy.d.ts +20 -28
  141. package/dist/lib/types/get-media-buys.d.ts +20 -28
  142. package/dist/lib/types/get-products.d.ts +20 -28
  143. package/dist/lib/types/index.d.mts +6 -1
  144. package/dist/lib/types/index.d.ts +6 -1
  145. package/dist/lib/types/index.js +6 -1
  146. package/dist/lib/types/index.mjs +4 -1
  147. package/dist/lib/types/inline-enums.generated.d.mts +30 -4
  148. package/dist/lib/types/inline-enums.generated.d.ts +30 -4
  149. package/dist/lib/types/inline-enums.generated.js +41 -2
  150. package/dist/lib/types/inline-enums.generated.mjs +28 -2
  151. package/dist/lib/types/list-products.d.ts +20 -28
  152. package/dist/lib/types/list-proposals.d.ts +20 -28
  153. package/dist/lib/types/media-buy-delivery-report.d.mts +6 -0
  154. package/dist/lib/types/media-buy-delivery-report.d.ts +6 -0
  155. package/dist/lib/types/media-buy-delivery-report.js +16 -0
  156. package/dist/lib/types/media-buy-delivery-report.mjs +0 -0
  157. package/dist/lib/types/refine-proposals.d.ts +20 -28
  158. package/dist/lib/types/request-proposals.d.ts +20 -28
  159. package/dist/lib/types/schemas.generated.d.ts +63113 -127273
  160. package/dist/lib/types/schemas.generated.js +759 -770
  161. package/dist/lib/types/schemas.generated.mjs +759 -770
  162. package/dist/lib/types/targeting-keys.generated.d.mts +4 -0
  163. package/dist/lib/types/targeting-keys.generated.d.ts +4 -0
  164. package/dist/lib/types/targeting-keys.generated.js +109 -0
  165. package/dist/lib/types/targeting-keys.generated.mjs +84 -0
  166. package/dist/lib/types/tools.generated.d.mts +2 -68
  167. package/dist/lib/types/tools.generated.d.ts +2 -68
  168. package/dist/lib/types/update-media-buy.d.ts +20 -28
  169. package/dist/lib/utils/adcp-version-config.js +5 -2
  170. package/dist/lib/utils/adcp-version-config.mjs +5 -2
  171. package/dist/lib/utils/response-unwrapper.js +6 -1
  172. package/dist/lib/utils/response-unwrapper.mjs +6 -1
  173. package/dist/lib/v2/format-schema/resolver.js +1 -1
  174. package/dist/lib/v2/format-schema/resolver.mjs +1 -1
  175. package/dist/lib/v2/projection/creative-delivery.js +104 -29
  176. package/dist/lib/v2/projection/creative-delivery.mjs +108 -29
  177. package/dist/lib/v2/projection/index.d.mts +1 -0
  178. package/dist/lib/v2/projection/index.d.ts +1 -0
  179. package/dist/lib/v2/projection/index.js +3 -0
  180. package/dist/lib/v2/projection/index.mjs +2 -0
  181. package/dist/lib/v2/projection/legacy-metadata.d.mts +19 -0
  182. package/dist/lib/v2/projection/legacy-metadata.d.ts +19 -0
  183. package/dist/lib/v2/projection/legacy-metadata.js +91 -0
  184. package/dist/lib/v2/projection/legacy-metadata.mjs +86 -0
  185. package/dist/lib/v2/projection/v1-to-v2.d.mts +1 -1
  186. package/dist/lib/v2/projection/v1-to-v2.d.ts +1 -1
  187. package/dist/lib/v2/projection/v1-to-v2.js +12 -9
  188. package/dist/lib/v2/projection/v1-to-v2.mjs +12 -9
  189. package/dist/lib/validation/budget-allocation.d.mts +3 -3
  190. package/dist/lib/validation/budget-allocation.d.ts +3 -3
  191. package/dist/lib/validation/compact-schema.d.mts +27 -0
  192. package/dist/lib/validation/compact-schema.d.ts +27 -0
  193. package/dist/lib/validation/compact-schema.js +276 -0
  194. package/dist/lib/validation/compact-schema.mjs +250 -0
  195. package/dist/lib/validation/media-buy-delivery-report.d.mts +8 -0
  196. package/dist/lib/validation/media-buy-delivery-report.d.ts +8 -0
  197. package/dist/lib/validation/media-buy-delivery-report.js +31 -0
  198. package/dist/lib/validation/media-buy-delivery-report.mjs +7 -0
  199. package/dist/lib/validation/nonempty-array.d.mts +15 -0
  200. package/dist/lib/validation/nonempty-array.d.ts +15 -0
  201. package/dist/lib/validation/nonempty-array.js +41 -0
  202. package/dist/lib/validation/nonempty-array.mjs +7 -0
  203. package/dist/lib/validation/schema-diagnostic-origins.d.mts +21 -0
  204. package/dist/lib/validation/schema-diagnostic-origins.d.ts +21 -0
  205. package/dist/lib/validation/schema-diagnostic-origins.js +193 -0
  206. package/dist/lib/validation/schema-diagnostic-origins.mjs +169 -0
  207. package/dist/lib/validation/schema-loader.js +86 -16
  208. package/dist/lib/validation/schema-loader.mjs +82 -16
  209. package/dist/lib/validation/schema-validator.d.mts +10 -19
  210. package/dist/lib/validation/schema-validator.d.ts +10 -19
  211. package/dist/lib/validation/schema-validator.js +135 -42
  212. package/dist/lib/validation/schema-validator.mjs +139 -43
  213. package/dist/lib/validation/sync-creatives.d.mts +22 -22
  214. package/dist/lib/validation/sync-creatives.d.ts +22 -22
  215. package/dist/lib/version.d.mts +3 -3
  216. package/dist/lib/version.d.ts +3 -3
  217. package/dist/lib/version.js +3 -3
  218. package/dist/lib/version.mjs +3 -3
  219. package/dist/lib/webhooks/index.d.mts +3 -0
  220. package/dist/lib/webhooks/index.d.ts +3 -0
  221. package/dist/lib/webhooks/index.js +3 -0
  222. package/dist/lib/webhooks/index.mjs +2 -0
  223. package/dist/lib/webhooks/media-buy-delivery.d.mts +43 -0
  224. package/dist/lib/webhooks/media-buy-delivery.d.ts +43 -0
  225. package/dist/lib/webhooks/media-buy-delivery.js +119 -0
  226. package/dist/lib/webhooks/media-buy-delivery.mjs +94 -0
  227. package/docs/TYPE-SUMMARY.md +2 -2
  228. package/docs/guides/DELIVERY-WEBHOOK-PARSING.md +142 -0
  229. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
  230. package/docs/guides/REPORTING-LEDGER.md +93 -0
  231. package/docs/guides/REPORTING-STABILITY.md +1 -1
  232. package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
  233. package/docs/llms.txt +2 -2
  234. package/docs/migration-14.x-rc-worksheet.md +4 -4
  235. package/docs/migration-16-to-17.md +191 -14
  236. package/docs/migration-6.6-to-6.7.md +14 -0
  237. package/docs/migration-account-change-feed.md +15 -0
  238. package/docs/recipes/verifying-inbound-webhooks.md +18 -2
  239. package/package.json +2 -2
@@ -1,5 +1,24 @@
1
1
  import type { ProductFormatDeclaration } from '../../types/tools.generated';
2
2
  import type { V1FormatId, V2ProductFormatDeclaration } from './types';
3
+ import type { VersionDrift } from '../../adapters/version/types';
4
+ type Json = Record<string, unknown>;
5
+ export interface LegacyPixelTracker {
6
+ asset: Json;
7
+ assetId: string;
8
+ lostFields: string[];
9
+ }
10
+ /** Apply the AdCP 3.1 pixel-tracker schema's normative 3.0 downgrade table. */
11
+ export declare function downgradePixelTracker(value: unknown): LegacyPixelTracker | undefined;
12
+ export declare function pixelTrackerDrift(path: string, tracker: LegacyPixelTracker): VersionDrift | undefined;
13
+ /** Keep delivery advisories out of creative JSON sent to the seller. */
14
+ export declare function rememberCreativeDeliveryDiagnostics(value: object, entries: readonly VersionDrift[]): void;
15
+ export declare function transferCreativeDeliveryDiagnostics(source: object, target: object): void;
16
+ /**
17
+ * Read advisories from a projected creative or a sync/create/update request.
18
+ * Pure projection callers can surface these alongside the returned wire object.
19
+ * SingleAgentClient includes them in the task's debug logs automatically.
20
+ */
21
+ export declare function getCreativeDeliveryDiagnostics(value: unknown): VersionDrift[];
3
22
  /**
4
23
  * SDK-private projection metadata held out-of-band. WeakMaps keep seller
5
24
  * origin evidence and legacy routing identifiers absent from canonical objects
@@ -20,8 +20,12 @@ var legacy_metadata_exports = {};
20
20
  __export(legacy_metadata_exports, {
21
21
  concealLegacyFormatRefs: () => concealLegacyFormatRefs,
22
22
  concealSelectedFormatOptions: () => concealSelectedFormatOptions,
23
+ downgradePixelTracker: () => downgradePixelTracker,
24
+ getCreativeDeliveryDiagnostics: () => getCreativeDeliveryDiagnostics,
23
25
  isSynthesizedFormatOption: () => isSynthesizedFormatOption,
24
26
  legacyFormatRefsForDeclaration: () => legacyFormatRefsForDeclaration,
27
+ pixelTrackerDrift: () => pixelTrackerDrift,
28
+ rememberCreativeDeliveryDiagnostics: () => rememberCreativeDeliveryDiagnostics,
25
29
  rememberSellerDeclaredFormatOption: () => rememberSellerDeclaredFormatOption,
26
30
  rememberSellerFormatEvidence: () => rememberSellerFormatEvidence,
27
31
  rememberSynthesizedFormatOption: () => rememberSynthesizedFormatOption,
@@ -29,10 +33,90 @@ __export(legacy_metadata_exports, {
29
33
  sellerDeclaredFormatOption: () => sellerDeclaredFormatOption,
30
34
  sellerFormatEvidence: () => sellerFormatEvidence,
31
35
  structuredCloneWithLegacyCreativeMetadata: () => structuredCloneWithLegacyCreativeMetadata,
36
+ transferCreativeDeliveryDiagnostics: () => transferCreativeDeliveryDiagnostics,
32
37
  transferLegacyCreativeMetadata: () => transferLegacyCreativeMetadata
33
38
  });
34
39
  module.exports = __toCommonJS(legacy_metadata_exports);
35
40
  var import_jcs = require('../../utils/jcs.js');
41
+ const diagnostics = /* @__PURE__ */ new WeakMap();
42
+ function downgradePixelTracker(value) {
43
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
44
+ const asset = value;
45
+ if (asset.asset_type !== "pixel_tracker" || typeof asset.url !== "string") return void 0;
46
+ if (asset.method !== void 0 && asset.method !== "img" && asset.method !== "js") return void 0;
47
+ let assetId;
48
+ const lostFields = [];
49
+ switch (asset.event) {
50
+ case "impression":
51
+ assetId = "impression_tracker";
52
+ break;
53
+ case "click":
54
+ assetId = "click_tracker";
55
+ break;
56
+ case "viewable_mrc_50":
57
+ case "viewable_mrc_100":
58
+ case "viewable_video_50":
59
+ case "audible_video_complete":
60
+ assetId = "viewability_tracker";
61
+ lostFields.push("event");
62
+ break;
63
+ case "custom":
64
+ if (typeof asset.custom_event_name !== "string" || asset.custom_event_name.length === 0) return void 0;
65
+ assetId = "impression_tracker";
66
+ lostFields.push("event", "custom_event_name");
67
+ break;
68
+ default:
69
+ return void 0;
70
+ }
71
+ if (asset.method === "js") lostFields.push("method");
72
+ const { event: _event, method: _method, custom_event_name: _custom, ...rest } = asset;
73
+ return { asset: { ...rest, asset_type: "url", url_type: "tracker_pixel" }, assetId, lostFields };
74
+ }
75
+ function pixelTrackerDrift(path, tracker) {
76
+ if (tracker.lostFields.length === 0) return void 0;
77
+ return {
78
+ type: "PIXEL_TRACKER_LOSSY_DOWNGRADE",
79
+ message: `${path} converted to a legacy URL tracker. ` + (tracker.lostFields.includes("event") ? "The original event variant or custom timing is not represented. " : "") + (tracker.lostFields.includes("method") ? "The URL is requested as an image; its JavaScript does not execute. " : "") + "AdCP 3.0 cannot preserve these tracker semantics.",
80
+ strippedFields: tracker.lostFields.map((field) => `${path}.${field}`)
81
+ };
82
+ }
83
+ function rememberCreativeDeliveryDiagnostics(value, entries) {
84
+ if (entries.length === 0) return;
85
+ const combined = [...diagnostics.get(value) ?? [], ...entries];
86
+ diagnostics.set(value, [...new Map(combined.map((entry) => [JSON.stringify(entry), entry])).values()]);
87
+ }
88
+ function transferCreativeDeliveryDiagnostics(source, target) {
89
+ const entries = diagnostics.get(source);
90
+ if (entries) rememberCreativeDeliveryDiagnostics(target, entries);
91
+ }
92
+ function getCreativeDeliveryDiagnostics(value) {
93
+ const result = [];
94
+ const append = (creative, prefix) => {
95
+ if (!creative || typeof creative !== "object") return;
96
+ for (const entry of diagnostics.get(creative) ?? []) {
97
+ result.push({
98
+ ...entry,
99
+ message: prefix ? `${prefix}: ${entry.message}` : entry.message,
100
+ strippedFields: entry.strippedFields?.map((field) => `${prefix}${prefix ? "." : ""}${field}`)
101
+ });
102
+ }
103
+ };
104
+ append(value, "");
105
+ if (!value || typeof value !== "object" || Array.isArray(value)) return result;
106
+ const request = value;
107
+ const creatives = (items, prefix) => {
108
+ if (Array.isArray(items)) items.forEach((item, index) => append(item, `${prefix}[${index}]`));
109
+ };
110
+ creatives(request.creatives, "creatives");
111
+ for (const field of ["packages", "new_packages"]) {
112
+ const packages = request[field];
113
+ if (!Array.isArray(packages)) continue;
114
+ packages.forEach((pkg, index) => {
115
+ if (pkg && typeof pkg === "object") creatives(pkg.creatives, `${field}[${index}].creatives`);
116
+ });
117
+ }
118
+ return result;
119
+ }
36
120
  const legacyRefsByDeclaration = /* @__PURE__ */ new WeakMap();
37
121
  const selectedOptionsByRefs = /* @__PURE__ */ new WeakMap();
38
122
  const sellerDeclaredByDeclaration = /* @__PURE__ */ new WeakMap();
@@ -101,6 +185,7 @@ function concealSelectedFormatOptions(refs, declarations) {
101
185
  selectedOptionsByRefs.set(refs, declarations);
102
186
  }
103
187
  function transferLegacyCreativeMetadata(source, target) {
188
+ transferCreativeDeliveryDiagnostics(source, target);
104
189
  const refs = legacyRefsByDeclaration.get(source);
105
190
  if (refs) legacyRefsByDeclaration.set(target, refs);
106
191
  const selected = selectedOptionsByRefs.get(source);
@@ -114,6 +199,7 @@ function structuredCloneWithLegacyCreativeMetadata(value) {
114
199
  const clone = structuredClone(value);
115
200
  const visited = /* @__PURE__ */ new WeakMap();
116
201
  const snapshotMetadata = (source, target) => {
202
+ transferCreativeDeliveryDiagnostics(source, target);
117
203
  const declared = sellerDeclaredByDeclaration.get(source);
118
204
  if (declared !== void 0) sellerDeclaredByDeclaration.set(target, declared);
119
205
  const evidence = sellerEvidenceByDeclaration.get(source);
@@ -155,8 +241,12 @@ function structuredCloneWithLegacyCreativeMetadata(value) {
155
241
  0 && (module.exports = {
156
242
  concealLegacyFormatRefs,
157
243
  concealSelectedFormatOptions,
244
+ downgradePixelTracker,
245
+ getCreativeDeliveryDiagnostics,
158
246
  isSynthesizedFormatOption,
159
247
  legacyFormatRefsForDeclaration,
248
+ pixelTrackerDrift,
249
+ rememberCreativeDeliveryDiagnostics,
160
250
  rememberSellerDeclaredFormatOption,
161
251
  rememberSellerFormatEvidence,
162
252
  rememberSynthesizedFormatOption,
@@ -164,5 +254,6 @@ function structuredCloneWithLegacyCreativeMetadata(value) {
164
254
  sellerDeclaredFormatOption,
165
255
  sellerFormatEvidence,
166
256
  structuredCloneWithLegacyCreativeMetadata,
257
+ transferCreativeDeliveryDiagnostics,
167
258
  transferLegacyCreativeMetadata
168
259
  });
@@ -1,4 +1,83 @@
1
1
  import { canonicalize } from "../../utils/jcs.mjs";
2
+ const diagnostics = /* @__PURE__ */ new WeakMap();
3
+ function downgradePixelTracker(value) {
4
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
5
+ const asset = value;
6
+ if (asset.asset_type !== "pixel_tracker" || typeof asset.url !== "string") return void 0;
7
+ if (asset.method !== void 0 && asset.method !== "img" && asset.method !== "js") return void 0;
8
+ let assetId;
9
+ const lostFields = [];
10
+ switch (asset.event) {
11
+ case "impression":
12
+ assetId = "impression_tracker";
13
+ break;
14
+ case "click":
15
+ assetId = "click_tracker";
16
+ break;
17
+ case "viewable_mrc_50":
18
+ case "viewable_mrc_100":
19
+ case "viewable_video_50":
20
+ case "audible_video_complete":
21
+ assetId = "viewability_tracker";
22
+ lostFields.push("event");
23
+ break;
24
+ case "custom":
25
+ if (typeof asset.custom_event_name !== "string" || asset.custom_event_name.length === 0) return void 0;
26
+ assetId = "impression_tracker";
27
+ lostFields.push("event", "custom_event_name");
28
+ break;
29
+ default:
30
+ return void 0;
31
+ }
32
+ if (asset.method === "js") lostFields.push("method");
33
+ const { event: _event, method: _method, custom_event_name: _custom, ...rest } = asset;
34
+ return { asset: { ...rest, asset_type: "url", url_type: "tracker_pixel" }, assetId, lostFields };
35
+ }
36
+ function pixelTrackerDrift(path, tracker) {
37
+ if (tracker.lostFields.length === 0) return void 0;
38
+ return {
39
+ type: "PIXEL_TRACKER_LOSSY_DOWNGRADE",
40
+ message: `${path} converted to a legacy URL tracker. ` + (tracker.lostFields.includes("event") ? "The original event variant or custom timing is not represented. " : "") + (tracker.lostFields.includes("method") ? "The URL is requested as an image; its JavaScript does not execute. " : "") + "AdCP 3.0 cannot preserve these tracker semantics.",
41
+ strippedFields: tracker.lostFields.map((field) => `${path}.${field}`)
42
+ };
43
+ }
44
+ function rememberCreativeDeliveryDiagnostics(value, entries) {
45
+ if (entries.length === 0) return;
46
+ const combined = [...diagnostics.get(value) ?? [], ...entries];
47
+ diagnostics.set(value, [...new Map(combined.map((entry) => [JSON.stringify(entry), entry])).values()]);
48
+ }
49
+ function transferCreativeDeliveryDiagnostics(source, target) {
50
+ const entries = diagnostics.get(source);
51
+ if (entries) rememberCreativeDeliveryDiagnostics(target, entries);
52
+ }
53
+ function getCreativeDeliveryDiagnostics(value) {
54
+ const result = [];
55
+ const append = (creative, prefix) => {
56
+ if (!creative || typeof creative !== "object") return;
57
+ for (const entry of diagnostics.get(creative) ?? []) {
58
+ result.push({
59
+ ...entry,
60
+ message: prefix ? `${prefix}: ${entry.message}` : entry.message,
61
+ strippedFields: entry.strippedFields?.map((field) => `${prefix}${prefix ? "." : ""}${field}`)
62
+ });
63
+ }
64
+ };
65
+ append(value, "");
66
+ if (!value || typeof value !== "object" || Array.isArray(value)) return result;
67
+ const request = value;
68
+ const creatives = (items, prefix) => {
69
+ if (Array.isArray(items)) items.forEach((item, index) => append(item, `${prefix}[${index}]`));
70
+ };
71
+ creatives(request.creatives, "creatives");
72
+ for (const field of ["packages", "new_packages"]) {
73
+ const packages = request[field];
74
+ if (!Array.isArray(packages)) continue;
75
+ packages.forEach((pkg, index) => {
76
+ if (pkg && typeof pkg === "object") creatives(pkg.creatives, `${field}[${index}].creatives`);
77
+ });
78
+ }
79
+ return result;
80
+ }
2
81
  const legacyRefsByDeclaration = /* @__PURE__ */ new WeakMap();
3
82
  const selectedOptionsByRefs = /* @__PURE__ */ new WeakMap();
4
83
  const sellerDeclaredByDeclaration = /* @__PURE__ */ new WeakMap();
@@ -67,6 +146,7 @@ function concealSelectedFormatOptions(refs, declarations) {
67
146
  selectedOptionsByRefs.set(refs, declarations);
68
147
  }
69
148
  function transferLegacyCreativeMetadata(source, target) {
149
+ transferCreativeDeliveryDiagnostics(source, target);
70
150
  const refs = legacyRefsByDeclaration.get(source);
71
151
  if (refs) legacyRefsByDeclaration.set(target, refs);
72
152
  const selected = selectedOptionsByRefs.get(source);
@@ -80,6 +160,7 @@ function structuredCloneWithLegacyCreativeMetadata(value) {
80
160
  const clone = structuredClone(value);
81
161
  const visited = /* @__PURE__ */ new WeakMap();
82
162
  const snapshotMetadata = (source, target) => {
163
+ transferCreativeDeliveryDiagnostics(source, target);
83
164
  const declared = sellerDeclaredByDeclaration.get(source);
84
165
  if (declared !== void 0) sellerDeclaredByDeclaration.set(target, declared);
85
166
  const evidence = sellerEvidenceByDeclaration.get(source);
@@ -120,8 +201,12 @@ function structuredCloneWithLegacyCreativeMetadata(value) {
120
201
  export {
121
202
  concealLegacyFormatRefs,
122
203
  concealSelectedFormatOptions,
204
+ downgradePixelTracker,
205
+ getCreativeDeliveryDiagnostics,
123
206
  isSynthesizedFormatOption,
124
207
  legacyFormatRefsForDeclaration,
208
+ pixelTrackerDrift,
209
+ rememberCreativeDeliveryDiagnostics,
125
210
  rememberSellerDeclaredFormatOption,
126
211
  rememberSellerFormatEvidence,
127
212
  rememberSynthesizedFormatOption,
@@ -129,5 +214,6 @@ export {
129
214
  sellerDeclaredFormatOption,
130
215
  sellerFormatEvidence,
131
216
  structuredCloneWithLegacyCreativeMetadata,
217
+ transferCreativeDeliveryDiagnostics,
132
218
  transferLegacyCreativeMetadata
133
219
  };
@@ -213,7 +213,7 @@ export declare function canonicalDeclarationFromBareId(id: string, options?: Bar
213
213
  */
214
214
  export declare function resolveCanonicalFormatKind(id: string, options?: BareFormatIdResolveOptions): CanonicalFormatKind | null;
215
215
  /**
216
- * Preserve index pairing only when the whole seller-authored alignment is credible.
216
+ * Preserve each compatible index pairing in a seller-authored dual emission.
217
217
  * AdCP 3.1.24 core/product.json defines this correspondence: "the format_options[i]
218
218
  * narrows the canonical that the named format in format_ids[i] resolves to via the
219
219
  * registry / explicit canonical field". Explicit routes remain authoritative.
@@ -213,7 +213,7 @@ export declare function canonicalDeclarationFromBareId(id: string, options?: Bar
213
213
  */
214
214
  export declare function resolveCanonicalFormatKind(id: string, options?: BareFormatIdResolveOptions): CanonicalFormatKind | null;
215
215
  /**
216
- * Preserve index pairing only when the whole seller-authored alignment is credible.
216
+ * Preserve each compatible index pairing in a seller-authored dual emission.
217
217
  * AdCP 3.1.24 core/product.json defines this correspondence: "the format_options[i]
218
218
  * narrows the canonical that the named format in format_ids[i] resolves to via the
219
219
  * registry / explicit canonical field". Explicit routes remain authoritative.
@@ -430,19 +430,22 @@ function compatible(option, ref) {
430
430
  }
431
431
  function withDualEmissionLegacyRefs(formatOptions, formatIds) {
432
432
  if (!Array.isArray(formatIds) || formatIds.length !== formatOptions.length) return formatOptions;
433
- const aligned = formatOptions.every((value, index) => {
433
+ if (formatOptions.some((value, index) => {
434
+ const explicit = (0, import_legacy_metadata.legacyFormatRefsForDeclaration)(value);
435
+ if (explicit.length === 0) return false;
436
+ const ref = record(formatIds[index]);
437
+ return !ref || typeof ref.agent_url !== "string" || typeof ref.id !== "string" || !explicit.some((existing) => sameIdentity(existing, ref));
438
+ }))
439
+ return formatOptions;
440
+ return formatOptions.map((value, index) => {
434
441
  const option = record(value);
435
442
  const ref = record(formatIds[index]);
436
443
  if (!option || typeof option.format_kind !== "string" || option.canonical_formats_only === true || !ref || typeof ref.agent_url !== "string" || ref.agent_url.length === 0 || typeof ref.id !== "string" || ref.id.length === 0) {
437
- return false;
444
+ return value;
445
+ }
446
+ if ((0, import_legacy_metadata.legacyFormatRefsForDeclaration)(option).length > 0 || !compatible(option, ref)) {
447
+ return value;
438
448
  }
439
- const typedRef = ref;
440
- const explicit = (0, import_legacy_metadata.legacyFormatRefsForDeclaration)(option);
441
- return explicit.length > 0 ? explicit.some((existing) => sameIdentity(existing, typedRef)) : compatible(option, typedRef);
442
- });
443
- if (!aligned) return formatOptions;
444
- return formatOptions.map((value, index) => {
445
- if ((0, import_legacy_metadata.legacyFormatRefsForDeclaration)(value).length > 0) return value;
446
449
  const paired = (0, import_legacy_metadata.concealLegacyFormatRefs)({
447
450
  ...value,
448
451
  v1_format_ref: [{ ...formatIds[index] }]
@@ -413,19 +413,22 @@ function compatible(option, ref) {
413
413
  }
414
414
  function withDualEmissionLegacyRefs(formatOptions, formatIds) {
415
415
  if (!Array.isArray(formatIds) || formatIds.length !== formatOptions.length) return formatOptions;
416
- const aligned = formatOptions.every((value, index) => {
416
+ if (formatOptions.some((value, index) => {
417
+ const explicit = legacyFormatRefsForDeclaration(value);
418
+ if (explicit.length === 0) return false;
419
+ const ref = record(formatIds[index]);
420
+ return !ref || typeof ref.agent_url !== "string" || typeof ref.id !== "string" || !explicit.some((existing) => sameIdentity(existing, ref));
421
+ }))
422
+ return formatOptions;
423
+ return formatOptions.map((value, index) => {
417
424
  const option = record(value);
418
425
  const ref = record(formatIds[index]);
419
426
  if (!option || typeof option.format_kind !== "string" || option.canonical_formats_only === true || !ref || typeof ref.agent_url !== "string" || ref.agent_url.length === 0 || typeof ref.id !== "string" || ref.id.length === 0) {
420
- return false;
427
+ return value;
428
+ }
429
+ if (legacyFormatRefsForDeclaration(option).length > 0 || !compatible(option, ref)) {
430
+ return value;
421
431
  }
422
- const typedRef = ref;
423
- const explicit = legacyFormatRefsForDeclaration(option);
424
- return explicit.length > 0 ? explicit.some((existing) => sameIdentity(existing, typedRef)) : compatible(option, typedRef);
425
- });
426
- if (!aligned) return formatOptions;
427
- return formatOptions.map((value, index) => {
428
- if (legacyFormatRefsForDeclaration(value).length > 0) return value;
429
432
  const paired = concealLegacyFormatRefs({
430
433
  ...value,
431
434
  v1_format_ref: [{ ...formatIds[index] }]
@@ -4,14 +4,14 @@ export declare const CanonicalBudgetAllocationSchema: z.ZodUnion<readonly [z.Zod
4
4
  mode: z.ZodLiteral<"fixed">;
5
5
  }, z.core.$loose>, z.ZodObject<{
6
6
  mode: z.ZodLiteral<"seller_optimized">;
7
- optimization_goals: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
7
+ optimization_goals: import("./nonempty-array.mjs").NonemptyArraySchema<z.ZodUnion<readonly [z.ZodObject<{
8
8
  kind: z.ZodLiteral<"metric">;
9
9
  metric: z.ZodUnion<readonly [z.ZodLiteral<"clicks">, z.ZodLiteral<"views">, z.ZodLiteral<"completed_views">, z.ZodLiteral<"viewed_seconds">, z.ZodLiteral<"viewable_rate">, z.ZodLiteral<"engagements">, z.ZodLiteral<"follows">, z.ZodLiteral<"saves">, z.ZodLiteral<"profile_visits">, z.ZodLiteral<"reach">]>;
10
10
  standard: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"mrc">, z.ZodLiteral<"groupm">]>>;
11
11
  vendor: z.ZodOptional<z.ZodObject<{
12
12
  domain: z.ZodString;
13
13
  brand_id: z.ZodOptional<z.ZodString>;
14
- countries: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ countries: z.ZodOptional<import("./nonempty-array.mjs").NonemptyArraySchema<z.ZodString>>;
15
15
  }, z.core.$loose>>;
16
16
  reach_unit: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"individuals">, z.ZodLiteral<"households">, z.ZodLiteral<"devices">, z.ZodLiteral<"accounts">, z.ZodLiteral<"cookies">, z.ZodLiteral<"custom">]>>;
17
17
  target_frequency: z.ZodOptional<z.ZodObject<{
@@ -57,7 +57,7 @@ export declare const CanonicalBudgetAllocationSchema: z.ZodUnion<readonly [z.Zod
57
57
  vendor: z.ZodObject<{
58
58
  domain: z.ZodString;
59
59
  brand_id: z.ZodOptional<z.ZodString>;
60
- countries: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ countries: z.ZodOptional<import("./nonempty-array.mjs").NonemptyArraySchema<z.ZodString>>;
61
61
  }, z.core.$loose>;
62
62
  metric_id: z.ZodString;
63
63
  target: z.ZodOptional<z.ZodObject<{
@@ -4,14 +4,14 @@ export declare const CanonicalBudgetAllocationSchema: z.ZodUnion<readonly [z.Zod
4
4
  mode: z.ZodLiteral<"fixed">;
5
5
  }, z.core.$loose>, z.ZodObject<{
6
6
  mode: z.ZodLiteral<"seller_optimized">;
7
- optimization_goals: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
7
+ optimization_goals: import("./nonempty-array").NonemptyArraySchema<z.ZodUnion<readonly [z.ZodObject<{
8
8
  kind: z.ZodLiteral<"metric">;
9
9
  metric: z.ZodUnion<readonly [z.ZodLiteral<"clicks">, z.ZodLiteral<"views">, z.ZodLiteral<"completed_views">, z.ZodLiteral<"viewed_seconds">, z.ZodLiteral<"viewable_rate">, z.ZodLiteral<"engagements">, z.ZodLiteral<"follows">, z.ZodLiteral<"saves">, z.ZodLiteral<"profile_visits">, z.ZodLiteral<"reach">]>;
10
10
  standard: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"mrc">, z.ZodLiteral<"groupm">]>>;
11
11
  vendor: z.ZodOptional<z.ZodObject<{
12
12
  domain: z.ZodString;
13
13
  brand_id: z.ZodOptional<z.ZodString>;
14
- countries: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ countries: z.ZodOptional<import("./nonempty-array").NonemptyArraySchema<z.ZodString>>;
15
15
  }, z.core.$loose>>;
16
16
  reach_unit: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"individuals">, z.ZodLiteral<"households">, z.ZodLiteral<"devices">, z.ZodLiteral<"accounts">, z.ZodLiteral<"cookies">, z.ZodLiteral<"custom">]>>;
17
17
  target_frequency: z.ZodOptional<z.ZodObject<{
@@ -57,7 +57,7 @@ export declare const CanonicalBudgetAllocationSchema: z.ZodUnion<readonly [z.Zod
57
57
  vendor: z.ZodObject<{
58
58
  domain: z.ZodString;
59
59
  brand_id: z.ZodOptional<z.ZodString>;
60
- countries: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ countries: z.ZodOptional<import("./nonempty-array").NonemptyArraySchema<z.ZodString>>;
61
61
  }, z.core.$loose>;
62
62
  metric_id: z.ZodString;
63
63
  target: z.ZodOptional<z.ZodObject<{
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Convert a mostly dereferenced bundled JSON Schema into a serializable schema
3
+ * that stores repeated schema nodes once under `$defs`.
4
+ *
5
+ * The upstream `bundled/` tree expands shared definitions at every use site,
6
+ * growing to hundreds of megabytes. This serializer replaces repeated schema
7
+ * nodes with private local refs while leaving annotation/default/example data
8
+ * alone. Public schema readers expand these private refs; validation can keep
9
+ * them to compile small referenced functions instead of multi-megabyte code.
10
+ */
11
+ type JsonObject = Record<string, unknown>;
12
+ export declare const COMPACT_DEFINITIONS_KEY = "x-adcp-compact-definitions";
13
+ /**
14
+ * Compact an acyclic schema object graph. Repeated schemas become private local
15
+ * `$defs` refs. The archive reader expands those private refs before exposing
16
+ * a schema, preserving the original document and AJV diagnostic paths.
17
+ */
18
+ export declare function compactBundledSchema(root: JsonObject, options?: {
19
+ maxInlineSchemaBytes?: number;
20
+ }): JsonObject;
21
+ /**
22
+ * Prepare a self-contained bundled schema for bounded AJV compilation. Nested
23
+ * IDs in these dereferenced bundles are source annotations, not ref scopes.
24
+ * Walk schema positions only so IDs in enum/default/example data stay intact.
25
+ */
26
+ export declare function compactSchemaForValidation(schema: JsonObject): JsonObject;
27
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Convert a mostly dereferenced bundled JSON Schema into a serializable schema
3
+ * that stores repeated schema nodes once under `$defs`.
4
+ *
5
+ * The upstream `bundled/` tree expands shared definitions at every use site,
6
+ * growing to hundreds of megabytes. This serializer replaces repeated schema
7
+ * nodes with private local refs while leaving annotation/default/example data
8
+ * alone. Public schema readers expand these private refs; validation can keep
9
+ * them to compile small referenced functions instead of multi-megabyte code.
10
+ */
11
+ type JsonObject = Record<string, unknown>;
12
+ export declare const COMPACT_DEFINITIONS_KEY = "x-adcp-compact-definitions";
13
+ /**
14
+ * Compact an acyclic schema object graph. Repeated schemas become private local
15
+ * `$defs` refs. The archive reader expands those private refs before exposing
16
+ * a schema, preserving the original document and AJV diagnostic paths.
17
+ */
18
+ export declare function compactBundledSchema(root: JsonObject, options?: {
19
+ maxInlineSchemaBytes?: number;
20
+ }): JsonObject;
21
+ /**
22
+ * Prepare a self-contained bundled schema for bounded AJV compilation. Nested
23
+ * IDs in these dereferenced bundles are source annotations, not ref scopes.
24
+ * Walk schema positions only so IDs in enum/default/example data stay intact.
25
+ */
26
+ export declare function compactSchemaForValidation(schema: JsonObject): JsonObject;
27
+ export {};