@adcp/sdk 16.2.0 → 16.4.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 (161) hide show
  1. package/AGENTS.md +2 -0
  2. package/dist/lib/adapters/version/3.1/assignments.d.mts +12 -0
  3. package/dist/lib/adapters/version/3.1/assignments.d.ts +12 -0
  4. package/dist/lib/adapters/version/3.1/assignments.js +67 -0
  5. package/dist/lib/adapters/version/3.1/assignments.mjs +43 -0
  6. package/dist/lib/adapters/version/3.1/bidding.d.mts +3 -0
  7. package/dist/lib/adapters/version/3.1/bidding.d.ts +3 -0
  8. package/dist/lib/adapters/version/3.1/bidding.js +115 -0
  9. package/dist/lib/adapters/version/3.1/bidding.mjs +90 -0
  10. package/dist/lib/adapters/version/3.1/delivery.d.mts +7 -0
  11. package/dist/lib/adapters/version/3.1/delivery.d.ts +7 -0
  12. package/dist/lib/adapters/version/3.1/delivery.js +78 -0
  13. package/dist/lib/adapters/version/3.1/delivery.mjs +54 -0
  14. package/dist/lib/adapters/version/3.1/index.d.mts +3 -0
  15. package/dist/lib/adapters/version/3.1/index.d.ts +3 -0
  16. package/dist/lib/adapters/version/3.1/index.js +36 -0
  17. package/dist/lib/adapters/version/3.1/index.mjs +12 -0
  18. package/dist/lib/adapters/version/index.d.mts +59 -7
  19. package/dist/lib/adapters/version/index.d.ts +59 -7
  20. package/dist/lib/adapters/version/index.js +51 -2
  21. package/dist/lib/adapters/version/index.mjs +49 -1
  22. package/dist/lib/adapters/version/negotiate.d.mts +71 -0
  23. package/dist/lib/adapters/version/negotiate.d.ts +71 -0
  24. package/dist/lib/adapters/version/negotiate.js +101 -0
  25. package/dist/lib/adapters/version/negotiate.mjs +73 -0
  26. package/dist/lib/adapters/version/schema-projection.d.mts +33 -0
  27. package/dist/lib/adapters/version/schema-projection.d.ts +33 -0
  28. package/dist/lib/adapters/version/schema-projection.js +294 -0
  29. package/dist/lib/adapters/version/schema-projection.mjs +269 -0
  30. package/dist/lib/adapters/version/translate.d.mts +122 -0
  31. package/dist/lib/adapters/version/translate.d.ts +122 -0
  32. package/dist/lib/adapters/version/translate.js +169 -0
  33. package/dist/lib/adapters/version/translate.mjs +141 -0
  34. package/dist/lib/adapters/version/types.d.mts +51 -10
  35. package/dist/lib/adapters/version/types.d.ts +51 -10
  36. package/dist/lib/core/AgentClient.d.mts +1 -1
  37. package/dist/lib/core/AgentClient.d.ts +1 -1
  38. package/dist/lib/core/AgentClient.js +17 -1
  39. package/dist/lib/core/AgentClient.mjs +17 -1
  40. package/dist/lib/core/ConversationTypes.d.mts +7 -0
  41. package/dist/lib/core/ConversationTypes.d.ts +7 -0
  42. package/dist/lib/core/SingleAgentClient.d.mts +82 -0
  43. package/dist/lib/core/SingleAgentClient.d.ts +82 -0
  44. package/dist/lib/core/SingleAgentClient.js +336 -15
  45. package/dist/lib/core/SingleAgentClient.mjs +350 -17
  46. package/dist/lib/core/TaskExecutor.d.mts +1 -1
  47. package/dist/lib/core/TaskExecutor.d.ts +1 -1
  48. package/dist/lib/core/TaskExecutor.js +182 -31
  49. package/dist/lib/core/TaskExecutor.mjs +183 -32
  50. package/dist/lib/core/account-reduction.d.mts +36 -0
  51. package/dist/lib/core/account-reduction.d.ts +36 -0
  52. package/dist/lib/core/account-reduction.js +127 -0
  53. package/dist/lib/core/account-reduction.mjs +98 -0
  54. package/dist/lib/core/buyer-account-registry.d.mts +52 -0
  55. package/dist/lib/core/buyer-account-registry.d.ts +52 -0
  56. package/dist/lib/core/buyer-account-registry.js +142 -6
  57. package/dist/lib/core/buyer-account-registry.mjs +142 -6
  58. package/dist/lib/errors/index.d.mts +34 -0
  59. package/dist/lib/errors/index.d.ts +34 -0
  60. package/dist/lib/errors/index.js +11 -0
  61. package/dist/lib/errors/index.mjs +10 -0
  62. package/dist/lib/index.d.mts +1 -1
  63. package/dist/lib/index.d.ts +1 -1
  64. package/dist/lib/index.js +2 -0
  65. package/dist/lib/index.mjs +2 -0
  66. package/dist/lib/media-buy/action-contracts.js +4 -4
  67. package/dist/lib/media-buy/action-contracts.mjs +4 -4
  68. package/dist/lib/media-buy/action-types.d.mts +3 -2
  69. package/dist/lib/media-buy/action-types.d.ts +3 -2
  70. package/dist/lib/media-buy/compatibility.d.mts +1 -0
  71. package/dist/lib/media-buy/compatibility.d.ts +1 -0
  72. package/dist/lib/media-buy/compatibility.js +33 -10
  73. package/dist/lib/media-buy/compatibility.mjs +32 -14
  74. package/dist/lib/media-buy/update-fields.generated.d.mts +3 -2
  75. package/dist/lib/media-buy/update-fields.generated.d.ts +3 -2
  76. package/dist/lib/negotiation/buyer.js +11 -5
  77. package/dist/lib/negotiation/buyer.mjs +11 -5
  78. package/dist/lib/negotiation/types.d.mts +4 -2
  79. package/dist/lib/negotiation/types.d.ts +4 -2
  80. package/dist/lib/negotiation/verification.d.mts +15 -6
  81. package/dist/lib/negotiation/verification.d.ts +15 -6
  82. package/dist/lib/negotiation/verification.js +146 -27
  83. package/dist/lib/negotiation/verification.mjs +146 -28
  84. package/dist/lib/negotiation/version.d.mts +6 -0
  85. package/dist/lib/negotiation/version.d.ts +6 -0
  86. package/dist/lib/negotiation/version.js +60 -0
  87. package/dist/lib/negotiation/version.mjs +33 -0
  88. package/dist/lib/registry/types.generated.d.mts +1 -1
  89. package/dist/lib/registry/types.generated.d.ts +1 -1
  90. package/dist/lib/server/create-adcp-server.d.mts +21 -0
  91. package/dist/lib/server/create-adcp-server.d.ts +21 -0
  92. package/dist/lib/server/create-adcp-server.js +98 -16
  93. package/dist/lib/server/create-adcp-server.mjs +84 -2
  94. package/dist/lib/server/error-arm-tools.d.mts +10 -10
  95. package/dist/lib/server/error-arm-tools.d.ts +10 -10
  96. package/dist/lib/server/error-arm-tools.js +22 -58
  97. package/dist/lib/server/error-arm-tools.mjs +30 -65
  98. package/dist/lib/server/index.d.mts +1 -1
  99. package/dist/lib/server/index.d.ts +1 -1
  100. package/dist/lib/storage/interfaces.d.mts +2 -0
  101. package/dist/lib/storage/interfaces.d.ts +2 -0
  102. package/dist/lib/testing/compliance/comply.js +17 -0
  103. package/dist/lib/testing/compliance/comply.mjs +17 -0
  104. package/dist/lib/testing/index.d.mts +3 -0
  105. package/dist/lib/testing/index.d.ts +3 -0
  106. package/dist/lib/testing/index.js +44 -2
  107. package/dist/lib/testing/index.mjs +42 -0
  108. package/dist/lib/testing/storyboard/collection-selection.d.mts +259 -0
  109. package/dist/lib/testing/storyboard/collection-selection.d.ts +259 -0
  110. package/dist/lib/testing/storyboard/collection-selection.js +384 -0
  111. package/dist/lib/testing/storyboard/collection-selection.mjs +348 -0
  112. package/dist/lib/testing/storyboard/context.js +12 -6
  113. package/dist/lib/testing/storyboard/context.mjs +12 -6
  114. package/dist/lib/testing/storyboard/fixture-resolution.d.mts +39 -1
  115. package/dist/lib/testing/storyboard/fixture-resolution.d.ts +39 -1
  116. package/dist/lib/testing/storyboard/fixture-resolution.js +216 -12
  117. package/dist/lib/testing/storyboard/fixture-resolution.mjs +218 -12
  118. package/dist/lib/testing/storyboard/index.d.mts +9 -2
  119. package/dist/lib/testing/storyboard/index.d.ts +9 -2
  120. package/dist/lib/testing/storyboard/index.js +51 -2
  121. package/dist/lib/testing/storyboard/index.mjs +49 -1
  122. package/dist/lib/testing/storyboard/prepared-fixtures.d.mts +471 -0
  123. package/dist/lib/testing/storyboard/prepared-fixtures.d.ts +471 -0
  124. package/dist/lib/testing/storyboard/prepared-fixtures.js +434 -0
  125. package/dist/lib/testing/storyboard/prepared-fixtures.mjs +389 -0
  126. package/dist/lib/testing/storyboard/protected-context.d.mts +127 -0
  127. package/dist/lib/testing/storyboard/protected-context.d.ts +127 -0
  128. package/dist/lib/testing/storyboard/protected-context.js +301 -0
  129. package/dist/lib/testing/storyboard/protected-context.mjs +267 -0
  130. package/dist/lib/testing/storyboard/rejection-hints.js +13 -4
  131. package/dist/lib/testing/storyboard/rejection-hints.mjs +13 -4
  132. package/dist/lib/testing/storyboard/runner.d.mts +24 -0
  133. package/dist/lib/testing/storyboard/runner.d.ts +24 -0
  134. package/dist/lib/testing/storyboard/runner.js +1061 -105
  135. package/dist/lib/testing/storyboard/runner.mjs +1075 -106
  136. package/dist/lib/testing/storyboard/seeding.d.mts +15 -1
  137. package/dist/lib/testing/storyboard/seeding.d.ts +15 -1
  138. package/dist/lib/testing/storyboard/seeding.js +272 -12
  139. package/dist/lib/testing/storyboard/seeding.mjs +274 -13
  140. package/dist/lib/testing/storyboard/types.d.mts +207 -10
  141. package/dist/lib/testing/storyboard/types.d.ts +207 -10
  142. package/dist/lib/testing/storyboard/types.js +1 -1
  143. package/dist/lib/testing/storyboard/types.mjs +1 -1
  144. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  145. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  146. package/dist/lib/testing/storyboard/validations.js +95 -0
  147. package/dist/lib/testing/storyboard/validations.mjs +95 -0
  148. package/dist/lib/validation/bundled-schema-store.js +5 -0
  149. package/dist/lib/validation/bundled-schema-store.mjs +4 -0
  150. package/dist/lib/validation/schema-loader.js +19 -2
  151. package/dist/lib/validation/schema-loader.mjs +22 -3
  152. package/dist/lib/version.d.mts +3 -3
  153. package/dist/lib/version.d.ts +3 -3
  154. package/dist/lib/version.js +3 -3
  155. package/dist/lib/version.mjs +3 -3
  156. package/docs/TYPE-SUMMARY.md +2 -2
  157. package/docs/guides/COLLECTION-FIXTURE-FOUNDATION.md +850 -0
  158. package/docs/guides/PROPOSAL-TERMS-VERIFICATION.md +66 -0
  159. package/docs/llms.txt +4 -3
  160. package/docs/migration-14.x-rc-worksheet.md +4 -4
  161. package/package.json +1 -1
