@nosto/nosto-react 0.4.3 → 1.0.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.
@@ -0,0 +1,1201 @@
1
+ import { Context } from 'react';
2
+ import { default as default_2 } from 'react';
3
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
4
+
5
+ /**
6
+ * @group Types
7
+ */
8
+ declare interface Action {
9
+ /**
10
+ * Handles click attribution for product recommendations.
11
+ * This can be called when reporting a product view
12
+ * to signal that the view is a result of a click on a recommendation.
13
+ *
14
+ * @public
15
+ * @param {String} productId currently viewed product's product id
16
+ * @param {String} reference value of result_id from the recommendation response that was clicked
17
+ * @return {Action}
18
+ */
19
+ setRef(productId: string, reference: string): Action;
20
+ /**
21
+ * Allows you to provide an additional recommender hint that a product is being
22
+ * viewed.
23
+ * <br/><br/>
24
+ * You must invoke [the load method]{@link Action#load} on the resultant
25
+ * action in order for the request to be made.
26
+ *
27
+ * @public
28
+ * @param {String} product the identifier of the product being viewed
29
+ * @return {Action} the instance of the action
30
+ */
31
+ setProduct(product: string | Product): Action;
32
+ /**
33
+ * @deprecated
34
+ * @param {Array<String>} products
35
+ * @return {Action}
36
+ */
37
+ setProducts(products: (string | Product)[]): Action;
38
+ /**
39
+ * Sets the information about the user's current shopping cart. It the user
40
+ * does not have any items in his shopping cart, you can pass <code>null<code>.
41
+ * Passing <code>null<code> will nullify the user's shopping cart on Nosto's
42
+ * end. You must also pass in the shopping cart content in it's entirety as
43
+ * partial content are not supported.
44
+ * <br/><br/>
45
+ * It is not recommended to pass the current cart contents to an action but
46
+ * instead use the the session
47
+ * <br/><br/>
48
+ * You must invoke [the load method]{@link Action#load} on the resultant
49
+ * action in order for the request to be made.
50
+ *
51
+ * @see {@link Session#setCart}
52
+ * @return {Action}
53
+ */
54
+ setCart(cart: Cart): Action;
55
+ /**
56
+ * Sets the information about the currently logged in customer. If the current
57
+ * customer is not provided, you will not be able to leverage features such as
58
+ * triggered emails. While it is recommended to always provide the details of
59
+ * the currently logged in customer, it may be omitted if there are concerns
60
+ * about privacy or compliance.
61
+ * <br/><br/>
62
+ * It is not recommended to pass the current customer details to an action but
63
+ * instead use the the session
64
+ * <br/><br/>
65
+ * You must invoke [the load method]{@link Action#load} on the resultant
66
+ * action in order for the request to be made.
67
+ *
68
+ * @see {@link Session#setCustomer}
69
+ * @public
70
+ * @param {Customer} customer the details of the currently logged in customer
71
+ * @return {Action}
72
+ */
73
+ setCustomer(customer: Customer): Action;
74
+ /**
75
+ * @param {Order} order
76
+ * @return {Action}
77
+ */
78
+ setOrder(order: Order): Action;
79
+ /**
80
+ * <br/><br/>
81
+ * You must invoke [the load method]{@link Action#load} on the resultant
82
+ * action in order for the request to be made.
83
+ *
84
+ * @public
85
+ * @param searchTerms
86
+ * @return {Action}
87
+ */
88
+ setSearchTerms(searchTerms: string[]): Action;
89
+ /**
90
+ * <br/><br/>
91
+ * You must invoke [the load method]{@link Action#load} on the resultant
92
+ * action in order for the request to be made.
93
+ *
94
+ * @public
95
+ * @param {Array<String>} categories
96
+ * @return {Action}
97
+ */
98
+ setCategories(categories: string[]): Action;
99
+ /**
100
+ * <br/><br/>
101
+ * You must invoke [the load method]{@link Action#load} on the resultant
102
+ * action in order for the request to be made.
103
+ *
104
+ * @public
105
+ * @param {Array<String>} categoryIds
106
+ * @return {Action}
107
+ */
108
+ setCategoryIds(categoryIds: string[]): Action;
109
+ /**
110
+ * <br/><br/>
111
+ * You must invoke [the load method]{@link Action#load} on the resultant
112
+ * action in order for the request to be made.
113
+ *
114
+ * @public
115
+ * @param {Array<String>} parentCategoryIds
116
+ * @return {Action}
117
+ */
118
+ setParentCategoryIds(parentCategoryIds: string[]): Action;
119
+ /**
120
+ * <br/><br/>
121
+ * You must invoke [the load method]{@link Action#load} on the resultant
122
+ * action in order for the request to be made.
123
+ *
124
+ * @public
125
+ * @param tags
126
+ * @return {Action}
127
+ */
128
+ setTags(tags: string[]): Action;
129
+ /**
130
+ * <br/><br/>
131
+ * You must invoke [the load method]{@link Action#load} on the resultant
132
+ * action in order for the request to be made.
133
+ *
134
+ * @public
135
+ * @param customFields
136
+ * @return {Action}
137
+ */
138
+ setCustomFields(customFields: Record<string, string[]>): Action;
139
+ /**
140
+ * Sets the current variation identifier for the session. A variation identifier
141
+ * identifies the current currency (or the current customer group). If your site
142
+ * uses multi-currency, you must provide the ISO code current currency being viewed.
143
+ * <br/><br/>
144
+ * It is not recommended to pass the variation identifier to an action but
145
+ * instead use the the session.
146
+ * <br/><br/>
147
+ * You must invoke [the load method]{@link Action#load} on the resultant
148
+ * action in order for the request to be made.
149
+ *
150
+ * @see {@link Session#setVariation}
151
+ * @public
152
+ * @param {String} variation the case-sensitive identifier of the current variation
153
+ * @return {Action}
154
+ */
155
+ setVariation(variation: string): Action;
156
+ /**
157
+ * <br/><br/>
158
+ * You must invoke [the load method]{@link Action#load} on the resultant
159
+ * action in order for the request to be made.
160
+ *
161
+ * @public
162
+ * @param {Array.<String>} placements
163
+ * @return {Action}
164
+ */
165
+ setPlacements(placements: string[]): Action;
166
+ /**
167
+ * Sets the restore link for the current session. Restore links can be leveraged
168
+ * in email campaigns. Restore links allow the the user to restore the cart
169
+ * contents in a single click.
170
+ * <br/><br/>
171
+ * Read more about
172
+ * {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
173
+ * <br/><br/>
174
+ * It is not recommended to pass the restore link to an action but instead use the the
175
+ * session.
176
+ * <br/><br/>
177
+ * You must invoke [the load method]{@link Action#load} on the resultant
178
+ * action in order for the request to be made.
179
+ *
180
+ * @see {@link Session#setRestoreLink}
181
+ * @public
182
+ * @param {String} restoreLink the secure URL to restore the user's current session
183
+ * @return {Action}
184
+ */
185
+ setRestoreLink(restoreLink: string): Action;
186
+ /**
187
+ * Sets the identifier of the current page type to the current request. The different
188
+ * page types are product, front, search, cart, order, category, notfound and other.
189
+ * <br/><br/>
190
+ * You must invoke [the load method]{@link Action#load} on the resultant
191
+ * action in order for the request to be made.
192
+ * <br/><br/>
193
+ * It is not recommended to pass the page type to an action but instead use the the
194
+ * session.
195
+ * <br/><br/>
196
+ * You must invoke [the load method]{@link Action#load} on the resultant
197
+ * action in order for the request to be made.
198
+ *
199
+ * @see {@link Session#viewFrontPage} for when a front or home page is being viewed
200
+ * @see {@link Session#viewCart} for when a cart or checkout page is being viewed
201
+ * @see {@link Session#viewNotFound} for when a not-found or 404 page is being viewed
202
+ * @see {@link Session#viewProduct} for when a product page is being viewed
203
+ * @see {@link Session#viewCategory} for when a category, collection or brand page is being viewed
204
+ * @see {@link Session#viewTag} for when a tag page is being viewed
205
+ * @see {@link Session#viewSearch} for when a search page is being viewed
206
+ * @see {@link Session#viewOther} for when a miscellaneous page is being viewed
207
+ * @public
208
+ */
209
+ setPageType(pageType: PageType): Action;
210
+ /**
211
+ * @public
212
+ * @return {Object}
213
+ */
214
+ dumpData(): Data;
215
+ update(): unknown;
216
+ load(flags?: RecommendationRequestFlags): Promise<ActionResponse>;
217
+ }
218
+
219
+ declare interface ActionResponse {
220
+ recommendations: Record<string, unknown>;
221
+ campaigns?: {
222
+ recommendations: Record<string, unknown>;
223
+ content: Record<string, unknown>;
224
+ };
225
+ page_views: number;
226
+ geo_location: string[];
227
+ affinities: CustomerAffinityResponse;
228
+ cmpid: string;
229
+ }
230
+
231
+ declare type AnyFunction = (...args: unknown[]) => unknown;
232
+
233
+ /**
234
+ * @group Types
235
+ */
236
+ export declare interface Cart {
237
+ hcid?: string;
238
+ items: CartItem[];
239
+ }
240
+
241
+ /**
242
+ * @group Types
243
+ */
244
+ declare interface CartItem {
245
+ name: string;
246
+ price_currency_code: string;
247
+ product_id: string;
248
+ quantity: number;
249
+ sku_id?: string;
250
+ unit_price: number;
251
+ }
252
+
253
+ /**
254
+ * @group Types
255
+ */
256
+ declare interface ConversionItem {
257
+ name: string;
258
+ price_currency_code: string;
259
+ product_id: string;
260
+ quantity?: number;
261
+ sku_id?: string;
262
+ unit_price?: number;
263
+ }
264
+
265
+ /**
266
+ * @group Types
267
+ */
268
+ export declare interface Customer {
269
+ customer_reference?: string;
270
+ email: string;
271
+ first_name: string;
272
+ hcid?: string;
273
+ last_name: string;
274
+ newsletter?: boolean;
275
+ order_number?: string;
276
+ source?: string;
277
+ source_id?: string;
278
+ type?: string;
279
+ }
280
+
281
+ /**
282
+ * @group Types
283
+ */
284
+ declare interface CustomerAffinityResponse {
285
+ discount: number;
286
+ top_brands: CustomerAffinityResponseItem[];
287
+ top_categories: CustomerAffinityResponseItem[];
288
+ top_product_types: CustomerAffinityResponseItem[];
289
+ top_skus: {
290
+ [index: string]: CustomerAffinityResponseItem[];
291
+ };
292
+ }
293
+
294
+ /**
295
+ * @group Types
296
+ */
297
+ declare interface CustomerAffinityResponseItem {
298
+ name: string;
299
+ score: number;
300
+ }
301
+
302
+ /**
303
+ * @group Types
304
+ */
305
+ declare interface Data<ProductType extends Product = Product> {
306
+ cart: Cart | undefined;
307
+ customer: Customer | undefined;
308
+ variation: string | undefined;
309
+ restoreLink: string | undefined;
310
+ products: ProductType[];
311
+ order: Order | undefined;
312
+ searchTerms: string[] | undefined;
313
+ categories: string[] | undefined;
314
+ categoryIds: string[] | undefined;
315
+ parentCategoryIds: string[] | undefined;
316
+ tags: string[] | undefined;
317
+ customFields: Record<string, string[]> | undefined;
318
+ elements: string[] | undefined;
319
+ pageType: PageType | undefined;
320
+ sortOrder: string | undefined;
321
+ pluginVersion: PluginMetadata | undefined;
322
+ }
323
+
324
+ declare type EventType = typeof eventTypes[number];
325
+
326
+ declare const eventTypes: readonly ["vp", "lp", "dp", "rp", "bp", "vc", "or", "is", "cp", "ec", "es", "gc", "src", "cpr", "pl", "cc", "con"];
327
+
328
+ /**
329
+ * You can personalise your cart and checkout pages by using the `Nosto404` component.
330
+ * The component does not require any props.
331
+ *
332
+ * By default, your account, when created, has three 404-page placements named `notfound-nosto-1`, `notfound-nosto-2` and `notfound-nosto-3`.
333
+ * You may omit these and use any identifier you need.
334
+ * The identifiers used here are simply provided to illustrate the example.
335
+ *
336
+ * @example
337
+ * ```
338
+ * <div className="notfound-page">
339
+ * <NostoPlacement id="notfound-nosto-1" />
340
+ * <NostoPlacement id="notfound-nosto-2" />
341
+ * <NostoPlacement id="notfound-nosto-3" />
342
+ * <Nosto404 />
343
+ * </div>
344
+ * ```
345
+ *
346
+ * @group Components
347
+ */
348
+ export declare function Nosto404(props: {
349
+ placements?: string[];
350
+ }): null;
351
+
352
+ /**
353
+ * You can personalise your category and collection pages by using the NostoCategory component.
354
+ * The component requires that you provide it the the slash-delimited slug representation of the current category.
355
+ *
356
+ * By default, your account, when created, has two category placements named `categorypage-nosto-1` and `categorypage-nosto-2`.
357
+ * You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
358
+ *
359
+ * @example
360
+ * ```
361
+ * <div className="category-page">
362
+ * <NostoPlacement id="categorypage-nosto-1" />
363
+ * <NostoPlacement id="categorypage-nosto-2" />
364
+ * <NostoCategory category={category.name} />
365
+ * </div>
366
+ * ```
367
+ *
368
+ * **Note:** Be sure to pass in the correct category representation.
369
+ * If the category being viewed is `Mens >> Jackets`, you must provide the name as `/Mens/Jackets`.
370
+ * You must ensure that the category path provided here matches that of the categories tagged in your products.
371
+ *
372
+ * @group Components
373
+ */
374
+ export declare function NostoCategory(props: {
375
+ category: string;
376
+ placements?: string[];
377
+ }): null;
378
+
379
+ /**
380
+ * You can personalise your cart and checkout pages by using the NostoCheckout component.
381
+ * The component does not require any props.
382
+ *
383
+ * By default, your account, when created, has two cart-page placements named `categorypage-nosto-1` and `categorypage-nosto-2`.
384
+ * You may omit these and use any identifier you need.
385
+ * The identifiers used here are simply provided to illustrate the example.
386
+ *
387
+ * @example
388
+ * ```
389
+ * <div className="checkout-page">
390
+ * <NostoPlacement id="checkout-nosto-1" />
391
+ * <NostoPlacement id="checkout-nosto-2" />
392
+ * <NostoCheckout />
393
+ * </div>
394
+ * ```
395
+ *
396
+ * @group Components
397
+ */
398
+ export declare function NostoCheckout(props: {
399
+ placements?: string[];
400
+ }): null;
401
+
402
+ /**
403
+ * @group Types
404
+ */
405
+ declare interface NostoClient {
406
+ setAutoLoad(autoload: boolean): void;
407
+ defaultSession(): Session;
408
+ placements: {
409
+ getPlacements(): string[];
410
+ injectCampaigns(recommendations: Record<string, unknown>): void;
411
+ };
412
+ }
413
+
414
+ /**
415
+ * @group Essential Functions
416
+ */
417
+ export declare const NostoContext: Context<NostoContextType>;
418
+
419
+ /**
420
+ * @group Types
421
+ */
422
+ export declare interface NostoContextType {
423
+ account: string;
424
+ clientScriptLoaded: boolean;
425
+ currentVariation?: string;
426
+ renderFunction?: AnyFunction;
427
+ responseMode: RenderMode;
428
+ recommendationComponent?: React.ReactElement<{
429
+ nostoRecommendation: Recommendation;
430
+ }>;
431
+ useRenderCampaigns(type: string): {
432
+ renderCampaigns(data: unknown, api: NostoClient): void;
433
+ pageTypeUpdated: boolean;
434
+ };
435
+ pageType: string;
436
+ }
437
+
438
+ /**
439
+ * The `NostoHome` component must be used to personalise the home page. The component does not require any props.
440
+ *
441
+ * By default, your account, when created, has four front-page placements named `frontpage-nosto-1`, `frontpage-nosto-2`, `frontpage-nosto-3` and `frontpage-nosto-4`.
442
+ * You may omit these and use any identifier you need.
443
+ * The identifiers used here are simply provided to illustrate the example.
444
+ *
445
+ * The `<NostoHome \>` component needs to be added after the placements.
446
+ * Content and recommendations will be rendered through this component.
447
+ *
448
+ * @example
449
+ * ```
450
+ * <div className="front-page">
451
+ * <NostoPlacement id="frontpage-nosto-1" />
452
+ * <NostoPlacement id="frontpage-nosto-2" />
453
+ * <NostoPlacement id="frontpage-nosto-3" />
454
+ * <NostoPlacement id="frontpage-nosto-4" />
455
+ * <NostoHome />
456
+ * </div>
457
+ * ```
458
+ *
459
+ * @group Components
460
+ */
461
+ export declare function NostoHome(props: {
462
+ placements?: string[];
463
+ }): null;
464
+
465
+ /**
466
+ * You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component.
467
+ * The component requires that you provide it with the details of the order.
468
+ *
469
+ * By default, your account, when created, has one other-page placement named `thankyou-nosto-1`.
470
+ * You may omit this and use any identifier you need. The identifier used here is simply provided to illustrate the example.
471
+ *
472
+ * The order prop requires a value that adheres to the type `Purchase`.
473
+ *
474
+ * @example
475
+ * ```
476
+ * <div className="thankyou-page">
477
+ * <NostoPlacement id="thankyou-nosto-1" />
478
+ * <NostoOrder order={{ purchase: toOrder(order) }} />
479
+ * </div>
480
+ * ```
481
+ *
482
+ * @group Components
483
+ */
484
+ export declare function NostoOrder(props: {
485
+ order: Order;
486
+ placements?: string[];
487
+ }): null;
488
+
489
+ /**
490
+ * You can personalise your miscellaneous pages by using the NostoOther component.
491
+ * The component does not require any props.
492
+ *
493
+ * By default, your account, when created, has two other-page placements named `other-nosto-1` and `other-nosto-2`.
494
+ * You may omit these and use any identifier you need.
495
+ * The identifiers used here are simply provided to illustrate the example.
496
+ *
497
+ * @example
498
+ * ```
499
+ * <div className="other-page">
500
+ * <NostoPlacement id="other-nosto-1" />
501
+ * <NostoPlacement id="other-nosto-2" />
502
+ * <NostoOther />
503
+ * </div>;
504
+ * ```
505
+ *
506
+ * @group Components
507
+ */
508
+ export declare function NostoOther(props: {
509
+ placements?: string[];
510
+ }): null;
511
+
512
+ /**
513
+ * Nosto React has a special component called NostoPlacement.
514
+ * The component is a simply a hidden `<div>` placeholder into which Nosto injects recommendations or personalises the content between the tags.
515
+ *
516
+ * We recommend adding as many placements across your views as needed as these are hidden and only populated when a corresponding campaign (targeting that placement) is configured.
517
+ *
518
+ * @example
519
+ * ```
520
+ * <NostoPlacement id="frontpage-nosto-1" />
521
+ * ```
522
+ *
523
+ * @group Components
524
+ */
525
+ export declare function NostoPlacement(props: {
526
+ id: string;
527
+ pageType?: string;
528
+ }): JSX_2.Element;
529
+
530
+ /**
531
+ * The NostoProduct component must be used to personalise the product page.
532
+ * The component requires that you provide it the identifier of the current product being viewed.
533
+ *
534
+ * By default, your account, when created, has three product-page placements named `productpage-nosto-1`, `productpage-nosto-2` and `productpage-nosto-3`.
535
+ * You may omit these and use any identifier you need.
536
+ * The identifiers used here are simply provided to illustrate the example.
537
+ *
538
+ * The `<NostoProduct \>` component needs to be added after the placements.
539
+ * Content and recommendations will be rendered through this component.
540
+ * Pass in the product ID via the product prop to pass this information back to Nosto.
541
+ *
542
+ * @example
543
+ * ```
544
+ * <div className="product-page">
545
+ * <NostoPlacement id="productpage-nosto-1" />
546
+ * <NostoPlacement id="productpage-nosto-2" />
547
+ * <NostoPlacement id="productpage-nosto-3" />
548
+ * <NostoProduct product={product.id} />
549
+ * </div>
550
+ * ```
551
+ *
552
+ * @group Components
553
+ */
554
+ export declare function NostoProduct(props: {
555
+ product: string;
556
+ tagging?: Product;
557
+ placements?: string[];
558
+ }): null;
559
+
560
+ /**
561
+ * This widget is what we call the Nosto root widget, which is responsible for adding the actual Nosto script and the JS API stub.
562
+ * This widget wraps all other React Nosto widgets.
563
+ *
564
+ * ```
565
+ * <NostoProvider account="your-nosto-account-id" recommendationComponent={<NostoSlot />}>
566
+ * <App />
567
+ * </NostoProvider>
568
+ * ```
569
+ *
570
+ * **Note:** the component also accepts a prop to configure the host `host="connect.nosto.com"`.
571
+ * In advanced use-cases, the need to configure the host may surface.
572
+ *
573
+ * In order to implement client-side rendering, the requires a designated component to render the recommendations provided by Nosto.
574
+ * This component should be capable of processing the JSON response received from our backend.
575
+ * Notice the `recommendationComponent` prop passed to `<NostoProvider>` above.
576
+ *
577
+ * Learn more [here](https://github.com/Nosto/shopify-hydrogen/blob/main/README.md#client-side-rendering-for-recommendations) and see a [live example](https://github.com/Nosto/shopify-hydrogen-demo) on our demo store.
578
+ *
579
+ * @group Components
580
+ */
581
+ export declare function NostoProvider(props: NostoProviderProps): JSX_2.Element;
582
+
583
+ /**
584
+ * @group Components
585
+ */
586
+ declare interface NostoProviderProps {
587
+ /**
588
+ * Indicates merchant id
589
+ */
590
+ account: string;
591
+ /**
592
+ * Indicates currency
593
+ */
594
+ currentVariation?: string;
595
+ /**
596
+ * Indicates an url of a server
597
+ */
598
+ host?: string;
599
+ children: default_2.ReactElement;
600
+ /**
601
+ * Indicates if merchant uses multiple currencies
602
+ */
603
+ multiCurrency?: boolean;
604
+ /**
605
+ * Recommendation component which holds nostoRecommendation object
606
+ */
607
+ recommendationComponent?: default_2.ReactElement<{
608
+ nostoRecommendation: Recommendation;
609
+ }>;
610
+ /**
611
+ * Enables Shopify markets with language and market id
612
+ */
613
+ shopifyMarkets?: {
614
+ language?: string;
615
+ marketId?: string | number;
616
+ };
617
+ }
618
+
619
+ /**
620
+ * You can personalise your search pages by using the NostoSearch component.
621
+ * The component requires that you provide it the current search term.
622
+ *
623
+ * By default, your account, when created, has two search-page placements named `searchpage-nosto-1` and `searchpage-nosto-2`.
624
+ * You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
625
+ *
626
+ * @example
627
+ * ```
628
+ * <div className="search-page">
629
+ * <NostoPlacement id="searchpage-nosto-1" />
630
+ * <NostoPlacement id="searchpage-nosto-2" />
631
+ * <NostoSearch query={"black shoes"} />
632
+ * </div>
633
+ * ```
634
+ *
635
+ * **Note:** Do not encode the search term in any way.
636
+ * It should be provided an unencoded string.
637
+ * A query for `black shoes` must be provided as-is and not as `black+shoes`.
638
+ * Doing so will lead to invalid results.
639
+ *
640
+ * @group Components
641
+ */
642
+ export declare function NostoSearch(props: {
643
+ query: string;
644
+ placements?: string[];
645
+ }): null;
646
+
647
+ /**
648
+ * Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change.
649
+ * This makes it easier to add attribution.
650
+ *
651
+ * The `NostoSession` component makes it very easy to keep the session up to date so long as the cart and the customer are provided.
652
+ *
653
+ * The cart prop requires a value that adheres to the type `Cart`, while the customer prop requires a value that adheres to the type `Customer`.
654
+ *
655
+ * @group Essential Functions
656
+ */
657
+ export declare function NostoSession(props?: {
658
+ cart?: Cart;
659
+ customer?: Customer;
660
+ }): JSX_2.Element;
661
+
662
+ /**
663
+ * @group Types
664
+ */
665
+ export declare interface Order {
666
+ created_at?: Date;
667
+ external_order_ref: string;
668
+ info?: OrderCustomer;
669
+ items: ConversionItem[];
670
+ order_status?: string;
671
+ order_status_label?: string;
672
+ payment_provider: string;
673
+ }
674
+
675
+ /**
676
+ * @group Types
677
+ */
678
+ declare interface OrderCustomer {
679
+ country: string;
680
+ email?: string;
681
+ first_name?: string;
682
+ last_name?: string;
683
+ newsletter: string;
684
+ order_number: string;
685
+ phone: string;
686
+ post_code: string;
687
+ type: string;
688
+ }
689
+
690
+ /**
691
+ * @group Types
692
+ */
693
+ declare type PageType = "front" | "category" | "product" | "cart" | "search" | "notfound" | "order" | "other" | "checkout";
694
+
695
+ /**
696
+ * @group Types
697
+ */
698
+ declare interface PluginMetadata {
699
+ mainModule?: string;
700
+ cmpModule?: string;
701
+ msiModule?: string;
702
+ }
703
+
704
+ /**
705
+ * @group Types
706
+ */
707
+ export declare type Product = {
708
+ product_id: string;
709
+ selected_sku_id?: string;
710
+ };
711
+
712
+ /**
713
+ * @group Types
714
+ */
715
+ export declare interface Recommendation {
716
+ result_id: string;
717
+ products: Product[];
718
+ result_type: string;
719
+ title: string;
720
+ div_id: string;
721
+ source_product_ids: string[];
722
+ params: unknown;
723
+ }
724
+
725
+ /**
726
+ * @group Types
727
+ */
728
+ declare interface RecommendationRequestFlags {
729
+ skipPageViews?: boolean;
730
+ trackEvents?: boolean;
731
+ skipEvents?: boolean;
732
+ reloadCart?: boolean;
733
+ }
734
+
735
+ /**
736
+ * @group Types
737
+ */
738
+ declare type RenderMode = "HTML" | "SIMPLE" | "JSON_170x170" | "JSON_100_X_100" | "JSON_90x70" | "JSON_50x50" | "JSON_30x30" | "JSON_100x140" | "JSON_200x200" | "JSON_400x400" | "JSON_750x750" | "JSON_10_MAX_SQUARE" | "JSON_200x200_SQUARE" | "JSON_400x400_SQUARE" | "JSON_750x750_SQUARE" | "JSON_ORIGINAL" | "VERSION_SOURCE";
739
+
740
+ /**
741
+ * @group Types
742
+ */
743
+ declare interface Session {
744
+ /**
745
+ * Sets the information about the user's current shopping cart. It the user
746
+ * does not have any items in his shopping cart, you can pass <code>null<code>.
747
+ * Passing <code>null<code> will nullify the user's shopping cart on Nosto's
748
+ * end. You must also pass in the shopping cart content in it's entirety as
749
+ * partial content are not supported.
750
+ *
751
+ * @example
752
+ * nostojs(api => api
753
+ * .defaultSession()
754
+ * .setCart({
755
+ * items: [
756
+ * product_id: "101",
757
+ * sku_id: "101-S",
758
+ * name: "Shoe",
759
+ * unit_price: 34.99
760
+ * price_currency_code: "EUR"
761
+ * ]
762
+ * })
763
+ * .viewCart()
764
+ * .setPlacements(["free-shipper"])
765
+ * .update()
766
+ * .then(data => console.log(data)))
767
+ *
768
+ * @public
769
+ * @param {Cart|undefined} cart the details of the user's shopping cart contents
770
+ * @returns {Session} the current session
771
+ */
772
+ setCart(cart: Cart | undefined): Session;
773
+ /**
774
+ * Sets the information about the currently logged in customer. If the current
775
+ * customer is not provided, you will not be able to leverage features such as
776
+ * triggered emails. While it is recommended to always provide the details of
777
+ * the currently logged in customer, it may be omitted if there are concerns
778
+ * about privacy or compliance.
779
+ *
780
+ * @example
781
+ * nostojs(api => api
782
+ * .defaultSession()
783
+ * .setCustomer({
784
+ * first_name: "Mridang",
785
+ * last_name: "Agarwalla",
786
+ * email: "mridang@nosto.com",
787
+ * newsletter: false,
788
+ * customer_reference: "5e3d4a9c-cf58-11ea-87d0-0242ac130003"
789
+ * })
790
+ * .viewCart()
791
+ * .setPlacements(["free-shipper"])
792
+ * .load()
793
+ * .then(data => console.log(data)))
794
+ *
795
+ * @public
796
+ * @param {Customer} customer the details of the currently logged in customer
797
+ * @returns {Session} the current session
798
+ */
799
+ setCustomer(customer: Customer | undefined): Session;
800
+ /**
801
+ * Sets the current variation identifier for the session. A variation identifier
802
+ * identifies the current currency (or the current customer group). If your site
803
+ * uses multi-currency, you must provide the ISO code current currency being viewed.
804
+ *
805
+ * @example
806
+ * nostojs(api => api
807
+ * .defaultSession()
808
+ * .setVariation("GBP")
809
+ * .viewCart()
810
+ * .setPlacements(["free-shipper"])
811
+ * .load()
812
+ * .then(data => console.log(data)))
813
+ *
814
+ * @public
815
+ * @param {String} variation the case-sensitive identifier of the current variation
816
+ * @returns {Session} the current session
817
+ */
818
+ setVariation(variation: string): Session;
819
+ /**
820
+ * Sets the restore link for the current session. Restore links can be leveraged
821
+ * in email campaigns. Restore links allow the the user to restore the cart
822
+ * contents in a single click.
823
+ * <br/><br/>
824
+ * Read more about
825
+ * {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
826
+ *
827
+ * @example
828
+ * nostojs(api => api
829
+ * .defaultSession()
830
+ * .setRestoreLink("https://jeans.com/session/restore?sid=6bdb69d5-ed15-4d92")
831
+ * .viewCart()
832
+ * .setPlacements(["free-shipper"])
833
+ * .load()
834
+ * .then(data => console.log(data)))
835
+ *
836
+ * @public
837
+ * @param {String} restoreLink the secure URL to restore the user's current session
838
+ * @returns {Session} the current session
839
+ */
840
+ setRestoreLink(restoreLink: string): Session;
841
+ /**
842
+ * Sets the response type to HTML or JSON_ORIGINAL. This denotes the preferred
843
+ * response type of the recommendation result.
844
+ * If you would like to access the raw recommendation data in <code>JSON</code> form, specify
845
+ * <code>JSON</code>. When you specify JSON, you will need to template the result yourself.
846
+ * If you require a more simplified approach, specify <code>HTML</code>. When you specify
847
+ * <code>HTML</code>, you get back HTML blobs, that you may simply inject into
848
+ * you placements.
849
+ *
850
+ * @example
851
+ * nostojs(api => api
852
+ * .defaultSession()
853
+ * .setResponseMode("HTML")
854
+ * .viewCart()
855
+ * .setPlacements(["free-shipper"])
856
+ * .load()
857
+ * .then(data => console.log(data)))
858
+ *
859
+ * @public
860
+ * @param {String} mode the response mode for the recommendation data
861
+ * @returns {Session} the current session
862
+ */
863
+ setResponseMode(mode: RenderMode): Session;
864
+ /**
865
+ * Create a new action for a front page. This should be used when the user
866
+ * visits the home page.
867
+ * <br/><br/>
868
+ * You must invoke [the load method]{@link Action#load} on the resultant
869
+ * action in order for the request to be made.
870
+ * <br/><br/>
871
+ * You do not need to specify the page-type explicitly as it is inferred
872
+ * from the action.
873
+ *
874
+ * @example
875
+ * nostojs(api => api
876
+ * .defaultSession()
877
+ * .viewFrontPage()
878
+ * .setPlacements(["best-seller"])
879
+ * .load()
880
+ * .then(data => console.log(data)))
881
+ *
882
+ *
883
+ * @public
884
+ * @returns {Action} the action instance to load content or track events.
885
+ */
886
+ viewFrontPage(): Action;
887
+ /**
888
+ * Create a new action for a cart page. This should be used on all cart and
889
+ * checkout pages. If your site has a multi-step checkout, it is recommended
890
+ * that you send this event on each checkout page.
891
+ * <br/><br/>
892
+ * You must invoke [the load method]{@link Action#load} on the resultant
893
+ * action in order for the request to be made.
894
+ * <br/><br/>
895
+ * You do not need to specify the page-type explicitly as it is inferred
896
+ * from the action.
897
+ *
898
+ * @example
899
+ * nostojs(api => api
900
+ * .defaultSession()
901
+ * .viewCart()
902
+ * .setPlacements(["free-shipper"])
903
+ * .load()
904
+ * .then(data => console.log(data)))
905
+ *
906
+ * @public
907
+ * @returns {Action} the action instance to load content or track events.
908
+ */
909
+ viewCart(): Action;
910
+ /**
911
+ * Create a new action for a not found page. This should be used only on 404
912
+ * pages.
913
+ * <br/><br/>
914
+ * You must invoke [the load method]{@link Action#load} on the resultant
915
+ * action in order for the request to be made.
916
+ * <br/><br/>
917
+ * You do not need to specify the page-type explicitly as it is inferred
918
+ * from the action.
919
+ *
920
+ * @example
921
+ * nostojs(api => api
922
+ * .defaultSession()
923
+ * .viewNotFound()
924
+ * .setPlacements(["best-seller"])
925
+ * .load()
926
+ * .then(data => console.log(data)))
927
+ *
928
+ * @public
929
+ * @returns {Action} the action instance to load content or track events.
930
+ */
931
+ viewNotFound(): Action;
932
+ /**
933
+ * Create a new action for a product page. This must be used only when a
934
+ * product is being viewed. In case a specific SKU of the product is being viewed, use viewProductSku instead.
935
+ * <br/><br/>
936
+ * You must invoke [the load method]{@link Action#load} on the resultant
937
+ * action in order for the request to be made.
938
+ * <br/><br/>
939
+ * You do not need to specify the page-type explicitly as it is inferred
940
+ * from the action.
941
+ *
942
+ * @example
943
+ * nostojs(api => api
944
+ * .defaultSession()
945
+ * .viewProduct("101")
946
+ * .setCategories(["/men/trousers"])
947
+ * .setRef("123", "example_reco_id")
948
+ * .setPlacements(["cross-seller"])
949
+ * .load()
950
+ * .then(data => console.log(data)))
951
+ *
952
+ * @public
953
+ * @param product
954
+ * @returns {Action} the action instance to load content or track events.
955
+ */
956
+ viewProduct(product: string | Product): Action;
957
+ /**
958
+ * Create a new action for a product page when a specific SKU has been chosen. This must be used only when a
959
+ * product and specific SKU is being viewed.
960
+ * <br/><br/>
961
+ * You must invoke [the load method]{@link Action#load} on the resultant
962
+ * action in order for the request to be made.
963
+ * <br/><br/>
964
+ * You do not need to specify the page-type explicitly as it is inferred
965
+ * from the action.
966
+ *
967
+ * @example
968
+ * nostojs(api => api
969
+ * .defaultSession()
970
+ * .viewProductSku("101", "101-sku-1")
971
+ * .setCategories(["/men/trousers"])
972
+ * .setRef("123", "example_reco_id")
973
+ * .setPlacements(["cross-seller"])
974
+ * .load()
975
+ * .then(data => console.log(data)))
976
+ *
977
+ * @public
978
+ * @param productId
979
+ * @param skuId
980
+ * @returns {Action} the action instance to load content or track events.
981
+ */
982
+ viewProductSku(productId: string, skuId: string): Action;
983
+ /**
984
+ * Create a new action for a category page. This should be used on all
985
+ * category, collection of brand pages.
986
+ * <br/><br/>
987
+ * You must invoke [the load method]{@link Action#load} on the resultant
988
+ * action in order for the request to be made.
989
+ * <br/><br/>
990
+ * You do not need to specify the page-type explicitly as it is inferred
991
+ * from the action.
992
+ *
993
+ * @example
994
+ * nostojs(api => api
995
+ * .defaultSession()
996
+ * .viewCategory("/men/shoes")
997
+ * .setPlacements(["category123"])
998
+ * .load()
999
+ * .then(data => console.log(data)))
1000
+ *
1001
+ * @public
1002
+ * @param {Array<String>} categories
1003
+ * @returns {Action} the action instance to load content or track events.
1004
+ */
1005
+ viewCategory(...categories: string[]): Action;
1006
+ /**
1007
+ * Create a new action for a tag page. This should be used only on tag pages.
1008
+ * <br/><br/>
1009
+ * You must invoke [the load method]{@link Action#load} on the resultant
1010
+ * action in order for the request to be made.
1011
+ * <br/><br/>
1012
+ * You do not need to specify the page-type explicitly as it is inferred
1013
+ * from the action.
1014
+ * Note: tags are not case-sensitive.
1015
+ *
1016
+ * @example
1017
+ * nostojs(api => api
1018
+ * .defaultSession()
1019
+ * .viewTag("colourful")
1020
+ * .load()
1021
+ * .then(data => console.log(data)))
1022
+ *
1023
+ * @public
1024
+ * @deprecated as this is an advanced action with a limited a use case
1025
+ * @param {Array<String>} tags the set of the tags being viewed.
1026
+ * @returns {Action} the action instance to load content or track events.
1027
+ */
1028
+ viewTag(...tags: string[]): Action;
1029
+ /**
1030
+ * Create a new action with custom fields.
1031
+ * <br/><br/>
1032
+ * You must invoke [the load method]{@link Action#load} on the resultant
1033
+ * action in order for the request to be made.
1034
+ * <br/><br/>
1035
+ * You do not need to specify the page-type explicitly as it is inferred
1036
+ * from the action.
1037
+ * Note: tags are not case-sensitive.
1038
+ *
1039
+ * @example
1040
+ * nostojs(api => api
1041
+ * .defaultSession()
1042
+ * .viewCustomField({material: "cotton"})
1043
+ * .load()
1044
+ * .then(data => console.log(data)))
1045
+ *
1046
+ * @public
1047
+ * @deprecated as this is an advanced action with a limited a use case
1048
+ * @param {Object} customFields custom fields being viewed.
1049
+ * @returns {Action} the action instance to load content or track events.
1050
+ */
1051
+ viewCustomField(customFields: Record<string, string[]>): Action;
1052
+ /**
1053
+ * Create a new action for a search page. This should be used only
1054
+ * on search pages. A search page action requires you to pass the search
1055
+ * term. For example, if the user search for "black shoes", you must pass
1056
+ * in "black shoes" and not an encoded version such as "black+shoes".
1057
+ * <br/><br/>
1058
+ * You must invoke [the load method]{@link Action#load} on the resultant
1059
+ * action in order for the request to be made.
1060
+ * <br/><br/>
1061
+ * You do not need to specify the page-type explicitly as it is inferred
1062
+ * from the action.
1063
+ * Search terms are not case-sensitive.
1064
+ *
1065
+ * @example
1066
+ * nostojs(api => api
1067
+ * .defaultSession()
1068
+ * .viewSearch("black shoes")
1069
+ * .load()
1070
+ * .then(data => console.log(data)))
1071
+ *
1072
+ * @public
1073
+ * @param {Array.<String>} searchTerms the non-encoded search terms
1074
+ * @returns {Action} the action instance to load content or track events.
1075
+ */
1076
+ viewSearch(...searchTerms: string[]): Action;
1077
+ /**
1078
+ * Create a new action for a general page. This should be used only on
1079
+ * pages that don't have a corresponding action. For example, if the user
1080
+ * is viewing a page such as a "Contact Us" page, you should use the viewOther
1081
+ * action.
1082
+ * <br/><br/>
1083
+ * You must invoke [the load method]{@link Action#load} on the resultant
1084
+ * action in order for the request to be made.
1085
+ * <br/><br/>
1086
+ * You do not need to specify the page-type explicitly as it is inferred
1087
+ * from the action.
1088
+ *
1089
+ * @example
1090
+ * nostojs(api => api
1091
+ * .defaultSession()
1092
+ * .viewOther()
1093
+ * .load()
1094
+ * .then(data => console.log(data)))
1095
+ *
1096
+ * @public
1097
+ * @returns {Action} the action instance to load content or track events.
1098
+ */
1099
+ viewOther(): Action;
1100
+ /**
1101
+ * Create a new action for an order page. This should only be used on order
1102
+ * confirmation / thank you pages.
1103
+ * <br/><br/>
1104
+ * You do not need to specify the page-type explicitly as it is inferred
1105
+ * from the action.
1106
+ * <br/><br/>
1107
+ * You must invoke [the load method]{@link Action#load} on the resultant
1108
+ * action in order for the request to be made.
1109
+ *
1110
+ * @example
1111
+ * nostojs(api => {
1112
+ * api.defaultSession()
1113
+ * .addOrder({
1114
+ * external_order_ref: "145000006",
1115
+ * info: {
1116
+ * order_number: "195",
1117
+ * email: "mridang@nosto.com",
1118
+ * first_name: "Mridang",
1119
+ * last_name: "Agarwalla",
1120
+ * type: "order",
1121
+ * newsletter: true
1122
+ * },
1123
+ * items: [{
1124
+ * product_id: "406",
1125
+ * sku_id: "243",
1126
+ * name: "Linen Blazer (White, S)",
1127
+ * quantity: 1,
1128
+ * unit_price: 455,
1129
+ * price_currency_code: "EUR"
1130
+ * }]
1131
+ * })
1132
+ * .setPlacements(["order-related"])
1133
+ * .load()
1134
+ * .then(data => {
1135
+ * console.log(data.recommendations)
1136
+ * })
1137
+ * })
1138
+ * @public
1139
+ * @param {Order} order the information about the order that was placed
1140
+ * @returns {Action} the action instance to load content or track events.
1141
+ */
1142
+ addOrder(order: Order): Action;
1143
+ /**
1144
+ * Creates an action to report that product was added to the shopping cart,
1145
+ * e.g. from the recommendation slot with "Add to cart" button.
1146
+ * <p>
1147
+ * You must invoke [the load method]{@link Action#load} on the resultant
1148
+ * action in order for the request to be made.
1149
+ *
1150
+ *
1151
+ * @example
1152
+ * nostojs(api => api
1153
+ * .defaultSession()
1154
+ * .reportAddToCart("123", "reco-slot-1")
1155
+ * .load()
1156
+ * .then(data => console.log(data)))
1157
+ *
1158
+ * @public
1159
+ * @param product
1160
+ * @param element
1161
+ * @returns {Action} the action instance to load content or track events.
1162
+ */
1163
+ reportAddToCart(product: string, element: string): Action;
1164
+ /**
1165
+ * @example
1166
+ * nostojs(api => api
1167
+ * .defaultSession()
1168
+ * .recordAttribution("vp", "12345678", "123456")
1169
+ * .done()
1170
+ * .then(data => console.log(data))
1171
+ * @param { EventType } type
1172
+ * @param { String } target
1173
+ * @param { String | undefined } [ref]
1174
+ * @param { String | undefined } [refSrc]
1175
+ * @return { Object }
1176
+ *
1177
+ */
1178
+ recordAttribution(type: EventType, target: string, ref: string, refSrc: string): object;
1179
+ }
1180
+
1181
+ /**
1182
+ * A hook that allows you to access the NostoContext and retrieve Nosto-related data from it in React components.
1183
+ *
1184
+ * @group Essential Functions
1185
+ */
1186
+ export declare function useNostoContext(): NostoContextType;
1187
+
1188
+ export { }
1189
+
1190
+ declare global {
1191
+ interface Window {
1192
+ nosto?: {
1193
+ reload(settings: unknown): void;
1194
+ };
1195
+ nostojs: {
1196
+ (callback: (api: NostoClient) => void): void;
1197
+ q?: unknown[];
1198
+ };
1199
+ }
1200
+ }
1201
+