@scayle/omnichannel-nuxt 2.1.1 → 2.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/CHANGELOG.md +7 -0
- package/dist/chunks/createOmnichannelHandler.mjs +9 -3
- package/dist/module.json +1 -1
- package/dist/runtime/handler.mjs +6 -2
- package/dist/runtime/lib/init.mjs +9 -2
- package/dist/runtime/rpc/storeLocator.mjs +1 -2
- package/package.json +5 -5
- package/dist/runtime/constants/index.d.ts +0 -1
- package/dist/runtime/constants/index.mjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -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
|
|
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
|
|
96
|
+
radius: options.filters.radius
|
|
91
97
|
},
|
|
92
98
|
variantId: options.variantId,
|
|
93
99
|
perPage: 10
|
package/dist/module.json
CHANGED
package/dist/runtime/handler.mjs
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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
|
|
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.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Collection of essential utilities to work with omnichannel",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,17 +70,17 @@
|
|
|
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.
|
|
73
|
+
"@types/node": "20.11.20",
|
|
74
74
|
"@types/qs": "6.9.11",
|
|
75
|
-
"eslint": "8.
|
|
75
|
+
"eslint": "8.57.0",
|
|
76
76
|
"eslint-formatter-gitlab": "5.1.0",
|
|
77
|
-
"h3": "1.
|
|
77
|
+
"h3": "1.11.1",
|
|
78
78
|
"nuxi": "3.10.1",
|
|
79
79
|
"prettier": "3.0.0",
|
|
80
80
|
"typescript": "5.3.3",
|
|
81
81
|
"vue": "2.7.16"
|
|
82
82
|
},
|
|
83
83
|
"volta": {
|
|
84
|
-
"node": "20.11.
|
|
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;
|