@nocode-factory/sanity-kit 2.35.0 → 2.37.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.
package/bin/ncf-kit.mjs CHANGED
@@ -303,6 +303,9 @@ async function doctor() {
303
303
  const config = ['sanity.config.ts', 'sanity.config.tsx', 'sanity.config.js'].map((f) => read(join(studio, f))).find(Boolean) ?? ''
304
304
  if (!config.includes('ncfKit(')) ko('Plugin', 'ncfKit(...) absent de sanity.config')
305
305
  else ok('Plugin', 'ncfKit branché')
306
+ if (/locales|i18n/.test(config) && !config.includes('withSameLanguageReferences('))
307
+ ko('Références de la même langue', "règle d'or du multilingue : le kit a besoin de withSameLanguageReferences sur les types du projet pour que chaque référence ne propose que des documents de la même langue ; le projet ne l'a pas : schema: {types: withSameLanguageReferences(schemaTypes, ncfOptions)}.")
308
+ else if (config.includes('withSameLanguageReferences(')) ok('Références de la même langue', 'withSameLanguageReferences')
306
309
  if (!config.includes('ncfPresentationComponents('))
307
310
  warn('Presentation : liste des pages', "le kit a besoin de ncfPresentationComponents dans presentationTool pour afficher la liste des pages à gauche de l'aperçu ; le projet ne l'a pas : presentationTool({components: ncfPresentationComponents(ncfOptions), ...}).")
308
311
  else ok('Presentation : liste des pages', 'ncfPresentationComponents')
package/dist/index.d.ts CHANGED
@@ -1134,6 +1134,55 @@ interface PreviewTargetState {
1134
1134
  isProduction: boolean;
1135
1135
  }
1136
1136
  export declare function usePreviewTarget(): PreviewTargetState;
1137
+ /**
1138
+ * RÈGLE D'OR DU MULTILINGUE : une référence ne propose que des documents de la
1139
+ * MÊME langue que le document en cours (un article EN ne voit que les catégories EN,
1140
+ * une page FR que les pages FR). Les documents sans langue (logos, régions, assets…)
1141
+ * restent proposés. Un document commun à toutes les langues (Navigation…) vise la
1142
+ * langue principale.
1143
+ *
1144
+ * Pose ce filtre sur TOUS les champs de référence des types donnés (champs, listes,
1145
+ * objets imbriqués, annotations du texte riche), combiné avec un filtre déjà présent.
1146
+ * À appliquer aux types du projet :
1147
+ *
1148
+ * ```ts
1149
+ * schema: {types: withSameLanguageReferences(schemaTypes, ncfOptions)}
1150
+ * ```
1151
+ */
1152
+ export declare function withSameLanguageReferences<T>(types: T[], options: Pick<NcfKitConfig, 'i18n'>): T[];
1153
+ interface CrossLanguageReport {
1154
+ /** Références repointées (ou à repointer en simulation). */
1155
+ fixed: {
1156
+ documentId: string;
1157
+ path: string;
1158
+ from: string;
1159
+ to: string;
1160
+ }[];
1161
+ /** Références croisées sans équivalent dans la langue du document (laissées). */
1162
+ missing: {
1163
+ documentId: string;
1164
+ path: string;
1165
+ ref: string;
1166
+ language: string;
1167
+ }[];
1168
+ }
1169
+ /**
1170
+ * RÈGLE D'OR DU MULTILINGUE, côté données : chaque référence d'un document vise un
1171
+ * document de SA langue (document sans langue : la langue principale). Une
1172
+ * référence croisée est repointée vers la traduction de la bonne langue (liens de
1173
+ * traduction) ; sans traduction, elle est signalée et laissée. Publiés et
1174
+ * brouillons. `apply: false` : simulation.
1175
+ *
1176
+ * ```ts
1177
+ * // studio/scripts/references-same-language.ts (sanity exec --with-user-token)
1178
+ * const report = await fixCrossLanguageReferences(getCliClient(...), {defaultLocale: 'fr', apply})
1179
+ * ```
1180
+ */
1181
+ export declare function fixCrossLanguageReferences(client: SanityClient, options: {
1182
+ field?: string;
1183
+ defaultLocale: string;
1184
+ apply?: boolean;
1185
+ }): Promise<CrossLanguageReport>;
1137
1186
  /**
1138
1187
  * Bascule brouillons / en ligne, posée dans l'aperçu lui-même.
1139
1188
  *
@@ -1389,7 +1438,7 @@ export declare function ActorName(props: {
1389
1438
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1390
1439
  * le vérifie.
1391
1440
  */
1392
- export declare const KIT_VERSION = "2.35.0";
1441
+ export declare const KIT_VERSION = "2.37.0";
1393
1442
  /**
1394
1443
  * Données de la page proposées comme colonnes.
1395
1444
  *
@@ -1885,5 +1934,5 @@ export declare const NCF_HISTORY_TOOL = "ncf-history";
1885
1934
  export declare const NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system";
1886
1935
  export declare const NCF_TOOL_NAMES: readonly ["ncf-pages", "ncf-components", "ncf-history", "ncf-design-system"];
1887
1936
  export declare const ncfKit: import("sanity").Plugin<NcfKitConfig>;
1888
- export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, DEFAULT_COMPONENT_DEFAULTS_TYPE, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MainDocumentRoute, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc, componentDefaultsMainDocument, componentDefaultsMainDocuments, defaultsFieldName, defineComponentDefaults, requiredUnlessDefault, requiredUnlessDefaultFor };
1937
+ export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, type CrossLanguageReport, DEFAULT_COMPONENT_DEFAULTS_TYPE, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MainDocumentRoute, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc, componentDefaultsMainDocument, componentDefaultsMainDocuments, defaultsFieldName, defineComponentDefaults, requiredUnlessDefault, requiredUnlessDefaultFor };
1889
1938
  //# sourceMappingURL=index.d.ts.map