gt-sanity 2.0.13 → 2.0.14
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/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -11
- package/src/adapter/createTask.ts +3 -3
- package/src/adapter/getLocales.ts +1 -1
- package/src/components/TranslationsProvider.tsx +1 -1
- package/src/components/page/TranslationsTool.tsx +0 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +1 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.ts +1 -3
- package/src/configuration/baseFieldLevelConfig.ts +1 -8
- package/src/sanity-api/resolveRefs.ts +0 -10
- package/src/serialization/BaseSerializationConfig.ts +1 -1
- package/src/serialization/__tests__/BaseDocumentSerializer/documentInlineMarks.test.ts +3 -8
- package/src/serialization/__tests__/README +1 -1
- package/src/serialization/__tests__/__fixtures__/inlineSchema.ts +1 -1
- package/src/serialization/__tests__/__fixtures__/messy-html.html +5 -1
- package/src/serialization/__tests__/__fixtures__/schema.ts +1 -1
- package/src/serialization/serialize/fieldFilters.ts +1 -1
- package/src/serialization/types.ts +1 -1
- package/src/translation/downloadTranslations.ts +1 -1
- package/src/translation/initProject.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-sanity",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"description": "General Translation integration with Sanity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"jsonpath-plus": "^10.3.0",
|
|
53
53
|
"jsonpointer": "^5.0.1",
|
|
54
54
|
"lodash.merge": "^4.6.2",
|
|
55
|
-
"generaltranslation": "8.2.
|
|
55
|
+
"generaltranslation": "8.2.12"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@portabletext/types": "^2.0.15",
|
|
@@ -60,13 +60,8 @@
|
|
|
60
60
|
"@sanity/plugin-kit": "^4.0.20",
|
|
61
61
|
"@types/lodash.merge": "^4.6.9",
|
|
62
62
|
"@types/react": "^19.2.7",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
64
|
-
"@typescript-eslint/parser": "^8.43.0",
|
|
65
|
-
"eslint": "^9.36.0",
|
|
66
|
-
"eslint-config-sanity": "^7.1.4",
|
|
67
63
|
"jsdom": "^26.1.0",
|
|
68
64
|
"just-clone": "^6.2.0",
|
|
69
|
-
"prettier-plugin-packagejson": "^2.5.19",
|
|
70
65
|
"react": "^19.2.3",
|
|
71
66
|
"react-dom": "^19.2.3",
|
|
72
67
|
"sanity": "^5.18.0",
|
|
@@ -91,11 +86,10 @@
|
|
|
91
86
|
"release:beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
92
87
|
"release:latest": "pnpm run build && pnpm publish --access public --tag latest",
|
|
93
88
|
"build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
|
|
94
|
-
"format": "
|
|
89
|
+
"format": "oxfmt .",
|
|
95
90
|
"link-watch": "plugin-kit link-watch",
|
|
96
|
-
"lint": "eslint .",
|
|
97
|
-
"lint:fix": "eslint . --fix",
|
|
98
91
|
"test": "vitest run",
|
|
99
|
-
"watch": "pkg-utils watch --strict"
|
|
92
|
+
"watch": "pkg-utils watch --strict",
|
|
93
|
+
"typecheck": "tsc --noEmit"
|
|
100
94
|
}
|
|
101
95
|
}
|
|
@@ -10,8 +10,8 @@ export const createTask: Adapter['createTask'] = async (
|
|
|
10
10
|
serializedDocument: GTSerializedDocument,
|
|
11
11
|
localeIds: string[],
|
|
12
12
|
secrets: Secrets | null,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
_workflowUid?: string,
|
|
14
|
+
_callbackUrl?: string
|
|
15
15
|
) => {
|
|
16
16
|
const fileName = `sanity/${documentInfo.documentId}`;
|
|
17
17
|
overrideConfig(secrets);
|
|
@@ -32,7 +32,7 @@ export const createTask: Adapter['createTask'] = async (
|
|
|
32
32
|
sourceLocale: gt.sourceLocale || libraryDefaultLocale,
|
|
33
33
|
}
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
await gt.enqueueFiles(uploadResult.uploadedFiles, {
|
|
36
36
|
sourceLocale: gt.sourceLocale || libraryDefaultLocale,
|
|
37
37
|
targetLocales: localeIds,
|
|
38
38
|
});
|
|
@@ -3,7 +3,7 @@ import { gt, pluginConfig } from './core';
|
|
|
3
3
|
|
|
4
4
|
// note: this function is used to get the available locales for a project
|
|
5
5
|
export const getLocales: Adapter['getLocales'] = async (
|
|
6
|
-
|
|
6
|
+
_secrets: Secrets | null
|
|
7
7
|
) => {
|
|
8
8
|
return pluginConfig.getLocales().map((locale: string) => ({
|
|
9
9
|
localeId: locale,
|
|
@@ -587,7 +587,7 @@ export const TranslationsProvider: React.FC<TranslationsProviderProps> = ({
|
|
|
587
587
|
secrets
|
|
588
588
|
);
|
|
589
589
|
|
|
590
|
-
setTranslationStatuses((
|
|
590
|
+
setTranslationStatuses(() => {
|
|
591
591
|
const newStatuses = new Map();
|
|
592
592
|
|
|
593
593
|
for (const doc of documents) {
|
|
@@ -68,7 +68,7 @@ export async function createI18nDocAndPatchMetadata(
|
|
|
68
68
|
|
|
69
69
|
const doc = await createDocumentPromise;
|
|
70
70
|
const _ref = getPublishedId(doc._id);
|
|
71
|
-
|
|
71
|
+
await client
|
|
72
72
|
.transaction()
|
|
73
73
|
.patch(translationMetadata._id, (p) =>
|
|
74
74
|
p.insert(operation, location, [
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
// adapted from https://github.com/sanity-io/sanity-translations-tab. See LICENSE.md for more details.
|
|
2
2
|
|
|
3
3
|
import { SanityClient, SanityDocument } from 'sanity';
|
|
4
|
-
import {
|
|
5
|
-
BaseDocumentSerializer,
|
|
6
|
-
BaseDocumentDeserializer,
|
|
7
|
-
BaseDocumentMerger,
|
|
8
|
-
defaultStopTypes,
|
|
9
|
-
customSerializers,
|
|
10
|
-
customBlockDeserializers,
|
|
11
|
-
} from '../serialization/';
|
|
4
|
+
import { BaseDocumentMerger } from '../serialization/';
|
|
12
5
|
|
|
13
6
|
import type {
|
|
14
7
|
ExportForTranslation,
|
|
@@ -6,16 +6,6 @@ interface Reference {
|
|
|
6
6
|
_ref: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
interface TranslationMetadata {
|
|
10
|
-
_id: string;
|
|
11
|
-
_type: 'translation.metadata';
|
|
12
|
-
translations: {
|
|
13
|
-
_key: string;
|
|
14
|
-
language: string;
|
|
15
|
-
value: Reference;
|
|
16
|
-
}[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
9
|
/**
|
|
20
10
|
* Function that:
|
|
21
11
|
* 1. Finds all references in the document
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { htmlToBlocks } from '@portabletext/block-tools';
|
|
14
14
|
import { blockContentType } from './deserialize/helpers';
|
|
15
15
|
import { PortableTextObject, PortableTextTextBlock, TypedObject } from 'sanity';
|
|
16
|
-
import {
|
|
16
|
+
import { detachGTData } from './data';
|
|
17
17
|
|
|
18
18
|
export const defaultStopTypes = [
|
|
19
19
|
'reference',
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
getSerialized,
|
|
5
|
-
getValidFields,
|
|
6
|
-
toPlainText,
|
|
7
|
-
getDeserialized,
|
|
8
|
-
} from '../helpers';
|
|
1
|
+
import { SanityDocument } from 'sanity';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { getDeserialized } from '../helpers';
|
|
9
4
|
import { docWithInlineMarks, findByClass, getHTMLNode, schema } from './utils';
|
|
10
5
|
import { attachGTData, BaseDocumentSerializer, customSerializers } from '../..';
|
|
11
6
|
import { TranslationLevel } from '../../types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
Files in this directory are adapted from https://github.com/sanity-io/sanity-naive-html-serializer
|
|
2
|
-
and are licensed under MIT. See LICENSE.md for more details.
|
|
2
|
+
and are licensed under MIT. See LICENSE.md for more details.
|
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
<div class="childObjectField" id="8b2f375c2e7c" data-type="object">
|
|
16
16
|
<span class="title">Det här är en dragspels titeln</span>
|
|
17
17
|
<div class="content" data-type="array">
|
|
18
|
-
<p id="7ac862f38e89">
|
|
18
|
+
<p id="7ac862f38e89">
|
|
19
|
+
Lite content
|
|
20
|
+
<br />
|
|
21
|
+
i vår accordion
|
|
22
|
+
</p>
|
|
19
23
|
</div>
|
|
20
24
|
</div>
|
|
21
25
|
</div>
|
|
@@ -113,7 +113,7 @@ export const fieldFilter = (
|
|
|
113
113
|
|
|
114
114
|
const validFields = [
|
|
115
115
|
...META_FIELDS,
|
|
116
|
-
...objFields
|
|
116
|
+
...objFields.filter(fieldFilterFunc).map((field) => field.name),
|
|
117
117
|
];
|
|
118
118
|
validFields.forEach((field) => {
|
|
119
119
|
if (obj[field]) {
|
|
@@ -32,7 +32,7 @@ export async function downloadTranslations(
|
|
|
32
32
|
);
|
|
33
33
|
const downloadedFiles = responseData.files || [];
|
|
34
34
|
return downloadedFiles;
|
|
35
|
-
} catch
|
|
35
|
+
} catch {
|
|
36
36
|
// Increment retry counter and wait before next attempt
|
|
37
37
|
retries++;
|
|
38
38
|
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
@@ -48,8 +48,10 @@ export async function initProject(
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (setupCompleted) {
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
51
52
|
console.log('Setup successfully completed');
|
|
52
53
|
} else {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
53
55
|
console.log(
|
|
54
56
|
`Setup ${setupFailedMessage ? 'failed' : 'timed out'} — proceeding without setup${
|
|
55
57
|
setupFailedMessage ? ` (${setupFailedMessage})` : ''
|