@littlebox/strapi-suite 1.0.51 → 1.0.54
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/README.md +29 -0
- package/dist/_chunks/{App-C7RgdLC-.js → App-B7_8BaVG.js} +557 -35
- package/dist/_chunks/{App-b_1MuDrk.mjs → App-BfGB2pF_.mjs} +550 -28
- package/dist/_chunks/{SlugInput-DlOanbzA.mjs → SlugInput-CvgVtZza.mjs} +1 -2
- package/dist/_chunks/{SlugInput-DvQWzpBu.js → SlugInput-eCwgqJtH.js} +3 -4
- package/dist/_chunks/{en-CGJcJfk1.js → en-D89cXiov.js} +46 -1
- package/dist/_chunks/{en-CRSiVe4w.mjs → en-knG97mCH.mjs} +46 -1
- package/dist/_chunks/{index-C3MUddO-.mjs → index-97f0S4q6.mjs} +2270 -73
- package/dist/_chunks/{index-UZTUyNY3.js → index-DnXsi_Ar.js} +2292 -78
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/src/components/DocumentTranslateBox.d.ts +5 -0
- package/dist/admin/src/components/DocumentTranslateModal.d.ts +11 -0
- package/dist/admin/src/components/TranslationAiModal.d.ts +8 -0
- package/dist/admin/src/components/TranslationSettingsModal.d.ts +6 -0
- package/dist/admin/src/contexts/settings.d.ts +1 -0
- package/dist/admin/src/core/config.d.ts +1 -0
- package/dist/admin/src/core/gateways/aiGateway.d.ts +19 -0
- package/dist/admin/src/core/gateways/documentGateway.d.ts +15 -0
- package/dist/admin/src/core/gateways/translationGateway.d.ts +13 -0
- package/dist/admin/src/core/usecases/translateDocument.d.ts +33 -0
- package/dist/admin/src/core/usecases/translateWithAi.d.ts +17 -0
- package/dist/admin/src/core/utils/documentFields.d.ts +23 -0
- package/dist/admin/src/core/utils/tabs.d.ts +53 -0
- package/dist/admin/src/ctb/TabSelect.d.ts +31 -0
- package/dist/admin/src/ctb/TabsEditor.d.ts +21 -0
- package/dist/admin/src/ctb/registerTabsInContentTypeBuilder.d.ts +1 -0
- package/dist/admin/src/ctb/tabBadges.d.ts +14 -0
- package/dist/admin/src/editView/TabSection.d.ts +6 -0
- package/dist/admin/src/editView/TabsBar.d.ts +10 -0
- package/dist/admin/src/editView/mutateEditViewLayout.d.ts +12 -0
- package/dist/admin/src/editView/sectionVisibility.d.ts +7 -0
- package/dist/admin/src/editView/tabsStore.d.ts +13 -0
- package/dist/server/index.js +812 -392
- package/dist/server/index.mjs +812 -392
- package/dist/server/src/config/index.d.ts +4 -0
- package/dist/server/src/controllers/index.d.ts +6 -0
- package/dist/server/src/controllers/modules/ai-translation.d.ts +7 -0
- package/dist/server/src/controllers/modules/translation.d.ts +1 -0
- package/dist/server/src/index.d.ts +22 -1
- package/dist/server/src/middlewares/tabs.d.ts +4 -0
- package/dist/server/src/services/app/setting.d.ts +3 -1
- package/dist/server/src/services/index.d.ts +16 -1
- package/dist/server/src/services/modules/ai-translation.d.ts +35 -0
- package/dist/server/src/utils/groupByContentTypeTabs.d.ts +7 -0
- package/dist/server/src/utils/tabs.d.ts +17 -0
- package/package.json +6 -3
- package/dist/_chunks/convertToSlug-DmgViUjP.mjs +0 -84
- package/dist/_chunks/convertToSlug-DqHa9ej4.js +0 -83
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
|
@@ -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;
|
|
@@ -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>;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const TABS_PLUGIN_KEY = "littlebox-strapi-suite";
|
|
2
|
+
export declare const TABS_HASH_PARAM = "ltbTab";
|
|
3
|
+
export declare const TABS_BAR_FIELD_TYPE = "ltb-tabs-bar";
|
|
4
|
+
export declare const TABS_SECTION_FIELD_TYPE = "ltb-tab-section";
|
|
5
|
+
export interface LtbTab {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export type LayoutField = {
|
|
10
|
+
name: string;
|
|
11
|
+
attribute?: unknown;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export type LayoutPanel = LayoutField[][];
|
|
15
|
+
export type TabsValidationError = 'name.required' | 'key.empty' | 'key.duplicated';
|
|
16
|
+
export declare function toTabKey(name: string): string;
|
|
17
|
+
export declare function generateTabId(): string;
|
|
18
|
+
export declare function readTabs(pluginOptions: unknown): LtbTab[];
|
|
19
|
+
/**
|
|
20
|
+
* Tabs value to store in the form. The content type builder applies the modal values to its state
|
|
21
|
+
* with lodash `merge`, which merges arrays by index, so a shorter array would keep the removed
|
|
22
|
+
* tabs. Padding with `null` up to the previous length overwrites them; `readTabs` ignores nulls
|
|
23
|
+
* and `cleanContentTypeSchema` drops them on save.
|
|
24
|
+
*/
|
|
25
|
+
export declare function padTabs(next: LtbTab[], previous: unknown): (LtbTab | null)[];
|
|
26
|
+
export declare function readAttributeTabId(attribute: unknown): string | null;
|
|
27
|
+
/** Tabs whose API key matches a field or system key; the server does not group them. */
|
|
28
|
+
export declare function getConflictingTabIds(tabs: LtbTab[], attributes: unknown): Set<string>;
|
|
29
|
+
export declare function validateTabs(tabs: LtbTab[]): TabsValidationError | null;
|
|
30
|
+
export declare function cleanContentTypeSchema<T>(schema: T): T;
|
|
31
|
+
export declare function resolveActiveTab(tabs: LtbTab[], requested: unknown): LtbTab | null;
|
|
32
|
+
export declare function groupLayoutByTabs(panels: LayoutPanel[], tabs: LtbTab[]): {
|
|
33
|
+
rootPanels: LayoutPanel[];
|
|
34
|
+
sections: {
|
|
35
|
+
tab: LtbTab;
|
|
36
|
+
panels: LayoutPanel[];
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
type ComponentLayouts = Record<string, {
|
|
40
|
+
layout?: LayoutField[][];
|
|
41
|
+
} | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* Name borrowed by the tabs bar and section fields. The content manager checks field
|
|
44
|
+
* permissions by name, and permissions only list component leaves (e.g. `seo.metaTitle`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function findAnchorName(panels: LayoutPanel[], components?: ComponentLayouts): string | null;
|
|
47
|
+
export declare function readTabFromHash(hash: string): string | null;
|
|
48
|
+
export declare function pickInitialTab(keys: string[], hashKey: string | null, currentKey: string | null): string | null;
|
|
49
|
+
export declare function tabHash(key: string): string;
|
|
50
|
+
export declare function mapFieldsToTabKeys(panels: LayoutPanel[], tabs: LtbTab[]): Record<string, string>;
|
|
51
|
+
export declare function countErrorsByTab(errors: unknown, fieldTabKeys: Record<string, string>): Record<string, number>;
|
|
52
|
+
export declare function isEditViewPath(pathname: string): boolean;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type IntlMessage = {
|
|
2
|
+
id: string;
|
|
3
|
+
defaultMessage: string;
|
|
4
|
+
};
|
|
5
|
+
type TabSelectOption = {
|
|
6
|
+
key: string;
|
|
7
|
+
value: string;
|
|
8
|
+
metadatas: {
|
|
9
|
+
intlLabel: IntlMessage;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
hidden?: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type TabSelectProps = {
|
|
15
|
+
name: string;
|
|
16
|
+
value?: string | null;
|
|
17
|
+
error?: string;
|
|
18
|
+
intlLabel: IntlMessage;
|
|
19
|
+
description?: IntlMessage;
|
|
20
|
+
options?: TabSelectOption[];
|
|
21
|
+
onChange: (event: {
|
|
22
|
+
target: {
|
|
23
|
+
name: string;
|
|
24
|
+
value: string;
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
}) => void;
|
|
28
|
+
};
|
|
29
|
+
/** Tab select for the field advanced settings; the built-in select does not allow styling its label. */
|
|
30
|
+
declare const TabSelect: ({ name, value, error, intlLabel, description, options, onChange, }: TabSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export default TabSelect;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LtbTab } from '../core/utils/tabs';
|
|
2
|
+
type IntlMessage = {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
values?: Record<string, string | number>;
|
|
6
|
+
};
|
|
7
|
+
type TabsEditorProps = {
|
|
8
|
+
name: string;
|
|
9
|
+
value?: unknown;
|
|
10
|
+
error?: string;
|
|
11
|
+
intlLabel: IntlMessage;
|
|
12
|
+
description?: IntlMessage;
|
|
13
|
+
onChange: (event: {
|
|
14
|
+
target: {
|
|
15
|
+
name: string;
|
|
16
|
+
value: (LtbTab | null)[];
|
|
17
|
+
};
|
|
18
|
+
}) => void;
|
|
19
|
+
};
|
|
20
|
+
declare const TabsEditor: ({ name, value, error, intlLabel, description, onChange }: TabsEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export default TabsEditor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerTabsInContentTypeBuilder(app: any): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function ctbContentTypeUid(pathname: string): string | null;
|
|
2
|
+
/** Maps each field that belongs to an existing tab to the tab name. */
|
|
3
|
+
export declare function buildFieldTabNames(contentType: any): Record<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* Adds, updates or removes the tab badge after the name of each top-level field row of the
|
|
6
|
+
* content type builder list. Rows of component sub-fields are left untouched.
|
|
7
|
+
*/
|
|
8
|
+
export declare function syncTabBadges(root: ParentNode, fieldTabNames: Record<string, string>): void;
|
|
9
|
+
/**
|
|
10
|
+
* Shows the tab of each field in the content type builder list. The builder has no extension
|
|
11
|
+
* point there, so this watches the DOM and reads the builder state (including unsaved changes)
|
|
12
|
+
* from the admin redux store. If the markup changes in a future Strapi version, no badge shows.
|
|
13
|
+
*/
|
|
14
|
+
export declare function startTabBadges(app: any): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type TabsBarProps = {
|
|
2
|
+
ltbTabs?: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
key: string;
|
|
6
|
+
}[];
|
|
7
|
+
ltbFieldTabKeys?: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
declare const TabsBar: ({ ltbTabs, ltbFieldTabKeys }: TabsBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default TabsBar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type HookArgs = {
|
|
2
|
+
layout: any;
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Keeps every field in the layout and arranges it as: fields without a tab, the tabs bar,
|
|
7
|
+
* then one section per tab (a marker panel followed by the tab panels). Switching tabs only
|
|
8
|
+
* hides and shows sections at render time: the content manager recomputes this hook only when
|
|
9
|
+
* the URL query changes, and a query change triggers its unsaved-changes guard and a refetch.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mutateEditViewLayout<T extends HookArgs>(args: T, pathname?: string): T;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shows or hides the panels of a tab section. The content manager renders every panel of
|
|
3
|
+
* the edit layout as a direct child of one column; the section marker sits in its own panel,
|
|
4
|
+
* followed by the panels of its tab until the next marker. Returns that column, or null when
|
|
5
|
+
* the structure is not found, in which case nothing is hidden.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applySectionVisibility(marker: HTMLElement, visible: boolean): HTMLElement | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Listener = () => void;
|
|
2
|
+
export declare function createTabsStore(): {
|
|
3
|
+
get: () => string | null;
|
|
4
|
+
set(key: string): void;
|
|
5
|
+
subscribe(listener: Listener): () => void;
|
|
6
|
+
};
|
|
7
|
+
/** Active tab shared by the tabs bar and the tab sections of the open edit view. */
|
|
8
|
+
export declare const tabsStore: {
|
|
9
|
+
get: () => string | null;
|
|
10
|
+
set(key: string): void;
|
|
11
|
+
subscribe(listener: Listener): () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|