@justanarthur/payload-www 0.3.3 → 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.
- package/dist/access.js +13 -3
- package/dist/blocks.js +21 -7
- package/dist/collections.js +72 -19
- package/dist/components.js +1 -0
- package/dist/config.js +108 -26
- package/dist/core-access.js +13 -3
- package/dist/core-blocks.js +21 -7
- package/dist/core-fields.js +21 -7
- package/dist/core-utils.js +20 -6
- package/dist/data-collections.js +72 -19
- package/dist/data-test.js +108 -26
- package/dist/fields.js +21 -7
- package/dist/globals.js +18 -1
- package/dist/hooks.js +47 -15
- package/dist/index.js +1 -0
- package/dist/metadata.js +68 -22
- package/dist/pages.js +133 -41
- package/dist/render-components.js +13 -3
- package/dist/render-metadata.js +68 -22
- package/dist/render-pages.js +206 -61
- package/dist/render-utils.js +62 -16
- package/dist/server.js +228 -71
- package/dist/test.js +108 -26
- package/dist/utils.js +20 -6
- package/dist/with-www-config.js +108 -26
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -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 = () =>
|
|
20
|
-
|
|
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
|
-
|
|
59
|
-
if (mode === "as-needed" && locale === defaultLocale)
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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 = {}) =>
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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);
|
|
@@ -609,11 +662,14 @@ function createPreviewHandler(options) {
|
|
|
609
662
|
const url = new URL(req.url);
|
|
610
663
|
const path = url.searchParams.get("path") ?? "/";
|
|
611
664
|
const previewSecret = url.searchParams.get("previewSecret");
|
|
665
|
+
console.log("[WWW] render/preview:createPreviewHandler:GET path=", path, "hasSecret=", Boolean(previewSecret), "enableDraftMode=", enableDraftMode);
|
|
612
666
|
if (!previewSecret || previewSecret !== secret) {
|
|
667
|
+
console.warn("[WWW] render/preview:createPreviewHandler:GET invalid preview secret (401)");
|
|
613
668
|
return new Response("Invalid preview secret", { status: 401 });
|
|
614
669
|
}
|
|
615
670
|
if (enableDraftMode) {
|
|
616
671
|
(await draftMode()).enable();
|
|
672
|
+
console.log("[WWW] render/preview:createPreviewHandler:GET draftMode enabled");
|
|
617
673
|
}
|
|
618
674
|
redirect(path);
|
|
619
675
|
return new Response(null, { status: 204 });
|
|
@@ -633,6 +689,7 @@ async function buildHreflangAlternates({
|
|
|
633
689
|
localePrefix = "always"
|
|
634
690
|
}) {
|
|
635
691
|
const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
|
|
692
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
|
|
636
693
|
const languages = {};
|
|
637
694
|
const urlFor = (l, slug) => {
|
|
638
695
|
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
@@ -650,6 +707,7 @@ async function buildHreflangAlternates({
|
|
|
650
707
|
if (allLocaleSlugs?.[defaultLocale]) {
|
|
651
708
|
languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
|
|
652
709
|
}
|
|
710
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
|
|
653
711
|
return languages;
|
|
654
712
|
}
|
|
655
713
|
|
|
@@ -659,7 +717,10 @@ import { cache } from "react";
|
|
|
659
717
|
|
|
660
718
|
// src/core/utils/getFromImportMap.ts
|
|
661
719
|
function getFromImportMap(key, importMap) {
|
|
662
|
-
|
|
720
|
+
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
721
|
+
const value = importMap[resolvedKey];
|
|
722
|
+
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
723
|
+
return value;
|
|
663
724
|
}
|
|
664
725
|
|
|
665
726
|
// src/render/metadata/query.ts
|
|
@@ -671,6 +732,7 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
671
732
|
draft = false,
|
|
672
733
|
config
|
|
673
734
|
}) {
|
|
735
|
+
console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField2, "locale=", locale, "draft=", draft);
|
|
674
736
|
const payload = await getPayload({ config });
|
|
675
737
|
const result = await payload.find({
|
|
676
738
|
collection: collectionSlug,
|
|
@@ -681,7 +743,9 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
681
743
|
where: { [slugField2]: { equals: slug } },
|
|
682
744
|
locale
|
|
683
745
|
});
|
|
684
|
-
|
|
746
|
+
const doc = result.docs?.[0] ?? null;
|
|
747
|
+
console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
|
|
748
|
+
return doc;
|
|
685
749
|
});
|
|
686
750
|
var queryAllDocs = cache(async function queryAllDocs2({
|
|
687
751
|
collectionSlug,
|
|
@@ -689,6 +753,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
689
753
|
locale,
|
|
690
754
|
config
|
|
691
755
|
}) {
|
|
756
|
+
console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
|
|
692
757
|
const payload = await getPayload({ config });
|
|
693
758
|
const result = await payload.find({
|
|
694
759
|
collection: collectionSlug,
|
|
@@ -699,7 +764,9 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
699
764
|
select: { [slugField2]: true },
|
|
700
765
|
locale
|
|
701
766
|
});
|
|
702
|
-
|
|
767
|
+
const docs = result.docs ?? [];
|
|
768
|
+
console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
|
|
769
|
+
return docs;
|
|
703
770
|
});
|
|
704
771
|
var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
705
772
|
collectionSlug,
|
|
@@ -708,6 +775,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
708
775
|
locale,
|
|
709
776
|
config
|
|
710
777
|
}) {
|
|
778
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
|
|
711
779
|
const payload = await getPayload({ config });
|
|
712
780
|
const result = await payload.find({
|
|
713
781
|
collection: collectionSlug,
|
|
@@ -720,8 +788,10 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
720
788
|
select: { [slugField2]: true }
|
|
721
789
|
});
|
|
722
790
|
const doc = result.docs?.[0];
|
|
723
|
-
if (!doc)
|
|
791
|
+
if (!doc) {
|
|
792
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
|
|
724
793
|
return;
|
|
794
|
+
}
|
|
725
795
|
let fieldValue = doc[slugField2];
|
|
726
796
|
if (doc.id != null) {
|
|
727
797
|
const allLocales2 = await payload.findByID({
|
|
@@ -736,6 +806,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
736
806
|
fieldValue = allLocales2[slugField2];
|
|
737
807
|
}
|
|
738
808
|
if (fieldValue && typeof fieldValue === "object") {
|
|
809
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
|
|
739
810
|
return fieldValue;
|
|
740
811
|
}
|
|
741
812
|
const resolved = await config;
|
|
@@ -743,6 +814,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
743
814
|
const out = {};
|
|
744
815
|
for (const l of rawLocales)
|
|
745
816
|
out[l] = String(fieldValue ?? slug);
|
|
817
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
|
|
746
818
|
return out;
|
|
747
819
|
});
|
|
748
820
|
var queryGlobal = cache(async function queryGlobal2({
|
|
@@ -752,6 +824,7 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
752
824
|
draft = false,
|
|
753
825
|
config
|
|
754
826
|
}) {
|
|
827
|
+
console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
|
|
755
828
|
const payload = await getPayload({ config });
|
|
756
829
|
try {
|
|
757
830
|
const global = await payload.findGlobal({
|
|
@@ -760,27 +833,35 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
760
833
|
draft,
|
|
761
834
|
locale
|
|
762
835
|
});
|
|
836
|
+
console.log("[WWW] render/metadata:queryGlobal -> hit");
|
|
763
837
|
return global;
|
|
764
|
-
} catch {
|
|
838
|
+
} catch (error) {
|
|
839
|
+
console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
|
|
765
840
|
return null;
|
|
766
841
|
}
|
|
767
842
|
});
|
|
768
843
|
function getRenderModuleExports(exportName, collection, importMap) {
|
|
769
844
|
const path = collection?.custom?.path;
|
|
770
|
-
if (!path)
|
|
845
|
+
if (!path) {
|
|
846
|
+
console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
|
|
771
847
|
return;
|
|
848
|
+
}
|
|
772
849
|
const mod = getFromImportMap(path, importMap);
|
|
773
|
-
|
|
850
|
+
const value = mod?.[exportName];
|
|
851
|
+
console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
|
|
852
|
+
return value;
|
|
774
853
|
}
|
|
775
854
|
|
|
776
855
|
// src/render/sitemap/createSitemapFile.ts
|
|
777
856
|
function createSitemapFile(options) {
|
|
778
857
|
const { collections } = options;
|
|
779
858
|
return async function sitemap() {
|
|
859
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap collections=", JSON.stringify(options.collections), "localePrefix=", options.localePrefix ?? "always");
|
|
780
860
|
const cfg = await options.config;
|
|
781
861
|
const allLocales2 = Array.isArray(cfg.localization?.locales) ? cfg.localization.locales.map((l) => typeof l === "string" ? l : l.code) : [cfg.localization?.defaultLocale ?? "en"];
|
|
782
862
|
const defaultLocale = cfg.localization?.defaultLocale ?? allLocales2[0];
|
|
783
863
|
const activeLocales = Array.isArray(options.locales) && options.locales.length > 0 ? options.locales.filter((l) => allLocales2.includes(l)) : allLocales2;
|
|
864
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap allLocales=", JSON.stringify(allLocales2), "default=", defaultLocale, "active=", JSON.stringify(activeLocales));
|
|
784
865
|
const entries = [];
|
|
785
866
|
const seen = new Set;
|
|
786
867
|
for (const collectionSlug of collections) {
|
|
@@ -836,6 +917,7 @@ function createSitemapFile(options) {
|
|
|
836
917
|
}
|
|
837
918
|
}
|
|
838
919
|
}
|
|
920
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap -> entries=", entries.length);
|
|
839
921
|
return entries;
|
|
840
922
|
};
|
|
841
923
|
}
|
package/dist/core-access.js
CHANGED
|
@@ -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 = () =>
|
|
20
|
-
|
|
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
|
|
package/dist/core-blocks.js
CHANGED
|
@@ -17,17 +17,27 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
17
17
|
|
|
18
18
|
// src/core/utils/getFromImportMap.ts
|
|
19
19
|
function getFromImportMap(key, importMap) {
|
|
20
|
-
|
|
20
|
+
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
21
|
+
const value = importMap[resolvedKey];
|
|
22
|
+
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
23
|
+
return value;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
// src/core/utils/generateImportName.ts
|
|
24
27
|
function generateImportName(type, slug) {
|
|
25
28
|
switch (type) {
|
|
26
|
-
case "block":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
29
|
+
case "block": {
|
|
30
|
+
const name = `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
31
|
+
console.log("[WWW] core/utils:generateImportName type=block slug=", slug, "->", name);
|
|
32
|
+
return name;
|
|
33
|
+
}
|
|
34
|
+
case "page": {
|
|
35
|
+
const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
36
|
+
console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
|
|
37
|
+
return name;
|
|
38
|
+
}
|
|
30
39
|
default:
|
|
40
|
+
console.error("[WWW] core/utils:generateImportName unknown type:", type);
|
|
31
41
|
throw new Error(`Unknown type: ${type}`);
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -42,8 +52,11 @@ var RenderBlocks = ({
|
|
|
42
52
|
locale,
|
|
43
53
|
searchParams
|
|
44
54
|
}) => {
|
|
45
|
-
if (!blocks || !Array.isArray(blocks) || blocks.length === 0)
|
|
55
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
|
|
56
|
+
console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
|
|
46
57
|
return null;
|
|
58
|
+
}
|
|
59
|
+
console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
|
|
47
60
|
const rendered = [];
|
|
48
61
|
for (let i = 0;i < blocks.length; i++) {
|
|
49
62
|
const block = blocks[i];
|
|
@@ -51,9 +64,10 @@ var RenderBlocks = ({
|
|
|
51
64
|
const importMapPath = config.admin?.dependencies?.[blockType]?.path ?? generateImportName("block", blockType);
|
|
52
65
|
const Block = getFromImportMap(importMapPath, importMap);
|
|
53
66
|
if (!Block) {
|
|
54
|
-
console.warn(`
|
|
67
|
+
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
55
68
|
continue;
|
|
56
69
|
}
|
|
70
|
+
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
57
71
|
rendered.push(/* @__PURE__ */ jsx(Block, {
|
|
58
72
|
index: i,
|
|
59
73
|
...blockProps,
|
package/dist/core-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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
};
|
package/dist/core-utils.js
CHANGED
|
@@ -17,17 +17,27 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
17
17
|
|
|
18
18
|
// src/core/utils/getFromImportMap.ts
|
|
19
19
|
function getFromImportMap(key, importMap) {
|
|
20
|
-
|
|
20
|
+
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
21
|
+
const value = importMap[resolvedKey];
|
|
22
|
+
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
23
|
+
return value;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
// src/core/utils/generateImportName.ts
|
|
24
27
|
function generateImportName(type, slug) {
|
|
25
28
|
switch (type) {
|
|
26
|
-
case "block":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
29
|
+
case "block": {
|
|
30
|
+
const name = `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
31
|
+
console.log("[WWW] core/utils:generateImportName type=block slug=", slug, "->", name);
|
|
32
|
+
return name;
|
|
33
|
+
}
|
|
34
|
+
case "page": {
|
|
35
|
+
const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
36
|
+
console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
|
|
37
|
+
return name;
|
|
38
|
+
}
|
|
30
39
|
default:
|
|
40
|
+
console.error("[WWW] core/utils:generateImportName unknown type:", type);
|
|
31
41
|
throw new Error(`Unknown type: ${type}`);
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -36,13 +46,17 @@ function generateImportName(type, slug) {
|
|
|
36
46
|
import { jsx } from "react/jsx-runtime";
|
|
37
47
|
function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
38
48
|
const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
|
|
39
|
-
if (!renderPath)
|
|
49
|
+
if (!renderPath) {
|
|
50
|
+
console.log("[WWW] render/utils:renderCollectionModule no custom.path slug=", slug);
|
|
40
51
|
return null;
|
|
52
|
+
}
|
|
41
53
|
const CollectionRenderModule = getFromImportMap(renderPath, importMap);
|
|
42
54
|
if (!CollectionRenderModule) {
|
|
55
|
+
console.error("[WWW] render/utils:renderCollectionModule not found slug=", slug, "path=", renderPath);
|
|
43
56
|
if (false) {}
|
|
44
57
|
return null;
|
|
45
58
|
}
|
|
59
|
+
console.log("[WWW] render/utils:renderCollectionModule rendering slug=", slug, "path=", renderPath);
|
|
46
60
|
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
47
61
|
importMap,
|
|
48
62
|
...props
|