@kidecms/core 0.25.1 → 0.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.
@@ -90,7 +90,7 @@ const extractDataFromForm = async (request: Request) => {
90
90
  data: Object.fromEntries(
91
91
  entries.filter(
92
92
  ([key]) =>
93
- (!key.startsWith("_") || key === "_publishAt" || key === "_unpublishAt") &&
93
+ (!key.startsWith("_") || key === "_publishAt" || key === "_unpublishAt" || key === "_sourceLocale") &&
94
94
  key !== "redirectTo" &&
95
95
  key !== "locale" &&
96
96
  key !== "version",
@@ -74,6 +74,9 @@ export const GET: APIRoute = async ({ url, locals }) => {
74
74
  (c) => requested.includes(c.slug) && !HIDDEN_FROM_SEARCH.has(c.slug),
75
75
  );
76
76
  const results: SearchResult[] = [];
77
+ // Pickers say so when the list is cut off, so 20 rows don't read as "all
78
+ // there is" — one extra row tells us without a count query.
79
+ let hasMore = false;
77
80
 
78
81
  for (const collection of collections) {
79
82
  const api = cmsAny[collection.slug];
@@ -92,15 +95,20 @@ export const GET: APIRoute = async ({ url, locals }) => {
92
95
  // Recently-updated first in both modes — without a sort, LIMIT keeps an
93
96
  // arbitrary subset of the matches.
94
97
  const sort = { field: "_updatedAt", direction: "desc" } as const;
95
- if (q.length >= MIN_QUERY_LENGTH) return api.find({ search: q, status: "any", sort, limit }, context);
96
- return api.find({ status: "any", sort, limit }, context);
98
+ const probe = limit + 1;
99
+ const found =
100
+ q.length >= MIN_QUERY_LENGTH
101
+ ? await api.find({ search: q, status: "any", sort, limit: probe }, context)
102
+ : await api.find({ status: "any", sort, limit: probe }, context);
103
+ if (found.length > limit) hasMore = true;
104
+ return found.slice(0, limit);
97
105
  })().catch(() => null);
98
106
 
99
107
  if (!docs) continue;
100
108
  for (const doc of docs) results.push(toResult(collection, doc));
101
109
  }
102
110
 
103
- return Response.json({ results });
111
+ return Response.json({ results, hasMore });
104
112
  }
105
113
 
106
114
  // Palette mode: everything, a few hits per collection.