@littlebox/strapi-suite 1.0.51 → 1.0.52

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.
Files changed (35) hide show
  1. package/dist/_chunks/{App-C7RgdLC-.js → App-C-h--Kv_.js} +557 -35
  2. package/dist/_chunks/{App-b_1MuDrk.mjs → App-C1HyspTk.mjs} +550 -28
  3. package/dist/_chunks/{SlugInput-DvQWzpBu.js → SlugInput-3gkr6B0t.js} +3 -4
  4. package/dist/_chunks/{SlugInput-DlOanbzA.mjs → SlugInput-CU9_b0dd.mjs} +1 -2
  5. package/dist/_chunks/{en-CGJcJfk1.js → en-CLNZnNeq.js} +30 -0
  6. package/dist/_chunks/{en-CRSiVe4w.mjs → en-F6RYx79c.mjs} +30 -0
  7. package/dist/_chunks/{index-UZTUyNY3.js → index-60sq8G6p.js} +667 -20
  8. package/dist/_chunks/{index-C3MUddO-.mjs → index-DQ3vX9So.mjs} +639 -9
  9. package/dist/admin/index.js +1 -1
  10. package/dist/admin/index.mjs +2 -2
  11. package/dist/admin/src/components/DocumentTranslateBox.d.ts +5 -0
  12. package/dist/admin/src/components/DocumentTranslateModal.d.ts +11 -0
  13. package/dist/admin/src/components/TranslationAiModal.d.ts +8 -0
  14. package/dist/admin/src/components/TranslationSettingsModal.d.ts +6 -0
  15. package/dist/admin/src/contexts/settings.d.ts +1 -0
  16. package/dist/admin/src/core/config.d.ts +1 -0
  17. package/dist/admin/src/core/gateways/aiGateway.d.ts +19 -0
  18. package/dist/admin/src/core/gateways/documentGateway.d.ts +15 -0
  19. package/dist/admin/src/core/gateways/translationGateway.d.ts +13 -0
  20. package/dist/admin/src/core/usecases/translateDocument.d.ts +33 -0
  21. package/dist/admin/src/core/usecases/translateWithAi.d.ts +17 -0
  22. package/dist/admin/src/core/utils/documentFields.d.ts +23 -0
  23. package/dist/server/index.js +386 -79
  24. package/dist/server/index.mjs +386 -79
  25. package/dist/server/src/config/index.d.ts +4 -0
  26. package/dist/server/src/controllers/index.d.ts +6 -0
  27. package/dist/server/src/controllers/modules/ai-translation.d.ts +7 -0
  28. package/dist/server/src/controllers/modules/translation.d.ts +1 -0
  29. package/dist/server/src/index.d.ts +22 -1
  30. package/dist/server/src/services/app/setting.d.ts +3 -1
  31. package/dist/server/src/services/index.d.ts +16 -1
  32. package/dist/server/src/services/modules/ai-translation.d.ts +35 -0
  33. package/package.json +1 -1
  34. package/dist/_chunks/convertToSlug-DmgViUjP.mjs +0 -84
  35. package/dist/_chunks/convertToSlug-DqHa9ej4.js +0 -83
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-UZTUyNY3.js");
2
+ const index = require("../_chunks/index-60sq8G6p.js");
3
3
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-C3MUddO-.mjs";
1
+ import { j } from "../_chunks/index-DQ3vX9So.mjs";
2
2
  export {
3
- i as default
3
+ j as default
4
4
  };
