@thorprovider/types 7.9.0 → 7.10.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/.turbo/turbo-build.log +18 -18
- package/.turbo/turbo-type-check.log +0 -0
- package/CHANGELOG.md +13 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.mts +123 -3
- package/dist/index.d.ts +123 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/publish.log +60 -0
- package/src/auth.ts +15 -1
- package/src/cart.ts +9 -2
- package/src/checkout.ts +13 -0
- package/src/commerce-provider.ts +32 -1
- package/src/customer.ts +50 -0
- package/src/index.ts +10 -0
- package/src/product.ts +53 -0
package/src/auth.ts
CHANGED
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
* Follows Thor Commerce principles: decoupling, agnostic configuration.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
Customer,
|
|
11
|
+
Address,
|
|
12
|
+
AddressListQuery,
|
|
13
|
+
AddressListResult,
|
|
14
|
+
} from './customer';
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
17
|
* Authentication method configuration
|
|
@@ -418,6 +423,15 @@ export interface AuthProvider {
|
|
|
418
423
|
* @returns List of customer addresses
|
|
419
424
|
*/
|
|
420
425
|
getAddresses(): Promise<Address[]>;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Read one server-filtered page of the customer's address book.
|
|
429
|
+
*
|
|
430
|
+
* Optional so existing providers keep compiling; a provider that cannot
|
|
431
|
+
* serve the query must omit it rather than return a partial or locally
|
|
432
|
+
* filtered page.
|
|
433
|
+
*/
|
|
434
|
+
listAddresses?(query: AddressListQuery): Promise<AddressListResult>;
|
|
421
435
|
|
|
422
436
|
/**
|
|
423
437
|
* Create new address for current customer
|
package/src/cart.ts
CHANGED
|
@@ -190,8 +190,7 @@ export interface Cart {
|
|
|
190
190
|
*/
|
|
191
191
|
guestContact?: GuestContact;
|
|
192
192
|
/** Backend id of the applied shipping method, when one is selected. */
|
|
193
|
-
selectedShippingMethodId?: string;
|
|
194
|
-
/**
|
|
193
|
+
selectedShippingMethodId?: string; /**
|
|
195
194
|
* Backend id of the shipping option the applied method was created from.
|
|
196
195
|
*
|
|
197
196
|
* This is the identity the checkout shipping UI selects (the value passed to
|
|
@@ -206,6 +205,14 @@ export interface Cart {
|
|
|
206
205
|
promotions?: PromotionSummary[];
|
|
207
206
|
/** Platform-specific backend metadata, carried through unchanged. */
|
|
208
207
|
metadata?: Record<string, unknown>;
|
|
208
|
+
/**
|
|
209
|
+
* Buyer email the backend holds on the cart.
|
|
210
|
+
*
|
|
211
|
+
* Authoritative for the guest checkout: the backend requires `cart.email`
|
|
212
|
+
* before a guest order can be completed. Absent when the cart has no contact
|
|
213
|
+
* email yet, which is the state the host must resolve before payment.
|
|
214
|
+
*/
|
|
215
|
+
contactEmail?: string;
|
|
209
216
|
}
|
|
210
217
|
|
|
211
218
|
/**
|
package/src/checkout.ts
CHANGED
|
@@ -127,6 +127,19 @@ export interface CheckoutShippingGroupItem {
|
|
|
127
127
|
quantity?: number;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/** Outcome of requesting a guest-order claim (transfer) for a registered customer. */
|
|
131
|
+
export interface CheckoutOrderClaimRequestResult {
|
|
132
|
+
/** True once the backend accepted the transfer request. */
|
|
133
|
+
requested: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Outcome of accepting a guest-order claim with the email token. */
|
|
137
|
+
export interface CheckoutOrderClaimAcceptResult {
|
|
138
|
+
accepted: boolean;
|
|
139
|
+
/** The order the transfer was applied to. */
|
|
140
|
+
orderId: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
130
143
|
export interface CheckoutAdjustmentPayment {
|
|
131
144
|
id: string;
|
|
132
145
|
kind: 'gift-card' | 'store-credit';
|
package/src/commerce-provider.ts
CHANGED
|
@@ -49,7 +49,11 @@ import type {
|
|
|
49
49
|
GiftCardValidationResult,
|
|
50
50
|
StoreCreditAccountSummary,
|
|
51
51
|
} from './payment';
|
|
52
|
-
import type {
|
|
52
|
+
import type {
|
|
53
|
+
CheckoutGuestContact,
|
|
54
|
+
CheckoutOrderClaimAcceptResult,
|
|
55
|
+
CheckoutOrderClaimRequestResult,
|
|
56
|
+
} from './checkout';
|
|
53
57
|
import type { AuthProvider } from './auth';
|
|
54
58
|
import type { StorefrontContext } from './storefront';
|
|
55
59
|
import type { StockLocation, InventoryLevel, StockValidation, FulfillmentOption } from './stock-location';
|
|
@@ -786,6 +790,33 @@ export interface CommerceProvider {
|
|
|
786
790
|
* @throws {ProviderAPIError} If the backend fails or returns an invalid projection
|
|
787
791
|
*/
|
|
788
792
|
getCheckoutLineProjection?(cartId: string): Promise<CheckoutLineProjection>;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Read the backend's own capability flags, awaited (OPTIONAL).
|
|
796
|
+
*
|
|
797
|
+
* The synchronous `capabilities` property is a snapshot that returns static
|
|
798
|
+
* defaults until a provider's discovery fetch resolves, and those defaults are
|
|
799
|
+
* not authoritative. A caller that gates behaviour on a flag (guest checkout,
|
|
800
|
+
* for example) must use this method so an unread or failed flag can be treated
|
|
801
|
+
* as off.
|
|
802
|
+
*/
|
|
803
|
+
getCapabilities?(): Promise<BackendCapabilities>;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Request the transfer of a guest order to the authenticated customer
|
|
807
|
+
* (OPTIONAL). The backend emails an acceptance token; nothing moves until it
|
|
808
|
+
* is accepted.
|
|
809
|
+
*/
|
|
810
|
+
requestOrderClaim?(orderId: string): Promise<CheckoutOrderClaimRequestResult>;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Accept a previously requested guest-order transfer with its email token
|
|
814
|
+
* (OPTIONAL). Requires no customer session.
|
|
815
|
+
*/
|
|
816
|
+
acceptOrderClaim?(
|
|
817
|
+
orderId: string,
|
|
818
|
+
token: string,
|
|
819
|
+
): Promise<CheckoutOrderClaimAcceptResult>;
|
|
789
820
|
|
|
790
821
|
/**
|
|
791
822
|
* Initiate payment session with provider
|
package/src/customer.ts
CHANGED
|
@@ -34,6 +34,56 @@ export interface Address {
|
|
|
34
34
|
isDefaultBilling?: boolean; // Whether this is the default billing address
|
|
35
35
|
isDefaultShipping?: boolean; // Whether this is the default shipping address
|
|
36
36
|
metadata?: Record<string, unknown>; // Flexible storage for platform-specific extras (label, etc.)
|
|
37
|
+
createdAt?: string; // ISO 8601 timestamp
|
|
38
|
+
updatedAt?: string; // ISO 8601 timestamp; the address book sorts by it
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Filters the address book can request from the provider. */
|
|
42
|
+
export type AddressFilter =
|
|
43
|
+
| 'all'
|
|
44
|
+
| 'personal'
|
|
45
|
+
| 'business'
|
|
46
|
+
| 'default-shipping'
|
|
47
|
+
| 'default-billing'
|
|
48
|
+
| 'verified'
|
|
49
|
+
| 'needs-review'
|
|
50
|
+
| 'delivery-available';
|
|
51
|
+
|
|
52
|
+
/** Server-side ordering supported by the address book. */
|
|
53
|
+
export type AddressSort =
|
|
54
|
+
| 'default-first'
|
|
55
|
+
| 'recent'
|
|
56
|
+
| 'oldest'
|
|
57
|
+
| 'alphabetical'
|
|
58
|
+
| 'city'
|
|
59
|
+
| 'country'
|
|
60
|
+
| 'company';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* One page of the authenticated customer's address book.
|
|
64
|
+
*
|
|
65
|
+
* `total` is the filtered total of the customer's scope, never the page
|
|
66
|
+
* length. `serverQuery` is intentionally absent: it is a presentation fact the
|
|
67
|
+
* host knows, not a domain field.
|
|
68
|
+
*/
|
|
69
|
+
export interface AddressListQuery {
|
|
70
|
+
/** Free-text match over label, recipient, company, postal lines and phone. */
|
|
71
|
+
search?: string;
|
|
72
|
+
filter?: AddressFilter;
|
|
73
|
+
sort?: AddressSort;
|
|
74
|
+
/** 1-based page index. */
|
|
75
|
+
page?: number;
|
|
76
|
+
/** Page size requested from the provider. */
|
|
77
|
+
pageSize?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Result of a server-side address list query. */
|
|
81
|
+
export interface AddressListResult {
|
|
82
|
+
items: Address[];
|
|
83
|
+
total: number;
|
|
84
|
+
page: number;
|
|
85
|
+
pageSize: number;
|
|
86
|
+
hasMore: boolean;
|
|
37
87
|
}
|
|
38
88
|
|
|
39
89
|
/**
|
package/src/index.ts
CHANGED
|
@@ -51,6 +51,8 @@ export type {
|
|
|
51
51
|
CheckoutShippingGroup,
|
|
52
52
|
CheckoutShippingGroupItem,
|
|
53
53
|
CheckoutAdjustmentPayment,
|
|
54
|
+
CheckoutOrderClaimRequestResult,
|
|
55
|
+
CheckoutOrderClaimAcceptResult,
|
|
54
56
|
CheckoutInterruptionKind,
|
|
55
57
|
CheckoutInterruptionAction,
|
|
56
58
|
CheckoutInterruption,
|
|
@@ -118,6 +120,10 @@ export type {
|
|
|
118
120
|
ProductVariant,
|
|
119
121
|
SelectedOption,
|
|
120
122
|
PriceRange,
|
|
123
|
+
ProductHighlight,
|
|
124
|
+
ProductAttribute,
|
|
125
|
+
ProductAttributeGroup,
|
|
126
|
+
ProductAttachment,
|
|
121
127
|
GetProductsOptions,
|
|
122
128
|
ActiveFilter,
|
|
123
129
|
SortOption,
|
|
@@ -186,6 +192,10 @@ export type {
|
|
|
186
192
|
export type {
|
|
187
193
|
Customer,
|
|
188
194
|
Address,
|
|
195
|
+
AddressFilter,
|
|
196
|
+
AddressSort,
|
|
197
|
+
AddressListQuery,
|
|
198
|
+
AddressListResult,
|
|
189
199
|
GetCustomersOptions,
|
|
190
200
|
GetCustomersCallback,
|
|
191
201
|
} from './customer';
|
package/src/product.ts
CHANGED
|
@@ -50,6 +50,10 @@ export interface ProductVariant {
|
|
|
50
50
|
|
|
51
51
|
// Media
|
|
52
52
|
image?: Image; // Variant-specific image
|
|
53
|
+
|
|
54
|
+
// Specifications that differ per variant (e.g. a size chart); absent means
|
|
55
|
+
// the product-level groups apply.
|
|
56
|
+
attributes?: ProductAttributeGroup[];
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
/**
|
|
@@ -60,6 +64,45 @@ export interface PriceRange {
|
|
|
60
64
|
maxVariantPrice: Money;
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
/**
|
|
68
|
+
* One merchandising highlight, rendered as a label/value pair (e.g.
|
|
69
|
+
* "Pantalla" / "14 pulgadas") above the description.
|
|
70
|
+
*/
|
|
71
|
+
export interface ProductHighlight {
|
|
72
|
+
label: string;
|
|
73
|
+
value: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** One row inside an attribute group. */
|
|
77
|
+
export interface ProductAttribute {
|
|
78
|
+
id?: string;
|
|
79
|
+
label: string;
|
|
80
|
+
value: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A titled block of specifications (e.g. "Peso y medidas"). Grouped rather than
|
|
85
|
+
* flat so the product detail can render several tables without inventing titles.
|
|
86
|
+
*/
|
|
87
|
+
export interface ProductAttributeGroup {
|
|
88
|
+
id?: string;
|
|
89
|
+
title: string;
|
|
90
|
+
items: ProductAttribute[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A document attached to the product (datasheet, manual, care guide). */
|
|
94
|
+
export interface ProductAttachment {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
kind?: string;
|
|
98
|
+
language?: string;
|
|
99
|
+
size?: string;
|
|
100
|
+
version?: string;
|
|
101
|
+
url?: string;
|
|
102
|
+
/** Empty or absent means the attachment applies to every variant. */
|
|
103
|
+
variantIds?: string[];
|
|
104
|
+
}
|
|
105
|
+
|
|
63
106
|
/**
|
|
64
107
|
* Main product type - normalized across all providers
|
|
65
108
|
*
|
|
@@ -96,6 +139,16 @@ export interface Product {
|
|
|
96
139
|
productType?: string; // Shopify: productType, Medusa: type, WooCommerce: type (simple/variable)
|
|
97
140
|
vendor?: string; // Shopify-specific, stored in metadata for others
|
|
98
141
|
tags?: string[];
|
|
142
|
+
|
|
143
|
+
// Merchandising detail (optional, provider-dependent). A provider without a
|
|
144
|
+
// source for one of these omits it; the product detail renders the module off
|
|
145
|
+
// instead of showing an empty shell.
|
|
146
|
+
brand?: string;
|
|
147
|
+
model?: string;
|
|
148
|
+
shortDescription?: string;
|
|
149
|
+
highlights?: ProductHighlight[];
|
|
150
|
+
attributes?: ProductAttributeGroup[];
|
|
151
|
+
attachments?: ProductAttachment[];
|
|
99
152
|
|
|
100
153
|
// SEO
|
|
101
154
|
seo?: SEO;
|