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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-sanity",
3
- "version": "2.0.13",
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.11"
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": "prettier --write --cache --ignore-unknown .",
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
- workflowUid?: string,
14
- callbackUrl?: string
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
- const enqueueResult = await gt.enqueueFiles(uploadResult.uploadedFiles, {
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
- secrets: Secrets | null
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((prevStatuses) => {
590
+ setTranslationStatuses(() => {
591
591
  const newStatuses = new Map();
592
592
 
593
593
  for (const doc of documents) {
@@ -8,7 +8,6 @@ import {
8
8
  Stack,
9
9
  Switch,
10
10
  Text,
11
- Spinner,
12
11
  Tooltip,
13
12
  } from '@sanity/ui';
14
13
  import {
@@ -68,7 +68,7 @@ export async function createI18nDocAndPatchMetadata(
68
68
 
69
69
  const doc = await createDocumentPromise;
70
70
  const _ref = getPublishedId(doc._id);
71
- const result = await client
71
+ await client
72
72
  .transaction()
73
73
  .patch(translationMetadata._id, (p) =>
74
74
  p.insert(operation, location, [
@@ -61,7 +61,5 @@ export async function patchI18nDoc(
61
61
  }
62
62
  );
63
63
  }
64
- const newDocument = await client
65
- .patch(i18nDocId, { set: appliedDocument })
66
- .commit();
64
+ await client.patch(i18nDocId, { set: appliedDocument }).commit();
67
65
  }
@@ -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 { attachGTData, detachGTData } from './data';
16
+ import { detachGTData } from './data';
17
17
 
18
18
  export const defaultStopTypes = [
19
19
  'reference',
@@ -1,11 +1,6 @@
1
- import { PortableTextBlock, SanityDocument } from 'sanity';
2
- import { describe, expect, test } from 'vitest';
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.
@@ -152,7 +152,7 @@ const documentLevelArticle = {
152
152
 
153
153
  function createLocaleFields(locales: string[], fieldType: Record<string, any>) {
154
154
  return locales.map((locale) => ({
155
- ...{ name: locale },
155
+ name: locale,
156
156
  ...fieldType,
157
157
  }));
158
158
  }
@@ -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">Lite content<br />i vår accordion</p>
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>
@@ -191,7 +191,7 @@ const documentLevelArticle = {
191
191
 
192
192
  function createLocaleFields(locales: string[], fieldType: Record<string, any>) {
193
193
  return locales.map((locale) => ({
194
- ...{ name: locale },
194
+ name: locale,
195
195
  ...fieldType,
196
196
  }));
197
197
  }
@@ -113,7 +113,7 @@ export const fieldFilter = (
113
113
 
114
114
  const validFields = [
115
115
  ...META_FIELDS,
116
- ...objFields?.filter(fieldFilterFunc)?.map((field) => field.name),
116
+ ...objFields.filter(fieldFilterFunc).map((field) => field.name),
117
117
  ];
118
118
  validFields.forEach((field) => {
119
119
  if (obj[field]) {
@@ -1,6 +1,6 @@
1
1
  // Adapted from https://github.com/sanity-io/sanity-naive-html-serializer
2
2
 
3
- import { ObjectField, SanityDocument, TypedObject, Schema } from 'sanity';
3
+ import { SanityDocument } from 'sanity';
4
4
 
5
5
  export type SerializedDocument = {
6
6
  name: string;
@@ -32,7 +32,7 @@ export async function downloadTranslations(
32
32
  );
33
33
  const downloadedFiles = responseData.files || [];
34
34
  return downloadedFiles;
35
- } catch (error) {
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})` : ''