summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/arcade/arcade-see-all-request.js
blob: 6f2094469fd4ec65cc19f76b1c36378c85c9bb98 (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
import { PageFacets } from "../../api/models";
import { isDefinedNonNullNonEmpty, isNullOrEmpty } from "../../foundation/json-parsing/server-data";
import { Parameters } from "../../foundation/network/url-constants";
import { shouldUsePrerenderedIconArtwork } from "../content/content";
import { binCompatGamesFacetOptionParameter, comingSoonAppsFacetOptionValue, comingSoonFacetOptionParameter, comingSoonGroupingFacetOptionValue, facetOptionsParameterMapping, sortCategoryFacetOptionValue, sortFacetOptionParameter, sortLastUpdatedFacetOptionValue, sortNameFacetOptionValue, sortReleaseDateFacetOptionValue, } from "./arcade-see-all-games-facets";
export function defaultRequestAttributes(objectGraph) {
    const attributes = [
        "editorialArtwork",
        "editorialVideo",
        "isAppleWatchSupported",
        "requiredCapabilities",
        "videoPreviewsByType",
        "screenshotsByType",
    ];
    if (objectGraph.appleSilicon.isSupportEnabled) {
        attributes.push("macRequiredCapabilities");
    }
    if (objectGraph.client.isMac) {
        attributes.push("hasMacIPAPackage");
    }
    if (objectGraph.client.isVision) {
        attributes.push("compatibilityControllerRequirement");
    }
    if (objectGraph.bag.enableUpdatedAgeRatings) {
        attributes.push("ageRating");
    }
    if (shouldUsePrerenderedIconArtwork(objectGraph)) {
        attributes.push("iconArtwork");
    }
    return attributes;
}
const defaultSparseCount = 4;
export function prepareRequestWithSelectedFacets(request, selectedFacetOptions) {
    let includeSparseCount = false;
    for (const key of Object.keys(selectedFacetOptions)) {
        // We need to choose the correct value for the coming soon parameter if coming soon is enabled.
        if (key === comingSoonFacetOptionParameter && isDefinedNonNullNonEmpty(selectedFacetOptions[key])) {
            const selectedSortValue = selectedFacetOptions[sortFacetOptionParameter];
            if (isDefinedNonNullNonEmpty(selectedSortValue)) {
                switch (selectedSortValue[0].value) {
                    case sortReleaseDateFacetOptionValue:
                    case sortLastUpdatedFacetOptionValue:
                        selectedFacetOptions[key][0].value = comingSoonGroupingFacetOptionValue;
                        break;
                    case sortNameFacetOptionValue:
                        selectedFacetOptions[key][0].value = comingSoonAppsFacetOptionValue;
                        break;
                    case sortCategoryFacetOptionValue:
                        selectedFacetOptions[key][0].value = comingSoonAppsFacetOptionValue;
                        includeSparseCount = true;
                        break;
                    default:
                        break;
                }
            }
        }
        // We need to choose the correct value for the bin compat games parameter if it is disabled.
        if (key === binCompatGamesFacetOptionParameter && isNullOrEmpty(selectedFacetOptions[key])) {
            selectedFacetOptions[key] = facetOptionsParameterMapping[Parameters.binCompatGames].false;
        }
    }
    // We include the sparse count when dealing with the category sort.
    if (includeSparseCount) {
        request.withSparseCount(defaultSparseCount);
    }
    for (const key of Object.keys(selectedFacetOptions)) {
        const requestValues = PageFacets.requestValuesForSelectedFacetOptions(selectedFacetOptions[key]);
        if (isDefinedNonNullNonEmpty(requestValues)) {
            if (isDefinedNonNullNonEmpty(requestValues.value)) {
                request.addingQuery(key, requestValues.value);
            }
            for (const additionalKey of Object.keys(requestValues.additionalKeyValuePairs)) {
                request.addingQuery(additionalKey, requestValues.additionalKeyValuePairs[additionalKey]);
            }
        }
    }
}
//# sourceMappingURL=arcade-see-all-request.js.map