@@ -1,20 +1,31 @@
1
1
  /**
2
- * Registry of per-version request adapters, keyed by target AdCP version string.
2
+ * Registry of per-version adapters, keyed by the older AdCP release of each
3
+ * consecutive minor pair (`'3.1'` holds the 3.2 ↔ 3.1 adapters, `'3.0'` the
4
+ * 3.1 ↔ 3.0 adapters).
3
5
  *
4
- * `resolveAdapterKey` maps a (clientVersion, sellerCaps) pair to the adapter
5
- * key whose adapters should be applied. `getVersionAdapter` looks up the
6
- * per-tool adapter for that key. The dispatch in `SingleAgentClient` calls
7
- * both; tools without a registered adapter for the resolved key pass through
8
- * unchanged.
6
+ * `negotiateAdcpRelease` picks the wire release for a seller.
7
+ * `convertRequest` / `convertResponse` then chain the adapters and the
8
+ * schema projection across every step between the client's release and the
9
+ * wire release. `resolveAdapterKey` remains for sellers whose release cannot
10
+ * be negotiated (synthetic capabilities), where only the 3.0 adapters apply.
9
11
  *
10
12
  * Add a new version transition by:
11
- * 1. Create a `version/<target>/` directory with per-tool adapter modules.
13
+ * 1. Create a `version/<target>/` directory with per-tool adapter modules
14
+ * for renames and moves. Pure additions need no adapter: the schema
15
+ * projection removes and reports them.
12
16
  * 2. Collect them in `version/<target>/index.ts` as a `ReadonlyArray<VersionAdapter>`.
13
17
  * 3. Register below.
14
18
  * 4. Add tests to the conformance suite.
15
19
  */
