summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-page-intent-controller.js55
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-shelf-collection-page-intent-controller.js35
2 files changed, 90 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-page-intent-controller.js b/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-page-intent-controller.js
new file mode 100644
index 0000000..8c19eb7
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-page-intent-controller.js
@@ -0,0 +1,55 @@
+import { isNothing } from "@jet/environment";
+import { renderPage as renderEditorialPage } from "../../common/editorial-pages/editorial-page-controller-util";
+import { makeEditorialPageRequest } from "../../common/editorial-pages/editorial-page-media-api-utils";
+import * as mediaNetwork from "../../foundation/media/network";
+import { FlowAction } from "../../api/models";
+import { withActiveIntent } from "../../foundation/dependencies/active-intent";
+import { isEditorialPageIntentByID } from "../../api/intents/editorial/editorial-page-intent";
+import { editorialPageRoutes, makeEditorialPageURL, } from "../../common/editorial-pages/editorial-page-intent-controller-utils";
+import { injectWebNavigation } from "../../common/web-navigation/inject-web-navigation";
+import { injectSEOData } from "../../api/models/web-renderable-page";
+import { validateAdamId, validateNeedsVisionRestriction } from "../../foundation/media/util";
+export const EditorialPageIntentController = {
+ $intentKind: "EditorialPageIntent",
+ routes(objectGraph) {
+ return editorialPageRoutes(objectGraph);
+ },
+ async perform(intent, objectGraphWithoutActiveIntent) {
+ return await withActiveIntent(objectGraphWithoutActiveIntent, intent, async (objectGraph) => {
+ var _a;
+ if ("id" in intent) {
+ // See: https://github.pie.apple.com/its/Jingle/blob/ce14e21b6ac3dd4be884aa12b26d4e79c6d8aa7a/MZStorePlatform/src/main/java/com/apple/jingle/store/mediaapi/resource/SFMediaAPICommonResourceType.java#L91
+ validateAdamId(objectGraph, intent.id);
+ }
+ validateNeedsVisionRestriction(objectGraph);
+ const mediaApiRequest = makeEditorialPageRequest(objectGraph, intent);
+ const response = await mediaNetwork.fetchData(objectGraph, mediaApiRequest);
+ const editorialPage = await renderEditorialPage(objectGraph, response, {
+ isArcadePage: false,
+ });
+ if (isNothing(editorialPage)) {
+ const notFoundError = new mediaNetwork.NetworkError("Media API response lacked required data");
+ notFoundError.statusCode = 404;
+ throw notFoundError;
+ }
+ // The Media API often does not provide a URL; if that is the case, synthesize one
+ if (isNothing(editorialPage.canonicalURL) && isEditorialPageIntentByID(intent)) {
+ editorialPage.canonicalURL = makeEditorialPageURL(objectGraph, intent);
+ }
+ if (objectGraph.client.isWeb) {
+ injectWebNavigation(objectGraph, editorialPage, intent.platform);
+ injectSEOData(editorialPage, (_a = objectGraph.seo) === null || _a === void 0 ? void 0 : _a.getSEODataForEditorialPage(objectGraph, editorialPage, response));
+ }
+ return editorialPage;
+ });
+ },
+ actionFor(intent, objectGraph) {
+ const action = new FlowAction("page");
+ action.destination = intent;
+ if (isEditorialPageIntentByID(intent)) {
+ action.pageUrl = makeEditorialPageURL(objectGraph, intent);
+ }
+ return action;
+ },
+};
+//# sourceMappingURL=editorial-page-intent-controller.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-shelf-collection-page-intent-controller.js b/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-shelf-collection-page-intent-controller.js
new file mode 100644
index 0000000..a8fdf9c
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/controllers/editorial-pages/editorial-shelf-collection-page-intent-controller.js
@@ -0,0 +1,35 @@
+import { isNothing } from "@jet/environment/types/optional";
+import * as mediaNetwork from "../../foundation/media/network";
+import { withActiveIntent } from "../../foundation/dependencies/active-intent";
+import { editorialShelfCollectionPageRoutes, makeEditorialShelfCollectionPageURL, makeEditorialShelfCollectionPageRequest, renderEditorialShelfCollectionPage, } from "../../common/editorial-pages/editorial-shelf-collection-page-utils";
+import { injectWebNavigation } from "../../common/web-navigation/inject-web-navigation";
+import { injectSEOData } from "../../api/models/web-renderable-page";
+import { validateEditorialShelfCollectionId } from "../../foundation/media/util";
+export const EditorialShelfCollectionPageIntentController = {
+ $intentKind: "EditorialShelfCollectionPageIntent",
+ routes: editorialShelfCollectionPageRoutes,
+ async perform(intent, objectGraphWithoutActiveIntent) {
+ return await withActiveIntent(objectGraphWithoutActiveIntent, intent, async (objectGraph) => {
+ var _a;
+ // See: https://github.pie.apple.com/its/amp-enums/blob/f75500b44f871f35ba3ce459a5ff4c9f225e71b0/src/main/java/com/apple/jingle/store/IdSpace.java#L43
+ validateEditorialShelfCollectionId(objectGraph, intent.id);
+ const mediaApiReqest = makeEditorialShelfCollectionPageRequest(objectGraph, intent);
+ const response = await mediaNetwork.fetchData(objectGraph, mediaApiReqest);
+ const editorialShelfCollectionPage = renderEditorialShelfCollectionPage(objectGraph, response);
+ if (isNothing(editorialShelfCollectionPage)) {
+ const notFoundError = new mediaNetwork.NetworkError("Media API response lacked required data");
+ notFoundError.statusCode = 404;
+ throw notFoundError;
+ }
+ if (isNothing(editorialShelfCollectionPage.canonicalURL)) {
+ editorialShelfCollectionPage.canonicalURL = makeEditorialShelfCollectionPageURL(objectGraph, intent);
+ }
+ if (objectGraph.client.isWeb) {
+ injectWebNavigation(objectGraph, editorialShelfCollectionPage, intent.platform);
+ injectSEOData(editorialShelfCollectionPage, (_a = objectGraph.seo) === null || _a === void 0 ? void 0 : _a.getSEODataForEditorialShelfCollectionPage(objectGraph, editorialShelfCollectionPage, response));
+ }
+ return editorialShelfCollectionPage;
+ });
+ },
+};
+//# sourceMappingURL=editorial-shelf-collection-page-intent-controller.js.map \ No newline at end of file