@behio/storefront-sdk 0.1.0 → 0.1.2
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 -1
- package/dist/{chunk-3OJEEMLI.mjs → chunk-DBZPF3IR.mjs} +10 -8
- package/dist/{chunk-26WZOAWP.js → chunk-SNODOM7L.js} +10 -8
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/react.js +2 -2
- package/dist/react.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
# @behio/storefront-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Build your own e-shop. Keep 100% control over the frontend.**
|
|
4
|
+
|
|
5
|
+
Behio is a headless e-commerce platform that gives you a complete backend — products, inventory, orders, customers, discounts, multi-currency, multi-language, payments — and lets *you* design the storefront however you want. No themes, no templates, no vendor lock-in.
|
|
6
|
+
|
|
7
|
+
This SDK is the fastest way to connect your Next.js, React, or any JavaScript app to the Behio Storefront API.
|
|
8
|
+
|
|
9
|
+
## Why Behio?
|
|
10
|
+
|
|
11
|
+
- **You own the frontend.** Build it in Next.js, Astro, Nuxt, SvelteKit, React Native — or use plain HTML. The backend doesn't care.
|
|
12
|
+
- **Production-ready e-commerce backend in minutes.** Product catalog, cart, checkout, customer accounts, orders, tracking, CMS pages, discount codes, volume pricing, multi-warehouse inventory — all included.
|
|
13
|
+
- **Built for developers.** Type-safe, auto-completing, fully documented. Modern React hooks with TanStack Query under the hood. Automatic token refresh, optimistic cart updates, SSR prefetch support.
|
|
14
|
+
- **Scale-ready.** Redis caching, rate limiting, webhooks, API keys with scoped permissions. From MVP to millions of orders on the same stack.
|
|
15
|
+
- **Admin UI you don't have to build.** Behio comes with a full admin dashboard for managing products, orders, customers, CMS content, and analytics. You focus on the customer experience.
|
|
16
|
+
|
|
17
|
+
**Perfect for:**
|
|
18
|
+
- Agencies building custom e-shops for clients
|
|
19
|
+
- Brands that want their storefront to look and feel unique
|
|
20
|
+
- SaaS apps that need built-in commerce
|
|
21
|
+
- Headless migrations from Shopify, WooCommerce, PrestaShop
|
|
22
|
+
|
|
23
|
+
## Get started
|
|
4
24
|
|
|
5
25
|
```bash
|
|
6
26
|
npm install @behio/storefront-sdk
|
|
@@ -91,7 +91,7 @@ var BehioStorefront = class {
|
|
|
91
91
|
this.apiKey = config.apiKey;
|
|
92
92
|
this.defaultLocale = config.locale;
|
|
93
93
|
this.defaultCurrency = config.currency;
|
|
94
|
-
this.fetchFn = config.fetch || globalThis.fetch;
|
|
94
|
+
this.fetchFn = config.fetch || globalThis.fetch.bind(globalThis);
|
|
95
95
|
this.timeout = config.timeout ?? 3e4;
|
|
96
96
|
this.retries = config.retries ?? 1;
|
|
97
97
|
this.retryDelay = config.retryDelay ?? 1e3;
|
|
@@ -201,20 +201,22 @@ var BehioStorefront = class {
|
|
|
201
201
|
// --- Internal fetch ---
|
|
202
202
|
/** @internal */
|
|
203
203
|
async request(method, path, options) {
|
|
204
|
-
const
|
|
204
|
+
const params = new URLSearchParams();
|
|
205
205
|
if (options?.query) {
|
|
206
206
|
for (const [key, value] of Object.entries(options.query)) {
|
|
207
207
|
if (value !== void 0 && value !== null && value !== "") {
|
|
208
|
-
|
|
208
|
+
params.set(key, String(value));
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
if (this.defaultLocale && !
|
|
213
|
-
|
|
212
|
+
if (this.defaultLocale && !params.has("locale")) {
|
|
213
|
+
params.set("locale", this.defaultLocale);
|
|
214
214
|
}
|
|
215
|
-
if (this.defaultCurrency && !
|
|
216
|
-
|
|
215
|
+
if (this.defaultCurrency && !params.has("currency")) {
|
|
216
|
+
params.set("currency", this.defaultCurrency);
|
|
217
217
|
}
|
|
218
|
+
const qs = params.toString();
|
|
219
|
+
const url = `${this.baseUrl}/storefront/v1${path}${qs ? `?${qs}` : ""}`;
|
|
218
220
|
const headers = {
|
|
219
221
|
"X-Api-Key": this.apiKey,
|
|
220
222
|
"Content-Type": "application/json"
|
|
@@ -227,7 +229,7 @@ var BehioStorefront = class {
|
|
|
227
229
|
}
|
|
228
230
|
const bodyStr = options?.body ? JSON.stringify(options.body) : void 0;
|
|
229
231
|
let interceptedConfig = {
|
|
230
|
-
url
|
|
232
|
+
url,
|
|
231
233
|
method,
|
|
232
234
|
headers,
|
|
233
235
|
body: bodyStr
|
|
@@ -91,7 +91,7 @@ var BehioStorefront = class {
|
|
|
91
91
|
this.apiKey = config.apiKey;
|
|
92
92
|
this.defaultLocale = config.locale;
|
|
93
93
|
this.defaultCurrency = config.currency;
|
|
94
|
-
this.fetchFn = config.fetch || globalThis.fetch;
|
|
94
|
+
this.fetchFn = config.fetch || globalThis.fetch.bind(globalThis);
|
|
95
95
|
this.timeout = _nullishCoalesce(config.timeout, () => ( 3e4));
|
|
96
96
|
this.retries = _nullishCoalesce(config.retries, () => ( 1));
|
|
97
97
|
this.retryDelay = _nullishCoalesce(config.retryDelay, () => ( 1e3));
|
|
@@ -201,20 +201,22 @@ var BehioStorefront = class {
|
|
|
201
201
|
// --- Internal fetch ---
|
|
202
202
|
/** @internal */
|
|
203
203
|
async request(method, path, options) {
|
|
204
|
-
const
|
|
204
|
+
const params = new URLSearchParams();
|
|
205
205
|
if (_optionalChain([options, 'optionalAccess', _12 => _12.query])) {
|
|
206
206
|
for (const [key, value] of Object.entries(options.query)) {
|
|
207
207
|
if (value !== void 0 && value !== null && value !== "") {
|
|
208
|
-
|
|
208
|
+
params.set(key, String(value));
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
if (this.defaultLocale && !
|
|
213
|
-
|
|
212
|
+
if (this.defaultLocale && !params.has("locale")) {
|
|
213
|
+
params.set("locale", this.defaultLocale);
|
|
214
214
|
}
|
|
215
|
-
if (this.defaultCurrency && !
|
|
216
|
-
|
|
215
|
+
if (this.defaultCurrency && !params.has("currency")) {
|
|
216
|
+
params.set("currency", this.defaultCurrency);
|
|
217
217
|
}
|
|
218
|
+
const qs = params.toString();
|
|
219
|
+
const url = `${this.baseUrl}/storefront/v1${path}${qs ? `?${qs}` : ""}`;
|
|
218
220
|
const headers = {
|
|
219
221
|
"X-Api-Key": this.apiKey,
|
|
220
222
|
"Content-Type": "application/json"
|
|
@@ -227,7 +229,7 @@ var BehioStorefront = class {
|
|
|
227
229
|
}
|
|
228
230
|
const bodyStr = _optionalChain([options, 'optionalAccess', _14 => _14.body]) ? JSON.stringify(options.body) : void 0;
|
|
229
231
|
let interceptedConfig = {
|
|
230
|
-
url
|
|
232
|
+
url,
|
|
231
233
|
method,
|
|
232
234
|
headers,
|
|
233
235
|
body: bodyStr
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkSNODOM7Ljs = require('./chunk-SNODOM7L.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,4 +17,4 @@ var _chunk26WZOAWPjs = require('./chunk-26WZOAWP.js');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
exports.AddressTypes =
|
|
20
|
+
exports.AddressTypes = _chunkSNODOM7Ljs.AddressTypes; exports.BehioApiError = _chunkSNODOM7Ljs.BehioApiError; exports.BehioNetworkError = _chunkSNODOM7Ljs.BehioNetworkError; exports.BehioStorefront = _chunkSNODOM7Ljs.BehioStorefront; exports.FulfillmentStatuses = _chunkSNODOM7Ljs.FulfillmentStatuses; exports.OrderStatuses = _chunkSNODOM7Ljs.OrderStatuses; exports.PaymentStatuses = _chunkSNODOM7Ljs.PaymentStatuses; exports.ProductSort = _chunkSNODOM7Ljs.ProductSort;
|
package/dist/index.mjs
CHANGED
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 _chunkSNODOM7Ljs = require('./chunk-SNODOM7L.js');
|
|
4
4
|
|
|
5
5
|
// src/react/provider.tsx
|
|
6
6
|
var _react = require('react');
|
|
@@ -114,7 +114,7 @@ function BehioProvider({
|
|
|
114
114
|
const storageAdapter = _react.useMemo.call(void 0, () => resolveStorage(storageOption), [storageOption]);
|
|
115
115
|
const clientRef = _react.useRef.call(void 0, null);
|
|
116
116
|
if (!clientRef.current) {
|
|
117
|
-
clientRef.current = new (0,
|
|
117
|
+
clientRef.current = new (0, _chunkSNODOM7Ljs.BehioStorefront)({
|
|
118
118
|
apiKey,
|
|
119
119
|
baseUrl,
|
|
120
120
|
locale,
|
package/dist/react.mjs
CHANGED