16
20
  import type { VersionAdapter } from './types';
21
+ import { type AccountIdentityDowngrade, type RequestTranslation, type ResponseTranslation } from './translate';
17
22
  export type { VersionAdapter, VersionDrift } from './types';
23
+ export type { AccountIdentityDowngrade, RequestTranslation, ResponseTranslation, TranslationStep } from './translate';
24
+ export { translationSteps } from './translate';
25
+ export { negotiateAdcpRelease, isNegotiationFailure, parseAdcpRelease, adcpMinorLine, compareAdcpMinorLines, } from './negotiate';
26
+ export type { NegotiatedAdcpRelease, AdcpNegotiationFailure, AdcpNegotiationSource } from './negotiate';
27
+ export { projectToolPayload, releaseDefinesTool } from './schema-projection';
28
+ export type { ProjectionDrop, ProjectionResult } from './schema-projection';
18
29
  /**
19
30
  * Look up the version adapter for a given (adapterKey, toolName) pair.
20
31
  * Returns `undefined` when no adapter is registered — caller passes through.
@@ -36,3 +47,44 @@ export declare function resolveAdapterKey(clientVersion: string | undefined, cap
36
47
  * Used by the conformance test suite as the authoritative list.
37
48
  */
38
49
  export declare function listVersionAdapterTools(adapterKey: string): string[];
