@asteby/storefront 0.16.1 → 0.17.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/dist/{types-DSHzYSHU.d.ts → account-settings-DNcJKOQl.d.ts} +144 -1
- package/dist/{types-C5nEQicj.d.cts → account-settings-H6zuI7iG.d.cts} +144 -1
- package/dist/cli.js +38 -1
- package/dist/fiscal-document.d.cts +2 -2
- package/dist/fiscal-document.d.ts +2 -2
- package/dist/index.cjs +64 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -70
- package/dist/index.d.ts +34 -70
- package/dist/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +156 -2
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +16 -1
- package/dist/mock.d.ts +16 -1
- package/dist/mock.js +156 -2
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { b4 as ProductSort, bH as TokenIntrospection, bx as Shop, be as Region, bi as RegionPostalCode, b2 as ProductConnection, a$ as Product, z as Connection, y as Collection, an as LocationListParams, ak as Location, at as NearestLocation, bB as StockLevel, bj as RestockSubscriptionInput, bk as RestockSubscriptionResult, n as CartLineInput, C as Cart, q as CartLineUpdateInput, g as CartBuyerInput, b as AddressInput, U as DeliveryOptions, aR as PaymentMethods, S as DeliveryInput, af as InvoiceRequest, bc as RecommendationPlacement, t as CartRecommendations, v as CheckoutInput, x as CheckoutResult, b9 as PromotionsList, aN as PaymentConfig, aW as PaymentSubmitInput, aJ as PaymentAttemptResult, E as CustomerIdentifier, M as CustomerSessionInput, K as CustomerSession, D as CustomerCapabilities, H as CustomerRegisterInput, I as CustomerRegisterResult, P as CustomerVerifyRegistrationInput, F as CustomerPasswordLoginInput, N as CustomerSetPasswordInput, J as CustomerResetPasswordInput, B as Customer, O as CustomerUpdateInput, L as CustomerSessionInfo, ba as ReauthInput, bb as ReauthResult, Q as DataExportFile, A as AccountDeleteInput, aw as Order, bm as ReturnRequestInput, bl as ReturnRequest, ag as InvoiceResult, aY as PendingPayment, ae as InvoiceFileKind, ad as InvoiceFile, $ as FiscalProfile, a0 as FiscalProfileInput, a as Address, bG as Theme, aG as Page, ap as Menu, c as Article, ar as Money, e as AvailabilityStatus, p as CartLineProblem, d as Availability, aa as InsufficientStockLine, b5 as ProductVariant, R as DeclineCode, aX as PaymentVoucher, aS as PaymentNextStep, r as CartPromotions, b7 as PromotionReward, ac as InvoiceDoc, bq as Shipment, au as NextAction, aA as OrderProgress, bu as ShipmentStatus, br as ShipmentEvent, T as DeliveryMethod, bI as UnavailableRateProvider } from './account-settings-H6zuI7iG.cjs';
|
|
2
|
+
export { f as CartBuyer, h as CartCost, i as CartDelivery, j as CartDiscountCode, k as CartDiscountLine, l as CartInvoice, m as CartLine, o as CartLineMerchandise, s as CartRecommendation, u as CheckoutInfo, w as CheckoutPayment, G as CustomerPreferences, V as Facet, W as FacetValue, X as FiscalDocumentEvidence, Y as FiscalDocumentSource, Z as FiscalIdentity, _ as FiscalIdentityInput, a1 as FiscalVerification, a2 as GeoHint, a3 as IdentityCapture, a4 as IdentityDocumentSpec, a5 as IdentityFieldRule, a6 as IdentityRulesV1, a7 as IdentityStrategy, a8 as Image, a9 as InsufficientStockDetails, ab as InvoiceAction, ah as InvoiceStage, ai as InvoiceSummary, aj as InvoicingCapabilities, al as LocationContacts, am as LocationKind, ao as LocationPickup, aq as MenuItem, as as MoneyRange, av as NextActionKind, ax as OrderLine, ay as OrderPickup, az as OrderProblem, aB as OrderProgressStep, aC as OrderSection, aD as OrderStage, aE as OrderStepKey, aF as OrderStepState, aH as PageInfo, aI as PaymentAction, aK as PaymentAttemptStatus, aL as PaymentClient, aM as PaymentClientCsp, aO as PaymentFlow, aP as PaymentInfo, aQ as PaymentMethod, aT as PaymentOption, aU as PaymentOptionKey, aV as PaymentPoint, aZ as PendingPaymentVoucher, a_ as PickupOption, b0 as ProductAttributeValue, b1 as ProductCategory, b3 as ProductOption, b6 as PromotionAnnouncement, b8 as PromotionTier, bd as Refund, bf as RegionFiscalEntry, bg as RegionFiscalId, bh as RegionPaymentMethod, bn as SEO, bo as Section, bp as SelectedOption, bs as ShipmentKind, bt as ShipmentMap, bv as ShipmentsSummary, bw as ShippingRate, by as ShopBranch, bz as ShopContact, bA as ShopPolicies, bC as StorefrontError, bD as StorefrontErrorBody, bE as StorefrontErrorCode, bF as StorefrontErrorInit, bJ as dataExportBytes, bK as isAccountDeleteBlocked, bL as isReauthRequired, bM as isStorefrontError, bN as safeExportFilename } from './account-settings-H6zuI7iG.cjs';
|
|
1
3
|
import { GeoPoint } from './geo.cjs';
|
|
2
4
|
export { OpenStatus, OpeningHours } from './geo.cjs';
|
|
3
|
-
import { b0 as ProductSort, bz as TokenIntrospection, br as Shop, b8 as Region, bc as RegionPostalCode, a_ as ProductConnection, aX as Product, y as Connection, x as Collection, aj as LocationListParams, ag as Location, ap as NearestLocation, bv as StockLevel, bd as RestockSubscriptionInput, be as RestockSubscriptionResult, m as CartLineInput, C as Cart, p as CartLineUpdateInput, f as CartBuyerInput, a as AddressInput, Q as DeliveryOptions, aN as PaymentMethods, O as DeliveryInput, ab as InvoiceRequest, b6 as RecommendationPlacement, s as CartRecommendations, u as CheckoutInput, w as CheckoutResult, b5 as PromotionsList, aJ as PaymentConfig, aS as PaymentSubmitInput, aF as PaymentAttemptResult, D as CustomerIdentifier, J as CustomerSessionInput, I as CustomerSession, B as CustomerCapabilities, F as CustomerRegisterInput, G as CustomerRegisterResult, M as CustomerVerifyRegistrationInput, E as CustomerPasswordLoginInput, K as CustomerSetPasswordInput, H as CustomerResetPasswordInput, z as Customer, L as CustomerUpdateInput, as as Order, bg as ReturnRequestInput, bf as ReturnRequest, ac as InvoiceResult, aU as PendingPayment, aa as InvoiceFileKind, a9 as InvoiceFile, X as FiscalProfile, Y as FiscalProfileInput, A as Address, by as Theme, aC as Page, al as Menu, b as Article, bx as StorefrontErrorCode, a6 as InsufficientStockLine, an as Money, d as AvailabilityStatus, o as CartLineProblem, c as Availability, b1 as ProductVariant, N as DeclineCode, aT as PaymentVoucher, aO as PaymentNextStep, q as CartPromotions, b3 as PromotionReward, a8 as InvoiceDoc, bk as Shipment, aq as NextAction, aw as OrderProgress, bo as ShipmentStatus, bl as ShipmentEvent, P as DeliveryMethod, bA as UnavailableRateProvider } from './types-C5nEQicj.cjs';
|
|
4
|
-
export { e as CartBuyer, g as CartCost, h as CartDelivery, i as CartDiscountCode, j as CartDiscountLine, k as CartInvoice, l as CartLine, n as CartLineMerchandise, r as CartRecommendation, t as CheckoutInfo, v as CheckoutPayment, R as Facet, S as FacetValue, T as FiscalDocumentEvidence, U as FiscalDocumentSource, V as FiscalIdentity, W as FiscalIdentityInput, Z as FiscalVerification, _ as GeoHint, $ as IdentityCapture, a0 as IdentityDocumentSpec, a1 as IdentityFieldRule, a2 as IdentityRulesV1, a3 as IdentityStrategy, a4 as Image, a5 as InsufficientStockDetails, a7 as InvoiceAction, ad as InvoiceStage, ae as InvoiceSummary, af as InvoicingCapabilities, ah as LocationContacts, ai as LocationKind, ak as LocationPickup, am as MenuItem, ao as MoneyRange, ar as NextActionKind, at as OrderLine, au as OrderPickup, av as OrderProblem, ax as OrderProgressStep, ay as OrderSection, az as OrderStage, aA as OrderStepKey, aB as OrderStepState, aD as PageInfo, aE as PaymentAction, aG as PaymentAttemptStatus, aH as PaymentClient, aI as PaymentClientCsp, aK as PaymentFlow, aL as PaymentInfo, aM as PaymentMethod, aP as PaymentOption, aQ as PaymentOptionKey, aR as PaymentPoint, aV as PendingPaymentVoucher, aW as PickupOption, aY as ProductAttributeValue, aZ as ProductCategory, a$ as ProductOption, b2 as PromotionAnnouncement, b4 as PromotionTier, b7 as Refund, b9 as RegionFiscalEntry, ba as RegionFiscalId, bb as RegionPaymentMethod, bh as SEO, bi as Section, bj as SelectedOption, bm as ShipmentKind, bn as ShipmentMap, bp as ShipmentsSummary, bq as ShippingRate, bs as ShopBranch, bt as ShopContact, bu as ShopPolicies, bw as StorefrontErrorBody } from './types-C5nEQicj.cjs';
|
|
5
5
|
|
|
6
6
|
type QueryValue = string | number | boolean | null | undefined;
|
|
7
7
|
type QueryParams = Record<string, QueryValue | QueryValue[]>;
|
|
@@ -323,6 +323,37 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
323
323
|
get: (options?: RequestOptions) => Promise<Customer>;
|
|
324
324
|
/** Updates the profile and the saved fiscal data; `fiscal: null` deletes the latter. `422` with `field: 'fiscal.<field>'`. */
|
|
325
325
|
update: (input: CustomerUpdateInput, options?: WriteOptions) => Promise<Customer>;
|
|
326
|
+
/**
|
|
327
|
+
* Active sessions of the buyer («Devices»; contract 1.9). Private, never cached. The list carries no address
|
|
328
|
+
* and no token: only what the buyer needs to recognize their own devices.
|
|
329
|
+
*/
|
|
330
|
+
sessions: {
|
|
331
|
+
list: (options?: RequestOptions) => Promise<CustomerSessionInfo[]>;
|
|
332
|
+
/** Closes one session. Repeating it is fine. `404` for a session that is not the buyer's. Closing the current one is a sign-out. */
|
|
333
|
+
revoke: (id: string, options?: WriteOptions) => Promise<void>;
|
|
334
|
+
/** Closes every session except the one making the call. */
|
|
335
|
+
revokeOthers: (options?: WriteOptions) => Promise<void>;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Confirms the buyer's identity again with their password or a sign-in code (`requestOtp` first). The
|
|
339
|
+
* confirmation lasts `valid_for_seconds` (a few minutes) and counts only for the session that made the call;
|
|
340
|
+
* exporting data and deleting the account need it (`403 reauth_required` otherwise, see `isReauthRequired`).
|
|
341
|
+
* A wrong credential is always the same `400`; too many tries is `429` (`StorefrontError.retryAfter`).
|
|
342
|
+
*/
|
|
343
|
+
reauth: (input: ReauthInput, options?: WriteOptions) => Promise<ReauthResult>;
|
|
344
|
+
/**
|
|
345
|
+
* The buyer's data as a JSON file (contract 1.9, `capabilities().data_export`). Needs a recent `reauth`. It is
|
|
346
|
+
* built on request and is neither stored nor emailed: call it from YOUR server, stream the bytes
|
|
347
|
+
* (`dataExportBytes`, `safeExportFilename`) with `Cache-Control: no-store`, and keep nothing. Three a day per account.
|
|
348
|
+
*/
|
|
349
|
+
exportData: (options?: WriteOptions) => Promise<DataExportFile>;
|
|
350
|
+
/**
|
|
351
|
+
* Deletes the buyer's account (contract 1.9, `capabilities().account_delete`). Needs a recent `reauth` and the
|
|
352
|
+
* text the buyer typed in `confirm`. Personal data is erased; orders and invoices are kept by the store.
|
|
353
|
+
* `409` (see `isAccountDeleteBlocked`) while an order is on its way or a payment is pending. Idempotent: a
|
|
354
|
+
* repeat after success is also fine. Afterwards the token is dead: drop it.
|
|
355
|
+
*/
|
|
356
|
+
deleteAccount: (input: AccountDeleteInput, options?: WriteOptions) => Promise<void>;
|
|
326
357
|
orders: (params?: PaginationParams, options?: RequestOptions) => Promise<Connection<Order>>;
|
|
327
358
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
328
359
|
order: (id: string, options?: RequestOptions) => Promise<Order | null>;
|
|
@@ -376,73 +407,6 @@ type StorefrontClient = ReturnType<typeof createStorefrontClient>;
|
|
|
376
407
|
/** `X-Storefront-Domain` value: the host, plus `#<market>` when a valid market code is given. */
|
|
377
408
|
declare function storefrontDomainHeader(domain: string, market?: string | null): string;
|
|
378
409
|
|
|
379
|
-
type StorefrontErrorInit = {
|
|
380
|
-
status: number;
|
|
381
|
-
code: StorefrontErrorCode;
|
|
382
|
-
message: string;
|
|
383
|
-
field?: string;
|
|
384
|
-
/** Raw `error.details` from the body (untrusted shape). */
|
|
385
|
-
details?: unknown;
|
|
386
|
-
/** Request URL that failed (without credentials). */
|
|
387
|
-
url?: string;
|
|
388
|
-
cause?: unknown;
|
|
389
|
-
/** Scopes named by the gateway on a `403 insufficient_scope`. */
|
|
390
|
-
requiredScopes?: string[];
|
|
391
|
-
/** `error.retryable` as OPS declared it (payment failures). `undefined` = OPS did not say. */
|
|
392
|
-
retryable?: boolean;
|
|
393
|
-
/** `error.retry_after` in seconds. */
|
|
394
|
-
retryAfter?: number;
|
|
395
|
-
/** `error.checkout_id`: the checkout a refused cart write can resume. */
|
|
396
|
-
checkoutId?: string;
|
|
397
|
-
/** `error.cost` of a `price_mismatch` (the cart's current cost; untrusted shape). */
|
|
398
|
-
cost?: unknown;
|
|
399
|
-
/** `error.message_en`. */
|
|
400
|
-
messageEn?: string;
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* Error thrown by the client for any non-2xx response, network failure,
|
|
404
|
-
* timeout or abort. `status` is `0` when no HTTP response was received.
|
|
405
|
-
*/
|
|
406
|
-
declare class StorefrontError extends Error {
|
|
407
|
-
readonly name = "StorefrontError";
|
|
408
|
-
readonly status: number;
|
|
409
|
-
readonly code: StorefrontErrorCode;
|
|
410
|
-
readonly field: string | undefined;
|
|
411
|
-
readonly details: unknown;
|
|
412
|
-
readonly url: string | undefined;
|
|
413
|
-
/** Scopes a `403 insufficient_scope` says the route needs (empty for any other error). */
|
|
414
|
-
readonly requiredScopes: string[];
|
|
415
|
-
/** `true`: repeating the request (same idempotency key) can succeed. `false`: not until someone fixes something. `undefined`: OPS did not say. */
|
|
416
|
-
readonly retryable: boolean | undefined;
|
|
417
|
-
/** Seconds OPS asks to wait before retrying. */
|
|
418
|
-
readonly retryAfter: number | undefined;
|
|
419
|
-
/** Checkout that a refused cart write can resume. */
|
|
420
|
-
readonly checkoutId: string | undefined;
|
|
421
|
-
/** Current cart cost sent with a `price_mismatch` (untrusted shape). */
|
|
422
|
-
readonly cost: unknown;
|
|
423
|
-
/** English version of `message`, when OPS sent one. */
|
|
424
|
-
readonly messageEn: string | undefined;
|
|
425
|
-
constructor(init: StorefrontErrorInit);
|
|
426
|
-
/**
|
|
427
|
-
* Affected lines of a `409 insufficient_stock` (empty for any other error or a
|
|
428
|
-
* server older than contract 1.1). The cart is untouched: show the lines and
|
|
429
|
-
* let the buyer adjust or remove them.
|
|
430
|
-
*/
|
|
431
|
-
get stockLines(): InsufficientStockLine[];
|
|
432
|
-
toJSON(): {
|
|
433
|
-
checkoutId?: string | undefined;
|
|
434
|
-
retryAfter?: number | undefined;
|
|
435
|
-
retryable?: boolean | undefined;
|
|
436
|
-
requiredScopes?: string[] | undefined;
|
|
437
|
-
name: string;
|
|
438
|
-
status: number;
|
|
439
|
-
code: StorefrontErrorCode;
|
|
440
|
-
message: string;
|
|
441
|
-
field: string | undefined;
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
declare function isStorefrontError(err: unknown): err is StorefrontError;
|
|
445
|
-
|
|
446
410
|
/**
|
|
447
411
|
* Classification of the failures of a card payment (`POST pay` / `GET status`). No texts, no DOM, no server APIs: the
|
|
448
412
|
* shop's server uses it to answer with `kind` and `retryable`, and the browser transport uses it to decide whether to
|
|
@@ -899,4 +863,4 @@ type DeliveryNotices = {
|
|
|
899
863
|
/** Splits `delivery.unavailable` into the `missing_weight` notice and the generic one. */
|
|
900
864
|
declare function deliveryNotices(delivery: Pick<DeliveryOptions, 'unavailable' | 'partial'> | null | undefined): DeliveryNotices;
|
|
901
865
|
|
|
902
|
-
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, CustomerUpdateInput, CustomerVerifyRegistrationInput, DeclineCode, type DeliveryChoice, type DeliveryChoiceKind, DeliveryInput, DeliveryMethod, type DeliveryNotices, DeliveryOptions, type DiagnoseOptions, type DiscountBarState, type DiscountBarView, type FetchLike, FiscalProfile, FiscalProfileInput, type FormatMoneyOptions, GeoPoint, InsufficientStockLine, InvoiceDoc, InvoiceFile, InvoiceFileKind, type InvoiceGroup, InvoiceRequest, InvoiceResult, Location, LocationListParams, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, NextAction, Order, OrderProgress, PAYMENT_CHOICE_REFUSED_FIELD, PICKUP_STEPS, Page, type PaginationParams, PaymentAttemptResult, PaymentConfig, type PaymentErrorClass, type PaymentErrorClassKind, type PaymentErrorKind, type PaymentErrorLike, type PaymentErrorView, type PaymentLocale, type PaymentMessageKey, type PaymentMessages, PaymentMethods, PaymentNextStep, type PaymentOutcome, type PaymentOutcomeKind, PaymentSubmitInput, PaymentVoucher, PendingPayment, type PreviewOptions, Product, ProductConnection, type ProductListParams, ProductSort, ProductVariant, type PromoProgressView, type PromotionLocale, type PromotionMessageKey, type PromotionMessages, PromotionReward, PromotionsList, type QueryParams, type QueryValue, RecommendationPlacement, Region, RegionPostalCode, type RequestOptions, type ResolveAvailabilityOptions, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, SHIPPING_STEPS, Shipment, ShipmentEvent, ShipmentStatus, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions,
|
|
866
|
+
export { AccountDeleteInput, 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, CustomerSessionInfo, CustomerSessionInput, CustomerSetPasswordInput, CustomerUpdateInput, CustomerVerifyRegistrationInput, DataExportFile, DeclineCode, type DeliveryChoice, type DeliveryChoiceKind, DeliveryInput, DeliveryMethod, type DeliveryNotices, DeliveryOptions, type DiagnoseOptions, type DiscountBarState, type DiscountBarView, type FetchLike, FiscalProfile, FiscalProfileInput, type FormatMoneyOptions, GeoPoint, InsufficientStockLine, InvoiceDoc, InvoiceFile, InvoiceFileKind, type InvoiceGroup, InvoiceRequest, InvoiceResult, Location, LocationListParams, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, NextAction, Order, OrderProgress, PAYMENT_CHOICE_REFUSED_FIELD, PICKUP_STEPS, Page, type PaginationParams, PaymentAttemptResult, PaymentConfig, type PaymentErrorClass, type PaymentErrorClassKind, type PaymentErrorKind, type PaymentErrorLike, type PaymentErrorView, type PaymentLocale, type PaymentMessageKey, type PaymentMessages, PaymentMethods, PaymentNextStep, type PaymentOutcome, type PaymentOutcomeKind, PaymentSubmitInput, PaymentVoucher, PendingPayment, type PreviewOptions, Product, ProductConnection, type ProductListParams, ProductSort, ProductVariant, type PromoProgressView, type PromotionLocale, type PromotionMessageKey, type PromotionMessages, PromotionReward, PromotionsList, type QueryParams, type QueryValue, ReauthInput, ReauthResult, RecommendationPlacement, Region, RegionPostalCode, type RequestOptions, type ResolveAvailabilityOptions, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, SHIPPING_STEPS, Shipment, ShipmentEvent, ShipmentStatus, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions, type StorefrontRequestContext, type StorefrontResponseContext, Theme, TokenIntrospection, UnavailableRateProvider, type WriteOptions, appendParams, availabilityLocale, availabilityMessages, availabilityView, cartLineProblemView, clampPercent, classifyPaymentError, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, diagnose, formatAvailabilityMessage, formatMoney, formatVoucherExpiry, generateIdempotencyKey, groupInvoiceDocs, hreflangLinks, invoiceFileBytes, isTestInvoice, isTestShipment, isTokenPublishable, maskToken, negotiateLocale, nextAction, normalizeClientIp, normalizeNote, opsSaysNotRetryable, orderProgress, orderShipments, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productAvailability, productListQuery, promoProgressView, promotionMessages, repairPath, resolveAvailability, rewardLabel, safeHttpsUrl, safeInvoiceFilename, safeTrackingUrl, schemaAvailability, shipmentsStatus, sortTrackingEvents, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { b4 as ProductSort, bH as TokenIntrospection, bx as Shop, be as Region, bi as RegionPostalCode, b2 as ProductConnection, a$ as Product, z as Connection, y as Collection, an as LocationListParams, ak as Location, at as NearestLocation, bB as StockLevel, bj as RestockSubscriptionInput, bk as RestockSubscriptionResult, n as CartLineInput, C as Cart, q as CartLineUpdateInput, g as CartBuyerInput, b as AddressInput, U as DeliveryOptions, aR as PaymentMethods, S as DeliveryInput, af as InvoiceRequest, bc as RecommendationPlacement, t as CartRecommendations, v as CheckoutInput, x as CheckoutResult, b9 as PromotionsList, aN as PaymentConfig, aW as PaymentSubmitInput, aJ as PaymentAttemptResult, E as CustomerIdentifier, M as CustomerSessionInput, K as CustomerSession, D as CustomerCapabilities, H as CustomerRegisterInput, I as CustomerRegisterResult, P as CustomerVerifyRegistrationInput, F as CustomerPasswordLoginInput, N as CustomerSetPasswordInput, J as CustomerResetPasswordInput, B as Customer, O as CustomerUpdateInput, L as CustomerSessionInfo, ba as ReauthInput, bb as ReauthResult, Q as DataExportFile, A as AccountDeleteInput, aw as Order, bm as ReturnRequestInput, bl as ReturnRequest, ag as InvoiceResult, aY as PendingPayment, ae as InvoiceFileKind, ad as InvoiceFile, $ as FiscalProfile, a0 as FiscalProfileInput, a as Address, bG as Theme, aG as Page, ap as Menu, c as Article, ar as Money, e as AvailabilityStatus, p as CartLineProblem, d as Availability, aa as InsufficientStockLine, b5 as ProductVariant, R as DeclineCode, aX as PaymentVoucher, aS as PaymentNextStep, r as CartPromotions, b7 as PromotionReward, ac as InvoiceDoc, bq as Shipment, au as NextAction, aA as OrderProgress, bu as ShipmentStatus, br as ShipmentEvent, T as DeliveryMethod, bI as UnavailableRateProvider } from './account-settings-DNcJKOQl.js';
|
|
2
|
+
export { f as CartBuyer, h as CartCost, i as CartDelivery, j as CartDiscountCode, k as CartDiscountLine, l as CartInvoice, m as CartLine, o as CartLineMerchandise, s as CartRecommendation, u as CheckoutInfo, w as CheckoutPayment, G as CustomerPreferences, V as Facet, W as FacetValue, X as FiscalDocumentEvidence, Y as FiscalDocumentSource, Z as FiscalIdentity, _ as FiscalIdentityInput, a1 as FiscalVerification, a2 as GeoHint, a3 as IdentityCapture, a4 as IdentityDocumentSpec, a5 as IdentityFieldRule, a6 as IdentityRulesV1, a7 as IdentityStrategy, a8 as Image, a9 as InsufficientStockDetails, ab as InvoiceAction, ah as InvoiceStage, ai as InvoiceSummary, aj as InvoicingCapabilities, al as LocationContacts, am as LocationKind, ao as LocationPickup, aq as MenuItem, as as MoneyRange, av as NextActionKind, ax as OrderLine, ay as OrderPickup, az as OrderProblem, aB as OrderProgressStep, aC as OrderSection, aD as OrderStage, aE as OrderStepKey, aF as OrderStepState, aH as PageInfo, aI as PaymentAction, aK as PaymentAttemptStatus, aL as PaymentClient, aM as PaymentClientCsp, aO as PaymentFlow, aP as PaymentInfo, aQ as PaymentMethod, aT as PaymentOption, aU as PaymentOptionKey, aV as PaymentPoint, aZ as PendingPaymentVoucher, a_ as PickupOption, b0 as ProductAttributeValue, b1 as ProductCategory, b3 as ProductOption, b6 as PromotionAnnouncement, b8 as PromotionTier, bd as Refund, bf as RegionFiscalEntry, bg as RegionFiscalId, bh as RegionPaymentMethod, bn as SEO, bo as Section, bp as SelectedOption, bs as ShipmentKind, bt as ShipmentMap, bv as ShipmentsSummary, bw as ShippingRate, by as ShopBranch, bz as ShopContact, bA as ShopPolicies, bC as StorefrontError, bD as StorefrontErrorBody, bE as StorefrontErrorCode, bF as StorefrontErrorInit, bJ as dataExportBytes, bK as isAccountDeleteBlocked, bL as isReauthRequired, bM as isStorefrontError, bN as safeExportFilename } from './account-settings-DNcJKOQl.js';
|
|
1
3
|
import { GeoPoint } from './geo.js';
|
|
2
4
|
export { OpenStatus, OpeningHours } from './geo.js';
|
|
3
|
-
import { b0 as ProductSort, bz as TokenIntrospection, br as Shop, b8 as Region, bc as RegionPostalCode, a_ as ProductConnection, aX as Product, y as Connection, x as Collection, aj as LocationListParams, ag as Location, ap as NearestLocation, bv as StockLevel, bd as RestockSubscriptionInput, be as RestockSubscriptionResult, m as CartLineInput, C as Cart, p as CartLineUpdateInput, f as CartBuyerInput, a as AddressInput, Q as DeliveryOptions, aN as PaymentMethods, O as DeliveryInput, ab as InvoiceRequest, b6 as RecommendationPlacement, s as CartRecommendations, u as CheckoutInput, w as CheckoutResult, b5 as PromotionsList, aJ as PaymentConfig, aS as PaymentSubmitInput, aF as PaymentAttemptResult, D as CustomerIdentifier, J as CustomerSessionInput, I as CustomerSession, B as CustomerCapabilities, F as CustomerRegisterInput, G as CustomerRegisterResult, M as CustomerVerifyRegistrationInput, E as CustomerPasswordLoginInput, K as CustomerSetPasswordInput, H as CustomerResetPasswordInput, z as Customer, L as CustomerUpdateInput, as as Order, bg as ReturnRequestInput, bf as ReturnRequest, ac as InvoiceResult, aU as PendingPayment, aa as InvoiceFileKind, a9 as InvoiceFile, X as FiscalProfile, Y as FiscalProfileInput, A as Address, by as Theme, aC as Page, al as Menu, b as Article, bx as StorefrontErrorCode, a6 as InsufficientStockLine, an as Money, d as AvailabilityStatus, o as CartLineProblem, c as Availability, b1 as ProductVariant, N as DeclineCode, aT as PaymentVoucher, aO as PaymentNextStep, q as CartPromotions, b3 as PromotionReward, a8 as InvoiceDoc, bk as Shipment, aq as NextAction, aw as OrderProgress, bo as ShipmentStatus, bl as ShipmentEvent, P as DeliveryMethod, bA as UnavailableRateProvider } from './types-DSHzYSHU.js';
|
|
4
|
-
export { e as CartBuyer, g as CartCost, h as CartDelivery, i as CartDiscountCode, j as CartDiscountLine, k as CartInvoice, l as CartLine, n as CartLineMerchandise, r as CartRecommendation, t as CheckoutInfo, v as CheckoutPayment, R as Facet, S as FacetValue, T as FiscalDocumentEvidence, U as FiscalDocumentSource, V as FiscalIdentity, W as FiscalIdentityInput, Z as FiscalVerification, _ as GeoHint, $ as IdentityCapture, a0 as IdentityDocumentSpec, a1 as IdentityFieldRule, a2 as IdentityRulesV1, a3 as IdentityStrategy, a4 as Image, a5 as InsufficientStockDetails, a7 as InvoiceAction, ad as InvoiceStage, ae as InvoiceSummary, af as InvoicingCapabilities, ah as LocationContacts, ai as LocationKind, ak as LocationPickup, am as MenuItem, ao as MoneyRange, ar as NextActionKind, at as OrderLine, au as OrderPickup, av as OrderProblem, ax as OrderProgressStep, ay as OrderSection, az as OrderStage, aA as OrderStepKey, aB as OrderStepState, aD as PageInfo, aE as PaymentAction, aG as PaymentAttemptStatus, aH as PaymentClient, aI as PaymentClientCsp, aK as PaymentFlow, aL as PaymentInfo, aM as PaymentMethod, aP as PaymentOption, aQ as PaymentOptionKey, aR as PaymentPoint, aV as PendingPaymentVoucher, aW as PickupOption, aY as ProductAttributeValue, aZ as ProductCategory, a$ as ProductOption, b2 as PromotionAnnouncement, b4 as PromotionTier, b7 as Refund, b9 as RegionFiscalEntry, ba as RegionFiscalId, bb as RegionPaymentMethod, bh as SEO, bi as Section, bj as SelectedOption, bm as ShipmentKind, bn as ShipmentMap, bp as ShipmentsSummary, bq as ShippingRate, bs as ShopBranch, bt as ShopContact, bu as ShopPolicies, bw as StorefrontErrorBody } from './types-DSHzYSHU.js';
|
|
5
5
|
|
|
6
6
|
type QueryValue = string | number | boolean | null | undefined;
|
|
7
7
|
type QueryParams = Record<string, QueryValue | QueryValue[]>;
|
|
@@ -323,6 +323,37 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
323
323
|
get: (options?: RequestOptions) => Promise<Customer>;
|
|
324
324
|
/** Updates the profile and the saved fiscal data; `fiscal: null` deletes the latter. `422` with `field: 'fiscal.<field>'`. */
|
|
325
325
|
update: (input: CustomerUpdateInput, options?: WriteOptions) => Promise<Customer>;
|
|
326
|
+
/**
|
|
327
|
+
* Active sessions of the buyer («Devices»; contract 1.9). Private, never cached. The list carries no address
|
|
328
|
+
* and no token: only what the buyer needs to recognize their own devices.
|
|
329
|
+
*/
|
|
330
|
+
sessions: {
|
|
331
|
+
list: (options?: RequestOptions) => Promise<CustomerSessionInfo[]>;
|
|
332
|
+
/** Closes one session. Repeating it is fine. `404` for a session that is not the buyer's. Closing the current one is a sign-out. */
|
|
333
|
+
revoke: (id: string, options?: WriteOptions) => Promise<void>;
|
|
334
|
+
/** Closes every session except the one making the call. */
|
|
335
|
+
revokeOthers: (options?: WriteOptions) => Promise<void>;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Confirms the buyer's identity again with their password or a sign-in code (`requestOtp` first). The
|
|
339
|
+
* confirmation lasts `valid_for_seconds` (a few minutes) and counts only for the session that made the call;
|
|
340
|
+
* exporting data and deleting the account need it (`403 reauth_required` otherwise, see `isReauthRequired`).
|
|
341
|
+
* A wrong credential is always the same `400`; too many tries is `429` (`StorefrontError.retryAfter`).
|
|
342
|
+
*/
|
|
343
|
+
reauth: (input: ReauthInput, options?: WriteOptions) => Promise<ReauthResult>;
|
|
344
|
+
/**
|
|
345
|
+
* The buyer's data as a JSON file (contract 1.9, `capabilities().data_export`). Needs a recent `reauth`. It is
|
|
346
|
+
* built on request and is neither stored nor emailed: call it from YOUR server, stream the bytes
|
|
347
|
+
* (`dataExportBytes`, `safeExportFilename`) with `Cache-Control: no-store`, and keep nothing. Three a day per account.
|
|
348
|
+
*/
|
|
349
|
+
exportData: (options?: WriteOptions) => Promise<DataExportFile>;
|
|
350
|
+
/**
|
|
351
|
+
* Deletes the buyer's account (contract 1.9, `capabilities().account_delete`). Needs a recent `reauth` and the
|
|
352
|
+
* text the buyer typed in `confirm`. Personal data is erased; orders and invoices are kept by the store.
|
|
353
|
+
* `409` (see `isAccountDeleteBlocked`) while an order is on its way or a payment is pending. Idempotent: a
|
|
354
|
+
* repeat after success is also fine. Afterwards the token is dead: drop it.
|
|
355
|
+
*/
|
|
356
|
+
deleteAccount: (input: AccountDeleteInput, options?: WriteOptions) => Promise<void>;
|
|
326
357
|
orders: (params?: PaginationParams, options?: RequestOptions) => Promise<Connection<Order>>;
|
|
327
358
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
328
359
|
order: (id: string, options?: RequestOptions) => Promise<Order | null>;
|
|
@@ -376,73 +407,6 @@ type StorefrontClient = ReturnType<typeof createStorefrontClient>;
|
|
|
376
407
|
/** `X-Storefront-Domain` value: the host, plus `#<market>` when a valid market code is given. */
|
|
377
408
|
declare function storefrontDomainHeader(domain: string, market?: string | null): string;
|
|
378
409
|
|
|
379
|
-
type StorefrontErrorInit = {
|
|
380
|
-
status: number;
|
|
381
|
-
code: StorefrontErrorCode;
|
|
382
|
-
message: string;
|
|
383
|
-
field?: string;
|
|
384
|
-
/** Raw `error.details` from the body (untrusted shape). */
|
|
385
|
-
details?: unknown;
|
|
386
|
-
/** Request URL that failed (without credentials). */
|
|
387
|
-
url?: string;
|
|
388
|
-
cause?: unknown;
|
|
389
|
-
/** Scopes named by the gateway on a `403 insufficient_scope`. */
|
|
390
|
-
requiredScopes?: string[];
|
|
391
|
-
/** `error.retryable` as OPS declared it (payment failures). `undefined` = OPS did not say. */
|
|
392
|
-
retryable?: boolean;
|
|
393
|
-
/** `error.retry_after` in seconds. */
|
|
394
|
-
retryAfter?: number;
|
|
395
|
-
/** `error.checkout_id`: the checkout a refused cart write can resume. */
|
|
396
|
-
checkoutId?: string;
|
|
397
|
-
/** `error.cost` of a `price_mismatch` (the cart's current cost; untrusted shape). */
|
|
398
|
-
cost?: unknown;
|
|
399
|
-
/** `error.message_en`. */
|
|
400
|
-
messageEn?: string;
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* Error thrown by the client for any non-2xx response, network failure,
|
|
404
|
-
* timeout or abort. `status` is `0` when no HTTP response was received.
|
|
405
|
-
*/
|
|
406
|
-
declare class StorefrontError extends Error {
|
|
407
|
-
readonly name = "StorefrontError";
|
|
408
|
-
readonly status: number;
|
|
409
|
-
readonly code: StorefrontErrorCode;
|
|
410
|
-
readonly field: string | undefined;
|
|
411
|
-
readonly details: unknown;
|
|
412
|
-
readonly url: string | undefined;
|
|
413
|
-
/** Scopes a `403 insufficient_scope` says the route needs (empty for any other error). */
|
|
414
|
-
readonly requiredScopes: string[];
|
|
415
|
-
/** `true`: repeating the request (same idempotency key) can succeed. `false`: not until someone fixes something. `undefined`: OPS did not say. */
|
|
416
|
-
readonly retryable: boolean | undefined;
|
|
417
|
-
/** Seconds OPS asks to wait before retrying. */
|
|
418
|
-
readonly retryAfter: number | undefined;
|
|
419
|
-
/** Checkout that a refused cart write can resume. */
|
|
420
|
-
readonly checkoutId: string | undefined;
|
|
421
|
-
/** Current cart cost sent with a `price_mismatch` (untrusted shape). */
|
|
422
|
-
readonly cost: unknown;
|
|
423
|
-
/** English version of `message`, when OPS sent one. */
|
|
424
|
-
readonly messageEn: string | undefined;
|
|
425
|
-
constructor(init: StorefrontErrorInit);
|
|
426
|
-
/**
|
|
427
|
-
* Affected lines of a `409 insufficient_stock` (empty for any other error or a
|
|
428
|
-
* server older than contract 1.1). The cart is untouched: show the lines and
|
|
429
|
-
* let the buyer adjust or remove them.
|
|
430
|
-
*/
|
|
431
|
-
get stockLines(): InsufficientStockLine[];
|
|
432
|
-
toJSON(): {
|
|
433
|
-
checkoutId?: string | undefined;
|
|
434
|
-
retryAfter?: number | undefined;
|
|
435
|
-
retryable?: boolean | undefined;
|
|
436
|
-
requiredScopes?: string[] | undefined;
|
|
437
|
-
name: string;
|
|
438
|
-
status: number;
|
|
439
|
-
code: StorefrontErrorCode;
|
|
440
|
-
message: string;
|
|
441
|
-
field: string | undefined;
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
declare function isStorefrontError(err: unknown): err is StorefrontError;
|
|
445
|
-
|
|
446
410
|
/**
|
|
447
411
|
* Classification of the failures of a card payment (`POST pay` / `GET status`). No texts, no DOM, no server APIs: the
|
|
448
412
|
* shop's server uses it to answer with `kind` and `retryable`, and the browser transport uses it to decide whether to
|
|
@@ -899,4 +863,4 @@ type DeliveryNotices = {
|
|
|
899
863
|
/** Splits `delivery.unavailable` into the `missing_weight` notice and the generic one. */
|
|
900
864
|
declare function deliveryNotices(delivery: Pick<DeliveryOptions, 'unavailable' | 'partial'> | null | undefined): DeliveryNotices;
|
|
901
865
|
|
|
902
|
-
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, CustomerUpdateInput, CustomerVerifyRegistrationInput, DeclineCode, type DeliveryChoice, type DeliveryChoiceKind, DeliveryInput, DeliveryMethod, type DeliveryNotices, DeliveryOptions, type DiagnoseOptions, type DiscountBarState, type DiscountBarView, type FetchLike, FiscalProfile, FiscalProfileInput, type FormatMoneyOptions, GeoPoint, InsufficientStockLine, InvoiceDoc, InvoiceFile, InvoiceFileKind, type InvoiceGroup, InvoiceRequest, InvoiceResult, Location, LocationListParams, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, NextAction, Order, OrderProgress, PAYMENT_CHOICE_REFUSED_FIELD, PICKUP_STEPS, Page, type PaginationParams, PaymentAttemptResult, PaymentConfig, type PaymentErrorClass, type PaymentErrorClassKind, type PaymentErrorKind, type PaymentErrorLike, type PaymentErrorView, type PaymentLocale, type PaymentMessageKey, type PaymentMessages, PaymentMethods, PaymentNextStep, type PaymentOutcome, type PaymentOutcomeKind, PaymentSubmitInput, PaymentVoucher, PendingPayment, type PreviewOptions, Product, ProductConnection, type ProductListParams, ProductSort, ProductVariant, type PromoProgressView, type PromotionLocale, type PromotionMessageKey, type PromotionMessages, PromotionReward, PromotionsList, type QueryParams, type QueryValue, RecommendationPlacement, Region, RegionPostalCode, type RequestOptions, type ResolveAvailabilityOptions, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, SHIPPING_STEPS, Shipment, ShipmentEvent, ShipmentStatus, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions,
|
|
866
|
+
export { AccountDeleteInput, 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, CustomerSessionInfo, CustomerSessionInput, CustomerSetPasswordInput, CustomerUpdateInput, CustomerVerifyRegistrationInput, DataExportFile, DeclineCode, type DeliveryChoice, type DeliveryChoiceKind, DeliveryInput, DeliveryMethod, type DeliveryNotices, DeliveryOptions, type DiagnoseOptions, type DiscountBarState, type DiscountBarView, type FetchLike, FiscalProfile, FiscalProfileInput, type FormatMoneyOptions, GeoPoint, InsufficientStockLine, InvoiceDoc, InvoiceFile, InvoiceFileKind, type InvoiceGroup, InvoiceRequest, InvoiceResult, Location, LocationListParams, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, NextAction, Order, OrderProgress, PAYMENT_CHOICE_REFUSED_FIELD, PICKUP_STEPS, Page, type PaginationParams, PaymentAttemptResult, PaymentConfig, type PaymentErrorClass, type PaymentErrorClassKind, type PaymentErrorKind, type PaymentErrorLike, type PaymentErrorView, type PaymentLocale, type PaymentMessageKey, type PaymentMessages, PaymentMethods, PaymentNextStep, type PaymentOutcome, type PaymentOutcomeKind, PaymentSubmitInput, PaymentVoucher, PendingPayment, type PreviewOptions, Product, ProductConnection, type ProductListParams, ProductSort, ProductVariant, type PromoProgressView, type PromotionLocale, type PromotionMessageKey, type PromotionMessages, PromotionReward, PromotionsList, type QueryParams, type QueryValue, ReauthInput, ReauthResult, RecommendationPlacement, Region, RegionPostalCode, type RequestOptions, type ResolveAvailabilityOptions, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, SHIPPING_STEPS, Shipment, ShipmentEvent, ShipmentStatus, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions, type StorefrontRequestContext, type StorefrontResponseContext, Theme, TokenIntrospection, UnavailableRateProvider, type WriteOptions, appendParams, availabilityLocale, availabilityMessages, availabilityView, cartLineProblemView, clampPercent, classifyPaymentError, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, diagnose, formatAvailabilityMessage, formatMoney, formatVoucherExpiry, generateIdempotencyKey, groupInvoiceDocs, hreflangLinks, invoiceFileBytes, isTestInvoice, isTestShipment, isTokenPublishable, maskToken, negotiateLocale, nextAction, normalizeClientIp, normalizeNote, opsSaysNotRetryable, orderProgress, orderShipments, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productAvailability, productListQuery, promoProgressView, promotionMessages, repairPath, resolveAvailability, rewardLabel, safeHttpsUrl, safeInvoiceFilename, safeTrackingUrl, schemaAvailability, shipmentsStatus, sortTrackingEvents, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
package/dist/index.js
CHANGED
|
@@ -410,6 +410,43 @@ function createStorefrontClient(config) {
|
|
|
410
410
|
get: (options) => get("/storefront/customer", void 0, options),
|
|
411
411
|
/** Updates the profile and the saved fiscal data; `fiscal: null` deletes the latter. `422` with `field: 'fiscal.<field>'`. */
|
|
412
412
|
update: (input, options) => write("PATCH", "/storefront/customer", input, options),
|
|
413
|
+
/**
|
|
414
|
+
* Active sessions of the buyer («Devices»; contract 1.9). Private, never cached. The list carries no address
|
|
415
|
+
* and no token: only what the buyer needs to recognize their own devices.
|
|
416
|
+
*/
|
|
417
|
+
sessions: {
|
|
418
|
+
list: async (options) => (await get("/storefront/customer/sessions", void 0, { ...options, cache: "no-store" })).nodes,
|
|
419
|
+
/** Closes one session. Repeating it is fine. `404` for a session that is not the buyer's. Closing the current one is a sign-out. */
|
|
420
|
+
revoke: (id, options) => write("DELETE", `/storefront/customer/sessions/${enc(id)}`, void 0, options),
|
|
421
|
+
/** Closes every session except the one making the call. */
|
|
422
|
+
revokeOthers: (options) => write("DELETE", "/storefront/customer/sessions/others", void 0, options)
|
|
423
|
+
},
|
|
424
|
+
/**
|
|
425
|
+
* Confirms the buyer's identity again with their password or a sign-in code (`requestOtp` first). The
|
|
426
|
+
* confirmation lasts `valid_for_seconds` (a few minutes) and counts only for the session that made the call;
|
|
427
|
+
* exporting data and deleting the account need it (`403 reauth_required` otherwise, see `isReauthRequired`).
|
|
428
|
+
* A wrong credential is always the same `400`; too many tries is `429` (`StorefrontError.retryAfter`).
|
|
429
|
+
*/
|
|
430
|
+
reauth: (input, options) => write("POST", "/storefront/customer/reauth", input, options),
|
|
431
|
+
/**
|
|
432
|
+
* The buyer's data as a JSON file (contract 1.9, `capabilities().data_export`). Needs a recent `reauth`. It is
|
|
433
|
+
* built on request and is neither stored nor emailed: call it from YOUR server, stream the bytes
|
|
434
|
+
* (`dataExportBytes`, `safeExportFilename`) with `Cache-Control: no-store`, and keep nothing. Three a day per account.
|
|
435
|
+
*/
|
|
436
|
+
exportData: async (options) => {
|
|
437
|
+
const file = await write("POST", "/storefront/customer/data-export", void 0, { ...options, cache: "no-store" });
|
|
438
|
+
if (!file || typeof file.content_base64 !== "string" || typeof file.filename !== "string" || typeof file.content_type !== "string") {
|
|
439
|
+
throw new StorefrontError({ status: 502, code: "invalid_response", message: "The data export answer is not a file" });
|
|
440
|
+
}
|
|
441
|
+
return { filename: file.filename, content_type: file.content_type, content_base64: file.content_base64 };
|
|
442
|
+
},
|
|
443
|
+
/**
|
|
444
|
+
* Deletes the buyer's account (contract 1.9, `capabilities().account_delete`). Needs a recent `reauth` and the
|
|
445
|
+
* text the buyer typed in `confirm`. Personal data is erased; orders and invoices are kept by the store.
|
|
446
|
+
* `409` (see `isAccountDeleteBlocked`) while an order is on its way or a payment is pending. Idempotent: a
|
|
447
|
+
* repeat after success is also fine. Afterwards the token is dead: drop it.
|
|
448
|
+
*/
|
|
449
|
+
deleteAccount: (input, options) => write("DELETE", "/storefront/customer", input, options),
|
|
413
450
|
orders: (params, options) => get("/storefront/customer/orders", params, options),
|
|
414
451
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
415
452
|
order: (id, options) => getOrNull(`/storefront/customer/orders/${enc(id)}`, void 0, options),
|
|
@@ -806,6 +843,29 @@ function hreflangLinks(markets, path, defaultMarket, protocol = "https") {
|
|
|
806
843
|
return links;
|
|
807
844
|
}
|
|
808
845
|
|
|
846
|
+
// src/account-settings.ts
|
|
847
|
+
function isReauthRequired(error) {
|
|
848
|
+
const e = error;
|
|
849
|
+
return !!e && typeof e === "object" && e.status === 403 && e.code === "reauth_required";
|
|
850
|
+
}
|
|
851
|
+
function isAccountDeleteBlocked(error) {
|
|
852
|
+
const e = error;
|
|
853
|
+
return !!e && typeof e === "object" && e.status === 409 && (e.field === "orders" || e.field === "pending_payments");
|
|
854
|
+
}
|
|
855
|
+
function dataExportBytes(file) {
|
|
856
|
+
const raw = typeof file.content_base64 === "string" ? file.content_base64.replace(/\s+/g, "") : "";
|
|
857
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(raw) || raw.length % 4 === 1) throw new TypeError("data export is not valid base64");
|
|
858
|
+
const bin = atob(raw);
|
|
859
|
+
const out = new Uint8Array(bin.length);
|
|
860
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
861
|
+
return out;
|
|
862
|
+
}
|
|
863
|
+
function safeExportFilename(name, fallback = "account-data.json") {
|
|
864
|
+
const base = typeof name === "string" ? name.split(/[\\/]/).pop() ?? "" : "";
|
|
865
|
+
const clean = base.replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^\.+/, "").slice(0, 80);
|
|
866
|
+
return clean || fallback;
|
|
867
|
+
}
|
|
868
|
+
|
|
809
869
|
// src/invoice-docs.ts
|
|
810
870
|
function groupInvoiceDocs(docs) {
|
|
811
871
|
const list = Array.isArray(docs) ? docs.filter((d) => !!d && typeof d === "object") : [];
|
|
@@ -859,6 +919,6 @@ function deliveryNotices(delivery) {
|
|
|
859
919
|
};
|
|
860
920
|
}
|
|
861
921
|
|
|
862
|
-
export { CLIENT_IP_HEADER, COUNTRY_HEADERS, MISSING_WEIGHT, NOTE_MAX_LENGTH, PAYMENT_CHOICE_REFUSED_FIELD, appendParams, clampPercent, classifyPaymentError, createStorefrontClient, deliveryInput, deliveryNotices, diagnose, formatMoney, generateIdempotencyKey, groupInvoiceDocs, hreflangLinks, invoiceFileBytes, isTokenPublishable, maskToken, negotiateLocale, normalizeClientIp, normalizeNote, opsSaysNotRetryable, parseDelivery, parseMoney, parseProductFilters, preferredLanguages, productListQuery, promoProgressView, promotionMessages, repairPath, rewardLabel, safeInvoiceFilename, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
|
922
|
+
export { CLIENT_IP_HEADER, COUNTRY_HEADERS, MISSING_WEIGHT, NOTE_MAX_LENGTH, PAYMENT_CHOICE_REFUSED_FIELD, appendParams, clampPercent, classifyPaymentError, createStorefrontClient, dataExportBytes, deliveryInput, deliveryNotices, diagnose, formatMoney, generateIdempotencyKey, groupInvoiceDocs, hreflangLinks, invoiceFileBytes, isAccountDeleteBlocked, isReauthRequired, isTokenPublishable, maskToken, negotiateLocale, normalizeClientIp, normalizeNote, opsSaysNotRetryable, parseDelivery, parseMoney, parseProductFilters, preferredLanguages, productListQuery, promoProgressView, promotionMessages, repairPath, rewardLabel, safeExportFilename, safeInvoiceFilename, storefrontDomainHeader, suggestMarket, toMoney, visitorCountry };
|
|
863
923
|
//# sourceMappingURL=index.js.map
|
|
864
924
|
//# sourceMappingURL=index.js.map
|