summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/today/article-request.js
blob: 4371605c13fd2bdb3c3c5e3754fb1c46d26ee794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { defaultAdditionalPlatformsForClient, Request } from "../../foundation/media/data-fetching";
import { shouldFetchCustomAttributes } from "../product-page/product-page-variants";
import { appEventsAreEnabled, appOfferItemsAreEnabled } from "../app-promotions/app-promotions-common";
import { shouldUsePrerenderedIconArtwork } from "../content/content";
import { AppEventsAttributes } from "../../gameservicesui/src/foundation/media-api/requests/recommendation-request-types";
function buildAttributesForArticlePageRequest(objectGraph) {
    const attributes = [
        "screenshotsByType",
        "videoPreviewsByType",
        "requiredCapabilities",
        "minimumOSVersion",
        "editorialArtwork",
        "editorialVideo",
        "editorialClientParams",
        "shortEditorialNotes",
        "enrichedEditorialNotes",
    ];
    if (objectGraph.bag.enableUpdatedAgeRatings) {
        attributes.push("ageRating");
    }
    if (objectGraph.appleSilicon.isSupportEnabled) {
        attributes.push("macRequiredCapabilities");
    }
    if (objectGraph.client.isMac) {
        attributes.push("hasMacIPAPackage");
    }
    if (objectGraph.client.isVision) {
        attributes.push("compatibilityControllerRequirement");
    }
    if (shouldUsePrerenderedIconArtwork(objectGraph)) {
        attributes.push("iconArtwork");
    }
    return attributes;
}
/**
 * Create a Media API request for an `editorial-item`
 *
 * This corresponsd to an "Article" or "Story" page
 */
export function buildArticlePageRequest(objectGraph, intent, isIncomingURL) {
    const request = new Request(objectGraph)
        .withIdOfType(intent.id, "editorial-items")
        .includingAdditionalPlatforms(defaultAdditionalPlatformsForClient(objectGraph))
        .includingAttributes(buildAttributesForArticlePageRequest(objectGraph))
        .includingRelationships(["canvas"])
        .includingRelationshipsForUpsell(true)
        .includingMacOSCompatibleIOSAppsWhenSupported(true)
        .usingCustomAttributes(shouldFetchCustomAttributes(objectGraph));
    if (!isIncomingURL) {
        request.includingAgeRestrictions();
    }
    if (appEventsAreEnabled(objectGraph)) {
        request.enablingFeature("appEvents");
        request.includingScopedAttributes("app-events", AppEventsAttributes);
        request.includingScopedRelationships("app-events", ["app"]);
        request.includingScopedRelationships("editorial-item-shelves", ["app-events"]);
        request.includingScopedAvailableIn("app-events", ["past"]);
    }
    if (appOfferItemsAreEnabled(objectGraph)) {
        request.enablingFeature("offerItems");
        request.includingScopedRelationships("offer-items", ["salables"]);
        request.includingAssociateKeys("editorial-items", ["editorial-cards"]);
        request.includingMetaKeys("offer-items:salables", ["discountOffer"]);
        request.includingScopedAttributes("offer-items", [
            "title",
            "subtitle",
            "additionalTerms",
            "redemptionExpirationDate",
        ]);
    }
    if (objectGraph.client.isVision) {
        request.enablingFeature("supportsCustomTextColor");
        request.includingScopedAttributes("editorial-items", ["enrichedEditorialNotes"]);
    }
    if (objectGraph.client.isWeb) {
        request.includingAttributes([
            // Publication date is used as part of SEO meta-data
            "lastPublishedDate",
        ]);
    }
    if (preprocessor.GAMES_TARGET) {
        request.includingScopedAttributes("apps", ["isEligibleForGamesApp"]);
    }
    return request;
}
//# sourceMappingURL=article-request.js.map