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