@disconetwork/core 0.0.17 → 0.0.19

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 (120) hide show
  1. package/README.md +14 -12
  2. package/dist/TrackingManager.d.ts +64 -0
  3. package/dist/TrackingManager.d.ts.map +1 -0
  4. package/dist/TrackingManager.js +114 -0
  5. package/dist/TrackingManager.js.map +1 -0
  6. package/dist/api/generated/events/client/client.gen.js +176 -0
  7. package/dist/api/generated/events/client/client.gen.js.map +1 -0
  8. package/dist/api/generated/events/client/utils.gen.js +179 -0
  9. package/dist/api/generated/events/client/utils.gen.js.map +1 -0
  10. package/dist/api/generated/events/client.gen.js +8 -0
  11. package/dist/api/generated/events/client.gen.js.map +1 -0
  12. package/dist/api/generated/events/core/auth.gen.js +12 -0
  13. package/dist/api/generated/events/core/auth.gen.js.map +1 -0
  14. package/dist/api/generated/events/core/bodySerializer.gen.js +6 -0
  15. package/dist/api/generated/events/core/bodySerializer.gen.js.map +1 -0
  16. package/dist/api/generated/events/core/pathSerializer.gen.js +82 -0
  17. package/dist/api/generated/events/core/pathSerializer.gen.js.map +1 -0
  18. package/dist/api/generated/events/core/serverSentEvents.gen.js +95 -0
  19. package/dist/api/generated/events/core/serverSentEvents.gen.js.map +1 -0
  20. package/dist/api/generated/events/core/utils.gen.js +78 -0
  21. package/dist/api/generated/events/core/utils.gen.js.map +1 -0
  22. package/dist/api/generated/events/sdk.gen.js +31 -0
  23. package/dist/api/generated/events/sdk.gen.js.map +1 -0
  24. package/dist/api/generated/events/zod.gen.js +197 -0
  25. package/dist/api/generated/events/zod.gen.js.map +1 -0
  26. package/dist/api/generated/recommendations/client/client.gen.js +176 -0
  27. package/dist/api/generated/recommendations/client/client.gen.js.map +1 -0
  28. package/dist/api/generated/recommendations/client/utils.gen.js +179 -0
  29. package/dist/api/generated/recommendations/client/utils.gen.js.map +1 -0
  30. package/dist/api/generated/recommendations/client.gen.js +8 -0
  31. package/dist/api/generated/recommendations/client.gen.js.map +1 -0
  32. package/dist/api/generated/recommendations/core/auth.gen.js +12 -0
  33. package/dist/api/generated/recommendations/core/auth.gen.js.map +1 -0
  34. package/dist/api/generated/recommendations/core/bodySerializer.gen.js +6 -0
  35. package/dist/api/generated/recommendations/core/bodySerializer.gen.js.map +1 -0
  36. package/dist/api/generated/recommendations/core/pathSerializer.gen.js +82 -0
  37. package/dist/api/generated/recommendations/core/pathSerializer.gen.js.map +1 -0
  38. package/dist/api/generated/recommendations/core/serverSentEvents.gen.js +95 -0
  39. package/dist/api/generated/recommendations/core/serverSentEvents.gen.js.map +1 -0
  40. package/dist/api/generated/recommendations/core/utils.gen.js +78 -0
  41. package/dist/api/generated/recommendations/core/utils.gen.js.map +1 -0
  42. package/dist/api/generated/recommendations/sdk.gen.js +35 -0
  43. package/dist/api/generated/recommendations/sdk.gen.js.map +1 -0
  44. package/dist/api/generated/recommendations/types.gen.d.ts +32 -0
  45. package/dist/api/generated/recommendations/types.gen.d.ts.map +1 -0
  46. package/dist/api/generated/recommendations/zod.gen.js +407 -0
  47. package/dist/api/generated/recommendations/zod.gen.js.map +1 -0
  48. package/dist/api/index.js +60 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/apiKey.js +13 -0
  51. package/dist/apiKey.js.map +1 -0
  52. package/dist/config.js +38 -0
  53. package/dist/config.js.map +1 -0
  54. package/dist/env.d.ts +5 -0
  55. package/dist/env.d.ts.map +1 -0
  56. package/dist/errors.d.ts +56 -0
  57. package/dist/errors.d.ts.map +1 -0
  58. package/dist/errors.js +76 -0
  59. package/dist/errors.js.map +1 -0
  60. package/dist/events/dedupe.d.ts +15 -0
  61. package/dist/events/dedupe.d.ts.map +1 -0
  62. package/dist/events/dedupe.js +34 -0
  63. package/dist/events/dedupe.js.map +1 -0
  64. package/dist/events/eventMapping.js +88 -0
  65. package/dist/events/eventMapping.js.map +1 -0
  66. package/dist/external/DiscoClient.d.ts +88 -0
  67. package/dist/external/DiscoClient.d.ts.map +1 -0
  68. package/dist/external/DiscoClient.js +122 -0
  69. package/dist/external/DiscoClient.js.map +1 -0
  70. package/dist/external/recommendations.d.ts +186 -0
  71. package/dist/external/recommendations.d.ts.map +1 -0
  72. package/dist/external/recommendationsTransforms.js +216 -0
  73. package/dist/external/recommendationsTransforms.js.map +1 -0
  74. package/dist/index.d.ts +8 -97
  75. package/dist/index.js +3 -1769
  76. package/dist/internal/InternalDiscoClient.d.ts +129 -0
  77. package/dist/internal/InternalDiscoClient.d.ts.map +1 -0
  78. package/dist/internal/InternalDiscoClient.js +137 -0
  79. package/dist/internal/InternalDiscoClient.js.map +1 -0
  80. package/dist/internal/denormalize.d.ts +18 -0
  81. package/dist/internal/denormalize.d.ts.map +1 -0
  82. package/dist/internal/denormalize.js +49 -0
  83. package/dist/internal/denormalize.js.map +1 -0
  84. package/dist/internal/recommendations.d.ts +90 -0
  85. package/dist/internal/recommendations.d.ts.map +1 -0
  86. package/dist/internal/recommendationsMapper.js +68 -0
  87. package/dist/internal/recommendationsMapper.js.map +1 -0
  88. package/dist/internal/recommendationsRequestMapper.js +121 -0
  89. package/dist/internal/recommendationsRequestMapper.js.map +1 -0
  90. package/dist/internal/screens.d.ts +77 -0
  91. package/dist/internal/screens.d.ts.map +1 -0
  92. package/dist/internal/screens.js +79 -0
  93. package/dist/internal/screens.js.map +1 -0
  94. package/dist/internal.d.ts +11 -400
  95. package/dist/internal.js +5 -564
  96. package/dist/lib/case.js +26 -0
  97. package/dist/lib/case.js.map +1 -0
  98. package/dist/lib/http.js +21 -0
  99. package/dist/lib/http.js.map +1 -0
  100. package/dist/lib/primitives.js +23 -0
  101. package/dist/lib/primitives.js.map +1 -0
  102. package/dist/lib/schemas.js +25 -0
  103. package/dist/lib/schemas.js.map +1 -0
  104. package/dist/package.js +7 -0
  105. package/dist/package.js.map +1 -0
  106. package/dist/sdkIdentity.d.ts +9 -0
  107. package/dist/sdkIdentity.d.ts.map +1 -0
  108. package/dist/sdkIdentity.js +16 -0
  109. package/dist/sdkIdentity.js.map +1 -0
  110. package/dist/types.d.ts +91 -0
  111. package/dist/types.d.ts.map +1 -0
  112. package/package.json +4 -4
  113. package/dist/errors-DpKOKpT8.d.ts +0 -363
  114. package/dist/errors-DpKOKpT8.d.ts.map +0 -1
  115. package/dist/index.d.ts.map +0 -1
  116. package/dist/index.js.map +0 -1
  117. package/dist/internal.d.ts.map +0 -1
  118. package/dist/internal.js.map +0 -1
  119. package/dist/recommendationsTransforms-D_E4xU1d.js +0 -748
  120. package/dist/recommendationsTransforms-D_E4xU1d.js.map +0 -1