50
+ /**
51
+ * Convert a request built for `fromVersion` (the client's release) down to
52
+ * the negotiated wire release `toVersion`.
53
+ */
54
+ export declare function convertRequest<T>(toolName: string, params: T, options: {
55
+ fromVersion: string;
56
+ toVersion: string;
57
+ accountIdentity?: AccountIdentityDowngrade;
58
+ /** Defaults to `isMutatingTask(toolName)`. */
59
+ mutating?: boolean;
60
+ }): RequestTranslation<T>;
61
+ /**
62
+ * Convert a response served at the wire release `fromVersion` up to the
63
+ * client's release `toVersion`.
64
+ */
65
+ export declare function convertResponse<T>(toolName: string, data: T, options: {
66
+ fromVersion: string;
67
+ toVersion: string;
68
+ }): ResponseTranslation<T>;
69
+ /**
70
+ * Server side: convert an older buyer's request from the served release
71
+ * `fromVersion` up to the server's release `toVersion`.
72
+ */
73
+ export declare function upgradeRequest<T>(toolName: string, params: T, options: {
74
+ fromVersion: string;
75
+ toVersion: string;
76
+ }): {
77
+ params: T;
78
+ drifts: import('./types').VersionDrift[];
79
+ };
80
+ /**
81
+ * Server side: convert a handler's response from the server's release
82
+ * `fromVersion` down to the served release `toVersion`.
83
+ */
84
+ export declare function downgradeResponse<T>(toolName: string, data: T, options: {
85
+ fromVersion: string;
86
+ toVersion: string;
87
+ }): {
88
+ data: T;
89
+ drifts: import('./types').VersionDrift[];
90
+ };
@@ -18,18 +18,37 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var version_exports = {};
20
20
  __export(version_exports, {
21
+ adcpMinorLine: () => import_negotiate.adcpMinorLine,
22
+ compareAdcpMinorLines: () => import_negotiate.compareAdcpMinorLines,
23
+ convertRequest: () => convertRequest,
24
+ convertResponse: () => convertResponse,
25
+ downgradeResponse: () => downgradeResponse,
21
26
  getVersionAdapter: () => getVersionAdapter,
27
+ isNegotiationFailure: () => import_negotiate.isNegotiationFailure,
22
28
  listVersionAdapterTools: () => listVersionAdapterTools,
23
- resolveAdapterKey: () => resolveAdapterKey
29
+ negotiateAdcpRelease: () => import_negotiate.negotiateAdcpRelease,
30
+ parseAdcpRelease: () => import_negotiate.parseAdcpRelease,
31
+ projectToolPayload: () => import_schema_projection.projectToolPayload,
32
+ releaseDefinesTool: () => import_schema_projection.releaseDefinesTool,
33
+ resolveAdapterKey: () => resolveAdapterKey,
34
+ translationSteps: () => import_translate2.translationSteps,
35
+ upgradeRequest: () => upgradeRequest
24
36
  });
25
37
  module.exports = __toCommonJS(version_exports);
26
38
  var import_adcp_version_config = require('../../utils/adcp-version-config.js');
39
+ var import_idempotency = require('../../utils/idempotency.js');
27
40
  var import__ = require('./3.0/index.js');
41
+ var import__2 = require('./3.1/index.js');
42
+ var import_translate = require('./translate.js');
43
+ var import_translate2 = require('./translate.js');
44
+ var import_negotiate = require('./negotiate.js');
45
+ var import_schema_projection = require('./schema-projection.js');
28
46
  const REGISTRY = /* @__PURE__ */ new Map();
29
47
  function register(version, adapters) {
30
48
  REGISTRY.set(version, new Map(adapters.map((a) => [a.toolName, a])));
31
49
  }
32
50
  register("3.0", import__.v30Adapters);
51
+ register("3.1", import__2.v31Adapters);
33
52
  function getVersionAdapter(adapterKey, toolName) {
34
53
  return REGISTRY.get(adapterKey)?.get(toolName);
35
54
  }
