@sixtyninecommerce/client 0.32.0 → 0.34.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 +64 -2
- package/dist/build-client.d.ts.map +1 -1
- package/dist/build-client.js +3 -0
- package/dist/build-client.js.map +1 -1
- package/dist/commerce/checkout.d.ts +4 -2
- package/dist/commerce/checkout.d.ts.map +1 -1
- package/dist/commerce/checkout.js +4 -2
- package/dist/commerce/checkout.js.map +1 -1
- package/dist/commerce/customer.d.ts +253 -5
- package/dist/commerce/customer.d.ts.map +1 -1
- package/dist/commerce/customer.js +83 -29
- package/dist/commerce/customer.js.map +1 -1
- package/dist/commerce/index.d.ts +255 -5
- package/dist/commerce/index.d.ts.map +1 -1
- package/dist/commerce/index.js +6 -0
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/money-view.d.ts +33 -0
- package/dist/commerce/money-view.d.ts.map +1 -0
- package/dist/commerce/money-view.js +75 -0
- package/dist/commerce/money-view.js.map +1 -0
- package/dist/commerce/order-access-key.d.ts +29 -0
- package/dist/commerce/order-access-key.d.ts.map +1 -0
- package/dist/commerce/order-access-key.js +38 -0
- package/dist/commerce/order-access-key.js.map +1 -0
- package/dist/commerce/parked-orders.d.ts +3 -3
- package/dist/commerce/parked-orders.d.ts.map +1 -1
- package/dist/commerce/parked-orders.js +34 -5
- package/dist/commerce/parked-orders.js.map +1 -1
- package/dist/commerce/payments.d.ts +2 -1
- package/dist/commerce/payments.d.ts.map +1 -1
- package/dist/commerce/payments.js +2 -1
- package/dist/commerce/payments.js.map +1 -1
- package/dist/commerce/queries.d.ts +18 -3
- package/dist/commerce/queries.d.ts.map +1 -1
- package/dist/commerce/queries.js +119 -7
- package/dist/commerce/queries.js.map +1 -1
- package/dist/core/customer-session.d.ts +34 -0
- package/dist/core/customer-session.d.ts.map +1 -0
- package/dist/core/customer-session.js +48 -0
- package/dist/core/customer-session.js.map +1 -0
- package/dist/core/http.d.ts +9 -0
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +64 -25
- package/dist/core/http.js.map +1 -1
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/events/payloads.d.ts +1 -1
- package/dist/events/payloads.d.ts.map +1 -1
- package/dist/generated/cms.d.ts +4 -2
- package/dist/generated/cms.d.ts.map +1 -1
- package/dist/generated/shop.d.ts +200 -8
- package/dist/generated/shop.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/pricing/index.d.ts +1 -0
- package/dist/pricing/index.d.ts.map +1 -1
- package/dist/pricing/index.js +1 -0
- package/dist/pricing/index.js.map +1 -1
- package/dist/pricing/order-money-rows.d.ts +92 -0
- package/dist/pricing/order-money-rows.d.ts.map +1 -0
- package/dist/pricing/order-money-rows.js +88 -0
- package/dist/pricing/order-money-rows.js.map +1 -0
- package/dist/pricing/tax-display.d.ts +8 -4
- package/dist/pricing/tax-display.d.ts.map +1 -1
- package/dist/pricing/tax-display.js +10 -4
- package/dist/pricing/tax-display.js.map +1 -1
- package/dist/types.d.ts +241 -23
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -120,18 +120,39 @@ export interface StorefrontClientConfig {
|
|
|
120
120
|
* checkout for 15 minutes. Anything else is refused with `AGENT_SESSION_SCOPE`.
|
|
121
121
|
*/
|
|
122
122
|
customerToken?: string;
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Called when Vendure hands the client a new session token (a sign-in, or a
|
|
125
|
+
* new anonymous session for a guest or a dead token). Use to persist it.
|
|
126
|
+
*
|
|
127
|
+
* Only for a token that replaces the one the client holds now: a call
|
|
128
|
+
* answered after its token was replaced (a sign-in, `logout`, `setAuthToken`
|
|
129
|
+
* landed while it was in flight) has its token dropped, so a late answer
|
|
130
|
+
* never signs the newer session out. A sign-in's own token always applies.
|
|
131
|
+
*/
|
|
124
132
|
onAuthToken?: (token: string) => void;
|
|
125
133
|
/**
|
|
126
|
-
* Called when
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* `
|
|
134
|
+
* Called when a SIGNED-IN customer's session is gone: a Shop API call failed
|
|
135
|
+
* with UNAUTHORIZED, or with FORBIDDEN and a follow-up `activeCustomer` probe
|
|
136
|
+
* answered no customer. Vendure's Shop API returns FORBIDDEN both for a lost
|
|
137
|
+
* session and for a real authorization denial, so the probe is what tells
|
|
138
|
+
* them apart. Fires once per lost session. Use to prompt re-login or clear
|
|
139
|
+
* local user state.
|
|
140
|
+
*
|
|
141
|
+
* "Signed in" is what this client SAW: a successful `login`, `authenticate`,
|
|
142
|
+
* `loginWithMagicLink`, `loginWithMagicCode`, `verifyAccount` or
|
|
143
|
+
* `resetPassword`, or a `getCurrentCustomer()` that returned a customer.
|
|
144
|
+
* It never fires for a guest: a guest is refused with FORBIDDEN legitimately
|
|
145
|
+
* (an order placed in another browser, or past its guest read window), and
|
|
146
|
+
* its session — and cart — is still alive. A token handed in by
|
|
147
|
+
* `setAuthToken` or `customerToken` counts as signed in only once
|
|
148
|
+
* `getCurrentCustomer()` returns a customer for it, so a storefront that
|
|
149
|
+
* restores a stored token and wants this callback reads the customer first.
|
|
150
|
+
* `logout`, `setAuthToken` and `clearAuthToken` reset it.
|
|
151
|
+
*
|
|
152
|
+
* A FORBIDDEN with a still-signed-in session is an authorization denial,
|
|
153
|
+
* NOT an expiry: `onAuthExpired` does not fire and the caller receives a
|
|
154
|
+
* StorefrontError with `errorCode: 'FORBIDDEN'` / `statusCode: 403` to handle.
|
|
155
|
+
* Earlier releases also fired it for a guest's FORBIDDEN.
|
|
135
156
|
*/
|
|
136
157
|
onAuthExpired?: () => void;
|
|
137
158
|
/**
|
|
@@ -465,6 +486,21 @@ export interface StoreContext {
|
|
|
465
486
|
/** Channel tax-display storage mode — see {@link ChannelInfo.pricesIncludeTax}. */
|
|
466
487
|
pricesIncludeTax: boolean;
|
|
467
488
|
authToken: string | null;
|
|
489
|
+
/**
|
|
490
|
+
* `true` while the client knows `authToken` is a SIGNED-IN customer's
|
|
491
|
+
* session: a sign-in through this client succeeded, or an `activeCustomer`
|
|
492
|
+
* read answered a customer. Absent for a token the client never saw signed
|
|
493
|
+
* in (a guest's cart session, or one handed in by `setAuthToken` /
|
|
494
|
+
* `customerToken`); `false` once the server answered no customer. Gates
|
|
495
|
+
* `onAuthExpired`. Treat as internal.
|
|
496
|
+
*/
|
|
497
|
+
customerSession?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Bumped on every change to `customerSession` (`core/customer-session.ts`),
|
|
500
|
+
* so a response can tell whether the session it was sent for is still the
|
|
501
|
+
* one the client holds. Treat as internal.
|
|
502
|
+
*/
|
|
503
|
+
customerSessionEpoch?: number;
|
|
468
504
|
/**
|
|
469
505
|
* Active order scope, emitted as the `x-order-scope` header. `null`/absent
|
|
470
506
|
* means "send no header" — legacy, unscoped behaviour. See
|
|
@@ -575,7 +611,7 @@ export interface Asset {
|
|
|
575
611
|
* `@sixtyninecommerce/client/pricing` does exactly that.
|
|
576
612
|
*/
|
|
577
613
|
export type ProductAvailabilityState = Shop.ProductAvailabilityState;
|
|
578
|
-
export type { AddItemInput, AdjustmentType, AuthenticationInput, BreadcrumbFragment, ChannelCustomFieldsFragment, CollectionDetailFragment, CollectionFragment, CollectionRefFragment, ConvertedAmountFragment, CreateAddressInput, CreateCustomerInput, CreateProductReviewInput, CreateQuoteRequestInput, CreditBalanceSource, CurrencyCode, CurrentUserFragment, CustomerPaymentTermsFragment, CustomerReturnFragment, CustomerSubscriptionFragment, DeliveryAdvice, DeliverySelectionSource, DeliveryTermsStatus, DepositPaymentIntentInput, FacetFragment, FacetValueFragment, FavoriteListOptions, LanguageCode, MolliePaymentIntentInput, MolliePaymentMethodsInput, MyPaymentMandateFragment, MyparcelDeliveryOptionsInput, MyparcelDropOffPointInput, NativeAuthInput, OrderDeliveryTermsFragment, OrderFragment, OrderFulfillmentParcelsFragment, OrderFulfillmentsFragment, OrderPaymentIntent, OrderPaymentTermsFragment, OrderReturnReasonCode, OrderReturnSettlementMethod, OrderReturnState, OrderSummaryFragment, OrderWritableCustomFieldsFragment, ParkedOrderFragment, ParkedOrderPaymentIntentInput, PayDepositInput, PaymentInput, PaymentTermsClassification, PaymentTermsStatus, PayParkedOrderInput, PickupLocationSearchInput, PlacementRejectionFragment, PriceTierFragment, ProductAvailabilityFragment, ProductCardFragment, ProductFragment, ProductMetadataFragment, ProductPropertyGroupValuesFragment, ProductReviewFragment, ProductReviewListOptions, ProductSummaryFragment, ProductVariantFragment, PropertyGroupFragment, PublicPaymentMethodFragment, PublicShippingMethodFragment, QuoteFragment, QuoteLegacyFragment, QuoteLineDiscountType, QuoteLineRequestInput, QuoteListOptions, QuoteStatus, RecentReviewsOptions, RecommendedProductGroupFragment, RegisterCustomerInput, RequestReturnInput, ReturnRequestLineInput, ReviewSortKey, ReviewStatus, SavedListFragment, SearchResultFragment, SearchResultItemFragment, SetupPaymentMandateInput, SubscriptionFirstChargeTiming, SubscriptionPlanPublicFragment, SubscriptionPurchaseResultFragment, UpdateAddressInput, UpdateCustomerInput, UpdateOrderCustomFieldsInput, UpdateProductReviewInput, VariantLocationAvailabilityFragment, VatValidationResultFragment, } from './generated/shop.js';
|
|
614
|
+
export type { AddItemInput, AdjustmentType, AuthenticationInput, BreadcrumbFragment, ChannelCustomFieldsFragment, CollectionDetailFragment, CollectionFragment, CollectionRefFragment, ConvertedAmountFragment, CreateAddressInput, CreateCustomerInput, CreateProductReviewInput, CreateQuoteRequestInput, CreditBalanceSource, CurrencyCode, CurrentUserFragment, CustomerPaymentTermsFragment, CustomerReturnFragment, CustomerSubscriptionFragment, DeliveryAdvice, DeliverySelectionSource, DeliveryTermsStatus, DepositPaymentIntentInput, FacetFragment, FacetValueFragment, FavoriteListOptions, LanguageCode, MolliePaymentIntentInput, MolliePaymentMethodsInput, MyPaymentMandateFragment, MyparcelDeliveryOptionsInput, MyparcelDropOffPointInput, NativeAuthInput, OrderDeliveryTermsFragment, OrderFragment, OrderFulfillmentParcelsFragment, OrderFulfillmentsFragment, OrderMoneyBasis, OrderMoneyViewFragment, OrderPaymentIntent, OrderPaymentTermsFragment, OrderReturnReasonCode, OrderReturnSettlementMethod, OrderReturnState, OrderSummaryFragment, OrderWritableCustomFieldsFragment, ParkedOrderFragment, ParkedOrderPaymentIntentInput, PayDepositInput, PaymentInput, PaymentTermsClassification, PaymentTermsStatus, PayParkedOrderInput, PickupLocationSearchInput, PlacementRejectionFragment, PriceTierFragment, ProductAvailabilityFragment, ProductCardFragment, ProductFragment, ProductMetadataFragment, ProductPropertyGroupValuesFragment, ProductReviewFragment, ProductReviewListOptions, ProductSummaryFragment, ProductVariantFragment, PropertyGroupFragment, PublicPaymentMethodFragment, PublicShippingMethodFragment, QuoteFragment, QuoteLegacyFragment, QuoteLineDiscountType, QuoteLineRequestInput, QuoteListOptions, QuoteStatus, RecentReviewsOptions, RecommendedProductGroupFragment, RegisterCustomerInput, RequestReturnInput, ReturnRequestLineInput, ReviewSortKey, ReviewStatus, SavedListFragment, SearchResultFragment, SearchResultItemFragment, SetupPaymentMandateInput, SubscriptionFirstChargeTiming, SubscriptionPlanPublicFragment, SubscriptionPurchaseResultFragment, UpdateAddressInput, UpdateCustomerInput, UpdateOrderCustomFieldsInput, UpdateProductReviewInput, VariantLocationAvailabilityFragment, VatValidationResultFragment, } from './generated/shop.js';
|
|
579
615
|
/** A strategy `commerce.authenticate` can sign in through: a member of the engine's `AuthenticationInput` (`native` today). */
|
|
580
616
|
export type AuthenticationStrategy = keyof Shop.AuthenticationInput;
|
|
581
617
|
/** What a strategy takes — `{ username, password }` for `native`. */
|
|
@@ -636,6 +672,14 @@ export type Product = Omit<Shop.ProductFragment, 'metadata'> & {
|
|
|
636
672
|
* - `GIFT_CARD_NEEDS_BUYER_EMAIL` — the order sells gift cards, whose codes are
|
|
637
673
|
* sent only by email, and its customer has no address that can receive one.
|
|
638
674
|
* The buyer gives a real email address and places again.
|
|
675
|
+
* - `GIFT_CARD_NOT_FOR_SALE` — the cart holds a gift card, and the store sells
|
|
676
|
+
* none now (`lines` names the card lines). The buyer removes them. Adding a
|
|
677
|
+
* gift card, or raising its quantity, is refused with the same code.
|
|
678
|
+
* - `VIEW_ONLY_ACCOUNT` — the signed-in account is view-only: it browses and
|
|
679
|
+
* fills a basket but never places an order (the customer's `isViewOnly`).
|
|
680
|
+
* Paying, opening a payment intent or mandate, and requesting or accepting a
|
|
681
|
+
* quote are refused with the same code (the error's message is the buyer's
|
|
682
|
+
* sentence). Show `customerMessage` and offer no checkout.
|
|
639
683
|
*/
|
|
640
684
|
export type PlacementRejectionCode = Shop.PlacementRejectionCode;
|
|
641
685
|
/**
|
|
@@ -906,7 +950,21 @@ export interface CollectionListOptions {
|
|
|
906
950
|
export interface OrderListOptions {
|
|
907
951
|
take?: number;
|
|
908
952
|
skip?: number;
|
|
953
|
+
/**
|
|
954
|
+
* Also read each order's money view (`Order.moneyView`) in `basis` (default `CUSTOMER`), so
|
|
955
|
+
* the list prints the same total as the order page: `item.moneyView.total`. `null` on an
|
|
956
|
+
* engine before the field (print `totalWithTax` as before).
|
|
957
|
+
*/
|
|
958
|
+
moneyView?: {
|
|
959
|
+
basis?: Shop.OrderMoneyBasis;
|
|
960
|
+
};
|
|
909
961
|
}
|
|
962
|
+
/** An order-history page with each order's money view. */
|
|
963
|
+
export type CustomerOrdersWithMoneyView = MergedSelection<NonNullable<Shop.CustomerOrdersQuery['activeCustomer']>['orders']> & {
|
|
964
|
+
items: Array<MergedSelection<NonNullable<Shop.CustomerOrdersQuery['activeCustomer']>['orders']['items'][number]> & {
|
|
965
|
+
moneyView: Shop.OrderMoneyViewFragment | null;
|
|
966
|
+
}>;
|
|
967
|
+
};
|
|
910
968
|
/** A "back in stock" subscription, as `subscribeToStockNotification` returns it. */
|
|
911
969
|
export interface StockNotificationSubscriptionResult {
|
|
912
970
|
id: string;
|
|
@@ -1104,6 +1162,11 @@ export interface TaxDisplayInputs {
|
|
|
1104
1162
|
countryCode: string | null;
|
|
1105
1163
|
/** `Channel.pricesIncludeTax` — the STORAGE mode, not a display decision. */
|
|
1106
1164
|
pricesIncludeTax: boolean;
|
|
1165
|
+
/**
|
|
1166
|
+
* Member of a "view only" customer group (`Customer.isViewOnly`): always
|
|
1167
|
+
* shown gross, unless a listed country applies. Absent means false.
|
|
1168
|
+
*/
|
|
1169
|
+
isViewOnly?: boolean;
|
|
1107
1170
|
}
|
|
1108
1171
|
/**
|
|
1109
1172
|
* A resolved mode cached against the identity it was resolved for. Stored on
|
|
@@ -1212,6 +1275,21 @@ export type QuoteLine = Shop.QuoteLegacyFragment['lines'][number] & Partial<Omit
|
|
|
1212
1275
|
export type Quote = Omit<Shop.QuoteFragment, 'lines'> & {
|
|
1213
1276
|
lines: QuoteLine[];
|
|
1214
1277
|
};
|
|
1278
|
+
/**
|
|
1279
|
+
* The money on a held order as either parked-order document answers it. `creditNoted` (what the
|
|
1280
|
+
* order's credit notes took off what it bills) and `owed` (what is left to pay after them: the
|
|
1281
|
+
* most a payment may take, and what an omitted amount pays) are `undefined` against an engine
|
|
1282
|
+
* before them, which caps a payment at `outstanding`: read `owed ?? outstanding`.
|
|
1283
|
+
*/
|
|
1284
|
+
export type ParkedOrderPosition = Shop.ParkedOrderLegacyFragment['position'] & Partial<Pick<Shop.ParkedOrderFragment['position'], 'creditNoted' | 'owed'>>;
|
|
1285
|
+
/** A held order as `getParkedOrders` answers it — see {@link ParkedOrderPosition}. */
|
|
1286
|
+
export type ParkedOrder = Omit<Shop.ParkedOrderFragment, 'position'> & {
|
|
1287
|
+
position: ParkedOrderPosition;
|
|
1288
|
+
};
|
|
1289
|
+
/** What `payParkedOrder` answers — see {@link ParkedOrderPosition}. */
|
|
1290
|
+
export type ParkedOrderPaymentResult = Omit<Shop.PayParkedOrderMutation['payParkedOrder'], 'position'> & {
|
|
1291
|
+
position: ParkedOrderPosition;
|
|
1292
|
+
};
|
|
1215
1293
|
/** One page of `getMyQuotes`. */
|
|
1216
1294
|
export type QuoteList = Omit<Shop.MyQuotesQuery['myQuotes'], 'items'> & {
|
|
1217
1295
|
items: Quote[];
|
|
@@ -1735,9 +1813,15 @@ export interface CommerceModule {
|
|
|
1735
1813
|
* Force-fetch the Mollie payment status and reconcile the order state.
|
|
1736
1814
|
* Use as a fallback when the Mollie webhook is delayed or did not arrive
|
|
1737
1815
|
* (e.g. local/staging without a public tunnel). Returns `null` when no
|
|
1738
|
-
* order matches `orderCode`.
|
|
1816
|
+
* order matches `orderCode`. Answered by the same rule as
|
|
1817
|
+
* {@link CommerceModule.getOrderByCode}: pass `{ accessKey }` (the order's
|
|
1818
|
+
* access key from the return URL) when the shopper may be back in another
|
|
1819
|
+
* browser; the key only lets the order be READ, the sync itself only lands
|
|
1820
|
+
* what Mollie reports paid.
|
|
1821
|
+
*
|
|
1822
|
+
* @effect write
|
|
1739
1823
|
*/
|
|
1740
|
-
syncMolliePaymentStatus(orderCode: string, options?: RequestOptions): Promise<Shop.SyncMolliePaymentStatusMutation['syncMolliePaymentStatus']>;
|
|
1824
|
+
syncMolliePaymentStatus(orderCode: string, options?: RequestOptions & import('./commerce/order-access-key.js').OrderAccessKeyOption): Promise<Shop.SyncMolliePaymentStatusMutation['syncMolliePaymentStatus']>;
|
|
1741
1825
|
/**
|
|
1742
1826
|
* Orders the store is currently HOLDING for the signed-in shopper.
|
|
1743
1827
|
*
|
|
@@ -1749,8 +1833,13 @@ export interface CommerceModule {
|
|
|
1749
1833
|
* An order the store is REVIEWING after the shopper paid it (an app the store
|
|
1750
1834
|
* uses could not confirm it) is left out until the store accepts it: nothing
|
|
1751
1835
|
* can be paid on it before then.
|
|
1836
|
+
*
|
|
1837
|
+
* Each `position` says what is left to pay as `owed`: on an order whose
|
|
1838
|
+
* invoice a credit note lowered it is less than `outstanding`, which still
|
|
1839
|
+
* counts the credited part. Against an engine before it, `owed` is absent
|
|
1840
|
+
* (that engine takes up to `outstanding`).
|
|
1752
1841
|
*/
|
|
1753
|
-
getParkedOrders(options?: RequestOptions): Promise<
|
|
1842
|
+
getParkedOrders(options?: RequestOptions): Promise<ParkedOrder[]>;
|
|
1754
1843
|
/**
|
|
1755
1844
|
* Pay some or all of what a held order still owes. Requires a signed-in
|
|
1756
1845
|
* customer, and the order must be theirs.
|
|
@@ -1766,6 +1855,10 @@ export interface CommerceModule {
|
|
|
1766
1855
|
* card method is refused `PAYMENT_METHOD_UNUSABLE_HERE`; use
|
|
1767
1856
|
* {@link CommerceModule.createParkedOrderPaymentIntent} for a card.
|
|
1768
1857
|
*
|
|
1858
|
+
* An omitted `amount` pays what the order still owes (`position.owed`); more
|
|
1859
|
+
* than that is refused `AMOUNT_EXCEEDS_OUTSTANDING`, its message naming the
|
|
1860
|
+
* credit notes when they lowered it.
|
|
1861
|
+
*
|
|
1769
1862
|
* Pass `idempotencyKey` for anything a shopper can double-tap: a repeat under
|
|
1770
1863
|
* the same key returns the first payment instead of taking the money twice.
|
|
1771
1864
|
*
|
|
@@ -1776,11 +1869,11 @@ export interface CommerceModule {
|
|
|
1776
1869
|
*/
|
|
1777
1870
|
payParkedOrder(orderCode: string, input: Shop.PayParkedOrderInput, options?: RequestOptions & {
|
|
1778
1871
|
idempotencyKey?: string;
|
|
1779
|
-
}): Promise<
|
|
1872
|
+
}): Promise<ParkedOrderPaymentResult>;
|
|
1780
1873
|
/**
|
|
1781
|
-
* Open a CARD payment for one of the signed-in shopper's held orders, for
|
|
1782
|
-
*
|
|
1783
|
-
* and send the shopper to the returned `url`.
|
|
1874
|
+
* Open a CARD payment for one of the signed-in shopper's held orders, for
|
|
1875
|
+
* what it still owes (`position.owed`, or, where the store takes deposits,
|
|
1876
|
+
* part of it), and send the shopper to the returned `url`.
|
|
1784
1877
|
*
|
|
1785
1878
|
* Nothing is paid by this call and the order does not change: the money is
|
|
1786
1879
|
* recorded on the order when the provider confirms it, and the order leaves
|
|
@@ -1797,6 +1890,14 @@ export interface CommerceModule {
|
|
|
1797
1890
|
createParkedOrderPaymentIntent(orderCode: string, input: Shop.ParkedOrderPaymentIntentInput, options?: RequestOptions & {
|
|
1798
1891
|
idempotencyKey?: string;
|
|
1799
1892
|
}): Promise<Shop.CreateParkedOrderPaymentIntentMutation['createParkedOrderPaymentIntent']>;
|
|
1893
|
+
/**
|
|
1894
|
+
* Sign in with email and password. An imported account without a password
|
|
1895
|
+
* answers `password_reset_required`, an unverified one `account_not_verified`;
|
|
1896
|
+
* a wrong password throws `INVALID_CREDENTIALS_ERROR`. A success marks the
|
|
1897
|
+
* client signed in, so a later lost session fires `onAuthExpired`.
|
|
1898
|
+
*
|
|
1899
|
+
* @effect write
|
|
1900
|
+
*/
|
|
1800
1901
|
login(email: string, password: string): Promise<LoginResult>;
|
|
1801
1902
|
/**
|
|
1802
1903
|
* Sign in through a named authentication strategy — the general form of
|
|
@@ -1816,6 +1917,11 @@ export interface CommerceModule {
|
|
|
1816
1917
|
* whose lifetime the engine's session duration decides. A blank `strategy`
|
|
1817
1918
|
* or an `input` that is not an object throws a 400 `INVALID_ARGUMENT` before
|
|
1818
1919
|
* any request.
|
|
1920
|
+
*
|
|
1921
|
+
* A success marks the client signed in, so a later lost session fires
|
|
1922
|
+
* `onAuthExpired`.
|
|
1923
|
+
*
|
|
1924
|
+
* @effect write
|
|
1819
1925
|
*/
|
|
1820
1926
|
authenticate<S extends AuthenticationStrategy>(strategy: S, input: AuthenticationStrategyInput<S>, options?: RequestOptions & {
|
|
1821
1927
|
rememberMe?: boolean;
|
|
@@ -1823,7 +1929,22 @@ export interface CommerceModule {
|
|
|
1823
1929
|
register(input: Shop.RegisterCustomerInput): Promise<{
|
|
1824
1930
|
success: boolean;
|
|
1825
1931
|
}>;
|
|
1932
|
+
/**
|
|
1933
|
+
* End the session: clears the token, fires `onAuthCleared`, and forgets that
|
|
1934
|
+
* the client was signed in (no `onAuthExpired` follows).
|
|
1935
|
+
*
|
|
1936
|
+
* @effect write
|
|
1937
|
+
*/
|
|
1826
1938
|
logout(): Promise<void>;
|
|
1939
|
+
/**
|
|
1940
|
+
* The signed-in customer, or `null` for a guest or a session that lost its
|
|
1941
|
+
* sign-in. Also teaches the client which one its token is: a customer makes
|
|
1942
|
+
* a later lost session fire `onAuthExpired`, `null` does not. A storefront
|
|
1943
|
+
* that restores a stored token with `setAuthToken` reads this first when it
|
|
1944
|
+
* wants that callback.
|
|
1945
|
+
*
|
|
1946
|
+
* @effect read
|
|
1947
|
+
*/
|
|
1827
1948
|
getCurrentCustomer(): Promise<Shop.MeQuery['activeCustomer']>;
|
|
1828
1949
|
/**
|
|
1829
1950
|
* Price lists currently applying to the signed-in customer (identity only,
|
|
@@ -1835,8 +1956,47 @@ export interface CommerceModule {
|
|
|
1835
1956
|
* The signed-in customer's placed orders, newest first: the order-history rows
|
|
1836
1957
|
* with each line's `backorderedQuantity` and every parcel's barcode
|
|
1837
1958
|
* (`fulfillments[].trackingCodes`). An empty page for an anonymous visitor.
|
|
1959
|
+
* `{ moneyView: { basis } }` adds each order's money view (see {@link OrderListOptions}).
|
|
1960
|
+
*
|
|
1961
|
+
* @effect read
|
|
1962
|
+
*/
|
|
1963
|
+
getCustomerOrders(options: OrderListOptions & {
|
|
1964
|
+
moneyView: {
|
|
1965
|
+
basis?: Shop.OrderMoneyBasis;
|
|
1966
|
+
};
|
|
1967
|
+
}): Promise<CustomerOrdersWithMoneyView>;
|
|
1968
|
+
getCustomerOrders(options?: OrderListOptions & {
|
|
1969
|
+
moneyView?: undefined;
|
|
1970
|
+
}): Promise<MergedSelection<NonNullable<Shop.CustomerOrdersQuery['activeCustomer']>['orders']>>;
|
|
1971
|
+
getCustomerOrders(options?: OrderListOptions): Promise<MergedSelection<NonNullable<Shop.CustomerOrdersQuery['activeCustomer']>['orders']> | CustomerOrdersWithMoneyView>;
|
|
1972
|
+
/**
|
|
1973
|
+
* The order's money as the engine prints it on the dashboard, in emails and on invoices: rows
|
|
1974
|
+
* that add up exactly to the order's own totals, in `options.basis` (default `CUSTOMER`: how
|
|
1975
|
+
* the shop shows prices to that customer). `'active'` is the shopper's cart; `{ code }` a
|
|
1976
|
+
* placed order the shopper may read (as `getOrderByCode`, else `NOT_FOUND`, 404). Print it
|
|
1977
|
+
* with `orderMoneyRows(view)`; never add the figures up yourself.
|
|
1978
|
+
*
|
|
1979
|
+
* Resolves `null` when there is nothing to print from: no active order, or an engine before
|
|
1980
|
+
* `Order.moneyView` (print the order's own fields as before). Refused before sending:
|
|
1981
|
+
* `INVALID_ORDER_MONEY_BASIS` and `INVALID_ORDER_MONEY_TARGET` (400), and a
|
|
1982
|
+
* blank `accessKey` (`INVALID_ARGUMENT`). `{ accessKey }` reads a `{ code }`
|
|
1983
|
+
* order as {@link CommerceModule.getOrderByCode} does.
|
|
1984
|
+
*
|
|
1985
|
+
* @effect read
|
|
1838
1986
|
*/
|
|
1839
|
-
|
|
1987
|
+
getOrderMoneyView(order: import('./commerce/money-view.js').OrderMoneyViewTarget, options?: RequestOptions & import('./commerce/order-access-key.js').OrderAccessKeyOption & {
|
|
1988
|
+
basis?: Shop.OrderMoneyBasis;
|
|
1989
|
+
}): Promise<Shop.OrderMoneyViewFragment | null>;
|
|
1990
|
+
/**
|
|
1991
|
+
* The cart's private access key (`Order.accessKey`), to put in the payment
|
|
1992
|
+
* return URL so the confirmation page can read the order in whatever browser
|
|
1993
|
+
* the shopper comes back in: `getOrderByCode(code, { accessKey })`. `null`
|
|
1994
|
+
* with no cart, no keys configured on the engine, or an engine before the
|
|
1995
|
+
* field. A secret of the shopper's: never log it or send it to analytics.
|
|
1996
|
+
*
|
|
1997
|
+
* @effect read
|
|
1998
|
+
*/
|
|
1999
|
+
getActiveOrderAccessKey(options?: RequestOptions): Promise<string | null>;
|
|
1840
2000
|
/**
|
|
1841
2001
|
* Add every line of a previous order to the active cart. Returns the new
|
|
1842
2002
|
* active order plus a list of lines that could not be added (e.g. variant
|
|
@@ -1886,9 +2046,23 @@ export interface CommerceModule {
|
|
|
1886
2046
|
*/
|
|
1887
2047
|
setPassword(newPassword: string): Promise<void>;
|
|
1888
2048
|
requestPasswordReset(emailAddress: string): Promise<void>;
|
|
2049
|
+
/**
|
|
2050
|
+
* Set a new password from a reset token and sign in.
|
|
2051
|
+
* A success marks the client signed in, so a later lost session fires
|
|
2052
|
+
* `onAuthExpired`.
|
|
2053
|
+
*
|
|
2054
|
+
* @effect write
|
|
2055
|
+
*/
|
|
1889
2056
|
resetPassword(token: string, password: string): Promise<Shop.CurrentUserFragment>;
|
|
1890
2057
|
requestEmailUpdate(password: string, newEmailAddress: string): Promise<void>;
|
|
1891
2058
|
updateEmail(token: string): Promise<void>;
|
|
2059
|
+
/**
|
|
2060
|
+
* Verify the account from its emailed token and sign in.
|
|
2061
|
+
* A success marks the client signed in, so a later lost session fires
|
|
2062
|
+
* `onAuthExpired`.
|
|
2063
|
+
*
|
|
2064
|
+
* @effect write
|
|
2065
|
+
*/
|
|
1892
2066
|
verifyAccount(token: string, password?: string): Promise<Shop.CurrentUserFragment>;
|
|
1893
2067
|
refreshVerification(emailAddress: string): Promise<void>;
|
|
1894
2068
|
/**
|
|
@@ -1900,7 +2074,21 @@ export interface CommerceModule {
|
|
|
1900
2074
|
* credential limiter does. Neither reveals whether the account exists.
|
|
1901
2075
|
*/
|
|
1902
2076
|
requestMagicLink(emailAddress: string, options?: RequestMagicLinkOptions): Promise<void>;
|
|
2077
|
+
/**
|
|
2078
|
+
* Sign in with the emailed link's token.
|
|
2079
|
+
* A success marks the client signed in, so a later lost session fires
|
|
2080
|
+
* `onAuthExpired`.
|
|
2081
|
+
*
|
|
2082
|
+
* @effect write
|
|
2083
|
+
*/
|
|
1903
2084
|
loginWithMagicLink(token: string): Promise<Shop.CurrentUserFragment>;
|
|
2085
|
+
/**
|
|
2086
|
+
* Sign in with the emailed 6-digit code.
|
|
2087
|
+
* A success marks the client signed in, so a later lost session fires
|
|
2088
|
+
* `onAuthExpired`.
|
|
2089
|
+
*
|
|
2090
|
+
* @effect write
|
|
2091
|
+
*/
|
|
1904
2092
|
loginWithMagicCode(emailAddress: string, code: string): Promise<Shop.CurrentUserFragment>;
|
|
1905
2093
|
createAddress(input: Shop.CreateAddressInput): Promise<Shop.CreateAddressMutation['createCustomerAddress']>;
|
|
1906
2094
|
updateAddress(input: Shop.UpdateAddressInput): Promise<Shop.UpdateAddressMutation['updateCustomerAddress']>;
|
|
@@ -1910,10 +2098,32 @@ export interface CommerceModule {
|
|
|
1910
2098
|
* One of the shopper's orders by code — the cart selection plus what a placed
|
|
1911
2099
|
* order carries: `lines[].backorderedQuantity`, `customFields.chargedParcelCount`,
|
|
1912
2100
|
* the fulfilments with every parcel's barcode, the external shipments and the
|
|
1913
|
-
* payment and delivery terms frozen at acceptance.
|
|
1914
|
-
*
|
|
1915
|
-
|
|
1916
|
-
|
|
2101
|
+
* payment and delivery terms frozen at acceptance.
|
|
2102
|
+
*
|
|
2103
|
+
* Answered only to the signed-in customer whose order it is, or to the guest
|
|
2104
|
+
* session that put the order together (the client's own session token), for
|
|
2105
|
+
* as long as that session lives: there is no limit on the order's age. The
|
|
2106
|
+
* platform drops a guest session after a year, or once it has held no cart for
|
|
2107
|
+
* 7 days; a storefront that loses or clears the token loses it too. Anyone
|
|
2108
|
+
* else, another browser of the same guest or a later session of the same
|
|
2109
|
+
* browser included, gets a `FORBIDDEN` `StorefrontError` (403), and so does a
|
|
2110
|
+
* code that names no order: the server never tells the two apart. (`NOT_FOUND`
|
|
2111
|
+
* is thrown only if the server answers no order without an error.) A
|
|
2112
|
+
* confirmation page shows a "thank you, order {code} received, the details are
|
|
2113
|
+
* in your email" fallback on `FORBIDDEN`, never the order's contents. A
|
|
2114
|
+
* guest's `FORBIDDEN` here never fires `onAuthExpired`: its session is alive.
|
|
2115
|
+
*
|
|
2116
|
+
* `{ accessKey }`: the order's private access key (the `key` of the order
|
|
2117
|
+
* email's "view your order" link, or `getActiveOrderAccessKey()` put in the
|
|
2118
|
+
* return URL). With it a client with NO sign-in reads this one order in any
|
|
2119
|
+
* browser, for as long as the order exists; a signed-in client's login
|
|
2120
|
+
* decides instead, so sign-in-aware pages send it from an anonymous client.
|
|
2121
|
+
* A wrong or foreign key is the same `FORBIDDEN`. A blank one is refused
|
|
2122
|
+
* before sending (`INVALID_ARGUMENT`).
|
|
2123
|
+
*
|
|
2124
|
+
* @effect read
|
|
2125
|
+
*/
|
|
2126
|
+
getOrderByCode(code: string, options?: import('./commerce/order-access-key.js').OrderAccessKeyOption): Promise<MergedSelection<NonNullable<Shop.OrderByCodeQuery['orderByCode']>>>;
|
|
1917
2127
|
/** Invoices for one of the signed-in customer's own orders. */
|
|
1918
2128
|
getMyOrderInvoices(orderCode: string): Promise<Shop.MyOrderInvoicesQuery['myOrderInvoices']>;
|
|
1919
2129
|
/** Download one of the signed-in customer's own invoices as a base64 PDF. */
|
|
@@ -2534,7 +2744,15 @@ export interface StorefrontClient {
|
|
|
2534
2744
|
readonly maintenanceMode: boolean;
|
|
2535
2745
|
setLanguage(code: string): void;
|
|
2536
2746
|
getLanguage(): string;
|
|
2747
|
+
/**
|
|
2748
|
+
* Send this session token on every Shop API call (a token restored from a
|
|
2749
|
+
* cookie or storage). The client cannot tell a guest's token from a
|
|
2750
|
+
* customer's, so it does not count as signed in — and `onAuthExpired` does
|
|
2751
|
+
* not fire for it — until `commerce.getCurrentCustomer()` returns a customer
|
|
2752
|
+
* or a sign-in succeeds.
|
|
2753
|
+
*/
|
|
2537
2754
|
setAuthToken(token: string): void;
|
|
2755
|
+
/** Stop sending a session token; the client is no longer signed in. */
|
|
2538
2756
|
clearAuthToken(): void;
|
|
2539
2757
|
/**
|
|
2540
2758
|
* Change which storefront this client speaks for. Takes effect on the next
|