Просмотр исходного кода

refactor getServerSideCommonEachProps

Yuki Takei 7 месяцев назад
Родитель
Сommit
2c25c676b9

+ 33 - 6
apps/app/src/pages/[[...path]]/index.page.tsx

@@ -27,12 +27,14 @@ import { useSWRMUTxCurrentPageYjsData } from '~/stores/yjs';
 import type { NextPageWithLayout } from '../_app.page';
 import type { BasicLayoutConfigurationProps } from '../basic-layout-page';
 import { useHydrateBasicLayoutConfigurationAtoms } from '../basic-layout-page/hydrate';
+import { getServerSideCommonEachProps } from '../common-props';
 import type { GeneralPageInitialProps } from '../general-page';
 import { useInitialCSRFetch } from '../general-page';
 import { useHydrateGeneralPageConfigurationAtoms } from '../general-page/hydrate';
 import { registerPageToShowRevisionWithMeta } from '../general-page/superjson';
 import { NextjsRoutingType, detectNextjsRoutingType } from '../utils/nextjs-routing-utils';
 import { useCustomTitleForPage } from '../utils/page-title-customization';
+import { mergeGetServerSidePropsResults } from '../utils/server-side-props';
 
 import { NEXT_JS_ROUTING_PAGE } from './consts';
 import { getServerSidePropsForInitial, getServerSidePropsForSameRoute } from './server-side-props';
@@ -207,15 +209,40 @@ Page.getLayout = function getLayout(page: React.ReactElement<Props>) {
 };
 
 export const getServerSideProps: GetServerSideProps<Props> = async(context: GetServerSidePropsContext) => {
+  //
+  // STAGE 1
+  //
+
+  const commonEachPropsResult = await getServerSideCommonEachProps(context, NEXT_JS_ROUTING_PAGE);
+  // Handle early return cases (redirect/notFound)
+  if ('redirect' in commonEachPropsResult || 'notFound' in commonEachPropsResult) {
+    return commonEachPropsResult;
+  }
+  const commonEachProps = await commonEachPropsResult.props;
+
+  // Handle redirect destination from common props
+  if (commonEachProps.redirectDestination != null) {
+    return {
+      redirect: {
+        permanent: false,
+        destination: commonEachProps.redirectDestination,
+      },
+    };
+  }
+
+  //
+  // STAGE 2
+  //
+
   // detect Next.js routing type
   const nextjsRoutingType = detectNextjsRoutingType(context, NEXT_JS_ROUTING_PAGE);
 
-  if (nextjsRoutingType === NextjsRoutingType.INITIAL) {
-    return getServerSidePropsForInitial(context);
-  }
-
-  // Lightweight props for same-route navigation
-  return getServerSidePropsForSameRoute(context);
+  // Merge all results in a type-safe manner (using sequential merging)
+  return mergeGetServerSidePropsResults(commonEachPropsResult, (
+    (nextjsRoutingType === NextjsRoutingType.INITIAL)
+      ? await getServerSidePropsForInitial(context)
+      : await getServerSidePropsForSameRoute(context)
+  ));
 };
 
 export default Page;

+ 16 - 85
apps/app/src/pages/[[...path]]/server-side-props.ts

@@ -2,20 +2,21 @@ import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
 
 import { getServerSideBasicLayoutProps } from '../basic-layout-page';
 import {
-  getServerSideI18nProps, getServerSideCommonInitialProps, getServerSideCommonEachProps, isValidCommonEachRouteProps,
+  getServerSideI18nProps, getServerSideCommonInitialProps,
 } from '../common-props';
 import type { GeneralPageInitialProps } from '../general-page';
 import {
   getServerSideRendererConfigProps,
-  getActivityAction, isValidInitialAndSameRouteProps,
+  getActivityAction,
   getServerSideGeneralPageProps,
 } from '../general-page';
+import { isValidGeneralPageInitialProps } from '../general-page/type-guards';
 import { addActivity } from '../utils/activity';
 import { mergeGetServerSidePropsResults } from '../utils/server-side-props';
 
 import { NEXT_JS_ROUTING_PAGE } from './consts';
 import { getPageDataForInitial, getPageDataForSameRoute } from './page-data-props';
-import type { EachProps } from './types';
+import type { PageEachProps } from './types';
 
 
 const nextjsRoutingProps = {
@@ -24,32 +25,8 @@ const nextjsRoutingProps = {
   },
 };
 
