@uniformdev/next-app-router 20.7.1-alpha.118

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.
@@ -0,0 +1,70 @@
1
+ import { Quirks } from '@uniformdev/context';
2
+ import { PageState, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
3
+ import { NextRequest, NextResponse } from 'next/server';
4
+ import { D as DataClient } from './client-BCGVjYM-.mjs';
5
+ import '@uniformdev/canvas';
6
+
7
+ type RewriteOptions = {
8
+ source: 'route' | 'playground';
9
+ /**
10
+ * The code that was generated from the evaluated composition.
11
+ */
12
+ code: string;
13
+ /**
14
+ * The page state that was generated from the evaluated composition.
15
+ */
16
+ pageState: PageState;
17
+ };
18
+ type RewriteRequestPathOptions = {
19
+ url: URL;
20
+ request: Request;
21
+ };
22
+ type RequestInfo = Pick<NextRequest, 'nextUrl' | 'cookies'>;
23
+ type HandleOptions = {
24
+ /**
25
+ * If provided, the rewrite function will be called with the request.
26
+ * The function should return the desired route path to be resolved via Uniform Route API.
27
+ */
28
+ rewriteRequestPath?: (options: RewriteRequestPathOptions) => Promise<RewriteRequestPathResult | undefined>;
29
+ /**
30
+ * If provided, the rewrite function will be called with the route and code.
31
+ * The function should return the path to rewrite to.
32
+ */
33
+ rewriteDestinationPath?: (options: RewriteOptions) => Promise<string>;
34
+ /**
35
+ * If provided, the middleware will only precompute the runnables for the paths that match the patterns.
36
+ */
37
+ pathPatternsWithVariations?: string[];
38
+ /**
39
+ * If provided, the middleware will use the data client to retrieve data.
40
+ */
41
+ dataClient?: DataClient;
42
+ /**
43
+ * Release ID to resolve the route from.
44
+ */
45
+ release?: {
46
+ /**
47
+ * The release ID to resolve the route from.
48
+ */
49
+ id: string;
50
+ };
51
+ /**
52
+ * If provided, the middleware will use the quirks to update the context.
53
+ */
54
+ quirks?: Quirks;
55
+ /**
56
+ * If provided, the middleware will use this value for defaultConsent on Context.
57
+ * If not provided, middleware will use the server config default consent or false if not set.
58
+ */
59
+ defaultConsent?: boolean | undefined;
60
+ };
61
+ declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
62
+ declare const handleUniformRoute: ({ request, dataClient, ...options }: HandleOptions & {
63
+ request: NextRequest;
64
+ }) => Promise<NextResponse<unknown>>;
65
+ declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
66
+ searchParams: URLSearchParams;
67
+ isDraftModeEnabled: boolean;
68
+ }) => "preview" | "editor" | undefined;
69
+
70
+ export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
@@ -0,0 +1,70 @@
1
+ import { Quirks } from '@uniformdev/context';
2
+ import { PageState, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
3
+ import { NextRequest, NextResponse } from 'next/server';
4
+ import { D as DataClient } from './client-BCGVjYM-.js';
5
+ import '@uniformdev/canvas';
6
+
7
+ type RewriteOptions = {
8
+ source: 'route' | 'playground';
9
+ /**
10
+ * The code that was generated from the evaluated composition.
11
+ */
12
+ code: string;
13
+ /**
14
+ * The page state that was generated from the evaluated composition.
15
+ */
16
+ pageState: PageState;
17
+ };
18
+ type RewriteRequestPathOptions = {
19
+ url: URL;
20
+ request: Request;
21
+ };
22
+ type RequestInfo = Pick<NextRequest, 'nextUrl' | 'cookies'>;
23
+ type HandleOptions = {
24
+ /**
25
+ * If provided, the rewrite function will be called with the request.
26
+ * The function should return the desired route path to be resolved via Uniform Route API.
27
+ */
28
+ rewriteRequestPath?: (options: RewriteRequestPathOptions) => Promise<RewriteRequestPathResult | undefined>;
29
+ /**
30
+ * If provided, the rewrite function will be called with the route and code.
31
+ * The function should return the path to rewrite to.
32
+ */
33
+ rewriteDestinationPath?: (options: RewriteOptions) => Promise<string>;
34
+ /**
35
+ * If provided, the middleware will only precompute the runnables for the paths that match the patterns.
36
+ */
37
+ pathPatternsWithVariations?: string[];
38
+ /**
39
+ * If provided, the middleware will use the data client to retrieve data.
40
+ */
41
+ dataClient?: DataClient;
42
+ /**
43
+ * Release ID to resolve the route from.
44
+ */
45
+ release?: {
46
+ /**
47
+ * The release ID to resolve the route from.
48
+ */
49
+ id: string;
50
+ };
51
+ /**
52
+ * If provided, the middleware will use the quirks to update the context.
53
+ */
54
+ quirks?: Quirks;
55
+ /**
56
+ * If provided, the middleware will use this value for defaultConsent on Context.
57
+ * If not provided, middleware will use the server config default consent or false if not set.
58
+ */
59
+ defaultConsent?: boolean | undefined;
60
+ };
61
+ declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
62
+ declare const handleUniformRoute: ({ request, dataClient, ...options }: HandleOptions & {
63
+ request: NextRequest;
64
+ }) => Promise<NextResponse<unknown>>;
65
+ declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
66
+ searchParams: URLSearchParams;
67
+ isDraftModeEnabled: boolean;
68
+ }) => "preview" | "editor" | undefined;
69
+
70
+ export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };