(
normalizedDomain: string,
scope: NormalizedScope,
placements: PlacementDefinition[],
placementTagDefinitions: Record<string, PlacementTagDefinition>
)
| 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, |
no test coverage detected