@anywayseo/gatsby-plugin 6.2.0 → 6.3.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.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anywayseo/gatsby-plugin",
|
|
3
3
|
"description": "Shared config for Anywayseo sites",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.3.0",
|
|
5
5
|
"author": "zerg41",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"commonmark": "0.31.2",
|
|
32
|
-
"qs": "6.
|
|
32
|
+
"qs": "6.15.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/commonmark": "0.27.10",
|
|
36
36
|
"@types/node": "^20.0.0",
|
|
37
|
-
"@types/qs": "6.
|
|
37
|
+
"@types/qs": "6.15.1",
|
|
38
38
|
"rimraf": "^6.0.1",
|
|
39
39
|
"typescript": "^5.0.0"
|
|
40
40
|
},
|
|
@@ -19,36 +19,30 @@ const helpers_1 = require("./helpers");
|
|
|
19
19
|
const utils_1 = require("./utils");
|
|
20
20
|
function fetchEntities(_a, schemas_1, strapiClient_1, reporter_1) {
|
|
21
21
|
return __awaiter(this, arguments, void 0, function* ({ endpoint, queryParams, uid }, schemas, strapiClient, reporter) {
|
|
22
|
-
var _b, _c
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
var _b, _c;
|
|
23
|
+
const isPaginated = Boolean(queryParams.pagination);
|
|
24
|
+
const pageSize = Math.min((_c = (_b = queryParams.pagination) === null || _b === void 0 ? void 0 : _b.pageSize) !== null && _c !== void 0 ? _c : utils_1.DEFAULT_PAGE_SIZE, utils_1.MAX_PAGE_SIZE);
|
|
25
|
+
const data = [];
|
|
26
|
+
let page = utils_1.INITIAL_PAGE;
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (pageResult.data) {
|
|
45
|
-
data.push(pageResult.data);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
28
|
+
while (true) {
|
|
29
|
+
const params = (0, helpers_1.convertQueryParameters)(Object.assign(Object.assign({}, queryParams), (isPaginated && { pagination: { pageSize, page } })));
|
|
30
|
+
const query = qs_1.default.stringify(params, { encodeValuesOnly: true });
|
|
31
|
+
const path = `${endpoint}?${query}`;
|
|
32
|
+
reporter.info(page === utils_1.INITIAL_PAGE
|
|
33
|
+
? `Starting to fetch ${endpoint} with ${query}`
|
|
34
|
+
: `Starting to fetch next page (${page}) of ${endpoint}`);
|
|
35
|
+
const result = yield strapiClient.fetch(path);
|
|
36
|
+
const currentPageData = (0, utils_1.castArray)(result.data);
|
|
37
|
+
const currentPageSize = currentPageData.length;
|
|
38
|
+
data.push(...currentPageData);
|
|
39
|
+
// Strapi's meta.pagination.total/pageCount can't be trusted (some instances report 0
|
|
40
|
+
// regardless of actual content), so keep paging until a response comes back short of a
|
|
41
|
+
// full page rather than relying on that count.
|
|
42
|
+
if (!isPaginated || currentPageSize < pageSize) {
|
|
43
|
+
break;
|
|
51
44
|
}
|
|
45
|
+
page += 1;
|
|
52
46
|
}
|
|
53
47
|
const entities = data.map((entity) => (0, clean_entity_1.cleanEntity)(entity, uid, schemas));
|
|
54
48
|
return entities;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const STRAPI_ID_PROPERTY = "strapi_id";
|
|
2
2
|
export declare const DEFAULT_PAGE_SIZE = 25;
|
|
3
|
+
export declare const MAX_PAGE_SIZE = 100;
|
|
4
|
+
export declare const INITIAL_PAGE = 1;
|
|
3
5
|
export declare function castArray<T>(value: T | T[]): T[];
|
|
4
6
|
export declare function toSnakeCase(str?: string): string;
|
|
5
7
|
export declare function pick<T extends Record<string, any>>(obj: T, keys: string[]): Partial<T>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_PAGE_SIZE = exports.STRAPI_ID_PROPERTY = void 0;
|
|
3
|
+
exports.INITIAL_PAGE = exports.MAX_PAGE_SIZE = exports.DEFAULT_PAGE_SIZE = exports.STRAPI_ID_PROPERTY = void 0;
|
|
4
4
|
exports.castArray = castArray;
|
|
5
5
|
exports.toSnakeCase = toSnakeCase;
|
|
6
6
|
exports.pick = pick;
|
|
7
7
|
exports.STRAPI_ID_PROPERTY = 'strapi_id';
|
|
8
8
|
exports.DEFAULT_PAGE_SIZE = 25;
|
|
9
|
+
exports.MAX_PAGE_SIZE = 100;
|
|
10
|
+
exports.INITIAL_PAGE = 1;
|
|
9
11
|
function castArray(value) {
|
|
10
12
|
return Array.isArray(value) ? value : [value];
|
|
11
13
|
}
|