@adcp/sdk 17.0.0-beta.1 → 17.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/adapters/keyed-account-store.js +1 -1
- package/dist/lib/adapters/keyed-account-store.mjs +1 -1
- package/dist/lib/adapters/version/3.0/brand-fields.d.mts +7 -1
- package/dist/lib/adapters/version/3.0/brand-fields.d.ts +7 -1
- package/dist/lib/adapters/version/3.0/brand-fields.js +139 -3
- package/dist/lib/adapters/version/3.0/brand-fields.mjs +136 -2
- package/dist/lib/adapters/version/3.0/index.js +6 -0
- package/dist/lib/adapters/version/3.0/index.mjs +7 -1
- package/dist/lib/adapters/version/index.d.mts +9 -0
- package/dist/lib/adapters/version/index.d.ts +9 -0
- package/dist/lib/adapters/version/index.js +20 -6
- package/dist/lib/adapters/version/index.mjs +15 -2
- package/dist/lib/adapters/version/types.d.mts +5 -0
- package/dist/lib/adapters/version/types.d.ts +5 -0
- package/dist/lib/canonical-references/index.js +2 -0
- package/dist/lib/canonical-references/index.mjs +2 -0
- package/dist/lib/client/account-changes.d.mts +3 -1
- package/dist/lib/client/account-changes.d.ts +3 -1
- package/dist/lib/client/account-changes.js +22 -2
- package/dist/lib/client/account-changes.mjs +22 -2
- package/dist/lib/conformance/oracle.js +3 -2
- package/dist/lib/conformance/oracle.mjs +3 -2
- package/dist/lib/core/AgentClient.d.mts +165 -1
- package/dist/lib/core/AgentClient.d.ts +165 -1
- package/dist/lib/core/AgentClient.js +446 -8
- package/dist/lib/core/AgentClient.mjs +446 -8
- package/dist/lib/core/ConversationTypes.d.mts +8 -0
- package/dist/lib/core/ConversationTypes.d.ts +8 -0
- package/dist/lib/core/ProtocolResponseParser.d.mts +1 -1
- package/dist/lib/core/ProtocolResponseParser.d.ts +1 -1
- package/dist/lib/core/ProtocolResponseParser.js +28 -18
- package/dist/lib/core/ProtocolResponseParser.mjs +11 -1
- package/dist/lib/core/SingleAgentClient.d.mts +115 -2
- package/dist/lib/core/SingleAgentClient.d.ts +115 -2
- package/dist/lib/core/SingleAgentClient.js +547 -67
- package/dist/lib/core/SingleAgentClient.mjs +534 -54
- package/dist/lib/core/TaskExecutor.d.mts +7 -0
- package/dist/lib/core/TaskExecutor.d.ts +7 -0
- package/dist/lib/core/TaskExecutor.js +18 -5
- package/dist/lib/core/TaskExecutor.mjs +18 -5
- package/dist/lib/core/task-status.d.mts +2 -0
- package/dist/lib/core/task-status.d.ts +2 -0
- package/dist/lib/core/task-status.js +11 -2
- package/dist/lib/core/task-status.mjs +9 -1
- package/dist/lib/identity-3.3/trust.d.mts +1 -4
- package/dist/lib/identity-3.3/trust.d.ts +1 -4
- package/dist/lib/identity-3.3/trust.js +43 -23
- package/dist/lib/identity-3.3/trust.mjs +43 -23
- package/dist/lib/identity-3.3/validation.js +5 -3
- package/dist/lib/identity-3.3/validation.mjs +6 -4
- package/dist/lib/index.d.mts +6 -52
- package/dist/lib/index.d.ts +6 -52
- package/dist/lib/index.js +11 -0
- package/dist/lib/index.mjs +7 -0
- package/dist/lib/media-buy/compatibility.js +6 -1
- package/dist/lib/media-buy/compatibility.mjs +6 -1
- package/dist/lib/protocols/mcp-scope.d.mts +3 -0
- package/dist/lib/protocols/mcp-scope.d.ts +3 -0
- package/dist/lib/protocols/mcp-scope.js +8 -3
- package/dist/lib/protocols/mcp-scope.mjs +8 -3
- package/dist/lib/reporting/inspection.js +1 -0
- package/dist/lib/reporting/inspection.mjs +1 -0
- package/dist/lib/reporting/ledger/coverage.d.mts +5 -0
- package/dist/lib/reporting/ledger/coverage.d.ts +5 -0
- package/dist/lib/reporting/ledger/coverage.js +37 -3
- package/dist/lib/reporting/ledger/coverage.mjs +36 -3
- package/dist/lib/reporting/ledger/handler.js +7 -4
- package/dist/lib/reporting/ledger/handler.mjs +7 -4
- package/dist/lib/reporting/ledger/producer.js +215 -69
- package/dist/lib/reporting/ledger/producer.mjs +217 -70
- package/dist/lib/reporting/ledger/schedule.d.mts +2 -2
- package/dist/lib/reporting/ledger/schedule.d.ts +2 -2
- package/dist/lib/reporting/ledger/schedule.js +8 -5
- package/dist/lib/reporting/ledger/schedule.mjs +8 -5
- package/dist/lib/reporting/ledger/status-ingest.d.mts +1 -1
- package/dist/lib/reporting/ledger/status-ingest.d.ts +1 -1
- package/dist/lib/reporting/ledger/status-ingest.js +4 -3
- package/dist/lib/reporting/ledger/status-ingest.mjs +4 -3
- package/dist/lib/reporting/ledger/types.d.mts +36 -1
- package/dist/lib/reporting/ledger/types.d.ts +36 -1
- package/dist/lib/reporting/service/index.d.mts +14 -1
- package/dist/lib/reporting/service/index.d.ts +14 -1
- package/dist/lib/reporting/service/index.js +24 -12
- package/dist/lib/reporting/service/index.mjs +24 -12
- package/dist/lib/schemas/browser.d.mts +2 -0
- package/dist/lib/schemas/browser.d.ts +2 -0
- package/dist/lib/schemas/browser.js +3 -0
- package/dist/lib/schemas/browser.mjs +2 -0
- package/dist/lib/schemas/index.d.mts +5 -3
- package/dist/lib/schemas/index.d.ts +5 -3
- package/dist/lib/schemas/index.js +5 -0
- package/dist/lib/schemas/index.mjs +4 -0
- package/dist/lib/server/a2a-adapter.js +2 -1
- package/dist/lib/server/a2a-adapter.mjs +2 -1
- package/dist/lib/server/account-response-identity.d.mts +17 -0
- package/dist/lib/server/account-response-identity.d.ts +17 -0
- package/dist/lib/server/account-response-identity.js +52 -0
- package/dist/lib/server/account-response-identity.mjs +28 -0
- package/dist/lib/server/account-sync-contract.js +2 -2
- package/dist/lib/server/account-sync-contract.mjs +2 -2
- package/dist/lib/server/auth-signature.d.mts +2 -2
- package/dist/lib/server/auth-signature.d.ts +2 -2
- package/dist/lib/server/auth-signature.js +3 -0
- package/dist/lib/server/auth-signature.mjs +3 -0
- package/dist/lib/server/create-adcp-server.d.mts +2 -2
- package/dist/lib/server/create-adcp-server.d.ts +2 -2
- package/dist/lib/server/create-adcp-server.js +58 -23
- package/dist/lib/server/create-adcp-server.mjs +61 -15
- package/dist/lib/server/decisioning/account.d.mts +36 -10
- package/dist/lib/server/decisioning/account.d.ts +36 -10
- package/dist/lib/server/decisioning/account.js +33 -14
- package/dist/lib/server/decisioning/account.mjs +33 -14
- package/dist/lib/server/decisioning/runtime/from-platform.d.mts +5 -5
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +5 -5
- package/dist/lib/server/decisioning/runtime/from-platform.js +4 -4
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +4 -4
- package/dist/lib/server/media-buy-store.d.mts +26 -12
- package/dist/lib/server/media-buy-store.d.ts +26 -12
- package/dist/lib/server/media-buy-store.js +69 -21
- package/dist/lib/server/media-buy-store.mjs +69 -21
- package/dist/lib/server/notification-subscriptions/runtime.d.mts +1 -1
- package/dist/lib/server/notification-subscriptions/runtime.d.ts +1 -1
- package/dist/lib/server/notification-subscriptions/runtime.js +4 -0
- package/dist/lib/server/notification-subscriptions/runtime.mjs +4 -0
- package/dist/lib/server/responses.js +9 -1
- package/dist/lib/server/responses.mjs +9 -1
- package/dist/lib/server/serve.js +3 -1
- package/dist/lib/server/serve.mjs +3 -1
- package/dist/lib/server/signed-request-transport.d.mts +1 -0
- package/dist/lib/server/signed-request-transport.d.ts +1 -0
- package/dist/lib/server/signed-request-transport.js +46 -0
- package/dist/lib/server/signed-request-transport.mjs +20 -0
- package/dist/lib/server/test-controller.d.mts +1 -0
- package/dist/lib/server/test-controller.d.ts +1 -0
- package/dist/lib/server/test-controller.js +5 -1
- package/dist/lib/server/test-controller.mjs +5 -1
- package/dist/lib/signing/agent-fetch.d.mts +1 -1
- package/dist/lib/signing/agent-fetch.d.ts +1 -1
- package/dist/lib/signing/agent-fetch.js +3 -3
- package/dist/lib/signing/agent-fetch.mjs +3 -3
- package/dist/lib/testing/index.d.mts +1 -0
- package/dist/lib/testing/index.d.ts +1 -0
- package/dist/lib/testing/index.js +3 -0
- package/dist/lib/testing/index.mjs +2 -0
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.js +61 -29
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +61 -29
- package/dist/lib/testing/storyboard/compliance.d.mts +2 -5
- package/dist/lib/testing/storyboard/compliance.d.ts +2 -5
- package/dist/lib/testing/storyboard/compliance.js +62 -13
- package/dist/lib/testing/storyboard/compliance.mjs +63 -14
- package/dist/lib/testing/storyboard/index.d.mts +1 -0
- package/dist/lib/testing/storyboard/index.d.ts +1 -0
- package/dist/lib/testing/storyboard/index.js +3 -0
- package/dist/lib/testing/storyboard/index.mjs +2 -0
- package/dist/lib/testing/storyboard/loader.js +7 -0
- package/dist/lib/testing/storyboard/loader.mjs +7 -0
- package/dist/lib/testing/storyboard/request-builder.js +9 -6
- package/dist/lib/testing/storyboard/request-builder.mjs +9 -6
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +11 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +10 -0
- package/dist/lib/testing/storyboard/runner.js +59 -6
- package/dist/lib/testing/storyboard/runner.mjs +59 -6
- package/dist/lib/testing/storyboard/types.d.mts +18 -0
- package/dist/lib/testing/storyboard/types.d.ts +18 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/web-bot-auth.d.mts +10 -0
- package/dist/lib/testing/storyboard/web-bot-auth.d.ts +10 -0
- package/dist/lib/testing/storyboard/web-bot-auth.js +80 -0
- package/dist/lib/testing/storyboard/web-bot-auth.mjs +56 -0
- package/dist/lib/types/accept-proposal.d.ts +20 -28
- package/dist/lib/types/asset-instances.d.mts +1 -1
- package/dist/lib/types/asset-instances.d.ts +1 -1
- package/dist/lib/types/buy-products.d.ts +20 -28
- package/dist/lib/types/check-governance.d.ts +20 -28
- package/dist/lib/types/comply-test-controller.d.ts +20 -28
- package/dist/lib/types/control-media-buy.d.ts +20 -28
- package/dist/lib/types/core.generated.d.mts +273 -184
- package/dist/lib/types/core.generated.d.ts +273 -184
- package/dist/lib/types/create-media-buy.d.ts +20 -28
- package/dist/lib/types/get-media-buys.d.ts +20 -28
- package/dist/lib/types/get-products.d.ts +20 -28
- package/dist/lib/types/index.d.mts +6 -1
- package/dist/lib/types/index.d.ts +6 -1
- package/dist/lib/types/index.js +6 -1
- package/dist/lib/types/index.mjs +4 -1
- package/dist/lib/types/inline-enums.generated.d.mts +30 -4
- package/dist/lib/types/inline-enums.generated.d.ts +30 -4
- package/dist/lib/types/inline-enums.generated.js +41 -2
- package/dist/lib/types/inline-enums.generated.mjs +28 -2
- package/dist/lib/types/list-products.d.ts +20 -28
- package/dist/lib/types/list-proposals.d.ts +20 -28
- package/dist/lib/types/media-buy-delivery-report.d.mts +6 -0
- package/dist/lib/types/media-buy-delivery-report.d.ts +6 -0
- package/dist/lib/types/media-buy-delivery-report.js +16 -0
- package/dist/lib/types/media-buy-delivery-report.mjs +0 -0
- package/dist/lib/types/refine-proposals.d.ts +20 -28
- package/dist/lib/types/request-proposals.d.ts +20 -28
- package/dist/lib/types/schemas.generated.d.ts +63113 -127273
- package/dist/lib/types/schemas.generated.js +759 -770
- package/dist/lib/types/schemas.generated.mjs +759 -770
- package/dist/lib/types/targeting-keys.generated.d.mts +4 -0
- package/dist/lib/types/targeting-keys.generated.d.ts +4 -0
- package/dist/lib/types/targeting-keys.generated.js +109 -0
- package/dist/lib/types/targeting-keys.generated.mjs +84 -0
- package/dist/lib/types/tools.generated.d.mts +2 -68
- package/dist/lib/types/tools.generated.d.ts +2 -68
- package/dist/lib/types/update-media-buy.d.ts +20 -28
- package/dist/lib/utils/adcp-version-config.js +5 -2
- package/dist/lib/utils/adcp-version-config.mjs +5 -2
- package/dist/lib/utils/response-unwrapper.js +6 -1
- package/dist/lib/utils/response-unwrapper.mjs +6 -1
- package/dist/lib/v2/format-schema/resolver.js +1 -1
- package/dist/lib/v2/format-schema/resolver.mjs +1 -1
- package/dist/lib/v2/projection/creative-delivery.js +104 -29
- package/dist/lib/v2/projection/creative-delivery.mjs +108 -29
- package/dist/lib/v2/projection/index.d.mts +1 -0
- package/dist/lib/v2/projection/index.d.ts +1 -0
- package/dist/lib/v2/projection/index.js +3 -0
- package/dist/lib/v2/projection/index.mjs +2 -0
- package/dist/lib/v2/projection/legacy-metadata.d.mts +19 -0
- package/dist/lib/v2/projection/legacy-metadata.d.ts +19 -0
- package/dist/lib/v2/projection/legacy-metadata.js +91 -0
- package/dist/lib/v2/projection/legacy-metadata.mjs +86 -0
- package/dist/lib/v2/projection/v1-to-v2.d.mts +1 -1
- package/dist/lib/v2/projection/v1-to-v2.d.ts +1 -1
- package/dist/lib/v2/projection/v1-to-v2.js +12 -9
- package/dist/lib/v2/projection/v1-to-v2.mjs +12 -9
- package/dist/lib/validation/budget-allocation.d.mts +3 -3
- package/dist/lib/validation/budget-allocation.d.ts +3 -3
- package/dist/lib/validation/compact-schema.d.mts +27 -0
- package/dist/lib/validation/compact-schema.d.ts +27 -0
- package/dist/lib/validation/compact-schema.js +276 -0
- package/dist/lib/validation/compact-schema.mjs +250 -0
- package/dist/lib/validation/media-buy-delivery-report.d.mts +8 -0
- package/dist/lib/validation/media-buy-delivery-report.d.ts +8 -0
- package/dist/lib/validation/media-buy-delivery-report.js +31 -0
- package/dist/lib/validation/media-buy-delivery-report.mjs +7 -0
- package/dist/lib/validation/nonempty-array.d.mts +15 -0
- package/dist/lib/validation/nonempty-array.d.ts +15 -0
- package/dist/lib/validation/nonempty-array.js +41 -0
- package/dist/lib/validation/nonempty-array.mjs +7 -0
- package/dist/lib/validation/schema-diagnostic-origins.d.mts +21 -0
- package/dist/lib/validation/schema-diagnostic-origins.d.ts +21 -0
- package/dist/lib/validation/schema-diagnostic-origins.js +193 -0
- package/dist/lib/validation/schema-diagnostic-origins.mjs +169 -0
- package/dist/lib/validation/schema-loader.js +86 -16
- package/dist/lib/validation/schema-loader.mjs +82 -16
- package/dist/lib/validation/schema-validator.d.mts +10 -19
- package/dist/lib/validation/schema-validator.d.ts +10 -19
- package/dist/lib/validation/schema-validator.js +135 -42
- package/dist/lib/validation/schema-validator.mjs +139 -43
- package/dist/lib/validation/sync-creatives.d.mts +22 -22
- package/dist/lib/validation/sync-creatives.d.ts +22 -22
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/webhooks/index.d.mts +3 -0
- package/dist/lib/webhooks/index.d.ts +3 -0
- package/dist/lib/webhooks/index.js +3 -0
- package/dist/lib/webhooks/index.mjs +2 -0
- package/dist/lib/webhooks/media-buy-delivery.d.mts +43 -0
- package/dist/lib/webhooks/media-buy-delivery.d.ts +43 -0
- package/dist/lib/webhooks/media-buy-delivery.js +119 -0
- package/dist/lib/webhooks/media-buy-delivery.mjs +94 -0
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/guides/DELIVERY-WEBHOOK-PARSING.md +142 -0
- package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +15 -0
- package/docs/guides/REPORTING-LEDGER.md +93 -0
- package/docs/guides/REPORTING-STABILITY.md +1 -1
- package/docs/guides/TYPED-CLIENT-TOOLS.md +49 -0
- package/docs/llms.txt +2 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-16-to-17.md +218 -14
- package/docs/migration-6.6-to-6.7.md +14 -0
- package/docs/migration-account-change-feed.md +15 -0
- package/docs/migration-agent-identity-3.3.md +106 -4
- package/docs/recipes/verifying-inbound-webhooks.md +18 -2
- package/package.json +16 -3
|
@@ -154,6 +154,13 @@ function compareBundleNamesDesc(a, b) {
|
|
|
154
154
|
return b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" });
|
|
155
155
|
}
|
|
156
156
|
const states = /* @__PURE__ */ new Map();
|
|
157
|
+
const validatorDiagnosticOrigins = /* @__PURE__ */ new WeakMap();
|
|
158
|
+
function resolveValidatorDiagnosticPath(validator, schemaPath) {
|
|
159
|
+
return validatorDiagnosticOrigins.get(validator)?.resolve(schemaPath);
|
|
160
|
+
}
|
|
161
|
+
function getValidatorDiagnosticOrigin(validator, schemaPath) {
|
|
162
|
+
return validatorDiagnosticOrigins.get(validator)?.origin(schemaPath);
|
|
163
|
+
}
|
|
157
164
|
const schemaRefValidators = /* @__PURE__ */ new Map();
|
|
158
165
|
const keywordSchemaRefValidators = /* @__PURE__ */ new WeakMap();
|
|
159
166
|
let keywordCacheGeneration = 0;
|
|
@@ -418,21 +425,30 @@ function ensureInit(version) {
|
|
|
418
425
|
const cacheKey = stateCacheKey(key, root);
|
|
419
426
|
const cached = states.get(cacheKey);
|
|
420
427
|
if (cached) return cached;
|
|
428
|
+
const { createSchemaDiagnosticOrigins } = require2("./schema-diagnostic-origins");
|
|
429
|
+
const diagnosticOrigins = createSchemaDiagnosticOrigins();
|
|
430
|
+
const bundledDiagnosticOrigins = createSchemaDiagnosticOrigins();
|
|
421
431
|
const ajv = new Ajv({
|
|
432
|
+
inlineRefs: false,
|
|
422
433
|
strict: false,
|
|
423
434
|
allErrors: true,
|
|
424
|
-
allowUnionTypes: true
|
|
435
|
+
allowUnionTypes: true,
|
|
436
|
+
code: { process: diagnosticOrigins.process }
|
|
425
437
|
});
|
|
426
438
|
addFormats(ajv);
|
|
427
439
|
const bundledAjv = new Ajv({
|
|
440
|
+
inlineRefs: false,
|
|
428
441
|
strict: false,
|
|
429
442
|
allErrors: true,
|
|
430
|
-
allowUnionTypes: true
|
|
443
|
+
allowUnionTypes: true,
|
|
444
|
+
code: { process: bundledDiagnosticOrigins.process }
|
|
431
445
|
});
|
|
432
446
|
addFormats(bundledAjv);
|
|
433
447
|
const state = {
|
|
434
448
|
ajv,
|
|
435
449
|
bundledAjv,
|
|
450
|
+
diagnosticOrigins,
|
|
451
|
+
bundledDiagnosticOrigins,
|
|
436
452
|
canonicalValidators: /* @__PURE__ */ new Map(),
|
|
437
453
|
fileIndex: buildFileIndex(root),
|
|
438
454
|
validators: /* @__PURE__ */ new Map(),
|
|
@@ -449,7 +465,8 @@ function ensureCoreLoaded(s) {
|
|
|
449
465
|
if (s.coreLoaded) return;
|
|
450
466
|
const selectedToolsById = /* @__PURE__ */ new Map();
|
|
451
467
|
const responseToolFiles = /* @__PURE__ */ new Set();
|
|
452
|
-
for (const [key,
|
|
468
|
+
for (const [key, indexedFile] of s.fileIndex) {
|
|
469
|
+
const file = authoredToolSchemaFile(s, indexedFile);
|
|
453
470
|
const response = !key.endsWith("::request");
|
|
454
471
|
if (response) responseToolFiles.add(file);
|
|
455
472
|
const schema = loadJson(file);
|
|
@@ -484,17 +501,20 @@ function getValidator(toolName, direction, version = ADCP_VERSION) {
|
|
|
484
501
|
const cacheKey = `${toolName}::${direction}`;
|
|
485
502
|
const cached = s.validators.get(cacheKey);
|
|
486
503
|
if (cached) return cached;
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
504
|
+
const indexedFile = s.fileIndex.get(cacheKey);
|
|
505
|
+
if (!indexedFile) return void 0;
|
|
506
|
+
const file = runtimeToolSchemaFile(s, indexedFile, direction);
|
|
489
507
|
const fromBundled = file.includes(`${path.sep}bundled${path.sep}`);
|
|
490
508
|
if (!fromBundled) ensureCoreLoaded(s);
|
|
491
509
|
const rawSchema = loadJson(file);
|
|
492
510
|
const prepared = fromBundled ? stripNestedIds(rawSchema) : rawSchema;
|
|
493
|
-
const
|
|
511
|
+
const envelope = direction === "request" ? prepared : relaxResponseRoot(prepared);
|
|
512
|
+
const schema = fromBundled ? compactSchemaForValidation(envelope) : envelope;
|
|
494
513
|
const ajv = fromBundled ? s.bundledAjv : s.ajv;
|
|
495
514
|
const existing = typeof schema.$id === "string" ? ajv.getSchema(schema.$id) : void 0;
|
|
496
515
|
const compiled = existing ?? ajv.compile(schema);
|
|
497
516
|
s.validators.set(cacheKey, compiled);
|
|
517
|
+
validatorDiagnosticOrigins.set(compiled, fromBundled ? s.bundledDiagnosticOrigins : s.diagnosticOrigins);
|
|
498
518
|
return compiled;
|
|
499
519
|
}
|
|
500
520
|
function authoredToolSchemaFile(state, indexedFile) {
|
|
@@ -504,6 +524,23 @@ function authoredToolSchemaFile(state, indexedFile) {
|
|
|
504
524
|
const authoredFile = path.join(state.root, relative);
|
|
505
525
|
return existsSync(authoredFile) ? authoredFile : indexedFile;
|
|
506
526
|
}
|
|
527
|
+
function runtimeToolSchemaFile(state, indexedFile, direction) {
|
|
528
|
+
const authoredFile = authoredToolSchemaFile(state, indexedFile);
|
|
529
|
+
if (direction === "request" || authoredFile === indexedFile) return authoredFile;
|
|
530
|
+
const hasCompositionReference = (node) => {
|
|
531
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return false;
|
|
532
|
+
const schema = node;
|
|
533
|
+
if (typeof schema.$ref === "string") return true;
|
|
534
|
+
return ["allOf", "oneOf", "anyOf"].some(
|
|
535
|
+
(keyword) => Array.isArray(schema[keyword]) && schema[keyword].some(hasCompositionReference)
|
|
536
|
+
);
|
|
537
|
+
};
|
|
538
|
+
return hasCompositionReference(loadJson(authoredFile)) ? indexedFile : authoredFile;
|
|
539
|
+
}
|
|
540
|
+
function compactSchemaForValidation(schema) {
|
|
541
|
+
const compactor = require2("./compact-schema");
|
|
542
|
+
return compactor.compactSchemaForValidation(schema);
|
|
543
|
+
}
|
|
507
544
|
function getToolSchemaDocument(toolName, direction, version = ADCP_VERSION) {
|
|
508
545
|
const state = ensureInit(version);
|
|
509
546
|
const file = state.fileIndex.get(`${toolName}::${direction}`);
|
|
@@ -562,6 +599,33 @@ function getSchemaDocumentByRef(schemaRef, version = ADCP_VERSION) {
|
|
|
562
599
|
};
|
|
563
600
|
}
|
|
564
601
|
function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, options = {}) {
|
|
602
|
+
return compileSchemaReference(schemaRef, version, keywords, options);
|
|
603
|
+
}
|
|
604
|
+
function getMediaBuyDeliveryEnvelopeValidator(version) {
|
|
605
|
+
return compileSchemaReference(
|
|
606
|
+
"core/mcp-webhook-payload.json",
|
|
607
|
+
version,
|
|
608
|
+
void 0,
|
|
609
|
+
{},
|
|
610
|
+
{
|
|
611
|
+
key: "media-buy-delivery-envelope",
|
|
612
|
+
project: (schema) => ({
|
|
613
|
+
...schema,
|
|
614
|
+
properties: {
|
|
615
|
+
...schema.properties,
|
|
616
|
+
// The 3.0 task-type enum predates this documented reporting task. All
|
|
617
|
+
// releases use the same concrete discriminator on delivery envelopes.
|
|
618
|
+
task_type: { const: "media_buy_delivery" },
|
|
619
|
+
// The caller validates this independently against the served report
|
|
620
|
+
// schema, so result errors cannot masquerade as envelope errors.
|
|
621
|
+
result: {}
|
|
622
|
+
},
|
|
623
|
+
required: [.../* @__PURE__ */ new Set([...schema.required ?? [], "task_type", "result"])]
|
|
624
|
+
})
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
function compileSchemaReference(schemaRef, version, keywords, options, projection) {
|
|
565
629
|
const bundleKey = resolveBundleKey(version);
|
|
566
630
|
const root = resolveSchemaRoot(version);
|
|
567
631
|
const normalized = normalizeSchemaRef(schemaRef);
|
|
@@ -576,12 +640,13 @@ function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, op
|
|
|
576
640
|
cache = entry.validators;
|
|
577
641
|
}
|
|
578
642
|
const allErrors = options.allErrors ?? false;
|
|
579
|
-
const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}`;
|
|
643
|
+
const cacheKey = `${stateCacheKey(bundleKey, root)}\0schema-ref::${normalized}\0all-errors::${allErrors}\0projection::${projection?.key ?? "raw"}`;
|
|
580
644
|
const cached = cache.get(cacheKey);
|
|
581
645
|
if (cached) return cached;
|
|
582
646
|
const file = path.join(root, normalized);
|
|
583
647
|
if (!existsSync(file)) return void 0;
|
|
584
648
|
const ajv = new Ajv({
|
|
649
|
+
inlineRefs: false,
|
|
585
650
|
strict: false,
|
|
586
651
|
// Schema-ref validators process remote webhook payloads. By default they
|
|
587
652
|
// fail on the first violation so deeply nested hostile input cannot
|
|
@@ -592,7 +657,8 @@ function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, op
|
|
|
592
657
|
});
|
|
593
658
|
addFormats(ajv);
|
|
594
659
|
for (const keyword of keywords ?? []) ajv.addKeyword(keyword);
|
|
595
|
-
const
|
|
660
|
+
const authoredSchema = identity33ReferenceSchema(loadJson(file), version);
|
|
661
|
+
const rawSchema = projection ? projection.project(authoredSchema) : authoredSchema;
|
|
596
662
|
const dependencySchemas = [];
|
|
597
663
|
const registeredIds = /* @__PURE__ */ new Map();
|
|
598
664
|
for (const schemaFile of walkJsonFiles(root)) {
|
|
@@ -602,8 +668,8 @@ function getSchemaValidatorByRef(schemaRef, version = ADCP_VERSION, keywords, op
|
|
|
602
668
|
}
|
|
603
669
|
if (schemaFile === file) continue;
|
|
604
670
|
const schema = identity33ReferenceSchema(loadJson(schemaFile), version);
|
|
605
|
-
if (
|
|
606
|
-
const previous = schema.$id ===
|
|
671
|
+
if (typeof schema.$id === "string") {
|
|
672
|
+
const previous = schema.$id === authoredSchema.$id ? authoredSchema : registeredIds.get(schema.$id);
|
|
607
673
|
if (previous && !isDeepStrictEqual(previous, schema)) {
|
|
608
674
|
throw new ConfigurationError("Schema validation requires unambiguous schema identities", "schemaRoot");
|
|
609
675
|
}
|
|
@@ -633,17 +699,13 @@ function getCanonicalToolValidatorForVersion(toolName, direction, version = ADCP
|
|
|
633
699
|
const ajv = ensureCanonicalAjv(state);
|
|
634
700
|
const existing = typeof rawSchema.$id === "string" ? ajv.getSchema(rawSchema.$id) : void 0;
|
|
635
701
|
const fromBundled = file.includes(`${path.sep}bundled${path.sep}`);
|
|
636
|
-
const compiled = existing ?? ajv.compile(fromBundled ? stripNestedIds(rawSchema) : rawSchema);
|
|
702
|
+
const compiled = existing ?? ajv.compile(fromBundled ? compactSchemaForValidation(stripNestedIds(rawSchema)) : rawSchema);
|
|
637
703
|
state.canonicalValidators.set(cacheKey, compiled);
|
|
638
704
|
return compiled;
|
|
639
705
|
}
|
|
640
706
|
function ensureCanonicalAjv(state) {
|
|
641
707
|
if (state.canonicalAjv) return state.canonicalAjv;
|
|
642
|
-
const ajv = new Ajv({
|
|
643
|
-
strict: false,
|
|
644
|
-
allErrors: true,
|
|
645
|
-
allowUnionTypes: true
|
|
646
|
-
});
|
|
708
|
+
const ajv = new Ajv({ inlineRefs: false, strict: false, allErrors: true, allowUnionTypes: true });
|
|
647
709
|
addFormats(ajv);
|
|
648
710
|
const schemasById = /* @__PURE__ */ new Map();
|
|
649
711
|
for (const schemaFile of walkJsonFiles(state.root)) {
|
|
@@ -1078,6 +1140,7 @@ export {
|
|
|
1078
1140
|
getMcpProfileInputSchema,
|
|
1079
1141
|
getMcpToolSchema,
|
|
1080
1142
|
getMcpToolSummary,
|
|
1143
|
+
getMediaBuyDeliveryEnvelopeValidator,
|
|
1081
1144
|
getRegisteredSchemaIds,
|
|
1082
1145
|
getRequestSchemaEntityPaths,
|
|
1083
1146
|
getSchemaDefaultByPath,
|
|
@@ -1086,14 +1149,17 @@ export {
|
|
|
1086
1149
|
getSchemaValidatorByRef,
|
|
1087
1150
|
getToolSchemaDocument,
|
|
1088
1151
|
getValidator,
|
|
1152
|
+
getValidatorDiagnosticOrigin,
|
|
1089
1153
|
hasSchemaBundle,
|
|
1090
1154
|
isExternalSchemaRootActive,
|
|
1091
1155
|
isIdentity33SchemaScope,
|
|
1092
1156
|
listValidatorKeys,
|
|
1093
1157
|
registerExternalSchemaRoot,
|
|
1158
|
+
relaxResponseRoot,
|
|
1094
1159
|
resolveBundleKey,
|
|
1095
1160
|
resolveSchemaRoot,
|
|
1096
1161
|
resolveServedValidationVersion,
|
|
1162
|
+
resolveValidatorDiagnosticPath,
|
|
1097
1163
|
schemaAllowsTopLevelField,
|
|
1098
1164
|
toReleasePrecisionWire,
|
|
1099
1165
|
unregisterExternalSchemaRoot,
|
|
@@ -36,27 +36,18 @@ export interface ValidationIssue {
|
|
|
36
36
|
message: string;
|
|
37
37
|
/** AJV keyword that rejected the payload (e.g., `required`, `type`). */
|
|
38
38
|
keyword: string;
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* AJV's original function-relative path in the compiled runtime schema.
|
|
41
|
+
* Factoring can change paths; they are diagnostic details rather than stable
|
|
42
|
+
* selectors into the public bundled document. Synthetic origin IDs stay internal.
|
|
43
|
+
*/
|
|
40
44
|
schemaPath: string;
|
|
41
45
|
/**
|
|
42
|
-
* `$id` of the rejecting
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* those tools, `schemaId` resolves to the response root (e.g.
|
|
48
|
-
* `/schemas/3.0.4/bundled/signals/activate-signal-response.json`), not
|
|
49
|
-
* the deeper sub-schema. Tools served from the flat tree (`governance/`,
|
|
50
|
-
* `brand/`, etc.) preserve sub-schema `$id`s, so `schemaId` can land on
|
|
51
|
-
* something deeper like `/schemas/3.0.4/core/activation-key.json`. Either
|
|
52
|
-
* way, the field names exactly the schema the validator looked at.
|
|
53
|
-
*
|
|
54
|
-
* Always projected — the `$id` is the published spec URI, not internal
|
|
55
|
-
* handler shape. (Same precedent as {@link ValidationIssue.variants} and
|
|
56
|
-
* {@link ValidationIssue.allowedValues}, both of which already ship
|
|
57
|
-
* always-on with the same rationale.)
|
|
58
|
-
*
|
|
59
|
-
* Absent only when the rejecting schema didn't declare an `$id`.
|
|
46
|
+
* Effective `$id` of the rejecting resource, including embedded resources.
|
|
47
|
+
* Bundled documents may strip nested IDs, in which case the tool root is
|
|
48
|
+
* the available identity. Unsupported origin metadata conservatively falls
|
|
49
|
+
* back to the compiled root ID; anonymous resources can omit this field.
|
|
50
|
+
* Always projected because published schema IDs are protocol metadata.
|
|
60
51
|
*/
|
|
61
52
|
schemaId?: string;
|
|
62
53
|
/**
|
|
@@ -36,27 +36,18 @@ export interface ValidationIssue {
|
|
|
36
36
|
message: string;
|
|
37
37
|
/** AJV keyword that rejected the payload (e.g., `required`, `type`). */
|
|
38
38
|
keyword: string;
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* AJV's original function-relative path in the compiled runtime schema.
|
|
41
|
+
* Factoring can change paths; they are diagnostic details rather than stable
|
|
42
|
+
* selectors into the public bundled document. Synthetic origin IDs stay internal.
|
|
43
|
+
*/
|
|
40
44
|
schemaPath: string;
|
|
41
45
|
/**
|
|
42
|
-
* `$id` of the rejecting
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* those tools, `schemaId` resolves to the response root (e.g.
|
|
48
|
-
* `/schemas/3.0.4/bundled/signals/activate-signal-response.json`), not
|
|
49
|
-
* the deeper sub-schema. Tools served from the flat tree (`governance/`,
|
|
50
|
-
* `brand/`, etc.) preserve sub-schema `$id`s, so `schemaId` can land on
|
|
51
|
-
* something deeper like `/schemas/3.0.4/core/activation-key.json`. Either
|
|
52
|
-
* way, the field names exactly the schema the validator looked at.
|
|
53
|
-
*
|
|
54
|
-
* Always projected — the `$id` is the published spec URI, not internal
|
|
55
|
-
* handler shape. (Same precedent as {@link ValidationIssue.variants} and
|
|
56
|
-
* {@link ValidationIssue.allowedValues}, both of which already ship
|
|
57
|
-
* always-on with the same rationale.)
|
|
58
|
-
*
|
|
59
|
-
* Absent only when the rejecting schema didn't declare an `$id`.
|
|
46
|
+
* Effective `$id` of the rejecting resource, including embedded resources.
|
|
47
|
+
* Bundled documents may strip nested IDs, in which case the tool root is
|
|
48
|
+
* the available identity. Unsupported origin metadata conservatively falls
|
|
49
|
+
* back to the compiled root ID; anonymous resources can omit this field.
|
|
50
|
+
* Always projected because published schema IDs are protocol metadata.
|
|
60
51
|
*/
|
|
61
52
|
schemaId?: string;
|
|
62
53
|
/**
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var schema_validator_exports = {};
|
|
20
20
|
__export(schema_validator_exports, {
|
|
21
|
+
compactUnionErrors: () => compactUnionErrors,
|
|
21
22
|
formatDiscriminator: () => formatDiscriminator,
|
|
22
23
|
formatIssueLine: () => formatIssueLine,
|
|
23
24
|
formatIssues: () => formatIssues,
|
|
@@ -46,17 +47,18 @@ function extractSchemaId(schemaPath, rootSchema, registeredIds) {
|
|
|
46
47
|
}
|
|
47
48
|
function formatIssue(err, ctx) {
|
|
48
49
|
const instancePath = err.instancePath || "";
|
|
49
|
-
const missingProperty = err.keyword === "required" && err.params && typeof err.params.missingProperty === "string" ? `/${err.params.missingProperty}` : "";
|
|
50
|
+
const missingProperty = err.keyword === "required" && err.params && typeof err.params.missingProperty === "string" ? `/${err.params.missingProperty.replace(/~/g, "~0").replace(/\//g, "~1")}` : "";
|
|
50
51
|
const isEnum = err.keyword === "enum" && err.params != null && Array.isArray(err.params.allowedValues);
|
|
51
52
|
const allowedValues = isEnum ? err.params.allowedValues : void 0;
|
|
52
53
|
const message = isEnum ? `must be one of: ${allowedValues.map((v) => JSON.stringify(v)).join(", ")}` : err.message ?? "validation failed";
|
|
53
|
-
const
|
|
54
|
+
const origin = ctx.diagnosticOrigin?.(err.__adcp_originSchemaPath ?? err.schemaPath);
|
|
55
|
+
const schemaId = origin ? origin.schemaId : extractSchemaId(err.schemaPath, ctx.rootSchema, ctx.registeredIds) ?? ctx.rootSchemaId;
|
|
54
56
|
const discriminator = err.__adcp_discriminator;
|
|
55
57
|
const issue = {
|
|
56
58
|
pointer: `${instancePath}${missingProperty}` || "/",
|
|
57
59
|
message,
|
|
58
60
|
keyword: err.keyword,
|
|
59
|
-
schemaPath: err.schemaPath,
|
|
61
|
+
schemaPath: err.schemaPath === "" ? "" : origin?.schemaPath ?? err.schemaPath,
|
|
60
62
|
...schemaId !== void 0 && { schemaId },
|
|
61
63
|
...discriminator !== void 0 && discriminator.length > 0 && { discriminator },
|
|
62
64
|
...allowedValues !== void 0 && { allowedValues }
|
|
@@ -65,24 +67,19 @@ function formatIssue(err, ctx) {
|
|
|
65
67
|
if (hint !== void 0) issue.hint = hint;
|
|
66
68
|
return issue;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (FORBIDDEN_SCHEMA_PATH_SEGMENTS.has(decoded)) return void 0;
|
|
78
|
-
if (!Object.prototype.hasOwnProperty.call(cursor, decoded)) return void 0;
|
|
79
|
-
cursor = cursor[decoded];
|
|
80
|
-
}
|
|
81
|
-
return cursor;
|
|
70
|
+
function createDiagnosticOriginResolver(validator) {
|
|
71
|
+
const memo = /* @__PURE__ */ new Map();
|
|
72
|
+
return (schemaPath) => {
|
|
73
|
+
if (memo.has(schemaPath)) return memo.get(schemaPath);
|
|
74
|
+
if (memo.size >= 1024) return void 0;
|
|
75
|
+
const resolved = (0, import_schema_loader.getValidatorDiagnosticOrigin)(validator, schemaPath);
|
|
76
|
+
memo.set(schemaPath, resolved);
|
|
77
|
+
return resolved;
|
|
78
|
+
};
|
|
82
79
|
}
|
|
83
|
-
function* expandNotErrors(errors,
|
|
80
|
+
function* expandNotErrors(errors, resolveDiagnosticPath, payload) {
|
|
84
81
|
for (const error of errors) {
|
|
85
|
-
const rule = error.keyword === "not" ?
|
|
82
|
+
const rule = error.keyword === "not" ? resolveDiagnosticPath(error.instancePath, error.schemaPath) : void 0;
|
|
86
83
|
const branches = rule && typeof rule === "object" ? rule.anyOf : void 0;
|
|
87
84
|
if (!Array.isArray(branches) || branches.length === 0 || Object.keys(rule).length !== 1) {
|
|
88
85
|
yield error;
|
|
@@ -126,47 +123,118 @@ function* expandNotErrors(errors, rootSchema, payload) {
|
|
|
126
123
|
}
|
|
127
124
|
}
|
|
128
125
|
function formatValidationIssues(errors, ctx, payload) {
|
|
126
|
+
const resolveDiagnosticPath = (_instancePath, path) => ctx.diagnosticOrigin?.(path)?.schema;
|
|
129
127
|
function* formatted() {
|
|
130
|
-
for (const error of expandNotErrors(
|
|
131
|
-
|
|
128
|
+
for (const error of expandNotErrors(
|
|
129
|
+
compactUnionErrors(errors, resolveDiagnosticPath),
|
|
130
|
+
resolveDiagnosticPath,
|
|
131
|
+
payload
|
|
132
|
+
)) {
|
|
133
|
+
yield enrichWithVariants(
|
|
134
|
+
formatIssue(error, ctx),
|
|
135
|
+
(_instance, _publicPath) => resolveDiagnosticPath(error.instancePath, error.schemaPath)
|
|
136
|
+
);
|
|
132
137
|
}
|
|
133
138
|
}
|
|
134
139
|
return ctx.toolName === "sync_accounts" ? [...formatted()] : (0, import_diagnostic_limits.boundValidationIssues)(formatted());
|
|
135
140
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
function inlineUnionOwner(error, unionPath, variants) {
|
|
142
|
+
const instance = error.instancePath ? error.instancePath.slice(1).split("/") : [];
|
|
143
|
+
let pointer;
|
|
144
|
+
try {
|
|
145
|
+
pointer = error.schemaPath.slice(unionPath.length + 1).split("/").map((segment) => decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
146
|
+
} catch {
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
let cursor = variants;
|
|
150
|
+
const consumed = [];
|
|
151
|
+
for (let index = 0; index < pointer.length - 1; index++) {
|
|
152
|
+
if (!cursor || typeof cursor !== "object") return void 0;
|
|
153
|
+
const keyword = pointer[index];
|
|
154
|
+
if (!Array.isArray(cursor) && ["properties", "patternProperties"].includes(keyword)) {
|
|
155
|
+
const property = pointer[++index];
|
|
156
|
+
if (property === void 0) return void 0;
|
|
157
|
+
consumed.push(keyword === "properties" ? property : void 0);
|
|
158
|
+
cursor = cursor[keyword]?.[property];
|
|
159
|
+
} else if (!Array.isArray(cursor) && [
|
|
160
|
+
"items",
|
|
161
|
+
"prefixItems",
|
|
162
|
+
"additionalItems",
|
|
163
|
+
"contains",
|
|
164
|
+
"additionalProperties",
|
|
165
|
+
"unevaluatedProperties",
|
|
166
|
+
"unevaluatedItems"
|
|
167
|
+
].includes(keyword)) {
|
|
168
|
+
consumed.push(void 0);
|
|
169
|
+
cursor = cursor[keyword];
|
|
170
|
+
if (Array.isArray(cursor)) cursor = cursor[Number(pointer[++index])];
|
|
171
|
+
} else cursor = cursor[keyword];
|
|
146
172
|
}
|
|
173
|
+
if (consumed.length > instance.length) return void 0;
|
|
174
|
+
for (let index = 0; index < consumed.length; index++) {
|
|
175
|
+
const expected = consumed[index];
|
|
176
|
+
const actual = instance[instance.length - consumed.length + index].replace(/~1/g, "/").replace(/~0/g, "~");
|
|
177
|
+
if (expected !== void 0 && actual !== expected) return void 0;
|
|
178
|
+
}
|
|
179
|
+
return consumed.length ? instance.length === consumed.length ? "" : "/" + instance.slice(0, -consumed.length).join("/") : error.instancePath;
|
|
180
|
+
}
|
|
181
|
+
function compactUnionErrors(errors, resolveDiagnosticPath) {
|
|
182
|
+
if (errors.length === 0) return [...errors];
|
|
147
183
|
const dropped = /* @__PURE__ */ new Set();
|
|
148
184
|
const added = [];
|
|
149
|
-
const unionRoots = errors.filter((e) => e.keyword === "oneOf" || e.keyword === "anyOf").slice().sort((a, b) => b.schemaPath.length - a.schemaPath.length);
|
|
185
|
+
const unionRoots = errors.filter((e) => e.keyword === "oneOf" || e.keyword === "anyOf").slice().sort((a, b) => b.instancePath.length - a.instancePath.length || b.schemaPath.length - a.schemaPath.length);
|
|
186
|
+
const unionOwners = /* @__PURE__ */ new Map();
|
|
187
|
+
for (const root of unionRoots) {
|
|
188
|
+
const owners = unionOwners.get(root.schemaPath) ?? /* @__PURE__ */ new Set();
|
|
189
|
+
owners.add(root.instancePath);
|
|
190
|
+
unionOwners.set(root.schemaPath, owners);
|
|
191
|
+
}
|
|
192
|
+
const errorsByOwner = /* @__PURE__ */ new Map();
|
|
193
|
+
for (const error of errors) {
|
|
194
|
+
const match = error.schemaPath.match(/^(.*\/(?:oneOf|anyOf))\/\d+(?:\/|$)/);
|
|
195
|
+
if (!match) continue;
|
|
196
|
+
const schemaPath = match[1];
|
|
197
|
+
const owners = unionOwners.get(schemaPath);
|
|
198
|
+
if (!owners) continue;
|
|
199
|
+
const variants = resolveDiagnosticPath(error.instancePath, schemaPath);
|
|
200
|
+
const nearest = inlineUnionOwner(error, schemaPath, variants);
|
|
201
|
+
if (nearest === void 0 || !owners.has(nearest)) continue;
|
|
202
|
+
const locations = errorsByOwner.get(schemaPath) ?? /* @__PURE__ */ new Map();
|
|
203
|
+
const bucket = locations.get(nearest) ?? [];
|
|
204
|
+
bucket.push(error);
|
|
205
|
+
locations.set(nearest, bucket);
|
|
206
|
+
errorsByOwner.set(schemaPath, locations);
|
|
207
|
+
}
|
|
208
|
+
const processedRoots = /* @__PURE__ */ new Map();
|
|
150
209
|
for (const root of unionRoots) {
|
|
151
210
|
if (dropped.has(root)) continue;
|
|
152
211
|
const oneOfPath = root.schemaPath;
|
|
153
212
|
const rootInstance = root.instancePath;
|
|
154
|
-
|
|
213
|
+
if (root.keyword === "oneOf" && Array.isArray(root.params.passingSchemas) && root.params.passingSchemas.length > 1)
|
|
214
|
+
continue;
|
|
215
|
+
const variantSchemas = resolveDiagnosticPath(rootInstance, oneOfPath);
|
|
216
|
+
if (!Array.isArray(variantSchemas)) continue;
|
|
217
|
+
const processed = processedRoots.get(oneOfPath) ?? /* @__PURE__ */ new Set();
|
|
218
|
+
if (processed.has(rootInstance)) {
|
|
219
|
+
dropped.add(root);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
processed.add(rootInstance);
|
|
223
|
+
processedRoots.set(oneOfPath, processed);
|
|
224
|
+
const candidateErrors = errorsByOwner.get(oneOfPath)?.get(rootInstance) ?? [];
|
|
155
225
|
const byVariant = /* @__PURE__ */ new Map();
|
|
156
226
|
for (const e of candidateErrors) {
|
|
157
227
|
if (e === root || dropped.has(e)) continue;
|
|
158
228
|
const tail = e.schemaPath.slice(oneOfPath.length + 1);
|
|
159
229
|
const m = tail.match(/^(\d+)(?:\/|$)/);
|
|
160
230
|
if (!m) continue;
|
|
161
|
-
if (e.instancePath !== rootInstance && !e.instancePath.startsWith(rootInstance + "/")) continue;
|
|
162
231
|
const idx = parseInt(m[1], 10);
|
|
163
232
|
const bucket = byVariant.get(idx);
|
|
164
233
|
if (bucket) bucket.push(e);
|
|
165
234
|
else byVariant.set(idx, [e]);
|
|
166
235
|
}
|
|
167
236
|
if (byVariant.size === 0) continue;
|
|
168
|
-
const
|
|
169
|
-
const variantArr = Array.isArray(variantSchemas) ? variantSchemas : [];
|
|
237
|
+
const variantArr = variantSchemas;
|
|
170
238
|
const constAsserters = /* @__PURE__ */ new Map();
|
|
171
239
|
for (let i = 0; i < variantArr.length; i++) {
|
|
172
240
|
const variant = variantArr[i];
|
|
@@ -213,6 +281,7 @@ function compactUnionErrors(errors, rootSchema) {
|
|
|
213
281
|
...sample,
|
|
214
282
|
keyword: "enum",
|
|
215
283
|
schemaPath: "",
|
|
284
|
+
__adcp_originSchemaPath: sample.schemaPath,
|
|
216
285
|
message: `must be one of: ${allowedValues.map((v) => JSON.stringify(v)).join(", ")}`,
|
|
217
286
|
params: { allowedValues }
|
|
218
287
|
});
|
|
@@ -243,12 +312,23 @@ function compactUnionErrors(errors, rootSchema) {
|
|
|
243
312
|
}
|
|
244
313
|
}
|
|
245
314
|
}
|
|
246
|
-
const allVariantsHaveNot = variantsWithNotFailure.size ===
|
|
315
|
+
const allVariantsHaveNot = variantsWithNotFailure.size === variantSchemas.length && variantSchemas.length > 0;
|
|
316
|
+
const contradictedVariants = /* @__PURE__ */ new Set();
|
|
317
|
+
for (const [relativePath, asserters] of constAsserters) {
|
|
318
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
319
|
+
for (const [index, residual] of residualByVariant) {
|
|
320
|
+
if (residual.some((error) => error.keyword === "const" && error.instancePath === rootInstance + relativePath))
|
|
321
|
+
emitted.add(index);
|
|
322
|
+
}
|
|
323
|
+
if ([...asserters.keys()].some((index) => !emitted.has(index))) {
|
|
324
|
+
for (const index of emitted) if (asserters.has(index)) contradictedVariants.add(index);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
247
327
|
let bestIdx = -1;
|
|
248
328
|
let bestCount = Infinity;
|
|
249
329
|
let bestConsts = Infinity;
|
|
250
330
|
for (const [idx, residual] of residualByVariant) {
|
|
251
|
-
if (!allVariantsHaveNot && variantsWithNotFailure.has(idx)) continue;
|
|
331
|
+
if (!allVariantsHaveNot && variantsWithNotFailure.has(idx) || contradictedVariants.has(idx)) continue;
|
|
252
332
|
const constCount = residual.reduce((n, e) => e.keyword === "const" ? n + 1 : n, 0);
|
|
253
333
|
if (residual.length < bestCount || residual.length === bestCount && constCount < bestConsts) {
|
|
254
334
|
bestIdx = idx;
|
|
@@ -278,9 +358,9 @@ function compactUnionErrors(errors, rootSchema) {
|
|
|
278
358
|
}
|
|
279
359
|
return [...errors.filter((e) => !dropped.has(e)), ...added];
|
|
280
360
|
}
|
|
281
|
-
function enrichWithVariants(issue,
|
|
361
|
+
function enrichWithVariants(issue, resolveDiagnosticPath) {
|
|
282
362
|
if (issue.keyword !== "oneOf" && issue.keyword !== "anyOf") return issue;
|
|
283
|
-
const resolved =
|
|
363
|
+
const resolved = resolveDiagnosticPath(issue.pointer === "/" ? "" : issue.pointer, issue.schemaPath);
|
|
284
364
|
if (!Array.isArray(resolved)) return issue;
|
|
285
365
|
const variants = resolved.map((variant, index) => {
|
|
286
366
|
if (variant == null || typeof variant !== "object") {
|
|
@@ -301,7 +381,13 @@ function validateRequest(toolName, payload, version) {
|
|
|
301
381
|
const rootSchemaId = rootSchema && typeof rootSchema === "object" && typeof rootSchema.$id === "string" ? rootSchema.$id : void 0;
|
|
302
382
|
if (valid) return { valid: true, issues: [], variant: "request", ...rootSchemaId && { schemaId: rootSchemaId } };
|
|
303
383
|
const registeredIds = (0, import_schema_loader.getRegisteredSchemaIds)(version);
|
|
304
|
-
const ctx = {
|
|
384
|
+
const ctx = {
|
|
385
|
+
rootSchema,
|
|
386
|
+
rootSchemaId,
|
|
387
|
+
registeredIds,
|
|
388
|
+
toolName,
|
|
389
|
+
diagnosticOrigin: createDiagnosticOriginResolver(validator)
|
|
390
|
+
};
|
|
305
391
|
return {
|
|
306
392
|
valid: false,
|
|
307
393
|
issues: formatValidationIssues(validator.errors ?? [], ctx, payload),
|
|
@@ -341,7 +427,13 @@ function validateResponse(toolName, payload, version) {
|
|
|
341
427
|
};
|
|
342
428
|
}
|
|
343
429
|
const registeredIds = (0, import_schema_loader.getRegisteredSchemaIds)(version);
|
|
344
|
-
const ctx = {
|
|
430
|
+
const ctx = {
|
|
431
|
+
rootSchema,
|
|
432
|
+
rootSchemaId,
|
|
433
|
+
registeredIds,
|
|
434
|
+
toolName,
|
|
435
|
+
diagnosticOrigin: createDiagnosticOriginResolver(effective)
|
|
436
|
+
};
|
|
345
437
|
return {
|
|
346
438
|
valid: false,
|
|
347
439
|
issues: formatValidationIssues(effective.errors ?? [], ctx, normalizedPayload),
|
|
@@ -375,6 +467,7 @@ function formatIssues(issues, limit = 3, options = {}) {
|
|
|
375
467
|
}
|
|
376
468
|
// Annotate the CommonJS export names for ESM import in node:
|
|
377
469
|
0 && (module.exports = {
|
|
470
|
+
compactUnionErrors,
|
|
378
471
|
formatDiscriminator,
|
|
379
472
|
formatIssueLine,
|
|
380
473
|
formatIssues,
|