@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
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
type ScopeCleanup = () => Promise<void>;
|
|
1
|
+
type ScopeCleanup = (terminateSession: boolean) => Promise<void>;
|
|
2
2
|
/** Cache-key suffix for the current caller-owned MCP workflow. */
|
|
3
3
|
export declare function currentMCPConnectionScopeKey(): string | undefined;
|
|
4
|
+
/** Preserve seller work even when a higher layer handles a request timeout. */
|
|
5
|
+
export declare function markMCPConnectionScopeInterrupted(): void;
|
|
4
6
|
/** Whether an LRU entry belongs to a workflow that has not finished yet. */
|
|
5
7
|
export declare function isMCPConnectionScopeCacheKeyActive(cacheKey: string): boolean;
|
|
6
8
|
/** Register one idempotent cache-entry cleanup with the current workflow. */
|
|
@@ -20,6 +22,9 @@ export declare function closeCurrentMCPConnectionScope(): Promise<boolean>;
|
|
|
20
22
|
* Per-call correlation headers, `AbortSignal`s and timeouts do not choose the
|
|
21
23
|
* session. The scope terminates its sessions once, when `fn` settles; pass
|
|
22
24
|
* `{ isolate: true }` to force a fresh scope even when called from inside one.
|
|
25
|
+
* Explicit workflows terminate sessions at exit even if an inner call returned
|
|
26
|
+
* submitted/working; the caller owns that lifetime. Implicit task scopes may
|
|
27
|
+
* close only their local clients when their final result remains nonterminal.
|
|
23
28
|
*
|
|
24
29
|
* @example
|
|
25
30
|
* ```ts
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
type ScopeCleanup = () => Promise<void>;
|
|
1
|
+
type ScopeCleanup = (terminateSession: boolean) => Promise<void>;
|
|
2
2
|
/** Cache-key suffix for the current caller-owned MCP workflow. */
|
|
3
3
|
export declare function currentMCPConnectionScopeKey(): string | undefined;
|
|
4
|
+
/** Preserve seller work even when a higher layer handles a request timeout. */
|
|
5
|
+
export declare function markMCPConnectionScopeInterrupted(): void;
|
|
4
6
|
/** Whether an LRU entry belongs to a workflow that has not finished yet. */
|
|
5
7
|
export declare function isMCPConnectionScopeCacheKeyActive(cacheKey: string): boolean;
|
|
6
8
|
/** Register one idempotent cache-entry cleanup with the current workflow. */
|
|
@@ -20,6 +22,9 @@ export declare function closeCurrentMCPConnectionScope(): Promise<boolean>;
|
|
|
20
22
|
* Per-call correlation headers, `AbortSignal`s and timeouts do not choose the
|
|
21
23
|
* session. The scope terminates its sessions once, when `fn` settles; pass
|
|
22
24
|
* `{ isolate: true }` to force a fresh scope even when called from inside one.
|
|
25
|
+
* Explicit workflows terminate sessions at exit even if an inner call returned
|
|
26
|
+
* submitted/working; the caller owns that lifetime. Implicit task scopes may
|
|
27
|
+
* close only their local clients when their final result remains nonterminal.
|
|
23
28
|
*
|
|
24
29
|
* @example
|
|
25
30
|
* ```ts
|
|
@@ -21,18 +21,24 @@ __export(mcp_scope_exports, {
|
|
|
21
21
|
closeCurrentMCPConnectionScope: () => closeCurrentMCPConnectionScope,
|
|
22
22
|
currentMCPConnectionScopeKey: () => currentMCPConnectionScopeKey,
|
|
23
23
|
isMCPConnectionScopeCacheKeyActive: () => isMCPConnectionScopeCacheKeyActive,
|
|
24
|
+
markMCPConnectionScopeInterrupted: () => markMCPConnectionScopeInterrupted,
|
|
24
25
|
registerMCPConnectionScopeCleanup: () => registerMCPConnectionScopeCleanup,
|
|
25
26
|
registerMCPConnectionScopePending: () => registerMCPConnectionScopePending,
|
|
26
27
|
withMCPConnectionScope: () => withMCPConnectionScope
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(mcp_scope_exports);
|
|
29
30
|
var import_node_async_hooks = require("node:async_hooks");
|
|
31
|
+
var import_abort = require('./abort.js');
|
|
30
32
|
const scopeStorage = new import_node_async_hooks.AsyncLocalStorage();
|
|
31
33
|
const activeScopeKeys = /* @__PURE__ */ new Set();
|
|
32
34
|
let nextScopeId = 0;
|
|
33
35
|
function currentMCPConnectionScopeKey() {
|
|
34
36
|
return scopeStorage.getStore()?.cacheKey;
|
|
35
37
|
}
|
|
38
|
+
function markMCPConnectionScopeInterrupted() {
|
|
39
|
+
const scope = scopeStorage.getStore();
|
|
40
|
+
if (scope?.preserveOnInterruption) scope.interrupted = true;
|
|
41
|
+
}
|
|
36
42
|
function isMCPConnectionScopeCacheKeyActive(cacheKey) {
|
|
37
43
|
const marker = cacheKey.lastIndexOf("::scope:");
|
|
38
44
|
return marker >= 0 && activeScopeKeys.has(cacheKey.slice(marker + 2));
|
|
@@ -55,17 +61,32 @@ async function closeCurrentMCPConnectionScope() {
|
|
|
55
61
|
}
|
|
56
62
|
const cleanups = [...scope.cleanups.values()];
|
|
57
63
|
scope.cleanups.clear();
|
|
58
|
-
await Promise.allSettled(
|
|
64
|
+
await Promise.allSettled(
|
|
65
|
+
cleanups.map((cleanup) => cleanup(!scope.signal?.aborted && !scope.interrupted && !scope.preserveSession))
|
|
66
|
+
);
|
|
59
67
|
return true;
|
|
60
68
|
}
|
|
61
69
|
async function withMCPConnectionScope(fn, options = {}) {
|
|
62
70
|
if (scopeStorage.getStore() && options.isolate !== true) return fn();
|
|
63
71
|
const id = ++nextScopeId;
|
|
64
|
-
const scope = {
|
|
72
|
+
const scope = {
|
|
73
|
+
id,
|
|
74
|
+
cacheKey: `scope:${id}`,
|
|
75
|
+
pending: /* @__PURE__ */ new Set(),
|
|
76
|
+
cleanups: /* @__PURE__ */ new Map(),
|
|
77
|
+
signal: options.signal,
|
|
78
|
+
preserveOnInterruption: options.preserveOnInterruption,
|
|
79
|
+
preserveSessionOnResult: options.preserveSessionOnResult
|
|
80
|
+
};
|
|
65
81
|
activeScopeKeys.add(scope.cacheKey);
|
|
66
82
|
return scopeStorage.run(scope, async () => {
|
|
67
83
|
try {
|
|
68
|
-
|
|
84
|
+
const result = await fn();
|
|
85
|
+
scope.preserveSession = scope.preserveSessionOnResult?.(result) === true;
|
|
86
|
+
return result;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if ((0, import_abort.isAbortOrTimeoutError)(error)) markMCPConnectionScopeInterrupted();
|
|
89
|
+
throw error;
|
|
69
90
|
} finally {
|
|
70
91
|
try {
|
|
71
92
|
await closeCurrentMCPConnectionScope();
|
|
@@ -80,6 +101,7 @@ async function withMCPConnectionScope(fn, options = {}) {
|
|
|
80
101
|
closeCurrentMCPConnectionScope,
|
|
81
102
|
currentMCPConnectionScopeKey,
|
|
82
103
|
isMCPConnectionScopeCacheKeyActive,
|
|
104
|
+
markMCPConnectionScopeInterrupted,
|
|
83
105
|
registerMCPConnectionScopeCleanup,
|
|
84
106
|
registerMCPConnectionScopePending,
|
|
85
107
|
withMCPConnectionScope
|
|
@@ -4,12 +4,17 @@ import { createRequire as __adcpCreateRequire } from "node:module";
|
|
|
4
4
|
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
5
|
const require2 = __adcpCreateRequire(import.meta.url);
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
|
+
import { isAbortOrTimeoutError } from "./abort.mjs";
|
|
7
8
|
const scopeStorage = new AsyncLocalStorage();
|
|
8
9
|
const activeScopeKeys = /* @__PURE__ */ new Set();
|
|
9
10
|
let nextScopeId = 0;
|
|
10
11
|
function currentMCPConnectionScopeKey() {
|
|
11
12
|
return scopeStorage.getStore()?.cacheKey;
|
|
12
13
|
}
|
|
14
|
+
function markMCPConnectionScopeInterrupted() {
|
|
15
|
+
const scope = scopeStorage.getStore();
|
|
16
|
+
if (scope?.preserveOnInterruption) scope.interrupted = true;
|
|
17
|
+
}
|
|
13
18
|
function isMCPConnectionScopeCacheKeyActive(cacheKey) {
|
|
14
19
|
const marker = cacheKey.lastIndexOf("::scope:");
|
|
15
20
|
return marker >= 0 && activeScopeKeys.has(cacheKey.slice(marker + 2));
|
|
@@ -32,17 +37,32 @@ async function closeCurrentMCPConnectionScope() {
|
|
|
32
37
|
}
|
|
33
38
|
const cleanups = [...scope.cleanups.values()];
|
|
34
39
|
scope.cleanups.clear();
|
|
35
|
-
await Promise.allSettled(
|
|
40
|
+
await Promise.allSettled(
|
|
41
|
+
cleanups.map((cleanup) => cleanup(!scope.signal?.aborted && !scope.interrupted && !scope.preserveSession))
|
|
42
|
+
);
|
|
36
43
|
return true;
|
|
37
44
|
}
|
|
38
45
|
async function withMCPConnectionScope(fn, options = {}) {
|
|
39
46
|
if (scopeStorage.getStore() && options.isolate !== true) return fn();
|
|
40
47
|
const id = ++nextScopeId;
|
|
41
|
-
const scope = {
|
|
48
|
+
const scope = {
|
|
49
|
+
id,
|
|
50
|
+
cacheKey: `scope:${id}`,
|
|
51
|
+
pending: /* @__PURE__ */ new Set(),
|
|
52
|
+
cleanups: /* @__PURE__ */ new Map(),
|
|
53
|
+
signal: options.signal,
|
|
54
|
+
preserveOnInterruption: options.preserveOnInterruption,
|
|
55
|
+
preserveSessionOnResult: options.preserveSessionOnResult
|
|
56
|
+
};
|
|
42
57
|
activeScopeKeys.add(scope.cacheKey);
|
|
43
58
|
return scopeStorage.run(scope, async () => {
|
|
44
59
|
try {
|
|
45
|
-
|
|
60
|
+
const result = await fn();
|
|
61
|
+
scope.preserveSession = scope.preserveSessionOnResult?.(result) === true;
|
|
62
|
+
return result;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (isAbortOrTimeoutError(error)) markMCPConnectionScopeInterrupted();
|
|
65
|
+
throw error;
|
|
46
66
|
} finally {
|
|
47
67
|
try {
|
|
48
68
|
await closeCurrentMCPConnectionScope();
|
|
@@ -56,6 +76,7 @@ export {
|
|
|
56
76
|
closeCurrentMCPConnectionScope,
|
|
57
77
|
currentMCPConnectionScopeKey,
|
|
58
78
|
isMCPConnectionScopeCacheKeyActive,
|
|
79
|
+
markMCPConnectionScopeInterrupted,
|
|
59
80
|
registerMCPConnectionScopeCleanup,
|
|
60
81
|
registerMCPConnectionScopePending,
|
|
61
82
|
withMCPConnectionScope
|
|
@@ -207,10 +207,10 @@ async function getOrCreateConnection(cacheKey, baseUrl, authHeaders, debugLogs,
|
|
|
207
207
|
throw new Error(`MCP ${label} completed after connection teardown`);
|
|
208
208
|
}
|
|
209
209
|
connectionCache.set(cacheKey, client);
|
|
210
|
-
(0, import_mcp_scope.registerMCPConnectionScopeCleanup)("legacy", cacheKey, async () => {
|
|
210
|
+
(0, import_mcp_scope.registerMCPConnectionScopeCleanup)("legacy", cacheKey, async (terminateSession) => {
|
|
211
211
|
if (connectionCache.get(cacheKey) !== client) return;
|
|
212
212
|
connectionCache.delete(cacheKey);
|
|
213
|
-
await closeMCPClient(client);
|
|
213
|
+
await closeMCPClient(client, terminateSession);
|
|
214
214
|
});
|
|
215
215
|
evictLeastRecentlyUsed();
|
|
216
216
|
return client;
|
|
@@ -280,10 +280,10 @@ async function getOrCreateOAuthConnection(cacheKey, options) {
|
|
|
280
280
|
throw new Error("OAuth MCP connection completed after connection teardown");
|
|
281
281
|
}
|
|
282
282
|
oauthConnectionCache.set(cacheKey, client);
|
|
283
|
-
(0, import_mcp_scope.registerMCPConnectionScopeCleanup)("oauth", cacheKey, async () => {
|
|
283
|
+
(0, import_mcp_scope.registerMCPConnectionScopeCleanup)("oauth", cacheKey, async (terminateSession) => {
|
|
284
284
|
if (oauthConnectionCache.get(cacheKey) !== client) return;
|
|
285
285
|
oauthConnectionCache.delete(cacheKey);
|
|
286
|
-
await closeMCPClient(client);
|
|
286
|
+
await closeMCPClient(client, terminateSession);
|
|
287
287
|
});
|
|
288
288
|
evictLeastRecentlyUsedOAuth();
|
|
289
289
|
return client;
|
|
@@ -337,7 +337,10 @@ async function withCachedOAuthConnectionImpl(options, label, fn) {
|
|
|
337
337
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
338
338
|
error
|
|
339
339
|
});
|
|
340
|
-
if ((0, import_abort.isAbortOrTimeoutError)(error))
|
|
340
|
+
if ((0, import_abort.isAbortOrTimeoutError)(error)) {
|
|
341
|
+
(0, import_mcp_scope.markMCPConnectionScopeInterrupted)();
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
341
344
|
if ((0, import_errors.is401Error)(error)) {
|
|
342
345
|
options.debugLogs.push({
|
|
343
346
|
type: "warning",
|
|
@@ -405,7 +408,10 @@ async function withCachedConnectionImpl(agentUrl, authToken, authHeaders, debugL
|
|
|
405
408
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
406
409
|
error
|
|
407
410
|
});
|
|
408
|
-
if ((0, import_abort.isAbortOrTimeoutError)(error))
|
|
411
|
+
if ((0, import_abort.isAbortOrTimeoutError)(error)) {
|
|
412
|
+
(0, import_mcp_scope.markMCPConnectionScopeInterrupted)();
|
|
413
|
+
throw error;
|
|
414
|
+
}
|
|
409
415
|
if ((0, import_errors.is401Error)(error)) {
|
|
410
416
|
debugLogs.push({
|
|
411
417
|
type: "warning",
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
import { closeModernMCPConnections, tryCallModernMCPTool } from "./mcp-modern.mjs";
|
|
36
36
|
import {
|
|
37
37
|
currentMCPConnectionScopeKey,
|
|
38
|
+
markMCPConnectionScopeInterrupted,
|
|
38
39
|
isMCPConnectionScopeCacheKeyActive,
|
|
39
40
|
registerMCPConnectionScopeCleanup,
|
|
40
41
|
registerMCPConnectionScopePending
|
|
@@ -208,10 +209,10 @@ async function getOrCreateConnection(cacheKey, baseUrl, authHeaders, debugLogs,
|
|
|
208
209
|
throw new Error(`MCP ${label} completed after connection teardown`);
|
|
209
210
|
}
|
|
210
211
|
connectionCache.set(cacheKey, client);
|
|
211
|
-
registerMCPConnectionScopeCleanup("legacy", cacheKey, async () => {
|
|
212
|
+
registerMCPConnectionScopeCleanup("legacy", cacheKey, async (terminateSession) => {
|
|
212
213
|
if (connectionCache.get(cacheKey) !== client) return;
|
|
213
214
|
connectionCache.delete(cacheKey);
|
|
214
|
-
await closeMCPClient(client);
|
|
215
|
+
await closeMCPClient(client, terminateSession);
|
|
215
216
|
});
|
|
216
217
|
evictLeastRecentlyUsed();
|
|
217
218
|
return client;
|
|
@@ -281,10 +282,10 @@ async function getOrCreateOAuthConnection(cacheKey, options) {
|
|
|
281
282
|
throw new Error("OAuth MCP connection completed after connection teardown");
|
|
282
283
|
}
|
|
283
284
|
oauthConnectionCache.set(cacheKey, client);
|
|
284
|
-
registerMCPConnectionScopeCleanup("oauth", cacheKey, async () => {
|
|
285
|
+
registerMCPConnectionScopeCleanup("oauth", cacheKey, async (terminateSession) => {
|
|
285
286
|
if (oauthConnectionCache.get(cacheKey) !== client) return;
|
|
286
287
|
oauthConnectionCache.delete(cacheKey);
|
|
287
|
-
await closeMCPClient(client);
|
|
288
|
+
await closeMCPClient(client, terminateSession);
|
|
288
289
|
});
|
|
289
290
|
evictLeastRecentlyUsedOAuth();
|
|
290
291
|
return client;
|
|
@@ -338,7 +339,10 @@ async function withCachedOAuthConnectionImpl(options, label, fn) {
|
|
|
338
339
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
339
340
|
error
|
|
340
341
|
});
|
|
341
|
-
if (isAbortOrTimeoutError(error))
|
|
342
|
+
if (isAbortOrTimeoutError(error)) {
|
|
343
|
+
markMCPConnectionScopeInterrupted();
|
|
344
|
+
throw error;
|
|
345
|
+
}
|
|
342
346
|
if (is401Error(error)) {
|
|
343
347
|
options.debugLogs.push({
|
|
344
348
|
type: "warning",
|
|
@@ -406,7 +410,10 @@ async function withCachedConnectionImpl(agentUrl, authToken, authHeaders, debugL
|
|
|
406
410
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
407
411
|
error
|
|
408
412
|
});
|
|
409
|
-
if (isAbortOrTimeoutError(error))
|
|
413
|
+
if (isAbortOrTimeoutError(error)) {
|
|
414
|
+
markMCPConnectionScopeInterrupted();
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
410
417
|
if (is401Error(error)) {
|
|
411
418
|
debugLogs.push({
|
|
412
419
|
type: "warning",
|
|
@@ -502,6 +502,7 @@ function compileRowSchema(schema, maxCompileMs, deadline) {
|
|
|
502
502
|
assertInspectionDeadline(deadline);
|
|
503
503
|
const startedAt = Date.now();
|
|
504
504
|
const ajv = new Ajv2020({
|
|
505
|
+
inlineRefs: false,
|
|
505
506
|
strictSchema: true,
|
|
506
507
|
strictTypes: false,
|
|
507
508
|
allErrors: true,
|
|
@@ -472,6 +472,7 @@ function compileRowSchema(schema, maxCompileMs, deadline) {
|
|
|
472
472
|
assertInspectionDeadline(deadline);
|
|
473
473
|
const startedAt = Date.now();
|
|
474
474
|
const ajv = new Ajv2020({
|
|
475
|
+
inlineRefs: false,
|
|
475
476
|
strictSchema: true,
|
|
476
477
|
strictTypes: false,
|
|
477
478
|
allErrors: true,
|
|
@@ -12,3 +12,5 @@ export { BiddingPolicySchema } from '../validation/bidding-policy.mjs';
|
|
|
12
12
|
export { CanonicalBudgetAllocationSchema } from '../validation/budget-allocation.mjs';
|
|
13
13
|
export { SyncCreativesItemSchema, SyncCreativesSuccessStrictSchema, SyncCreativesResponseStrictSchema, SyncCreativesActionSchema, } from '../validation/sync-creatives.mjs';
|
|
14
14
|
export type { SyncCreativesItem, SyncCreativesSuccessStrict } from '../validation/sync-creatives.mjs';
|
|
15
|
+
export { MediaBuyDeliveryReportSchema } from '../validation/media-buy-delivery-report.mjs';
|
|
16
|
+
export type { MediaBuyDeliveryReport } from '../types/media-buy-delivery-report.mjs';
|
|
@@ -12,3 +12,5 @@ export { BiddingPolicySchema } from '../validation/bidding-policy';
|
|
|
12
12
|
export { CanonicalBudgetAllocationSchema } from '../validation/budget-allocation';
|
|
13
13
|
export { SyncCreativesItemSchema, SyncCreativesSuccessStrictSchema, SyncCreativesResponseStrictSchema, SyncCreativesActionSchema, } from '../validation/sync-creatives';
|
|
14
14
|
export type { SyncCreativesItem, SyncCreativesSuccessStrict } from '../validation/sync-creatives';
|
|
15
|
+
export { MediaBuyDeliveryReportSchema } from '../validation/media-buy-delivery-report';
|
|
16
|
+
export type { MediaBuyDeliveryReport } from '../types/media-buy-delivery-report';
|
|
@@ -23,6 +23,7 @@ __export(browser_exports, {
|
|
|
23
23
|
CanonicalBudgetAllocationSchema: () => import_budget_allocation.CanonicalBudgetAllocationSchema,
|
|
24
24
|
GetProductsRequestSchema: () => import_get_products_request.GetProductsRequestSchema,
|
|
25
25
|
LegacyGetProductsRequestSchema: () => import_get_products_request.LegacyGetProductsRequestSchema,
|
|
26
|
+
MediaBuyDeliveryReportSchema: () => import_media_buy_delivery_report.MediaBuyDeliveryReportSchema,
|
|
26
27
|
SyncCreativesActionSchema: () => import_sync_creatives.SyncCreativesActionSchema,
|
|
27
28
|
SyncCreativesItemSchema: () => import_sync_creatives.SyncCreativesItemSchema,
|
|
28
29
|
SyncCreativesResponseStrictSchema: () => import_sync_creatives.SyncCreativesResponseStrictSchema,
|
|
@@ -34,12 +35,14 @@ var import_get_products_request = require('../validation/get-products-request.js
|
|
|
34
35
|
var import_bidding_policy = require('../validation/bidding-policy.js');
|
|
35
36
|
var import_budget_allocation = require('../validation/budget-allocation.js');
|
|
36
37
|
var import_sync_creatives = require('../validation/sync-creatives.js');
|
|
38
|
+
var import_media_buy_delivery_report = require('../validation/media-buy-delivery-report.js');
|
|
37
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
40
|
0 && (module.exports = {
|
|
39
41
|
BiddingPolicySchema,
|
|
40
42
|
CanonicalBudgetAllocationSchema,
|
|
41
43
|
GetProductsRequestSchema,
|
|
42
44
|
LegacyGetProductsRequestSchema,
|
|
45
|
+
MediaBuyDeliveryReportSchema,
|
|
43
46
|
SyncCreativesActionSchema,
|
|
44
47
|
SyncCreativesItemSchema,
|
|
45
48
|
SyncCreativesResponseStrictSchema,
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
SyncCreativesResponseStrictSchema,
|
|
9
9
|
SyncCreativesActionSchema
|
|
10
10
|
} from "../validation/sync-creatives.mjs";
|
|
11
|
+
import { MediaBuyDeliveryReportSchema } from "../validation/media-buy-delivery-report.mjs";
|
|
11
12
|
export {
|
|
12
13
|
BiddingPolicySchema,
|
|
13
14
|
CanonicalBudgetAllocationSchema,
|
|
14
15
|
GetProductsRequestSchema,
|
|
15
16
|
LegacyGetProductsRequestSchema,
|
|
17
|
+
MediaBuyDeliveryReportSchema,
|
|
16
18
|
SyncCreativesActionSchema,
|
|
17
19
|
SyncCreativesItemSchema,
|
|
18
20
|
SyncCreativesResponseStrictSchema,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
import { z } from 'zod';
|
|
43
43
|
import * as schemas from '../types/schemas.generated.mjs';
|
|
44
44
|
import type { KnownToolRequestSchemas } from '../utils/tool-request-schemas.mjs';
|
|
45
|
-
import { getSchemaDocumentByRef, type Direction, type ResolvedToolSchemaDocument, type ResponseVariant } from '../validation/schema-loader.mjs';
|
|
45
|
+
import { getSchemaDocumentByRef, getSchemaValidatorByRef, type Direction, type ResolvedToolSchemaDocument, type ResponseVariant } from '../validation/schema-loader.mjs';
|
|
46
46
|
import type { ValidateFunction } from 'ajv';
|
|
47
47
|
export * from '../types/schemas.generated.mjs';
|
|
48
48
|
export { AgentOAuthClientCredentialsSchema } from '../auth/oauth/client-credentials-schema.mjs';
|
|
@@ -73,7 +73,7 @@ export type VersionedToolSchema = ResolvedToolSchemaDocument;
|
|
|
73
73
|
* callers should normally prefer {@link getCanonicalToolValidator} so
|
|
74
74
|
* reference registration stays internal.
|
|
75
75
|
*/
|
|
76
|
-
export { getSchemaDocumentByRef };
|
|
76
|
+
export { getSchemaDocumentByRef, getSchemaValidatorByRef };
|
|
77
77
|
/** Retrieve the protocol-authored request JSON Schema for a specific AdCP release. */
|
|
78
78
|
export declare function getToolInputSchema(toolName: string, options?: ToolSchemaLookupOptions): VersionedToolSchema | undefined;
|
|
79
79
|
/** Retrieve a protocol-authored response JSON Schema for a specific AdCP release. */
|
|
@@ -178,3 +178,6 @@ export declare function customToolForSchema<TSchema extends InputSchema>(name: s
|
|
|
178
178
|
inputSchema: TSchema;
|
|
179
179
|
handler: (args: z.input<TSchema>, extra?: unknown) => unknown | Promise<unknown>;
|
|
180
180
|
};
|
|
181
|
+
export { MediaBuyDeliveryReportSchema } from '../validation/media-buy-delivery-report.mjs';
|
|
182
|
+
export type { MediaBuyDeliveryReport } from '../types/media-buy-delivery-report.mjs';
|
|
183
|
+
export type { AssetVariant } from '../types/core.generated.mjs';
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
import { z } from 'zod';
|
|
43
43
|
import * as schemas from '../types/schemas.generated';
|
|
44
44
|
import type { KnownToolRequestSchemas } from '../utils/tool-request-schemas';
|
|
45
|
-
import { getSchemaDocumentByRef, type Direction, type ResolvedToolSchemaDocument, type ResponseVariant } from '../validation/schema-loader';
|
|
45
|
+
import { getSchemaDocumentByRef, getSchemaValidatorByRef, type Direction, type ResolvedToolSchemaDocument, type ResponseVariant } from '../validation/schema-loader';
|
|
46
46
|
import type { ValidateFunction } from 'ajv';
|
|
47
47
|
export * from '../types/schemas.generated';
|
|
48
48
|
export { AgentOAuthClientCredentialsSchema } from '../auth/oauth/client-credentials-schema';
|
|
@@ -73,7 +73,7 @@ export type VersionedToolSchema = ResolvedToolSchemaDocument;
|
|
|
73
73
|
* callers should normally prefer {@link getCanonicalToolValidator} so
|
|
74
74
|
* reference registration stays internal.
|
|
75
75
|
*/
|
|
76
|
-
export { getSchemaDocumentByRef };
|
|
76
|
+
export { getSchemaDocumentByRef, getSchemaValidatorByRef };
|
|
77
77
|
/** Retrieve the protocol-authored request JSON Schema for a specific AdCP release. */
|
|
78
78
|
export declare function getToolInputSchema(toolName: string, options?: ToolSchemaLookupOptions): VersionedToolSchema | undefined;
|
|
79
79
|
/** Retrieve a protocol-authored response JSON Schema for a specific AdCP release. */
|
|
@@ -178,3 +178,6 @@ export declare function customToolForSchema<TSchema extends InputSchema>(name: s
|
|
|
178
178
|
inputSchema: TSchema;
|
|
179
179
|
handler: (args: z.input<TSchema>, extra?: unknown) => unknown | Promise<unknown>;
|
|
180
180
|
};
|
|
181
|
+
export { MediaBuyDeliveryReportSchema } from '../validation/media-buy-delivery-report';
|
|
182
|
+
export type { MediaBuyDeliveryReport } from '../types/media-buy-delivery-report';
|
|
183
|
+
export type { AssetVariant } from '../types/core.generated';
|
|
@@ -34,6 +34,7 @@ __export(schemas_exports, {
|
|
|
34
34
|
CanonicalBudgetAllocationSchema: () => import_budget_allocation.CanonicalBudgetAllocationSchema,
|
|
35
35
|
GetProductsRequestSchema: () => import_get_products_request.GetProductsRequestSchema,
|
|
36
36
|
LegacyGetProductsRequestSchema: () => import_get_products_request.LegacyGetProductsRequestSchema,
|
|
37
|
+
MediaBuyDeliveryReportSchema: () => import_media_buy_delivery_report.MediaBuyDeliveryReportSchema,
|
|
37
38
|
SyncCreativesActionSchema: () => import_sync_creatives.SyncCreativesActionSchema,
|
|
38
39
|
SyncCreativesItemSchema: () => import_sync_creatives.SyncCreativesItemSchema,
|
|
39
40
|
SyncCreativesResponseStrictSchema: () => import_sync_creatives.SyncCreativesResponseStrictSchema,
|
|
@@ -46,6 +47,7 @@ __export(schemas_exports, {
|
|
|
46
47
|
customToolForSchema: () => customToolForSchema,
|
|
47
48
|
getCanonicalToolValidator: () => getCanonicalToolValidator,
|
|
48
49
|
getSchemaDocumentByRef: () => import_schema_loader.getSchemaDocumentByRef,
|
|
50
|
+
getSchemaValidatorByRef: () => import_schema_loader.getSchemaValidatorByRef,
|
|
49
51
|
getToolInputSchema: () => getToolInputSchema,
|
|
50
52
|
getToolResponseSchema: () => getToolResponseSchema
|
|
51
53
|
});
|
|
@@ -62,6 +64,7 @@ var import_budget_allocation = require('../validation/budget-allocation.js');
|
|
|
62
64
|
var import_tool_request_schemas2 = require('../utils/tool-request-schemas.js');
|
|
63
65
|
var import_response_schemas = require('../utils/response-schemas.js');
|
|
64
66
|
var import_sync_creatives = require('../validation/sync-creatives.js');
|
|
67
|
+
var import_media_buy_delivery_report = require('../validation/media-buy-delivery-report.js');
|
|
65
68
|
function getToolInputSchema(toolName, options = {}) {
|
|
66
69
|
return (0, import_schema_loader.getToolSchemaDocument)(toolName, "request", (0, import_adcp_version_config.resolveAdcpVersion)(options.adcpVersion));
|
|
67
70
|
}
|
|
@@ -113,6 +116,7 @@ function customToolForSchema(name, description, inputSchema, handler) {
|
|
|
113
116
|
CanonicalBudgetAllocationSchema,
|
|
114
117
|
GetProductsRequestSchema,
|
|
115
118
|
LegacyGetProductsRequestSchema,
|
|
119
|
+
MediaBuyDeliveryReportSchema,
|
|
116
120
|
SyncCreativesActionSchema,
|
|
117
121
|
SyncCreativesItemSchema,
|
|
118
122
|
SyncCreativesResponseStrictSchema,
|
|
@@ -125,6 +129,7 @@ function customToolForSchema(name, description, inputSchema, handler) {
|
|
|
125
129
|
customToolForSchema,
|
|
126
130
|
getCanonicalToolValidator,
|
|
127
131
|
getSchemaDocumentByRef,
|
|
132
|
+
getSchemaValidatorByRef,
|
|
128
133
|
getToolInputSchema,
|
|
129
134
|
getToolResponseSchema,
|
|
130
135
|
...require('../types/schemas.generated.js')
|
|
@@ -3,6 +3,7 @@ import { TOOL_REQUEST_SCHEMAS } from "../utils/tool-request-schemas.mjs";
|
|
|
3
3
|
import {
|
|
4
4
|
getCanonicalToolValidatorForVersion,
|
|
5
5
|
getSchemaDocumentByRef,
|
|
6
|
+
getSchemaValidatorByRef,
|
|
6
7
|
getToolSchemaDocument
|
|
7
8
|
} from "../validation/schema-loader.mjs";
|
|
8
9
|
import { resolveAdcpVersion } from "../utils/adcp-version-config.mjs";
|
|
@@ -63,12 +64,14 @@ function customToolForSchema(name, description, inputSchema, handler) {
|
|
|
63
64
|
void name;
|
|
64
65
|
return { description, inputSchema, handler };
|
|
65
66
|
}
|
|
67
|
+
import { MediaBuyDeliveryReportSchema } from "../validation/media-buy-delivery-report.mjs";
|
|
66
68
|
export {
|
|
67
69
|
AgentOAuthClientCredentialsSchema,
|
|
68
70
|
BiddingPolicySchema,
|
|
69
71
|
CanonicalBudgetAllocationSchema,
|
|
70
72
|
GetProductsRequestSchema,
|
|
71
73
|
LegacyGetProductsRequestSchema,
|
|
74
|
+
MediaBuyDeliveryReportSchema,
|
|
72
75
|
SyncCreativesActionSchema,
|
|
73
76
|
SyncCreativesItemSchema,
|
|
74
77
|
SyncCreativesResponseStrictSchema,
|
|
@@ -81,6 +84,7 @@ export {
|
|
|
81
84
|
customToolForSchema,
|
|
82
85
|
getCanonicalToolValidator,
|
|
83
86
|
getSchemaDocumentByRef,
|
|
87
|
+
getSchemaValidatorByRef,
|
|
84
88
|
getToolInputSchema,
|
|
85
89
|
getToolResponseSchema
|
|
86
90
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SyncAccountsSuccess } from '../types/tools.generated.mjs';
|
|
2
|
+
declare const IDENTITY_RESPONSE_SCHEMAS: {
|
|
3
|
+
readonly account: "core/account-ref.json";
|
|
4
|
+
readonly operator_unit: "core/operator-unit.json";
|
|
5
|
+
readonly identity_change: "core/account-identity-change.json";
|
|
6
|
+
readonly identity_change_preview: "core/account-identity-change-preview.json";
|
|
7
|
+
};
|
|
8
|
+
type IdentityFields = Pick<SyncAccountsSuccess['accounts'][number], keyof typeof IDENTITY_RESPONSE_SCHEMAS>;
|
|
9
|
+
/**
|
|
10
|
+
* These canonical identity objects have closed schemas, including their nested
|
|
11
|
+
* operator identities. Validate and emit the same detached snapshot so retained
|
|
12
|
+
* DB/request fields or later mutations cannot enter a response or replay cache,
|
|
13
|
+
* even with whole-response validation off. These four core contracts are shared
|
|
14
|
+
* by the maintained 3.2 and 3.3 bundles.
|
|
15
|
+
*/
|
|
16
|
+
export declare function projectAccountResponseIdentityFields(account: object): IdentityFields;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SyncAccountsSuccess } from '../types/tools.generated';
|
|
2
|
+
declare const IDENTITY_RESPONSE_SCHEMAS: {
|
|
3
|
+
readonly account: "core/account-ref.json";
|
|
4
|
+
readonly operator_unit: "core/operator-unit.json";
|
|
5
|
+
readonly identity_change: "core/account-identity-change.json";
|
|
6
|
+
readonly identity_change_preview: "core/account-identity-change-preview.json";
|
|
7
|
+
};
|
|
8
|
+
type IdentityFields = Pick<SyncAccountsSuccess['accounts'][number], keyof typeof IDENTITY_RESPONSE_SCHEMAS>;
|
|
9
|
+
/**
|
|
10
|
+
* These canonical identity objects have closed schemas, including their nested
|
|
11
|
+
* operator identities. Validate and emit the same detached snapshot so retained
|
|
12
|
+
* DB/request fields or later mutations cannot enter a response or replay cache,
|
|
13
|
+
* even with whole-response validation off. These four core contracts are shared
|
|
14
|
+
* by the maintained 3.2 and 3.3 bundles.
|
|
15
|
+
*/
|
|
16
|
+
export declare function projectAccountResponseIdentityFields(account: object): IdentityFields;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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 account_response_identity_exports = {};
|
|
20
|
+
__export(account_response_identity_exports, {
|
|
21
|
+
projectAccountResponseIdentityFields: () => projectAccountResponseIdentityFields
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(account_response_identity_exports);
|
|
24
|
+
var import_schema_loader = require('../validation/schema-loader.js');
|
|
25
|
+
const IDENTITY_RESPONSE_SCHEMAS = {
|
|
26
|
+
account: "core/account-ref.json",
|
|
27
|
+
operator_unit: "core/operator-unit.json",
|
|
28
|
+
identity_change: "core/account-identity-change.json",
|
|
29
|
+
identity_change_preview: "core/account-identity-change-preview.json"
|
|
30
|
+
};
|
|
31
|
+
function projectAccountResponseIdentityFields(account) {
|
|
32
|
+
const fields = account;
|
|
33
|
+
const projected = {};
|
|
34
|
+
for (const [field, schemaRef] of Object.entries(IDENTITY_RESPONSE_SCHEMAS)) {
|
|
35
|
+
const value = fields[field];
|
|
36
|
+
if (value === void 0) continue;
|
|
37
|
+
const snapshot = structuredClone(value);
|
|
38
|
+
const validate = (0, import_schema_loader.getSchemaValidatorByRef)(schemaRef);
|
|
39
|
+
if (!validate) throw new Error(`Account response identity schema unavailable: ${schemaRef}.`);
|
|
40
|
+
if (!validate(snapshot)) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Account response ${field} must match its canonical identity schema without retained internal fields.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
Object.assign(projected, { [field]: snapshot });
|
|
46
|
+
}
|
|
47
|
+
return projected;
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
projectAccountResponseIdentityFields
|
|
52
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getSchemaValidatorByRef } from "../validation/schema-loader.mjs";
|
|
2
|
+
const IDENTITY_RESPONSE_SCHEMAS = {
|
|
3
|
+
account: "core/account-ref.json",
|
|
4
|
+
operator_unit: "core/operator-unit.json",
|
|
5
|
+
identity_change: "core/account-identity-change.json",
|
|
6
|
+
identity_change_preview: "core/account-identity-change-preview.json"
|
|
7
|
+
};
|
|
8
|
+
function projectAccountResponseIdentityFields(account) {
|
|
9
|
+
const fields = account;
|
|
10
|
+
const projected = {};
|
|
11
|
+
for (const [field, schemaRef] of Object.entries(IDENTITY_RESPONSE_SCHEMAS)) {
|
|
12
|
+
const value = fields[field];
|
|
13
|
+
if (value === void 0) continue;
|
|
14
|
+
const snapshot = structuredClone(value);
|
|
15
|
+
const validate = getSchemaValidatorByRef(schemaRef);
|
|
16
|
+
if (!validate) throw new Error(`Account response identity schema unavailable: ${schemaRef}.`);
|
|
17
|
+
if (!validate(snapshot)) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`Account response ${field} must match its canonical identity schema without retained internal fields.`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
Object.assign(projected, { [field]: snapshot });
|
|
23
|
+
}
|
|
24
|
+
return projected;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
projectAccountResponseIdentityFields
|
|
28
|
+
};
|
|
@@ -206,6 +206,7 @@ async function checkSyncAccountRows(accounts, entries, existing, rows, indices,
|
|
|
206
206
|
}
|
|
207
207
|
).toStructuredError();
|
|
208
208
|
row = {
|
|
209
|
+
...row.account !== void 0 && { account: row.account },
|
|
209
210
|
brand: row.brand,
|
|
210
211
|
operator: row.operator,
|
|
211
212
|
...priorId === row.account_id && priorId && { account_id: priorId },
|
|
@@ -179,6 +179,7 @@ async function checkSyncAccountRows(accounts, entries, existing, rows, indices,
|
|
|
179
179
|
}
|
|
180
180
|
).toStructuredError();
|
|
181
181
|
row = {
|
|
182
|
+
...row.account !== void 0 && { account: row.account },
|
|
182
183
|
brand: row.brand,
|
|
183
184
|
operator: row.operator,
|
|
184
185
|
...priorId === row.account_id && priorId && { account_id: priorId },
|