@ampless/runtime 1.0.0-beta.71 → 1.0.0-beta.72

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.
@@ -207,6 +207,7 @@ function createMarkdownRouteHandler(ampless) {
207
207
  }
208
208
 
209
209
  // src/routes/llms.ts
210
+ import { collectBounded } from "ampless";
210
211
  var DEFAULT_LIMIT = 100;
211
212
  var MIN_LIMIT = 1;
212
213
  var MAX_LIMIT = 1e3;
@@ -241,36 +242,10 @@ function fixedEncodeURIComponent(s) {
241
242
  );
242
243
  }
243
244
  async function collectPosts(ampless, limit) {
244
- const items = [];
245
- const seenTokens = /* @__PURE__ */ new Set();
246
- let token;
247
- let truncated = null;
248
- for (let page = 0; page < MAX_PAGES; page++) {
249
- const remaining = limit + 1 - items.length;
250
- const pageLimit = Math.min(PAGE_SIZE_CAP, remaining);
251
- const res = await ampless.listPublishedPosts({ limit: pageLimit, nextToken: token });
252
- items.push(...res.items);
253
- if (items.length > limit) {
254
- truncated = "limit";
255
- break;
256
- }
257
- if (!res.nextToken) {
258
- break;
259
- }
260
- if (seenTokens.has(res.nextToken)) {
261
- truncated = "early";
262
- break;
263
- }
264
- seenTokens.add(res.nextToken);
265
- token = res.nextToken;
266
- if (page === MAX_PAGES - 1) {
267
- truncated = "early";
268
- }
269
- }
270
- return {
271
- items: truncated === "limit" ? items.slice(0, limit) : items,
272
- truncated
273
- };
245
+ return collectBounded(
246
+ (args) => ampless.listPublishedPosts({ limit: args.limit, nextToken: args.nextToken }),
247
+ { limit, pageSizeCap: PAGE_SIZE_CAP, maxPages: MAX_PAGES }
248
+ );
274
249
  }
275
250
  function truncationNote(truncated, limit) {
276
251
  if (truncated === "limit") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/runtime",
3
- "version": "1.0.0-beta.71",
3
+ "version": "1.0.0-beta.72",
4
4
  "description": "Public-side runtime for ampless: post fetching, theme dispatch, middleware, public route handlers",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,8 +51,8 @@
51
51
  "marked": "^18.0.4",
52
52
  "sanitize-html": "^2.17.4",
53
53
  "tailwind-merge": "^3.6.0",
54
- "@ampless/plugin-og-image": "0.2.0-beta.58",
55
- "ampless": "1.0.0-beta.58"
54
+ "@ampless/plugin-og-image": "0.2.0-beta.59",
55
+ "ampless": "1.0.0-beta.59"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@aws-amplify/adapter-nextjs": "^1",