@payload-enchants/translator 1.1.22 → 1.1.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. package/dist/client/components/CustomButton/CustomButtonWithTranslator.d.ts +6 -0
  2. package/dist/client/components/CustomButton/CustomButtonWithTranslator.d.ts.map +1 -0
  3. package/dist/client/components/{CustomSaveButton/CustomSaveButton.js → CustomButton/CustomButtonWithTranslator.js} +4 -5
  4. package/dist/client/components/CustomButton/CustomButtonWithTranslator.js.map +1 -0
  5. package/dist/client/components/CustomButton/index.d.ts +3 -0
  6. package/dist/client/components/CustomButton/index.d.ts.map +1 -0
  7. package/dist/client/components/CustomButton/index.js +14 -0
  8. package/dist/client/components/CustomButton/index.js.map +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +5 -3
  11. package/dist/index.js.map +1 -1
  12. package/dist/resolvers/openAI.d.ts +2 -1
  13. package/dist/resolvers/openAI.d.ts.map +1 -1
  14. package/dist/resolvers/openAI.js +9 -6
  15. package/dist/resolvers/openAI.js.map +1 -1
  16. package/package.json +11 -11
  17. package/dist/client/components/CustomSaveButton/CustomSaveButton.d.ts +0 -4
  18. package/dist/client/components/CustomSaveButton/CustomSaveButton.d.ts.map +0 -1
  19. package/dist/client/components/CustomSaveButton/CustomSaveButton.js.map +0 -1
  20. package/dist/client/components/CustomSaveButton/index.d.ts +0 -2
  21. package/dist/client/components/CustomSaveButton/index.d.ts.map +0 -1
  22. package/dist/client/components/CustomSaveButton/index.js +0 -3
  23. package/dist/client/components/CustomSaveButton/index.js.map +0 -1
  24. /package/dist/client/components/{CustomSaveButton → CustomButton}/styles.scss +0 -0
@@ -0,0 +1,6 @@
1
+ import './styles.scss';
2
+ import type { ReactNode } from 'react';
3
+ export declare const CustomButtonWithTranslator: ({ defaultButton }: {
4
+ defaultButton: ReactNode;
5
+ }) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
6
+ //# sourceMappingURL=CustomButtonWithTranslator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomButtonWithTranslator.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomButton/CustomButtonWithTranslator.tsx"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,eAAO,MAAM,0BAA0B,sBAAuB;IAAE,aAAa,EAAE,SAAS,CAAA;CAAE,gUAoBzF,CAAC"}
@@ -1,17 +1,16 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import './styles.scss';
4
- import { DefaultSaveButton } from '@payloadcms/ui/elements/Save';
5
4
  import { useConfig } from '@payloadcms/ui/providers/Config';
6
5
  import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
7
6
  import { TranslatorProvider } from '../../providers/Translator/TranslatorProvider';
8
7
  import { ResolverButton } from '../ResolverButton';
9
8
  import { TranslatorModal } from '../TranslatorModal';
