@uniformdev/canvas-next 19.79.1-alpha.11 → 19.79.1-alpha.7
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/{models-f9fd03c4.d.ts → models--s4UGr5M.d.mts} +1 -1
- package/dist/models--s4UGr5M.d.ts +26 -0
- package/dist/project-map/index.d.mts +41 -4
- package/dist/project-map/index.d.ts +41 -4
- package/dist/project-map/index.mjs +156 -9
- package/dist/route/index.d.mts +99 -14
- package/dist/route/index.d.ts +99 -14
- package/dist/route/index.js +94 -178
- package/dist/route/index.mjs +73 -17
- package/dist/slug/index.d.mts +3 -1
- package/dist/slug/index.d.ts +3 -1
- package/package.json +8 -8
- package/dist/chunk-ZLQ2WCJC.mjs +0 -166
- package/dist/withUniformGetStaticPaths-77db0164.d.ts +0 -39
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
|
|
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
|
|
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 };
|
|
@@ -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
|
|
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
|
-
|
|
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,7 @@ 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
37
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
|
|
38
38
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
39
39
|
callback?: UniformGetServerSideProps<TProps> | undefined;
|
|
@@ -41,6 +41,42 @@ declare const withUniformGetServerSideProps: <TProps extends {
|
|
|
41
41
|
silent?: boolean | undefined;
|
|
42
42
|
} | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
|
|
43
43
|
|
|
44
|
+
declare const withUniformGetStaticPaths: (options?: {
|
|
45
|
+
projectMapId?: string | undefined;
|
|
46
|
+
/** Starting path to fetch nodes from */
|
|
47
|
+
rootPath?: string | undefined;
|
|
48
|
+
/** 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 */
|
|
49
|
+
prefix?: string | undefined;
|
|
50
|
+
/** Set to true if you want to include draft compositions */
|
|
51
|
+
preview?: boolean | undefined;
|
|
52
|
+
/** Way to override getNodes request params */
|
|
53
|
+
requestOptions?: Partial<{
|
|
54
|
+
projectMapId?: string | undefined;
|
|
55
|
+
projectId: string;
|
|
56
|
+
id?: string | undefined;
|
|
57
|
+
path?: string | undefined;
|
|
58
|
+
compositionId?: string | undefined;
|
|
59
|
+
limit?: number | undefined;
|
|
60
|
+
offset?: number | undefined;
|
|
61
|
+
depth?: number | undefined;
|
|
62
|
+
state?: number | undefined;
|
|
63
|
+
tree?: boolean | undefined;
|
|
64
|
+
search?: string | undefined;
|
|
65
|
+
includeAncestors?: boolean | undefined;
|
|
66
|
+
expanded?: boolean | undefined;
|
|
67
|
+
withCompositionData?: boolean | undefined;
|
|
68
|
+
withCompositionUIStatus?: boolean | undefined;
|
|
69
|
+
withRedirectData?: boolean | undefined;
|
|
70
|
+
}> | undefined;
|
|
71
|
+
/** Way to modify list of nodes before building array of paths */
|
|
72
|
+
callback?: ((nodes: ProjectMapNodeGetResponse['nodes']) => Promise<ProjectMapNodeGetResponse['nodes']>) | undefined;
|
|
73
|
+
/** If you need to override the default client, you can pass it here */
|
|
74
|
+
client?: ProjectMapClient | undefined;
|
|
75
|
+
} | undefined) => () => Promise<{
|
|
76
|
+
paths: string[] | undefined;
|
|
77
|
+
fallback: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
|
|
44
80
|
declare const withUniformGetStaticProps: <TProps extends {
|
|
45
81
|
[key: string]: any;
|
|
46
82
|
} = {
|
|
@@ -66,6 +102,7 @@ declare const withUniformGetStaticProps: <TProps extends {
|
|
|
66
102
|
withTotalCount?: boolean | undefined;
|
|
67
103
|
withUIStatus?: boolean | undefined;
|
|
68
104
|
withContentSourceMap?: boolean | undefined;
|
|
105
|
+
locale?: string | undefined;
|
|
69
106
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
|
|
70
107
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
71
108
|
callback?: UniformGetStaticProps<TProps> | undefined;
|
|
@@ -85,4 +122,4 @@ declare const getStaticPaths: () => Promise<{
|
|
|
85
122
|
fallback: boolean;
|
|
86
123
|
}>;
|
|
87
124
|
|
|
88
|
-
export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticProps };
|
|
125
|
+
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
|
|
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
|
-
|
|
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,7 @@ 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
37
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
|
|
38
38
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
39
39
|
callback?: UniformGetServerSideProps<TProps> | undefined;
|
|
@@ -41,6 +41,42 @@ declare const withUniformGetServerSideProps: <TProps extends {
|
|
|
41
41
|
silent?: boolean | undefined;
|
|
42
42
|
} | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
|
|
43
43
|
|
|
44
|
+
declare const withUniformGetStaticPaths: (options?: {
|
|
45
|
+
projectMapId?: string | undefined;
|
|
46
|
+
/** Starting path to fetch nodes from */
|
|
47
|
+
rootPath?: string | undefined;
|
|
48
|
+
/** 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 */
|
|
49
|
+
prefix?: string | undefined;
|
|
50
|
+
/** Set to true if you want to include draft compositions */
|
|
51
|
+
preview?: boolean | undefined;
|
|
52
|
+
/** Way to override getNodes request params */
|
|
53
|
+
requestOptions?: Partial<{
|
|
54
|
+
projectMapId?: string | undefined;
|
|
55
|
+
projectId: string;
|
|
56
|
+
id?: string | undefined;
|
|
57
|
+
path?: string | undefined;
|
|
58
|
+
compositionId?: string | undefined;
|
|
59
|
+
limit?: number | undefined;
|
|
60
|
+
offset?: number | undefined;
|
|
61
|
+
depth?: number | undefined;
|
|
62
|
+
state?: number | undefined;
|
|
63
|
+
tree?: boolean | undefined;
|
|
64
|
+
search?: string | undefined;
|
|
65
|
+
includeAncestors?: boolean | undefined;
|
|
66
|
+
expanded?: boolean | undefined;
|
|
67
|
+
withCompositionData?: boolean | undefined;
|
|
68
|
+
withCompositionUIStatus?: boolean | undefined;
|
|
69
|
+
withRedirectData?: boolean | undefined;
|
|
70
|
+
}> | undefined;
|
|
71
|
+
/** Way to modify list of nodes before building array of paths */
|
|
72
|
+
callback?: ((nodes: ProjectMapNodeGetResponse['nodes']) => Promise<ProjectMapNodeGetResponse['nodes']>) | undefined;
|
|
73
|
+
/** If you need to override the default client, you can pass it here */
|
|
74
|
+
client?: ProjectMapClient | undefined;
|
|
75
|
+
} | undefined) => () => Promise<{
|
|
76
|
+
paths: string[] | undefined;
|
|
77
|
+
fallback: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
|
|
44
80
|
declare const withUniformGetStaticProps: <TProps extends {
|
|
45
81
|
[key: string]: any;
|
|
46
82
|
} = {
|
|
@@ -66,6 +102,7 @@ declare const withUniformGetStaticProps: <TProps extends {
|
|
|
66
102
|
withTotalCount?: boolean | undefined;
|
|
67
103
|
withUIStatus?: boolean | undefined;
|
|
68
104
|
withContentSourceMap?: boolean | undefined;
|
|
105
|
+
locale?: string | undefined;
|
|
69
106
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
|
|
70
107
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
71
108
|
callback?: UniformGetStaticProps<TProps> | undefined;
|
|
@@ -85,4 +122,4 @@ declare const getStaticPaths: () => Promise<{
|
|
|
85
122
|
fallback: boolean;
|
|
86
123
|
}>;
|
|
87
124
|
|
|
88
|
-
export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticProps };
|
|
125
|
+
export { getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
|
|
@@ -1,13 +1,160 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
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,
|
package/dist/route/index.d.mts
CHANGED
|
@@ -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
|
|
3
|
+
import { a as UniformPreviewData } from '../models--s4UGr5M.mjs';
|
|
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
|
|
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
|
|
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
|
|
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;
|
|
@@ -150,6 +197,17 @@ declare const getServerSideProps: next.GetServerSideProps<{
|
|
|
150
197
|
_id: string;
|
|
151
198
|
_slug?: string | null | undefined;
|
|
152
199
|
_name: string;
|
|
200
|
+
_pattern?: string | undefined;
|
|
201
|
+
_patternDataResources?: {
|
|
202
|
+
[key: string]: {
|
|
203
|
+
type: string;
|
|
204
|
+
isPatternParameter?: boolean | undefined;
|
|
205
|
+
ignorePatternParameterDefault?: boolean | undefined;
|
|
206
|
+
variables?: {
|
|
207
|
+
[key: string]: string;
|
|
208
|
+
} | undefined;
|
|
209
|
+
};
|
|
210
|
+
} | undefined;
|
|
153
211
|
_dataResources?: {
|
|
154
212
|
[key: string]: {
|
|
155
213
|
type: string;
|
|
@@ -164,12 +222,15 @@ declare const getServerSideProps: next.GetServerSideProps<{
|
|
|
164
222
|
[key: string]: {
|
|
165
223
|
parameters?: {
|
|
166
224
|
[key: string]: {
|
|
167
|
-
value
|
|
225
|
+
value?: unknown;
|
|
168
226
|
type: string;
|
|
169
227
|
connectedData?: {
|
|
170
228
|
pointer: string;
|
|
171
229
|
syntax: "jptr";
|
|
172
230
|
} | undefined;
|
|
231
|
+
locales?: {
|
|
232
|
+
[key: string]: unknown;
|
|
233
|
+
} | undefined;
|
|
173
234
|
};
|
|
174
235
|
} | undefined;
|
|
175
236
|
variant?: string | undefined;
|
|
@@ -181,9 +242,9 @@ declare const getServerSideProps: next.GetServerSideProps<{
|
|
|
181
242
|
} | undefined;
|
|
182
243
|
variants?: boolean | undefined;
|
|
183
244
|
} | undefined;
|
|
245
|
+
_locales?: string[] | undefined;
|
|
184
246
|
};
|
|
185
247
|
}, querystring.ParsedUrlQuery, UniformPreviewData>;
|
|
186
|
-
|
|
187
248
|
/**
|
|
188
249
|
* Default implementation of getStaticProps with routes
|
|
189
250
|
* To configure custom behavior, use:
|
|
@@ -194,12 +255,15 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
194
255
|
type: string;
|
|
195
256
|
parameters?: {
|
|
196
257
|
[key: string]: {
|
|
197
|
-
value
|
|
258
|
+
value?: unknown;
|
|
198
259
|
type: string;
|
|
199
260
|
connectedData?: {
|
|
200
261
|
pointer: string;
|
|
201
262
|
syntax: "jptr";
|
|
202
263
|
} | undefined;
|
|
264
|
+
locales?: {
|
|
265
|
+
[key: string]: unknown;
|
|
266
|
+
} | undefined;
|
|
203
267
|
};
|
|
204
268
|
} | undefined;
|
|
205
269
|
variant?: string | undefined;
|
|
@@ -213,12 +277,15 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
213
277
|
type: string;
|
|
214
278
|
parameters?: {
|
|
215
279
|
[key: string]: {
|
|
216
|
-
value
|
|
280
|
+
value?: unknown;
|
|
217
281
|
type: string;
|
|
218
282
|
connectedData?: {
|
|
219
283
|
pointer: string;
|
|
220
284
|
syntax: "jptr";
|
|
221
285
|
} | undefined;
|
|
286
|
+
locales?: {
|
|
287
|
+
[key: string]: unknown;
|
|
288
|
+
} | undefined;
|
|
222
289
|
};
|
|
223
290
|
} | undefined;
|
|
224
291
|
variant?: string | undefined;
|
|
@@ -252,12 +319,15 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
252
319
|
[key: string]: {
|
|
253
320
|
parameters?: {
|
|
254
321
|
[key: string]: {
|
|
255
|
-
value
|
|
322
|
+
value?: unknown;
|
|
256
323
|
type: string;
|
|
257
324
|
connectedData?: {
|
|
258
325
|
pointer: string;
|
|
259
326
|
syntax: "jptr";
|
|
260
327
|
} | undefined;
|
|
328
|
+
locales?: {
|
|
329
|
+
[key: string]: unknown;
|
|
330
|
+
} | undefined;
|
|
261
331
|
};
|
|
262
332
|
} | undefined;
|
|
263
333
|
variant?: string | undefined;
|
|
@@ -274,6 +344,17 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
274
344
|
_id: string;
|
|
275
345
|
_slug?: string | null | undefined;
|
|
276
346
|
_name: string;
|
|
347
|
+
_pattern?: string | undefined;
|
|
348
|
+
_patternDataResources?: {
|
|
349
|
+
[key: string]: {
|
|
350
|
+
type: string;
|
|
351
|
+
isPatternParameter?: boolean | undefined;
|
|
352
|
+
ignorePatternParameterDefault?: boolean | undefined;
|
|
353
|
+
variables?: {
|
|
354
|
+
[key: string]: string;
|
|
355
|
+
} | undefined;
|
|
356
|
+
};
|
|
357
|
+
} | undefined;
|
|
277
358
|
_dataResources?: {
|
|
278
359
|
[key: string]: {
|
|
279
360
|
type: string;
|
|
@@ -288,12 +369,15 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
288
369
|
[key: string]: {
|
|
289
370
|
parameters?: {
|
|
290
371
|
[key: string]: {
|
|
291
|
-
value
|
|
372
|
+
value?: unknown;
|
|
292
373
|
type: string;
|
|
293
374
|
connectedData?: {
|
|
294
375
|
pointer: string;
|
|
295
376
|
syntax: "jptr";
|
|
296
377
|
} | undefined;
|
|
378
|
+
locales?: {
|
|
379
|
+
[key: string]: unknown;
|
|
380
|
+
} | undefined;
|
|
297
381
|
};
|
|
298
382
|
} | undefined;
|
|
299
383
|
variant?: string | undefined;
|
|
@@ -305,6 +389,7 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
305
389
|
} | undefined;
|
|
306
390
|
variants?: boolean | undefined;
|
|
307
391
|
} | undefined;
|
|
392
|
+
_locales?: string[] | undefined;
|
|
308
393
|
};
|
|
309
394
|
}, querystring.ParsedUrlQuery, UniformPreviewData>;
|
|
310
395
|
/**
|
|
@@ -315,8 +400,8 @@ declare const getStaticProps: next.GetStaticProps<{
|
|
|
315
400
|
* NOTE: fallback must be supported. You cannot generate static paths for dynamic routes which contain query parameters.
|
|
316
401
|
*/
|
|
317
402
|
declare const getStaticPaths: () => Promise<{
|
|
318
|
-
paths: string[]
|
|
403
|
+
paths: string[];
|
|
319
404
|
fallback: boolean;
|
|
320
405
|
}>;
|
|
321
406
|
|
|
322
|
-
export { HandleRouteCompositionFunction, HandleRouteNotFoundFunction, HandleRouteRedirectFunction, RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticProps };
|
|
407
|
+
export { type HandleRouteCompositionFunction, type HandleRouteNotFoundFunction, type HandleRouteRedirectFunction, type RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
|