storyblok 4.3.3 → 4.3.4

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/index.mjs CHANGED
@@ -2838,18 +2838,21 @@ const fetchStories = async (space, params) => {
2838
2838
  const allStories = [];
2839
2839
  let currentPage = 1;
2840
2840
  let hasMorePages = true;
2841
+ const perPage = 100;
2841
2842
  while (hasMorePages) {
2842
2843
  const { filter_query, ...restParams } = params || {};
2843
2844
  const regularParams = new URLSearchParams({
2844
- ...objectToStringParams({ ...restParams, per_page: 100 }),
2845
+ ...objectToStringParams({ ...restParams, per_page: perPage }),
2845
2846
  ...currentPage > 1 && { page: currentPage.toString() }
2846
2847
  }).toString();
2847
2848
  const queryString = filter_query ? `${regularParams ? `${regularParams}&` : ""}${filter_query}` : regularParams;
2848
2849
  const endpoint = `spaces/${space}/stories${queryString ? `?${queryString}` : ""}`;
2849
2850
  const { data } = await client.get(endpoint, {});
2850
2851
  allStories.push(...data.stories);
2851
- const totalPages = Math.ceil(data.total / data.per_page);
2852
- hasMorePages = currentPage < totalPages;
2852
+ hasMorePages = data.stories.length === perPage && data.stories.length > 0;
2853
+ if (data.stories.length < perPage) {
2854
+ break;
2855
+ }
2853
2856
  currentPage++;
2854
2857
  }
2855
2858
  return allStories;
@@ -4860,7 +4863,7 @@ program$1.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
4860
4863
  konsola.br();
4861
4864
  });
4862
4865
 
4863
- const version = "4.3.3";
4866
+ const version = "4.3.4";
4864
4867
  const pkg = {
4865
4868
  version: version};
4866
4869