@doswiftly/storefront-sdk 14.0.0 → 15.1.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/CHANGELOG.md +55 -0
- package/dist/core/auth/auth-client.d.ts +13 -1
- package/dist/core/auth/auth-client.d.ts.map +1 -1
- package/dist/core/auth/auth-client.js +16 -1
- package/dist/core/auth/types.d.ts +18 -52
- package/dist/core/auth/types.d.ts.map +1 -1
- package/dist/core/auth/types.js +0 -3
- package/dist/core/cart/cart-client.d.ts +50 -1
- package/dist/core/cart/cart-client.d.ts.map +1 -1
- package/dist/core/cart/cart-client.js +63 -1
- package/dist/core/cart/types.d.ts +75 -391
- package/dist/core/cart/types.d.ts.map +1 -1
- package/dist/core/cart/types.js +0 -8
- package/dist/core/generated/operation-types.d.ts +4428 -0
- package/dist/core/generated/operation-types.d.ts.map +1 -0
- package/dist/core/generated/operation-types.js +4 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/operations/auth.d.ts +7 -0
- package/dist/core/operations/auth.d.ts.map +1 -1
- package/dist/core/operations/auth.js +68 -0
- package/dist/core/operations/cart.d.ts +30 -0
- package/dist/core/operations/cart.d.ts.map +1 -1
- package/dist/core/operations/cart.js +147 -0
- package/dist/react/hooks/use-cart.d.ts +78 -0
- package/dist/react/hooks/use-cart.d.ts.map +1 -0
- package/dist/react/hooks/use-cart.js +121 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/package.json +7 -1
|
@@ -1,421 +1,105 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cart types —
|
|
2
|
+
* Cart types — derived from the generated GraphQL operation types.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Output types alias the generated `*Fragment` types; input types and enums
|
|
5
|
+
* re-export the generated schema types. This file only assigns stable, public
|
|
6
|
+
* names — it does NOT define shapes.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
export interface Money {
|
|
10
|
-
amount: string;
|
|
11
|
-
currencyCode: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ImageThumbnail {
|
|
14
|
-
id: string | null;
|
|
15
|
-
url: string;
|
|
16
|
-
altText: string | null;
|
|
17
|
-
width: number | null;
|
|
18
|
-
height: number | null;
|
|
19
|
-
thumbhash: string | null;
|
|
20
|
-
}
|
|
21
|
-
export interface PageInfo {
|
|
22
|
-
hasNextPage: boolean;
|
|
23
|
-
hasPreviousPage: boolean;
|
|
24
|
-
startCursor: string | null;
|
|
25
|
-
endCursor: string | null;
|
|
26
|
-
}
|
|
27
|
-
export interface CartCost {
|
|
28
|
-
total: Money;
|
|
29
|
-
subtotal: Money;
|
|
30
|
-
totalTax: Money | null;
|
|
31
|
-
totalDuty: Money | null;
|
|
32
|
-
checkoutCharge: Money | null;
|
|
33
|
-
}
|
|
34
|
-
export interface CartLineCost {
|
|
35
|
-
pricePerUnit: Money;
|
|
36
|
-
subtotal: Money;
|
|
37
|
-
total: Money;
|
|
38
|
-
compareAtPricePerUnit: Money | null;
|
|
39
|
-
}
|
|
40
|
-
export interface SelectedOption {
|
|
41
|
-
name: string;
|
|
42
|
-
value: string;
|
|
43
|
-
}
|
|
44
|
-
export interface ProductVariantWeight {
|
|
45
|
-
value: number;
|
|
46
|
-
unit: string;
|
|
47
|
-
}
|
|
48
|
-
export interface ProductVariant {
|
|
49
|
-
id: string;
|
|
50
|
-
title: string;
|
|
51
|
-
sku: string | null;
|
|
52
|
-
price: Money;
|
|
53
|
-
compareAtPrice: Money | null;
|
|
54
|
-
isAvailable: boolean;
|
|
55
|
-
availableStock: number | null;
|
|
56
|
-
image: ImageThumbnail | null;
|
|
57
|
-
selectedOptions: SelectedOption[];
|
|
58
|
-
barcode: string | null;
|
|
59
|
-
weight: ProductVariantWeight | null;
|
|
60
|
-
sortOrder: number | null;
|
|
61
|
-
}
|
|
62
|
-
export interface AttributeSelection {
|
|
63
|
-
attributeDefinitionId: string;
|
|
64
|
-
attributeName: string;
|
|
65
|
-
type: string;
|
|
66
|
-
fillingMode: string;
|
|
67
|
-
billingMode: string | null;
|
|
68
|
-
optionId: string | null;
|
|
69
|
-
optionLabel: string | null;
|
|
70
|
-
optionIds: string[] | null;
|
|
71
|
-
textValue: string | null;
|
|
72
|
-
surchargeAmount: number;
|
|
73
|
-
surchargeType: string | null;
|
|
74
|
-
taxClassId: string | null;
|
|
75
|
-
linkedVariantId: string | null;
|
|
76
|
-
}
|
|
77
|
-
export interface CartLine {
|
|
78
|
-
id: string;
|
|
79
|
-
quantity: number;
|
|
80
|
-
variant: ProductVariant;
|
|
81
|
-
cost: CartLineCost;
|
|
82
|
-
attributes: Array<{
|
|
83
|
-
key: string;
|
|
84
|
-
value: string | null;
|
|
85
|
-
}>;
|
|
86
|
-
attributeSelections: AttributeSelection[];
|
|
87
|
-
productId: string | null;
|
|
88
|
-
productTitle: string | null;
|
|
89
|
-
productHandle: string | null;
|
|
90
|
-
productType: string | null;
|
|
91
|
-
}
|
|
92
|
-
export interface CartLineEdge {
|
|
93
|
-
cursor: string;
|
|
94
|
-
node: CartLine;
|
|
95
|
-
}
|
|
96
|
-
export interface CartLineConnection {
|
|
97
|
-
edges: CartLineEdge[];
|
|
98
|
-
nodes: CartLine[];
|
|
99
|
-
pageInfo: PageInfo;
|
|
100
|
-
totalCount: number;
|
|
101
|
-
}
|
|
102
|
-
export interface CartDiscountCode {
|
|
103
|
-
code: string;
|
|
104
|
-
isApplicable: boolean;
|
|
105
|
-
}
|
|
106
|
-
export interface CartDiscountAllocation {
|
|
107
|
-
discountCode: string;
|
|
108
|
-
amount: Money;
|
|
109
|
-
}
|
|
110
|
-
export interface CartBuyerIdentity {
|
|
111
|
-
email: string | null;
|
|
112
|
-
phone: string | null;
|
|
113
|
-
countryCode: string | null;
|
|
114
|
-
}
|
|
115
|
-
export interface Cart {
|
|
116
|
-
id: string;
|
|
117
|
-
checkoutUrl: string | null;
|
|
118
|
-
totalQuantity: number;
|
|
119
|
-
note: string | null;
|
|
120
|
-
createdAt: string;
|
|
121
|
-
updatedAt: string;
|
|
122
|
-
cost: CartCost;
|
|
123
|
-
lines: CartLineConnection;
|
|
124
|
-
buyerIdentity: CartBuyerIdentity | null;
|
|
125
|
-
discountCodes: CartDiscountCode[];
|
|
126
|
-
discountAllocations: CartDiscountAllocation[];
|
|
127
|
-
attributes: Array<{
|
|
128
|
-
key: string;
|
|
129
|
-
value: string | null;
|
|
130
|
-
}>;
|
|
131
|
-
email: string | null;
|
|
132
|
-
phone: string | null;
|
|
133
|
-
shippingAddress: MailingAddress | null;
|
|
134
|
-
billingAddress: MailingAddress | null;
|
|
135
|
-
selectedShippingMethod: CartShippingMethod | null;
|
|
136
|
-
selectedPaymentMethod: CartSelectedPaymentMethod | null;
|
|
137
|
-
appliedGiftCards: CartAppliedGiftCard[];
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Customer-filled attribute selection submitted with a cart line.
|
|
8
|
+
* SSOT chain: backend storefront-graphql schema → `core/operations/*.ts`
|
|
9
|
+
* → `src/core/generated/operation-types.ts` (regenerate with `pnpm codegen`).
|
|
141
10
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* snapshots name/surcharge/taxRate, and stores them on `cart_items.attribute_selections`.
|
|
145
|
-
*
|
|
146
|
-
* Faza 1: SELECT/RADIO/CHECKBOX use `optionId`; TEXT/TEXTAREA/NUMBER/DATE use `textValue`.
|
|
147
|
-
* Faza 2 will enable `optionIds` for MULTI_SELECT.
|
|
11
|
+
* Never hand-edit a shape here — if a type looks wrong, fix the operation /
|
|
12
|
+
* schema and regenerate. `cart-operations-drift` test guards the operations.
|
|
148
13
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
export
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
export
|
|
167
|
-
id: string;
|
|
168
|
-
quantity: number;
|
|
169
|
-
attributes?: Array<{
|
|
170
|
-
key: string;
|
|
171
|
-
value: string;
|
|
172
|
-
}>;
|
|
173
|
-
/** Faza 1 — pass `null` to preserve, `[]` to clear, or array to replace selections. */
|
|
174
|
-
attributeSelections?: CartAttributeSelectionInput[] | null;
|
|
175
|
-
}
|
|
176
|
-
export interface CartCreateInput {
|
|
177
|
-
lines?: CartLineInput[];
|
|
178
|
-
buyerIdentity?: CartBuyerIdentityInput;
|
|
179
|
-
discountCodes?: string[];
|
|
180
|
-
note?: string;
|
|
181
|
-
attributes?: Array<{
|
|
182
|
-
key: string;
|
|
183
|
-
value: string;
|
|
184
|
-
}>;
|
|
185
|
-
/** Phase 3 Task 3.2 — initial checkout fields w jednym round-trip. */
|
|
186
|
-
email?: string;
|
|
187
|
-
shippingAddress?: CartAddressInput;
|
|
188
|
-
}
|
|
189
|
-
export interface CartBuyerIdentityInput {
|
|
190
|
-
email?: string;
|
|
191
|
-
phone?: string;
|
|
192
|
-
/** ISO 3166-1 alpha-2 country code (e.g. 'PL', 'DE'). */
|
|
193
|
-
countryCode?: string;
|
|
194
|
-
customerId?: string;
|
|
195
|
-
/** ISO 639-1 preferred language code (e.g. 'PL', 'EN'). Accepted by backend; not yet persisted server-side. */
|
|
196
|
-
languageCode?: string;
|
|
197
|
-
}
|
|
14
|
+
import type { CartFragment, CartCostFragment, CartLineFragment, CartLineCostFragment, ProductVariantFragment, MoneyFragment, ImageThumbnailFragment, SelectedOptionFragment, AttributeSelectionFragment, PageInfoFragment, CartBuyerIdentityFragment, CartDiscountCodeFragment, CartDiscountAllocationFragment, CartWarningFragment, CartShippingMethodFragment, CartAppliedGiftCardFragment, CartSelectedPaymentMethodFragment, OrderFragment, PaymentSessionFragment, CartValidateDiscountCodeQuery, AvailableShippingMethodFragment, AvailablePaymentMethodsFragment, PaymentMethodFragment, UserErrorFragment, AvailableShippingMethodsPayload as AvailableShippingMethodsPayloadSchema } from '../generated/operation-types';
|
|
15
|
+
export type Money = MoneyFragment;
|
|
16
|
+
export type ImageThumbnail = ImageThumbnailFragment;
|
|
17
|
+
export type PageInfo = PageInfoFragment;
|
|
18
|
+
export type CartCost = CartCostFragment;
|
|
19
|
+
export type CartLineCost = CartLineCostFragment;
|
|
20
|
+
export type SelectedOption = SelectedOptionFragment;
|
|
21
|
+
export type ProductVariant = ProductVariantFragment;
|
|
22
|
+
/** Weight of a product variant — non-null shape of `ProductVariant.weight`. */
|
|
23
|
+
export type ProductVariantWeight = NonNullable<ProductVariantFragment['weight']>;
|
|
24
|
+
export type AttributeSelection = AttributeSelectionFragment;
|
|
25
|
+
export type CartLine = CartLineFragment;
|
|
26
|
+
/** Cart line list as returned by the cart query (`totalCount` + `nodes` + `pageInfo`). */
|
|
27
|
+
export type CartLineConnection = CartFragment['lines'];
|
|
28
|
+
export type CartBuyerIdentity = CartBuyerIdentityFragment;
|
|
29
|
+
export type CartDiscountCode = CartDiscountCodeFragment;
|
|
30
|
+
export type CartDiscountAllocation = CartDiscountAllocationFragment;
|
|
31
|
+
export type Cart = CartFragment;
|
|
198
32
|
/**
|
|
199
33
|
* Non-blocking cart warning surfaced by mutations alongside a successful
|
|
200
|
-
* payload
|
|
201
|
-
* partial availability, etc.) for the storefront UI to render as soft warnings.
|
|
202
|
-
*
|
|
203
|
-
* Mirror of GraphQL `CartWarning` type.
|
|
34
|
+
* payload — advisory hints (low stock, partial availability, etc.) for the UI.
|
|
204
35
|
*/
|
|
205
|
-
export
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
36
|
+
export type CartWarning = CartWarningFragment;
|
|
37
|
+
/** Shipping method selected on a cart — returned from `cart.selectedShippingMethod`. */
|
|
38
|
+
export type CartShippingMethod = CartShippingMethodFragment;
|
|
39
|
+
/** Gift card applied to the cart — balance debited atomically at `cartComplete`. */
|
|
40
|
+
export type CartAppliedGiftCard = CartAppliedGiftCardFragment;
|
|
41
|
+
/** Payment method (integration provider) selected on the cart. */
|
|
42
|
+
export type CartSelectedPaymentMethod = CartSelectedPaymentMethodFragment;
|
|
210
43
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
44
|
+
* Single payment method enabled for the shop — returned by
|
|
45
|
+
* `CartClient.getAvailablePaymentMethods()` inside the payload `methods[]`
|
|
46
|
+
* and `defaultMethod` slots. Same shape as `CartSelectedPaymentMethod`,
|
|
47
|
+
* different framing (one of the "available" choices vs the chosen one).
|
|
214
48
|
*/
|
|
215
|
-
export
|
|
216
|
-
id: string | null;
|
|
217
|
-
firstName: string | null;
|
|
218
|
-
lastName: string | null;
|
|
219
|
-
name: string | null;
|
|
220
|
-
company: string | null;
|
|
221
|
-
streetLine1: string | null;
|
|
222
|
-
streetLine2: string | null;
|
|
223
|
-
city: string | null;
|
|
224
|
-
state: string | null;
|
|
225
|
-
stateCode: string | null;
|
|
226
|
-
country: string | null;
|
|
227
|
-
countryCode: string | null;
|
|
228
|
-
postalCode: string | null;
|
|
229
|
-
phone: string | null;
|
|
230
|
-
isDefault: boolean | null;
|
|
231
|
-
}
|
|
49
|
+
export type PaymentMethod = PaymentMethodFragment;
|
|
232
50
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* (
|
|
51
|
+
* Result of the shop-level "available payment methods" query — returned by
|
|
52
|
+
* `CartClient.getAvailablePaymentMethods()`. Carries the methods list plus
|
|
53
|
+
* the merchant-flagged `defaultMethod` (may be null when none is configured).
|
|
236
54
|
*/
|
|
237
|
-
export
|
|
238
|
-
firstName?: string;
|
|
239
|
-
lastName?: string;
|
|
240
|
-
company?: string;
|
|
241
|
-
streetLine1: string;
|
|
242
|
-
streetLine2?: string;
|
|
243
|
-
city: string;
|
|
244
|
-
state?: string;
|
|
245
|
-
country: string;
|
|
246
|
-
postalCode: string;
|
|
247
|
-
phone?: string;
|
|
248
|
-
}
|
|
55
|
+
export type AvailablePaymentMethods = AvailablePaymentMethodsFragment;
|
|
249
56
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
57
|
+
* Single shipping method offered for the destination + cart shape — element of
|
|
58
|
+
* `AvailableShippingMethodsPayload.methods`. `deliveryType` decides the UI:
|
|
59
|
+
* `HOME` renders the standard form, `PICKUP_POINT` / `LOCKER` triggers the
|
|
60
|
+
* pickup picker.
|
|
252
61
|
*/
|
|
253
|
-
export
|
|
254
|
-
handle: string;
|
|
255
|
-
title: string;
|
|
256
|
-
price: Money;
|
|
257
|
-
}
|
|
62
|
+
export type AvailableShippingMethod = AvailableShippingMethodFragment;
|
|
258
63
|
/**
|
|
259
|
-
*
|
|
260
|
-
*
|
|
64
|
+
* Result of the cart-aware "available shipping methods" query — returned by
|
|
65
|
+
* `CartClient.getAvailableShippingMethods()`. Carries the methods list, the
|
|
66
|
+
* best free-shipping progress across all methods, and `userErrors[]` populated
|
|
67
|
+
* by the backend with translated messages (e.g. `DIGITAL_ONLY_NO_SHIPPING`
|
|
68
|
+
* when the cart contains only non-physical items). Branch on
|
|
69
|
+
* `result.userErrors[0].code`; the `message` is already localized per the
|
|
70
|
+
* request's `Accept-Language`.
|
|
261
71
|
*/
|
|
262
|
-
export
|
|
263
|
-
maskedCode: string;
|
|
264
|
-
lastCharacters: string;
|
|
265
|
-
appliedAmount: Money;
|
|
266
|
-
remainingBalance: Money;
|
|
267
|
-
}
|
|
72
|
+
export type AvailableShippingMethodsPayload = AvailableShippingMethodsPayloadSchema;
|
|
268
73
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
74
|
+
* `userErrors[]` envelope element. Surfaces machine-readable `code`
|
|
75
|
+
* alongside a human message — branch on `code` for translation / retry
|
|
76
|
+
* logic, never on `message`.
|
|
271
77
|
*/
|
|
272
|
-
export
|
|
273
|
-
id: string;
|
|
274
|
-
name: string;
|
|
275
|
-
provider: string;
|
|
276
|
-
type: PaymentMethodType;
|
|
277
|
-
icon: string | null;
|
|
278
|
-
description: string | null;
|
|
279
|
-
isDefault: boolean | null;
|
|
280
|
-
supportedCurrencies: string[] | null;
|
|
281
|
-
position: number | null;
|
|
282
|
-
}
|
|
78
|
+
export type UserError = UserErrorFragment;
|
|
283
79
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
* not present until their respective providers are deployed — `OTHER` is
|
|
288
|
-
* the fallback for any registered-but-unmapped provider.
|
|
289
|
-
*/
|
|
290
|
-
export type PaymentMethodType = 'CARD' | 'BLIK' | 'BANK_TRANSFER' | 'CASH_ON_DELIVERY' | 'OTHER';
|
|
291
|
-
export interface CartSetShippingAddressInput {
|
|
292
|
-
cartId: string;
|
|
293
|
-
address: CartAddressInput;
|
|
294
|
-
}
|
|
295
|
-
export interface CartSetBillingAddressInput {
|
|
296
|
-
cartId: string;
|
|
297
|
-
address: CartAddressInput;
|
|
298
|
-
}
|
|
299
|
-
export interface CartSelectShippingMethodInput {
|
|
300
|
-
cartId: string;
|
|
301
|
-
shippingMethodId: string;
|
|
302
|
-
}
|
|
303
|
-
export interface CartSelectPaymentMethodInput {
|
|
304
|
-
cartId: string;
|
|
305
|
-
paymentMethodId: string;
|
|
306
|
-
}
|
|
307
|
-
export interface CartApplyGiftCardInput {
|
|
308
|
-
cartId: string;
|
|
309
|
-
giftCardCode: string;
|
|
310
|
-
}
|
|
311
|
-
export interface CartRemoveGiftCardInput {
|
|
312
|
-
cartId: string;
|
|
313
|
-
giftCardCode: string;
|
|
314
|
-
}
|
|
315
|
-
export interface CartUpdateGiftCardRecipientInput {
|
|
316
|
-
cartId: string;
|
|
317
|
-
lineItemId: string;
|
|
318
|
-
recipientEmail?: string;
|
|
319
|
-
recipientName?: string;
|
|
320
|
-
message?: string;
|
|
321
|
-
}
|
|
322
|
-
export interface CartCompleteInput {
|
|
323
|
-
cartId: string;
|
|
324
|
-
idempotencyKey?: string;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Order surface — matches SSOT `Order` fragment shape (status + totals + lifecycle
|
|
328
|
-
* timestamps + shipping address + payment capability signal). The
|
|
329
|
-
* `canCreatePayment` + `paymentMethodType` fields let the storefront decide
|
|
80
|
+
* Order surface returned by `cartComplete` and the `orderByToken` query —
|
|
81
|
+
* status + totals + lifecycle timestamps + payment capability signals.
|
|
82
|
+
* `canCreatePayment` + `paymentMethodType` let the storefront pick the
|
|
330
83
|
* post-completion payment flow without hard-coded provider checks.
|
|
331
|
-
*
|
|
332
|
-
* Line items NOT included — query them via the separate `order(id).lineItems`
|
|
333
|
-
* field when needed (Relay Connection, paginated).
|
|
334
84
|
*/
|
|
335
|
-
export
|
|
336
|
-
id: string;
|
|
337
|
-
orderNumber: string;
|
|
338
|
-
totals: {
|
|
339
|
-
total: Money;
|
|
340
|
-
subtotal: Money;
|
|
341
|
-
totalTax: Money | null;
|
|
342
|
-
totalShipping: Money | null;
|
|
343
|
-
};
|
|
344
|
-
status: string;
|
|
345
|
-
paymentStatus: string;
|
|
346
|
-
fulfillmentStatus: string;
|
|
347
|
-
processedAt: string;
|
|
348
|
-
confirmedAt: string | null;
|
|
349
|
-
cancelledAt: string | null;
|
|
350
|
-
expiredAt: string | null;
|
|
351
|
-
shippingAddress: MailingAddress | null;
|
|
352
|
-
itemCount: number;
|
|
353
|
-
canCreatePayment: boolean;
|
|
354
|
-
paymentMethodType: PaymentMethodType;
|
|
355
|
-
}
|
|
85
|
+
export type Order = OrderFragment;
|
|
356
86
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* - `INSTANT_DIRECT` — already settled with no UI, read `PaymentSession.status`
|
|
361
|
-
* - `OFFLINE_MANUAL` — never returned (`order.canCreatePayment` is false for offline methods)
|
|
362
|
-
*
|
|
363
|
-
* Mirror of GraphQL `PaymentInitiationFlow` enum.
|
|
87
|
+
* Initiated payment session for an order — returned by `CartClient.createPayment`.
|
|
88
|
+
* Branch on `flow`: `redirectUrl` for redirect, `clientSecret` for an embedded
|
|
89
|
+
* widget, `status` for an instant settlement.
|
|
364
90
|
*/
|
|
365
|
-
export type
|
|
91
|
+
export type PaymentSession = PaymentSessionFragment;
|
|
92
|
+
/** Read-only discount preview returned by `CartClient.validateDiscountCode`. */
|
|
93
|
+
export type DiscountValidationResult = CartValidateDiscountCodeQuery['cartValidateDiscountCode'];
|
|
94
|
+
export type DiscountInfo = NonNullable<DiscountValidationResult['discount']>;
|
|
95
|
+
export type DiscountValidationError = NonNullable<DiscountValidationResult['error']>;
|
|
96
|
+
export type { CartCreateInput, CartLineInput, CartLineUpdateInput, CartBuyerIdentityInput, CartAddressInput, CartAttributeInput, CartCompleteInput, CartApplyGiftCardInput, CartRemoveGiftCardInput, CartSelectPaymentMethodInput, CartSelectShippingMethodInput, CartSetBillingAddressInput, CartSetShippingAddressInput, CartUpdateGiftCardRecipientInput, PaymentCreateInput, ShippingAddressInput, DeliveryType, AttributeSelectionInput as CartAttributeSelectionInput, PaymentMethodType, PaymentInitiationFlow, DiscountApplicationType, DiscountErrorCode, CurrencyCode, CountryCode, LanguageCode, ProductTypeEnum, WeightUnit, CartWarningCode, AttributeType, AttributeFillingMode, AttributeBillingMode, AttributeOptionSurchargeType, StorefrontOrderStatus, OrderPaymentStatus, OrderFulfillmentStatus, } from '../generated/operation-types';
|
|
366
97
|
/**
|
|
367
98
|
* Machine-readable error code surfaced when `createPayment` fails. The call
|
|
368
99
|
* throws a `StorefrontError` on `userErrors` — read `.userErrors[0].code` off
|
|
369
100
|
* the thrown error and compare against these values.
|
|
101
|
+
*
|
|
102
|
+
* This is a hand-curated `userErrors[].code` contract, not a GraphQL enum.
|
|
370
103
|
*/
|
|
371
104
|
export type PaymentErrorCode = 'ORDER_NOT_FOUND' | 'ORDER_ALREADY_PAID' | 'ORDER_NOT_PAYABLE' | 'PAYMENT_PROVIDER_NOT_CONFIGURED' | 'RETURN_URL_INVALID' | 'INVALID_ID_FORMAT' | 'PAYMENT_FAILED';
|
|
372
|
-
/**
|
|
373
|
-
* Initiated payment session for an order — returned by `CartClient.createPayment`.
|
|
374
|
-
* Mirror of GraphQL `PaymentSession`. Branch on `flow` to decide the next step
|
|
375
|
-
* (`redirectUrl` for redirect, `clientSecret` for an embedded widget, `status`
|
|
376
|
-
* for an instant settlement).
|
|
377
|
-
*/
|
|
378
|
-
export interface PaymentSession {
|
|
379
|
-
id: string;
|
|
380
|
-
orderId: string;
|
|
381
|
-
flow: PaymentInitiationFlow;
|
|
382
|
-
/** Provider code that created the session (e.g. `PAYU`). */
|
|
383
|
-
provider: string;
|
|
384
|
-
/** Hosted gateway URL — present for the `ONLINE_REDIRECT` flow. */
|
|
385
|
-
redirectUrl: string | null;
|
|
386
|
-
/** In-page widget token — present for the `ONLINE_EMBEDDED` flow. */
|
|
387
|
-
clientSecret: string | null;
|
|
388
|
-
/** Order payment status at session creation. */
|
|
389
|
-
status: string;
|
|
390
|
-
/** When `redirectUrl` / `clientSecret` expires (ISO 8601), if the gateway sets a TTL. */
|
|
391
|
-
expiresAt: string | null;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Input for `CartClient.createPayment`. `returnUrl` / `cancelUrl` are optional —
|
|
395
|
-
* when supplied they must point to a verified domain of the shop (the server
|
|
396
|
-
* rejects others to prevent open redirects).
|
|
397
|
-
*/
|
|
398
|
-
export interface PaymentCreateInput {
|
|
399
|
-
orderId: string;
|
|
400
|
-
returnUrl?: string;
|
|
401
|
-
cancelUrl?: string;
|
|
402
|
-
}
|
|
403
|
-
export type DiscountErrorCode = 'NOT_FOUND' | 'INACTIVE' | 'NOT_STARTED' | 'EXPIRED' | 'USAGE_LIMIT_REACHED' | 'CUSTOMER_USAGE_LIMIT_REACHED' | 'CUSTOMER_NOT_ELIGIBLE' | 'MINIMUM_ORDER_NOT_MET' | 'MINIMUM_QUANTITY_NOT_MET' | 'DISCOUNT_COMBINATION_NOT_ALLOWED' | 'SHOP_NOT_FOUND';
|
|
404
|
-
export type DiscountApplicationType = 'PERCENTAGE' | 'FIXED_AMOUNT' | 'FREE_SHIPPING' | 'BUY_X_GET_Y';
|
|
405
|
-
export interface DiscountInfo {
|
|
406
|
-
code: string;
|
|
407
|
-
title: string;
|
|
408
|
-
type: DiscountApplicationType;
|
|
409
|
-
value: number;
|
|
410
|
-
discountAmount: Money | null;
|
|
411
|
-
}
|
|
412
|
-
export interface DiscountValidationError {
|
|
413
|
-
code: DiscountErrorCode;
|
|
414
|
-
message: string;
|
|
415
|
-
}
|
|
416
|
-
export interface DiscountValidationResult {
|
|
417
|
-
isValid: boolean;
|
|
418
|
-
discount: DiscountInfo | null;
|
|
419
|
-
error: DiscountValidationError | null;
|
|
420
|
-
}
|
|
421
105
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"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"}
|
package/dist/core/cart/types.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cart types — manual (no codegen).
|
|
3
|
-
*
|
|
4
|
-
* These match the backend storefront-graphql Cart type.
|
|
5
|
-
* Keep in sync with SSOT: backend/storefront-graphql/types/cart.types.ts
|
|
6
|
-
*
|
|
7
|
-
* Validate with: pnpm test:contract (cart-operations-drift test)
|
|
8
|
-
*/
|
|
9
1
|
export {};
|