@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.
Files changed (78) hide show
  1. package/README.md +415 -27
  2. package/dist/astro/chunk-O7N6GPAH.js +173 -0
  3. package/dist/astro/graphql.cjs +1030 -0
  4. package/dist/astro/graphql.d.cts +305 -0
  5. package/dist/astro/graphql.d.ts +305 -0
  6. package/dist/astro/graphql.js +936 -0
  7. package/dist/astro/index-XT_z-RYT.d.cts +130 -0
  8. package/dist/astro/index-XT_z-RYT.d.ts +130 -0
  9. package/dist/astro/index.cjs +14 -1
  10. package/dist/astro/index.d.cts +1 -120
  11. package/dist/astro/index.d.ts +1 -120
  12. package/dist/astro/index.js +15 -153
  13. package/dist/chunk-3JLWZQ37.js +179 -0
  14. package/dist/chunk-3NCEVJJ3.js +10 -0
  15. package/dist/chunk-S5RWVMDJ.js +148 -0
  16. package/dist/chunk-TBKSBXGH.js +452 -0
  17. package/dist/{chunk-FLPNN3CV.js → chunk-VI6QZTBM.js} +73 -276
  18. package/dist/chunk-YWIKKWBR.js +26 -0
  19. package/dist/graphql/codegen.cjs +510 -0
  20. package/dist/graphql/codegen.d.cts +23 -0
  21. package/dist/graphql/codegen.d.ts +23 -0
  22. package/dist/graphql/codegen.js +99 -0
  23. package/dist/graphql.cjs +941 -0
  24. package/dist/graphql.d.cts +305 -0
  25. package/dist/graphql.d.ts +305 -0
  26. package/dist/graphql.js +419 -0
  27. package/dist/index.cjs +76 -119
  28. package/dist/index.d.cts +12 -64
  29. package/dist/index.d.ts +12 -64
  30. package/dist/index.js +27 -167
  31. package/dist/nextjs/chunk-BQ6IGSH6.js +231 -0
  32. package/dist/nextjs/components.cjs +190 -122
  33. package/dist/nextjs/components.d.cts +33 -2
  34. package/dist/nextjs/components.d.ts +33 -2
  35. package/dist/nextjs/components.js +133 -4
  36. package/dist/nextjs/graphql.cjs +1362 -0
  37. package/dist/nextjs/graphql.d.cts +435 -0
  38. package/dist/nextjs/graphql.d.ts +435 -0
  39. package/dist/nextjs/graphql.js +1261 -0
  40. package/dist/nextjs/index.cjs +126 -6
  41. package/dist/nextjs/index.d.cts +53 -147
  42. package/dist/nextjs/index.d.ts +53 -147
  43. package/dist/nextjs/index.js +113 -203
  44. package/dist/nextjs/server-CjpELYvq.d.cts +156 -0
  45. package/dist/nextjs/server-CjpELYvq.d.ts +156 -0
  46. package/dist/nuxt/chunk-IQDSBPDN.js +417 -0
  47. package/dist/nuxt/graphql.cjs +1037 -0
  48. package/dist/nuxt/graphql.d.cts +302 -0
  49. package/dist/nuxt/graphql.d.ts +302 -0
  50. package/dist/nuxt/graphql.js +937 -0
  51. package/dist/nuxt/index.cjs +14 -1
  52. package/dist/nuxt/index.d.cts +3 -148
  53. package/dist/nuxt/index.d.ts +3 -148
  54. package/dist/nuxt/index.js +15 -391
  55. package/dist/nuxt/server-8v6OHbsw.d.cts +158 -0
  56. package/dist/nuxt/server-8v6OHbsw.d.ts +158 -0
  57. package/dist/pixel-DwW7cXJm.d.cts +49 -0
  58. package/dist/pixel-DwW7cXJm.d.ts +49 -0
  59. package/dist/react/components.cjs +88 -120
  60. package/dist/react/components.d.cts +2 -8
  61. package/dist/react/components.d.ts +2 -8
  62. package/dist/react/components.js +88 -120
  63. package/dist/server-Brr1UgtW.d.ts +59 -0
  64. package/dist/server-DJuS3YU0.d.cts +59 -0
  65. package/dist/sveltekit/chunk-OKYZ6HPH.js +413 -0
  66. package/dist/sveltekit/graphql.cjs +1043 -0
  67. package/dist/sveltekit/graphql.d.cts +307 -0
  68. package/dist/sveltekit/graphql.d.ts +307 -0
  69. package/dist/sveltekit/graphql.js +943 -0
  70. package/dist/sveltekit/index.cjs +14 -1
  71. package/dist/sveltekit/index.d.cts +3 -88
  72. package/dist/sveltekit/index.d.ts +3 -88
  73. package/dist/sveltekit/index.js +15 -387
  74. package/dist/sveltekit/server-CO847mEV.d.cts +98 -0
  75. package/dist/sveltekit/server-CO847mEV.d.ts +98 -0
  76. package/dist/{pixel-B3oQNbZ3.d.cts → types-BYH9XqmN.d.cts} +4 -58
  77. package/dist/{pixel-B3oQNbZ3.d.ts → types-BYH9XqmN.d.ts} +4 -58
  78. package/package.json +36 -1
