@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.
Files changed (56) hide show
  1. package/README.md +4 -0
  2. package/dist/client/api/index.js.map +1 -1
  3. package/dist/client/components/CustomButton/CustomButtonWithTranslator.d.ts +3 -4
  4. package/dist/client/components/CustomButton/CustomButtonWithTranslator.d.ts.map +1 -1
  5. package/dist/client/components/CustomButton/CustomButtonWithTranslator.js +6 -5
  6. package/dist/client/components/CustomButton/CustomButtonWithTranslator.js.map +1 -1
  7. package/dist/client/components/CustomButton/index.d.ts +2 -1
  8. package/dist/client/components/CustomButton/index.d.ts.map +1 -1
  9. package/dist/client/components/CustomButton/index.js +5 -8
  10. package/dist/client/components/CustomButton/index.js.map +1 -1
  11. package/dist/client/components/LocaleLabel/LocaleLabel.js.map +1 -1
  12. package/dist/client/components/ResolverButton/ResolverButton.js +0 -1
  13. package/dist/client/components/ResolverButton/ResolverButton.js.map +1 -1
  14. package/dist/client/components/TranslatorModal/TranslatorModal.d.ts.map +1 -1
  15. package/dist/client/components/TranslatorModal/TranslatorModal.js +2 -3
  16. package/dist/client/components/TranslatorModal/TranslatorModal.js.map +1 -1
  17. package/dist/client/providers/Translator/TranslatorProvider.d.ts.map +1 -1
  18. package/dist/client/providers/Translator/TranslatorProvider.js +25 -19
  19. package/dist/client/providers/Translator/TranslatorProvider.js.map +1 -1
  20. package/dist/exports/client.d.ts +2 -0
  21. package/dist/exports/client.d.ts.map +1 -0
  22. package/dist/exports/client.js +3 -0
  23. package/dist/exports/client.js.map +1 -0
  24. package/dist/i18n-translations.d.ts +18 -0
  25. package/dist/i18n-translations.d.ts.map +1 -1
  26. package/dist/i18n-translations.js +18 -0
  27. package/dist/i18n-translations.js.map +1 -1
  28. package/dist/index.d.ts +5 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +8 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/resolvers/google.js +1 -1
  33. package/dist/resolvers/google.js.map +1 -1
  34. package/dist/resolvers/libreTranslate.d.ts +16 -0
  35. package/dist/resolvers/libreTranslate.d.ts.map +1 -0
  36. package/dist/resolvers/libreTranslate.js +48 -0
  37. package/dist/resolvers/libreTranslate.js.map +1 -0
  38. package/dist/resolvers/openAI.d.ts +2 -2
  39. package/dist/resolvers/openAI.d.ts.map +1 -1
  40. package/dist/resolvers/openAI.js +10 -10
  41. package/dist/resolvers/openAI.js.map +1 -1
  42. package/dist/translate/findEntityWithConfig.d.ts.map +1 -1
  43. package/dist/translate/findEntityWithConfig.js +4 -4
  44. package/dist/translate/findEntityWithConfig.js.map +1 -1
  45. package/dist/translate/operation.d.ts.map +1 -1
  46. package/dist/translate/operation.js +3 -1
  47. package/dist/translate/operation.js.map +1 -1
  48. package/dist/translate/traverseFields.d.ts.map +1 -1
  49. package/dist/translate/traverseFields.js +94 -86
  50. package/dist/translate/traverseFields.js.map +1 -1
  51. package/dist/translate/traverseRichText.js +3 -3
  52. package/dist/translate/traverseRichText.js.map +1 -1
  53. package/dist/translate/updateEntity.d.ts.map +1 -1
  54. package/dist/translate/updateEntity.js +2 -2
  55. package/dist/translate/updateEntity.js.map +1 -1
  56. 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.forEach((siblingData)=>{
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.forEach((siblingData) => {\n traverseRichText({\n onText,\n root,\n siblingData,\n });\n });\n }\n};\n"],"names":["traverseRichText","onText","root","siblingData","text","Array","isArray","children","forEach"],"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;QACxCJ,YAAYI,QAAQ,CAACC,OAAO,CAAC,CAACL;YAC5BH,iBAAiB;gBACfC;gBACAC;gBACAC;YACF;QACF;IACF;AACF,EAAE"}
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,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1D,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"}
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 string,\n })\n : req.payload.update({\n collection: collectionSlug as string,\n data,\n depth,\n id: id as number | string,\n locale,\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;QACAC;QACAC;QACAO,MAAMX;IACR,KACAI,IAAIE,OAAO,CAACM,MAAM,CAAC;QACjBC,YAAYjB;QACZC;QACAC;QACAG,IAAIA;QACJC;QACAC;QACAC;IACF;IAEJ,OAAOK;AACT,EAAE"}
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.2.2",
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
- "@payloadcms/translations": "3.0.0-beta.61",
50
- "@payloadcms/ui": "3.0.0-beta.61",
51
- "@types/react": "npm:types-react@19.0.0-beta.2",
52
- "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2",
53
- "payload": "3.0.0-beta.61",
54
- "react": "19.0.0-rc-f994737d14-20240522",
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.0.0-beta.61",
60
- "@payloadcms/ui": "^3.0.0-beta.61",
61
- "payload": "^3.0.0-beta.61"
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/"