@preprio/prepr-nextjs 1.0.0-beta.5 → 1.0.0-beta.6
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/components.d.mts +9 -0
- package/dist/components.d.ts +9 -0
- package/dist/index.d.mts +56 -0
- package/dist/index.d.ts +56 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
|
|
3
|
+
declare function PreprMiddleware(request: NextRequest, response?: NextResponse): NextResponse<unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the Prepr Customer ID from the headers
|
|
6
|
+
*/
|
|
7
|
+
declare function getPreprUUID(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Retuns the active segment from the headers
|
|
10
|
+
*/
|
|
11
|
+
declare function getActiveSegment(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the active variant from the headers
|
|
14
|
+
*/
|
|
15
|
+
declare function getActiveVariant(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to retrieve Prepr headers (will filter out customer ID if in preview mode)
|
|
18
|
+
*/
|
|
19
|
+
declare function getPreprHeaders(): {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
type PreprSegment = {
|
|
23
|
+
id: string;
|
|
24
|
+
created_on: string;
|
|
25
|
+
changed_on: string;
|
|
26
|
+
synced_on: string;
|
|
27
|
+
label: string;
|
|
28
|
+
reference_id: string;
|
|
29
|
+
body: string;
|
|
30
|
+
query: string;
|
|
31
|
+
count: number;
|
|
32
|
+
};
|
|
33
|
+
type PreprSegmentsResponse = {
|
|
34
|
+
total: number;
|
|
35
|
+
skip: number;
|
|
36
|
+
limit: number;
|
|
37
|
+
items: PreprSegment[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Fetches the segments from the Prepr API
|
|
41
|
+
* @param token Prepr access token with scope 'segments'
|
|
42
|
+
* @returns Object with total, skip, limit and items
|
|
43
|
+
*/
|
|
44
|
+
declare function getPreprEnvironmentSegments(token: string): Promise<PreprSegmentsResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetches all the necessary previewbar props
|
|
47
|
+
* @param token Prepr access token with scope 'segments'
|
|
48
|
+
* @returns Object with activeSegment, activeVariant and data
|
|
49
|
+
*/
|
|
50
|
+
declare function getPreviewBarProps(token: string): Promise<{
|
|
51
|
+
activeSegment: string | null;
|
|
52
|
+
activeVariant: string | null;
|
|
53
|
+
data: PreprSegmentsResponse;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
export { PreprMiddleware, type PreprSegment, type PreprSegmentsResponse, getActiveSegment, getActiveVariant, getPreprEnvironmentSegments, getPreprHeaders, getPreprUUID, getPreviewBarProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
|
|
3
|
+
declare function PreprMiddleware(request: NextRequest, response?: NextResponse): NextResponse<unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the Prepr Customer ID from the headers
|
|
6
|
+
*/
|
|
7
|
+
declare function getPreprUUID(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Retuns the active segment from the headers
|
|
10
|
+
*/
|
|
11
|
+
declare function getActiveSegment(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the active variant from the headers
|
|
14
|
+
*/
|
|
15
|
+
declare function getActiveVariant(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to retrieve Prepr headers (will filter out customer ID if in preview mode)
|
|
18
|
+
*/
|
|
19
|
+
declare function getPreprHeaders(): {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
type PreprSegment = {
|
|
23
|
+
id: string;
|
|
24
|
+
created_on: string;
|
|
25
|
+
changed_on: string;
|
|
26
|
+
synced_on: string;
|
|
27
|
+
label: string;
|
|
28
|
+
reference_id: string;
|
|
29
|
+
body: string;
|
|
30
|
+
query: string;
|
|
31
|
+
count: number;
|
|
32
|
+
};
|
|
33
|
+
type PreprSegmentsResponse = {
|
|
34
|
+
total: number;
|
|
35
|
+
skip: number;
|
|
36
|
+
limit: number;
|
|
37
|
+
items: PreprSegment[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Fetches the segments from the Prepr API
|
|
41
|
+
* @param token Prepr access token with scope 'segments'
|
|
42
|
+
* @returns Object with total, skip, limit and items
|
|
43
|
+
*/
|
|
44
|
+
declare function getPreprEnvironmentSegments(token: string): Promise<PreprSegmentsResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetches all the necessary previewbar props
|
|
47
|
+
* @param token Prepr access token with scope 'segments'
|
|
48
|
+
* @returns Object with activeSegment, activeVariant and data
|
|
49
|
+
*/
|
|
50
|
+
declare function getPreviewBarProps(token: string): Promise<{
|
|
51
|
+
activeSegment: string | null;
|
|
52
|
+
activeVariant: string | null;
|
|
53
|
+
data: PreprSegmentsResponse;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
export { PreprMiddleware, type PreprSegment, type PreprSegmentsResponse, getActiveSegment, getActiveVariant, getPreprEnvironmentSegments, getPreprHeaders, getPreprUUID, getPreviewBarProps };
|