@asteby/storefront 0.8.0 → 0.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/README.md +33 -1
- package/dist/index.cjs +48 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -3
- package/dist/index.d.ts +49 -3
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +113 -0
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +19 -1
- package/dist/mock.d.ts +19 -1
- package/dist/mock.js +113 -0
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/{types-iGGZ9EiC.d.ts → types-COSwo4ND.d.ts} +41 -1
- package/dist/{types-CSMuPSQA.d.cts → types-DdLzlxw4.d.cts} +41 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeoPoint } from './geo.cjs';
|
|
2
2
|
export { OpenStatus, OpeningHours } from './geo.cjs';
|
|
3
|
-
import {
|
|
4
|
-
export { e as CartBuyer, g as CartCost, h as CartDelivery, i as CartDiscountCode, j as CartDiscountLine, k as CartLine, m as CartLineMerchandise, q as CartRecommendation, s as CheckoutInfo, u as CheckoutPayment,
|
|
3
|
+
import { at as ProductSort, aI as Shop, ar as ProductConnection, ao as Product, x as Connection, w as Collection, Z as LocationListParams, W as Location, a3 as NearestLocation, aM as StockLevel, aA as RestockSubscriptionInput, aB as RestockSubscriptionResult, l as CartLineInput, C as Cart, o as CartLineUpdateInput, f as CartBuyerInput, a as AddressInput, O as DeliveryOptions, ag as PaymentMethods, M as DeliveryInput, az as RecommendationPlacement, r as CartRecommendations, t as CheckoutInput, v as CheckoutResult, ay as PromotionsList, ad as PaymentConfig, al as PaymentSubmitInput, a9 as PaymentAttemptResult, B as CustomerIdentifier, I as CustomerSessionInput, H as CustomerSession, z as CustomerCapabilities, E as CustomerRegisterInput, F as CustomerRegisterResult, K as CustomerVerifyRegistrationInput, D as CustomerPasswordLoginInput, J as CustomerSetPasswordInput, G as CustomerResetPasswordInput, y as Customer, a4 as Order, aD as ReturnRequestInput, aC as ReturnRequest, U as InvoiceRequest, V as InvoiceResult, A as Address, aP as Theme, a6 as Page, $ as Menu, b as Article, aO as StorefrontErrorCode, T as InsufficientStockLine, a1 as Money, d as AvailabilityStatus, n as CartLineProblem, c as Availability, au as ProductVariant, L as DeclineCode, am as PaymentVoucher, ah as PaymentNextStep, p as CartPromotions, aw as PromotionReward, N as DeliveryMethod, aQ as UnavailableRateProvider } from './types-DdLzlxw4.cjs';
|
|
4
|
+
export { e as CartBuyer, g as CartCost, h as CartDelivery, i as CartDiscountCode, j as CartDiscountLine, k as CartLine, m as CartLineMerchandise, q as CartRecommendation, s as CheckoutInfo, u as CheckoutPayment, P as Facet, Q as FacetValue, R as Image, S as InsufficientStockDetails, X as LocationContacts, Y as LocationKind, _ as LocationPickup, a0 as MenuItem, a2 as MoneyRange, a5 as OrderLine, a7 as PageInfo, a8 as PaymentAction, aa as PaymentAttemptStatus, ab as PaymentClient, ac as PaymentClientCsp, ae as PaymentFlow, af as PaymentMethod, ai as PaymentOption, aj as PaymentOptionKey, ak as PaymentPoint, an as PickupOption, ap as ProductAttributeValue, aq as ProductCategory, as as ProductOption, av as PromotionAnnouncement, ax as PromotionTier, aE as SEO, aF as Section, aG as SelectedOption, aH as ShippingRate, aJ as ShopBranch, aK as ShopContact, aL as ShopPolicies, aN as StorefrontErrorBody } from './types-DdLzlxw4.cjs';
|
|
5
5
|
|
|
6
6
|
type QueryValue = string | number | boolean | null | undefined;
|
|
7
7
|
type QueryParams = Record<string, QueryValue | QueryValue[]>;
|
|
@@ -270,6 +270,21 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
270
270
|
requestOtp: (identifier: CustomerIdentifier, options?: WriteOptions) => Promise<void>;
|
|
271
271
|
/** Exchanges the code for a buyer session (`token` goes in `customerToken`). */
|
|
272
272
|
createSession: (input: CustomerSessionInput, options?: WriteOptions) => Promise<CustomerSession>;
|
|
273
|
+
/** What the store supports (password login, email verification, OTP channels). Drives which forms to show. */
|
|
274
|
+
capabilities: (options?: RequestOptions) => Promise<CustomerCapabilities>;
|
|
275
|
+
/**
|
|
276
|
+
* Creates an account with email + password. `verification_required` (202): a code was emailed, finish with
|
|
277
|
+
* `verifyRegistration`. `created` (201): the account exists and `session` is ready. `409` when the email is taken.
|
|
278
|
+
*/
|
|
279
|
+
register: (input: CustomerRegisterInput, options?: WriteOptions) => Promise<CustomerRegisterResult>;
|
|
280
|
+
/** Confirms the emailed registration code and returns the new buyer session. */
|
|
281
|
+
verifyRegistration: (input: CustomerVerifyRegistrationInput, options?: WriteOptions) => Promise<CustomerSession>;
|
|
282
|
+
/** Email + password login. `401` for wrong credentials. */
|
|
283
|
+
loginWithPassword: (input: CustomerPasswordLoginInput, options?: WriteOptions) => Promise<CustomerSession>;
|
|
284
|
+
/** Sets or changes the password of the signed-in buyer (`options.customerToken`, or a `withCustomerToken` client). */
|
|
285
|
+
setPassword: (input: CustomerSetPasswordInput, options?: WriteOptions) => Promise<void>;
|
|
286
|
+
/** Resets a forgotten password with the code from `requestOtp({ email })`. */
|
|
287
|
+
resetPassword: (input: CustomerResetPasswordInput, options?: WriteOptions) => Promise<void>;
|
|
273
288
|
get: (options?: RequestOptions) => Promise<Customer>;
|
|
274
289
|
orders: (params?: PaginationParams, options?: RequestOptions) => Promise<Connection<Order>>;
|
|
275
290
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
@@ -646,4 +661,35 @@ declare function hreflangLinks(markets: MarketInfo[], path: string, defaultMarke
|
|
|
646
661
|
href: string;
|
|
647
662
|
}[];
|
|
648
663
|
|
|
649
|
-
|
|
664
|
+
/** Kind of a delivery radio: `ship` (address only, quote later), `rate` (a quoted rate) or `pickup` (a branch). */
|
|
665
|
+
type DeliveryChoiceKind = 'ship' | 'rate' | 'pickup';
|
|
666
|
+
type DeliveryChoice = {
|
|
667
|
+
kind: DeliveryChoiceKind;
|
|
668
|
+
/** Everything after the first `:` — a rate id may contain more colons (`rate:skydropx:<id>`). */
|
|
669
|
+
id: string;
|
|
670
|
+
method: DeliveryMethod;
|
|
671
|
+
/** `ship:` — only the address is saved; the rate is picked on the next pass. */
|
|
672
|
+
addressOnly: boolean;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* Parses the value of the single delivery radio group: `ship:`, `rate:<id>` or `pickup:<branch>`.
|
|
676
|
+
* Splits on the FIRST colon only, so ids like `skydropx:<id>` survive intact (`split(':', 2)` would
|
|
677
|
+
* silently drop everything after the second colon). Anything unknown is treated as `rate`.
|
|
678
|
+
*/
|
|
679
|
+
declare function parseDelivery(value: string | null | undefined): DeliveryChoice;
|
|
680
|
+
/** The `setDelivery` payload for a choice; `null` when it only saves the address (`ship:`). */
|
|
681
|
+
declare function deliveryInput(choice: DeliveryChoice): DeliveryInput | null;
|
|
682
|
+
/** Reason code a rate provider reports when the cart has items without weight. */
|
|
683
|
+
declare const MISSING_WEIGHT = "missing_weight";
|
|
684
|
+
type DeliveryNotices = {
|
|
685
|
+
/** Providers that could not quote because some item has no weight. */
|
|
686
|
+
missingWeight: UnavailableRateProvider[];
|
|
687
|
+
/** Providers that failed for any other reason (timeouts, errors). */
|
|
688
|
+
unavailable: UnavailableRateProvider[];
|
|
689
|
+
/** `true` when the shopper should be told something is off with the quote. */
|
|
690
|
+
hasNotices: boolean;
|
|
691
|
+
};
|
|
692
|
+
/** Splits `delivery.unavailable` into the `missing_weight` notice and the generic one. */
|
|
693
|
+
declare function deliveryNotices(delivery: Pick<DeliveryOptions, 'unavailable' | 'partial'> | null | undefined): DeliveryNotices;
|
|
694
|
+
|
|
695
|
+
export { Address, AddressInput, Article, type ArticleListParams, Availability, type AvailabilityLocale, type AvailabilityMessageKey, type AvailabilityMessages, AvailabilityStatus, type AvailabilityTone, type AvailabilityView, type AvailabilityViewOptions, CLIENT_IP_HEADER, COUNTRY_HEADERS, Cart, CartBuyerInput, CartLineInput, CartLineProblem, type CartLineProblemView, CartLineUpdateInput, CartPromotions, CartRecommendations, CheckoutInput, CheckoutResult, Collection, type CollectionListParams, Connection, Customer, CustomerCapabilities, CustomerIdentifier, CustomerPasswordLoginInput, CustomerRegisterInput, CustomerRegisterResult, CustomerResetPasswordInput, CustomerSession, CustomerSessionInput, CustomerSetPasswordInput, CustomerVerifyRegistrationInput, DeclineCode, type DeliveryChoice, type DeliveryChoiceKind, DeliveryInput, DeliveryMethod, type DeliveryNotices, DeliveryOptions, type DiscountBarState, type DiscountBarView, type FetchLike, type FormatMoneyOptions, GeoPoint, InsufficientStockLine, InvoiceRequest, InvoiceResult, Location, LocationListParams, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, Order, Page, type PaginationParams, PaymentAttemptResult, PaymentConfig, type PaymentErrorKind, type PaymentErrorView, type PaymentLocale, type PaymentMessageKey, type PaymentMessages, PaymentMethods, PaymentNextStep, type PaymentOutcome, type PaymentOutcomeKind, PaymentSubmitInput, PaymentVoucher, type PreviewOptions, Product, ProductConnection, type ProductListParams, ProductSort, ProductVariant, type PromoProgressView, type PromotionLocale, type PromotionMessageKey, type PromotionMessages, PromotionReward, PromotionsList, type QueryParams, type QueryValue, RecommendationPlacement, type RequestOptions, type ResolveAvailabilityOptions, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions, StorefrontError, StorefrontErrorCode, type StorefrontErrorInit, type StorefrontRequestContext, type StorefrontResponseContext, Theme, UnavailableRateProvider, type WriteOptions, appendParams, availabilityLocale, availabilityMessages, availabilityView, cartLineProblemView, clampPercent, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, formatAvailabilityMessage, formatMoney, formatVoucherExpiry, generateIdempotencyKey, hreflangLinks, isStorefrontError, isTokenPublishable, negotiateLocale, normalizeClientIp, normalizeNote, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productAvailability, productListQuery, promoProgressView, promotionMessages, resolveAvailability, rewardLabel, safeHttpsUrl, schemaAvailability, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeoPoint } from './geo.js';
|
|
2
2
|
export { OpenStatus, OpeningHours } from './geo.js';
|
|
3
|
-
import {
|
|
4
|
-
export { e as CartBuyer, g as CartCost, h as CartDelivery, i as CartDiscountCode, j as CartDiscountLine, k as CartLine, m as CartLineMerchandise, q as CartRecommendation, s as CheckoutInfo, u as CheckoutPayment,
|
|
3
|
+
import { at as ProductSort, aI as Shop, ar as ProductConnection, ao as Product, x as Connection, w as Collection, Z as LocationListParams, W as Location, a3 as NearestLocation, aM as StockLevel, aA as RestockSubscriptionInput, aB as RestockSubscriptionResult, l as CartLineInput, C as Cart, o as CartLineUpdateInput, f as CartBuyerInput, a as AddressInput, O as DeliveryOptions, ag as PaymentMethods, M as DeliveryInput, az as RecommendationPlacement, r as CartRecommendations, t as CheckoutInput, v as CheckoutResult, ay as PromotionsList, ad as PaymentConfig, al as PaymentSubmitInput, a9 as PaymentAttemptResult, B as CustomerIdentifier, I as CustomerSessionInput, H as CustomerSession, z as CustomerCapabilities, E as CustomerRegisterInput, F as CustomerRegisterResult, K as CustomerVerifyRegistrationInput, D as CustomerPasswordLoginInput, J as CustomerSetPasswordInput, G as CustomerResetPasswordInput, y as Customer, a4 as Order, aD as ReturnRequestInput, aC as ReturnRequest, U as InvoiceRequest, V as InvoiceResult, A as Address, aP as Theme, a6 as Page, $ as Menu, b as Article, aO as StorefrontErrorCode, T as InsufficientStockLine, a1 as Money, d as AvailabilityStatus, n as CartLineProblem, c as Availability, au as ProductVariant, L as DeclineCode, am as PaymentVoucher, ah as PaymentNextStep, p as CartPromotions, aw as PromotionReward, N as DeliveryMethod, aQ as UnavailableRateProvider } from './types-COSwo4ND.js';
|
|
4
|
+
export { e as CartBuyer, g as CartCost, h as CartDelivery, i as CartDiscountCode, j as CartDiscountLine, k as CartLine, m as CartLineMerchandise, q as CartRecommendation, s as CheckoutInfo, u as CheckoutPayment, P as Facet, Q as FacetValue, R as Image, S as InsufficientStockDetails, X as LocationContacts, Y as LocationKind, _ as LocationPickup, a0 as MenuItem, a2 as MoneyRange, a5 as OrderLine, a7 as PageInfo, a8 as PaymentAction, aa as PaymentAttemptStatus, ab as PaymentClient, ac as PaymentClientCsp, ae as PaymentFlow, af as PaymentMethod, ai as PaymentOption, aj as PaymentOptionKey, ak as PaymentPoint, an as PickupOption, ap as ProductAttributeValue, aq as ProductCategory, as as ProductOption, av as PromotionAnnouncement, ax as PromotionTier, aE as SEO, aF as Section, aG as SelectedOption, aH as ShippingRate, aJ as ShopBranch, aK as ShopContact, aL as ShopPolicies, aN as StorefrontErrorBody } from './types-COSwo4ND.js';
|
|
5
5
|
|
|
6
6
|
type QueryValue = string | number | boolean | null | undefined;
|
|
7
7
|
type QueryParams = Record<string, QueryValue | QueryValue[]>;
|
|
@@ -270,6 +270,21 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
270
270
|
requestOtp: (identifier: CustomerIdentifier, options?: WriteOptions) => Promise<void>;
|
|
271
271
|
/** Exchanges the code for a buyer session (`token` goes in `customerToken`). */
|
|
272
272
|
createSession: (input: CustomerSessionInput, options?: WriteOptions) => Promise<CustomerSession>;
|
|
273
|
+
/** What the store supports (password login, email verification, OTP channels). Drives which forms to show. */
|
|
274
|
+
capabilities: (options?: RequestOptions) => Promise<CustomerCapabilities>;
|
|
275
|
+
/**
|
|
276
|
+
* Creates an account with email + password. `verification_required` (202): a code was emailed, finish with
|
|
277
|
+
* `verifyRegistration`. `created` (201): the account exists and `session` is ready. `409` when the email is taken.
|
|
278
|
+
*/
|
|
279
|
+
register: (input: CustomerRegisterInput, options?: WriteOptions) => Promise<CustomerRegisterResult>;
|
|
280
|
+
/** Confirms the emailed registration code and returns the new buyer session. */
|
|
281
|
+
verifyRegistration: (input: CustomerVerifyRegistrationInput, options?: WriteOptions) => Promise<CustomerSession>;
|
|
282
|
+
/** Email + password login. `401` for wrong credentials. */
|
|
283
|
+
loginWithPassword: (input: CustomerPasswordLoginInput, options?: WriteOptions) => Promise<CustomerSession>;
|
|
284
|
+
/** Sets or changes the password of the signed-in buyer (`options.customerToken`, or a `withCustomerToken` client). */
|
|
285
|
+
setPassword: (input: CustomerSetPasswordInput, options?: WriteOptions) => Promise<void>;
|
|
286
|
+
/** Resets a forgotten password with the code from `requestOtp({ email })`. */
|
|
287
|
+
resetPassword: (input: CustomerResetPasswordInput, options?: WriteOptions) => Promise<void>;
|
|
273
288
|
get: (options?: RequestOptions) => Promise<Customer>;
|
|
274
289
|
orders: (params?: PaginationParams, options?: RequestOptions) => Promise<Connection<Order>>;
|
|
275
290
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
@@ -646,4 +661,35 @@ declare function hreflangLinks(markets: MarketInfo[], path: string, defaultMarke
|
|
|
646
661
|
href: string;
|
|
647
662
|
}[];
|
|
648
663
|
|
|
649
|
-
|
|
664
|
+
/** Kind of a delivery radio: `ship` (address only, quote later), `rate` (a quoted rate) or `pickup` (a branch). */
|
|
665
|
+
type DeliveryChoiceKind = 'ship' | 'rate' | 'pickup';
|
|
666
|
+
type DeliveryChoice = {
|
|
667
|
+
kind: DeliveryChoiceKind;
|
|
668
|
+
/** Everything after the first `:` — a rate id may contain more colons (`rate:skydropx:<id>`). */
|
|
669
|
+
id: string;
|
|
670
|
+
method: DeliveryMethod;
|
|
671
|
+
/** `ship:` — only the address is saved; the rate is picked on the next pass. */
|
|
672
|
+
addressOnly: boolean;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* Parses the value of the single delivery radio group: `ship:`, `rate:<id>` or `pickup:<branch>`.
|
|
676
|
+
* Splits on the FIRST colon only, so ids like `skydropx:<id>` survive intact (`split(':', 2)` would
|
|
677
|
+
* silently drop everything after the second colon). Anything unknown is treated as `rate`.
|
|
678
|
+
*/
|
|
679
|
+
declare function parseDelivery(value: string | null | undefined): DeliveryChoice;
|
|
680
|
+
/** The `setDelivery` payload for a choice; `null` when it only saves the address (`ship:`). */
|
|
681
|
+
declare function deliveryInput(choice: DeliveryChoice): DeliveryInput | null;
|
|
682
|
+
/** Reason code a rate provider reports when the cart has items without weight. */
|
|
683
|
+
declare const MISSING_WEIGHT = "missing_weight";
|
|
684
|
+
type DeliveryNotices = {
|
|
685
|
+
/** Providers that could not quote because some item has no weight. */
|
|
686
|
+
missingWeight: UnavailableRateProvider[];
|
|
687
|
+
/** Providers that failed for any other reason (timeouts, errors). */
|
|
688
|
+
unavailable: UnavailableRateProvider[];
|
|
689
|
+
/** `true` when the shopper should be told something is off with the quote. */
|
|
690
|
+
hasNotices: boolean;
|
|
691
|
+
};
|
|
692
|
+
/** Splits `delivery.unavailable` into the `missing_weight` notice and the generic one. */
|
|
693
|
+
declare function deliveryNotices(delivery: Pick<DeliveryOptions, 'unavailable' | 'partial'> | null | undefined): DeliveryNotices;
|
|
694
|
+
|
|
695
|
+
export { Address, AddressInput, Article, type ArticleListParams, Availability, type AvailabilityLocale, type AvailabilityMessageKey, type AvailabilityMessages, AvailabilityStatus, type AvailabilityTone, type AvailabilityView, type AvailabilityViewOptions, CLIENT_IP_HEADER, COUNTRY_HEADERS, Cart, CartBuyerInput, CartLineInput, CartLineProblem, type CartLineProblemView, CartLineUpdateInput, CartPromotions, CartRecommendations, CheckoutInput, CheckoutResult, Collection, type CollectionListParams, Connection, Customer, CustomerCapabilities, CustomerIdentifier, CustomerPasswordLoginInput, CustomerRegisterInput, CustomerRegisterResult, CustomerResetPasswordInput, CustomerSession, CustomerSessionInput, CustomerSetPasswordInput, CustomerVerifyRegistrationInput, DeclineCode, type DeliveryChoice, type DeliveryChoiceKind, DeliveryInput, DeliveryMethod, type DeliveryNotices, DeliveryOptions, type DiscountBarState, type DiscountBarView, type FetchLike, type FormatMoneyOptions, GeoPoint, InsufficientStockLine, InvoiceRequest, InvoiceResult, Location, LocationListParams, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, Order, Page, type PaginationParams, PaymentAttemptResult, PaymentConfig, type PaymentErrorKind, type PaymentErrorView, type PaymentLocale, type PaymentMessageKey, type PaymentMessages, PaymentMethods, PaymentNextStep, type PaymentOutcome, type PaymentOutcomeKind, PaymentSubmitInput, PaymentVoucher, type PreviewOptions, Product, ProductConnection, type ProductListParams, ProductSort, ProductVariant, type PromoProgressView, type PromotionLocale, type PromotionMessageKey, type PromotionMessages, PromotionReward, PromotionsList, type QueryParams, type QueryValue, RecommendationPlacement, type RequestOptions, type ResolveAvailabilityOptions, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions, StorefrontError, StorefrontErrorCode, type StorefrontErrorInit, type StorefrontRequestContext, type StorefrontResponseContext, Theme, UnavailableRateProvider, type WriteOptions, appendParams, availabilityLocale, availabilityMessages, availabilityView, cartLineProblemView, clampPercent, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, formatAvailabilityMessage, formatMoney, formatVoucherExpiry, generateIdempotencyKey, hreflangLinks, isStorefrontError, isTokenPublishable, negotiateLocale, normalizeClientIp, normalizeNote, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productAvailability, productListQuery, promoProgressView, promotionMessages, resolveAvailability, rewardLabel, safeHttpsUrl, schemaAvailability, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
package/dist/index.js
CHANGED
|
@@ -380,6 +380,24 @@ function createStorefrontClient(config) {
|
|
|
380
380
|
requestOtp: (identifier, options) => write("POST", "/storefront/customer/otp", identifier, options),
|
|
381
381
|
/** Exchanges the code for a buyer session (`token` goes in `customerToken`). */
|
|
382
382
|
createSession: (input, options) => write("POST", "/storefront/customer/session", input, options),
|
|
383
|
+
/** What the store supports (password login, email verification, OTP channels). Drives which forms to show. */
|
|
384
|
+
capabilities: (options) => get("/storefront/customer/capabilities", void 0, options),
|
|
385
|
+
/**
|
|
386
|
+
* Creates an account with email + password. `verification_required` (202): a code was emailed, finish with
|
|
387
|
+
* `verifyRegistration`. `created` (201): the account exists and `session` is ready. `409` when the email is taken.
|
|
388
|
+
*/
|
|
389
|
+
register: async (input, options) => {
|
|
390
|
+
const res = await write("POST", "/storefront/customer/register", input, options);
|
|
391
|
+
return res && "token" in res ? { status: "created", session: res } : { status: "verification_required" };
|
|
392
|
+
},
|
|
393
|
+
/** Confirms the emailed registration code and returns the new buyer session. */
|
|
394
|
+
verifyRegistration: (input, options) => write("POST", "/storefront/customer/register/verify", input, options),
|
|
395
|
+
/** Email + password login. `401` for wrong credentials. */
|
|
396
|
+
loginWithPassword: (input, options) => write("POST", "/storefront/customer/login", input, options),
|
|
397
|
+
/** Sets or changes the password of the signed-in buyer (`options.customerToken`, or a `withCustomerToken` client). */
|
|
398
|
+
setPassword: (input, options) => write("PUT", "/storefront/customer/password", input, options),
|
|
399
|
+
/** Resets a forgotten password with the code from `requestOtp({ email })`. */
|
|
400
|
+
resetPassword: (input, options) => write("POST", "/storefront/customer/password/reset", input, options),
|
|
383
401
|
get: (options) => get("/storefront/customer", void 0, options),
|
|
384
402
|
orders: (params, options) => get("/storefront/customer/orders", params, options),
|
|
385
403
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
@@ -891,6 +909,32 @@ function hreflangLinks(markets, path, defaultMarket, protocol = "https") {
|
|
|
891
909
|
return links;
|
|
892
910
|
}
|
|
893
911
|
|
|
894
|
-
|
|
912
|
+
// src/delivery.ts
|
|
913
|
+
function parseDelivery(value) {
|
|
914
|
+
const raw = (value ?? "").trim();
|
|
915
|
+
const i = raw.indexOf(":");
|
|
916
|
+
const head = i === -1 ? raw : raw.slice(0, i);
|
|
917
|
+
const id = i === -1 ? "" : raw.slice(i + 1);
|
|
918
|
+
const kind = head === "pickup" ? "pickup" : head === "ship" ? "ship" : "rate";
|
|
919
|
+
return { kind, id, method: kind === "pickup" ? "pickup" : "shipping", addressOnly: kind === "ship" };
|
|
920
|
+
}
|
|
921
|
+
function deliveryInput(choice) {
|
|
922
|
+
if (choice.addressOnly) return null;
|
|
923
|
+
if (choice.kind === "pickup") return { method: "pickup", branch_id: choice.id };
|
|
924
|
+
return { method: "shipping", rate_id: choice.id || void 0 };
|
|
925
|
+
}
|
|
926
|
+
var MISSING_WEIGHT = "missing_weight";
|
|
927
|
+
function deliveryNotices(delivery) {
|
|
928
|
+
const all = delivery?.unavailable ?? [];
|
|
929
|
+
const missingWeight = all.filter((u) => u.code === MISSING_WEIGHT);
|
|
930
|
+
const unavailable = all.filter((u) => u.code !== MISSING_WEIGHT);
|
|
931
|
+
return {
|
|
932
|
+
missingWeight,
|
|
933
|
+
unavailable,
|
|
934
|
+
hasNotices: missingWeight.length > 0 || unavailable.length > 0 || delivery?.partial === true
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
export { CLIENT_IP_HEADER, COUNTRY_HEADERS, MISSING_WEIGHT, NOTE_MAX_LENGTH, StorefrontError, appendParams, clampPercent, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, formatMoney, formatVoucherExpiry, generateIdempotencyKey, hreflangLinks, isStorefrontError, isTokenPublishable, negotiateLocale, normalizeClientIp, normalizeNote, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productListQuery, promoProgressView, promotionMessages, rewardLabel, safeHttpsUrl, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
|
895
939
|
//# sourceMappingURL=index.js.map
|
|
896
940
|
//# sourceMappingURL=index.js.map
|