@adcp/sdk 17.0.0-beta.1 → 17.0.0-beta.3
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/keyed-account-store.js +1 -1
- package/dist/lib/adapters/keyed-account-store.mjs +1 -1
- 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/index.d.mts +9 -0
- package/dist/lib/adapters/version/index.d.ts +9 -0
- package/dist/lib/adapters/version/index.js +20 -6
- package/dist/lib/adapters/version/index.mjs +15 -2
- 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/SingleAgentClient.d.mts +115 -2
- package/dist/lib/core/SingleAgentClient.d.ts +115 -2
- package/dist/lib/core/SingleAgentClient.js +547 -67
- package/dist/lib/core/SingleAgentClient.mjs +534 -54
- package/dist/lib/core/TaskExecutor.d.mts +7 -0
- package/dist/lib/core/TaskExecutor.d.ts +7 -0
- package/dist/lib/core/TaskExecutor.js +18 -5
- package/dist/lib/core/TaskExecutor.mjs +18 -5
- 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/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 +43 -23
- package/dist/lib/identity-3.3/trust.mjs +43 -23
- 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 +6 -52
- package/dist/lib/index.d.ts +6 -52
- package/dist/lib/index.js +11 -0
- package/dist/lib/index.mjs +7 -0
- package/dist/lib/media-buy/compatibility.js +6 -1
- package/dist/lib/media-buy/compatibility.mjs +6 -1
- package/dist/lib/protocols/mcp-scope.d.mts +3 -0
- package/dist/lib/protocols/mcp-scope.d.ts +3 -0
- package/dist/lib/protocols/mcp-scope.js +8 -3
- package/dist/lib/protocols/mcp-scope.mjs +8 -3
- package/dist/lib/reporting/inspection.js +1 -0
- package/dist/lib/reporting/inspection.mjs +1 -0
- package/dist/lib/reporting/ledger/coverage.d.mts +5 -0
- package/dist/lib/reporting/ledger/coverage.d.ts +5 -0
- package/dist/lib/reporting/ledger/coverage.js +37 -3
- package/dist/lib/reporting/ledger/coverage.mjs +36 -3
- package/dist/lib/reporting/ledger/handler.js +7 -4
- package/dist/lib/reporting/ledger/handler.mjs +7 -4
- package/dist/lib/reporting/ledger/producer.js +215 -69
- package/dist/lib/reporting/ledger/producer.mjs +217 -70
- package/dist/lib/reporting/ledger/schedule.d.mts +2 -2
- package/dist/lib/reporting/ledger/schedule.d.ts +2 -2
- package/dist/lib/reporting/ledger/schedule.js +8 -5
- package/dist/lib/reporting/ledger/schedule.mjs +8 -5
- package/dist/lib/reporting/ledger/status-ingest.d.mts +1 -1
- package/dist/lib/reporting/ledger/status-ingest.d.ts +1 -1
- package/dist/lib/reporting/ledger/status-ingest.js +4 -3
- package/dist/lib/reporting/ledger/status-ingest.mjs +4 -3
- package/dist/lib/reporting/ledger/types.d.mts +36 -1
- package/dist/lib/reporting/ledger/types.d.ts +36 -1
- package/dist/lib/reporting/service/index.d.mts +14 -1
- package/dist/lib/reporting/service/index.d.ts +14 -1
- package/dist/lib/reporting/service/index.js +24 -12
- package/dist/lib/reporting/service/index.mjs +24 -12
- 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 -3
- package/dist/lib/schemas/index.d.ts +5 -3
- package/dist/lib/schemas/index.js +5 -0
- package/dist/lib/schemas/index.mjs +4 -0
- package/dist/lib/server/a2a-adapter.js +2 -1
- package/dist/lib/server/a2a-adapter.mjs +2 -1
- 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 +2 -2
- package/dist/lib/server/account-sync-contract.mjs +2 -2
- package/dist/lib/server/auth-signature.d.mts +2 -2
- package/dist/lib/server/auth-signature.d.ts +2 -2
- package/dist/lib/server/auth-signature.js +3 -0
- package/dist/lib/server/auth-signature.mjs +3 -0
- package/dist/lib/server/create-adcp-server.d.mts +2 -2
- package/dist/lib/server/create-adcp-server.d.ts +2 -2
- package/dist/lib/server/create-adcp-server.js +58 -23
- package/dist/lib/server/create-adcp-server.mjs +61 -15
- package/dist/lib/server/decisioning/account.d.mts +36 -10
- package/dist/lib/server/decisioning/account.d.ts +36 -10
- package/dist/lib/server/decisioning/account.js +33 -14
- package/dist/lib/server/decisioning/account.mjs +33 -14
- 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 +4 -4
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +4 -4
- 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/notification-subscriptions/runtime.d.mts +1 -1
- package/dist/lib/server/notification-subscriptions/runtime.d.ts +1 -1
- package/dist/lib/server/notification-subscriptions/runtime.js +4 -0
- package/dist/lib/server/notification-subscriptions/runtime.mjs +4 -0
- package/dist/lib/server/responses.js +9 -1
- package/dist/lib/server/responses.mjs +9 -1
- package/dist/lib/server/serve.js +3 -1
- package/dist/lib/server/serve.mjs +3 -1
- package/dist/lib/server/signed-request-transport.d.mts +1 -0
- package/dist/lib/server/signed-request-transport.d.ts +1 -0
- package/dist/lib/server/signed-request-transport.js +46 -0
- package/dist/lib/server/signed-request-transport.mjs +20 -0
- package/dist/lib/server/test-controller.d.mts +1 -0
- package/dist/lib/server/test-controller.d.ts +1 -0
- package/dist/lib/server/test-controller.js +5 -1
- package/dist/lib/server/test-controller.mjs +5 -1
- 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/index.d.mts +1 -0
- package/dist/lib/testing/index.d.ts +1 -0
- package/dist/lib/testing/index.js +3 -0
- package/dist/lib/testing/index.mjs +2 -0
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +61 -29
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +61 -29
- 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/index.d.mts +1 -0
- package/dist/lib/testing/storyboard/index.d.ts +1 -0
- package/dist/lib/testing/storyboard/index.js +3 -0
- package/dist/lib/testing/storyboard/index.mjs +2 -0
- package/dist/lib/testing/storyboard/loader.js +7 -0
- package/dist/lib/testing/storyboard/loader.mjs +7 -0
- package/dist/lib/testing/storyboard/request-builder.js +9 -6
- package/dist/lib/testing/storyboard/request-builder.mjs +9 -6
- 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 +59 -6
- package/dist/lib/testing/storyboard/runner.mjs +59 -6
- package/dist/lib/testing/storyboard/types.d.mts +18 -0
- package/dist/lib/testing/storyboard/types.d.ts +18 -0
- 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/web-bot-auth.d.mts +10 -0
- package/dist/lib/testing/storyboard/web-bot-auth.d.ts +10 -0
- package/dist/lib/testing/storyboard/web-bot-auth.js +80 -0
- package/dist/lib/testing/storyboard/web-bot-auth.mjs +56 -0
- package/dist/lib/types/accept-proposal.d.ts +20 -28
- package/dist/lib/types/asset-instances.d.mts +1 -1
- package/dist/lib/types/asset-instances.d.ts +1 -1
- package/dist/lib/types/buy-products.d.ts +20 -28
- package/dist/lib/types/check-governance.d.ts +20 -28
- package/dist/lib/types/comply-test-controller.d.ts +20 -28
- package/dist/lib/types/control-media-buy.d.ts +20 -28
- package/dist/lib/types/core.generated.d.mts +273 -184
- package/dist/lib/types/core.generated.d.ts +273 -184
- package/dist/lib/types/create-media-buy.d.ts +20 -28
- package/dist/lib/types/get-media-buys.d.ts +20 -28
- package/dist/lib/types/get-products.d.ts +20 -28
- package/dist/lib/types/index.d.mts +6 -1
- package/dist/lib/types/index.d.ts +6 -1
- 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/list-products.d.ts +20 -28
- package/dist/lib/types/list-proposals.d.ts +20 -28
- package/dist/lib/types/media-buy-delivery-report.d.mts +6 -0
- package/dist/lib/types/media-buy-delivery-report.d.ts +6 -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/refine-proposals.d.ts +20 -28
- package/dist/lib/types/request-proposals.d.ts +20 -28
- package/dist/lib/types/schemas.generated.d.ts +63113 -127273
- package/dist/lib/types/schemas.generated.js +759 -770
- package/dist/lib/types/schemas.generated.mjs +759 -770
- 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 +109 -0
- package/dist/lib/types/targeting-keys.generated.mjs +84 -0
- package/dist/lib/types/tools.generated.d.mts +2 -68
- package/dist/lib/types/tools.generated.d.ts +2 -68
- package/dist/lib/types/update-media-buy.d.ts +20 -28
- package/dist/lib/utils/adcp-version-config.js +5 -2
- package/dist/lib/utils/adcp-version-config.mjs +5 -2
- package/dist/lib/utils/response-unwrapper.js +6 -1
- package/dist/lib/utils/response-unwrapper.mjs +6 -1
- 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 +104 -29
- package/dist/lib/v2/projection/creative-delivery.mjs +108 -29
- 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/v2/projection/v1-to-v2.d.mts +1 -1
- package/dist/lib/v2/projection/v1-to-v2.d.ts +1 -1
- package/dist/lib/v2/projection/v1-to-v2.js +12 -9
- package/dist/lib/v2/projection/v1-to-v2.mjs +12 -9
- package/dist/lib/validation/budget-allocation.d.mts +3 -3
- package/dist/lib/validation/budget-allocation.d.ts +3 -3
- 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/nonempty-array.d.mts +15 -0
- package/dist/lib/validation/nonempty-array.d.ts +15 -0
- package/dist/lib/validation/nonempty-array.js +41 -0
- package/dist/lib/validation/nonempty-array.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 +135 -42
- package/dist/lib/validation/schema-validator.mjs +139 -43
- package/dist/lib/validation/sync-creatives.d.mts +22 -22
- package/dist/lib/validation/sync-creatives.d.ts +22 -22
- 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/DELIVERY-WEBHOOK-PARSING.md +142 -0
- package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
- package/docs/guides/REPORTING-LEDGER.md +93 -0
- package/docs/guides/REPORTING-STABILITY.md +1 -1
- package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
- package/docs/llms.txt +2 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-16-to-17.md +218 -14
- package/docs/migration-6.6-to-6.7.md +14 -0
- package/docs/migration-account-change-feed.md +15 -0
- package/docs/migration-agent-identity-3.3.md +106 -4
- package/docs/recipes/verifying-inbound-webhooks.md +18 -2
- package/package.json +16 -3
|
@@ -25,6 +25,25 @@ module.exports = __toCommonJS(media_buy_store_exports);
|
|
|
25
25
|
var import_targeting_input = require('../media-buy/targeting-input.js');
|
|
26
26
|
var import_state_store = require('./state-store.js');
|
|
27
27
|
const DEFAULT_MEDIA_BUY_STORE_COLLECTION = "media_buys_targeting";
|
|
28
|
+
const PACKAGE_IDENTITY_FIELDS = ["package_id", "product_id", "buyer_ref"];
|
|
29
|
+
function compatibleIdentity(left, right) {
|
|
30
|
+
if (!left || !right) return false;
|
|
31
|
+
return PACKAGE_IDENTITY_FIELDS.every((key) => !left[key] || !right[key] || left[key] === right[key]);
|
|
32
|
+
}
|
|
33
|
+
function sharesIdentity(left, right) {
|
|
34
|
+
if (!left || !right) return false;
|
|
35
|
+
return compatibleIdentity(left, right) && PACKAGE_IDENTITY_FIELDS.some((key) => left[key] && left[key] === right[key]);
|
|
36
|
+
}
|
|
37
|
+
function matchContextPackage(requests, responses, index) {
|
|
38
|
+
const matches = requests.filter((request) => sharesIdentity(request, responses[index]));
|
|
39
|
+
if (matches.length === 1 && responses.filter((response) => sharesIdentity(matches[0], response)).length === 1) {
|
|
40
|
+
return matches[0];
|
|
41
|
+
}
|
|
42
|
+
if (requests.length === responses.length && requests.every((request, i) => compatibleIdentity(request, responses[i]))) {
|
|
43
|
+
return requests[index];
|
|
44
|
+
}
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
28
47
|
function createMediaBuyStore(options) {
|
|
29
48
|
const collection = options.collection ?? DEFAULT_MEDIA_BUY_STORE_COLLECTION;
|
|
30
49
|
function viewFor(accountId) {
|
|
@@ -42,8 +61,9 @@ function createMediaBuyStore(options) {
|
|
|
42
61
|
async persistFromCreate(accountId, request, result) {
|
|
43
62
|
const requestPackages = request.packages ?? [];
|
|
44
63
|
const responsePackages = result.packages ?? [];
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
64
|
+
if (!result.media_buy_id) return;
|
|
65
|
+
const prior = await loadRecord(accountId, result.media_buy_id);
|
|
66
|
+
const byId = new Map((prior?.packages ?? []).map((pkg) => [pkg.package_id, { ...pkg }]));
|
|
47
67
|
for (let i = 0; i < requestPackages.length; i++) {
|
|
48
68
|
const reqPkg = requestPackages[i];
|
|
49
69
|
if (!reqPkg?.targeting_overlay) continue;
|
|
@@ -54,12 +74,26 @@ function createMediaBuyStore(options) {
|
|
|
54
74
|
if (!packageId) continue;
|
|
55
75
|
const persistedOverlay = respPkg?.targeting_overlay ?? (0, import_targeting_input.resolveTargetingInput)(reqPkg.targeting_overlay);
|
|
56
76
|
if (!persistedOverlay) continue;
|
|
57
|
-
|
|
77
|
+
byId.set(packageId, { ...byId.get(packageId), package_id: packageId, targeting_overlay: persistedOverlay });
|
|
58
78
|
}
|
|
59
|
-
|
|
79
|
+
for (const [index, response] of responsePackages.entries()) {
|
|
80
|
+
if (!response.package_id) continue;
|
|
81
|
+
const context2 = matchContextPackage(requestPackages, responsePackages, index)?.context ?? response.context;
|
|
82
|
+
const stored = byId.get(response.package_id);
|
|
83
|
+
if (context2 !== void 0 && stored?.context === void 0) {
|
|
84
|
+
byId.set(response.package_id, {
|
|
85
|
+
...stored,
|
|
86
|
+
package_id: response.package_id,
|
|
87
|
+
context: structuredClone(context2)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const context = prior?.context ?? request.context ?? result.context;
|
|
92
|
+
if (byId.size === 0 && context === void 0) return;
|
|
60
93
|
await writeRecord(accountId, {
|
|
61
94
|
media_buy_id: result.media_buy_id,
|
|
62
|
-
|
|
95
|
+
...context !== void 0 ? { context: structuredClone(context) } : {},
|
|
96
|
+
packages: Array.from(byId.values())
|
|
63
97
|
});
|
|
64
98
|
},
|
|
65
99
|
async mergeFromUpdate(accountId, mediaBuyId, patch) {
|
|
@@ -67,42 +101,56 @@ function createMediaBuyStore(options) {
|
|
|
67
101
|
media_buy_id: mediaBuyId,
|
|
68
102
|
packages: []
|
|
69
103
|
};
|
|
70
|
-
const byId = new Map(prior.packages.map((p) => [p.package_id, p
|
|
104
|
+
const byId = new Map(prior.packages.map((p) => [p.package_id, { ...p }]));
|
|
71
105
|
for (const pkg of patch.packages ?? []) {
|
|
72
106
|
const packageId = pkg?.package_id;
|
|
73
107
|
if (!packageId) continue;
|
|
74
108
|
if (!("targeting_overlay" in pkg)) continue;
|
|
75
109
|
const incoming = pkg.targeting_overlay;
|
|
76
110
|
if (incoming === void 0) continue;
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
111
|
+
const stored = byId.get(packageId);
|
|
112
|
+
const merged = (0, import_targeting_input.applyTargetingInput)(stored?.targeting_overlay, incoming);
|
|
113
|
+
if (merged) byId.set(packageId, { ...stored, package_id: packageId, targeting_overlay: merged });
|
|
114
|
+
else if (stored?.context !== void 0) {
|
|
115
|
+
byId.set(packageId, { package_id: packageId, context: stored.context });
|
|
116
|
+
} else byId.delete(packageId);
|
|
80
117
|
}
|
|
81
118
|
for (const pkg of patch.new_packages ?? []) {
|
|
82
119
|
if (!pkg?.targeting_overlay || !pkg.package_id) continue;
|
|
83
120
|
const resolved = (0, import_targeting_input.resolveTargetingInput)(pkg.targeting_overlay);
|
|
84
|
-
if (resolved)
|
|
121
|
+
if (resolved)
|
|
122
|
+
byId.set(pkg.package_id, {
|
|
123
|
+
...byId.get(pkg.package_id),
|
|
124
|
+
package_id: pkg.package_id,
|
|
125
|
+
targeting_overlay: resolved
|
|
126
|
+
});
|
|
85
127
|
}
|
|
86
128
|
await writeRecord(accountId, {
|
|
87
|
-
|
|
88
|
-
packages: Array.from(byId.
|
|
89
|
-
package_id,
|
|
90
|
-
targeting_overlay
|
|
91
|
-
}))
|
|
129
|
+
...prior,
|
|
130
|
+
packages: Array.from(byId.values())
|
|
92
131
|
});
|
|
93
132
|
},
|
|
94
133
|
async backfill(accountId, result) {
|
|
95
134
|
const buys = result.media_buys;
|
|
96
135
|
if (!buys || buys.length === 0) return result;
|
|
97
136
|
for (const buy of buys) {
|
|
98
|
-
if (!buy?.media_buy_id
|
|
137
|
+
if (!buy?.media_buy_id) continue;
|
|
99
138
|
const record = await loadRecord(accountId, buy.media_buy_id);
|
|
100
139
|
if (!record) continue;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
140
|
+
if (buy.context === void 0 && record.context !== void 0) {
|
|
141
|
+
buy.context = structuredClone(record.context);
|
|
142
|
+
}
|
|
143
|
+
const byId = new Map(record.packages.map((p) => [p.package_id, p]));
|
|
144
|
+
for (const pkg of buy.packages ?? []) {
|
|
145
|
+
if (!pkg?.package_id) continue;
|
|
146
|
+
const persisted = byId.get(pkg.package_id);
|
|
147
|
+
if (!persisted) continue;
|
|
148
|
+
if (pkg.targeting_overlay === void 0 && persisted.targeting_overlay !== void 0) {
|
|
149
|
+
pkg.targeting_overlay = persisted.targeting_overlay;
|
|
150
|
+
}
|
|
151
|
+
if (pkg.context === void 0 && persisted.context !== void 0) {
|
|
152
|
+
pkg.context = structuredClone(persisted.context);
|
|
153
|
+
}
|
|
106
154
|
}
|
|
107
155
|
}
|
|
108
156
|
return result;
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { applyTargetingInput, resolveTargetingInput } from "../media-buy/targeting-input.mjs";
|
|
2
2
|
import { scopedStore } from "./state-store.mjs";
|
|
3
3
|
const DEFAULT_MEDIA_BUY_STORE_COLLECTION = "media_buys_targeting";
|
|
4
|
+
const PACKAGE_IDENTITY_FIELDS = ["package_id", "product_id", "buyer_ref"];
|
|
5
|
+
function compatibleIdentity(left, right) {
|
|
6
|
+
if (!left || !right) return false;
|
|
7
|
+
return PACKAGE_IDENTITY_FIELDS.every((key) => !left[key] || !right[key] || left[key] === right[key]);
|
|
8
|
+
}
|
|
9
|
+
function sharesIdentity(left, right) {
|
|
10
|
+
if (!left || !right) return false;
|
|
11
|
+
return compatibleIdentity(left, right) && PACKAGE_IDENTITY_FIELDS.some((key) => left[key] && left[key] === right[key]);
|
|
12
|
+
}
|
|
13
|
+
function matchContextPackage(requests, responses, index) {
|
|
14
|
+
const matches = requests.filter((request) => sharesIdentity(request, responses[index]));
|
|
15
|
+
if (matches.length === 1 && responses.filter((response) => sharesIdentity(matches[0], response)).length === 1) {
|
|
16
|
+
return matches[0];
|
|
17
|
+
}
|
|
18
|
+
if (requests.length === responses.length && requests.every((request, i) => compatibleIdentity(request, responses[i]))) {
|
|
19
|
+
return requests[index];
|
|
20
|
+
}
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
4
23
|
function createMediaBuyStore(options) {
|
|
5
24
|
const collection = options.collection ?? DEFAULT_MEDIA_BUY_STORE_COLLECTION;
|
|
6
25
|
function viewFor(accountId) {
|
|
@@ -18,8 +37,9 @@ function createMediaBuyStore(options) {
|
|
|
18
37
|
async persistFromCreate(accountId, request, result) {
|
|
19
38
|
const requestPackages = request.packages ?? [];
|
|
20
39
|
const responsePackages = result.packages ?? [];
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
40
|
+
if (!result.media_buy_id) return;
|
|
41
|
+
const prior = await loadRecord(accountId, result.media_buy_id);
|
|
42
|
+
const byId = new Map((prior?.packages ?? []).map((pkg) => [pkg.package_id, { ...pkg }]));
|
|
23
43
|
for (let i = 0; i < requestPackages.length; i++) {
|
|
24
44
|
const reqPkg = requestPackages[i];
|
|
25
45
|
if (!reqPkg?.targeting_overlay) continue;
|
|
@@ -30,12 +50,26 @@ function createMediaBuyStore(options) {
|
|
|
30
50
|
if (!packageId) continue;
|
|
31
51
|
const persistedOverlay = respPkg?.targeting_overlay ?? resolveTargetingInput(reqPkg.targeting_overlay);
|
|
32
52
|
if (!persistedOverlay) continue;
|
|
33
|
-
|
|
53
|
+
byId.set(packageId, { ...byId.get(packageId), package_id: packageId, targeting_overlay: persistedOverlay });
|
|
34
54
|
}
|
|
35
|
-
|
|
55
|
+
for (const [index, response] of responsePackages.entries()) {
|
|
56
|
+
if (!response.package_id) continue;
|
|
57
|
+
const context2 = matchContextPackage(requestPackages, responsePackages, index)?.context ?? response.context;
|
|
58
|
+
const stored = byId.get(response.package_id);
|
|
59
|
+
if (context2 !== void 0 && stored?.context === void 0) {
|
|
60
|
+
byId.set(response.package_id, {
|
|
61
|
+
...stored,
|
|
62
|
+
package_id: response.package_id,
|
|
63
|
+
context: structuredClone(context2)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const context = prior?.context ?? request.context ?? result.context;
|
|
68
|
+
if (byId.size === 0 && context === void 0) return;
|
|
36
69
|
await writeRecord(accountId, {
|
|
37
70
|
media_buy_id: result.media_buy_id,
|
|
38
|
-
|
|
71
|
+
...context !== void 0 ? { context: structuredClone(context) } : {},
|
|
72
|
+
packages: Array.from(byId.values())
|
|
39
73
|
});
|
|
40
74
|
},
|
|
41
75
|
async mergeFromUpdate(accountId, mediaBuyId, patch) {
|
|
@@ -43,42 +77,56 @@ function createMediaBuyStore(options) {
|
|
|
43
77
|
media_buy_id: mediaBuyId,
|
|
44
78
|
packages: []
|
|
45
79
|
};
|
|
46
|
-
const byId = new Map(prior.packages.map((p) => [p.package_id, p
|
|
80
|
+
const byId = new Map(prior.packages.map((p) => [p.package_id, { ...p }]));
|
|
47
81
|
for (const pkg of patch.packages ?? []) {
|
|
48
82
|
const packageId = pkg?.package_id;
|
|
49
83
|
if (!packageId) continue;
|
|
50
84
|
if (!("targeting_overlay" in pkg)) continue;
|
|
51
85
|
const incoming = pkg.targeting_overlay;
|
|
52
86
|
if (incoming === void 0) continue;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
const stored = byId.get(packageId);
|
|
88
|
+
const merged = applyTargetingInput(stored?.targeting_overlay, incoming);
|
|
89
|
+
if (merged) byId.set(packageId, { ...stored, package_id: packageId, targeting_overlay: merged });
|
|
90
|
+
else if (stored?.context !== void 0) {
|
|
91
|
+
byId.set(packageId, { package_id: packageId, context: stored.context });
|
|
92
|
+
} else byId.delete(packageId);
|
|
56
93
|
}
|
|
57
94
|
for (const pkg of patch.new_packages ?? []) {
|
|
58
95
|
if (!pkg?.targeting_overlay || !pkg.package_id) continue;
|
|
59
96
|
const resolved = resolveTargetingInput(pkg.targeting_overlay);
|
|
60
|
-
if (resolved)
|
|
97
|
+
if (resolved)
|
|
98
|
+
byId.set(pkg.package_id, {
|
|
99
|
+
...byId.get(pkg.package_id),
|
|
100
|
+
package_id: pkg.package_id,
|
|
101
|
+
targeting_overlay: resolved
|
|
102
|
+
});
|
|
61
103
|
}
|
|
62
104
|
await writeRecord(accountId, {
|
|
63
|
-
|
|
64
|
-
packages: Array.from(byId.
|
|
65
|
-
package_id,
|
|
66
|
-
targeting_overlay
|
|
67
|
-
}))
|
|
105
|
+
...prior,
|
|
106
|
+
packages: Array.from(byId.values())
|
|
68
107
|
});
|
|
69
108
|
},
|
|
70
109
|
async backfill(accountId, result) {
|
|
71
110
|
const buys = result.media_buys;
|
|
72
111
|
if (!buys || buys.length === 0) return result;
|
|
73
112
|
for (const buy of buys) {
|
|
74
|
-
if (!buy?.media_buy_id
|
|
113
|
+
if (!buy?.media_buy_id) continue;
|
|
75
114
|
const record = await loadRecord(accountId, buy.media_buy_id);
|
|
76
115
|
if (!record) continue;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
116
|
+
if (buy.context === void 0 && record.context !== void 0) {
|
|
117
|
+
buy.context = structuredClone(record.context);
|
|
118
|
+
}
|
|
119
|
+
const byId = new Map(record.packages.map((p) => [p.package_id, p]));
|
|
120
|
+
for (const pkg of buy.packages ?? []) {
|
|
121
|
+
if (!pkg?.package_id) continue;
|
|
122
|
+
const persisted = byId.get(pkg.package_id);
|
|
123
|
+
if (!persisted) continue;
|
|
124
|
+
if (pkg.targeting_overlay === void 0 && persisted.targeting_overlay !== void 0) {
|
|
125
|
+
pkg.targeting_overlay = persisted.targeting_overlay;
|
|
126
|
+
}
|
|
127
|
+
if (pkg.context === void 0 && persisted.context !== void 0) {
|
|
128
|
+
pkg.context = structuredClone(persisted.context);
|
|
129
|
+
}
|
|
82
130
|
}
|
|
83
131
|
}
|
|
84
132
|
return result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { WebhookAttemptSuppressionReason } from '../webhook-emitter.mjs';
|
|
2
2
|
import type { NotificationSubscriptionConfigInput, NotificationSubscriptionView, NotificationSuppressionDisposition, PersistentNotificationRuntime, PersistentNotificationRuntimeOptions, StoredNotificationSubscription } from './types.mjs';
|
|
3
3
|
export declare const CALLER_NOTIFICATION_TYPES: readonly ["capabilities.changed", "principal.changed"];
|
|
4
|
-
export declare const ACCOUNT_NOTIFICATION_TYPES: readonly ["creative.status_changed", "creative.assignment_changed", "indicators.changed", "creative.purged", "account.status_changed", "account.change_recorded", "product.created", "product.updated", "product.priced", "product.removed", "signal.created", "signal.updated", "signal.priced", "signal.removed", "wholesale_feed.bulk_change", "reporting.delivery_ready", "reporting.status_changed", "reporting.ledger_changed"];
|
|
4
|
+
export declare const ACCOUNT_NOTIFICATION_TYPES: readonly ["creative.status_changed", "creative.assignment_changed", "indicators.changed", "creative.purged", "account.status_changed", "account.change_recorded", "product.created", "product.updated", "product.priced", "product.removed", "signal.created", "signal.updated", "signal.priced", "signal.removed", "wholesale_feed.bulk_change", "collection_card.updated", "collection_card.removed", "collection_catalog.bulk_change", "proposal.created", "reporting.delivery_ready", "reporting.status_changed", "reporting.ledger_changed"];
|
|
5
5
|
/**
|
|
6
6
|
* Durable subscription control plane. The supplied emitter factory is called
|
|
7
7
|
* exactly once with the runtime's mandatory live authorizer, preventing a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { WebhookAttemptSuppressionReason } from '../webhook-emitter';
|
|
2
2
|
import type { NotificationSubscriptionConfigInput, NotificationSubscriptionView, NotificationSuppressionDisposition, PersistentNotificationRuntime, PersistentNotificationRuntimeOptions, StoredNotificationSubscription } from './types';
|
|
3
3
|
export declare const CALLER_NOTIFICATION_TYPES: readonly ["capabilities.changed", "principal.changed"];
|
|
4
|
-
export declare const ACCOUNT_NOTIFICATION_TYPES: readonly ["creative.status_changed", "creative.assignment_changed", "indicators.changed", "creative.purged", "account.status_changed", "account.change_recorded", "product.created", "product.updated", "product.priced", "product.removed", "signal.created", "signal.updated", "signal.priced", "signal.removed", "wholesale_feed.bulk_change", "reporting.delivery_ready", "reporting.status_changed", "reporting.ledger_changed"];
|
|
4
|
+
export declare const ACCOUNT_NOTIFICATION_TYPES: readonly ["creative.status_changed", "creative.assignment_changed", "indicators.changed", "creative.purged", "account.status_changed", "account.change_recorded", "product.created", "product.updated", "product.priced", "product.removed", "signal.created", "signal.updated", "signal.priced", "signal.removed", "wholesale_feed.bulk_change", "collection_card.updated", "collection_card.removed", "collection_catalog.bulk_change", "proposal.created", "reporting.delivery_ready", "reporting.status_changed", "reporting.ledger_changed"];
|
|
5
5
|
/**
|
|
6
6
|
* Durable subscription control plane. The supplied emitter factory is called
|
|
7
7
|
* exactly once with the runtime's mandatory live authorizer, preventing a
|
|
@@ -51,6 +51,10 @@ const ACCOUNT_NOTIFICATION_TYPES = Object.freeze([
|
|
|
51
51
|
"signal.priced",
|
|
52
52
|
"signal.removed",
|
|
53
53
|
"wholesale_feed.bulk_change",
|
|
54
|
+
"collection_card.updated",
|
|
55
|
+
"collection_card.removed",
|
|
56
|
+
"collection_catalog.bulk_change",
|
|
57
|
+
"proposal.created",
|
|
54
58
|
"reporting.delivery_ready",
|
|
55
59
|
"reporting.status_changed",
|
|
56
60
|
"reporting.ledger_changed"
|
|
@@ -22,6 +22,10 @@ const ACCOUNT_NOTIFICATION_TYPES = Object.freeze([
|
|
|
22
22
|
"signal.priced",
|
|
23
23
|
"signal.removed",
|
|
24
24
|
"wholesale_feed.bulk_change",
|
|
25
|
+
"collection_card.updated",
|
|
26
|
+
"collection_card.removed",
|
|
27
|
+
"collection_catalog.bulk_change",
|
|
28
|
+
"proposal.created",
|
|
25
29
|
"reporting.delivery_ready",
|
|
26
30
|
"reporting.status_changed",
|
|
27
31
|
"reporting.ledger_changed"
|
|
@@ -60,6 +60,7 @@ __export(responses_exports, {
|
|
|
60
60
|
module.exports = __toCommonJS(responses_exports);
|
|
61
61
|
var import_media_buy_helpers = require('./media-buy-helpers.js');
|
|
62
62
|
var import_reporting_delivery_config = require('./reporting-delivery-config.js');
|
|
63
|
+
var import_account_response_identity = require('./account-response-identity.js');
|
|
63
64
|
const explicitResponseSummaries = /* @__PURE__ */ new WeakMap();
|
|
64
65
|
function _getExplicitResponseSummary(response) {
|
|
65
66
|
return explicitResponseSummaries.get(response);
|
|
@@ -124,7 +125,14 @@ function stripBusinessEntityBank(row, key) {
|
|
|
124
125
|
return stripped;
|
|
125
126
|
}
|
|
126
127
|
function stripAccountWriteOnlyFields(account) {
|
|
127
|
-
const
|
|
128
|
+
const {
|
|
129
|
+
destination_billing_entity: _destination,
|
|
130
|
+
authInfo: _authInfo,
|
|
131
|
+
ctx_metadata: _metadata,
|
|
132
|
+
...responseFields
|
|
133
|
+
} = account;
|
|
134
|
+
const response = stripBusinessEntityBank(stripNotificationConfigSecrets(responseFields), "billing_entity");
|
|
135
|
+
const stripped = { ...response, ...(0, import_account_response_identity.projectAccountResponseIdentityFields)(response) };
|
|
128
136
|
const reportingDeliveryConfigs = stripped.reporting_delivery_configs;
|
|
129
137
|
if (reportingDeliveryConfigs === void 0) return stripped;
|
|
130
138
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validActionsForStatus } from "./media-buy-helpers.mjs";
|
|
2
2
|
import { projectReportingDeliveryConfigStates } from "./reporting-delivery-config.mjs";
|
|
3
|
+
import { projectAccountResponseIdentityFields } from "./account-response-identity.mjs";
|
|
3
4
|
const explicitResponseSummaries = /* @__PURE__ */ new WeakMap();
|
|
4
5
|
function _getExplicitResponseSummary(response) {
|
|
5
6
|
return explicitResponseSummaries.get(response);
|
|
@@ -64,7 +65,14 @@ function stripBusinessEntityBank(row, key) {
|
|
|
64
65
|
return stripped;
|
|
65
66
|
}
|
|
66
67
|
function stripAccountWriteOnlyFields(account) {
|
|
67
|
-
const
|
|
68
|
+
const {
|
|
69
|
+
destination_billing_entity: _destination,
|
|
70
|
+
authInfo: _authInfo,
|
|
71
|
+
ctx_metadata: _metadata,
|
|
72
|
+
...responseFields
|
|
73
|
+
} = account;
|
|
74
|
+
const response = stripBusinessEntityBank(stripNotificationConfigSecrets(responseFields), "billing_entity");
|
|
75
|
+
const stripped = { ...response, ...projectAccountResponseIdentityFields(response) };
|
|
68
76
|
const reportingDeliveryConfigs = stripped.reporting_delivery_configs;
|
|
69
77
|
if (reportingDeliveryConfigs === void 0) return stripped;
|
|
70
78
|
return {
|
package/dist/lib/server/serve.js
CHANGED
|
@@ -36,6 +36,7 @@ var import_create_adcp_server = require('./create-adcp-server.js');
|
|
|
36
36
|
var import_tasks = require('./tasks.js');
|
|
37
37
|
var import_adcp_server = require('./adcp-server.js');
|
|
38
38
|
var import_mcp_modern_server = require('./mcp-modern-server.js');
|
|
39
|
+
var import_signed_request_transport = require('./signed-request-transport.js');
|
|
39
40
|
class UnknownHostError extends Error {
|
|
40
41
|
constructor(message = "Unknown host") {
|
|
41
42
|
super(message);
|
|
@@ -407,7 +408,7 @@ function serve(createAgent, options) {
|
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
|
-
const attached = agentServer[import_create_adcp_server.ADCP_PRE_TRANSPORT];
|
|
411
|
+
const attached = (0, import_signed_request_transport.getSignedRequestPreTransport)(agentServer) ?? agentServer[import_create_adcp_server.ADCP_PRE_TRANSPORT];
|
|
411
412
|
const autoWiredPreTransport = typeof attached === "function" ? attached : void 0;
|
|
412
413
|
const activePreTransport = explicitPreTransport ?? autoWiredPreTransport;
|
|
413
414
|
if (activePreTransport) {
|
|
@@ -487,6 +488,7 @@ function serve(createAgent, options) {
|
|
|
487
488
|
const transport = new import_streamableHttp.StreamableHTTPServerTransport({
|
|
488
489
|
sessionIdGenerator: void 0
|
|
489
490
|
});
|
|
491
|
+
(0, import_signed_request_transport.permitSignedRequestTransport)(agentServer, transport);
|
|
490
492
|
await agentServer.connect(transport);
|
|
491
493
|
if (parsedBody !== void 0) {
|
|
492
494
|
await transport.handleRequest(req, res, parsedBody);
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { ADCP_TASK_MESSAGE_QUEUE } from "./tasks.mjs";
|
|
20
20
|
import { getSdkServer, isAdcpServer } from "./adcp-server.mjs";
|
|
21
21
|
import { createModernMcpServerAdapter } from "./mcp-modern-server.mjs";
|
|
22
|
+
import { getSignedRequestPreTransport, permitSignedRequestTransport } from "./signed-request-transport.mjs";
|
|
22
23
|
class UnknownHostError extends Error {
|
|
23
24
|
constructor(message = "Unknown host") {
|
|
24
25
|
super(message);
|
|
@@ -390,7 +391,7 @@ function serve(createAgent, options) {
|
|
|
390
391
|
return;
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
|
-
const attached = agentServer[ADCP_PRE_TRANSPORT];
|
|
394
|
+
const attached = getSignedRequestPreTransport(agentServer) ?? agentServer[ADCP_PRE_TRANSPORT];
|
|
394
395
|
const autoWiredPreTransport = typeof attached === "function" ? attached : void 0;
|
|
395
396
|
const activePreTransport = explicitPreTransport ?? autoWiredPreTransport;
|
|
396
397
|
if (activePreTransport) {
|
|
@@ -470,6 +471,7 @@ function serve(createAgent, options) {
|
|
|
470
471
|
const transport = new StreamableHTTPServerTransport({
|
|
471
472
|
sessionIdGenerator: void 0
|
|
472
473
|
});
|
|
474
|
+
permitSignedRequestTransport(agentServer, transport);
|
|
473
475
|
await agentServer.connect(transport);
|
|
474
476
|
if (parsedBody !== void 0) {
|
|
475
477
|
await transport.handleRequest(req, res, parsedBody);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
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 signed_request_transport_exports = {};
|
|
20
|
+
__export(signed_request_transport_exports, {
|
|
21
|
+
getSignedRequestPreTransport: () => getSignedRequestPreTransport,
|
|
22
|
+
permitSignedRequestTransport: () => permitSignedRequestTransport,
|
|
23
|
+
registerSignedRequestTransportGuard: () => registerSignedRequestTransportGuard
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(signed_request_transport_exports);
|
|
26
|
+
const GUARD = /* @__PURE__ */ Symbol.for("@adcp/client.signedRequestTransportGuard");
|
|
27
|
+
function guardFor(server) {
|
|
28
|
+
return server[GUARD];
|
|
29
|
+
}
|
|
30
|
+
function registerSignedRequestTransportGuard(server, preTransport) {
|
|
31
|
+
const entry = { preTransport, transports: /* @__PURE__ */ new WeakSet() };
|
|
32
|
+
Object.defineProperty(server, GUARD, { value: entry });
|
|
33
|
+
return (transport) => entry.transports.has(transport);
|
|
34
|
+
}
|
|
35
|
+
function getSignedRequestPreTransport(server) {
|
|
36
|
+
return guardFor(server)?.preTransport;
|
|
37
|
+
}
|
|
38
|
+
function permitSignedRequestTransport(server, transport) {
|
|
39
|
+
guardFor(server)?.transports.add(transport);
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
getSignedRequestPreTransport,
|
|
44
|
+
permitSignedRequestTransport,
|
|
45
|
+
registerSignedRequestTransportGuard
|
|
46
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const GUARD = /* @__PURE__ */ Symbol.for("@adcp/client.signedRequestTransportGuard");
|
|
2
|
+
function guardFor(server) {
|
|
3
|
+
return server[GUARD];
|
|
4
|
+
}
|
|
5
|
+
function registerSignedRequestTransportGuard(server, preTransport) {
|
|
6
|
+
const entry = { preTransport, transports: /* @__PURE__ */ new WeakSet() };
|
|
7
|
+
Object.defineProperty(server, GUARD, { value: entry });
|
|
8
|
+
return (transport) => entry.transports.has(transport);
|
|
9
|
+
}
|
|
10
|
+
function getSignedRequestPreTransport(server) {
|
|
11
|
+
return guardFor(server)?.preTransport;
|
|
12
|
+
}
|
|
13
|
+
function permitSignedRequestTransport(server, transport) {
|
|
14
|
+
guardFor(server)?.transports.add(transport);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getSignedRequestPreTransport,
|
|
18
|
+
permitSignedRequestTransport,
|
|
19
|
+
registerSignedRequestTransportGuard
|
|
20
|
+
};
|
|
@@ -764,10 +764,14 @@ async function handleTestControllerRequestImpl(storeOrFactory, input, options) {
|
|
|
764
764
|
if (typeof forceParams.tool !== "string" || forceParams.tool.length === 0) {
|
|
765
765
|
return controllerError("INVALID_PARAMS", "force_upstream_unavailable requires params.tool");
|
|
766
766
|
}
|
|
767
|
+
if (forceParams.cache_age_seconds !== void 0 && (!Number.isInteger(forceParams.cache_age_seconds) || forceParams.cache_age_seconds < 0)) {
|
|
768
|
+
return controllerError("INVALID_PARAMS", "cache_age_seconds must be a non-negative integer");
|
|
769
|
+
}
|
|
767
770
|
return wrapStoreSuccess(
|
|
768
771
|
await store.forceUpstreamUnavailable({
|
|
769
772
|
tool: forceParams.tool,
|
|
770
|
-
upstream_name: typeof forceParams.upstream_name === "string" ? forceParams.upstream_name : void 0
|
|
773
|
+
upstream_name: typeof forceParams.upstream_name === "string" ? forceParams.upstream_name : void 0,
|
|
774
|
+
...typeof forceParams.cache_age_seconds === "number" ? { cache_age_seconds: forceParams.cache_age_seconds } : {}
|
|
771
775
|
})
|
|
772
776
|
);
|
|
773
777
|
}
|
|
@@ -736,10 +736,14 @@ async function handleTestControllerRequestImpl(storeOrFactory, input, options) {
|
|
|
736
736
|
if (typeof forceParams.tool !== "string" || forceParams.tool.length === 0) {
|
|
737
737
|
return controllerError("INVALID_PARAMS", "force_upstream_unavailable requires params.tool");
|
|
738
738
|
}
|
|
739
|
+
if (forceParams.cache_age_seconds !== void 0 && (!Number.isInteger(forceParams.cache_age_seconds) || forceParams.cache_age_seconds < 0)) {
|
|
740
|
+
return controllerError("INVALID_PARAMS", "cache_age_seconds must be a non-negative integer");
|
|
741
|
+
}
|
|
739
742
|
return wrapStoreSuccess(
|
|
740
743
|
await store.forceUpstreamUnavailable({
|
|
741
744
|
tool: forceParams.tool,
|
|
742
|
-
upstream_name: typeof forceParams.upstream_name === "string" ? forceParams.upstream_name : void 0
|
|
745
|
+
upstream_name: typeof forceParams.upstream_name === "string" ? forceParams.upstream_name : void 0,
|
|
746
|
+
...typeof forceParams.cache_age_seconds === "number" ? { cache_age_seconds: forceParams.cache_age_seconds } : {}
|
|
743
747
|
})
|
|
744
748
|
);
|
|
745
749
|
}
|
|
@@ -80,7 +80,7 @@ export interface BuildAgentSigningFetchOptions {
|
|
|
80
80
|
* 1. Sign immediately when the payload carries webhook authentication.
|
|
81
81
|
* 2. Resolve the AdCP operation and exact JSON-RPC protocol method.
|
|
82
82
|
* 3. Consult each capability namespace independently; either can request
|
|
83
|
-
* signing.
|
|
83
|
+
* signing. SDK AdCP task polls sign when the seller supports signing.
|
|
84
84
|
* 4. Resolve the seller's content-digest policy into a per-request toggle.
|
|
85
85
|
* 5. Delegate to `createSigningFetch` with the decision baked in.
|
|
86
86
|
*/
|
|
@@ -80,7 +80,7 @@ export interface BuildAgentSigningFetchOptions {
|
|
|
80
80
|
* 1. Sign immediately when the payload carries webhook authentication.
|
|
81
81
|
* 2. Resolve the AdCP operation and exact JSON-RPC protocol method.
|
|
82
82
|
* 3. Consult each capability namespace independently; either can request
|
|
83
|
-
* signing.
|
|
83
|
+
* signing. SDK AdCP task polls sign when the seller supports signing.
|
|
84
84
|
* 4. Resolve the seller's content-digest policy into a per-request toggle.
|
|
85
85
|
* 5. Delegate to `createSigningFetch` with the decision baked in.
|
|
86
86
|
*/
|
|
@@ -157,13 +157,13 @@ function buildAgentSigningFetch(options) {
|
|
|
157
157
|
}
|
|
158
158
|
const operation = extractAdcpOperation(init?.body);
|
|
159
159
|
if (operation === "get_adcp_capabilities" && (0, import_protocol_methods.hasUnsignedCapabilityBootstrap)(signing)) return false;
|
|
160
|
-
const isPollOperation = operation === "tasks_get" || operation === "tasks/get";
|
|
160
|
+
const isPollOperation = operation === "get_task_status" || operation === "tasks_get" || operation === "tasks/get";
|
|
161
161
|
const methods = policyMethods ?? (isPollOperation ? jsonRpcMethodsForSigning(init?.body) : []);
|
|
162
162
|
const profileCompatible = signing.profile === "web-bot-auth" ? (0, import_protocol_methods.signingListIncludes)(capability?.profiles, "web-bot-auth") : capability?.profiles === void 0 || (0, import_protocol_methods.signingListIncludes)(capability.profiles, "adcp/request-signing/v1");
|
|
163
|
-
const
|
|
163
|
+
const signedPoll = profileCompatible && capability?.supported === true && ((operation === "tasks_get" || operation === "get_task_status") && methods.includes("tools/call") || (operation === "tasks/get" || operation === "get_task_status") && methods.some(
|
|
164
164
|
(method) => ["message/send", "message/stream", "SendMessage", "SendStreamingMessage"].includes(method)
|
|
165
165
|
));
|
|
166
|
-
const sign = signing.profile === "web-bot-auth" && !!operation && (0, import_protocol_methods.signingListIncludes)(capability?.profiles, "web-bot-auth") || shouldSignOperation(operation, capability, signing) || methods.some((method) => shouldSignProtocolMethod(method, capability, signing)) ||
|
|
166
|
+
const sign = signing.profile === "web-bot-auth" && !!operation && (0, import_protocol_methods.signingListIncludes)(capability?.profiles, "web-bot-auth") || shouldSignOperation(operation, capability, signing) || methods.some((method) => shouldSignProtocolMethod(method, capability, signing)) || signedPoll;
|
|
167
167
|
if (sign && signing.profile === "web-bot-auth" && !(0, import_protocol_methods.signingListIncludes)(capability?.profiles, "web-bot-auth"))
|
|
168
168
|
throw new TypeError("Seller did not advertise the Web Bot Auth request signing profile");
|
|
169
169
|
return sign;
|
|
@@ -139,13 +139,13 @@ function buildAgentSigningFetch(options) {
|
|
|
139
139
|
}
|
|
140
140
|
const operation = extractAdcpOperation(init?.body);
|
|
141
141
|
if (operation === "get_adcp_capabilities" && hasUnsignedCapabilityBootstrap(signing)) return false;
|
|
142
|
-
const isPollOperation = operation === "tasks_get" || operation === "tasks/get";
|
|
142
|
+
const isPollOperation = operation === "get_task_status" || operation === "tasks_get" || operation === "tasks/get";
|
|
143
143
|
const methods = policyMethods ?? (isPollOperation ? jsonRpcMethodsForSigning(init?.body) : []);
|
|
144
144
|
const profileCompatible = signing.profile === "web-bot-auth" ? signingListIncludes(capability?.profiles, "web-bot-auth") : capability?.profiles === void 0 || signingListIncludes(capability.profiles, "adcp/request-signing/v1");
|
|
145
|
-
const
|
|
145
|
+
const signedPoll = profileCompatible && capability?.supported === true && ((operation === "tasks_get" || operation === "get_task_status") && methods.includes("tools/call") || (operation === "tasks/get" || operation === "get_task_status") && methods.some(
|
|
146
146
|
(method) => ["message/send", "message/stream", "SendMessage", "SendStreamingMessage"].includes(method)
|
|
147
147
|
));
|
|
148
|
-
const sign = signing.profile === "web-bot-auth" && !!operation && signingListIncludes(capability?.profiles, "web-bot-auth") || shouldSignOperation(operation, capability, signing) || methods.some((method) => shouldSignProtocolMethod(method, capability, signing)) ||
|
|
148
|
+
const sign = signing.profile === "web-bot-auth" && !!operation && signingListIncludes(capability?.profiles, "web-bot-auth") || shouldSignOperation(operation, capability, signing) || methods.some((method) => shouldSignProtocolMethod(method, capability, signing)) || signedPoll;
|
|
149
149
|
if (sign && signing.profile === "web-bot-auth" && !signingListIncludes(capability?.profiles, "web-bot-auth"))
|
|
150
150
|
throw new TypeError("Seller did not advertise the Web Bot Auth request signing profile");
|
|
151
151
|
return sign;
|
|
@@ -23,3 +23,4 @@ export { COLLECTION_DIAGNOSTIC_LIMIT, COLLECTION_PAIR_LIMIT, COLLECTION_TARGETIN
|
|
|
23
23
|
export type { CollectionNormalizationCode, CollectionNormalizationFailure, CollectionNormalizationResult, CrossPublisherCollectionRelation, CollectionPair, CollectionSelectionEvaluation, CollectionSelectionSelector, CollectionSelectionWitness, CollectionSelectorObject, CollectionWitnessKind, CollectionWitnessReadResult, FixtureContextOutput, NormalizedCollectionSelectors, PreparedFixtureBinding, PreparedFixtureSelection, PreparedFixturesAuthorizer, PreparedFixturesDecision, PreparedFixturesDisposition, PreparedFixturesLookup, PreparedFixturesPreparationLookup, PreparedFixturesPreparationAuthorizer, PreparedFixturesRefusal, PreparedFixturesRefusalCode, PreparedFixturesReference, PreparedSchemaArtifact, ProtectedContextViolationCode, ResolvedCollectionSelectionSelector, } from './storyboard/index.mjs';
|
|
24
24
|
export { resolveCreativeBuildProbe, validateCreativeBuildProbeSpec } from './storyboard/index.mjs';
|
|
25
25
|
export type { CreativeBuildProbeSpec, CreativeBuildProbeInputFixture, CreativeBuildProbeResolution, } from './storyboard/index.mjs';
|
|
26
|
+
export { createStoryboardWebBotAuthFetch } from './storyboard/web-bot-auth.mjs';
|
|
@@ -23,3 +23,4 @@ export { COLLECTION_DIAGNOSTIC_LIMIT, COLLECTION_PAIR_LIMIT, COLLECTION_TARGETIN
|
|
|
23
23
|
export type { CollectionNormalizationCode, CollectionNormalizationFailure, CollectionNormalizationResult, CrossPublisherCollectionRelation, CollectionPair, CollectionSelectionEvaluation, CollectionSelectionSelector, CollectionSelectionWitness, CollectionSelectorObject, CollectionWitnessKind, CollectionWitnessReadResult, FixtureContextOutput, NormalizedCollectionSelectors, PreparedFixtureBinding, PreparedFixtureSelection, PreparedFixturesAuthorizer, PreparedFixturesDecision, PreparedFixturesDisposition, PreparedFixturesLookup, PreparedFixturesPreparationLookup, PreparedFixturesPreparationAuthorizer, PreparedFixturesRefusal, PreparedFixturesRefusalCode, PreparedFixturesReference, PreparedSchemaArtifact, ProtectedContextViolationCode, ResolvedCollectionSelectionSelector, } from './storyboard';
|
|
24
24
|
export { resolveCreativeBuildProbe, validateCreativeBuildProbeSpec } from './storyboard';
|
|
25
25
|
export type { CreativeBuildProbeSpec, CreativeBuildProbeInputFixture, CreativeBuildProbeResolution, } from './storyboard';
|
|
26
|
+
export { createStoryboardWebBotAuthFetch } from './storyboard/web-bot-auth';
|