@adcp/sdk 17.0.0-beta.1 → 17.0.0-beta.2
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/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 +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 +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/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/create-adcp-server.js +33 -20
- package/dist/lib/server/create-adcp-server.mjs +36 -12
- 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/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/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/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/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- 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 +191 -14
- package/docs/migration-6.6-to-6.7.md +14 -0
- package/docs/migration-account-change-feed.md +15 -0
- package/docs/recipes/verifying-inbound-webhooks.md +18 -2
- package/package.json +2 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface SchemaEnvironment {
|
|
2
|
+
schema: unknown;
|
|
3
|
+
root: {
|
|
4
|
+
schema: unknown;
|
|
5
|
+
};
|
|
6
|
+
baseId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SchemaDiagnosticOrigin {
|
|
9
|
+
schema: unknown;
|
|
10
|
+
schemaId?: string;
|
|
11
|
+
/** Original AJV function-relative spelling; exact origins remain internal. */
|
|
12
|
+
schemaPath: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SchemaDiagnosticOrigins {
|
|
15
|
+
process: (source: string, environment?: SchemaEnvironment) => string;
|
|
16
|
+
resolve: (schemaPath: string) => unknown;
|
|
17
|
+
origin: (schemaPath: string) => SchemaDiagnosticOrigin | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Use AJV's supported code.process hook; only diagnostic string literals change. */
|
|
20
|
+
export declare function createSchemaDiagnosticOrigins(): SchemaDiagnosticOrigins;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface SchemaEnvironment {
|
|
2
|
+
schema: unknown;
|
|
3
|
+
root: {
|
|
4
|
+
schema: unknown;
|
|
5
|
+
};
|
|
6
|
+
baseId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SchemaDiagnosticOrigin {
|
|
9
|
+
schema: unknown;
|
|
10
|
+
schemaId?: string;
|
|
11
|
+
/** Original AJV function-relative spelling; exact origins remain internal. */
|
|
12
|
+
schemaPath: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SchemaDiagnosticOrigins {
|
|
15
|
+
process: (source: string, environment?: SchemaEnvironment) => string;
|
|
16
|
+
resolve: (schemaPath: string) => unknown;
|
|
17
|
+
origin: (schemaPath: string) => SchemaDiagnosticOrigin | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Use AJV's supported code.process hook; only diagnostic string literals change. */
|
|
20
|
+
export declare function createSchemaDiagnosticOrigins(): SchemaDiagnosticOrigins;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var schema_diagnostic_origins_exports = {};
|
|
20
|
+
__export(schema_diagnostic_origins_exports, {
|
|
21
|
+
createSchemaDiagnosticOrigins: () => createSchemaDiagnosticOrigins
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(schema_diagnostic_origins_exports);
|
|
24
|
+
function object(value) {
|
|
25
|
+
return value !== null && typeof value === "object";
|
|
26
|
+
}
|
|
27
|
+
function schemaPathLiterals(source) {
|
|
28
|
+
const paths = [];
|
|
29
|
+
const stringEnd = (start) => {
|
|
30
|
+
const quote = source[start];
|
|
31
|
+
for (let index = start + 1; index < source.length; index++) {
|
|
32
|
+
if (source[index] === "\\") index++;
|
|
33
|
+
else if (source[index] === quote) return index + 1;
|
|
34
|
+
}
|
|
35
|
+
return -1;
|
|
36
|
+
};
|
|
37
|
+
for (let index = 0; index < source.length; ) {
|
|
38
|
+
const start = index;
|
|
39
|
+
let key;
|
|
40
|
+
if (source[index] === '"' || source[index] === "'") {
|
|
41
|
+
index = stringEnd(index);
|
|
42
|
+
if (index < 0) return void 0;
|
|
43
|
+
try {
|
|
44
|
+
key = JSON.parse(source.slice(start, index));
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
} else if (/[A-Za-z_$]/.test(source[index])) {
|
|
48
|
+
while (index < source.length && /[\w$]/.test(source[index])) index++;
|
|
49
|
+
key = source.slice(start, index);
|
|
50
|
+
} else if (source.startsWith("//", index)) {
|
|
51
|
+
index = source.indexOf("\n", index + 2);
|
|
52
|
+
if (index < 0) break;
|
|
53
|
+
} else if (source.startsWith("/*", index)) {
|
|
54
|
+
index = source.indexOf("*/", index + 2);
|
|
55
|
+
if (index < 0) return void 0;
|
|
56
|
+
index += 2;
|
|
57
|
+
} else {
|
|
58
|
+
if (source[index] === "`") return void 0;
|
|
59
|
+
if (source[index] === "/") {
|
|
60
|
+
const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
|
|
61
|
+
if (pointerEscape && /\.replace\(\s*$/.test(source.slice(0, index))) {
|
|
62
|
+
index += pointerEscape.length;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const previous = source.slice(0, index).match(/(?:^|[^\w$])(data\d*)\s*$/);
|
|
66
|
+
if (!previous) return void 0;
|
|
67
|
+
}
|
|
68
|
+
index++;
|
|
69
|
+
}
|
|
70
|
+
if (key !== "schemaPath") continue;
|
|
71
|
+
let valueStart = index;
|
|
72
|
+
while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
|
|
73
|
+
if (source[valueStart] !== ":") continue;
|
|
74
|
+
valueStart++;
|
|
75
|
+
while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
|
|
76
|
+
if (source[valueStart] !== '"') return void 0;
|
|
77
|
+
const end = stringEnd(valueStart);
|
|
78
|
+
if (end < 0) return void 0;
|
|
79
|
+
let value;
|
|
80
|
+
try {
|
|
81
|
+
value = JSON.parse(source.slice(valueStart, end));
|
|
82
|
+
} catch {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
if (typeof value !== "string" || !value.startsWith("#")) return void 0;
|
|
86
|
+
paths.push({ start: valueStart, end, value });
|
|
87
|
+
index = end;
|
|
88
|
+
}
|
|
89
|
+
return paths;
|
|
90
|
+
}
|
|
91
|
+
function createSchemaDiagnosticOrigins() {
|
|
92
|
+
const indexes = /* @__PURE__ */ new WeakMap();
|
|
93
|
+
const anonymousIds = /* @__PURE__ */ new WeakMap();
|
|
94
|
+
const origins = /* @__PURE__ */ new Map();
|
|
95
|
+
let anonymousId = 0;
|
|
96
|
+
const indexRoot = (root) => {
|
|
97
|
+
const cached = indexes.get(root);
|
|
98
|
+
if (cached) return cached;
|
|
99
|
+
const paths = /* @__PURE__ */ new WeakMap();
|
|
100
|
+
const pending = [[root, "#"]];
|
|
101
|
+
while (pending.length) {
|
|
102
|
+
const [node, pointer] = pending.pop();
|
|
103
|
+
if (paths.has(node)) continue;
|
|
104
|
+
paths.set(node, pointer);
|
|
105
|
+
for (const [key, child] of Object.entries(node)) {
|
|
106
|
+
if (object(child))
|
|
107
|
+
pending.push([child, `${pointer}/${encodeURIComponent(key.replace(/~/g, "~0").replace(/\//g, "~1"))}`]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
indexes.set(root, paths);
|
|
111
|
+
return paths;
|
|
112
|
+
};
|
|
113
|
+
const origin = (schemaPath) => {
|
|
114
|
+
const hash = schemaPath.indexOf("#");
|
|
115
|
+
if (hash < 0) return void 0;
|
|
116
|
+
let prefix = schemaPath;
|
|
117
|
+
while (prefix.length >= hash + 1) {
|
|
118
|
+
if (origins.has(prefix)) {
|
|
119
|
+
const entry = origins.get(prefix);
|
|
120
|
+
if (!entry) return void 0;
|
|
121
|
+
let cursor = entry.schema;
|
|
122
|
+
let schemaId = entry.schemaId;
|
|
123
|
+
const relative = schemaPath.slice(prefix.length);
|
|
124
|
+
if (relative)
|
|
125
|
+
for (const segment of relative.slice(1).split("/")) {
|
|
126
|
+
let key;
|
|
127
|
+
try {
|
|
128
|
+
key = decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~");
|
|
129
|
+
} catch {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype" || !object(cursor) || !Object.hasOwn(cursor, key))
|
|
133
|
+
return void 0;
|
|
134
|
+
cursor = cursor[key];
|
|
135
|
+
if (object(cursor) && typeof cursor.$id === "string") {
|
|
136
|
+
try {
|
|
137
|
+
schemaId = new URL(cursor.$id, schemaId).href;
|
|
138
|
+
} catch {
|
|
139
|
+
schemaId = cursor.$id;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { schema: cursor, ...schemaId && { schemaId }, schemaPath: `#${relative}` };
|
|
144
|
+
}
|
|
145
|
+
const slash = prefix.lastIndexOf("/");
|
|
146
|
+
if (slash <= hash) {
|
|
147
|
+
if (prefix.length === hash + 1) break;
|
|
148
|
+
prefix = prefix.slice(0, hash + 1);
|
|
149
|
+
} else prefix = prefix.slice(0, slash);
|
|
150
|
+
}
|
|
151
|
+
return void 0;
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
process(source, environment) {
|
|
155
|
+
const literals = schemaPathLiterals(source);
|
|
156
|
+
if (!environment || !literals?.length || !object(environment.schema) || !object(environment.root.schema))
|
|
157
|
+
return source;
|
|
158
|
+
const root = environment.root.schema;
|
|
159
|
+
const pointer = indexRoot(root).get(environment.schema);
|
|
160
|
+
const document = pointer !== void 0 ? root : environment.schema;
|
|
161
|
+
let id = typeof document.$id === "string" ? document.$id.replace(/#.*$/, "") : void 0;
|
|
162
|
+
if (!id) {
|
|
163
|
+
id = anonymousIds.get(document);
|
|
164
|
+
if (!id) {
|
|
165
|
+
id = `urn:adcp:schema-origin:${anonymousId++}`;
|
|
166
|
+
anonymousIds.set(document, id);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const prefix = `${id}${pointer ?? "#"}`;
|
|
170
|
+
if (origins.has(prefix) && origins.get(prefix)?.schema !== environment.schema) origins.set(prefix, void 0);
|
|
171
|
+
else if (!origins.has(prefix)) {
|
|
172
|
+
const schemaId = environment.baseId || (typeof environment.schema.$id === "string" ? environment.schema.$id : void 0);
|
|
173
|
+
origins.set(prefix, { schema: environment.schema, ...schemaId && { schemaId } });
|
|
174
|
+
}
|
|
175
|
+
const fragments = [];
|
|
176
|
+
let cursor = 0;
|
|
177
|
+
for (const literal of literals) {
|
|
178
|
+
fragments.push(source.slice(cursor, literal.start), JSON.stringify(prefix + literal.value.slice(1)));
|
|
179
|
+
cursor = literal.end;
|
|
180
|
+
}
|
|
181
|
+
fragments.push(source.slice(cursor));
|
|
182
|
+
return fragments.join("");
|
|
183
|
+
},
|
|
184
|
+
resolve(schemaPath) {
|
|
185
|
+
return origin(schemaPath)?.schema;
|
|
186
|
+
},
|
|
187
|
+
origin
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
+
0 && (module.exports = {
|
|
192
|
+
createSchemaDiagnosticOrigins
|
|
193
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
function object(value) {
|
|
2
|
+
return value !== null && typeof value === "object";
|
|
3
|
+
}
|
|
4
|
+
function schemaPathLiterals(source) {
|
|
5
|
+
const paths = [];
|
|
6
|
+
const stringEnd = (start) => {
|
|
7
|
+
const quote = source[start];
|
|
8
|
+
for (let index = start + 1; index < source.length; index++) {
|
|
9
|
+
if (source[index] === "\\") index++;
|
|
10
|
+
else if (source[index] === quote) return index + 1;
|
|
11
|
+
}
|
|
12
|
+
return -1;
|
|
13
|
+
};
|
|
14
|
+
for (let index = 0; index < source.length; ) {
|
|
15
|
+
const start = index;
|
|
16
|
+
let key;
|
|
17
|
+
if (source[index] === '"' || source[index] === "'") {
|
|
18
|
+
index = stringEnd(index);
|
|
19
|
+
if (index < 0) return void 0;
|
|
20
|
+
try {
|
|
21
|
+
key = JSON.parse(source.slice(start, index));
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
} else if (/[A-Za-z_$]/.test(source[index])) {
|
|
25
|
+
while (index < source.length && /[\w$]/.test(source[index])) index++;
|
|
26
|
+
key = source.slice(start, index);
|
|
27
|
+
} else if (source.startsWith("//", index)) {
|
|
28
|
+
index = source.indexOf("\n", index + 2);
|
|
29
|
+
if (index < 0) break;
|
|
30
|
+
} else if (source.startsWith("/*", index)) {
|
|
31
|
+
index = source.indexOf("*/", index + 2);
|
|
32
|
+
if (index < 0) return void 0;
|
|
33
|
+
index += 2;
|
|
34
|
+
} else {
|
|
35
|
+
if (source[index] === "`") return void 0;
|
|
36
|
+
if (source[index] === "/") {
|
|
37
|
+
const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
|
|
38
|
+
if (pointerEscape && /\.replace\(\s*$/.test(source.slice(0, index))) {
|
|
39
|
+
index += pointerEscape.length;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const previous = source.slice(0, index).match(/(?:^|[^\w$])(data\d*)\s*$/);
|
|
43
|
+
if (!previous) return void 0;
|
|
44
|
+
}
|
|
45
|
+
index++;
|
|
46
|
+
}
|
|
47
|
+
if (key !== "schemaPath") continue;
|
|
48
|
+
let valueStart = index;
|
|
49
|
+
while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
|
|
50
|
+
if (source[valueStart] !== ":") continue;
|
|
51
|
+
valueStart++;
|
|
52
|
+
while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
|
|
53
|
+
if (source[valueStart] !== '"') return void 0;
|
|
54
|
+
const end = stringEnd(valueStart);
|
|
55
|
+
if (end < 0) return void 0;
|
|
56
|
+
let value;
|
|
57
|
+
try {
|
|
58
|
+
value = JSON.parse(source.slice(valueStart, end));
|
|
59
|
+
} catch {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
if (typeof value !== "string" || !value.startsWith("#")) return void 0;
|
|
63
|
+
paths.push({ start: valueStart, end, value });
|
|
64
|
+
index = end;
|
|
65
|
+
}
|
|
66
|
+
return paths;
|
|
67
|
+
}
|
|
68
|
+
function createSchemaDiagnosticOrigins() {
|
|
69
|
+
const indexes = /* @__PURE__ */ new WeakMap();
|
|
70
|
+
const anonymousIds = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
const origins = /* @__PURE__ */ new Map();
|
|
72
|
+
let anonymousId = 0;
|
|
73
|
+
const indexRoot = (root) => {
|
|
74
|
+
const cached = indexes.get(root);
|
|
75
|
+
if (cached) return cached;
|
|
76
|
+
const paths = /* @__PURE__ */ new WeakMap();
|
|
77
|
+
const pending = [[root, "#"]];
|
|
78
|
+
while (pending.length) {
|
|
79
|
+
const [node, pointer] = pending.pop();
|
|
80
|
+
if (paths.has(node)) continue;
|
|
81
|
+
paths.set(node, pointer);
|
|
82
|
+
for (const [key, child] of Object.entries(node)) {
|
|
83
|
+
if (object(child))
|
|
84
|
+
pending.push([child, `${pointer}/${encodeURIComponent(key.replace(/~/g, "~0").replace(/\//g, "~1"))}`]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
indexes.set(root, paths);
|
|
88
|
+
return paths;
|
|
89
|
+
};
|
|
90
|
+
const origin = (schemaPath) => {
|
|
91
|
+
const hash = schemaPath.indexOf("#");
|
|
92
|
+
if (hash < 0) return void 0;
|
|
93
|
+
let prefix = schemaPath;
|
|
94
|
+
while (prefix.length >= hash + 1) {
|
|
95
|
+
if (origins.has(prefix)) {
|
|
96
|
+
const entry = origins.get(prefix);
|
|
97
|
+
if (!entry) return void 0;
|
|
98
|
+
let cursor = entry.schema;
|
|
99
|
+
let schemaId = entry.schemaId;
|
|
100
|
+
const relative = schemaPath.slice(prefix.length);
|
|
101
|
+
if (relative)
|
|
102
|
+
for (const segment of relative.slice(1).split("/")) {
|
|
103
|
+
let key;
|
|
104
|
+
try {
|
|
105
|
+
key = decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~");
|
|
106
|
+
} catch {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype" || !object(cursor) || !Object.hasOwn(cursor, key))
|
|
110
|
+
return void 0;
|
|
111
|
+
cursor = cursor[key];
|
|
112
|
+
if (object(cursor) && typeof cursor.$id === "string") {
|
|
113
|
+
try {
|
|
114
|
+
schemaId = new URL(cursor.$id, schemaId).href;
|
|
115
|
+
} catch {
|
|
116
|
+
schemaId = cursor.$id;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return { schema: cursor, ...schemaId && { schemaId }, schemaPath: `#${relative}` };
|
|
121
|
+
}
|
|
122
|
+
const slash = prefix.lastIndexOf("/");
|
|
123
|
+
if (slash <= hash) {
|
|
124
|
+
if (prefix.length === hash + 1) break;
|
|
125
|
+
prefix = prefix.slice(0, hash + 1);
|
|
126
|
+
} else prefix = prefix.slice(0, slash);
|
|
127
|
+
}
|
|
128
|
+
return void 0;
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
process(source, environment) {
|
|
132
|
+
const literals = schemaPathLiterals(source);
|
|
133
|
+
if (!environment || !literals?.length || !object(environment.schema) || !object(environment.root.schema))
|
|
134
|
+
return source;
|
|
135
|
+
const root = environment.root.schema;
|
|
136
|
+
const pointer = indexRoot(root).get(environment.schema);
|
|
137
|
+
const document = pointer !== void 0 ? root : environment.schema;
|
|
138
|
+
let id = typeof document.$id === "string" ? document.$id.replace(/#.*$/, "") : void 0;
|
|
139
|
+
if (!id) {
|
|
140
|
+
id = anonymousIds.get(document);
|
|
141
|
+
if (!id) {
|
|
142
|
+
id = `urn:adcp:schema-origin:${anonymousId++}`;
|
|
143
|
+
anonymousIds.set(document, id);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const prefix = `${id}${pointer ?? "#"}`;
|
|
147
|
+
if (origins.has(prefix) && origins.get(prefix)?.schema !== environment.schema) origins.set(prefix, void 0);
|
|
148
|
+
else if (!origins.has(prefix)) {
|
|
149
|
+
const schemaId = environment.baseId || (typeof environment.schema.$id === "string" ? environment.schema.$id : void 0);
|
|
150
|
+
origins.set(prefix, { schema: environment.schema, ...schemaId && { schemaId } });
|
|
151
|
+
}
|
|
152
|
+
const fragments = [];
|
|
153
|
+
let cursor = 0;
|
|
154
|
+
for (const literal of literals) {
|
|
155
|
+
fragments.push(source.slice(cursor, literal.start), JSON.stringify(prefix + literal.value.slice(1)));
|
|
156
|
+
cursor = literal.end;
|
|
157
|
+
}
|
|
158
|
+
fragments.push(source.slice(cursor));
|
|
159
|
+
return fragments.join("");
|
|
160
|
+
},
|
|
161
|
+
resolve(schemaPath) {
|
|
162
|
+
return origin(schemaPath)?.schema;
|
|
163
|
+
},
|
|
164
|
+
origin
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
createSchemaDiagnosticOrigins
|
|
169
|
+
};
|
|
@@ -36,6 +36,7 @@ __export(schema_loader_exports, {
|
|
|
36
36
|
getMcpProfileInputSchema: () => getMcpProfileInputSchema,
|
|
37
37
|
getMcpToolSchema: () => getMcpToolSchema,
|
|
38
38
|
getMcpToolSummary: () => getMcpToolSummary,
|
|
39
|
+
getMediaBuyDeliveryEnvelopeValidator: () => getMediaBuyDeliveryEnvelopeValidator,
|
|
39
40
|
getRegisteredSchemaIds: () => getRegisteredSchemaIds,
|
|
40
41
|
getRequestSchemaEntityPaths: () => getRequestSchemaEntityPaths,
|
|
41
42
|
getSchemaDefaultByPath: () => getSchemaDefaultByPath,
|
|
@@ -44,14 +45,17 @@ __export(schema_loader_exports, {
|
|
|
44
45
|
getSchemaValidatorByRef: () => getSchemaValidatorByRef,
|
|
45
46
|
getToolSchemaDocument: () => getToolSchemaDocument,
|
|
46
47
|
getValidator: () => getValidator,
|
|
48
|
+
getValidatorDiagnosticOrigin: () => getValidatorDiagnosticOrigin,
|
|
47
49
|
hasSchemaBundle: () => hasSchemaBundle,
|
|
48
50
|
isExternalSchemaRootActive: () => isExternalSchemaRootActive,
|
|
49
51
|
isIdentity33SchemaScope: () => isIdentity33SchemaScope,
|
|
50
52
|
listValidatorKeys: () => listValidatorKeys,
|
|
51
53
|
registerExternalSchemaRoot: () => registerExternalSchemaRoot,
|
|
54
|
+
relaxResponseRoot: () => relaxResponseRoot,
|
|
52
55
|
resolveBundleKey: () => resolveBundleKey,
|
|
53
56
|
resolveSchemaRoot: () => resolveSchemaRoot,
|
|
54
57
|
resolveServedValidationVersion: () => resolveServedValidationVersion,
|
|
58
|
+
resolveValidatorDiagnosticPath: () => resolveValidatorDiagnosticPath,
|
|
55
59
|
schemaAllowsTopLevelField: () => schemaAllowsTopLevelField,
|
|
56
60
|
toReleasePrecisionWire: () => toReleasePrecisionWire,
|
|
57
61
|
unregisterExternalSchemaRoot: () => unregisterExternalSchemaRoot,
|
|
@@ -208,6 +212,13 @@ function compareBundleNamesDesc(a, b) {
|
|
|
208
212
|
return b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" });
|
|
209
213
|
}
|
|
210
214
|
const states = /* @__PURE__ */ new Map();
|
|
215
|
+
const validatorDiagnosticOrigins = /* @__PURE__ */ new WeakMap();
|
|
216
|
+
function resolveValidatorDiagnosticPath(validator, schemaPath) {
|
|
217
|
+
return validatorDiagnosticOrigins.get(validator)?.resolve(schemaPath);
|
|
218
|
+
}
|
|
219
|
+
function getValidatorDiagnosticOrigin(validator, schemaPath) {
|
|
220
|
+
return validatorDiagnosticOrigins.get(validator)?.origin(schemaPath);
|
|
221
|
+
}
|
|
211
222
|
const schemaRefValidators = /* @__PURE__ */ new Map();
|
|
212
223
|
const keywordSchemaRefValidators = /* @__PURE__ */ new WeakMap();
|
|
213
224
|
let keywordCacheGeneration = 0;
|
|
@@ -472,21 +483,30 @@ function ensureInit(version) {
|
|
|
472
483
|
const cacheKey = stateCacheKey(key, root);
|
|
473
484
|
const cached = states.get(cacheKey);
|
|
474
485
|
if (cached) return cached;
|
|
486
|
+
const { createSchemaDiagnosticOrigins } = require('./schema-diagnostic-origins.js');
|
|
487
|
+
const diagnosticOrigins = createSchemaDiagnosticOrigins();
|
|
488
|
+
const bundledDiagnosticOrigins = createSchemaDiagnosticOrigins();
|
|
475
489
|
const ajv = new import_ajv.default({
|
|
490
|
+
inlineRefs: false,
|
|
476
491
|
strict: false,
|
|
477
492
|
allErrors: true,
|
|
478
|
-
allowUnionTypes: true
|
|
493
|
+
allowUnionTypes: true,
|
|
494
|
+
code: { process: diagnosticOrigins.process }
|
|
479
495
|
});
|
|
480
496
|
(0, import_ajv_formats.default)(ajv);
|
|
481
497
|
const bundledAjv = new import_ajv.default({
|
|
498
|
+
inlineRefs: false,
|
|
482
499
|
strict: false,
|
|
483
500
|
allErrors: true,
|
|
484
|
-
allowUnionTypes: true
|
|
501
|
+
allowUnionTypes: true,
|
|
502
|
+
code: { process: bundledDiagnosticOrigins.process }
|
|
485
503
|
});
|
|
486
504
|
(0, import_ajv_formats.default)(bundledAjv);
|
|
487
505
|
const state = {
|
|
488
506
|
ajv,
|
|
489
507
|
bundledAjv,
|
|
508
|
+
diagnosticOrigins,
|
|
509
|
+
bundledDiagnosticOrigins,
|
|
490
510
|
canonicalValidators: /* @__PURE__ */ new Map(),
|
|
491
511
|
fileIndex: buildFileIndex(root),
|
|
492
512
|
validators: /* @__PURE__ */ new Map(),
|
|
@@ -503,7 +523,8 @@ function ensureCoreLoaded(s) {
|
|
|
503
523
|
if (s.coreLoaded) return;
|
|
504
524
|
const selectedToolsById = /* @__PURE__ */ new Map();
|
|
505
525
|
const responseToolFiles = /* @__PURE__ */ new Set();
|
|
506
|
-
for (const [key,
|
|
526
|
+
for (const [key, indexedFile] of s.fileIndex) {
|
|
527
|
+
const file = authoredToolSchemaFile(s, indexedFile);
|
|
507
528
|
const response = !key.endsWith("::request");
|
|
508
529
|
if (response) responseToolFiles.add(file);
|
|
509
530
|
const schema = loadJson(file);
|
|
@@ -538,17 +559,20 @@ function getValidator(toolName, direction, version = import_version.ADCP_VERSION
|
|
|
538
559
|
const cacheKey = `${toolName}::${direction}`;
|
|
539
560
|
const cached = s.validators.get(cacheKey);
|
|
540
561
|
if (cached) return cached;
|
|
541
|
-
const
|
|
542
|
-
if (!
|
|
562
|
+
const indexedFile = s.fileIndex.get(cacheKey);
|
|
563
|
+
if (!indexedFile) return void 0;
|
|
564
|
+
const file = runtimeToolSchemaFile(s, indexedFile, direction);
|
|
543
565
|
const fromBundled = file.includes(`${import_path.default.sep}bundled${import_path.default.sep}`);
|
|
544
566
|
if (!fromBundled) ensureCoreLoaded(s);
|
|
545
567
|
const rawSchema = loadJson(file);
|
|
546
568
|
const prepared = fromBundled ? stripNestedIds(rawSchema) : rawSchema;
|
|
547
|
-
const
|
|
569
|
+
const envelope = direction === "request" ? prepared : relaxResponseRoot(prepared);
|
|
570
|
+
const schema = fromBundled ? compactSchemaForValidation(envelope) : envelope;
|
|
548
571
|
const ajv = fromBundled ? s.bundledAjv : s.ajv;
|
|
549
572
|
const existing = typeof schema.$id === "string" ? ajv.getSchema(schema.$id) : void 0;
|
|
550
573
|
const compiled = existing ?? ajv.compile(schema);
|
|
551
574
|
s.validators.set(cacheKey, compiled);
|
|
575
|
+
validatorDiagnosticOrigins.set(compiled, fromBundled ? s.bundledDiagnosticOrigins : s.diagnosticOrigins);
|
|
552
576
|
return compiled;
|
|
553
577
|
}
|
|
554
578
|
function authoredToolSchemaFile(state, indexedFile) {
|
|
@@ -558,6 +582,23 @@ function authoredToolSchemaFile(state, indexedFile) {
|
|
|
558
582
|
const authoredFile = import_path.default.join(state.root, relative);
|
|
559
583
|
return (0, import_fs.existsSync)(authoredFile) ? authoredFile : indexedFile;
|
|
560
584
|
}
|
|
585
|
+
function runtimeToolSchemaFile(state, indexedFile, direction) {
|
|
586
|
+
const authoredFile = authoredToolSchemaFile(state, indexedFile);
|
|
587
|
+
if (direction === "request" || authoredFile === indexedFile) return authoredFile;
|
|
588
|
+
const hasCompositionReference = (node) => {
|
|
589
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return false;
|
|
590
|
+
const schema = node;
|
|
591
|
+
if (typeof schema.$ref === "string") return true;
|
|
592
|
+
return ["allOf", "oneOf", "anyOf"].some(
|
|
593
|
+
(keyword) => Array.isArray(schema[keyword]) && schema[keyword].some(hasCompositionReference)
|
|
594
|
+
);
|
|
595
|
+
};
|
|
596
|
+
return hasCompositionReference(loadJson(authoredFile)) ? indexedFile : authoredFile;
|
|
597
|
+
}
|
|
598
|
+
function compactSchemaForValidation(schema) {
|
|
599
|
+
const compactor = require('./compact-schema.js');
|
|
600
|
+
return compactor.compactSchemaForValidation(schema);
|
|
601
|
+
}
|
|
561
602
|
function getToolSchemaDocument(toolName, direction, version = import_version.ADCP_VERSION) {
|
|
562
603
|
const state = ensureInit(version);
|
|
563
604
|
const file = state.fileIndex.get(`${toolName}::${direction}`);
|
|
@@ -616,6 +657,33 @@ function getSchemaDocumentByRef(schemaRef, version = import_version.ADCP_VERSION
|
|
|
616
657
|
};
|
|
617
658
|
}
|
|
618
659
|
function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSION, keywords, options = {}) {
|
|
660
|
+
return compileSchemaReference(schemaRef, version, keywords, options);
|
|
661
|
+
}
|
|
662
|
+
function getMediaBuyDeliveryEnvelopeValidator(version) {
|
|
663
|
+
return compileSchemaReference(
|
|
664
|
+
"core/mcp-webhook-payload.json",
|
|
665
|
+
version,
|
|
666
|
+
void 0,
|
|
667
|
+
{},
|
|
668
|
+
{
|
|
669
|
+
key: "media-buy-delivery-envelope",
|
|
670
|
+
project: (schema) => ({
|
|
671
|
+
...schema,
|
|
672
|
+
properties: {
|
|
673
|
+
...schema.properties,
|
|
674
|
+
// The 3.0 task-type enum predates this documented reporting task. All
|
|
675
|
+
// releases use the same concrete discriminator on delivery envelopes.
|
|
676
|
+
task_type: { const: "media_buy_delivery" },
|
|
677
|
+
// The caller validates this independently against the served report
|
|
678
|
+
// schema, so result errors cannot masquerade as envelope errors.
|
|
679
|
+
result: {}
|
|
680
|
+
},
|
|
681
|
+
required: [.../* @__PURE__ */ new Set([...schema.required ?? [], "task_type", "result"])]
|
|
682
|
+
})
|
|
683
|
+
}
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
function compileSchemaReference(schemaRef, version, keywords, options, projection) {
|
|
619
687
|
const bundleKey = resolveBundleKey(version);
|
|
620
688
|
const root = resolveSchemaRoot(version);
|
|
621
689
|
const normalized = normalizeSchemaRef(schemaRef);
|
|
@@ -630,12 +698,13 @@ function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSIO
|
|
|
630
698
|
cache = entry.validators;
|
|
631
699
|
}
|
|
632
700
|
const allErrors = options.allErrors ?? false;
|
|
633
|
-
const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}`;
|
|
701
|
+
const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}\0projection::${projection?.key ?? "raw"}`;
|
|
634
702
|
const cached = cache.get(cacheKey);
|
|
635
703
|
if (cached) return cached;
|
|
636
704
|
const file = import_path.default.join(root, normalized);
|
|
637
705
|
if (!(0, import_fs.existsSync)(file)) return void 0;
|
|
638
706
|
const ajv = new import_ajv.default({
|
|
707
|
+
inlineRefs: false,
|
|
639
708
|
strict: false,
|
|
640
709
|
// Schema-ref validators process remote webhook payloads. By default they
|
|
641
710
|
// fail on the first violation so deeply nested hostile input cannot
|
|
@@ -646,7 +715,8 @@ function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSIO
|
|
|
646
715
|
});
|
|
647
716
|
(0, import_ajv_formats.default)(ajv);
|
|
648
717
|
for (const keyword of keywords ?? []) ajv.addKeyword(keyword);
|
|
649
|
-
const
|
|
718
|
+
const authoredSchema = identity33ReferenceSchema(loadJson(file), version);
|
|
719
|
+
const rawSchema = projection ? projection.project(authoredSchema) : authoredSchema;
|
|
650
720
|
const dependencySchemas = [];
|
|
651
721
|
const registeredIds = /* @__PURE__ */ new Map();
|
|
652
722
|
for (const schemaFile of walkJsonFiles(root)) {
|
|
@@ -656,8 +726,8 @@ function getSchemaValidatorByRef(schemaRef, version = import_version.ADCP_VERSIO
|
|
|
656
726
|
}
|
|
657
727
|
if (schemaFile === file) continue;
|
|
658
728
|
const schema = identity33ReferenceSchema(loadJson(schemaFile), version);
|
|
659
|
-
if (
|
|
660
|
-
const previous = schema.$id ===
|
|
729
|
+
if (typeof schema.$id === "string") {
|
|
730
|
+
const previous = schema.$id === authoredSchema.$id ? authoredSchema : registeredIds.get(schema.$id);
|
|
661
731
|
if (previous && !(0, import_node_util.isDeepStrictEqual)(previous, schema)) {
|
|
662
732
|
throw new import_errors.ConfigurationError("Schema validation requires unambiguous schema identities", "schemaRoot");
|
|
663
733
|
}
|
|
@@ -687,17 +757,13 @@ function getCanonicalToolValidatorForVersion(toolName, direction, version = impo
|
|
|
687
757
|
const ajv = ensureCanonicalAjv(state);
|
|
688
758
|
const existing = typeof rawSchema.$id === "string" ? ajv.getSchema(rawSchema.$id) : void 0;
|
|
689
759
|
const fromBundled = file.includes(`${import_path.default.sep}bundled${import_path.default.sep}`);
|
|
690
|
-
const compiled = existing ?? ajv.compile(fromBundled ? stripNestedIds(rawSchema) : rawSchema);
|
|
760
|
+
const compiled = existing ?? ajv.compile(fromBundled ? compactSchemaForValidation(stripNestedIds(rawSchema)) : rawSchema);
|
|
691
761
|
state.canonicalValidators.set(cacheKey, compiled);
|
|
692
762
|
return compiled;
|
|
693
763
|
}
|
|
694
764
|
function ensureCanonicalAjv(state) {
|
|
695
765
|
if (state.canonicalAjv) return state.canonicalAjv;
|
|
696
|
-
const ajv = new import_ajv.default({
|
|
697
|
-
strict: false,
|
|
698
|
-
allErrors: true,
|
|
699
|
-
allowUnionTypes: true
|
|
700
|
-
});
|
|
766
|
+
const ajv = new import_ajv.default({ inlineRefs: false, strict: false, allErrors: true, allowUnionTypes: true });
|
|
701
767
|
(0, import_ajv_formats.default)(ajv);
|
|
702
768
|
const schemasById = /* @__PURE__ */ new Map();
|
|
703
769
|
for (const schemaFile of walkJsonFiles(state.root)) {
|
|
@@ -1133,6 +1199,7 @@ function cloneJsonValue(value) {
|
|
|
1133
1199
|
getMcpProfileInputSchema,
|
|
1134
1200
|
getMcpToolSchema,
|
|
1135
1201
|
getMcpToolSummary,
|
|
1202
|
+
getMediaBuyDeliveryEnvelopeValidator,
|
|
1136
1203
|
getRegisteredSchemaIds,
|
|
1137
1204
|
getRequestSchemaEntityPaths,
|
|
1138
1205
|
getSchemaDefaultByPath,
|
|
@@ -1141,14 +1208,17 @@ function cloneJsonValue(value) {
|
|
|
1141
1208
|
getSchemaValidatorByRef,
|
|
1142
1209
|
getToolSchemaDocument,
|
|
1143
1210
|
getValidator,
|
|
1211
|
+
getValidatorDiagnosticOrigin,
|
|
1144
1212
|
hasSchemaBundle,
|
|
1145
1213
|
isExternalSchemaRootActive,
|
|
1146
1214
|
isIdentity33SchemaScope,
|
|
1147
1215
|
listValidatorKeys,
|
|
1148
1216
|
registerExternalSchemaRoot,
|
|
1217
|
+
relaxResponseRoot,
|
|
1149
1218
|
resolveBundleKey,
|
|
1150
1219
|
resolveSchemaRoot,
|
|
1151
1220
|
resolveServedValidationVersion,
|
|
1221
|
+
resolveValidatorDiagnosticPath,
|
|
1152
1222
|
schemaAllowsTopLevelField,
|
|
1153
1223
|
toReleasePrecisionWire,
|
|
1154
1224
|
unregisterExternalSchemaRoot,
|