@uniformdev/canvas-next 19.69.0 → 19.71.1-alpha.103

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.
@@ -1,12 +1,12 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, GetServerSidePropsResult, GetServerSideProps, GetStaticPropsContext, GetStaticPropsResult, GetStaticProps } from 'next';
3
- import { a as UniformPreviewData } from '../models-f9fd03c4.js';
3
+ import { a as UniformPreviewData } from '../models--s4UGr5M.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
- export { w as withUniformGetStaticPaths } from '../withUniformGetStaticPaths-77db0164.js';
7
6
  import { RouteGetResponseEdgehancedComposition, RouteGetResponseNotFound, RouteGetResponseRedirect, RouteClient, RouteGetParameters, RootComponentInstance } from '@uniformdev/canvas';
7
+ import { ProjectMapNodeGetResponse, ProjectMapClient } from '@uniformdev/project-map';
8
+ import { RedirectClient } from '@uniformdev/redirect';
8
9
  import '@uniformdev/canvas-react';
9
- import '@uniformdev/project-map';
10
10
 
11
11
  type HandleRouteCompositionFunction<TContext, TResult> = (composition: RouteGetResponseEdgehancedComposition, context: TContext, defaultHandler: (composition: RouteGetResponseEdgehancedComposition) => Promise<TResult | null> | TResult | null, duration: number) => Promise<TResult | null> | TResult | null;
12
12
  type HandleRouteNotFoundFunction<TContext, TResult> = (result: RouteGetResponseNotFound, context: TContext, defaultHandler: (result: RouteGetResponseNotFound) => TResult, duration: number) => TResult;