@@ -40,9 +59,39 @@ function resolveAdapterKey(clientVersion, caps) {
40
59
  function listVersionAdapterTools(adapterKey) {
41
60
  return [...REGISTRY.get(adapterKey)?.keys() ?? []];
42
61
  }
62
+ function convertRequest(toolName, params, options) {
63
+ return (0, import_translate.convertRequestToRelease)(toolName, params, {
64
+ fromVersion: options.fromVersion,
65
+ toVersion: options.toVersion,
66
+ accountIdentity: options.accountIdentity ?? "refuse",
67
+ mutating: options.mutating ?? (0, import_idempotency.isMutatingTask)(toolName),
68
+ adapters: getVersionAdapter
69
+ });
70
+ }
71
+ function convertResponse(toolName, data, options) {
72
+ return (0, import_translate.convertResponseFromRelease)(toolName, data, { ...options, adapters: getVersionAdapter });
73
+ }
74
+ function upgradeRequest(toolName, params, options) {
75
+ return (0, import_translate.convertRequestFromRelease)(toolName, params, { ...options, adapters: getVersionAdapter });
76
+ }
77
+ function downgradeResponse(toolName, data, options) {
78
+ return (0, import_translate.convertResponseToRelease)(toolName, data, { ...options, adapters: getVersionAdapter });
79
+ }
43
80
  // Annotate the CommonJS export names for ESM import in node:
44
81
  0 && (module.exports = {
82
+ adcpMinorLine,
83
+ compareAdcpMinorLines,
84
+ convertRequest,
85
+ convertResponse,
86
+ downgradeResponse,
45
87
  getVersionAdapter,
88
+ isNegotiationFailure,
46
89
  listVersionAdapterTools,
47
- resolveAdapterKey
90
+ negotiateAdcpRelease,
91
+ parseAdcpRelease,
92
+ projectToolPayload,
93
+ releaseDefinesTool,
94
+ resolveAdapterKey,
95
+ translationSteps,
96
+ upgradeRequest
48
97
  });
@@ -1,10 +1,28 @@
1
1
  import { shouldOmit31Fields } from "../../utils/adcp-version-config.mjs";
2
+ import { isMutatingTask } from "../../utils/idempotency.mjs";
2
3
  import { v30Adapters } from "./3.0/index.mjs";
4
+ import { v31Adapters } from "./3.1/index.mjs";
5
+ import {
6
+ convertRequestFromRelease,
7
+ convertRequestToRelease,
8
+ convertResponseFromRelease,
9
+ convertResponseToRelease
10
+ } from "./translate.mjs";
11
+ import { translationSteps } from "./translate.mjs";
12
+ import {
13
+ negotiateAdcpRelease,
14
+ isNegotiationFailure,
15
+ parseAdcpRelease,
16
+ adcpMinorLine,
17
+ compareAdcpMinorLines
18
+ } from "./negotiate.mjs";
19
+ import { projectToolPayload, releaseDefinesTool } from "./schema-projection.mjs";
3
20
  const REGISTRY = /* @__PURE__ */ new Map();
4
21
  function register(version, adapters) {
5
22
  REGISTRY.set(version, new Map(adapters.map((a) => [a.toolName, a])));
6
23
  }
7
24
  register("3.0", v30Adapters);
25
+ register("3.1", v31Adapters);
8
26
  function getVersionAdapter(adapterKey, toolName) {
9
27
  return REGISTRY.get(adapterKey)?.get(toolName);
10
28
  }
@@ -15,8 +33,38 @@ function resolveAdapterKey(clientVersion, caps) {
15
33
  function listVersionAdapterTools(adapterKey) {
16
34
  return [...REGISTRY.get(adapterKey)?.keys() ?? []];
17
35
  }
36
+ function convertRequest(toolName, params, options) {
37
+ return convertRequestToRelease(toolName, params, {
38
+ fromVersion: options.fromVersion,
39
+ toVersion: options.toVersion,
40
+ accountIdentity: options.accountIdentity ?? "refuse",
41
+ mutating: options.mutating ?? isMutatingTask(toolName),
42
+ adapters: getVersionAdapter
43
+ });
44
+ }
45
+ function convertResponse(toolName, data, options) {
46
+ return convertResponseFromRelease(toolName, data, { ...options, adapters: getVersionAdapter });
47
+ }
48
+ function upgradeRequest(toolName, params, options) {
49
+ return convertRequestFromRelease(toolName, params, { ...options, adapters: getVersionAdapter });
50
+ }
51
+ function downgradeResponse(toolName, data, options) {
52
+ return convertResponseToRelease(toolName, data, { ...options, adapters: getVersionAdapter });
53
+ }
18
54
  export {
55
+ adcpMinorLine,
56
+ compareAdcpMinorLines,
57
+ convertRequest,
58
+ convertResponse,
59
+ downgradeResponse,
19
60
  getVersionAdapter,
61
+ isNegotiationFailure,
20
62
  listVersionAdapterTools,
21
- resolveAdapterKey
63
+ negotiateAdcpRelease,
64
+ parseAdcpRelease,
65
+ projectToolPayload,
66
+ releaseDefinesTool,
67
+ resolveAdapterKey,
68
+ translationSteps,
69
+ upgradeRequest
22
70
  };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Per-seller AdCP release negotiation.
3
+ *
4
+ * The client builds every request in the shape of its own pinned release (the
5
+ * latest the SDK supports, unless the adopter pins lower). Before a call goes
6
+ * out, this module picks the release actually spoken on the wire: the highest
7
+ * release both sides support. Requests are then converted down to that
8
+ * release and responses converted back up (see `translate.ts`).
9
+ */
10
+ import type { AdcpCapabilities } from '../../utils/capabilities.mjs';
11
+ export interface ParsedAdcpRelease {
12
+ major: number;
13
+ minor: number;
14
+ patch: number;
15
+ prerelease?: string;
16
+ /** Whether the source string carried a patch component (`3.1.4` vs `3.1`). */
17
+ hasPatch: boolean;
18
+ }
19
+ export declare function parseAdcpRelease(value: string): ParsedAdcpRelease | undefined;
20
+ /** `MAJOR.MINOR` line of a release, e.g. `'3.2'` for `'3.2.5'` or `'3.2.0-beta.6'`. */
21
+ export declare function adcpMinorLine(value: string): string | undefined;
22
+ /** Compare two releases by `MAJOR.MINOR` only. */
23
+ export declare function compareAdcpMinorLines(left: string, right: string): number;
24
+ export type AdcpNegotiationSource =
25
+ /** The seller lists the client's own minor line in `supported_versions`. */
26
+ 'same_release'
27
+ /** The highest older GA line from the seller's `supported_versions`. */
28
+ | 'supported_versions'
29
+ /** No `supported_versions`; the release the seller served on discovery. */
30
+ | 'served_version'
31
+ /** A declared AdCP 3 seller with no release metadata predates 3.1. */
32
+ | 'legacy_v3';
33
+ export interface NegotiatedAdcpRelease {
34
+ /**
35
+ * Release to speak on the wire. Equal to the client's own pin when the
36
+ * seller supports the client's minor line, otherwise the seller's
37
+ * release-precision `MAJOR.MINOR` (e.g. `'3.1'`).
38
+ */
39
+ version: string;
40
+ source: AdcpNegotiationSource;
41
+ /** Whether `version` is on an older minor line than the client pin. */
42
+ downgraded: boolean;
43
+ }
44
+ export interface AdcpNegotiationFailure {
45
+ version?: undefined;
46
+ reason: 'no_common_version';
47
+ /** The seller's advertised releases, for diagnostics. */
48
+ advertised: string[];
49
+ }
50
+ type NegotiationCapabilities = Pick<AdcpCapabilities, 'supportedVersions' | 'servedVersion' | '_synthetic'> & {
51
+ version?: AdcpCapabilities['version'];
52
+ majorVersions?: AdcpCapabilities['majorVersions'];
53
+ _raw?: Record<string, unknown>;
54
+ };
55
+ /**
56
+ * Pick the highest AdCP release both the client and the seller support.
57
+ *
58
+ * - Returns `undefined` when there is no authoritative evidence to negotiate
59
+ * on (no capabilities, or capabilities synthesized after a failed
60
+ * discovery call). Callers keep their pre-negotiation behavior.
61
+ * - Returns an {@link AdcpNegotiationFailure} when the seller advertises
62
+ * releases but none of them is on or below the client's line.
63
+ *
64
+ * Same-line matches return the client's exact pin so a seller that supports
65
+ * the client's minor sees the same wire version as before negotiation
66
+ * existed. Prereleases on older lines are never selected: a prerelease wire
67
+ * shape matches only itself, and the SDK ships GA bundles for older lines.
68
+ */
69
+ export declare function negotiateAdcpRelease(clientVersion: string, capabilities: NegotiationCapabilities | undefined): NegotiatedAdcpRelease | AdcpNegotiationFailure | undefined;
70
+ export declare function isNegotiationFailure(value: NegotiatedAdcpRelease | AdcpNegotiationFailure | undefined): value is AdcpNegotiationFailure;
71
+ export {};
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Per-seller AdCP release negotiation.
3
+ *
4
+ * The client builds every request in the shape of its own pinned release (the
5
+ * latest the SDK supports, unless the adopter pins lower). Before a call goes
6
+ * out, this module picks the release actually spoken on the wire: the highest
7
+ * release both sides support. Requests are then converted down to that
8
+ * release and responses converted back up (see `translate.ts`).
9
+ */
10
+ import type { AdcpCapabilities } from '../../utils/capabilities';
11
+ export interface ParsedAdcpRelease {
12
+ major: number;
13
+ minor: number;
14
+ patch: number;
15
+ prerelease?: string;
16
+ /** Whether the source string carried a patch component (`3.1.4` vs `3.1`). */
17
+ hasPatch: boolean;
18
+ }
19
+ export declare function parseAdcpRelease(value: string): ParsedAdcpRelease | undefined;
20
+ /** `MAJOR.MINOR` line of a release, e.g. `'3.2'` for `'3.2.5'` or `'3.2.0-beta.6'`. */
21
+ export declare function adcpMinorLine(value: string): string | undefined;
22
+ /** Compare two releases by `MAJOR.MINOR` only. */
23
+ export declare function compareAdcpMinorLines(left: string, right: string): number;
24
+ export type AdcpNegotiationSource =
25
+ /** The seller lists the client's own minor line in `supported_versions`. */
26
+ 'same_release'
27
+ /** The highest older GA line from the seller's `supported_versions`. */
28
+ | 'supported_versions'
29
+ /** No `supported_versions`; the release the seller served on discovery. */
30
+ | 'served_version'
31
+ /** A declared AdCP 3 seller with no release metadata predates 3.1. */
32
+ | 'legacy_v3';
33
+ export interface NegotiatedAdcpRelease {
34
+ /**
35
+ * Release to speak on the wire. Equal to the client's own pin when the
36
+ * seller supports the client's minor line, otherwise the seller's
37
+ * release-precision `MAJOR.MINOR` (e.g. `'3.1'`).
38
+ */
39
+ version: string;
40
+ source: AdcpNegotiationSource;
41
+ /** Whether `version` is on an older minor line than the client pin. */
42
+ downgraded: boolean;
43
+ }
44
+ export interface AdcpNegotiationFailure {
45
+ version?: undefined;
46
+ reason: 'no_common_version';
47
+ /** The seller's advertised releases, for diagnostics. */
48
+ advertised: string[];
49
+ }
50
+ type NegotiationCapabilities = Pick<AdcpCapabilities, 'supportedVersions' | 'servedVersion' | '_synthetic'> & {
51
+ version?: AdcpCapabilities['version'];
52
+ majorVersions?: AdcpCapabilities['majorVersions'];
53
+ _raw?: Record<string, unknown>;
54
+ };
55
+ /**
56
+ * Pick the highest AdCP release both the client and the seller support.
57
+ *
58
+ * - Returns `undefined` when there is no authoritative evidence to negotiate
59
+ * on (no capabilities, or capabilities synthesized after a failed
60
+ * discovery call). Callers keep their pre-negotiation behavior.
61
+ * - Returns an {@link AdcpNegotiationFailure} when the seller advertises
62
+ * releases but none of them is on or below the client's line.
63
+ *
64
+ * Same-line matches return the client's exact pin so a seller that supports
65
+ * the client's minor sees the same wire version as before negotiation
66
+ * existed. Prereleases on older lines are never selected: a prerelease wire
67
+ * shape matches only itself, and the SDK ships GA bundles for older lines.
68
+ */
69
+ export declare function negotiateAdcpRelease(clientVersion: string, capabilities: NegotiationCapabilities | undefined): NegotiatedAdcpRelease | AdcpNegotiationFailure | undefined;
70
+ export declare function isNegotiationFailure(value: NegotiatedAdcpRelease | AdcpNegotiationFailure | undefined): value is AdcpNegotiationFailure;
71
+ export {};
@@ -0,0 +1,101 @@
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 negotiate_exports = {};
20
+ __export(negotiate_exports, {
21
+ adcpMinorLine: () => adcpMinorLine,
22
+ compareAdcpMinorLines: () => compareAdcpMinorLines,
23
+ isNegotiationFailure: () => isNegotiationFailure,
24
+ negotiateAdcpRelease: () => negotiateAdcpRelease,
25
+ parseAdcpRelease: () => parseAdcpRelease
26
+ });
27
+ module.exports = __toCommonJS(negotiate_exports);
28
+ var import_schema_loader = require('../../validation/schema-loader.js');
29
+ function parseAdcpRelease(value) {
30
+ const match = /^v?(\d+)\.(\d+)(?:\.(\d+))?(?:-([A-Za-z0-9.-]+))?(?:\+[A-Za-z0-9.-]+)?$/.exec(value.trim());
31
+ if (!match) return void 0;
32
+ return {
33
+ major: Number(match[1]),
34
+ minor: Number(match[2]),
35
+ patch: Number(match[3] ?? 0),
36
+ hasPatch: match[3] !== void 0,
37
+ ...match[4] !== void 0 && { prerelease: match[4] }
38
+ };
39
+ }
40
+ function adcpMinorLine(value) {
41
+ const release = parseAdcpRelease(value);
42
+ return release ? `${release.major}.${release.minor}` : void 0;
43
+ }
44
+ function compareAdcpMinorLines(left, right) {
45
+ const a = parseAdcpRelease(left);
46
+ const b = parseAdcpRelease(right);
47
+ if (!a || !b) return 0;
48
+ return a.major - b.major || a.minor - b.minor;
49
+ }
50
+ function negotiateAdcpRelease(clientVersion, capabilities) {
51
+ if (!capabilities || capabilities._synthetic) return void 0;
52
+ const client = parseAdcpRelease(clientVersion);
53
+ if (!client) return void 0;
54
+ const advertised = (capabilities.supportedVersions ?? []).filter((v) => typeof v === "string");
55
+ if (advertised.length > 0) {
56
+ let best;
57
+ for (const value of advertised) {
58
+ const release = parseAdcpRelease(value);
59
+ if (!release || release.major !== client.major) continue;
60
+ if (release.minor === client.minor) {
61
+ if (release.prerelease !== client.prerelease) continue;
62
+ return { version: clientVersion, source: "same_release", downgraded: false };
63
+ }
64
+ if (release.minor > client.minor || release.prerelease !== void 0) continue;
65
+ if (!(0, import_schema_loader.hasSchemaBundle)(`${release.major}.${release.minor}`)) continue;
66
+ if (!best || release.minor > best.release.minor) best = { release, value };
67
+ }
68
+ if (!best) return { reason: "no_common_version", advertised };
69
+ return {
70
+ version: `${best.release.major}.${best.release.minor}`,
71
+ source: "supported_versions",
72
+ downgraded: true
73
+ };
74
+ }
75
+ const served = capabilities.servedVersion ?? (typeof capabilities._raw?.adcp_version === "string" ? capabilities._raw.adcp_version : void 0);
76
+ const servedRelease = served !== void 0 ? parseAdcpRelease(served) : void 0;
77
+ if (servedRelease && servedRelease.major === client.major) {
78
+ if (servedRelease.minor >= client.minor) {
79
+ return { version: clientVersion, source: "served_version", downgraded: false };
80
+ }
81
+ const servedLine = `${servedRelease.major}.${servedRelease.minor}`;
82
+ if (servedRelease.prerelease !== void 0 || !(0, import_schema_loader.hasSchemaBundle)(servedLine)) return void 0;
83
+ return { version: servedLine, source: "served_version", downgraded: true };
84
+ }
85
+ if (capabilities.version === "v3" && client.major === 3) {
86
+ if (client.minor === 0) return { version: clientVersion, source: "legacy_v3", downgraded: false };
87
+ return { version: "3.0", source: "legacy_v3", downgraded: true };
88
+ }
89
+ return void 0;
90
+ }
91
+ function isNegotiationFailure(value) {
92
+ return value !== void 0 && "reason" in value;
93
+ }
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ adcpMinorLine,
97
+ compareAdcpMinorLines,
98
+ isNegotiationFailure,
99
+ negotiateAdcpRelease,
100
+ parseAdcpRelease
101
+ });
@@ -0,0 +1,73 @@
1
+ import { hasSchemaBundle } from "../../validation/schema-loader.mjs";
2
+ function parseAdcpRelease(value) {
3
+ const match = /^v?(\d+)\.(\d+)(?:\.(\d+))?(?:-([A-Za-z0-9.-]+))?(?:\+[A-Za-z0-9.-]+)?$/.exec(value.trim());
4
+ if (!match) return void 0;
5
+ return {
6
+ major: Number(match[1]),
7
+ minor: Number(match[2]),
8
+ patch: Number(match[3] ?? 0),
9
+ hasPatch: match[3] !== void 0,
10
+ ...match[4] !== void 0 && { prerelease: match[4] }
11
+ };
12
+ }
13
+ function adcpMinorLine(value) {
14
+ const release = parseAdcpRelease(value);
15
+ return release ? `${release.major}.${release.minor}` : void 0;
16
+ }
17
+ function compareAdcpMinorLines(left, right) {
18
+ const a = parseAdcpRelease(left);
19
+ const b = parseAdcpRelease(right);
20
+ if (!a || !b) return 0;
21
+ return a.major - b.major || a.minor - b.minor;
22
+ }
23
+ function negotiateAdcpRelease(clientVersion, capabilities) {
24
+ if (!capabilities || capabilities._synthetic) return void 0;
25
+ const client = parseAdcpRelease(clientVersion);
26
+ if (!client) return void 0;
27
+ const advertised = (capabilities.supportedVersions ?? []).filter((v) => typeof v === "string");
28
+ if (advertised.length > 0) {
29
+ let best;
30
+ for (const value of advertised) {
31
+ const release = parseAdcpRelease(value);
32
+ if (!release || release.major !== client.major) continue;
33
+ if (release.minor === client.minor) {
34
+ if (release.prerelease !== client.prerelease) continue;
35
+ return { version: clientVersion, source: "same_release", downgraded: false };
36
+ }
37
+ if (release.minor > client.minor || release.prerelease !== void 0) continue;
38
+ if (!hasSchemaBundle(`${release.major}.${release.minor}`)) continue;
39
+ if (!best || release.minor > best.release.minor) best = { release, value };
40
+ }
41
+ if (!best) return { reason: "no_common_version", advertised };
42
+ return {
43
+ version: `${best.release.major}.${best.release.minor}`,
44
+ source: "supported_versions",
45
+ downgraded: true
46
+ };
47
+ }
48
+ const served = capabilities.servedVersion ?? (typeof capabilities._raw?.adcp_version === "string" ? capabilities._raw.adcp_version : void 0);
49
+ const servedRelease = served !== void 0 ? parseAdcpRelease(served) : void 0;
50
+ if (servedRelease && servedRelease.major === client.major) {
51
+ if (servedRelease.minor >= client.minor) {
52
+ return { version: clientVersion, source: "served_version", downgraded: false };
53
+ }
54
+ const servedLine = `${servedRelease.major}.${servedRelease.minor}`;
55
+ if (servedRelease.prerelease !== void 0 || !hasSchemaBundle(servedLine)) return void 0;
56
+ return { version: servedLine, source: "served_version", downgraded: true };
57
+ }
58
+ if (capabilities.version === "v3" && client.major === 3) {
59
+ if (client.minor === 0) return { version: clientVersion, source: "legacy_v3", downgraded: false };
60
+ return { version: "3.0", source: "legacy_v3", downgraded: true };
61
+ }
62
+ return void 0;
63
+ }
64
+ function isNegotiationFailure(value) {
65
+ return value !== void 0 && "reason" in value;
66
+ }
67
+ export {
68
+ adcpMinorLine,
69
+ compareAdcpMinorLines,
70
+ isNegotiationFailure,
71
+ negotiateAdcpRelease,
72
+ parseAdcpRelease
73
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Schema-driven projection between two AdCP releases.
3
+ *
4
+ * Converting a payload down from a newer release to an older one removes what
5
+ * the older release cannot express: properties the newer schema declares but
6
+ * the older one does not, enum values the older release does not define, and
7
+ * union variants whose discriminator the older release does not know.
8
+ * Everything the projection removes is reported so callers can surface it.
9
+ *
10
+ * The projection is a diff of the two schemas, not a whitelist of the older
11
+ * one. A property neither release declares (an adopter extension at an open
12
+ * object, say) is left alone, as is anything under an object whose older
13
+ * schema declares no properties (a free-form map such as `ext`).
14
+ */
15
+ import { type Direction } from '../../validation/schema-loader.mjs';
16
+ export interface ProjectionDrop {
17
+ /** JSON path of the removed value, e.g. `packages[0].bidding`. */
18
+ path: string;
19
+ /** What kind of value the older release could not express. */
20
+ kind: 'field' | 'enum_value' | 'variant';
21
+ }
22
+ export interface ProjectionResult<T = unknown> {
23
+ value: T;
24
+ dropped: ProjectionDrop[];
25
+ }
26
+ /**
27
+ * Project a tool payload from the `fromVersion` schema to the `toVersion`
28
+ * schema. Returns the original reference unchanged (and no drops) when
29
+ * nothing needs removing or when either release has no schema for the tool.
30
+ */
31
+ export declare function projectToolPayload<T>(toolName: string, direction: Direction, payload: T, fromVersion: string, toVersion: string): ProjectionResult<T>;
32
+ /** Whether the release's schema bundle defines a request schema for the tool. */
33
+ export declare function releaseDefinesTool(toolName: string, version: string): boolean;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Schema-driven projection between two AdCP releases.
3
+ *
4
+ * Converting a payload down from a newer release to an older one removes what
5
+ * the older release cannot express: properties the newer schema declares but
6
+ * the older one does not, enum values the older release does not define, and
7
+ * union variants whose discriminator the older release does not know.
8
+ * Everything the projection removes is reported so callers can surface it.
9
+ *
10
+ * The projection is a diff of the two schemas, not a whitelist of the older
11
+ * one. A property neither release declares (an adopter extension at an open
12
+ * object, say) is left alone, as is anything under an object whose older
13
+ * schema declares no properties (a free-form map such as `ext`).
14
+ */
15
+ import { type Direction } from '../../validation/schema-loader';
16
+ export interface ProjectionDrop {
17
+ /** JSON path of the removed value, e.g. `packages[0].bidding`. */
18
+ path: string;
19
+ /** What kind of value the older release could not express. */
20
+ kind: 'field' | 'enum_value' | 'variant';
21
+ }
22
+ export interface ProjectionResult<T = unknown> {
23
+ value: T;
24
+ dropped: ProjectionDrop[];
25
+ }
26
+ /**
27
+ * Project a tool payload from the `fromVersion` schema to the `toVersion`
28
+ * schema. Returns the original reference unchanged (and no drops) when
29
+ * nothing needs removing or when either release has no schema for the tool.
30
+ */
31
+ export declare function projectToolPayload<T>(toolName: string, direction: Direction, payload: T, fromVersion: string, toVersion: string): ProjectionResult<T>;
32
+ /** Whether the release's schema bundle defines a request schema for the tool. */
33
+ export declare function releaseDefinesTool(toolName: string, version: string): boolean;