@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.
- package/dist/lib/adapters/version/3.0/brand-fields.d.mts +7 -1
- package/dist/lib/adapters/version/3.0/brand-fields.d.ts +7 -1
- package/dist/lib/adapters/version/3.0/brand-fields.js +139 -3
- package/dist/lib/adapters/version/3.0/brand-fields.mjs +136 -2
- package/dist/lib/adapters/version/3.0/index.js +6 -0
- package/dist/lib/adapters/version/3.0/index.mjs +7 -1
- package/dist/lib/adapters/version/3.1/bidding.js +1 -1
- package/dist/lib/adapters/version/3.1/bidding.mjs +1 -1
- package/dist/lib/adapters/version/types.d.mts +5 -0
- package/dist/lib/adapters/version/types.d.ts +5 -0
- package/dist/lib/canonical-references/index.js +2 -0
- package/dist/lib/canonical-references/index.mjs +2 -0
- package/dist/lib/client/account-changes.d.mts +3 -1
- package/dist/lib/client/account-changes.d.ts +3 -1
- package/dist/lib/client/account-changes.js +22 -2
- package/dist/lib/client/account-changes.mjs +22 -2
- package/dist/lib/conformance/oracle.js +3 -2
- package/dist/lib/conformance/oracle.mjs +3 -2
- package/dist/lib/core/AgentClient.d.mts +165 -1
- package/dist/lib/core/AgentClient.d.ts +165 -1
- package/dist/lib/core/AgentClient.js +446 -8
- package/dist/lib/core/AgentClient.mjs +446 -8
- package/dist/lib/core/ConversationTypes.d.mts +8 -0
- package/dist/lib/core/ConversationTypes.d.ts +8 -0
- package/dist/lib/core/ProtocolResponseParser.d.mts +1 -1
- package/dist/lib/core/ProtocolResponseParser.d.ts +1 -1
- package/dist/lib/core/ProtocolResponseParser.js +28 -18
- package/dist/lib/core/ProtocolResponseParser.mjs +11 -1
- package/dist/lib/core/ResponseValidator.js +1 -1
- package/dist/lib/core/ResponseValidator.mjs +1 -1
- package/dist/lib/core/SingleAgentClient.d.mts +116 -6
- package/dist/lib/core/SingleAgentClient.d.ts +116 -6
- package/dist/lib/core/SingleAgentClient.js +556 -84
- package/dist/lib/core/SingleAgentClient.mjs +545 -72
- package/dist/lib/core/TaskExecutor.d.mts +7 -0
- package/dist/lib/core/TaskExecutor.d.ts +7 -0
- package/dist/lib/core/TaskExecutor.js +23 -8
- package/dist/lib/core/TaskExecutor.mjs +23 -8
- package/dist/lib/core/task-status.d.mts +2 -0
- package/dist/lib/core/task-status.d.ts +2 -0
- package/dist/lib/core/task-status.js +11 -2
- package/dist/lib/core/task-status.mjs +9 -1
- package/dist/lib/errors/index.d.mts +22 -0
- package/dist/lib/errors/index.d.ts +22 -0
- package/dist/lib/errors/index.js +43 -0
- package/dist/lib/errors/index.mjs +42 -0
- package/dist/lib/identity-3.3/trust.d.mts +1 -4
- package/dist/lib/identity-3.3/trust.d.ts +1 -4
- package/dist/lib/identity-3.3/trust.js +34 -21
- package/dist/lib/identity-3.3/trust.mjs +34 -21
- package/dist/lib/identity-3.3/validation.js +5 -3
- package/dist/lib/identity-3.3/validation.mjs +6 -4
- package/dist/lib/index.d.mts +8 -54
- package/dist/lib/index.d.ts +8 -54
- package/dist/lib/index.js +15 -0
- package/dist/lib/index.mjs +11 -0
- package/dist/lib/media-buy/action-assessment.js +29 -3
- package/dist/lib/media-buy/action-assessment.mjs +32 -4
- package/dist/lib/media-buy/action-contracts.d.mts +3 -0
- package/dist/lib/media-buy/action-contracts.d.ts +3 -0
- package/dist/lib/media-buy/action-contracts.js +24 -1
- package/dist/lib/media-buy/action-contracts.mjs +22 -1
- package/dist/lib/media-buy/compatibility.js +6 -1
- package/dist/lib/media-buy/compatibility.mjs +6 -1
- package/dist/lib/media-buy/preflight.js +1 -1
- package/dist/lib/media-buy/preflight.mjs +3 -2
- package/dist/lib/media-buy/types.d.mts +6 -1
- package/dist/lib/media-buy/types.d.ts +6 -1
- package/dist/lib/protocols/mcp-modern.d.mts +2 -0
- package/dist/lib/protocols/mcp-modern.d.ts +2 -0
- package/dist/lib/protocols/mcp-modern.js +31 -5
- package/dist/lib/protocols/mcp-modern.mjs +31 -5
- package/dist/lib/protocols/mcp-scope.d.mts +6 -1
- package/dist/lib/protocols/mcp-scope.d.ts +6 -1
- package/dist/lib/protocols/mcp-scope.js +25 -3
- package/dist/lib/protocols/mcp-scope.mjs +24 -3
- package/dist/lib/protocols/mcp.js +12 -6
- package/dist/lib/protocols/mcp.mjs +13 -6
- package/dist/lib/reporting/inspection.js +1 -0
- package/dist/lib/reporting/inspection.mjs +1 -0
- package/dist/lib/schemas/browser.d.mts +2 -0
- package/dist/lib/schemas/browser.d.ts +2 -0
- package/dist/lib/schemas/browser.js +3 -0
- package/dist/lib/schemas/browser.mjs +2 -0
- package/dist/lib/schemas/index.d.mts +5 -2
- package/dist/lib/schemas/index.d.ts +5 -2
- package/dist/lib/schemas/index.js +5 -0
- package/dist/lib/schemas/index.mjs +4 -0
- package/dist/lib/server/account-response-identity.d.mts +17 -0
- package/dist/lib/server/account-response-identity.d.ts +17 -0
- package/dist/lib/server/account-response-identity.js +52 -0
- package/dist/lib/server/account-response-identity.mjs +28 -0
- package/dist/lib/server/account-sync-contract.js +1 -0
- package/dist/lib/server/account-sync-contract.mjs +1 -0
- package/dist/lib/server/create-adcp-server.js +32 -19
- package/dist/lib/server/create-adcp-server.mjs +36 -12
- package/dist/lib/server/decisioning/account.d.mts +13 -6
- package/dist/lib/server/decisioning/account.d.ts +13 -6
- package/dist/lib/server/decisioning/account.js +37 -15
- package/dist/lib/server/decisioning/account.mjs +37 -15
- package/dist/lib/server/decisioning/runtime/from-platform.d.mts +5 -5
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +5 -5
- package/dist/lib/server/decisioning/runtime/from-platform.js +6 -6
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +6 -6
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/index.js +2 -0
- package/dist/lib/server/index.mjs +2 -0
- package/dist/lib/server/media-buy-action-resolver.d.mts +3 -0
- package/dist/lib/server/media-buy-action-resolver.d.ts +3 -0
- package/dist/lib/server/media-buy-action-resolver.js +32 -0
- package/dist/lib/server/media-buy-action-resolver.mjs +32 -0
- package/dist/lib/server/media-buy-store.d.mts +26 -12
- package/dist/lib/server/media-buy-store.d.ts +26 -12
- package/dist/lib/server/media-buy-store.js +69 -21
- package/dist/lib/server/media-buy-store.mjs +69 -21
- package/dist/lib/server/responses.js +9 -1
- package/dist/lib/server/responses.mjs +9 -1
- package/dist/lib/server/state-machine.d.mts +10 -11
- package/dist/lib/server/state-machine.d.ts +10 -11
- package/dist/lib/server/state-machine.js +20 -5
- package/dist/lib/server/state-machine.mjs +19 -5
- package/dist/lib/signing/agent-fetch.d.mts +1 -1
- package/dist/lib/signing/agent-fetch.d.ts +1 -1
- package/dist/lib/signing/agent-fetch.js +3 -3
- package/dist/lib/signing/agent-fetch.mjs +3 -3
- package/dist/lib/testing/client.d.mts +1 -0
- package/dist/lib/testing/client.d.ts +1 -0
- package/dist/lib/testing/client.js +6 -5
- package/dist/lib/testing/client.mjs +6 -5
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +60 -14
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +60 -14
- package/dist/lib/testing/storyboard/compliance.d.mts +2 -5
- package/dist/lib/testing/storyboard/compliance.d.ts +2 -5
- package/dist/lib/testing/storyboard/compliance.js +62 -13
- package/dist/lib/testing/storyboard/compliance.mjs +63 -14
- package/dist/lib/testing/storyboard/context.d.mts +13 -3
- package/dist/lib/testing/storyboard/context.d.ts +13 -3
- package/dist/lib/testing/storyboard/context.js +15 -10
- package/dist/lib/testing/storyboard/context.mjs +15 -10
- package/dist/lib/testing/storyboard/default-invariants.js +10 -8
- package/dist/lib/testing/storyboard/default-invariants.mjs +11 -9
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +11 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +10 -0
- package/dist/lib/testing/storyboard/runner.js +23 -10
- package/dist/lib/testing/storyboard/runner.mjs +23 -10
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/validations.js +4 -1
- package/dist/lib/testing/storyboard/validations.mjs +4 -1
- package/dist/lib/testing/test-controller.js +3 -0
- package/dist/lib/testing/test-controller.mjs +3 -0
- package/dist/lib/types/asset-instances.d.mts +1 -1
- package/dist/lib/types/asset-instances.d.ts +1 -1
- package/dist/lib/types/index.d.mts +5 -0
- package/dist/lib/types/index.d.ts +5 -0
- package/dist/lib/types/index.js +6 -1
- package/dist/lib/types/index.mjs +4 -1
- package/dist/lib/types/inline-enums.generated.d.mts +30 -4
- package/dist/lib/types/inline-enums.generated.d.ts +30 -4
- package/dist/lib/types/inline-enums.generated.js +41 -2
- package/dist/lib/types/inline-enums.generated.mjs +28 -2
- package/dist/lib/types/media-buy-delivery-report.d.mts +4 -0
- package/dist/lib/types/media-buy-delivery-report.d.ts +4 -0
- package/dist/lib/types/media-buy-delivery-report.js +16 -0
- package/dist/lib/types/media-buy-delivery-report.mjs +0 -0
- package/dist/lib/types/schemas.generated.d.ts +20 -69
- package/dist/lib/types/schemas.generated.js +29 -46
- package/dist/lib/types/schemas.generated.mjs +29 -46
- package/dist/lib/types/targeting-keys.generated.d.mts +4 -0
- package/dist/lib/types/targeting-keys.generated.d.ts +4 -0
- package/dist/lib/types/targeting-keys.generated.js +105 -0
- package/dist/lib/types/targeting-keys.generated.mjs +80 -0
- package/dist/lib/utils/adcp-version-config.js +5 -2
- package/dist/lib/utils/adcp-version-config.mjs +5 -2
- package/dist/lib/utils/envelope-status-compat.d.mts +18 -1
- package/dist/lib/utils/envelope-status-compat.d.ts +18 -1
- package/dist/lib/utils/envelope-status-compat.js +11 -5
- package/dist/lib/utils/envelope-status-compat.mjs +11 -5
- package/dist/lib/utils/response-unwrapper.js +18 -10
- package/dist/lib/utils/response-unwrapper.mjs +18 -10
- package/dist/lib/v2/format-schema/resolver.js +1 -1
- package/dist/lib/v2/format-schema/resolver.mjs +1 -1
- package/dist/lib/v2/projection/creative-delivery.js +123 -30
- package/dist/lib/v2/projection/creative-delivery.mjs +127 -30
- package/dist/lib/v2/projection/index.d.mts +1 -0
- package/dist/lib/v2/projection/index.d.ts +1 -0
- package/dist/lib/v2/projection/index.js +3 -0
- package/dist/lib/v2/projection/index.mjs +2 -0
- package/dist/lib/v2/projection/legacy-metadata.d.mts +19 -0
- package/dist/lib/v2/projection/legacy-metadata.d.ts +19 -0
- package/dist/lib/v2/projection/legacy-metadata.js +91 -0
- package/dist/lib/v2/projection/legacy-metadata.mjs +86 -0
- package/dist/lib/validation/compact-schema.d.mts +27 -0
- package/dist/lib/validation/compact-schema.d.ts +27 -0
- package/dist/lib/validation/compact-schema.js +276 -0
- package/dist/lib/validation/compact-schema.mjs +250 -0
- package/dist/lib/validation/media-buy-delivery-report.d.mts +8 -0
- package/dist/lib/validation/media-buy-delivery-report.d.ts +8 -0
- package/dist/lib/validation/media-buy-delivery-report.js +31 -0
- package/dist/lib/validation/media-buy-delivery-report.mjs +7 -0
- package/dist/lib/validation/schema-diagnostic-origins.d.mts +21 -0
- package/dist/lib/validation/schema-diagnostic-origins.d.ts +21 -0
- package/dist/lib/validation/schema-diagnostic-origins.js +193 -0
- package/dist/lib/validation/schema-diagnostic-origins.mjs +169 -0
- package/dist/lib/validation/schema-loader.js +86 -16
- package/dist/lib/validation/schema-loader.mjs +82 -16
- package/dist/lib/validation/schema-validator.d.mts +10 -19
- package/dist/lib/validation/schema-validator.d.ts +10 -19
- package/dist/lib/validation/schema-validator.js +136 -43
- package/dist/lib/validation/schema-validator.mjs +140 -44
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/webhooks/index.d.mts +3 -0
- package/dist/lib/webhooks/index.d.ts +3 -0
- package/dist/lib/webhooks/index.js +3 -0
- package/dist/lib/webhooks/index.mjs +2 -0
- package/dist/lib/webhooks/media-buy-delivery.d.mts +43 -0
- package/dist/lib/webhooks/media-buy-delivery.d.ts +43 -0
- package/dist/lib/webhooks/media-buy-delivery.js +119 -0
- package/dist/lib/webhooks/media-buy-delivery.mjs +94 -0
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/guides/BUILD-AN-AGENT.md +9 -1
- package/docs/guides/DELIVERY-WEBHOOK-PARSING.md +135 -0
- package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
- package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
- package/docs/llms.txt +3 -3
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-6.6-to-6.7.md +14 -0
- package/docs/migration-account-change-feed.md +19 -0
- package/docs/releases/sdk-16.6-adoption-fixes.md +33 -0
- package/package.json +2 -2
|
@@ -30,6 +30,7 @@ __export(create_adcp_server_exports, {
|
|
|
30
30
|
requireSessionKey: () => requireSessionKey
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(create_adcp_server_exports);
|
|
33
|
+
var import_adcp_version_config = require('../utils/adcp-version-config.js');
|
|
33
34
|
var import_web_bot_auth = require('../signing/web-bot-auth.js');
|
|
34
35
|
var import_version = require('../adapters/version/index.js');
|
|
35
36
|
var import_schema_loader = require('../validation/schema-loader.js');
|
|
@@ -40,7 +41,7 @@ var import_validation = require('../identity-3.3/validation.js');
|
|
|
40
41
|
var import_trust = require('../identity-3.3/trust.js');
|
|
41
42
|
var import_zod = require("zod");
|
|
42
43
|
var import_version2 = require('../version.js');
|
|
43
|
-
var
|
|
44
|
+
var import_adcp_version_config2 = require('../utils/adcp-version-config.js');
|
|
44
45
|
var import_errors = require('../errors/index.js');
|
|
45
46
|
var import_schema_loader2 = require('../validation/schema-loader.js');
|
|
46
47
|
var import_schemas = require('../schemas/index.js');
|
|
@@ -957,8 +958,7 @@ function projectValueToCapabilitySchema(root, schema, value, depth = 0) {
|
|
|
957
958
|
return projectedObject;
|
|
958
959
|
}
|
|
959
960
|
function projectCapabilitiesToVersion(data, version) {
|
|
960
|
-
const
|
|
961
|
-
const schema = asProjectionSchema(validator?.schema);
|
|
961
|
+
const schema = asProjectionSchema((0, import_schema_loader2.getToolSchemaDocument)("get_adcp_capabilities", "sync", version)?.schema);
|
|
962
962
|
if (!schema) return data;
|
|
963
963
|
const projected = projectValueToCapabilitySchema(schema, schema, data);
|
|
964
964
|
if (!isPlainObject(projected)) return data;
|
|
@@ -1368,7 +1368,9 @@ function injectContextIntoResponse(response, context) {
|
|
|
1368
1368
|
syncContentJsonText(response, sc, mirrorsStructuredContent);
|
|
1369
1369
|
}
|
|
1370
1370
|
}
|
|
1371
|
-
function injectEnvelopeStatusIntoResponse(response, toolName) {
|
|
1371
|
+
function injectEnvelopeStatusIntoResponse(response, toolName, servedVersion) {
|
|
1372
|
+
if (servedVersion && (0, import_adcp_version_config.isPre31AdcpVersion)(servedVersion) && MEDIA_BUY_RESPONSE_TOOLS_REQUIRING_STATUS_SPLIT.has(toolName) && response.isError !== true)
|
|
1373
|
+
return;
|
|
1372
1374
|
const sc = response.structuredContent;
|
|
1373
1375
|
if (!sc || typeof sc !== "object") return;
|
|
1374
1376
|
if ("status" in sc) return;
|
|
@@ -1392,12 +1394,23 @@ const MEDIA_BUY_STATUS_VALUES = /* @__PURE__ */ new Set([
|
|
|
1392
1394
|
"rejected",
|
|
1393
1395
|
"canceled"
|
|
1394
1396
|
]);
|
|
1395
|
-
function normalizeMediaBuyStatusCollision(response, toolName) {
|
|
1397
|
+
function normalizeMediaBuyStatusCollision(response, toolName, servedVersion) {
|
|
1396
1398
|
if (!MEDIA_BUY_RESPONSE_TOOLS_REQUIRING_STATUS_SPLIT.has(toolName)) return;
|
|
1397
1399
|
const sc = response.structuredContent;
|
|
1398
1400
|
if (!sc || typeof sc !== "object") return;
|
|
1401
|
+
if (servedVersion && (0, import_adcp_version_config.isPre31AdcpVersion)(servedVersion)) {
|
|
1402
|
+
const adapted = typeof sc.media_buy_status === "string" ? (0, import_version.getVersionAdapter)("3.0", toolName)?.downgradeResponse?.(sc) : void 0;
|
|
1403
|
+
if (adapted && adapted.data !== sc && adapted.data && typeof adapted.data === "object") {
|
|
1404
|
+
const mirrors = contentTextMirrorsStructuredContent(response, sc);
|
|
1405
|
+
response.structuredContent = adapted.data;
|
|
1406
|
+
syncContentJsonText(response, response.structuredContent, mirrors);
|
|
1407
|
+
}
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1399
1410
|
const status = sc.status;
|
|
1400
1411
|
if (typeof status !== "string" || !MEDIA_BUY_STATUS_VALUES.has(status)) return;
|
|
1412
|
+
if (servedVersion && sc.media_buy_status === void 0 && (status === "completed" || status === "rejected" || status === "canceled"))
|
|
1413
|
+
return;
|
|
1401
1414
|
const looksLikeMediaBuyPayload = typeof sc.media_buy_id === "string" || "media_buy_status" in sc || Array.isArray(sc.packages);
|
|
1402
1415
|
if (!looksLikeMediaBuyPayload) return;
|
|
1403
1416
|
const mirrorsStructuredContent = contentTextMirrorsStructuredContent(response, sc);
|
|
@@ -1774,7 +1787,7 @@ function supportedVersionsForTool(toolName, ranges, capConfig, serverPin) {
|
|
|
1774
1787
|
}
|
|
1775
1788
|
const PUSH_OPERATION_ID_PATTERN = /^[A-Za-z0-9_.:-]{1,255}$/;
|
|
1776
1789
|
function releaseRequiresPushOperationId(release) {
|
|
1777
|
-
return (0,
|
|
1790
|
+
return (0, import_adcp_version_config2.isAdcpVersionAtLeast)((0, import_schema_loader2.resolveBundleKey)(release), "3.2.0-beta.5");
|
|
1778
1791
|
}
|
|
1779
1792
|
function pushOperationIdError(params, release) {
|
|
1780
1793
|
const config = params.push_notification_config;
|
|
@@ -2058,18 +2071,18 @@ function createAdcpServer(config) {
|
|
|
2058
2071
|
logger.warn(message);
|
|
2059
2072
|
}
|
|
2060
2073
|
const credentialPolicyPatterns = credentialPolicy === void 0 || typeof credentialPolicy === "string" ? void 0 : credentialPolicy.patterns;
|
|
2061
|
-
const adcpVersion = (0,
|
|
2074
|
+
const adcpVersion = (0, import_adcp_version_config2.resolveAdcpVersion)(
|
|
2062
2075
|
configuredAdcpVersion ?? (config.identity33 ? "3.3" : config.proposalNegotiation ? import_version3.ADCP_VERSION : void 0)
|
|
2063
2076
|
);
|
|
2064
2077
|
const toolVersionRanges = parseToolVersionRanges(config.toolVersions);
|
|
2065
2078
|
const toolAvailableForRelease = (toolName, release) => toolIsAvailableInRelease(toolVersionRanges, toolName, release);
|
|
2066
|
-
const movingSupportedVersion = capConfig?.supported_versions?.find(
|
|
2079
|
+
const movingSupportedVersion = capConfig?.supported_versions?.find(import_adcp_version_config2.isMovingAdcpPrereleaseFamilyAlias);
|
|
2067
2080
|
if (movingSupportedVersion) {
|
|
2068
2081
|
throw new Error(
|
|
2069
2082
|
`createAdcpServer: capabilities.supported_versions contains moving prerelease-family alias ${JSON.stringify(movingSupportedVersion)}; pin ${JSON.stringify((0, import_version2.toReleasePrecisionVersion)(import_version3.ADCP_VERSION))} instead`
|
|
2070
2083
|
);
|
|
2071
2084
|
}
|
|
2072
|
-
const configuredDefaultVersion = configuredDefaultAdcpVersion === void 0 ? void 0 : (0,
|
|
2085
|
+
const configuredDefaultVersion = configuredDefaultAdcpVersion === void 0 ? void 0 : (0, import_adcp_version_config2.resolveAdcpVersion)(configuredDefaultAdcpVersion, "defaultAdcpVersion");
|
|
2073
2086
|
const maximumRelease = parseAdcpRelease(adcpVersion);
|
|
2074
2087
|
const requestedDefaultRelease = configuredDefaultVersion === void 0 ? void 0 : parseAdcpRelease(configuredDefaultVersion);
|
|
2075
2088
|
if (maximumRelease === void 0) {
|
|
@@ -2406,8 +2419,8 @@ function createAdcpServer(config) {
|
|
|
2406
2419
|
enrichErrorTwoLayer(response, toolName, (0, import_error_arm_tools.getToolsWithErrorArm)(release.validationVersion));
|
|
2407
2420
|
if (!isErrorResponse(response)) {
|
|
2408
2421
|
response = downgradeTaskStatusResult(toolName, response, release.validationVersion);
|
|
2409
|
-
normalizeMediaBuyStatusCollision(response, toolName);
|
|
2410
|
-
injectEnvelopeStatusIntoResponse(response, toolName);
|
|
2422
|
+
normalizeMediaBuyStatusCollision(response, toolName, release.validationVersion);
|
|
2423
|
+
injectEnvelopeStatusIntoResponse(response, toolName, release.validationVersion);
|
|
2411
2424
|
const validationError = protocolTaskResponseValidationError(toolName, response, params);
|
|
2412
2425
|
if (validationError) return finalizeProtocolTaskToolResponse(toolName, params, validationError, opts);
|
|
2413
2426
|
}
|
|
@@ -2786,8 +2799,8 @@ function createAdcpServer(config) {
|
|
|
2786
2799
|
const finalizeProtocolEnvelope = (response) => {
|
|
2787
2800
|
sanitizeAdcpErrorEnvelope(response);
|
|
2788
2801
|
enrichErrorTwoLayer(response, toolName, requestErrorArms);
|
|
2789
|
-
normalizeMediaBuyStatusCollision(response, toolName);
|
|
2790
|
-
injectEnvelopeStatusIntoResponse(response, toolName);
|
|
2802
|
+
normalizeMediaBuyStatusCollision(response, toolName, requestRelease.validationVersion);
|
|
2803
|
+
injectEnvelopeStatusIntoResponse(response, toolName, requestRelease.validationVersion);
|
|
2791
2804
|
injectContextIntoResponse(response, params.context);
|
|
2792
2805
|
injectVersionIntoResponse(response, requestRelease.wireVersion);
|
|
2793
2806
|
return response;
|
|
@@ -2813,7 +2826,7 @@ function createAdcpServer(config) {
|
|
|
2813
2826
|
const offered = capabilitiesData.webhook_signing?.profiles ?? [
|
|
2814
2827
|
"adcp/webhook-signing/v1"
|
|
2815
2828
|
];
|
|
2816
|
-
if (typeof selectedProfile !== "string" || !offered.includes(selectedProfile) || selectedProfile === "web-bot-auth" && (!config.identity33 || !(0,
|
|
2829
|
+
if (typeof selectedProfile !== "string" || !offered.includes(selectedProfile) || selectedProfile === "web-bot-auth" && (!config.identity33 || !(0, import_adcp_version_config2.isAdcpVersionAtLeast)(requestRelease.wireVersion, "3.3")) || selectedProfile === "web-bot-auth" && registration.authentication !== void 0)
|
|
2817
2830
|
return finalize(
|
|
2818
2831
|
(0, import_errors2.adcpError)("INVALID_REQUEST", {
|
|
2819
2832
|
message: "Unsupported or ambiguous webhook signing profile",
|
|
@@ -3001,7 +3014,7 @@ function createAdcpServer(config) {
|
|
|
3001
3014
|
params,
|
|
3002
3015
|
requestRelease.validationVersion,
|
|
3003
3016
|
proposalRefinementCapabilities,
|
|
3004
|
-
!!config.identity33 && (0,
|
|
3017
|
+
!!config.identity33 && (0, import_adcp_version_config2.isAdcpVersionAtLeast)(requestRelease.wireVersion, "3.3")
|
|
3005
3018
|
);
|
|
3006
3019
|
if (!outcome.valid) {
|
|
3007
3020
|
if ("refinementError" in outcome && outcome.refinementError?.code === "UNSUPPORTED_FEATURE") {
|
|
@@ -3968,8 +3981,8 @@ function createAdcpServer(config) {
|
|
|
3968
3981
|
formatted = normalizeGetProductsCacheScope(formatted, params, ctx.account, ctx.authInfo, exposeErrorDetails) ?? formatted;
|
|
3969
3982
|
}
|
|
3970
3983
|
if (!isErrorResponse(formatted)) {
|
|
3971
|
-
normalizeMediaBuyStatusCollision(formatted, toolName);
|
|
3972
|
-
injectEnvelopeStatusIntoResponse(formatted, toolName);
|
|
3984
|
+
normalizeMediaBuyStatusCollision(formatted, toolName, adcpVersion);
|
|
3985
|
+
injectEnvelopeStatusIntoResponse(formatted, toolName, adcpVersion);
|
|
3973
3986
|
}
|
|
3974
3987
|
}
|
|
3975
3988
|
if (translatesRelease && !isErrorResponse(formatted) && formatted.structuredContent) {
|
|
@@ -4005,7 +4018,7 @@ function createAdcpServer(config) {
|
|
|
4005
4018
|
payload,
|
|
4006
4019
|
requestRelease.validationVersion,
|
|
4007
4020
|
void 0,
|
|
4008
|
-
!!config.identity33 && (0,
|
|
4021
|
+
!!config.identity33 && (0, import_adcp_version_config2.isAdcpVersionAtLeast)(requestRelease.wireVersion, "3.3")
|
|
4009
4022
|
);
|
|
4010
4023
|
if (!outcome.valid) {
|
|
4011
4024
|
logger.warn(
|
|
@@ -4889,7 +4902,7 @@ function createAdcpServer(config) {
|
|
|
4889
4902
|
delete validationPayload.media_buy.proposal_refinement;
|
|
4890
4903
|
delete validationPayload.media_buy.lifecycle_tools;
|
|
4891
4904
|
}
|
|
4892
|
-
const responseOutcome = config.identity33 && (0,
|
|
4905
|
+
const responseOutcome = config.identity33 && (0, import_adcp_version_config2.isAdcpVersionAtLeast)(release.wireVersion, "3.3") ? (0, import_validation.validateIdentity33Payload)(
|
|
4893
4906
|
"get_adcp_capabilities",
|
|
4894
4907
|
"response",
|
|
4895
4908
|
validationPayload,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { isPre31AdcpVersion } from "../utils/adcp-version-config.mjs";
|
|
1
2
|
import { assertWebBotAuthSigningKey, getWebBotAuthLegacyOriginGate } from "../signing/web-bot-auth.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
downgradeResponse,
|
|
5
|
+
getVersionAdapter,
|
|
6
|
+
translationSteps,
|
|
7
|
+
upgradeRequest
|
|
8
|
+
} from "../adapters/version/index.mjs";
|
|
3
9
|
import {
|
|
4
10
|
isIdentity33SchemaScope,
|
|
5
11
|
withIdentity33SchemaScope,
|
|
@@ -37,7 +43,13 @@ import {
|
|
|
37
43
|
resolveAdcpVersion
|
|
38
44
|
} from "../utils/adcp-version-config.mjs";
|
|
39
45
|
import { ConfigurationError } from "../errors/index.mjs";
|
|
40
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
getValidator,
|
|
48
|
+
getToolSchemaDocument,
|
|
49
|
+
hasSchemaBundle,
|
|
50
|
+
resolveBundleKey,
|
|
51
|
+
getMcpProfileInputSchema
|
|
52
|
+
} from "../validation/schema-loader.mjs";
|
|
41
53
|
import { TOOL_INPUT_SHAPES } from "../schemas/index.mjs";
|
|
42
54
|
import { TaskTypeValues } from "../types/enums.generated.mjs";
|
|
43
55
|
import { bundleSupportsAdcpVersionField } from "../protocols/index.mjs";
|
|
@@ -1048,8 +1060,7 @@ function projectValueToCapabilitySchema(root, schema, value, depth = 0) {
|
|
|
1048
1060
|
return projectedObject;
|
|
1049
1061
|
}
|
|
1050
1062
|
function projectCapabilitiesToVersion(data, version) {
|
|
1051
|
-
const
|
|
1052
|
-
const schema = asProjectionSchema(validator?.schema);
|
|
1063
|
+
const schema = asProjectionSchema(getToolSchemaDocument("get_adcp_capabilities", "sync", version)?.schema);
|
|
1053
1064
|
if (!schema) return data;
|
|
1054
1065
|
const projected = projectValueToCapabilitySchema(schema, schema, data);
|
|
1055
1066
|
if (!isPlainObject(projected)) return data;
|
|
@@ -1459,7 +1470,9 @@ function injectContextIntoResponse(response, context) {
|
|
|
1459
1470
|
syncContentJsonText(response, sc, mirrorsStructuredContent);
|
|
1460
1471
|
}
|
|
1461
1472
|
}
|
|
1462
|
-
function injectEnvelopeStatusIntoResponse(response, toolName) {
|
|
1473
|
+
function injectEnvelopeStatusIntoResponse(response, toolName, servedVersion) {
|
|
1474
|
+
if (servedVersion && isPre31AdcpVersion(servedVersion) && MEDIA_BUY_RESPONSE_TOOLS_REQUIRING_STATUS_SPLIT.has(toolName) && response.isError !== true)
|
|
1475
|
+
return;
|
|
1463
1476
|
const sc = response.structuredContent;
|
|
1464
1477
|
if (!sc || typeof sc !== "object") return;
|
|
1465
1478
|
if ("status" in sc) return;
|
|
@@ -1483,12 +1496,23 @@ const MEDIA_BUY_STATUS_VALUES = /* @__PURE__ */ new Set([
|
|
|
1483
1496
|
"rejected",
|
|
1484
1497
|
"canceled"
|
|
1485
1498
|
]);
|
|
1486
|
-
function normalizeMediaBuyStatusCollision(response, toolName) {
|
|
1499
|
+
function normalizeMediaBuyStatusCollision(response, toolName, servedVersion) {
|
|
1487
1500
|
if (!MEDIA_BUY_RESPONSE_TOOLS_REQUIRING_STATUS_SPLIT.has(toolName)) return;
|
|
1488
1501
|
const sc = response.structuredContent;
|
|
1489
1502
|
if (!sc || typeof sc !== "object") return;
|
|
1503
|
+
if (servedVersion && isPre31AdcpVersion(servedVersion)) {
|
|
1504
|
+
const adapted = typeof sc.media_buy_status === "string" ? getVersionAdapter("3.0", toolName)?.downgradeResponse?.(sc) : void 0;
|
|
1505
|
+
if (adapted && adapted.data !== sc && adapted.data && typeof adapted.data === "object") {
|
|
1506
|
+
const mirrors = contentTextMirrorsStructuredContent(response, sc);
|
|
1507
|
+
response.structuredContent = adapted.data;
|
|
1508
|
+
syncContentJsonText(response, response.structuredContent, mirrors);
|
|
1509
|
+
}
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1490
1512
|
const status = sc.status;
|
|
1491
1513
|
if (typeof status !== "string" || !MEDIA_BUY_STATUS_VALUES.has(status)) return;
|
|
1514
|
+
if (servedVersion && sc.media_buy_status === void 0 && (status === "completed" || status === "rejected" || status === "canceled"))
|
|
1515
|
+
return;
|
|
1492
1516
|
const looksLikeMediaBuyPayload = typeof sc.media_buy_id === "string" || "media_buy_status" in sc || Array.isArray(sc.packages);
|
|
1493
1517
|
if (!looksLikeMediaBuyPayload) return;
|
|
1494
1518
|
const mirrorsStructuredContent = contentTextMirrorsStructuredContent(response, sc);
|
|
@@ -2497,8 +2521,8 @@ function createAdcpServer(config) {
|
|
|
2497
2521
|
enrichErrorTwoLayer(response, toolName, getToolsWithErrorArm(release.validationVersion));
|
|
2498
2522
|
if (!isErrorResponse(response)) {
|
|
2499
2523
|
response = downgradeTaskStatusResult(toolName, response, release.validationVersion);
|
|
2500
|
-
normalizeMediaBuyStatusCollision(response, toolName);
|
|
2501
|
-
injectEnvelopeStatusIntoResponse(response, toolName);
|
|
2524
|
+
normalizeMediaBuyStatusCollision(response, toolName, release.validationVersion);
|
|
2525
|
+
injectEnvelopeStatusIntoResponse(response, toolName, release.validationVersion);
|
|
2502
2526
|
const validationError = protocolTaskResponseValidationError(toolName, response, params);
|
|
2503
2527
|
if (validationError) return finalizeProtocolTaskToolResponse(toolName, params, validationError, opts);
|
|
2504
2528
|
}
|
|
@@ -2877,8 +2901,8 @@ function createAdcpServer(config) {
|
|
|
2877
2901
|
const finalizeProtocolEnvelope = (response) => {
|
|
2878
2902
|
sanitizeAdcpErrorEnvelope(response);
|
|
2879
2903
|
enrichErrorTwoLayer(response, toolName, requestErrorArms);
|
|
2880
|
-
normalizeMediaBuyStatusCollision(response, toolName);
|
|
2881
|
-
injectEnvelopeStatusIntoResponse(response, toolName);
|
|
2904
|
+
normalizeMediaBuyStatusCollision(response, toolName, requestRelease.validationVersion);
|
|
2905
|
+
injectEnvelopeStatusIntoResponse(response, toolName, requestRelease.validationVersion);
|
|
2882
2906
|
injectContextIntoResponse(response, params.context);
|
|
2883
2907
|
injectVersionIntoResponse(response, requestRelease.wireVersion);
|
|
2884
2908
|
return response;
|
|
@@ -4059,8 +4083,8 @@ function createAdcpServer(config) {
|
|
|
4059
4083
|
formatted = normalizeGetProductsCacheScope(formatted, params, ctx.account, ctx.authInfo, exposeErrorDetails) ?? formatted;
|
|
4060
4084
|
}
|
|
4061
4085
|
if (!isErrorResponse(formatted)) {
|
|
4062
|
-
normalizeMediaBuyStatusCollision(formatted, toolName);
|
|
4063
|
-
injectEnvelopeStatusIntoResponse(formatted, toolName);
|
|
4086
|
+
normalizeMediaBuyStatusCollision(formatted, toolName, adcpVersion);
|
|
4087
|
+
injectEnvelopeStatusIntoResponse(formatted, toolName, adcpVersion);
|
|
4064
4088
|
}
|
|
4065
4089
|
}
|
|
4066
4090
|
if (translatesRelease && !isErrorResponse(formatted) && formatted.structuredContent) {
|
|
@@ -633,11 +633,10 @@ export interface AccountStore<TCtxMeta = Record<string, unknown>> {
|
|
|
633
633
|
* already run, and note the framework performs no such check for
|
|
634
634
|
* `'explicit'` / `'implicit'`, where the entry key is buyer-declared.
|
|
635
635
|
*
|
|
636
|
-
* **
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
* adcontextprotocol/adcp#7517.
|
|
636
|
+
* **Keep the stable result interface's legacy fields.** AdCP 3.2 settings
|
|
637
|
+
* updates may also populate `account`; the projector uses that wire anchor
|
|
638
|
+
* and omits flat brand/operator for 3.2, while older releases keep the flat
|
|
639
|
+
* identity. SDK 17 adds modern account-only result typing.
|
|
641
640
|
*
|
|
642
641
|
* In AdCP 3.1 beta, adopters that need settings-update entries with
|
|
643
642
|
* `notification_configs[]` can read the full wire body from `ctx.input`
|
|
@@ -892,6 +891,14 @@ export type AccountFilter = ListAccountsRequest;
|
|
|
892
891
|
*/
|
|
893
892
|
export interface SyncAccountsResultRow {
|
|
894
893
|
account_id?: string;
|
|
894
|
+
/** 3.2+ settings-update wire anchor. Legacy fields remain required for stable source compatibility. */
|
|
895
|
+
account?: SyncAccountsRow['account'];
|
|
896
|
+
operator_unit?: SyncAccountsRow['operator_unit'];
|
|
897
|
+
revision?: SyncAccountsRow['revision'];
|
|
898
|
+
identity_change?: SyncAccountsRow['identity_change'];
|
|
899
|
+
identity_change_preview?: SyncAccountsRow['identity_change_preview'];
|
|
900
|
+
currency?: SyncAccountsRow['currency'];
|
|
901
|
+
timezone?: SyncAccountsRow['timezone'];
|
|
895
902
|
brand: BrandReference;
|
|
896
903
|
operator: string;
|
|
897
904
|
/** Human-readable account name assigned by the seller. */
|
|
@@ -956,7 +963,7 @@ export type WireSyncAccountRow = SyncAccountsSuccess['accounts'][number];
|
|
|
956
963
|
* never call this directly — they return `SyncAccountsResultRow[]` from
|
|
957
964
|
* `accounts.upsert` and the framework projects.
|
|
958
965
|
*/
|
|
959
|
-
export declare function toWireSyncAccountRow(row: SyncAccountsResultRow): WireSyncAccountRow;
|
|
966
|
+
export declare function toWireSyncAccountRow(row: SyncAccountsResultRow, servedAdcpVersion?: string): WireSyncAccountRow;
|
|
960
967
|
export type WireSyncGovernanceRow = SyncGovernanceSuccess['accounts'][number];
|
|
961
968
|
/**
|
|
962
969
|
* Project a `sync_governance` response row to the wire shape, stripping
|
|
@@ -633,11 +633,10 @@ export interface AccountStore<TCtxMeta = Record<string, unknown>> {
|
|
|
633
633
|
* already run, and note the framework performs no such check for
|
|
634
634
|
* `'explicit'` / `'implicit'`, where the entry key is buyer-declared.
|
|
635
635
|
*
|
|
636
|
-
* **
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
* adcontextprotocol/adcp#7517.
|
|
636
|
+
* **Keep the stable result interface's legacy fields.** AdCP 3.2 settings
|
|
637
|
+
* updates may also populate `account`; the projector uses that wire anchor
|
|
638
|
+
* and omits flat brand/operator for 3.2, while older releases keep the flat
|
|
639
|
+
* identity. SDK 17 adds modern account-only result typing.
|
|
641
640
|
*
|
|
642
641
|
* In AdCP 3.1 beta, adopters that need settings-update entries with
|
|
643
642
|
* `notification_configs[]` can read the full wire body from `ctx.input`
|
|
@@ -892,6 +891,14 @@ export type AccountFilter = ListAccountsRequest;
|
|
|
892
891
|
*/
|
|
893
892
|
export interface SyncAccountsResultRow {
|
|
894
893
|
account_id?: string;
|
|
894
|
+
/** 3.2+ settings-update wire anchor. Legacy fields remain required for stable source compatibility. */
|
|
895
|
+
account?: SyncAccountsRow['account'];
|
|
896
|
+
operator_unit?: SyncAccountsRow['operator_unit'];
|
|
897
|
+
revision?: SyncAccountsRow['revision'];
|
|
898
|
+
identity_change?: SyncAccountsRow['identity_change'];
|
|
899
|
+
identity_change_preview?: SyncAccountsRow['identity_change_preview'];
|
|
900
|
+
currency?: SyncAccountsRow['currency'];
|
|
901
|
+
timezone?: SyncAccountsRow['timezone'];
|
|
895
902
|
brand: BrandReference;
|
|
896
903
|
operator: string;
|
|
897
904
|
/** Human-readable account name assigned by the seller. */
|
|
@@ -956,7 +963,7 @@ export type WireSyncAccountRow = SyncAccountsSuccess['accounts'][number];
|
|
|
956
963
|
* never call this directly — they return `SyncAccountsResultRow[]` from
|
|
957
964
|
* `accounts.upsert` and the framework projects.
|
|
958
965
|
*/
|
|
959
|
-
export declare function toWireSyncAccountRow(row: SyncAccountsResultRow): WireSyncAccountRow;
|
|
966
|
+
export declare function toWireSyncAccountRow(row: SyncAccountsResultRow, servedAdcpVersion?: string): WireSyncAccountRow;
|
|
960
967
|
export type WireSyncGovernanceRow = SyncGovernanceSuccess['accounts'][number];
|
|
961
968
|
/**
|
|
962
969
|
* Project a `sync_governance` response row to the wire shape, stripping
|
|
@@ -30,6 +30,8 @@ __export(account_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(account_exports);
|
|
32
32
|
var import_reporting_delivery_config = require('../reporting-delivery-config.js');
|
|
33
|
+
var import_adcp_version_config = require('../../utils/adcp-version-config.js');
|
|
34
|
+
var import_account_response_identity = require('../account-response-identity.js');
|
|
33
35
|
const ACCOUNT_AUTHORIZATION_WIRE_KEYS = [
|
|
34
36
|
"allowed_tasks",
|
|
35
37
|
"field_scopes",
|
|
@@ -50,6 +52,30 @@ class AccountNotFoundError extends Error {
|
|
|
50
52
|
super(message);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
const SYNC_ACCOUNT_PASSTHROUGH_KEYS = [
|
|
56
|
+
"account_id",
|
|
57
|
+
"brand",
|
|
58
|
+
"operator",
|
|
59
|
+
"revision",
|
|
60
|
+
"currency",
|
|
61
|
+
"timezone",
|
|
62
|
+
"name",
|
|
63
|
+
"action",
|
|
64
|
+
"status",
|
|
65
|
+
"billing",
|
|
66
|
+
"account_scope",
|
|
67
|
+
"setup",
|
|
68
|
+
"rate_card",
|
|
69
|
+
"payment_terms",
|
|
70
|
+
"credit_limit",
|
|
71
|
+
"errors",
|
|
72
|
+
"warnings",
|
|
73
|
+
"sandbox"
|
|
74
|
+
];
|
|
75
|
+
const SYNC_ACCOUNTS_RESULT_KEY_COVERAGE = {};
|
|
76
|
+
void SYNC_ACCOUNTS_RESULT_KEY_COVERAGE;
|
|
77
|
+
const SYNC_ACCOUNTS_PROJECTION_KEY_COVERAGE = {};
|
|
78
|
+
void SYNC_ACCOUNTS_PROJECTION_KEY_COVERAGE;
|
|
53
79
|
function toWireAccount(account) {
|
|
54
80
|
const wire = {
|
|
55
81
|
account_id: account.id,
|
|
@@ -106,23 +132,22 @@ function projectAccountAuthorization(authorization) {
|
|
|
106
132
|
if (authorization.read_only !== void 0) projected.read_only = authorization.read_only;
|
|
107
133
|
return projected;
|
|
108
134
|
}
|
|
109
|
-
function toWireSyncAccountRow(row) {
|
|
135
|
+
function toWireSyncAccountRow(row, servedAdcpVersion) {
|
|
136
|
+
const modernAnchor = !(0, import_adcp_version_config.isPre32AdcpVersion)(servedAdcpVersion);
|
|
137
|
+
const identity = (0, import_account_response_identity.projectAccountResponseIdentityFields)(modernAnchor ? row : { ...row, account: void 0 });
|
|
110
138
|
const wire = {
|
|
111
|
-
brand: row.brand,
|
|
112
|
-
operator: row.operator,
|
|
113
139
|
action: row.action,
|
|
114
|
-
|
|
140
|
+
...identity
|
|
115
141
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
142
|
+
const source = row;
|
|
143
|
+
function copyField(key) {
|
|
144
|
+
if (modernAnchor && identity.account !== void 0 && (key === "brand" || key === "operator")) return;
|
|
145
|
+
const value = source[key];
|
|
146
|
+
if (value !== void 0) wire[key] = value;
|
|
147
|
+
}
|
|
148
|
+
for (const key of SYNC_ACCOUNT_PASSTHROUGH_KEYS) copyField(key);
|
|
119
149
|
const projectedEntity = projectBillingEntity(row.billing_entity);
|
|
120
150
|
if (projectedEntity !== void 0) wire.billing_entity = projectedEntity;
|
|
121
|
-
if (row.account_scope !== void 0) wire.account_scope = row.account_scope;
|
|
122
|
-
if (row.setup !== void 0) wire.setup = row.setup;
|
|
123
|
-
if (row.rate_card !== void 0) wire.rate_card = row.rate_card;
|
|
124
|
-
if (row.payment_terms !== void 0) wire.payment_terms = row.payment_terms;
|
|
125
|
-
if (row.credit_limit !== void 0) wire.credit_limit = row.credit_limit;
|
|
126
151
|
if (row.notification_configs !== void 0) {
|
|
127
152
|
wire.notification_configs = row.notification_configs.map(projectNotificationConfig);
|
|
128
153
|
}
|
|
@@ -134,9 +159,6 @@ function toWireSyncAccountRow(row) {
|
|
|
134
159
|
row.authorization
|
|
135
160
|
);
|
|
136
161
|
}
|
|
137
|
-
if (row.errors !== void 0) wire.errors = row.errors;
|
|
138
|
-
if (row.warnings !== void 0) wire.warnings = row.warnings;
|
|
139
|
-
if (row.sandbox !== void 0) wire.sandbox = row.sandbox;
|
|
140
162
|
return wire;
|
|
141
163
|
}
|
|
142
164
|
function projectNotificationConfig(config) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { projectReportingDeliveryConfigStates } from "../reporting-delivery-config.mjs";
|
|
2
|
+
import { isPre32AdcpVersion } from "../../utils/adcp-version-config.mjs";
|
|
3
|
+
import { projectAccountResponseIdentityFields } from "../account-response-identity.mjs";
|
|
2
4
|
const ACCOUNT_AUTHORIZATION_WIRE_KEYS = [
|
|
3
5
|
"allowed_tasks",
|
|
4
6
|
"field_scopes",
|
|
@@ -19,6 +21,30 @@ class AccountNotFoundError extends Error {
|
|
|
19
21
|
super(message);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
24
|
+
const SYNC_ACCOUNT_PASSTHROUGH_KEYS = [
|
|
25
|
+
"account_id",
|
|
26
|
+
"brand",
|
|
27
|
+
"operator",
|
|
28
|
+
"revision",
|
|
29
|
+
"currency",
|
|
30
|
+
"timezone",
|
|
31
|
+
"name",
|
|
32
|
+
"action",
|
|
33
|
+
"status",
|
|
34
|
+
"billing",
|
|
35
|
+
"account_scope",
|
|
36
|
+
"setup",
|
|
37
|
+
"rate_card",
|
|
38
|
+
"payment_terms",
|
|
39
|
+
"credit_limit",
|
|
40
|
+
"errors",
|
|
41
|
+
"warnings",
|
|
42
|
+
"sandbox"
|
|
43
|
+
];
|
|
44
|
+
const SYNC_ACCOUNTS_RESULT_KEY_COVERAGE = {};
|
|
45
|
+
void SYNC_ACCOUNTS_RESULT_KEY_COVERAGE;
|
|
46
|
+
const SYNC_ACCOUNTS_PROJECTION_KEY_COVERAGE = {};
|
|
47
|
+
void SYNC_ACCOUNTS_PROJECTION_KEY_COVERAGE;
|
|
22
48
|
function toWireAccount(account) {
|
|
23
49
|
const wire = {
|
|
24
50
|
account_id: account.id,
|
|
@@ -75,23 +101,22 @@ function projectAccountAuthorization(authorization) {
|
|
|
75
101
|
if (authorization.read_only !== void 0) projected.read_only = authorization.read_only;
|
|
76
102
|
return projected;
|
|
77
103
|
}
|
|
78
|
-
function toWireSyncAccountRow(row) {
|
|
104
|
+
function toWireSyncAccountRow(row, servedAdcpVersion) {
|
|
105
|
+
const modernAnchor = !isPre32AdcpVersion(servedAdcpVersion);
|
|
106
|
+
const identity = projectAccountResponseIdentityFields(modernAnchor ? row : { ...row, account: void 0 });
|
|
79
107
|
const wire = {
|
|
80
|
-
brand: row.brand,
|
|
81
|
-
operator: row.operator,
|
|
82
108
|
action: row.action,
|
|
83
|
-
|
|
109
|
+
...identity
|
|
84
110
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
111
|
+
const source = row;
|
|
112
|
+
function copyField(key) {
|
|
113
|
+
if (modernAnchor && identity.account !== void 0 && (key === "brand" || key === "operator")) return;
|
|
114
|
+
const value = source[key];
|
|
115
|
+
if (value !== void 0) wire[key] = value;
|
|
116
|
+
}
|
|
117
|
+
for (const key of SYNC_ACCOUNT_PASSTHROUGH_KEYS) copyField(key);
|
|
88
118
|
const projectedEntity = projectBillingEntity(row.billing_entity);
|
|
89
119
|
if (projectedEntity !== void 0) wire.billing_entity = projectedEntity;
|
|
90
|
-
if (row.account_scope !== void 0) wire.account_scope = row.account_scope;
|
|
91
|
-
if (row.setup !== void 0) wire.setup = row.setup;
|
|
92
|
-
if (row.rate_card !== void 0) wire.rate_card = row.rate_card;
|
|
93
|
-
if (row.payment_terms !== void 0) wire.payment_terms = row.payment_terms;
|
|
94
|
-
if (row.credit_limit !== void 0) wire.credit_limit = row.credit_limit;
|
|
95
120
|
if (row.notification_configs !== void 0) {
|
|
96
121
|
wire.notification_configs = row.notification_configs.map(projectNotificationConfig);
|
|
97
122
|
}
|
|
@@ -103,9 +128,6 @@ function toWireSyncAccountRow(row) {
|
|
|
103
128
|
row.authorization
|
|
104
129
|
);
|
|
105
130
|
}
|
|
106
|
-
if (row.errors !== void 0) wire.errors = row.errors;
|
|
107
|
-
if (row.warnings !== void 0) wire.warnings = row.warnings;
|
|
108
|
-
if (row.sandbox !== void 0) wire.sandbox = row.sandbox;
|
|
109
131
|
return wire;
|
|
110
132
|
}
|
|
111
133
|
function projectNotificationConfig(config) {
|
|
@@ -362,10 +362,10 @@ export interface CreateAdcpServerFromPlatformOptions<TAccount = unknown> extends
|
|
|
362
362
|
ctxMetadata?: CtxMetadataStore;
|
|
363
363
|
/**
|
|
364
364
|
* Opinionated media-buy store that satisfies the seller spec contract for
|
|
365
|
-
*
|
|
366
|
-
* `
|
|
367
|
-
* `
|
|
368
|
-
* `collection_list` references.
|
|
365
|
+
* creation context and targeting echo: persist buy/package `context` and
|
|
366
|
+
* `packages[].targeting_overlay` from `create_media_buy`, then fill missing
|
|
367
|
+
* fields on `get_media_buys`. Targeting updates preserve creation context
|
|
368
|
+
* and prior `property_list` / `collection_list` references.
|
|
369
369
|
*
|
|
370
370
|
* Wire to honor the
|
|
371
371
|
* `schemas/cache/<v>/media-buy/get-media-buys-response.json` contract
|
|
@@ -373,7 +373,7 @@ export interface CreateAdcpServerFromPlatformOptions<TAccount = unknown> extends
|
|
|
373
373
|
* `property-lists` / `collection-lists` MUST echo the persisted refs;
|
|
374
374
|
* `mediaBuyStore` is the framework-side way to do it.
|
|
375
375
|
*
|
|
376
|
-
* Backed by any `AdcpStateStore
|
|
376
|
+
* Backed by any `AdcpStateStore`: `InMemoryStateStore` for dev,
|
|
377
377
|
* `PostgresStateStore` for production. Failures are logged and swallowed
|
|
378
378
|
* (auto-echo MUST NOT break a successful seller response).
|
|
379
379
|
*
|
|
@@ -362,10 +362,10 @@ export interface CreateAdcpServerFromPlatformOptions<TAccount = unknown> extends
|
|
|
362
362
|
ctxMetadata?: CtxMetadataStore;
|
|
363
363
|
/**
|
|
364
364
|
* Opinionated media-buy store that satisfies the seller spec contract for
|
|
365
|
-
*
|
|
366
|
-
* `
|
|
367
|
-
* `
|
|
368
|
-
* `collection_list` references.
|
|
365
|
+
* creation context and targeting echo: persist buy/package `context` and
|
|
366
|
+
* `packages[].targeting_overlay` from `create_media_buy`, then fill missing
|
|
367
|
+
* fields on `get_media_buys`. Targeting updates preserve creation context
|
|
368
|
+
* and prior `property_list` / `collection_list` references.
|
|
369
369
|
*
|
|
370
370
|
* Wire to honor the
|
|
371
371
|
* `schemas/cache/<v>/media-buy/get-media-buys-response.json` contract
|
|
@@ -373,7 +373,7 @@ export interface CreateAdcpServerFromPlatformOptions<TAccount = unknown> extends
|
|
|
373
373
|
* `property-lists` / `collection-lists` MUST echo the persisted refs;
|
|
374
374
|
* `mediaBuyStore` is the framework-side way to do it.
|
|
375
375
|
*
|
|
376
|
-
* Backed by any `AdcpStateStore
|
|
376
|
+
* Backed by any `AdcpStateStore`: `InMemoryStateStore` for dev,
|
|
377
377
|
* `PostgresStateStore` for production. Failures are logged and swallowed
|
|
378
378
|
* (auto-echo MUST NOT break a successful seller response).
|
|
379
379
|
*
|
|
@@ -3267,7 +3267,7 @@ async function autoStoreResources(store, accountId, kind, resources, idField, lo
|
|
|
3267
3267
|
);
|
|
3268
3268
|
}
|
|
3269
3269
|
}
|
|
3270
|
-
async function
|
|
3270
|
+
async function persistMediaBuyFromCreate(store, accountId, request, result, logger) {
|
|
3271
3271
|
if (!store || !accountId) return;
|
|
3272
3272
|
if (result == null || typeof result !== "object") return;
|
|
3273
3273
|
try {
|
|
@@ -3290,7 +3290,7 @@ async function persistTargetingOverlayFromUpdate(store, accountId, mediaBuyId, p
|
|
|
3290
3290
|
logger.warn(`[adcp/decisioning] mediaBuyStore.mergeFromUpdate failed: ${msg}`);
|
|
3291
3291
|
}
|
|
3292
3292
|
}
|
|
3293
|
-
async function
|
|
3293
|
+
async function backfillMediaBuyState(store, accountId, result, logger) {
|
|
3294
3294
|
if (!store || !accountId) return;
|
|
3295
3295
|
if (result == null || typeof result !== "object") return;
|
|
3296
3296
|
try {
|
|
@@ -4064,7 +4064,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
|
|
|
4064
4064
|
},
|
|
4065
4065
|
result,
|
|
4066
4066
|
async (r) => {
|
|
4067
|
-
await
|
|
4067
|
+
await persistMediaBuyFromCreate(mediaBuyStore, reqCtx.account?.id, params, r, logger);
|
|
4068
4068
|
return asSemanticServerResponseForWire(
|
|
4069
4069
|
r,
|
|
4070
4070
|
"create_media_buy",
|
|
@@ -4352,7 +4352,7 @@ function buildMediaBuyHandlers(platform, taskRegistry, taskWebhookEmit, observab
|
|
|
4352
4352
|
canonicalFormatLegacyResolver,
|
|
4353
4353
|
responseWireMode
|
|
4354
4354
|
);
|
|
4355
|
-
await
|
|
4355
|
+
await backfillMediaBuyState(mediaBuyStore, reqCtx.account?.id, wireResult, logger);
|
|
4356
4356
|
return wireResult;
|
|
4357
4357
|
},
|
|
4358
4358
|
(r) => r
|
|
@@ -5494,7 +5494,7 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
|
|
|
5494
5494
|
if (policy.failedRows.size === 0) {
|
|
5495
5495
|
return {
|
|
5496
5496
|
...dryRun && { dry_run: true },
|
|
5497
|
-
accounts: rows.map(import_account.toWireSyncAccountRow)
|
|
5497
|
+
accounts: rows.map((row) => (0, import_account.toWireSyncAccountRow)(row, resolveCtx.servedAdcpVersion))
|
|
5498
5498
|
};
|
|
5499
5499
|
}
|
|
5500
5500
|
const combined = [];
|
|
@@ -5510,7 +5510,7 @@ function buildAccountHandlers(platform, ctxFor, logger = DEFAULT_FRAMEWORK_LOGGE
|
|
|
5510
5510
|
}
|
|
5511
5511
|
return {
|
|
5512
5512
|
...dryRun && { dry_run: true },
|
|
5513
|
-
accounts: combined.map(import_account.toWireSyncAccountRow)
|
|
5513
|
+
accounts: combined.map((row) => (0, import_account.toWireSyncAccountRow)(row, resolveCtx.servedAdcpVersion))
|
|
5514
5514
|
};
|
|
5515
5515
|
}
|
|
5516
5516
|
);
|