@sanity/document-internationalization 0.0.1-beta.1

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 (91) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +30 -0
  3. package/config.dist.json +4 -0
  4. package/lib/actions/DeleteWithi18nAction.d.ts +16 -0
  5. package/lib/actions/DuplicateWithi18nAction.d.ts +8 -0
  6. package/lib/actions/PublishWithi18nAction.d.ts +9 -0
  7. package/lib/actions/index.d.ts +8 -0
  8. package/lib/actions/index.js +19549 -0
  9. package/lib/actions/index.js.map +1 -0
  10. package/lib/badges/LanguageBadge.d.ts +5 -0
  11. package/lib/badges/index.d.ts +5 -0
  12. package/lib/badges/index.js +17324 -0
  13. package/lib/badges/index.js.map +1 -0
  14. package/lib/constants/I18nDelimiter.d.ts +1 -0
  15. package/lib/constants/I18nPrefix.d.ts +1 -0
  16. package/lib/constants/IdStructure.d.ts +4 -0
  17. package/lib/constants/LanguageCultures.d.ts +4 -0
  18. package/lib/constants/ReferenceBehavior.d.ts +5 -0
  19. package/lib/constants/UiMessages.d.ts +34 -0
  20. package/lib/constants/index.d.ts +6 -0
  21. package/lib/constants/index.js +736 -0
  22. package/lib/constants/index.js.map +1 -0
  23. package/lib/structure/IDefaultDocumentNodeStructureProps.d.ts +4 -0
  24. package/lib/structure/components/Flag/Flag.d.ts +6 -0
  25. package/lib/structure/components/Flag/allEmojiFlagCodes.d.ts +1 -0
  26. package/lib/structure/components/Flag/index.d.ts +1 -0
  27. package/lib/structure/components/MaintenanceTab/MaintenanceTab.d.ts +2 -0
  28. package/lib/structure/components/MaintenanceTab/index.d.ts +1 -0
  29. package/lib/structure/components/MaintenanceTabResult/MaintenanceTabResult.d.ts +10 -0
  30. package/lib/structure/components/MaintenanceTabResult/index.d.ts +1 -0
  31. package/lib/structure/components/MaintenanceTabTypeSelector/MaintenanceTabTypeSelector.d.ts +8 -0
  32. package/lib/structure/components/MaintenanceTabTypeSelector/index.d.ts +1 -0
  33. package/lib/structure/components/TranslationLink/TranslationLink.d.ts +12 -0
  34. package/lib/structure/components/TranslationLink/index.d.ts +1 -0
  35. package/lib/structure/components/TranslationsComponentFactory/TranslationsComponentFactory.d.ts +5 -0
  36. package/lib/structure/components/TranslationsComponentFactory/index.d.ts +1 -0
  37. package/lib/structure/hooks/index.d.ts +1 -0
  38. package/lib/structure/hooks/useDocumentsInformation.d.ts +20 -0
  39. package/lib/structure/index.d.ts +13 -0
  40. package/lib/structure/index.js +20464 -0
  41. package/lib/structure/index.js.map +1 -0
  42. package/lib/structure/utils/fixBaseDocumentRefs.d.ts +2 -0
  43. package/lib/structure/utils/fixBaseLanguageMismatch.d.ts +2 -0
  44. package/lib/structure/utils/fixIdStructureMismatchDocuments.d.ts +2 -0
  45. package/lib/structure/utils/fixLanguageFields.d.ts +2 -0
  46. package/lib/structure/utils/fixOrphanedDocuments.d.ts +2 -0
  47. package/lib/structure/utils/fixReferenceBehaviorMismatch.d.ts +2 -0
  48. package/lib/structure/utils/fixTranslationRefs.d.ts +2 -0
  49. package/lib/structure/utils/index.d.ts +6 -0
  50. package/lib/types/IEditState.d.ts +5 -0
  51. package/lib/types/ILanguageObject.d.ts +6 -0
  52. package/lib/types/ILanguageQuery.d.ts +10 -0
  53. package/lib/types/IResolverProps.d.ts +9 -0
  54. package/lib/types/ITranslationRef.d.ts +6 -0
  55. package/lib/types/IType.d.ts +38 -0
  56. package/lib/types/IUseDocumentOperationResult.d.ts +11 -0
  57. package/lib/types/TFieldNamesConfig.d.ts +5 -0
  58. package/lib/types/TLanguage.d.ts +2 -0
  59. package/lib/types/TLanguagesOption.d.ts +3 -0
  60. package/lib/types/TSchema.d.ts +6 -0
  61. package/lib/types/Ti18nConfig.d.ts +10 -0
  62. package/lib/types/Ti18nDocument.d.ts +13 -0
  63. package/lib/types/Ti18nSchema.d.ts +5 -0
  64. package/lib/types/index.d.ts +14 -0
  65. package/lib/utils/baseToTop.d.ts +1 -0
  66. package/lib/utils/batch.d.ts +1 -0
  67. package/lib/utils/buildDocId.d.ts +1 -0
  68. package/lib/utils/createSanityReference.d.ts +5 -0
  69. package/lib/utils/getAllSchemas.d.ts +2 -0
  70. package/lib/utils/getBaseIdFromId.d.ts +1 -0
  71. package/lib/utils/getBaseLanguage.d.ts +2 -0
  72. package/lib/utils/getConfig.d.ts +6 -0
  73. package/lib/utils/getFlag.d.ts +2 -0
  74. package/lib/utils/getLanguageFromId.d.ts +1 -0
  75. package/lib/utils/getLanguagesFromOption.d.ts +3 -0
  76. package/lib/utils/getSanityClient.d.ts +1 -0
  77. package/lib/utils/getSchema.d.ts +2 -0
  78. package/lib/utils/getTranslationsForId.d.ts +2 -0
  79. package/lib/utils/index.d.ts +16 -0
  80. package/lib/utils/index.js +18425 -0
  81. package/lib/utils/index.js.map +1 -0
  82. package/lib/utils/makeObjectKey.d.ts +1 -0
  83. package/lib/utils/normalizeLanguageList.d.ts +6 -0
  84. package/lib/utils/serializePath.d.ts +2 -0
  85. package/lib/utils/updateIntlFieldsForDocument.d.ts +2 -0
  86. package/lib/validators/index.d.ts +1 -0
  87. package/lib/validators/index.js +17309 -0
  88. package/lib/validators/index.js.map +1 -0
  89. package/lib/validators/isSlugUnique.d.ts +2 -0
  90. package/package.json +151 -0
  91. package/sanity.json +28 -0
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixBaseDocumentRefs: (schema: string, translatedDocuments: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixBaseLanguageMismatch: (schema: string, basedocuments: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixIdStructureMismatchDocuments: (schema: string, documents: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixLanguageFields: (schema: string, documents: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixOrphanedDocuments: (basedocuments: Ti18nDocument[], translatedDocuments: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixReferenceBehaviorMismatch: (schema: string, baseDocuments: Ti18nDocument[], translatedDocuments: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Ti18nDocument } from '../../types';
2
+ export declare const fixTranslationRefs: (schema: string, baseDocuments: Ti18nDocument[], translatedDocuments: Ti18nDocument[]) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ export * from './fixIdStructureMismatchDocuments';
2
+ export * from './fixLanguageFields';
3
+ export * from './fixTranslationRefs';
4
+ export * from './fixOrphanedDocuments';
5
+ export * from './fixBaseLanguageMismatch';
6
+ export * from './fixBaseDocumentRefs';
@@ -0,0 +1,5 @@
1
+ import type { SanityDocument } from '@sanity/client';
2
+ export interface IEditState<T extends Record<string, any> = Record<string, any>> {
3
+ draft?: SanityDocument<T>;
4
+ published?: SanityDocument<T>;
5
+ }
@@ -0,0 +1,6 @@
1
+ export interface ILanguageObject {
2
+ id: string;
3
+ title: string;
4
+ isCurrentLanguage?: boolean;
5
+ isBase?: boolean;
6
+ }
@@ -0,0 +1,10 @@
1
+ export interface ILanguageQuery {
2
+ query: string;
3
+ value: string | {
4
+ id: string;
5
+ title: string;
6
+ } | {
7
+ name: string;
8
+ title: string;
9
+ };
10
+ }
@@ -0,0 +1,9 @@
1
+ import { SanityDocument } from '@sanity/client';
2
+ export interface IResolverProps<T = any> {
3
+ id: string;
4
+ type: string;
5
+ liveEdit: boolean;
6
+ draft?: SanityDocument<T>;
7
+ published?: SanityDocument<T>;
8
+ onComplete?: () => void;
9
+ }
@@ -0,0 +1,6 @@
1
+ export interface ITranslationRef {
2
+ _key: string;
3
+ _type: 'reference';
4
+ _ref: string;
5
+ _weak?: boolean;
6
+ }
@@ -0,0 +1,38 @@
1
+ import { TLanguagesOption } from './TLanguagesOption';
2
+ import { ObjectSchemaTypeWithOptions } from '@sanity/types';
3
+ export interface IField {
4
+ name: string;
5
+ type: IType;
6
+ readOnly?: boolean;
7
+ }
8
+ export interface IFieldSet {
9
+ name: string;
10
+ title: string;
11
+ description: string;
12
+ single: boolean;
13
+ options: ObjectSchemaTypeWithOptions['options'];
14
+ field: IField;
15
+ fields: IField[];
16
+ }
17
+ export interface IType {
18
+ name: string;
19
+ title: string;
20
+ description: string;
21
+ hidden?: boolean;
22
+ level: number;
23
+ type: string;
24
+ jsonType: string;
25
+ fields: IField[];
26
+ fieldsets: IFieldSet[];
27
+ options: ObjectSchemaTypeWithOptions['options'] & {
28
+ base?: string;
29
+ i18n?: boolean;
30
+ languages?: TLanguagesOption;
31
+ css?: (classNames: Record<string, string>) => string;
32
+ messages?: {
33
+ loading?: string;
34
+ missingTranslations?: string;
35
+ };
36
+ [key: string]: any;
37
+ };
38
+ }
@@ -0,0 +1,11 @@
1
+ declare type ExecutablAction = {
2
+ disabled?: string;
3
+ execute: (...args: any[]) => void;
4
+ };
5
+ export interface IUseDocumentOperationResult {
6
+ patch: ExecutablAction;
7
+ publish: ExecutablAction;
8
+ duplicate: ExecutablAction;
9
+ delete: ExecutablAction;
10
+ }
11
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare type TFieldNamesConfig = {
2
+ lang?: string;
3
+ references?: string;
4
+ baseReference?: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { ILanguageObject } from './ILanguageObject';
2
+ export declare type Tlanguage = string | ILanguageObject;
@@ -0,0 +1,3 @@
1
+ import { ILanguageQuery } from './ILanguageQuery';
2
+ import { ILanguageObject } from './ILanguageObject';
3
+ export declare type TLanguagesOption = (string | ILanguageObject)[] | ILanguageQuery;
@@ -0,0 +1,6 @@
1
+ export declare type TSchema<T = any> = T & {
2
+ name: string;
3
+ title: string;
4
+ icon?: any;
5
+ fields: any[];
6
+ };
@@ -0,0 +1,10 @@
1
+ import { TLanguagesOption } from './TLanguagesOption';
2
+ import { TFieldNamesConfig } from './TFieldNamesConfig';
3
+ import { IdStructure, ReferenceBehavior } from '../constants';
4
+ export declare type Ti18nConfig = {
5
+ base?: string;
6
+ languages?: TLanguagesOption;
7
+ idStructure?: IdStructure;
8
+ referenceBehavior?: ReferenceBehavior;
9
+ fieldNames?: TFieldNamesConfig;
10
+ };
@@ -0,0 +1,13 @@
1
+ import type { SanityDocument } from '@sanity/client';
2
+ export declare type Ti18nDocument<D = any> = SanityDocument<D> & {
3
+ __i18n_lang?: string;
4
+ __i18n_refs?: {
5
+ _key: string;
6
+ lang: string;
7
+ ref: {
8
+ _type: 'reference';
9
+ _ref: string;
10
+ _weak: boolean;
11
+ };
12
+ }[];
13
+ };
@@ -0,0 +1,5 @@
1
+ import { TSchema } from './TSchema';
2
+ import { Ti18nConfig } from './Ti18nConfig';
3
+ export declare type Ti18nSchema = TSchema<{
4
+ i18n: boolean | Ti18nConfig;
5
+ }>;
@@ -0,0 +1,14 @@
1
+ export * from './ILanguageObject';
2
+ export * from './ILanguageQuery';
3
+ export * from './IType';
4
+ export * from './TLanguage';
5
+ export * from './IResolverProps';
6
+ export * from './TLanguagesOption';
7
+ export * from './TSchema';
8
+ export * from './Ti18nSchema';
9
+ export * from './Ti18nConfig';
10
+ export * from './Ti18nDocument';
11
+ export * from './TFieldNamesConfig';
12
+ export * from './IUseDocumentOperationResult';
13
+ export * from './ITranslationRef';
14
+ export * from './IEditState';
@@ -0,0 +1 @@
1
+ export declare const baseToTop: (a: any, b: any) => number;
@@ -0,0 +1 @@
1
+ export declare function batch<R>(input: R[], fn: (input: R[]) => Promise<void>): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const buildDocId: (id: string, lang: string | null) => string;
@@ -0,0 +1,5 @@
1
+ export declare function createSanityReference(id: string, weak?: boolean, strengthen?: boolean): {
2
+ _weak?: boolean;
3
+ _type: "reference";
4
+ _ref: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { TSchema } from '../types';
2
+ export declare const getAllSchemas: () => TSchema[];
@@ -0,0 +1 @@
1
+ export declare const getBaseIdFromId: (id: string) => string;
@@ -0,0 +1,2 @@
1
+ import { ILanguageObject } from '../types';
2
+ export declare const getBaseLanguage: (langs: ILanguageObject[], base?: string | undefined) => ILanguageObject | null;
@@ -0,0 +1,6 @@
1
+ import { Ti18nSchema, Ti18nConfig } from '../types';
2
+ export declare function getConfig(type?: string | Ti18nSchema): Required<{
3
+ [K in keyof Ti18nConfig]: Required<Ti18nConfig[K]>;
4
+ }> & {
5
+ withTranslationsMaintenance: boolean;
6
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getFlag: (code?: string) => string;
2
+ export declare const getFlagCode: (code?: string) => string;
@@ -0,0 +1 @@
1
+ export declare const getLanguageFromId: (id: string) => string | null;
@@ -0,0 +1,3 @@
1
+ import type { SanityDocument } from '@sanity/client';
2
+ import { ILanguageObject, TLanguagesOption } from '../types';
3
+ export declare const getLanguagesFromOption: <D extends SanityDocument<Record<string, any>>>(langs: TLanguagesOption, document?: D | null | undefined) => Promise<ILanguageObject[]>;
@@ -0,0 +1 @@
1
+ export declare const getSanityClient: () => import('@sanity/client').SanityClient;
@@ -0,0 +1,2 @@
1
+ import { TSchema } from '../types';
2
+ export declare const getSchema: <T = any>(name: string) => TSchema<T>;
@@ -0,0 +1,2 @@
1
+ import { SanityDocument } from '@sanity/client';
2
+ export declare const getTranslationsFor: (baseDocumentId: string) => Promise<SanityDocument<Record<string, any>>[]>;
@@ -0,0 +1,16 @@
1
+ export * from './getConfig';
2
+ export * from './buildDocId';
3
+ export * from './normalizeLanguageList';
4
+ export * from './getBaseLanguage';
5
+ export * from './getSanityClient';
6
+ export * from './getLanguagesFromOption';
7
+ export * from './getSchema';
8
+ export * from './getLanguageFromId';
9
+ export * from './getBaseIdFromId';
10
+ export * from './getAllSchemas';
11
+ export * from './getTranslationsForId';
12
+ export * from './makeObjectKey';
13
+ export * from './createSanityReference';
14
+ export * from './updateIntlFieldsForDocument';
15
+ export * from './serializePath';
16
+ export * from './batch';