@sitecore-jss/sitecore-jss-nextjs 22.9.0-canary.9 → 22.9.1-canary.1

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.
@@ -54,9 +54,6 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
54
54
  }
55
55
  results {
56
56
  path: routePath
57
- route {
58
- displayName
59
- }
60
57
  ${usesPersonalize
61
58
  ? `
62
59
  route {
@@ -83,10 +80,8 @@ class BaseGraphQLSitemapService {
83
80
  * @param {GraphQLSitemapServiceConfig} options instance
84
81
  */
85
82
  constructor(options) {
86
- var _a;
87
83
  this.options = options;
88
84
  this._graphQLClient = this.getGraphQLClient();
89
- this._enableDisplayNameRouting = (_a = options.enableDisplayNameRouting) !== null && _a !== void 0 ? _a : false;
90
85
  }
91
86
  /**
92
87
  * GraphQL client accessible by descendant classes when needed
@@ -150,90 +145,21 @@ class BaseGraphQLSitemapService {
150
145
  }
151
146
  transformLanguageSitePaths(sitePaths, formatStaticPath, language) {
152
147
  return __awaiter(this, void 0, void 0, function* () {
153
- var _a, _b, _c, _d;
148
+ const toSegments = (p) => decodeURI(p)
149
+ .replace(/^\/|\/$/g, '')
150
+ .split('/');
154
151
  const aggregatedPaths = [];
155
- /**
156
- * Build a map of the last segment of each path to its encoded display name.
157
- * This is used later to substitute the final segment with a display name if available.
158
- */
159
- const displayNameMap = new Map();
160
- if (this._enableDisplayNameRouting) {
161
- for (const item of sitePaths) {
162
- if (!item || typeof item.path !== 'string')
163
- continue;
164
- const segments = item.path.replace(/^\/|\/$/g, '').split('/');
165
- const lastSegment = segments[segments.length - 1];
166
- const displayName = (_a = item.route) === null || _a === void 0 ? void 0 : _a.displayName;
167
- if (displayName) {
168
- displayNameMap.set(lastSegment, encodeURIComponent(displayName));
169
- }
170
- }
171
- }
172
- /**
173
- * Recursively generate all path combinations using either:
174
- * - The item name segment (default)
175
- * - Or the display name (if available in the map)
176
- *
177
- * For example: if path is ['about', 'team'] and displayName for 'team' is 'Team-Page',
178
- * it will generate:
179
- * - ['about', 'team']
180
- * - ['about', 'Team-Page']
181
- * @param {string[]} segments
182
- */
183
- const generateCombinations = (segments) => {
184
- if (!this._enableDisplayNameRouting) {
185
- return [segments];
186
- }
187
- const results = [];
188
- const helper = (index, current) => {
189
- if (index === segments.length) {
190
- results.push([...current]);
191
- return;
192
- }
193
- const segment = segments[index];
194
- const display = displayNameMap.get(segment);
195
- // Item name segment
196
- current.push(segment);
197
- helper(index + 1, current);
198
- current.pop();
199
- // Display name segment (if available and different)
200
- if (display && display !== segment) {
201
- current.push(display);
202
- helper(index + 1, current);
203
- current.pop();
204
- }
205
- };
206
- helper(0, []);
207
- return results;
208
- };
209
- /**
210
- * Process each route in the result set to:
211
- * - Add itemName-based and displayName-based paths
212
- * - Add personalized variants (if applicable) for each of those paths
213
- */
214
- for (const item of sitePaths) {
215
- if (!item || typeof item.path !== 'string')
216
- continue;
217
- const itemPath = item.path.replace(/^\/|\/$/g, '');
218
- const segments = itemPath ? itemPath.split('/') : [];
219
- // Generate all display/item name path combinations
220
- const allCombinations = generateCombinations(segments);
221
- // Add plain paths to the aggregated paths list
222
- for (const combo of allCombinations) {
223
- aggregatedPaths.push(formatStaticPath(combo, language));
224
- }
225
- // Check for personalization variants
226
- const variantIds = (_d = (_c = (_b = item.route) === null || _b === void 0 ? void 0 : _b.personalization) === null || _c === void 0 ? void 0 : _c.variantIds) === null || _d === void 0 ? void 0 : _d.filter((variantId) => !variantId.includes('_'));
152
+ sitePaths.forEach((item) => {
153
+ var _a, _b, _c;
154
+ if (!item)
155
+ return;
156
+ aggregatedPaths.push(formatStaticPath(toSegments(item.path), language));
157
+ const variantIds = (_c = (_b = (_a = item.route) === null || _a === void 0 ? void 0 : _a.personalization) === null || _b === void 0 ? void 0 : _b.variantIds) === null || _c === void 0 ? void 0 : _c.filter((variantId) => !variantId.includes('_') // exclude component A/B test
158
+ );
227
159
  if (variantIds === null || variantIds === void 0 ? void 0 : variantIds.length) {
228
- for (const variantId of variantIds) {
229
- for (const combo of allCombinations) {
230
- const rewritePath = (0, personalize_1.getPersonalizedRewrite)('/' + combo.join('/'), [variantId]);
231
- const variantSegments = rewritePath.replace(/^\/|\/$/g, '').split('/');
232
- aggregatedPaths.push(formatStaticPath(variantSegments, language));
233
- }
234
- }
160
+ aggregatedPaths.push(...variantIds.map((varId) => formatStaticPath(toSegments((0, personalize_1.getPersonalizedRewrite)(item.path, [varId])), language)));
235
161
  }
236
- }
162
+ });
237
163
  return aggregatedPaths;
238
164
  });
239
165
  }
@@ -50,9 +50,6 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
50
50
  }
51
51
  results {
52
52
  path: routePath
53
- route {
54
- displayName
55
- }
56
53
  ${usesPersonalize
57
54
  ? `
58
55
  route {
@@ -79,10 +76,8 @@ export class BaseGraphQLSitemapService {
79
76
  * @param {GraphQLSitemapServiceConfig} options instance
80
77
  */
81
78
  constructor(options) {
82
- var _a;
83
79
  this.options = options;
84
80
  this._graphQLClient = this.getGraphQLClient();
85
- this._enableDisplayNameRouting = (_a = options.enableDisplayNameRouting) !== null && _a !== void 0 ? _a : false;
86
81
  }
87
82
  /**
88
83
  * GraphQL client accessible by descendant classes when needed
@@ -146,90 +141,21 @@ export class BaseGraphQLSitemapService {
146
141
  }
147
142
  transformLanguageSitePaths(sitePaths, formatStaticPath, language) {
148
143
  return __awaiter(this, void 0, void 0, function* () {
149
- var _a, _b, _c, _d;
144
+ const toSegments = (p) => decodeURI(p)
145
+ .replace(/^\/|\/$/g, '')
146
+ .split('/');
150
147
  const aggregatedPaths = [];
151
- /**
152
- * Build a map of the last segment of each path to its encoded display name.
153
- * This is used later to substitute the final segment with a display name if available.
154
- */
155
- const displayNameMap = new Map();
156
- if (this._enableDisplayNameRouting) {
157
- for (const item of sitePaths) {
158
- if (!item || typeof item.path !== 'string')
159
- continue;
160
- const segments = item.path.replace(/^\/|\/$/g, '').split('/');
161
- const lastSegment = segments[segments.length - 1];
162
- const displayName = (_a = item.route) === null || _a === void 0 ? void 0 : _a.displayName;
163
- if (displayName) {
164
- displayNameMap.set(lastSegment, encodeURIComponent(displayName));
165
- }
166
- }
167
- }
168
- /**
169
- * Recursively generate all path combinations using either:
170
- * - The item name segment (default)
171
- * - Or the display name (if available in the map)
172
- *
173
- * For example: if path is ['about', 'team'] and displayName for 'team' is 'Team-Page',
174
- * it will generate:
175
- * - ['about', 'team']
176
- * - ['about', 'Team-Page']
177
- * @param {string[]} segments
178
- */
179
- const generateCombinations = (segments) => {
180
- if (!this._enableDisplayNameRouting) {
181
- return [segments];
182
- }
183
- const results = [];
184
- const helper = (index, current) => {
185
- if (index === segments.length) {
186
- results.push([...current]);
187
- return;
188
- }
189
- const segment = segments[index];
190
- const display = displayNameMap.get(segment);
191
- // Item name segment
192
- current.push(segment);
193
- helper(index + 1, current);
194
- current.pop();
195
- // Display name segment (if available and different)
196
- if (display && display !== segment) {
197
- current.push(display);
198
- helper(index + 1, current);
199
- current.pop();
200
- }
201
- };
202
- helper(0, []);
203
- return results;
204
- };
205
- /**
206
- * Process each route in the result set to:
207
- * - Add itemName-based and displayName-based paths
208
- * - Add personalized variants (if applicable) for each of those paths
209
- */
210
- for (const item of sitePaths) {
211
- if (!item || typeof item.path !== 'string')
212
- continue;
213
- const itemPath = item.path.replace(/^\/|\/$/g, '');
214
- const segments = itemPath ? itemPath.split('/') : [];
215
- // Generate all display/item name path combinations
216
- const allCombinations = generateCombinations(segments);
217
- // Add plain paths to the aggregated paths list
218
- for (const combo of allCombinations) {
219
- aggregatedPaths.push(formatStaticPath(combo, language));
220
- }
221
- // Check for personalization variants
222
- const variantIds = (_d = (_c = (_b = item.route) === null || _b === void 0 ? void 0 : _b.personalization) === null || _c === void 0 ? void 0 : _c.variantIds) === null || _d === void 0 ? void 0 : _d.filter((variantId) => !variantId.includes('_'));
148
+ sitePaths.forEach((item) => {
149
+ var _a, _b, _c;
150
+ if (!item)
151
+ return;
152
+ aggregatedPaths.push(formatStaticPath(toSegments(item.path), language));
153
+ const variantIds = (_c = (_b = (_a = item.route) === null || _a === void 0 ? void 0 : _a.personalization) === null || _b === void 0 ? void 0 : _b.variantIds) === null || _c === void 0 ? void 0 : _c.filter((variantId) => !variantId.includes('_') // exclude component A/B test
154
+ );
223
155
  if (variantIds === null || variantIds === void 0 ? void 0 : variantIds.length) {
224
- for (const variantId of variantIds) {
225
- for (const combo of allCombinations) {
226
- const rewritePath = getPersonalizedRewrite('/' + combo.join('/'), [variantId]);
227
- const variantSegments = rewritePath.replace(/^\/|\/$/g, '').split('/');
228
- aggregatedPaths.push(formatStaticPath(variantSegments, language));
229
- }
230
- }
156
+ aggregatedPaths.push(...variantIds.map((varId) => formatStaticPath(toSegments(getPersonalizedRewrite(item.path, [varId])), language)));
231
157
  }
232
- }
158
+ });
233
159
  return aggregatedPaths;
234
160
  });
235
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "22.9.0-canary.9",
3
+ "version": "22.9.1-canary.1",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -72,16 +72,16 @@
72
72
  "react-dom": "^19.1.0"
73
73
  },
74
74
  "dependencies": {
75
- "@sitecore-jss/sitecore-jss": "22.9.0-canary.9",
76
- "@sitecore-jss/sitecore-jss-dev-tools": "22.9.0-canary.9",
77
- "@sitecore-jss/sitecore-jss-react": "22.9.0-canary.9",
75
+ "@sitecore-jss/sitecore-jss": "22.9.1-canary.1",
76
+ "@sitecore-jss/sitecore-jss-dev-tools": "22.9.1-canary.1",
77
+ "@sitecore-jss/sitecore-jss-react": "22.9.1-canary.1",
78
78
  "@vercel/kv": "^0.2.1",
79
79
  "regex-parser": "^2.2.11",
80
80
  "sync-disk-cache": "^2.1.0"
81
81
  },
82
82
  "description": "",
83
83
  "types": "types/index.d.ts",
84
- "gitHead": "0a43b0e00378ba1dcfeb30c18971d98da017fe0a",
84
+ "gitHead": "37948499e02360fcf6e7f262d241444451bda07d",
85
85
  "files": [
86
86
  "dist",
87
87
  "types",
@@ -58,7 +58,6 @@ export interface SiteRouteQueryResult<T> {
58
58
  export type RouteListQueryResult = {
59
59
  path: string;
60
60
  route?: {
61
- displayName: string;
62
61
  personalization?: {
63
62
  variantIds: string[];
64
63
  };
@@ -74,10 +73,6 @@ export interface BaseGraphQLSitemapServiceConfig extends Omit<SiteRouteQueryVari
74
73
  * Turned off by default.
75
74
  */
76
75
  includePersonalizedRoutes?: boolean;
77
- /**
78
- * Gets a flag indicating whether display name routing is enabled.
79
- */
80
- enableDisplayNameRouting?: boolean;
81
76
  /**
82
77
  * A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
83
78
  * This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
@@ -102,7 +97,6 @@ export type StaticPath = {
102
97
  export declare abstract class BaseGraphQLSitemapService {
103
98
  options: BaseGraphQLSitemapServiceConfig;
104
99
  private _graphQLClient;
105
- private _enableDisplayNameRouting;
106
100
  /**
107
101
  * Creates an instance of graphQL sitemap service with the provided options
108
102
  * @param {GraphQLSitemapServiceConfig} options instance