gt-sanity 2.0.7 → 2.0.9
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/README.md +3 -0
- package/dist/index.d.mts +13 -14
- package/dist/index.d.ts +13 -14
- package/dist/index.js +309 -101
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +310 -102
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/adapter/core.ts +10 -0
- package/src/adapter/types.ts +6 -5
- package/src/components/TranslationsProvider.tsx +86 -28
- package/src/components/page/TranslationsTable.tsx +12 -4
- package/src/components/shared/LanguageStatus.tsx +3 -2
- package/src/components/shared/SingleDocumentView.tsx +12 -4
- package/src/components/tab/TranslationView.tsx +35 -6
- package/src/configuration/baseDocumentLevelConfig/documentLevelPatch.test.ts +76 -0
- package/src/configuration/baseDocumentLevelConfig/documentLevelPatch.ts +27 -2
- package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +12 -5
- package/src/configuration/baseDocumentLevelConfig/helpers/createTranslationMetadata.ts +2 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/getOrCreateTranslationMetadata.ts +7 -4
- package/src/configuration/baseDocumentLevelConfig/helpers/getTranslationMetadata.ts +2 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.test.ts +52 -0
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.ts +20 -2
- package/src/configuration/utils/findLatestDraft.ts +3 -1
- package/src/index.ts +4 -0
- package/src/sanity-api/findDocuments.ts +11 -5
- package/src/sanity-api/publishDocuments.ts +2 -1
- package/src/sanity-api/resolveRefs.ts +5 -4
- package/src/translation/checkTranslationStatus.ts +25 -6
- package/src/utils/__tests__/batchProcessor.test.ts +44 -0
- package/src/utils/__tests__/documentIds.test.ts +42 -0
- package/src/utils/__tests__/forEachMatchingField.test.ts +71 -1
- package/src/utils/__tests__/importUtils.test.ts +66 -0
- package/src/utils/applyDocuments.ts +56 -5
- package/src/utils/batchProcessor.ts +40 -1
- package/src/utils/documentIds.ts +49 -0
- package/src/utils/importUtils.ts +15 -7
- package/src/utils/serialize.ts +10 -6
package/README.md
CHANGED
|
@@ -32,6 +32,9 @@ export default defineConfig({
|
|
|
32
32
|
gtPlugin({
|
|
33
33
|
sourceLocale: 'en',
|
|
34
34
|
locales: ['es', 'fr'],
|
|
35
|
+
// Initialize translated document slugs with a unique locale suffix,
|
|
36
|
+
// e.g. "hello-world" -> "hello-world-es".
|
|
37
|
+
dedupeFields: [{ fields: [{ property: '$.slug' }] }],
|
|
35
38
|
}),
|
|
36
39
|
],
|
|
37
40
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -86,6 +86,8 @@ export declare const BaseDocumentSerializer: (schemas: Schema) => {
|
|
|
86
86
|
|
|
87
87
|
export declare const customSerializers: Partial<PortableTextHtmlComponents>;
|
|
88
88
|
|
|
89
|
+
declare type DedupeFields = FieldMatcher;
|
|
90
|
+
|
|
89
91
|
export declare const defaultStopTypes: string[];
|
|
90
92
|
|
|
91
93
|
declare interface Deserializer {
|
|
@@ -117,6 +119,14 @@ export declare type ExportForTranslation = (
|
|
|
117
119
|
context: TranslationFunctionContext
|
|
118
120
|
) => Promise<GTSerializedDocument>;
|
|
119
121
|
|
|
122
|
+
declare type FieldMatcher = {
|
|
123
|
+
documentId?: string;
|
|
124
|
+
fields?: {
|
|
125
|
+
property: string;
|
|
126
|
+
type?: string;
|
|
127
|
+
}[];
|
|
128
|
+
};
|
|
129
|
+
|
|
120
130
|
export declare const findLatestDraft: (
|
|
121
131
|
documentId: string,
|
|
122
132
|
client: SanityClient
|
|
@@ -153,6 +163,7 @@ export declare type GTPluginConfig = Omit<
|
|
|
153
163
|
singletons?: string[];
|
|
154
164
|
singletonMapping?: (sourceDocumentId: string, locale: string) => string;
|
|
155
165
|
ignoreFields?: IgnoreFields[];
|
|
166
|
+
dedupeFields?: DedupeFields[];
|
|
156
167
|
skipFields?: SkipFields[];
|
|
157
168
|
languageField?: string;
|
|
158
169
|
translateDocuments?: TranslateDocumentFilter[] | string[];
|
|
@@ -166,13 +177,7 @@ export declare type GTPluginConfig = Omit<
|
|
|
166
177
|
|
|
167
178
|
declare type GTSerializedDocument = Omit<SerializedDocument, 'name'> & GTFile;
|
|
168
179
|
|
|
169
|
-
declare type IgnoreFields =
|
|
170
|
-
documentId?: string;
|
|
171
|
-
fields?: {
|
|
172
|
-
property: string;
|
|
173
|
-
type?: string;
|
|
174
|
-
}[];
|
|
175
|
-
};
|
|
180
|
+
declare type IgnoreFields = FieldMatcher;
|
|
176
181
|
|
|
177
182
|
export declare type ImportTranslation = (
|
|
178
183
|
documentInfo: GTFile,
|
|
@@ -220,13 +225,7 @@ export declare type SerializedDocument = {
|
|
|
220
225
|
content: string;
|
|
221
226
|
};
|
|
222
227
|
|
|
223
|
-
declare type SkipFields =
|
|
224
|
-
documentId?: string;
|
|
225
|
-
fields?: {
|
|
226
|
-
property: string;
|
|
227
|
-
type?: string;
|
|
228
|
-
}[];
|
|
229
|
-
};
|
|
228
|
+
declare type SkipFields = FieldMatcher;
|
|
230
229
|
|
|
231
230
|
export declare const translateAction: DocumentActionComponent;
|
|
232
231
|
|
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,8 @@ export declare const BaseDocumentSerializer: (schemas: Schema) => {
|
|
|
86
86
|
|
|
87
87
|
export declare const customSerializers: Partial<PortableTextHtmlComponents>;
|
|
88
88
|
|
|
89
|
+
declare type DedupeFields = FieldMatcher;
|
|
90
|
+
|
|
89
91
|
export declare const defaultStopTypes: string[];
|
|
90
92
|
|
|
91
93
|
declare interface Deserializer {
|
|
@@ -117,6 +119,14 @@ export declare type ExportForTranslation = (
|
|
|
117
119
|
context: TranslationFunctionContext
|
|
118
120
|
) => Promise<GTSerializedDocument>;
|
|
119
121
|
|
|
122
|
+
declare type FieldMatcher = {
|
|
123
|
+
documentId?: string;
|
|
124
|
+
fields?: {
|
|
125
|
+
property: string;
|
|
126
|
+
type?: string;
|
|
127
|
+
}[];
|
|
128
|
+
};
|
|
129
|
+
|
|
120
130
|
export declare const findLatestDraft: (
|
|
121
131
|
documentId: string,
|
|
122
132
|
client: SanityClient
|
|
@@ -153,6 +163,7 @@ export declare type GTPluginConfig = Omit<
|
|
|
153
163
|
singletons?: string[];
|
|
154
164
|
singletonMapping?: (sourceDocumentId: string, locale: string) => string;
|
|
155
165
|
ignoreFields?: IgnoreFields[];
|
|
166
|
+
dedupeFields?: DedupeFields[];
|
|
156
167
|
skipFields?: SkipFields[];
|
|
157
168
|
languageField?: string;
|
|
158
169
|
translateDocuments?: TranslateDocumentFilter[] | string[];
|
|
@@ -166,13 +177,7 @@ export declare type GTPluginConfig = Omit<
|
|
|
166
177
|
|
|
167
178
|
declare type GTSerializedDocument = Omit<SerializedDocument, 'name'> & GTFile;
|
|
168
179
|
|
|
169
|
-
declare type IgnoreFields =
|
|
170
|
-
documentId?: string;
|
|
171
|
-
fields?: {
|
|
172
|
-
property: string;
|
|
173
|
-
type?: string;
|
|
174
|
-
}[];
|
|
175
|
-
};
|
|
180
|
+
declare type IgnoreFields = FieldMatcher;
|
|
176
181
|
|
|
177
182
|
export declare type ImportTranslation = (
|
|
178
183
|
documentInfo: GTFile,
|
|
@@ -220,13 +225,7 @@ export declare type SerializedDocument = {
|
|
|
220
225
|
content: string;
|
|
221
226
|
};
|
|
222
227
|
|
|
223
|
-
declare type SkipFields =
|
|
224
|
-
documentId?: string;
|
|
225
|
-
fields?: {
|
|
226
|
-
property: string;
|
|
227
|
-
type?: string;
|
|
228
|
-
}[];
|
|
229
|
-
};
|
|
228
|
+
declare type SkipFields = FieldMatcher;
|
|
230
229
|
|
|
231
230
|
export declare const translateAction: DocumentActionComponent;
|
|
232
231
|
|