@@ -0,0 +1,435 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import { DocumentNode } from 'graphql';
3
+ import { P as PreprHeaders } from './server-CjpELYvq.js';
4
+ export { a as PreprError, i as isPersonalizedResponse } from './server-CjpELYvq.js';
5
+ import { ReactNode, ReactElement } from 'react';
6
+
7
+ /** Prepr's variant id for visitors outside every targeted segment. */
8
+ declare const PREPR_DEFAULT_VARIANT = "ALL_OTHER_USERS";
9
+
10
+ /** The variant ids Prepr chose for one visitor, per personalization group. */
11
+ type PreprDecisions = ReadonlyMap<string, readonly string[]>;
12
+ /**
13
+ * Variant ids per group from a decision response, de-duplicated and in
14
+ * Prepr's order. A visitor in several segments can get more than one variant
15
+ * of the same group, so each entry is a list.
16
+ */
17
+ declare function decisionsFrom(data: unknown): PreprDecisions;
18
+ interface ResolveVariantsOptions {
19
+ /**
20
+ * The visitor's per-group variants (from a decision query). Without it,
21
+ * personalization groups show their default variant.
22
+ */
23
+ decisions?: PreprDecisions;
24
+ /** The visitor's A/B bucket. Without it, A/B groups use the decision, then `A`. */
25
+ bucket?: string;
26
+ }
27
+ /**
28
+ * Keeps, in every list of a variants query result, only the variants this
29
+ * visitor gets, at any depth (page stacks, nested stacks, personalized
30
+ * buttons). Items outside a group are kept as they are.
31
+ */
32
+ declare function resolveVariants<T>(data: T, options?: ResolveVariantsOptions): T;
33
+
34
+ interface FieldInfo {
35
+ /** Named type of the field, without list/non-null wrappers. */
36
+ type: string;
37
+ /** The field accepts Prepr's `personalize` argument (a stack). */
38
+ personalizable: boolean;
39
+ }
40
+ interface TypeInfo {
41
+ fields: Record<string, FieldInfo>;
42
+ /** Members of a union or implementations of an interface. */
43
+ possibleTypes: string[];
44
+ hasContext: boolean;
45
+ }
46
+ /** The slice of the schema the variant transforms need. */
47
+ interface PreprSchemaInfo {
48
+ queryType: string;
49
+ types: Record<string, TypeInfo>;
50
+ }
51
+
52
+ /** A run of stack items that renders the same way: see {@link splitStack}. */
53
+ interface PreprStackBlock<T> {
54
+ key: string;
55
+ items: T[];
56
+ /**
57
+ * Rendered position of the block's first item: a group (whichever variant
58
+ * shows) takes one position, any other item one each. Use it for anything
59
+ * that depends on page position, like which section owns the h1.
60
+ */
61
+ index: number;
62
+ /**
63
+ * Some item in the block (or nested inside one) is a segment variant, so
64
+ * the block depends on the visitor and is decided per request.
65
+ */
66
+ personalized: boolean;
67
+ /**
68
+ * Some item in the block (or nested inside one) is an A/B variant. Without
69
+ * a known bucket, such a block renders once per bucket and the visitor's
70
+ * bucket is picked in the browser before first paint.
71
+ */
72
+ abTest: boolean;
73
+ }
74
+ /**
75
+ * Splits a variants-query stack into blocks. Each personalization or A/B
76
+ * group becomes one block (a variant can hold a different number of items
77
+ * than the default); consecutive items that never vary are merged.
78
+ */
79
+ declare function splitStack<T>(items: readonly T[]): PreprStackBlock<T>[];
80
+
81
+ /** The attribute Prepr's tracking pixel reads impressions and conversions from. */
82
+ interface PreprVariantProps {
83
+ 'data-prepr-variant-key'?: string;
84
+ }
85
+ /**
86
+ * Attributes that let Prepr's tracking pixel count impressions of this item's
87
+ * variant, for an item from a query run with `variants: true`. Spread them on
88
+ * the element that shows the item; an item outside any personalization or A/B
89
+ * group gets none.
90
+ *
91
+ * Items rendered by the Next.js `PreprStack` are tagged for you. Reach for this
92
+ * for items nested inside them (cards, buttons, models in a section) and in
93
+ * frameworks without `PreprStack`.
94
+ *
95
+ * @example
96
+ * <article {...preprVariantProps(card)}>…</article>
97
+ */
98
+ declare function preprVariantProps(item: unknown): PreprVariantProps;
99
+
100
+ /**
101
+ * The schema facts the query rewrites need, from `loadPreprSchema`. Pass it
102
+ * along; its shape is not part of the public API.
103
+ */
104
+ type PreprSchema = PreprSchemaInfo;
105
+ /**
106
+ * Your query, asking for every personalization and A/B variant: what
107
+ * `query(..., { variants: true })` sends, as a string for your own GraphQL
108
+ * client. The result is the same for every visitor, so cache it like any
109
+ * other content query, and render it with `resolveVariants` or `PreprStack`.
110
+ *
111
+ * A query without personalizable fields comes back unchanged (minified).
112
+ */
113
+ declare function toVariantsQuery(document: PreprDocument<unknown, unknown> | string, schema: PreprSchema): string;
114
+ /**
115
+ * The per-visitor decision query for the same query: send it with the
116
+ * visitor's Prepr headers, never cached, and pass the response's `data` to
117
+ * `decisionsFrom`.
118
+ *
119
+ * Pass the variants result as `from` whenever you have it: the query then
120
+ * asks only about the lists that hold segment groups on this page, which is
121
+ * a few hundred bytes instead of the whole page and markedly faster for a
122
+ * visitor Prepr has not seen before. Without `from` it asks about every
123
+ * personalizable list. `topLevelOnly` stops at the first personalizable list
124
+ * on each path, for middleware that decides only the top of a stack.
125
+ *
126
+ * Null when there is nothing to decide: send no request then.
127
+ */
128
+ declare function toDecisionQuery(document: PreprDocument<unknown, unknown> | string, schema: PreprSchema, options?: {
129
+ from?: unknown;
130
+ topLevelOnly?: boolean;
131
+ }): string | null;
132
+
133
+ /**
134
+ * A GraphQL document accepted by `query`: a plain string, graphql-codegen's
135
+ * `TypedDocumentString` (`documentMode: 'string'`), or any `DocumentNode`,
136
+ * including codegen's default `TypedDocumentNode` output.
137
+ *
138
+ * The phantom `__apiType` field is how codegen attaches result and variable
139
+ * types; matching it structurally keeps `@graphql-typed-document-node/core`
140
+ * out of this package.
141
+ */
142
+ type PreprDocument<TResult, TVariables> = string | ({
143
+ __apiType?: (variables: TVariables) => TResult;
144
+ } & (String | DocumentNode));
145
+ /**
146
+ * How stega markers are stripped from the response:
147
+ * - `'urls'`: only from values under URL-like keys (`url`, `slug`, `link`,
148
+ * `href`), where markers break links. Text keeps its markers for
149
+ * click-to-edit.
150
+ * - `'all'`: from every string.
151
+ * - `'none'`: never.
152
+ */
153
+ type PreprStegaMode = 'urls' | 'all' | 'none';
154
+ interface PreprClientOptions {
155
+ /** Full Prepr GraphQL URL, `https://graphql.prepr.io/<token>`. */
156
+ url: string;
157
+ /**
158
+ * Fetch implementation. Defaults to the global `fetch`, read at call time so
159
+ * framework-patched versions (such as Next.js's) are used.
160
+ */
161
+ fetch?: typeof fetch;
162
+ /**
163
+ * Preview mode: every query skips the HTTP cache so editors see each edit,
164
+ * and stega defaults to `'urls'` so click-to-edit keeps working.
165
+ */
166
+ preview?: boolean;
167
+ /** Default: `'urls'` when `preview` is true, otherwise `'all'`. */
168
+ stega?: PreprStegaMode;
169
+ /**
170
+ * Send queries as a GET with the request body base64-encoded in a
171
+ * `Fastly-Query` header, which Prepr's edge serves from the nearest point
172
+ * of presence (about half the latency of a POST in our measurements).
173
+ * Queries too large for a header still go as a POST. Off by default: it
174
+ * relies on Prepr edge behavior that is not part of the documented API.
175
+ */
176
+ fastlyQuery?: boolean;
177
+ /**
178
+ * @internal Fetch options for the one-time schema introspection, so a
179
+ * framework wrapper can put it in its data cache.
180
+ */
181
+ schemaInit?: RequestInit;
182
+ /**
183
+ * Headers sent with every request, such as a header a proxy in front of the
184
+ * API requires. They are fixed when the client is created, so they cannot
185
+ * vary per visitor and do not stop responses from being cached. Put
186
+ * per-request values in the query's `headers` instead.
187
+ */
188
+ headers?: HeadersInit;
189
+ }
190
+ interface PreprQueryOptions {
191
+ /**
192
+ * Prepr headers to forward, typically from `getPreprHeaders`. Passing any
193
+ * headers object, even an empty one, makes the request `no-store`: the
194
+ * response may be personalized and must not be shared between visitors.
195
+ */
196
+ headers?: PreprHeaders | HeadersInit;
197
+ /**
198
+ * Extra fetch options such as `signal`. `method` and `body` are set by the
199
+ * client. `init.headers` are merged like `headers`, and also make the
200
+ * request `no-store`.
201
+ */
202
+ init?: RequestInit;
203
+ /** Per-query fetch, overriding the client's (e.g. SvelteKit's `event.fetch`). */
204
+ fetch?: typeof fetch;
205
+ /**
206
+ * Fetch every variant instead of the visitor's: `personalize: false` is
207
+ * added to every personalizable field in the query, at any depth, and each
208
+ * item gets its `_context` (under `_preprContext`). The result is the same
209
+ * for every visitor, so it can be cached; pass it to `resolveVariants` with
210
+ * the visitor's `decide()` result to get what they see.
211
+ *
212
+ * The client learns which fields are personalizable from one schema
213
+ * introspection request, made on first use.
214
+ */
215
+ variants?: boolean;
216
+ }
217
+ /** Options for `decide()`. */
218
+ interface PreprDecideOptions extends Omit<PreprQueryOptions, 'variants'> {
219
+ /**
220
+ * The `variants: true` result this decision is for (the whole `data`
221
+ * object). The decision query then asks only about the fields that hold
222
+ * segment personalization groups, and is skipped entirely when there are
223
+ * none, e.g. on pages with only A/B tests or no personalization.
224
+ */
225
+ from?: unknown;
226
+ /**
227
+ * @internal Ask only about the first personalizable list on each path,
228
+ * without `from`: what middleware needs for groups at the top of a stack.
229
+ */
230
+ topLevelOnly?: boolean;
231
+ }
232
+ interface PreprQueryResult<TResult> {
233
+ data: TResult;
234
+ /**
235
+ * True when Prepr reports, through the response's `Vary` header, that the
236
+ * queried fields hold segment variants or A/B tests.
237
+ */
238
+ personalized: boolean;
239
+ }
240
+
241
+ /**
242
+ * Loads what `toVariantsQuery` and `toDecisionQuery` need to know about your
243
+ * Prepr schema (which fields take `personalize`, which types can hold
244
+ * variants) with one introspection request, kept in memory per URL. For a
245
+ * site that uses its own GraphQL client; `createPreprClient` does this
246
+ * itself.
247
+ *
248
+ * Load it once at startup or lazily before the first rewrite. Schema changes
249
+ * in Prepr take effect after a restart or redeploy.
250
+ *
251
+ * @throws PreprError when the URL is invalid or the request fails; the URL,
252
+ * which holds your access token, is never part of the message.
253
+ */
254
+ declare function loadPreprSchema(url: string, options?: {
255
+ fetch?: typeof fetch;
256
+ }): Promise<PreprSchemaInfo>;
257
+
258
+ /** The cookie `resolveDecisions` writes and the `PreprStack` switch reads. */
259
+ declare const PREPR_DECISIONS_COOKIE = "prepr_decisions";
260
+
261
+ interface PreprStackProps<T> {
262
+ /** A stack (e.g. `page.content`) from a query run with `variants: true`. */
263
+ items: readonly T[];
264
+ /**
265
+ * The visitor's decisions, as a promise from `decide()`. Only the parts
266
+ * that vary per segment wait for it; a failed decision falls back to the
267
+ * default variants instead of failing the page.
268
+ */
269
+ decisions: Promise<PreprDecisions>;
270
+ /**
271
+ * Renders resolved stack items, e.g. your section switch. `index` is the
272
+ * position of the block's first item in the whole stack, for anything that
273
+ * depends on page position, such as which section owns the h1 or the
274
+ * priority image.
275
+ *
276
+ * `placeholder` is true while this render only stands in for the visitor's
277
+ * variant of a segment group (the default variant, shown until the
278
+ * decision streams in). Leave `data-prepr-variant-key` off it: the tracking
279
+ * pixel would count an impression of a variant the visitor may never get.
280
+ */
281
+ render: (items: T[], position: {
282
+ index: number;
283
+ placeholder: boolean;
284
+ }) => ReactNode;
285
+ /**
286
+ * The visitor's A/B bucket, when the route already knows it (for example
287
+ * from a URL segment). Leave it out to render both variants of each A/B
288
+ * test and pick the visitor's in the browser before first paint.
289
+ */
290
+ bucket?: string;
291
+ /** Nonce for the inline A/B switch script, under a strict CSP. */
292
+ nonce?: string;
293
+ /**
294
+ * Tag each personalization and A/B variant for Prepr's tracking pixel, so
295
+ * it counts impressions (and clicks on `data-prepr-variant-event` elements
296
+ * inside) without `data-prepr-variant-key` in your components. Default
297
+ * `false`.
298
+ *
299
+ * Each item's key goes on the element `render` returns for it, in order,
300
+ * once the page has hydrated. Each variant gets a wrapper with
301
+ * `display: contents`: it takes no box, but CSS child combinators (`>`) and
302
+ * `:first-child` from the stack's parent no longer reach the sections. Lists
303
+ * nested inside an item are not tagged; use `preprVariantProps` there.
304
+ */
305
+ trackVariants?: boolean;
306
+ /**
307
+ * How many blocks, from the top, are on screen before the visitor scrolls.
308
+ * Default `0`.
309
+ *
310
+ * Their segment groups do not stream: every variant is in the cached page,
311
+ * and the variant the proxy decided (`prepr.resolveDecisions`) shows before
312
+ * first paint, so nothing on screen changes while the page loads. Without
313
+ * a decision (no cookie yet, or the proxy's lookup failed) the default
314
+ * variant shows. Costs the HTML of the other variants; images in them still
315
+ * download. An item with a segment group nested inside it keeps streaming.
316
+ */
317
+ aboveTheFold?: number;
318
+ }
319
+ /**
320
+ * Renders a personalized stack with Cache Components / Partial Prerendering.
321
+ *
322
+ * - Items that never vary render in the static shell.
323
+ * - A/B tests render in the static shell too, once per bucket; a tiny inline
324
+ * script shows the visitor's bucket (from `resolvePreprBucket`'s cookie)
325
+ * before first paint, so no variant streams or swaps in. `A` is the
326
+ * default. Pass `bucket` instead when the route already knows it.
327
+ * - Each segment-personalized group, and each item with segment content
328
+ * nested inside it, gets its own `<Suspense>` boundary: the default
329
+ * variant (possibly empty) is the fallback, and this visitor's variant
330
+ * streams in once `decisions` resolves. Because `items` holds every
331
+ * variant, a group with no default variant still gets its place.
332
+ *
333
+ * @example
334
+ * const data = await getPage(slug); // 'use cache' + query(..., { variants: true })
335
+ * <PreprStack
336
+ * items={data.Page.content}
337
+ * decisions={prepr.decide(PageDocument, { slug }, { from: data })}
338
+ * render={(items, { index }) => <Sections sections={items} offset={index} />}
339
+ * />
340
+ */
341
+ declare function PreprStack<T>({ items, decisions, render, bucket, nonce, trackVariants, aboveTheFold, }: PreprStackProps<T>): ReactElement;
342
+
343
+ interface PreprNextClientOptions extends PreprClientOptions {
344
+ /** Tags set on every cacheable fetch, for `revalidateTag`. Default `['prepr']`. */
345
+ cacheTags?: string[];
346
+ /**
347
+ * `next.revalidate` for cacheable fetches. Unset leaves the installed Next
348
+ * version's default in place. `false` caches until `revalidateTag` runs,
349
+ * which suits a publish webhook calling `revalidateTag('prepr')`.
350
+ */
351
+ revalidate?: number | false;
352
+ }
353
+ interface PreprNextQueryOptions extends PreprQueryOptions {
354
+ /**
355
+ * Forward the visitor's Prepr headers (read through `next/headers`) and
356
+ * skip the Data Cache. The route renders per request.
357
+ */
358
+ personalize?: boolean;
359
+ }
360
+ interface PreprNextClient {
361
+ /**
362
+ * Run a GraphQL query against Prepr.
363
+ *
364
+ * Without `personalize`, the fetch is tagged for `revalidateTag` and may be
365
+ * served from the Data Cache. Do not swallow errors thrown here without
366
+ * `unstable_rethrow`: Next.js signals dynamic rendering by throwing from
367
+ * inside fetch, and the client passes those signals through untouched.
368
+ *
369
+ * @throws PreprError — `INVALID_DOCUMENT`, `FETCH_ERROR`, `HTTP_ERROR`,
370
+ * `INVALID_RESPONSE` or `GRAPHQL_ERROR`.
371
+ */
372
+ query<TResult, TVariables>(document: PreprDocument<TResult, TVariables>, variables?: TVariables, options?: PreprNextQueryOptions): Promise<PreprQueryResult<TResult>>;
373
+ /**
374
+ * Which variant of each personalization and A/B group this visitor gets,
375
+ * for the query you render with `variants: true`. Forwards the visitor's
376
+ * Prepr headers (read through `next/headers`); never cached. Prepr decides
377
+ * from everything the middleware forwards: customer profile, UTM
378
+ * parameters, visitor IP, HubSpot id.
379
+ *
380
+ * Start it without awaiting and hand the promise to `PreprStack`: only the
381
+ * parts that vary per visitor wait for it.
382
+ */
383
+ decide<TVariables>(document: PreprDocument<unknown, TVariables>, variables?: TVariables, options?: PreprDecideOptions): Promise<PreprDecisions>;
384
+ /**
385
+ * Whether the query's result holds an A/B test: see `resolvePreprBucket`'s
386
+ * `onlyIf`. Never reads request headers, so it also works in middleware.
387
+ */
388
+ hasAbTests<TVariables>(document: PreprDocument<unknown, TVariables>, variables?: TVariables): Promise<boolean>;
389
+ /**
390
+ * In middleware (`proxy.ts`): asks Prepr which segment variant this visitor
391
+ * gets for each personalization group on the page, and stores the answer in
392
+ * the `prepr_decisions` cookie on `response`. `PreprStack` with
393
+ * `aboveTheFold` then shows those variants before first paint instead of
394
+ * streaming them in.
395
+ *
396
+ * Call it after `createPreprMiddleware`, whose visitor headers (customer id,
397
+ * UTM parameters, IP, HubSpot id) it forwards. A decision is an uncached
398
+ * Prepr request, made once per visit by default (see `reuse`); limit it
399
+ * with `onlyIf` to pages whose personalized content is above the fold.
400
+ * Pages without segment groups are skipped after a cached check. Never throws and gives up after `timeoutMs`
401
+ * (default 1000): the default variant shows instead.
402
+ */
403
+ resolveDecisions<TVariables>(request: NextRequest, response: NextResponse, document: PreprDocument<unknown, TVariables>, variables?: TVariables, options?: {
404
+ timeoutMs?: number;
405
+ /**
406
+ * Reuse the stored decision for the rest of the visit instead of asking
407
+ * Prepr on every page view. Default `true`. Asks again when UTM
408
+ * parameters arrive, on a first visit, and when preview forces a
409
+ * segment. A visitor who joins a segment mid-visit (say, by submitting
410
+ * a form) sees the change from their next asked request.
411
+ */
412
+ reuse?: boolean;
413
+ /** Skip the decision when this resolves to false, e.g. for pages without a personalized hero. */
414
+ onlyIf?: () => boolean | Promise<boolean>;
415
+ }): Promise<void>;
416
+ }
417
+ /**
418
+ * Prepr GraphQL client for Next.js (App Router, server only).
419
+ *
420
+ * Headerless queries go through the Data Cache with `cacheTags`; queries with
421
+ * `personalize: true` forward the visitor's Prepr headers and are never
422
+ * cached.
423
+ *
424
+ * With Cache Components, run headerless queries inside `'use cache'` (the
425
+ * client's fetch tags carry over to the entry, so `revalidateTag` reaches it)
426
+ * and `personalize: true` queries inside `<Suspense>`: `personalize` reads
427
+ * request headers, which `'use cache'` forbids. A headerless query outside
428
+ * both only prerenders when `revalidate` is set. `preview: true` works inside `'use cache'`, but the entry is still
429
+ * cached unless draft mode is enabled, which makes Next skip cached entries.
430
+ *
431
+ * Requires the `graphql` package, which graphql-codegen already installs.
432
+ */
433
+ declare function createPreprClient(options: PreprNextClientOptions): PreprNextClient;
434
+
435
+ export { PREPR_DECISIONS_COOKIE, PREPR_DEFAULT_VARIANT, type PreprDecideOptions, type PreprDecisions, type PreprDocument, type PreprNextClient, type PreprNextClientOptions, type PreprNextQueryOptions, type PreprQueryResult, type PreprSchema, PreprStack, type PreprStackBlock, type PreprStackProps, type PreprStegaMode, type PreprVariantProps, type ResolveVariantsOptions, createPreprClient, decisionsFrom, loadPreprSchema, preprVariantProps, resolveVariants, splitStack, toDecisionQuery, toVariantsQuery };