10
- export const CustomSaveButton = ()=>{
9
+ export const CustomButtonWithTranslator = ({ defaultButton })=>{
11
10
  const config = useConfig();
12
11
  const { globalSlug, id } = useDocumentInfo();
13
12
  const resolvers = config.admin?.custom?.translator?.resolvers ?? [];
14
- if (!id && !globalSlug) return /*#__PURE__*/ _jsx(DefaultSaveButton, {});
13
+ if (!id && !globalSlug) return defaultButton;
15
14
  return /*#__PURE__*/ _jsx(TranslatorProvider, {
16
15
  children: /*#__PURE__*/ _jsxs("div", {
17
16
  className: 'translator__custom-save-button',
@@ -20,10 +19,10 @@ export const CustomSaveButton = ()=>{
20
19
  resolvers.map((resolver)=>/*#__PURE__*/ _jsx(ResolverButton, {
21
20
  resolver: resolver
22
21
  }, resolver.key)),
23
- /*#__PURE__*/ _jsx(DefaultSaveButton, {})
22
+ defaultButton
24
23
  ]
25
24
  })
26
25
  });
27
26
  };
28
27
 
29
- //# sourceMappingURL=CustomSaveButton.js.map
28
+ //# sourceMappingURL=CustomButtonWithTranslator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/components/CustomButton/CustomButtonWithTranslator.tsx"],"sourcesContent":["'use client';\n\nimport './styles.scss';\n\nimport { useConfig } from '@payloadcms/ui/providers/Config';\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';\nimport type { ReactNode } from 'react';\n\nimport type { TranslateResolver } from '../../../resolvers/types';\nimport { TranslatorProvider } from '../../providers/Translator/TranslatorProvider';\nimport { ResolverButton } from '../ResolverButton';\nimport { TranslatorModal } from '../TranslatorModal';\n\nexport const CustomButtonWithTranslator = ({ defaultButton }: { defaultButton: ReactNode }) => {\n const config = useConfig();\n\n const { globalSlug, id } = useDocumentInfo();\n\n const resolvers = (config.admin?.custom?.translator?.resolvers as TranslateResolver[]) ?? [];\n\n if (!id && !globalSlug) return defaultButton;\n\n return (\n <TranslatorProvider>\n <div className={'translator__custom-save-button'}>\n <TranslatorModal />\n {resolvers.map((resolver) => (\n <ResolverButton key={resolver.key} resolver={resolver} />\n ))}\n {defaultButton}\n </div>\n </TranslatorProvider>\n );\n};\n"],"names":["useConfig","useDocumentInfo","TranslatorProvider","ResolverButton","TranslatorModal","CustomButtonWithTranslator","defaultButton","config","globalSlug","id","resolvers","admin","custom","translator","div","className","map","resolver","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,OAAO,gBAAgB;AAEvB,SAASA,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,eAAe,QAAQ,wCAAwC;AAIxE,SAASC,kBAAkB,QAAQ,gDAAgD;AACnF,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,eAAe,QAAQ,qBAAqB;AAErD,OAAO,MAAMC,6BAA6B,CAAC,EAAEC,aAAa,EAAgC;IACxF,MAAMC,SAASP;IAEf,MAAM,EAAEQ,UAAU,EAAEC,EAAE,EAAE,GAAGR;IAE3B,MAAMS,YAAY,AAACH,OAAOI,KAAK,EAAEC,QAAQC,YAAYH,aAAqC,EAAE;IAE5F,IAAI,CAACD,MAAM,CAACD,YAAY,OAAOF;IAE/B,qBACE,KAACJ;kBACC,cAAA,MAACY;YAAIC,WAAW;;8BACd,KAACX;gBACAM,UAAUM,GAAG,CAAC,CAACC,yBACd,KAACd;wBAAkCc,UAAUA;uBAAxBA,SAASC,GAAG;gBAElCZ;;;;AAIT,EAAE"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ export declare const CustomButton: (type: 'publish' | 'save') => () => import("react").JSX.Element;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomButton/index.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,MAAM,sCAMpD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DefaultPublishButton } from '@payloadcms/ui/elements/PublishButton';
3
+ import { DefaultSaveButton } from '@payloadcms/ui/elements/SaveButton';
4
+ import { CustomButtonWithTranslator } from './CustomButtonWithTranslator';
5
+ export const CustomButton = (type)=>{
6
+ return ()=>{
7
+ const defaultButton = type === 'publish' ? /*#__PURE__*/ _jsx(DefaultPublishButton, {}) : /*#__PURE__*/ _jsx(DefaultSaveButton, {});
8
+ return /*#__PURE__*/ _jsx(CustomButtonWithTranslator, {
9
+ defaultButton: defaultButton
10
+ });
11
+ };
12
+ };
13
+
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/components/CustomButton/index.tsx"],"sourcesContent":["import { DefaultPublishButton } from '@payloadcms/ui/elements/PublishButton';\nimport { DefaultSaveButton } from '@payloadcms/ui/elements/SaveButton';\n\nimport { CustomButtonWithTranslator } from './CustomButtonWithTranslator';\n\nexport const CustomButton = (type: 'publish' | 'save') => {\n return () => {\n const defaultButton = type === 'publish' ? <DefaultPublishButton /> : <DefaultSaveButton />;\n\n return <CustomButtonWithTranslator defaultButton={defaultButton} />;\n };\n};\n"],"names":["DefaultPublishButton","DefaultSaveButton","CustomButtonWithTranslator","CustomButton","type","defaultButton"],"rangeMappings":";;;;;;;;;;;","mappings":";AAAA,SAASA,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,iBAAiB,QAAQ,qCAAqC;AAEvE,SAASC,0BAA0B,QAAQ,+BAA+B;AAE1E,OAAO,MAAMC,eAAe,CAACC;IAC3B,OAAO;QACL,MAAMC,gBAAgBD,SAAS,0BAAY,KAACJ,0CAA0B,KAACC;QAEvE,qBAAO,KAACC;YAA2BG,eAAeA;;IACpD;AACF,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,eAAO,MAAM,UAAU,EAAE,CAAC,YAAY,EAAE,gBAAgB,KAAK,MA0E5D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,eAAO,MAAM,UAAU,EAAE,CAAC,YAAY,EAAE,gBAAgB,KAAK,MA4E5D,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable perfectionist/sort-named-exports */ import { deepMerge } from 'payload/utilities';
2
- import { CustomSaveButton } from './client/components/CustomSaveButton';
2
+ import { CustomButton } from './client/components/CustomButton';
3
3
  import { translations } from './i18n-translations';
4
4
  import { translateEndpoint } from './translate/endpoint';
5
5
  import { translateOperation } from './translate/operation';
@@ -30,7 +30,8 @@ export const translator = (pluginConfig)=>{
30
30
  ...collection.admin?.components ?? {},
31
31
  edit: {
32
32
  ...collection.admin?.components?.edit ?? {},
33
- SaveButton: CustomSaveButton
33
+ PublishButton: CustomButton('publish'),
34
+ SaveButton: CustomButton('save')
34
35
  }
35
36
  }
36
37
  }
