@behio/storefront-sdk 0.35.0 → 0.36.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.
@@ -1147,11 +1147,18 @@ var ConsentModule = class {
1147
1147
  return this.client.request("POST", "/consent", { body: input, auth: false });
1148
1148
  }
1149
1149
  async get(visitorId) {
1150
- const result = await this.client.request("GET", `/consent/${visitorId}`, { auth: false });
1150
+ const result = await this.client.request(
1151
+ "GET",
1152
+ `/consent/${visitorId}/status`,
1153
+ { auth: false }
1154
+ );
1151
1155
  if (result.error && result.error.status === 404) {
1152
- return { data: null, error: null };
1156
+ const legacy = await this.client.request("GET", `/consent/${visitorId}`, { auth: false });
1157
+ if (legacy.error && legacy.error.status === 404) return { data: null, error: null };
1158
+ return legacy;
1153
1159
  }
1154
- return result;
1160
+ if (result.error) return { data: null, error: result.error };
1161
+ return { data: result.data?.consented ? result.data.consent : null, error: null };
1155
1162
  }
1156
1163
  async revoke(visitorId) {
1157
1164
  return this.client.request("DELETE", `/consent/${visitorId}`, { auth: false });
@@ -1147,11 +1147,18 @@ var ConsentModule = class {
1147
1147
  return this.client.request("POST", "/consent", { body: input, auth: false });
1148
1148
  }
1149
1149
  async get(visitorId) {
1150
- const result = await this.client.request("GET", `/consent/${visitorId}`, { auth: false });
1150
+ const result = await this.client.request(
1151
+ "GET",
1152
+ `/consent/${visitorId}/status`,
1153
+ { auth: false }
1154
+ );
1151
1155
  if (result.error && result.error.status === 404) {
1152
- return { data: null, error: null };
1156
+ const legacy = await this.client.request("GET", `/consent/${visitorId}`, { auth: false });
1157
+ if (legacy.error && legacy.error.status === 404) return { data: null, error: null };
1158
+ return legacy;
1153
1159
  }
1154
- return result;
1160
+ if (result.error) return { data: null, error: result.error };
1161
+ return { data: _optionalChain([result, 'access', _32 => _32.data, 'optionalAccess', _33 => _33.consented]) ? result.data.consent : null, error: null };
1155
1162
  }
1156
1163
  async revoke(visitorId) {
1157
1164
  return this.client.request("DELETE", `/consent/${visitorId}`, { auth: false });
@@ -1211,10 +1218,10 @@ var ShippingModule = class {
1211
1218
  */
1212
1219
  async listMethods(opts) {
1213
1220
  const query = {};
1214
- if (_optionalChain([opts, 'optionalAccess', _32 => _32.currency])) query.currency = opts.currency;
1215
- if (_optionalChain([opts, 'optionalAccess', _33 => _33.country])) query.country = opts.country;
1216
- if (_optionalChain([opts, 'optionalAccess', _34 => _34.cartTotal]) != null) query.cartTotal = String(opts.cartTotal);
1217
- if (_optionalChain([opts, 'optionalAccess', _35 => _35.cartWeightKg]) != null) query.cartWeightKg = String(opts.cartWeightKg);
1221
+ if (_optionalChain([opts, 'optionalAccess', _34 => _34.currency])) query.currency = opts.currency;
1222
+ if (_optionalChain([opts, 'optionalAccess', _35 => _35.country])) query.country = opts.country;
1223
+ if (_optionalChain([opts, 'optionalAccess', _36 => _36.cartTotal]) != null) query.cartTotal = String(opts.cartTotal);
1224
+ if (_optionalChain([opts, 'optionalAccess', _37 => _37.cartWeightKg]) != null) query.cartWeightKg = String(opts.cartWeightKg);
1218
1225
  return this.client.request(
1219
1226
  "GET",
1220
1227
  "/catalog/shipping-methods",
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ var _chunkCZRSJULDjs = require('./chunk-CZRSJULD.js');
18
18
 
19
19
 
20
20
 
21
- var _chunkXEU3XH6Hjs = require('./chunk-XEU3XH6H.js');
21
+ var _chunkQKEW2EU5js = require('./chunk-QKEW2EU5.js');
22
22
 
23
23
 
24
24
 
@@ -37,4 +37,4 @@ var _chunkXEU3XH6Hjs = require('./chunk-XEU3XH6H.js');
37
37
 
38
38
 
39
39
 
40
- exports.AddressTypes = _chunkXEU3XH6Hjs.AddressTypes; exports.BehioApiError = _chunkXEU3XH6Hjs.BehioApiError; exports.BehioNetworkError = _chunkXEU3XH6Hjs.BehioNetworkError; exports.BehioStorefront = _chunkXEU3XH6Hjs.BehioStorefront; exports.FulfillmentStatuses = _chunkXEU3XH6Hjs.FulfillmentStatuses; exports.OrderStatuses = _chunkXEU3XH6Hjs.OrderStatuses; exports.PaymentStatuses = _chunkXEU3XH6Hjs.PaymentStatuses; exports.ProductSort = _chunkXEU3XH6Hjs.ProductSort; exports.err = _chunkXEU3XH6Hjs.err; exports.formatPrice = _chunkCZRSJULDjs.formatPrice; exports.generateVisitorId = _chunkCZRSJULDjs.generateVisitorId; exports.getStoredVisitorId = _chunkCZRSJULDjs.getStoredVisitorId; exports.grantAnalyticsConsent = _chunkCZRSJULDjs.grantAnalyticsConsent; exports.ok = _chunkXEU3XH6Hjs.ok; exports.revokeAnalyticsConsent = _chunkCZRSJULDjs.revokeAnalyticsConsent; exports.toSdkError = _chunkXEU3XH6Hjs.toSdkError; exports.trackEcommerceEvent = _chunkCZRSJULDjs.trackEcommerceEvent;
40
+ exports.AddressTypes = _chunkQKEW2EU5js.AddressTypes; exports.BehioApiError = _chunkQKEW2EU5js.BehioApiError; exports.BehioNetworkError = _chunkQKEW2EU5js.BehioNetworkError; exports.BehioStorefront = _chunkQKEW2EU5js.BehioStorefront; exports.FulfillmentStatuses = _chunkQKEW2EU5js.FulfillmentStatuses; exports.OrderStatuses = _chunkQKEW2EU5js.OrderStatuses; exports.PaymentStatuses = _chunkQKEW2EU5js.PaymentStatuses; exports.ProductSort = _chunkQKEW2EU5js.ProductSort; exports.err = _chunkQKEW2EU5js.err; exports.formatPrice = _chunkCZRSJULDjs.formatPrice; exports.generateVisitorId = _chunkCZRSJULDjs.generateVisitorId; exports.getStoredVisitorId = _chunkCZRSJULDjs.getStoredVisitorId; exports.grantAnalyticsConsent = _chunkCZRSJULDjs.grantAnalyticsConsent; exports.ok = _chunkQKEW2EU5js.ok; exports.revokeAnalyticsConsent = _chunkCZRSJULDjs.revokeAnalyticsConsent; exports.toSdkError = _chunkQKEW2EU5js.toSdkError; exports.trackEcommerceEvent = _chunkCZRSJULDjs.trackEcommerceEvent;
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  err,
19
19
  ok,
20
20
  toSdkError
21
- } from "./chunk-LNYVY6ER.mjs";
21
+ } from "./chunk-5C6MNGGB.mjs";
22
22
  export {
23
23
  AddressTypes,
24
24
  BehioApiError,
package/dist/next.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 _chunkXEU3XH6Hjs = require('./chunk-XEU3XH6H.js');
3
+ var _chunkQKEW2EU5js = require('./chunk-QKEW2EU5.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -18,7 +18,7 @@ async function getBehio(options = {}) {
18
18
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
19
19
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
20
20
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
21
- const client = new (0, _chunkXEU3XH6Hjs.BehioStorefront)({
21
+ const client = new (0, _chunkQKEW2EU5js.BehioStorefront)({
22
22
  apiKey,
23
23
  ...baseUrl ? { baseUrl } : {},
24
24
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-LNYVY6ER.mjs";
3
+ } from "./chunk-5C6MNGGB.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies } from "next/headers";
package/dist/react.js CHANGED
@@ -8,7 +8,7 @@
8
8
  var _chunkCZRSJULDjs = require('./chunk-CZRSJULD.js');
9
9
 
10
10
 
11
- var _chunkXEU3XH6Hjs = require('./chunk-XEU3XH6H.js');
11
+ var _chunkQKEW2EU5js = require('./chunk-QKEW2EU5.js');
12
12
 
13
13
  // src/react/provider.tsx
14
14
  var _react = require('react');
@@ -138,7 +138,7 @@ function BehioProvider({
138
138
  const [activeCurrency, setActiveCurrency] = _react.useState.call(void 0, resolveInitialCurrency);
139
139
  const clientRef = _react.useRef.call(void 0, null);
140
140
  if (!clientRef.current) {
141
- clientRef.current = new (0, _chunkXEU3XH6Hjs.BehioStorefront)({
141
+ clientRef.current = new (0, _chunkQKEW2EU5js.BehioStorefront)({
142
142
  apiKey,
143
143
  baseUrl,
144
144
  ...shopDomain ? { shopDomain } : {},
package/dist/react.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-QUU76QUB.mjs";
9
9
  import {
10
10
  BehioStorefront
11
- } from "./chunk-LNYVY6ER.mjs";
11
+ } from "./chunk-5C6MNGGB.mjs";
12
12
 
13
13
  // src/react/provider.tsx
14
14
  import { useRef, useEffect, useMemo, useState, useCallback } from "react";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "0.35.0",
4
- "description": "TypeScript SDK for Behio Headless E-Shop core client + React hooks",
3
+ "version": "0.36.0",
4
+ "description": "TypeScript SDK for Behio Headless E-Shop \u2014 core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",
7
7
  "main": "./dist/index.js",