@nocode-factory/sanity-kit 2.65.0-rc.5 → 2.65.0-rc.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocode-factory/sanity-kit",
3
- "version": "2.65.0-rc.5",
3
+ "version": "2.65.0-rc.7",
4
4
  "description": "Outils Studio de NoCode Factory : Pages (liste + board), Composants, Historique",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -32,6 +32,9 @@ type Line = {tone: 'positive' | 'caution' | 'critical'; text: string}
32
32
  const EXCLUDED = ['translation.metadata', BOARD_LAYOUT_TYPE, TRANSLATION_TODO_TYPE]
33
33
  const TITLE = 'coalesce(title, name, heading, internalName, slug.current, _id)'
34
34
 
35
+ /** Nom lisible d'une version inachevée (les valeurs par défaut n'ont pas de titre). */
36
+ const label = (t: Todo) => (/componentDefaults/.test(t.documentId) || /componentDefaults/.test(t.title ?? '') ? 'Component defaults' : (t.title ?? t.documentId).replace(/^drafts\./, ''))
37
+
35
38
  /** Erreur lisible pour l'équipe (le service renvoie parfois un message technique). */
36
39
  function explain(error: string): string {
37
40
  const e = error.toLowerCase()
@@ -106,7 +109,12 @@ export function LanguagesSync() {
106
109
  const drafts = others.map((language) => ({language, count: draftOnly.filter((d) => d.language === language).length})).filter((d) => d.count)
107
110
 
108
111
  const defaultsDocs = await client.fetch<Doc[]>(`*[_type == $type && !(_id in path("drafts.**"))]`, {type: defaultsType})
112
+ const defaultsDrafts = await client.fetch<Doc[]>(`*[_type == $type && _id in path("drafts.**")]`, {type: defaultsType})
109
113
  const byLang = (lang: string) => defaultsDocs.find((d) => d[field] === lang) ?? null
114
+ // Version à compléter : le brouillon s'il existe (une traduction en cours de relecture
115
+ // n'est plus « à traduire »), sans les textes déjà repris par « Unfinished translations ».
116
+ const currentOf = (doc: Doc) => defaultsDrafts.find((d) => d._id === `drafts.${String(doc._id)}`) ?? doc
117
+ const inTodo = (doc: Doc) => new Set(unfinished.filter((t) => t.documentId === String(doc._id)).flatMap((t) => t.paths))
110
118
  const sourceLang = byLang(i18n.defaultsSourceLocale) ? i18n.defaultsSourceLocale : main
111
119
  const sourceDoc = byLang(sourceLang)
112
120
  const mainDoc = byLang(main)
@@ -115,7 +123,8 @@ export function LanguagesSync() {
115
123
  // (anglais) est d'abord complétée depuis elle.
116
124
  if (sourceDoc && mainDoc && sourceLang !== main) {
117
125
  const trace = await readTrace(client, String(sourceDoc._id))
118
- const texts = untranslatedPaths(mainDoc, sourceDoc, typeOf(defaultsType), trace).length
126
+ const pending = inTodo(sourceDoc)
127
+ const texts = untranslatedPaths(mainDoc, currentOf(sourceDoc), typeOf(defaultsType), trace).filter((p) => !pending.has(p)).length
119
128
  if (texts) defaults.push({language: sourceLang, exists: true, texts, from: main})
120
129
  }
121
130
  // 2. Puis chaque autre langue depuis la langue source.
@@ -123,7 +132,9 @@ export function LanguagesSync() {
123
132
  for (const language of i18n.locales.filter((l) => l !== sourceLang)) {
124
133
  const doc = byLang(language)
125
134
  const trace = doc ? await readTrace(client, String(doc._id)) : undefined
126
- defaults.push({language, exists: Boolean(doc), texts: untranslatedPaths(sourceDoc, doc, typeOf(defaultsType), trace).length, from: sourceLang})
135
+ const pending = doc ? inTodo(doc) : new Set<string>()
136
+ const texts = untranslatedPaths(sourceDoc, doc ? currentOf(doc) : null, typeOf(defaultsType), trace).filter((p) => !pending.has(p)).length
137
+ defaults.push({language, exists: Boolean(doc), texts, from: sourceLang})
127
138
  }
128
139
  setPlan({missing, unfinished, drafts, defaults})
129
140
  }, [client, defaultsType, field, i18n]) // eslint-disable-line react-hooks/exhaustive-deps
@@ -180,7 +191,7 @@ export function LanguagesSync() {
180
191
  if (pick.unfinished)
181
192
  for (const [n, t] of plan.unfinished.entries()) {
182
193
  setProgress(`Unfinished translations ${n + 1}/${plan.unfinished.length}`)
183
- const what = `${(t.language ?? '').toUpperCase()} « ${t.title ?? t.documentId} »`
194
+ const what = `${(t.language ?? '').toUpperCase()} « ${label(t)} »`
184
195
  if (!t.language) {
185
196
  fail(what, 'language of the translated version unknown')
186
197
  continue
@@ -321,7 +332,7 @@ export function LanguagesSync() {
321
332
  </Text>
322
333
  {plan.unfinished.slice(0, 8).map((t) => (
323
334
  <Text key={t.documentId} size={1} muted>
324
- {(t.language ?? '').toUpperCase()} « {t.title ?? t.documentId} »: {t.paths.length} text{t.paths.length > 1 ? 's' : ''}
335
+ {(t.language ?? '').toUpperCase()} « {label(t)} »: {t.paths.length} text{t.paths.length > 1 ? 's' : ''}
325
336
  </Text>
326
337
  ))}
327
338
  </Stack>
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
4
4
  * le vérifie.
5
5
  */
6
- export const KIT_VERSION = '2.65.0-rc.5'
6
+ export const KIT_VERSION = '2.65.0-rc.7'