@sitecore-jss/sitecore-jss-nextjs 21.7.0-canary.7 → 21.7.0-canary.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/NextImage.js +2 -10
- package/dist/cjs/components/RichText.js +2 -2
- package/dist/cjs/context/context.js +30 -10
- package/dist/cjs/editing/editing-config-middleware.js +49 -0
- package/dist/cjs/editing/editing-render-middleware.js +3 -16
- package/dist/cjs/editing/feaas-render-middleware.js +87 -0
- package/dist/cjs/editing/index.js +5 -1
- package/dist/cjs/editing/render-middleware.js +27 -0
- package/dist/cjs/graphql/index.js +2 -1
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/middleware/personalize-middleware.js +1 -1
- package/dist/cjs/middleware/redirects-middleware.js +24 -10
- package/dist/cjs/revalidate/index.js +5 -0
- package/dist/cjs/revalidate/revalidate-middleware.js +216 -0
- package/dist/cjs/utils/utils.js +6 -18
- package/dist/esm/components/NextImage.js +1 -8
- package/dist/esm/components/RichText.js +2 -2
- package/dist/esm/context/context.js +30 -10
- package/dist/esm/editing/editing-config-middleware.js +45 -0
- package/dist/esm/editing/editing-render-middleware.js +4 -17
- package/dist/esm/editing/feaas-render-middleware.js +83 -0
- package/dist/esm/editing/index.js +2 -0
- package/dist/esm/editing/render-middleware.js +23 -0
- package/dist/esm/graphql/index.js +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/middleware/personalize-middleware.js +1 -1
- package/dist/esm/middleware/redirects-middleware.js +24 -10
- package/dist/esm/revalidate/index.js +1 -0
- package/dist/esm/revalidate/revalidate-middleware.js +212 -0
- package/dist/esm/utils/utils.js +6 -15
- package/package.json +10 -11
- package/revalidate.d.ts +1 -0
- package/revalidate.js +1 -0
- package/types/components/NextImage.d.ts +1 -2
- package/types/context/context.d.ts +13 -1
- package/types/editing/editing-config-middleware.d.ts +29 -0
- package/types/editing/editing-render-middleware.d.ts +2 -11
- package/types/editing/feaas-render-middleware.d.ts +32 -0
- package/types/editing/index.d.ts +2 -0
- package/types/editing/render-middleware.d.ts +15 -0
- package/types/graphql/index.d.ts +1 -1
- package/types/index.d.ts +3 -3
- package/types/revalidate/index.d.ts +1 -0
- package/types/revalidate/revalidate-middleware.d.ts +115 -0
- package/types/utils/utils.d.ts +1 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { NextApiResponse, NextApiRequest } from 'next';
|
|
2
|
+
import { GraphQLRequestClientFactory } from '@sitecore-jss/sitecore-jss/graphql';
|
|
3
|
+
declare enum EntityDefinition {
|
|
4
|
+
LayoutData = "LayoutData",
|
|
5
|
+
Item = "Item"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Object model of each updated entity returned from the webhook payload
|
|
9
|
+
*/
|
|
10
|
+
export type Entity = {
|
|
11
|
+
identifier: string;
|
|
12
|
+
entity_definition: EntityDefinition;
|
|
13
|
+
operation: string;
|
|
14
|
+
entity_culture: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Object model for updated paths returned from the webhook payload
|
|
18
|
+
*/
|
|
19
|
+
export type UpdatedPaths = {
|
|
20
|
+
path: string;
|
|
21
|
+
language: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Object model for personalized results from GraphqlPersonalizeService
|
|
25
|
+
*/
|
|
26
|
+
export type PersonalizedResult = {
|
|
27
|
+
path: string;
|
|
28
|
+
variantId: string;
|
|
29
|
+
};
|
|
30
|
+
export type RevalidateConfig = {
|
|
31
|
+
/**
|
|
32
|
+
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
33
|
+
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
34
|
+
*/
|
|
35
|
+
clientFactory: GraphQLRequestClientFactory;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates whether multisite functionality is enabled.
|
|
38
|
+
* Default is false
|
|
39
|
+
*/
|
|
40
|
+
multiSite?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Indicates whether personalization is enabled.
|
|
43
|
+
* Default is false
|
|
44
|
+
*/
|
|
45
|
+
personalize?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Function to handle language prefixes for different locales.
|
|
48
|
+
* @param language - The language to generate the prefix for.
|
|
49
|
+
* @returns The language prefix or null.
|
|
50
|
+
*/
|
|
51
|
+
localePrefix?: (language: string) => string | null;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Middleware / handler for on-demand ISR (e.g. '/api/revalidate').
|
|
55
|
+
*/
|
|
56
|
+
export declare class RevalidateMiddleware {
|
|
57
|
+
protected config: RevalidateConfig;
|
|
58
|
+
private personalizeService;
|
|
59
|
+
constructor(config: RevalidateConfig);
|
|
60
|
+
/**
|
|
61
|
+
* Generates a Next.js API route handler that executes a revalidation process.
|
|
62
|
+
* @returns The route handler function for handling Next.js API requests.
|
|
63
|
+
*/
|
|
64
|
+
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Gets personalized results for the updated paths
|
|
67
|
+
* @param {UpdatedPaths[]} filteredUpdates Updated paths
|
|
68
|
+
*/
|
|
69
|
+
getPersonalizedResults(filteredUpdates: UpdatedPaths[]): Promise<{
|
|
70
|
+
personalized: PersonalizedResult[];
|
|
71
|
+
nonPersonalized: {
|
|
72
|
+
path: string;
|
|
73
|
+
}[];
|
|
74
|
+
}>;
|
|
75
|
+
protected isEmpty(data: UpdatedPaths[]): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Extracts the paths from the updated paths
|
|
78
|
+
* @param {UpdatedPaths[]} filteredUpdates Updated paths
|
|
79
|
+
* @returns {string[]} paths
|
|
80
|
+
*/
|
|
81
|
+
protected extractPaths(filteredUpdates: UpdatedPaths[]): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Gets the site name from the path name
|
|
84
|
+
* @param {string} pathname Path name
|
|
85
|
+
* @returns {string} site name
|
|
86
|
+
*/
|
|
87
|
+
protected getSiteName(pathname: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the path name from the full path
|
|
90
|
+
* @param {string} fullPath Full path
|
|
91
|
+
* @returns {string} path name
|
|
92
|
+
*/
|
|
93
|
+
protected getPathName(fullPath: string): string;
|
|
94
|
+
protected extractSiteName(path: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Filters out the updated paths and language from the request body
|
|
97
|
+
* @param {NextApiRequest} req Next.js API request
|
|
98
|
+
* @returns {UpdatedPaths[]} updated paths
|
|
99
|
+
*/
|
|
100
|
+
protected getFilteredUpdates(req: NextApiRequest): UpdatedPaths[];
|
|
101
|
+
protected handleMultiSitePersonalization(personalizeInfo: {
|
|
102
|
+
personalized: PersonalizedResult[];
|
|
103
|
+
nonPersonalized: {
|
|
104
|
+
path: string;
|
|
105
|
+
}[];
|
|
106
|
+
}, pathsToRevalidate: string[], getPathName: (x: string) => string, getSiteName: (x: string) => string): void;
|
|
107
|
+
protected handleNonMultiSitePersonalization(personalizeInfo: {
|
|
108
|
+
personalized: PersonalizedResult[];
|
|
109
|
+
nonPersonalized: {
|
|
110
|
+
path: string;
|
|
111
|
+
}[];
|
|
112
|
+
}, pathsToRevalidate: string[], getPathName: (x: string) => string): void;
|
|
113
|
+
private handler;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
package/types/utils/utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
|
|
6
6
|
* preview deployment has unique url, we don't know exact url.
|
|
7
7
|
* Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
|
|
8
|
+
* In production non-editing environments it is desirable to use relative urls, so in that case set PUBLIC_URL = ''
|
|
8
9
|
*/
|
|
9
10
|
export declare const getPublicUrl: () => string;
|
|
10
11
|
/**
|