vinmonopolet-ts 2.0.4 → 2.0.5
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/cjs/retrievers/getFacets.js +1 -1
- package/dist/cjs/retrievers/getProductsByStore.js +5 -1
- package/dist/cjs/retrievers/getStore.js +1 -1
- package/dist/cjs/retrievers/getStores.js +2 -2
- package/dist/cjs/util/request.js +1 -0
- package/dist/esm/retrievers/getFacets.js +1 -1
- package/dist/esm/retrievers/getProductsByStore.js +5 -1
- package/dist/esm/retrievers/getStore.js +1 -1
- package/dist/esm/retrievers/getStores.js +2 -2
- package/dist/esm/util/request.js +1 -0
- package/dist/types/retrievers/getProductsByStore.d.ts +2 -2
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@ const request_1 = __importDefault(require("../util/request"));
|
|
|
7
7
|
const Facet_1 = __importDefault(require("../models/Facet"));
|
|
8
8
|
function getFacets() {
|
|
9
9
|
return request_1.default
|
|
10
|
-
.get("/
|
|
10
|
+
.get("/vmpws/v2/vmp/search", {
|
|
11
11
|
baseUrl: "https://www.vinmonopolet.no",
|
|
12
12
|
query: {
|
|
13
13
|
fields: "FULL",
|
|
@@ -16,7 +16,11 @@ async function getProductsByStore(store, opts) {
|
|
|
16
16
|
const safeFacets = opts?.facets.filter((facet) => facet !== undefined);
|
|
17
17
|
facets = facets.concat(safeFacets);
|
|
18
18
|
}
|
|
19
|
-
const options = {
|
|
19
|
+
const options = {
|
|
20
|
+
limit: opts?.limit,
|
|
21
|
+
facets: facets,
|
|
22
|
+
page: opts?.page ?? 1,
|
|
23
|
+
};
|
|
20
24
|
const allProducts = await (0, getProducts_1.default)(options);
|
|
21
25
|
return { ...allProducts, store };
|
|
22
26
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Store_1 = __importDefault(require("../models/Store"));
|
|
7
7
|
const request_1 = __importDefault(require("../util/request"));
|
|
8
8
|
const getStore = async (store_id) => {
|
|
9
|
-
const res = await request_1.default.get(`/
|
|
9
|
+
const res = await request_1.default.get(`/vmpws/v2/vmp/stores/${store_id}`, {
|
|
10
10
|
baseUrl: "https://www.vinmonopolet.no",
|
|
11
11
|
query: { fields: "FULL" },
|
|
12
12
|
});
|
|
@@ -25,7 +25,7 @@ function searchByQuery(querystring) {
|
|
|
25
25
|
const query = {
|
|
26
26
|
query: querystring,
|
|
27
27
|
};
|
|
28
|
-
const req = request_1.default.get("/
|
|
28
|
+
const req = request_1.default.get("/vmpws/v2/vmp/stores/autocomplete", {
|
|
29
29
|
baseUrl: "https://www.vinmonopolet.no",
|
|
30
30
|
query,
|
|
31
31
|
});
|
|
@@ -41,7 +41,7 @@ function searchByLocation(lat, lon, currentPage = 1, pageSize = 10) {
|
|
|
41
41
|
latitude: lat,
|
|
42
42
|
longitude: lon,
|
|
43
43
|
};
|
|
44
|
-
const req = request_1.default.get("/
|
|
44
|
+
const req = request_1.default.get("/vmpws/v2/vmp/stores", {
|
|
45
45
|
baseUrl: "https://www.vinmonopolet.no",
|
|
46
46
|
query,
|
|
47
47
|
});
|
package/dist/cjs/util/request.js
CHANGED
|
@@ -13,6 +13,7 @@ function sendRequest(path, options = {}) {
|
|
|
13
13
|
const reqOpts = options.request || {};
|
|
14
14
|
const base = options.baseUrl || baseUrl;
|
|
15
15
|
const url = `${base}${path}${query}`;
|
|
16
|
+
console.log(url);
|
|
16
17
|
return fetch(url, reqOpts);
|
|
17
18
|
}
|
|
18
19
|
sendRequest.get = (path, options) => sendRequest(path, options)
|
|
@@ -11,7 +11,11 @@ async function getProductsByStore(store, opts) {
|
|
|
11
11
|
const safeFacets = opts?.facets.filter((facet) => facet !== undefined);
|
|
12
12
|
facets = facets.concat(safeFacets);
|
|
13
13
|
}
|
|
14
|
-
const options = {
|
|
14
|
+
const options = {
|
|
15
|
+
limit: opts?.limit,
|
|
16
|
+
facets: facets,
|
|
17
|
+
page: opts?.page ?? 1,
|
|
18
|
+
};
|
|
15
19
|
const allProducts = await getProducts(options);
|
|
16
20
|
return { ...allProducts, store };
|
|
17
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PopulatedStore from "../models/Store";
|
|
2
2
|
import request from "../util/request";
|
|
3
3
|
const getStore = async (store_id) => {
|
|
4
|
-
const res = await request.get(`/
|
|
4
|
+
const res = await request.get(`/vmpws/v2/vmp/stores/${store_id}`, {
|
|
5
5
|
baseUrl: "https://www.vinmonopolet.no",
|
|
6
6
|
query: { fields: "FULL" },
|
|
7
7
|
});
|
|
@@ -18,7 +18,7 @@ function searchByQuery(querystring) {
|
|
|
18
18
|
const query = {
|
|
19
19
|
query: querystring,
|
|
20
20
|
};
|
|
21
|
-
const req = request.get("/
|
|
21
|
+
const req = request.get("/vmpws/v2/vmp/stores/autocomplete", {
|
|
22
22
|
baseUrl: "https://www.vinmonopolet.no",
|
|
23
23
|
query,
|
|
24
24
|
});
|
|
@@ -34,7 +34,7 @@ function searchByLocation(lat, lon, currentPage = 1, pageSize = 10) {
|
|
|
34
34
|
latitude: lat,
|
|
35
35
|
longitude: lon,
|
|
36
36
|
};
|
|
37
|
-
const req = request.get("/
|
|
37
|
+
const req = request.get("/vmpws/v2/vmp/stores", {
|
|
38
38
|
baseUrl: "https://www.vinmonopolet.no",
|
|
39
39
|
query,
|
|
40
40
|
});
|
package/dist/esm/util/request.js
CHANGED
|
@@ -8,6 +8,7 @@ function sendRequest(path, options = {}) {
|
|
|
8
8
|
const reqOpts = options.request || {};
|
|
9
9
|
const base = options.baseUrl || baseUrl;
|
|
10
10
|
const url = `${base}${path}${query}`;
|
|
11
|
+
console.log(url);
|
|
11
12
|
return fetch(url, reqOpts);
|
|
12
13
|
}
|
|
13
14
|
sendRequest.get = (path, options) => sendRequest(path, options)
|
|
@@ -18,8 +18,8 @@ interface IGetProductsByStoreOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
page?: number;
|
|
20
20
|
}
|
|
21
|
-
interface
|
|
21
|
+
export interface IGetProductsByStoreResponse extends IGetProductsResponse {
|
|
22
22
|
store: string;
|
|
23
23
|
}
|
|
24
|
-
declare function getProductsByStore(store: string, opts?: IGetProductsByStoreOptions): Promise<
|
|
24
|
+
declare function getProductsByStore(store: string, opts?: IGetProductsByStoreOptions): Promise<IGetProductsByStoreResponse>;
|
|
25
25
|
export default getProductsByStore;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vinmonopolet-ts",
|
|
3
3
|
"description": "Extracts information on products, categories and stores from Vinmonopolet",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vinmonopolet",
|
|
7
7
|
"beer",
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
"query-string": "^4.3.4",
|
|
66
66
|
"typescript": "^4.7.3"
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|