@preprio/toolkit 0.5.0-rc.1 → 0.6.0-alpha.0

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 (69) hide show
  1. package/README.md +300 -19
  2. package/dist/astro/chunk-3UVUDDNY.js +173 -0
  3. package/dist/astro/graphql.cjs +983 -0
  4. package/dist/astro/graphql.d.cts +231 -0
  5. package/dist/astro/graphql.d.ts +231 -0
  6. package/dist/astro/graphql.js +893 -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-4JNKYIEV.js → chunk-BJ2LBLWO.js} +69 -268
  14. package/dist/chunk-DGZA7KX7.js +172 -0
  15. package/dist/chunk-YR7P4IWE.js +187 -0
  16. package/dist/graphql.cjs +894 -0
  17. package/dist/graphql.d.cts +231 -0
  18. package/dist/graphql.d.ts +231 -0
  19. package/dist/graphql.js +787 -0
  20. package/dist/index.cjs +74 -111
  21. package/dist/index.d.cts +11 -62
  22. package/dist/index.d.ts +11 -62
  23. package/dist/index.js +23 -167
  24. package/dist/nextjs/chunk-U4HXENF7.js +231 -0
  25. package/dist/nextjs/components.cjs +188 -114
  26. package/dist/nextjs/components.d.cts +33 -2
  27. package/dist/nextjs/components.d.ts +33 -2
  28. package/dist/nextjs/components.js +132 -4
  29. package/dist/nextjs/graphql.cjs +1315 -0
  30. package/dist/nextjs/graphql.d.cts +361 -0
  31. package/dist/nextjs/graphql.d.ts +361 -0
  32. package/dist/nextjs/graphql.js +1218 -0
  33. package/dist/nextjs/index.cjs +126 -6
  34. package/dist/nextjs/index.d.cts +53 -141
  35. package/dist/nextjs/index.d.ts +53 -141
  36. package/dist/nextjs/index.js +113 -203
  37. package/dist/nextjs/server-CjpELYvq.d.cts +156 -0
  38. package/dist/nextjs/server-CjpELYvq.d.ts +156 -0
  39. package/dist/nuxt/chunk-P6ENNAEE.js +417 -0
  40. package/dist/nuxt/graphql.cjs +990 -0
  41. package/dist/nuxt/graphql.d.cts +228 -0
  42. package/dist/nuxt/graphql.d.ts +228 -0
  43. package/dist/nuxt/graphql.js +894 -0
  44. package/dist/nuxt/index.cjs +14 -1
  45. package/dist/nuxt/index.d.cts +3 -148
  46. package/dist/nuxt/index.d.ts +3 -148
  47. package/dist/nuxt/index.js +15 -391
  48. package/dist/nuxt/server-8v6OHbsw.d.cts +158 -0
  49. package/dist/nuxt/server-8v6OHbsw.d.ts +158 -0
  50. package/dist/pixel-DwW7cXJm.d.cts +49 -0
  51. package/dist/pixel-DwW7cXJm.d.ts +49 -0
  52. package/dist/react/components.cjs +86 -112
  53. package/dist/react/components.js +86 -112
  54. package/dist/server-Brr1UgtW.d.ts +59 -0
  55. package/dist/server-DJuS3YU0.d.cts +59 -0
  56. package/dist/sveltekit/chunk-FSARVMG5.js +413 -0
  57. package/dist/sveltekit/graphql.cjs +996 -0
  58. package/dist/sveltekit/graphql.d.cts +233 -0
  59. package/dist/sveltekit/graphql.d.ts +233 -0
  60. package/dist/sveltekit/graphql.js +900 -0
  61. package/dist/sveltekit/index.cjs +14 -1
  62. package/dist/sveltekit/index.d.cts +3 -88
  63. package/dist/sveltekit/index.d.ts +3 -88
  64. package/dist/sveltekit/index.js +15 -387
  65. package/dist/sveltekit/server-CO847mEV.d.cts +98 -0
  66. package/dist/sveltekit/server-CO847mEV.d.ts +98 -0
  67. package/dist/{pixel-e1fUWl2Y.d.cts → types-BYH9XqmN.d.cts} +2 -50
  68. package/dist/{pixel-e1fUWl2Y.d.ts → types-BYH9XqmN.d.ts} +2 -50
  69. package/package.json +31 -1
