@translationstudio/translationstudio-strapi-extension 2.0.2 → 4.0.0

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 (46) hide show
  1. package/README.md +1 -1
  2. package/dist/Types.d.ts +36 -0
  3. package/dist/_chunks/App-BR-y9Q87.js +331 -0
  4. package/dist/_chunks/App-Cc3EklWX.mjs +331 -0
  5. package/dist/_chunks/HistoryPage-BG_RchOk.js +1057 -0
  6. package/dist/_chunks/HistoryPage-CSMW8AED.mjs +1057 -0
  7. package/dist/_chunks/index-B9kFLfY3.js +834 -0
  8. package/dist/_chunks/index-ChM8Lw4L.mjs +835 -0
  9. package/dist/admin/index.js +2 -344
  10. package/dist/admin/index.mjs +2 -344
  11. package/dist/admin/src/components/BulkTranslationMenu.d.ts +3 -0
  12. package/dist/admin/src/components/BulkTranslationPanel.d.ts +3 -0
  13. package/dist/admin/src/components/EntryHistory.d.ts +3 -0
  14. package/dist/admin/src/components/HistoryIcon.d.ts +2 -0
  15. package/dist/admin/src/components/HistoryMenu.d.ts +2 -0
  16. package/dist/admin/src/components/LoadingSpinner.d.ts +4 -0
  17. package/dist/admin/src/components/SettingsIcon.d.ts +2 -0
  18. package/dist/admin/src/components/TranslationstudioLogo.d.ts +2 -0
  19. package/dist/admin/src/components/utils/alertUtils.d.ts +13 -0
  20. package/dist/admin/src/components/utils/dateUtils.d.ts +1 -0
  21. package/dist/admin/src/components/utils/emailUtils.d.ts +2 -0
  22. package/dist/admin/src/components/utils/entryUtils.d.ts +2 -0
  23. package/dist/admin/src/components/utils/filterAndTransformContentTypes.d.ts +2 -0
  24. package/dist/admin/src/components/utils/formatDate.d.ts +1 -0
  25. package/dist/admin/src/components/utils/getEntryHelper.d.ts +3 -0
  26. package/dist/admin/src/components/utils/handleHistoryResponse.d.ts +5 -0
  27. package/dist/admin/src/components/utils/historyDataUtils.d.ts +13 -0
  28. package/dist/admin/src/components/utils/historyStatusUtils.d.ts +7 -0
  29. package/dist/admin/src/components/utils/searchUtils.d.ts +2 -0
  30. package/dist/admin/src/components/utils/sortUtils.d.ts +9 -0
  31. package/dist/admin/src/components/utils/statusHelper.d.ts +6 -0
  32. package/dist/admin/src/components/utils/theme.d.ts +15 -0
  33. package/dist/admin/src/components/utils/translationUtils.d.ts +5 -0
  34. package/dist/admin/src/components/utils/useDebounce.d.ts +1 -0
  35. package/dist/admin/src/pages/HistoryPage.d.ts +2 -0
  36. package/dist/server/index.js +50 -29
  37. package/dist/server/index.mjs +50 -29
  38. package/dist/server/src/controllers/controller.d.ts +1 -1
  39. package/dist/server/src/controllers/index.d.ts +1 -1
  40. package/dist/server/src/index.d.ts +2 -4
  41. package/dist/server/src/services/functions/importData/transformFieldsToData.d.ts +1 -1
  42. package/dist/server/src/services/index.d.ts +1 -3
  43. package/dist/server/src/services/service.d.ts +1 -3
  44. package/package.json +23 -21
  45. package/dist/_chunks/App-C5dxwMbx.js +0 -342
  46. package/dist/_chunks/App-DxAbaDu8.mjs +0 -342
@@ -162,10 +162,6 @@ const controller = ({ strapi: strapi2 }) => ({
162
162
  ctx.body = {};
163
163
  }
164
164
  },
165
- async getEmail(ctx) {
166
- const result = await strapi2.plugin(APP_NAME$1).service("service").getEmail(ctx);
167
- ctx.body = result;
168
- },
169
165
  async getEntryData(ctx) {
170
166
  const { uid, locale } = ctx.request.body;
171
167
  if (!uid) {
@@ -178,6 +174,19 @@ const controller = ({ strapi: strapi2 }) => ({
178
174
  } catch (error) {
179
175
  return ctx.badRequest("Failed to get entry data", { error: error.message });
180
176
  }
177
+ },
178
+ async getHistory(ctx) {
179
+ try {
180
+ const { entryUid } = ctx.request.query;
181
+ const decodedEntryUid = entryUid ? decodeURIComponent(entryUid) : void 0;
182
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getHistory(decodedEntryUid);
183
+ ctx.status = 200;
184
+ ctx.body = result;
185
+ } catch (err) {
186
+ console.error(err);
187
+ ctx.status = 500;
188
+ ctx.body = { error: "Failed to fetch history" };
189
+ }
181
190
  }
182
191
  });
