@adcp/sdk 16.5.0 → 16.6.0

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 (236) hide show
  1. package/dist/lib/adapters/version/3.0/brand-fields.d.mts +7 -1
  2. package/dist/lib/adapters/version/3.0/brand-fields.d.ts +7 -1
  3. package/dist/lib/adapters/version/3.0/brand-fields.js +139 -3
  4. package/dist/lib/adapters/version/3.0/brand-fields.mjs +136 -2
  5. package/dist/lib/adapters/version/3.0/index.js +6 -0
  6. package/dist/lib/adapters/version/3.0/index.mjs +7 -1
  7. package/dist/lib/adapters/version/3.1/bidding.js +1 -1
  8. package/dist/lib/adapters/version/3.1/bidding.mjs +1 -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/ResponseValidator.js +1 -1
  30. package/dist/lib/core/ResponseValidator.mjs +1 -1
  31. package/dist/lib/core/SingleAgentClient.d.mts +116 -6
  32. package/dist/lib/core/SingleAgentClient.d.ts +116 -6
  33. package/dist/lib/core/SingleAgentClient.js +556 -84
  34. package/dist/lib/core/SingleAgentClient.mjs +545 -72
  35. package/dist/lib/core/TaskExecutor.d.mts +7 -0
  36. package/dist/lib/core/TaskExecutor.d.ts +7 -0
  37. package/dist/lib/core/TaskExecutor.js +23 -8
  38. package/dist/lib/core/TaskExecutor.mjs +23 -8
  39. package/dist/lib/core/task-status.d.mts +2 -0
  40. package/dist/lib/core/task-status.d.ts +2 -0
  41. package/dist/lib/core/task-status.js +11 -2
  42. package/dist/lib/core/task-status.mjs +9 -1
  43. package/dist/lib/errors/index.d.mts +22 -0
  44. package/dist/lib/errors/index.d.ts +22 -0
  45. package/dist/lib/errors/index.js +43 -0
  46. package/dist/lib/errors/index.mjs +42 -0
  47. package/dist/lib/identity-3.3/trust.d.mts +1 -4
  48. package/dist/lib/identity-3.3/trust.d.ts +1 -4
  49. package/dist/lib/identity-3.3/trust.js +34 -21
  50. package/dist/lib/identity-3.3/trust.mjs +34 -21
  51. package/dist/lib/identity-3.3/validation.js +5 -3
  52. package/dist/lib/identity-3.3/validation.mjs +6 -4
  53. package/dist/lib/index.d.mts +8 -54
  54. package/dist/lib/index.d.ts +8 -54
  55. package/dist/lib/index.js +15 -0
  56. package/dist/lib/index.mjs +11 -0
  57. package/dist/lib/media-buy/action-assessment.js +29 -3
  58. package/dist/lib/media-buy/action-assessment.mjs +32 -4
  59. package/dist/lib/media-buy/action-contracts.d.mts +3 -0
  60. package/dist/lib/media-buy/action-contracts.d.ts +3 -0
  61. package/dist/lib/media-buy/action-contracts.js +24 -1
  62. package/dist/lib/media-buy/action-contracts.mjs +22 -1
  63. package/dist/lib/media-buy/compatibility.js +6 -1
  64. package/dist/lib/media-buy/compatibility.mjs +6 -1
  65. package/dist/lib/media-buy/preflight.js +1 -1
  66. package/dist/lib/media-buy/preflight.mjs +3 -2
  67. package/dist/lib/media-buy/types.d.mts +6 -1
  68. package/dist/lib/media-buy/types.d.ts +6 -1
  69. package/dist/lib/protocols/mcp-modern.d.mts +2 -0
  70. package/dist/lib/protocols/mcp-modern.d.ts +2 -0
  71. package/dist/lib/protocols/mcp-modern.js +31 -5
  72. package/dist/lib/protocols/mcp-modern.mjs +31 -5
  73. package/dist/lib/protocols/mcp-scope.d.mts +6 -1
  74. package/dist/lib/protocols/mcp-scope.d.ts +6 -1
  75. package/dist/lib/protocols/mcp-scope.js +25 -3
  76. package/dist/lib/protocols/mcp-scope.mjs +24 -3
  77. package/dist/lib/protocols/mcp.js +12 -6
  78. package/dist/lib/protocols/mcp.mjs +13 -6
  79. package/dist/lib/reporting/inspection.js +1 -0
  80. package/dist/lib/reporting/inspection.mjs +1 -0
  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 -2
  86. package/dist/lib/schemas/index.d.ts +5 -2
  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 +1 -0
  94. package/dist/lib/server/account-sync-contract.mjs +1 -0
  95. package/dist/lib/server/create-adcp-server.js +32 -19
  96. package/dist/lib/server/create-adcp-server.mjs +36 -12
  97. package/dist/lib/server/decisioning/account.d.mts +13 -6
  98. package/dist/lib/server/decisioning/account.d.ts +13 -6
  99. package/dist/lib/server/decisioning/account.js +37 -15
  100. package/dist/lib/server/decisioning/account.mjs +37 -15
  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 +6 -6
  104. package/dist/lib/server/decisioning/runtime/from-platform.mjs +6 -6
  105. package/dist/lib/server/index.d.mts +1 -1
  106. package/dist/lib/server/index.d.ts +1 -1
  107. package/dist/lib/server/index.js +2 -0
  108. package/dist/lib/server/index.mjs +2 -0
  109. package/dist/lib/server/media-buy-action-resolver.d.mts +3 -0
  110. package/dist/lib/server/media-buy-action-resolver.d.ts +3 -0
  111. package/dist/lib/server/media-buy-action-resolver.js +32 -0
  112. package/dist/lib/server/media-buy-action-resolver.mjs +32 -0
  113. package/dist/lib/server/media-buy-store.d.mts +26 -12
  114. package/dist/lib/server/media-buy-store.d.ts +26 -12
  115. package/dist/lib/server/media-buy-store.js +69 -21
  116. package/dist/lib/server/media-buy-store.mjs +69 -21
  117. package/dist/lib/server/responses.js +9 -1
  118. package/dist/lib/server/responses.mjs +9 -1
  119. package/dist/lib/server/state-machine.d.mts +10 -11
  120. package/dist/lib/server/state-machine.d.ts +10 -11
  121. package/dist/lib/server/state-machine.js +20 -5
  122. package/dist/lib/server/state-machine.mjs +19 -5
  123. package/dist/lib/signing/agent-fetch.d.mts +1 -1
  124. package/dist/lib/signing/agent-fetch.d.ts +1 -1
  125. package/dist/lib/signing/agent-fetch.js +3 -3
  126. package/dist/lib/signing/agent-fetch.mjs +3 -3
  127. package/dist/lib/testing/client.d.mts +1 -0
  128. package/dist/lib/testing/client.d.ts +1 -0
  129. package/dist/lib/testing/client.js +6 -5
  130. package/dist/lib/testing/client.mjs +6 -5
  131. package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +60 -14
  132. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +60 -14
  133. package/dist/lib/testing/storyboard/compliance.d.mts +2 -5
  134. package/dist/lib/testing/storyboard/compliance.d.ts +2 -5
  135. package/dist/lib/testing/storyboard/compliance.js +62 -13
  136. package/dist/lib/testing/storyboard/compliance.mjs +63 -14
  137. package/dist/lib/testing/storyboard/context.d.mts +13 -3
  138. package/dist/lib/testing/storyboard/context.d.ts +13 -3
  139. package/dist/lib/testing/storyboard/context.js +15 -10
  140. package/dist/lib/testing/storyboard/context.mjs +15 -10
  141. package/dist/lib/testing/storyboard/default-invariants.js +10 -8
  142. package/dist/lib/testing/storyboard/default-invariants.mjs +11 -9
  143. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
  144. package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
  145. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +11 -0
  146. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +10 -0
  147. package/dist/lib/testing/storyboard/runner.js +23 -10
  148. package/dist/lib/testing/storyboard/runner.mjs +23 -10
  149. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  150. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  151. package/dist/lib/testing/storyboard/validations.js +4 -1
  152. package/dist/lib/testing/storyboard/validations.mjs +4 -1
  153. package/dist/lib/testing/test-controller.js +3 -0
  154. package/dist/lib/testing/test-controller.mjs +3 -0
  155. package/dist/lib/types/asset-instances.d.mts +1 -1
  156. package/dist/lib/types/asset-instances.d.ts +1 -1
  157. package/dist/lib/types/index.d.mts +5 -0
  158. package/dist/lib/types/index.d.ts +5 -0
  159. package/dist/lib/types/index.js +6 -1
  160. package/dist/lib/types/index.mjs +4 -1
  161. package/dist/lib/types/inline-enums.generated.d.mts +30 -4
  162. package/dist/lib/types/inline-enums.generated.d.ts +30 -4
  163. package/dist/lib/types/inline-enums.generated.js +41 -2
  164. package/dist/lib/types/inline-enums.generated.mjs +28 -2
  165. package/dist/lib/types/media-buy-delivery-report.d.mts +4 -0
  166. package/dist/lib/types/media-buy-delivery-report.d.ts +4 -0
  167. package/dist/lib/types/media-buy-delivery-report.js +16 -0
  168. package/dist/lib/types/media-buy-delivery-report.mjs +0 -0
  169. package/dist/lib/types/schemas.generated.d.ts +20 -69
  170. package/dist/lib/types/schemas.generated.js +29 -46
  171. package/dist/lib/types/schemas.generated.mjs +29 -46
  172. package/dist/lib/types/targeting-keys.generated.d.mts +4 -0
  173. package/dist/lib/types/targeting-keys.generated.d.ts +4 -0
  174. package/dist/lib/types/targeting-keys.generated.js +105 -0
  175. package/dist/lib/types/targeting-keys.generated.mjs +80 -0
  176. package/dist/lib/utils/adcp-version-config.js +5 -2
  177. package/dist/lib/utils/adcp-version-config.mjs +5 -2
  178. package/dist/lib/utils/envelope-status-compat.d.mts +18 -1
  179. package/dist/lib/utils/envelope-status-compat.d.ts +18 -1
  180. package/dist/lib/utils/envelope-status-compat.js +11 -5
  181. package/dist/lib/utils/envelope-status-compat.mjs +11 -5
  182. package/dist/lib/utils/response-unwrapper.js +18 -10
  183. package/dist/lib/utils/response-unwrapper.mjs +18 -10
  184. package/dist/lib/v2/format-schema/resolver.js +1 -1
  185. package/dist/lib/v2/format-schema/resolver.mjs +1 -1
  186. package/dist/lib/v2/projection/creative-delivery.js +123 -30
  187. package/dist/lib/v2/projection/creative-delivery.mjs +127 -30
  188. package/dist/lib/v2/projection/index.d.mts +1 -0
  189. package/dist/lib/v2/projection/index.d.ts +1 -0
  190. package/dist/lib/v2/projection/index.js +3 -0
  191. package/dist/lib/v2/projection/index.mjs +2 -0
  192. package/dist/lib/v2/projection/legacy-metadata.d.mts +19 -0
  193. package/dist/lib/v2/projection/legacy-metadata.d.ts +19 -0
  194. package/dist/lib/v2/projection/legacy-metadata.js +91 -0
  195. package/dist/lib/v2/projection/legacy-metadata.mjs +86 -0
  196. package/dist/lib/validation/compact-schema.d.mts +27 -0
  197. package/dist/lib/validation/compact-schema.d.ts +27 -0
  198. package/dist/lib/validation/compact-schema.js +276 -0
  199. package/dist/lib/validation/compact-schema.mjs +250 -0
  200. package/dist/lib/validation/media-buy-delivery-report.d.mts +8 -0
  201. package/dist/lib/validation/media-buy-delivery-report.d.ts +8 -0
  202. package/dist/lib/validation/media-buy-delivery-report.js +31 -0
  203. package/dist/lib/validation/media-buy-delivery-report.mjs +7 -0
  204. package/dist/lib/validation/schema-diagnostic-origins.d.mts +21 -0
  205. package/dist/lib/validation/schema-diagnostic-origins.d.ts +21 -0
  206. package/dist/lib/validation/schema-diagnostic-origins.js +193 -0
  207. package/dist/lib/validation/schema-diagnostic-origins.mjs +169 -0
  208. package/dist/lib/validation/schema-loader.js +86 -16
  209. package/dist/lib/validation/schema-loader.mjs +82 -16
  210. package/dist/lib/validation/schema-validator.d.mts +10 -19
  211. package/dist/lib/validation/schema-validator.d.ts +10 -19
  212. package/dist/lib/validation/schema-validator.js +136 -43
  213. package/dist/lib/validation/schema-validator.mjs +140 -44
  214. package/dist/lib/version.d.mts +3 -3
  215. package/dist/lib/version.d.ts +3 -3
  216. package/dist/lib/version.js +3 -3
  217. package/dist/lib/version.mjs +3 -3
  218. package/dist/lib/webhooks/index.d.mts +3 -0
  219. package/dist/lib/webhooks/index.d.ts +3 -0
  220. package/dist/lib/webhooks/index.js +3 -0
  221. package/dist/lib/webhooks/index.mjs +2 -0
  222. package/dist/lib/webhooks/media-buy-delivery.d.mts +43 -0
  223. package/dist/lib/webhooks/media-buy-delivery.d.ts +43 -0
  224. package/dist/lib/webhooks/media-buy-delivery.js +119 -0
  225. package/dist/lib/webhooks/media-buy-delivery.mjs +94 -0
  226. package/docs/TYPE-SUMMARY.md +2 -2
  227. package/docs/guides/BUILD-AN-AGENT.md +9 -1
  228. package/docs/guides/DELIVERY-WEBHOOK-PARSING.md +135 -0
  229. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
  230. package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
  231. package/docs/llms.txt +3 -3
  232. package/docs/migration-14.x-rc-worksheet.md +4 -4
  233. package/docs/migration-6.6-to-6.7.md +14 -0
  234. package/docs/migration-account-change-feed.md +19 -0
  235. package/docs/releases/sdk-16.6-adoption-fixes.md +33 -0
  236. package/package.json +2 -2
