@nosto/nosto-react 0.5.0 → 2.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.
package/README.md CHANGED
@@ -251,21 +251,16 @@ You can personalise your order-confirmation/thank-you page by using the `NostoOr
251
251
 
252
252
  By default, your account, when created, has one other-page placement named `thankyou-nosto-1`. You may omit this and use any identifier you need. The identifier used here is simply provided to illustrate the example.
253
253
 
254
- The `order` prop requires a value that adheres to the type `Purchase`.
255
-
256
254
  ```jsx
257
255
  import {
258
- Buyer,
259
- Item,
260
256
  NostoOrder,
261
257
  NostoPlacement,
262
- Purchase,
263
258
  } from "@nosto/nosto-react";
264
259
 
265
260
  <div className="thankyou-page">
266
261
  ... ... ...
267
262
  <NostoPlacement id="thankyou-nosto-1" />
268
- <NostoOrder order={{ purchase: toOrder(order) }} />
263
+ <NostoOrder order={ order } />
269
264
  </div>;
270
265
  ```
271
266
 
package/dist/index.d.ts CHANGED
@@ -2,55 +2,54 @@ import { Context } from 'react';
2
2
  import { default as default_2 } from 'react';
3
3
  import { JSX as JSX_2 } from 'react/jsx-runtime';
4
4
 
5
+ declare type AnyFunction = (...args: unknown[]) => unknown;
6
+
5
7
  /**
6
8
  * @group Types
7
9
  */
8
- declare interface Affinity {
9
- name: string;
10
- score: number;
10
+ export declare interface Cart {
11
+ hcid?: string;
12
+ items: CartItem[];
11
13
  }
12
14
 
13
- declare type AnyFunction = (...args: unknown[]) => unknown;
14
-
15
15
  /**
16
16
  * @group Types
17
17
  */
18
- export declare interface Buyer {
19
- first_name: string;
20
- last_name: string;
21
- email: string;
22
- type: string;
23
- newsletter: boolean;
18
+ declare interface CartItem {
19
+ name: string;
20
+ price_currency_code: string;
21
+ product_id: string;
22
+ quantity: number;
23
+ sku_id?: string;
24
+ unit_price: number;
24
25
  }
25
26
 
26
27
  /**
27
28
  * @group Types
28
29
  */
29
- export declare interface Cart {
30
- items: Item[];
30
+ declare interface ConversionItem {
31
+ name: string;
32
+ price_currency_code: string;
33
+ product_id: string;
34
+ quantity?: number;
35
+ sku_id?: string;
36
+ unit_price?: number;
31
37
  }
32
38
 
33
39
  /**
34
40
  * @group Types
35
41
  */
36
42
  export declare interface Customer {
37
- customer_reference: string;
43
+ customer_reference?: string;
38
44
  email: string;
39
45
  first_name: string;
46
+ hcid?: string;
40
47
  last_name: string;
41
- newsletter: boolean;
42
- }
43
-
44
- /**
45
- * @group Types
46
- */
47
- export declare interface Item {
48
- name: string;
49
- price_currency_code: string;
50
- product_id: string;
51
- quantity: number;
52
- sku_id: string;
53
- unit_price: number;
48
+ newsletter?: boolean;
49
+ order_number?: string;
50
+ source?: string;
51
+ source_id?: string;
52
+ type?: string;
54
53
  }
55
54
 
56
55
  /**
@@ -75,7 +74,7 @@ export declare interface Item {
75
74
  */
76
75
  export declare function Nosto404(props: {
77
76
  placements?: string[];
78
- }): JSX_2.Element;
77
+ }): null;
79
78
 
80
79
  /**
81
80
  * You can personalise your category and collection pages by using the NostoCategory component.
@@ -102,7 +101,7 @@ export declare function Nosto404(props: {
102
101
  export declare function NostoCategory(props: {
103
102
  category: string;
104
103
  placements?: string[];
105
- }): JSX_2.Element;
104
+ }): null;
106
105
 
107
106
  /**
108
107
  * You can personalise your cart and checkout pages by using the NostoCheckout component.
@@ -125,39 +124,7 @@ export declare function NostoCategory(props: {
125
124
  */
126
125
  export declare function NostoCheckout(props: {
127
126
  placements?: string[];
128
- }): JSX_2.Element;
129
-
130
- /**
131
- * @group Types
132
- */
133
- declare interface NostoClient {
134
- setAutoLoad(autoload: boolean): NostoClient;
135
- defaultSession(): NostoClientSession;
136
- placements: {
137
- getPlacements(): string[];
138
- injectCampaigns(recommendations: Record<string, Recommendation>): void;
139
- };
140
- }
141
-
142
- /**
143
- * @group Types
144
- */
145
- declare interface NostoClientSession {
146
- setCart(cart?: Cart): NostoClientSession;
147
- setCustomer(customer?: Customer): NostoClientSession;
148
- setResponseMode(mode: string): NostoClientSession;
149
- setVariation(variation?: string): NostoClientSession;
150
- addOrder(order: {
151
- purchase: Purchase;
152
- }): SessionAction;
153
- viewCategory(category: string): SessionAction;
154
- viewProduct(product: string): SessionAction;
155
- viewFrontPage(): SessionAction;
156
- viewNotFound(): SessionAction;
157
- viewOther(): SessionAction;
158
- viewSearch(query: string): SessionAction;
159
- viewCart(): SessionAction;
160
- }
127
+ }): null;
161
128
 
162
129
  /**
163
130
  * @group Essential Functions
@@ -172,15 +139,8 @@ export declare interface NostoContextType {
172
139
  clientScriptLoaded: boolean;
173
140
  currentVariation?: string;
174
141
  renderFunction?: AnyFunction;
175
- responseMode: string;
176
- recommendationComponent?: React.ReactElement<{
177
- nostoRecommendation: Recommendation;
178
- }>;
179
- useRenderCampaigns(type: string): {
180
- renderCampaigns(data: unknown, api: NostoClient): void;
181
- pageTypeUpdated: boolean;
182
- };
183
- pageType: string;
142
+ responseMode: RenderMode;
143
+ recommendationComponent?: RecommendationComponent;
184
144
  }
185
145
 
186
146
  /**
@@ -208,7 +168,7 @@ export declare interface NostoContextType {
208
168
  */
209
169
  export declare function NostoHome(props: {
210
170
  placements?: string[];
211
- }): JSX_2.Element;
171
+ }): null;
212
172
 
213
173
  /**
214
174
  * You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component.
@@ -230,11 +190,9 @@ export declare function NostoHome(props: {
230
190
  * @group Components
231
191
  */
232
192
  export declare function NostoOrder(props: {
233
- order: {
234
- purchase: Purchase;
235
- };
193
+ order: Order;
236
194
  placements?: string[];
237
- }): JSX_2.Element;
195
+ }): null;
238
196
 
239
197
  /**
240
198
  * You can personalise your miscellaneous pages by using the NostoOther component.
@@ -257,7 +215,7 @@ export declare function NostoOrder(props: {
257
215
  */
258
216
  export declare function NostoOther(props: {
259
217
  placements?: string[];
260
- }): JSX_2.Element;
218
+ }): null;
261
219
 
262
220
  /**
263
221
  * Nosto React has a special component called NostoPlacement.
@@ -305,7 +263,7 @@ export declare function NostoProduct(props: {
305
263
  product: string;
306
264
  tagging?: Product;
307
265
  placements?: string[];
308
- }): JSX_2.Element;
266
+ }): null;
309
267
 
310
268
  /**
311
269
  * This widget is what we call the Nosto root widget, which is responsible for adding the actual Nosto script and the JS API stub.
@@ -346,7 +304,10 @@ declare interface NostoProviderProps {
346
304
  * Indicates an url of a server
347
305
  */
348
306
  host?: string;
349
- children: default_2.ReactElement;
307
+ /**
308
+ * children
309
+ */
310
+ children: default_2.ReactElement | default_2.ReactElement[];
350
311
  /**
351
312
  * Indicates if merchant uses multiple currencies
352
313
  */
@@ -354,9 +315,7 @@ declare interface NostoProviderProps {
354
315
  /**
355
316
  * Recommendation component which holds nostoRecommendation object
356
317
  */
357
- recommendationComponent?: default_2.ReactElement<{
358
- nostoRecommendation: Recommendation;
359
- }>;
318
+ recommendationComponent?: RecommendationComponent;
360
319
  /**
361
320
  * Enables Shopify markets with language and market id
362
321
  */
@@ -392,7 +351,7 @@ declare interface NostoProviderProps {
392
351
  export declare function NostoSearch(props: {
393
352
  query: string;
394
353
  placements?: string[];
395
- }): JSX_2.Element;
354
+ }): null;
396
355
 
397
356
  /**
398
357
  * 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.
@@ -404,53 +363,109 @@ export declare function NostoSearch(props: {
404
363
  *
405
364
  * @group Essential Functions
406
365
  */
407
- export declare function NostoSession(props: {
408
- cart: Cart;
409
- customer: Customer;
366
+ export declare function NostoSession(props?: {
367
+ cart?: Cart;
368
+ customer?: Customer;
410
369
  }): JSX_2.Element;
411
370
 
371
+ declare interface NostoSku extends Sku {
372
+ inventory_level?: number;
373
+ }
374
+
375
+ declare interface NostoVariant {
376
+ availability: string;
377
+ available: boolean;
378
+ discounted: boolean;
379
+ list_price?: number;
380
+ price: number;
381
+ price_currency_code: string;
382
+ price_text?: string;
383
+ }
384
+
385
+ /**
386
+ * @group Types
387
+ */
388
+ export declare interface Order {
389
+ created_at?: Date;
390
+ external_order_ref: string;
391
+ info?: OrderCustomer;
392
+ items: ConversionItem[];
393
+ order_status?: string;
394
+ order_status_label?: string;
395
+ payment_provider: string;
396
+ }
397
+
398
+ /**
399
+ * @group Types
400
+ */
401
+ declare interface OrderCustomer {
402
+ country: string;
403
+ email?: string;
404
+ first_name?: string;
405
+ last_name?: string;
406
+ newsletter: string;
407
+ order_number: string;
408
+ phone: string;
409
+ post_code: string;
410
+ type: string;
411
+ }
412
+
412
413
  /**
413
414
  * @group Types
414
415
  */
415
- export declare interface Product {
416
- alternateImageUrls?: URL[];
417
- availability: "InStock" | "OutOfStock";
416
+ export declare type Product = {
417
+ product_id: string;
418
+ selected_sku_id?: string;
419
+ };
420
+
421
+ declare interface PushedProduct {
422
+ age_group?: string;
423
+ alternate_image_urls: string[];
424
+ availability: string;
418
425
  brand?: string;
419
426
  category: string[];
420
- categoryIds?: string[];
421
- description: string;
422
- googleCategory?: string;
427
+ category_id: string[];
423
428
  condition?: string;
429
+ custom_fields: {
430
+ [index: string]: string;
431
+ };
432
+ date_published?: Date;
433
+ description?: string;
424
434
  gender?: string;
425
- ageGroup?: string;
435
+ google_category?: string;
426
436
  gtin?: string;
427
- imageUrl: URL;
428
- listPrice?: number;
437
+ image_url?: string;
438
+ inventory_level?: number;
439
+ list_price?: number;
429
440
  name: string;
441
+ parent_category_id: string[];
430
442
  price: number;
431
- ratingValue?: number;
432
- reviewCount?: number;
433
- priceCurrencyCode: string;
434
- productId: string;
435
- tags1?: string[];
436
- tags2?: string[];
437
- tags3?: string[];
438
- thumbUrl?: URL;
439
- url: URL;
440
- customFields?: {
441
- [key: string]: string;
443
+ price_currency_code: string;
444
+ product_id: string;
445
+ rating_value?: number;
446
+ review_count?: number;
447
+ skus: PushedProductSKU[];
448
+ source_updated?: Date;
449
+ supplier_cost?: number;
450
+ tags1: string[];
451
+ tags2: string[];
452
+ tags3: string[];
453
+ thumb_url?: string;
454
+ unit_pricing_base_measure?: number;
455
+ unit_pricing_measure?: number;
456
+ unit_pricing_unit?: string;
457
+ update_received?: Date;
458
+ url: string;
459
+ variation_id?: string;
460
+ variations: {
461
+ [index: string]: PushedVariation;
442
462
  };
443
- variationId?: string;
444
- skus?: SKU[];
445
463
  }
446
464
 
447
- /**
448
- * @group Types
449
- */
450
- export declare interface Purchase {
451
- number: string;
452
- info: Buyer;
453
- items: Item[];
465
+ declare interface PushedProductSKU extends NostoSku {
466
+ }
467
+
468
+ declare interface PushedVariation extends NostoVariant {
454
469
  }
455
470
 
456
471
  /**
@@ -458,7 +473,7 @@ export declare interface Purchase {
458
473
  */
459
474
  export declare interface Recommendation {
460
475
  result_id: string;
461
- products: Product[];
476
+ products: PushedProduct[];
462
477
  result_type: string;
463
478
  title: string;
464
479
  div_id: string;
@@ -466,34 +481,27 @@ export declare interface Recommendation {
466
481
  params: unknown;
467
482
  }
468
483
 
469
- /**
470
- * @group Types
471
- */
472
- declare interface SessionAction {
473
- setPlacements(placements: string[]): SessionAction;
474
- load(): Promise<{
475
- affinities: Record<string, Affinity[]>;
476
- geo_location?: string[];
477
- page_views: number;
478
- recommendations: Recommendation[];
479
- }>;
480
- }
484
+ declare type RecommendationComponent = React.ReactElement<{
485
+ nostoRecommendation: Recommendation;
486
+ }>;
481
487
 
482
488
  /**
483
489
  * @group Types
484
490
  */
485
- export declare interface SKU {
491
+ 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";
492
+
493
+ declare interface Sku {
494
+ availability: string;
495
+ custom_fields: {
496
+ [index: string]: string;
497
+ };
498
+ gtin?: string;
486
499
  id: string;
500
+ image_url?: string;
501
+ list_price?: number;
487
502
  name: string;
488
503
  price: number;
489
- listPrice?: number;
490
- url: URL;
491
- imageUrl: URL;
492
- gtin?: string;
493
- availability: "InStock" | "OutOfStock";
494
- customFields?: {
495
- [key: string]: string;
496
- };
504
+ url?: string;
497
505
  }
498
506
 
499
507
  /**