@putiikkipalvelu/storefront-sdk 0.11.2 → 0.14.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/dist/index.cjs +74 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +328 -165
- package/dist/index.d.ts +328 -165
- package/dist/index.js +74 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Types
|
|
3
|
+
*
|
|
4
|
+
* Types for product-related API endpoints.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Product variation option (e.g., Size: Large)
|
|
9
|
+
*/
|
|
10
|
+
interface VariationOption {
|
|
11
|
+
/** Option value (e.g., "Large", "Red") */
|
|
12
|
+
value: string;
|
|
13
|
+
/** Option type information */
|
|
14
|
+
optionType: {
|
|
15
|
+
/** Option type name (e.g., "Size", "Color") */
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Product variation for listings (minimal fields)
|
|
21
|
+
*/
|
|
22
|
+
interface ProductVariationListing {
|
|
23
|
+
/** Unique variation identifier */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Variation price in cents */
|
|
26
|
+
price: number;
|
|
27
|
+
/** Sale price in cents (null if not on sale) */
|
|
28
|
+
salePrice: number | null;
|
|
29
|
+
/** Sale discount percentage as string (null if not on sale) */
|
|
30
|
+
salePercent: string | null;
|
|
31
|
+
/** Sale start date (ISO 8601), null = immediate */
|
|
32
|
+
saleStartDate: string | null;
|
|
33
|
+
/** Sale end date (ISO 8601), null = no end */
|
|
34
|
+
saleEndDate: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Full product variation (for product detail page)
|
|
38
|
+
*/
|
|
39
|
+
interface ProductVariation extends ProductVariationListing {
|
|
40
|
+
/** Variation weight in kg (null = use product weight) */
|
|
41
|
+
weight: number | null;
|
|
42
|
+
/** Available quantity (null = unlimited) */
|
|
43
|
+
quantity: number | null;
|
|
44
|
+
/** Stock keeping unit */
|
|
45
|
+
sku: string | null;
|
|
46
|
+
/** Variation-specific images */
|
|
47
|
+
images: string[];
|
|
48
|
+
/** Variation-specific description */
|
|
49
|
+
description: string | null;
|
|
50
|
+
/** Whether variation is visible on store */
|
|
51
|
+
showOnStore: boolean;
|
|
52
|
+
/** Variation options (size, color, etc.) */
|
|
53
|
+
options: VariationOption[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Product for listing (cards, grids)
|
|
57
|
+
* Used by: /latest-products, /sorted-products
|
|
58
|
+
*/
|
|
59
|
+
interface Product {
|
|
60
|
+
/** Unique product identifier */
|
|
61
|
+
id: string;
|
|
62
|
+
/** Product display name */
|
|
63
|
+
name: string;
|
|
64
|
+
/** URL-friendly slug */
|
|
65
|
+
slug: string;
|
|
66
|
+
/** Product description */
|
|
67
|
+
description: string;
|
|
68
|
+
/** Base price in cents */
|
|
69
|
+
price: number;
|
|
70
|
+
/** Product images (URLs) */
|
|
71
|
+
images: string[];
|
|
72
|
+
/** Available quantity (null = unlimited) */
|
|
73
|
+
quantity: number | null;
|
|
74
|
+
/** Sale price in cents (null if not on sale) */
|
|
75
|
+
salePrice: number | null;
|
|
76
|
+
/** Sale discount percentage as string (null if not on sale) */
|
|
77
|
+
salePercent: string | null;
|
|
78
|
+
/** Sale start date (ISO 8601), null = immediate */
|
|
79
|
+
saleStartDate: string | null;
|
|
80
|
+
/** Sale end date (ISO 8601), null = no end */
|
|
81
|
+
saleEndDate: string | null;
|
|
82
|
+
/** True if this product is delivered as a digital download (no shipping) */
|
|
83
|
+
isDigital?: boolean;
|
|
84
|
+
/** Product variations (minimal fields for listing) */
|
|
85
|
+
variations: ProductVariationListing[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Full product detail (single product page)
|
|
89
|
+
* Used by: /product/{slug}
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* Ticket info attached to a ticket product
|
|
93
|
+
*/
|
|
94
|
+
interface ProductTicketInfo {
|
|
95
|
+
/** Ticket info ID */
|
|
96
|
+
id: string;
|
|
97
|
+
/** Whether holder name is required per ticket at checkout */
|
|
98
|
+
requiresHolder: boolean;
|
|
99
|
+
/** Maximum uses per ticket (0 = unlimited) */
|
|
100
|
+
maxUses: number;
|
|
101
|
+
/** Ticket sales start (ISO 8601), null = sales open immediately */
|
|
102
|
+
salesStart: string | null;
|
|
103
|
+
/** Ticket sales end (ISO 8601), null = sales never end */
|
|
104
|
+
salesEnd: string | null;
|
|
105
|
+
}
|
|
106
|
+
interface ProductDetail extends Omit<Product, "variations"> {
|
|
107
|
+
/** Product weight in kg (for shipping calculations) */
|
|
108
|
+
weight: number;
|
|
109
|
+
/** Stock keeping unit */
|
|
110
|
+
sku: string | null;
|
|
111
|
+
/** SEO meta title */
|
|
112
|
+
metaTitle: string | null;
|
|
113
|
+
/** SEO meta description */
|
|
114
|
+
metaDescription: string | null;
|
|
115
|
+
/** Product categories */
|
|
116
|
+
categories: CategoryReference[];
|
|
117
|
+
/** Full product variations */
|
|
118
|
+
variations: ProductVariation[];
|
|
119
|
+
/** Ticket info (present if product is a ticket, null otherwise) */
|
|
120
|
+
ticketInfo: ProductTicketInfo | null;
|
|
121
|
+
/**
|
|
122
|
+
* HTML instructions shown to the buyer after a digital purchase.
|
|
123
|
+
* Only populated when isDigital=true; null otherwise.
|
|
124
|
+
*/
|
|
125
|
+
digitalContent?: string | null;
|
|
126
|
+
/** Average rating across approved reviews (null when there are none) */
|
|
127
|
+
averageRating: number | null;
|
|
128
|
+
/** Number of approved reviews */
|
|
129
|
+
reviewCount: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Response from /sorted-products
|
|
133
|
+
*/
|
|
134
|
+
interface ProductListResponse {
|
|
135
|
+
/** Category/collection name */
|
|
136
|
+
name: string;
|
|
137
|
+
/** Products in the list */
|
|
138
|
+
products: Product[];
|
|
139
|
+
/** Total count for pagination (only in sorted-products) */
|
|
140
|
+
totalCount?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Response from /products-count
|
|
144
|
+
*/
|
|
145
|
+
interface ProductCountResponse {
|
|
146
|
+
/** Number of products */
|
|
147
|
+
count: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sort options for product listing
|
|
151
|
+
*/
|
|
152
|
+
type ProductSortOption = "newest" | "price_asc" | "price_desc" | "popularity" | "relevance"
|
|
153
|
+
/** The merchant's manual per-category order (set in the dashboard). Only
|
|
154
|
+
* meaningful within a category; falls back to "newest" on all-products. */
|
|
155
|
+
| "featured";
|
|
156
|
+
/**
|
|
157
|
+
* Parameters for sorted products
|
|
158
|
+
*/
|
|
159
|
+
interface ProductListParams {
|
|
160
|
+
/** Category slugs to filter by (omit for all products) */
|
|
161
|
+
slugs?: string[];
|
|
162
|
+
/** Page number (1-based, default: 1) */
|
|
163
|
+
page?: number;
|
|
164
|
+
/** Products per page (default: 12, max: 100) */
|
|
165
|
+
pageSize?: number;
|
|
166
|
+
/** Sort order */
|
|
167
|
+
sort?: ProductSortOption;
|
|
168
|
+
/** Full-text search query */
|
|
169
|
+
query?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
1
172
|
/**
|
|
2
173
|
* Store Configuration Types
|
|
3
174
|
*
|
|
4
175
|
* Types for the store config endpoint response.
|
|
5
176
|
*/
|
|
177
|
+
|
|
6
178
|
/**
|
|
7
179
|
* Complete store configuration returned by the API.
|
|
8
180
|
* Includes business info, SEO settings, payments, campaigns, and feature flags.
|
|
@@ -70,6 +242,10 @@ interface StoreInfo {
|
|
|
70
242
|
logoUrl: string | null;
|
|
71
243
|
/** Product image aspect ratio: SQUARE (1:1) or PORTRAIT (3:4) */
|
|
72
244
|
imageAspectRatio: ImageAspectRatio;
|
|
245
|
+
/** Default product sort for storefront category pages before the shopper
|
|
246
|
+
* picks a sort. "featured" = the merchant's manual per-category order.
|
|
247
|
+
* Optional for backward compatibility with older backends. */
|
|
248
|
+
defaultProductSort?: ProductSortOption;
|
|
73
249
|
}
|
|
74
250
|
/**
|
|
75
251
|
* Store SEO and social media configuration
|
|
@@ -276,170 +452,6 @@ interface CategoryReference {
|
|
|
276
452
|
parentId: string | null;
|
|
277
453
|
}
|
|
278
454
|
|
|
279
|
-
/**
|
|
280
|
-
* Product Types
|
|
281
|
-
*
|
|
282
|
-
* Types for product-related API endpoints.
|
|
283
|
-
*/
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Product variation option (e.g., Size: Large)
|
|
287
|
-
*/
|
|
288
|
-
interface VariationOption {
|
|
289
|
-
/** Option value (e.g., "Large", "Red") */
|
|
290
|
-
value: string;
|
|
291
|
-
/** Option type information */
|
|
292
|
-
optionType: {
|
|
293
|
-
/** Option type name (e.g., "Size", "Color") */
|
|
294
|
-
name: string;
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Product variation for listings (minimal fields)
|
|
299
|
-
*/
|
|
300
|
-
interface ProductVariationListing {
|
|
301
|
-
/** Unique variation identifier */
|
|
302
|
-
id: string;
|
|
303
|
-
/** Variation price in cents */
|
|
304
|
-
price: number;
|
|
305
|
-
/** Sale price in cents (null if not on sale) */
|
|
306
|
-
salePrice: number | null;
|
|
307
|
-
/** Sale discount percentage as string (null if not on sale) */
|
|
308
|
-
salePercent: string | null;
|
|
309
|
-
/** Sale start date (ISO 8601), null = immediate */
|
|
310
|
-
saleStartDate: string | null;
|
|
311
|
-
/** Sale end date (ISO 8601), null = no end */
|
|
312
|
-
saleEndDate: string | null;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Full product variation (for product detail page)
|
|
316
|
-
*/
|
|
317
|
-
interface ProductVariation extends ProductVariationListing {
|
|
318
|
-
/** Variation weight in kg (null = use product weight) */
|
|
319
|
-
weight: number | null;
|
|
320
|
-
/** Available quantity (null = unlimited) */
|
|
321
|
-
quantity: number | null;
|
|
322
|
-
/** Stock keeping unit */
|
|
323
|
-
sku: string | null;
|
|
324
|
-
/** Variation-specific images */
|
|
325
|
-
images: string[];
|
|
326
|
-
/** Variation-specific description */
|
|
327
|
-
description: string | null;
|
|
328
|
-
/** Whether variation is visible on store */
|
|
329
|
-
showOnStore: boolean;
|
|
330
|
-
/** Variation options (size, color, etc.) */
|
|
331
|
-
options: VariationOption[];
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Product for listing (cards, grids)
|
|
335
|
-
* Used by: /latest-products, /sorted-products
|
|
336
|
-
*/
|
|
337
|
-
interface Product {
|
|
338
|
-
/** Unique product identifier */
|
|
339
|
-
id: string;
|
|
340
|
-
/** Product display name */
|
|
341
|
-
name: string;
|
|
342
|
-
/** URL-friendly slug */
|
|
343
|
-
slug: string;
|
|
344
|
-
/** Product description */
|
|
345
|
-
description: string;
|
|
346
|
-
/** Base price in cents */
|
|
347
|
-
price: number;
|
|
348
|
-
/** Product images (URLs) */
|
|
349
|
-
images: string[];
|
|
350
|
-
/** Available quantity (null = unlimited) */
|
|
351
|
-
quantity: number | null;
|
|
352
|
-
/** Sale price in cents (null if not on sale) */
|
|
353
|
-
salePrice: number | null;
|
|
354
|
-
/** Sale discount percentage as string (null if not on sale) */
|
|
355
|
-
salePercent: string | null;
|
|
356
|
-
/** Sale start date (ISO 8601), null = immediate */
|
|
357
|
-
saleStartDate: string | null;
|
|
358
|
-
/** Sale end date (ISO 8601), null = no end */
|
|
359
|
-
saleEndDate: string | null;
|
|
360
|
-
/** True if this product is delivered as a digital download (no shipping) */
|
|
361
|
-
isDigital?: boolean;
|
|
362
|
-
/** Product variations (minimal fields for listing) */
|
|
363
|
-
variations: ProductVariationListing[];
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Full product detail (single product page)
|
|
367
|
-
* Used by: /product/{slug}
|
|
368
|
-
*/
|
|
369
|
-
/**
|
|
370
|
-
* Ticket info attached to a ticket product
|
|
371
|
-
*/
|
|
372
|
-
interface ProductTicketInfo {
|
|
373
|
-
/** Ticket info ID */
|
|
374
|
-
id: string;
|
|
375
|
-
/** Whether holder name is required per ticket at checkout */
|
|
376
|
-
requiresHolder: boolean;
|
|
377
|
-
/** Maximum uses per ticket (0 = unlimited) */
|
|
378
|
-
maxUses: number;
|
|
379
|
-
/** Ticket sales start (ISO 8601), null = sales open immediately */
|
|
380
|
-
salesStart: string | null;
|
|
381
|
-
/** Ticket sales end (ISO 8601), null = sales never end */
|
|
382
|
-
salesEnd: string | null;
|
|
383
|
-
}
|
|
384
|
-
interface ProductDetail extends Omit<Product, "variations"> {
|
|
385
|
-
/** Product weight in kg (for shipping calculations) */
|
|
386
|
-
weight: number;
|
|
387
|
-
/** Stock keeping unit */
|
|
388
|
-
sku: string | null;
|
|
389
|
-
/** SEO meta title */
|
|
390
|
-
metaTitle: string | null;
|
|
391
|
-
/** SEO meta description */
|
|
392
|
-
metaDescription: string | null;
|
|
393
|
-
/** Product categories */
|
|
394
|
-
categories: CategoryReference[];
|
|
395
|
-
/** Full product variations */
|
|
396
|
-
variations: ProductVariation[];
|
|
397
|
-
/** Ticket info (present if product is a ticket, null otherwise) */
|
|
398
|
-
ticketInfo: ProductTicketInfo | null;
|
|
399
|
-
/**
|
|
400
|
-
* HTML instructions shown to the buyer after a digital purchase.
|
|
401
|
-
* Only populated when isDigital=true; null otherwise.
|
|
402
|
-
*/
|
|
403
|
-
digitalContent?: string | null;
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Response from /sorted-products
|
|
407
|
-
*/
|
|
408
|
-
interface ProductListResponse {
|
|
409
|
-
/** Category/collection name */
|
|
410
|
-
name: string;
|
|
411
|
-
/** Products in the list */
|
|
412
|
-
products: Product[];
|
|
413
|
-
/** Total count for pagination (only in sorted-products) */
|
|
414
|
-
totalCount?: number;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Response from /products-count
|
|
418
|
-
*/
|
|
419
|
-
interface ProductCountResponse {
|
|
420
|
-
/** Number of products */
|
|
421
|
-
count: number;
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Sort options for product listing
|
|
425
|
-
*/
|
|
426
|
-
type ProductSortOption = "newest" | "price_asc" | "price_desc" | "popularity" | "relevance";
|
|
427
|
-
/**
|
|
428
|
-
* Parameters for sorted products
|
|
429
|
-
*/
|
|
430
|
-
interface ProductListParams {
|
|
431
|
-
/** Category slugs to filter by (omit for all products) */
|
|
432
|
-
slugs?: string[];
|
|
433
|
-
/** Page number (1-based, default: 1) */
|
|
434
|
-
page?: number;
|
|
435
|
-
/** Products per page (default: 12, max: 100) */
|
|
436
|
-
pageSize?: number;
|
|
437
|
-
/** Sort order */
|
|
438
|
-
sort?: ProductSortOption;
|
|
439
|
-
/** Full-text search query */
|
|
440
|
-
query?: string;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
455
|
/**
|
|
444
456
|
* Category Types
|
|
445
457
|
*
|
|
@@ -1887,6 +1899,90 @@ interface WithdrawalResolveTokenResponse {
|
|
|
1887
1899
|
expiresAt: string;
|
|
1888
1900
|
}
|
|
1889
1901
|
|
|
1902
|
+
/**
|
|
1903
|
+
* Review Types
|
|
1904
|
+
*
|
|
1905
|
+
* Types for the product reviews & ratings endpoints.
|
|
1906
|
+
*/
|
|
1907
|
+
/** Moderation status of a review */
|
|
1908
|
+
type ReviewStatus = "PENDING" | "APPROVED" | "REJECTED";
|
|
1909
|
+
/**
|
|
1910
|
+
* A single approved review as returned by the public list endpoint.
|
|
1911
|
+
*/
|
|
1912
|
+
interface Review {
|
|
1913
|
+
/** Unique review identifier */
|
|
1914
|
+
id: string;
|
|
1915
|
+
/** Star rating 1–5 */
|
|
1916
|
+
rating: number;
|
|
1917
|
+
/** Optional short title (null if omitted) */
|
|
1918
|
+
title: string | null;
|
|
1919
|
+
/** Review body (plain text). Empty when the moderator hid the content. */
|
|
1920
|
+
body: string;
|
|
1921
|
+
/** True when the moderator redacted the text — show a placeholder, keep stars */
|
|
1922
|
+
contentHidden: boolean;
|
|
1923
|
+
/** True when tied to a verified purchase (and the store shows the badge) */
|
|
1924
|
+
verifiedPurchase: boolean;
|
|
1925
|
+
/** Store owner's reply (null if none) */
|
|
1926
|
+
merchantReply: string | null;
|
|
1927
|
+
/** Creation timestamp (ISO 8601) */
|
|
1928
|
+
createdAt: string;
|
|
1929
|
+
/** Display name (logged-in first name → anonymous name → fallback) */
|
|
1930
|
+
reviewerName: string;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Response from GET /reviews/{slug} — approved reviews for a product.
|
|
1934
|
+
*/
|
|
1935
|
+
interface ReviewListResponse {
|
|
1936
|
+
/** Average rating across approved reviews (null when none) */
|
|
1937
|
+
averageRating: number | null;
|
|
1938
|
+
/** Number of approved reviews */
|
|
1939
|
+
reviewCount: number;
|
|
1940
|
+
/** Count of approved reviews per star, keyed "1".."5" */
|
|
1941
|
+
distribution: Record<string, number>;
|
|
1942
|
+
/** Most recent approved reviews */
|
|
1943
|
+
reviews: Review[];
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Parameters for submitting a review.
|
|
1947
|
+
* Pass a sessionId to {@link ReviewsResource.submit} for logged-in reviews
|
|
1948
|
+
* (enables the verified-purchase check + reward code); omit it for anonymous.
|
|
1949
|
+
*/
|
|
1950
|
+
interface SubmitReviewParams {
|
|
1951
|
+
/** Slug of the product being reviewed */
|
|
1952
|
+
slug: string;
|
|
1953
|
+
/** Star rating 1–5 */
|
|
1954
|
+
rating: number;
|
|
1955
|
+
/** Review body text */
|
|
1956
|
+
body: string;
|
|
1957
|
+
/** Optional short title */
|
|
1958
|
+
title?: string;
|
|
1959
|
+
/** Display name for anonymous reviews (ignored when a sessionId is passed) */
|
|
1960
|
+
authorName?: string;
|
|
1961
|
+
}
|
|
1962
|
+
/** Reward discount code revealed to a logged-in reviewer (if enabled). */
|
|
1963
|
+
interface SubmitReviewReward {
|
|
1964
|
+
/** The discount code, e.g. "KIITOS10" */
|
|
1965
|
+
code: string;
|
|
1966
|
+
/** "PERCENTAGE" | "FIXED_AMOUNT" */
|
|
1967
|
+
discountType: string;
|
|
1968
|
+
/** Percentage (e.g. 10) or fixed amount in cents, per discountType */
|
|
1969
|
+
discountValue: number;
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Response from POST /reviews. The created review is always PENDING (the store
|
|
1973
|
+
* owner moderates it). `reward` is non-null only for logged-in reviewers when
|
|
1974
|
+
* the store has enabled a (still-live) reward code.
|
|
1975
|
+
*/
|
|
1976
|
+
interface SubmitReviewResponse {
|
|
1977
|
+
success: boolean;
|
|
1978
|
+
review: {
|
|
1979
|
+
id: string;
|
|
1980
|
+
status: ReviewStatus;
|
|
1981
|
+
verifiedPurchase: boolean;
|
|
1982
|
+
};
|
|
1983
|
+
reward: SubmitReviewReward | null;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1890
1986
|
/**
|
|
1891
1987
|
* Putiikkipalvelu Storefront SDK Types
|
|
1892
1988
|
*
|
|
@@ -3185,6 +3281,69 @@ declare function createWithdrawalResource(fetcher: Fetcher): {
|
|
|
3185
3281
|
*/
|
|
3186
3282
|
type WithdrawalResource = ReturnType<typeof createWithdrawalResource>;
|
|
3187
3283
|
|
|
3284
|
+
/**
|
|
3285
|
+
* Reviews Resource
|
|
3286
|
+
*
|
|
3287
|
+
* Read approved product reviews and submit new ones. Submitting works both
|
|
3288
|
+
* anonymously and for logged-in customers — pass a sessionId to run the
|
|
3289
|
+
* verified-purchase check and (if the store enabled it) reveal a reward code.
|
|
3290
|
+
*/
|
|
3291
|
+
|
|
3292
|
+
/**
|
|
3293
|
+
* Reviews resource for listing and submitting product reviews
|
|
3294
|
+
*/
|
|
3295
|
+
declare function createReviewsResource(fetcher: Fetcher): {
|
|
3296
|
+
/**
|
|
3297
|
+
* List approved reviews for a product, with the aggregate rating and a
|
|
3298
|
+
* 1–5 star distribution.
|
|
3299
|
+
*
|
|
3300
|
+
* @param slug - Product URL slug
|
|
3301
|
+
* @param options - Fetch options (caching, headers, etc.)
|
|
3302
|
+
* @returns Approved reviews, average rating, count, and distribution
|
|
3303
|
+
*
|
|
3304
|
+
* @example
|
|
3305
|
+
* ```typescript
|
|
3306
|
+
* const { reviews, averageRating, reviewCount } =
|
|
3307
|
+
* await client.reviews.list('my-product');
|
|
3308
|
+
* ```
|
|
3309
|
+
*/
|
|
3310
|
+
list(slug: string, options?: FetchOptions): Promise<ReviewListResponse>;
|
|
3311
|
+
/**
|
|
3312
|
+
* Submit a product review. Anonymous by default; pass a sessionId to submit
|
|
3313
|
+
* as a logged-in customer (enables the verified-purchase check + reward code).
|
|
3314
|
+
* The review is created as PENDING and appears once the store owner approves it.
|
|
3315
|
+
*
|
|
3316
|
+
* @param params - Review data (slug, rating 1–5, body, optional title/authorName)
|
|
3317
|
+
* @param sessionId - Optional customer session id (logged-in submit)
|
|
3318
|
+
* @param options - Fetch options
|
|
3319
|
+
* @returns The created review (PENDING) and a reward code if revealed
|
|
3320
|
+
*
|
|
3321
|
+
* @example Anonymous
|
|
3322
|
+
* ```typescript
|
|
3323
|
+
* await client.reviews.submit({
|
|
3324
|
+
* slug: 'my-product',
|
|
3325
|
+
* rating: 5,
|
|
3326
|
+
* body: 'Loistava tuote!',
|
|
3327
|
+
* authorName: 'Matti',
|
|
3328
|
+
* });
|
|
3329
|
+
* ```
|
|
3330
|
+
*
|
|
3331
|
+
* @example Logged-in (may return a reward code)
|
|
3332
|
+
* ```typescript
|
|
3333
|
+
* const { reward } = await client.reviews.submit(
|
|
3334
|
+
* { slug: 'my-product', rating: 5, body: 'Loistava tuote!' },
|
|
3335
|
+
* sessionId
|
|
3336
|
+
* );
|
|
3337
|
+
* if (reward) console.log(`Käytä koodia ${reward.code}`);
|
|
3338
|
+
* ```
|
|
3339
|
+
*/
|
|
3340
|
+
submit(params: SubmitReviewParams, sessionId?: string, options?: FetchOptions): Promise<SubmitReviewResponse>;
|
|
3341
|
+
};
|
|
3342
|
+
/**
|
|
3343
|
+
* Type for the reviews resource
|
|
3344
|
+
*/
|
|
3345
|
+
type ReviewsResource = ReturnType<typeof createReviewsResource>;
|
|
3346
|
+
|
|
3188
3347
|
/**
|
|
3189
3348
|
* The Storefront API client
|
|
3190
3349
|
*/
|
|
@@ -3241,6 +3400,10 @@ interface StorefrontClient {
|
|
|
3241
3400
|
* Withdrawal resource for consumer withdrawal notices (KKV peruutustoiminto)
|
|
3242
3401
|
*/
|
|
3243
3402
|
readonly withdrawal: WithdrawalResource;
|
|
3403
|
+
/**
|
|
3404
|
+
* Reviews resource for listing and submitting product reviews
|
|
3405
|
+
*/
|
|
3406
|
+
readonly reviews: ReviewsResource;
|
|
3244
3407
|
}
|
|
3245
3408
|
/**
|
|
3246
3409
|
* Create a new Storefront API client
|
|
@@ -3488,4 +3651,4 @@ declare class VerificationRequiredError extends StorefrontError {
|
|
|
3488
3651
|
constructor(message: string, customerId: string);
|
|
3489
3652
|
}
|
|
3490
3653
|
|
|
3491
|
-
export { type AboutBlock, type AccordionBlock, type AccordionItem, type AddToCartParams, type AddToWishlistResponse, type AnalyticsConfig, type AppliedDiscount, type ApplyDiscountParams, type ApplyDiscountResponse, AuthError, type BuyXPayYCampaign, type CalculatedCartItem, type Campaign, type CampaignType, type CarouselContentBlock, type CarouselContentItem, type CartCalculationResult, type CartItem, type CartResponse, type CartSessionOptions, type CartValidationChanges, type CartValidationResponse, type Category, type CategoryReference, type CategoryResponse, type CheckoutCustomerData, type CheckoutErrorCode, type CheckoutErrorDetails, type CheckoutOptions, type CheckoutParams, type CheckoutShipmentMethod, type ConfirmationItemType, type ConfirmationOrderCustomerData, type ConfirmationOrderLineItem, type ConfirmationOrderShipmentMethod, type Customer, type CustomerOrder, type DeleteAccountResponse, type DiscountApplyErrorCode, type DiscountCodeError, type DiscountMessageLocale, type DiscountRemovalReason, type DiscountType, type DownloadUrlResponse, type DownloadsAuthOptions, type FeatureFlags, type FetchOptions, type ForgotPasswordResponse, type FormatDiscountOptions, type GalleryBlock, type GalleryItem, type GetDiscountParams, type GetDiscountResponse, type GetOrdersResponse, type GetUserResponse, type HomeDeliveryOption, type ImageAspectRatio, type ImageGridBlock, type ImageGridItem, type LoginOptions, type LoginResponse, type LoginVerificationRequiredResponse, type LogoutResponse, type MarkdownBlock, type NavPage, NotFoundError, type OpeningHours, type OpeningHoursBlock, type OpeningHoursEntry, type Order, type OrderDownload, type OrderDownloadLineItem, type OrderDownloadsResponse, type OrderLineItem, type OrderProductInfo, type OrderShipmentMethod, type OrderStatus, type PageBlock, type PageSeo, type PaymentConfig, type PaytrailCheckoutResponse, type PaytrailGroup, type PaytrailProvider, type PickupPointOption, type PriceInfo, type Product, type ProductCountResponse, type ProductDetail, type ProductListParams, type ProductListResponse, type ProductSortOption, type ProductTicketInfo, type ProductVariation, type ProductVariationListing, type PurchasedTicket, RateLimitError, type RegisterData, type RegisterResponse, type RemoveDiscountParams, type RemoveDiscountResponse, type RemoveFromCartParams, type RemoveFromWishlistResponse, type ResendVerificationResponse, type ResetPasswordResponse, type ShipitShippingMethod, type ShipmentMethod, type ShipmentMethodsResponse, type ShowcaseBlock, type ShowcaseItem, type StoreConfig, type StoreInfo, type StorePage, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, type StripeCheckoutResponse, type TableBlock, type TextGridBlock, type TextGridItem, type TicketEvent, type TicketEventsResponse, type TicketGetResponse, type TicketHolderData, type TicketStatus, type TicketUseResponse, type TicketValidatePinResponse, type UpdateCartQuantityParams, type UpdateProfileData, type UpdateProfileResponse, ValidationError, type VariationOption, VerificationRequiredError, type VerifyEmailResponse, type WishlistItem, type WishlistProduct, type WishlistResponse, type WishlistVariation, type WishlistVariationOption, type WithdrawalItem, type WithdrawalNoticeParams, type WithdrawalResolveTokenResponse, type WithdrawalSubmitResponse, calculateCartWithCampaigns, calculateDiscountAmount, createStorefrontClient, formatDiscountValue, getDiscountApplyErrorMessage, getDiscountRemovalMessage, getPriceInfo, isSaleActive };
|
|
3654
|
+
export { type AboutBlock, type AccordionBlock, type AccordionItem, type AddToCartParams, type AddToWishlistResponse, type AnalyticsConfig, type AppliedDiscount, type ApplyDiscountParams, type ApplyDiscountResponse, AuthError, type BuyXPayYCampaign, type CalculatedCartItem, type Campaign, type CampaignType, type CarouselContentBlock, type CarouselContentItem, type CartCalculationResult, type CartItem, type CartResponse, type CartSessionOptions, type CartValidationChanges, type CartValidationResponse, type Category, type CategoryReference, type CategoryResponse, type CheckoutCustomerData, type CheckoutErrorCode, type CheckoutErrorDetails, type CheckoutOptions, type CheckoutParams, type CheckoutShipmentMethod, type ConfirmationItemType, type ConfirmationOrderCustomerData, type ConfirmationOrderLineItem, type ConfirmationOrderShipmentMethod, type Customer, type CustomerOrder, type DeleteAccountResponse, type DiscountApplyErrorCode, type DiscountCodeError, type DiscountMessageLocale, type DiscountRemovalReason, type DiscountType, type DownloadUrlResponse, type DownloadsAuthOptions, type FeatureFlags, type FetchOptions, type ForgotPasswordResponse, type FormatDiscountOptions, type GalleryBlock, type GalleryItem, type GetDiscountParams, type GetDiscountResponse, type GetOrdersResponse, type GetUserResponse, type HomeDeliveryOption, type ImageAspectRatio, type ImageGridBlock, type ImageGridItem, type LoginOptions, type LoginResponse, type LoginVerificationRequiredResponse, type LogoutResponse, type MarkdownBlock, type NavPage, NotFoundError, type OpeningHours, type OpeningHoursBlock, type OpeningHoursEntry, type Order, type OrderDownload, type OrderDownloadLineItem, type OrderDownloadsResponse, type OrderLineItem, type OrderProductInfo, type OrderShipmentMethod, type OrderStatus, type PageBlock, type PageSeo, type PaymentConfig, type PaytrailCheckoutResponse, type PaytrailGroup, type PaytrailProvider, type PickupPointOption, type PriceInfo, type Product, type ProductCountResponse, type ProductDetail, type ProductListParams, type ProductListResponse, type ProductSortOption, type ProductTicketInfo, type ProductVariation, type ProductVariationListing, type PurchasedTicket, RateLimitError, type RegisterData, type RegisterResponse, type RemoveDiscountParams, type RemoveDiscountResponse, type RemoveFromCartParams, type RemoveFromWishlistResponse, type ResendVerificationResponse, type ResetPasswordResponse, type Review, type ReviewListResponse, type ReviewStatus, type ShipitShippingMethod, type ShipmentMethod, type ShipmentMethodsResponse, type ShowcaseBlock, type ShowcaseItem, type StoreConfig, type StoreInfo, type StorePage, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, type StripeCheckoutResponse, type SubmitReviewParams, type SubmitReviewResponse, type SubmitReviewReward, type TableBlock, type TextGridBlock, type TextGridItem, type TicketEvent, type TicketEventsResponse, type TicketGetResponse, type TicketHolderData, type TicketStatus, type TicketUseResponse, type TicketValidatePinResponse, type UpdateCartQuantityParams, type UpdateProfileData, type UpdateProfileResponse, ValidationError, type VariationOption, VerificationRequiredError, type VerifyEmailResponse, type WishlistItem, type WishlistProduct, type WishlistResponse, type WishlistVariation, type WishlistVariationOption, type WithdrawalItem, type WithdrawalNoticeParams, type WithdrawalResolveTokenResponse, type WithdrawalSubmitResponse, calculateCartWithCampaigns, calculateDiscountAmount, createStorefrontClient, formatDiscountValue, getDiscountApplyErrorMessage, getDiscountRemovalMessage, getPriceInfo, isSaleActive };
|