@webround/commerce 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/catalog/types.d.ts
CHANGED
|
@@ -344,6 +344,10 @@ export interface StoreSettings {
|
|
|
344
344
|
cadences: string[];
|
|
345
345
|
/** The link to Stripe's customer portal, to manage a subscription: an empty text when the store has none. */
|
|
346
346
|
stripeCustomerPortalUrl: string;
|
|
347
|
+
/** `false` when the store has turned reviews off: the site shows none, in the product's page and in the account. Absent from a catalog that does not say it: on. */
|
|
348
|
+
reviewsEnabled?: boolean;
|
|
349
|
+
/** `false` when the store has turned the wishlist off: the site shows none, on the product's card and page and in the account. Absent from a catalog that does not say it: on. */
|
|
350
|
+
wishlistEnabled?: boolean;
|
|
347
351
|
}
|
|
348
352
|
export interface StoreTagValue {
|
|
349
353
|
id: string;
|
package/dist/reviews/types.d.ts
CHANGED
|
@@ -50,5 +50,11 @@ export declare const REVIEW_ERROR_CODES: {
|
|
|
50
50
|
readonly alreadyExists: "REVIEW_ALREADY_EXISTS";
|
|
51
51
|
/** A guest has to log in (from here: the store is not asked). */
|
|
52
52
|
readonly loginRequired: "LOGIN_REQUIRED";
|
|
53
|
+
/** The store has turned reviews off (403). */
|
|
54
|
+
readonly disabled: "REVIEWS_DISABLED";
|
|
55
|
+
/** The variant is not the store's (404). */
|
|
56
|
+
readonly variantNotFound: "VARIANT_NOT_FOUND";
|
|
57
|
+
/** The review is not the customer's, or is not there any more (404). */
|
|
58
|
+
readonly notFound: "REVIEW_NOT_FOUND";
|
|
53
59
|
};
|
|
54
60
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/reviews/types.js
CHANGED
|
@@ -6,5 +6,11 @@ export const REVIEW_ERROR_CODES = {
|
|
|
6
6
|
alreadyExists: 'REVIEW_ALREADY_EXISTS',
|
|
7
7
|
/** A guest has to log in (from here: the store is not asked). */
|
|
8
8
|
loginRequired: 'LOGIN_REQUIRED',
|
|
9
|
+
/** The store has turned reviews off (403). */
|
|
10
|
+
disabled: 'REVIEWS_DISABLED',
|
|
11
|
+
/** The variant is not the store's (404). */
|
|
12
|
+
variantNotFound: 'VARIANT_NOT_FOUND',
|
|
13
|
+
/** The review is not the customer's, or is not there any more (404). */
|
|
14
|
+
notFound: 'REVIEW_NOT_FOUND',
|
|
9
15
|
};
|
|
10
16
|
//# sourceMappingURL=types.js.map
|
package/dist/wishlist/types.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ export interface WishlistToggleAnswer {
|
|
|
23
23
|
wasAdded: boolean;
|
|
24
24
|
item?: WishlistItem;
|
|
25
25
|
}
|
|
26
|
-
/** The `code` of the
|
|
26
|
+
/** The `code`s of what is refused of the wishlist: a guest has none (from here), and a store can turn it off (403). */
|
|
27
27
|
export declare const WISHLIST_ERROR_CODES: {
|
|
28
28
|
readonly loginRequired: "LOGIN_REQUIRED";
|
|
29
|
+
readonly disabled: "WISHLIST_DISABLED";
|
|
29
30
|
};
|
|
30
31
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/wishlist/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// What the wishlist calls of commerce-core take and give, as the store says it. A customer keeps variants they want to come back to; there is one call that adds or removes (a switch). A guest has none: it is the customer's.
|
|
2
|
-
/** The `code` of the
|
|
3
|
-
export const WISHLIST_ERROR_CODES = { loginRequired: 'LOGIN_REQUIRED' };
|
|
2
|
+
/** The `code`s of what is refused of the wishlist: a guest has none (from here), and a store can turn it off (403). */
|
|
3
|
+
export const WISHLIST_ERROR_CODES = { loginRequired: 'LOGIN_REQUIRED', disabled: 'WISHLIST_DISABLED' };
|
|
4
4
|
//# sourceMappingURL=types.js.map
|
|
@@ -2,8 +2,8 @@ import { CommerceError, toCommerceError } from '../errors.js';
|
|
|
2
2
|
import { createSerialQueue, createStateHolder, followAuth } from '../store-kit.js';
|
|
3
3
|
import { WISHLIST_ERROR_CODES } from './types.js';
|
|
4
4
|
const idsOf = (items) => items.flatMap((i) => i.product.variants.map((v) => v.id));
|
|
5
|
-
/** Whether the store said the wishlist is off (its 403): a refusal that is not about the customer. */
|
|
6
|
-
const isDisabled = (error) => error.status === 403 && /disabled/i.test(error.message);
|
|
5
|
+
/** Whether the store said the wishlist is off (its 403, with its `code`; a store that sends none is told by its words): a refusal that is not about the customer. */
|
|
6
|
+
const isDisabled = (error) => error.status === 403 && (error.code === WISHLIST_ERROR_CODES.disabled || /disabled/i.test(error.message));
|
|
7
7
|
export function createWishlist(options) {
|
|
8
8
|
const { api, auth } = options;
|
|
9
9
|
const holder = createStateHolder({ owner: 'unknown', items: [], variantIds: [], count: 0, loaded: false, enabled: null, busy: false, error: null });
|