@nocode-factory/sanity-kit 2.47.0 → 2.48.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.
Files changed (36) hide show
  1. package/README.md +2 -1
  2. package/dist/CodeEmbedInput-CobMRQ5s.d.ts +46 -0
  3. package/dist/aiJsonLd-DiYeDzou.js +170 -0
  4. package/dist/aiJsonLd-DiYeDzou.js.map +1 -0
  5. package/dist/code-embed.d.ts +2 -0
  6. package/dist/code-embed.js +2 -0
  7. package/dist/codeEmbedType-1bEOTxBT.js +160 -0
  8. package/dist/codeEmbedType-1bEOTxBT.js.map +1 -0
  9. package/dist/finalUrl-C1kzYMzQ.js +273 -0
  10. package/dist/finalUrl-C1kzYMzQ.js.map +1 -0
  11. package/dist/{fixCrossLanguageReferences-CQGzpNii.js → fixCrossLanguageReferences-BZk9CkdI.js} +3 -271
  12. package/dist/fixCrossLanguageReferences-BZk9CkdI.js.map +1 -0
  13. package/dist/{fixCrossLanguageReferences-CFZax-Nb.d.ts → fixCrossLanguageReferences-CjL_Xy0U.d.ts} +23 -1
  14. package/dist/index.d.ts +5 -47
  15. package/dist/index.js +70 -237
  16. package/dist/index.js.map +1 -1
  17. package/dist/jsonld.d.ts +79 -0
  18. package/dist/jsonld.js +225 -0
  19. package/dist/jsonld.js.map +1 -0
  20. package/dist/schema.d.ts +1 -1
  21. package/dist/schema.js +2 -1
  22. package/dist/schema.js.map +1 -1
  23. package/package.json +12 -2
  24. package/src/actions/JsonLdPublish.tsx +69 -0
  25. package/src/code-embed.ts +19 -0
  26. package/src/config/resolve.ts +6 -0
  27. package/src/config/types.ts +24 -0
  28. package/src/form/JsonLdInput.tsx +191 -0
  29. package/src/form/codeEmbedType.ts +0 -2
  30. package/src/form/jsonLdType.ts +61 -0
  31. package/src/index.ts +8 -2
  32. package/src/jsonld.ts +19 -0
  33. package/src/lib/aiJsonLd.ts +53 -0
  34. package/src/lib/jsonLdContent.ts +91 -0
  35. package/src/version.ts +1 -1
  36. package/dist/fixCrossLanguageReferences-CQGzpNii.js.map +0 -1
