@djangocfg/nextjs 2.1.544 → 2.1.545

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { CreateDjangoSitemapOptions, CreateRobotsOptions, CreateSitemapIndexOptions, SitemapChunkInfo, SitemapEntry, SitemapFeedPage, SitemapIndex, SitemapSourceInfo, StaticRoute, createDjangoSitemap, createRobots, createSitemapIndex, decodeChunkId, encodeChunkId, fetchSitemapFeed, fetchSitemapIndex } from './sitemap/index.mjs';
1
+ export { CreateDjangoSitemapOptions, CreateRobotsOptions, CreateSitemapIndexOptions, SitemapChunkInfo, SitemapEntry, SitemapFeedPage, SitemapIndex, SitemapSourceInfo, SourceSelector, StaticRoute, createDjangoSitemap, createRobots, createSitemapIndex, decodeChunkId, encodeChunkId, fetchSitemapFeed, fetchSitemapIndex, selectSources, sourceFilter, tenantSources } from './sitemap/index.mjs';
2
2
  export { HealthCheck, HealthConfig, createHealthHandler } from './health/index.mjs';
3
3
  export { BreadcrumbItem, MenuGroup, MenuItem, NavGroup, NavGroupWithRoutes, NavigationItem, NavigationSection, RouteDefinition, RouteMetadata, defineRoute, findRoute, findRouteByPattern, getPageTitle, getUnauthenticatedRedirect, groupRoutesByNavGroups, isActive, redirectToAuth, routesToMenuItems } from './navigation/index.mjs';
4
4
  export { BaseNextConfigOptions, CSP_BASELINE_VENDORS, CSP_VENDOR_PRESETS, CompressionPluginOptions, CspOrigins, CspVendor, DEFAULT_OPTIMIZE_PACKAGES, DEFAULT_TRANSPILE_PACKAGES, DJANGOCFG_PACKAGES, DJANGO_CFG_BANNER, DevStartupPlugin, DevStartupPluginOptions, InstallOptions, InstallProgress, MissingPackage, OPTIONAL_PACKAGES, PACKAGE_NAME, PEER_DEPENDENCIES, PackageDefinition, PackageVersion, UpdateOptions, addCompressionPlugins, buildInstallCommand, buildSingleInstallCommand, checkAndInstallPackages, checkAndUpdatePackages, checkForUpdate, checkForUpdates, checkPackages, createBaseNextConfig, deepMerge, detectPackageManager, fetchLatestVersion, getApiUrl, getBasePath, getCurrentVersion, getInstalledVersion, getMissingPackages, getOutdatedPackages, getPackagesForContext, getSiteUrl, getUpdateCommand, installPackages, installPackagesWithProgress, isCI, isCompressionAvailable, isDev, isPackageInstalled, isProduction, isStaticBuild, printVersionInfo, resetDevStartupState, resetInstallerPreferences, resetUpdaterPreferences, resolveCspVendors, updatePackagesWithProgress } from './config/index.mjs';
package/dist/index.mjs CHANGED
@@ -69,12 +69,40 @@ function decodeChunkId(id) {
69
69
  return { source, cursor: cursorRaw === "" ? null : cursorRaw };
70
70
  }
71
71
 
72
+ // src/sitemap/select.ts
73
+ function sourceFilter(select) {
74
+ if (select === void 0) return () => true;
75
+ if (typeof select === "function") return select;
76
+ const allowed = new Set(select);
77
+ return (name) => allowed.has(name);
78
+ }
79
+ function selectSources(index, select) {
80
+ const keep = sourceFilter(select);
81
+ return index.sources.filter((source) => keep(source.name));
82
+ }
83
+ function selectedChunkIds(index, select, encode) {
84
+ const ids = [];
85
+ for (const source of selectSources(index, select)) {
86
+ for (const chunk of source.chunks) {
87
+ ids.push(encode(source.name, chunk.cursor_to));
88
+ }
89
+ }
90
+ return ids;
91
+ }
92
+ function tenantSources(tenant) {
93
+ return (name) => {
94
+ const sep = name.lastIndexOf("-");
95
+ return sep !== -1 && name.slice(sep + 1) === tenant;
96
+ };
97
+ }
98
+
72
99
  // src/sitemap/sitemap.ts
73
100
  function createDjangoSitemap(opts) {
74
101
  const {
75
102
  host,
76
103
  apiUrl,
77
104
  staticRoutes = [],
105
+ sources,
78
106
  indexRevalidate = DEFAULT_INDEX_REVALIDATE,
79
107
  feedRevalidate = DEFAULT_FEED_REVALIDATE
80
108
  } = opts;
@@ -83,10 +111,8 @@ function createDjangoSitemap(opts) {
83
111
  const ids = [{ id: STATIC_ID }];
84
112
  if (!apiUrl) return ids;
85
113
  const index = await fetchSitemapIndex(apiUrl, indexRevalidate);
86
- for (const s of index.sources) {
87
- for (const c of s.chunks) {
88
- ids.push({ id: encodeChunkId(s.name, c.cursor_to) });
89
- }
114
+ for (const id of selectedChunkIds(index, sources, encodeChunkId)) {
115
+ ids.push({ id });
90
116
  }
91
117
  return ids;
92
118
  },
@@ -97,6 +123,7 @@ function createDjangoSitemap(opts) {
97
123
  }
98
124
  if (!apiUrl) return [];
99
125
  const { source, cursor } = decodeChunkId(id);
126
+ if (!sourceFilter(sources)(source)) return [];
100
127
  const feed = await fetchSitemapFeed(apiUrl, source, cursor, feedRevalidate);
101
128
  return feed.entries.map((e) => ({
102
129
  url: `${host}${e.loc}`,
@@ -118,6 +145,7 @@ function createSitemapIndex(opts) {
118
145
  const {
119
146
  host,
120
147
  apiUrl,
148
+ sources,
121
149
  indexRevalidate = DEFAULT_INDEX_REVALIDATE,
122
150
  includeStatic = true
123
151
  } = opts;
@@ -126,11 +154,7 @@ function createSitemapIndex(opts) {
126
154
  const ids = includeStatic ? [STATIC_ID] : [];
127
155
  if (apiUrl) {
128
156
  const index = await fetchSitemapIndex(apiUrl, indexRevalidate);
129
- for (const s of index.sources) {
130
- for (const c of s.chunks) {
131
- ids.push(encodeChunkId(s.name, c.cursor_to));
132
- }
133
- }
157
+ ids.push(...selectedChunkIds(index, sources, encodeChunkId));
134
158
  }
135
159
  const lastmod = (/* @__PURE__ */ new Date()).toISOString();
136
160
  const body = renderIndex(host, ids, lastmod);
@@ -1932,6 +1956,9 @@ export {
1932
1956
  resolveCspVendors,
1933
1957
  routesToMenuItems,
1934
1958
  search,
1959
+ selectSources,
1960
+ sourceFilter,
1961
+ tenantSources,
1935
1962
  updatePackagesWithProgress
1936
1963
  };
1937
1964
  //# sourceMappingURL=index.mjs.map