@behio/storefront-sdk 0.10.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LNSFBNPJ.js → chunk-GGUHYQNF.js} +26 -0
- package/dist/{chunk-O3IM7PAY.mjs → chunk-XITY2WQN.mjs} +26 -0
- package/dist/chunk-XWYDXBLG.js +18 -0
- package/dist/chunk-YJ45WIQZ.mjs +18 -0
- package/dist/client-Dy4lLabe.d.mts +1340 -0
- package/dist/client-Dy4lLabe.d.ts +1340 -0
- package/dist/index.d.mts +9 -1314
- package/dist/index.d.ts +9 -1314
- package/dist/index.js +6 -2
- package/dist/index.mjs +5 -1
- package/dist/next.d.mts +3 -1
- package/dist/next.d.ts +3 -1
- package/dist/next.js +10 -2
- package/dist/next.mjs +9 -1
- package/dist/react.d.mts +201 -87
- package/dist/react.d.ts +201 -87
- package/dist/react.js +182 -86
- package/dist/react.mjs +173 -77
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkXWYDXBLGjs = require('./chunk-XWYDXBLG.js');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
@@ -10,9 +11,9 @@
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
var _chunkLNSFBNPJjs = require('./chunk-LNSFBNPJ.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
var _chunkGGUHYQNFjs = require('./chunk-GGUHYQNF.js');
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -23,4 +24,7 @@ var _chunkLNSFBNPJjs = require('./chunk-LNSFBNPJ.js');
|
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.AddressTypes = _chunkGGUHYQNFjs.AddressTypes; exports.BehioApiError = _chunkGGUHYQNFjs.BehioApiError; exports.BehioNetworkError = _chunkGGUHYQNFjs.BehioNetworkError; exports.BehioStorefront = _chunkGGUHYQNFjs.BehioStorefront; exports.FulfillmentStatuses = _chunkGGUHYQNFjs.FulfillmentStatuses; exports.OrderStatuses = _chunkGGUHYQNFjs.OrderStatuses; exports.PaymentStatuses = _chunkGGUHYQNFjs.PaymentStatuses; exports.ProductSort = _chunkGGUHYQNFjs.ProductSort; exports.err = _chunkGGUHYQNFjs.err; exports.formatPrice = _chunkXWYDXBLGjs.formatPrice; exports.ok = _chunkGGUHYQNFjs.ok; exports.toSdkError = _chunkGGUHYQNFjs.toSdkError;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatPrice
|
|
3
|
+
} from "./chunk-YJ45WIQZ.mjs";
|
|
1
4
|
import {
|
|
2
5
|
AddressTypes,
|
|
3
6
|
BehioApiError,
|
|
@@ -10,7 +13,7 @@ import {
|
|
|
10
13
|
err,
|
|
11
14
|
ok,
|
|
12
15
|
toSdkError
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-XITY2WQN.mjs";
|
|
14
17
|
export {
|
|
15
18
|
AddressTypes,
|
|
16
19
|
BehioApiError,
|
|
@@ -21,6 +24,7 @@ export {
|
|
|
21
24
|
PaymentStatuses,
|
|
22
25
|
ProductSort,
|
|
23
26
|
err,
|
|
27
|
+
formatPrice,
|
|
24
28
|
ok,
|
|
25
29
|
toSdkError
|
|
26
30
|
};
|
package/dist/next.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { BehioStorefrontConfig, BehioStorefront } from './
|
|
1
|
+
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-Dy4lLabe.mjs';
|
|
2
2
|
|
|
3
3
|
interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
|
|
4
4
|
/** Override the cart session cookie name (default: "behio_cart_session"). */
|
|
5
5
|
cartCookieName?: string;
|
|
6
|
+
/** Override the currency cookie name (default: "behio_currency"). */
|
|
7
|
+
currencyCookieName?: string;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Returns a per-request bound BehioStorefront instance. Reads the cart
|
package/dist/next.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { BehioStorefrontConfig, BehioStorefront } from './
|
|
1
|
+
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-Dy4lLabe.js';
|
|
2
2
|
|
|
3
3
|
interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
|
|
4
4
|
/** Override the cart session cookie name (default: "behio_cart_session"). */
|
|
5
5
|
cartCookieName?: string;
|
|
6
|
+
/** Override the currency cookie name (default: "behio_currency"). */
|
|
7
|
+
currencyCookieName?: string;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Returns a per-request bound BehioStorefront instance. Reads the cart
|
package/dist/next.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkGGUHYQNFjs = require('./chunk-GGUHYQNF.js');
|
|
4
4
|
|
|
5
5
|
// src/next.ts
|
|
6
6
|
var _headers = require('next/headers');
|
|
7
7
|
var CART_COOKIE_NAME = "behio_cart_session";
|
|
8
|
+
var CURRENCY_COOKIE_NAME = "behio_currency";
|
|
8
9
|
var CART_COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
9
10
|
async function getBehio(options = {}) {
|
|
10
11
|
const apiKey = _nullishCoalesce(options.apiKey, () => ( process.env.BEHIO_API_KEY));
|
|
@@ -17,7 +18,7 @@ async function getBehio(options = {}) {
|
|
|
17
18
|
const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
|
|
18
19
|
const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
|
|
19
20
|
const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
|
|
20
|
-
const client = new (0,
|
|
21
|
+
const client = new (0, _chunkGGUHYQNFjs.BehioStorefront)({
|
|
21
22
|
apiKey,
|
|
22
23
|
...baseUrl ? { baseUrl } : {},
|
|
23
24
|
...locale ? { locale } : {},
|
|
@@ -29,6 +30,13 @@ async function getBehio(options = {}) {
|
|
|
29
30
|
if (existing) {
|
|
30
31
|
client.setCartSession(existing);
|
|
31
32
|
}
|
|
33
|
+
if (!currency) {
|
|
34
|
+
const currencyCookieName = _nullishCoalesce(options.currencyCookieName, () => ( CURRENCY_COOKIE_NAME));
|
|
35
|
+
const chosenCurrency = _optionalChain([cookieStore, 'access', _4 => _4.get, 'call', _5 => _5(currencyCookieName), 'optionalAccess', _6 => _6.value]);
|
|
36
|
+
if (chosenCurrency) {
|
|
37
|
+
client.setCurrency(chosenCurrency);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
32
40
|
const originalSet = client.setCartSession.bind(client);
|
|
33
41
|
const originalClear = client.clearCartSession.bind(client);
|
|
34
42
|
client.setCartSession = (token) => {
|
package/dist/next.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BehioStorefront
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XITY2WQN.mjs";
|
|
4
4
|
|
|
5
5
|
// src/next.ts
|
|
6
6
|
import { cookies } from "next/headers";
|
|
7
7
|
var CART_COOKIE_NAME = "behio_cart_session";
|
|
8
|
+
var CURRENCY_COOKIE_NAME = "behio_currency";
|
|
8
9
|
var CART_COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
9
10
|
async function getBehio(options = {}) {
|
|
10
11
|
const apiKey = options.apiKey ?? process.env.BEHIO_API_KEY;
|
|
@@ -29,6 +30,13 @@ async function getBehio(options = {}) {
|
|
|
29
30
|
if (existing) {
|
|
30
31
|
client.setCartSession(existing);
|
|
31
32
|
}
|
|
33
|
+
if (!currency) {
|
|
34
|
+
const currencyCookieName = options.currencyCookieName ?? CURRENCY_COOKIE_NAME;
|
|
35
|
+
const chosenCurrency = cookieStore.get(currencyCookieName)?.value;
|
|
36
|
+
if (chosenCurrency) {
|
|
37
|
+
client.setCurrency(chosenCurrency);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
32
40
|
const originalSet = client.setCartSession.bind(client);
|
|
33
41
|
const originalClear = client.clearCartSession.bind(client);
|
|
34
42
|
client.setCartSession = (token) => {
|