@vio-live/web-sdk 0.19.0 → 0.23.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.
- package/README.md +144 -0
- package/dist/chunk-25QECQDS.js +3 -0
- package/dist/{chunk-PZUOMOLF.js.map → chunk-25QECQDS.js.map} +1 -1
- package/dist/{chunk-CMNTHF66.js → chunk-AMDI7KH3.js} +918 -83
- package/dist/chunk-AMDI7KH3.js.map +1 -0
- package/dist/{chunk-NUNGU6LL.js → chunk-COCHGJ2K.js} +699 -69
- package/dist/chunk-COCHGJ2K.js.map +1 -0
- package/dist/core/index.d.ts +467 -11
- package/dist/core/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/react/index.js.map +1 -1
- package/dist/{tokens-IrVSMVcA.d.ts → tokens-DSYvrBsB.d.ts} +117 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-CMNTHF66.js.map +0 -1
- package/dist/chunk-NUNGU6LL.js.map +0 -1
- package/dist/chunk-PZUOMOLF.js +0 -3
package/dist/core/index.d.ts
CHANGED
|
@@ -11,11 +11,31 @@ import { GraphQLClient } from 'graphql-request';
|
|
|
11
11
|
* them from env vars / their config and passes them to `Vio.init`.
|
|
12
12
|
*/
|
|
13
13
|
type Environment = 'development' | 'testing' | 'production';
|
|
14
|
+
/**
|
|
15
|
+
* Platform type of the surface this page belongs to (ADR-0027). It travels
|
|
16
|
+
* with every slot declaration and as `?platform=` on the bootstrap, so the
|
|
17
|
+
* campaigns service only answers with the slot assignments of this platform.
|
|
18
|
+
*/
|
|
19
|
+
type VioPlatform = 'web' | 'custom-web' | 'vev';
|
|
14
20
|
interface VioConfig {
|
|
15
21
|
/** Vio API key for this client app (from the Vio dashboard). */
|
|
16
22
|
apiKey: string;
|
|
17
23
|
/** Target environment. Defaults to 'development'. */
|
|
18
24
|
environment?: Environment;
|
|
25
|
+
/**
|
|
26
|
+
* Platform type of this surface: `web` (the no-code snippet), `custom-web`
|
|
27
|
+
* (the SDK integrated by code) or `vev`. Defaults to `web`.
|
|
28
|
+
*/
|
|
29
|
+
platform?: VioPlatform;
|
|
30
|
+
/**
|
|
31
|
+
* The host's own id for the content (article, page) this SDK instance is
|
|
32
|
+
* rendered in — the first choice of `Vio.content()`, ahead of the URL query,
|
|
33
|
+
* the `vio:content-id` meta, the canonical URL and the pathname. Goes on
|
|
34
|
+
* every analytics event as `content_id`.
|
|
35
|
+
*/
|
|
36
|
+
contentId?: string | number;
|
|
37
|
+
/** Human-readable title of that content (`content_title`); see `contentId`. */
|
|
38
|
+
contentTitle?: string;
|
|
19
39
|
/** Override REST API base. Defaults are env-aware. */
|
|
20
40
|
apiBase?: string;
|
|
21
41
|
/** Override GraphQL base. Defaults are env-aware. */
|
|
@@ -48,6 +68,9 @@ interface VioConfig {
|
|
|
48
68
|
interface ResolvedConfig {
|
|
49
69
|
apiKey: string;
|
|
50
70
|
environment: Environment;
|
|
71
|
+
platform: VioPlatform;
|
|
72
|
+
contentId?: string | number;
|
|
73
|
+
contentTitle?: string;
|
|
51
74
|
apiBase: string;
|
|
52
75
|
graphQLBase: string;
|
|
53
76
|
eventsBase: string;
|
|
@@ -150,19 +173,115 @@ interface Sponsor {
|
|
|
150
173
|
secondaryColor?: string | null;
|
|
151
174
|
commerce: SponsorCommerceBlock;
|
|
152
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* `campaign` of `GET /v2/mobile/config`: the head of the surface's default
|
|
178
|
+
* campaign (the one `primarySponsor` / `secondarySponsors` belong to).
|
|
179
|
+
*/
|
|
180
|
+
interface BootstrapCampaign {
|
|
181
|
+
id: number;
|
|
182
|
+
name: string;
|
|
183
|
+
logo?: string | null;
|
|
184
|
+
isActive?: boolean;
|
|
185
|
+
isPaused?: boolean;
|
|
186
|
+
startDate?: string | null;
|
|
187
|
+
endDate?: string | null;
|
|
188
|
+
}
|
|
189
|
+
/** Campaign status as the backend computes it (`[startsAt, endsAt)`). */
|
|
190
|
+
type BootstrapCampaignStatus = 'scheduled' | 'active' | 'paused' | 'ended';
|
|
191
|
+
/** A slot assignment of a campaign on this surface (`campaigns[].slots[]`). */
|
|
192
|
+
interface BootstrapSlot {
|
|
193
|
+
name: string;
|
|
194
|
+
platform?: string | null;
|
|
195
|
+
startDate?: string | null;
|
|
196
|
+
endDate?: string | null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* One entry of `campaigns[]`: every active campaign of the surface, with its
|
|
200
|
+
* own sponsors — a sponsor may live only in a non-default campaign.
|
|
201
|
+
*/
|
|
202
|
+
interface BootstrapCampaignEntry extends BootstrapCampaign {
|
|
203
|
+
isDefault?: boolean;
|
|
204
|
+
status?: BootstrapCampaignStatus;
|
|
205
|
+
primarySponsor?: Sponsor | null;
|
|
206
|
+
secondarySponsors?: Sponsor[];
|
|
207
|
+
slots?: BootstrapSlot[];
|
|
208
|
+
}
|
|
153
209
|
/**
|
|
154
210
|
* Response shape of `GET /v2/mobile/config` (and likely future `/v2/web/config`).
|
|
155
211
|
* Matches the iOS SDK's `SdkBootstrapResponse` model.
|
|
212
|
+
*
|
|
213
|
+
* `campaign` + `primarySponsor` + `secondarySponsors` describe the surface's
|
|
214
|
+
* default campaign; `campaigns[]` lists every active one. There is no
|
|
215
|
+
* top-level `campaignId` — the id lives in `campaign.id`.
|
|
156
216
|
*/
|
|
157
217
|
interface BootstrapResponse {
|
|
158
|
-
|
|
218
|
+
endpoints?: {
|
|
219
|
+
webSocketBase?: string;
|
|
220
|
+
commerceGraphQL?: string;
|
|
221
|
+
};
|
|
222
|
+
campaign?: BootstrapCampaign;
|
|
159
223
|
primarySponsor?: Sponsor;
|
|
160
224
|
secondarySponsors?: Sponsor[];
|
|
225
|
+
features?: {
|
|
226
|
+
shoppable?: boolean;
|
|
227
|
+
lineup?: boolean;
|
|
228
|
+
};
|
|
229
|
+
campaigns?: BootstrapCampaignEntry[];
|
|
161
230
|
market?: {
|
|
162
231
|
countryCode: string;
|
|
163
232
|
currencyCode: string;
|
|
164
233
|
};
|
|
165
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* A slot this page declares to the campaigns service (ADR-0027 / ADR-0034):
|
|
237
|
+
* `id` is the slot name (≤ 100 chars, what `vio-slot` carries and what the
|
|
238
|
+
* dashboard assigns a campaign to); `displayName` is only for the dashboard.
|
|
239
|
+
*/
|
|
240
|
+
interface ManifestLocation {
|
|
241
|
+
id: string;
|
|
242
|
+
displayName?: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Where something happened, as `Vio.attribution(slot)` answers it — the ONE
|
|
246
|
+
* attribution shape the SDK elements, Vev and Replit all use: the place
|
|
247
|
+
* (`slot`), the campaign that place shows right now and its primary sponsor,
|
|
248
|
+
* and the content (article) the page is. Everything optional: `{}` before the
|
|
249
|
+
* bootstrap, except the content.
|
|
250
|
+
*/
|
|
251
|
+
interface Attribution {
|
|
252
|
+
slot?: string;
|
|
253
|
+
campaignId?: number;
|
|
254
|
+
sponsorId?: number;
|
|
255
|
+
contentId?: string;
|
|
256
|
+
contentTitle?: string;
|
|
257
|
+
}
|
|
258
|
+
/** Body of `POST /v2/mobile/components/manifest`. */
|
|
259
|
+
interface ManifestRequest {
|
|
260
|
+
platform: string;
|
|
261
|
+
/**
|
|
262
|
+
* `merge` upserts the slots without deprecating those of other pages (a
|
|
263
|
+
* surface on the web has many pages, each knowing only its own blocks);
|
|
264
|
+
* `replace` (the native SDKs' mode) deprecates whatever is not listed.
|
|
265
|
+
*/
|
|
266
|
+
mode: 'merge' | 'replace';
|
|
267
|
+
locations: ManifestLocation[];
|
|
268
|
+
}
|
|
269
|
+
/** Response of `POST /v2/mobile/components/manifest`. */
|
|
270
|
+
interface ManifestResult {
|
|
271
|
+
clientAppId: number;
|
|
272
|
+
platform: string;
|
|
273
|
+
mode: 'merge' | 'replace';
|
|
274
|
+
locations: Array<{
|
|
275
|
+
id: number | string;
|
|
276
|
+
locationId: string;
|
|
277
|
+
displayName?: string | null;
|
|
278
|
+
}>;
|
|
279
|
+
deprecatedCount: number;
|
|
280
|
+
warnings: Array<{
|
|
281
|
+
kind: string;
|
|
282
|
+
detail: string;
|
|
283
|
+
}>;
|
|
284
|
+
}
|
|
166
285
|
/**
|
|
167
286
|
* A placement component returned by `/v2/mobile/campaigns/:id/components`.
|
|
168
287
|
* Used by `<vio-product-carousel campaign-id="...">` to know which products
|
|
@@ -223,14 +342,24 @@ declare class VioApi {
|
|
|
223
342
|
/**
|
|
224
343
|
* Bootstrap — fetches client app config (sponsors with commerce keys,
|
|
225
344
|
* default market, campaign id). Called once at SDK init.
|
|
345
|
+
*
|
|
346
|
+
* With `platform`, `campaigns[].slots[]` only lists the assignments of that
|
|
347
|
+
* platform (plus the ones with no platform) — see ADR-0027.
|
|
226
348
|
*/
|
|
227
|
-
bootstrap(): Promise<BootstrapResponse>;
|
|
349
|
+
bootstrap(platform?: string): Promise<BootstrapResponse>;
|
|
350
|
+
/**
|
|
351
|
+
* Declare the slots of this page to the campaigns service
|
|
352
|
+
* (`POST /v2/mobile/components/manifest`, ADR-0034). The web SDK always
|
|
353
|
+
* sends `mode: 'merge'`; see `Vio.declareSlots()` for the dedupe on top.
|
|
354
|
+
*/
|
|
355
|
+
declareManifest(body: ManifestRequest): Promise<ManifestResult>;
|
|
228
356
|
/**
|
|
229
357
|
* Get placement components for a campaign. Used by the carousel auto-fetch
|
|
230
358
|
* mode (`<vio-product-carousel campaign-id="36" location="news-favorites">`).
|
|
231
359
|
*/
|
|
232
360
|
getComponents(campaignId: number | string): Promise<PlacementComponent[]>;
|
|
233
361
|
private get;
|
|
362
|
+
private post;
|
|
234
363
|
}
|
|
235
364
|
declare class VioApiError extends Error {
|
|
236
365
|
readonly status: number;
|
|
@@ -310,6 +439,21 @@ declare function createCommerceClient(options: CommerceClientOptions): CommerceC
|
|
|
310
439
|
* Mirrors the iOS SDK's `SponsorCart` + `CartLineItem` structure so the
|
|
311
440
|
* mental model stays consistent across platforms.
|
|
312
441
|
*/
|
|
442
|
+
/**
|
|
443
|
+
* Where a unit in the cart came from (ADR-0027 / ADR-0034): the campaign
|
|
444
|
+
* the place showed when it was added, the place (`slot`) and the content
|
|
445
|
+
* (article). What `Vio.attribution(slot)` answers, minus the sponsor and the
|
|
446
|
+
* title. The purchase is split per campaign from these.
|
|
447
|
+
*/
|
|
448
|
+
interface CartOrigin {
|
|
449
|
+
campaignId?: number;
|
|
450
|
+
slot?: string;
|
|
451
|
+
contentId?: string;
|
|
452
|
+
}
|
|
453
|
+
/** One origin of a line and how many of its units came from it. */
|
|
454
|
+
interface CartLineOrigin extends CartOrigin {
|
|
455
|
+
quantity: number;
|
|
456
|
+
}
|
|
313
457
|
interface CartLineItem {
|
|
314
458
|
/** Unique local id for this line item (used for update/remove). */
|
|
315
459
|
id: string;
|
|
@@ -333,6 +477,12 @@ interface CartLineItem {
|
|
|
333
477
|
imageUrl: string;
|
|
334
478
|
/** Quantity. */
|
|
335
479
|
quantity: number;
|
|
480
|
+
/**
|
|
481
|
+
* Where the units came from, most recent last; their quantities add up to
|
|
482
|
+
* `quantity`. Absent on carts persisted before origins existed — read them
|
|
483
|
+
* through `lineOrigins()`, which fills the gap with an empty origin.
|
|
484
|
+
*/
|
|
485
|
+
origins?: CartLineOrigin[];
|
|
336
486
|
/** Selected shipping for this line (backend cart). */
|
|
337
487
|
shipping?: unknown;
|
|
338
488
|
/** Shipping options offered by the backend for this line. */
|
|
@@ -374,6 +524,8 @@ interface AddProductOptions {
|
|
|
374
524
|
sponsorName?: string;
|
|
375
525
|
quantity?: number;
|
|
376
526
|
variantId?: number;
|
|
527
|
+
/** Where these units come from (`Vio.attribution(slot)`); see `CartOrigin`. */
|
|
528
|
+
origin?: CartOrigin;
|
|
377
529
|
}
|
|
378
530
|
/** Minimal product shape — for callers who only have e.g. mock data, not a full Product. */
|
|
379
531
|
interface AddManualOptions {
|
|
@@ -387,6 +539,8 @@ interface AddManualOptions {
|
|
|
387
539
|
imageUrl: string;
|
|
388
540
|
quantity?: number;
|
|
389
541
|
variantId?: number;
|
|
542
|
+
/** Where these units come from (`Vio.attribution(slot)`); see `CartOrigin`. */
|
|
543
|
+
origin?: CartOrigin;
|
|
390
544
|
}
|
|
391
545
|
declare class CartManager extends EventTarget {
|
|
392
546
|
private cartsBySponsor;
|
|
@@ -404,13 +558,36 @@ declare class CartManager extends EventTarget {
|
|
|
404
558
|
* landed (Alan, 2026-08-18: shippings queried before AddItem settled,
|
|
405
559
|
* came back empty). */
|
|
406
560
|
private inFlightMutations;
|
|
561
|
+
/** Per-line quantity sync with the backend: at most ONE UpdateItem /
|
|
562
|
+
* DeleteItem in flight per line. Targets that arrive while one is in flight
|
|
563
|
+
* are coalesced into `pending` (only the latest survives) and sent when the
|
|
564
|
+
* current request settles. Keyed by `${sponsorId}:${cartItemId}`.
|
|
565
|
+
* (Alan, 2026-10-15: a burst of +/− clicks fired one UpdateItem per click
|
|
566
|
+
* in parallel; each response re-applied the whole backend cart, so an
|
|
567
|
+
* older one landing after a newer optimistic change rolled the line back.) */
|
|
568
|
+
private qtySyncs;
|
|
407
569
|
constructor();
|
|
408
570
|
private nextSeq;
|
|
409
|
-
/** Resolves once
|
|
410
|
-
* sponsor has settled (success or failure)
|
|
571
|
+
/** Resolves once every in-flight AddItem/UpdateItem/DeleteItem for this
|
|
572
|
+
* sponsor has settled (success or failure), including ones started while
|
|
573
|
+
* waiting (a quantity intent replayed by an AddItem reconcile). No-op if
|
|
574
|
+
* nothing is pending. */
|
|
411
575
|
waitForCartMutations(sponsorId: number): Promise<void>;
|
|
412
|
-
/**
|
|
576
|
+
/** Register a backend mutation so `waitForCartMutations` can await it. */
|
|
577
|
+
private trackMutation;
|
|
578
|
+
private qtySyncKey;
|
|
579
|
+
/** The quantity a line is heading to (pending beats in flight), or
|
|
580
|
+
* undefined when no quantity sync is active for it. */
|
|
581
|
+
private intendedQuantity;
|
|
582
|
+
/** Apply a backend response only if no newer response was applied already.
|
|
583
|
+
* Returns false when it was discarded as stale. */
|
|
413
584
|
private applyBackendCart;
|
|
585
|
+
/** The final answer of a line's sync lost the per-sponsor seq race (another
|
|
586
|
+
* line answered later): the cart as a whole is stale, but for THIS line it
|
|
587
|
+
* is the latest word. Copy its quantity (and price) so a server-side clamp
|
|
588
|
+
* — stock — doesn't leave the optimistic value behind for good, with the
|
|
589
|
+
* checkout / Apple Pay total built on it. */
|
|
590
|
+
private reconcileLineFromResponse;
|
|
414
591
|
/** Surface a cart sync problem to hosts/UI (and the console). */
|
|
415
592
|
private emitError;
|
|
416
593
|
/** Ensure the sponsor cart exists server-side; returns its backend cart id. */
|
|
@@ -455,7 +632,28 @@ declare class CartManager extends EventTarget {
|
|
|
455
632
|
* when the AddItem response reconciles (keyed by product::variant). */
|
|
456
633
|
private pendingQtyIntents;
|
|
457
634
|
private intentKey;
|
|
458
|
-
|
|
635
|
+
private findLine;
|
|
636
|
+
/** Change a line's quantity by `delta`, computed on the manager's CURRENT
|
|
637
|
+
* quantity — not on whatever a UI rendered a moment ago. A burst of +/−
|
|
638
|
+
* clicks before a re-render therefore asks for 2, 3, 4… and not for the
|
|
639
|
+
* same target several times. Reaching 0 removes the line. */
|
|
640
|
+
adjustQuantity(lineItemId: string, sponsorId: number, delta: number, opts?: {
|
|
641
|
+
origin?: CartOrigin;
|
|
642
|
+
}): void;
|
|
643
|
+
/** Set a line's quantity (0 or less removes it). Optimistic: the local
|
|
644
|
+
* state and `change` update at once; the backend is synced through
|
|
645
|
+
* `syncQuantity`, one request in flight per line, latest target wins. */
|
|
646
|
+
updateQuantity(lineItemId: string, sponsorId: number, quantity: number, opts?: {
|
|
647
|
+
origin?: CartOrigin;
|
|
648
|
+
}): void;
|
|
649
|
+
/** Send a line's target quantity to the backend — ONE request in flight per
|
|
650
|
+
* line. A target that arrives while one is in flight replaces any earlier
|
|
651
|
+
* waiting one and goes out when the current request settles, so the server
|
|
652
|
+
* ends on the last intent and never sees two updates racing each other.
|
|
653
|
+
* While the sync is active the line keeps its optimistic quantity through
|
|
654
|
+
* any backend response (see `updateFromBackendCart`); a rejection drops
|
|
655
|
+
* what was queued and reconciles the cart from the server. */
|
|
656
|
+
private syncQuantity;
|
|
459
657
|
removeItem(lineItemId: string, sponsorId: number): void;
|
|
460
658
|
clearSponsorCart(sponsorId: number): void;
|
|
461
659
|
clearAllCarts(): void;
|
|
@@ -479,6 +677,16 @@ declare class CartManager extends EventTarget {
|
|
|
479
677
|
private loadFromStorage;
|
|
480
678
|
private emit;
|
|
481
679
|
}
|
|
680
|
+
/** Only the three attribution fields, trimmed; `{}` when nothing is known. */
|
|
681
|
+
declare function normalizeOrigin(origin: CartOrigin | null | undefined): CartOrigin;
|
|
682
|
+
/** Two origins are the same place when campaign, slot and content all match. */
|
|
683
|
+
declare function sameOrigin(a: CartOrigin, b: CartOrigin): boolean;
|
|
684
|
+
/**
|
|
685
|
+
* The origins of a line for reporting: what it carries, plus an empty origin
|
|
686
|
+
* for any units it does not account for (a cart persisted before origins
|
|
687
|
+
* existed, a server-side bump). Their quantities add up to the line's.
|
|
688
|
+
*/
|
|
689
|
+
declare function lineOrigins(line: Pick<CartLineItem, 'origins' | 'quantity'>): CartLineOrigin[];
|
|
482
690
|
|
|
483
691
|
/**
|
|
484
692
|
* Vipps MobilePay Payment Adapter — GraphQL Integration & Types.
|
|
@@ -499,7 +707,7 @@ declare const CREATE_PAYMENT_VIPPS_MUTATION = "\nmutation CreatePaymentVipps($ch
|
|
|
499
707
|
/**
|
|
500
708
|
* GraphQL query to fetch current Vipps payment status.
|
|
501
709
|
*/
|
|
502
|
-
declare const GET_VIPPS_STATUS_QUERY = "\nquery GetVippsStatus($checkoutId: String!) {\n Payment {\n GetVippsStatus(checkout_id: $checkoutId) {\n state\n }\n }\n}\n";
|
|
710
|
+
declare const GET_VIPPS_STATUS_QUERY = "\nquery GetVippsStatus($checkoutId: String!) {\n Payment {\n GetVippsStatus(checkout_id: $checkoutId) {\n state\n duplicate_of\n }\n }\n}\n";
|
|
503
711
|
interface CreatePaymentVippsVariables extends Record<string, unknown> {
|
|
504
712
|
checkoutId: string;
|
|
505
713
|
/** Optional since Express: Vipps hands the email back with the payment. */
|
|
@@ -526,6 +734,8 @@ interface GetVippsStatusVariables extends Record<string, unknown> {
|
|
|
526
734
|
}
|
|
527
735
|
interface VippsStatusResult {
|
|
528
736
|
state: string;
|
|
737
|
+
/** Set when this checkout was closed as a duplicate: the checkout that paid the cart. */
|
|
738
|
+
duplicate_of?: string | null;
|
|
529
739
|
}
|
|
530
740
|
type VippsPaymentState = 'CREATED' | 'INITIATED' | 'AUTHORIZED' | 'TERMINATED' | 'EXPIRED' | string;
|
|
531
741
|
/**
|
|
@@ -546,7 +756,7 @@ declare const GET_LINE_ITEMS_BY_SUPPLIER_QUERY = "\nquery GetLineItemsBySupplier
|
|
|
546
756
|
declare const UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION = "\nmutation UpdateShippingsBySupplier($cartId: String!, $data: [DataUpdateShippingsBySupplier!]!) {\n Cart {\n UpdateShippingsBySupplier(cart_id: $cartId, data: $data) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
547
757
|
declare const CREATE_CHECKOUT_MUTATION = "\nmutation CreateCheckout($cartId: String!) {\n Checkout {\n CreateCheckout(cart_id: $cartId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
548
758
|
declare const UPDATE_CHECKOUT_MUTATION = "\nmutation UpdateCheckout($checkoutId: String!, $status: String, $successUrl: String, $email: String, $cancelUrl: String, $paymentMethod: String, $shippingAddress: AddressArgs, $billingAddress: AddressArgs, $buyerAcceptsPurchaseConditions: Boolean, $buyerAcceptsTermsConditions: Boolean) {\n Checkout {\n UpdateCheckout(checkout_id: $checkoutId, status: $status, success_url: $successUrl, email: $email, cancel_url: $cancelUrl, payment_method: $paymentMethod, shipping_address: $shippingAddress, billing_address: $billingAddress, buyer_accepts_purchase_conditions: $buyerAcceptsPurchaseConditions, buyer_accepts_terms_conditions: $buyerAcceptsTermsConditions) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
549
|
-
declare const GET_CHECKOUT_QUERY = "\nquery GetCheckout($checkoutId: String!) {\n Checkout {\n GetCheckout(checkout_id: $checkoutId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
759
|
+
declare const GET_CHECKOUT_QUERY = "\nquery GetCheckout($checkoutId: String!) {\n Checkout {\n GetCheckout(checkout_id: $checkoutId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n duplicate_of\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
550
760
|
declare const GET_AVAILABLE_PAYMENT_METHODS_QUERY = "\nquery Config {\n Payment {\n GetAvailablePaymentMethods {\n config {\n name\n type\n value\n }\n name\n }\n }\n}\n";
|
|
551
761
|
/** Transport options for a cart/checkout GraphQL call. */
|
|
552
762
|
interface CartQueryOptions {
|
|
@@ -576,7 +786,8 @@ interface GraphQLEnvelope {
|
|
|
576
786
|
}
|
|
577
787
|
/** Execute a GraphQL query/mutation against the configured commerce endpoint.
|
|
578
788
|
* Callers that skip `getCartGraphQLOptions()` (or pass a bare sponsorId) get
|
|
579
|
-
* it resolved here instead of silently sending an unauthenticated request.
|
|
789
|
+
* it resolved here instead of silently sending an unauthenticated request.
|
|
790
|
+
* Rejects after `CART_GRAPHQL_TIMEOUT_MS` (and aborts the fetch). */
|
|
580
791
|
declare function executeCartGraphQL(query: string, variables: Record<string, unknown>, options?: CartQueryOptions | number | undefined): Promise<GraphQLEnvelope>;
|
|
581
792
|
declare function createCart(customerSessionId: string, currency: string, shippingCountry?: string | null, options?: CartQueryOptions): Promise<any>;
|
|
582
793
|
declare function addItem(cartId: string, lineItems: unknown[], options?: CartQueryOptions): Promise<any>;
|
|
@@ -1391,6 +1602,7 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1391
1602
|
* cart-queries.ts for why this exists instead of trusting GetCheckout. */
|
|
1392
1603
|
getVippsStatus(checkoutId: string, sponsorId?: number): Promise<{
|
|
1393
1604
|
state?: string;
|
|
1605
|
+
duplicate_of?: string | null;
|
|
1394
1606
|
} | null>;
|
|
1395
1607
|
/**
|
|
1396
1608
|
* Kustom (former Klarna Checkout) — create the KCO order via Vio Commerce
|
|
@@ -1726,6 +1938,7 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1726
1938
|
* the publisher-facing feature; NOT part of the Vio pipeline)
|
|
1727
1939
|
* 3. `vio:analytics` DOM event — always when started (inspector/bridges)
|
|
1728
1940
|
*/
|
|
1941
|
+
|
|
1729
1942
|
declare const ANALYTICS_EVENT_NAMES: readonly ["view_item_list", "select_item", "view_item", "add_to_cart", "remove_from_cart", "view_cart", "begin_checkout", "purchase", "component_impression", "component_click", "ad_impression", "ad_click", "poll_impression", "contest_impression", "session_start", "session_end", "checkout_error", "sdk_error"];
|
|
1730
1943
|
type AnalyticsEventName = (typeof ANALYTICS_EVENT_NAMES)[number];
|
|
1731
1944
|
/** Camel-case for DX; mapped to the snake_case wire format at build time. */
|
|
@@ -1751,6 +1964,14 @@ interface AnalyticsContext {
|
|
|
1751
1964
|
/** Código corto del fallo (`sdk_error` / `checkout_error`). */
|
|
1752
1965
|
errorCode?: string;
|
|
1753
1966
|
variant?: string;
|
|
1967
|
+
/**
|
|
1968
|
+
* The slot (ADR-0027) the component sits in — its `vio-slot`. Attribution
|
|
1969
|
+
* follows it: the event's `campaign_id` is the campaign assigned to the slot
|
|
1970
|
+
* right now, before the sponsor rule. On the wire it fills `location_id`
|
|
1971
|
+
* when no explicit `locationId` is given (a slot IS a location id to the
|
|
1972
|
+
* campaigns service).
|
|
1973
|
+
*/
|
|
1974
|
+
slot?: string;
|
|
1754
1975
|
}
|
|
1755
1976
|
interface AnalyticsItemInput {
|
|
1756
1977
|
productId: number | string;
|
|
@@ -1878,10 +2099,175 @@ declare class AnalyticsManager extends EventTarget {
|
|
|
1878
2099
|
* writes ZERO tracking code for the commerce funnel.
|
|
1879
2100
|
*/
|
|
1880
2101
|
private installAutoListeners;
|
|
2102
|
+
/** The lines of the cart (current, else the pre-clear snapshot), optionally one sponsor's. */
|
|
2103
|
+
private cartLines;
|
|
2104
|
+
/**
|
|
2105
|
+
* The cart split per campaign (ADR-0034): every unit of every line goes to
|
|
2106
|
+
* the campaign of its origin — the one the place showed when it was added
|
|
2107
|
+
* — and units without one to the campaign the current rule resolves for
|
|
2108
|
+
* the line's sponsor. One slice per campaign: its items (quantities from
|
|
2109
|
+
* the origins), its value, and the slot / content when they are the same
|
|
2110
|
+
* for the whole slice. A cart with one campaign is one slice.
|
|
2111
|
+
*/
|
|
2112
|
+
private cartSlices;
|
|
2113
|
+
/** The context of a per-campaign event: the slice's campaign, slot and content, over the event's own. */
|
|
2114
|
+
private sliceContext;
|
|
1881
2115
|
/** Current cart → commerce payload; falls back to the pre-clear snapshot. */
|
|
1882
2116
|
private cartCommerce;
|
|
1883
2117
|
private findLine;
|
|
1884
2118
|
}
|
|
2119
|
+
/**
|
|
2120
|
+
* The `campaign_id` of an event. In order: the context's explicit id; the
|
|
2121
|
+
* campaign assigned to the context's `slot` right now (ADR-0027 — only an
|
|
2122
|
+
* open assignment for the init platform counts, see `findSlotAssignment`);
|
|
2123
|
+
* the active campaign of `campaigns[]` the event's sponsor takes part in, as
|
|
2124
|
+
* its primary or one of its secondaries — when it is in several, the
|
|
2125
|
+
* surface's default campaign if it is one of them, else the first one the
|
|
2126
|
+
* backend lists; the default campaign (`campaign.id`). `/v2/mobile/config`
|
|
2127
|
+
* has no top-level `campaignId` — reading one is why every event used to
|
|
2128
|
+
* leave with `campaign_id: 0` and the campaigns screen stayed empty.
|
|
2129
|
+
*
|
|
2130
|
+
* A malformed `campaigns[]` (not an array, a null entry) never breaks
|
|
2131
|
+
* `track()`: it falls back to `campaign.id`.
|
|
2132
|
+
*/
|
|
2133
|
+
declare function resolveCampaignId(ctx: Pick<AnalyticsContext, 'campaignId' | 'sponsorId' | 'slot'>, boot: Pick<BootstrapResponse, 'campaign' | 'campaigns'> | null | undefined): number | undefined;
|
|
2134
|
+
/**
|
|
2135
|
+
* `detail` of `vio:payment-success` as the checkout emits it. Four paths,
|
|
2136
|
+
* three shapes: a redirect return (`orderId` = Vio's checkout id), the
|
|
2137
|
+
* confirmation drawer and a provider's own receipt (`result` from the
|
|
2138
|
+
* provider or the backend, plus Vio's `checkoutId`), and Apple Pay express
|
|
2139
|
+
* from the cart (`result` with the backend's `confirmation`, no sponsor).
|
|
2140
|
+
*/
|
|
2141
|
+
interface PaymentSuccessDetail {
|
|
2142
|
+
method?: string;
|
|
2143
|
+
sponsorId?: number | string;
|
|
2144
|
+
/** The slot the purchase started from, when the emitter knows it. */
|
|
2145
|
+
slot?: string;
|
|
2146
|
+
/** Per-element content override (`vio-content-id` / `vio-content-title`), when the emitter carries one. */
|
|
2147
|
+
contentId?: string | number;
|
|
2148
|
+
contentTitle?: string;
|
|
2149
|
+
/** Redirect return: Vio's checkout id (the name predates `checkoutId`). */
|
|
2150
|
+
orderId?: string | number;
|
|
2151
|
+
/** Vio's checkout id — from the checkout state or the return URL. */
|
|
2152
|
+
checkoutId?: string | number;
|
|
2153
|
+
result?: PaymentSuccessResult | null;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* What the checkout attaches as `result`. Only `confirmation` carries a Vio
|
|
2157
|
+
* id: the order `ConfirmPaymentApplePay` created. `order.orderId` / `orderId`
|
|
2158
|
+
* are the PROVIDER's references (Qliro's, Walley's — the checkout itself
|
|
2159
|
+
* shows them as `providerRef`), and `chargedTotal` includes shipping on some
|
|
2160
|
+
* methods only. Analytics reads none of those.
|
|
2161
|
+
*/
|
|
2162
|
+
interface PaymentSuccessResult {
|
|
2163
|
+
confirmation?: {
|
|
2164
|
+
orderId?: string | number | null;
|
|
2165
|
+
status?: string;
|
|
2166
|
+
} | null;
|
|
2167
|
+
[key: string]: unknown;
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* The `order_id` of a `purchase`: ALWAYS a Vio id, never a provider's
|
|
2171
|
+
* reference. Normalized across every emitter: `orderId` (redirect return) →
|
|
2172
|
+
* `result.confirmation.orderId` (Apple Pay) → `checkoutId`. `value` and
|
|
2173
|
+
* `currency` are deliberately NOT read from the result: on every path they
|
|
2174
|
+
* come from the cart snapshot (sum of the items, no shipping), so revenue
|
|
2175
|
+
* stays comparable across payment methods — the charged total will arrive
|
|
2176
|
+
* through the server-side `order_paid` event. With nothing to say it
|
|
2177
|
+
* returns `{}`, so the cart snapshot keeps its keys.
|
|
2178
|
+
*/
|
|
2179
|
+
declare function purchaseFromPaymentSuccess(d: PaymentSuccessDetail): Pick<AnalyticsCommerce, 'orderId'>;
|
|
2180
|
+
|
|
2181
|
+
/**
|
|
2182
|
+
* Content (article) attribution — the other half of "where did this happen".
|
|
2183
|
+
*
|
|
2184
|
+
* The SLOT says the place on the page (`carousel-1`, `hero`); the CONTENT says
|
|
2185
|
+
* the article/page the place was rendered in. One Vev design serves thousands
|
|
2186
|
+
* of article URLs, so the article must not leak into the slot id — it travels
|
|
2187
|
+
* on every analytics event as `content_id` / `content_title` instead, and this
|
|
2188
|
+
* module finds it without the editor doing anything.
|
|
2189
|
+
*
|
|
2190
|
+
* Pure: `resolveContent()` takes the document and location (defaults to the
|
|
2191
|
+
* globals) so it can be tested, never throws, and answers `{}` where there is
|
|
2192
|
+
* no DOM (SSR, node tests). `Vio.content()` caches it per page and forgets the
|
|
2193
|
+
* cache on every `Vio.init()`.
|
|
2194
|
+
*/
|
|
2195
|
+
interface ContentRef {
|
|
2196
|
+
id?: string;
|
|
2197
|
+
title?: string;
|
|
2198
|
+
}
|
|
2199
|
+
interface ContentInit {
|
|
2200
|
+
contentId?: string | number | null;
|
|
2201
|
+
contentTitle?: string | null;
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Id: `Vio.init({ contentId })` → `?vio_content=` → `<meta name="vio:content-id">`
|
|
2205
|
+
* → `<link rel="canonical">` href or `<meta property="og:url">` (without query
|
|
2206
|
+
* and hash) → `location.pathname`.
|
|
2207
|
+
* Title: `Vio.init({ contentTitle })` → `?vio_content_title=` →
|
|
2208
|
+
* `<meta name="vio:content-title">` → `<meta property="og:title">` → `document.title`.
|
|
2209
|
+
*/
|
|
2210
|
+
declare function resolveContent(init?: ContentInit | null, doc?: Document | null | undefined, loc?: Location | {
|
|
2211
|
+
href?: string;
|
|
2212
|
+
pathname?: string;
|
|
2213
|
+
search?: string;
|
|
2214
|
+
} | null | undefined): ContentRef;
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Slots — the pure half of ADR-0027 / ADR-0034 on the web.
|
|
2218
|
+
*
|
|
2219
|
+
* A slot is a NAME for a place on a page. The page declares its slots to the
|
|
2220
|
+
* campaigns service (`Vio.declareSlots()` / `Vio.registerSlot()` in client.ts),
|
|
2221
|
+
* the dashboard assigns a campaign to each one, optionally with a date window,
|
|
2222
|
+
* and `GET /v2/mobile/config` answers with `campaigns[].slots[]` — only the
|
|
2223
|
+
* assignments whose window is open NOW. Whatever no slot names shows the
|
|
2224
|
+
* surface's default campaign (`campaign`).
|
|
2225
|
+
*
|
|
2226
|
+
* Everything here is side-effect free and never throws on a malformed
|
|
2227
|
+
* bootstrap: a broken `campaigns[]` must never blank a product block or break
|
|
2228
|
+
* `track()`.
|
|
2229
|
+
*/
|
|
2230
|
+
|
|
2231
|
+
/** What `Vio.declareSlots()` accepts per slot. */
|
|
2232
|
+
type SlotInput = string | {
|
|
2233
|
+
id: string;
|
|
2234
|
+
displayName?: string;
|
|
2235
|
+
};
|
|
2236
|
+
type BootLike = Pick<BootstrapResponse, 'campaign' | 'campaigns' | 'primarySponsor' | 'secondarySponsors'>;
|
|
2237
|
+
/**
|
|
2238
|
+
* The campaign a slot shows right now. Among the `status === 'active'`
|
|
2239
|
+
* entries of `campaigns[]`, the one with an assignment named `slot` for this
|
|
2240
|
+
* platform (`platform` null on the assignment, or equal to `platform`) whose
|
|
2241
|
+
* window contains `now` (`startDate <= now < endDate`, null = open). When
|
|
2242
|
+
* several qualify, the surface's default campaign wins, else the first the
|
|
2243
|
+
* backend lists.
|
|
2244
|
+
*
|
|
2245
|
+
* No slot, or no assignment → the default campaign: the `campaigns[]` entry
|
|
2246
|
+
* whose id is `campaign.id`, or a minimal entry built from `campaign` (+ the
|
|
2247
|
+
* top-level sponsors) when the list does not carry it. No bootstrap → null.
|
|
2248
|
+
*/
|
|
2249
|
+
declare function resolveSlotCampaign(boot: BootLike | null | undefined, slot: string | null | undefined, now?: number, platform?: string | null): BootstrapCampaignEntry | null;
|
|
2250
|
+
/** The kinds of Vio element that register themselves. */
|
|
2251
|
+
type SlotKind = 'card' | 'carousel' | 'detail';
|
|
2252
|
+
/**
|
|
2253
|
+
* The id an element gets when the host set no `vio-slot`:
|
|
2254
|
+
* `${scope ? scope + '-' : ''}${kind}-${ordinal + 1}` (`carousel-1`, `card-3`,
|
|
2255
|
+
* `article-123-carousel-1`), `ordinal` being the element's index among the
|
|
2256
|
+
* same-kind Vio elements WITH THE SAME SCOPE, in document order at connect
|
|
2257
|
+
* time. The scope is inherited from the DOM (`vio-scope` on the element, else
|
|
2258
|
+
* the nearest `data-vio-scope` ancestor): a Vev page or a Replit article
|
|
2259
|
+
* (`<body data-vio-scope="article-123">`) gets per-page slots with one line
|
|
2260
|
+
* and no per-element naming; a template that wants slots shared across
|
|
2261
|
+
* articles simply sets no scope. On purpose there is NO page path in the id:
|
|
2262
|
+
* the article goes to analytics as `content_id`, not into the slot. Stable
|
|
2263
|
+
* across reloads while the layout is; a layout change leaves a stale entry,
|
|
2264
|
+
* which ADR-0034 accepts.
|
|
2265
|
+
*/
|
|
2266
|
+
declare function autoSlotId(kind: SlotKind, ordinal: number, scope?: string | null): string;
|
|
2267
|
+
/** `"Carousel 1"`, `"Card 3"` — with ` · ${scopeName}` when the scope has a human label. */
|
|
2268
|
+
declare function autoSlotDisplayName(kind: SlotKind, ordinal: number, scopeName?: string | null): string;
|
|
2269
|
+
/** A scope value fit for an id: trimmed, inner whitespace → `-`. */
|
|
2270
|
+
declare function normalizeScope(scope: string | null | undefined): string;
|
|
1885
2271
|
|
|
1886
2272
|
declare class VioFacade {
|
|
1887
2273
|
private apiInstance;
|
|
@@ -1891,10 +2277,31 @@ declare class VioFacade {
|
|
|
1891
2277
|
/** Last bootstrap failure — short backoff so cart mutations don't hammer a
|
|
1892
2278
|
* dead endpoint on every call. */
|
|
1893
2279
|
private bootstrapFailedAt;
|
|
2280
|
+
/** Bumped by every init(). A bootstrap started under an older configuration
|
|
2281
|
+
* (another key or environment) is still in flight after a re-init; its answer
|
|
2282
|
+
* belongs to that configuration and must not land in this one. */
|
|
2283
|
+
private generation;
|
|
2284
|
+
/** Slot ids present on the page (`Vio.registerSlot`): how many elements hold each + its display name. */
|
|
2285
|
+
private slotRegistry;
|
|
2286
|
+
/** Pending debounced declaration of the registry. */
|
|
2287
|
+
private slotDeclareTimer;
|
|
2288
|
+
/** A name appeared (or the key changed) since the registry was last declared. */
|
|
2289
|
+
private slotsDirty;
|
|
2290
|
+
/** `Vio.content()` resolved once per page; forgotten on every init(). */
|
|
2291
|
+
private contentCache;
|
|
1894
2292
|
private cartManager;
|
|
1895
2293
|
private checkoutManager;
|
|
1896
2294
|
private analyticsManager;
|
|
1897
2295
|
init(config: VioConfig): void;
|
|
2296
|
+
/**
|
|
2297
|
+
* The content (article, page) this SDK instance is rendered in — what every
|
|
2298
|
+
* analytics event carries as `content_id` / `content_title` when the event
|
|
2299
|
+
* has no explicit one. Resolved once per page (init option → URL query →
|
|
2300
|
+
* `vio:content-*` metas → canonical/og:url → pathname; see
|
|
2301
|
+
* `resolveContent`), forgotten on every `init()`. Never throws; `{}` without
|
|
2302
|
+
* a document.
|
|
2303
|
+
*/
|
|
2304
|
+
content(): ContentRef;
|
|
1898
2305
|
get isInitialized(): boolean;
|
|
1899
2306
|
get config(): ResolvedConfig;
|
|
1900
2307
|
/** Multi-sponsor cart manager. Reactive — listen via addEventListener('change', ...). */
|
|
@@ -1911,6 +2318,11 @@ declare class VioFacade {
|
|
|
1911
2318
|
/**
|
|
1912
2319
|
* Bootstrap — fetches client config and caches it. Dedupes in-flight
|
|
1913
2320
|
* concurrent requests.
|
|
2321
|
+
*
|
|
2322
|
+
* A request that was started before the last init() (Vev starts with the key
|
|
2323
|
+
* the browser remembers, then the page's own key arrives) answers for a key
|
|
2324
|
+
* that is gone: it neither fills the cache nor arms the failure backoff, and
|
|
2325
|
+
* whoever awaited it gets the current configuration's bootstrap instead.
|
|
1914
2326
|
*/
|
|
1915
2327
|
bootstrap(): Promise<BootstrapResponse>;
|
|
1916
2328
|
get bootstrapCache(): BootstrapResponse | null;
|
|
@@ -1921,6 +2333,50 @@ declare class VioFacade {
|
|
|
1921
2333
|
commerceFor(sponsorId: number): CommerceClient;
|
|
1922
2334
|
/** Get a CommerceClient using an explicit commerce apiKey (skip bootstrap). */
|
|
1923
2335
|
commerceWithKey(commerceApiKey: string): CommerceClient;
|
|
2336
|
+
/**
|
|
2337
|
+
* Declare this page's slots to the campaigns service
|
|
2338
|
+
* (`POST /v2/mobile/components/manifest`, `mode: 'merge'`, the init
|
|
2339
|
+
* platform). Best-effort: it NEVER throws — a failure is logged and resolves
|
|
2340
|
+
* `null`. The same set is not re-posted from this browser for 24 h unless
|
|
2341
|
+
* `force` (then `null` also means "skipped, already declared"). Ids are
|
|
2342
|
+
* trimmed, cut at 100 chars, deduped; empties are dropped.
|
|
2343
|
+
*/
|
|
2344
|
+
declareSlots(slots: ReadonlyArray<SlotInput>, opts?: {
|
|
2345
|
+
force?: boolean;
|
|
2346
|
+
}): Promise<ManifestResult | null>;
|
|
2347
|
+
/**
|
|
2348
|
+
* Register a slot present on the page (the `<vio-*>` elements call it with
|
|
2349
|
+
* their effective id — the host's `vio-slot` or the auto-generated one —
|
|
2350
|
+
* and the optional display name). The registry is declared ONCE, debounced,
|
|
2351
|
+
* after the first successful bootstrap — and again whenever a new id or a
|
|
2352
|
+
* new display name appears. A `displayName` given later for an id already
|
|
2353
|
+
* registered replaces the one kept; `undefined` leaves it alone. The
|
|
2354
|
+
* returned function unregisters; removal never re-declares.
|
|
2355
|
+
*/
|
|
2356
|
+
registerSlot(name: string, displayName?: string): () => void;
|
|
2357
|
+
/**
|
|
2358
|
+
* The campaign a slot shows now, from the last bootstrap: its assigned and
|
|
2359
|
+
* open campaign for the init platform, else the surface's default. With no
|
|
2360
|
+
* slot, the default. `null` before the bootstrap. See `resolveSlotCampaign`.
|
|
2361
|
+
*/
|
|
2362
|
+
campaignForSlot(slot?: string | null): BootstrapCampaignEntry | null;
|
|
2363
|
+
/**
|
|
2364
|
+
* THE attribution helper — the SDK elements, Vev and Replit all use this
|
|
2365
|
+
* one. For a place (`slot`): the campaign it shows right now
|
|
2366
|
+
* (`campaignForSlot`: its assignment, else the surface's default) as
|
|
2367
|
+
* `campaignId` + that campaign's primary sponsor as `sponsorId`, plus the
|
|
2368
|
+
* page's content (`content()`). Pure, never throws; `{}` before the
|
|
2369
|
+
* bootstrap, except the content.
|
|
2370
|
+
*
|
|
2371
|
+
* `hint.sponsorId` — when the caller already knows the sponsor (a card with
|
|
2372
|
+
* `sponsor-id`) it is kept as `sponsorId`, and the campaign follows the same
|
|
2373
|
+
* cascade analytics uses (slot assignment → the sponsor's active campaign →
|
|
2374
|
+
* default), so what the cart remembers matches what the events say.
|
|
2375
|
+
*/
|
|
2376
|
+
attribution(slot?: string | null, hint?: {
|
|
2377
|
+
sponsorId?: number | string;
|
|
2378
|
+
}): Attribution;
|
|
2379
|
+
private scheduleSlotDeclaration;
|
|
1924
2380
|
private findSponsor;
|
|
1925
2381
|
}
|
|
1926
2382
|
declare const Vio: VioFacade;
|
|
@@ -1932,7 +2388,7 @@ declare const Vio: VioFacade;
|
|
|
1932
2388
|
*
|
|
1933
2389
|
* RELEASE CHECKLIST: bump together with package.json (see CONTRIBUTING).
|
|
1934
2390
|
*/
|
|
1935
|
-
declare const SDK_VERSION = "0.
|
|
2391
|
+
declare const SDK_VERSION = "0.23.0";
|
|
1936
2392
|
|
|
1937
2393
|
/**
|
|
1938
2394
|
* Vipps MobilePay's own button, the way the design guidelines ask for it.
|
|
@@ -1961,4 +2417,4 @@ declare function vippsButtonAttributes(verb?: 'buy' | 'pay' | 'express' | 'conti
|
|
|
1961
2417
|
language?: string;
|
|
1962
2418
|
}): Record<string, string>;
|
|
1963
2419
|
|
|
1964
|
-
export { ADD_ITEM_MUTATION, type AddManualOptions, type AddProductOptions, type AnalyticsCommerce, type AnalyticsContext, type AnalyticsEventName, type AnalyticsItemInput, AnalyticsManager, type AnalyticsStartOptions, type ApplePayConfig, type ApplePayResult, type BootstrapResponse, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, type CartChangeDetail, type CartLineItem, CartManager, type CartQueryOptions, type CheckoutAddress, type CheckoutChangeDetail, CheckoutManager, type CheckoutState, CommerceClient, Configuration, type CreatePaymentVippsResponse, type CreatePaymentVippsVariables, DELETE_ITEM_MUTATION, type Environment, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, type GetVippsStatusVariables, type ImageSize, type PaymentCompleteDetail, type PaymentMethod, type PaymentSelectDetail, type PlacementComponent, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductPrice, type ProductVariant, type ResolvedConfig, SDK_VERSION, type Sponsor, type SponsorCartState, type SponsorCommerceBlock, type TrackOptions, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, type VioConfig, type VippsPaymentState, type VippsStatusResult, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, ensureVippsButton, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes };
|
|
2420
|
+
export { ADD_ITEM_MUTATION, type AddManualOptions, type AddProductOptions, type AnalyticsCommerce, type AnalyticsContext, type AnalyticsEventName, type AnalyticsItemInput, AnalyticsManager, type AnalyticsStartOptions, type ApplePayConfig, type ApplePayResult, type Attribution, type BootstrapCampaign, type BootstrapCampaignEntry, type BootstrapCampaignStatus, type BootstrapResponse, type BootstrapSlot, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, type CartChangeDetail, type CartLineItem, type CartLineOrigin, CartManager, type CartOrigin, type CartQueryOptions, type CheckoutAddress, type CheckoutChangeDetail, CheckoutManager, type CheckoutState, CommerceClient, Configuration, type ContentRef, type CreatePaymentVippsResponse, type CreatePaymentVippsVariables, DELETE_ITEM_MUTATION, type Environment, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, type GetVippsStatusVariables, type ImageSize, type ManifestLocation, type ManifestRequest, type ManifestResult, type PaymentCompleteDetail, type PaymentMethod, type PaymentSelectDetail, type PaymentSuccessDetail, type PaymentSuccessResult, type PlacementComponent, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductPrice, type ProductVariant, type ResolvedConfig, SDK_VERSION, type SlotInput, type SlotKind, type Sponsor, type SponsorCartState, type SponsorCommerceBlock, type TrackOptions, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, type VioConfig, type VioPlatform, type VippsPaymentState, type VippsStatusResult, addItem, autoSlotDisplayName, autoSlotId, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, ensureVippsButton, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, lineOrigins, normalizeOrigin, normalizeScope, primaryImageUrl, purchaseFromPaymentSuccess, resolveCampaignId, resolveContent, resolveSlotCampaign, sameOrigin, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes };
|