@pronto-tools-and-more/api 14.24.0 → 14.26.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/api",
3
- "version": "14.24.0",
3
+ "version": "14.26.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  import * as GraphQlQueryAppSettings from "../GraphQlQueryAppSettings/GraphQlQueryAppSettings.js";
2
2
 
3
- export const handleApiAppSettings = async ({ appId, apiUrl, req }) => {
3
+ const getDataOnce = async ({ appId, apiUrl, offset, batchSize }) => {
4
4
  const realBottom = {
5
5
  ...GraphQlQueryAppSettings.bottom,
6
6
  filter: {},
@@ -8,6 +8,8 @@ export const handleApiAppSettings = async ({ appId, apiUrl, req }) => {
8
8
  ...GraphQlQueryAppSettings.bottom.appInfo,
9
9
  appId,
10
10
  },
11
+ first: batchSize,
12
+ after: `${offset}`,
11
13
  };
12
14
  const response = await fetch(apiUrl, {
13
15
  method: "POST",
@@ -30,9 +32,25 @@ export const handleApiAppSettings = async ({ appId, apiUrl, req }) => {
30
32
  const { __typename, ...rest } = node;
31
33
  return rest;
32
34
  });
35
+ return realData;
36
+ };
33
37
 
38
+ export const handleApiAppSettings = async ({ appId, apiUrl, req }) => {
39
+ const allData = [];
40
+ let offset = 0;
41
+ const batchSize = 100;
42
+ let count = 0;
43
+ const maxCount = 30;
44
+ while (true) {
45
+ if (count++ > maxCount) {
46
+ break;
47
+ }
48
+ const data = await getDataOnce({ apiUrl, appId, offset, batchSize });
49
+ offset += batchSize;
50
+ allData.push(...data);
51
+ }
34
52
  const object = Object.create(null);
35
- for (const node of realData) {
53
+ for (const node of allData) {
36
54
  object[node.key] = node.value;
37
55
  }
38
56