@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.
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+
3
+ declare function PreprPreviewBar(props: {
4
+ activeSegment?: string | null;
5
+ activeVariant?: string | null;
6
+ data?: any;
7
+ }): React.JSX.Element;
8
+
9
+ export { PreprPreviewBar };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+
3
+ declare function PreprPreviewBar(props: {
4
+ activeSegment?: string | null;
5
+ activeVariant?: string | null;
6
+ data?: any;
7
+ }): React.JSX.Element;
8
+
9
+ export { PreprPreviewBar };
@@ -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 };
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preprio/prepr-nextjs",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
4
4
  "description": "A next.js package with code snippets to use with Prepr",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",