MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / resolveRequestedPlacements

Method resolveRequestedPlacements

server/src/validator.ts:705–738  ·  view source on GitHub ↗
(
    normalizedDomain: string,
    scope: NormalizedScope,
    placements: PlacementDefinition[],
    placementTagDefinitions: Record<string, PlacementTagDefinition>
  )

Source from the content-addressed store, hash-verified

703 }
704
705 private resolveRequestedPlacements(
706 normalizedDomain: string,
707 scope: NormalizedScope,
708 placements: PlacementDefinition[],
709 placementTagDefinitions: Record<string, PlacementTagDefinition>
710 ): PlacementDefinition[] {
711 const placementIds = scope.placement_ids ? new Set(scope.placement_ids) : null;
712 const placementTags = scope.placement_tags ? new Set(scope.placement_tags) : null;
713
714 if (placementTags) {
715 const definedTagIds = new Set([
716 ...Object.keys(placementTagDefinitions || {}),
717 ...placements.flatMap((placement) => placement.tags || []),
718 ]);
719 for (const tag of placementTags) {
720 if (!definedTagIds.has(tag)) {
721 return [];
722 }
723 }
724 }
725
726 return placements.filter((placement) => {
727 if (placement.publisher_domain && this.normalizeDomain(placement.publisher_domain) !== normalizedDomain) {
728 return false;
729 }
730 if (placementIds && !placementIds.has(placement.placement_id)) {
731 return false;
732 }
733 if (placementTags && !this.hasIntersection(placement.tags || [], [...placementTags])) {
734 return false;
735 }
736 return true;
737 });
738 }
739
740 private placementMatchesAuthorizedScope(
741 placement: PlacementDefinition,

Callers 1

matchesPlacementsMethod · 0.95

Calls 3

normalizeDomainMethod · 0.95
hasIntersectionMethod · 0.95
hasMethod · 0.80

Tested by

no test coverage detected