-export async function getServerSidePropsForInitial(context: GetServerSidePropsContext): Promise<GetServerSidePropsResult<GeneralPageInitialProps & EachProps>> {
-  //
-  // STAGE 1
-  //
-
-  const commonEachPropsResult = await getServerSideCommonEachProps(context);
-  // Handle early return cases (redirect/notFound)
-  if ('redirect' in commonEachPropsResult || 'notFound' in commonEachPropsResult) {
-    return commonEachPropsResult;
-  }
-  const commonEachProps = await commonEachPropsResult.props;
-
-  // Handle redirect destination from common props
-  if (commonEachProps.redirectDestination != null) {
-    return {
-      redirect: {
-        permanent: false,
-        destination: commonEachProps.redirectDestination,
-      },
-    };
-  }
-
-  //
-  // STAGE 2
-  //
-
+export async function getServerSidePropsForInitial(context: GetServerSidePropsContext):
+    Promise<GetServerSidePropsResult<GeneralPageInitialProps & PageEachProps>> {
   const [
     commonInitialResult,
     basicLayoutResult,
@@ -67,13 +44,12 @@ export async function getServerSidePropsForInitial(context: GetServerSidePropsCo
   ]);
 
   // Merge all results in a type-safe manner (using sequential merging)
-  const mergedResult = mergeGetServerSidePropsResults(commonEachPropsResult,
-    mergeGetServerSidePropsResults(commonInitialResult,
-      mergeGetServerSidePropsResults(basicLayoutResult,
-        mergeGetServerSidePropsResults(generalPageResult,
-          mergeGetServerSidePropsResults(rendererConfigResult,
-            mergeGetServerSidePropsResults(i18nPropsResult,
-              mergeGetServerSidePropsResults(pageDataResult, nextjsRoutingProps)))))));
+  const mergedResult = mergeGetServerSidePropsResults(commonInitialResult,
+    mergeGetServerSidePropsResults(basicLayoutResult,
+      mergeGetServerSidePropsResults(generalPageResult,
+        mergeGetServerSidePropsResults(rendererConfigResult,
+          mergeGetServerSidePropsResults(i18nPropsResult,
+            mergeGetServerSidePropsResults(pageDataResult, nextjsRoutingProps))))));
 
   // Check for early return (redirect/notFound)
   if ('redirect' in mergedResult || 'notFound' in mergedResult) {
@@ -83,7 +59,7 @@ export async function getServerSidePropsForInitial(context: GetServerSidePropsCo
   const mergedProps = await mergedResult.props;
 
   // Type-safe props validation AFTER skipSSR is properly set
-  if (!isValidInitialAndSameRouteProps(mergedProps)) {
+  if (!isValidGeneralPageInitialProps(mergedProps)) {
     throw new Error('Invalid merged props structure');
   }
 
@@ -91,58 +67,13 @@ export async function getServerSidePropsForInitial(context: GetServerSidePropsCo
   return mergedResult;
 }
 
-export async function getServerSidePropsForSameRoute(context: GetServerSidePropsContext): Promise<GetServerSidePropsResult<EachProps>> {
-  //
-  // STAGE 1
-  //
-
-  const commonEachPropsResult = await getServerSideCommonEachProps(context);
-  // Handle early return cases (redirect/notFound)
-  if ('redirect' in commonEachPropsResult || 'notFound' in commonEachPropsResult) {
-    return commonEachPropsResult;
-  }
-  const commonEachProps = await commonEachPropsResult.props;
-
-  // Handle redirect destination from common props
-  if (commonEachProps.redirectDestination != null) {
-    return {
-      redirect: {
-        permanent: false,
-        destination: commonEachProps.redirectDestination,
-      },
-    };
-  }
-
-  //
-  // STAGE 2
-  //
-
+export async function getServerSidePropsForSameRoute(context: GetServerSidePropsContext): Promise<GetServerSidePropsResult<PageEachProps>> {
   // Get page data
-  const sameRoutePageDataResult = await getPageDataForSameRoute(context);
-
-  // Merge results in a type-safe manner
-  const mergedResult = mergeGetServerSidePropsResults(commonEachPropsResult,
-    mergeGetServerSidePropsResults(sameRoutePageDataResult, nextjsRoutingProps));
-
-  // Check for early return (redirect/notFound)
-  if ('redirect' in mergedResult || 'notFound' in mergedResult) {
-    return mergedResult;
-  }
-
-  // Validate the merged props have all required properties
-  if (!isValidCommonEachRouteProps(mergedResult.props)) {
-    throw new Error('Invalid same route props structure');
-  }
+  const result = await getPageDataForSameRoute(context);
 
   // -- TODO: persist activity
 
   // const mergedProps = await mergedResult.props;
-
-  // // Type-safe props validation AFTER skipSSR is properly set
-  // if (!isValidSameRouteProps(mergedProps)) {
-  //   throw new Error('Invalid same route props structure');
-  // }
-
   // await addActivity(context, getActivityAction(mergedProps));
-  return mergedResult;
+  return result;
 }

+ 4 - 2
apps/app/src/pages/[[...path]]/types.ts

@@ -1,10 +1,12 @@
 import type { CommonEachProps } from '../common-props';
 
-export type EachProps = CommonEachProps & {
+export type PageEachProps = {
   redirectFrom?: string;
 
   isIdenticalPathPage: boolean,
 
   templateTagData?: string[],
   templateBodyData?: string,
-}
+};
+
+export type EachProps = CommonEachProps & PageEachProps;

+ 26 - 18
apps/app/src/pages/common-props/commons.ts

@@ -48,7 +48,7 @@ export const getServerSideCommonInitialProps: GetServerSideProps<CommonInitialPr
 
 export type CommonEachProps = {
   currentPathname: string,
-  nextjsRoutingPage: string | null, // must be set by each page
+  nextjsRoutingPage?: string, // must be set by each page
   currentUser?: IUserHasId,
   csrfToken: string,
   isMaintenanceMode: boolean,
@@ -59,7 +59,7 @@ export type CommonEachProps = {
  * Type guard for SameRouteEachProps validation
  * Lightweight validation for same-route navigation
  */
-export function isValidCommonEachRouteProps(props: unknown): props is CommonEachProps {
+function isValidCommonEachRouteProps(props: unknown, shouldContainNextjsRoutingPage = false): props is CommonEachProps {
   if (typeof props !== 'object' || props === null) {
     logger.warn('isValidCommonEachRouteProps: props is not an object or is null');
     return false;
@@ -68,9 +68,11 @@ export function isValidCommonEachRouteProps(props: unknown): props is CommonEach
   const p = props as Record<string, unknown>;
 
   // Essential properties validation
-  if (typeof p.nextjsRoutingPage !== 'string' && p.nextjsRoutingPage !== null) {
-    logger.warn('isValidCommonEachRouteProps: nextjsRoutingPage is not a string or null', { nextjsRoutingPage: p.nextjsRoutingPage });
-    return false;
+  if (shouldContainNextjsRoutingPage) {
+    if (typeof p.nextjsRoutingPage !== 'string' && p.nextjsRoutingPage !== undefined) {
+      logger.warn('isValidCommonEachRouteProps: nextjsRoutingPage is not a string or null', { nextjsRoutingPage: p.nextjsRoutingPage });
+      return false;
+    }
   }
   if (typeof p.currentPathname !== 'string') {
     logger.warn('isValidCommonEachRouteProps: currentPathname is not a string', { currentPathname: p.currentPathname });
@@ -84,20 +86,20 @@ export function isValidCommonEachRouteProps(props: unknown): props is CommonEach
     logger.warn('isValidCommonEachRouteProps: isMaintenanceMode is not a boolean', { isMaintenanceMode: p.isMaintenanceMode });
     return false;
   }
-  if (typeof p.isIdenticalPathPage !== 'boolean') {
-    logger.warn('isValidCommonEachRouteProps: isIdenticalPathPage is not a boolean', { isIdenticalPathPage: p.isIdenticalPathPage });
-    return false;
-  }
 
   return true;
 }
 
-export const getServerSideCommonEachProps: GetServerSideProps<Omit<CommonEachProps, 'nextjsRoutingPage'>> = async(context: GetServerSidePropsContext) => {
+export const getServerSideCommonEachProps = async(
+    context: GetServerSidePropsContext, nextjsRoutingPage?: string,
+): ReturnType<GetServerSideProps<CommonEachProps>> => {
+
   const req = context.req as CrowiRequest;
   const { crowi, user } = req;
   const { appService } = crowi;
 
   const url = new URL(context.resolvedUrl, 'http://example.com');
+
   const currentPathname = decodeURIComponent(url.pathname);
 
   const isMaintenanceMode = appService.isMaintenanceMode();
@@ -122,13 +124,19 @@ export const getServerSideCommonEachProps: GetServerSideProps<Omit<CommonEachPro
     redirectDestination = null;
   }
 
-  return {
-    props: {
-      currentPathname,
-      currentUser,
-      csrfToken: req.csrfToken(),
-      isMaintenanceMode,
-      redirectDestination,
-    },
+  const props = {
+    currentPathname,
+    nextjsRoutingPage,
+    currentUser,
+    csrfToken: req.csrfToken(),
+    isMaintenanceMode,
+    redirectDestination,
   };
+
+  const shouldContainNextjsRoutingPage = (nextjsRoutingPage != null);
+  if (!isValidCommonEachRouteProps(props, shouldContainNextjsRoutingPage)) {
+    throw new Error('Invalid common each route props structure');
+  }
+
+  return { props };
 };

+ 1 - 1
apps/app/src/pages/common-props/index.ts

@@ -1,5 +1,5 @@
 export {
   type CommonInitialProps, getServerSideCommonInitialProps,
-  type CommonEachProps, getServerSideCommonEachProps, isValidCommonEachRouteProps,
+  type CommonEachProps, getServerSideCommonEachProps,
 } from './commons';
 export { getServerSideI18nProps } from './i18n';

+ 1 - 1
apps/app/src/pages/general-page/index.ts

@@ -1,5 +1,5 @@
 export { getServerSideRendererConfigProps, getServerSideGeneralPageProps } from './configuration-props';
 export { getActivityAction } from './get-activity-action';
 export type * from './types';
-export { isValidInitialAndSameRouteProps } from './type-guards';
+export { isValidGeneralPageInitialProps } from './type-guards';
 export { useInitialCSRFetch } from './use-initial-skip-ssr-fetch';

+ 6 - 15
apps/app/src/pages/general-page/type-guards.ts

@@ -1,8 +1,5 @@
 import loggerFactory from '~/utils/logger';
 
-import type { CommonEachProps } from '../common-props';
-import { isValidCommonEachRouteProps } from '../common-props';
-
 import type { GeneralPageInitialProps } from './types';
 
 const logger = loggerFactory('growi:pages:general-page:type-guards');
@@ -11,37 +8,31 @@ const logger = loggerFactory('growi:pages:general-page:type-guards');
  * Type guard for GeneralPageInitialProps & CommonEachProps validation
  * First validates CommonEachProps, then checks GeneralPageGeneralPageInitialProps-specific properties
  */
-export function isValidInitialAndSameRouteProps(props: unknown): props is GeneralPageInitialProps & CommonEachProps {
-  // First, validate CommonEachProps
-  if (!isValidCommonEachRouteProps(props)) {
-    logger.warn('isValidInitialAndSameRouteProps: CommonEachProps validation failed');
-    return false;
-  }
-
+export function isValidGeneralPageInitialProps(props: unknown): props is GeneralPageInitialProps {
   const p = props as Record<string, unknown>;
 
   // Then validate GeneralPageInitialProps-specific properties
   // CommonPageInitialProps
   if (p.isNextjsRoutingTypeInitial !== true) {
-    logger.warn('isValidInitialAndSameRouteProps: isNextjsRoutingTypeInitial is not true', { isNextjsRoutingTypeInitial: p.isNextjsRoutingTypeInitial });
+    logger.warn('isValidGeneralPageInitialProps: isNextjsRoutingTypeInitial is not true', { isNextjsRoutingTypeInitial: p.isNextjsRoutingTypeInitial });
     return false;
   }
   if (typeof p.growiVersion !== 'string') {
-    logger.warn('isValidInitialAndSameRouteProps: growiVersion is not a string', { growiVersion: p.growiVersion });
+    logger.warn('isValidGeneralPageInitialProps: growiVersion is not a string', { growiVersion: p.growiVersion });
     return false;
   }
 
   // GeneralPageInitialProps specific page state
   if (typeof p.isNotFound !== 'boolean') {
-    logger.warn('isValidInitialAndSameRouteProps: isNotFound is not a boolean', { isNotFound: p.isNotFound });
+    logger.warn('isValidGeneralPageInitialProps: isNotFound is not a boolean', { isNotFound: p.isNotFound });
     return false;
   }
   if (typeof p.isForbidden !== 'boolean') {
-    logger.warn('isValidInitialAndSameRouteProps: isForbidden is not a boolean', { isForbidden: p.isForbidden });
+    logger.warn('isValidGeneralPageInitialProps: isForbidden is not a boolean', { isForbidden: p.isForbidden });
     return false;
   }
   if (typeof p.isNotCreatable !== 'boolean') {
-    logger.warn('isValidInitialAndSameRouteProps: isNotCreatable is not a boolean', { isNotCreatable: p.isNotCreatable });
+    logger.warn('isValidGeneralPageInitialProps: isNotCreatable is not a boolean', { isNotCreatable: p.isNotCreatable });
     return false;
   }
 

+ 38 - 6
apps/app/src/pages/share/[[...path]]/index.page.tsx

@@ -11,8 +11,10 @@ import { ShareLinkLayout } from '~/components/Layout/ShareLinkLayout';
 import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
 import { ShareLinkPageView } from '~/components/ShareLinkPageView';
 import type { CommonEachProps } from '~/pages/common-props';
+import { getServerSideCommonEachProps } from '~/pages/common-props';
 import { NextjsRoutingType, detectNextjsRoutingType } from '~/pages/utils/nextjs-routing-utils';
 import { useCustomTitleForPage } from '~/pages/utils/page-title-customization';
+import { mergeGetServerSidePropsResults } from '~/pages/utils/server-side-props';
 import {
   useCurrentPageData, useCurrentPagePath,
 } from '~/states/page';
@@ -27,7 +29,7 @@ import { useHydrateGeneralPageConfigurationAtoms } from '../../general-page/hydr
 import { registerPageToShowRevisionWithMeta } from '../../general-page/superjson';
 
 import { NEXT_JS_ROUTING_PAGE } from './consts';
-import { getServerSidePropsForInitial, getServerSidePropsForSameRoute } from './server-side-props';
+import { getServerSidePropsForInitial } from './server-side-props';
 import type { ShareLinkInitialProps } from './types';
 
 // call superjson custom register
@@ -134,16 +136,46 @@ SharedPage.getLayout = function getLayout(page) {
 //   return action;
 // }
 
+const emptyProps = {
+  props: {},
+};
+
 export const getServerSideProps: GetServerSideProps<Props> = async(context: GetServerSidePropsContext) => {
+  //
+  // STAGE 1
+  //
+
+  const commonEachPropsResult = await getServerSideCommonEachProps(context, NEXT_JS_ROUTING_PAGE);
+  // Handle early return cases (redirect/notFound)
+  if ('redirect' in commonEachPropsResult || 'notFound' in commonEachPropsResult) {
+    return commonEachPropsResult;
+  }
+  const commonEachProps = await commonEachPropsResult.props;
+
+  // Handle redirect destination from common props
+  if (commonEachProps.redirectDestination != null) {
+    return {
+      redirect: {
+        permanent: false,
+        destination: commonEachProps.redirectDestination,
+      },
+    };
+  }
+
+  //
+  // STAGE 2
+  //
+
   // detect Next.js routing type
   const nextjsRoutingType = detectNextjsRoutingType(context, NEXT_JS_ROUTING_PAGE);
 
-  if (nextjsRoutingType === NextjsRoutingType.INITIAL) {
-    return getServerSidePropsForInitial(context);
-  }
+  // Merge all results in a type-safe manner (using sequential merging)
+  return mergeGetServerSidePropsResults(commonEachPropsResult, (
+    (nextjsRoutingType === NextjsRoutingType.INITIAL)
+      ? await getServerSidePropsForInitial(context)
+      : emptyProps
+  ));
 
-  // Lightweight props for same-route navigation
-  return getServerSidePropsForSameRoute(context);
 };
 
 export default SharedPage;

+ 9 - 86
apps/app/src/pages/share/[[...path]]/server-side-props.ts

@@ -1,29 +1,21 @@
 import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
 
-import type { CommonEachProps } from '../../common-props';
 import {
-  getServerSideI18nProps, getServerSideCommonInitialProps, getServerSideCommonEachProps,
+  getServerSideI18nProps, getServerSideCommonInitialProps,
 } from '../../common-props';
 import type { GeneralPageInitialProps } from '../../general-page';
 import {
   getServerSideGeneralPageProps,
   getServerSideRendererConfigProps,
-  getActivityAction, isValidInitialAndSameRouteProps,
+  getActivityAction, isValidGeneralPageInitialProps,
 } from '../../general-page';
 import { addActivity } from '../../utils/activity';
 import { mergeGetServerSidePropsResults } from '../../utils/server-side-props';
 
-import { NEXT_JS_ROUTING_PAGE } from './consts';
 import { getPageDataForInitial } from './page-data-props';
 import type { ShareLinkInitialProps } from './types';
 
 
-const nextjsRoutingProps = {
-  props: {
-    nextjsRoutingPage: NEXT_JS_ROUTING_PAGE,
-  },
-};
-
 const basisProps = {
   props: {
     isNotCreatable: true,
@@ -33,32 +25,7 @@ const basisProps = {
 };
 
 export async function getServerSidePropsForInitial(context: GetServerSidePropsContext):
-    Promise<GetServerSidePropsResult<GeneralPageInitialProps & ShareLinkInitialProps & CommonEachProps>> {
-
-  //
-  // STAGE 1
-  //
-
-  const commonEachPropsResult = await getServerSideCommonEachProps(context);
-  // Handle early return cases (redirect/notFound)
-  if ('redirect' in commonEachPropsResult || 'notFound' in commonEachPropsResult) {
-    return commonEachPropsResult;
-  }
-  const commonEachProps = await commonEachPropsResult.props;
-
-  // Handle redirect destination from common props
-  if (commonEachProps.redirectDestination != null) {
-    return {
-      redirect: {
-        permanent: false,
-        destination: commonEachProps.redirectDestination,
-      },
-    };
-  }
-
-  //
-  // STAGE 2
-  //
+    Promise<GetServerSidePropsResult<GeneralPageInitialProps & ShareLinkInitialProps>> {
 
   const [
     commonInitialResult,
@@ -75,13 +42,11 @@ export async function getServerSidePropsForInitial(context: GetServerSidePropsCo
   ]);
 
   // Merge all results in a type-safe manner (using sequential merging)
-  const mergedResult = mergeGetServerSidePropsResults(commonEachPropsResult,
-    mergeGetServerSidePropsResults(commonInitialResult,
-      mergeGetServerSidePropsResults(generalPageResult,
-        mergeGetServerSidePropsResults(rendererConfigResult,
-          mergeGetServerSidePropsResults(i18nPropsResult,
-            mergeGetServerSidePropsResults(pageDataResult,
-              mergeGetServerSidePropsResults(nextjsRoutingProps, basisProps)))))));
+  const mergedResult = mergeGetServerSidePropsResults(commonInitialResult,
+    mergeGetServerSidePropsResults(generalPageResult,
+      mergeGetServerSidePropsResults(rendererConfigResult,
+        mergeGetServerSidePropsResults(i18nPropsResult,
+          mergeGetServerSidePropsResults(pageDataResult, basisProps)))));
 
   // Check for early return (redirect/notFound)
   if ('redirect' in mergedResult || 'notFound' in mergedResult) {
@@ -91,52 +56,10 @@ export async function getServerSidePropsForInitial(context: GetServerSidePropsCo
   const mergedProps = await mergedResult.props;
 
   // Type-safe props validation AFTER skipSSR is properly set
-  if (!isValidInitialAndSameRouteProps(mergedProps)) {
+  if (!isValidGeneralPageInitialProps(mergedProps)) {
     throw new Error('Invalid merged props structure');
   }
 
   await addActivity(context, getActivityAction(mergedProps));
   return mergedResult;
 }
-
-export async function getServerSidePropsForSameRoute(context: GetServerSidePropsContext): Promise<GetServerSidePropsResult<CommonEachProps>> {
-  //
-  // STAGE 1
-  //
-
-  const commonEachPropsResult = await getServerSideCommonEachProps(context);
-  // Handle early return cases (redirect/notFound)
-  if ('redirect' in commonEachPropsResult || 'notFound' in commonEachPropsResult) {
-    return commonEachPropsResult;
-  }
-  const commonEachProps = await commonEachPropsResult.props;
-
-  // Handle redirect destination from common props
-  if (commonEachProps.redirectDestination != null) {
-    return {
-      redirect: {
-        permanent: false,
-        destination: commonEachProps.redirectDestination,
-      },
-    };
-  }
-
-  //
-  // STAGE 2
-  //
-
-  // Merge results in a type-safe manner
-  const mergedResult = mergeGetServerSidePropsResults(commonEachPropsResult, nextjsRoutingProps);
-
-  // -- TODO: persist activity
-
-  // const mergedProps = await mergedResult.props;
-
-  // // Type-safe props validation AFTER skipSSR is properly set
-  // if (!isValidSameRouteProps(mergedProps)) {
-  //   throw new Error('Invalid same route props structure');
-  // }
-
-  // await addActivity(context, getActivityAction(mergedProps));
-  return mergedResult;
-}