@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.
Files changed (49) hide show
  1. package/README.md +29 -0
  2. package/dist/_chunks/{App-C7RgdLC-.js → App-B7_8BaVG.js} +557 -35
  3. package/dist/_chunks/{App-b_1MuDrk.mjs → App-BfGB2pF_.mjs} +550 -28
  4. package/dist/_chunks/{SlugInput-DlOanbzA.mjs → SlugInput-CvgVtZza.mjs} +1 -2
  5. package/dist/_chunks/{SlugInput-DvQWzpBu.js → SlugInput-eCwgqJtH.js} +3 -4
  6. package/dist/_chunks/{en-CGJcJfk1.js → en-D89cXiov.js} +46 -1
  7. package/dist/_chunks/{en-CRSiVe4w.mjs → en-knG97mCH.mjs} +46 -1
  8. package/dist/_chunks/{index-C3MUddO-.mjs → index-97f0S4q6.mjs} +2270 -73
  9. package/dist/_chunks/{index-UZTUyNY3.js → index-DnXsi_Ar.js} +2292 -78
  10. package/dist/admin/index.js +1 -1
  11. package/dist/admin/index.mjs +2 -2
  12. package/dist/admin/src/components/DocumentTranslateBox.d.ts +5 -0
  13. package/dist/admin/src/components/DocumentTranslateModal.d.ts +11 -0
  14. package/dist/admin/src/components/TranslationAiModal.d.ts +8 -0
  15. package/dist/admin/src/components/TranslationSettingsModal.d.ts +6 -0
  16. package/dist/admin/src/contexts/settings.d.ts +1 -0
  17. package/dist/admin/src/core/config.d.ts +1 -0
  18. package/dist/admin/src/core/gateways/aiGateway.d.ts +19 -0
  19. package/dist/admin/src/core/gateways/documentGateway.d.ts +15 -0
  20. package/dist/admin/src/core/gateways/translationGateway.d.ts +13 -0
  21. package/dist/admin/src/core/usecases/translateDocument.d.ts +33 -0
  22. package/dist/admin/src/core/usecases/translateWithAi.d.ts +17 -0
  23. package/dist/admin/src/core/utils/documentFields.d.ts +23 -0
  24. package/dist/admin/src/core/utils/tabs.d.ts +53 -0
  25. package/dist/admin/src/ctb/TabSelect.d.ts +31 -0
  26. package/dist/admin/src/ctb/TabsEditor.d.ts +21 -0
  27. package/dist/admin/src/ctb/registerTabsInContentTypeBuilder.d.ts +1 -0
  28. package/dist/admin/src/ctb/tabBadges.d.ts +14 -0
  29. package/dist/admin/src/editView/TabSection.d.ts +6 -0
  30. package/dist/admin/src/editView/TabsBar.d.ts +10 -0
  31. package/dist/admin/src/editView/mutateEditViewLayout.d.ts +12 -0
  32. package/dist/admin/src/editView/sectionVisibility.d.ts +7 -0
  33. package/dist/admin/src/editView/tabsStore.d.ts +13 -0
  34. package/dist/server/index.js +812 -392
  35. package/dist/server/index.mjs +812 -392
  36. package/dist/server/src/config/index.d.ts +4 -0
  37. package/dist/server/src/controllers/index.d.ts +6 -0
  38. package/dist/server/src/controllers/modules/ai-translation.d.ts +7 -0
  39. package/dist/server/src/controllers/modules/translation.d.ts +1 -0
  40. package/dist/server/src/index.d.ts +22 -1
  41. package/dist/server/src/middlewares/tabs.d.ts +4 -0
  42. package/dist/server/src/services/app/setting.d.ts +3 -1
  43. package/dist/server/src/services/index.d.ts +16 -1
  44. package/dist/server/src/services/modules/ai-translation.d.ts +35 -0
  45. package/dist/server/src/utils/groupByContentTypeTabs.d.ts +7 -0
  46. package/dist/server/src/utils/tabs.d.ts +17 -0
  47. package/package.json +6 -3
  48. package/dist/_chunks/convertToSlug-DmgViUjP.mjs +0 -84
  49. package/dist/_chunks/convertToSlug-DqHa9ej4.js +0 -83
@@ -2,6 +2,10 @@ import { UID } from "@strapi/strapi";
2
2
  export declare const PLUGIN_ID = "littlebox-strapi-suite";
