@weaverse/hydrogen 5.12.1 → 5.13.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/dist/index.mjs CHANGED
@@ -1405,6 +1405,49 @@ var WeaverseClient = class {
1405
1405
  ]
1406
1406
  };
1407
1407
  };
1408
+ /**
1409
+ * Fetch all published custom pages for sitemap generation.
1410
+ * Paginates automatically, never throws, returns accumulated results on partial failure.
1411
+ */
1412
+ async fetchCustomPages(opts) {
1413
+ const { weaverseHost, projectId } = this.configs;
1414
+ const entries = [];
1415
+ const MAX_PAGES = 100;
1416
+ let cursor = null;
1417
+ for (let i = 0; i < MAX_PAGES; i++) {
1418
+ const params = new URLSearchParams();
1419
+ if (opts?.locale) {
1420
+ params.set("locale", opts.locale);
1421
+ }
1422
+ if (opts?.limit) {
1423
+ params.set("limit", String(opts.limit));
1424
+ }
1425
+ if (cursor) {
1426
+ params.set("cursor", cursor);
1427
+ }
1428
+ const qs = params.toString();
1429
+ const url = `${weaverseHost}/api/public/v1/projects/${projectId}/custom-pages${qs ? `?${qs}` : ""}`;
1430
+ try {
1431
+ const result = await this.fetchWithCache(url);
1432
+ entries.push(...result.data || []);
1433
+ if (!result.nextCursor) {
1434
+ return entries;
1435
+ }
1436
+ cursor = result.nextCursor;
1437
+ } catch (err) {
1438
+ const status = err?.status;
1439
+ const msg = err?.message || String(err);
1440
+ console.warn(
1441
+ entries.length === 0 ? `[Weaverse] Failed to fetch custom pages: ${msg}${status ? ` (HTTP ${status})` : ""}` : `[Weaverse] Custom pages pagination interrupted: ${msg}`
1442
+ );
1443
+ return entries;
1444
+ }
1445
+ }
1446
+ console.warn(
1447
+ "[Weaverse] Custom pages pagination cap reached (100 iterations)"
1448
+ );
1449
+ return entries;
1450
+ }
1408
1451
  /**
1409
1452
  * Load page data from Weaverse API with optional route-level project override.
1410
1453
  * Fetches page content, executes component loaders, and handles empty items fallback.