@justanarthur/payload-www 0.3.2 → 0.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.
@@ -16,11 +16,21 @@ var __export = (target, all) => {
16
16
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
17
 
18
18
  // src/core/access/index.ts
19
- var anyone = () => true;
20
- var authenticated = ({ req: { user } }) => Boolean(user);
19
+ var anyone = () => {
20
+ console.log("[WWW] core/access:anyone -> true");
21
+ return true;
22
+ };
23
+ var authenticated = ({ req: { user } }) => {
24
+ const result = Boolean(user);
25
+ console.log("[WWW] core/access:authenticated ->", result);
26
+ return result;
27
+ };
21
28
  var authenticatedOrPublished = ({ req: { user } }) => {
22
- if (user)
29
+ if (user) {
30
+ console.log("[WWW] core/access:authenticatedOrPublished -> true (authenticated)");
23
31
  return true;
32
+ }
33
+ console.log('[WWW] core/access:authenticatedOrPublished -> { _status: { equals: "published" } }');
24
34
  return { _status: { equals: "published" } };
25
35
  };
26
36
 
@@ -31,6 +41,7 @@ var slugField = (options = {}) => {
31
41
  const { name = "slug", nested = false, localized = true } = options;
32
42
  const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
33
43
  const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
44
+ console.log("[WWW] core/fields:slugField options=", JSON.stringify({ name, nested, localized }));
34
45
  return {
35
46
  name,
36
47
  type: "text",
@@ -45,8 +56,10 @@ var slugField = (options = {}) => {
45
56
  validate: (value) => {
46
57
  if (typeof value !== "string")
47
58
  return "Slug must be a string";
48
- if (value !== "" && !pattern.test(value))
59
+ if (value !== "" && !pattern.test(value)) {
60
+ console.warn("[WWW] core/fields:slugField invalid slug value=", JSON.stringify(value));
49
61
  return invalidMessage;
62
+ }
50
63
  return true;
51
64
  }
52
65
  };
@@ -54,30 +67,45 @@ var slugField = (options = {}) => {
54
67
 
55
68
  // src/render/_locale.ts
56
69
  function prefixFor(locale, defaultLocale, mode) {
70
+ let result;
57
71
  if (mode === "never")
58
- return "";
59
- if (mode === "as-needed" && locale === defaultLocale)
60
- return "";
61
- return `/${locale}`;
72
+ result = "";
73
+ else if (mode === "as-needed" && locale === defaultLocale)
74
+ result = "";
75
+ else
76
+ result = `/${locale}`;
77
+ console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
78
+ return result;
62
79
  }
63
80
  function resolveLocale(req) {
64
- if (!req || typeof req !== "object")
81
+ if (!req || typeof req !== "object") {
82
+ console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
65
83
  return "";
84
+ }
66
85
  const r = req;
67
- if (typeof r.locale === "string" && r.locale.length > 0)
86
+ if (typeof r.locale === "string" && r.locale.length > 0) {
87
+ console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
68
88
  return r.locale;
89
+ }
69
90
  const fallback = r.payload?.config?.localization?.defaultLocale;
70
- if (typeof fallback === "string" && fallback.length > 0)
91
+ if (typeof fallback === "string" && fallback.length > 0) {
92
+ console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
71
93
  return fallback;
94
+ }
95
+ console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
72
96
  return "";
73
97
  }
74
98
  function allLocales(req) {
75
- if (!req || typeof req !== "object")
99
+ if (!req || typeof req !== "object") {
100
+ console.log("[WWW] render/_locale:allLocales -> [] (no req)");
76
101
  return [];
102
+ }
77
103
  const r = req;
78
104
  const list = r.payload?.config?.localization?.locales;
79
- if (!Array.isArray(list) || list.length === 0)
105
+ if (!Array.isArray(list) || list.length === 0) {
106
+ console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
80
107
  return [];
108
+ }
81
109
  const out = [];
82
110
  for (const entry of list) {
83
111
  if (typeof entry === "string" && entry.length > 0) {
@@ -88,6 +116,7 @@ function allLocales(req) {
88
116
  out.push(code);
89
117
  }
90
118
  }
119
+ console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
91
120
  return out;
92
121
  }
93
122
 
@@ -97,21 +126,28 @@ function nextCacheImport() {
97
126
  return cachePromise ??= import("next/cache");
98
127
  }
99
128
  function shouldSkipRevalidate(context) {
100
- return Boolean(context?.disableRevalidate);
129
+ const skip = Boolean(context?.disableRevalidate);
130
+ if (skip)
131
+ console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
132
+ return skip;
101
133
  }
102
134
  async function safeRevalidatePath(payload, path) {
135
+ console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
103
136
  try {
104
137
  const { revalidatePath } = await nextCacheImport();
105
138
  revalidatePath(path);
106
139
  } catch (error) {
140
+ console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
107
141
  payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
108
142
  }
109
143
  }
110
144
  async function safeRevalidateTag(payload, tag, profile = "max") {
145
+ console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
111
146
  try {
112
147
  const { revalidateTag } = await nextCacheImport();
113
148
  revalidateTag(tag, profile);
114
149
  } catch (error) {
150
+ console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
115
151
  payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
116
152
  }
117
153
  }
@@ -127,6 +163,7 @@ function createRevalidateCollectionHook(options) {
127
163
  pathMode = "url"
128
164
  } = options;
129
165
  const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
166
+ console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
130
167
  const resolveDefaults = (req) => {
131
168
  const mode = modeOption ?? "always";
132
169
  const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
@@ -155,6 +192,7 @@ function createRevalidateCollectionHook(options) {
155
192
  }
156
193
  };
157
194
  const fireCollectionTags = async (payload, docId, req) => {
195
+ console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
158
196
  if (typeof docId === "string" || typeof docId === "number") {
159
197
  await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
160
198
  }
@@ -168,6 +206,7 @@ function createRevalidateCollectionHook(options) {
168
206
  const { payload } = req;
169
207
  const typed = doc;
170
208
  const prev = previousDoc;
209
+ console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
171
210
  const isPublished = typed._status === "published";
172
211
  const wasPublished = prev?._status === "published";
173
212
  const prevSlugIsString = typeof prev?.slug === "string";
@@ -191,6 +230,7 @@ function createRevalidateCollectionHook(options) {
191
230
  return doc ?? null;
192
231
  const { payload } = req;
193
232
  const typed = doc;
233
+ console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
194
234
  if (pathMode !== "tag-only") {
195
235
  await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
196
236
  }
@@ -199,11 +239,14 @@ function createRevalidateCollectionHook(options) {
199
239
  };
200
240
  return { afterChange, afterDelete };
201
241
  }
202
- var createRevalidatePageHooks = (opts = {}) => createRevalidateCollectionHook({
203
- collectionSlug: "pages",
204
- urlPathPrefix: "",
205
- ...opts
206
- });
242
+ var createRevalidatePageHooks = (opts = {}) => {
243
+ console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
244
+ return createRevalidateCollectionHook({
245
+ collectionSlug: "pages",
246
+ urlPathPrefix: "",
247
+ ...opts
248
+ });
249
+ };
207
250
 
208
251
  // src/config/constants.ts
209
252
  var PAGES_RENDER_PATH = "@justanarthur/payload-www/render-pages#PagesPage";
@@ -428,6 +471,13 @@ var link = (options = {}) => {
428
471
  overrides = {},
429
472
  extraFields = []
430
473
  } = options;
474
+ console.log("[WWW] core/fields:link options=", JSON.stringify({
475
+ appearances: appearances === false ? false : appearances ?? "default-set",
476
+ disableLabel,
477
+ relationTo,
478
+ localized,
479
+ extraFieldsCount: extraFields.length
480
+ }));
431
481
  const result = {
432
482
  name: "link",
433
483
  type: "group",
@@ -506,15 +556,18 @@ var link = (options = {}) => {
506
556
  if (extraFields.length) {
507
557
  result.fields.push(...extraFields);
508
558
  }
559
+ console.log("[WWW] core/fields:link built fieldsCount=", result.fields.length);
509
560
  return { ...result, ...overrides };
510
561
  };
511
562
 
512
563
  // src/render/hooks/revalidateGlobal.ts
513
564
  function createRevalidateGlobalHook(slug) {
565
+ console.log("[WWW] render/hooks:createRevalidateGlobalHook slug=", slug);
514
566
  return async ({ doc, req: { payload, context, locale } }) => {
515
567
  if (shouldSkipRevalidate(context))
516
568
  return doc;
517
569
  const tags = [`global_${slug}`, `global_${slug}_${locale}`];
570
+ console.log("[WWW] render/hooks:revalidateGlobal slug=", slug, "locale=", locale, "tags=", JSON.stringify(tags));
518
571
  payload.logger.info?.(`Revalidating global: ${tags.join(", ")}`);
519
572
  for (const tag of tags) {
520
573
  await safeRevalidateTag(payload, tag);
package/dist/data-test.js CHANGED
@@ -22,11 +22,21 @@ import path from "node:path";
22
22
  import { fileURLToPath } from "node:url";
23
23
 
24
24
  // src/core/access/index.ts
25
- var anyone = () => true;
26
- var authenticated = ({ req: { user } }) => Boolean(user);
25
+ var anyone = () => {
26
+ console.log("[WWW] core/access:anyone -> true");
27
+ return true;
28
+ };
29
+ var authenticated = ({ req: { user } }) => {
30
+ const result = Boolean(user);
31
+ console.log("[WWW] core/access:authenticated ->", result);
32
+ return result;
33
+ };
27
34
  var authenticatedOrPublished = ({ req: { user } }) => {
28
- if (user)
35
+ if (user) {
36
+ console.log("[WWW] core/access:authenticatedOrPublished -> true (authenticated)");
29
37
  return true;
38
+ }
39
+ console.log('[WWW] core/access:authenticatedOrPublished -> { _status: { equals: "published" } }');
30
40
  return { _status: { equals: "published" } };
31
41
  };
32
42
 
@@ -37,6 +47,7 @@ var slugField = (options = {}) => {
37
47
  const { name = "slug", nested = false, localized = true } = options;
38
48
  const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
39
49
  const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
50
+ console.log("[WWW] core/fields:slugField options=", JSON.stringify({ name, nested, localized }));
40
51
  return {
41
52
  name,
42
53
  type: "text",
@@ -51,8 +62,10 @@ var slugField = (options = {}) => {
51
62
  validate: (value) => {
52
63
  if (typeof value !== "string")
53
64
  return "Slug must be a string";
54
- if (value !== "" && !pattern.test(value))
65
+ if (value !== "" && !pattern.test(value)) {
66
+ console.warn("[WWW] core/fields:slugField invalid slug value=", JSON.stringify(value));
55
67
  return invalidMessage;
68
+ }
56
69
  return true;
57
70
  }
58
71
  };
@@ -60,30 +73,45 @@ var slugField = (options = {}) => {
60
73
 
61
74
  // src/render/_locale.ts
62
75
  function prefixFor(locale, defaultLocale, mode) {
76
+ let result;
63
77
  if (mode === "never")
64
- return "";
65
- if (mode === "as-needed" && locale === defaultLocale)
66
- return "";
67
- return `/${locale}`;
78
+ result = "";
79
+ else if (mode === "as-needed" && locale === defaultLocale)
80
+ result = "";
81
+ else
82
+ result = `/${locale}`;
83
+ console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
84
+ return result;
68
85
  }
69
86
  function resolveLocale(req) {
70
- if (!req || typeof req !== "object")
87
+ if (!req || typeof req !== "object") {
88
+ console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
71
89
  return "";
90
+ }
72
91
  const r = req;
73
- if (typeof r.locale === "string" && r.locale.length > 0)
92
+ if (typeof r.locale === "string" && r.locale.length > 0) {
93
+ console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
74
94
  return r.locale;
95
+ }
75
96
  const fallback = r.payload?.config?.localization?.defaultLocale;
76
- if (typeof fallback === "string" && fallback.length > 0)
97
+ if (typeof fallback === "string" && fallback.length > 0) {
98
+ console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
77
99
  return fallback;
100
+ }
101
+ console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
78
102
  return "";
79
103
  }
80
104
  function allLocales(req) {
81
- if (!req || typeof req !== "object")
105
+ if (!req || typeof req !== "object") {
106
+ console.log("[WWW] render/_locale:allLocales -> [] (no req)");
82
107
  return [];
108
+ }
83
109
  const r = req;
84
110
  const list = r.payload?.config?.localization?.locales;
85
- if (!Array.isArray(list) || list.length === 0)
111
+ if (!Array.isArray(list) || list.length === 0) {
112
+ console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
86
113
  return [];
114
+ }
87
115
  const out = [];
88
116
  for (const entry of list) {
89
117
  if (typeof entry === "string" && entry.length > 0) {
@@ -94,6 +122,7 @@ function allLocales(req) {
94
122
  out.push(code);
95
123
  }
96
124
  }
125
+ console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
97
126
  return out;
98
127
  }
99
128
 
@@ -103,21 +132,28 @@ function nextCacheImport() {
103
132
  return cachePromise ??= import("next/cache");
104
133
  }
105
134
  function shouldSkipRevalidate(context) {
106
- return Boolean(context?.disableRevalidate);
135
+ const skip = Boolean(context?.disableRevalidate);
136
+ if (skip)
137
+ console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
138
+ return skip;
107
139
  }
108
140
  async function safeRevalidatePath(payload, path) {
141
+ console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
109
142
  try {
110
143
  const { revalidatePath } = await nextCacheImport();
111
144
  revalidatePath(path);
112
145
  } catch (error) {
146
+ console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
113
147
  payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
114
148
  }
115
149
  }
116
150
  async function safeRevalidateTag(payload, tag, profile = "max") {
151
+ console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
117
152
  try {
118
153
  const { revalidateTag } = await nextCacheImport();
119
154
  revalidateTag(tag, profile);
120
155
  } catch (error) {
156
+ console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
121
157
  payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
122
158
  }
123
159
  }
@@ -133,6 +169,7 @@ function createRevalidateCollectionHook(options) {
133
169
  pathMode = "url"
134
170
  } = options;
135
171
  const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
172
+ console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
136
173
  const resolveDefaults = (req) => {
137
174
  const mode = modeOption ?? "always";
138
175
  const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
@@ -161,6 +198,7 @@ function createRevalidateCollectionHook(options) {
161
198
  }
162
199
  };
163
200
  const fireCollectionTags = async (payload, docId, req) => {
201
+ console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
164
202
  if (typeof docId === "string" || typeof docId === "number") {
165
203
  await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
166
204
  }
@@ -174,6 +212,7 @@ function createRevalidateCollectionHook(options) {
174
212
  const { payload } = req;
175
213
  const typed = doc;
176
214
  const prev = previousDoc;
215
+ console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
177
216
  const isPublished = typed._status === "published";
178
217
  const wasPublished = prev?._status === "published";
179
218
  const prevSlugIsString = typeof prev?.slug === "string";
@@ -197,6 +236,7 @@ function createRevalidateCollectionHook(options) {
197
236
  return doc ?? null;
198
237
  const { payload } = req;
199
238
  const typed = doc;
239
+ console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
200
240
  if (pathMode !== "tag-only") {
201
241
  await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
202
242
  }
@@ -205,11 +245,14 @@ function createRevalidateCollectionHook(options) {
205
245
  };
206
246
  return { afterChange, afterDelete };
207
247
  }
208
- var createRevalidatePageHooks = (opts = {}) => createRevalidateCollectionHook({
209
- collectionSlug: "pages",
210
- urlPathPrefix: "",
211
- ...opts
212
- });
248
+ var createRevalidatePageHooks = (opts = {}) => {
249
+ console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
250
+ return createRevalidateCollectionHook({
251
+ collectionSlug: "pages",
252
+ urlPathPrefix: "",
253
+ ...opts
254
+ });
255
+ };
213
256
 
214
257
  // src/config/constants.ts
215
258
  var PAGES_RENDER_PATH = "@justanarthur/payload-www/render-pages#PagesPage";
@@ -434,6 +477,13 @@ var link = (options = {}) => {
434
477
  overrides = {},
435
478
  extraFields = []
436
479
  } = options;
480
+ console.log("[WWW] core/fields:link options=", JSON.stringify({
481
+ appearances: appearances === false ? false : appearances ?? "default-set",
482
+ disableLabel,
483
+ relationTo,
484
+ localized,
485
+ extraFieldsCount: extraFields.length
486
+ }));
437
487
  const result = {
438
488
  name: "link",
439
489
  type: "group",
@@ -512,15 +562,18 @@ var link = (options = {}) => {
512
562
  if (extraFields.length) {
513
563
  result.fields.push(...extraFields);
514
564
  }
565
+ console.log("[WWW] core/fields:link built fieldsCount=", result.fields.length);
515
566
  return { ...result, ...overrides };
516
567
  };
517
568
 
518
569
  // src/render/hooks/revalidateGlobal.ts
519
570
  function createRevalidateGlobalHook(slug) {
571
+ console.log("[WWW] render/hooks:createRevalidateGlobalHook slug=", slug);
520
572
  return async ({ doc, req: { payload, context, locale } }) => {
521
573
  if (shouldSkipRevalidate(context))
522
574
  return doc;
523
575
  const tags = [`global_${slug}`, `global_${slug}_${locale}`];
576
+ console.log("[WWW] render/hooks:revalidateGlobal slug=", slug, "locale=", locale, "tags=", JSON.stringify(tags));
524
577
  payload.logger.info?.(`Revalidating global: ${tags.join(", ")}`);
525
578
  for (const tag of tags) {
526
579
  await safeRevalidateTag(payload, tag);
@@ -615,11 +668,14 @@ function createPreviewHandler(options) {
615
668
  const url = new URL(req.url);
616
669
  const path = url.searchParams.get("path") ?? "/";
617
670
  const previewSecret = url.searchParams.get("previewSecret");
671
+ console.log("[WWW] render/preview:createPreviewHandler:GET path=", path, "hasSecret=", Boolean(previewSecret), "enableDraftMode=", enableDraftMode);
618
672
  if (!previewSecret || previewSecret !== secret) {
673
+ console.warn("[WWW] render/preview:createPreviewHandler:GET invalid preview secret (401)");
619
674
  return new Response("Invalid preview secret", { status: 401 });
620
675
  }
621
676
  if (enableDraftMode) {
622
677
  (await draftMode()).enable();
678
+ console.log("[WWW] render/preview:createPreviewHandler:GET draftMode enabled");
623
679
  }
624
680
  redirect(path);
625
681
  return new Response(null, { status: 204 });
@@ -639,6 +695,7 @@ async function buildHreflangAlternates({
639
695
  localePrefix = "always"
640
696
  }) {
641
697
  const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
698
+ console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
642
699
  const languages = {};
643
700
  const urlFor = (l, slug) => {
644
701
  const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
@@ -656,6 +713,7 @@ async function buildHreflangAlternates({
656
713
  if (allLocaleSlugs?.[defaultLocale]) {
657
714
  languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
658
715
  }
716
+ console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
659
717
  return languages;
660
718
  }
661
719
 
@@ -665,7 +723,10 @@ import { cache } from "react";
665
723
 
666
724
  // src/core/utils/getFromImportMap.ts
667
725
  function getFromImportMap(key, importMap) {
668
- return importMap[key.includes("#") ? key : key + "#default"];
726
+ const resolvedKey = key.includes("#") ? key : key + "#default";
727
+ const value = importMap[resolvedKey];
728
+ console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
729
+ return value;
669
730
  }
670
731
 
671
732
  // src/render/metadata/query.ts
@@ -677,6 +738,7 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
677
738
  draft = false,
678
739
  config
679
740
  }) {
741
+ console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField2, "locale=", locale, "draft=", draft);
680
742
  const payload = await getPayload({ config });
681
743
  const result = await payload.find({
682
744
  collection: collectionSlug,
@@ -687,7 +749,9 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
687
749
  where: { [slugField2]: { equals: slug } },
688
750
  locale
689
751
  });
690
- return result.docs?.[0] ?? null;
752
+ const doc = result.docs?.[0] ?? null;
753
+ console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
754
+ return doc;
691
755
  });
692
756
  var queryAllDocs = cache(async function queryAllDocs2({
693
757
  collectionSlug,
@@ -695,6 +759,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
695
759
  locale,
696
760
  config
697
761
  }) {
762
+ console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
698
763
  const payload = await getPayload({ config });
699
764
  const result = await payload.find({
700
765
  collection: collectionSlug,
@@ -705,7 +770,9 @@ var queryAllDocs = cache(async function queryAllDocs2({
705
770
  select: { [slugField2]: true },
706
771
  locale
707
772
  });
708
- return result.docs ?? [];
773
+ const docs = result.docs ?? [];
774
+ console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
775
+ return docs;
709
776
  });
710
777
  var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
711
778
  collectionSlug,
@@ -714,6 +781,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
714
781
  locale,
715
782
  config
716
783
  }) {
784
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
717
785
  const payload = await getPayload({ config });
718
786
  const result = await payload.find({
719
787
  collection: collectionSlug,
@@ -726,8 +794,10 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
726
794
  select: { [slugField2]: true }
727
795
  });
728
796
  const doc = result.docs?.[0];
729
- if (!doc)
797
+ if (!doc) {
798
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
730
799
  return;
800
+ }
731
801
  let fieldValue = doc[slugField2];
732
802
  if (doc.id != null) {
733
803
  const allLocales2 = await payload.findByID({
@@ -742,6 +812,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
742
812
  fieldValue = allLocales2[slugField2];
743
813
  }
744
814
  if (fieldValue && typeof fieldValue === "object") {
815
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
745
816
  return fieldValue;
746
817
  }
747
818
  const resolved = await config;
@@ -749,6 +820,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
749
820
  const out = {};
750
821
  for (const l of rawLocales)
751
822
  out[l] = String(fieldValue ?? slug);
823
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
752
824
  return out;
753
825
  });
754
826
  var queryGlobal = cache(async function queryGlobal2({
@@ -758,6 +830,7 @@ var queryGlobal = cache(async function queryGlobal2({
758
830
  draft = false,
759
831
  config
760
832
  }) {
833
+ console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
761
834
  const payload = await getPayload({ config });
762
835
  try {
763
836
  const global = await payload.findGlobal({
@@ -766,27 +839,35 @@ var queryGlobal = cache(async function queryGlobal2({
766
839
  draft,
767
840
  locale
768
841
  });
842
+ console.log("[WWW] render/metadata:queryGlobal -> hit");
769
843
  return global;
770
- } catch {
844
+ } catch (error) {
845
+ console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
771
846
  return null;
772
847
  }
773
848
  });
774
849
  function getRenderModuleExports(exportName, collection, importMap) {
775
850
  const path = collection?.custom?.path;
776
- if (!path)
851
+ if (!path) {
852
+ console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
777
853
  return;
854
+ }
778
855
  const mod = getFromImportMap(path, importMap);
779
- return mod?.[exportName];
856
+ const value = mod?.[exportName];
857
+ console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
858
+ return value;
780
859
  }
781
860
 
782
861
  // src/render/sitemap/createSitemapFile.ts
783
862
  function createSitemapFile(options) {
784
863
  const { collections } = options;
785
864
  return async function sitemap() {
865
+ console.log("[WWW] render/sitemap:createSitemapFile:sitemap collections=", JSON.stringify(options.collections), "localePrefix=", options.localePrefix ?? "always");
786
866
  const cfg = await options.config;
787
867
  const allLocales2 = Array.isArray(cfg.localization?.locales) ? cfg.localization.locales.map((l) => typeof l === "string" ? l : l.code) : [cfg.localization?.defaultLocale ?? "en"];
788
868
  const defaultLocale = cfg.localization?.defaultLocale ?? allLocales2[0];
789
869
  const activeLocales = Array.isArray(options.locales) && options.locales.length > 0 ? options.locales.filter((l) => allLocales2.includes(l)) : allLocales2;
870
+ console.log("[WWW] render/sitemap:createSitemapFile:sitemap allLocales=", JSON.stringify(allLocales2), "default=", defaultLocale, "active=", JSON.stringify(activeLocales));
790
871
  const entries = [];
791
872
  const seen = new Set;
792
873
  for (const collectionSlug of collections) {
@@ -842,6 +923,7 @@ function createSitemapFile(options) {
842
923
  }
843
924
  }
844
925
  }
926
+ console.log("[WWW] render/sitemap:createSitemapFile:sitemap -> entries=", entries.length);
845
927
  return entries;
846
928
  };
847
929
  }
package/dist/fields.js CHANGED
@@ -39,6 +39,13 @@ var link = (options = {}) => {
39
39
  overrides = {},
40
40
  extraFields = []
41
41
  } = options;
42
+ console.log("[WWW] core/fields:link options=", JSON.stringify({
43
+ appearances: appearances === false ? false : appearances ?? "default-set",
44
+ disableLabel,
45
+ relationTo,
46
+ localized,
47
+ extraFieldsCount: extraFields.length
48
+ }));
42
49
  const result = {
43
50
  name: "link",
44
51
  type: "group",
@@ -117,16 +124,20 @@ var link = (options = {}) => {
117
124
  if (extraFields.length) {
118
125
  result.fields.push(...extraFields);
119
126
  }
127
+ console.log("[WWW] core/fields:link built fieldsCount=", result.fields.length);
120
128
  return { ...result, ...overrides };
121
129
  };
122
130
 
123
131
  // src/core/fields/linkGroup.ts
124
- var linkGroup = (options = {}) => ({
125
- name: "links",
126
- type: "array",
127
- fields: [link(options)],
128
- admin: { initCollapsed: true }
129
- });
132
+ var linkGroup = (options = {}) => {
133
+ console.log("[WWW] core/fields:linkGroup relationTo=", JSON.stringify(options.relationTo ?? "link-default"), "extraFields=", options.extraFields?.length ?? 0);
134
+ return {
135
+ name: "links",
136
+ type: "array",
137
+ fields: [link(options)],
138
+ admin: { initCollapsed: true }
139
+ };
140
+ };
130
141
 
131
142
  // src/core/fields/slug.ts
132
143
  var FLAT_PATTERN = /^[a-z0-9-]+$/;
@@ -135,6 +146,7 @@ var slugField = (options = {}) => {
135
146
  const { name = "slug", nested = false, localized = true } = options;
136
147
  const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
137
148
  const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
149
+ console.log("[WWW] core/fields:slugField options=", JSON.stringify({ name, nested, localized }));
138
150
  return {
139
151
  name,
140
152
  type: "text",
@@ -149,8 +161,10 @@ var slugField = (options = {}) => {
149
161
  validate: (value) => {
150
162
  if (typeof value !== "string")
151
163
  return "Slug must be a string";
152
- if (value !== "" && !pattern.test(value))
164
+ if (value !== "" && !pattern.test(value)) {
165
+ console.warn("[WWW] core/fields:slugField invalid slug value=", JSON.stringify(value));
153
166
  return invalidMessage;
167
+ }
154
168
  return true;
155
169
  }
156
170
  };