3
3
  export declare const SLUG_LANGUAGE_STRATEGY = "language";
4
4
  export declare const SLUG_CONTENT_STRATEGY = "content";
5
+ export declare const AI_TRANSLATION_MODULE = "translation";
6
+ export declare const AI_TRANSLATION_DEFAULT_MODEL = "gpt-4o";
7
+ export declare const AI_TRANSLATION_BATCH_SIZE = 40;
8
+ export declare const OPENAI_CHAT_COMPLETIONS_URL = "https://api.openai.com/v1/chat/completions";
5
9
  export interface LtbConfigs {
6
10
  pluginId: string;
7
11
  uuid: {
@@ -56,6 +56,7 @@ declare const _default: {
56
56
  adminCreate(): Promise<any>;
57
57
  adminEdit(): Promise<any>;
58
58
  adminBulkDelete(): Promise<any>;
59
+ adminAiTranslate(): Promise<any>;
59
60
  getTranslations(): Promise<any>;
60
61
  };
61
62
  LocalesModuleController: ({ strapi }: {
@@ -66,5 +67,10 @@ declare const _default: {
66
67
  default: any;
67
68
  }>;
68
69
  };
70
+ AiTranslationModuleController: ({ strapi }: {
71
+ strapi: import("@strapi/types/dist/core").Strapi;
72
+ }) => {
73
+ adminTranslateStrings(): Promise<any>;
74
+ };
69
75
  };
70
76
  export default _default;
@@ -0,0 +1,7 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ declare const AiTranslationModuleController: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => {
5
+ adminTranslateStrings(): Promise<any>;
6
+ };
7
+ export default AiTranslationModuleController;
@@ -6,6 +6,7 @@ declare const TranslationModuleController: ({ strapi }: {
6
6
  adminCreate(): Promise<any>;
7
7
  adminEdit(): Promise<any>;
8
8
  adminBulkDelete(): Promise<any>;
9
+ adminAiTranslate(): Promise<any>;
9
10
  getTranslations(): Promise<any>;
10
11
  };
11
12
  export default TranslationModuleController;
@@ -97,6 +97,7 @@ declare const _default: {
97
97
  adminCreate(): Promise<any>;
98
98
  adminEdit(): Promise<any>;
99
99
  adminBulkDelete(): Promise<any>;
100
+ adminAiTranslate(): Promise<any>;
100
101
  getTranslations(): Promise<any>;
101
102
  };
102
103
  LocalesModuleController: ({ strapi }: {
@@ -107,6 +108,11 @@ declare const _default: {
107
108
  default: any;
108
109
  }>;
109
110
  };
111
+ AiTranslationModuleController: ({ strapi }: {
112
+ strapi: import("@strapi/types/dist/core").Strapi;
113
+ }) => {
114
+ adminTranslateStrings(): Promise<any>;
115
+ };
110
116
  };
111
117
  routes: {
112
118
  admin: {
@@ -142,7 +148,8 @@ declare const _default: {
142
148
  strapi: import("@strapi/types/dist/core").Strapi;
143
149
  }) => {
144
150
  getAll(): Promise<any>;
145
- update(ctx: import("koa").Context): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
151
+ getRawValue(module: string, property: string): Promise<any>;
152
+ update(ctx: import("koa").Context): Promise<any>;
146
153
  };
147
154
  SlugModuleService: ({ strapi }: {
148
155
  strapi: import("@strapi/types/dist/core").Strapi;
@@ -203,6 +210,20 @@ declare const _default: {
203
210
  adminEdit(): Promise<void>;
204
211
  getTranslations(): Promise<import("./services/modules/translation").TranslationItem[]>;
205
212
  };
213
+ AiTranslationModuleService: ({ strapi }: {
214
+ strapi: import("@strapi/types/dist/core").Strapi;
215
+ }) => {
216
+ getLocales(): Promise<import("./services/modules/ai-translation").Locale[]>;
217
+ getCredentials(): Promise<import("./services/modules/ai-translation").Credentials>;
218
+ translateStrings(credentials: import("./services/modules/ai-translation").Credentials, source: import("./services/modules/ai-translation").Locale, target: import("./services/modules/ai-translation").Locale, strings: Record<string, string>): Promise<import("./services/modules/ai-translation").TranslateStringsResult>;
219
+ adminTranslate(): Promise<import("koa").Context | {
220
+ translated: number;
221
+ skipped: number;
222
+ failed: number;
223
+ errors: string[];
224
+ }>;
225
+ adminTranslateStrings(): Promise<import("koa").Context | import("./services/modules/ai-translation").TranslateStringsResult>;
226
+ };
206
227
  };
207
228
  contentTypes: {
208
229
  "ltb-st-app-setting": {
@@ -0,0 +1,4 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ export declare function createTabsMiddleware({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }): (ctx: any, next: () => Promise<void>) => Promise<void>;
@@ -1,9 +1,11 @@
1
1
  import type { Core } from '@strapi/strapi';
2
2
  import { Context } from 'koa';
3
+ export declare function maskSecret(value: string | null): string | null;
3
4
  declare const SettingAppService: ({ strapi }: {
4
5
  strapi: Core.Strapi;
5
6
  }) => {
6
7
  getAll(): Promise<any>;
7
- update(ctx: Context): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
8
+ getRawValue(module: string, property: string): Promise<any>;
9
+ update(ctx: Context): Promise<any>;
8
10
  };
9
11
  export default SettingAppService;
@@ -4,7 +4,8 @@ declare const _default: {
4
4
  strapi: import("@strapi/types/dist/core").Strapi;
5
5
  }) => {
6
6
  getAll(): Promise<any>;
7
- update(ctx: import("koa").Context): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
7
+ getRawValue(module: string, property: string): Promise<any>;
8
+ update(ctx: import("koa").Context): Promise<any>;
8
9
  };
9
10
  SlugModuleService: ({ strapi }: {
10
11
  strapi: import("@strapi/types/dist/core").Strapi;
@@ -65,5 +66,19 @@ declare const _default: {
65
66
  adminEdit(): Promise<void>;
66
67
  getTranslations(): Promise<import("./modules/translation").TranslationItem[]>;
67
68
  };
69
+ AiTranslationModuleService: ({ strapi }: {
70
+ strapi: import("@strapi/types/dist/core").Strapi;
71
+ }) => {
72
+ getLocales(): Promise<import("./modules/ai-translation").Locale[]>;
73
+ getCredentials(): Promise<import("./modules/ai-translation").Credentials>;
74
+ translateStrings(credentials: import("./modules/ai-translation").Credentials, source: import("./modules/ai-translation").Locale, target: import("./modules/ai-translation").Locale, strings: Record<string, string>): Promise<import("./modules/ai-translation").TranslateStringsResult>;
75
+ adminTranslate(): Promise<import("koa").Context | {
76
+ translated: number;
77
+ skipped: number;
78
+ failed: number;
79
+ errors: string[];
80
+ }>;
81
+ adminTranslateStrings(): Promise<import("koa").Context | import("./modules/ai-translation").TranslateStringsResult>;
82
+ };
68
83
  };
69
84
  export default _default;
@@ -0,0 +1,35 @@
1
+ /// <reference types="koa" />
2
+ import type { Core } from '@strapi/strapi';
3
+ export interface Locale {
4
+ code: string;
5
+ name: string;
6
+ }
7
+ export interface Credentials {
8
+ apiKey: string;
9
+ model: string;
10
+ }
11
+ export interface TranslationEntry {
12
+ uid: string;
13
+ translations: Record<string, string>;
14
+ }
15
+ export interface TranslateStringsResult {
16
+ translations: Record<string, string>;
17
+ failed: number;
18
+ errors: string[];
19
+ }
20
+ export declare function buildSystemPrompt(source: Locale, target: Locale): string;
21
+ declare const AiTranslationModuleService: ({ strapi }: {
22
+ strapi: Core.Strapi;
23
+ }) => {
24
+ getLocales(): Promise<Locale[]>;
25
+ getCredentials(): Promise<Credentials | null>;
26
+ translateStrings(credentials: Credentials, source: Locale, target: Locale, strings: Record<string, string>): Promise<TranslateStringsResult>;
27
+ adminTranslate(): Promise<import("koa").Context | {
28
+ translated: number;
29
+ skipped: number;
30
+ failed: number;
31
+ errors: string[];
32
+ }>;
33
+ adminTranslateStrings(): Promise<import("koa").Context | TranslateStringsResult>;
34
+ };
35
+ export default AiTranslationModuleService;
@@ -0,0 +1,7 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ /**
3
+ * Returns a function that groups the fields of a content type entry (or list of entries)
4
+ * by the tabs configured in its schema. Conflicting tabs are warned about once; any failure
5
+ * is logged and the data is returned unchanged.
6
+ */
7
+ export declare function createContentTypeTabsGrouper(strapi: Core.Strapi): <T>(uid: string, data: T) => T;
@@ -0,0 +1,17 @@
1
+ export declare const TABS_PLUGIN_KEY = "littlebox-strapi-suite";
2
+ export interface LtbTab {
3
+ id: string;
4
+ name: string;
5
+ }
6
+ export interface TabGroup {
7
+ tab: LtbTab;
8
+ key: string;
9
+ fields: string[];
10
+ }
11
+ export declare function toTabKey(name: string): string;
12
+ export declare function readTabs(pluginOptions: unknown): LtbTab[];
13
+ export declare function readAttributeTabId(attribute: unknown): string | null;
14
+ export declare function buildTabGroups(tabs: LtbTab[], attributes: Record<string, unknown>, onConflict?: (tab: LtbTab, key: string) => void): TabGroup[];
15
+ export declare function groupEntryByTabs(entry: unknown, groups: TabGroup[]): unknown;
16
+ export declare function groupDataByTabs(data: unknown, groups: TabGroup[]): unknown;
17
+ export declare function parseHandlerUid(handler: unknown): string | null;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.51",
2
+ "version": "1.0.54",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi plugin",
@@ -39,7 +39,8 @@
39
39
  "watch:link": "strapi-plugin watch:link",
40
40
  "verify": "strapi-plugin verify",
41
41
  "test:ts:front": "run -T tsc -p admin/tsconfig.json",
42
- "test:ts:back": "run -T tsc -p server/tsconfig.json"
42
+ "test:ts:back": "run -T tsc -p server/tsconfig.json",
43
+ "test": "vitest run"
43
44
  },
44
45
  "dependencies": {
45
46
  "@dnd-kit/core": "^6.3.1",
@@ -64,6 +65,7 @@
64
65
  "@types/react": "^19.0.10",
65
66
  "@types/react-dom": "^19.0.4",
66
67
  "css-loader": "^7.1.2",
68
+ "jsdom": "^26.1.0",
67
69
  "prettier": "^3.5.1",
68
70
  "react": "^18.3.1",
69
71
  "react-dom": "^18.3.1",
@@ -71,7 +73,8 @@
71
73
  "style-loader": "^4.0.0",
72
74
  "styled-components": "^6.1.15",
73
75
  "tsc-alias": "^1.8.11",
74
- "typescript": "^5.7.3"
76
+ "typescript": "^5.7.3",
77
+ "vitest": "^3.2.7"
75
78
  },
76
79
  "peerDependencies": {
77
80
  "@strapi/sdk-plugin": "^5.3.2",
@@ -1,84 +0,0 @@
1
- import { R as Registry } from "./index-C3MUddO-.mjs";
2
- class FetchLocales {
3
- localeGateway;
4
- constructor() {
5
- this.localeGateway = Registry.getInstance().inject("localeGateway");
6
- }
7
- async execute() {
8
- const result = await this.localeGateway.fetch();
9
- const output = result.map((data) => ({
10
- id: data.id,
11
- code: data.code,
12
- name: data.name,
13
- isDefault: data.isDefault
14
- }));
15
- return output;
16
- }
17
- }
18
- class AbstractSlugHandler {
19
- nextHandler = null;
20
- setNext(handler) {
21
- this.nextHandler = handler;
22
- return handler;
23
- }
24
- handle(text) {
25
- if (this.nextHandler) {
26
- return this.nextHandler.handle(this.process(text));
27
- }
28
- return this.process(text);
29
- }
30
- }
31
- class LowercaseHandler extends AbstractSlugHandler {
32
- process(text) {
33
- return text.toLowerCase();
34
- }
35
- }
36
- class AccentRemovalHandler extends AbstractSlugHandler {
37
- process(text) {
38
- return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
39
- }
40
- }
41
- class SpecialCharsHandler extends AbstractSlugHandler {
42
- process(text) {
43
- return text.replace(/[^a-z0-9-]+/g, "-");
44
- }
45
- }
46
- class TrimHyphensHandler extends AbstractSlugHandler {
47
- process(text) {
48
- return text.replace(/^-+|-+$/g, "");
49
- }
50
- }
51
- class MultipleHyphensHandler extends AbstractSlugHandler {
52
- process(text) {
53
- return text.replace(/-+/g, "-");
54
- }
55
- }
56
- class LengthLimitHandler extends AbstractSlugHandler {
57
- maxLength;
58
- constructor(maxLength = 100) {
59
- super();
60
- this.maxLength = maxLength;
61
- }
62
- process(text) {
63
- if (text.length > this.maxLength) {
64
- const truncated = text.substring(0, this.maxLength);
65
- return truncated.replace(/-+$/g, "");
66
- }
67
- return text;
68
- }
69
- }
70
- const convertToSlug = (text, maxLength = 100) => {
71
- if (!text) return "";
72
- const chain = new LowercaseHandler();
73
- const accentHandler = new AccentRemovalHandler();
74
- const specialCharsHandler = new SpecialCharsHandler();
75
- const trimHandler = new TrimHyphensHandler();
76
- const multipleHyphensHandler = new MultipleHyphensHandler();
77
- const lengthHandler = new LengthLimitHandler(maxLength);
78
- chain.setNext(accentHandler).setNext(specialCharsHandler).setNext(trimHandler).setNext(multipleHyphensHandler).setNext(lengthHandler);
79
- return chain.handle(text);
80
- };
81
- export {
82
- FetchLocales as F,
83
- convertToSlug as c
84
- };
@@ -1,83 +0,0 @@
1
- "use strict";
2
- const index = require("./index-UZTUyNY3.js");
3
- class FetchLocales {
4
- localeGateway;
5
- constructor() {
6
- this.localeGateway = index.Registry.getInstance().inject("localeGateway");
7
- }
8
- async execute() {
9
- const result = await this.localeGateway.fetch();
10
- const output = result.map((data) => ({
11
- id: data.id,
12
- code: data.code,
13
- name: data.name,
14
- isDefault: data.isDefault
15
- }));
16
- return output;
17
- }
18
- }
19
- class AbstractSlugHandler {
20
- nextHandler = null;
21
- setNext(handler) {
22
- this.nextHandler = handler;
23
- return handler;
24
- }
25
- handle(text) {
26
- if (this.nextHandler) {
27
- return this.nextHandler.handle(this.process(text));
28
- }
29
- return this.process(text);
30
- }
31
- }
32
- class LowercaseHandler extends AbstractSlugHandler {
33
- process(text) {
34
- return text.toLowerCase();
35
- }
36
- }
37
- class AccentRemovalHandler extends AbstractSlugHandler {
38
- process(text) {
39
- return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
40
- }
41
- }
42
- class SpecialCharsHandler extends AbstractSlugHandler {
43
- process(text) {
44
- return text.replace(/[^a-z0-9-]+/g, "-");
45
- }
46
- }
47
- class TrimHyphensHandler extends AbstractSlugHandler {
48
- process(text) {
49
- return text.replace(/^-+|-+$/g, "");
50
- }
51
- }
52
- class MultipleHyphensHandler extends AbstractSlugHandler {
53
- process(text) {
54
- return text.replace(/-+/g, "-");
55
- }
56
- }
57
- class LengthLimitHandler extends AbstractSlugHandler {
58
- maxLength;
59
- constructor(maxLength = 100) {
60
- super();
61
- this.maxLength = maxLength;
62
- }
63
- process(text) {
64
- if (text.length > this.maxLength) {
65
- const truncated = text.substring(0, this.maxLength);
66
- return truncated.replace(/-+$/g, "");
67
- }
68
- return text;
69
- }
70
- }
71
- const convertToSlug = (text, maxLength = 100) => {
72
- if (!text) return "";
73
- const chain = new LowercaseHandler();
74
- const accentHandler = new AccentRemovalHandler();
75
- const specialCharsHandler = new SpecialCharsHandler();
76
- const trimHandler = new TrimHyphensHandler();
77
- const multipleHyphensHandler = new MultipleHyphensHandler();
78
- const lengthHandler = new LengthLimitHandler(maxLength);
79
- chain.setNext(accentHandler).setNext(specialCharsHandler).setNext(trimHandler).setNext(multipleHyphensHandler).setNext(lengthHandler);
80
- return chain.handle(text);
81
- };
82
- exports.FetchLocales = FetchLocales;
83
- exports.convertToSlug = convertToSlug;