@nosto/nosto-react 2.2.2 → 2.4.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/src/types.ts CHANGED
@@ -1,27 +1,4 @@
1
- declare global {
2
- interface Window {
3
- nosto?: {
4
- reload(settings: unknown): void
5
- }
6
- nostojs: {
7
- (callback: (api: NostoClient) => void): void
8
- q?: unknown[]
9
- }
10
- }
11
- }
12
-
13
- /**
14
- * @group Types
15
- */
16
- export interface NostoClient {
17
- setAutoLoad(autoload: boolean): void
18
- defaultSession(): Session
19
- listen(event: string, callback: (data: unknown) => void): void
20
- placements: {
21
- getPlacements(): string[]
22
- injectCampaigns(recommendations: Record<string, unknown>): void
23
- }
24
- }
1
+ import type { PushedProduct } from "@nosto/nosto-js/client"
25
2
 
26
3
  /**
27
4
  * @group Types
@@ -35,944 +12,3 @@ export interface Recommendation {
35
12
  source_product_ids: string[]
36
13
  params: unknown
37
14
  }
38
-
39
- export interface PushedProduct {
40
- age_group?: string
41
- alternate_image_urls: string[]
42
- availability: string
43
- brand?: string
44
- category: string[]
45
- category_id: string[]
46
- condition?: string
47
- custom_fields: { [index: string]: string }
48
- date_published?: Date
49
- description?: string
50
- gender?: string
51
- google_category?: string
52
- gtin?: string
53
- image_url?: string
54
- inventory_level?: number
55
- list_price?: number
56
- name: string
57
- parent_category_id: string[]
58
- price: number
59
- price_currency_code: string
60
- product_id: string
61
- rating_value?: number
62
- review_count?: number
63
- skus: PushedProductSKU[]
64
- source_updated?: Date
65
- supplier_cost?: number
66
- tags1: string[]
67
- tags2: string[]
68
- tags3: string[]
69
- thumb_url?: string
70
- unit_pricing_base_measure?: number
71
- unit_pricing_measure?: number
72
- unit_pricing_unit?: string
73
- update_received?: Date
74
- url: string
75
- variation_id?: string
76
- variations: { [index: string]: PushedVariation }
77
- }
78
-
79
- export interface PushedProductSKU extends NostoSku {}
80
-
81
- export interface PushedVariation extends NostoVariant {}
82
-
83
- export interface NostoSku extends Sku {
84
- inventory_level?: number
85
- }
86
-
87
- export interface NostoVariant {
88
- availability: string
89
- available: boolean
90
- discounted: boolean
91
- list_price?: number
92
- price: number
93
- price_currency_code: string
94
- price_text?: string
95
- }
96
-
97
- export interface Sku {
98
- availability: string
99
- custom_fields: { [index: string]: string }
100
- gtin?: string
101
- id: string
102
- image_url?: string
103
- list_price?: number
104
- name: string
105
- price: number
106
- url?: string
107
- }
108
-
109
- // copied from client script d.ts export
110
- declare const eventTypes: readonly [
111
- "vp",
112
- "lp",
113
- "dp",
114
- "rp",
115
- "bp",
116
- "vc",
117
- "or",
118
- "is",
119
- "cp",
120
- "ec",
121
- "es",
122
- "gc",
123
- "src",
124
- "cpr",
125
- "pl",
126
- "cc",
127
- "con"
128
- ]
129
- declare type EventType = (typeof eventTypes)[number]
130
-
131
- /**
132
- * @group Types
133
- */
134
- export interface CartItem {
135
- name: string
136
- price_currency_code: string
137
- product_id: string
138
- quantity: number
139
- sku_id?: string
140
- unit_price: number
141
- }
142
-
143
- /**
144
- * @group Types
145
- */
146
- export interface ConversionItem {
147
- name: string
148
- price_currency_code: string
149
- product_id: string
150
- quantity?: number
151
- sku_id?: string
152
- unit_price?: number
153
- }
154
-
155
- /**
156
- * @group Types
157
- */
158
- export interface CustomerAffinityResponse {
159
- discount: number
160
- top_brands: CustomerAffinityResponseItem[]
161
- top_categories: CustomerAffinityResponseItem[]
162
- top_product_types: CustomerAffinityResponseItem[]
163
- top_skus: {
164
- [index: string]: CustomerAffinityResponseItem[]
165
- }
166
- }
167
-
168
- /**
169
- * @group Types
170
- */
171
- export interface CustomerAffinityResponseItem {
172
- name: string
173
- score: number
174
- }
175
-
176
- /**
177
- * @group Types
178
- */
179
- export interface OrderCustomer {
180
- country: string
181
- email?: string
182
- first_name?: string
183
- last_name?: string
184
- newsletter: string
185
- order_number: string
186
- phone: string
187
- post_code: string
188
- type: string
189
- }
190
-
191
- /**
192
- * @group Types
193
- */
194
- export interface Customer {
195
- customer_reference?: string
196
- email: string
197
- first_name: string
198
- hcid?: string
199
- last_name: string
200
- newsletter?: boolean
201
- order_number?: string
202
- source?: string
203
- source_id?: string
204
- type?: string
205
- }
206
-
207
- /**
208
- * @group Types
209
- */
210
- export interface Order {
211
- created_at?: Date
212
- external_order_ref: string
213
- info?: OrderCustomer
214
- items: ConversionItem[]
215
- order_status?: string
216
- order_status_label?: string
217
- payment_provider: string
218
- }
219
-
220
- /**
221
- * @group Types
222
- */
223
- export type PageType =
224
- | "front"
225
- | "category"
226
- | "product"
227
- | "cart"
228
- | "search"
229
- | "notfound"
230
- | "order"
231
- | "other"
232
- | "checkout"
233
-
234
- /**
235
- * @group Types
236
- */
237
- export type RenderMode =
238
- | "HTML"
239
- | "SIMPLE"
240
- | "JSON_170x170"
241
- | "JSON_100_X_100"
242
- | "JSON_90x70"
243
- | "JSON_50x50"
244
- | "JSON_30x30"
245
- | "JSON_100x140"
246
- | "JSON_200x200"
247
- | "JSON_400x400"
248
- | "JSON_750x750"
249
- | "JSON_10_MAX_SQUARE"
250
- | "JSON_200x200_SQUARE"
251
- | "JSON_400x400_SQUARE"
252
- | "JSON_750x750_SQUARE"
253
- | "JSON_ORIGINAL"
254
- | "VERSION_SOURCE"
255
-
256
- /**
257
- * @group Types
258
- */
259
- interface PluginMetadata {
260
- mainModule?: string
261
- cmpModule?: string
262
- msiModule?: string
263
- }
264
-
265
- /**
266
- * @group Types
267
- */
268
- export interface Cart {
269
- hcid?: string
270
- items: CartItem[]
271
- }
272
-
273
- /**
274
- * @group Types
275
- */
276
- export type Product = {
277
- product_id: string
278
- selected_sku_id?: string
279
- }
280
-
281
- /**
282
- * @group Types
283
- */
284
- export interface Data<ProductType extends Product = Product> {
285
- cart: Cart | undefined
286
- customer: Customer | undefined
287
- variation: string | undefined
288
- restoreLink: string | undefined
289
- products: ProductType[]
290
- order: Order | undefined
291
- searchTerms: string[] | undefined
292
- categories: string[] | undefined
293
- categoryIds: string[] | undefined
294
- parentCategoryIds: string[] | undefined
295
- tags: string[] | undefined
296
- customFields: Record<string, string[]> | undefined
297
- elements: string[] | undefined
298
- pageType: PageType | undefined
299
- sortOrder: string | undefined
300
- pluginVersion: PluginMetadata | undefined
301
- }
302
-
303
- /**
304
- * @group Types
305
- */
306
- export interface RecommendationRequestFlags {
307
- skipPageViews?: boolean
308
- trackEvents?: boolean
309
- skipEvents?: boolean
310
- reloadCart?: boolean
311
- }
312
-
313
- /**
314
- * @group Types
315
- */
316
- export interface Session {
317
- /**
318
- * Sets the information about the user's current shopping cart. It the user
319
- * does not have any items in his shopping cart, you can pass <code>null<code>.
320
- * Passing <code>null<code> will nullify the user's shopping cart on Nosto's
321
- * end. You must also pass in the shopping cart content in it's entirety as
322
- * partial content are not supported.
323
- *
324
- * @example
325
- * nostojs(api => api
326
- * .defaultSession()
327
- * .setCart({
328
- * items: [
329
- * product_id: "101",
330
- * sku_id: "101-S",
331
- * name: "Shoe",
332
- * unit_price: 34.99
333
- * price_currency_code: "EUR"
334
- * ]
335
- * })
336
- * .viewCart()
337
- * .setPlacements(["free-shipper"])
338
- * .update()
339
- * .then(data => console.log(data)))
340
- *
341
- * @public
342
- * @param {Cart|undefined} cart the details of the user's shopping cart contents
343
- * @returns {Session} the current session
344
- */
345
- setCart(cart: Cart | undefined): Session
346
- /**
347
- * Sets the information about the currently logged in customer. If the current
348
- * customer is not provided, you will not be able to leverage features such as
349
- * triggered emails. While it is recommended to always provide the details of
350
- * the currently logged in customer, it may be omitted if there are concerns
351
- * about privacy or compliance.
352
- *
353
- * @example
354
- * nostojs(api => api
355
- * .defaultSession()
356
- * .setCustomer({
357
- * first_name: "Mridang",
358
- * last_name: "Agarwalla",
359
- * email: "mridang@nosto.com",
360
- * newsletter: false,
361
- * customer_reference: "5e3d4a9c-cf58-11ea-87d0-0242ac130003"
362
- * })
363
- * .viewCart()
364
- * .setPlacements(["free-shipper"])
365
- * .load()
366
- * .then(data => console.log(data)))
367
- *
368
- * @public
369
- * @param {Customer} customer the details of the currently logged in customer
370
- * @returns {Session} the current session
371
- */
372
- setCustomer(customer: Customer | undefined): Session
373
- /**
374
- * Sets the current variation identifier for the session. A variation identifier
375
- * identifies the current currency (or the current customer group). If your site
376
- * uses multi-currency, you must provide the ISO code current currency being viewed.
377
- *
378
- * @example
379
- * nostojs(api => api
380
- * .defaultSession()
381
- * .setVariation("GBP")
382
- * .viewCart()
383
- * .setPlacements(["free-shipper"])
384
- * .load()
385
- * .then(data => console.log(data)))
386
- *
387
- * @public
388
- * @param {String} variation the case-sensitive identifier of the current variation
389
- * @returns {Session} the current session
390
- */
391
- setVariation(variation: string): Session
392
- /**
393
- * Sets the restore link for the current session. Restore links can be leveraged
394
- * in email campaigns. Restore links allow the the user to restore the cart
395
- * contents in a single click.
396
- * <br/><br/>
397
- * Read more about
398
- * {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
399
- *
400
- * @example
401
- * nostojs(api => api
402
- * .defaultSession()
403
- * .setRestoreLink("https://jeans.com/session/restore?sid=6bdb69d5-ed15-4d92")
404
- * .viewCart()
405
- * .setPlacements(["free-shipper"])
406
- * .load()
407
- * .then(data => console.log(data)))
408
- *
409
- * @public
410
- * @param {String} restoreLink the secure URL to restore the user's current session
411
- * @returns {Session} the current session
412
- */
413
- setRestoreLink(restoreLink: string): Session
414
- /**
415
- * Sets the response type to HTML or JSON_ORIGINAL. This denotes the preferred
416
- * response type of the recommendation result.
417
- * If you would like to access the raw recommendation data in <code>JSON</code> form, specify
418
- * <code>JSON</code>. When you specify JSON, you will need to template the result yourself.
419
- * If you require a more simplified approach, specify <code>HTML</code>. When you specify
420
- * <code>HTML</code>, you get back HTML blobs, that you may simply inject into
421
- * you placements.
422
- *
423
- * @example
424
- * nostojs(api => api
425
- * .defaultSession()
426
- * .setResponseMode("HTML")
427
- * .viewCart()
428
- * .setPlacements(["free-shipper"])
429
- * .load()
430
- * .then(data => console.log(data)))
431
- *
432
- * @public
433
- * @param {String} mode the response mode for the recommendation data
434
- * @returns {Session} the current session
435
- */
436
- setResponseMode(mode: RenderMode): Session
437
- /**
438
- * Create a new action for a front page. This should be used when the user
439
- * visits the home page.
440
- * <br/><br/>
441
- * You must invoke [the load method]{@link Action#load} on the resultant
442
- * action in order for the request to be made.
443
- * <br/><br/>
444
- * You do not need to specify the page-type explicitly as it is inferred
445
- * from the action.
446
- *
447
- * @example
448
- * nostojs(api => api
449
- * .defaultSession()
450
- * .viewFrontPage()
451
- * .setPlacements(["best-seller"])
452
- * .load()
453
- * .then(data => console.log(data)))
454
- *
455
- *
456
- * @public
457
- * @returns {Action} the action instance to load content or track events.
458
- */
459
- viewFrontPage(): Action
460
- /**
461
- * Create a new action for a cart page. This should be used on all cart and
462
- * checkout pages. If your site has a multi-step checkout, it is recommended
463
- * that you send this event on each checkout page.
464
- * <br/><br/>
465
- * You must invoke [the load method]{@link Action#load} on the resultant
466
- * action in order for the request to be made.
467
- * <br/><br/>
468
- * You do not need to specify the page-type explicitly as it is inferred
469
- * from the action.
470
- *
471
- * @example
472
- * nostojs(api => api
473
- * .defaultSession()
474
- * .viewCart()
475
- * .setPlacements(["free-shipper"])
476
- * .load()
477
- * .then(data => console.log(data)))
478
- *
479
- * @public
480
- * @returns {Action} the action instance to load content or track events.
481
- */
482
- viewCart(): Action
483
- /**
484
- * Create a new action for a not found page. This should be used only on 404
485
- * pages.
486
- * <br/><br/>
487
- * You must invoke [the load method]{@link Action#load} on the resultant
488
- * action in order for the request to be made.
489
- * <br/><br/>
490
- * You do not need to specify the page-type explicitly as it is inferred
491
- * from the action.
492
- *
493
- * @example
494
- * nostojs(api => api
495
- * .defaultSession()
496
- * .viewNotFound()
497
- * .setPlacements(["best-seller"])
498
- * .load()
499
- * .then(data => console.log(data)))
500
- *
501
- * @public
502
- * @returns {Action} the action instance to load content or track events.
503
- */
504
- viewNotFound(): Action
505
- /**
506
- * Create a new action for a product page. This must be used only when a
507
- * product is being viewed. In case a specific SKU of the product is being viewed, use viewProductSku instead.
508
- * <br/><br/>
509
- * You must invoke [the load method]{@link Action#load} on the resultant
510
- * action in order for the request to be made.
511
- * <br/><br/>
512
- * You do not need to specify the page-type explicitly as it is inferred
513
- * from the action.
514
- *
515
- * @example
516
- * nostojs(api => api
517
- * .defaultSession()
518
- * .viewProduct("101")
519
- * .setCategories(["/men/trousers"])
520
- * .setRef("123", "example_reco_id")
521
- * .setPlacements(["cross-seller"])
522
- * .load()
523
- * .then(data => console.log(data)))
524
- *
525
- * @public
526
- * @param product
527
- * @returns {Action} the action instance to load content or track events.
528
- */
529
- viewProduct(product: string | Product): Action
530
- /**
531
- * Create a new action for a product page when a specific SKU has been chosen. This must be used only when a
532
- * product and specific SKU is being viewed.
533
- * <br/><br/>
534
- * You must invoke [the load method]{@link Action#load} on the resultant
535
- * action in order for the request to be made.
536
- * <br/><br/>
537
- * You do not need to specify the page-type explicitly as it is inferred
538
- * from the action.
539
- *
540
- * @example
541
- * nostojs(api => api
542
- * .defaultSession()
543
- * .viewProductSku("101", "101-sku-1")
544
- * .setCategories(["/men/trousers"])
545
- * .setRef("123", "example_reco_id")
546
- * .setPlacements(["cross-seller"])
547
- * .load()
548
- * .then(data => console.log(data)))
549
- *
550
- * @public
551
- * @param productId
552
- * @param skuId
553
- * @returns {Action} the action instance to load content or track events.
554
- */
555
- viewProductSku(productId: string, skuId: string): Action
556
- /**
557
- * Create a new action for a category page. This should be used on all
558
- * category, collection of brand pages.
559
- * <br/><br/>
560
- * You must invoke [the load method]{@link Action#load} on the resultant
561
- * action in order for the request to be made.
562
- * <br/><br/>
563
- * You do not need to specify the page-type explicitly as it is inferred
564
- * from the action.
565
- *
566
- * @example
567
- * nostojs(api => api
568
- * .defaultSession()
569
- * .viewCategory("/men/shoes")
570
- * .setPlacements(["category123"])
571
- * .load()
572
- * .then(data => console.log(data)))
573
- *
574
- * @public
575
- * @param {Array<String>} categories
576
- * @returns {Action} the action instance to load content or track events.
577
- */
578
- viewCategory(...categories: string[]): Action
579
- /**
580
- * Create a new action for a tag page. This should be used only on tag pages.
581
- * <br/><br/>
582
- * You must invoke [the load method]{@link Action#load} on the resultant
583
- * action in order for the request to be made.
584
- * <br/><br/>
585
- * You do not need to specify the page-type explicitly as it is inferred
586
- * from the action.
587
- * Note: tags are not case-sensitive.
588
- *
589
- * @example
590
- * nostojs(api => api
591
- * .defaultSession()
592
- * .viewTag("colourful")
593
- * .load()
594
- * .then(data => console.log(data)))
595
- *
596
- * @public
597
- * @deprecated as this is an advanced action with a limited a use case
598
- * @param {Array<String>} tags the set of the tags being viewed.
599
- * @returns {Action} the action instance to load content or track events.
600
- */
601
- viewTag(...tags: string[]): Action
602
- /**
603
- * Create a new action with custom fields.
604
- * <br/><br/>
605
- * You must invoke [the load method]{@link Action#load} on the resultant
606
- * action in order for the request to be made.
607
- * <br/><br/>
608
- * You do not need to specify the page-type explicitly as it is inferred
609
- * from the action.
610
- * Note: tags are not case-sensitive.
611
- *
612
- * @example
613
- * nostojs(api => api
614
- * .defaultSession()
615
- * .viewCustomField({material: "cotton"})
616
- * .load()
617
- * .then(data => console.log(data)))
618
- *
619
- * @public
620
- * @deprecated as this is an advanced action with a limited a use case
621
- * @param {Object} customFields custom fields being viewed.
622
- * @returns {Action} the action instance to load content or track events.
623
- */
624
- viewCustomField(customFields: Record<string, string[]>): Action
625
- /**
626
- * Create a new action for a search page. This should be used only
627
- * on search pages. A search page action requires you to pass the search
628
- * term. For example, if the user search for "black shoes", you must pass
629
- * in "black shoes" and not an encoded version such as "black+shoes".
630
- * <br/><br/>
631
- * You must invoke [the load method]{@link Action#load} on the resultant
632
- * action in order for the request to be made.
633
- * <br/><br/>
634
- * You do not need to specify the page-type explicitly as it is inferred
635
- * from the action.
636
- * Search terms are not case-sensitive.
637
- *
638
- * @example
639
- * nostojs(api => api
640
- * .defaultSession()
641
- * .viewSearch("black shoes")
642
- * .load()
643
- * .then(data => console.log(data)))
644
- *
645
- * @public
646
- * @param {Array.<String>} searchTerms the non-encoded search terms
647
- * @returns {Action} the action instance to load content or track events.
648
- */
649
- viewSearch(...searchTerms: string[]): Action
650
- /**
651
- * Create a new action for a general page. This should be used only on
652
- * pages that don't have a corresponding action. For example, if the user
653
- * is viewing a page such as a "Contact Us" page, you should use the viewOther
654
- * action.
655
- * <br/><br/>
656
- * You must invoke [the load method]{@link Action#load} on the resultant
657
- * action in order for the request to be made.
658
- * <br/><br/>
659
- * You do not need to specify the page-type explicitly as it is inferred
660
- * from the action.
661
- *
662
- * @example
663
- * nostojs(api => api
664
- * .defaultSession()
665
- * .viewOther()
666
- * .load()
667
- * .then(data => console.log(data)))
668
- *
669
- * @public
670
- * @returns {Action} the action instance to load content or track events.
671
- */
672
- viewOther(): Action
673
- /**
674
- * Create a new action for an order page. This should only be used on order
675
- * confirmation / thank you pages.
676
- * <br/><br/>
677
- * You do not need to specify the page-type explicitly as it is inferred
678
- * from the action.
679
- * <br/><br/>
680
- * You must invoke [the load method]{@link Action#load} on the resultant
681
- * action in order for the request to be made.
682
- *
683
- * @example
684
- * nostojs(api => {
685
- * api.defaultSession()
686
- * .addOrder({
687
- * external_order_ref: "145000006",
688
- * info: {
689
- * order_number: "195",
690
- * email: "mridang@nosto.com",
691
- * first_name: "Mridang",
692
- * last_name: "Agarwalla",
693
- * type: "order",
694
- * newsletter: true
695
- * },
696
- * items: [{
697
- * product_id: "406",
698
- * sku_id: "243",
699
- * name: "Linen Blazer (White, S)",
700
- * quantity: 1,
701
- * unit_price: 455,
702
- * price_currency_code: "EUR"
703
- * }]
704
- * })
705
- * .setPlacements(["order-related"])
706
- * .load()
707
- * .then(data => {
708
- * console.log(data.recommendations)
709
- * })
710
- * })
711
- * @public
712
- * @param {Order} order the information about the order that was placed
713
- * @returns {Action} the action instance to load content or track events.
714
- */
715
- addOrder(order: Order): Action
716
- /**
717
- * Creates an action to report that product was added to the shopping cart,
718
- * e.g. from the recommendation slot with "Add to cart" button.
719
- * <p>
720
- * You must invoke [the load method]{@link Action#load} on the resultant
721
- * action in order for the request to be made.
722
- *
723
- *
724
- * @example
725
- * nostojs(api => api
726
- * .defaultSession()
727
- * .reportAddToCart("123", "reco-slot-1")
728
- * .load()
729
- * .then(data => console.log(data)))
730
- *
731
- * @public
732
- * @param product
733
- * @param element
734
- * @returns {Action} the action instance to load content or track events.
735
- */
736
- reportAddToCart(product: string, element: string): Action
737
- /**
738
- * @example
739
- * nostojs(api => api
740
- * .defaultSession()
741
- * .recordAttribution("vp", "12345678", "123456")
742
- * .done()
743
- * .then(data => console.log(data))
744
- * @param { EventType } type
745
- * @param { String } target
746
- * @param { String | undefined } [ref]
747
- * @param { String | undefined } [refSrc]
748
- * @return { Object }
749
- *
750
- */
751
- recordAttribution(type: EventType, target: string, ref: string, refSrc: string): object
752
- }
753
-
754
- /**
755
- * @group Types
756
- */
757
- export interface Action {
758
- /**
759
- * Handles click attribution for product recommendations.
760
- * This can be called when reporting a product view
761
- * to signal that the view is a result of a click on a recommendation.
762
- *
763
- * @public
764
- * @param {String} productId currently viewed product's product id
765
- * @param {String} reference value of result_id from the recommendation response that was clicked
766
- * @return {Action}
767
- */
768
- setRef(productId: string, reference: string): Action
769
- /**
770
- * Allows you to provide an additional recommender hint that a product is being
771
- * viewed.
772
- * <br/><br/>
773
- * You must invoke [the load method]{@link Action#load} on the resultant
774
- * action in order for the request to be made.
775
- *
776
- * @public
777
- * @param {String} product the identifier of the product being viewed
778
- * @return {Action} the instance of the action
779
- */
780
- setProduct(product: string | Product): Action
781
- /**
782
- * @deprecated
783
- * @param {Array<String>} products
784
- * @return {Action}
785
- */
786
- setProducts(products: (string | Product)[]): Action
787
- /**
788
- * Sets the information about the user's current shopping cart. It the user
789
- * does not have any items in his shopping cart, you can pass <code>null<code>.
790
- * Passing <code>null<code> will nullify the user's shopping cart on Nosto's
791
- * end. You must also pass in the shopping cart content in it's entirety as
792
- * partial content are not supported.
793
- * <br/><br/>
794
- * It is not recommended to pass the current cart contents to an action but
795
- * instead use the the session
796
- * <br/><br/>
797
- * You must invoke [the load method]{@link Action#load} on the resultant
798
- * action in order for the request to be made.
799
- *
800
- * @see {@link Session#setCart}
801
- * @return {Action}
802
- */
803
- setCart(cart: Cart): Action
804
- /**
805
- * Sets the information about the currently logged in customer. If the current
806
- * customer is not provided, you will not be able to leverage features such as
807
- * triggered emails. While it is recommended to always provide the details of
808
- * the currently logged in customer, it may be omitted if there are concerns
809
- * about privacy or compliance.
810
- * <br/><br/>
811
- * It is not recommended to pass the current customer details to an action but
812
- * instead use the the session
813
- * <br/><br/>
814
- * You must invoke [the load method]{@link Action#load} on the resultant
815
- * action in order for the request to be made.
816
- *
817
- * @see {@link Session#setCustomer}
818
- * @public
819
- * @param {Customer} customer the details of the currently logged in customer
820
- * @return {Action}
821
- */
822
- setCustomer(customer: Customer): Action
823
- /**
824
- * @param {Order} order
825
- * @return {Action}
826
- */
827
- setOrder(order: Order): Action
828
- /**
829
- * <br/><br/>
830
- * You must invoke [the load method]{@link Action#load} on the resultant
831
- * action in order for the request to be made.
832
- *
833
- * @public
834
- * @param searchTerms
835
- * @return {Action}
836
- */
837
- setSearchTerms(searchTerms: string[]): Action
838
- /**
839
- * <br/><br/>
840
- * You must invoke [the load method]{@link Action#load} on the resultant
841
- * action in order for the request to be made.
842
- *
843
- * @public
844
- * @param {Array<String>} categories
845
- * @return {Action}
846
- */
847
- setCategories(categories: string[]): Action
848
- /**
849
- * <br/><br/>
850
- * You must invoke [the load method]{@link Action#load} on the resultant
851
- * action in order for the request to be made.
852
- *
853
- * @public
854
- * @param {Array<String>} categoryIds
855
- * @return {Action}
856
- */
857
- setCategoryIds(categoryIds: string[]): Action
858
- /**
859
- * <br/><br/>
860
- * You must invoke [the load method]{@link Action#load} on the resultant
861
- * action in order for the request to be made.
862
- *
863
- * @public
864
- * @param {Array<String>} parentCategoryIds
865
- * @return {Action}
866
- */
867
- setParentCategoryIds(parentCategoryIds: string[]): Action
868
- /**
869
- * <br/><br/>
870
- * You must invoke [the load method]{@link Action#load} on the resultant
871
- * action in order for the request to be made.
872
- *
873
- * @public
874
- * @param tags
875
- * @return {Action}
876
- */
877
- setTags(tags: string[]): Action
878
- /**
879
- * <br/><br/>
880
- * You must invoke [the load method]{@link Action#load} on the resultant
881
- * action in order for the request to be made.
882
- *
883
- * @public
884
- * @param customFields
885
- * @return {Action}
886
- */
887
- setCustomFields(customFields: Record<string, string[]>): Action
888
- /**
889
- * Sets the current variation identifier for the session. A variation identifier
890
- * identifies the current currency (or the current customer group). If your site
891
- * uses multi-currency, you must provide the ISO code current currency being viewed.
892
- * <br/><br/>
893
- * It is not recommended to pass the variation identifier to an action but
894
- * instead use the the session.
895
- * <br/><br/>
896
- * You must invoke [the load method]{@link Action#load} on the resultant
897
- * action in order for the request to be made.
898
- *
899
- * @see {@link Session#setVariation}
900
- * @public
901
- * @param {String} variation the case-sensitive identifier of the current variation
902
- * @return {Action}
903
- */
904
- setVariation(variation: string): Action
905
- /**
906
- * <br/><br/>
907
- * You must invoke [the load method]{@link Action#load} on the resultant
908
- * action in order for the request to be made.
909
- *
910
- * @public
911
- * @param {Array.<String>} placements
912
- * @return {Action}
913
- */
914
- setPlacements(placements: string[]): Action
915
- /**
916
- * Sets the restore link for the current session. Restore links can be leveraged
917
- * in email campaigns. Restore links allow the the user to restore the cart
918
- * contents in a single click.
919
- * <br/><br/>
920
- * Read more about
921
- * {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
922
- * <br/><br/>
923
- * It is not recommended to pass the restore link to an action but instead use the the
924
- * session.
925
- * <br/><br/>
926
- * You must invoke [the load method]{@link Action#load} on the resultant
927
- * action in order for the request to be made.
928
- *
929
- * @see {@link Session#setRestoreLink}
930
- * @public
931
- * @param {String} restoreLink the secure URL to restore the user's current session
932
- * @return {Action}
933
- */
934
- setRestoreLink(restoreLink: string): Action
935
- /**
936
- * Sets the identifier of the current page type to the current request. The different
937
- * page types are product, front, search, cart, order, category, notfound and other.
938
- * <br/><br/>
939
- * You must invoke [the load method]{@link Action#load} on the resultant
940
- * action in order for the request to be made.
941
- * <br/><br/>
942
- * It is not recommended to pass the page type to an action but instead use the the
943
- * session.
944
- * <br/><br/>
945
- * You must invoke [the load method]{@link Action#load} on the resultant
946
- * action in order for the request to be made.
947
- *
948
- * @see {@link Session#viewFrontPage} for when a front or home page is being viewed
949
- * @see {@link Session#viewCart} for when a cart or checkout page is being viewed
950
- * @see {@link Session#viewNotFound} for when a not-found or 404 page is being viewed
951
- * @see {@link Session#viewProduct} for when a product page is being viewed
952
- * @see {@link Session#viewCategory} for when a category, collection or brand page is being viewed
953
- * @see {@link Session#viewTag} for when a tag page is being viewed
954
- * @see {@link Session#viewSearch} for when a search page is being viewed
955
- * @see {@link Session#viewOther} for when a miscellaneous page is being viewed
956
- * @public
957
- */
958
- setPageType(pageType: PageType): Action
959
- /**
960
- * @public
961
- * @return {Object}
962
- */
963
- dumpData(): Data
964
- update(): unknown
965
- load(flags?: RecommendationRequestFlags): Promise<ActionResponse>
966
- }
967
-
968
- export interface ActionResponse {
969
- recommendations: Record<string, unknown>
970
- campaigns?: {
971
- recommendations: Record<string, unknown>
972
- content: Record<string, unknown>
973
- }
974
- page_views: number
975
- geo_location: string[]
976
- affinities: CustomerAffinityResponse
977
- cmpid: string
978
- }