@preprio/toolkit 0.5.0-rc.2 → 0.6.0-alpha.1
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/README.md +415 -27
- package/dist/astro/chunk-O7N6GPAH.js +173 -0
- package/dist/astro/graphql.cjs +1030 -0
- package/dist/astro/graphql.d.cts +305 -0
- package/dist/astro/graphql.d.ts +305 -0
- package/dist/astro/graphql.js +936 -0
- package/dist/astro/index-XT_z-RYT.d.cts +130 -0
- package/dist/astro/index-XT_z-RYT.d.ts +130 -0
- package/dist/astro/index.cjs +14 -1
- package/dist/astro/index.d.cts +1 -120
- package/dist/astro/index.d.ts +1 -120
- package/dist/astro/index.js +15 -153
- package/dist/chunk-3JLWZQ37.js +179 -0
- package/dist/chunk-3NCEVJJ3.js +10 -0
- package/dist/chunk-S5RWVMDJ.js +148 -0
- package/dist/chunk-TBKSBXGH.js +452 -0
- package/dist/{chunk-FLPNN3CV.js → chunk-VI6QZTBM.js} +73 -276
- package/dist/chunk-YWIKKWBR.js +26 -0
- package/dist/graphql/codegen.cjs +510 -0
- package/dist/graphql/codegen.d.cts +23 -0
- package/dist/graphql/codegen.d.ts +23 -0
- package/dist/graphql/codegen.js +99 -0
- package/dist/graphql.cjs +941 -0
- package/dist/graphql.d.cts +305 -0
- package/dist/graphql.d.ts +305 -0
- package/dist/graphql.js +419 -0
- package/dist/index.cjs +76 -119
- package/dist/index.d.cts +12 -64
- package/dist/index.d.ts +12 -64
- package/dist/index.js +27 -167
- package/dist/nextjs/chunk-BQ6IGSH6.js +231 -0
- package/dist/nextjs/components.cjs +190 -122
- package/dist/nextjs/components.d.cts +33 -2
- package/dist/nextjs/components.d.ts +33 -2
- package/dist/nextjs/components.js +133 -4
- package/dist/nextjs/graphql.cjs +1362 -0
- package/dist/nextjs/graphql.d.cts +435 -0
- package/dist/nextjs/graphql.d.ts +435 -0
- package/dist/nextjs/graphql.js +1261 -0
- package/dist/nextjs/index.cjs +126 -6
- package/dist/nextjs/index.d.cts +53 -147
- package/dist/nextjs/index.d.ts +53 -147
- package/dist/nextjs/index.js +113 -203
- package/dist/nextjs/server-CjpELYvq.d.cts +156 -0
- package/dist/nextjs/server-CjpELYvq.d.ts +156 -0
- package/dist/nuxt/chunk-IQDSBPDN.js +417 -0
- package/dist/nuxt/graphql.cjs +1037 -0
- package/dist/nuxt/graphql.d.cts +302 -0
- package/dist/nuxt/graphql.d.ts +302 -0
- package/dist/nuxt/graphql.js +937 -0
- package/dist/nuxt/index.cjs +14 -1
- package/dist/nuxt/index.d.cts +3 -148
- package/dist/nuxt/index.d.ts +3 -148
- package/dist/nuxt/index.js +15 -391
- package/dist/nuxt/server-8v6OHbsw.d.cts +158 -0
- package/dist/nuxt/server-8v6OHbsw.d.ts +158 -0
- package/dist/pixel-DwW7cXJm.d.cts +49 -0
- package/dist/pixel-DwW7cXJm.d.ts +49 -0
- package/dist/react/components.cjs +88 -120
- package/dist/react/components.d.cts +2 -8
- package/dist/react/components.d.ts +2 -8
- package/dist/react/components.js +88 -120
- package/dist/server-Brr1UgtW.d.ts +59 -0
- package/dist/server-DJuS3YU0.d.cts +59 -0
- package/dist/sveltekit/chunk-OKYZ6HPH.js +413 -0
- package/dist/sveltekit/graphql.cjs +1043 -0
- package/dist/sveltekit/graphql.d.cts +307 -0
- package/dist/sveltekit/graphql.d.ts +307 -0
- package/dist/sveltekit/graphql.js +943 -0
- package/dist/sveltekit/index.cjs +14 -1
- package/dist/sveltekit/index.d.cts +3 -88
- package/dist/sveltekit/index.d.ts +3 -88
- package/dist/sveltekit/index.js +15 -387
- package/dist/sveltekit/server-CO847mEV.d.cts +98 -0
- package/dist/sveltekit/server-CO847mEV.d.ts +98 -0
- package/dist/{pixel-B3oQNbZ3.d.cts → types-BYH9XqmN.d.cts} +4 -58
- package/dist/{pixel-B3oQNbZ3.d.ts → types-BYH9XqmN.d.ts} +4 -58
- package/package.json +36 -1
package/dist/nuxt/index.cjs
CHANGED
|
@@ -30,12 +30,13 @@ __export(nuxt_exports, {
|
|
|
30
30
|
getPreprUUID: () => getPreprUUID,
|
|
31
31
|
getToolbarProps: () => getToolbarProps,
|
|
32
32
|
handlePreprRequest: () => handlePreprRequest,
|
|
33
|
+
isPersonalizedResponse: () => isPersonalizedResponse,
|
|
33
34
|
validatePreprToken: () => validatePreprToken
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(nuxt_exports);
|
|
36
37
|
|
|
37
38
|
// src/version.ts
|
|
38
|
-
var VERSION = "0.
|
|
39
|
+
var VERSION = "0.6.0-alpha.1";
|
|
39
40
|
|
|
40
41
|
// src/core/constants.ts
|
|
41
42
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -229,6 +230,10 @@ function processFrameworkRequest(request, opts, framework) {
|
|
|
229
230
|
});
|
|
230
231
|
}
|
|
231
232
|
}
|
|
233
|
+
if (requestHeaders.has("Prepr-Segments")) {
|
|
234
|
+
requestHeaders.delete("Prepr-Customer-Id");
|
|
235
|
+
requestHeaders.delete("Prepr-Customer-Id-Created");
|
|
236
|
+
}
|
|
232
237
|
return { requestHeaders, responseCookies };
|
|
233
238
|
}
|
|
234
239
|
|
|
@@ -442,6 +447,13 @@ function getPreprHeaders(headers) {
|
|
|
442
447
|
async function getToolbarProps(headers, token, features) {
|
|
443
448
|
return getToolbarPropsFromHeaders(headers, token, features);
|
|
444
449
|
}
|
|
450
|
+
|
|
451
|
+
// src/core/personalization.ts
|
|
452
|
+
var PERSONALIZED_VARY = /\bPrepr-(Segments|ABTesting)/i;
|
|
453
|
+
function isPersonalizedResponse(source) {
|
|
454
|
+
const headers = "headers" in source ? source.headers : source;
|
|
455
|
+
return PERSONALIZED_VARY.test(headers.get("vary") ?? "");
|
|
456
|
+
}
|
|
445
457
|
// Annotate the CommonJS export names for ESM import in node:
|
|
446
458
|
0 && (module.exports = {
|
|
447
459
|
PREPR_CONTEXT_KEY,
|
|
@@ -454,5 +466,6 @@ async function getToolbarProps(headers, token, features) {
|
|
|
454
466
|
getPreprUUID,
|
|
455
467
|
getToolbarProps,
|
|
456
468
|
handlePreprRequest,
|
|
469
|
+
isPersonalizedResponse,
|
|
457
470
|
validatePreprToken
|
|
458
471
|
});
|
package/dist/nuxt/index.d.cts
CHANGED
|
@@ -1,131 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly name: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Per-feature config. `false` is shorthand for `{ enabled: false }`; the object
|
|
7
|
-
* form leaves room for per-feature options later without a breaking change.
|
|
8
|
-
*/
|
|
9
|
-
type PreprFeatureConfig = boolean | {
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
};
|
|
12
|
-
/** Toolkit features a consumer can turn off. Omitted keys stay enabled. */
|
|
13
|
-
interface PreprFeatures {
|
|
14
|
-
/** Segment picker, `Prepr-Segments` header and its cookie/query param. */
|
|
15
|
-
segments?: PreprFeatureConfig;
|
|
16
|
-
/** A/B variant switch, `Prepr-ABtesting` header and its cookie/query param. */
|
|
17
|
-
abTesting?: PreprFeatureConfig;
|
|
18
|
-
/**
|
|
19
|
-
* The site's own click-to-edit: the toolbar's Edit mode control, the stega
|
|
20
|
-
* tooltip/overlay and the close-edit pill.
|
|
21
|
-
*
|
|
22
|
-
* NOT a security control, and NOT the Prepr editor's live preview. When the
|
|
23
|
-
* site is framed by the editor, `prepr:initVE` still activates edit mode —
|
|
24
|
-
* that is the CMS operating inside its own iframe, not an affordance offered
|
|
25
|
-
* to visitors. See iframe-bridge.ts.
|
|
26
|
-
*/
|
|
27
|
-
editMode?: PreprFeatureConfig;
|
|
28
|
-
}
|
|
29
|
-
interface PreprToolbarProps {
|
|
30
|
-
/**
|
|
31
|
-
* Server-resolved active segment. Optional: omit it with `segments`
|
|
32
|
-
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
33
|
-
* the persisted cookie is used.
|
|
34
|
-
*/
|
|
35
|
-
readonly activeSegment?: string | null;
|
|
36
|
-
/**
|
|
37
|
-
* Server-resolved active A/B variant. Optional: omit it with `abTesting`
|
|
38
|
-
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
39
|
-
* the persisted cookie is used.
|
|
40
|
-
*/
|
|
41
|
-
readonly activeVariant?: string | null;
|
|
42
|
-
/** Available segments to personalize on. */
|
|
43
|
-
readonly segments?: readonly PreprSegment[];
|
|
44
|
-
/** @deprecated Alias for `segments`. */
|
|
45
|
-
readonly data?: readonly PreprSegment[];
|
|
46
|
-
}
|
|
47
|
-
type PreprVariant = 'A' | 'B';
|
|
48
|
-
interface PreprHeaders {
|
|
49
|
-
readonly 'prepr-customer-id'?: string;
|
|
50
|
-
readonly 'Prepr-Segments'?: string;
|
|
51
|
-
readonly 'Prepr-ABtesting'?: PreprVariant;
|
|
52
|
-
readonly 'Prepr-Preview-Bar'?: 'true';
|
|
53
|
-
readonly 'Prepr-Context-utm_source'?: string;
|
|
54
|
-
readonly 'Prepr-Context-utm_medium'?: string;
|
|
55
|
-
readonly 'Prepr-Context-utm_term'?: string;
|
|
56
|
-
readonly 'Prepr-Context-utm_content'?: string;
|
|
57
|
-
readonly 'Prepr-Context-utm_campaign'?: string;
|
|
58
|
-
readonly 'Prepr-Context-initial_referral'?: string;
|
|
59
|
-
readonly 'Prepr-Visitor-IP'?: string;
|
|
60
|
-
readonly 'Prepr-Hubspot-Id'?: string;
|
|
61
|
-
readonly 'Prepr-Customer-Id-Created'?: 'true';
|
|
62
|
-
/** The visitor's browser User-Agent, used by the API for device detection. */
|
|
63
|
-
readonly 'User-Agent'?: string;
|
|
64
|
-
/** @deprecated Never populated; the visitor's value is under `User-Agent`. */
|
|
65
|
-
readonly 'Prepr-User-Agent'?: string;
|
|
66
|
-
readonly 'Prepr-Package'?: string;
|
|
67
|
-
}
|
|
68
|
-
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR';
|
|
69
|
-
|
|
70
|
-
interface PreprMiddlewareOptions {
|
|
71
|
-
/** Enable preview-mode headers (segment/AB overrides, preview bar). */
|
|
72
|
-
preview?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Disable features app-wide. Pass the same object you give the toolbar: a
|
|
75
|
-
* disabled feature injects no header and persists no cookie, whatever the
|
|
76
|
-
* request carries.
|
|
77
|
-
*/
|
|
78
|
-
features?: PreprFeatures;
|
|
79
|
-
/** Override the version reported in Prepr-Package (mainly for tests). */
|
|
80
|
-
version?: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Structural stand-in for h3's `H3Event`, so this package needs no build-time
|
|
85
|
-
* dependency on `h3`/`nuxt`. Only the fields `handlePreprRequest` uses.
|
|
86
|
-
*
|
|
87
|
-
* `node` ties this to Nitro's Node.js preset (the Nuxt default). Edge presets
|
|
88
|
-
* expose no raw Node request/response to fold headers back onto.
|
|
89
|
-
*/
|
|
90
|
-
interface H3EventLike {
|
|
91
|
-
node: {
|
|
92
|
-
req: {
|
|
93
|
-
url?: string;
|
|
94
|
-
headers: Record<string, string | string[] | undefined>;
|
|
95
|
-
};
|
|
96
|
-
res: {
|
|
97
|
-
/** Node's `ServerResponse.appendHeader` (Node >= 18.3). */
|
|
98
|
-
appendHeader(name: string, value: string): unknown;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
/** Request-scoped bag shared with route handlers and Vue via `useRequestEvent`. */
|
|
102
|
-
context: Record<string, unknown>;
|
|
103
|
-
}
|
|
104
|
-
/** Key under which `handlePreprRequest` mirrors the forwarded Prepr `Headers`. */
|
|
105
|
-
declare const PREPR_CONTEXT_KEY = "prepr";
|
|
106
|
-
/**
|
|
107
|
-
* Nuxt server middleware entry point — call it inside `defineEventHandler` in
|
|
108
|
-
* `server/middleware/prepr.ts`:
|
|
109
|
-
*
|
|
110
|
-
* ```ts
|
|
111
|
-
* export default defineEventHandler(event => {
|
|
112
|
-
* handlePreprRequest(event, { preview: import.meta.dev });
|
|
113
|
-
* });
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* The computed Prepr headers are folded back onto the raw Node request
|
|
117
|
-
* (lowercased, as Node stores them), which is what `useRequestHeaders()` and
|
|
118
|
-
* downstream handlers read. The same `Headers` are mirrored onto
|
|
119
|
-
* `event.context.prepr` for callers who prefer an explicit read
|
|
120
|
-
* (`getPreprHeadersFromEvent`). Cookies are appended to the response.
|
|
121
|
-
*/
|
|
122
|
-
declare function handlePreprRequest(event: H3EventLike, options?: PreprMiddlewareOptions): void;
|
|
123
|
-
/**
|
|
124
|
-
* Personalization headers to forward to your GraphQL fetch, from the h3 event.
|
|
125
|
-
* Empty `Headers` if `handlePreprRequest` did not run, so the result is always
|
|
126
|
-
* safe to spread.
|
|
127
|
-
*/
|
|
128
|
-
declare function getPreprHeadersFromEvent(event: Pick<H3EventLike, 'context'>): Headers;
|
|
1
|
+
import { P as PreprHeaders, b as PreprFeatures, c as PreprToolbarProps } from './server-8v6OHbsw.cjs';
|
|
2
|
+
export { H as H3EventLike, d as PREPR_CONTEXT_KEY, a as PreprError, e as PreprMiddlewareOptions, f as extractAccessToken, g as getPreprHeadersFromEvent, h as handlePreprRequest, i as isPersonalizedResponse, v as validatePreprToken } from './server-8v6OHbsw.cjs';
|
|
129
3
|
|
|
130
4
|
/** Returns the Prepr Customer ID from the request headers. */
|
|
131
5
|
declare function getPreprUUID(headers: Headers): string | null;
|
|
@@ -142,23 +16,4 @@ declare function getPreprHeaders(headers: Headers): PreprHeaders;
|
|
|
142
16
|
*/
|
|
143
17
|
declare function getToolbarProps(headers: Headers, token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
|
|
144
18
|
|
|
145
|
-
|
|
146
|
-
declare class PreprError extends Error {
|
|
147
|
-
readonly code: PreprErrorCode;
|
|
148
|
-
readonly context?: string | undefined;
|
|
149
|
-
readonly originalError?: Error | undefined;
|
|
150
|
-
constructor(message: string, code: PreprErrorCode, context?: string | undefined, originalError?: Error | undefined);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Asserts `token` is the full `https://graphql.prepr.io/<token>` URL.
|
|
154
|
-
* @throws PreprError if the token is missing or not an HTTPS URL.
|
|
155
|
-
*/
|
|
156
|
-
declare function validatePreprToken(token: string): void;
|
|
157
|
-
/**
|
|
158
|
-
* Pulls the access token out of a GraphQL URL: `https://graphql.prepr.io/abc123`
|
|
159
|
-
* -> `abc123`.
|
|
160
|
-
* @throws PreprError if the URL is not a valid `graphql.prepr.io` URL.
|
|
161
|
-
*/
|
|
162
|
-
declare function extractAccessToken(graphqlUrl: string): string;
|
|
163
|
-
|
|
164
|
-
export { type H3EventLike, PREPR_CONTEXT_KEY, PreprError, type PreprMiddlewareOptions, extractAccessToken, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprHeadersFromEvent, getPreprUUID, getToolbarProps, handlePreprRequest, validatePreprToken };
|
|
19
|
+
export { getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps };
|
package/dist/nuxt/index.d.ts
CHANGED
|
@@ -1,131 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly name: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Per-feature config. `false` is shorthand for `{ enabled: false }`; the object
|
|
7
|
-
* form leaves room for per-feature options later without a breaking change.
|
|
8
|
-
*/
|
|
9
|
-
type PreprFeatureConfig = boolean | {
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
};
|
|
12
|
-
/** Toolkit features a consumer can turn off. Omitted keys stay enabled. */
|
|
13
|
-
interface PreprFeatures {
|
|
14
|
-
/** Segment picker, `Prepr-Segments` header and its cookie/query param. */
|
|
15
|
-
segments?: PreprFeatureConfig;
|
|
16
|
-
/** A/B variant switch, `Prepr-ABtesting` header and its cookie/query param. */
|
|
17
|
-
abTesting?: PreprFeatureConfig;
|
|
18
|
-
/**
|
|
19
|
-
* The site's own click-to-edit: the toolbar's Edit mode control, the stega
|
|
20
|
-
* tooltip/overlay and the close-edit pill.
|
|
21
|
-
*
|
|
22
|
-
* NOT a security control, and NOT the Prepr editor's live preview. When the
|
|
23
|
-
* site is framed by the editor, `prepr:initVE` still activates edit mode —
|
|
24
|
-
* that is the CMS operating inside its own iframe, not an affordance offered
|
|
25
|
-
* to visitors. See iframe-bridge.ts.
|
|
26
|
-
*/
|
|
27
|
-
editMode?: PreprFeatureConfig;
|
|
28
|
-
}
|
|
29
|
-
interface PreprToolbarProps {
|
|
30
|
-
/**
|
|
31
|
-
* Server-resolved active segment. Optional: omit it with `segments`
|
|
32
|
-
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
33
|
-
* the persisted cookie is used.
|
|
34
|
-
*/
|
|
35
|
-
readonly activeSegment?: string | null;
|
|
36
|
-
/**
|
|
37
|
-
* Server-resolved active A/B variant. Optional: omit it with `abTesting`
|
|
38
|
-
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
39
|
-
* the persisted cookie is used.
|
|
40
|
-
*/
|
|
41
|
-
readonly activeVariant?: string | null;
|
|
42
|
-
/** Available segments to personalize on. */
|
|
43
|
-
readonly segments?: readonly PreprSegment[];
|
|
44
|
-
/** @deprecated Alias for `segments`. */
|
|
45
|
-
readonly data?: readonly PreprSegment[];
|
|
46
|
-
}
|
|
47
|
-
type PreprVariant = 'A' | 'B';
|
|
48
|
-
interface PreprHeaders {
|
|
49
|
-
readonly 'prepr-customer-id'?: string;
|
|
50
|
-
readonly 'Prepr-Segments'?: string;
|
|
51
|
-
readonly 'Prepr-ABtesting'?: PreprVariant;
|
|
52
|
-
readonly 'Prepr-Preview-Bar'?: 'true';
|
|
53
|
-
readonly 'Prepr-Context-utm_source'?: string;
|
|
54
|
-
readonly 'Prepr-Context-utm_medium'?: string;
|
|
55
|
-
readonly 'Prepr-Context-utm_term'?: string;
|
|
56
|
-
readonly 'Prepr-Context-utm_content'?: string;
|
|
57
|
-
readonly 'Prepr-Context-utm_campaign'?: string;
|
|
58
|
-
readonly 'Prepr-Context-initial_referral'?: string;
|
|
59
|
-
readonly 'Prepr-Visitor-IP'?: string;
|
|
60
|
-
readonly 'Prepr-Hubspot-Id'?: string;
|
|
61
|
-
readonly 'Prepr-Customer-Id-Created'?: 'true';
|
|
62
|
-
/** The visitor's browser User-Agent, used by the API for device detection. */
|
|
63
|
-
readonly 'User-Agent'?: string;
|
|
64
|
-
/** @deprecated Never populated; the visitor's value is under `User-Agent`. */
|
|
65
|
-
readonly 'Prepr-User-Agent'?: string;
|
|
66
|
-
readonly 'Prepr-Package'?: string;
|
|
67
|
-
}
|
|
68
|
-
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR';
|
|
69
|
-
|
|
70
|
-
interface PreprMiddlewareOptions {
|
|
71
|
-
/** Enable preview-mode headers (segment/AB overrides, preview bar). */
|
|
72
|
-
preview?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Disable features app-wide. Pass the same object you give the toolbar: a
|
|
75
|
-
* disabled feature injects no header and persists no cookie, whatever the
|
|
76
|
-
* request carries.
|
|
77
|
-
*/
|
|
78
|
-
features?: PreprFeatures;
|
|
79
|
-
/** Override the version reported in Prepr-Package (mainly for tests). */
|
|
80
|
-
version?: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Structural stand-in for h3's `H3Event`, so this package needs no build-time
|
|
85
|
-
* dependency on `h3`/`nuxt`. Only the fields `handlePreprRequest` uses.
|
|
86
|
-
*
|
|
87
|
-
* `node` ties this to Nitro's Node.js preset (the Nuxt default). Edge presets
|
|
88
|
-
* expose no raw Node request/response to fold headers back onto.
|
|
89
|
-
*/
|
|
90
|
-
interface H3EventLike {
|
|
91
|
-
node: {
|
|
92
|
-
req: {
|
|
93
|
-
url?: string;
|
|
94
|
-
headers: Record<string, string | string[] | undefined>;
|
|
95
|
-
};
|
|
96
|
-
res: {
|
|
97
|
-
/** Node's `ServerResponse.appendHeader` (Node >= 18.3). */
|
|
98
|
-
appendHeader(name: string, value: string): unknown;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
/** Request-scoped bag shared with route handlers and Vue via `useRequestEvent`. */
|
|
102
|
-
context: Record<string, unknown>;
|
|
103
|
-
}
|
|
104
|
-
/** Key under which `handlePreprRequest` mirrors the forwarded Prepr `Headers`. */
|
|
105
|
-
declare const PREPR_CONTEXT_KEY = "prepr";
|
|
106
|
-
/**
|
|
107
|
-
* Nuxt server middleware entry point — call it inside `defineEventHandler` in
|
|
108
|
-
* `server/middleware/prepr.ts`:
|
|
109
|
-
*
|
|
110
|
-
* ```ts
|
|
111
|
-
* export default defineEventHandler(event => {
|
|
112
|
-
* handlePreprRequest(event, { preview: import.meta.dev });
|
|
113
|
-
* });
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* The computed Prepr headers are folded back onto the raw Node request
|
|
117
|
-
* (lowercased, as Node stores them), which is what `useRequestHeaders()` and
|
|
118
|
-
* downstream handlers read. The same `Headers` are mirrored onto
|
|
119
|
-
* `event.context.prepr` for callers who prefer an explicit read
|
|
120
|
-
* (`getPreprHeadersFromEvent`). Cookies are appended to the response.
|
|
121
|
-
*/
|
|
122
|
-
declare function handlePreprRequest(event: H3EventLike, options?: PreprMiddlewareOptions): void;
|
|
123
|
-
/**
|
|
124
|
-
* Personalization headers to forward to your GraphQL fetch, from the h3 event.
|
|
125
|
-
* Empty `Headers` if `handlePreprRequest` did not run, so the result is always
|
|
126
|
-
* safe to spread.
|
|
127
|
-
*/
|
|
128
|
-
declare function getPreprHeadersFromEvent(event: Pick<H3EventLike, 'context'>): Headers;
|
|
1
|
+
import { P as PreprHeaders, b as PreprFeatures, c as PreprToolbarProps } from './server-8v6OHbsw.js';
|
|
2
|
+
export { H as H3EventLike, d as PREPR_CONTEXT_KEY, a as PreprError, e as PreprMiddlewareOptions, f as extractAccessToken, g as getPreprHeadersFromEvent, h as handlePreprRequest, i as isPersonalizedResponse, v as validatePreprToken } from './server-8v6OHbsw.js';
|
|
129
3
|
|
|
130
4
|
/** Returns the Prepr Customer ID from the request headers. */
|
|
131
5
|
declare function getPreprUUID(headers: Headers): string | null;
|
|
@@ -142,23 +16,4 @@ declare function getPreprHeaders(headers: Headers): PreprHeaders;
|
|
|
142
16
|
*/
|
|
143
17
|
declare function getToolbarProps(headers: Headers, token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
|
|
144
18
|
|
|
145
|
-
|
|
146
|
-
declare class PreprError extends Error {
|
|
147
|
-
readonly code: PreprErrorCode;
|
|
148
|
-
readonly context?: string | undefined;
|
|
149
|
-
readonly originalError?: Error | undefined;
|
|
150
|
-
constructor(message: string, code: PreprErrorCode, context?: string | undefined, originalError?: Error | undefined);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Asserts `token` is the full `https://graphql.prepr.io/<token>` URL.
|
|
154
|
-
* @throws PreprError if the token is missing or not an HTTPS URL.
|
|
155
|
-
*/
|
|
156
|
-
declare function validatePreprToken(token: string): void;
|
|
157
|
-
/**
|
|
158
|
-
* Pulls the access token out of a GraphQL URL: `https://graphql.prepr.io/abc123`
|
|
159
|
-
* -> `abc123`.
|
|
160
|
-
* @throws PreprError if the URL is not a valid `graphql.prepr.io` URL.
|
|
161
|
-
*/
|
|
162
|
-
declare function extractAccessToken(graphqlUrl: string): string;
|
|
163
|
-
|
|
164
|
-
export { type H3EventLike, PREPR_CONTEXT_KEY, PreprError, type PreprMiddlewareOptions, extractAccessToken, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprHeadersFromEvent, getPreprUUID, getToolbarProps, handlePreprRequest, validatePreprToken };
|
|
19
|
+
export { getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps };
|