@@ -46,6 +46,44 @@ declare const withUniformGetServerSideProps: <TProps extends {
46
46
  data: RootComponentInstance;
47
47
  }>(options?: RouteHandlerOptions<GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData>, GetServerSidePropsResult<never>, GetServerSidePropsResult<TProps>> | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
48
48
 
49
+ declare const withUniformGetStaticPaths: (options?: {
50
+ projectMapId?: string | undefined;
51
+ /** Starting path to fetch nodes from */
52
+ rootPath?: string | undefined;
53
+ /** A string that you want prepended to paths returned by your project map. Useful when calling from a nested folder which is not part of your project map structure */
54
+ prefix?: string | undefined;
55
+ /** Set to true if you want to include draft compositions */
56
+ preview?: boolean | undefined;
57
+ /** Way to override getNodes request params */
58
+ requestOptions?: Partial<{
59
+ projectMapId?: string | undefined;
60
+ projectId: string;
61
+ id?: string | undefined;
62
+ path?: string | undefined;
63
+ compositionId?: string | undefined;
64
+ limit?: number | undefined;
65
+ offset?: number | undefined;
66
+ depth?: number | undefined;
67
+ state?: number | undefined;
68
+ tree?: boolean | undefined;
69
+ search?: string | undefined;
70
+ includeAncestors?: boolean | undefined;
71
+ expanded?: boolean | undefined;
72
+ withCompositionData?: boolean | undefined;
73
+ withCompositionUIStatus?: boolean | undefined;
74
+ withRedirectData?: boolean | undefined;
75
+ }> | undefined;
76
+ /** Way to modify list of nodes before building array of paths */
77
+ callback?: ((nodes: ProjectMapNodeGetResponse['nodes']) => Promise<ProjectMapNodeGetResponse['nodes']>) | undefined;
78
+ /** If you need to override the default client, you can pass it here */
79
+ client?: ProjectMapClient | undefined;
80
+ /** If you need to override the default redirect client, you can pass it here */
81
+ redirectClient?: RedirectClient | undefined;
82
+ } | undefined) => () => Promise<{
83
+ paths: string[];
84
+ fallback: boolean;
85
+ }>;
86
+
49
87
  /**
50
88
  * Creates an implementation of `getStaticProps` using the Uniform Route API.
51
89
  * Static and dynamic routing as well as redirection is automatically supported.
@@ -70,12 +108,15 @@ declare const getServerSideProps: next.GetServerSideProps<{
70
108
  type: string;
71
109
  parameters?: {
72
110
  [key: string]: {
73
- value: unknown;
111
+ value?: unknown;
74
112
  type: string;
75
113
  connectedData?: {
76
114
  pointer: string;
77
115
  syntax: "jptr";
78
116
  } | undefined;
117
+ locales?: {
118
+ [key: string]: unknown;
119
+ } | undefined;
79
120
  };
80
121
  } | undefined;
81
122
  variant?: string | undefined;
@@ -89,12 +130,15 @@ declare const getServerSideProps: next.GetServerSideProps<{
89
130
  type: string;
90
131
  parameters?: {
91
132
  [key: string]: {
92
- value: unknown;
133
+ value?: unknown;
93
134
  type: string;
94
135
  connectedData?: {
95
136
  pointer: string;
96
137
  syntax: "jptr";
97
138
  } | undefined;
139
+ locales?: {
140
+ [key: string]: unknown;
141
+ } | undefined;
98
142
  };
99
143
  } | undefined;
100
144
  variant?: string | undefined;
@@ -128,12 +172,15 @@ declare const getServerSideProps: next.GetServerSideProps<{
128
172
  [key: string]: {
129
173
  parameters?: {
130
174
  [key: string]: {
131
- value: unknown;
175
+ value?: unknown;
132
176
  type: string;
133
177
  connectedData?: {
134
178
  pointer: string;
135
179
  syntax: "jptr";
136
180
  } | undefined;
181
+ locales?: {
182
+ [key: string]: unknown;
183
+ } | undefined;
137
184
  };
138
185
  } | undefined;
139
186
  variant?: string | undefined;
@@ -164,12 +211,15 @@ declare const getServerSideProps: next.GetServerSideProps<{
164
211
  [key: string]: {
165
212
  parameters?: {
166
213
  [key: string]: {
167
- value: unknown;
214
+ value?: unknown;
168
215
  type: string;
169
216
  connectedData?: {
170
217
  pointer: string;
171
218
  syntax: "jptr";
172
219
  } | undefined;
220
+ locales?: {
221
+ [key: string]: unknown;
222
+ } | undefined;
173
223
  };
174
224
  } | undefined;
175
225
  variant?: string | undefined;
@@ -181,9 +231,9 @@ declare const getServerSideProps: next.GetServerSideProps<{
181
231
  } | undefined;
182
232
  variants?: boolean | undefined;
183
233
  } | undefined;
234
+ _locales?: string[] | undefined;
184
235
  };
185
236
  }, querystring.ParsedUrlQuery, UniformPreviewData>;
186
-
187
237
  /**
188
238
  * Default implementation of getStaticProps with routes
189
239
  * To configure custom behavior, use:
@@ -194,12 +244,15 @@ declare const getStaticProps: next.GetStaticProps<{
194
244
  type: string;
195
245
  parameters?: {
196
246
  [key: string]: {
197
- value: unknown;
247
+ value?: unknown;
198
248
  type: string;
199
249
  connectedData?: {
200
250
  pointer: string;
201
251
  syntax: "jptr";
202
252
  } | undefined;
253
+ locales?: {
254
+ [key: string]: unknown;
255
+ } | undefined;
203
256
  };
204
257
  } | undefined;
205
258
  variant?: string | undefined;
@@ -213,12 +266,15 @@ declare const getStaticProps: next.GetStaticProps<{
213
266
  type: string;
214
267
  parameters?: {
215
268
  [key: string]: {
216
- value: unknown;
269
+ value?: unknown;
217
270
  type: string;
218
271
  connectedData?: {
219
272
  pointer: string;
220
273
  syntax: "jptr";
221
274
  } | undefined;
275
+ locales?: {
276
+ [key: string]: unknown;
277
+ } | undefined;
222
278
  };
223
279
  } | undefined;
224
280
  variant?: string | undefined;
@@ -252,12 +308,15 @@ declare const getStaticProps: next.GetStaticProps<{
252
308
  [key: string]: {
253
309
  parameters?: {
254
310
  [key: string]: {
255
- value: unknown;
311
+ value?: unknown;
256
312
  type: string;
257
313
  connectedData?: {
258
314
  pointer: string;
259
315
  syntax: "jptr";
260
316
  } | undefined;
317
+ locales?: {
318
+ [key: string]: unknown;
319
+ } | undefined;
261
320
  };
262
321
  } | undefined;
263
322
  variant?: string | undefined;
@@ -288,12 +347,15 @@ declare const getStaticProps: next.GetStaticProps<{
288
347
  [key: string]: {
289
348
  parameters?: {
290
349
  [key: string]: {
291
- value: unknown;
350
+ value?: unknown;
292
351
  type: string;
293
352
  connectedData?: {
294
353
  pointer: string;
295
354
  syntax: "jptr";
296
355
  } | undefined;
356
+ locales?: {
357
+ [key: string]: unknown;
358
+ } | undefined;
297
359
  };
298
360
  } | undefined;
299
361
  variant?: string | undefined;
@@ -305,6 +367,7 @@ declare const getStaticProps: next.GetStaticProps<{
305
367
  } | undefined;
306
368
  variants?: boolean | undefined;
307
369
  } | undefined;
370
+ _locales?: string[] | undefined;
308
371
  };
309
372
  }, querystring.ParsedUrlQuery, UniformPreviewData>;
310
373
  /**
@@ -315,8 +378,8 @@ declare const getStaticProps: next.GetStaticProps<{
315
378
  * NOTE: fallback must be supported. You cannot generate static paths for dynamic routes which contain query parameters.
316
379
  */
317
380
  declare const getStaticPaths: () => Promise<{
318
- paths: string[] | undefined;
381
+ paths: string[];
319
382
  fallback: boolean;
320
383
  }>;
321
384
 
322
- export { HandleRouteCompositionFunction, HandleRouteNotFoundFunction, HandleRouteRedirectFunction, RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticProps };
385
+ export { type HandleRouteCompositionFunction, type HandleRouteNotFoundFunction, type HandleRouteRedirectFunction, type RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
@@ -20,17 +20,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/route/index.ts
21
21
  var route_exports = {};
22
22
  __export(route_exports, {
23
- getServerSideProps: () => getServerSideProps2,
24
- getStaticPaths: () => getStaticPaths2,
25
- getStaticProps: () => getStaticProps2,
26
- withUniformGetServerSideProps: () => withUniformGetServerSideProps2,
23
+ getServerSideProps: () => getServerSideProps,
24
+ getStaticPaths: () => getStaticPaths,
25
+ getStaticProps: () => getStaticProps,
26
+ withUniformGetServerSideProps: () => withUniformGetServerSideProps,
27
27
  withUniformGetStaticPaths: () => withUniformGetStaticPaths,
28
- withUniformGetStaticProps: () => withUniformGetStaticProps2
28
+ withUniformGetStaticProps: () => withUniformGetStaticProps
29
29
  });
30
30
  module.exports = __toCommonJS(route_exports);
31
31
 
32
- // src/project-map/withUniformGetServerSideProps.ts
32
+ // src/route/withUniformGetServerSideProps.ts
33
+ var import_canvas2 = require("@uniformdev/canvas");
34
+ var import_redirect = require("@uniformdev/redirect");
35
+
36
+ // src/route/createRouteFetcher.ts
33
37
  var import_canvas = require("@uniformdev/canvas");
38
+ var import_colorette6 = require("colorette");
34
39
 
35
40
  // src/logging/logCompositionIssues.ts
36
41
  var import_colorette = require("colorette");
@@ -183,163 +188,7 @@ function logRouteResponse(response, duration) {
183
188
  logRouteCompositionResponse(response, duration);
184
189
  }
185
190
 
186
- // src/project-map/withUniformGetServerSideProps.ts
187
- var withUniformGetServerSideProps = (options) => {
188
- const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
189
- apiKey: process.env.UNIFORM_API_KEY,
190
- projectId: process.env.UNIFORM_PROJECT_ID,
191
- apiHost: process.env.UNIFORM_CLI_BASE_URL,
192
- edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
193
- });
194
- return async function wrappedGetServerSideProps(context) {
195
- var _a, _b;
196
- const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
197
- const { preview, previewData } = context;
198
- let composition = void 0;
199
- let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
200
- if (options == null ? void 0 : options.modifyPath) {
201
- nodePath = options.modifyPath(nodePath, context);
202
- }
203
- if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
204
- composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas.EMPTY_COMPOSITION._id };
205
- } else {
206
- try {
207
- const time = Date.now();
208
- const response = await canvasClient.getCompositionByNodePath({
209
- ...options == null ? void 0 : options.requestOptions,
210
- projectMapId,
211
- projectMapNodePath: nodePath,
212
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
213
- });
214
- const duration = Date.now() - time;
215
- composition = response.composition;
216
- if (!(options == null ? void 0 : options.silent)) {
217
- logCompositionResponse(response, duration);
218
- }
219
- } catch (e) {
220
- console.error("[canvas-next] Failed to fetch composition", e);
221
- return {
222
- notFound: true
223
- };
224
- }
225
- }
226
- const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
227
- if (Object.hasOwn(ret, "props")) {
228
- const casted = ret;
229
- casted.props["data"] = composition;
230
- }
231
- return ret;
232
- };
233
- };
234
-
235
- // src/project-map/withUniformGetStaticPaths.ts
236
- var import_canvas2 = require("@uniformdev/canvas");
237
- var import_project_map = require("@uniformdev/project-map");
238
- var withUniformGetStaticPaths = (options) => {
239
- return async function wrappedGetStaticPaths() {
240
- var _a, _b;
241
- const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
242
- const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new import_project_map.ProjectMapClient({
243
- apiKey: process.env.UNIFORM_API_KEY,
244
- projectId: process.env.UNIFORM_PROJECT_ID,
245
- apiHost: process.env.UNIFORM_CLI_BASE_URL
246
- });
247
- const response = await projectMapClient.getNodes({
248
- ...options == null ? void 0 : options.requestOptions,
249
- path: options == null ? void 0 : options.rootPath,
250
- projectMapId,
251
- state: (options == null ? void 0 : options.preview) ? import_canvas2.CANVAS_DRAFT_STATE : import_canvas2.CANVAS_PUBLISHED_STATE
252
- });
253
- const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
254
- const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
255
- var _a2;
256
- return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
257
- });
258
- return {
259
- paths,
260
- fallback: true
261
- };
262
- };
263
- };
264
-
265
- // src/project-map/withUniformGetStaticProps.ts
266
- var import_canvas3 = require("@uniformdev/canvas");
267
-
268
- // src/helpers/resolveSlugFromParams.ts
269
- var resolveSlugFromParams = ({
270
- param = "slug",
271
- params
272
- }) => {
273
- const slug = (params == null ? void 0 : params[param]) || "";
274
- const slugString = Array.isArray(slug) ? slug.join("/") : slug;
275
- return `/${slugString}`;
276
- };
277
-
278
- // src/project-map/withUniformGetStaticProps.ts
279
- var withUniformGetStaticProps = (options) => {
280
- var _a;
281
- const canvasClient = (_a = options == null ? void 0 : options.client) != null ? _a : new import_canvas3.CanvasClient({
282
- apiKey: process.env.UNIFORM_API_KEY,
283
- projectId: process.env.UNIFORM_PROJECT_ID,
284
- apiHost: process.env.UNIFORM_CLI_BASE_URL,
285
- edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
286
- });
287
- return async function wrappedGetStaticProps(context) {
288
- var _a2, _b;
289
- const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
290
- let pathString = resolveSlugFromParams({
291
- param: options == null ? void 0 : options.param,
292
- params: context == null ? void 0 : context.params
293
- });
294
- if (options == null ? void 0 : options.modifyPath) {
295
- pathString = options.modifyPath(pathString, context);
296
- }
297
- const { preview, previewData } = context;
298
- let composition = void 0;
299
- if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
300
- composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas3.EMPTY_COMPOSITION._id };
301
- } else {
302
- try {
303
- const time = Date.now();
304
- const response = await canvasClient.getCompositionByNodePath({
305
- ...options == null ? void 0 : options.requestOptions,
306
- projectMapId,
307
- projectMapNodePath: pathString,
308
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
309
- });
310
- const duration = Date.now() - time;
311
- composition = response.composition;
312
- if (!(options == null ? void 0 : options.silent)) {
313
- logCompositionResponse(response, duration);
314
- }
315
- } catch (e) {
316
- console.error("[canvas-next] Failed to fetch composition", e);
317
- return {
318
- notFound: true
319
- };
320
- }
321
- }
322
- const ret = options.callback ? await options.callback(context, composition) : { props: {} };
323
- if (composition && Object.hasOwn(ret, "props")) {
324
- const casted = ret;
325
- casted.props["data"] = composition;
326
- }
327
- return ret;
328
- };
329
- };
330
-
331
- // src/project-map/index.ts
332
- var getServerSideProps = withUniformGetServerSideProps();
333
- var getStaticProps = withUniformGetStaticProps({ param: "path" });
334
- var getStaticPaths = withUniformGetStaticPaths();
335
-
336
- // src/route/withUniformGetServerSideProps.ts
337
- var import_canvas5 = require("@uniformdev/canvas");
338
- var import_redirect = require("@uniformdev/redirect");
339
-
340
191
  // src/route/createRouteFetcher.ts
