@sixtyninecommerce/client 0.24.0 → 0.26.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 +21 -0
- package/dist/admin/forms.js +19 -0
- package/dist/admin/forms.js.map +1 -1
- package/dist/admin/http.d.ts +9 -0
- package/dist/admin/http.d.ts.map +1 -1
- package/dist/admin/http.js +3 -0
- package/dist/admin/http.js.map +1 -1
- package/dist/admin/index.d.ts +63 -0
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +67 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/redirects.d.ts +6 -0
- package/dist/admin/redirects.d.ts.map +1 -1
- package/dist/admin/redirects.js +12 -0
- package/dist/admin/redirects.js.map +1 -1
- package/dist/admin/types.d.ts +63 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/cache-tags.d.ts +19 -0
- package/dist/cache-tags.d.ts.map +1 -1
- package/dist/cache-tags.js +19 -0
- package/dist/cache-tags.js.map +1 -1
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -0
- package/dist/client.js.map +1 -1
- package/dist/commerce/age-verification.js +3 -3
- package/dist/commerce/age-verification.js.map +1 -1
- package/dist/commerce/branding.js +7 -0
- package/dist/commerce/branding.js.map +1 -1
- package/dist/commerce/cart.js +25 -0
- package/dist/commerce/cart.js.map +1 -1
- package/dist/commerce/checkout.d.ts +68 -0
- package/dist/commerce/checkout.d.ts.map +1 -1
- package/dist/commerce/checkout.js +83 -0
- package/dist/commerce/checkout.js.map +1 -1
- package/dist/commerce/customer.d.ts +58 -0
- package/dist/commerce/customer.d.ts.map +1 -1
- package/dist/commerce/customer.js +65 -0
- package/dist/commerce/customer.js.map +1 -1
- package/dist/commerce/pickup-location-parser.d.ts +18 -0
- package/dist/commerce/pickup-location-parser.d.ts.map +1 -1
- package/dist/commerce/pickup-location-parser.js +28 -0
- package/dist/commerce/pickup-location-parser.js.map +1 -1
- package/dist/commerce/placement-error.d.ts +52 -0
- package/dist/commerce/placement-error.d.ts.map +1 -1
- package/dist/commerce/placement-error.js +87 -0
- package/dist/commerce/placement-error.js.map +1 -1
- package/dist/commerce/products.d.ts +48 -0
- package/dist/commerce/products.d.ts.map +1 -1
- package/dist/commerce/products.js +92 -0
- package/dist/commerce/products.js.map +1 -1
- package/dist/commerce/queries.d.ts +113 -27
- package/dist/commerce/queries.d.ts.map +1 -1
- package/dist/commerce/queries.js +188 -2
- package/dist/commerce/queries.js.map +1 -1
- package/dist/commerce/quotes.js +33 -0
- package/dist/commerce/quotes.js.map +1 -1
- package/dist/commerce/saved-lists.d.ts +7 -7
- package/dist/commerce/saved-lists.d.ts.map +1 -1
- package/dist/commerce/saved-lists.js +1 -1
- package/dist/commerce/search.js +3 -0
- package/dist/commerce/search.js.map +1 -1
- package/dist/commerce/shipping.js +3 -3
- package/dist/commerce/shipping.js.map +1 -1
- package/dist/commerce/stock-notifications.d.ts +11 -0
- package/dist/commerce/stock-notifications.d.ts.map +1 -1
- package/dist/commerce/stock-notifications.js +11 -0
- package/dist/commerce/stock-notifications.js.map +1 -1
- package/dist/commerce/vat-validation.js +4 -4
- package/dist/commerce/vat-validation.js.map +1 -1
- package/dist/constants.d.ts +31 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -1
- package/dist/content/asset-urls.d.ts +50 -0
- package/dist/content/asset-urls.d.ts.map +1 -1
- package/dist/content/asset-urls.js +92 -0
- package/dist/content/asset-urls.js.map +1 -1
- package/dist/content/assets.d.ts +15 -0
- package/dist/content/assets.d.ts.map +1 -1
- package/dist/content/assets.js +15 -0
- package/dist/content/assets.js.map +1 -1
- package/dist/content/collection-pages.d.ts +5 -0
- package/dist/content/collection-pages.d.ts.map +1 -1
- package/dist/content/collection-pages.js +8 -0
- package/dist/content/collection-pages.js.map +1 -1
- package/dist/content/collections.d.ts +14 -0
- package/dist/content/collections.d.ts.map +1 -1
- package/dist/content/collections.js +16 -0
- package/dist/content/collections.js.map +1 -1
- package/dist/content/filtered-products.d.ts +18 -0
- package/dist/content/filtered-products.d.ts.map +1 -1
- package/dist/content/filtered-products.js +16 -0
- package/dist/content/filtered-products.js.map +1 -1
- package/dist/content/form-field-types.d.ts +6 -0
- package/dist/content/form-field-types.d.ts.map +1 -1
- package/dist/content/form-field-types.js +12 -0
- package/dist/content/form-field-types.js.map +1 -1
- package/dist/content/forms.d.ts +16 -0
- package/dist/content/forms.d.ts.map +1 -1
- package/dist/content/forms.js +23 -0
- package/dist/content/forms.js.map +1 -1
- package/dist/content/items.d.ts +26 -0
- package/dist/content/items.d.ts.map +1 -1
- package/dist/content/items.js +33 -0
- package/dist/content/items.js.map +1 -1
- package/dist/content/resolve.js +6 -0
- package/dist/content/resolve.js.map +1 -1
- package/dist/content/sitemap.d.ts +5 -0
- package/dist/content/sitemap.d.ts.map +1 -1
- package/dist/content/sitemap.js +5 -0
- package/dist/content/sitemap.js.map +1 -1
- package/dist/core/context.js +6 -0
- package/dist/core/context.js.map +1 -1
- package/dist/core/headers.js +2 -0
- package/dist/core/headers.js.map +1 -1
- package/dist/core/http.d.ts +8 -0
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +89 -1
- package/dist/core/http.js.map +1 -1
- package/dist/credit/credit-status.js +2 -2
- package/dist/credit/credit-status.js.map +1 -1
- package/dist/credit/payment-terms.js +2 -2
- package/dist/credit/payment-terms.js.map +1 -1
- package/dist/currency/exchange.d.ts +11 -0
- package/dist/currency/exchange.d.ts.map +1 -1
- package/dist/currency/exchange.js +11 -0
- package/dist/currency/exchange.js.map +1 -1
- package/dist/errors.d.ts +50 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +48 -2
- package/dist/errors.js.map +1 -1
- package/dist/events/envelope.d.ts +60 -0
- package/dist/events/envelope.d.ts.map +1 -1
- package/dist/events/envelope.js +12 -0
- package/dist/events/envelope.js.map +1 -1
- package/dist/events/index.d.ts +14 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +13 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/payloads.d.ts +19 -0
- package/dist/events/payloads.d.ts.map +1 -1
- package/dist/events/payloads.js +12 -0
- package/dist/events/payloads.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/media/index.js +2 -0
- package/dist/media/index.js.map +1 -1
- package/dist/media/urls.d.ts +52 -0
- package/dist/media/urls.d.ts.map +1 -1
- package/dist/media/urls.js +38 -0
- package/dist/media/urls.js.map +1 -1
- package/dist/media/video.d.ts +16 -0
- package/dist/media/video.d.ts.map +1 -1
- package/dist/media/video.js +16 -0
- package/dist/media/video.js.map +1 -1
- package/dist/next/artifact-handler.d.ts +22 -0
- package/dist/next/artifact-handler.d.ts.map +1 -1
- package/dist/next/artifact-handler.js +22 -0
- package/dist/next/artifact-handler.js.map +1 -1
- package/dist/next/event-revalidate-handler.d.ts +67 -0
- package/dist/next/event-revalidate-handler.d.ts.map +1 -1
- package/dist/next/event-revalidate-handler.js +48 -0
- package/dist/next/event-revalidate-handler.js.map +1 -1
- package/dist/next/index.d.ts +6 -0
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +6 -0
- package/dist/next/index.js.map +1 -1
- package/dist/next/json-ld.d.ts +9 -0
- package/dist/next/json-ld.d.ts.map +1 -1
- package/dist/next/json-ld.js +9 -0
- package/dist/next/json-ld.js.map +1 -1
- package/dist/next/metadata.d.ts +18 -0
- package/dist/next/metadata.d.ts.map +1 -1
- package/dist/next/metadata.js +21 -0
- package/dist/next/metadata.js.map +1 -1
- package/dist/next/redirect-middleware.d.ts +39 -0
- package/dist/next/redirect-middleware.d.ts.map +1 -1
- package/dist/next/redirect-middleware.js +32 -0
- package/dist/next/redirect-middleware.js.map +1 -1
- package/dist/next/revalidate-handler.d.ts +30 -0
- package/dist/next/revalidate-handler.d.ts.map +1 -1
- package/dist/next/revalidate-handler.js +22 -0
- package/dist/next/revalidate-handler.js.map +1 -1
- package/dist/order-scope.d.ts +27 -0
- package/dist/order-scope.d.ts.map +1 -1
- package/dist/order-scope.js +29 -0
- package/dist/order-scope.js.map +1 -1
- package/dist/pricing/format.d.ts +17 -0
- package/dist/pricing/format.d.ts.map +1 -1
- package/dist/pricing/format.js +19 -0
- package/dist/pricing/format.js.map +1 -1
- package/dist/pricing/index.d.ts +8 -1
- package/dist/pricing/index.d.ts.map +1 -1
- package/dist/pricing/index.js +18 -2
- package/dist/pricing/index.js.map +1 -1
- package/dist/pricing/tax-display.d.ts +77 -0
- package/dist/pricing/tax-display.d.ts.map +1 -1
- package/dist/pricing/tax-display.js +85 -0
- package/dist/pricing/tax-display.js.map +1 -1
- package/dist/pricing/tiers.d.ts +9 -0
- package/dist/pricing/tiers.d.ts.map +1 -1
- package/dist/pricing/tiers.js +9 -0
- package/dist/pricing/tiers.js.map +1 -1
- package/dist/pricing/validation.d.ts +56 -1
- package/dist/pricing/validation.d.ts.map +1 -1
- package/dist/pricing/validation.js +61 -0
- package/dist/pricing/validation.js.map +1 -1
- package/dist/redirects/index.d.ts +1 -0
- package/dist/redirects/index.d.ts.map +1 -1
- package/dist/redirects/index.js +1 -0
- package/dist/redirects/index.js.map +1 -1
- package/dist/redirects/store.d.ts +20 -0
- package/dist/redirects/store.d.ts.map +1 -1
- package/dist/redirects/store.js +57 -0
- package/dist/redirects/store.js.map +1 -1
- package/dist/redirects/types.d.ts +24 -0
- package/dist/redirects/types.d.ts.map +1 -1
- package/dist/redirects/types.js +1 -0
- package/dist/redirects/types.js.map +1 -1
- package/dist/revalidation/event-plan.d.ts +48 -0
- package/dist/revalidation/event-plan.d.ts.map +1 -1
- package/dist/revalidation/event-plan.js +61 -0
- package/dist/revalidation/event-plan.js.map +1 -1
- package/dist/revalidation/event-verify.d.ts +25 -0
- package/dist/revalidation/event-verify.d.ts.map +1 -1
- package/dist/revalidation/event-verify.js +27 -0
- package/dist/revalidation/event-verify.js.map +1 -1
- package/dist/revalidation/types.d.ts +20 -0
- package/dist/revalidation/types.d.ts.map +1 -1
- package/dist/revalidation/types.js +10 -0
- package/dist/revalidation/types.js.map +1 -1
- package/dist/revalidation/url-context.d.ts +25 -0
- package/dist/revalidation/url-context.d.ts.map +1 -1
- package/dist/revalidation/url-context.js +17 -0
- package/dist/revalidation/url-context.js.map +1 -1
- package/dist/revalidation/verify.d.ts +8 -0
- package/dist/revalidation/verify.d.ts.map +1 -1
- package/dist/revalidation/verify.js +8 -0
- package/dist/revalidation/verify.js.map +1 -1
- package/dist/seo/ai.d.ts +17 -0
- package/dist/seo/ai.d.ts.map +1 -1
- package/dist/seo/ai.js +12 -0
- package/dist/seo/ai.js.map +1 -1
- package/dist/seo/alternates.js +13 -0
- package/dist/seo/alternates.js.map +1 -1
- package/dist/seo/artifacts.d.ts +13 -0
- package/dist/seo/artifacts.d.ts.map +1 -1
- package/dist/seo/artifacts.js +19 -0
- package/dist/seo/artifacts.js.map +1 -1
- package/dist/seo/canonical.d.ts +15 -0
- package/dist/seo/canonical.d.ts.map +1 -1
- package/dist/seo/canonical.js +24 -0
- package/dist/seo/canonical.js.map +1 -1
- package/dist/seo/index.js +6 -0
- package/dist/seo/index.js.map +1 -1
- package/dist/seo/json-ld.d.ts +13 -0
- package/dist/seo/json-ld.d.ts.map +1 -1
- package/dist/seo/json-ld.js +32 -0
- package/dist/seo/json-ld.js.map +1 -1
- package/dist/seo/locale-tag.d.ts +31 -0
- package/dist/seo/locale-tag.d.ts.map +1 -1
- package/dist/seo/locale-tag.js +31 -0
- package/dist/seo/locale-tag.js.map +1 -1
- package/dist/seo/meta-tags.d.ts +29 -0
- package/dist/seo/meta-tags.d.ts.map +1 -1
- package/dist/seo/meta-tags.js +28 -0
- package/dist/seo/meta-tags.js.map +1 -1
- package/dist/seo/metadata-parser.d.ts +24 -0
- package/dist/seo/metadata-parser.d.ts.map +1 -1
- package/dist/seo/metadata-parser.js +38 -0
- package/dist/seo/metadata-parser.js.map +1 -1
- package/dist/seo/metadata-types.d.ts +16 -0
- package/dist/seo/metadata-types.d.ts.map +1 -1
- package/dist/seo/product-path.d.ts +96 -0
- package/dist/seo/product-path.d.ts.map +1 -1
- package/dist/seo/product-path.js +96 -0
- package/dist/seo/product-path.js.map +1 -1
- package/dist/seo/robots.d.ts +17 -0
- package/dist/seo/robots.d.ts.map +1 -1
- package/dist/seo/robots.js +12 -0
- package/dist/seo/robots.js.map +1 -1
- package/dist/seo/types.d.ts +39 -0
- package/dist/seo/types.d.ts.map +1 -1
- package/dist/seo/url-builder.d.ts +31 -0
- package/dist/seo/url-builder.d.ts.map +1 -1
- package/dist/seo/url-builder.js +36 -0
- package/dist/seo/url-builder.js.map +1 -1
- package/dist/types.d.ts +1163 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,21 @@ function unwrapResult(data, field) {
|
|
|
12
12
|
}
|
|
13
13
|
export function createCustomerMethods(http, ctx) {
|
|
14
14
|
return {
|
|
15
|
+
// --- Auth ---
|
|
16
|
+
/**
|
|
17
|
+
* Authenticate a customer against the active channel.
|
|
18
|
+
*
|
|
19
|
+
* Returns a discriminated {@link LoginResult}: on success the current
|
|
20
|
+
* user, otherwise a typed signal for imported accounts that have no
|
|
21
|
+
* migrated password (`password_reset_required` — a reset link has already
|
|
22
|
+
* been emailed) or accounts that are not yet verified
|
|
23
|
+
* (`account_not_verified`). Only a *genuine* bad password throws a
|
|
24
|
+
* `MutationError('INVALID_CREDENTIALS_ERROR')`.
|
|
25
|
+
*
|
|
26
|
+
* The platform's per-channel auth strategy surfaces these signals through
|
|
27
|
+
* `InvalidCredentialsError.authenticationError`; we translate them here so
|
|
28
|
+
* an imported customer is not wrongly told their password is wrong.
|
|
29
|
+
*/
|
|
15
30
|
async login(email, password) {
|
|
16
31
|
const data = await http.graphql(LOGIN, { email, password });
|
|
17
32
|
const result = data.login;
|
|
@@ -39,6 +54,13 @@ export function createCustomerMethods(http, ctx) {
|
|
|
39
54
|
const data = await http.graphql(REGISTER, { input });
|
|
40
55
|
return unwrapResult(data, 'registerCustomerAccount');
|
|
41
56
|
},
|
|
57
|
+
/**
|
|
58
|
+
* End the customer session. Runs the Vendure `logout` mutation, then clears
|
|
59
|
+
* the SDK's stored auth token and fires `onAuthCleared` (the inverse of the
|
|
60
|
+
* `onAuthToken` signal login raises) so the consumer can drop the persisted
|
|
61
|
+
* token — otherwise the token stays live and subsequent requests keep
|
|
62
|
+
* sending it.
|
|
63
|
+
*/
|
|
42
64
|
async logout() {
|
|
43
65
|
await http.graphql(LOGOUT);
|
|
44
66
|
if (ctx) {
|
|
@@ -59,6 +81,12 @@ export function createCustomerMethods(http, ctx) {
|
|
|
59
81
|
});
|
|
60
82
|
unwrapResult(data, 'refreshCustomerVerification');
|
|
61
83
|
},
|
|
84
|
+
// --- Passwordless (magic link) ---
|
|
85
|
+
/**
|
|
86
|
+
* Request a passwordless sign-in email (clickable link + 6-digit code) for
|
|
87
|
+
* the given address. Resolves whether or not an account exists
|
|
88
|
+
* (anti-enumeration) — only a real error (e.g. misconfigured auth) throws.
|
|
89
|
+
*/
|
|
62
90
|
async requestMagicLink(emailAddress) {
|
|
63
91
|
const data = await http.graphql(REQUEST_MAGIC_LINK, {
|
|
64
92
|
emailAddress,
|
|
@@ -68,10 +96,18 @@ export function createCustomerMethods(http, ctx) {
|
|
|
68
96
|
throw new MutationError(result.errorCode, result.message, result);
|
|
69
97
|
}
|
|
70
98
|
},
|
|
99
|
+
/**
|
|
100
|
+
* Consume a magic-link token (from the emailed link) and start a session.
|
|
101
|
+
* The auth token is captured automatically (fires `onAuthToken`), like login.
|
|
102
|
+
*/
|
|
71
103
|
async loginWithMagicLink(token) {
|
|
72
104
|
const data = await http.graphql(LOGIN_WITH_MAGIC_LINK, { token });
|
|
73
105
|
return unwrapResult(data, 'loginWithMagicLink');
|
|
74
106
|
},
|
|
107
|
+
/**
|
|
108
|
+
* Consume a 6-digit magic-link code for the given email and start a session.
|
|
109
|
+
* Cross-device friendly: enter the code on the same device that requested it.
|
|
110
|
+
*/
|
|
75
111
|
async loginWithMagicCode(emailAddress, code) {
|
|
76
112
|
const data = await http.graphql(LOGIN_WITH_MAGIC_CODE, {
|
|
77
113
|
emailAddress,
|
|
@@ -79,6 +115,7 @@ export function createCustomerMethods(http, ctx) {
|
|
|
79
115
|
});
|
|
80
116
|
return unwrapResult(data, 'loginWithMagicCode');
|
|
81
117
|
},
|
|
118
|
+
// --- Password ---
|
|
82
119
|
async updatePassword(currentPassword, newPassword) {
|
|
83
120
|
const data = await http.graphql(UPDATE_PASSWORD, {
|
|
84
121
|
currentPassword,
|
|
@@ -102,6 +139,7 @@ export function createCustomerMethods(http, ctx) {
|
|
|
102
139
|
});
|
|
103
140
|
return unwrapResult(data, 'resetPassword');
|
|
104
141
|
},
|
|
142
|
+
// --- Email ---
|
|
105
143
|
async requestEmailUpdate(password, newEmailAddress) {
|
|
106
144
|
const data = await http.graphql(REQUEST_EMAIL_UPDATE, {
|
|
107
145
|
password,
|
|
@@ -113,10 +151,18 @@ export function createCustomerMethods(http, ctx) {
|
|
|
113
151
|
const data = await http.graphql(UPDATE_EMAIL, { token });
|
|
114
152
|
unwrapResult(data, 'updateCustomerEmailAddress');
|
|
115
153
|
},
|
|
154
|
+
// --- Profile ---
|
|
116
155
|
async getCurrentCustomer() {
|
|
117
156
|
const data = await http.graphql(GET_CURRENT_CUSTOMER);
|
|
118
157
|
return data.activeCustomer;
|
|
119
158
|
},
|
|
159
|
+
/**
|
|
160
|
+
* The price lists currently applying to the signed-in customer (contract,
|
|
161
|
+
* customer-direct, group, and channel-wide), sorted by resolution priority.
|
|
162
|
+
* Identity only — prices are already applied server-side; use this to label
|
|
163
|
+
* which lists the customer is on. Empty for anonymous visitors with no
|
|
164
|
+
* channel-wide lists.
|
|
165
|
+
*/
|
|
120
166
|
async getActiveCustomerPriceLists(options) {
|
|
121
167
|
const data = await http.graphql(ACTIVE_CUSTOMER_PRICE_LISTS, undefined, options);
|
|
122
168
|
return data.activeCustomerPriceLists;
|
|
@@ -137,6 +183,7 @@ export function createCustomerMethods(http, ctx) {
|
|
|
137
183
|
const data = await http.graphql(GET_CUSTOMER_ORDERS, vars);
|
|
138
184
|
return data.activeCustomer?.orders ?? { items: [], totalItems: 0 };
|
|
139
185
|
},
|
|
186
|
+
// --- Addresses ---
|
|
140
187
|
async createAddress(input) {
|
|
141
188
|
const data = await http.graphql(CREATE_ADDRESS, {
|
|
142
189
|
input,
|
|
@@ -152,6 +199,7 @@ export function createCustomerMethods(http, ctx) {
|
|
|
152
199
|
async deleteAddress(id) {
|
|
153
200
|
await http.graphql(DELETE_ADDRESS, { id });
|
|
154
201
|
},
|
|
202
|
+
// --- Utility Queries ---
|
|
155
203
|
async getAvailableCountries() {
|
|
156
204
|
const data = await http.graphql(AVAILABLE_COUNTRIES);
|
|
157
205
|
return data.availableCountries;
|
|
@@ -163,18 +211,35 @@ export function createCustomerMethods(http, ctx) {
|
|
|
163
211
|
}
|
|
164
212
|
return data.orderByCode;
|
|
165
213
|
},
|
|
214
|
+
/**
|
|
215
|
+
* Invoices issued for one of the signed-in customer's own orders.
|
|
216
|
+
* Requires authentication; other customers' order codes yield FORBIDDEN.
|
|
217
|
+
*/
|
|
166
218
|
async getMyOrderInvoices(orderCode) {
|
|
167
219
|
const data = await http.graphql(MY_ORDER_INVOICES, {
|
|
168
220
|
orderCode,
|
|
169
221
|
});
|
|
170
222
|
return data.myOrderInvoices;
|
|
171
223
|
},
|
|
224
|
+
/**
|
|
225
|
+
* Download one of the signed-in customer's own invoices. Returns the PDF
|
|
226
|
+
* bytes base64-encoded plus a suggested filename — decode with
|
|
227
|
+
* `atob`/`Buffer.from(base64, 'base64')` and serve as
|
|
228
|
+
* `application/pdf`.
|
|
229
|
+
*/
|
|
172
230
|
async getMyInvoicePdf(invoiceId) {
|
|
173
231
|
const data = await http.graphql(MY_INVOICE_PDF, {
|
|
174
232
|
invoiceId,
|
|
175
233
|
});
|
|
176
234
|
return data.myInvoicePdf;
|
|
177
235
|
},
|
|
236
|
+
/**
|
|
237
|
+
* Add every line of a previous order to the active cart ("buy again").
|
|
238
|
+
* Lines whose variants no longer exist or have insufficient stock are
|
|
239
|
+
* collected in `skipped` instead of throwing — the caller decides how to
|
|
240
|
+
* surface them. Lines are added sequentially so cart state is consistent
|
|
241
|
+
* if the caller aborts mid-way.
|
|
242
|
+
*/
|
|
178
243
|
async reorder(orderCode) {
|
|
179
244
|
const previous = await this.getOrderByCode(orderCode);
|
|
180
245
|
const skipped = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqB9D,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,SAAS,YAAY,CAAC,IAA6B,EAAE,KAAa;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAwC,CAAC;IAClE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,kBAAkB,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAgB,EAAE,GAAkB;IACxE,OAAO;
|
|
1
|
+
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqB9D,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,SAAS,YAAY,CAAC,IAA6B,EAAE,KAAa;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAwC,CAAC;IAClE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,kBAAkB,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAgB,EAAE,GAAkB;IACxE,OAAO;QACL,eAAe;QAEf;;;;;;;;;;;;;WAaG;QACH,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,QAAgB;YACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,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AW,EAAE,CAAC;gBACjB,MAAM,IAAI,aAAa,CACrB,wBAAwB,EACxB,qCAAqC,SAAS,EAAE,EAChD,EAAE,OAAO,EAAE,CACZ,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;QACrD,CAAC;QAED,KAAK,CAAC,gBAAgB;YACpB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAmC,kBAAkB,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC,aAAa,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { PickupLocation } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a single `PickupLocation` returned by the Vendure shop API. Throws
|
|
4
|
+
* `StorefrontError` on any shape violation so downstream consumers can rely
|
|
5
|
+
* on the typed shape.
|
|
6
|
+
*/
|
|
2
7
|
export declare function parsePickupLocation(value: unknown): PickupLocation;
|
|
8
|
+
/**
|
|
9
|
+
* Parse an array of pickup locations. Returns `[]` for a `null`/`undefined`
|
|
10
|
+
* top-level (the Vendure shop API uses `null` only when there is no active
|
|
11
|
+
* order; the array form is always emitted).
|
|
12
|
+
*/
|
|
3
13
|
export declare function parsePickupLocations(value: unknown): PickupLocation[];
|
|
14
|
+
/** Optional pickup location (`null` when no selection has been made). */
|
|
4
15
|
export declare function parseOptionalPickupLocation(value: unknown): PickupLocation | null;
|
|
16
|
+
/**
|
|
17
|
+
* Normalize a client-provided pickup location into the wire shape before
|
|
18
|
+
* sending it to `setActiveOrderPickupLocation`. The backend re-validates
|
|
19
|
+
* against the provider's current response, but parsing client-side first
|
|
20
|
+
* surfaces shape bugs at the SDK boundary instead of as opaque
|
|
21
|
+
* `MutationError`s later.
|
|
22
|
+
*/
|
|
5
23
|
export declare function normalizePickupLocationInput(value: unknown): PickupLocation;
|
|
6
24
|
//# sourceMappingURL=pickup-location-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickup-location-parser.d.ts","sourceRoot":"","sources":["../../src/commerce/pickup-location-parser.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pickup-location-parser.d.ts","sourceRoot":"","sources":["../../src/commerce/pickup-location-parser.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,aAAa,CAAC;AAuDrB;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAiClE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,EAAE,CAIrE;AAED,yEAAyE;AACzE,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAGjF;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAE3E"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict parsers for the `PickupLocation` shape returned by the Vendure shop
|
|
3
|
+
* API. The SDK persists pickup selections back to the order; per the project's
|
|
4
|
+
* data integrity rules, every external value must be parsed before downstream
|
|
5
|
+
* code touches it. Hand-written guards (no Zod) match the rest of the SDK,
|
|
6
|
+
* which keeps zero runtime dependencies.
|
|
7
|
+
*/
|
|
1
8
|
import { StorefrontError } from '../errors.js';
|
|
2
9
|
function reject(field, message) {
|
|
3
10
|
throw new StorefrontError(`Invalid PickupLocation payload at "${field}": ${message}`, 'vendure');
|
|
@@ -51,6 +58,11 @@ function parseOpeningHours(value, field) {
|
|
|
51
58
|
close,
|
|
52
59
|
};
|
|
53
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse a single `PickupLocation` returned by the Vendure shop API. Throws
|
|
63
|
+
* `StorefrontError` on any shape violation so downstream consumers can rely
|
|
64
|
+
* on the typed shape.
|
|
65
|
+
*/
|
|
54
66
|
export function parsePickupLocation(value) {
|
|
55
67
|
if (!isPlainObject(value))
|
|
56
68
|
reject('pickupLocation', 'expected object');
|
|
@@ -75,10 +87,18 @@ export function parsePickupLocation(value) {
|
|
|
75
87
|
out.openingHours = openingHoursRaw.map((entry, idx) => parseOpeningHours(entry, `pickupLocation.openingHours[${idx}]`));
|
|
76
88
|
}
|
|
77
89
|
if (isPlainObject(detailsRaw)) {
|
|
90
|
+
// `details` is a carrier-specific extras bag; the inner shape is opaque
|
|
91
|
+
// by design. We keep the keys verbatim — only the wrapper type is
|
|
92
|
+
// asserted here.
|
|
78
93
|
out.details = detailsRaw;
|
|
79
94
|
}
|
|
80
95
|
return out;
|
|
81
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Parse an array of pickup locations. Returns `[]` for a `null`/`undefined`
|
|
99
|
+
* top-level (the Vendure shop API uses `null` only when there is no active
|
|
100
|
+
* order; the array form is always emitted).
|
|
101
|
+
*/
|
|
82
102
|
export function parsePickupLocations(value) {
|
|
83
103
|
if (value === null || value === undefined)
|
|
84
104
|
return [];
|
|
@@ -86,11 +106,19 @@ export function parsePickupLocations(value) {
|
|
|
86
106
|
reject('pickupLocations', 'expected array');
|
|
87
107
|
return value.map((entry) => parsePickupLocation(entry));
|
|
88
108
|
}
|
|
109
|
+
/** Optional pickup location (`null` when no selection has been made). */
|
|
89
110
|
export function parseOptionalPickupLocation(value) {
|
|
90
111
|
if (value === null || value === undefined)
|
|
91
112
|
return null;
|
|
92
113
|
return parsePickupLocation(value);
|
|
93
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Normalize a client-provided pickup location into the wire shape before
|
|
117
|
+
* sending it to `setActiveOrderPickupLocation`. The backend re-validates
|
|
118
|
+
* against the provider's current response, but parsing client-side first
|
|
119
|
+
* surfaces shape bugs at the SDK boundary instead of as opaque
|
|
120
|
+
* `MutationError`s later.
|
|
121
|
+
*/
|
|
94
122
|
export function normalizePickupLocationInput(value) {
|
|
95
123
|
return parsePickupLocation(value);
|
|
96
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickup-location-parser.js","sourceRoot":"","sources":["../../src/commerce/pickup-location-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pickup-location-parser.js","sourceRoot":"","sources":["../../src/commerce/pickup-location-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C,SAAS,MAAM,CAAC,KAAa,EAAE,OAAe;IAC5C,MAAM,IAAI,eAAe,CAAC,sCAAsC,KAAK,MAAM,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACnG,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc,EAAE,KAAa;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,KAAK,EAAE,2BAA2B,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,KAAa,EAAE,GAAY,EAAE,GAAY;IAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrF,MAAM,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,GAAG,GAAG;QAAE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;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAc;IACzD,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1,6 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hoisting the structured half of a refusal onto the thrown `MutationError`.
|
|
3
|
+
*
|
|
4
|
+
* Two different shapes carry "why" out of the Shop API, and a storefront
|
|
5
|
+
* should not have to know which one it got:
|
|
6
|
+
*
|
|
7
|
+
* - A **placement rejection** (`OrderStateTransitionError.placement`,
|
|
8
|
+
* `PaymentDeclinedError.placement`, `PaymentFailedError.placement`) — a
|
|
9
|
+
* full payload with a stable `code`, a shopper-safe `customerMessage` and
|
|
10
|
+
* per-code metadata. The operator prose stays on `transitionError` /
|
|
11
|
+
* `paymentErrorMessage`, untouched, for merchant-facing surfaces.
|
|
12
|
+
* - An **`InsufficientStockError`**, which is not a placement rejection at
|
|
13
|
+
* all (it comes back from the CART mutations, long before any transition)
|
|
14
|
+
* but answers the same question and carries its own identity fields.
|
|
15
|
+
*
|
|
16
|
+
* Both land on `MutationError` as `code` + `lines`, so `catch (e) { switch
|
|
17
|
+
* (e.code) }` is the single way to branch. This module is the only place that
|
|
18
|
+
* reads the wire shapes.
|
|
19
|
+
*/
|
|
1
20
|
import { MutationError } from '../errors.js';
|
|
2
21
|
import type { PlacementRejection, PlacementRejectionLine } from '../types.js';
|
|
22
|
+
/**
|
|
23
|
+
* The `placement` payload, when the document selected it AND the engine filled
|
|
24
|
+
* it in. Null/absent is the normal case for a core state-machine error, for a
|
|
25
|
+
* veto site that predates the envelope, and for any engine older than the
|
|
26
|
+
* placement-rejection schema.
|
|
27
|
+
*
|
|
28
|
+
* An unrecognised `code` is passed through unchanged rather than rewritten to
|
|
29
|
+
* `UNKNOWN`: the value is what a newer storefront branches on, and the engine
|
|
30
|
+
* already substitutes `UNKNOWN` for codes IT cannot decode.
|
|
31
|
+
*/
|
|
3
32
|
export declare function readPlacement(result: Record<string, unknown>): PlacementRejection | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The line an `InsufficientStockError` is about, rebuilt from the fields the
|
|
35
|
+
* cart mutations fill in. `undefined` when the error names no variant — an
|
|
36
|
+
* error raised outside the overridden cart mutations answers null to all of
|
|
37
|
+
* them, and there is nothing to point the shopper at.
|
|
38
|
+
*/
|
|
4
39
|
export declare function insufficientStockLine(result: Record<string, unknown>): PlacementRejectionLine | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Build the `MutationError` for one GraphQL ErrorResult.
|
|
42
|
+
*
|
|
43
|
+
* Message precedence is the whole point: the shopper-safe
|
|
44
|
+
* `placement.customerMessage` wins, then a vetted reason field
|
|
45
|
+
* (`transitionError` / `interceptorError`) exactly as before this existed,
|
|
46
|
+
* then the ErrorResult's generic `message` — which is a per-code i18n TEMPLATE
|
|
47
|
+
* ("Cannot transition Order from X to Y"), never a reason.
|
|
48
|
+
*
|
|
49
|
+
* @param result the ErrorResult object as it came off the wire
|
|
50
|
+
* @param fields what to attach as `error.fields`; defaults to `result`. The
|
|
51
|
+
* bulk-add path passes a wider bag (the partially-mutated order, every
|
|
52
|
+
* per-input error) so the caller can reconcile what actually landed.
|
|
53
|
+
* @param linesOverride the lines to attach when the CALLER can see more of
|
|
54
|
+
* them than `result` alone: a bulk add throws about its first failing input,
|
|
55
|
+
* but every failing input names a row the shopper has to fix.
|
|
56
|
+
*/
|
|
5
57
|
export declare function toMutationError(result: Record<string, unknown>, fields?: Record<string, unknown>, linesOverride?: PlacementRejectionLine[]): MutationError;
|
|
6
58
|
//# sourceMappingURL=placement-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement-error.d.ts","sourceRoot":"","sources":["../../src/commerce/placement-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"placement-error.d.ts","sourceRoot":"","sources":["../../src/commerce/placement-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EACV,kBAAkB,EAElB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAsErB;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,GAAG,SAAS,CAiB7F;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,sBAAsB,GAAG,SAAS,CAEpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAU,EACxC,aAAa,CAAC,EAAE,sBAAsB,EAAE,GACvC,aAAa,CA+Bf"}
|
|
@@ -1,8 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hoisting the structured half of a refusal onto the thrown `MutationError`.
|
|
3
|
+
*
|
|
4
|
+
* Two different shapes carry "why" out of the Shop API, and a storefront
|
|
5
|
+
* should not have to know which one it got:
|
|
6
|
+
*
|
|
7
|
+
* - A **placement rejection** (`OrderStateTransitionError.placement`,
|
|
8
|
+
* `PaymentDeclinedError.placement`, `PaymentFailedError.placement`) — a
|
|
9
|
+
* full payload with a stable `code`, a shopper-safe `customerMessage` and
|
|
10
|
+
* per-code metadata. The operator prose stays on `transitionError` /
|
|
11
|
+
* `paymentErrorMessage`, untouched, for merchant-facing surfaces.
|
|
12
|
+
* - An **`InsufficientStockError`**, which is not a placement rejection at
|
|
13
|
+
* all (it comes back from the CART mutations, long before any transition)
|
|
14
|
+
* but answers the same question and carries its own identity fields.
|
|
15
|
+
*
|
|
16
|
+
* Both land on `MutationError` as `code` + `lines`, so `catch (e) { switch
|
|
17
|
+
* (e.code) }` is the single way to branch. This module is the only place that
|
|
18
|
+
* reads the wire shapes.
|
|
19
|
+
*/
|
|
1
20
|
import { MutationError } from '../errors.js';
|
|
21
|
+
/**
|
|
22
|
+
* ErrorResult fields whose prose may stand in for a missing `customerMessage`,
|
|
23
|
+
* most specific first. Each concrete error type has at most one, and a field
|
|
24
|
+
* the document did not select is simply absent — so this degrades to `message`
|
|
25
|
+
* rather than inventing detail.
|
|
26
|
+
*
|
|
27
|
+
* This is deliberately NOT the platform's `ERROR_REASON_FIELDS`. That list
|
|
28
|
+
* serves the audit trail and the merchant dashboard, where operator prose is
|
|
29
|
+
* exactly what is wanted; here every entry has to be prose a SHOPPER may read:
|
|
30
|
+
*
|
|
31
|
+
* - `transitionError` — what an order-process guard answered. Merchant
|
|
32
|
+
* English, but written about the order the shopper is placing.
|
|
33
|
+
* - `interceptorError` — what an order interceptor answered when it vetoed a
|
|
34
|
+
* cart mutation; likewise addressed at whoever tried the operation.
|
|
35
|
+
*
|
|
36
|
+
* `paymentErrorMessage` is excluded ON PURPOSE: a PSP or ERP decline carries
|
|
37
|
+
* internal detail ("the Exact Online customer has no payment condition
|
|
38
|
+
* assigned"). A payment refusal that carries no `placement` therefore keeps
|
|
39
|
+
* the generic Vendure `message`, and the raw text stays reachable on
|
|
40
|
+
* `error.fields.paymentErrorMessage` for merchant-facing surfaces.
|
|
41
|
+
*/
|
|
2
42
|
const REASON_FIELDS = ['transitionError', 'interceptorError'];
|
|
3
43
|
function nonEmpty(value) {
|
|
4
44
|
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
5
45
|
}
|
|
46
|
+
/** GraphQL `ID` may serialize as a string or a number depending on the engine's id strategy. */
|
|
6
47
|
function readId(value) {
|
|
7
48
|
if (typeof value === 'string' && value.length > 0)
|
|
8
49
|
return value;
|
|
@@ -13,6 +54,12 @@ function readId(value) {
|
|
|
13
54
|
function readInt(value) {
|
|
14
55
|
return typeof value === 'number' ? value : undefined;
|
|
15
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* One implicated line, normalised the same way whatever carried it: a
|
|
59
|
+
* `placement.lines` entry or the flat identity fields an
|
|
60
|
+
* `InsufficientStockError` answers. `undefined` when the entry names no
|
|
61
|
+
* variant — there is then nothing to point the shopper at.
|
|
62
|
+
*/
|
|
16
63
|
function readLine(raw) {
|
|
17
64
|
const productVariantId = readId(raw.productVariantId);
|
|
18
65
|
if (!productVariantId)
|
|
@@ -38,6 +85,16 @@ function readLines(raw) {
|
|
|
38
85
|
}
|
|
39
86
|
return lines;
|
|
40
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* The `placement` payload, when the document selected it AND the engine filled
|
|
90
|
+
* it in. Null/absent is the normal case for a core state-machine error, for a
|
|
91
|
+
* veto site that predates the envelope, and for any engine older than the
|
|
92
|
+
* placement-rejection schema.
|
|
93
|
+
*
|
|
94
|
+
* An unrecognised `code` is passed through unchanged rather than rewritten to
|
|
95
|
+
* `UNKNOWN`: the value is what a newer storefront branches on, and the engine
|
|
96
|
+
* already substitutes `UNKNOWN` for codes IT cannot decode.
|
|
97
|
+
*/
|
|
41
98
|
export function readPlacement(result) {
|
|
42
99
|
const raw = result.placement;
|
|
43
100
|
if (!raw || typeof raw !== 'object')
|
|
@@ -49,15 +106,42 @@ export function readPlacement(result) {
|
|
|
49
106
|
const placement = {
|
|
50
107
|
...payload,
|
|
51
108
|
code,
|
|
109
|
+
// Declared non-nullable, so never let an unselected field type as `true`.
|
|
52
110
|
linesTruncated: payload.linesTruncated === true,
|
|
53
111
|
};
|
|
112
|
+
// Same normalisation as the stock path, so `line.productVariantId` is a
|
|
113
|
+
// string on BOTH — otherwise a numeric-ID engine makes `=== variant.id`
|
|
114
|
+
// fail on placement lines and hold on stock lines.
|
|
54
115
|
if (Array.isArray(payload.lines))
|
|
55
116
|
placement.lines = readLines(payload.lines);
|
|
56
117
|
return placement;
|
|
57
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The line an `InsufficientStockError` is about, rebuilt from the fields the
|
|
121
|
+
* cart mutations fill in. `undefined` when the error names no variant — an
|
|
122
|
+
* error raised outside the overridden cart mutations answers null to all of
|
|
123
|
+
* them, and there is nothing to point the shopper at.
|
|
124
|
+
*/
|
|
58
125
|
export function insufficientStockLine(result) {
|
|
59
126
|
return readLine(result);
|
|
60
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Build the `MutationError` for one GraphQL ErrorResult.
|
|
130
|
+
*
|
|
131
|
+
* Message precedence is the whole point: the shopper-safe
|
|
132
|
+
* `placement.customerMessage` wins, then a vetted reason field
|
|
133
|
+
* (`transitionError` / `interceptorError`) exactly as before this existed,
|
|
134
|
+
* then the ErrorResult's generic `message` — which is a per-code i18n TEMPLATE
|
|
135
|
+
* ("Cannot transition Order from X to Y"), never a reason.
|
|
136
|
+
*
|
|
137
|
+
* @param result the ErrorResult object as it came off the wire
|
|
138
|
+
* @param fields what to attach as `error.fields`; defaults to `result`. The
|
|
139
|
+
* bulk-add path passes a wider bag (the partially-mutated order, every
|
|
140
|
+
* per-input error) so the caller can reconcile what actually landed.
|
|
141
|
+
* @param linesOverride the lines to attach when the CALLER can see more of
|
|
142
|
+
* them than `result` alone: a bulk add throws about its first failing input,
|
|
143
|
+
* but every failing input names a row the shopper has to fix.
|
|
144
|
+
*/
|
|
61
145
|
export function toMutationError(result, fields = result, linesOverride) {
|
|
62
146
|
const errorCode = nonEmpty(result.errorCode) ?? 'UNKNOWN_ERROR';
|
|
63
147
|
const placement = readPlacement(result);
|
|
@@ -66,6 +150,9 @@ export function toMutationError(result, fields = result, linesOverride) {
|
|
|
66
150
|
const lines = linesOverride?.length
|
|
67
151
|
? linesOverride
|
|
68
152
|
: (placementLines ?? (stockLine ? [stockLine] : undefined));
|
|
153
|
+
// A stock refusal carries no envelope, so the code is synthesized — even
|
|
154
|
+
// when the identity fields are absent, because "which line" being unknown
|
|
155
|
+
// does not make "not enough stock" unknown.
|
|
69
156
|
const code = placement?.code ??
|
|
70
157
|
(errorCode === 'INSUFFICIENT_STOCK_ERROR'
|
|
71
158
|
? 'INSUFFICIENT_STOCK'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement-error.js","sourceRoot":"","sources":["../../src/commerce/placement-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"placement-error.js","sourceRoot":"","sources":["../../src/commerce/placement-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAO7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,aAAa,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,CAAU,CAAC;AAEvE,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC;AAED,gGAAgG;AAChG,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,GAA4B;IAC5C,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtD,IAAI,CAAC,gBAAgB;QAAE,OAAO,SAAS,CAAC;IACxC,OAAO;QACL,gBAAgB;QAChB,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;QACpC,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,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC,IAAI,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE3F,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,EAAE;QAChE,IAAI;QACJ,SAAS;QACT,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
import { type HttpClient } from '../core/http.js';
|
|
2
2
|
import type { Collection, CollectionDetail, CollectionListOptions, CollectionProductListOptions, CollectionProductSummary, Facet, PaginatedList, Product, ProductListOptions, ProductPropertyGroupValues, ProductPropertyRecord, ProductSummary, PropertyGroup, RequestOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Flatten `getProductProperties(...)` output into a `slug → value` record for
|
|
5
|
+
* the product-detail view. Walks every group's `properties` to recover each
|
|
6
|
+
* value's slug (values are keyed by `propertyId`, not slug), then attaches the
|
|
7
|
+
* stored value. Later groups win on the rare slug collision.
|
|
8
|
+
*
|
|
9
|
+
* Empty-string and falsy-but-valid values (`false`, `0`) are preserved — the
|
|
10
|
+
* caller decides what counts as "blank". `content_item` slugs (e.g.
|
|
11
|
+
* `producer_winehouse`) map to a CMS item id string, not a name; resolve it
|
|
12
|
+
* against the CMS before display (see `ProductPropertyRecord`).
|
|
13
|
+
*/
|
|
3
14
|
export declare function mapProductProperties(groups: ProductPropertyGroupValues[]): ProductPropertyRecord;
|
|
4
15
|
export declare function createProductMethods(http: HttpClient): {
|
|
5
16
|
getProduct(slug: string, options?: RequestOptions): Promise<Product>;
|
|
6
17
|
getProductById(id: string, options?: RequestOptions): Promise<Product>;
|
|
18
|
+
/**
|
|
19
|
+
* List products for the active channel via the `products` list query.
|
|
20
|
+
* Defaults to `filter: { enabled: { eq: true } }` (and the Shop API forces
|
|
21
|
+
* the same server-side), so `totalItems` matches the browsable catalogue.
|
|
22
|
+
*
|
|
23
|
+
* Cannot sort by price — Vendure's `ProductSortParameter` has no price
|
|
24
|
+
* field. Price-sorted listings go through `getProductsInCollection` or
|
|
25
|
+
* `searchProducts`.
|
|
26
|
+
*
|
|
27
|
+
* The deprecated `{ collectionSlug }` option reroutes to the search
|
|
28
|
+
* backend with its flatter row shape — call `getProductsInCollection`
|
|
29
|
+
* instead, which returns that shape honestly typed. That branch returns
|
|
30
|
+
* before the document switch, so `detail` has no effect on it.
|
|
31
|
+
*
|
|
32
|
+
* Pass `{ detail: 'card' }` for listing pages: it swaps in a grid-tile
|
|
33
|
+
* selection that drops the per-VARIANT stock reads a tile never shows
|
|
34
|
+
* (`availabilityByLocation`, `stockOnHand`/`stockAllocated`, and the
|
|
35
|
+
* incoming-stock trio) plus the product `description`, including the
|
|
36
|
+
* per-language copy inside `translations`. Those variant fields are
|
|
37
|
+
* per-variant field resolvers server-side, so this cuts backend work and SQL
|
|
38
|
+
* statements, not only bytes.
|
|
39
|
+
*
|
|
40
|
+
* The collection tree, the translated slugs and `priceTiers` are KEPT, so a
|
|
41
|
+
* card row still drives canonical/hreflang URLs and quantity-break pricing —
|
|
42
|
+
* see `ProductListOptions.detail` for the full kept/dropped list and why.
|
|
43
|
+
* The default is unchanged, so existing callers keep the full shape.
|
|
44
|
+
*/
|
|
7
45
|
getProducts(listOptions?: ProductListOptions, options?: RequestOptions): Promise<PaginatedList<ProductSummary>>;
|
|
46
|
+
/**
|
|
47
|
+
* List the products of one collection, via the search backend — the only
|
|
48
|
+
* Shop API path that filters by collection. Returns the honest search-row
|
|
49
|
+
* shape (`CollectionProductSummary`): one synthesised variant per product,
|
|
50
|
+
* no `sku`/`facetValues`/`collections`, and a single preview image. Use
|
|
51
|
+
* `getProduct(slug)` for a product's full variant/asset tree. Supports
|
|
52
|
+
* `sort: { price }` (unlike `getProducts`). A search row with a
|
|
53
|
+
* missing/malformed price throws rather than defaulting to €0.
|
|
54
|
+
*/
|
|
8
55
|
getProductsInCollection(collectionSlug: string, listOptions?: CollectionProductListOptions, options?: RequestOptions): Promise<PaginatedList<CollectionProductSummary>>;
|
|
56
|
+
/** `getProductsInCollection` by id, tagged `collection:<id>`. */
|
|
9
57
|
getProductsInCollectionById(collectionId: string, listOptions?: CollectionProductListOptions, options?: RequestOptions): Promise<PaginatedList<CollectionProductSummary>>;
|
|
10
58
|
getFacets(options?: RequestOptions): Promise<Facet[]>;
|
|
11
59
|
getCollections(listOptions?: CollectionListOptions, options?: RequestOptions): Promise<Collection[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../src/commerce/products.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAc,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,EACxB,KAAK,EACL,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../src/commerce/products.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAc,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,EACxB,KAAK,EACL,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,aAAa,CAAC;AA+GrB;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,EAAE,GAAG,qBAAqB,CAUhG;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU;qBAE1B,MAAM,YAAY,cAAc,GAAG,OAAO,CAAC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