@@ -0,0 +1,233 @@
1
+ import { DocumentNode } from 'graphql';
2
+ import { P as PreprHeaders } from './server-CO847mEV.cjs';
3
+ export { a as PreprError, i as isPersonalizedResponse } from './server-CO847mEV.cjs';
4
+
5
+ /** Prepr's variant id for visitors outside every targeted segment. */
6
+ declare const PREPR_DEFAULT_VARIANT = "ALL_OTHER_USERS";
7
+
8
+ /** The variant ids Prepr chose for one visitor, per personalization group. */
9
+ type PreprDecisions = ReadonlyMap<string, readonly string[]>;
10
+ interface ResolveVariantsOptions {
11
+ /**
12
+ * The visitor's per-group variants (from a decision query). Without it,
13
+ * personalization groups show their default variant.
14
+ */
15
+ decisions?: PreprDecisions;
16
+ /** The visitor's A/B bucket. Without it, A/B groups use the decision, then `A`. */
17
+ bucket?: string;
18
+ }
19
+ /**
20
+ * Keeps, in every list of a variants query result, only the variants this
21
+ * visitor gets, at any depth (page stacks, nested stacks, personalized
22
+ * buttons). Items outside a group are kept as they are.
23
+ */
24
+ declare function resolveVariants<T>(data: T, options?: ResolveVariantsOptions): T;
25
+
26
+ /** A run of stack items that renders the same way: see {@link splitStack}. */
27
+ interface PreprStackBlock<T> {
28
+ key: string;
29
+ items: T[];
30
+ /**
31
+ * Rendered position of the block's first item: a group (whichever variant
32
+ * shows) takes one position, any other item one each. Use it for anything
33
+ * that depends on page position, like which section owns the h1.
34
+ */
35
+ index: number;
36
+ /**
37
+ * Some item in the block (or nested inside one) is a segment variant, so
38
+ * the block depends on the visitor and is decided per request.
39
+ */
40
+ personalized: boolean;
41
+ /**
42
+ * Some item in the block (or nested inside one) is an A/B variant. Without
43
+ * a known bucket, such a block renders once per bucket and the visitor's
44
+ * bucket is picked in the browser before first paint.
45
+ */
46
+ abTest: boolean;
47
+ }
48
+ /**
49
+ * Splits a variants-query stack into blocks. Each personalization or A/B
50
+ * group becomes one block (a variant can hold a different number of items
51
+ * than the default); consecutive items that never vary are merged.
52
+ */
53
+ declare function splitStack<T>(items: readonly T[]): PreprStackBlock<T>[];
54
+
55
+ /** The attribute Prepr's tracking pixel reads impressions and conversions from. */
56
+ interface PreprVariantProps {
57
+ 'data-prepr-variant-key'?: string;
58
+ }
59
+ /**
60
+ * Attributes that let Prepr's tracking pixel count impressions of this item's
61
+ * variant, for an item from a query run with `variants: true`. Spread them on
62
+ * the element that shows the item; an item outside any personalization or A/B
63
+ * group gets none.
64
+ *
65
+ * Items rendered by the Next.js `PreprStack` are tagged for you. Reach for this
66
+ * for items nested inside them (cards, buttons, models in a section) and in
67
+ * frameworks without `PreprStack`.
68
+ *
69
+ * @example
70
+ * <article {...preprVariantProps(card)}>…</article>
71
+ */
72
+ declare function preprVariantProps(item: unknown): PreprVariantProps;
73
+
74
+ /**
75
+ * A GraphQL document accepted by `query`: a plain string, graphql-codegen's
76
+ * `TypedDocumentString` (`documentMode: 'string'`), or any `DocumentNode`,
77
+ * including codegen's default `TypedDocumentNode` output.
78
+ *
79
+ * The phantom `__apiType` field is how codegen attaches result and variable
80
+ * types; matching it structurally keeps `@graphql-typed-document-node/core`
81
+ * out of this package.
82
+ */
83
+ type PreprDocument<TResult, TVariables> = string | ({
84
+ __apiType?: (variables: TVariables) => TResult;
85
+ } & (String | DocumentNode));
86
+ /**
87
+ * How stega markers are stripped from the response:
88
+ * - `'urls'`: only from values under URL-like keys (`url`, `slug`, `link`,
89
+ * `href`), where markers break links. Text keeps its markers for
90
+ * click-to-edit.
91
+ * - `'all'`: from every string.
92
+ * - `'none'`: never.
93
+ */
94
+ type PreprStegaMode = 'urls' | 'all' | 'none';
95
+ interface PreprClientOptions {
96
+ /** Full Prepr GraphQL URL, `https://graphql.prepr.io/<token>`. */
97
+ url: string;
98
+ /**
99
+ * Fetch implementation. Defaults to the global `fetch`, read at call time so
100
+ * framework-patched versions (such as Next.js's) are used.
101
+ */
102
+ fetch?: typeof fetch;
103
+ /**
104
+ * Preview mode: every query skips the HTTP cache so editors see each edit,
105
+ * and stega defaults to `'urls'` so click-to-edit keeps working.
106
+ */
107
+ preview?: boolean;
108
+ /** Default: `'urls'` when `preview` is true, otherwise `'all'`. */
109
+ stega?: PreprStegaMode;
110
+ /**
111
+ * Send queries as a GET with the request body base64-encoded in a
112
+ * `Fastly-Query` header, which Prepr's edge serves from the nearest point
113
+ * of presence (about half the latency of a POST in our measurements).
114
+ * Queries too large for a header still go as a POST. Off by default: it
115
+ * relies on Prepr edge behavior that is not part of the documented API.
116
+ */
117
+ fastlyQuery?: boolean;
118
+ /**
119
+ * @internal Fetch options for the one-time schema introspection, so a
120
+ * framework wrapper can put it in its data cache.
121
+ */
122
+ schemaInit?: RequestInit;
123
+ /**
124
+ * Headers sent with every request, such as a header a proxy in front of the
125
+ * API requires. They are fixed when the client is created, so they cannot
126
+ * vary per visitor and do not stop responses from being cached. Put
127
+ * per-request values in the query's `headers` instead.
128
+ */
129
+ headers?: HeadersInit;
130
+ }
131
+ interface PreprQueryOptions {
132
+ /**
133
+ * Prepr headers to forward, typically from `getPreprHeaders`. Passing any
134
+ * headers object, even an empty one, makes the request `no-store`: the
135
+ * response may be personalized and must not be shared between visitors.
136
+ */
137
+ headers?: PreprHeaders | HeadersInit;
138
+ /**
139
+ * Extra fetch options such as `signal`. `method` and `body` are set by the
140
+ * client. `init.headers` are merged like `headers`, and also make the
141
+ * request `no-store`.
142
+ */
143
+ init?: RequestInit;
144
+ /** Per-query fetch, overriding the client's (e.g. SvelteKit's `event.fetch`). */
145
+ fetch?: typeof fetch;
146
+ /**
147
+ * Fetch every variant instead of the visitor's: `personalize: false` is
148
+ * added to every personalizable field in the query, at any depth, and each
149
+ * item gets its `_context` (under `_preprContext`). The result is the same
150
+ * for every visitor, so it can be cached; pass it to `resolveVariants` with
151
+ * the visitor's `decide()` result to get what they see.
152
+ *
153
+ * The client learns which fields are personalizable from one schema
154
+ * introspection request, made on first use.
155
+ */
156
+ variants?: boolean;
157
+ }
158
+ /** Options for `decide()`. */
159
+ interface PreprDecideOptions extends Omit<PreprQueryOptions, 'variants'> {
160
+ /**
161
+ * The `variants: true` result this decision is for (the whole `data`
162
+ * object). The decision query then asks only about the fields that hold
163
+ * segment personalization groups, and is skipped entirely when there are
164
+ * none, e.g. on pages with only A/B tests or no personalization.
165
+ */
166
+ from?: unknown;
167
+ /**
168
+ * @internal Ask only about the first personalizable list on each path,
169
+ * without `from`: what middleware needs for groups at the top of a stack.
170
+ */
171
+ topLevelOnly?: boolean;
172
+ }
173
+ interface PreprQueryResult<TResult> {
174
+ data: TResult;
175
+ /**
176
+ * True when Prepr reports, through the response's `Vary` header, that the
177
+ * queried fields hold segment variants or A/B tests.
178
+ */
179
+ personalized: boolean;
180
+ }
181
+
182
+ /**
183
+ * Query options for frameworks without an implicit request scope.
184
+ * `personalize: true` requires the request `event`; the compiler enforces it.
185
+ */
186
+ type PreprEventQueryOptions<TEvent> = PreprQueryOptions & ({
187
+ personalize?: false;
188
+ event?: TEvent;
189
+ } | {
190
+ personalize: true;
191
+ event: TEvent;
192
+ });
193
+ interface PreprEventClient<TEvent> {
194
+ /**
195
+ * Run a GraphQL query against Prepr. With `personalize: true`, the Prepr
196
+ * headers of `event` are forwarded and the request is `no-store`; without
197
+ * it the request is identical for every visitor.
198
+ *
199
+ * @throws PreprError — as `PreprClient.query`, plus `CONTEXT_ERROR` when
200
+ * `personalize` is true and no `event` is passed.
201
+ */
202
+ query<TResult, TVariables>(document: PreprDocument<TResult, TVariables>, variables?: TVariables, options?: PreprEventQueryOptions<TEvent>): Promise<PreprQueryResult<TResult>>;
203
+ /**
204
+ * Which variant of each group this visitor gets, for the query you render
205
+ * with `variants: true`. Forwards the Prepr headers of `event`.
206
+ *
207
+ * @throws PreprError — `CONTEXT_ERROR` without an `event`.
208
+ */
209
+ decide<TVariables>(document: PreprDocument<unknown, TVariables>, variables: TVariables | undefined, options: PreprDecideOptions & {
210
+ event: TEvent;
211
+ }): Promise<PreprDecisions>;
212
+ }
213
+
214
+ /**
215
+ * The part of a SvelteKit `RequestEvent` or load event the client reads.
216
+ * `locals` is typed `object` so SvelteKit's `App.Locals` interface fits.
217
+ */
218
+ interface PreprSvelteKitEvent {
219
+ request: Request;
220
+ locals?: object;
221
+ fetch?: typeof fetch;
222
+ }
223
+ /**
224
+ * Prepr GraphQL client for SvelteKit. Pass the load or endpoint event as
225
+ * `event`: its `fetch` is used for every request, so SvelteKit can dedupe
226
+ * and serialize it. With `personalize: true`, the Prepr headers
227
+ * `preprHandle` computed are forwarded.
228
+ *
229
+ * Requires the `graphql` package, which graphql-codegen already installs.
230
+ */
231
+ declare function createPreprClient(options: PreprClientOptions): PreprEventClient<PreprSvelteKitEvent>;
232
+
233
+ export { PREPR_DEFAULT_VARIANT, type PreprClientOptions, type PreprDecideOptions, type PreprDecisions, type PreprDocument, type PreprEventClient, type PreprEventQueryOptions, type PreprQueryResult, type PreprStackBlock, type PreprStegaMode, type PreprSvelteKitEvent, type PreprVariantProps, type ResolveVariantsOptions, createPreprClient, preprVariantProps, resolveVariants, splitStack };
@@ -0,0 +1,233 @@
1
+ import { DocumentNode } from 'graphql';
2
+ import { P as PreprHeaders } from './server-CO847mEV.js';
3
+ export { a as PreprError, i as isPersonalizedResponse } from './server-CO847mEV.js';
4
+
5
+ /** Prepr's variant id for visitors outside every targeted segment. */
6
+ declare const PREPR_DEFAULT_VARIANT = "ALL_OTHER_USERS";
7
+
8
+ /** The variant ids Prepr chose for one visitor, per personalization group. */
9
+ type PreprDecisions = ReadonlyMap<string, readonly string[]>;
10
+ interface ResolveVariantsOptions {
11
+ /**
12
+ * The visitor's per-group variants (from a decision query). Without it,
13
+ * personalization groups show their default variant.
14
+ */
15
+ decisions?: PreprDecisions;
16
+ /** The visitor's A/B bucket. Without it, A/B groups use the decision, then `A`. */
17
+ bucket?: string;
18
+ }
19
+ /**
20
+ * Keeps, in every list of a variants query result, only the variants this
21
+ * visitor gets, at any depth (page stacks, nested stacks, personalized
22
+ * buttons). Items outside a group are kept as they are.
23
+ */
24
+ declare function resolveVariants<T>(data: T, options?: ResolveVariantsOptions): T;
25
+
26
+ /** A run of stack items that renders the same way: see {@link splitStack}. */
27
+ interface PreprStackBlock<T> {
28
+ key: string;
29
+ items: T[];
30
+ /**
31
+ * Rendered position of the block's first item: a group (whichever variant
32
+ * shows) takes one position, any other item one each. Use it for anything
33
+ * that depends on page position, like which section owns the h1.
34
+ */
35
+ index: number;
36
+ /**
37
+ * Some item in the block (or nested inside one) is a segment variant, so
38
+ * the block depends on the visitor and is decided per request.
39
+ */
40
+ personalized: boolean;
41
+ /**
42
+ * Some item in the block (or nested inside one) is an A/B variant. Without
43
+ * a known bucket, such a block renders once per bucket and the visitor's
44
+ * bucket is picked in the browser before first paint.
45
+ */
46
+ abTest: boolean;
47
+ }
48
+ /**
49
+ * Splits a variants-query stack into blocks. Each personalization or A/B
50
+ * group becomes one block (a variant can hold a different number of items
51
+ * than the default); consecutive items that never vary are merged.
52
+ */
53
+ declare function splitStack<T>(items: readonly T[]): PreprStackBlock<T>[];
54
+
55
+ /** The attribute Prepr's tracking pixel reads impressions and conversions from. */
56
+ interface PreprVariantProps {
57
+ 'data-prepr-variant-key'?: string;
58
+ }
59
+ /**
60
+ * Attributes that let Prepr's tracking pixel count impressions of this item's
61
+ * variant, for an item from a query run with `variants: true`. Spread them on
62
+ * the element that shows the item; an item outside any personalization or A/B
63
+ * group gets none.
64
+ *
65
+ * Items rendered by the Next.js `PreprStack` are tagged for you. Reach for this
66
+ * for items nested inside them (cards, buttons, models in a section) and in
67
+ * frameworks without `PreprStack`.
68
+ *
69
+ * @example
70
+ * <article {...preprVariantProps(card)}>…</article>
71
+ */
72
+ declare function preprVariantProps(item: unknown): PreprVariantProps;
73
+
74
+ /**
75
+ * A GraphQL document accepted by `query`: a plain string, graphql-codegen's
76
+ * `TypedDocumentString` (`documentMode: 'string'`), or any `DocumentNode`,
77
+ * including codegen's default `TypedDocumentNode` output.
78
+ *
79
+ * The phantom `__apiType` field is how codegen attaches result and variable
80
+ * types; matching it structurally keeps `@graphql-typed-document-node/core`
81
+ * out of this package.
82
+ */
83
+ type PreprDocument<TResult, TVariables> = string | ({
84
+ __apiType?: (variables: TVariables) => TResult;
85
+ } & (String | DocumentNode));
86
+ /**
87
+ * How stega markers are stripped from the response:
88
+ * - `'urls'`: only from values under URL-like keys (`url`, `slug`, `link`,
89
+ * `href`), where markers break links. Text keeps its markers for
90
+ * click-to-edit.
91
+ * - `'all'`: from every string.
92
+ * - `'none'`: never.
93
+ */
94
+ type PreprStegaMode = 'urls' | 'all' | 'none';
95
+ interface PreprClientOptions {
96
+ /** Full Prepr GraphQL URL, `https://graphql.prepr.io/<token>`. */
97
+ url: string;
98
+ /**
99
+ * Fetch implementation. Defaults to the global `fetch`, read at call time so
100
+ * framework-patched versions (such as Next.js's) are used.
101
+ */
102
+ fetch?: typeof fetch;
103
+ /**
104
+ * Preview mode: every query skips the HTTP cache so editors see each edit,
105
+ * and stega defaults to `'urls'` so click-to-edit keeps working.
106
+ */
107
+ preview?: boolean;
108
+ /** Default: `'urls'` when `preview` is true, otherwise `'all'`. */
109
+ stega?: PreprStegaMode;
110
+ /**
111
+ * Send queries as a GET with the request body base64-encoded in a
112
+ * `Fastly-Query` header, which Prepr's edge serves from the nearest point
113
+ * of presence (about half the latency of a POST in our measurements).
114
+ * Queries too large for a header still go as a POST. Off by default: it
115
+ * relies on Prepr edge behavior that is not part of the documented API.
116
+ */
117
+ fastlyQuery?: boolean;
118
+ /**
119
+ * @internal Fetch options for the one-time schema introspection, so a
120
+ * framework wrapper can put it in its data cache.
121
+ */
122
+ schemaInit?: RequestInit;
123
+ /**
124
+ * Headers sent with every request, such as a header a proxy in front of the
125
+ * API requires. They are fixed when the client is created, so they cannot
126
+ * vary per visitor and do not stop responses from being cached. Put
127
+ * per-request values in the query's `headers` instead.
128
+ */
129
+ headers?: HeadersInit;
130
+ }
131
+ interface PreprQueryOptions {
132
+ /**
133
+ * Prepr headers to forward, typically from `getPreprHeaders`. Passing any
134
+ * headers object, even an empty one, makes the request `no-store`: the
135
+ * response may be personalized and must not be shared between visitors.
136
+ */
137
+ headers?: PreprHeaders | HeadersInit;
138
+ /**
139
+ * Extra fetch options such as `signal`. `method` and `body` are set by the
140
+ * client. `init.headers` are merged like `headers`, and also make the
141
+ * request `no-store`.
142
+ */
143
+ init?: RequestInit;
144
+ /** Per-query fetch, overriding the client's (e.g. SvelteKit's `event.fetch`). */
145
+ fetch?: typeof fetch;
146
+ /**
147
+ * Fetch every variant instead of the visitor's: `personalize: false` is
148
+ * added to every personalizable field in the query, at any depth, and each
149
+ * item gets its `_context` (under `_preprContext`). The result is the same
150
+ * for every visitor, so it can be cached; pass it to `resolveVariants` with
151
+ * the visitor's `decide()` result to get what they see.
152
+ *
153
+ * The client learns which fields are personalizable from one schema
154
+ * introspection request, made on first use.
155
+ */
156
+ variants?: boolean;
157
+ }
158
+ /** Options for `decide()`. */
159
+ interface PreprDecideOptions extends Omit<PreprQueryOptions, 'variants'> {
160
+ /**
161
+ * The `variants: true` result this decision is for (the whole `data`
162
+ * object). The decision query then asks only about the fields that hold
163
+ * segment personalization groups, and is skipped entirely when there are
164
+ * none, e.g. on pages with only A/B tests or no personalization.
165
+ */
166
+ from?: unknown;
167
+ /**
168
+ * @internal Ask only about the first personalizable list on each path,
169
+ * without `from`: what middleware needs for groups at the top of a stack.
170
+ */
171
+ topLevelOnly?: boolean;
172
+ }
173
+ interface PreprQueryResult<TResult> {
174
+ data: TResult;
175
+ /**
176
+ * True when Prepr reports, through the response's `Vary` header, that the
177
+ * queried fields hold segment variants or A/B tests.
178
+ */
179
+ personalized: boolean;
180
+ }
181
+
182
+ /**
183
+ * Query options for frameworks without an implicit request scope.
184
+ * `personalize: true` requires the request `event`; the compiler enforces it.
185
+ */
186
+ type PreprEventQueryOptions<TEvent> = PreprQueryOptions & ({
187
+ personalize?: false;
188
+ event?: TEvent;
189
+ } | {
190
+ personalize: true;
191
+ event: TEvent;
192
+ });
193
+ interface PreprEventClient<TEvent> {
194
+ /**
195
+ * Run a GraphQL query against Prepr. With `personalize: true`, the Prepr
196
+ * headers of `event` are forwarded and the request is `no-store`; without
197
+ * it the request is identical for every visitor.
198
+ *
199
+ * @throws PreprError — as `PreprClient.query`, plus `CONTEXT_ERROR` when
200
+ * `personalize` is true and no `event` is passed.
201
+ */
202
+ query<TResult, TVariables>(document: PreprDocument<TResult, TVariables>, variables?: TVariables, options?: PreprEventQueryOptions<TEvent>): Promise<PreprQueryResult<TResult>>;
203
+ /**
204
+ * Which variant of each group this visitor gets, for the query you render
205
+ * with `variants: true`. Forwards the Prepr headers of `event`.
206
+ *
207
+ * @throws PreprError — `CONTEXT_ERROR` without an `event`.
208
+ */
209
+ decide<TVariables>(document: PreprDocument<unknown, TVariables>, variables: TVariables | undefined, options: PreprDecideOptions & {
210
+ event: TEvent;
211
+ }): Promise<PreprDecisions>;
212
+ }
213
+
214
+ /**
215
+ * The part of a SvelteKit `RequestEvent` or load event the client reads.
216
+ * `locals` is typed `object` so SvelteKit's `App.Locals` interface fits.
217
+ */
218
+ interface PreprSvelteKitEvent {
219
+ request: Request;
220
+ locals?: object;
221
+ fetch?: typeof fetch;
222
+ }
223
+ /**
224
+ * Prepr GraphQL client for SvelteKit. Pass the load or endpoint event as
225
+ * `event`: its `fetch` is used for every request, so SvelteKit can dedupe
226
+ * and serialize it. With `personalize: true`, the Prepr headers
227
+ * `preprHandle` computed are forwarded.
228
+ *
229
+ * Requires the `graphql` package, which graphql-codegen already installs.
230
+ */
231
+ declare function createPreprClient(options: PreprClientOptions): PreprEventClient<PreprSvelteKitEvent>;
232
+
233
+ export { PREPR_DEFAULT_VARIANT, type PreprClientOptions, type PreprDecideOptions, type PreprDecisions, type PreprDocument, type PreprEventClient, type PreprEventQueryOptions, type PreprQueryResult, type PreprStackBlock, type PreprStegaMode, type PreprSvelteKitEvent, type PreprVariantProps, type ResolveVariantsOptions, createPreprClient, preprVariantProps, resolveVariants, splitStack };