@payload-enchants/translator 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -0
- package/dist/client/api/index.js.map +1 -1
- package/dist/client/components/CustomButton/CustomButtonWithTranslator.d.ts +3 -4
- package/dist/client/components/CustomButton/CustomButtonWithTranslator.d.ts.map +1 -1
- package/dist/client/components/CustomButton/CustomButtonWithTranslator.js +6 -5
- package/dist/client/components/CustomButton/CustomButtonWithTranslator.js.map +1 -1
- package/dist/client/components/CustomButton/index.d.ts +2 -1
- package/dist/client/components/CustomButton/index.d.ts.map +1 -1
- package/dist/client/components/CustomButton/index.js +5 -8
- package/dist/client/components/CustomButton/index.js.map +1 -1
- package/dist/client/components/LocaleLabel/LocaleLabel.js.map +1 -1
- package/dist/client/components/ResolverButton/ResolverButton.js +0 -1
- package/dist/client/components/ResolverButton/ResolverButton.js.map +1 -1
- package/dist/client/components/TranslatorModal/TranslatorModal.d.ts.map +1 -1
- package/dist/client/components/TranslatorModal/TranslatorModal.js +2 -3
- package/dist/client/components/TranslatorModal/TranslatorModal.js.map +1 -1
- package/dist/client/providers/Translator/TranslatorProvider.d.ts.map +1 -1
- package/dist/client/providers/Translator/TranslatorProvider.js +25 -19
- package/dist/client/providers/Translator/TranslatorProvider.js.map +1 -1
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +3 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/i18n-translations.d.ts +18 -0
- package/dist/i18n-translations.d.ts.map +1 -1
- package/dist/i18n-translations.js +18 -0
- package/dist/i18n-translations.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/resolvers/google.js +1 -1
- package/dist/resolvers/google.js.map +1 -1
- package/dist/resolvers/libreTranslate.d.ts +16 -0
- package/dist/resolvers/libreTranslate.d.ts.map +1 -0
- package/dist/resolvers/libreTranslate.js +48 -0
- package/dist/resolvers/libreTranslate.js.map +1 -0
- package/dist/resolvers/openAI.d.ts +2 -2
- package/dist/resolvers/openAI.d.ts.map +1 -1
- package/dist/resolvers/openAI.js +10 -10
- package/dist/resolvers/openAI.js.map +1 -1
- package/dist/translate/findEntityWithConfig.d.ts.map +1 -1
- package/dist/translate/findEntityWithConfig.js +4 -4
- package/dist/translate/findEntityWithConfig.js.map +1 -1
- package/dist/translate/operation.d.ts.map +1 -1
- package/dist/translate/operation.js +3 -1
- package/dist/translate/operation.js.map +1 -1
- package/dist/translate/traverseFields.d.ts.map +1 -1
- package/dist/translate/traverseFields.js +94 -86
- package/dist/translate/traverseFields.js.map +1 -1
- package/dist/translate/traverseRichText.js +3 -3
- package/dist/translate/traverseRichText.js.map +1 -1
- package/dist/translate/updateEntity.d.ts.map +1 -1
- package/dist/translate/updateEntity.js +2 -2
- package/dist/translate/updateEntity.js.map +1 -1
- package/package.json +17 -13
@@ -4,13 +4,13 @@ export const traverseRichText = ({ onText, root, siblingData })=>{
|
|
4
4
|
onText(siblingData);
|
5
5
|
}
|
6
6
|
if (Array.isArray(siblingData?.children)) {
|
7
|
-
siblingData.children
|
7
|
+
for (const child of siblingData.children){
|
8
8
|
traverseRichText({
|
9
9
|
onText,
|
10
10
|
root,
|
11
|
-
siblingData
|
11
|
+
siblingData: child
|
12
12
|
});
|
13
|
-
}
|
13
|
+
}
|
14
14
|
}
|
15
15
|
};
|
16
16
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/translate/traverseRichText.ts"],"sourcesContent":["export const traverseRichText = ({\n onText,\n root,\n siblingData,\n}: {\n onText: (siblingData: Record<string, unknown>) => void;\n root: Record<string, unknown>;\n siblingData?: Record<string, unknown>;\n}) => {\n siblingData = siblingData ?? root;\n\n if (siblingData.text) {\n onText(siblingData);\n }\n\n if (Array.isArray(siblingData?.children)) {\n siblingData.children
|
1
|
+
{"version":3,"sources":["../../src/translate/traverseRichText.ts"],"sourcesContent":["export const traverseRichText = ({\n onText,\n root,\n siblingData,\n}: {\n onText: (siblingData: Record<string, unknown>) => void;\n root: Record<string, unknown>;\n siblingData?: Record<string, unknown>;\n}) => {\n siblingData = siblingData ?? root;\n\n if (siblingData.text) {\n onText(siblingData);\n }\n\n if (Array.isArray(siblingData?.children)) {\n for (const child of siblingData.children) {\n traverseRichText({\n onText,\n root,\n siblingData: child,\n });\n }\n }\n};\n"],"names":["traverseRichText","onText","root","siblingData","text","Array","isArray","children","child"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,CAAC,EAC/BC,MAAM,EACNC,IAAI,EACJC,WAAW,EAKZ;IACCA,cAAcA,eAAeD;IAE7B,IAAIC,YAAYC,IAAI,EAAE;QACpBH,OAAOE;IACT;IAEA,IAAIE,MAAMC,OAAO,CAACH,aAAaI,WAAW;QACxC,KAAK,MAAMC,SAASL,YAAYI,QAAQ,CAAE;YACxCP,iBAAiB;gBACfC;gBACAC;gBACAC,aAAaK;YACf;QACF;IACF;AACF,EAAE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"updateEntity.d.ts","sourceRoot":"","sources":["../../src/translate/updateEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"updateEntity.d.ts","sourceRoot":"","sources":["../../src/translate/updateEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtF,KAAK,IAAI,GAAG;IACV,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,EAAE,cAAc,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,YAAY,iGAStB,IAAI,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CA6BrD,CAAC"}
|
@@ -7,7 +7,7 @@ export const updateEntity = ({ collectionSlug, data, depth: incomingDepth, globa
|
|
7
7
|
const promise = isGlobal ? req.payload.updateGlobal({
|
8
8
|
data,
|
9
9
|
depth,
|
10
|
-
locale,
|
10
|
+
locale: locale,
|
11
11
|
overrideAccess,
|
12
12
|
req,
|
13
13
|
slug: globalSlug
|
@@ -16,7 +16,7 @@ export const updateEntity = ({ collectionSlug, data, depth: incomingDepth, globa
|
|
16
16
|
data,
|
17
17
|
depth,
|
18
18
|
id: id,
|
19
|
-
locale,
|
19
|
+
locale: locale,
|
20
20
|
overrideAccess,
|
21
21
|
req
|
22
22
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/translate/updateEntity.ts"],"sourcesContent":["import type { PayloadRequest, TypeWithID } from 'payload';\nimport { APIError } from 'payload';\n\ntype Args = {\n collectionSlug?: string;\n data: Record<string, any>;\n depth?: number;\n globalSlug?: string;\n id?: number | string;\n locale: string;\n overrideAccess?: boolean;\n req: PayloadRequest;\n};\n\nexport const updateEntity = ({\n collectionSlug,\n data,\n depth: incomingDepth,\n globalSlug,\n id,\n locale,\n overrideAccess,\n req,\n}: Args): Promise<Record<string, unknown> & TypeWithID> => {\n if (!collectionSlug && !globalSlug) throw new APIError('Bad Request', 400);\n\n const isGlobal = !!globalSlug;\n\n if (!isGlobal && !id) throw new APIError('Bad Request', 400);\n\n const depth = incomingDepth ?? req.payload.config.defaultDepth;\n\n const promise = isGlobal\n ? req.payload.updateGlobal({\n data,\n depth,\n locale,\n overrideAccess,\n req,\n slug: globalSlug as
|
1
|
+
{"version":3,"sources":["../../src/translate/updateEntity.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, PayloadRequest, TypeWithID } from 'payload';\nimport { APIError } from 'payload';\n\ntype Args = {\n collectionSlug?: string;\n data: Record<string, any>;\n depth?: number;\n globalSlug?: string;\n id?: number | string;\n locale: string;\n overrideAccess?: boolean;\n req: PayloadRequest;\n};\n\nexport const updateEntity = ({\n collectionSlug,\n data,\n depth: incomingDepth,\n globalSlug,\n id,\n locale,\n overrideAccess,\n req,\n}: Args): Promise<Record<string, unknown> & TypeWithID> => {\n if (!collectionSlug && !globalSlug) throw new APIError('Bad Request', 400);\n\n const isGlobal = !!globalSlug;\n\n if (!isGlobal && !id) throw new APIError('Bad Request', 400);\n\n const depth = incomingDepth ?? req.payload.config.defaultDepth;\n\n const promise = isGlobal\n ? req.payload.updateGlobal({\n data,\n depth,\n locale: locale as any,\n overrideAccess,\n req,\n slug: globalSlug as GlobalSlug,\n })\n : req.payload.update({\n collection: collectionSlug as CollectionSlug,\n data,\n depth,\n id: id as number | string,\n locale: locale as any,\n overrideAccess,\n req,\n });\n\n return promise as any;\n};\n"],"names":["APIError","updateEntity","collectionSlug","data","depth","incomingDepth","globalSlug","id","locale","overrideAccess","req","isGlobal","payload","config","defaultDepth","promise","updateGlobal","slug","update","collection"],"mappings":"AACA,SAASA,QAAQ,QAAQ,UAAU;AAanC,OAAO,MAAMC,eAAe,CAAC,EAC3BC,cAAc,EACdC,IAAI,EACJC,OAAOC,aAAa,EACpBC,UAAU,EACVC,EAAE,EACFC,MAAM,EACNC,cAAc,EACdC,GAAG,EACE;IACL,IAAI,CAACR,kBAAkB,CAACI,YAAY,MAAM,IAAIN,SAAS,eAAe;IAEtE,MAAMW,WAAW,CAAC,CAACL;IAEnB,IAAI,CAACK,YAAY,CAACJ,IAAI,MAAM,IAAIP,SAAS,eAAe;IAExD,MAAMI,QAAQC,iBAAiBK,IAAIE,OAAO,CAACC,MAAM,CAACC,YAAY;IAE9D,MAAMC,UAAUJ,WACZD,IAAIE,OAAO,CAACI,YAAY,CAAC;QACvBb;QACAC;QACAI,QAAQA;QACRC;QACAC;QACAO,MAAMX;IACR,KACAI,IAAIE,OAAO,CAACM,MAAM,CAAC;QACjBC,YAAYjB;QACZC;QACAC;QACAG,IAAIA;QACJC,QAAQA;QACRC;QACAC;IACF;IAEJ,OAAOK;AACT,EAAE"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payload-enchants/translator",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"private": false,
|
5
5
|
"bugs": "https://github.com/r1tsuu/payload-enchants/issues",
|
6
6
|
"repository": "https://github.com/r1tsuu/payload-enchants",
|
@@ -37,28 +37,32 @@
|
|
37
37
|
"import": "./dist/resolvers/openAI.js",
|
38
38
|
"require": "./dist/resolvers/openAI.js",
|
39
39
|
"types": "./dist/resolvers/openAI.d.ts"
|
40
|
+
},
|
41
|
+
"./client": {
|
42
|
+
"import": "./dist/exports/client.js",
|
43
|
+
"require": "./dist/exports/client.js",
|
44
|
+
"types": "./dist/exports/client.d.ts"
|
40
45
|
}
|
41
46
|
},
|
42
47
|
"files": [
|
43
48
|
"dist"
|
44
49
|
],
|
45
50
|
"dependencies": {
|
46
|
-
"bson-objectid": "^2.0.4"
|
51
|
+
"bson-objectid": "^2.0.4",
|
52
|
+
"he": "^1.2.0"
|
47
53
|
},
|
48
54
|
"devDependencies": {
|
49
|
-
"@
|
50
|
-
"@
|
51
|
-
"@types/react": "npm:types-react@19.0.0-
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"react-dom": "19.0.0-rc-f994737d14-20240522",
|
56
|
-
"typescript": "^5.5.2"
|
55
|
+
"@types/he": "^1.2.3",
|
56
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
57
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
58
|
+
"react": "19.0.0-rc-66855b96-20241106",
|
59
|
+
"react-dom": "19.0.0-rc-66855b96-20241106",
|
60
|
+
"typescript": "5.7.2"
|
57
61
|
},
|
58
62
|
"peerDependencies": {
|
59
|
-
"@payloadcms/translations": "^3.
|
60
|
-
"@payloadcms/ui": "^3.
|
61
|
-
"payload": "^3.
|
63
|
+
"@payloadcms/translations": "^3.1.0",
|
64
|
+
"@payloadcms/ui": "^3.1.0",
|
65
|
+
"payload": "^3.1.0"
|
62
66
|
},
|
63
67
|
"publishConfig": {
|
64
68
|
"registry": "https://registry.npmjs.org/"
|