@@ -1,400 +1,11 @@
1
- import { C as OfferMetadata, I as SdkIdentity, O as RecommendationsResponse$1, S as OfferDisclosureDetails, _ as Advertiser, a as BrandClickInitiatingTarget, b as OfferAsset, c as BrandVisibilityEventType, d as EventPlacementDetails, f as EventTracker, g as WidgetEventType, h as ProductProperties, i as DiscoValidationError, l as ElementClickInitiatingTarget, m as ProductEventType, n as DiscoError, o as BrandDisplayInitiatingTarget, p as ProductDisplayInitiatingTarget, r as DiscoNetworkError, s as BrandProperties, t as DiscoApiError, u as EventPayload, v as Footer, x as OfferCtaDetails, y as Offer } from "./errors-DpKOKpT8.js";
2
- import * as z from "zod/v4";
3
-
4
- //#region src/env.d.ts
5
- type DiscoEnv = "production" | "staging";
6
- //#endregion
7
- //#region src/internal/recommendations.d.ts
8
- type RecommendationsRequest = {
9
- user?: UserDetails;
10
- placement?: PlacementDetails;
11
- order?: OrderDetails;
12
- purchases?: Purchase[];
13
- experiments?: RunningExperiment[];
14
- attributes?: Record<string, unknown>;
15
- /**
16
- * Additional top-level fields passed through to the API unchanged.
17
- * Use for platform-specific extensions (e.g. `shopify_checkout_token`).
18
- * Keys here are not transformed — provide them in whatever case the
19
- * backend expects.
20
- */
21
- extras?: Record<string, unknown>;
22
- };
23
- type UserDetails = {
24
- email?: string;
25
- firstName?: string;
26
- lastName?: string;
27
- phone?: string;
28
- };
29
- type PlacementDetails = {
30
- /** Configured widget ID on the requested page (1-64 characters). */widgetId?: string; /** e.g. `"INLINE"`. Open-ended — see backend for supported values. */
31
- displayMode?: string; /** e.g. `"THANK_YOU"`, `"ORDER_STATUS"`. Open-ended. */
32
- view?: string;
33
- };
34
- type OrderDetails = {
35
- id?: string;
36
- amount?: number | string;
37
- currencyCode?: string;
38
- };
39
- type Purchase = {
40
- name?: string;
41
- type?: string;
42
- variant?: string;
43
- quantity?: number;
44
- productId?: string;
45
- amount?: number;
46
- currencyCode?: string;
47
- };
48
- type RunningExperiment = {
49
- id: string;
50
- variant: string;
51
- };
52
- type LayoutId = "SHOPIFY_NATIVE_LEAD_GEN" | "SHOPIFY_NATIVE_ESSENTIAL" | "SHOPIFY_NATIVE_COVER" | (string & {});
53
- type RecommendationsResponse = {
54
- sessionId: string;
55
- layoutId: LayoutId;
56
- recommendationGroups: RecommendationGroup[];
57
- footer: Footer;
58
- publisherCustomization: PublisherCustomization | null;
59
- };
60
- type RecommendationGroup = {
61
- heading: string | null;
62
- slotContext: "HERO" | "SCROLLABLE" | (string & {});
63
- recommendations: Recommendation[];
64
- };
65
- /**
66
- * A single recommendation within a denormalized group. Differs from the
67
- * external `Recommendation` (`{ advertiser, offer }`): the internal one is the
68
- * join result, so it also carries the offer-derived `id` and the group entry's
69
- * `insertionId`. The `advertiser` / `offer` leaves are the external types.
70
- */
71
- type Recommendation = {
72
- id: string;
73
- insertionId: string;
74
- advertiser: Advertiser;
75
- offer: Offer;
76
- };
77
- /**
78
- * Publisher-configured copy, boolean flags, and overrides. Keyed first by surface type
79
- * (`checkout`, `upfront`, …) and then by opaque server-defined keys —
80
- * see `applyCustomizationOrFallback` consumer-side helpers.
81
- *
82
- * Inner keys remain snake_case because they're identifiers, not
83
- * JavaScript field names.
84
- */
85
- type PublisherCustomization = {
86
- checkout?: Record<string, string | boolean>;
87
- upfront?: Record<string, string | boolean>;
88
- } & Record<string, Record<string, string | boolean> | undefined>;
89
- //#endregion
90
- //#region src/internal/InternalDiscoClient.d.ts
91
- /**
92
- * Per-environment base URL for the internal/proxy backend — the legacy server
93
- * that orchestrates and forwards to the downstream services. Both the
94
- * recommendations and tracking endpoints sit under this origin, routed by path
95
- * (the client appends `/core/recommendations/…` and `/track/partners_event/`).
96
- */
97
- declare const INTERNAL_BASE_URL: {
98
- readonly production: "https://consumer.disconetwork.com";
99
- readonly staging: "https://consumer.disconetwork-staging.com";
100
- };
101
- /**
102
- * Authenticate with a scoped public API key. Sent as the `x-api-key`
103
- * header against the unified `/core/recommendations/` endpoint. Both
104
- * `disco_pk_live_…` and `disco_pk_sandbox_…` keys use production; there is
105
- * no separate `env` to set.
106
- *
107
- * Use this from partner apps and server-side code that hold a key.
108
- *
109
- * Set `surface: "shopify"` from a Shopify UI extension to send the request to
110
- * the `/core/recommendations/shopify/` route instead. The route marks the
111
- * request as coming from an extension; the channel still comes from the key.
112
- */
113
- type ApiKeyConfig = {
114
- apiKey: string;
115
- surface?: "shopify";
116
- fetch?: typeof fetch;
117
- };
118
- /**
119
- * Authenticate by Shopify shop — for surfaces that must not embed a key,
120
- * notably the App-Store-deployed checkout extension. The request hits the
121
- * `/core/recommendations/shop_gid/<id>/` proxy with **no** API key; the
122
- * backend resolves the publisher from the shop and injects the key
123
- * server-side.
124
- *
125
- * `env` is required here to select the backend for shop-based authentication.
126
- * `shopGid` may be a full `gid://shopify/Shop/<id>` or the bare id.
127
- */
128
- type ShopGidConfig = {
129
- shopGid: string;
130
- env: DiscoEnv;
131
- fetch?: typeof fetch;
132
- };
133
- type DiscoClientConfig = (ApiKeyConfig | ShopGidConfig) & {
134
- sdk?: SdkIdentity;
135
- };
136
- type GetRecommendationsOptions = {
137
- /** Forwarded to `fetch` so consumers can cancel in-flight requests. */signal?: AbortSignal;
138
- };
139
- type CreateTrackingManagerOptions = {
140
- /**
141
- * Override the fetch implementation used by the tracker. Defaults to the
142
- * same fetch implementation configured on the client.
143
- */
144
- fetch?: typeof fetch;
145
- };
146
- /**
147
- * Result of `getRecommendationsWithTracker`: the mapped recommendations
148
- * response plus a tracker already bound to its session.
149
- */
150
- type RecommendationsWithTracker = {
151
- /**
152
- * The mapped, denormalized recommendations response — the same friendly
153
- * camelCase shape `getRecommendations` returns.
154
- */
155
- data: RecommendationsResponse; /** Event tracker bound to this response's session. */
156
- tracker: EventTracker;
157
- };
158
- /**
159
- * Internal client for the legacy **proxy** recommendations endpoint
160
- * (`/core/recommendations/` on the backend), which orchestrates placement,
161
- * experiments, layout, and `publisher_customization` server-side and supports
162
- * `shopGid` auth for first-party surfaces (e.g. the Shopify checkout
163
- * extension).
164
- *
165
- * First-party / legacy only — exported from `@disconetwork/core/internal`.
166
- * External partners use the `DiscoClient` from the package root, which talks
167
- * directly to `disco-recommendations-api`.
168
- *
169
- * Renderer-agnostic: this class makes plain HTTP calls and has no React
170
- * dependency.
171
- */
172
- declare class InternalDiscoClient {
173
- #private;
174
- get env(): DiscoEnv;
175
- constructor(config: DiscoClientConfig);
176
- /**
177
- * Fetch recommendations for the given request.
178
- *
179
- * Validates and transforms the friendly camelCase `request` into the wire
180
- * body, POSTs it, then validates and denormalizes the response into the
181
- * friendly `RecommendationsResponse`. The snake_case wire format is fully
182
- * encapsulated — callers never see it.
183
- *
184
- * Throws `DiscoValidationError` if the request or response fails schema
185
- * validation, `DiscoApiError` on non-2xx responses, and `DiscoNetworkError`
186
- * if the request can't reach the server (an abort rejects with the native
187
- * `AbortError`). Parse failures propagate as-is.
188
- */
189
- getRecommendations: (request: RecommendationsRequest, options?: GetRecommendationsOptions) => Promise<RecommendationsResponse>;
190
- /**
191
- * Fetch recommendations and create a session-bound tracker in one call.
192
- *
193
- * Composition convenience over `getRecommendations` + `createTrackingManager`:
194
- * it derives the tracker's session from the response so callers don't have to
195
- * thread the session id through themselves (and can't bind a tracker to the
196
- * wrong session). The returned `data` is the mapped `RecommendationsResponse`.
197
- *
198
- * Throws `DiscoValidationError` / `DiscoApiError` the same as
199
- * `getRecommendations`.
200
- */
201
- getRecommendationsWithTracker: (request: RecommendationsRequest, options?: GetRecommendationsOptions & CreateTrackingManagerOptions) => Promise<RecommendationsWithTracker>;
202
- /**
203
- * Create an event tracker bound to a recommendations session (the `sessionId`
204
- * from a `getRecommendations` response).
205
- *
206
- * The tracker uses the same environment as the recommendations call.
207
- * Both live and sandbox public keys use production.
208
- */
209
- createTrackingManager: (sessionId: string, options?: CreateTrackingManagerOptions) => EventTracker;
210
- }
211
- //#endregion
212
- //#region src/TrackingManager.d.ts
213
- type TrackingManagerConfig = {
214
- /**
215
- * Session identifier returned by the recommendations API. Stamped onto
216
- * every emitted event as `session_id`. A tracker is meaningless without
217
- * a session, so this is required — instantiate the manager only after
218
- * the recommendations response is in hand.
219
- */
220
- sessionId: string;
221
- /**
222
- * Absolute URL events are POSTed to. The external client points this at the
223
- * events service (`/events`); the internal client at the proxy
224
- * (`/track/partners_event/`). Prefer a client's `createTrackingManager` over
225
- * constructing this directly, so the endpoint and auth stay consistent with
226
- * the recommendations call.
227
- */
228
- endpoint: string;
229
- /**
230
- * Extra request headers — e.g. `{ "x-api-key": key }` for the external
231
- * events service. `Content-Type: application/json` is always sent.
232
- */
233
- headers?: Record<string, string>; /** SDK/renderer identity. Defaults to this core package's name and version. */
234
- sdk?: SdkIdentity;
235
- /**
236
- * Override the global `fetch`. Primarily useful in tests and in runtimes
237
- * that provide a non-standard fetch implementation. Defaults to
238
- * `globalThis.fetch`.
239
- */
240
- fetch?: typeof fetch;
241
- };
242
- /**
243
- * Renderer-agnostic event tracker for Disco recommendation surfaces.
244
- *
245
- * Owns:
246
- * - the dedup set (so repeated display/view events for the same brand
247
- * don't get re-sent within a session)
248
- * - the network call to the partner-events endpoint
249
- * - payload formatting (snake_case keys, BE-friendly datetime)
250
- *
251
- * Does not know about React. Wrap it in a Provider (`@disconetwork/react`'s
252
- * `DiscoProvider`) when consuming from a React tree, or instantiate it
253
- * directly from any other JS environment.
254
- *
255
- * `track` is implemented as an instance-bound arrow function so consumers
256
- * can safely destructure it without losing `this`.
257
- */
258
- declare class TrackingManager {
259
- #private;
260
- constructor(config: TrackingManagerConfig);
261
- /**
262
- * Send a tracking event. Fire-and-forget — never throws.
263
- * Failures are logged via `console.error`.
264
- *
265
- * Idempotency: `WIDGET_DISPLAY`, `WIDGET_VIEW`, `BRAND_DISPLAY`, and
266
- * `BRAND_VIEW` are deduped per-instance by (event type, insertionId).
267
- */
268
- track: (event: EventPayload) => void;
269
- }
270
- //#endregion
271
- //#region src/internal/denormalize.d.ts
272
- /**
273
- * Join the normalized response maps into ordered `RecommendationGroup[]`.
274
- *
275
- * Groups are ordered by the numeric suffix of their key (`group_0` before
276
- * `group_10`); within each group, entries are ordered by `insertionOrder`.
277
- * Groups missing their entry list or display properties are skipped, as are
278
- * entries whose `offerId` is absent from the recommendations map. Each result
279
- * recommendation's `id` is the offer's id and its `insertionId` comes from the
280
- * group entry.
281
- */
282
- declare function denormalize(response: RecommendationsResponse$1): RecommendationGroup[];
283
- //#endregion
284
- //#region src/internal/screens.d.ts
285
- declare const TextNodeSchema: z.ZodObject<{
286
- type: z.ZodLiteral<"text">;
287
- text: z.ZodString;
288
- }, z.core.$strip>;
289
- type ASTChildrenSchema = z.ZodArray<z.ZodDiscriminatedUnion<[typeof TextNodeSchema, typeof LinkNodeSchema, typeof ParagraphNodeSchema, typeof ScrollViewNodeSchema]>>;
290
- declare const LinkNodeSchema: z.ZodObject<{
291
- type: z.ZodLiteral<"link">;
292
- attributes: z.ZodUnion<readonly [z.ZodObject<{
293
- to: z.ZodURL;
294
- external: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
295
- }, z.core.$strip>, z.ZodObject<{
296
- targetScreenId: z.ZodString;
297
- }, z.core.$strip>]>;
298
- children: ASTChildrenSchema;
299
- }, z.core.$strip>;
300
- declare const ParagraphNodeSchema: z.ZodObject<{
301
- type: z.ZodLiteral<"paragraph">;
302
- children: ASTChildrenSchema;
303
- }, z.core.$strip>;
304
- declare const ScrollViewNodeSchema: z.ZodObject<{
305
- type: z.ZodLiteral<"scrollview">;
306
- attributes: z.ZodOptional<z.ZodObject<{
307
- maxBlockSize: z.ZodOptional<z.ZodNumber>;
308
- }, z.core.$strip>>;
309
- children: ASTChildrenSchema;
310
- }, z.core.$strip>;
311
- declare const ASTNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
312
- type: z.ZodLiteral<"text">;
313
- text: z.ZodString;
314
- }, z.core.$strip>, z.ZodObject<{
315
- type: z.ZodLiteral<"link">;
316
- attributes: z.ZodUnion<readonly [z.ZodObject<{
317
- to: z.ZodURL;
318
- external: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
319
- }, z.core.$strip>, z.ZodObject<{
320
- targetScreenId: z.ZodString;
321
- }, z.core.$strip>]>;
322
- children: ASTChildrenSchema;
323
- }, z.core.$strip>, z.ZodObject<{
324
- type: z.ZodLiteral<"paragraph">;
325
- children: ASTChildrenSchema;
326
- }, z.core.$strip>, z.ZodObject<{
327
- type: z.ZodLiteral<"scrollview">;
328
- attributes: z.ZodOptional<z.ZodObject<{
329
- maxBlockSize: z.ZodOptional<z.ZodNumber>;
330
- }, z.core.$strip>>;
331
- children: ASTChildrenSchema;
332
- }, z.core.$strip>], "type">;
333
- declare const ScreenSchema: z.ZodObject<{
334
- children: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
335
- type: z.ZodLiteral<"text">;
336
- text: z.ZodString;
337
- }, z.core.$strip>, z.ZodObject<{
338
- type: z.ZodLiteral<"link">;
339
- attributes: z.ZodUnion<readonly [z.ZodObject<{
340
- to: z.ZodURL;
341
- external: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
342
- }, z.core.$strip>, z.ZodObject<{
343
- targetScreenId: z.ZodString;
344
- }, z.core.$strip>]>;
345
- children: ASTChildrenSchema;
346
- }, z.core.$strip>, z.ZodObject<{
347
- type: z.ZodLiteral<"paragraph">;
348
- children: ASTChildrenSchema;
349
- }, z.core.$strip>, z.ZodObject<{
350
- type: z.ZodLiteral<"scrollview">;
351
- attributes: z.ZodOptional<z.ZodObject<{
352
- maxBlockSize: z.ZodOptional<z.ZodNumber>;
353
- }, z.core.$strip>>;
354
- children: ASTChildrenSchema;
355
- }, z.core.$strip>], "type">>;
356
- id: z.ZodString;
357
- }, z.core.$strip>;
358
- declare const ScreenDocumentSchema: z.ZodObject<{
359
- screens: z.ZodArray<z.ZodObject<{
360
- children: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
361
- type: z.ZodLiteral<"text">;
362
- text: z.ZodString;
363
- }, z.core.$strip>, z.ZodObject<{
364
- type: z.ZodLiteral<"link">;
365
- attributes: z.ZodUnion<readonly [z.ZodObject<{
366
- to: z.ZodURL;
367
- external: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
368
- }, z.core.$strip>, z.ZodObject<{
369
- targetScreenId: z.ZodString;
370
- }, z.core.$strip>]>;
371
- children: ASTChildrenSchema;
372
- }, z.core.$strip>, z.ZodObject<{
373
- type: z.ZodLiteral<"paragraph">;
374
- children: ASTChildrenSchema;
375
- }, z.core.$strip>, z.ZodObject<{
376
- type: z.ZodLiteral<"scrollview">;
377
- attributes: z.ZodOptional<z.ZodObject<{
378
- maxBlockSize: z.ZodOptional<z.ZodNumber>;
379
- }, z.core.$strip>>;
380
- children: ASTChildrenSchema;
381
- }, z.core.$strip>], "type">>;
382
- id: z.ZodString;
383
- }, z.core.$strip>>;
384
- }, z.core.$strip>;
385
- type TextNode = z.infer<typeof TextNodeSchema>;
386
- type LinkNode = z.infer<typeof LinkNodeSchema>;
387
- type ParagraphNode = z.infer<typeof ParagraphNodeSchema>;
388
- type ScrollViewNode = z.infer<typeof ScrollViewNodeSchema>;
389
- type ASTNode = z.infer<typeof ASTNodeSchema>;
390
- type Screen = z.infer<typeof ScreenSchema>;
391
- type ScreenDocument = z.infer<typeof ScreenDocumentSchema>;
392
- /**
393
- * Parse offer screens content into a list of screens. Returns `null` when the
394
- * content is missing or matches neither the screen document nor the legacy
395
- * single-root shape, so callers can render a fallback.
396
- */
397
- declare function parseScreens(jsonContent: Record<string, unknown> | undefined | null): Screen[] | null;
398
- //#endregion
399
- export { type ASTNode, type Advertiser, type ApiKeyConfig, type BrandClickInitiatingTarget, type BrandDisplayInitiatingTarget, type BrandProperties, type BrandVisibilityEventType, type CreateTrackingManagerOptions, DiscoApiError, type DiscoClientConfig, type DiscoEnv, DiscoError, DiscoNetworkError, DiscoValidationError, type ElementClickInitiatingTarget, type EventPayload, type EventPlacementDetails, type EventTracker, type Footer, type GetRecommendationsOptions, INTERNAL_BASE_URL, InternalDiscoClient, type LayoutId, type LinkNode, type Offer, type OfferAsset, type OfferCtaDetails, type OfferDisclosureDetails, type OfferMetadata, type OrderDetails, type ParagraphNode, type PlacementDetails, type ProductDisplayInitiatingTarget, type ProductEventType, type ProductProperties, type PublisherCustomization, type Purchase, type Recommendation, type RecommendationGroup, type RecommendationsRequest, type RecommendationsResponse, type RecommendationsWithTracker, type RunningExperiment, type Screen, type ScreenDocument, type ScrollViewNode, type SdkIdentity, type ShopGidConfig, type TextNode, TrackingManager, type TrackingManagerConfig, type UserDetails, type WidgetEventType, denormalize, parseScreens };
400
- //# sourceMappingURL=internal.d.ts.map
1
+ import { SdkIdentity } from "./sdkIdentity.js";
2
+ import { Address, Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata } from "./external/recommendations.js";
3
+ import { BrandClickInitiatingTarget, BrandDisplayInitiatingTarget, BrandProperties, BrandVisibilityEventType, ElementClickInitiatingTarget, EventPayload, EventPlacementDetails, EventTracker, ProductDisplayInitiatingTarget, ProductEventType, ProductProperties, WidgetEventType } from "./types.js";
4
+ import { DiscoApiError, DiscoError, DiscoNetworkError, DiscoValidationError } from "./errors.js";
5
+ import { DiscoEnv } from "./env.js";
6
+ import { LayoutId, OrderDetails, PlacementDetails, PublisherCustomization, Purchase, Recommendation, RecommendationGroup, RecommendationsRequest, RecommendationsResponse, RunningExperiment, UserDetails } from "./internal/recommendations.js";
7
+ import { ApiKeyConfig, CreateTrackingManagerOptions, DiscoClientConfig, GetRecommendationsOptions, INTERNAL_BASE_URL, InternalDiscoClient, RecommendationsWithTracker, ShopGidConfig } from "./internal/InternalDiscoClient.js";
8
+ import { TrackingManager, TrackingManagerConfig } from "./TrackingManager.js";
9
+ import { denormalize } from "./internal/denormalize.js";
10
+ import { ASTNode, LinkNode, ParagraphNode, Screen, ScreenDocument, ScrollViewNode, TextNode, parseScreens } from "./internal/screens.js";
11
+ export { type ASTNode, type Address, type Advertiser, type ApiKeyConfig, type BrandClickInitiatingTarget, type BrandDisplayInitiatingTarget, type BrandProperties, type BrandVisibilityEventType, type CreateTrackingManagerOptions, DiscoApiError, type DiscoClientConfig, type DiscoEnv, DiscoError, DiscoNetworkError, DiscoValidationError, type ElementClickInitiatingTarget, type EventPayload, type EventPlacementDetails, type EventTracker, type Footer, type GetRecommendationsOptions, INTERNAL_BASE_URL, InternalDiscoClient, type LayoutId, type LinkNode, type Offer, type OfferAsset, type OfferCtaDetails, type OfferDisclosureDetails, type OfferMetadata, type OrderDetails, type ParagraphNode, type PlacementDetails, type ProductDisplayInitiatingTarget, type ProductEventType, type ProductProperties, type PublisherCustomization, type Purchase, type Recommendation, type RecommendationGroup, type RecommendationsRequest, type RecommendationsResponse, type RecommendationsWithTracker, type RunningExperiment, type Screen, type ScreenDocument, type ScrollViewNode, type SdkIdentity, type ShopGidConfig, type TextNode, TrackingManager, type TrackingManagerConfig, type UserDetails, type WidgetEventType, denormalize, parseScreens };