this repo has no description
at main 3.9 kB view raw
1import { Request, defaultAdditionalPlatformsForClient } from "../../foundation/media/data-fetching"; 2import { shouldFetchCustomAttributes } from "../product-page/product-page-variants"; 3import { shouldUsePrerenderedIconArtwork } from "../content/content"; 4/** 5 * Returns the attributes to use for a developer media API request. 6 */ 7export function developerAttributes(objectGraph) { 8 const attributes = ["editorialArtwork", "editorialVideo", "requiredCapabilities", "minimumOSVersion"]; 9 if (objectGraph.client.isMac) { 10 attributes.push("screenshotsByType"); 11 } 12 else { 13 attributes.push("isAppleWatchSupported"); 14 } 15 if (objectGraph.appleSilicon.isSupportEnabled) { 16 attributes.push("macRequiredCapabilities"); 17 } 18 if (objectGraph.client.isMac) { 19 attributes.push("hasMacIPAPackage"); 20 } 21 if (objectGraph.client.isVision) { 22 attributes.push("compatibilityControllerRequirement"); 23 } 24 if (objectGraph.bag.enableUpdatedAgeRatings) { 25 attributes.push("ageRating"); 26 } 27 if (shouldUsePrerenderedIconArtwork(objectGraph)) { 28 attributes.push("iconArtwork"); 29 } 30 return attributes; 31} 32export const iosDeveloperRelationshipKeys = [ 33 "latest-release-app", 34 "system-apps", 35 "arcade-apps", 36 "app-bundles", 37 "ios-apps", 38 "imessage-apps", 39 "watch-apps", 40 "atv-apps", 41]; 42export const visionOSDeveloperRelationshipKeys = [ 43 "latest-release-app", 44 "xros-apps", 45 "arcade-apps", 46 "ios-apps", 47]; 48export const macosDeveloperRelationshipKeys = [ 49 "latest-release-app", 50 "arcade-apps", 51 "app-bundles", 52 "mac-apps", 53]; 54export const webDeveloperRelationshipKeys = [ 55 "latest-release-app", 56 "system-apps", 57 "arcade-apps", 58 "app-bundles", 59 "ios-apps", 60 "imessage-apps", 61 "watch-apps", 62 "atv-apps", 63 "xros-apps", 64 "mac-apps", 65]; 66export const watchosDeveloperRelationshipKey = "watch-apps"; 67function developerRelationships(objectGraph) { 68 let relationships = []; 69 switch (objectGraph.client.deviceType) { 70 case "mac": 71 relationships = relationships.concat(macosDeveloperRelationshipKeys); 72 if (objectGraph.appleSilicon.isSupportEnabled) { 73 relationships.push("mac-os-compatible-ios-apps"); 74 } 75 break; 76 case "watch": 77 relationships.push(watchosDeveloperRelationshipKey); 78 break; 79 case "vision": 80 relationships = relationships.concat(visionOSDeveloperRelationshipKeys); 81 break; 82 case "web": 83 relationships = relationships.concat(webDeveloperRelationshipKeys); 84 break; 85 default: 86 relationships = relationships.concat(iosDeveloperRelationshipKeys); 87 break; 88 } 89 return relationships; 90} 91/** 92 * Creates a {@linkcode Request} for a "developer" page with the given {@linkcode id} 93 */ 94export function makeDeveloperRequest(objectGraph, id) { 95 const request = new Request(objectGraph).withIdOfType(id, "developers"); 96 return addDeveloperRequestProperties(objectGraph, request); 97} 98/** 99 * Add the expected request attributes (relationships, platforms, etc) to a request 100 * for a "developer" resource 101 */ 102export function addDeveloperRequestProperties(objectGraph, request) { 103 request 104 .includingAdditionalPlatforms(defaultAdditionalPlatformsForClient(objectGraph)) 105 .includingRelationships(developerRelationships(objectGraph)) 106 .includingAttributes(developerAttributes(objectGraph)) 107 .includingMacOSCompatibleIOSAppsWhenSupported() 108 .usingCustomAttributes(shouldFetchCustomAttributes(objectGraph)); 109 if (objectGraph.client.isWeb) { 110 // The "web" client needs to load *all* of the data for SEO purposes 111 request.addingQuery("sparseLimit[developers:ios-apps]", "40"); 112 } 113 return request; 114} 115//# sourceMappingURL=developer-request.js.map