@@ -0,0 +1,250 @@
1
+ import { createHash } from "node:crypto";
2
+ const COMPACT_DEFINITIONS_KEY = "x-adcp-compact-definitions";
3
+ const SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set(["properties", "patternProperties", "$defs", "definitions", "dependentSchemas"]);
4
+ const SCHEMA_ARRAY_KEYWORDS = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf", "prefixItems"]);
5
+ const SCHEMA_VALUE_KEYWORDS = /* @__PURE__ */ new Set([
6
+ "additionalProperties",
7
+ "additionalItems",
8
+ "contains",
9
+ "if",
10
+ "then",
11
+ "else",
12
+ "not",
13
+ "propertyNames",
14
+ "contentSchema",
15
+ "unevaluatedProperties",
16
+ "unevaluatedItems"
17
+ ]);
18
+ function isObject(value) {
19
+ return value !== null && typeof value === "object" && !Array.isArray(value);
20
+ }
21
+ function forEachChildSchema(schema, visit) {
22
+ for (const [keyword, value] of Object.entries(schema)) {
23
+ if (SCHEMA_MAP_KEYWORDS.has(keyword) && isObject(value)) {
24
+ for (const child of Object.values(value)) visit(child);
25
+ } else if (SCHEMA_ARRAY_KEYWORDS.has(keyword) && Array.isArray(value)) {
26
+ for (const child of value) visit(child);
27
+ } else if (SCHEMA_VALUE_KEYWORDS.has(keyword)) {
28
+ visit(value);
29
+ } else if (keyword === "items") {
30
+ if (Array.isArray(value)) {
31
+ for (const child of value) visit(child);
32
+ } else {
33
+ visit(value);
34
+ }
35
+ } else if (keyword === "dependencies" && isObject(value)) {
36
+ for (const child of Object.values(value)) {
37
+ if (!Array.isArray(child)) visit(child);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ function cloneData(value) {
43
+ if (Array.isArray(value)) return value.map(cloneData);
44
+ if (!isObject(value)) return value;
45
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, cloneData(child)]));
46
+ }
47
+ function compactBundledSchema(root, options = {}) {
48
+ const referenceCounts = /* @__PURE__ */ new Map();
49
+ const visited = /* @__PURE__ */ new Set();
50
+ const countSchema = (value) => {
51
+ if (!isObject(value)) return;
52
+ referenceCounts.set(value, (referenceCounts.get(value) ?? 0) + 1);
53
+ if (visited.has(value)) return;
54
+ visited.add(value);
55
+ forEachChildSchema(value, countSchema);
56
+ };
57
+ countSchema(root);
58
+ const pointerAddressedNodes = /* @__PURE__ */ new Set();
59
+ const unionAlternatives = /* @__PURE__ */ new Set();
60
+ if (options.maxInlineSchemaBytes !== void 0) {
61
+ const rootUrl = new URL(typeof root.$id === "string" ? root.$id : "", "https://adcp.invalid/");
62
+ rootUrl.hash = "";
63
+ for (const schema of visited) {
64
+ for (const keyword of ["oneOf", "anyOf"]) {
65
+ const alternatives = schema[keyword];
66
+ if (Array.isArray(alternatives)) {
67
+ for (const alternative of alternatives) if (isObject(alternative)) unionAlternatives.add(alternative);
68
+ }
69
+ }
70
+ if (typeof schema.$ref !== "string") continue;
71
+ let fragment;
72
+ try {
73
+ const target = new URL(schema.$ref, rootUrl);
74
+ fragment = decodeURIComponent(target.hash.slice(1));
75
+ target.hash = "";
76
+ if (target.href !== rootUrl.href || !fragment.startsWith("/")) continue;
77
+ } catch {
78
+ continue;
79
+ }
80
+ let value = root;
81
+ for (const segment of fragment.slice(1).split("/")) {
82
+ if (isObject(value)) pointerAddressedNodes.add(value);
83
+ if (!isObject(value) && !Array.isArray(value)) break;
84
+ const key = segment.replace(/~1/g, "/").replace(/~0/g, "~");
85
+ value = value[key];
86
+ }
87
+ if (isObject(value)) pointerAddressedNodes.add(value);
88
+ }
89
+ }
90
+ const signatureCache = /* @__PURE__ */ new Map();
91
+ const weightCache = /* @__PURE__ */ new Map();
92
+ const schemaSignature = (schema) => {
93
+ const cached = signatureCache.get(schema);
94
+ if (cached) return cached;
95
+ const hash = createHash("sha256");
96
+ const updateHash = (value) => {
97
+ hash.update(`${Buffer.byteLength(value)}:`);
98
+ hash.update(value);
99
+ };
100
+ let weight = 2;
101
+ for (const [keyword, value] of Object.entries(schema)) {
102
+ updateHash(keyword);
103
+ if (SCHEMA_MAP_KEYWORDS.has(keyword) && isObject(value)) {
104
+ for (const [key, child] of Object.entries(value)) {
105
+ updateHash(key);
106
+ if (isObject(child)) {
107
+ updateHash(schemaSignature(child));
108
+ weight += weightCache.get(child) ?? 0;
109
+ } else {
110
+ const serialized = JSON.stringify(child);
111
+ updateHash(serialized);
112
+ weight += Buffer.byteLength(serialized);
113
+ }
114
+ }
115
+ } else if (SCHEMA_ARRAY_KEYWORDS.has(keyword) && Array.isArray(value)) {
116
+ for (const child of value) {
117
+ if (isObject(child)) {
118
+ updateHash(schemaSignature(child));
119
+ weight += weightCache.get(child) ?? 0;
120
+ } else {
121
+ const serialized = JSON.stringify(child);
122
+ updateHash(serialized);
123
+ weight += Buffer.byteLength(serialized);
124
+ }
125
+ }
126
+ } else if (SCHEMA_VALUE_KEYWORDS.has(keyword) && isObject(value)) {
127
+ updateHash(schemaSignature(value));
128
+ weight += weightCache.get(value) ?? 0;
129
+ } else if (keyword === "items") {
130
+ updateHash(Array.isArray(value) ? "tuple" : "single");
131
+ const children = Array.isArray(value) ? value : [value];
132
+ for (const child of children) {
133
+ if (isObject(child)) {
134
+ updateHash(schemaSignature(child));
135
+ weight += weightCache.get(child) ?? 0;
136
+ } else {
137
+ const serialized = JSON.stringify(child);
138
+ updateHash(serialized);
139
+ weight += Buffer.byteLength(serialized);
140
+ }
141
+ }
142
+ } else if (keyword === "dependencies" && isObject(value)) {
143
+ for (const [key, child] of Object.entries(value)) {
144
+ updateHash(key);
145
+ if (isObject(child)) {
146
+ updateHash(schemaSignature(child));
147
+ weight += weightCache.get(child) ?? 0;
148
+ } else {
149
+ const serialized = JSON.stringify(child);
150
+ updateHash(serialized);
151
+ weight += Buffer.byteLength(serialized);
152
+ }
153
+ }
154
+ } else {
155
+ const serialized = JSON.stringify(value);
156
+ updateHash(serialized);
157
+ weight += Buffer.byteLength(serialized);
158
+ }
159
+ }
160
+ const signature = hash.digest("hex");
161
+ signatureCache.set(schema, signature);
162
+ weightCache.set(schema, weight);
163
+ return signature;
164
+ };
165
+ const signatureGroups = /* @__PURE__ */ new Map();
166
+ for (const schema of visited) {
167
+ if (schema === root || pointerAddressedNodes.has(schema) || unionAlternatives.has(schema)) continue;
168
+ const signature = schemaSignature(schema);
169
+ const group = signatureGroups.get(signature) ?? [];
170
+ group.push(schema);
171
+ signatureGroups.set(signature, group);
172
+ }
173
+ const sharedNames = /* @__PURE__ */ new Map();
174
+ const sharedDefinitions = /* @__PURE__ */ new Map();
175
+ const reservedNames = new Set(isObject(root.$defs) ? Object.keys(root.$defs) : []);
176
+ let sharedIndex = 0;
177
+ for (const group of signatureGroups.values()) {
178
+ const useCount = group.reduce((sum, schema) => sum + (referenceCounts.get(schema) ?? 0), 0);
179
+ const weight = weightCache.get(group[0]) ?? 0;
180
+ const identityShared = group.some((schema) => (referenceCounts.get(schema) ?? 0) > 1);
181
+ const largeValidationNode = options.maxInlineSchemaBytes !== void 0 && weight >= options.maxInlineSchemaBytes;
182
+ if (!largeValidationNode && (useCount < 2 || !identityShared && weight < 256)) continue;
183
+ let name;
184
+ do
185
+ name = `__adcp_shared_${sharedIndex++}`;
186
+ while (reservedNames.has(name));
187
+ reservedNames.add(name);
188
+ for (const schema of group) sharedNames.set(schema, name);
189
+ sharedDefinitions.set(name, group[0]);
190
+ }
191
+ const encodeSchema = (schema, expanding, ancestors = /* @__PURE__ */ new Set()) => {
192
+ if (!isObject(schema)) return schema;
193
+ const sharedName = sharedNames.get(schema);
194
+ if (sharedName && schema !== expanding) return { $ref: `#/$defs/${sharedName}` };
195
+ if (ancestors.has(schema)) {
196
+ if (!sharedName) throw new Error("Dereferenced schema contains an unaddressable cycle");
197
+ return { $ref: `#/$defs/${sharedName}` };
198
+ }
199
+ const nextAncestors = new Set(ancestors);
200
+ nextAncestors.add(schema);
201
+ const encoded = {};
202
+ for (const [keyword, value] of Object.entries(schema)) {
203
+ if (SCHEMA_MAP_KEYWORDS.has(keyword) && isObject(value)) {
204
+ encoded[keyword] = Object.fromEntries(
205
+ Object.entries(value).map(([key, child]) => [key, encodeSchema(child, void 0, nextAncestors)])
206
+ );
207
+ } else if (SCHEMA_ARRAY_KEYWORDS.has(keyword) && Array.isArray(value)) {
208
+ encoded[keyword] = value.map((child) => encodeSchema(child, void 0, nextAncestors));
209
+ } else if (SCHEMA_VALUE_KEYWORDS.has(keyword)) {
210
+ encoded[keyword] = encodeSchema(value, void 0, nextAncestors);
211
+ } else if (keyword === "items") {
212
+ encoded[keyword] = Array.isArray(value) ? value.map((child) => encodeSchema(child, void 0, nextAncestors)) : encodeSchema(value, void 0, nextAncestors);
213
+ } else if (keyword === "dependencies" && isObject(value)) {
214
+ encoded[keyword] = Object.fromEntries(
215
+ Object.entries(value).map(([key, child]) => [
216
+ key,
217
+ Array.isArray(child) ? cloneData(child) : encodeSchema(child, void 0, nextAncestors)
218
+ ])
219
+ );
220
+ } else {
221
+ encoded[keyword] = cloneData(value);
222
+ }
223
+ }
224
+ return encoded;
225
+ };
226
+ const compacted = encodeSchema(root, root);
227
+ if (compacted[COMPACT_DEFINITIONS_KEY] !== void 0) {
228
+ throw new Error(`Schema already contains reserved property ${COMPACT_DEFINITIONS_KEY}`);
229
+ }
230
+ const defs = isObject(compacted.$defs) ? { ...compacted.$defs } : {};
231
+ for (const [name, schema] of sharedDefinitions) defs[name] = encodeSchema(schema, schema);
232
+ if (Object.keys(defs).length > 0) compacted.$defs = defs;
233
+ if (sharedDefinitions.size > 0) compacted[COMPACT_DEFINITIONS_KEY] = [...sharedDefinitions.keys()];
234
+ return compacted;
235
+ }
236
+ function compactSchemaForValidation(schema) {
237
+ const copied = cloneData(schema);
238
+ const stripIds = (node, root = false) => {
239
+ if (!isObject(node)) return;
240
+ if (!root) delete node.$id;
241
+ forEachChildSchema(node, (child) => stripIds(child));
242
+ };
243
+ stripIds(copied, true);
244
+ return compactBundledSchema(copied, { maxInlineSchemaBytes: 1024 });
245
+ }
246
+ export {
247
+ COMPACT_DEFINITIONS_KEY,
248
+ compactBundledSchema,
249
+ compactSchemaForValidation
250
+ };
@@ -0,0 +1,8 @@
1
+ import type { z } from 'zod';
2
+ import type { MediaBuyDeliveryReport } from '../types/media-buy-delivery-report.mjs';
3
+ /**
4
+ * Payload-only reporting shape at the SDK pin. Poll responses still require
5
+ * their task status; webhook receivers validate the separate outer envelope.
6
+ * Use parseMediaBuyDeliveryWebhook for strict validation at an older release.
7
+ */
8
+ export declare const MediaBuyDeliveryReportSchema: z.ZodType<MediaBuyDeliveryReport>;
@@ -0,0 +1,8 @@
1
+ import type { z } from 'zod';
2
+ import type { MediaBuyDeliveryReport } from '../types/media-buy-delivery-report';
3
+ /**
4
+ * Payload-only reporting shape at the SDK pin. Poll responses still require
5
+ * their task status; webhook receivers validate the separate outer envelope.
6
+ * Use parseMediaBuyDeliveryWebhook for strict validation at an older release.
7
+ */
8
+ export declare const MediaBuyDeliveryReportSchema: z.ZodType<MediaBuyDeliveryReport>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var media_buy_delivery_report_exports = {};
20
+ __export(media_buy_delivery_report_exports, {
21
+ MediaBuyDeliveryReportSchema: () => MediaBuyDeliveryReportSchema
22
+ });
23
+ module.exports = __toCommonJS(media_buy_delivery_report_exports);
24
+ var import_schemas = require('../types/schemas.generated.js');
25
+ const MediaBuyDeliveryReportSchema = /* @__PURE__ */ import_schemas.GetMediaBuyDeliveryResponseSchema.omit({
26
+ status: true
27
+ });
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ MediaBuyDeliveryReportSchema
31
+ });
@@ -0,0 +1,7 @@
1
+ import { GetMediaBuyDeliveryResponseSchema } from "../types/schemas.generated.mjs";
2
+ const MediaBuyDeliveryReportSchema = /* @__PURE__ */ GetMediaBuyDeliveryResponseSchema.omit({
3
+ status: true
4
+ });
5
+ export {
6
+ MediaBuyDeliveryReportSchema
7
+ };
@@ -0,0 +1,21 @@
1
+ interface SchemaEnvironment {
2
+ schema: unknown;
3
+ root: {
4
+ schema: unknown;
5
+ };
6
+ baseId?: string;
7
+ }
8
+ export interface SchemaDiagnosticOrigin {
9
+ schema: unknown;
10
+ schemaId?: string;
11
+ /** Original AJV function-relative spelling; exact origins remain internal. */
12
+ schemaPath: string;
13
+ }
14
+ export interface SchemaDiagnosticOrigins {
15
+ process: (source: string, environment?: SchemaEnvironment) => string;
16
+ resolve: (schemaPath: string) => unknown;
17
+ origin: (schemaPath: string) => SchemaDiagnosticOrigin | undefined;
18
+ }
19
+ /** Use AJV's supported code.process hook; only diagnostic string literals change. */
20
+ export declare function createSchemaDiagnosticOrigins(): SchemaDiagnosticOrigins;
21
+ export {};
@@ -0,0 +1,21 @@
1
+ interface SchemaEnvironment {
2
+ schema: unknown;
3
+ root: {
4
+ schema: unknown;
5
+ };
6
+ baseId?: string;
7
+ }
8
+ export interface SchemaDiagnosticOrigin {
9
+ schema: unknown;
10
+ schemaId?: string;
11
+ /** Original AJV function-relative spelling; exact origins remain internal. */
12
+ schemaPath: string;
13
+ }
14
+ export interface SchemaDiagnosticOrigins {
15
+ process: (source: string, environment?: SchemaEnvironment) => string;
16
+ resolve: (schemaPath: string) => unknown;
17
+ origin: (schemaPath: string) => SchemaDiagnosticOrigin | undefined;
18
+ }
19
+ /** Use AJV's supported code.process hook; only diagnostic string literals change. */
20
+ export declare function createSchemaDiagnosticOrigins(): SchemaDiagnosticOrigins;
21
+ export {};
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var schema_diagnostic_origins_exports = {};
20
+ __export(schema_diagnostic_origins_exports, {
21
+ createSchemaDiagnosticOrigins: () => createSchemaDiagnosticOrigins
22
+ });
23
+ module.exports = __toCommonJS(schema_diagnostic_origins_exports);
24
+ function object(value) {
25
+ return value !== null && typeof value === "object";
26
+ }
27
+ function schemaPathLiterals(source) {
28
+ const paths = [];
29
+ const stringEnd = (start) => {
30
+ const quote = source[start];
31
+ for (let index = start + 1; index < source.length; index++) {
32
+ if (source[index] === "\\") index++;
33
+ else if (source[index] === quote) return index + 1;
34
+ }
35
+ return -1;
36
+ };
37
+ for (let index = 0; index < source.length; ) {
38
+ const start = index;
39
+ let key;
40
+ if (source[index] === '"' || source[index] === "'") {
41
+ index = stringEnd(index);
42
+ if (index < 0) return void 0;
43
+ try {
44
+ key = JSON.parse(source.slice(start, index));
45
+ } catch {
46
+ }
47
+ } else if (/[A-Za-z_$]/.test(source[index])) {
48
+ while (index < source.length && /[\w$]/.test(source[index])) index++;
49
+ key = source.slice(start, index);
50
+ } else if (source.startsWith("//", index)) {
51
+ index = source.indexOf("\n", index + 2);
52
+ if (index < 0) break;
53
+ } else if (source.startsWith("/*", index)) {
54
+ index = source.indexOf("*/", index + 2);
55
+ if (index < 0) return void 0;
56
+ index += 2;
57
+ } else {
58
+ if (source[index] === "`") return void 0;
59
+ if (source[index] === "/") {
60
+ const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
61
+ if (pointerEscape && /\.replace\(\s*$/.test(source.slice(0, index))) {
62
+ index += pointerEscape.length;
63
+ continue;
64
+ }
65
+ const previous = source.slice(0, index).match(/(?:^|[^\w$])(data\d*)\s*$/);
66
+ if (!previous) return void 0;
67
+ }
68
+ index++;
69
+ }
70
+ if (key !== "schemaPath") continue;
71
+ let valueStart = index;
72
+ while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
73
+ if (source[valueStart] !== ":") continue;
74
+ valueStart++;
75
+ while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
76
+ if (source[valueStart] !== '"') return void 0;
77
+ const end = stringEnd(valueStart);
78
+ if (end < 0) return void 0;
79
+ let value;
80
+ try {
81
+ value = JSON.parse(source.slice(valueStart, end));
82
+ } catch {
83
+ return void 0;
84
+ }
85
+ if (typeof value !== "string" || !value.startsWith("#")) return void 0;
86
+ paths.push({ start: valueStart, end, value });
87
+ index = end;
88
+ }
89
+ return paths;
90
+ }
91
+ function createSchemaDiagnosticOrigins() {
92
+ const indexes = /* @__PURE__ */ new WeakMap();
93
+ const anonymousIds = /* @__PURE__ */ new WeakMap();
94
+ const origins = /* @__PURE__ */ new Map();
95
+ let anonymousId = 0;
96
+ const indexRoot = (root) => {
97
+ const cached = indexes.get(root);
98
+ if (cached) return cached;
99
+ const paths = /* @__PURE__ */ new WeakMap();
100
+ const pending = [[root, "#"]];
101
+ while (pending.length) {
102
+ const [node, pointer] = pending.pop();
103
+ if (paths.has(node)) continue;
104
+ paths.set(node, pointer);
105
+ for (const [key, child] of Object.entries(node)) {
106
+ if (object(child))
107
+ pending.push([child, `${pointer}/${encodeURIComponent(key.replace(/~/g, "~0").replace(/\//g, "~1"))}`]);
108
+ }
109
+ }
110
+ indexes.set(root, paths);
111
+ return paths;
112
+ };
113
+ const origin = (schemaPath) => {
114
+ const hash = schemaPath.indexOf("#");
115
+ if (hash < 0) return void 0;
116
+ let prefix = schemaPath;
117
+ while (prefix.length >= hash + 1) {
118
+ if (origins.has(prefix)) {
119
+ const entry = origins.get(prefix);
120
+ if (!entry) return void 0;
121
+ let cursor = entry.schema;
122
+ let schemaId = entry.schemaId;
123
+ const relative = schemaPath.slice(prefix.length);
124
+ if (relative)
125
+ for (const segment of relative.slice(1).split("/")) {
126
+ let key;
127
+ try {
128
+ key = decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~");
129
+ } catch {
130
+ return void 0;
131
+ }
132
+ if (key === "__proto__" || key === "constructor" || key === "prototype" || !object(cursor) || !Object.hasOwn(cursor, key))
133
+ return void 0;
134
+ cursor = cursor[key];
135
+ if (object(cursor) && typeof cursor.$id === "string") {
136
+ try {
137
+ schemaId = new URL(cursor.$id, schemaId).href;
138
+ } catch {
139
+ schemaId = cursor.$id;
140
+ }
141
+ }
142
+ }
143
+ return { schema: cursor, ...schemaId && { schemaId }, schemaPath: `#${relative}` };
144
+ }
145
+ const slash = prefix.lastIndexOf("/");
146
+ if (slash <= hash) {
147
+ if (prefix.length === hash + 1) break;
148
+ prefix = prefix.slice(0, hash + 1);
149
+ } else prefix = prefix.slice(0, slash);
150
+ }
151
+ return void 0;
152
+ };
153
+ return {
154
+ process(source, environment) {
155
+ const literals = schemaPathLiterals(source);
156
+ if (!environment || !literals?.length || !object(environment.schema) || !object(environment.root.schema))
157
+ return source;
158
+ const root = environment.root.schema;
159
+ const pointer = indexRoot(root).get(environment.schema);
160
+ const document = pointer !== void 0 ? root : environment.schema;
161
+ let id = typeof document.$id === "string" ? document.$id.replace(/#.*$/, "") : void 0;
162
+ if (!id) {
163
+ id = anonymousIds.get(document);
164
+ if (!id) {
165
+ id = `urn:adcp:schema-origin:${anonymousId++}`;
166
+ anonymousIds.set(document, id);
167
+ }
168
+ }
169
+ const prefix = `${id}${pointer ?? "#"}`;
170
+ if (origins.has(prefix) && origins.get(prefix)?.schema !== environment.schema) origins.set(prefix, void 0);
171
+ else if (!origins.has(prefix)) {
172
+ const schemaId = environment.baseId || (typeof environment.schema.$id === "string" ? environment.schema.$id : void 0);
173
+ origins.set(prefix, { schema: environment.schema, ...schemaId && { schemaId } });
174
+ }
175
+ const fragments = [];
176
+ let cursor = 0;
177
+ for (const literal of literals) {
178
+ fragments.push(source.slice(cursor, literal.start), JSON.stringify(prefix + literal.value.slice(1)));
179
+ cursor = literal.end;
180
+ }
181
+ fragments.push(source.slice(cursor));
182
+ return fragments.join("");
183
+ },
184
+ resolve(schemaPath) {
185
+ return origin(schemaPath)?.schema;
186
+ },
187
+ origin
188
+ };
189
+ }
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ createSchemaDiagnosticOrigins
193
+ });