@asstio-dev/storefront 0.18.0 → 0.20.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 +60 -0
- package/dist/analytics/events.d.ts +20 -0
- package/dist/analytics/events.js +23 -0
- package/dist/checkout/browser.d.ts +13 -1
- package/dist/checkout/browser.js +146 -3
- package/dist/checkout/controllers.d.ts +18 -2
- package/dist/checkout/controllers.js +133 -16
- package/dist/checkout/live-shipping.d.ts +30 -0
- package/dist/checkout/live-shipping.js +193 -0
- package/dist/checkout/server.d.ts +4 -1
- package/dist/checkout/server.js +9 -0
- package/dist/checkout/types.d.ts +12 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/schema.d.ts +292 -2
- package/package.json +2 -2
- package/src/schema.d.ts +292 -2
package/dist/schema.d.ts
CHANGED
|
@@ -183,6 +183,22 @@ export interface paths {
|
|
|
183
183
|
patch?: never;
|
|
184
184
|
trace?: never;
|
|
185
185
|
};
|
|
186
|
+
"/v1/checkout/{attemptId}/shipping": {
|
|
187
|
+
parameters: {
|
|
188
|
+
query?: never;
|
|
189
|
+
header?: never;
|
|
190
|
+
path?: never;
|
|
191
|
+
cookie?: never;
|
|
192
|
+
};
|
|
193
|
+
get: operations["GetCheckoutShipping"];
|
|
194
|
+
put?: never;
|
|
195
|
+
post?: never;
|
|
196
|
+
delete?: never;
|
|
197
|
+
options?: never;
|
|
198
|
+
head?: never;
|
|
199
|
+
patch?: never;
|
|
200
|
+
trace?: never;
|
|
201
|
+
};
|
|
186
202
|
"/v1/collections": {
|
|
187
203
|
parameters: {
|
|
188
204
|
query?: never;
|
|
@@ -233,6 +249,23 @@ export interface paths {
|
|
|
233
249
|
patch?: never;
|
|
234
250
|
trace?: never;
|
|
235
251
|
};
|
|
252
|
+
"/v1/events": {
|
|
253
|
+
parameters: {
|
|
254
|
+
query?: never;
|
|
255
|
+
header?: never;
|
|
256
|
+
path?: never;
|
|
257
|
+
cookie?: never;
|
|
258
|
+
};
|
|
259
|
+
get?: never;
|
|
260
|
+
put?: never;
|
|
261
|
+
/** Search exposures, clicks and add-to-carts for measurement (spec 2026-10-13 §9.2). Send only with the shopper's consent. Each event is validated on its own: a bad one is listed in rejected and the others are kept; an eventId the site already has is a duplicate and changes nothing. */
|
|
262
|
+
post: operations["TrackSearchEvents"];
|
|
263
|
+
delete?: never;
|
|
264
|
+
options?: never;
|
|
265
|
+
head?: never;
|
|
266
|
+
patch?: never;
|
|
267
|
+
trace?: never;
|
|
268
|
+
};
|
|
236
269
|
"/v1/orders/{orderId}": {
|
|
237
270
|
parameters: {
|
|
238
271
|
query?: never;
|
|
@@ -406,6 +439,8 @@ export interface components {
|
|
|
406
439
|
AppliedFilterDto: {
|
|
407
440
|
facet: string;
|
|
408
441
|
label: string;
|
|
442
|
+
/** @default filter */
|
|
443
|
+
source: string;
|
|
409
444
|
value: string;
|
|
410
445
|
};
|
|
411
446
|
AttributeDto: {
|
|
@@ -593,6 +628,32 @@ export interface components {
|
|
|
593
628
|
kind: string;
|
|
594
629
|
url: null | string;
|
|
595
630
|
};
|
|
631
|
+
CheckoutShippingPointDto: {
|
|
632
|
+
city: null | string;
|
|
633
|
+
name: string;
|
|
634
|
+
postalCode: null | string;
|
|
635
|
+
street: null | string;
|
|
636
|
+
};
|
|
637
|
+
CheckoutShippingViewDto: {
|
|
638
|
+
/** Format: int32 */
|
|
639
|
+
cartVersion: number | null | string;
|
|
640
|
+
currency: null | string;
|
|
641
|
+
deliveryType: null | string;
|
|
642
|
+
goodsInc: null | string;
|
|
643
|
+
name: null | string;
|
|
644
|
+
option: null | string;
|
|
645
|
+
otherInc: null | string;
|
|
646
|
+
point: null | components["schemas"]["CheckoutShippingPointDto"];
|
|
647
|
+
/** Format: date-time */
|
|
648
|
+
readAt: null | string;
|
|
649
|
+
reason: null | string;
|
|
650
|
+
/** Format: int32 */
|
|
651
|
+
retryAfterSeconds: number | null | string;
|
|
652
|
+
shippingInc: null | string;
|
|
653
|
+
state: string;
|
|
654
|
+
totalInc: null | string;
|
|
655
|
+
totalSource: null | string;
|
|
656
|
+
};
|
|
596
657
|
CheckoutStatusDto: {
|
|
597
658
|
attemptId: string;
|
|
598
659
|
order: null | components["schemas"]["CheckoutOrderRefDto"];
|
|
@@ -710,6 +771,7 @@ export interface components {
|
|
|
710
771
|
pageSize: number | string;
|
|
711
772
|
queryCorrection: null | string;
|
|
712
773
|
redirect: null | string;
|
|
774
|
+
search?: null | components["schemas"]["SearchInfoDto"];
|
|
713
775
|
sort: components["schemas"]["SortDto"];
|
|
714
776
|
/** Format: int64 */
|
|
715
777
|
total: number | string;
|
|
@@ -978,6 +1040,60 @@ export interface components {
|
|
|
978
1040
|
importer: null | components["schemas"]["PartyDto"];
|
|
979
1041
|
manufacturer: null | components["schemas"]["PartyDto"];
|
|
980
1042
|
};
|
|
1043
|
+
SearchEventDto: {
|
|
1044
|
+
eventId: null | string;
|
|
1045
|
+
exposureId?: null | string;
|
|
1046
|
+
/** Format: date-time */
|
|
1047
|
+
occurredAt: null | string;
|
|
1048
|
+
/** Format: int32 */
|
|
1049
|
+
page?: number | null;
|
|
1050
|
+
/** Format: int32 */
|
|
1051
|
+
position?: number | null;
|
|
1052
|
+
productId?: null | string;
|
|
1053
|
+
productIds?: string[] | null;
|
|
1054
|
+
/** Format: int32 */
|
|
1055
|
+
quantity?: number | null;
|
|
1056
|
+
query?: null | string;
|
|
1057
|
+
resultId?: null | string;
|
|
1058
|
+
sessionId?: null | string;
|
|
1059
|
+
type: null | string;
|
|
1060
|
+
variantId?: null | string;
|
|
1061
|
+
};
|
|
1062
|
+
SearchEventRejection: {
|
|
1063
|
+
code: string;
|
|
1064
|
+
/** Format: int32 */
|
|
1065
|
+
index: number | string;
|
|
1066
|
+
member: null | string;
|
|
1067
|
+
};
|
|
1068
|
+
SearchEventsRequest: {
|
|
1069
|
+
events: components["schemas"]["SearchEventDto"][] | null;
|
|
1070
|
+
};
|
|
1071
|
+
SearchEventsResponse: {
|
|
1072
|
+
/** Format: int32 */
|
|
1073
|
+
accepted: number | string;
|
|
1074
|
+
/** Format: int32 */
|
|
1075
|
+
duplicates: number | string;
|
|
1076
|
+
rejected: components["schemas"]["SearchEventRejection"][];
|
|
1077
|
+
/** Format: int32 */
|
|
1078
|
+
stored: number | string;
|
|
1079
|
+
};
|
|
1080
|
+
SearchInfoDto: {
|
|
1081
|
+
codeMatch: boolean;
|
|
1082
|
+
intents: components["schemas"]["SearchIntentDto"][];
|
|
1083
|
+
rescue: null | components["schemas"]["SearchRescueDto"];
|
|
1084
|
+
resultId: string;
|
|
1085
|
+
tier: string;
|
|
1086
|
+
};
|
|
1087
|
+
SearchIntentDto: {
|
|
1088
|
+
facet: string;
|
|
1089
|
+
queryWithout: string;
|
|
1090
|
+
values: string[];
|
|
1091
|
+
};
|
|
1092
|
+
SearchRescueDto: {
|
|
1093
|
+
collectionId: string;
|
|
1094
|
+
name: string;
|
|
1095
|
+
slug: string;
|
|
1096
|
+
};
|
|
981
1097
|
SellabilityDto: {
|
|
982
1098
|
mode: components["schemas"]["SiteSellabilityMode"];
|
|
983
1099
|
};
|
|
@@ -2401,6 +2517,91 @@ export interface operations {
|
|
|
2401
2517
|
};
|
|
2402
2518
|
};
|
|
2403
2519
|
};
|
|
2520
|
+
GetCheckoutShipping: {
|
|
2521
|
+
parameters: {
|
|
2522
|
+
query?: never;
|
|
2523
|
+
header: {
|
|
2524
|
+
/** @description Publishable, preview or secret site key. Required on every request; secret keys are server-side only. */
|
|
2525
|
+
"X-Site-Key": string;
|
|
2526
|
+
/** @description Market code (e.g. "se"). Omit for the site's default market. */
|
|
2527
|
+
"X-Market"?: string;
|
|
2528
|
+
/** @description BCP-47 language tag. Omit to use the market's language. */
|
|
2529
|
+
"Accept-Language"?: string;
|
|
2530
|
+
/** @description The cart's bearer token. The checkout works on this cart. */
|
|
2531
|
+
"X-Cart-Token": string;
|
|
2532
|
+
};
|
|
2533
|
+
path: {
|
|
2534
|
+
attemptId: string;
|
|
2535
|
+
};
|
|
2536
|
+
cookie?: never;
|
|
2537
|
+
};
|
|
2538
|
+
requestBody?: never;
|
|
2539
|
+
responses: {
|
|
2540
|
+
/** @description OK */
|
|
2541
|
+
200: {
|
|
2542
|
+
headers: {
|
|
2543
|
+
[name: string]: unknown;
|
|
2544
|
+
};
|
|
2545
|
+
content: {
|
|
2546
|
+
"application/json": components["schemas"]["CheckoutShippingViewDto"];
|
|
2547
|
+
};
|
|
2548
|
+
};
|
|
2549
|
+
/** @description problem+json. NOT_FOUND (X-Cart-Token missing). */
|
|
2550
|
+
400: {
|
|
2551
|
+
headers: {
|
|
2552
|
+
[name: string]: unknown;
|
|
2553
|
+
};
|
|
2554
|
+
content: {
|
|
2555
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2556
|
+
};
|
|
2557
|
+
};
|
|
2558
|
+
/** @description problem+json. SITE_KEY_MISSING or SITE_KEY_INVALID. */
|
|
2559
|
+
401: {
|
|
2560
|
+
headers: {
|
|
2561
|
+
[name: string]: unknown;
|
|
2562
|
+
};
|
|
2563
|
+
content: {
|
|
2564
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2565
|
+
};
|
|
2566
|
+
};
|
|
2567
|
+
/** @description problem+json. SECRET_KEY_FROM_BROWSER: a secret key was sent from a browser. */
|
|
2568
|
+
403: {
|
|
2569
|
+
headers: {
|
|
2570
|
+
[name: string]: unknown;
|
|
2571
|
+
};
|
|
2572
|
+
content: {
|
|
2573
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2574
|
+
};
|
|
2575
|
+
};
|
|
2576
|
+
/** @description problem+json. CHECKOUT_NOT_FOUND: no such attempt for this site and cart; or SITE_INACTIVE. */
|
|
2577
|
+
404: {
|
|
2578
|
+
headers: {
|
|
2579
|
+
[name: string]: unknown;
|
|
2580
|
+
};
|
|
2581
|
+
content: {
|
|
2582
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2583
|
+
};
|
|
2584
|
+
};
|
|
2585
|
+
/** @description problem+json. RATE_LIMITED; retryAfterSeconds and the Retry-After header say how long to wait. */
|
|
2586
|
+
429: {
|
|
2587
|
+
headers: {
|
|
2588
|
+
[name: string]: unknown;
|
|
2589
|
+
};
|
|
2590
|
+
content: {
|
|
2591
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2592
|
+
};
|
|
2593
|
+
};
|
|
2594
|
+
/** @description problem+json. SITE_REGISTRY_WARMING or INDEX_UNAVAILABLE — retry, the request was not wrong. */
|
|
2595
|
+
503: {
|
|
2596
|
+
headers: {
|
|
2597
|
+
[name: string]: unknown;
|
|
2598
|
+
};
|
|
2599
|
+
content: {
|
|
2600
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2601
|
+
};
|
|
2602
|
+
};
|
|
2603
|
+
};
|
|
2604
|
+
};
|
|
2404
2605
|
GetCollections: {
|
|
2405
2606
|
parameters: {
|
|
2406
2607
|
query?: never;
|
|
@@ -2485,7 +2686,7 @@ export interface operations {
|
|
|
2485
2686
|
GetCollection: {
|
|
2486
2687
|
parameters: {
|
|
2487
2688
|
query?: {
|
|
2488
|
-
/** @description Free-text search. Omit to browse rather than search. */
|
|
2689
|
+
/** @description Free-text search. Omit to browse rather than search; a q of separators only (such as !!!) browses too. A search answers with search (how it was answered), and may set queryCorrection and redirect. */
|
|
2489
2690
|
q?: string;
|
|
2490
2691
|
/** @description 1-based page. page × pageSize must not exceed 10000 (default pageSize 24, max 100). */
|
|
2491
2692
|
page?: number;
|
|
@@ -2497,6 +2698,8 @@ export interface operations {
|
|
|
2497
2698
|
filter?: {
|
|
2498
2699
|
[key: string]: string;
|
|
2499
2700
|
};
|
|
2701
|
+
/** @description Where a search came from, for measurement only: typed, suggestion, recent or other. It never changes the answer. Anything else is ignored with an ORIGIN_UNKNOWN warning. */
|
|
2702
|
+
origin?: "other" | "recent" | "suggestion" | "typed";
|
|
2500
2703
|
};
|
|
2501
2704
|
header: {
|
|
2502
2705
|
/** @description Publishable, preview or secret site key. Required on every request; secret keys are server-side only. */
|
|
@@ -2661,6 +2864,91 @@ export interface operations {
|
|
|
2661
2864
|
};
|
|
2662
2865
|
};
|
|
2663
2866
|
};
|
|
2867
|
+
TrackSearchEvents: {
|
|
2868
|
+
parameters: {
|
|
2869
|
+
query?: never;
|
|
2870
|
+
header: {
|
|
2871
|
+
/** @description Publishable, preview or secret site key. Required on every request; secret keys are server-side only. */
|
|
2872
|
+
"X-Site-Key": string;
|
|
2873
|
+
/** @description Market code (e.g. "se"). Omit for the site's default market. */
|
|
2874
|
+
"X-Market"?: string;
|
|
2875
|
+
/** @description BCP-47 language tag. Omit to use the market's language. */
|
|
2876
|
+
"Accept-Language"?: string;
|
|
2877
|
+
};
|
|
2878
|
+
path?: never;
|
|
2879
|
+
cookie?: never;
|
|
2880
|
+
};
|
|
2881
|
+
requestBody: {
|
|
2882
|
+
content: {
|
|
2883
|
+
"application/json": components["schemas"]["SearchEventsRequest"];
|
|
2884
|
+
};
|
|
2885
|
+
};
|
|
2886
|
+
responses: {
|
|
2887
|
+
/** @description Accepted */
|
|
2888
|
+
202: {
|
|
2889
|
+
headers: {
|
|
2890
|
+
[name: string]: unknown;
|
|
2891
|
+
};
|
|
2892
|
+
content: {
|
|
2893
|
+
"application/json": components["schemas"]["SearchEventsResponse"];
|
|
2894
|
+
};
|
|
2895
|
+
};
|
|
2896
|
+
/** @description problem+json. EVENTS_INVALID (not JSON, not { "events": [ … ] }, no event or more than 50, or a body over 64 KB; nothing is stored), or MARKET_UNKNOWN. One bad event is not a 400: it is listed in the 202's rejected. */
|
|
2897
|
+
400: {
|
|
2898
|
+
headers: {
|
|
2899
|
+
[name: string]: unknown;
|
|
2900
|
+
};
|
|
2901
|
+
content: {
|
|
2902
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2903
|
+
};
|
|
2904
|
+
};
|
|
2905
|
+
/** @description problem+json. SITE_KEY_MISSING or SITE_KEY_INVALID. */
|
|
2906
|
+
401: {
|
|
2907
|
+
headers: {
|
|
2908
|
+
[name: string]: unknown;
|
|
2909
|
+
};
|
|
2910
|
+
content: {
|
|
2911
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2912
|
+
};
|
|
2913
|
+
};
|
|
2914
|
+
/** @description problem+json. SECRET_KEY_FROM_BROWSER: a secret key was sent from a browser. */
|
|
2915
|
+
403: {
|
|
2916
|
+
headers: {
|
|
2917
|
+
[name: string]: unknown;
|
|
2918
|
+
};
|
|
2919
|
+
content: {
|
|
2920
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2921
|
+
};
|
|
2922
|
+
};
|
|
2923
|
+
/** @description problem+json. SITE_INACTIVE, or NOT_FOUND for an unrouted path. */
|
|
2924
|
+
404: {
|
|
2925
|
+
headers: {
|
|
2926
|
+
[name: string]: unknown;
|
|
2927
|
+
};
|
|
2928
|
+
content: {
|
|
2929
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2930
|
+
};
|
|
2931
|
+
};
|
|
2932
|
+
/** @description problem+json. RATE_LIMITED; retryAfterSeconds and the Retry-After header say how long to wait. */
|
|
2933
|
+
429: {
|
|
2934
|
+
headers: {
|
|
2935
|
+
[name: string]: unknown;
|
|
2936
|
+
};
|
|
2937
|
+
content: {
|
|
2938
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2939
|
+
};
|
|
2940
|
+
};
|
|
2941
|
+
/** @description problem+json. SITE_REGISTRY_WARMING or INDEX_UNAVAILABLE — retry, the request was not wrong. */
|
|
2942
|
+
503: {
|
|
2943
|
+
headers: {
|
|
2944
|
+
[name: string]: unknown;
|
|
2945
|
+
};
|
|
2946
|
+
content: {
|
|
2947
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
2948
|
+
};
|
|
2949
|
+
};
|
|
2950
|
+
};
|
|
2951
|
+
};
|
|
2664
2952
|
GetOrder: {
|
|
2665
2953
|
parameters: {
|
|
2666
2954
|
query?: never;
|
|
@@ -2751,7 +3039,7 @@ export interface operations {
|
|
|
2751
3039
|
ListProducts: {
|
|
2752
3040
|
parameters: {
|
|
2753
3041
|
query?: {
|
|
2754
|
-
/** @description Free-text search. Omit to browse rather than search. */
|
|
3042
|
+
/** @description Free-text search. Omit to browse rather than search; a q of separators only (such as !!!) browses too. A search answers with search (how it was answered), and may set queryCorrection and redirect. */
|
|
2755
3043
|
q?: string;
|
|
2756
3044
|
/** @description 1-based page. page × pageSize must not exceed 10000 (default pageSize 24, max 100). */
|
|
2757
3045
|
page?: number;
|
|
@@ -2763,6 +3051,8 @@ export interface operations {
|
|
|
2763
3051
|
filter?: {
|
|
2764
3052
|
[key: string]: string;
|
|
2765
3053
|
};
|
|
3054
|
+
/** @description Where a search came from, for measurement only: typed, suggestion, recent or other. It never changes the answer. Anything else is ignored with an ORIGIN_UNKNOWN warning. */
|
|
3055
|
+
origin?: "other" | "recent" | "suggestion" | "typed";
|
|
2766
3056
|
/** @description Narrow to a collection by slug path or id. An unknown one is answered with a COLLECTION_UNKNOWN warning, not a 404. */
|
|
2767
3057
|
collection?: string;
|
|
2768
3058
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asstio-dev/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Typed client for the Asstio Storefront API (generated from OpenAPI).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test": "vitest run",
|
|
22
22
|
"test:browser": "playwright test -c browser/playwright.config.ts",
|
|
23
23
|
"check": "npm run generate && npm run typecheck-examples && npm test && git diff --exit-code -- src/schema.d.ts && test -z \"$(git status --porcelain -- src/schema.d.ts)\"",
|
|
24
|
-
"smoke": "node --input-type=module -e \"import(\\\"./dist/index.js\\\").then(m => { for (const f of [\\\"createStorefrontClient\\\", \\\"filterQuery\\\", \\\"encodeFilterValues\\\", \\\"decodeFilterValues\\\", \\\"pictureSources\\\", \\\"mediaUrl\\\", \\\"formatImage\\\", \\\"styleToCss\\\", \\\"startCheckout\\\", \\\"syncCheckout\\\", \\\"completeCheckout\\\", \\\"getCheckoutStatus\\\", \\\"getOrder\\\", \\\"awaitCompletion\\\", \\\"mountCheckout\\\", \\\"productJsonLd\\\", \\\"gtinJsonLd\\\", \\\"breadcrumbJsonLd\\\", \\\"productHead\\\", \\\"collectionHead\\\", \\\"brandHead\\\", \\\"toNextMetadata\\\", \\\"jsonLdScript\\\", \\\"SeoError\\\", \\\"productFacts\\\", \\\"toGa4Item\\\", \\\"toGa4Ecommerce\\\", \\\"AnalyticsError\\\"]) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f) })\""
|
|
24
|
+
"smoke": "node --input-type=module -e \"import(\\\"./dist/index.js\\\").then(m => { for (const f of [\\\"createStorefrontClient\\\", \\\"filterQuery\\\", \\\"encodeFilterValues\\\", \\\"decodeFilterValues\\\", \\\"pictureSources\\\", \\\"mediaUrl\\\", \\\"formatImage\\\", \\\"styleToCss\\\", \\\"startCheckout\\\", \\\"syncCheckout\\\", \\\"completeCheckout\\\", \\\"getCheckoutStatus\\\", \\\"liveShippingFor\\\", \\\"getOrder\\\", \\\"awaitCompletion\\\", \\\"mountCheckout\\\", \\\"productJsonLd\\\", \\\"gtinJsonLd\\\", \\\"breadcrumbJsonLd\\\", \\\"productHead\\\", \\\"collectionHead\\\", \\\"brandHead\\\", \\\"toNextMetadata\\\", \\\"jsonLdScript\\\", \\\"SeoError\\\", \\\"productFacts\\\", \\\"toGa4Item\\\", \\\"toGa4Ecommerce\\\", \\\"AnalyticsError\\\", \\\"trackSearchEvents\\\"]) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f) })\""
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"openapi-fetch": "0.17.0"
|