183
192
  const controllers = {
@@ -286,19 +295,19 @@ const routes = [
286
295
  policies: []
287
296
  }
288
297
  },
298
+ /* get entry title */
289
299
  {
290
- method: "GET",
291
- path: "/email",
292
- handler: "controller.getEmail",
300
+ method: "POST",
301
+ path: "/entrydata",
302
+ handler: "controller.getEntryData",
293
303
  config: {
294
304
  policies: []
295
305
  }
296
306
  },
297
- /* get entry title */
298
307
  {
299
- method: "POST",
300
- path: "/entrydata",
301
- handler: "controller.getEntryData",
308
+ method: "GET",
309
+ path: "/history",
310
+ handler: "controller.getHistory",
302
311
  config: {
303
312
  policies: []
304
313
  }
@@ -1102,8 +1111,7 @@ const service = ({ strapi: strapi2 }) => {
1102
1111
  async getTranslationstudioUrl() {
1103
1112
  try {
1104
1113
  const result = await pluginStore.get({ key: "developurl" });
1105
- if (typeof result === "string" && result !== "")
1106
- return result;
1114
+ if (typeof result === "string" && result !== "") return result;
1107
1115
  } catch (err) {
1108
1116
  strapi2.log.warn(err);
1109
1117
  }
@@ -1134,8 +1142,7 @@ const service = ({ strapi: strapi2 }) => {
1134
1142
  async getDevelopmentUrl() {
1135
1143
  try {
1136
1144
  const result = await pluginStore.get({ key: "developurl" });
1137
- if (typeof result === "string")
1138
- return result;
1145
+ if (typeof result === "string") return result;
1139
1146
  } catch (error) {
1140
1147
  }
1141
1148
  return "";
@@ -1186,7 +1193,9 @@ const service = ({ strapi: strapi2 }) => {
1186
1193
  try {
1187
1194
  const sourceEntry = await getEntry(contentTypeID, entryID, sourceLocale);
1188
1195
  if (sourceEntry == null)
1189
- throw new Error("Cannot find source entry " + contentTypeID + "::" + entryID + " in " + sourceLocale);
1196
+ throw new Error(
1197
+ "Cannot find source entry " + contentTypeID + "::" + entryID + " in " + sourceLocale
1198
+ );
1190
1199
  const targetSchema = getContentType(contentTypeID);
1191
1200
  if (targetSchema === null || !IsLocalisableSchema(targetSchema.entry))
1192
1201
  throw new Error("Cannot find schema");
@@ -1199,12 +1208,7 @@ const service = ({ strapi: strapi2 }) => {
1199
1208
  strapi2.log.info("Loading target language entry");
1200
1209
  const targetLocaleEntry = await getEntry(contentTypeID, entryID, targetLocale);
1201
1210
  appendMissingFields(data, sourceEntry, targetSchema, targetLocaleEntry);
1202
- await updateEntry(
1203
- contentTypeID,
1204
- entryID,
1205
- targetLocale,
1206
- data
1207
- );
1211
+ await updateEntry(contentTypeID, entryID, targetLocale, data);
1208
1212
  return true;
1209
1213
  } catch (error) {
1210
1214
  strapi2.log.error(error);
@@ -1224,13 +1228,6 @@ const service = ({ strapi: strapi2 }) => {
1224
1228
  });
1225
1229
  if (response.status === 204) return true;
1226
1230
  },
1227
- async getEmail(ctx) {
1228
- const user = ctx.state.user;
1229
- if (!user) {
1230
- return { email: null };
1231
- }
1232
- return { email: user.email };
1233
- },
1234
1231
  async getLanguages() {
1235
1232
  try {
1236
1233
  const locales = await strapi2.plugin("i18n").service("locales").find();
@@ -1249,6 +1246,30 @@ const service = ({ strapi: strapi2 }) => {
1249
1246
  async getEntryData(contentTypeID, entryID, locale) {
1250
1247
  const entry = await getEntry(contentTypeID, entryID, locale);
1251
1248
  return entry;
1249
+ },
1250
+ async getHistory(entryUid) {
1251
+ const { license } = await this.getLicense();
1252
+ const url = await this.getTranslationstudioUrl();
1253
+ if (entryUid) {
1254
+ const response = await fetch(url + "/history", {
1255
+ method: "POST",
1256
+ headers: {
1257
+ Authorization: `${license}`,
1258
+ "Content-Type": "application/json"
1259
+ },
1260
+ body: JSON.stringify({
1261
+ element: entryUid
1262
+ })
1263
+ });
1264
+ const responseData = await response.json();
1265
+ return responseData;
1266
+ } else {
1267
+ const response = await fetch(url + "/history/project", {
1268
+ headers: { Authorization: `${license}` }
1269
+ });
1270
+ const responseData = await response.json();
1271
+ return responseData;
1272
+ }
1252
1273
  }
1253
1274
  };
1254
1275
  };
@@ -143,10 +143,6 @@ const controller = ({ strapi: strapi2 }) => ({
143
143
  ctx.body = {};
144
144
  }
145
145
  },
146
- async getEmail(ctx) {
147
- const result = await strapi2.plugin(APP_NAME$1).service("service").getEmail(ctx);
148
- ctx.body = result;
149
- },
150
146
  async getEntryData(ctx) {
151
147
  const { uid, locale } = ctx.request.body;
152
148
  if (!uid) {
@@ -159,6 +155,19 @@ const controller = ({ strapi: strapi2 }) => ({
159
155
  } catch (error) {
160
156
  return ctx.badRequest("Failed to get entry data", { error: error.message });
161
157
  }
158
+ },
159
+ async getHistory(ctx) {
160
+ try {
161
+ const { entryUid } = ctx.request.query;
162
+ const decodedEntryUid = entryUid ? decodeURIComponent(entryUid) : void 0;
163
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getHistory(decodedEntryUid);
164
+ ctx.status = 200;
165
+ ctx.body = result;
166
+ } catch (err) {
167
+ console.error(err);
168
+ ctx.status = 500;
169
+ ctx.body = { error: "Failed to fetch history" };
170
+ }
162
171
  }
163
172
  });
164
173
  const controllers = {
@@ -267,19 +276,19 @@ const routes = [
267
276
  policies: []
268
277
  }
269
278
  },
279
+ /* get entry title */
270
280
  {
271
- method: "GET",
272
- path: "/email",
273
- handler: "controller.getEmail",
281
+ method: "POST",
282
+ path: "/entrydata",
283
+ handler: "controller.getEntryData",
274
284
  config: {
275
285
  policies: []
276
286
  }
277
287
  },
278
- /* get entry title */
279
288
  {
280
- method: "POST",
281
- path: "/entrydata",
282
- handler: "controller.getEntryData",
289
+ method: "GET",
290
+ path: "/history",
291
+ handler: "controller.getHistory",
283
292
  config: {
284
293
  policies: []
285
294
  }
@@ -1083,8 +1092,7 @@ const service = ({ strapi: strapi2 }) => {
1083
1092
  async getTranslationstudioUrl() {
1084
1093
  try {
1085
1094
  const result = await pluginStore.get({ key: "developurl" });
1086
- if (typeof result === "string" && result !== "")
1087
- return result;
1095
+ if (typeof result === "string" && result !== "") return result;
1088
1096
  } catch (err) {
1089
1097
  strapi2.log.warn(err);
1090
1098
  }
@@ -1115,8 +1123,7 @@ const service = ({ strapi: strapi2 }) => {
1115
1123
  async getDevelopmentUrl() {
1116
1124
  try {
1117
1125
  const result = await pluginStore.get({ key: "developurl" });
1118
- if (typeof result === "string")
1119
- return result;
1126
+ if (typeof result === "string") return result;
1120
1127
  } catch (error) {
1121
1128
  }
1122
1129
  return "";
@@ -1167,7 +1174,9 @@ const service = ({ strapi: strapi2 }) => {
1167
1174
  try {
1168
1175
  const sourceEntry = await getEntry(contentTypeID, entryID, sourceLocale);
1169
1176
  if (sourceEntry == null)
1170
- throw new Error("Cannot find source entry " + contentTypeID + "::" + entryID + " in " + sourceLocale);
1177
+ throw new Error(
1178
+ "Cannot find source entry " + contentTypeID + "::" + entryID + " in " + sourceLocale
1179
+ );
1171
1180
  const targetSchema = getContentType(contentTypeID);
1172
1181
  if (targetSchema === null || !IsLocalisableSchema(targetSchema.entry))
1173
1182
  throw new Error("Cannot find schema");
@@ -1180,12 +1189,7 @@ const service = ({ strapi: strapi2 }) => {
1180
1189
  strapi2.log.info("Loading target language entry");
1181
1190
  const targetLocaleEntry = await getEntry(contentTypeID, entryID, targetLocale);
1182
1191
  appendMissingFields(data, sourceEntry, targetSchema, targetLocaleEntry);
1183
- await updateEntry(
1184
- contentTypeID,
1185
- entryID,
1186
- targetLocale,
1187
- data
1188
- );
1192
+ await updateEntry(contentTypeID, entryID, targetLocale, data);
1189
1193
  return true;
1190
1194
  } catch (error) {
1191
1195
  strapi2.log.error(error);
@@ -1205,13 +1209,6 @@ const service = ({ strapi: strapi2 }) => {
1205
1209
  });
1206
1210
  if (response.status === 204) return true;
1207
1211
  },
1208
- async getEmail(ctx) {
1209
- const user = ctx.state.user;
1210
- if (!user) {
1211
- return { email: null };
1212
- }
1213
- return { email: user.email };
1214
- },
1215
1212
  async getLanguages() {
1216
1213
  try {
1217
1214
  const locales = await strapi2.plugin("i18n").service("locales").find();
@@ -1230,6 +1227,30 @@ const service = ({ strapi: strapi2 }) => {
1230
1227
  async getEntryData(contentTypeID, entryID, locale) {
1231
1228
  const entry = await getEntry(contentTypeID, entryID, locale);
1232
1229
  return entry;
1230
+ },
1231
+ async getHistory(entryUid) {
1232
+ const { license } = await this.getLicense();
1233
+ const url = await this.getTranslationstudioUrl();
1234
+ if (entryUid) {
1235
+ const response = await fetch(url + "/history", {
1236
+ method: "POST",
1237
+ headers: {
1238
+ Authorization: `${license}`,
1239
+ "Content-Type": "application/json"
1240
+ },
1241
+ body: JSON.stringify({
1242
+ element: entryUid
1243
+ })
1244
+ });
1245
+ const responseData = await response.json();
1246
+ return responseData;
1247
+ } else {
1248
+ const response = await fetch(url + "/history/project", {
1249
+ headers: { Authorization: `${license}` }
1250
+ });
1251
+ const responseData = await response.json();
1252
+ return responseData;
1253
+ }
1233
1254
  }
1234
1255
  };
1235
1256
  };
@@ -15,7 +15,7 @@ declare const controller: ({ strapi }: {
15
15
  importData(ctx: any): Promise<void>;
16
16
  ping(ctx: any): Promise<void>;
17
17
  getLanguages(ctx: any): Promise<void>;
18
- getEmail(ctx: any): Promise<void>;
19
18
  getEntryData(ctx: any): Promise<any>;
19
+ getHistory(ctx: any): Promise<void>;
20
20
  };
21
21
  export default controller;
@@ -15,8 +15,8 @@ declare const _default: {
15
15
  importData(ctx: any): Promise<void>;
16
16
  ping(ctx: any): Promise<void>;
17
17
  getLanguages(ctx: any): Promise<void>;
18
- getEmail(ctx: any): Promise<void>;
19
18
  getEntryData(ctx: any): Promise<any>;
19
+ getHistory(ctx: any): Promise<void>;
20
20
  };
21
21
  };
22
22
  export default _default;
@@ -29,8 +29,8 @@ declare const _default: {
29
29
  importData(ctx: any): Promise<void>;
30
30
  ping(ctx: any): Promise<void>;
31
31
  getLanguages(ctx: any): Promise<void>;
32
- getEmail(ctx: any): Promise<void>;
33
32
  getEntryData(ctx: any): Promise<any>;
33
+ getHistory(ctx: any): Promise<void>;
34
34
  };
35
35
  };
36
36
  routes: ({
@@ -76,12 +76,10 @@ declare const _default: {
76
76
  }>;
77
77
  importData(payload: import("../../Types").ImportPayload): Promise<boolean>;
78
78
  requestTranslation(payload: import("../../Types").TranslationRequest): Promise<boolean>;
79
- getEmail(ctx: any): Promise<{
80
- email: any;
81
- }>;
82
79
  getLanguages(): Promise<import("../../Types").LocaleMap>;
83
80
  ping(): Promise<void>;
84
81
  getEntryData(contentTypeID: string, entryID: string, locale: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
82
+ getHistory(entryUid?: string): Promise<unknown>;
85
83
  };
86
84
  };
87
85
  contentTypes: {};
@@ -1,2 +1,2 @@
1
- import { TranslationstudioTranslatable } from "../../../../../Types";
1
+ import { TranslationstudioTranslatable } from '../../../../../Types';
2
2
  export declare function transformFieldsToData(fields: TranslationstudioTranslatable[]): Record<string, any>;
@@ -24,12 +24,10 @@ declare const _default: {
24
24
  }>;
25
25
  importData(payload: import("../../../Types").ImportPayload): Promise<boolean>;
26
26
  requestTranslation(payload: import("../../../Types").TranslationRequest): Promise<boolean>;
27
- getEmail(ctx: any): Promise<{
28
- email: any;
29
- }>;
30
27
  getLanguages(): Promise<import("../../../Types").LocaleMap>;
31
28
  ping(): Promise<void>;
32
29
  getEntryData(contentTypeID: string, entryID: string, locale: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
30
+ getHistory(entryUid?: string): Promise<unknown>;
33
31
  };
34
32
  };
35
33
  export default _default;
@@ -25,11 +25,9 @@ declare const service: ({ strapi }: {
25
25
  }>;
26
26
  importData(payload: ImportPayload): Promise<boolean>;
27
27
  requestTranslation(payload: TranslationRequest): Promise<boolean>;
28
- getEmail(ctx: any): Promise<{
29
- email: any;
30
- }>;
31
28
  getLanguages(): Promise<LocaleMap>;
32
29
  ping(): Promise<void>;
33
30
  getEntryData(contentTypeID: string, entryID: string, locale: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
31
+ getHistory(entryUid?: string): Promise<unknown>;
34
32
  };
35
33
  export default service;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  }
11
11
  ],
12
12
  "homepage": "https://translationstudio.tech",
13
- "version": "2.0.2",
13
+ "version": "4.0.0",
14
14
  "keywords": [
15
15
  "translationstudio",
16
16
  "strapi",
@@ -50,32 +50,34 @@
50
50
  "test:ts:back": "run -T tsc -p server/tsconfig.json"
51
51
  },
52
52
  "dependencies": {
53
- "@strapi/design-system": "^2.0.0-rc.14",
54
- "@strapi/icons": "^2.0.0-rc.14",
55
- "react-intl": "^7.1.10",
53
+ "@strapi/design-system": "2.0.1",
54
+ "@strapi/icons": "2.0.1",
55
+ "react-intl": "7.1.10",
56
56
  "translationstudio-strapi-extension": "file:.yalc/translationstudio-strapi-extension"
57
57
  },
58
58
  "devDependencies": {
59
- "@babel/preset-typescript": "^7.27.1",
60
- "@jest/globals": "^30.0.0-beta.3",
61
- "@strapi/sdk-plugin": "^5.3.2",
62
- "@strapi/strapi": "^5.12.4",
63
- "@strapi/typescript-utils": "^5.5.0",
59
+ "@babel/preset-typescript": "7.27.1",
60
+ "@jest/globals": "30.0.0-beta.3",
61
+ "@strapi/sdk-plugin": "5.4.0",
62
+ "@strapi/strapi": "5.33.1",
63
+ "@strapi/typescript-utils": "5.33.1",
64
64
  "@types/jest": "^29.5.14",
65
- "@types/react": "^18.3.1",
66
- "@types/react-dom": "^18.3.1",
67
- "jest": "^29.7.0",
68
- "prettier": "^3.4.2",
69
- "ts-jest": "^29.3.4",
70
- "typescript": "^5.7.2"
65
+ "@types/react": "18.3.20",
66
+ "@types/react-dom": "18.3.6",
67
+ "jest": "29.7.0",
68
+ "prettier": "3.4.2",
69
+ "ts-jest": "29.3.4",
70
+ "typescript": "5.7.2",
71
+ "@strapi/design-system": "2.0.1",
72
+ "@strapi/icons": "2.0.1"
71
73
  },
72
74
  "peerDependencies": {
73
- "@strapi/sdk-plugin": "^5.2.7",
74
- "@strapi/strapi": "^5.5.0",
75
- "react": "^18.3.1",
76
- "react-dom": "^18.3.1",
77
- "react-router-dom": "^6.28.0",
78
- "styled-components": "^6.1.13"
75
+ "@strapi/sdk-plugin": "5.4.0",
76
+ "@strapi/strapi": "5.33.1",
77
+ "react": "18.3.1",
78
+ "react-dom": "18.3.1",
79
+ "react-router-dom": "6.30.0",
80
+ "styled-components": "6.1.13"
79
81
  },
80
82
  "strapi": {
81
83
  "kind": "plugin",