@websline/cms-view-utils 1.7.0 → 1.7.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/package.json +42 -41
- package/src/client/fetchBoard.js +8 -0
- package/src/client/fetchBoards.js +7 -0
- package/src/client/fetchCollections.js +10 -0
- package/src/client/fetchFaqs.js +11 -0
- package/src/client/fetchPageTeasers.js +63 -0
- package/src/client/fetchRatings.js +29 -0
- package/src/client/fetchSimilarPackages.js +9 -0
- package/src/client/fetchSimilarRooms.js +9 -0
- package/src/index.js +2 -0
package/package.json
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
"name": "@websline/cms-view-utils",
|
|
3
|
+
"version": "1.7.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"src",
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.js",
|
|
11
|
+
"./server": "./src/server.js",
|
|
12
|
+
"./components/*": "./src/components/*",
|
|
13
|
+
"./preview-bridge": "./dist/previewBridge.global.js",
|
|
14
|
+
"./edit-scroll": "./dist/editScroll.global.js",
|
|
15
|
+
"./dist/*": "./dist/*"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"jsonwebtoken": "^9.0.3",
|
|
19
|
+
"tailwind-merge": "^3.6.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/compat": "^2.1.0",
|
|
23
|
+
"@eslint/js": "^10.0.1",
|
|
24
|
+
"eslint": "^10.9.0",
|
|
25
|
+
"eslint-config-prettier": "^10.1.8",
|
|
26
|
+
"eslint-plugin-svelte": "^3.23.0",
|
|
27
|
+
"globals": "^17.11.0",
|
|
28
|
+
"prettier": "^3.9.6",
|
|
29
|
+
"prettier-plugin-svelte": "^4.1.1",
|
|
30
|
+
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
31
|
+
"tsup": "^8.5.1"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"svelte": "^5.0.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"prepublishOnly": "pnpm build",
|
|
39
|
+
"format": "prettier --write .",
|
|
40
|
+
"lint": "prettier --check . && eslint ."
|
|
41
|
+
},
|
|
42
|
+
"sideEffects": false
|
|
43
|
+
}
|
package/src/client/fetchBoard.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a single ABM board.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {string|number} options.boardId - ABM id of the board.
|
|
7
|
+
* @returns {Promise<object>} The board object.
|
|
8
|
+
*/
|
|
1
9
|
const fetchBoard = async ({ locale, boardId }) => {
|
|
2
10
|
const url = `/api/cms/api/public/abm-boards/${locale}/${boardId}`;
|
|
3
11
|
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch all ABM boards.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @returns {Promise<object[]>} The boards.
|
|
7
|
+
*/
|
|
1
8
|
const fetchBoards = async ({ locale }) => {
|
|
2
9
|
const url = `/api/cms/api/public/abm-boards/${locale}`;
|
|
3
10
|
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch the items of a collection, or a single item of it.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {string} options.identifier - Collection identifier as configured in the CMS, e.g. `"blog"`.
|
|
7
|
+
* @param {string} [options.itemUuid] - Return only this item, as a plain object instead of an array.
|
|
8
|
+
* @param {number} [options.limit] - Maximum number of items, counted from the start of the CMS order. Ignored together with `itemUuid`.
|
|
9
|
+
* @returns {Promise<object[]|object>} An array of items, or a single item when `itemUuid` is set.
|
|
10
|
+
*/
|
|
1
11
|
const fetchCollections = async ({ identifier, itemUuid, limit, locale }) => {
|
|
2
12
|
const params = new URLSearchParams();
|
|
3
13
|
|
package/src/client/fetchFaqs.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch ABM FAQs.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {string|number} [options.excludeId] - ABM FAQ id to leave out, e.g. the FAQ already shown on the page.
|
|
7
|
+
* @param {string[]} [options.tags] - Keep only FAQs carrying at least one of these tags (OR, not AND).
|
|
8
|
+
* @param {string[]} [options.groups] - Keep only FAQs belonging to one of these group ids.
|
|
9
|
+
* @param {number} [options.limit] - Maximum number of FAQs, applied after the filters.
|
|
10
|
+
* @returns {Promise<object[]>} The matching FAQs.
|
|
11
|
+
*/
|
|
1
12
|
const fetchFaqs = async ({ excludeId, limit, locale, tags, groups }) => {
|
|
2
13
|
const params = new URLSearchParams();
|
|
3
14
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch the teasers of the tenant's published pages, e.g. for a blog index or related-posts list.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {string} [options.excludePageUuid] - Page UUID to leave out, e.g. the page currently shown.
|
|
7
|
+
* @param {boolean} [options.isBlog] - `true` for blog pages only, `false` for non-blog pages only, omit for all.
|
|
8
|
+
* @param {string[]} [options.tags] - Keep only pages carrying at least one of these tag UUIDs (OR, not AND).
|
|
9
|
+
* @param {"newest"|"oldest"} [options.order] - Sort by publication date; defaults to `"newest"`.
|
|
10
|
+
* @param {number} [options.offset] - Number of teasers to skip, applied after all filters.
|
|
11
|
+
* @param {number} [options.limit] - Maximum number of teasers; omit for all — there is no default.
|
|
12
|
+
* @returns {Promise<object[]>} The teasers.
|
|
13
|
+
*/
|
|
14
|
+
const fetchPageTeasers = async ({
|
|
15
|
+
locale,
|
|
16
|
+
excludePageUuid,
|
|
17
|
+
isBlog,
|
|
18
|
+
tags,
|
|
19
|
+
order,
|
|
20
|
+
offset,
|
|
21
|
+
limit,
|
|
22
|
+
}) => {
|
|
23
|
+
const params = new URLSearchParams();
|
|
24
|
+
|
|
25
|
+
if (excludePageUuid != null && excludePageUuid !== "") {
|
|
26
|
+
params.set("excludePageUuid", excludePageUuid);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The API accepts exactly `true` or `false` — anything else answers 422,
|
|
30
|
+
// so only real booleans are forwarded.
|
|
31
|
+
if (isBlog === true || isBlog === false) {
|
|
32
|
+
params.set("isBlog", isBlog);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(tags)) {
|
|
36
|
+
for (const tag of tags) {
|
|
37
|
+
if (tag != null && tag !== "") {
|
|
38
|
+
params.append("tags", tag);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (order != null && order !== "") {
|
|
44
|
+
params.set("order", order);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (offset != null) {
|
|
48
|
+
params.set("offset", offset);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (limit != null) {
|
|
52
|
+
params.set("limit", limit);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const query = params.toString();
|
|
56
|
+
const url = `/api/cms/api/public/page-teasers/${locale}${query ? `?${query}` : ""}`;
|
|
57
|
+
|
|
58
|
+
const response = await fetch(url, { method: "GET" });
|
|
59
|
+
|
|
60
|
+
return response.json();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { fetchPageTeasers };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch ABM guest reviews, newest first, page by page.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {number} [options.page] - 1-based page number. Invalid values fall back to 1.
|
|
7
|
+
* @param {number} [options.pageSize] - Reviews per page: 6, 9, 12, 15 or 18. Anything else falls back to 12.
|
|
8
|
+
* @returns {Promise<object>} `{ items, pagination }` — `pagination` carries `page`, `pages`, `pageSize` and `total`. A page past the end has empty `items`.
|
|
9
|
+
*/
|
|
10
|
+
const fetchRatings = async ({ locale, page, pageSize }) => {
|
|
11
|
+
const params = new URLSearchParams();
|
|
12
|
+
|
|
13
|
+
if (page != null) {
|
|
14
|
+
params.set("page", page);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (pageSize != null) {
|
|
18
|
+
params.set("pageSize", pageSize);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const query = params.toString();
|
|
22
|
+
const url = `/api/cms/api/public/abm-ratings/${locale}${query ? `?${query}` : ""}`;
|
|
23
|
+
|
|
24
|
+
const response = await fetch(url, { method: "GET" });
|
|
25
|
+
|
|
26
|
+
return response.json();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { fetchRatings };
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch ABM packages, typically for a "similar packages" section.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {string|number} [options.excludeId] - ABM package id to leave out, e.g. the package currently shown.
|
|
7
|
+
* @param {number} [options.limit] - Maximum number of packages to return.
|
|
8
|
+
* @returns {Promise<object[]>} The packages.
|
|
9
|
+
*/
|
|
1
10
|
const fetchSimilarPackages = async ({ excludeId, limit, locale }) => {
|
|
2
11
|
const params = new URLSearchParams();
|
|
3
12
|
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch ABM rooms, typically for a "similar rooms" section.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale - Locale code, e.g. `"de"`.
|
|
6
|
+
* @param {string|number} [options.excludeId] - ABM room id to leave out, e.g. the room currently shown.
|
|
7
|
+
* @param {number} [options.limit] - Maximum number of rooms to return.
|
|
8
|
+
* @returns {Promise<object[]>} The rooms.
|
|
9
|
+
*/
|
|
1
10
|
const fetchSimilarRooms = async ({ excludeId, limit, locale }) => {
|
|
2
11
|
const params = new URLSearchParams();
|
|
3
12
|
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,8 @@ export { fetchFaqs } from "./client/fetchFaqs.js";
|
|
|
5
5
|
export { fetchCollections } from "./client/fetchCollections.js";
|
|
6
6
|
export { fetchBoards } from "./client/fetchBoards.js";
|
|
7
7
|
export { fetchBoard } from "./client/fetchBoard.js";
|
|
8
|
+
export { fetchPageTeasers } from "./client/fetchPageTeasers.js";
|
|
9
|
+
export { fetchRatings } from "./client/fetchRatings.js";
|
|
8
10
|
|
|
9
11
|
export { default as AddBlockPlaceholder } from "./components/AddBlockPlaceholder.svelte";
|
|
10
12
|
export { default as BlockWrapper } from "./components/BlockWrapper.svelte";
|