@nocode-factory/sanity-kit 2.47.1 → 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.
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixCrossLanguageReferences-BZk9CkdI.js","names":["isObj"],"sources":["../src/lib/translationRedirects.ts","../src/schema/componentDefaults.ts","../src/lib/siteRoutes.ts","../src/schema/sameLanguageReferences.ts","../src/lib/fixCrossLanguageReferences.ts"],"sourcesContent":["import type {SanityClient} from 'sanity'\nimport {toPath} from './paths'\n\ntype Obj = Record<string, unknown>\n\nexport interface TranslationRedirectOptions {\n /** Champ de langue des documents. */\n field?: string\n /** Langue principale : son slug est le slug « d'origine ». */\n defaultLocale: string\n /** Types qui ont une page par document (préfixe d'adresse du registre). */\n types: {type: string; pathPrefix?: string | null; localizedPrefixes?: Record<string, string> | null; slugField?: string}[]\n /** Type de document des redirections (champs from, to, permanent, note). */\n redirectType?: string\n /** `false` : simulation, rien n'est écrit. Défaut : true. */\n apply?: boolean\n}\n\nexport interface TranslationRedirect {\n id: string\n from: string\n to: string\n note: string\n}\n\n/** Identifiant stable de la redirection d'une version (mise à jour, jamais dupliquée). */\nexport const translationRedirectId = (versionId: string) => `redirect-translation-${versionId.replace(/^drafts\\./, '').replace(/[^A-Za-z0-9_-]/g, '-')}`\n\n/**\n * RÈGLE D'OR DU MULTILINGUE, adresses : chaque version a un slug dans SA langue, et\n * l'adresse « slug d'origine dans cette langue » redirige vers elle (une page\n * /rouge, traduite /en/red : /en/rouge redirige vers /en/red). Enregistré comme\n * une vraie redirection (visible dans le Studio, « Redirects »), une par version,\n * mise à jour si un slug change. Rien quand le slug est le même, ni quand l'adresse\n * d'origine est déjà une vraie page de cette langue.\n *\n * `seeds` : documents dont on traite le groupe de traductions (tous si absent).\n * `override` : valeurs d'une version en cours de publication (pas encore lisibles).\n */\nexport async function syncTranslationRedirects(\n client: SanityClient,\n options: TranslationRedirectOptions,\n seeds?: string[],\n override?: {id: string; slug?: string | null; language?: string | null},\n): Promise<TranslationRedirect[]> {\n const field = options.field ?? 'language'\n const redirectType = options.redirectType ?? 'redirect'\n const byType = new Map(options.types.map((t) => [t.type, t]))\n const c = client.withConfig({perspective: 'raw'})\n const types = [...byType.keys()]\n if (!types.length) return []\n\n // Groupes de traductions des types à pages (publiés).\n const groups = await c.fetch<{translations?: {language?: string; _key?: string; value?: {_ref?: string}}[]}[]>(\n seeds?.length\n ? `*[_type == \"translation.metadata\" && count(translations[value._ref in $seeds]) > 0]{translations}`\n : `*[_type == \"translation.metadata\" && count(schemaTypes[@ in $types]) > 0]{translations}`,\n {seeds: (seeds ?? []).map((s) => s.replace(/^drafts\\./, '')), types},\n )\n const ids = [...new Set(groups.flatMap((g) => (g.translations ?? []).map((t) => t.value?._ref).filter((x): x is string => !!x)))]\n if (!ids.length) return []\n const docs = await c.fetch<Obj[]>(`*[_id in $ids]{_id, _type, ${field}, \"slugs\": {\"slug\": slug.current}, title}`, {ids})\n const byId = new Map(docs.map((d) => [String(d._id), d]))\n const slugOf = (d: Obj | undefined) => {\n if (!d) return null\n if (override && d._id === override.id && override.slug !== undefined) return override.slug\n return ((d.slugs as Obj | undefined)?.slug as string | undefined) ?? null\n }\n const langOf = (d: Obj | undefined) => (override && d?._id === override.id && override.language ? override.language : (d?.[field] as string | undefined))\n\n const wanted: TranslationRedirect[] = []\n const stale: string[] = []\n for (const g of groups) {\n const versions = (g.translations ?? []).map((t) => byId.get(t.value?._ref ?? '')).filter((d): d is Obj => !!d)\n const master = versions.find((d) => langOf(d) === options.defaultLocale)\n const masterSlug = slugOf(master)\n for (const v of versions) {\n if (v === master) continue\n const id = translationRedirectId(String(v._id))\n const t = byType.get(String(v._type))\n const language = langOf(v)\n const slug = slugOf(v)\n const from = t && masterSlug && language ? toPath({slug: masterSlug, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes, locale: language}, {field, defaultLocale: options.defaultLocale, locales: [], defaultsSourceLocale: options.defaultLocale}) : null\n const to = t && slug && language ? toPath({slug, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes, locale: language}, {field, defaultLocale: options.defaultLocale, locales: [], defaultsSourceLocale: options.defaultLocale}) : null\n if (!from || !to || from === to) {\n stale.push(id)\n continue\n }\n // L'adresse d'origine est une vraie page de cette langue : pas de redirection.\n const taken = await c.fetch<number>(\n `count(*[_type == $type && ${field} == $language && slug.current == $slug && !(_id in path(\"drafts.**\")) && _id != $self])`,\n {type: v._type, language, slug: masterSlug, self: v._id},\n )\n if (taken) {\n stale.push(id)\n continue\n }\n wanted.push({id, from, to, note: `Created automatically: ${language?.toUpperCase()} version of \"${String(master?.title ?? masterSlug)}\" (translated address)`})\n }\n }\n\n if (options.apply !== false) {\n const tx = c.transaction()\n // Une redirection qui partirait d'une adresse devenue une vraie page est retirée.\n const targets = wanted.map((w) => w.to)\n const loops = targets.length ? await c.fetch<string[]>(`*[_type == $redirectType && from in $targets]._id`, {redirectType, targets}) : []\n for (const id of loops) if (!wanted.some((w) => w.id === id)) tx.delete(id)\n for (const w of wanted) tx.createOrReplace({_id: w.id, _type: redirectType, from: w.from, to: w.to, permanent: true, note: w.note})\n for (const id of stale) tx.delete(id)\n await tx.commit({visibility: 'async'})\n }\n return wanted\n}\n\n/** Options de `syncTranslationRedirects` tirées de la configuration du kit (types à pages avec slug). */\nexport function translationRedirectOptions(config: {\n i18n: {field: string; defaultLocale: string} | null\n pageTypes: {type: string; slugField: string | null; path: string | null; pathPrefix: string | null; localizedPrefixes?: Record<string, string> | null}[]\n}): TranslationRedirectOptions | null {\n if (!config.i18n) return null\n const types = config.pageTypes.filter((t) => t.slugField && !t.path).map((t) => ({type: t.type, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes ?? null, slugField: t.slugField ?? 'slug'}))\n return types.length ? {field: config.i18n.field, defaultLocale: config.i18n.defaultLocale, types} : null\n}\n","import {defineField, defineType, type Rule} from 'sanity'\n\n/**\n * VALEURS PAR DÉFAUT DES COMPOSANTS, côté Studio.\n *\n * Un document (un par langue) avec un bloc par composant de la bibliothèque,\n * GÉNÉRÉ depuis les schémas des sections : une section ajoutée y apparaît sans\n * rien faire. Une instance dont un champ est vide affiche la valeur par défaut ;\n * un champ rempli (override) n'est jamais écrasé. Côté site :\n * `@nocode-factory/sanity-kit/web/defaults`. Dans le Studio, l'onglet Composants\n * ouvre chaque composant (rendu réel + réglages), et une pastille bleue marque\n * chaque champ d'instance qui diffère de la valeur par défaut.\n *\n * Deux règles pour les champs de section, qui en découlent :\n * - jamais d'`initialValue` (ce serait un override involontaire) ;\n * - « obligatoire » = `requiredUnlessDefault`.\n */\n\ntype FieldDef = {name: string; type: string; validation?: unknown; initialValue?: unknown; fields?: FieldDef[]; of?: FieldDef[]; [k: string]: unknown}\ntype SectionDef = {name: string; title?: string; fields: FieldDef[]}\n\nexport const DEFAULT_COMPONENT_DEFAULTS_TYPE = 'componentDefaults'\n\n/** Nom du champ d'un composant dans le document des valeurs par défaut : `section.cta` -> `cta`. */\nexport function defaultsFieldName(type: string, namespace = 'section.'): string {\n return type.startsWith(namespace) ? type.slice(namespace.length) : type\n}\n\n// Dans les valeurs par défaut, rien n'est obligatoire et rien n'est prérempli.\nconst relax = (f: FieldDef): FieldDef => {\n const {validation: _v, initialValue: _i, ...rest} = f\n return {\n ...rest,\n ...(rest.fields ? {fields: rest.fields.map(relax)} : {}),\n ...(rest.of ? {of: rest.of.map(relax)} : {}),\n }\n}\n\n/** Document « Composants : valeurs par défaut », généré depuis les sections. */\nexport function defineComponentDefaults(options: {sections: readonly unknown[]; name?: string; title?: string; namespace?: string}) {\n const {name = DEFAULT_COMPONENT_DEFAULTS_TYPE, title = '🧩 Components: default values', namespace = 'section.'} = options\n return defineType({\n name,\n title,\n type: 'document',\n description:\n 'Values applied to every instance of a component whose field is empty. A field filled in an instance takes precedence (override).',\n fields: (options.sections as SectionDef[]).map((t) =>\n defineField({\n name: defaultsFieldName(t.name, namespace),\n title: t.title || t.name,\n type: 'object',\n description: 'Default values of this component. Empty = design system value.',\n options: {collapsible: true, collapsed: true},\n // Un champ propre à l'instance (options.instanceOnly, ex. ancre) n'a pas de\n // valeur par défaut : absent des réglages du composant.\n fields: t.fields.filter((f) => !(f.options as {instanceOnly?: boolean} | undefined)?.instanceOnly).map(relax) as never,\n }),\n ),\n preview: {prepare: () => ({title: title.replace(/^\\S+\\s/, '')})},\n })\n}\n\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)\n\n/**\n * Règle « obligatoire SAUF si le composant a une valeur par défaut » pour un autre\n * type de document des valeurs par défaut ou un autre espace de noms.\n * `validation: requiredUnlessDefaultFor({type: 'mesDefauts'})`\n */\nexport function requiredUnlessDefaultFor(options: {type?: string; namespace?: string} = {}) {\n const {type: defaultsType = DEFAULT_COMPONENT_DEFAULTS_TYPE, namespace = 'section.'} = options\n return <R>(rule: R): R =>\n (rule as unknown as Rule).custom(async (value, context) => {\n if (!isEmpty(value)) return true\n const type = (context.parent as {_type?: string} | undefined)?._type\n const field = context.path?.[context.path.length - 1]\n const name = type ? defaultsFieldName(type, namespace) : ''\n if (!type?.startsWith(namespace) || typeof field !== 'string' || !/^\\w+$/.test(name) || !/^\\w+$/.test(field)) return 'Required.'\n const language = (context.document as {language?: string} | undefined)?.language ?? null\n const inherited = await context\n .getClient({apiVersion: '2024-10-01'})\n .fetch(\n `*[_type == $defaultsType && !(_id in path(\"drafts.**\")) && ($language == null || language == $language)][0].${name}.${field}`,\n {defaultsType, language},\n )\n return isEmpty(inherited) ? 'Required (or set it in Components > default values).' : true\n }) as unknown as R\n}\n\n/**\n * Champ de section obligatoire, SAUF si le composant a une valeur par défaut\n * pour ce champ (elle s'affichera). Tout type de champ.\n * `validation: requiredUnlessDefault`\n */\nexport const requiredUnlessDefault: <R>(rule: R) => R = requiredUnlessDefaultFor()\n\n/**\n * Presentation : la page qui rend un composant seul (par défaut\n * `/design-system/composant`) a pour document principal les valeurs par défaut.\n * Rendu réel et réglages côte à côte, en direct.\n * `presentationTool({resolve: {mainDocuments: defineDocuments([componentDefaultsMainDocument({language: 'fr'})])}})`\n */\nexport function componentDefaultsMainDocument(options: {language?: string; route?: string; type?: string} = {}): {route: string; filter: string} {\n const {language, route = '/design-system/composant', type = DEFAULT_COMPONENT_DEFAULTS_TYPE} = options\n const safeLang = language && /^[a-z]{2}(-[A-Za-z]{2})?$/.test(language) ? language : null\n return {route, filter: `_type == \"${type}\"${safeLang ? ` && language == \"${safeLang}\"` : ''}`}\n}\n\n/**\n * Presentation : les pages du design system ont pour document principal les valeurs\n * par défaut des composants. `/design-system` (toute la bibliothèque) et\n * `/design-system/composant` (un composant seul) : cliquer un composant ouvre ses\n * réglages globaux, et un style changé change le composant partout où il n'est\n * pas surchargé.\n * `presentationTool({resolve: {mainDocuments: defineDocuments(componentDefaultsMainDocuments({language: 'fr'}))}})`\n */\nexport function componentDefaultsMainDocuments(\n options: {language?: string; type?: string; routes?: string[]} = {},\n): {route: string; filter: string}[] {\n const {routes = ['/design-system/composant', '/design-system'], ...rest} = options\n return routes.map((route) => componentDefaultsMainDocument({...rest, route}))\n}\n","import type {NcfPageTypeInput} from '../config/types'\n\n/**\n * Registre des pages du starter NoCode Factory (`web/app/lib/site-routes.json`).\n * Seules les clés lues ici sont typées : le fichier en porte d'autres\n * (sections, titres, noindex) qui ne concernent pas le kit.\n */\nexport interface SiteRoutesRegistry {\n fixed?: {path: string; homePage?: boolean; system?: boolean; notFound?: boolean; pageSlug?: string; localized?: Record<string, string>}[]\n collections?: {type: string; pathPrefix?: string; localized?: Record<string, string>}[]\n}\n\n/**\n * `pageTypes` déduits du registre du starter, pour ne pas redire au kit ce que\n * le site sait déjà : l'accueil (chemin fixe `/`) et chaque collection avec\n * son préfixe d'URL (`/blog`, `/produits`, ou la racine).\n *\n * ```ts\n * import routes from '../web/app/lib/site-routes.json'\n * ncfKit({pageTypes: pageTypesFromSiteRoutes(routes)})\n * ```\n *\n * `homePageType` : nom du type de l'accueil dans le schéma (le registre ne le\n * porte pas). Les pages codées du registre (`pageSlug`) ne sont pas des types :\n * elles n'apparaissent pas ici.\n */\nexport function pageTypesFromSiteRoutes(\n routes: SiteRoutesRegistry,\n options: {homePageType?: string | null} = {},\n): NcfPageTypeInput[] {\n const homePageType = options.homePageType === undefined ? 'homePage' : options.homePageType\n const out: NcfPageTypeInput[] = []\n\n if (homePageType && routes.fixed?.some((r) => r.homePage)) {\n out.push({type: homePageType, path: '/'})\n }\n for (const collection of routes.collections ?? []) {\n if (!collection.type) continue\n const prefix = (collection.pathPrefix ?? '').trim()\n const localized = collection.localized && Object.keys(collection.localized).length ? {localizedPrefixes: collection.localized} : {}\n out.push(prefix ? {type: collection.type, pathPrefix: prefix, ...localized} : {type: collection.type, ...localized})\n }\n return out\n}\n","import type {NcfKitConfig} from '../config/types'\n\ntype Obj = Record<string, unknown>\ntype FilterResult = {filter?: string; params?: Record<string, unknown>}\ntype FilterFn = (context: {document?: Obj; [key: string]: unknown}) => FilterResult | Promise<FilterResult>\n\n// Objet de configuration simple (jamais un élément React, une icône ou une instance).\nconst isObj = (v: unknown): v is Obj => {\n if (!v || typeof v !== 'object' || Array.isArray(v) || '$$typeof' in v) return false\n const proto = Object.getPrototypeOf(v)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * RÈGLE D'OR DU MULTILINGUE : une référence ne propose que des documents de la\n * MÊME langue que le document en cours (un article EN ne voit que les catégories EN,\n * une page FR que les pages FR). Les documents sans langue (logos, régions, assets…)\n * restent proposés. Un document commun à toutes les langues (Navigation…) vise la\n * langue principale.\n *\n * Pose ce filtre sur TOUS les champs de référence des types donnés (champs, listes,\n * objets imbriqués, annotations du texte riche), combiné avec un filtre déjà présent.\n * À appliquer aux types du projet :\n *\n * ```ts\n * schema: {types: withSameLanguageReferences(schemaTypes, ncfOptions)}\n * ```\n */\nexport function withSameLanguageReferences<T>(types: T[], options: Pick<NcfKitConfig, 'i18n'>): T[] {\n const i18n = options.i18n\n if (!i18n) return types\n const field = i18n.field ?? 'language'\n const fallback = i18n.defaultLocale ?? i18n.locales?.[0]\n const condition = `(!defined(${field}) || ${field} == $ncfLanguage)`\n const languageOf = (document: Obj | undefined) => (typeof document?.[field] === 'string' && document[field]) || fallback\n\n const wrap = (opts: Obj | undefined): Obj => {\n const previous = opts?.filter\n const previousParams = (opts?.filterParams as Record<string, unknown> | undefined) ?? {}\n const filter: FilterFn = async (context) => {\n const base: FilterResult =\n typeof previous === 'function'\n ? ((await (previous as FilterFn)(context)) ?? {})\n : typeof previous === 'string'\n ? {filter: previous, params: previousParams}\n : {}\n return {\n filter: base.filter ? `(${base.filter}) && ${condition}` : condition,\n params: {...(base.params ?? {}), ncfLanguage: languageOf(context.document)},\n }\n }\n const {filterParams: _ignored, ...rest} = opts ?? {}\n return {...rest, filter}\n }\n\n const visit = (node: unknown): unknown => {\n if (Array.isArray(node)) return node.map(visit)\n if (!isObj(node)) return node\n const out: Obj = {}\n for (const [key, value] of Object.entries(node)) out[key] = key === 'options' || key === 'initialValue' || key === 'validation' ? value : visit(value)\n if (node.type === 'reference' && Array.isArray(node.to)) out.options = wrap(node.options as Obj | undefined)\n return out\n }\n return types.map((t) => visit(t) as T)\n}\n","import type {SanityClient} from 'sanity'\n\ntype Obj = Record<string, unknown>\nconst isObj = (v: unknown): v is Obj => !!v && typeof v === 'object' && !Array.isArray(v)\nconst bare = (id: string) => id.replace(/^drafts\\./, '')\n\nexport interface CrossLanguageReport {\n /** Références repointées (ou à repointer en simulation). */\n fixed: {documentId: string; path: string; from: string; to: string}[]\n /** Références croisées sans équivalent dans la langue du document (laissées). */\n missing: {documentId: string; path: string; ref: string; language: string}[]\n}\n\n/** Références d'une valeur, avec leur chemin de patch (`a.b[_key==\"x\"].c`). */\nfunction refs(value: unknown, path: string, out: {path: string; ref: string}[]) {\n if (Array.isArray(value)) {\n value.forEach((item, i) => refs(item, `${path}[${isObj(item) && typeof item._key === 'string' ? `_key==\"${item._key}\"` : i}]`, out))\n return\n }\n if (!isObj(value)) return\n if (typeof value._ref === 'string' && !/^(image|file)-/.test(value._ref)) out.push({path: `${path}._ref`, ref: value._ref})\n for (const [k, v] of Object.entries(value)) if (!k.startsWith('_')) refs(v, path ? `${path}.${k}` : k, out)\n}\n\n/**\n * RÈGLE D'OR DU MULTILINGUE, côté données : chaque référence d'un document vise un\n * document de SA langue (document sans langue : la langue principale). Une\n * référence croisée est repointée vers la traduction de la bonne langue (liens de\n * traduction) ; sans traduction, elle est signalée et laissée. Publiés et\n * brouillons. `apply: false` : simulation.\n *\n * ```ts\n * // studio/scripts/references-same-language.ts (sanity exec --with-user-token)\n * const report = await fixCrossLanguageReferences(getCliClient(...), {defaultLocale: 'fr', apply})\n * ```\n */\nexport async function fixCrossLanguageReferences(\n client: SanityClient,\n options: {field?: string; defaultLocale: string; apply?: boolean},\n): Promise<CrossLanguageReport> {\n const field = options.field ?? 'language'\n const c = client.withConfig({perspective: 'raw'})\n const docs = await c.fetch<Obj[]>(\n `*[!(_type match \"system.*\") && !(_type match \"sanity.*\") && !(_type match \"ncf.*\") && _type != \"translation.metadata\"]`,\n )\n const language = new Map<string, string>()\n for (const d of docs) if (typeof d[field] === 'string') language.set(bare(String(d._id)), String(d[field]))\n const metas = await c.fetch<{translations?: {language?: string; _key?: string; value?: {_ref?: string}}[]}[]>(\n `*[_type == \"translation.metadata\"]{translations}`,\n )\n const equivalent = new Map<string, Map<string, string>>()\n for (const m of metas) {\n const group = new Map<string, string>()\n for (const t of m.translations ?? []) if (t.value?._ref) group.set(t.language ?? t._key ?? '', t.value._ref)\n for (const id of group.values()) equivalent.set(id, group)\n }\n\n const report: CrossLanguageReport = {fixed: [], missing: []}\n for (const d of docs) {\n const own = typeof d[field] === 'string' ? String(d[field]) : options.defaultLocale\n const found: {path: string; ref: string}[] = []\n for (const [k, v] of Object.entries(d)) if (!k.startsWith('_')) refs(v, k, found)\n const set: Record<string, string> = {}\n for (const {path, ref} of found) {\n const target = language.get(bare(ref))\n if (!target || target === own) continue\n const to = equivalent.get(bare(ref))?.get(own)\n if (to) {\n set[path] = to\n report.fixed.push({documentId: String(d._id), path, from: ref, to})\n } else report.missing.push({documentId: String(d._id), path, ref, language: own})\n }\n if (options.apply && Object.keys(set).length) await c.patch(String(d._id)).ifRevisionId(String(d._rev)).set(set).commit({visibility: 'async'})\n }\n return report\n}\n"],"mappings":";;;AA0BA,MAAa,yBAAyB,cAAsB,wBAAwB,UAAU,QAAQ,aAAa,EAAE,CAAC,CAAC,QAAQ,mBAAmB,GAAG;;;;;;;;;;;;AAarJ,eAAsB,yBACpB,QACA,SACA,OACA,UACgC;CAChC,IAAM,QAAQ,QAAQ,SAAS,YACzB,eAAe,QAAQ,gBAAgB,YACvC,SAAS,IAAI,IAAI,QAAQ,MAAM,KAAK,MAAM,CAAC,EAAE,MAAM,CAAC,C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AAK;CAC3D;CAEA,IAAM,SAA8B;EAAC,OAAO,CAAC;EAAG,SAAS,CAAC;CAAC;CAC3D,KAAK,IAAM,KAAK,MAAM;EACpB,IAAM,MAAM,OAAO,EAAE,UAAW,WAAW,OAAO,EAAE,MAAM,IAAI,QAAQ,eAChE,QAAuC,CAAC;EAC9C,KAAK,IAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,CAAC,GAAG,AAAK,EAAE,WAAW,GAAG,KAAG,KAAK,GAAG,GAAG,KAAK;EAChF,IAAM,MAA8B,CAAC;EACrC,KAAK,IAAM,EAAC,MAAM,SAAQ,OAAO;GAC/B,IAAM,SAAS,SAAS,IAAI,KAAK,GAAG,CAAC;GACrC,IAAI,CAAC,UAAU,WAAW,KAAK;GAC/B,IAAM,KAAK,WAAW,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG;GAC7C,AAAI,MACF,IAAI,QAAQ,IACZ,OAAO,MAAM,KAAK;IAAC,YAAY,OAAO,EAAE,GAAG;IAAG;IAAM,MAAM;IAAK;GAAE,CAAC,KAC7D,OAAO,QAAQ,KAAK;IAAC,YAAY,OAAO,EAAE,GAAG;IAAG;IAAM;IAAK,UAAU;GAAG,CAAC;EAClF;EACA,AAAI,QAAQ,SAAS,OAAO,KAAK,GAAG,CAAC,CAAC,UAAQ,MAAM,EAAE,MAAM,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,aAAa,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,EAAC,YAAY,QAAO,CAAC;CAC/I;CACA,OAAO;AACT"}
@@ -84,6 +84,20 @@ interface NcfHistoryConfig {
84
84
  /** Base des Edge Functions. Par défaut, le service du kit. */
85
85
  endpoint?: string;
86
86
  }
87
+ /** Données structurées (JSON-LD) générées par IA. */
88
+ interface NcfJsonLdConfig {
89
+ /**
90
+ * Active la génération par IA : bouton « Rédiger avec l'IA » sur le champ et
91
+ * régénération à la publication des pages en mode auto. Nécessite le service
92
+ * du kit (`history.projectKey`) ; sans lui, rien n'est branché.
93
+ */
94
+ enabled?: boolean;
95
+ /**
96
+ * Nom du champ objet qui porte le mode (auto/manuel) et le JSON-LD stocké.
97
+ * Défaut : 'jsonLd'.
98
+ */
99
+ field?: string;
100
+ }
87
101
  /** Étiquette de suivi posable sur une page dans le board. */
88
102
  interface NcfBoardTag {
89
103
  /** Identifiant stable, enregistré dans le document de disposition. */
@@ -220,6 +234,8 @@ interface NcfKitConfig {
220
234
  i18n?: NcfI18nConfig | false;
221
235
  componentPreview?: NcfComponentPreviewConfig;
222
236
  history?: NcfHistoryConfig;
237
+ /** Données structurées (JSON-LD) générées par IA sur les pages. */
238
+ jsonLd?: NcfJsonLdConfig;
223
239
  /**
224
240
  * Base des Edge Functions du kit, pour l'enregistrement et l'historique.
225
241
  * `false` coupe tout appel sortant, y compris le signalement de présence.
@@ -293,6 +309,8 @@ interface ResolvedKitConfig {
293
309
  i18n: ResolvedI18n | null;
294
310
  componentPreview: ResolvedComponentPreview;
295
311
  history: ResolvedHistory | null;
312
+ /** `null` quand le JSON-LD IA est désactivé ou que le service du kit manque. */
313
+ jsonLd: ResolvedJsonLd | null;
296
314
  /** `null` quand on a explicitement coupé les appels sortants. */
297
315
  serviceEndpoint: string | null;
298
316
  tools: Required<NcfToolsConfig>;
@@ -306,6 +324,10 @@ interface ResolvedHistory {
306
324
  projectKey: string;
307
325
  endpoint: string;
308
326
  }
327
+ interface ResolvedJsonLd {
328
+ /** Nom du champ objet qui porte le mode et le JSON-LD stocké. */
329
+ field: string;
330
+ }
309
331
  interface ResolvedDocumentColumn {
310
332
  key: string;
311
333
  label: string;
@@ -499,4 +521,4 @@ declare function fixCrossLanguageReferences(client: SanityClient, options: {
499
521
  apply?: boolean;
500
522
  }): Promise<CrossLanguageReport>;
501
523
  export { ResolvedDocumentColumn as A, NcfInternalFieldOption as C, NcfToolName as D, NcfPageTypeInput as E, ResolvedI18n as M, ResolvedKitConfig as N, NcfToolsConfig as O, ResolvedPageType as P, NcfInternalField as S, NcfPageTypeConfig as T, NcfComponentPreviewConfig as _, pageTypesFromSiteRoutes as a, NcfHistoryConfig as b, componentDefaultsMainDocuments as c, requiredUnlessDefault as d, requiredUnlessDefaultFor as f, NcfBoardTag as g, KitContextValue as h, SiteRoutesRegistry as i, ResolvedHistory as j, ResolvedComponentPreview as k, defaultsFieldName as l, IssueLevel as m, fixCrossLanguageReferences as n, DEFAULT_COMPONENT_DEFAULTS_TYPE as o, ConfigIssue as p, withSameLanguageReferences as r, componentDefaultsMainDocument as s, CrossLanguageReport as t, defineComponentDefaults as u, NcfDocumentColumn as v, NcfKitConfig as w, NcfI18nConfig as x, NcfEnvironment as y };
502
- //# sourceMappingURL=fixCrossLanguageReferences-CFZax-Nb.d.ts.map
524
+ //# sourceMappingURL=fixCrossLanguageReferences-CjL_Xy0U.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as CodeEmbedTypeOptions, i as codeEditorInput, n as CodeEditorInput, o as defineCodeEmbedType, r as CodeLanguage, t as CodeEmbedInput } from "./CodeEmbedInput-CobMRQ5s.js";
2
- import { A as ResolvedDocumentColumn, C as NcfInternalFieldOption, D as NcfToolName, E as NcfPageTypeInput, M as ResolvedI18n, N as ResolvedKitConfig, O as NcfToolsConfig, P as ResolvedPageType, S as NcfInternalField, T as NcfPageTypeConfig, _ as NcfComponentPreviewConfig, a as pageTypesFromSiteRoutes, b as NcfHistoryConfig, c as componentDefaultsMainDocuments, d as requiredUnlessDefault, f as requiredUnlessDefaultFor, g as NcfBoardTag, h as KitContextValue, i as SiteRoutesRegistry, j as ResolvedHistory, k as ResolvedComponentPreview, l as defaultsFieldName, m as IssueLevel, n as fixCrossLanguageReferences, o as DEFAULT_COMPONENT_DEFAULTS_TYPE, p as ConfigIssue, r as withSameLanguageReferences, s as componentDefaultsMainDocument, t as CrossLanguageReport, u as defineComponentDefaults, v as NcfDocumentColumn, w as NcfKitConfig, x as NcfI18nConfig, y as NcfEnvironment } from "./fixCrossLanguageReferences-CFZax-Nb.js";
2
+ import { A as ResolvedDocumentColumn, C as NcfInternalFieldOption, D as NcfToolName, E as NcfPageTypeInput, M as ResolvedI18n, N as ResolvedKitConfig, O as NcfToolsConfig, P as ResolvedPageType, S as NcfInternalField, T as NcfPageTypeConfig, _ as NcfComponentPreviewConfig, a as pageTypesFromSiteRoutes, b as NcfHistoryConfig, c as componentDefaultsMainDocuments, d as requiredUnlessDefault, f as requiredUnlessDefaultFor, g as NcfBoardTag, h as KitContextValue, i as SiteRoutesRegistry, j as ResolvedHistory, k as ResolvedComponentPreview, l as defaultsFieldName, m as IssueLevel, n as fixCrossLanguageReferences, o as DEFAULT_COMPONENT_DEFAULTS_TYPE, p as ConfigIssue, r as withSameLanguageReferences, s as componentDefaultsMainDocument, t as CrossLanguageReport, u as defineComponentDefaults, v as NcfDocumentColumn, w as NcfKitConfig, x as NcfI18nConfig, y as NcfEnvironment } from "./fixCrossLanguageReferences-CjL_Xy0U.js";
3
3
  import { ComponentType, ReactNode } from "react";
4
4
  import { LayoutProps, SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
5
5
  import { PreviewHeaderProps } from "sanity/presentation";
@@ -1065,7 +1065,7 @@ export declare function ActorName(props: {
1065
1065
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1066
1066
  * le vérifie.
1067
1067
  */
1068
- export declare const KIT_VERSION = "2.47.1";
1068
+ export declare const KIT_VERSION = "2.48.0";
1069
1069
  /**
1070
1070
  * Données de la page proposées comme colonnes.
1071
1071
  *