@uniformdev/canvas-next 19.79.1-alpha.11 → 19.79.1-alpha.18

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/LICENSE.txt CHANGED
@@ -1,2 +1,2 @@
1
- © 2023 Uniform Systems, Inc. All Rights Reserved.
1
+ © 2024 Uniform Systems, Inc. All Rights Reserved.
2
2
  See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RichTextRendererComponent, RenderRichTextComponentResolver, UniformRichText as UniformRichText$1, UniformRichTextNode as UniformRichTextNode$1 } from '@uniformdev/canvas-react';
2
2
  import { ParsedUrlQuery } from 'querystring';
3
- export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-f9fd03c4.js';
3
+ export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models--s4UGr5M.mjs';
4
4
  import { NextApiHandler, NextApiRequest } from 'next';
5
5
  import { RootComponentInstance } from '@uniformdev/canvas';
6
6
 
@@ -51,4 +51,4 @@ declare const createPreviewHandlerPost: CreatePreviewHandlerPost;
51
51
  type CreatePreviewHandler = (options?: CreatePreviewHandlerGetOptions & CreatePreviewHandlerPostOptions) => NextApiHandler;
52
52
  declare const createPreviewHandler: CreatePreviewHandler;
53
53
 
54
- export { CreatePreviewHandler, CreatePreviewHandlerGet, CreatePreviewHandlerGetOptions, CreatePreviewHandlerPost, CreatePreviewHandlerPostOptions, NextLinkRichTextNode, ResolveFullPath, UniformRichText, UniformRichTextNode, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost, resolveSlugFromParams, useResolveNextRichTextRenderer };
54
+ export { type CreatePreviewHandler, type CreatePreviewHandlerGet, type CreatePreviewHandlerGetOptions, type CreatePreviewHandlerPost, type CreatePreviewHandlerPostOptions, NextLinkRichTextNode, type ResolveFullPath, UniformRichText, UniformRichTextNode, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost, resolveSlugFromParams, useResolveNextRichTextRenderer };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RichTextRendererComponent, RenderRichTextComponentResolver, UniformRichText as UniformRichText$1, UniformRichTextNode as UniformRichTextNode$1 } from '@uniformdev/canvas-react';
2
2
  import { ParsedUrlQuery } from 'querystring';
3
- export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-f9fd03c4.js';
3
+ export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models--s4UGr5M.js';
4
4
  import { NextApiHandler, NextApiRequest } from 'next';
5
5
  import { RootComponentInstance } from '@uniformdev/canvas';
6
6
 
@@ -51,4 +51,4 @@ declare const createPreviewHandlerPost: CreatePreviewHandlerPost;
51
51
  type CreatePreviewHandler = (options?: CreatePreviewHandlerGetOptions & CreatePreviewHandlerPostOptions) => NextApiHandler;
52
52
  declare const createPreviewHandler: CreatePreviewHandler;
53
53
 
