@asteby/storefront 0.16.1 → 0.18.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 +24 -0
- package/dist/{types-DSHzYSHU.d.ts → account-settings-Cw3PamUA.d.ts} +241 -1
- package/dist/{types-C5nEQicj.d.cts → account-settings-DAzmXHIn.d.cts} +241 -1
- package/dist/{chunk-IPUAZ3LQ.js → chunk-5BJRZIS3.js} +196 -3
- package/dist/chunk-5BJRZIS3.js.map +1 -0
- package/dist/cli.js +62 -2
- package/dist/fiscal-document.d.cts +2 -2
- package/dist/fiscal-document.d.ts +2 -2
- package/dist/index.cjs +296 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +135 -70
- package/dist/index.d.ts +135 -70
- package/dist/index.js +87 -4
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +403 -3
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +33 -2
- package/dist/mock.d.ts +33 -2
- package/dist/mock.js +299 -5
- 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/chunk-IPUAZ3LQ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { b4 as ProductSort, bQ 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, bG as Subject, bL as SubjectInput, bN as SubjectPatch, a as Address, bM as SubjectKind, bP 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, bI as SubjectCatalogNode, bJ as SubjectField, T as DeliveryMethod, bR as UnavailableRateProvider } from './account-settings-DAzmXHIn.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, bH as SubjectCatalog, bK as SubjectFieldType, bO as SubjectRef, bS as dataExportBytes, bT as isAccountDeleteBlocked, bU as isReauthRequired, bV as isStorefrontError, bW as safeExportFilename } from './account-settings-DAzmXHIn.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[]>;
|
|
@@ -29,6 +29,11 @@ type ProductListParams = PaginationParams & {
|
|
|
29
29
|
filters?: Record<string, QueryValue | QueryValue[]>;
|
|
30
30
|
/** Restrict to these handles (max 100). Serialized comma-separated. */
|
|
31
31
|
handles?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Only products carrying at least one of these tags (OR, at most 5 of 120 characters; contract 1.9). Serialized
|
|
34
|
+
* comma-separated. A parts store passes `fitTagsAny(fitKey)` (`fit:<key>`, `fit:universal`); any tag works.
|
|
35
|
+
*/
|
|
36
|
+
tags_any?: string[];
|
|
32
37
|
};
|
|
33
38
|
type CollectionListParams = PaginationParams;
|
|
34
39
|
type ArticleListParams = Omit<PaginationParams, 'first'> & {
|
|
@@ -323,6 +328,37 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
323
328
|
get: (options?: RequestOptions) => Promise<Customer>;
|
|
324
329
|
/** Updates the profile and the saved fiscal data; `fiscal: null` deletes the latter. `422` with `field: 'fiscal.<field>'`. */
|
|
325
330
|
update: (input: CustomerUpdateInput, options?: WriteOptions) => Promise<Customer>;
|
|
331
|
+
/**
|
|
332
|
+
* Active sessions of the buyer («Devices»; contract 1.9). Private, never cached. The list carries no address
|
|
333
|
+
* and no token: only what the buyer needs to recognize their own devices.
|
|
334
|
+
*/
|
|
335
|
+
sessions: {
|
|
336
|
+
list: (options?: RequestOptions) => Promise<CustomerSessionInfo[]>;
|
|
337
|
+
/** 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. */
|
|
338
|
+
revoke: (id: string, options?: WriteOptions) => Promise<void>;
|
|
339
|
+
/** Closes every session except the one making the call. */
|
|
340
|
+
revokeOthers: (options?: WriteOptions) => Promise<void>;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Confirms the buyer's identity again with their password or a sign-in code (`requestOtp` first). The
|
|
344
|
+
* confirmation lasts `valid_for_seconds` (a few minutes) and counts only for the session that made the call;
|
|
345
|
+
* exporting data and deleting the account need it (`403 reauth_required` otherwise, see `isReauthRequired`).
|
|
346
|
+
* A wrong credential is always the same `400`; too many tries is `429` (`StorefrontError.retryAfter`).
|
|
347
|
+
*/
|
|
348
|
+
reauth: (input: ReauthInput, options?: WriteOptions) => Promise<ReauthResult>;
|
|
349
|
+
/**
|
|
350
|
+
* The buyer's data as a JSON file (contract 1.9, `capabilities().data_export`). Needs a recent `reauth`. It is
|
|
351
|
+
* built on request and is neither stored nor emailed: call it from YOUR server, stream the bytes
|
|
352
|
+
* (`dataExportBytes`, `safeExportFilename`) with `Cache-Control: no-store`, and keep nothing. Three a day per account.
|
|
353
|
+
*/
|
|
354
|
+
exportData: (options?: WriteOptions) => Promise<DataExportFile>;
|
|
355
|
+
/**
|
|
356
|
+
* Deletes the buyer's account (contract 1.9, `capabilities().account_delete`). Needs a recent `reauth` and the
|
|
357
|
+
* text the buyer typed in `confirm`. Personal data is erased; orders and invoices are kept by the store.
|
|
358
|
+
* `409` (see `isAccountDeleteBlocked`) while an order is on its way or a payment is pending. Idempotent: a
|
|
359
|
+
* repeat after success is also fine. Afterwards the token is dead: drop it.
|
|
360
|
+
*/
|
|
361
|
+
deleteAccount: (input: AccountDeleteInput, options?: WriteOptions) => Promise<void>;
|
|
326
362
|
orders: (params?: PaginationParams, options?: RequestOptions) => Promise<Connection<Order>>;
|
|
327
363
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
328
364
|
order: (id: string, options?: RequestOptions) => Promise<Order | null>;
|
|
@@ -352,6 +388,21 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
352
388
|
/** Physical delete (a profile leaves nothing behind). A saved default passes to another profile. */
|
|
353
389
|
delete: (id: string, options?: WriteOptions) => Promise<void>;
|
|
354
390
|
};
|
|
391
|
+
/**
|
|
392
|
+
* Saved items of the buyer («My items», «My garage»; contract 1.9, `capabilities().subjects`). Personal data:
|
|
393
|
+
* private, never cached, never logged. `422` with `field: 'attributes.<field>'` when the kind refuses a value
|
|
394
|
+
* (it never echoes it); `409` for an item already saved or past the limit; `429` for too many saves; `404` for
|
|
395
|
+
* an item that is not the buyer's. The server builds `label` and `fit_key`; private fields come back masked.
|
|
396
|
+
*/
|
|
397
|
+
subjects: {
|
|
398
|
+
list: (params?: {
|
|
399
|
+
kind?: string;
|
|
400
|
+
}, options?: RequestOptions) => Promise<Subject[]>;
|
|
401
|
+
create: (input: SubjectInput, options?: WriteOptions) => Promise<Subject>;
|
|
402
|
+
update: (id: string, patch: SubjectPatch, options?: WriteOptions) => Promise<Subject>;
|
|
403
|
+
/** Physical delete (the item leaves nothing behind). The default of its kind passes to another item. */
|
|
404
|
+
delete: (id: string, options?: WriteOptions) => Promise<void>;
|
|
405
|
+
};
|
|
355
406
|
addresses: {
|
|
356
407
|
list: (options?: RequestOptions) => Promise<{
|
|
357
408
|
nodes: Address[];
|
|
@@ -362,6 +413,11 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
362
413
|
};
|
|
363
414
|
};
|
|
364
415
|
content: {
|
|
416
|
+
/**
|
|
417
|
+
* The kinds of buyer item the organization declares («My garage») and their catalogs (contract 1.9; public,
|
|
418
|
+
* cacheable). `[]` when it declares none or the server predates the route: the store has no such section.
|
|
419
|
+
*/
|
|
420
|
+
subjectKinds: (options?: RequestOptions) => Promise<SubjectKind[]>;
|
|
365
421
|
theme: (options?: RequestOptions) => Promise<Theme>;
|
|
366
422
|
/** `null` when the page does not exist. */
|
|
367
423
|
page: (handle: string, options?: PreviewOptions) => Promise<Page | null>;
|
|
@@ -376,73 +432,6 @@ type StorefrontClient = ReturnType<typeof createStorefrontClient>;
|
|
|
376
432
|
/** `X-Storefront-Domain` value: the host, plus `#<market>` when a valid market code is given. */
|
|
377
433
|
declare function storefrontDomainHeader(domain: string, market?: string | null): string;
|
|
378
434
|
|
|
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
435
|
/**
|
|
447
436
|
* Classification of the failures of a card payment (`POST pay` / `GET status`). No texts, no DOM, no server APIs: the
|
|
448
437
|
* shop's server uses it to answer with `kind` and `retryable`, and the browser transport uses it to decide whether to
|
|
@@ -868,6 +857,82 @@ declare function invoiceFileBytes(file: Pick<InvoiceFile, 'content_base64'>): Ui
|
|
|
868
857
|
/** A download filename that is safe in a `Content-Disposition` header: no path, quotes, control characters or spaces. */
|
|
869
858
|
declare function safeInvoiceFilename(name: unknown, fallback?: string): string;
|
|
870
859
|
|
|
860
|
+
declare const MIN_SUBJECT_YEAR = 1900;
|
|
861
|
+
declare const MAX_SUBJECT_YEAR = 2100;
|
|
862
|
+
type SubjectOption = {
|
|
863
|
+
value: string;
|
|
864
|
+
label: string;
|
|
865
|
+
};
|
|
866
|
+
type SubjectValues = Record<string, string | number | null | undefined>;
|
|
867
|
+
/** Why a value was refused (the server answers `422` with the field `attributes.<key>` and never the value). */
|
|
868
|
+
type SubjectProblemCode = 'required' | 'unknown' | 'invalid' | 'not_in_catalog' | 'year_range' | 'catalog_unavailable';
|
|
869
|
+
type SubjectProblems = Record<string, SubjectProblemCode>;
|
|
870
|
+
type ResolvedSubject = {
|
|
871
|
+
/** Built from the labels of the catalog and the public values, in field order. */
|
|
872
|
+
label: string;
|
|
873
|
+
/** `''` when a placeholder of the template has no value (the item then never matches a product). */
|
|
874
|
+
fit_key: string;
|
|
875
|
+
/** Public values, as the server stores them in `attributes`. */
|
|
876
|
+
attributes: Record<string, string | number>;
|
|
877
|
+
/** Private values: never in the label, the key or a tag. */
|
|
878
|
+
private: Record<string, string>;
|
|
879
|
+
};
|
|
880
|
+
/** Does the option cover the model year? Declared `ranges` win; else `from`/`to`; an option with none covers any year. */
|
|
881
|
+
declare function coversYear(node: Pick<SubjectCatalogNode, 'from' | 'to' | 'ranges'>, year: number): boolean;
|
|
882
|
+
/** The catalog fields that make the tree's levels, in order: `source: catalog` and not a year. */
|
|
883
|
+
declare function subjectLevels(kind: Pick<SubjectKind, 'fields'>): SubjectField[];
|
|
884
|
+
/** The visible fields of a form: everything the buyer fills in, in the order of the kind. */
|
|
885
|
+
declare function subjectFields(kind: Pick<SubjectKind, 'fields'>): SubjectField[];
|
|
886
|
+
/**
|
|
887
|
+
* The options a catalog field offers given what is already chosen (a cascade: a level shows nothing until the previous
|
|
888
|
+
* one is chosen). A level narrows by the chosen year when the option declares years; a year field offers the model
|
|
889
|
+
* years the chosen options cover (newest first), or nothing when no option declares years (a free number then).
|
|
890
|
+
*/
|
|
891
|
+
declare function subjectOptions(kind: SubjectKind, fieldKey: string, values: SubjectValues): SubjectOption[];
|
|
892
|
+
/**
|
|
893
|
+
* Drops what was chosen and is no longer valid after a change (a new make clears the model; a year the model does not
|
|
894
|
+
* cover is cleared), in field order. Free values are never touched.
|
|
895
|
+
*/
|
|
896
|
+
declare function reconcileSubjectValues(kind: SubjectKind, values: SubjectValues): SubjectValues;
|
|
897
|
+
/**
|
|
898
|
+
* Validates and resolves the values the way the server does: unknown field, wrong type, a value missing from the
|
|
899
|
+
* catalog and a year outside the chosen options' years are refused, naming the field only.
|
|
900
|
+
*/
|
|
901
|
+
declare function resolveSubject(kind: SubjectKind, values: SubjectValues): {
|
|
902
|
+
ok: true;
|
|
903
|
+
subject: ResolvedSubject;
|
|
904
|
+
} | {
|
|
905
|
+
ok: false;
|
|
906
|
+
problems: SubjectProblems;
|
|
907
|
+
};
|
|
908
|
+
/** The mask the server puts in place of a private value («••34»). */
|
|
909
|
+
declare const PRIVATE_MASK = "\u2022\u2022";
|
|
910
|
+
declare const isMasked: (v: unknown) => boolean;
|
|
911
|
+
/** Prefix of the tag that publishes compatibility (`<prefix><fit_key>`), as in `FitmentConfig.tagPrefix`. */
|
|
912
|
+
declare const DEFAULT_FIT_TAG_PREFIX = "fit:";
|
|
913
|
+
/** The product tag that marks a part as fitting the item with this key. */
|
|
914
|
+
declare const fitTag: (fitKey: string, prefix?: string) => string;
|
|
915
|
+
/**
|
|
916
|
+
* The `tags_any` of a listing "only what fits my item": its own tag plus the universal one (`<prefix>universal`).
|
|
917
|
+
* `[]` when the item has no key (it does not resolve completely): ask for nothing rather than for the wrong thing.
|
|
918
|
+
*/
|
|
919
|
+
declare function fitTagsAny(fitKey: string | null | undefined, opts?: {
|
|
920
|
+
prefix?: string;
|
|
921
|
+
universal?: boolean;
|
|
922
|
+
}): string[];
|
|
923
|
+
/**
|
|
924
|
+
* Budget of one catalog page, in bytes of the `tree` prop as OPS stores it (text, so every quote is escaped). Publishing
|
|
925
|
+
* a page is ONE write of at most 64 KiB that carries the draft and the published copy: ~28 KB of tree per page.
|
|
926
|
+
*/
|
|
927
|
+
declare const SUBJECT_CATALOG_PAGE_BYTES: number;
|
|
928
|
+
/**
|
|
929
|
+
* Splits a catalog tree by its first level into parts that each fit one page (`subject_catalog` section, prop `tree`).
|
|
930
|
+
* Publish part `i` on its own page and name them all in the kind's `catalog_ref` (`["page:x-1", "page:x-2", …]`); the
|
|
931
|
+
* server joins them back. A real parts catalog (make → model → engine) does not fit in one page. Throws `RangeError`
|
|
932
|
+
* when a single first-level option is larger than the budget on its own (split that level by hand, or trim labels).
|
|
933
|
+
*/
|
|
934
|
+
declare function splitSubjectTree(tree: Record<string, SubjectCatalogNode>, maxBytes?: number): Record<string, SubjectCatalogNode>[];
|
|
935
|
+
|
|
871
936
|
/** Kind of a delivery radio: `ship` (address only, quote later), `rate` (a quoted rate) or `pickup` (a branch). */
|
|
872
937
|
type DeliveryChoiceKind = 'ship' | 'rate' | 'pickup';
|
|
873
938
|
type DeliveryChoice = {
|
|
@@ -899,4 +964,4 @@ type DeliveryNotices = {
|
|
|
899
964
|
/** Splits `delivery.unavailable` into the `missing_weight` notice and the generic one. */
|
|
900
965
|
declare function deliveryNotices(delivery: Pick<DeliveryOptions, 'unavailable' | 'partial'> | null | undefined): DeliveryNotices;
|
|
901
966
|
|
|
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,
|
|
967
|
+
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, DEFAULT_FIT_TAG_PREFIX, 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, MAX_SUBJECT_YEAR, MIN_SUBJECT_YEAR, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, NextAction, Order, OrderProgress, PAYMENT_CHOICE_REFUSED_FIELD, PICKUP_STEPS, PRIVATE_MASK, 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, type ResolvedSubject, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, SHIPPING_STEPS, SUBJECT_CATALOG_PAGE_BYTES, Shipment, ShipmentEvent, ShipmentStatus, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions, type StorefrontRequestContext, type StorefrontResponseContext, Subject, SubjectCatalogNode, SubjectField, SubjectInput, SubjectKind, type SubjectOption, SubjectPatch, type SubjectProblemCode, type SubjectProblems, type SubjectValues, Theme, TokenIntrospection, UnavailableRateProvider, type WriteOptions, appendParams, availabilityLocale, availabilityMessages, availabilityView, cartLineProblemView, clampPercent, classifyPaymentError, coversYear, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, diagnose, fitTag, fitTagsAny, formatAvailabilityMessage, formatMoney, formatVoucherExpiry, generateIdempotencyKey, groupInvoiceDocs, hreflangLinks, invoiceFileBytes, isMasked, isTestInvoice, isTestShipment, isTokenPublishable, maskToken, negotiateLocale, nextAction, normalizeClientIp, normalizeNote, opsSaysNotRetryable, orderProgress, orderShipments, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productAvailability, productListQuery, promoProgressView, promotionMessages, reconcileSubjectValues, repairPath, resolveAvailability, resolveSubject, rewardLabel, safeHttpsUrl, safeInvoiceFilename, safeTrackingUrl, schemaAvailability, shipmentsStatus, sortTrackingEvents, splitSubjectTree, storefrontDomainHeader, subjectFields, subjectLevels, subjectOptions, suggestMarket, toMoney, visitorCountry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { b4 as ProductSort, bQ 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, bG as Subject, bL as SubjectInput, bN as SubjectPatch, a as Address, bM as SubjectKind, bP 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, bI as SubjectCatalogNode, bJ as SubjectField, T as DeliveryMethod, bR as UnavailableRateProvider } from './account-settings-Cw3PamUA.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, bH as SubjectCatalog, bK as SubjectFieldType, bO as SubjectRef, bS as dataExportBytes, bT as isAccountDeleteBlocked, bU as isReauthRequired, bV as isStorefrontError, bW as safeExportFilename } from './account-settings-Cw3PamUA.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[]>;
|
|
@@ -29,6 +29,11 @@ type ProductListParams = PaginationParams & {
|
|
|
29
29
|
filters?: Record<string, QueryValue | QueryValue[]>;
|
|
30
30
|
/** Restrict to these handles (max 100). Serialized comma-separated. */
|
|
31
31
|
handles?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Only products carrying at least one of these tags (OR, at most 5 of 120 characters; contract 1.9). Serialized
|
|
34
|
+
* comma-separated. A parts store passes `fitTagsAny(fitKey)` (`fit:<key>`, `fit:universal`); any tag works.
|
|
35
|
+
*/
|
|
36
|
+
tags_any?: string[];
|
|
32
37
|
};
|
|
33
38
|
type CollectionListParams = PaginationParams;
|
|
34
39
|
type ArticleListParams = Omit<PaginationParams, 'first'> & {
|
|
@@ -323,6 +328,37 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
323
328
|
get: (options?: RequestOptions) => Promise<Customer>;
|
|
324
329
|
/** Updates the profile and the saved fiscal data; `fiscal: null` deletes the latter. `422` with `field: 'fiscal.<field>'`. */
|
|
325
330
|
update: (input: CustomerUpdateInput, options?: WriteOptions) => Promise<Customer>;
|
|
331
|
+
/**
|
|
332
|
+
* Active sessions of the buyer («Devices»; contract 1.9). Private, never cached. The list carries no address
|
|
333
|
+
* and no token: only what the buyer needs to recognize their own devices.
|
|
334
|
+
*/
|
|
335
|
+
sessions: {
|
|
336
|
+
list: (options?: RequestOptions) => Promise<CustomerSessionInfo[]>;
|
|
337
|
+
/** 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. */
|
|
338
|
+
revoke: (id: string, options?: WriteOptions) => Promise<void>;
|
|
339
|
+
/** Closes every session except the one making the call. */
|
|
340
|
+
revokeOthers: (options?: WriteOptions) => Promise<void>;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Confirms the buyer's identity again with their password or a sign-in code (`requestOtp` first). The
|
|
344
|
+
* confirmation lasts `valid_for_seconds` (a few minutes) and counts only for the session that made the call;
|
|
345
|
+
* exporting data and deleting the account need it (`403 reauth_required` otherwise, see `isReauthRequired`).
|
|
346
|
+
* A wrong credential is always the same `400`; too many tries is `429` (`StorefrontError.retryAfter`).
|
|
347
|
+
*/
|
|
348
|
+
reauth: (input: ReauthInput, options?: WriteOptions) => Promise<ReauthResult>;
|
|
349
|
+
/**
|
|
350
|
+
* The buyer's data as a JSON file (contract 1.9, `capabilities().data_export`). Needs a recent `reauth`. It is
|
|
351
|
+
* built on request and is neither stored nor emailed: call it from YOUR server, stream the bytes
|
|
352
|
+
* (`dataExportBytes`, `safeExportFilename`) with `Cache-Control: no-store`, and keep nothing. Three a day per account.
|
|
353
|
+
*/
|
|
354
|
+
exportData: (options?: WriteOptions) => Promise<DataExportFile>;
|
|
355
|
+
/**
|
|
356
|
+
* Deletes the buyer's account (contract 1.9, `capabilities().account_delete`). Needs a recent `reauth` and the
|
|
357
|
+
* text the buyer typed in `confirm`. Personal data is erased; orders and invoices are kept by the store.
|
|
358
|
+
* `409` (see `isAccountDeleteBlocked`) while an order is on its way or a payment is pending. Idempotent: a
|
|
359
|
+
* repeat after success is also fine. Afterwards the token is dead: drop it.
|
|
360
|
+
*/
|
|
361
|
+
deleteAccount: (input: AccountDeleteInput, options?: WriteOptions) => Promise<void>;
|
|
326
362
|
orders: (params?: PaginationParams, options?: RequestOptions) => Promise<Connection<Order>>;
|
|
327
363
|
/** `null` when the order does not exist or belongs to someone else. */
|
|
328
364
|
order: (id: string, options?: RequestOptions) => Promise<Order | null>;
|
|
@@ -352,6 +388,21 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
352
388
|
/** Physical delete (a profile leaves nothing behind). A saved default passes to another profile. */
|
|
353
389
|
delete: (id: string, options?: WriteOptions) => Promise<void>;
|
|
354
390
|
};
|
|
391
|
+
/**
|
|
392
|
+
* Saved items of the buyer («My items», «My garage»; contract 1.9, `capabilities().subjects`). Personal data:
|
|
393
|
+
* private, never cached, never logged. `422` with `field: 'attributes.<field>'` when the kind refuses a value
|
|
394
|
+
* (it never echoes it); `409` for an item already saved or past the limit; `429` for too many saves; `404` for
|
|
395
|
+
* an item that is not the buyer's. The server builds `label` and `fit_key`; private fields come back masked.
|
|
396
|
+
*/
|
|
397
|
+
subjects: {
|
|
398
|
+
list: (params?: {
|
|
399
|
+
kind?: string;
|
|
400
|
+
}, options?: RequestOptions) => Promise<Subject[]>;
|
|
401
|
+
create: (input: SubjectInput, options?: WriteOptions) => Promise<Subject>;
|
|
402
|
+
update: (id: string, patch: SubjectPatch, options?: WriteOptions) => Promise<Subject>;
|
|
403
|
+
/** Physical delete (the item leaves nothing behind). The default of its kind passes to another item. */
|
|
404
|
+
delete: (id: string, options?: WriteOptions) => Promise<void>;
|
|
405
|
+
};
|
|
355
406
|
addresses: {
|
|
356
407
|
list: (options?: RequestOptions) => Promise<{
|
|
357
408
|
nodes: Address[];
|
|
@@ -362,6 +413,11 @@ declare function createStorefrontClient(config: StorefrontClientOptions): {
|
|
|
362
413
|
};
|
|
363
414
|
};
|
|
364
415
|
content: {
|
|
416
|
+
/**
|
|
417
|
+
* The kinds of buyer item the organization declares («My garage») and their catalogs (contract 1.9; public,
|
|
418
|
+
* cacheable). `[]` when it declares none or the server predates the route: the store has no such section.
|
|
419
|
+
*/
|
|
420
|
+
subjectKinds: (options?: RequestOptions) => Promise<SubjectKind[]>;
|
|
365
421
|
theme: (options?: RequestOptions) => Promise<Theme>;
|
|
366
422
|
/** `null` when the page does not exist. */
|
|
367
423
|
page: (handle: string, options?: PreviewOptions) => Promise<Page | null>;
|
|
@@ -376,73 +432,6 @@ type StorefrontClient = ReturnType<typeof createStorefrontClient>;
|
|
|
376
432
|
/** `X-Storefront-Domain` value: the host, plus `#<market>` when a valid market code is given. */
|
|
377
433
|
declare function storefrontDomainHeader(domain: string, market?: string | null): string;
|
|
378
434
|
|
|
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
435
|
/**
|
|
447
436
|
* Classification of the failures of a card payment (`POST pay` / `GET status`). No texts, no DOM, no server APIs: the
|
|
448
437
|
* shop's server uses it to answer with `kind` and `retryable`, and the browser transport uses it to decide whether to
|
|
@@ -868,6 +857,82 @@ declare function invoiceFileBytes(file: Pick<InvoiceFile, 'content_base64'>): Ui
|
|
|
868
857
|
/** A download filename that is safe in a `Content-Disposition` header: no path, quotes, control characters or spaces. */
|
|
869
858
|
declare function safeInvoiceFilename(name: unknown, fallback?: string): string;
|
|
870
859
|
|
|
860
|
+
declare const MIN_SUBJECT_YEAR = 1900;
|
|
861
|
+
declare const MAX_SUBJECT_YEAR = 2100;
|
|
862
|
+
type SubjectOption = {
|
|
863
|
+
value: string;
|
|
864
|
+
label: string;
|
|
865
|
+
};
|
|
866
|
+
type SubjectValues = Record<string, string | number | null | undefined>;
|
|
867
|
+
/** Why a value was refused (the server answers `422` with the field `attributes.<key>` and never the value). */
|
|
868
|
+
type SubjectProblemCode = 'required' | 'unknown' | 'invalid' | 'not_in_catalog' | 'year_range' | 'catalog_unavailable';
|
|
869
|
+
type SubjectProblems = Record<string, SubjectProblemCode>;
|
|
870
|
+
type ResolvedSubject = {
|
|
871
|
+
/** Built from the labels of the catalog and the public values, in field order. */
|
|
872
|
+
label: string;
|
|
873
|
+
/** `''` when a placeholder of the template has no value (the item then never matches a product). */
|
|
874
|
+
fit_key: string;
|
|
875
|
+
/** Public values, as the server stores them in `attributes`. */
|
|
876
|
+
attributes: Record<string, string | number>;
|
|
877
|
+
/** Private values: never in the label, the key or a tag. */
|
|
878
|
+
private: Record<string, string>;
|
|
879
|
+
};
|
|
880
|
+
/** Does the option cover the model year? Declared `ranges` win; else `from`/`to`; an option with none covers any year. */
|
|
881
|
+
declare function coversYear(node: Pick<SubjectCatalogNode, 'from' | 'to' | 'ranges'>, year: number): boolean;
|
|
882
|
+
/** The catalog fields that make the tree's levels, in order: `source: catalog` and not a year. */
|
|
883
|
+
declare function subjectLevels(kind: Pick<SubjectKind, 'fields'>): SubjectField[];
|
|
884
|
+
/** The visible fields of a form: everything the buyer fills in, in the order of the kind. */
|
|
885
|
+
declare function subjectFields(kind: Pick<SubjectKind, 'fields'>): SubjectField[];
|
|
886
|
+
/**
|
|
887
|
+
* The options a catalog field offers given what is already chosen (a cascade: a level shows nothing until the previous
|
|
888
|
+
* one is chosen). A level narrows by the chosen year when the option declares years; a year field offers the model
|
|
889
|
+
* years the chosen options cover (newest first), or nothing when no option declares years (a free number then).
|
|
890
|
+
*/
|
|
891
|
+
declare function subjectOptions(kind: SubjectKind, fieldKey: string, values: SubjectValues): SubjectOption[];
|
|
892
|
+
/**
|
|
893
|
+
* Drops what was chosen and is no longer valid after a change (a new make clears the model; a year the model does not
|
|
894
|
+
* cover is cleared), in field order. Free values are never touched.
|
|
895
|
+
*/
|
|
896
|
+
declare function reconcileSubjectValues(kind: SubjectKind, values: SubjectValues): SubjectValues;
|
|
897
|
+
/**
|
|
898
|
+
* Validates and resolves the values the way the server does: unknown field, wrong type, a value missing from the
|
|
899
|
+
* catalog and a year outside the chosen options' years are refused, naming the field only.
|
|
900
|
+
*/
|
|
901
|
+
declare function resolveSubject(kind: SubjectKind, values: SubjectValues): {
|
|
902
|
+
ok: true;
|
|
903
|
+
subject: ResolvedSubject;
|
|
904
|
+
} | {
|
|
905
|
+
ok: false;
|
|
906
|
+
problems: SubjectProblems;
|
|
907
|
+
};
|
|
908
|
+
/** The mask the server puts in place of a private value («••34»). */
|
|
909
|
+
declare const PRIVATE_MASK = "\u2022\u2022";
|
|
910
|
+
declare const isMasked: (v: unknown) => boolean;
|
|
911
|
+
/** Prefix of the tag that publishes compatibility (`<prefix><fit_key>`), as in `FitmentConfig.tagPrefix`. */
|
|
912
|
+
declare const DEFAULT_FIT_TAG_PREFIX = "fit:";
|
|
913
|
+
/** The product tag that marks a part as fitting the item with this key. */
|
|
914
|
+
declare const fitTag: (fitKey: string, prefix?: string) => string;
|
|
915
|
+
/**
|
|
916
|
+
* The `tags_any` of a listing "only what fits my item": its own tag plus the universal one (`<prefix>universal`).
|
|
917
|
+
* `[]` when the item has no key (it does not resolve completely): ask for nothing rather than for the wrong thing.
|
|
918
|
+
*/
|
|
919
|
+
declare function fitTagsAny(fitKey: string | null | undefined, opts?: {
|
|
920
|
+
prefix?: string;
|
|
921
|
+
universal?: boolean;
|
|
922
|
+
}): string[];
|
|
923
|
+
/**
|
|
924
|
+
* Budget of one catalog page, in bytes of the `tree` prop as OPS stores it (text, so every quote is escaped). Publishing
|
|
925
|
+
* a page is ONE write of at most 64 KiB that carries the draft and the published copy: ~28 KB of tree per page.
|
|
926
|
+
*/
|
|
927
|
+
declare const SUBJECT_CATALOG_PAGE_BYTES: number;
|
|
928
|
+
/**
|
|
929
|
+
* Splits a catalog tree by its first level into parts that each fit one page (`subject_catalog` section, prop `tree`).
|
|
930
|
+
* Publish part `i` on its own page and name them all in the kind's `catalog_ref` (`["page:x-1", "page:x-2", …]`); the
|
|
931
|
+
* server joins them back. A real parts catalog (make → model → engine) does not fit in one page. Throws `RangeError`
|
|
932
|
+
* when a single first-level option is larger than the budget on its own (split that level by hand, or trim labels).
|
|
933
|
+
*/
|
|
934
|
+
declare function splitSubjectTree(tree: Record<string, SubjectCatalogNode>, maxBytes?: number): Record<string, SubjectCatalogNode>[];
|
|
935
|
+
|
|
871
936
|
/** Kind of a delivery radio: `ship` (address only, quote later), `rate` (a quoted rate) or `pickup` (a branch). */
|
|
872
937
|
type DeliveryChoiceKind = 'ship' | 'rate' | 'pickup';
|
|
873
938
|
type DeliveryChoice = {
|
|
@@ -899,4 +964,4 @@ type DeliveryNotices = {
|
|
|
899
964
|
/** Splits `delivery.unavailable` into the `missing_weight` notice and the generic one. */
|
|
900
965
|
declare function deliveryNotices(delivery: Pick<DeliveryOptions, 'unavailable' | 'partial'> | null | undefined): DeliveryNotices;
|
|
901
966
|
|
|
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,
|
|
967
|
+
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, DEFAULT_FIT_TAG_PREFIX, 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, MAX_SUBJECT_YEAR, MIN_SUBJECT_YEAR, MISSING_WEIGHT, type MarketInfo, type MarketSuggestion, Menu, Money, NOTE_MAX_LENGTH, NearestLocation, NextAction, Order, OrderProgress, PAYMENT_CHOICE_REFUSED_FIELD, PICKUP_STEPS, PRIVATE_MASK, 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, type ResolvedSubject, RestockSubscriptionInput, RestockSubscriptionResult, ReturnRequest, ReturnRequestInput, SHIPPING_STEPS, SUBJECT_CATALOG_PAGE_BYTES, Shipment, ShipmentEvent, ShipmentStatus, type ShippingBarState, type ShippingBarView, Shop, StockLevel, type StorefrontClient, type StorefrontClientOptions, type StorefrontRequestContext, type StorefrontResponseContext, Subject, SubjectCatalogNode, SubjectField, SubjectInput, SubjectKind, type SubjectOption, SubjectPatch, type SubjectProblemCode, type SubjectProblems, type SubjectValues, Theme, TokenIntrospection, UnavailableRateProvider, type WriteOptions, appendParams, availabilityLocale, availabilityMessages, availabilityView, cartLineProblemView, clampPercent, classifyPaymentError, coversYear, createStorefrontClient, declineMessage, declineMessageKey, deliveryInput, deliveryNotices, diagnose, fitTag, fitTagsAny, formatAvailabilityMessage, formatMoney, formatVoucherExpiry, generateIdempotencyKey, groupInvoiceDocs, hreflangLinks, invoiceFileBytes, isMasked, isTestInvoice, isTestShipment, isTokenPublishable, maskToken, negotiateLocale, nextAction, normalizeClientIp, normalizeNote, opsSaysNotRetryable, orderProgress, orderShipments, parseDelivery, parseMoney, parseProductFilters, paymentErrorView, paymentIdempotencyKey, paymentMessages, paymentOutcome, preferredLanguages, productAvailability, productListQuery, promoProgressView, promotionMessages, reconcileSubjectValues, repairPath, resolveAvailability, resolveSubject, rewardLabel, safeHttpsUrl, safeInvoiceFilename, safeTrackingUrl, schemaAvailability, shipmentsStatus, sortTrackingEvents, splitSubjectTree, storefrontDomainHeader, subjectFields, subjectLevels, subjectOptions, suggestMarket, toMoney, visitorCountry };
|