@@ -60,7 +61,8 @@ export const translator = (pluginConfig)=>{
60
61
  ...global.admin?.components ?? {},
61
62
  elements: {
62
63
  ...global.admin?.components?.elements ?? {},
63
- SaveButton: CustomSaveButton
64
+ PublishButton: CustomButton('publish'),
65
+ SaveButton: CustomButton('save')
64
66
  }
65
67
  }
66
68
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-named-exports */\nimport type { Plugin } from 'payload/config';\nimport { deepMerge } from 'payload/utilities';\n\nimport { CustomSaveButton } from './client/components/CustomSaveButton';\nimport { translations } from './i18n-translations';\nimport { translateEndpoint } from './translate/endpoint';\nimport { translateOperation } from './translate/operation';\nimport type { TranslatorConfig } from './types';\n\nexport { translateOperation };\n\nexport const translator: (pluginConfig: TranslatorConfig) => Plugin = (pluginConfig) => {\n return (config) => {\n if (pluginConfig.disabled || !config.localization || config.localization.locales.length < 2)\n return config;\n\n return {\n ...config,\n admin: {\n ...(config.admin ?? {}),\n custom: {\n ...(config.admin?.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers.map(({ key }) => ({ key })),\n },\n },\n },\n collections:\n config.collections?.map((collection) => {\n if (!pluginConfig.collections.includes(collection.slug)) return collection;\n\n return {\n ...collection,\n admin: {\n ...(collection.admin ?? {}),\n components: {\n ...(collection.admin?.components ?? {}),\n edit: {\n ...(collection.admin?.components?.edit ?? {}),\n SaveButton: CustomSaveButton,\n },\n },\n },\n };\n }) ?? [],\n custom: {\n ...(config.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers,\n },\n },\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: translateEndpoint,\n method: 'post',\n path: '/translator/translate',\n },\n ],\n globals:\n config.globals?.map((global) => {\n if (!pluginConfig.globals.includes(global.slug)) return global;\n\n return {\n ...global,\n admin: {\n ...(global.admin ?? {}),\n components: {\n ...(global.admin?.components ?? {}),\n elements: {\n ...(global.admin?.components?.elements ?? {}),\n SaveButton: CustomSaveButton,\n },\n },\n },\n };\n }) ?? [],\n i18n: {\n ...config.i18n,\n translations: {\n ...deepMerge(config.i18n?.translations ?? {}, translations),\n },\n },\n };\n };\n};\n"],"names":["deepMerge","CustomSaveButton","translations","translateEndpoint","translateOperation","translator","pluginConfig","config","disabled","localization","locales","length","admin","custom","resolvers","map","key","collections","collection","includes","slug","components","edit","SaveButton","endpoints","handler","method","path","globals","global","elements","i18n"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,mDAAmD,GAEnD,SAASA,SAAS,QAAQ,oBAAoB;AAE9C,SAASC,gBAAgB,QAAQ,uCAAuC;AACxE,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,kBAAkB,QAAQ,wBAAwB;AAG3D,SAASA,kBAAkB,GAAG;AAE9B,OAAO,MAAMC,aAAyD,CAACC;IACrE,OAAO,CAACC;QACN,IAAID,aAAaE,QAAQ,IAAI,CAACD,OAAOE,YAAY,IAAIF,OAAOE,YAAY,CAACC,OAAO,CAACC,MAAM,GAAG,GACxF,OAAOJ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U;gCACR,GAAID,OAAOjB,KAAK,EAAES,YAAYS,YAAY,CAAC,CAAC;gCAC5CP,YAAYtB;4BACd;wBACF;oBACF;gBACF;YACF,MAAM,EAAE;YACV8B,MAAM;gBACJ,GAAGxB,OAAOwB,IAAI;gBACd7B,cAAc;oBACZ,GAAGF,UAAUO,OAAOwB,IAAI,EAAE7B,gBAAgB,CAAC,GAAGA,aAAa;gBAC7D;YACF;QACF;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-named-exports */\nimport type { Plugin } from 'payload/config';\nimport { deepMerge } from 'payload/utilities';\n\nimport { CustomButton } from './client/components/CustomButton';\nimport { translations } from './i18n-translations';\nimport { translateEndpoint } from './translate/endpoint';\nimport { translateOperation } from './translate/operation';\nimport type { TranslatorConfig } from './types';\n\nexport { translateOperation };\n\nexport const translator: (pluginConfig: TranslatorConfig) => Plugin = (pluginConfig) => {\n return (config) => {\n if (pluginConfig.disabled || !config.localization || config.localization.locales.length < 2)\n return config;\n\n return {\n ...config,\n admin: {\n ...(config.admin ?? {}),\n custom: {\n ...(config.admin?.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers.map(({ key }) => ({ key })),\n },\n },\n },\n collections:\n config.collections?.map((collection) => {\n if (!pluginConfig.collections.includes(collection.slug)) return collection;\n\n return {\n ...collection,\n admin: {\n ...(collection.admin ?? {}),\n components: {\n ...(collection.admin?.components ?? {}),\n edit: {\n ...(collection.admin?.components?.edit ?? {}),\n PublishButton: CustomButton('publish'),\n SaveButton: CustomButton('save'),\n },\n },\n },\n };\n }) ?? [],\n custom: {\n ...(config.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers,\n },\n },\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: translateEndpoint,\n method: 'post',\n path: '/translator/translate',\n },\n ],\n globals:\n config.globals?.map((global) => {\n if (!pluginConfig.globals.includes(global.slug)) return global;\n\n return {\n ...global,\n admin: {\n ...(global.admin ?? {}),\n components: {\n ...(global.admin?.components ?? {}),\n elements: {\n ...(global.admin?.components?.elements ?? {}),\n PublishButton: CustomButton('publish'),\n SaveButton: CustomButton('save'),\n },\n },\n },\n };\n }) ?? [],\n i18n: {\n ...config.i18n,\n translations: {\n ...deepMerge(config.i18n?.translations ?? {}, translations),\n },\n },\n };\n };\n};\n"],"names":["deepMerge","CustomButton","translations","translateEndpoint","translateOperation","translator","pluginConfig","config","disabled","localization","locales","length","admin","custom","resolvers","map","key","collections","collection","includes","slug","components","edit","PublishButton","SaveButton","endpoints","handler","method","path","globals","global","elements","i18n"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,mDAAmD,GAEnD,SAASA,SAAS,QAAQ,oBAAoB;AAE9C,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,kBAAkB,QAAQ,wBAAwB;AAG3D,SAASA,kBAAkB,GAAG;AAE9B,OAAO,MAAMC,aAAyD,CAACC;IACrE,OAAO,CAACC;QACN,IAAID,aAAaE,QAAQ,IAAI,CAACD,OAAOE,YAAY,IAAIF,OAAOE,YAAY,CAACC,OAAO,CAACC,MAAM,GAAG,GACxF,OAAOJ;QAET,OAAO;YACL,GAAGA,MAAM;YACTK,OAAO;gBACL,GAAIL,OAAOK,KAAK,IAAI,CAAC,CAAC;gBACtBC,QAAQ;oBACN,GAAIN,OAAOK,KAAK,EAAEC,UAAU,CAAC,CAAC;oBAC9BR,YAAY;wBACVS,WAAWR,aAAaQ,SAAS,CAACC,GAAG,CAAC,CAAC,EAAEC,GAAG,EAAE,GAAM,CAAA;gCAAEA;4BAAI,CAAA;oBAC5D;gBACF;YACF;YACAC,aACEV,OAAOU,WAAW,EAAEF,IAAI,CAACG;gBACvB,IAAI,CAACZ,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+6,7 @@ export type OpenAIPrompt = (args: {
6
6
  }) => string;
7
7
  export type OpenAIResolverConfig = {
8
8
  apiKey: string;
9
+ baseUrl?: string;
9
10
  /**
10
11
  * How many texts to include into 1 request
11
12
  * @default 100
@@ -17,5 +18,5 @@ export type OpenAIResolverConfig = {
17
18
  model?: string;
18
19
  promt?: OpenAIPrompt;
19
20
  };
20
- export declare const openAIResolver: ({ apiKey, chunkLength, model, promt, }: OpenAIResolverConfig) => TranslateResolver;
21
+ export declare const openAIResolver: ({ apiKey, baseUrl, chunkLength, model, promt, }: OpenAIResolverConfig) => TranslateResolver;
21
22
  //# sourceMappingURL=openAI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openAI.d.ts","sourceRoot":"","sources":["../../src/resolvers/openAI.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,KAAK,MAAM,CAAC;AAEb,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC;AAcF,eAAO,MAAM,cAAc,2CAKxB,oBAAoB,KAAG,iBA6GzB,CAAC"}
1
+ {"version":3,"file":"openAI.d.ts","sourceRoot":"","sources":["../../src/resolvers/openAI.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,KAAK,MAAM,CAAC;AAEb,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC;AAcF,eAAO,MAAM,cAAc,oDAMxB,oBAAoB,KAAG,iBAgHzB,CAAC"}
@@ -2,11 +2,11 @@ import { chunkArray } from '../utils/chunkArray';
2
2
  const defaultPromt = ({ localeFrom, localeTo, texts })=>{
3
3
  return `Translate me the following array: ${JSON.stringify(texts)} in locale=${localeFrom} to locale ${localeTo}, respond me with the same array structure`;
4
4
  };
5
- export const openAIResolver = ({ apiKey, chunkLength = 100, model = 'gpt-3.5-turbo', promt = defaultPromt })=>{
5
+ export const openAIResolver = ({ apiKey, baseUrl, chunkLength = 100, model = 'gpt-3.5-turbo', promt = defaultPromt })=>{
6
6
  return {
7
7
  key: 'openai',
8
8
  resolve: async ({ localeFrom, localeTo, req, texts })=>{
9
- const apiUrl = 'https://api.openai.com/v1/chat/completions';
9
+ const apiUrl = `${baseUrl || 'https://api.openai.com'}/v1/chat/completions`;
10
10
  try {
11
11
  const respones = await Promise.all(chunkArray(texts, chunkLength).map((texts)=>{
12
12
  return fetch(apiUrl, {
@@ -47,15 +47,16 @@ export const openAIResolver = ({ apiKey, chunkLength = 100, model = 'gpt-3.5-tur
47
47
  };
48
48
  const content = data?.choices?.[0]?.message?.content;
49
49
  if (!content) {
50
- req.payload.logger.info(`An error occurred when trying to translate the data using OpenAI API - missing content in the response`);
50
+ req.payload.logger.error(`An error occurred when trying to translate the data using OpenAI API - missing content in the response`);
51
51
  return {
52
52
  success: false
53
53
  };
54
54
  }
55
55
  const translatedChunk = JSON.parse(content);
56
56
  if (!Array.isArray(translatedChunk)) {
57
- req.payload.logger.info({
57
+ req.payload.logger.error({
58
58
  data: translatedChunk,
59
+ fullContent: content,
59
60
  message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not an array`
60
61
  });
61
62
  return {
@@ -64,9 +65,11 @@ export const openAIResolver = ({ apiKey, chunkLength = 100, model = 'gpt-3.5-tur
64
65
  }
65
66
  for (const text of translatedChunk){
66
67
  if (typeof text !== 'string') {
67
- req.payload.logger.info({
68
+ req.payload.logger.error({
69
+ chunkData: translatedChunk,
68
70
  data: text,
69
- message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not an array`
71
+ fullContent: content,
72
+ message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not a string`
70
73
  });
71
74
  return {
72
75
  success: false
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resolvers/openAI.ts"],"sourcesContent":["import { chunkArray } from '../utils/chunkArray';\nimport type { TranslateResolver } from './types';\n\nexport type OpenAIPrompt = (args: {\n localeFrom: string;\n localeTo: string;\n texts: string[];\n}) => string;\n\nexport type OpenAIResolverConfig = {\n apiKey: string;\n /**\n * How many texts to include into 1 request\n * @default 100\n */\n chunkLength?: number;\n /**\n * @default \"gpt-3.5-turbo\"\n */\n model?: string;\n promt?: OpenAIPrompt;\n};\n\ntype OpenAIResponse = {\n choices: {\n message: {\n content: string;\n };\n }[];\n};\n\nconst defaultPromt: OpenAIPrompt = ({ localeFrom, localeTo, texts }) => {\n return `Translate me the following array: ${JSON.stringify(texts)} in locale=${localeFrom} to locale ${localeTo}, respond me with the same array structure`;\n};\n\nexport const openAIResolver = ({\n apiKey,\n chunkLength = 100,\n model = 'gpt-3.5-turbo',\n promt = defaultPromt,\n}: OpenAIResolverConfig): TranslateResolver => {\n return {\n key: 'openai',\n resolve: async ({ localeFrom, localeTo, req, texts }) => {\n const apiUrl = 'https://api.openai.com/v1/chat/completions';\n\n try {\n const respones: {\n data: OpenAIResponse;\n success: boolean;\n }[] = await Promise.all(\n chunkArray(texts, chunkLength).map((texts) => {\n return fetch(apiUrl, {\n body: JSON.stringify({\n messages: [\n {\n content: promt({ localeFrom, localeTo, texts }),\n role: 'user',\n },\n ],\n model,\n }),\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n },\n method: 'post',\n }).then(async (res) => {\n const data = await res.json();\n\n if (!res.ok)\n req.payload.logger.info({\n message: `An error occurred when trying to translate the data using OpenAI API`,\n openAIresponse: data,\n });\n\n return {\n data,\n success: res.ok,\n };\n });\n }),\n );\n\n const translated: string[] = [];\n\n for (const { data, success } of respones) {\n if (!success)\n return {\n success: false as const,\n };\n\n const content = data?.choices?.[0]?.message?.content;\n\n if (!content) {\n req.payload.logger.info(\n `An error occurred when trying to translate the data using OpenAI API - missing content in the response`,\n );\n\n return {\n success: false as const,\n };\n }\n\n const translatedChunk: string[] = JSON.parse(content);\n\n if (!Array.isArray(translatedChunk)) {\n req.payload.logger.info({\n data: translatedChunk,\n message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not an array`,\n });\n\n return {\n success: false as const,\n };\n }\n\n for (const text of translatedChunk) {\n if (typeof text !== 'string') {\n req.payload.logger.info({\n data: text,\n message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not an array`,\n });\n\n return {\n success: false as const,\n };\n }\n\n translated.push(text);\n }\n }\n\n return {\n success: true as const,\n translatedTexts: translated,\n };\n } catch (e) {\n if (e instanceof Error) {\n req.payload.logger.info({\n message: `An error occurred when trying to translate the data using OpenAI API`,\n originalErr: e.message,\n });\n }\n\n return { success: false as const };\n }\n },\n };\n};\n"],"names":["chunkArray","defaultPromt","localeFrom","localeTo","texts","JSON","stringify","openAIResolver","apiKey","chunkLength","model","promt","key","resolve","req","apiUrl","respones","Promise","all","map","fetch","body","messages","content","role","headers","Authorization","method","then","res","data","json","ok","payload","logger","info","message","openAIresponse","success","translated","choices","translatedChunk","parse","Array","isArray","text","push","translatedTexts","e","Error","originalErr"],"rangeMappings":";;;;;;;;;;;;;;;;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MAAMO,aAAuB,EAAE;gBAE/B,KAAK,MAAM,EAAET,IAAI,EAAEQ,OAAO,EAAE,IAAItB,SAAU;oBACxC,IAAI,CAACsB,SACH,OAAO;wBACLA,SAAS;oBACX;oBAEF,MAAMf,UAAUO,MAAMU,SAAS,CAAC,EAAE,EAAEJ,SAASb;oBAE7C,IAAI,CAACA,SAAS;wBACZT,IAAImB,OAAO,CAACC,MAAM,CAACC,IAAI,CACrB,CAAC,sGAAsG,CAAC;wBAG1G,OAAO;4BACLG,SAAS;wBACX;oBACF;oBAEA,MAAMG,kBAA4BpC,KAAKqC,KAAK,CAACnB;oBAE7C,IAAI,CAACoB,MAAMC,OAAO,CAACH,kBAAkB;wBACnC3B,IAAImB,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;4BACtBL,MAAMW;4BACNL,SAAS,CAAC,qGAAqG,CAAC;wBAClH;wBAEA,OAAO;4BACLE,SAAS;wBACX;oBACF;oBAEA,KAAK,MAAMO,QAAQJ,gBAAiB;wBAClC,IAAI,OAAOI,SAAS,UAAU;4BAC5B/B,IAAImB,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;gCACtBL,MAAMe;gCACNT,SAAS,CAAC,qGAAqG,CAAC;4BAClH;4BAEA,OAAO;gCACLE,SAAS;4BACX;wBACF;wBAEAC,WAAWO,IAAI,CAACD;oBAClB;gBACF;gBAEA,OAAO;oBACLP,SAAS;oBACTS,iBAAiBR;gBACnB;YACF,EAAE,OAAOS,GAAG;gBACV,IAAIA,aAAaC,OAAO;oBACtBnC,IAAImB,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;wBACtBC,SAAS,CAAC,oEAAoE,CAAC;wBAC/Ec,aAAaF,EAAEZ,OAAO;oBACxB;gBACF;gBAEA,OAAO;oBAAEE,SAAS;gBAAe;YACnC;QACF;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/resolvers/openAI.ts"],"sourcesContent":["import { chunkArray } from '../utils/chunkArray';\nimport type { TranslateResolver } from './types';\n\nexport type OpenAIPrompt = (args: {\n localeFrom: string;\n localeTo: string;\n texts: string[];\n}) => string;\n\nexport type OpenAIResolverConfig = {\n apiKey: string;\n baseUrl?: string;\n /**\n * How many texts to include into 1 request\n * @default 100\n */\n chunkLength?: number;\n /**\n * @default \"gpt-3.5-turbo\"\n */\n model?: string;\n promt?: OpenAIPrompt;\n};\n\ntype OpenAIResponse = {\n choices: {\n message: {\n content: string;\n };\n }[];\n};\n\nconst defaultPromt: OpenAIPrompt = ({ localeFrom, localeTo, texts }) => {\n return `Translate me the following array: ${JSON.stringify(texts)} in locale=${localeFrom} to locale ${localeTo}, respond me with the same array structure`;\n};\n\nexport const openAIResolver = ({\n apiKey,\n baseUrl,\n chunkLength = 100,\n model = 'gpt-3.5-turbo',\n promt = defaultPromt,\n}: OpenAIResolverConfig): TranslateResolver => {\n return {\n key: 'openai',\n resolve: async ({ localeFrom, localeTo, req, texts }) => {\n const apiUrl = `${baseUrl || 'https://api.openai.com'}/v1/chat/completions`;\n\n try {\n const respones: {\n data: OpenAIResponse;\n success: boolean;\n }[] = await Promise.all(\n chunkArray(texts, chunkLength).map((texts) => {\n return fetch(apiUrl, {\n body: JSON.stringify({\n messages: [\n {\n content: promt({ localeFrom, localeTo, texts }),\n role: 'user',\n },\n ],\n model,\n }),\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n },\n method: 'post',\n }).then(async (res) => {\n const data = await res.json();\n\n if (!res.ok)\n req.payload.logger.info({\n message: `An error occurred when trying to translate the data using OpenAI API`,\n openAIresponse: data,\n });\n\n return {\n data,\n success: res.ok,\n };\n });\n }),\n );\n\n const translated: string[] = [];\n\n for (const { data, success } of respones) {\n if (!success)\n return {\n success: false as const,\n };\n\n const content = data?.choices?.[0]?.message?.content;\n\n if (!content) {\n req.payload.logger.error(\n `An error occurred when trying to translate the data using OpenAI API - missing content in the response`,\n );\n\n return {\n success: false as const,\n };\n }\n\n const translatedChunk: string[] = JSON.parse(content);\n\n if (!Array.isArray(translatedChunk)) {\n req.payload.logger.error({\n data: translatedChunk,\n fullContent: content,\n message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not an array`,\n });\n\n return {\n success: false as const,\n };\n }\n\n for (const text of translatedChunk) {\n if (typeof text !== 'string') {\n req.payload.logger.error({\n chunkData: translatedChunk,\n data: text,\n fullContent: content,\n message: `An error occurred when trying to translate the data using OpenAI API - parsed content is not a string`,\n });\n\n return {\n success: false as const,\n };\n }\n\n translated.push(text);\n }\n }\n\n return {\n success: true as const,\n translatedTexts: translated,\n };\n } catch (e) {\n if (e instanceof Error) {\n req.payload.logger.info({\n message: `An error occurred when trying to translate the data using OpenAI API`,\n originalErr: e.message,\n });\n }\n\n return { success: false as const };\n }\n },\n };\n};\n"],"names":["chunkArray","defaultPromt","localeFrom","localeTo","texts","JSON","stringify","openAIResolver","apiKey","baseUrl","chunkLength","model","promt","key","resolve","req","apiUrl","respones","Promise","all","map","fetch","body","messages","content","role","headers","Authorization","method","then","res","data","json","ok","payload","logger","info","message","openAIresponse","success","translated","choices","error","translatedChunk","parse","Array","isArray","fullContent","text","chunkData","push","translatedTexts","e","Error","originalErr"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,QAAQ,sBAAsB;AAgCjD,MAAMC,eAA6B,CAAC,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,KAAK,EAAE;IACjE,OAAO,CAAC,kCAAkC,EAAEC,KAAKC,SAAS,CAACF,OAAO,WAAW,EAAEF,WAAW,WAAW,EAAEC,SAAS,0CAA0C,CAAC;AAC7J;AAEA,OAAO,MAAMI,iBAAiB,CAAC,EAC7BC,MAAM,EACNC,OAAO,EACPC,cAAc,GAAG,EACjBC,QAAQ,eAAe,EACvBC,QAAQX,YAAY,EACC;IACrB,OAAO;QACLY,KAAK;QACL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ACH,kBAAkB;wBACnC5B,IAAImB,OAAO,CAACC,MAAM,CAACO,KAAK,CAAC;4BACvBX,MAAMY;4BACNI,aAAavB;4BACba,SAAS,CAAC,qGAAqG,CAAC;wBAClH;wBAEA,OAAO;4BACLE,SAAS;wBACX;oBACF;oBAEA,KAAK,MAAMS,QAAQL,gBAAiB;wBAClC,IAAI,OAAOK,SAAS,UAAU;4BAC5BjC,IAAImB,OAAO,CAACC,MAAM,CAACO,KAAK,CAAC;gCACvBO,WAAWN;gCACXZ,MAAMiB;gCACND,aAAavB;gCACba,SAAS,CAAC,qGAAqG,CAAC;4BAClH;4BAEA,OAAO;gCACLE,SAAS;4BACX;wBACF;wBAEAC,WAAWU,IAAI,CAACF;oBAClB;gBACF;gBAEA,OAAO;oBACLT,SAAS;oBACTY,iBAAiBX;gBACnB;YACF,EAAE,OAAOY,GAAG;gBACV,IAAIA,aAAaC,OAAO;oBACtBtC,IAAImB,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;wBACtBC,SAAS,CAAC,oEAAoE,CAAC;wBAC/EiB,aAAaF,EAAEf,OAAO;oBACxB;gBACF;gBAEA,OAAO;oBAAEE,SAAS;gBAAe;YACnC;QACF;IACF;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payload-enchants/translator",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "private": false,
5
5
  "bugs": "https://github.com/r1tsuu/payload-enchants/issues",
6
6
  "repository": "https://github.com/r1tsuu/payload-enchants",
@@ -46,19 +46,19 @@
46
46
  "bson-objectid": "^2.0.4"
47
47
  },
48
48
  "devDependencies": {
49
- "@payloadcms/translations": "3.0.0-beta.35",
50
- "@payloadcms/ui": "3.0.0-beta.35",
51
- "@types/react": "18.3.2",
52
- "@types/react-dom": "18.3.0",
53
- "payload": "3.0.0-beta.35",
49
+ "@payloadcms/translations": "3.0.0-beta.36",
50
+ "@payloadcms/ui": "3.0.0-beta.36",
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.36",
54
54
  "typescript": "^5.4.5",
55
- "react": "18.2.0",
56
- "react-dom": "18.2.0"
55
+ "react": "19.0.0-rc-f994737d14-20240522",
56
+ "react-dom": "19.0.0-rc-f994737d14-20240522"
57
57
  },
58
58
  "peerDependencies": {
59
- "@payloadcms/translations": "^3.0.0-beta.35",
60
- "@payloadcms/ui": "^3.0.0-beta.35",
61
- "payload": "^3.0.0-beta.35"
59
+ "@payloadcms/translations": "^3.0.0-beta.36",
60
+ "@payloadcms/ui": "^3.0.0-beta.36",
61
+ "payload": "^3.0.0-beta.36"
62
62
  },
63
63
  "publishConfig": {
64
64
  "registry": "https://registry.npmjs.org/"
@@ -1,4 +0,0 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
- import './styles.scss';
3
- export declare const CustomSaveButton: () => import("react").JSX.Element;
4
- //# sourceMappingURL=CustomSaveButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CustomSaveButton.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomSaveButton/CustomSaveButton.tsx"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAWvB,eAAO,MAAM,gBAAgB,mCAoB5B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/client/components/CustomSaveButton/CustomSaveButton.tsx"],"sourcesContent":["'use client';\n\nimport './styles.scss';\n\nimport { DefaultSaveButton } from '@payloadcms/ui/elements/Save';\nimport { useConfig } from '@payloadcms/ui/providers/Config';\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';\n\nimport type { TranslateResolver } from '../../../resolvers/types';\nimport { TranslatorProvider } from '../../providers/Translator/TranslatorProvider';\nimport { ResolverButton } from '../ResolverButton';\nimport { TranslatorModal } from '../TranslatorModal';\n\nexport const CustomSaveButton = () => {\n const config = useConfig();\n\n const { globalSlug, id } = useDocumentInfo();\n\n const resolvers = (config.admin?.custom?.translator?.resolvers as TranslateResolver[]) ?? [];\n\n if (!id && !globalSlug) return <DefaultSaveButton />;\n\n return (\n <TranslatorProvider>\n <div className={'translator__custom-save-button'}>\n <TranslatorModal />\n {resolvers.map((resolver) => (\n <ResolverButton key={resolver.key} resolver={resolver} />\n ))}\n <DefaultSaveButton />\n </div>\n </TranslatorProvider>\n );\n};\n"],"names":["DefaultSaveButton","useConfig","useDocumentInfo","TranslatorProvider","ResolverButton","TranslatorModal","CustomSaveButton","config","globalSlug","id","resolvers","admin","custom","translator","div","className","map","resolver","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,OAAO,gBAAgB;AAEvB,SAASA,iBAAiB,QAAQ,+BAA+B;AACjE,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,eAAe,QAAQ,wCAAwC;AAGxE,SAASC,kBAAkB,QAAQ,gDAAgD;AACnF,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,eAAe,QAAQ,qBAAqB;AAErD,OAAO,MAAMC,mBAAmB;IAC9B,MAAMC,SAASN;IAEf,MAAM,EAAEO,UAAU,EAAEC,EAAE,EAAE,GAAGP;IAE3B,MAAMQ,YAAY,AAACH,OAAOI,KAAK,EAAEC,QAAQC,YAAYH,aAAqC,EAAE;IAE5F,IAAI,CAACD,MAAM,CAACD,YAAY,qBAAO,KAACR;IAEhC,qBACE,KAACG;kBACC,cAAA,MAACW;YAAIC,WAAW;;8BACd,KAACV;gBACAK,UAAUM,GAAG,CAAC,CAACC,yBACd,KAACb;wBAAkCa,UAAUA;uBAAxBA,SAASC,GAAG;8BAEnC,KAAClB;;;;AAIT,EAAE"}
@@ -1,2 +0,0 @@
1
- export * from './CustomSaveButton';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomSaveButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './CustomSaveButton';
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/client/components/CustomSaveButton/index.ts"],"sourcesContent":["export * from './CustomSaveButton';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,qBAAqB"}