@scayle/omnichannel-nuxt 2.1.1 → 2.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @scayle/omnichannel-nuxt
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated to `nuxt@3.10.3` (​For more details check the [Nuxt 3.10.3 Release Notes](https://github.com/nuxt/nuxt/releases/tag/v3.10.3)​)
8
+
9
+ ## 2.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Fix Nuxt 3 runtime error on constant import
14
+ - Handle omnichannel config not present in `runtimeConfig`
15
+
3
16
  ## 2.1.1
4
17
 
5
18
  ### Patch Changes
@@ -3,7 +3,6 @@ import bodyParser from 'body-parser';
3
3
  import qs from 'qs';
4
4
 
5
5
  const DEFAULT_SEARCH_RADIUS = 1e4;
6
-
7
6
  class FetchError extends Error {
8
7
  response;
9
8
  data;
@@ -37,7 +36,14 @@ class OmnichannelClient {
37
36
  return await response.json();
38
37
  }
39
38
  async getStores(options) {
40
- const params = qs.stringify(options, { arrayFormat: "brackets" });
39
+ const fetchOptions = {
40
+ filters: {
41
+ ...options.filters,
42
+ radius: options.filters.radius ?? DEFAULT_SEARCH_RADIUS
43
+ },
44
+ perPage: options.perPage
45
+ };
46
+ const params = qs.stringify(fetchOptions, { arrayFormat: "brackets" });
41
47
  const response = await fetch(`${this.host}/stores/locator?${params}`, {
42
48
  headers: this.headers
43
49
  });
@@ -87,7 +93,7 @@ const getStoresForVariant = async function getStoresForVariant2(options, storeLo
87
93
  const fetchOptions = {
88
94
  filters: {
89
95
  address: options.filters.address,
90
- radius: options.filters.radius ?? DEFAULT_SEARCH_RADIUS
96
+ radius: options.filters.radius
91
97
  },
92
98
  variantId: options.variantId,
93
99
  perPage: 10
package/dist/module.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@scayle/omnichannel-nuxt",
3
- "version": "2.1.0"
3
+ "version": "2.1.2"
4
4
  }
@@ -11,11 +11,15 @@ export default defineEventHandler(async (event) => {
11
11
  const path = event.path.split("/").reverse()[0];
12
12
  const runtimeConfig = useRuntimeConfig();
13
13
  const config = runtimeConfig.omnichannel;
14
- if (!config.apiHost || !config.apiToken) {
14
+ if (!config || !config.apiHost || !config.apiToken) {
15
+ console.error(
16
+ "[Omnichannel] Token and host must be set in the runtimeConfig",
17
+ { config }
18
+ );
15
19
  setResponseStatus(event, HttpStatusCode.INTERNAL_SERVER_ERROR);
16
20
  return {
17
21
  statusCode: HttpStatusCode.INTERNAL_SERVER_ERROR,
18
- message: "Token and host must be set for the omnichannel"
22
+ message: "Token and host must be set in the runtimeConfig"
19
23
  };
20
24
  }
21
25
  const options = {
@@ -1,5 +1,5 @@
1
1
  import qs from "qs";
2
- import { DEFAULT_SEARCH_RADIUS } from "../constants/index.mjs";
2
+ const DEFAULT_SEARCH_RADIUS = 1e4;
3
3
  export class FetchError extends Error {
4
4
  response;
5
5
  data;
@@ -33,7 +33,14 @@ export class OmnichannelClient {
33
33
  return await response.json();
34
34
  }
35
35
  async getStores(options) {
36
- const params = qs.stringify(options, { arrayFormat: "brackets" });
36
+ const fetchOptions = {
37
+ filters: {
38
+ ...options.filters,
39
+ radius: options.filters.radius ?? DEFAULT_SEARCH_RADIUS
40
+ },
41
+ perPage: options.perPage
42
+ };
43
+ const params = qs.stringify(fetchOptions, { arrayFormat: "brackets" });
37
44
  const response = await fetch(`${this.host}/stores/locator?${params}`, {
38
45
  headers: this.headers
39
46
  });
@@ -1,5 +1,4 @@
1
1
  import { init } from "../lib/init.mjs";
2
- import { DEFAULT_SEARCH_RADIUS } from "../constants/index.mjs";
3
2
  const noClientMessage = "Client not configured";
4
3
  export const getStores = async function getStores2(options, storeLocator) {
5
4
  const omnichannelClient = init(storeLocator);
@@ -12,7 +11,7 @@ export const getStoresForVariant = async function getStoresForVariant2(options,
12
11
  const fetchOptions = {
13
12
  filters: {
14
13
  address: options.filters.address,
15
- radius: options.filters.radius ?? DEFAULT_SEARCH_RADIUS
14
+ radius: options.filters.radius
16
15
  },
17
16
  variantId: options.variantId,
18
17
  perPage: 10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/omnichannel-nuxt",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Collection of essential utilities to work with omnichannel",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -53,34 +53,34 @@
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@nuxtjs/composition-api": "0.33.1",
56
- "express": "4.18.2"
56
+ "express": "4.18.3"
57
57
  },
58
58
  "dependencies": {
59
- "@nuxt/kit": "3.10.2",
59
+ "@nuxt/kit": "3.10.3",
60
60
  "body-parser": "1.20.2",
61
- "qs": "6.11.2",
61
+ "qs": "6.12.0",
62
62
  "utility-types": "3.11.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@nuxt/module-builder": "0.5.5",
66
- "@nuxt/schema": "3.10.2",
67
- "@nuxt/types": "2.17.1",
66
+ "@nuxt/schema": "3.10.3",
67
+ "@nuxt/types": "2.17.3",
68
68
  "@nuxtjs/composition-api": "0.33.1",
69
69
  "@scayle/eslint-config-storefront": "3.2.6",
70
70
  "@scayle/prettier-config-storefront": "2.0.2",
71
71
  "@types/body-parser": "1.19.5",
72
72
  "@types/express": "4.17.21",
73
- "@types/node": "20.11.18",
74
- "@types/qs": "6.9.11",
75
- "eslint": "8.56.0",
73
+ "@types/node": "20.11.25",
74
+ "@types/qs": "6.9.12",
75
+ "eslint": "8.57.0",
76
76
  "eslint-formatter-gitlab": "5.1.0",
77
- "h3": "1.10.1",
77
+ "h3": "1.11.1",
78
78
  "nuxi": "3.10.1",
79
79
  "prettier": "3.0.0",
80
- "typescript": "5.3.3",
80
+ "typescript": "5.4.2",
81
81
  "vue": "2.7.16"
82
82
  },
83
83
  "volta": {
84
- "node": "20.11.0"
84
+ "node": "20.11.1"
85
85
  }
86
86
  }
@@ -1 +0,0 @@
1
- export declare const DEFAULT_SEARCH_RADIUS = 10000;
@@ -1 +0,0 @@
1
- export const DEFAULT_SEARCH_RADIUS = 1e4;