@@ -0,0 +1,273 @@
1
+ const DEFAULT_PAGE_BUILDER_FIELD = "sections", DEFAULT_SLUG_FIELD = "slug", DEFAULT_TITLE_FIELD = "title", DEFAULT_NOINDEX_FIELDS = ["seo.noindex", "noindex"], DEFAULT_I18N = {
2
+ field: "language",
3
+ locales: []
4
+ }, DEFAULT_COMPONENT_PREVIEW = {
5
+ provider: "designSystemPage",
6
+ path: "/design-system",
7
+ anchor: "{name}",
8
+ thumbnail: "/sections/{name}.png",
9
+ defaultsType: "componentDefaults",
10
+ live: "/design-system/composant?type={name}"
11
+ }, DEFAULT_TOOLS = {
12
+ pages: !0,
13
+ components: !0,
14
+ history: !0,
15
+ designSystem: !0
16
+ }, DEFAULT_TOOLBAR_MORE = [
17
+ "vision",
18
+ "releases",
19
+ "schedules"
20
+ ], DEFAULT_BOARD_TAGS = [
21
+ {
22
+ id: "en-cours",
23
+ label: "In progress",
24
+ color: "#f5a623"
25
+ },
26
+ {
27
+ id: "fait",
28
+ label: "Done",
29
+ color: "#43d675"
30
+ },
31
+ {
32
+ id: "a-relire",
33
+ label: "To review",
34
+ color: "#2276fc"
35
+ },
36
+ {
37
+ id: "a-refondre",
38
+ label: "To rework",
39
+ color: "#f03e3e"
40
+ }
41
+ ], DEFAULT_INTERNAL_FIELDS = [
42
+ {
43
+ id: "owner",
44
+ label: "Owner",
45
+ type: "text"
46
+ },
47
+ {
48
+ id: "audience",
49
+ label: "Audience",
50
+ type: "text"
51
+ },
52
+ {
53
+ id: "role",
54
+ label: "Page role",
55
+ type: "text"
56
+ }
57
+ ], trimTrailingSlash = (url) => url.replace(/\/+$/, ""), normalizePath = (path) => {
58
+ let trimmed = path.trim();
59
+ if (!trimmed || trimmed === "/") return "/";
60
+ let withSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
61
+ return withSlash.length > 1 ? trimTrailingSlash(withSlash) : withSlash;
62
+ };
63
+ function resolvePageType(entry, defaults) {
64
+ if (typeof entry == "string") return {
65
+ type: entry.trim(),
66
+ slugField: defaults.slugField,
67
+ path: null,
68
+ pathPrefix: null,
69
+ localizedPrefixes: null,
70
+ titleField: defaults.titleField
71
+ };
72
+ let path = typeof entry.path == "string" ? normalizePath(entry.path) : null, slugField = entry.slugField === null ? null : entry.slugField?.trim() || defaults.slugField, prefix = typeof entry.pathPrefix == "string" ? normalizePath(entry.pathPrefix) : "/";
73
+ return {
74
+ type: (entry.type ?? "").trim(),
75
+ slugField: path ? null : slugField,
76
+ path,
77
+ pathPrefix: prefix === "/" ? null : prefix,
78
+ localizedPrefixes: entry.localizedPrefixes ? Object.fromEntries(Object.entries(entry.localizedPrefixes).map(([l, p]) => [l, normalizePath(p) === "/" ? "" : normalizePath(p)])) : null,
79
+ titleField: entry.titleField?.trim() || defaults.titleField
80
+ };
81
+ }
82
+ /** Applique les valeurs par défaut. Ne valide rien : voir `validateConfig`. */
83
+ function resolveConfig(input) {
84
+ let slugField = input.slugField?.trim() || "slug", titleField = input.titleField?.trim() || "title", pageTypes = (Array.isArray(input.pageTypes) ? input.pageTypes : []).map((entry) => resolvePageType(entry, {
85
+ slugField,
86
+ titleField
87
+ })), i18n = input.i18n === !1 || input.i18n === void 0 ? null : (() => {
88
+ let locales = (input.i18n.locales ?? DEFAULT_I18N.locales).map((l) => l.trim()).filter(Boolean), defaultLocale = input.i18n.defaultLocale?.trim() || locales[0] || "";
89
+ return {
90
+ field: input.i18n.field?.trim() || DEFAULT_I18N.field,
91
+ defaultLocale,
92
+ locales,
93
+ defaultsSourceLocale: input.i18n.defaultsSourceLocale?.trim() || defaultLocale
94
+ };
95
+ })();
96
+ return {
97
+ pageTypes,
98
+ codedPages: (input.siteRoutes?.fixed ?? []).filter((f) => f.pageSlug && !f.homePage && !f.system && !f.notFound).map((f) => ({
99
+ pageSlug: f.pageSlug,
100
+ path: normalizePath(f.path),
101
+ localized: f.localized ?? null
102
+ })),
103
+ redirectType: input.redirectType?.trim() || "redirect",
104
+ pageTypeNames: pageTypes.map((p) => p.type).filter(Boolean),
105
+ pageBuilderField: input.pageBuilderField?.trim() || "sections",
106
+ blockNamespace: input.blockNamespace ?? "",
107
+ noindexFields: input.noindexField ? [input.noindexField].flat().map((field) => field.trim()).filter(Boolean) : DEFAULT_NOINDEX_FIELDS,
108
+ previewUrl: input.previewUrl ? trimTrailingSlash(input.previewUrl.trim()) : null,
109
+ environments: resolveEnvironments(input),
110
+ pageThumbnail: input.pageThumbnail?.trim() || null,
111
+ i18n,
112
+ componentPreview: {
113
+ provider: input.componentPreview?.provider ?? DEFAULT_COMPONENT_PREVIEW.provider,
114
+ path: input.componentPreview?.path ?? DEFAULT_COMPONENT_PREVIEW.path,
115
+ anchor: input.componentPreview?.anchor ?? DEFAULT_COMPONENT_PREVIEW.anchor,
116
+ thumbnail: input.componentPreview?.thumbnail ?? DEFAULT_COMPONENT_PREVIEW.thumbnail,
117
+ defaultsType: input.componentPreview?.defaultsType ?? DEFAULT_COMPONENT_PREVIEW.defaultsType,
118
+ live: input.componentPreview?.live ?? DEFAULT_COMPONENT_PREVIEW.live
119
+ },
120
+ serviceEndpoint: input.serviceEndpoint === !1 ? null : trimTrailingSlash((input.serviceEndpoint || "https://dkoxgivytgsmvqmjvmjt.supabase.co/functions/v1").trim()),
121
+ history: input.history?.projectKey?.trim() ? {
122
+ projectKey: input.history.projectKey.trim(),
123
+ endpoint: trimTrailingSlash((input.history.endpoint || input.serviceEndpoint || "https://dkoxgivytgsmvqmjvmjt.supabase.co/functions/v1").trim())
124
+ } : null,
125
+ jsonLd: input.jsonLd?.enabled && input.history?.projectKey?.trim() ? { field: input.jsonLd.field?.trim() || "jsonLd" } : null,
126
+ tools: {
127
+ ...DEFAULT_TOOLS,
128
+ ...input.tools
129
+ },
130
+ moreTools: input.moreTools === !1 ? [] : input.moreTools ?? DEFAULT_TOOLBAR_MORE,
131
+ boardTags: input.boardTags?.length ? input.boardTags : DEFAULT_BOARD_TAGS,
132
+ internalFields: input.internalFields?.length ? input.internalFields : DEFAULT_INTERNAL_FIELDS,
133
+ documentColumns: (input.documentColumns ?? []).map((column) => ({
134
+ key: column.key.trim(),
135
+ label: column.label?.trim() || column.key.trim(),
136
+ paths: [column.path].flat().map((path) => path.trim()).filter(Boolean),
137
+ type: column.type ?? "text"
138
+ }))
139
+ };
140
+ }
141
+ /**
142
+ * Préproduction déduite de la production, par convention.
143
+ *
144
+ * NoCode Factory assigne à chaque projet un domaine Vercel **fixe** pour la
145
+ * branche `preprod`, de la forme `preview-<projet>.vercel.app`. Fixe parce
146
+ * qu'un lien de partage doit survivre au commit suivant : une URL de
147
+ * déploiement change à chaque poussée, un domaine assigné non.
148
+ *
149
+ * La déduire évite de la déclarer neuf fois. Elle n'est proposée que pour un
150
+ * hôte Vercel — ailleurs la convention ne s'applique pas — et `environments`
151
+ * la remplace dès qu'on la déclare explicitement.
152
+ */
153
+ function conventionalPreprodUrl(previewUrl) {
154
+ if (!previewUrl) return null;
155
+ try {
156
+ let url = new URL(previewUrl);
157
+ return !url.hostname.endsWith(".vercel.app") || url.hostname.startsWith("preview-") ? null : `${url.protocol}//preview-${url.hostname}`;
158
+ } catch {
159
+ return null;
160
+ }
161
+ }
162
+ /**
163
+ * Environnements d'aperçu.
164
+ *
165
+ * `previewUrl` en fournit toujours un, nommé « Production » : un projet qui
166
+ * n'en déclare pas d'autres doit quand même pouvoir basculer entre brouillons
167
+ * et contenu en ligne.
168
+ *
169
+ * Quand `environments` mentionne déjà `previewUrl`, on ne le double pas.
170
+ */
171
+ function resolveEnvironments(input) {
172
+ let declared = (input.environments ?? []).map((environment) => ({
173
+ id: environment.id.trim(),
174
+ label: environment.label?.trim() || environment.id.trim(),
175
+ url: trimTrailingSlash((environment.url ?? "").trim())
176
+ })).filter((environment) => environment.id && environment.url), preview = input.previewUrl ? trimTrailingSlash(input.previewUrl.trim()) : null;
177
+ if (!preview) return declared;
178
+ let production = declared.some((environment) => environment.url === preview) ? [] : [{
179
+ id: "production",
180
+ label: "Production",
181
+ url: preview
182
+ }], conventional = conventionalPreprodUrl(preview), hasPreprod = declared.some((environment) => environment.url === conventional || environment.id === "preprod") || input.preprodUrl === !1, preprod = conventional && !hasPreprod ? [{
183
+ id: "preprod",
184
+ label: "Staging",
185
+ url: conventional
186
+ }] : [];
187
+ return [
188
+ ...production,
189
+ ...preprod,
190
+ ...declared
191
+ ];
192
+ }
193
+ /**
194
+ * Chemin d'une page sur le site. Le chemin fixe l'emporte sur le slug, le
195
+ * préfixe du type se place devant le slug ('/blog' + 'mon-article'), et la
196
+ * langue par défaut n'est pas préfixée (convention Next.js du starter).
197
+ */
198
+ function toPath(input, i18n) {
199
+ let localized = input.locale ? input.localizedPrefixes?.[input.locale] : void 0, raw = localized === void 0 ? input.pathPrefix : localized, prefix = typeof raw == "string" && raw ? normalizePath(raw) : "/", base = typeof input.path == "string" && input.path ? normalizePath(input.path) : input.slug ? normalizePath(prefix === "/" ? input.slug : `${prefix}/${input.slug.replace(/^\/+/, "")}`) : null;
200
+ return base === null ? null : !i18n || !input.locale || input.locale === i18n.defaultLocale ? base : base === "/" ? `/${input.locale}` : `/${input.locale}${base}`;
201
+ }
202
+ /** URL absolue d'une page, ou `null` si le front n'est pas configuré. */
203
+ function toUrl(previewUrl, path) {
204
+ return !previewUrl || path === null ? null : path === "/" ? previewUrl : `${previewUrl}${path}`;
205
+ }
206
+ /** Segments d'un chemin : '/services/plomberie' -> ['services', 'plomberie']. */
207
+ function segments(path) {
208
+ return path.split("/").filter(Boolean);
209
+ }
210
+ /** Profondeur dans l'arborescence. '/' vaut 0. */
211
+ function depth(path) {
212
+ return segments(path).length;
213
+ }
214
+ /**
215
+ * Chemin du parent, ou `null` à la racine. Sert au placement automatique du
216
+ * board : '/services/plomberie' -> '/services'.
217
+ */
218
+ function parentPath(path) {
219
+ let parts = segments(path);
220
+ return parts.length === 0 ? null : parts.length === 1 ? "/" : `/${parts.slice(0, -1).join("/")}`;
221
+ }
222
+ /** Le type de page correspondant à un document. */
223
+ function pageTypeFor(type, pageTypes) {
224
+ return pageTypes.find((p) => p.type === type);
225
+ }
226
+ /** Clé de comparaison des redirections (comme le site) : minuscules, sans « / » final, sans ? ni #. */
227
+ const redirectKey = (path) => {
228
+ let clean = (path.trim().split(/[?#]/)[0] ?? "").toLowerCase();
229
+ return clean.length > 1 ? clean.replace(/\/+$/, "") : clean;
230
+ };
231
+ function redirectMapOf(rows) {
232
+ let map = /* @__PURE__ */ new Map();
233
+ for (let r of rows) {
234
+ if (!r.from?.startsWith("/") || !r.to) continue;
235
+ let key = redirectKey(r.from);
236
+ key !== redirectKey(r.to) && !map.has(key) && map.set(key, r.to.trim());
237
+ }
238
+ return map;
239
+ }
240
+ /** Destination finale d'une adresse (chaîne de redirections suivie, boucles ignorées). */
241
+ function followRedirects(path, redirects) {
242
+ if (!redirects?.size) return path;
243
+ let current = path, seen = /* @__PURE__ */ new Set();
244
+ for (let hop = 0; hop < 5; hop++) {
245
+ let next = redirects.get(redirectKey(current));
246
+ if (!next || seen.has(next)) break;
247
+ seen.add(next), current = next;
248
+ }
249
+ return current;
250
+ }
251
+ /**
252
+ * URL FINALE d'une page (celle qui répond 200, sans redirection) : adresse réelle
253
+ * d'une page codée (registre `siteRoutes`, dossier de la langue), sinon dossier et
254
+ * slug de la langue ; puis destination si l'adresse est le départ d'une redirection
255
+ * du Studio. Affichée partout dans le kit (onglet Pages, board, Presentation, slug).
256
+ */
257
+ function finalPath(input, pageType, config, redirects) {
258
+ if (!pageType) return null;
259
+ let coded = !pageType.path && !pageType.pathPrefix && !pageType.localizedPrefixes && input.slug ? config.codedPages.find((c) => c.pageSlug === input.slug) : void 0, path = toPath(coded ? {
260
+ path: input.locale && coded.localized?.[input.locale] || coded.path,
261
+ locale: input.locale
262
+ } : {
263
+ slug: input.slug,
264
+ path: pageType.path,
265
+ pathPrefix: pageType.pathPrefix,
266
+ localizedPrefixes: pageType.localizedPrefixes,
267
+ locale: input.locale
268
+ }, config.i18n);
269
+ return path === null ? null : followRedirects(path, redirects);
270
+ }
271
+ export { DEFAULT_PAGE_BUILDER_FIELD as _, depth as a, segments as c, normalizePath as d, resolveConfig as f, DEFAULT_INTERNAL_FIELDS as g, DEFAULT_I18N as h, redirectMapOf as i, toPath as l, DEFAULT_COMPONENT_PREVIEW as m, followRedirects as n, pageTypeFor as o, DEFAULT_BOARD_TAGS as p, redirectKey as r, parentPath as s, finalPath as t, toUrl as u, DEFAULT_SLUG_FIELD as v, DEFAULT_TITLE_FIELD as y };
272
+
273
+ //# sourceMappingURL=finalUrl-C1kzYMzQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"finalUrl-C1kzYMzQ.js","names":[],"sources":["../src/config/defaults.ts","../src/config/resolve.ts","../src/lib/paths.ts","../src/lib/finalUrl.ts"],"sourcesContent":["import type {\n NcfBoardTag,\n NcfInternalField,\n NcfComponentPreviewConfig,\n NcfI18nConfig,\n NcfToolsConfig,\n} from './types'\n\nexport const DEFAULT_PAGE_BUILDER_FIELD = 'sections'\nexport const DEFAULT_SLUG_FIELD = 'slug'\nexport const DEFAULT_TITLE_FIELD = 'title'\nexport const DEFAULT_BLOCK_NAMESPACE = ''\n\n/**\n * Chemins essayés pour savoir si une page est indexable. Le premier\n * correspond à la convention du starter (`seo.noindex`), le second couvre les\n * schémas qui portent le drapeau à la racine.\n */\nexport const DEFAULT_NOINDEX_FIELDS = ['seo.noindex', 'noindex']\n\n// Aucune langue par défaut : la langue principale (master) vient TOUJOURS du projet\n// (`defaultLocale`, sinon la première de `locales`). Un site peut avoir le français,\n// l'anglais ou toute autre langue comme master.\nexport const DEFAULT_I18N: Omit<Required<NcfI18nConfig>, 'defaultsSourceLocale' | 'defaultLocale'> = {\n field: 'language',\n locales: [],\n}\n\n/**\n * Convention NoCode Factory : page `/design-system` dans le front, captures\n * dans `/sections/<nom>.png` générées au push par GitHub Actions.\n */\nexport const DEFAULT_COMPONENT_PREVIEW: Required<NcfComponentPreviewConfig> = {\n provider: 'designSystemPage',\n path: '/design-system',\n anchor: '{name}',\n thumbnail: '/sections/{name}.png',\n defaultsType: 'componentDefaults',\n live: '/design-system/composant?type={name}',\n}\n\nexport const DEFAULT_TOOLS: Required<NcfToolsConfig> = {\n pages: true,\n components: true,\n history: true,\n designSystem: true,\n}\n\n/**\n * Outils rangés dans « Plus » : Vision (console GROQ) et la planification\n * (« Scheduled drafts » quand les Releases sont désactivées, « Releases » sinon :\n * le même outil, nommé `releases` ; `schedules` couvre les anciennes versions).\n */\nexport const DEFAULT_TOOLBAR_MORE = ['vision', 'releases', 'schedules']\n\n/**\n * Étiquettes de suivi par défaut : l'avancement d'une refonte, pas un statut\n * de publication. Elles vivent dans le document de disposition du kit, donc\n * aucun schéma client n'est modifié.\n */\nexport const DEFAULT_BOARD_TAGS: NcfBoardTag[] = [\n {id: 'en-cours', label: 'In progress', color: '#f5a623'},\n {id: 'fait', label: 'Done', color: '#43d675'},\n {id: 'a-relire', label: 'To review', color: '#2276fc'},\n {id: 'a-refondre', label: 'To rework', color: '#f03e3e'},\n]\n\n/**\n * Colonnes de gestion interne par défaut. Volontairement peu nombreuses : ce\n * sont celles qu'on redemande sur tous les projets. `internalFields` les\n * remplace entièrement.\n */\nexport const DEFAULT_INTERNAL_FIELDS: NcfInternalField[] = [\n {id: 'owner', label: 'Owner', type: 'text'},\n {id: 'audience', label: 'Audience', type: 'text'},\n {id: 'role', label: 'Page role', type: 'text'},\n]\n\n/**\n * Service du kit, hébergé par NoCode Factory.\n *\n * Renseigné d'office pour qu'un Studio n'ait rien à configurer : il se\n * signale au démarrage, et c'est ce qui permet de savoir quels projets\n * utilisent le kit. `endpoint` le remplace pour une instance privée.\n */\nexport const DEFAULT_SERVICE_ENDPOINT = 'https://dkoxgivytgsmvqmjvmjt.supabase.co/functions/v1'\n","import {\n DEFAULT_BLOCK_NAMESPACE,\n DEFAULT_BOARD_TAGS,\n DEFAULT_INTERNAL_FIELDS,\n DEFAULT_SERVICE_ENDPOINT,\n DEFAULT_COMPONENT_PREVIEW,\n DEFAULT_I18N,\n DEFAULT_NOINDEX_FIELDS,\n DEFAULT_PAGE_BUILDER_FIELD,\n DEFAULT_SLUG_FIELD,\n DEFAULT_TITLE_FIELD,\n DEFAULT_TOOLBAR_MORE, DEFAULT_TOOLS,\n} from './defaults'\nimport type {\n NcfEnvironment,\n NcfKitConfig,\n NcfPageTypeConfig,\n ResolvedKitConfig,\n ResolvedPageType,\n} from './types'\n\nconst trimTrailingSlash = (url: string) => url.replace(/\\/+$/, '')\n\n/** Garantit un chemin absolu ('accueil' -> '/accueil', '' -> '/'). */\nexport const normalizePath = (path: string): string => {\n const trimmed = path.trim()\n if (!trimmed || trimmed === '/') return '/'\n const withSlash = trimmed.startsWith('/') ? trimmed : `/${trimmed}`\n return withSlash.length > 1 ? trimTrailingSlash(withSlash) : withSlash\n}\n\nfunction resolvePageType(\n entry: NcfPageTypeConfig,\n defaults: {slugField: string; titleField: string},\n): ResolvedPageType {\n if (typeof entry === 'string') {\n return {\n type: entry.trim(),\n slugField: defaults.slugField,\n path: null,\n pathPrefix: null,\n localizedPrefixes: null,\n titleField: defaults.titleField,\n }\n }\n\n // `path` gagne sur `slugField` : une page à chemin fixe (l'accueil) n'a pas\n // de slug à lire, même si le type en porte un par ailleurs.\n const path = typeof entry.path === 'string' ? normalizePath(entry.path) : null\n const slugField =\n entry.slugField === null ? null : (entry.slugField?.trim() || defaults.slugField)\n\n // Un préfixe vide ou '/' vaut « à la racine » : pas de préfixe.\n const prefix = typeof entry.pathPrefix === 'string' ? normalizePath(entry.pathPrefix) : '/'\n\n return {\n type: (entry.type ?? '').trim(),\n slugField: path ? null : slugField,\n path,\n // Conservé même avec `path` (qui gagne au calcul du chemin) : la validation\n // peut ainsi signaler le préfixe inutile.\n pathPrefix: prefix === '/' ? null : prefix,\n localizedPrefixes: entry.localizedPrefixes\n ? Object.fromEntries(Object.entries(entry.localizedPrefixes).map(([l, p]) => [l, normalizePath(p) === '/' ? '' : normalizePath(p)]))\n : null,\n titleField: entry.titleField?.trim() || defaults.titleField,\n }\n}\n\n/** Applique les valeurs par défaut. Ne valide rien : voir `validateConfig`. */\nexport function resolveConfig(input: NcfKitConfig): ResolvedKitConfig {\n const slugField = input.slugField?.trim() || DEFAULT_SLUG_FIELD\n const titleField = input.titleField?.trim() || DEFAULT_TITLE_FIELD\n\n const pageTypes = (Array.isArray(input.pageTypes) ? input.pageTypes : []).map((entry) =>\n resolvePageType(entry, {slugField, titleField}),\n )\n\n const i18n =\n input.i18n === false || input.i18n === undefined\n ? null\n : (() => {\n const locales = (input.i18n.locales ?? DEFAULT_I18N.locales).map((l) => l.trim()).filter(Boolean)\n // Master : `defaultLocale`, sinon la première langue. Jamais une langue écrite\n // dans le kit (absente : signalé par validateConfig).\n const defaultLocale = input.i18n.defaultLocale?.trim() || locales[0] || ''\n return {\n field: input.i18n.field?.trim() || DEFAULT_I18N.field,\n defaultLocale,\n locales,\n // Valeurs par défaut des composants : écrites dans la langue master,\n // traduites vers les autres (sauf choix explicite du projet).\n defaultsSourceLocale: input.i18n.defaultsSourceLocale?.trim() || defaultLocale,\n }\n })()\n\n return {\n pageTypes,\n codedPages: (input.siteRoutes?.fixed ?? [])\n .filter((f) => f.pageSlug && !f.homePage && !f.system && !f.notFound)\n .map((f) => ({pageSlug: f.pageSlug as string, path: normalizePath(f.path), localized: f.localized ?? null})),\n redirectType: input.redirectType?.trim() || 'redirect',\n pageTypeNames: pageTypes.map((p) => p.type).filter(Boolean),\n pageBuilderField: input.pageBuilderField?.trim() || DEFAULT_PAGE_BUILDER_FIELD,\n blockNamespace: input.blockNamespace ?? DEFAULT_BLOCK_NAMESPACE,\n noindexFields: input.noindexField\n ? [input.noindexField].flat().map((field) => field.trim()).filter(Boolean)\n : DEFAULT_NOINDEX_FIELDS,\n previewUrl: input.previewUrl ? trimTrailingSlash(input.previewUrl.trim()) : null,\n environments: resolveEnvironments(input),\n pageThumbnail: input.pageThumbnail?.trim() || null,\n i18n,\n componentPreview: {\n provider: input.componentPreview?.provider ?? DEFAULT_COMPONENT_PREVIEW.provider,\n path: input.componentPreview?.path ?? DEFAULT_COMPONENT_PREVIEW.path,\n anchor: input.componentPreview?.anchor ?? DEFAULT_COMPONENT_PREVIEW.anchor,\n thumbnail: input.componentPreview?.thumbnail ?? DEFAULT_COMPONENT_PREVIEW.thumbnail,\n defaultsType: input.componentPreview?.defaultsType ?? DEFAULT_COMPONENT_PREVIEW.defaultsType,\n live: input.componentPreview?.live ?? DEFAULT_COMPONENT_PREVIEW.live,\n },\n serviceEndpoint:\n input.serviceEndpoint === false\n ? null\n : trimTrailingSlash((input.serviceEndpoint || DEFAULT_SERVICE_ENDPOINT).trim()),\n history: input.history?.projectKey?.trim()\n ? {\n projectKey: input.history.projectKey.trim(),\n endpoint: trimTrailingSlash(\n (input.history.endpoint || input.serviceEndpoint || DEFAULT_SERVICE_ENDPOINT).trim(),\n ),\n }\n : null,\n // Le JSON-LD IA s'appuie sur le même service que la traduction : sans\n // `history.projectKey`, il n'y a pas d'IA à brancher.\n jsonLd:\n input.jsonLd?.enabled && input.history?.projectKey?.trim()\n ? {field: input.jsonLd.field?.trim() || 'jsonLd'}\n : null,\n tools: {...DEFAULT_TOOLS, ...input.tools},\n moreTools: input.moreTools === false ? [] : (input.moreTools ?? DEFAULT_TOOLBAR_MORE),\n boardTags: input.boardTags?.length ? input.boardTags : DEFAULT_BOARD_TAGS,\n internalFields: input.internalFields?.length\n ? input.internalFields\n : DEFAULT_INTERNAL_FIELDS,\n // Additif : le schéma du client fournit déjà l'essentiel, ceci ne sert\n // qu'à ce qu'un parcours de schéma ne sait pas exprimer.\n documentColumns: (input.documentColumns ?? []).map((column) => ({\n key: column.key.trim(),\n label: column.label?.trim() || column.key.trim(),\n paths: [column.path].flat().map((path) => path.trim()).filter(Boolean),\n type: column.type ?? 'text',\n })),\n }\n}\n\n\n/**\n * Préproduction déduite de la production, par convention.\n *\n * NoCode Factory assigne à chaque projet un domaine Vercel **fixe** pour la\n * branche `preprod`, de la forme `preview-<projet>.vercel.app`. Fixe parce\n * qu'un lien de partage doit survivre au commit suivant : une URL de\n * déploiement change à chaque poussée, un domaine assigné non.\n *\n * La déduire évite de la déclarer neuf fois. Elle n'est proposée que pour un\n * hôte Vercel — ailleurs la convention ne s'applique pas — et `environments`\n * la remplace dès qu'on la déclare explicitement.\n */\nexport function conventionalPreprodUrl(previewUrl: string | null): string | null {\n if (!previewUrl) return null\n try {\n const url = new URL(previewUrl)\n if (!url.hostname.endsWith('.vercel.app')) return null\n // Une préproduction ne se dérive pas d'une préproduction.\n if (url.hostname.startsWith('preview-')) return null\n return `${url.protocol}//preview-${url.hostname}`\n } catch {\n return null\n }\n}\n\n/**\n * Environnements d'aperçu.\n *\n * `previewUrl` en fournit toujours un, nommé « Production » : un projet qui\n * n'en déclare pas d'autres doit quand même pouvoir basculer entre brouillons\n * et contenu en ligne.\n *\n * Quand `environments` mentionne déjà `previewUrl`, on ne le double pas.\n */\nfunction resolveEnvironments(input: NcfKitConfig): NcfEnvironment[] {\n const declared = (input.environments ?? [])\n .map((environment) => ({\n id: environment.id.trim(),\n label: environment.label?.trim() || environment.id.trim(),\n url: trimTrailingSlash((environment.url ?? '').trim()),\n }))\n .filter((environment) => environment.id && environment.url)\n\n const preview = input.previewUrl ? trimTrailingSlash(input.previewUrl.trim()) : null\n if (!preview) return declared\n\n const production = declared.some((environment) => environment.url === preview)\n ? []\n : [{id: 'production', label: 'Production', url: preview}]\n\n // La préproduction conventionnelle complète la liste, sauf si le projet en\n // a déjà déclaré une — sa déclaration explicite fait foi.\n //\n // On compare l'identifiant autant que l'URL : un projet dont le domaine ne\n // suit pas exactement la convention déclare bien un `preprod`, à une autre\n // adresse. En n'écartant que par l'URL, on en ajoutait un second portant le\n // même identifiant, et la configuration devenait invalide.\n const conventional = conventionalPreprodUrl(preview)\n const hasPreprod =\n declared.some(\n (environment) => environment.url === conventional || environment.id === 'preprod',\n ) || input.preprodUrl === false\n\n const preprod =\n conventional && !hasPreprod\n ? [{id: 'preprod', label: 'Staging', url: conventional}]\n : []\n\n return [...production, ...preprod, ...declared]\n}\n","import {normalizePath} from '../config/resolve'\nimport type {ResolvedI18n, ResolvedPageType} from '../config/types'\n\nexport interface PathInput {\n /** Valeur du champ slug (`slug.current`). Peut contenir des `/`. */\n slug?: string | null\n /** Chemin fixe du type de page, s'il en a un. */\n path?: string | null\n /** Préfixe d'URL du type de page ('/blog'), devant le slug. */\n pathPrefix?: string | null\n /** Préfixe par langue (dossiers traduits) : celui de `locale` gagne sur `pathPrefix`. */\n localizedPrefixes?: Record<string, string> | null\n /** Langue du document. */\n locale?: string | null\n}\n\n/**\n * Chemin d'une page sur le site. Le chemin fixe l'emporte sur le slug, le\n * préfixe du type se place devant le slug ('/blog' + 'mon-article'), et la\n * langue par défaut n'est pas préfixée (convention Next.js du starter).\n */\nexport function toPath(input: PathInput, i18n: ResolvedI18n | null): string | null {\n const localized = input.locale ? input.localizedPrefixes?.[input.locale] : undefined\n const raw = localized !== undefined ? localized : input.pathPrefix\n const prefix = typeof raw === 'string' && raw ? normalizePath(raw) : '/'\n const base =\n typeof input.path === 'string' && input.path\n ? normalizePath(input.path)\n : input.slug\n ? normalizePath(prefix === '/' ? input.slug : `${prefix}/${input.slug.replace(/^\\/+/, '')}`)\n : null\n\n if (base === null) return null\n if (!i18n || !input.locale || input.locale === i18n.defaultLocale) return base\n return base === '/' ? `/${input.locale}` : `/${input.locale}${base}`\n}\n\n/** URL absolue d'une page, ou `null` si le front n'est pas configuré. */\nexport function toUrl(previewUrl: string | null, path: string | null): string | null {\n if (!previewUrl || path === null) return null\n return path === '/' ? previewUrl : `${previewUrl}${path}`\n}\n\n/** Segments d'un chemin : '/services/plomberie' -> ['services', 'plomberie']. */\nexport function segments(path: string): string[] {\n return path.split('/').filter(Boolean)\n}\n\n/** Profondeur dans l'arborescence. '/' vaut 0. */\nexport function depth(path: string): number {\n return segments(path).length\n}\n\n/**\n * Chemin du parent, ou `null` à la racine. Sert au placement automatique du\n * board : '/services/plomberie' -> '/services'.\n */\nexport function parentPath(path: string): string | null {\n const parts = segments(path)\n if (parts.length === 0) return null\n if (parts.length === 1) return '/'\n return `/${parts.slice(0, -1).join('/')}`\n}\n\n/** Le type de page correspondant à un document. */\nexport function pageTypeFor(\n type: string,\n pageTypes: ResolvedPageType[],\n): ResolvedPageType | undefined {\n return pageTypes.find((p) => p.type === type)\n}\n","import type {ResolvedKitConfig, ResolvedPageType} from '../config/types'\nimport {toPath} from './paths'\n\n/** Clé de comparaison des redirections (comme le site) : minuscules, sans « / » final, sans ? ni #. */\nexport const redirectKey = (path: string) => {\n const clean = (path.trim().split(/[?#]/)[0] ?? '').toLowerCase()\n return clean.length > 1 ? clean.replace(/\\/+$/, '') : clean\n}\n\n/** Table des redirections du Studio : départ (normalisé) -> destination. */\nexport type RedirectMap = Map<string, string>\n\nexport function redirectMapOf(rows: readonly {from?: string | null; to?: string | null}[]): RedirectMap {\n const map: RedirectMap = new Map()\n for (const r of rows) {\n if (!r.from?.startsWith('/') || !r.to) continue\n const key = redirectKey(r.from)\n if (key !== redirectKey(r.to) && !map.has(key)) map.set(key, r.to.trim())\n }\n return map\n}\n\n/** Destination finale d'une adresse (chaîne de redirections suivie, boucles ignorées). */\nexport function followRedirects(path: string, redirects: RedirectMap | null | undefined): string {\n if (!redirects?.size) return path\n let current = path\n const seen = new Set<string>()\n for (let hop = 0; hop < 5; hop++) {\n const next = redirects.get(redirectKey(current))\n if (!next || seen.has(next)) break\n seen.add(next)\n current = next\n }\n return current\n}\n\n/**\n * URL FINALE d'une page (celle qui répond 200, sans redirection) : adresse réelle\n * d'une page codée (registre `siteRoutes`, dossier de la langue), sinon dossier et\n * slug de la langue ; puis destination si l'adresse est le départ d'une redirection\n * du Studio. Affichée partout dans le kit (onglet Pages, board, Presentation, slug).\n */\nexport function finalPath(\n input: {slug: string | null; locale: string | null},\n pageType: ResolvedPageType | null | undefined,\n config: Pick<ResolvedKitConfig, 'i18n' | 'codedPages'>,\n redirects?: RedirectMap | null,\n): string | null {\n if (!pageType) return null\n const atRoot = !pageType.path && !pageType.pathPrefix && !pageType.localizedPrefixes\n const coded = atRoot && input.slug ? config.codedPages.find((c) => c.pageSlug === input.slug) : undefined\n const path = coded\n ? toPath({path: (input.locale && coded.localized?.[input.locale]) || coded.path, locale: input.locale}, config.i18n)\n : toPath(\n {slug: input.slug, path: pageType.path, pathPrefix: pageType.pathPrefix, localizedPrefixes: pageType.localizedPrefixes, locale: input.locale},\n config.i18n,\n )\n return path === null ? null : followRedirects(path, redirects)\n}\n"],"mappings":"AAQA,MAAa,6BAA6B,YAC7B,qBAAqB,QACrB,sBAAsB,SAQtB,yBAAyB,CAAC,eAAe,SAAS,GAKlD,eAAwF;CACnG,OAAO;CACP,SAAS,CAAC;AACZ,GAMa,4BAAiE;CAC5E,UAAU;CACV,MAAM;CACN,QAAQ;CACR,WAAW;CACX,cAAc;CACd,MAAM;AACR,GAEa,gBAA0C;CACrD,OAAO;CACP,YAAY;CACZ,SAAS;CACT,cAAc;AAChB,GAOa,uBAAuB;CAAC;CAAU;CAAY;AAAW,GAOzD,qBAAoC;CAC/C;EAAC,IAAI;EAAY,OAAO;EAAe,OAAO;CAAS;CACvD;EAAC,IAAI;EAAQ,OAAO;EAAQ,OAAO;CAAS;CAC5C;EAAC,IAAI;EAAY,OAAO;EAAa,OAAO;CAAS;CACrD;EAAC,IAAI;EAAc,OAAO;EAAa,OAAO;CAAS;AACzD,GAOa,0BAA8C;CACzD;EAAC,IAAI;EAAS,OAAO;EAAS,MAAM;CAAM;CAC1C;EAAC,IAAI;EAAY,OAAO;EAAY,MAAM;CAAM;CAChD;EAAC,IAAI;EAAQ,OAAO;EAAa,MAAM;CAAM;AAC/C,GCvDM,qBAAqB,QAAgB,IAAI,QAAQ,QAAQ,EAAE,GAGpD,iBAAiB,SAAyB;CACrD,IAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,WAAW,YAAY,KAAK,OAAO;CACxC,IAAM,YAAY,QAAQ,WA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I,IAAI,GAAG;EAE7B,AADA,KAAK,IAAI,IAAI,GACb,UAAU;CACZ;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,UACd,OACA,UACA,QACA,WACe;CACf,IAAI,CAAC,UAAU,OAAO;CAEtB,IAAM,QADS,CAAC,SAAS,QAAQ,CAAC,SAAS,cAAc,CAAC,SAAS,qBAC3C,MAAM,OAAO,OAAO,WAAW,MAAM,MAAM,EAAE,aAAa,MAAM,IAAI,IAAI,KAAA,GAC1F,OACF,OADS,QACF;EAAC,MAAO,MAAM,UAAU,MAAM,YAAY,MAAM,WAAY,MAAM;EAAM,QAAQ,MAAM;CAAM,IAEjG;EAAC,MAAM,MAAM;EAAM,MAAM,SAAS;EAAM,YAAY,SAAS;EAAY,mBAAmB,SAAS;EAAmB,QAAQ,MAAM;CAAM,GAFxC,OAAO,IAI7G;CACJ,OAAO,SAAS,OAAO,OAAO,gBAAgB,MAAM,SAAS;AAC/D"}
@@ -1,273 +1,5 @@
1
+ import { l as toPath } from "./finalUrl-C1kzYMzQ.js";
1
2
  import { defineField, defineType } from "sanity";
2
- const DEFAULT_PAGE_BUILDER_FIELD = "sections", DEFAULT_SLUG_FIELD = "slug", DEFAULT_TITLE_FIELD = "title", DEFAULT_NOINDEX_FIELDS = ["seo.noindex", "noindex"], DEFAULT_I18N = {
3
- field: "language",
4
- locales: []
5
- }, DEFAULT_COMPONENT_PREVIEW = {
6
- provider: "designSystemPage",
7
- path: "/design-system",
8
- anchor: "{name}",
9
- thumbnail: "/sections/{name}.png",
10
- defaultsType: "componentDefaults",
11
- live: "/design-system/composant?type={name}"
12
- }, DEFAULT_TOOLS = {
13
- pages: !0,
14
- components: !0,
15
- history: !0,
16
- designSystem: !0
17
- }, DEFAULT_TOOLBAR_MORE = [
18
- "vision",
19
- "releases",
20
- "schedules"
21
- ], DEFAULT_BOARD_TAGS = [
22
- {
23
- id: "en-cours",
24
- label: "In progress",
25
- color: "#f5a623"
26
- },
27
- {
28
- id: "fait",
29
- label: "Done",
30
- color: "#43d675"
31
- },
32
- {
33
- id: "a-relire",
34
- label: "To review",
35
- color: "#2276fc"
36
- },
37
- {
38
- id: "a-refondre",
39
- label: "To rework",
40
- color: "#f03e3e"
41
- }
42
- ], DEFAULT_INTERNAL_FIELDS = [
43
- {
44
- id: "owner",
45
- label: "Owner",
46
- type: "text"
47
- },
48
- {
49
- id: "audience",
50
- label: "Audience",
51
- type: "text"
52
- },
53
- {
54
- id: "role",
55
- label: "Page role",
56
- type: "text"
57
- }
58
- ], trimTrailingSlash = (url) => url.replace(/\/+$/, ""), normalizePath = (path) => {
59
- let trimmed = path.trim();
60
- if (!trimmed || trimmed === "/") return "/";
61
- let withSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
62
- return withSlash.length > 1 ? trimTrailingSlash(withSlash) : withSlash;
63
- };
64
- function resolvePageType(entry, defaults) {
65
- if (typeof entry == "string") return {
66
- type: entry.trim(),
67
- slugField: defaults.slugField,
68
- path: null,
69
- pathPrefix: null,
70
- localizedPrefixes: null,
71
- titleField: defaults.titleField
72
- };
73
- let path = typeof entry.path == "string" ? normalizePath(entry.path) : null, slugField = entry.slugField === null ? null : entry.slugField?.trim() || defaults.slugField, prefix = typeof entry.pathPrefix == "string" ? normalizePath(entry.pathPrefix) : "/";
74
- return {
75
- type: (entry.type ?? "").trim(),
76
- slugField: path ? null : slugField,
77
- path,
78
- pathPrefix: prefix === "/" ? null : prefix,
79
- localizedPrefixes: entry.localizedPrefixes ? Object.fromEntries(Object.entries(entry.localizedPrefixes).map(([l, p]) => [l, normalizePath(p) === "/" ? "" : normalizePath(p)])) : null,
80
- titleField: entry.titleField?.trim() || defaults.titleField
81
- };
82
- }
83
- /** Applique les valeurs par défaut. Ne valide rien : voir `validateConfig`. */
84
- function resolveConfig(input) {
85
- let slugField = input.slugField?.trim() || "slug", titleField = input.titleField?.trim() || "title", pageTypes = (Array.isArray(input.pageTypes) ? input.pageTypes : []).map((entry) => resolvePageType(entry, {
86
- slugField,
87
- titleField
88
- })), i18n = input.i18n === !1 || input.i18n === void 0 ? null : (() => {
89
- let locales = (input.i18n.locales ?? DEFAULT_I18N.locales).map((l) => l.trim()).filter(Boolean), defaultLocale = input.i18n.defaultLocale?.trim() || locales[0] || "";
90
- return {
91
- field: input.i18n.field?.trim() || DEFAULT_I18N.field,
92
- defaultLocale,
93
- locales,
94
- defaultsSourceLocale: input.i18n.defaultsSourceLocale?.trim() || defaultLocale
95
- };
96
- })();
97
- return {
98
- pageTypes,
99
- codedPages: (input.siteRoutes?.fixed ?? []).filter((f) => f.pageSlug && !f.homePage && !f.system && !f.notFound).map((f) => ({
100
- pageSlug: f.pageSlug,
101
- path: normalizePath(f.path),
102
- localized: f.localized ?? null
103
- })),
104
- redirectType: input.redirectType?.trim() || "redirect",
105
- pageTypeNames: pageTypes.map((p) => p.type).filter(Boolean),
106
- pageBuilderField: input.pageBuilderField?.trim() || "sections",
107
- blockNamespace: input.blockNamespace ?? "",
108
- noindexFields: input.noindexField ? [input.noindexField].flat().map((field) => field.trim()).filter(Boolean) : DEFAULT_NOINDEX_FIELDS,
109
- previewUrl: input.previewUrl ? trimTrailingSlash(input.previewUrl.trim()) : null,
110
- environments: resolveEnvironments(input),
111
- pageThumbnail: input.pageThumbnail?.trim() || null,
112
- i18n,
113
- componentPreview: {
114
- provider: input.componentPreview?.provider ?? DEFAULT_COMPONENT_PREVIEW.provider,
115
- path: input.componentPreview?.path ?? DEFAULT_COMPONENT_PREVIEW.path,
116
- anchor: input.componentPreview?.anchor ?? DEFAULT_COMPONENT_PREVIEW.anchor,
117
- thumbnail: input.componentPreview?.thumbnail ?? DEFAULT_COMPONENT_PREVIEW.thumbnail,
118
- defaultsType: input.componentPreview?.defaultsType ?? DEFAULT_COMPONENT_PREVIEW.defaultsType,
119
- live: input.componentPreview?.live ?? DEFAULT_COMPONENT_PREVIEW.live
120
- },
121
- serviceEndpoint: input.serviceEndpoint === !1 ? null : trimTrailingSlash((input.serviceEndpoint || "https://dkoxgivytgsmvqmjvmjt.supabase.co/functions/v1").trim()),
122
- history: input.history?.projectKey?.trim() ? {
123
- projectKey: input.history.projectKey.trim(),
124
- endpoint: trimTrailingSlash((input.history.endpoint || input.serviceEndpoint || "https://dkoxgivytgsmvqmjvmjt.supabase.co/functions/v1").trim())
125
- } : null,
126
- tools: {
127
- ...DEFAULT_TOOLS,
128
- ...input.tools
129
- },
130
- moreTools: input.moreTools === !1 ? [] : input.moreTools ?? DEFAULT_TOOLBAR_MORE,
131
- boardTags: input.boardTags?.length ? input.boardTags : DEFAULT_BOARD_TAGS,
132
- internalFields: input.internalFields?.length ? input.internalFields : DEFAULT_INTERNAL_FIELDS,
133
- documentColumns: (input.documentColumns ?? []).map((column) => ({
134
- key: column.key.trim(),
135
- label: column.label?.trim() || column.key.trim(),
136
- paths: [column.path].flat().map((path) => path.trim()).filter(Boolean),
137
- type: column.type ?? "text"
138
- }))
139
- };
140
- }
141
- /**
142
- * Préproduction déduite de la production, par convention.
143
- *
144
- * NoCode Factory assigne à chaque projet un domaine Vercel **fixe** pour la
145
- * branche `preprod`, de la forme `preview-<projet>.vercel.app`. Fixe parce
146
- * qu'un lien de partage doit survivre au commit suivant : une URL de
147
- * déploiement change à chaque poussée, un domaine assigné non.
148
- *
149
- * La déduire évite de la déclarer neuf fois. Elle n'est proposée que pour un
150
- * hôte Vercel — ailleurs la convention ne s'applique pas — et `environments`
151
- * la remplace dès qu'on la déclare explicitement.
152
- */
153
- function conventionalPreprodUrl(previewUrl) {
154
- if (!previewUrl) return null;
155
- try {
156
- let url = new URL(previewUrl);
157
- return !url.hostname.endsWith(".vercel.app") || url.hostname.startsWith("preview-") ? null : `${url.protocol}//preview-${url.hostname}`;
158
- } catch {
159
- return null;
160
- }
161
- }
162
- /**
163
- * Environnements d'aperçu.
164
- *
165
- * `previewUrl` en fournit toujours un, nommé « Production » : un projet qui
166
- * n'en déclare pas d'autres doit quand même pouvoir basculer entre brouillons
167
- * et contenu en ligne.
168
- *
169
- * Quand `environments` mentionne déjà `previewUrl`, on ne le double pas.
170
- */
171
- function resolveEnvironments(input) {
172
- let declared = (input.environments ?? []).map((environment) => ({
173
- id: environment.id.trim(),
174
- label: environment.label?.trim() || environment.id.trim(),
175
- url: trimTrailingSlash((environment.url ?? "").trim())
176
- })).filter((environment) => environment.id && environment.url), preview = input.previewUrl ? trimTrailingSlash(input.previewUrl.trim()) : null;
177
- if (!preview) return declared;
178
- let production = declared.some((environment) => environment.url === preview) ? [] : [{
179
- id: "production",
180
- label: "Production",
181
- url: preview
182
- }], conventional = conventionalPreprodUrl(preview), hasPreprod = declared.some((environment) => environment.url === conventional || environment.id === "preprod") || input.preprodUrl === !1, preprod = conventional && !hasPreprod ? [{
183
- id: "preprod",
184
- label: "Staging",
185
- url: conventional
186
- }] : [];
187
- return [
188
- ...production,
189
- ...preprod,
190
- ...declared
191
- ];
192
- }
193
- /**
194
- * Chemin d'une page sur le site. Le chemin fixe l'emporte sur le slug, le
195
- * préfixe du type se place devant le slug ('/blog' + 'mon-article'), et la
196
- * langue par défaut n'est pas préfixée (convention Next.js du starter).
197
- */
198
- function toPath(input, i18n) {
199
- let localized = input.locale ? input.localizedPrefixes?.[input.locale] : void 0, raw = localized === void 0 ? input.pathPrefix : localized, prefix = typeof raw == "string" && raw ? normalizePath(raw) : "/", base = typeof input.path == "string" && input.path ? normalizePath(input.path) : input.slug ? normalizePath(prefix === "/" ? input.slug : `${prefix}/${input.slug.replace(/^\/+/, "")}`) : null;
200
- return base === null ? null : !i18n || !input.locale || input.locale === i18n.defaultLocale ? base : base === "/" ? `/${input.locale}` : `/${input.locale}${base}`;
201
- }
202
- /** URL absolue d'une page, ou `null` si le front n'est pas configuré. */
203
- function toUrl(previewUrl, path) {
204
- return !previewUrl || path === null ? null : path === "/" ? previewUrl : `${previewUrl}${path}`;
205
- }
206
- /** Segments d'un chemin : '/services/plomberie' -> ['services', 'plomberie']. */
207
- function segments(path) {
208
- return path.split("/").filter(Boolean);
209
- }
210
- /** Profondeur dans l'arborescence. '/' vaut 0. */
211
- function depth(path) {
212
- return segments(path).length;
213
- }
214
- /**
215
- * Chemin du parent, ou `null` à la racine. Sert au placement automatique du
216
- * board : '/services/plomberie' -> '/services'.
217
- */
218
- function parentPath(path) {
219
- let parts = segments(path);
220
- return parts.length === 0 ? null : parts.length === 1 ? "/" : `/${parts.slice(0, -1).join("/")}`;
221
- }
222
- /** Le type de page correspondant à un document. */
223
- function pageTypeFor(type, pageTypes) {
224
- return pageTypes.find((p) => p.type === type);
225
- }
226
- /** Clé de comparaison des redirections (comme le site) : minuscules, sans « / » final, sans ? ni #. */
227
- const redirectKey = (path) => {
228
- let clean = (path.trim().split(/[?#]/)[0] ?? "").toLowerCase();
229
- return clean.length > 1 ? clean.replace(/\/+$/, "") : clean;
230
- };
231
- function redirectMapOf(rows) {
232
- let map = /* @__PURE__ */ new Map();
233
- for (let r of rows) {
234
- if (!r.from?.startsWith("/") || !r.to) continue;
235
- let key = redirectKey(r.from);
236
- key !== redirectKey(r.to) && !map.has(key) && map.set(key, r.to.trim());
237
- }
238
- return map;
239
- }
240
- /** Destination finale d'une adresse (chaîne de redirections suivie, boucles ignorées). */
241
- function followRedirects(path, redirects) {
242
- if (!redirects?.size) return path;
243
- let current = path, seen = /* @__PURE__ */ new Set();
244
- for (let hop = 0; hop < 5; hop++) {
245
- let next = redirects.get(redirectKey(current));
246
- if (!next || seen.has(next)) break;
247
- seen.add(next), current = next;
248
- }
249
- return current;
250
- }
251
- /**
252
- * URL FINALE d'une page (celle qui répond 200, sans redirection) : adresse réelle
253
- * d'une page codée (registre `siteRoutes`, dossier de la langue), sinon dossier et
254
- * slug de la langue ; puis destination si l'adresse est le départ d'une redirection
255
- * du Studio. Affichée partout dans le kit (onglet Pages, board, Presentation, slug).
256
- */
257
- function finalPath(input, pageType, config, redirects) {
258
- if (!pageType) return null;
259
- let coded = !pageType.path && !pageType.pathPrefix && !pageType.localizedPrefixes && input.slug ? config.codedPages.find((c) => c.pageSlug === input.slug) : void 0, path = toPath(coded ? {
260
- path: input.locale && coded.localized?.[input.locale] || coded.path,
261
- locale: input.locale
262
- } : {
263
- slug: input.slug,
264
- path: pageType.path,
265
- pathPrefix: pageType.pathPrefix,
266
- localizedPrefixes: pageType.localizedPrefixes,
267
- locale: input.locale
268
- }, config.i18n);
269
- return path === null ? null : followRedirects(path, redirects);
270
- }
271
3
  /** Identifiant stable de la redirection d'une version (mise à jour, jamais dupliquée). */
272
4
  const translationRedirectId = (versionId) => `redirect-translation-${versionId.replace(/^drafts\./, "").replace(/[^A-Za-z0-9_-]/g, "-")}`;
273
5
  /**
@@ -606,6 +338,6 @@ async function fixCrossLanguageReferences(client, options) {
606
338
  }
607
339
  return report;
608
340
  }
609
- export { DEFAULT_PAGE_BUILDER_FIELD as A, toUrl as C, DEFAULT_COMPONENT_PREVIEW as D, DEFAULT_BOARD_TAGS as E, DEFAULT_TITLE_FIELD as M, DEFAULT_I18N as O, toPath as S, resolveConfig as T, redirectMapOf as _, componentDefaultsMainDocument as a, parentPath as b, defineComponentDefaults as c, syncTranslationRedirects as d, translationRedirectId as f, redirectKey as g, followRedirects as h, DEFAULT_COMPONENT_DEFAULTS_TYPE as i, DEFAULT_SLUG_FIELD as j, DEFAULT_INTERNAL_FIELDS as k, requiredUnlessDefault as l, finalPath as m, withSameLanguageReferences as n, componentDefaultsMainDocuments as o, translationRedirectOptions as p, pageTypesFromSiteRoutes as r, defaultsFieldName as s, fixCrossLanguageReferences as t, requiredUnlessDefaultFor as u, depth as v, normalizePath as w, segments as x, pageTypeFor as y };
341
+ export { componentDefaultsMainDocument as a, defineComponentDefaults as c, syncTranslationRedirects as d, translationRedirectId as f, DEFAULT_COMPONENT_DEFAULTS_TYPE as i, requiredUnlessDefault as l, withSameLanguageReferences as n, componentDefaultsMainDocuments as o, translationRedirectOptions as p, pageTypesFromSiteRoutes as r, defaultsFieldName as s, fixCrossLanguageReferences as t, requiredUnlessDefaultFor as u };
610
342
 
611
- //# sourceMappingURL=fixCrossLanguageReferences-CQGzpNii.js.map
343
+ //# sourceMappingURL=fixCrossLanguageReferences-BZk9CkdI.js.map