341
- var import_canvas4 = require("@uniformdev/canvas");
342
- var import_colorette6 = require("colorette");
343
192
  function createRouteFetcher(options) {
344
193
  const {
345
194
  handleNotFound,
@@ -356,7 +205,7 @@ function createRouteFetcher(options) {
356
205
  silent,
357
206
  parseContext
358
207
  } = options;
359
- const routeClient = client || new import_canvas4.RouteClient({
208
+ const routeClient = client || new import_canvas.RouteClient({
360
209
  apiKey: process.env.UNIFORM_API_KEY,
361
210
  projectId: process.env.UNIFORM_PROJECT_ID,
362
211
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
@@ -419,8 +268,8 @@ function createRouteFetcher(options) {
419
268
  matchedRoute: "contextual-editing",
420
269
  compositionApiResponse: {
421
270
  composition: {
422
- ...import_canvas4.EMPTY_COMPOSITION,
423
- _id: contextualEditingCompositionId != null ? contextualEditingCompositionId : import_canvas4.EMPTY_COMPOSITION._id
271
+ ...import_canvas.EMPTY_COMPOSITION,
272
+ _id: contextualEditingCompositionId != null ? contextualEditingCompositionId : import_canvas.EMPTY_COMPOSITION._id
424
273
  }
425
274
  }
426
275
  },
@@ -436,7 +285,7 @@ function createRouteFetcher(options) {
436
285
  const time = Date.now();
437
286
  const response = await routeClient.getRoute({
438
287
  ...resolvedOptions,
439
- state: (_b = (_a = resolvedOptions == null ? void 0 : resolvedOptions.state) != null ? _a : defaultPreviewState) != null ? _b : import_canvas4.CANVAS_PUBLISHED_STATE,
288
+ state: (_b = (_a = resolvedOptions == null ? void 0 : resolvedOptions.state) != null ? _a : defaultPreviewState) != null ? _b : import_canvas.CANVAS_PUBLISHED_STATE,
440
289
  projectMapId,
441
290
  path: nodePath
442
291
  });
@@ -457,7 +306,7 @@ function createRouteFetcher(options) {
457
306
  return handleResult;
458
307
  } catch (e) {
459
308
  console.error((0, import_colorette6.red)("Failed to fetch route"), e);
460
- if (e instanceof import_canvas4.ApiClientError) {
309
+ if (e instanceof import_canvas.ApiClientError) {
461
310
  if (e.statusCode === 404) {
462
311
  return invokeNotFoundResult({ type: "notFound" }, 0);
463
312
  }
@@ -470,7 +319,7 @@ function createRouteFetcher(options) {
470
319
  }
471
320
 
472
321
  // src/route/withUniformGetServerSideProps.ts
473
- var withUniformGetServerSideProps2 = (options) => {
322
+ var withUniformGetServerSideProps = (options) => {
474
323
  const defaultHandleRedirect = (requestUrl, matched, context) => {
475
324
  if (matched.redirect.targetStatusCode > 400) {
476
325
  return {
@@ -480,8 +329,9 @@ var withUniformGetServerSideProps2 = (options) => {
480
329
  const absoluteUrl = `${context.req.headers["x-forwarded-proto"]}://${context.req.headers.host}${requestUrl}`;
481
330
  return {
482
331
  redirect: {
483
- destination: import_redirect.RedirectClient.getTargetVariableExpandedUrl(absoluteUrl, matched.redirect),
484
- statusCode: matched.redirect.targetStatusCode
332
+ destination: (0, import_redirect.getTargetVariableExpandedUrl)(absoluteUrl, matched.redirect),
333
+ statusCode: matched.redirect.targetStatusCode,
334
+ basePath: matched.redirect.targetPreserveIncomingDomain === false || matched.redirect.targetPreserveIncomingProtocol === false ? false : void 0
485
335
  }
486
336
  };
487
337
  };
@@ -507,21 +357,87 @@ var withUniformGetServerSideProps2 = (options) => {
507
357
  resolvedUrl: context.resolvedUrl,
508
358
  // auto engage draft content when in next preview mode
509
359
  // (can override with explicit setting of request options)'
510
- defaultFetchState: context.preview ? import_canvas5.CANVAS_DRAFT_STATE : void 0
360
+ defaultFetchState: context.preview ? import_canvas2.CANVAS_DRAFT_STATE : void 0
511
361
  };
512
362
  }
513
363
  });
514
364
  return routeFetcher;
515
365
  };
516
366
 
517
- // src/route/withUniformGetStaticProps.ts
518
- var import_canvas6 = require("@uniformdev/canvas");
367
+ // src/route/withUniformGetStaticPaths.ts
368
+ var import_canvas3 = require("@uniformdev/canvas");
369
+ var import_project_map = require("@uniformdev/project-map");
519
370
  var import_redirect2 = require("@uniformdev/redirect");
520
- var withUniformGetStaticProps2 = (options) => {
371
+ var findChildRedirects = async (allRedirects, parentPath) => {
372
+ const children = [];
373
+ let redirect = await allRedirects.next();
374
+ while (!redirect.done) {
375
+ const index = parentPath ? redirect.value.redirect.sourceUrl.indexOf(parentPath) : 0;
376
+ if (index > -1) {
377
+ children.push(redirect.value);
378
+ }
379
+ redirect = await allRedirects.next();
380
+ }
381
+ return children;
382
+ };
383
+ var withUniformGetStaticPaths = (options) => {
384
+ return async function wrappedGetStaticPaths() {
385
+ var _a, _b, _c;
386
+ const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
387
+ const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new import_project_map.ProjectMapClient({
388
+ apiKey: process.env.UNIFORM_API_KEY,
389
+ projectId: process.env.UNIFORM_PROJECT_ID,
390
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
391
+ });
392
+ const finalRedirectClient = (_c = options == null ? void 0 : options.redirectClient) != null ? _c : new import_redirect2.RedirectClient({
393
+ apiKey: process.env.UNIFORM_API_KEY,
394
+ projectId: process.env.UNIFORM_PROJECT_ID,
395
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
396
+ });
397
+ const [response, redirectResponse] = await Promise.all([
398
+ projectMapClient.getNodes({
399
+ ...options == null ? void 0 : options.requestOptions,
400
+ path: options == null ? void 0 : options.rootPath,
401
+ projectMapId,
402
+ state: (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
403
+ }),
404
+ finalRedirectClient.getAllRedirects()
405
+ ]);
406
+ const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
407
+ const redirectSources = (await findChildRedirects(redirectResponse, options == null ? void 0 : options.rootPath)).map(
408
+ (r) => r.redirect.sourceUrl
409
+ );
410
+ const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
411
+ var _a2;
412
+ return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
413
+ });
414
+ return {
415
+ paths: [...paths != null ? paths : [], ...redirectSources],
416
+ fallback: true
417
+ };
418
+ };
419
+ };
420
+
421
+ // src/route/withUniformGetStaticProps.ts
422
+ var import_canvas4 = require("@uniformdev/canvas");
423
+ var import_redirect3 = require("@uniformdev/redirect");
424
+
425
+ // src/helpers/resolveSlugFromParams.ts
426
+ var resolveSlugFromParams = ({
427
+ param = "slug",
428
+ params
429
+ }) => {
430
+ const slug = (params == null ? void 0 : params[param]) || "";
431
+ const slugString = Array.isArray(slug) ? slug.join("/") : slug;
432
+ return `/${slugString}`;
433
+ };
434
+
435
+ // src/route/withUniformGetStaticProps.ts
436
+ var withUniformGetStaticProps = (options) => {
521
437
  const defaultHandleRedirect = (requestUrl, matched) => {
522
438
  return {
523
439
  redirect: {
524
- destination: import_redirect2.RedirectClient.getTargetVariableExpandedUrl(requestUrl, matched.redirect),
440
+ destination: (0, import_redirect3.getTargetVariableExpandedUrl)(requestUrl, matched.redirect),
525
441
  statusCode: matched.redirect.targetStatusCode
526
442
  }
527
443
  };
@@ -551,7 +467,7 @@ var withUniformGetStaticProps2 = (options) => {
551
467
  }),
552
468
  // auto engage draft content when in next preview mode
553
469
  // (can override with explicit setting of request options)
554
- defaultFetchState: context.preview ? import_canvas6.CANVAS_DRAFT_STATE : void 0
470
+ defaultFetchState: context.preview ? import_canvas4.CANVAS_DRAFT_STATE : void 0
555
471
  };
556
472
  }
557
473
  });
@@ -559,9 +475,9 @@ var withUniformGetStaticProps2 = (options) => {
559
475
  };
560
476
 
561
477
  // src/route/index.ts
562
- var getServerSideProps2 = withUniformGetServerSideProps2();
563
- var getStaticProps2 = withUniformGetStaticProps2();
564
- var getStaticPaths2 = withUniformGetStaticPaths();
478
+ var getServerSideProps = withUniformGetServerSideProps();
479
+ var getStaticProps = withUniformGetStaticProps();
480
+ var getStaticPaths = withUniformGetStaticPaths();
565
481
  // Annotate the CommonJS export names for ESM import in node:
566
482
  0 && (module.exports = {
567
483
  getServerSideProps,