this repo has no description
1import { Request, defaultAdditionalPlatformsForClient, defaultSparseLimitForClient, } from "../../foundation/media/data-fetching";
2import { configureContingentItemsForGroupingRequest, configureOfferItemsForMediaRequest, configureTagsForMediaRequest, } from "../builders/url-mapping-utils";
3import { shouldFetchCustomAttributes } from "../product-page/product-page-variants";
4import { appContingentItemsAreEnabled, appEventsAreEnabled, appOfferItemsAreEnabled, } from "../app-promotions/app-promotions-common";
5import { areAppTagsEnabled } from "../util/app-tags-util";
6import * as mediaRequestUtils from "../../common/builders/url-mapping-utils";
7import { shouldUsePrerenderedIconArtwork } from "../content/content";
8import { AppEventsAttributes } from "../../gameservicesui/src/foundation/media-api/requests/recommendation-request-types";
9/**
10 * Create a "base" Media API {@linkcode Request} object for a "Grouping" page
11 *
12 * This is used to provision an initial {@linkcode Request} object that will be further
13 * modified later to include the specific page that should be fetched
14 *
15 * @see {@linkcode prepareGroupingPageRequest} to complete configuration of the `Request` object
16 */
17export function makeBaseGroupingPageRequest(objectGraph) {
18 // TODO: Update this code to work with genreId when this radar is complete
19 // <rdar://problem/37676122> Media Api: Need ability to lookup grouping resource by genreId
20 // TODO: Remove isAppleWatchSupported, once the following radar is resolved
21 // <rdar://problem/38923866> Media API: Include isAppleWatchSupported in secondary lookups
22 // Add this back in 18E when grouping supports additional platforms
23 // fixed with <rdar://problem/38899888> App Store Personalization: grouping: remove tabs query param for Apps realm
24 // .includingAdditionalPlatforms(mediaDataFetching.defaultAdditionalPlatformsForClient())
25 const attributes = [
26 "editorialArtwork",
27 "editorialVideo",
28 "isAppleWatchSupported",
29 "requiredCapabilities",
30 "expectedReleaseDateDisplayFormat",
31 "showExpectedReleaseDate",
32 "badge-content",
33 ];
34 if (objectGraph.appleSilicon.isSupportEnabled) {
35 attributes.push("macRequiredCapabilities");
36 }
37 if (objectGraph.client.isMac) {
38 attributes.push("hasMacIPAPackage");
39 }
40 if (objectGraph.bag.enableUpdatedAgeRatings) {
41 attributes.push("ageRating");
42 }
43 if (shouldUsePrerenderedIconArtwork(objectGraph)) {
44 attributes.push("iconArtwork");
45 }
46 const mediaApiRequest = new Request(objectGraph)
47 .forType("groupings")
48 .includingAgeRestrictions()
49 .includingAttributes(attributes)
50 .includingRelationshipsForUpsell(true);
51 if (areAppTagsEnabled(objectGraph, "grouping")) {
52 mediaRequestUtils.configureTagsForMediaRequest(mediaApiRequest);
53 }
54 return mediaApiRequest;
55}
56/**
57 * Complete the configuration of a "Grouping Page" {@linkcode Request}
58 */
59export function prepareGroupingPageRequest(objectGraph, request) {
60 request.includingAdditionalPlatforms(defaultAdditionalPlatformsForClient(objectGraph));
61 request.includingAgeRestrictions();
62 request.usingCustomAttributes(shouldFetchCustomAttributes(objectGraph));
63 // <rdar://53420717> For performance reasons, we limit shelves to 3 items on watchOS
64 if (objectGraph.client.isWatch) {
65 request.addingRelationshipLimit("contents", 3);
66 }
67 if (objectGraph.client.isWeb) {
68 // The "web" client needs to load *all* of the data for SEO purposes
69 // Without this, shelves will render with some missing items
70 request.withSparseCount(40);
71 const sparseLimit = defaultSparseLimitForClient(objectGraph);
72 if (sparseLimit) {
73 request.includingScopedSparseLimit("editorial-elements:contents", sparseLimit);
74 }
75 }
76 request.includingMacOSCompatibleIOSAppsWhenSupported();
77 if (appEventsAreEnabled(objectGraph)) {
78 request.enablingFeature("appEvents");
79 request.includingMetaKeys("editorial-elements:contents", ["personalizationData", "cppData"]);
80 request.includingScopedAttributes("app-events", AppEventsAttributes);
81 request.includingScopedRelationships("app-events", ["app"]);
82 }
83 if (areAppTagsEnabled(objectGraph, "grouping")) {
84 configureTagsForMediaRequest(request);
85 }
86 if (appContingentItemsAreEnabled(objectGraph)) {
87 request.enablingFeature("contingentItems");
88 configureContingentItemsForGroupingRequest(request);
89 }
90 if (appOfferItemsAreEnabled(objectGraph)) {
91 request.enablingFeature("offerItems");
92 configureOfferItemsForMediaRequest(request);
93 }
94 if (objectGraph.client.isiOS) {
95 request.enablingFeature("categoryHeaders");
96 request.enablingFeature("onDevicePersonalization");
97 }
98 // Enable category features
99 if (objectGraph.bag.enableFeaturedCategoriesOnGroupings) {
100 request.enablingFeature("featuredCategories");
101 }
102 // Enable category bricks
103 if (objectGraph.bag.enableCategoryBricksOnGroupings) {
104 request.enablingFeature("categoryBricks");
105 }
106}
107//# sourceMappingURL=grouping-request.js.map