///
import { FC } from "react";
import type { GetStaticPropsContext } from "next";
import { ParsedUrlQuery } from "querystring";
import { ContentItem, ApiClientInstance, Page } from "@agility/content-fetch";
/**
* The GetDynamicPageItem function is used to retrieve the dynamic page item for a given page.
*
* @export
* @interface getDynamicPageURL
* @param {int} contentID The contentID of the dynamic page item
* @param {boolean} preview Whether to use the preview API key
* @param {string | null} slug The slug of the dynamic page item, optional
* @param {string | null} locale The locale of the dynamic page item, optional
*
*/
export interface IGetDynamicPageURLProps {
contentID: number;
preview: boolean;
slug?: string | null;
locale?: string | null;
}
/**
* Extension of the GetStaticPropsContext type for Agility CMS.
* Adds the globalComponents array and getter methods for modules and page templates.
*
* @export
* @interface AgilityGetStaticPropsContext
* @extends {GetStaticPropsContext}
* @template Q
*/
export interface AgilityGetStaticPropsContext extends GetStaticPropsContext {
/**
* A dictionary of the global components (such as header/footer) that have a getCustomInitialProps method.
* Adding a component to this will add results of that method call to the globalData dictionary available in the page props
*
* @type {{ [ name: string ] : ComponentWithInit }}
* @memberof AgilityGetStaticPropsContext
*/
globalComponents?: {
[name: string]: ComponentWithInit;
};
/**
* A function that will return the component for a given module.
* If the component has a getCustomInitialProps method,
* that method will be called the result added to the customData dictionary available in the module props.
* This is OPTIONAL since we don't need it with app router implementations.
*
* @param {string} moduleName
* @returns {(FC | ClassicComponent)}
* @memberof AgilityGetStaticPropsContext
*/
getModule?: (moduleName: string) => ModuleWithInit | null;
apiOptions?: ApiOptions;
}
export interface AgilitySitemapNode {
title: string;
name: string;
pageID: number;
menuText: number;
visible: {
menu?: boolean;
sitemap?: boolean;
};
path: string;
redirect: string | null;
isFolder: false;
contentID?: number;
}
export interface AgilityPageProps {
sitemapNode: AgilitySitemapNode;
page?: Page;
dynamicPageItem?: any;
pageTemplateName?: string | null;
languageCode?: string | null;
channelName?: string | null;
isPreview?: boolean;
isDevelopmentMode?: boolean;
notFound?: boolean;
getModule?(moduleName: string): ModuleWithInit | null;
globalData?: {
[name: string]: any;
};
}
export interface CustomInitPropsArg {
item: any;
page: Page;
agility: ApiClientInstance;
languageCode: string;
channelName: string;
sitemapNode: AgilitySitemapNode;
dynamicPageItem?: any;
}
export interface GlobalCustomInitPropsArg {
page: Page;
agility: ApiClientInstance;
languageCode: string;
channelName: string;
sitemapNode: AgilitySitemapNode;
dynamicPageItem?: any;
}
export interface ModuleProps {
page: Page;
module: ContentItem;
languageCode: string;
channelName: string;
sitemapNode: AgilitySitemapNode;
dynamicPageItem?: ContentItem;
isDevelopmentMode: boolean;
isPreview: boolean;
globalData?: {
[name: string]: any;
};
}
export interface UnloadedModuleProps {
page: Page;
module: {
contentid: number;
};
languageCode: string;
channelName: string;
sitemapNode: AgilitySitemapNode;
dynamicPageItem?: ContentItem;
isDevelopmentMode: boolean;
isPreview: boolean;
globalData?: {
[name: string]: any;
};
}
export interface DynamicModuleProps {
page: Page;
module: ContentItem;
languageCode: string;
channelName: string;
sitemapNode: AgilitySitemapNode;
dynamicPageItem?: ContentItem;
globalData?: {
[name: string]: any;
};
}
export interface CustomInitProps extends ModuleProps {
customData: C;
}
export interface UnloadedModule extends FC {
}
export interface Module extends FC> {
}
export interface ModuleWithDynamic extends FC> {
}
/**
* A component used to render an Agility module that has an additional data access method called getCustomInitialProps
*
* @export
* @interface ModuleWithInit
* @extends {FC>}
* @template TProps The type of props object that the component expects
* @template TInit The type of object that will be returned by the getCustomInitialProps method
*/
export interface ModuleWithInit extends FC> {
getCustomInitialProps?(props: CustomInitPropsArg): Promise;
}
/**
* A component with an additional data access method called getCustomInitialProps
*
* @export
* @interface ComponentWithInit
* @extends {FC}
* @template TProps The type of props object that the component expects
* @template TInit The type of object that will be returned by the getCustomInitialProps method
*/
export interface ComponentWithInit extends FC {
getCustomInitialProps?(props: GlobalCustomInitPropsArg): Promise;
}
export interface ContentZoneProps {
name: string;
page: Page;
sitemapNode: AgilitySitemapNode;
dynamicPageItem?: any;
languageCode: string;
channelName: string;
getModule(moduleName: string): any;
isDevelopmentMode: boolean;
isPreview: boolean;
globalData?: {
[name: string]: any;
};
}
export interface Properties {
state: number;
modified: string;
versionID: number;
referenceName: string;
definitionName: string;
itemOrder: number;
}
export { ContentItem, ApiClientInstance };
export interface ImageField {
label: string;
url: string;
target: string;
filesize: number;
height: number;
width: number;
}
export interface URLField {
href: string;
target: string;
text: string;
}
export interface ApiOptions {
onSitemapRetrieved?: Function;
expandAllContentLinks?: boolean;
contentLinkDepth?: number;
}