54
- export { CreatePreviewHandler, CreatePreviewHandlerGet, CreatePreviewHandlerGetOptions, CreatePreviewHandlerPost, CreatePreviewHandlerPostOptions, NextLinkRichTextNode, ResolveFullPath, UniformRichText, UniformRichTextNode, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost, resolveSlugFromParams, useResolveNextRichTextRenderer };
54
+ export { type CreatePreviewHandler, type CreatePreviewHandlerGet, type CreatePreviewHandlerGetOptions, type CreatePreviewHandlerPost, type CreatePreviewHandlerPostOptions, NextLinkRichTextNode, type ResolveFullPath, UniformRichText, UniformRichTextNode, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost, resolveSlugFromParams, useResolveNextRichTextRenderer };
package/dist/index.esm.js CHANGED
@@ -76,13 +76,18 @@ var compositionQueryParam = {
76
76
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault, playgroundPath } = {}) => async (req, res) => {
77
77
  const isConfigCheck = getQueryParam(req, "is_config_check") === "true";
78
78
  if (isConfigCheck) {
79
- return res.json({
79
+ res.json({
80
80
  hasPlayground: Boolean(playgroundPath),
81
81
  isUsingCustomFullPathResolver: resolveFullPath !== resolveFullPathDefault
82
82
  });
83
+ return;
83
84
  }
84
85
  if (req.headers["sec-fetch-mode"] === "no-cors") {
85
- return res.status(204).end();
86
+ if (req.query.disable) {
87
+ res.clearPreviewData();
88
+ }
89
+ res.status(204).end();
90
+ return;
86
91
  }
87
92
  const isPlayground = req.query[IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM] === "true";
88
93
  let pathToRedirectTo;
@@ -98,7 +103,8 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
98
103
  }
99
104
  validateLocalRedirectUrl(pathToRedirectTo);
100
105
  if (!pathToRedirectTo) {
101
- return res.status(400).json({ message: "Could not resolve the full path of the preview page" });
106
+ res.status(400).json({ message: "Could not resolve the full path of the preview page" });
107
+ return;
102
108
  }
103
109
  if (req.query.disable) {
104
110
  res.clearPreviewData();
@@ -108,7 +114,8 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
108
114
  const previewSecret = typeof secret === "function" ? secret == null ? void 0 : secret() : secret;
109
115
  const isUsingPreviewSecret = Boolean(previewSecret);
110
116
  if (isUsingPreviewSecret && req.query[SECRET_QUERY_STRING_PARAM] !== previewSecret) {
111
- return res.status(401).json({ message: "Invalid token" });
117
+ res.status(401).json({ message: "Invalid token" });
118
+ return;
112
119
  }
113
120
  const isUniformContextualEditing = req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true" && isAllowedReferrer(req.headers.referer);
114
121
  res.setPreviewData(
@@ -208,13 +215,17 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath, playgroundPath }
208
215
  res.setHeader("Access-Control-Allow-Headers", "*");
209
216
  res.setHeader("Access-Control-Allow-Methods", "GET, HEAD");
210
217
  if (method === "get") {
211
- return createPreviewHandlerGet({ secret, resolveFullPath, playgroundPath })(req, res);
218
+ createPreviewHandlerGet({ secret, resolveFullPath, playgroundPath })(req, res);
219
+ return;
212
220
  } else if (method === "post") {
213
- return createPreviewHandlerPost({ secret, enhance })(req, res);
221
+ createPreviewHandlerPost({ secret, enhance })(req, res);
222
+ return;
214
223
  } else if (method === "options") {
215
- return res.status(204).end();
224
+ res.status(204).end();
225
+ return;
216
226
  }
217
- return res.status(501).json({ message: `Method "${method}" not implemented` });
227
+ res.status(501).json({ message: `Method "${method}" not implemented` });
228
+ return;
218
229
  };
219
230
  export {
220
231
  NextLinkRichTextNode,
package/dist/index.js CHANGED
@@ -118,13 +118,18 @@ var compositionQueryParam = {
118
118
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault, playgroundPath } = {}) => async (req, res) => {
119
119
  const isConfigCheck = getQueryParam(req, "is_config_check") === "true";
120
120
  if (isConfigCheck) {
121
- return res.json({
121
+ res.json({
122
122
  hasPlayground: Boolean(playgroundPath),
123
123
  isUsingCustomFullPathResolver: resolveFullPath !== resolveFullPathDefault
124
124
  });
125
+ return;
125
126
  }
126
127
  if (req.headers["sec-fetch-mode"] === "no-cors") {
127
- return res.status(204).end();
128
+ if (req.query.disable) {
129
+ res.clearPreviewData();
130
+ }
131
+ res.status(204).end();
132
+ return;
128
133
  }
129
134
  const isPlayground = req.query[import_canvas.IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM] === "true";
130
135
  let pathToRedirectTo;
@@ -140,7 +145,8 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
140
145
  }
141
146
  validateLocalRedirectUrl(pathToRedirectTo);
142
147
  if (!pathToRedirectTo) {
143
- return res.status(400).json({ message: "Could not resolve the full path of the preview page" });
148
+ res.status(400).json({ message: "Could not resolve the full path of the preview page" });
149
+ return;
144
150
  }
145
151
  if (req.query.disable) {
146
152
  res.clearPreviewData();
@@ -150,7 +156,8 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
150
156
  const previewSecret = typeof secret === "function" ? secret == null ? void 0 : secret() : secret;
151
157
  const isUsingPreviewSecret = Boolean(previewSecret);
152
158
  if (isUsingPreviewSecret && req.query[import_canvas.SECRET_QUERY_STRING_PARAM] !== previewSecret) {
153
- return res.status(401).json({ message: "Invalid token" });
159
+ res.status(401).json({ message: "Invalid token" });
160
+ return;
154
161
  }
155
162
  const isUniformContextualEditing = req.query[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true" && (0, import_canvas2.isAllowedReferrer)(req.headers.referer);
156
163
  res.setPreviewData(
@@ -250,13 +257,17 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath, playgroundPath }
250
257
  res.setHeader("Access-Control-Allow-Headers", "*");
251
258
  res.setHeader("Access-Control-Allow-Methods", "GET, HEAD");
252
259
  if (method === "get") {
253
- return createPreviewHandlerGet({ secret, resolveFullPath, playgroundPath })(req, res);
260
+ createPreviewHandlerGet({ secret, resolveFullPath, playgroundPath })(req, res);
261
+ return;
254
262
  } else if (method === "post") {
255
- return createPreviewHandlerPost({ secret, enhance })(req, res);
263
+ createPreviewHandlerPost({ secret, enhance })(req, res);
264
+ return;
256
265
  } else if (method === "options") {
257
- return res.status(204).end();
266
+ res.status(204).end();
267
+ return;
258
268
  }
259
- return res.status(501).json({ message: `Method "${method}" not implemented` });
269
+ res.status(501).json({ message: `Method "${method}" not implemented` });
270
+ return;
260
271
  };
261
272
  // Annotate the CommonJS export names for ESM import in node:
262
273
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -76,13 +76,18 @@ var compositionQueryParam = {
76
76
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault, playgroundPath } = {}) => async (req, res) => {
77
77
  const isConfigCheck = getQueryParam(req, "is_config_check") === "true";
78
78
  if (isConfigCheck) {
79
- return res.json({
79
+ res.json({
80
80
  hasPlayground: Boolean(playgroundPath),
81
81
  isUsingCustomFullPathResolver: resolveFullPath !== resolveFullPathDefault
82
82
  });
83
+ return;
83
84
  }
84
85
  if (req.headers["sec-fetch-mode"] === "no-cors") {
85
- return res.status(204).end();
86
+ if (req.query.disable) {
87
+ res.clearPreviewData();
88
+ }
89
+ res.status(204).end();
90
+ return;
86
91
  }
87
92
  const isPlayground = req.query[IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM] === "true";
88
93
  let pathToRedirectTo;
@@ -98,7 +103,8 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
98
103
  }
99
104
  validateLocalRedirectUrl(pathToRedirectTo);
100
105
  if (!pathToRedirectTo) {
101
- return res.status(400).json({ message: "Could not resolve the full path of the preview page" });
106
+ res.status(400).json({ message: "Could not resolve the full path of the preview page" });
107
+ return;
102
108
  }
103
109
  if (req.query.disable) {
104
110
  res.clearPreviewData();
@@ -108,7 +114,8 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
108
114
  const previewSecret = typeof secret === "function" ? secret == null ? void 0 : secret() : secret;
109
115
  const isUsingPreviewSecret = Boolean(previewSecret);
110
116
  if (isUsingPreviewSecret && req.query[SECRET_QUERY_STRING_PARAM] !== previewSecret) {
111
- return res.status(401).json({ message: "Invalid token" });
117
+ res.status(401).json({ message: "Invalid token" });
118
+ return;
112
119
  }
113
120
  const isUniformContextualEditing = req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true" && isAllowedReferrer(req.headers.referer);
114
121
  res.setPreviewData(
@@ -208,13 +215,17 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath, playgroundPath }
208
215
  res.setHeader("Access-Control-Allow-Headers", "*");
209
216
  res.setHeader("Access-Control-Allow-Methods", "GET, HEAD");
210
217
  if (method === "get") {
211
- return createPreviewHandlerGet({ secret, resolveFullPath, playgroundPath })(req, res);
218
+ createPreviewHandlerGet({ secret, resolveFullPath, playgroundPath })(req, res);
219
+ return;
212
220
  } else if (method === "post") {
213
- return createPreviewHandlerPost({ secret, enhance })(req, res);
221
+ createPreviewHandlerPost({ secret, enhance })(req, res);
222
+ return;
214
223
  } else if (method === "options") {
215
- return res.status(204).end();
224
+ res.status(204).end();
225
+ return;
216
226
  }
217
- return res.status(501).json({ message: `Method "${method}" not implemented` });
227
+ res.status(501).json({ message: `Method "${method}" not implemented` });
228
+ return;
218
229
  };
219
230
  export {
220
231
  NextLinkRichTextNode,
@@ -23,4 +23,4 @@ type UniformGetServerSideProps<P extends {
23
23
  [key: string]: any;
24
24
  }, Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = (context: GetServerSidePropsContext<Q, D>, composition: RootComponentInstance | undefined) => Promise<GetServerSidePropsResult<P>> | GetServerSidePropsResult<P>;
25
25
 
26
- export { UniformCompositionNextPage as U, UniformPreviewData as a, UniformGetStaticProps as b, UniformGetServerSideProps as c };
26
+ export type { UniformCompositionNextPage as U, UniformPreviewData as a, UniformGetStaticProps as b, UniformGetServerSideProps as c };
@@ -0,0 +1,26 @@
1
+ import { RootComponentInstance } from '@uniformdev/canvas';
2
+ import { UniformCompositionProps } from '@uniformdev/canvas-react';
3
+ import { NextPage, PreviewData, GetStaticPropsContext, GetStaticPropsResult, GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
4
+ import { ParsedUrlQuery } from 'querystring';
5
+
6
+ type UniformCompositionNextPage<TProps = unknown> = NextPage<TProps & UniformCompositionProps>;
7
+ type UniformPreviewData = PreviewData & {
8
+ isUniformContextualEditing: boolean;
9
+ compositionId?: string;
10
+ compositionSlug?: string;
11
+ compositionPath?: string;
12
+ locale?: string;
13
+ isPlayground?: boolean;
14
+ };
15
+ type UniformGetStaticProps<P extends {
16
+ [key: string]: any;
17
+ } = {
18
+ [key: string]: any;
19
+ }, Q extends ParsedUrlQuery = ParsedUrlQuery, D extends UniformPreviewData = UniformPreviewData> = (context: GetStaticPropsContext<Q, D>, composition: RootComponentInstance | undefined) => Promise<GetStaticPropsResult<P>> | GetStaticPropsResult<P>;
20
+ type UniformGetServerSideProps<P extends {
21
+ [key: string]: any;
22
+ } = {
23
+ [key: string]: any;
24
+ }, Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = (context: GetServerSidePropsContext<Q, D>, composition: RootComponentInstance | undefined) => Promise<GetServerSidePropsResult<P>> | GetServerSidePropsResult<P>;
25
+
26
+ export type { UniformCompositionNextPage as U, UniformPreviewData as a, UniformGetStaticProps as b, UniformGetServerSideProps as c };
@@ -1,13 +1,12 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, PreviewData, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
- import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-f9fd03c4.js';
3
+ import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models--s4UGr5M.mjs';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_canvas from '@uniformdev/canvas';
7
7
  import { CanvasClient, DataResolutionOption } from '@uniformdev/canvas';
8
- export { w as withUniformGetStaticPaths } from '../withUniformGetStaticPaths-77db0164.js';
8
+ import { ProjectMapNodeGetResponse, ProjectMapClient } from '@uniformdev/project-map';
9
9
  import '@uniformdev/canvas-react';
10
- import '@uniformdev/project-map';
11
10
 
12
11
  declare const withUniformGetServerSideProps: <TProps extends {
13
12
  [key: string]: any;
@@ -34,6 +33,8 @@ declare const withUniformGetServerSideProps: <TProps extends {
34
33
  withTotalCount?: boolean | undefined;
35
34
  withUIStatus?: boolean | undefined;
36
35
  withContentSourceMap?: boolean | undefined;
36
+ locale?: string | undefined;
37
+ releaseId?: string | undefined;
37
38
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
38
39
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
39
40
  callback?: UniformGetServerSideProps<TProps> | undefined;
@@ -41,6 +42,43 @@ declare const withUniformGetServerSideProps: <TProps extends {
41
42
  silent?: boolean | undefined;
42
43
  } | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
43
44
 
45
+ declare const withUniformGetStaticPaths: (options?: {
46
+ projectMapId?: string | undefined;
47
+ /** Starting path to fetch nodes from */
48
+ rootPath?: string | undefined;
49
+ /** 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 */
50
+ prefix?: string | undefined;
51
+ /** Set to true if you want to include draft compositions */
52
+ preview?: boolean | undefined;
53
+ /** Way to override getNodes request params */
54
+ requestOptions?: Partial<{
55
+ projectMapId?: string | undefined;
56
+ projectId: string;
57
+ releaseId?: string | undefined;
58
+ id?: string | undefined;
59
+ path?: string | undefined;
60
+ compositionId?: string | undefined;
61
+ limit?: number | undefined;
62
+ offset?: number | undefined;
63
+ depth?: number | undefined;
64
+ state?: number | undefined;
65
+ tree?: boolean | undefined;
66
+ search?: string | undefined;
67
+ includeAncestors?: boolean | undefined;
68
+ expanded?: boolean | undefined;
69
+ withCompositionData?: boolean | undefined;
70
+ withCompositionUIStatus?: boolean | undefined;
71
+ withRedirectData?: boolean | undefined;
72
+ }> | undefined;
73
+ /** Way to modify list of nodes before building array of paths */
74
+ callback?: ((nodes: ProjectMapNodeGetResponse['nodes']) => Promise<ProjectMapNodeGetResponse['nodes']>) | undefined;
75
+ /** If you need to override the default client, you can pass it here */
76
+ client?: ProjectMapClient | undefined;
77
+ } | undefined) => () => Promise<{
78
+ paths: string[] | undefined;
79
+ fallback: boolean;
80
+ }>;
81
+
44
82
  declare const withUniformGetStaticProps: <TProps extends {
45
83
  [key: string]: any;
46
84
  } = {
@@ -66,6 +104,8 @@ declare const withUniformGetStaticProps: <TProps extends {
66
104
  withTotalCount?: boolean | undefined;
67
105
  withUIStatus?: boolean | undefined;
68
106
  withContentSourceMap?: boolean | undefined;
107
+ locale?: string | undefined;
108
+ releaseId?: string | undefined;
69
109
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
70
110
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
71
111
  callback?: UniformGetStaticProps<TProps> | undefined;
@@ -85,4 +125,4 @@ declare const getStaticPaths: () => Promise<{
85
125
  fallback: boolean;
86
126
  }>;
87
127
 
88
- export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticProps };
128
+ export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
@@ -1,13 +1,12 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, PreviewData, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
- import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-f9fd03c4.js';
3
+ import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models--s4UGr5M.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_canvas from '@uniformdev/canvas';
7
7
  import { CanvasClient, DataResolutionOption } from '@uniformdev/canvas';
8
- export { w as withUniformGetStaticPaths } from '../withUniformGetStaticPaths-77db0164.js';
8
+ import { ProjectMapNodeGetResponse, ProjectMapClient } from '@uniformdev/project-map';
9
9
  import '@uniformdev/canvas-react';
10
- import '@uniformdev/project-map';
11
10
 
12
11
  declare const withUniformGetServerSideProps: <TProps extends {
13
12
  [key: string]: any;
@@ -34,6 +33,8 @@ declare const withUniformGetServerSideProps: <TProps extends {
34
33
  withTotalCount?: boolean | undefined;
35
34
  withUIStatus?: boolean | undefined;
36
35
  withContentSourceMap?: boolean | undefined;
36
+ locale?: string | undefined;
37
+ releaseId?: string | undefined;
37
38
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
38
39
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
39
40
  callback?: UniformGetServerSideProps<TProps> | undefined;
@@ -41,6 +42,43 @@ declare const withUniformGetServerSideProps: <TProps extends {
41
42
  silent?: boolean | undefined;
42
43
  } | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
43
44
 
45
+ declare const withUniformGetStaticPaths: (options?: {
46
+ projectMapId?: string | undefined;
47
+ /** Starting path to fetch nodes from */
48
+ rootPath?: string | undefined;
49
+ /** 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 */
50
+ prefix?: string | undefined;
51
+ /** Set to true if you want to include draft compositions */
52
+ preview?: boolean | undefined;
53
+ /** Way to override getNodes request params */
54
+ requestOptions?: Partial<{
55
+ projectMapId?: string | undefined;
56
+ projectId: string;
57
+ releaseId?: string | undefined;
58
+ id?: string | undefined;
59
+ path?: string | undefined;
60
+ compositionId?: string | undefined;
61
+ limit?: number | undefined;
62
+ offset?: number | undefined;
63
+ depth?: number | undefined;
64
+ state?: number | undefined;
65
+ tree?: boolean | undefined;
66
+ search?: string | undefined;
67
+ includeAncestors?: boolean | undefined;
68
+ expanded?: boolean | undefined;
69
+ withCompositionData?: boolean | undefined;
70
+ withCompositionUIStatus?: boolean | undefined;
71
+ withRedirectData?: boolean | undefined;
72
+ }> | undefined;
73
+ /** Way to modify list of nodes before building array of paths */
74
+ callback?: ((nodes: ProjectMapNodeGetResponse['nodes']) => Promise<ProjectMapNodeGetResponse['nodes']>) | undefined;
75
+ /** If you need to override the default client, you can pass it here */
76
+ client?: ProjectMapClient | undefined;
77
+ } | undefined) => () => Promise<{
78
+ paths: string[] | undefined;
79
+ fallback: boolean;
80
+ }>;
81
+
44
82
  declare const withUniformGetStaticProps: <TProps extends {
45
83
  [key: string]: any;
46
84
  } = {
@@ -66,6 +104,8 @@ declare const withUniformGetStaticProps: <TProps extends {
66
104
  withTotalCount?: boolean | undefined;
67
105
  withUIStatus?: boolean | undefined;
68
106
  withContentSourceMap?: boolean | undefined;
107
+ locale?: string | undefined;
108
+ releaseId?: string | undefined;
69
109
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
70
110
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
71
111
  callback?: UniformGetStaticProps<TProps> | undefined;
@@ -85,4 +125,4 @@ declare const getStaticPaths: () => Promise<{
85
125
  fallback: boolean;
86
126
  }>;
87
127
 
88
- export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticProps };
128
+ export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
@@ -1,13 +1,160 @@
1
1
  import {
2
- getServerSideProps,
3
- getStaticPaths,
4
- getStaticProps,
5
- withUniformGetServerSideProps,
6
- withUniformGetStaticPaths,
7
- withUniformGetStaticProps
8
- } from "../chunk-ZLQ2WCJC.mjs";
9
- import "../chunk-JQWYBVLI.mjs";
10
- import "../chunk-TR7V6ABJ.mjs";
2
+ logCompositionResponse
3
+ } from "../chunk-JQWYBVLI.mjs";
4
+ import {
5
+ resolveSlugFromParams
6
+ } from "../chunk-TR7V6ABJ.mjs";
7
+
8
+ // src/project-map/withUniformGetServerSideProps.ts
9
+ import {
10
+ CANVAS_DRAFT_STATE,
11
+ CANVAS_PUBLISHED_STATE,
12
+ CanvasClient,
13
+ EMPTY_COMPOSITION
14
+ } from "@uniformdev/canvas";
15
+ var withUniformGetServerSideProps = (options) => {
16
+ const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
17
+ apiKey: process.env.UNIFORM_API_KEY,
18
+ projectId: process.env.UNIFORM_PROJECT_ID,
19
+ apiHost: process.env.UNIFORM_CLI_BASE_URL,
20
+ edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
21
+ });
22
+ return async function wrappedGetServerSideProps(context) {
23
+ var _a, _b;
24
+ const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
25
+ const { preview, previewData } = context;
26
+ let composition = void 0;
27
+ let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
28
+ if (options == null ? void 0 : options.modifyPath) {
29
+ nodePath = options.modifyPath(nodePath, context);
30
+ }
31
+ if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
32
+ composition = { ...EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION._id };
33
+ } else {
34
+ try {
35
+ const time = Date.now();
36
+ const response = await canvasClient.getCompositionByNodePath({
37
+ ...options == null ? void 0 : options.requestOptions,
38
+ projectMapId,
39
+ projectMapNodePath: nodePath,
40
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE
41
+ });
42
+ const duration = Date.now() - time;
43
+ composition = response.composition;
44
+ if (!(options == null ? void 0 : options.silent)) {
45
+ logCompositionResponse(response, duration);
46
+ }
47
+ } catch (e) {
48
+ console.error("[canvas-next] Failed to fetch composition", e);
49
+ return {
50
+ notFound: true
51
+ };
52
+ }
53
+ }
54
+ const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
55
+ if (Object.hasOwn(ret, "props")) {
56
+ const casted = ret;
57
+ casted.props["data"] = composition;
58
+ }
59
+ return ret;
60
+ };
61
+ };
62
+
63
+ // src/project-map/withUniformGetStaticPaths.ts
64
+ import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2, CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2 } from "@uniformdev/canvas";
65
+ import {
66
+ ProjectMapClient
67
+ } from "@uniformdev/project-map";
68
+ var withUniformGetStaticPaths = (options) => {
69
+ return async function wrappedGetStaticPaths() {
70
+ var _a, _b;
71
+ const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
72
+ const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new ProjectMapClient({
73
+ apiKey: process.env.UNIFORM_API_KEY,
74
+ projectId: process.env.UNIFORM_PROJECT_ID,
75
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
76
+ });
77
+ const response = await projectMapClient.getNodes({
78
+ ...options == null ? void 0 : options.requestOptions,
79
+ path: options == null ? void 0 : options.rootPath,
80
+ projectMapId,
81
+ state: (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE2 : CANVAS_PUBLISHED_STATE2
82
+ });
83
+ const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
84
+ const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
85
+ var _a2;
86
+ return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
87
+ });
88
+ return {
89
+ paths,
90
+ fallback: true
91
+ };
92
+ };
93
+ };
94
+
95
+ // src/project-map/withUniformGetStaticProps.ts
96
+ import {
97
+ CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
98
+ CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
99
+ CanvasClient as CanvasClient2,
100
+ EMPTY_COMPOSITION as EMPTY_COMPOSITION2
101
+ } from "@uniformdev/canvas";
102
+ var withUniformGetStaticProps = (options) => {
103
+ var _a;
104
+ const canvasClient = (_a = options == null ? void 0 : options.client) != null ? _a : new CanvasClient2({
105
+ apiKey: process.env.UNIFORM_API_KEY,
106
+ projectId: process.env.UNIFORM_PROJECT_ID,
107
+ apiHost: process.env.UNIFORM_CLI_BASE_URL,
108
+ edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
109
+ });
110
+ return async function wrappedGetStaticProps(context) {
111
+ var _a2, _b;
112
+ const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
113
+ let pathString = resolveSlugFromParams({
114
+ param: options == null ? void 0 : options.param,
115
+ params: context == null ? void 0 : context.params
116
+ });
117
+ if (options == null ? void 0 : options.modifyPath) {
118
+ pathString = options.modifyPath(pathString, context);
119
+ }
120
+ const { preview, previewData } = context;
121
+ let composition = void 0;
122
+ if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
123
+ composition = { ...EMPTY_COMPOSITION2, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION2._id };
124
+ } else {
125
+ try {
126
+ const time = Date.now();
127
+ const response = await canvasClient.getCompositionByNodePath({
128
+ ...options == null ? void 0 : options.requestOptions,
129
+ projectMapId,
130
+ projectMapNodePath: pathString,
131
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3
132
+ });
133
+ const duration = Date.now() - time;
134
+ composition = response.composition;
135
+ if (!(options == null ? void 0 : options.silent)) {
136
+ logCompositionResponse(response, duration);
137
+ }
138
+ } catch (e) {
139
+ console.error("[canvas-next] Failed to fetch composition", e);
140
+ return {
141
+ notFound: true
142
+ };
143
+ }
144
+ }
145
+ const ret = options.callback ? await options.callback(context, composition) : { props: {} };
146
+ if (composition && Object.hasOwn(ret, "props")) {
147
+ const casted = ret;
148
+ casted.props["data"] = composition;
149
+ }
150
+ return ret;
151
+ };
152
+ };
153
+
154
+ // src/project-map/index.ts
155
+ var getServerSideProps = withUniformGetServerSideProps();
156
+ var getStaticProps = withUniformGetStaticProps({ param: "path" });
157
+ var getStaticPaths = withUniformGetStaticPaths();
11
158
  export {
12
159
  getServerSideProps,
13
160
  getStaticPaths,