@@ -0,0 +1,5 @@
1
+ declare const DocumentTranslateBox: ({ document }: any) => {
2
+ title: string;
3
+ content: import("react/jsx-runtime").JSX.Element;
4
+ } | null;
5
+ export default DocumentTranslateBox;
@@ -0,0 +1,11 @@
1
+ import { Output as OutputTranslateDocument } from '../core/usecases/translateDocument';
2
+ import { Output as OutputFetchLocales } from '../core/usecases/fetchLocales';
3
+ interface Props {
4
+ open: boolean;
5
+ locales: OutputFetchLocales[];
6
+ targetLocale?: OutputFetchLocales;
7
+ translate: (sourceLocale: string, overwrite: boolean) => Promise<OutputTranslateDocument>;
8
+ close: () => void;
9
+ }
10
+ declare const DocumentTranslateModal: ({ open, locales, targetLocale, translate, close }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export default DocumentTranslateModal;
@@ -0,0 +1,8 @@
1
+ import { Output as OutputFetchLocales } from '../core/usecases/fetchLocales';
2
+ interface Props {
3
+ open: boolean;
4
+ locales: OutputFetchLocales[];
5
+ close: (refresh: boolean) => void;
6
+ }
7
+ declare const TranslationAiModal: ({ open, locales, close }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ export default TranslationAiModal;
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ open: boolean;
3
+ close: () => void;
4
+ }
5
+ declare const TranslationSettingsModal: ({ open, close }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export default TranslationSettingsModal;
@@ -4,6 +4,7 @@ type SettingsProviderProps = {
4
4
  };
5
5
  type SettingsContextData = {
6
6
  provide(module: string): Record<string, any>;
7
+ refresh(): Promise<void>;
7
8
  };
8
9
  export declare function SettingsProvider({ children }: SettingsProviderProps): import("react/jsx-runtime").JSX.Element;
9
10
  export declare const SettingsContext: import("react").Context<SettingsContextData>;
@@ -1,5 +1,6 @@
1
1
  export declare const SLUG_LANGUAGE_STRATEGY = "language";
2
2
  export declare const SLUG_CONTENT_STRATEGY = "content";
3
+ export declare const AI_TRANSLATION_DEFAULT_MODEL = "gpt-4o";
3
4
  declare const _default: {
4
5
  pluginId: string;
5
6
  uuid: {
@@ -0,0 +1,19 @@
1
+ import HttpClient from "../http/httpClient";
2
+ export default interface AiGateway {
3
+ translateStrings(input: TranslateStringsInput): Promise<TranslateStringsOutput>;
4
+ }
5
+ export declare class AiGatewayHttp implements AiGateway {
6
+ httpClient: HttpClient;
7
+ constructor();
8
+ translateStrings(input: TranslateStringsInput): Promise<TranslateStringsOutput>;
9
+ }
10
+ export type TranslateStringsInput = {
11
+ sourceLocale: string;
12
+ targetLocale: string;
13
+ strings: Record<string, string>;
14
+ };
15
+ export type TranslateStringsOutput = {
16
+ translations: Record<string, string>;
17
+ failed: number;
18
+ errors: string[];
19
+ };
@@ -0,0 +1,15 @@
1
+ import HttpClient from "../http/httpClient";
2
+ export default interface DocumentGateway {
3
+ fetch(input: FetchInput): Promise<any>;
4
+ }
5
+ export declare class DocumentGatewayHttp implements DocumentGateway {
6
+ httpClient: HttpClient;
7
+ constructor();
8
+ fetch({ collectionType, model, documentId, params }: FetchInput): Promise<any>;
9
+ }
10
+ export type FetchInput = {
11
+ collectionType: string;
12
+ model: string;
13
+ documentId?: string;
14
+ params: Record<string, any>;
15
+ };
@@ -12,6 +12,7 @@ export default interface TranslationGateway {
12
12
  translation: string;
13
13
  locale: string;
14
14
  }[]): Promise<void>;
15
+ aiTranslate(params: AiTranslateInput): Promise<AiTranslateOutput>;
15
16
  }
16
17
  export declare class TranslationGatewayHttp implements TranslationGateway {
17
18
  httpClient: HttpClient;
@@ -28,7 +29,19 @@ export declare class TranslationGatewayHttp implements TranslationGateway {
28
29
  translation: string;
29
30
  locale: string;
30
31
  }[]): Promise<void>;
32
+ aiTranslate(params: AiTranslateInput): Promise<AiTranslateOutput>;
31
33
  }
34
+ export type AiTranslateInput = {
35
+ sourceLocale: string;
36
+ targetLocales: string[];
37
+ overwrite: boolean;
38
+ };
39
+ export type AiTranslateOutput = {
40
+ translated: number;
41
+ skipped: number;
42
+ failed: number;
43
+ errors: string[];
44
+ };
32
45
  type FetchOutput = {
33
46
  id: number;
34
47
  documentId: string;
@@ -0,0 +1,33 @@
1
+ import DocumentGateway from '../gateways/documentGateway';
2
+ import AiGateway from '../gateways/aiGateway';
3
+ export default class TranslateDocument {
4
+ documentGateway: DocumentGateway;
5
+ aiGateway: AiGateway;
6
+ constructor();
7
+ execute(input: Input): Promise<Output>;
8
+ }
9
+ export type Input = {
10
+ collectionType: string;
11
+ model: string;
12
+ documentId?: string;
13
+ sourceLocale: string;
14
+ targetLocale: string;
15
+ status?: string;
16
+ attributes: Record<string, any>;
17
+ components: Record<string, any>;
18
+ values: any;
19
+ overwrite: boolean;
20
+ };
21
+ export type Result = {
22
+ path: string;
23
+ value: string;
24
+ kind: string;
25
+ };
26
+ export type Output = {
27
+ results: Result[];
28
+ translated: number;
29
+ skipped: number;
30
+ unmatched: number;
31
+ failed: number;
32
+ errors: string[];
33
+ };
@@ -0,0 +1,17 @@
1
+ import TranslationGateway from '../gateways/translationGateway';
2
+ export default class TranslateWithAi {
3
+ translationGateway: TranslationGateway;
4
+ constructor();
5
+ execute(input: Input): Promise<Output>;
6
+ }
7
+ export type Input = {
8
+ sourceLocale: string;
9
+ targetLocales: string[];
10
+ overwrite: boolean;
11
+ };
12
+ export type Output = {
13
+ translated: number;
14
+ skipped: number;
15
+ failed: number;
16
+ errors: string[];
17
+ };
@@ -0,0 +1,23 @@
1
+ export type FieldKind = 'text' | 'slug';
2
+ export interface TranslatableField {
3
+ path: string;
4
+ value: string;
5
+ current: string;
6
+ kind: FieldKind;
7
+ }
8
+ type Attributes = Record<string, any>;
9
+ type Components = Record<string, any>;
10
+ /**
11
+ * Walks the schema over the values of the document being edited and, for every
12
+ * translatable leaf, pairs it with the text found at the same path in the source
13
+ * document. The walk is driven by the target so that every path produced already
14
+ * exists in the open form, and dynamic zone entries are only paired when both
15
+ * sides hold the same component.
16
+ */
17
+ export declare function collectTranslatableFields(attributes: Attributes, components: Components, target: any, source: any, basePath?: string): TranslatableField[];
18
+ /**
19
+ * Counts the translatable leaves of the source document on its own, so the
20
+ * caller can tell how many of them found no counterpart in the open document.
21
+ */
22
+ export declare function countTranslatableFields(attributes: Attributes, components: Components, source: any): number;
23
+ export {};