@translationstudio/translationstudio-strapi-extension 1.0.4 → 1.0.6

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.
@@ -11,6 +11,7 @@ const config = {
11
11
  }
12
12
  };
13
13
  const contentTypes = {};
14
+ const APP_NAME$1 = "translationstudio-strapi-extension";
14
15
  const controller = ({ strapi: strapi2 }) => ({
15
16
  async validateToken(ctx) {
16
17
  const authHeader = ctx.request.header.authorization;
@@ -19,7 +20,7 @@ const controller = ({ strapi: strapi2 }) => ({
19
20
  ctx.body = { error: "Missing authorization header" };
20
21
  return false;
21
22
  }
22
- const storedToken = await strapi2.plugin("translationstudio-strapi-extension").service("service").getToken();
23
+ const storedToken = await strapi2.plugin(APP_NAME$1).service("service").getToken();
23
24
  if (!storedToken?.token || authHeader !== storedToken.token) {
24
25
  ctx.status = 401;
25
26
  ctx.body = { error: "Invalid token" };
@@ -28,7 +29,7 @@ const controller = ({ strapi: strapi2 }) => ({
28
29
  return true;
29
30
  },
30
31
  async getLicense(ctx) {
31
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getLicense();
32
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getLicense();
32
33
  if (result.license) {
33
34
  ctx.status = 200;
34
35
  } else {
@@ -38,7 +39,7 @@ const controller = ({ strapi: strapi2 }) => ({
38
39
  },
39
40
  async setLicense(ctx) {
40
41
  const license = ctx.request.body.license;
41
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").setLicense(license);
42
+ const result = await strapi2.plugin(APP_NAME$1).service("service").setLicense(license);
42
43
  if (result.success) {
43
44
  ctx.status = 200;
44
45
  } else {
@@ -47,7 +48,7 @@ const controller = ({ strapi: strapi2 }) => ({
47
48
  ctx.body = result;
48
49
  },
49
50
  async getToken(ctx) {
50
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getToken();
51
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getToken();
51
52
  if (result.token) {
52
53
  ctx.status = 200;
53
54
  } else {
@@ -56,18 +57,18 @@ const controller = ({ strapi: strapi2 }) => ({
56
57
  ctx.body = result;
57
58
  },
58
59
  async generateToken(ctx) {
59
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").generateToken();
60
+ const result = await strapi2.plugin(APP_NAME$1).service("service").generateToken();
60
61
  ctx.status = 200;
61
62
  ctx.body = result;
62
63
  },
63
64
  async getLanguageOptions(ctx) {
64
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getLanguageOptions();
65
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getLanguageOptions();
65
66
  ctx.status = 200;
66
67
  ctx.body = result;
67
68
  },
68
69
  async requestTranslation(ctx) {
69
70
  const payload = ctx.request.body;
70
- const result = await strapi2.plugin("translationstudio").service("service").requestTranslation(payload);
71
+ const result = await strapi2.plugin(APP_NAME$1).service("service").requestTranslation(payload);
71
72
  ctx.body = result;
72
73
  },
73
74
  async exportData(ctx) {
@@ -76,7 +77,7 @@ const controller = ({ strapi: strapi2 }) => ({
76
77
  return;
77
78
  }
78
79
  const payload = JSON.parse(ctx.request.body);
79
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").exportData(payload);
80
+ const result = await strapi2.plugin(APP_NAME$1).service("service").exportData(payload);
80
81
  ctx.status = 200;
81
82
  ctx.body = [{ fields: result }];
82
83
  },
@@ -86,11 +87,11 @@ const controller = ({ strapi: strapi2 }) => ({
86
87
  return;
87
88
  }
88
89
  const payload = JSON.parse(ctx.request.body);
89
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").importData(payload);
90
+ const result = await strapi2.plugin(APP_NAME$1).service("service").importData(payload);
90
91
  ctx.body = result;
91
92
  },
92
93
  async ping(ctx) {
93
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").ping();
94
+ const result = await strapi2.plugin(APP_NAME$1).service("service").ping();
94
95
  ctx.status = 204;
95
96
  ctx.body = result;
96
97
  },
@@ -99,12 +100,12 @@ const controller = ({ strapi: strapi2 }) => ({
99
100
  ctx.status = 400;
100
101
  return;
101
102
  }
102
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getLanguages();
103
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getLanguages();
103
104
  ctx.status = 200;
104
105
  ctx.body = result;
105
106
  },
106
107
  async getEmail(ctx) {
107
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getEmail(ctx);
108
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getEmail(ctx);
108
109
  ctx.body = result;
109
110
  },
110
111
  async getEntryData(ctx) {
@@ -114,7 +115,7 @@ const controller = ({ strapi: strapi2 }) => ({
114
115
  }
115
116
  try {
116
117
  const [contentTypeID, entryID] = uid.split("#");
117
- const entry = await strapi2.plugin("translationstudio").service("service").getEntryData(contentTypeID, entryID, locale);
118
+ const entry = await strapi2.plugin(APP_NAME$1).service("service").getEntryData(contentTypeID, entryID, locale);
118
119
  return entry;
119
120
  } catch (error) {
120
121
  return ctx.badRequest("Failed to get entry data", { error: error.message });
@@ -878,10 +879,12 @@ function prepareImportData(translatables, existingEntry, targetSchema) {
878
879
  }
879
880
  const jwt = require("jsonwebtoken");
880
881
  const crypto = require("crypto");
882
+ const TRANSLATIONTUDIO_URL = "https://cms-strapi-service-7866fdd79eab.herokuapp.com";
883
+ const APP_NAME = "translationstudio-strapi-extension";
881
884
  const service = ({ strapi: strapi2 }) => {
882
885
  const pluginStore = strapi2.store({
883
886
  type: "plugin",
884
- name: "translationstudio"
887
+ name: APP_NAME
885
888
  });
886
889
  return {
887
890
  // translationstudio Lizenz
@@ -913,7 +916,7 @@ const service = ({ strapi: strapi2 }) => {
913
916
  const secretKey = crypto.randomBytes(64).toString("hex");
914
917
  const token = jwt.sign(
915
918
  {
916
- app: "translationstudio",
919
+ app: APP_NAME,
917
920
  iat: Math.floor(Date.now() / 1e3)
918
921
  },
919
922
  secretKey,
@@ -928,7 +931,7 @@ const service = ({ strapi: strapi2 }) => {
928
931
  async getLanguageOptions() {
929
932
  const { license } = await this.getLicense();
930
933
  const response = await fetch(
931
- "https://cms-strapi-service-7866fdd79eab.herokuapp.com/mappings",
934
+ TRANSLATIONTUDIO_URL + "/mappings",
932
935
  {
933
936
  headers: { Authorization: `${license}` }
934
937
  }
@@ -980,7 +983,7 @@ const service = ({ strapi: strapi2 }) => {
980
983
  async requestTranslation(payload) {
981
984
  const { license } = await this.getLicense();
982
985
  const response = await fetch(
983
- "https://cms-strapi-service-7866fdd79eab.herokuapp.com/translate",
986
+ TRANSLATIONTUDIO_URL + "/translate",
984
987
  {
985
988
  method: "POST",
986
989
  headers: {
@@ -10,6 +10,7 @@ const config = {
10
10
  }
11
11
  };
12
12
  const contentTypes = {};
13
+ const APP_NAME$1 = "translationstudio-strapi-extension";
13
14
  const controller = ({ strapi: strapi2 }) => ({
14
15
  async validateToken(ctx) {
15
16
  const authHeader = ctx.request.header.authorization;
@@ -18,7 +19,7 @@ const controller = ({ strapi: strapi2 }) => ({
18
19
  ctx.body = { error: "Missing authorization header" };
19
20
  return false;
20
21
  }
21
- const storedToken = await strapi2.plugin("translationstudio-strapi-extension").service("service").getToken();
22
+ const storedToken = await strapi2.plugin(APP_NAME$1).service("service").getToken();
22
23
  if (!storedToken?.token || authHeader !== storedToken.token) {
23
24
  ctx.status = 401;
24
25
  ctx.body = { error: "Invalid token" };
@@ -27,7 +28,7 @@ const controller = ({ strapi: strapi2 }) => ({
27
28
  return true;
28
29
  },
29
30
  async getLicense(ctx) {
30
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getLicense();
31
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getLicense();
31
32
  if (result.license) {
32
33
  ctx.status = 200;
33
34
  } else {
@@ -37,7 +38,7 @@ const controller = ({ strapi: strapi2 }) => ({
37
38
  },
38
39
  async setLicense(ctx) {
39
40
  const license = ctx.request.body.license;
40
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").setLicense(license);
41
+ const result = await strapi2.plugin(APP_NAME$1).service("service").setLicense(license);
41
42
  if (result.success) {
42
43
  ctx.status = 200;
43
44
  } else {
@@ -46,7 +47,7 @@ const controller = ({ strapi: strapi2 }) => ({
46
47
  ctx.body = result;
47
48
  },
48
49
  async getToken(ctx) {
49
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getToken();
50
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getToken();
50
51
  if (result.token) {
51
52
  ctx.status = 200;
52
53
  } else {
@@ -55,18 +56,18 @@ const controller = ({ strapi: strapi2 }) => ({
55
56
  ctx.body = result;
56
57
  },
57
58
  async generateToken(ctx) {
58
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").generateToken();
59
+ const result = await strapi2.plugin(APP_NAME$1).service("service").generateToken();
59
60
  ctx.status = 200;
60
61
  ctx.body = result;
61
62
  },
62
63
  async getLanguageOptions(ctx) {
63
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getLanguageOptions();
64
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getLanguageOptions();
64
65
  ctx.status = 200;
65
66
  ctx.body = result;
66
67
  },
67
68
  async requestTranslation(ctx) {
68
69
  const payload = ctx.request.body;
69
- const result = await strapi2.plugin("translationstudio").service("service").requestTranslation(payload);
70
+ const result = await strapi2.plugin(APP_NAME$1).service("service").requestTranslation(payload);
70
71
  ctx.body = result;
71
72
  },
72
73
  async exportData(ctx) {
@@ -75,7 +76,7 @@ const controller = ({ strapi: strapi2 }) => ({
75
76
  return;
76
77
  }
77
78
  const payload = JSON.parse(ctx.request.body);
78
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").exportData(payload);
79
+ const result = await strapi2.plugin(APP_NAME$1).service("service").exportData(payload);
79
80
  ctx.status = 200;
80
81
  ctx.body = [{ fields: result }];
81
82
  },
@@ -85,11 +86,11 @@ const controller = ({ strapi: strapi2 }) => ({
85
86
  return;
86
87
  }
87
88
  const payload = JSON.parse(ctx.request.body);
88
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").importData(payload);
89
+ const result = await strapi2.plugin(APP_NAME$1).service("service").importData(payload);
89
90
  ctx.body = result;
90
91
  },
91
92
  async ping(ctx) {
92
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").ping();
93
+ const result = await strapi2.plugin(APP_NAME$1).service("service").ping();
93
94
  ctx.status = 204;
94
95
  ctx.body = result;
95
96
  },
@@ -98,12 +99,12 @@ const controller = ({ strapi: strapi2 }) => ({
98
99
  ctx.status = 400;
99
100
  return;
100
101
  }
101
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getLanguages();
102
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getLanguages();
102
103
  ctx.status = 200;
103
104
  ctx.body = result;
104
105
  },
105
106
  async getEmail(ctx) {
106
- const result = await strapi2.plugin("translationstudio-strapi-extension").service("service").getEmail(ctx);
107
+ const result = await strapi2.plugin(APP_NAME$1).service("service").getEmail(ctx);
107
108
  ctx.body = result;
108
109
  },
109
110
  async getEntryData(ctx) {
@@ -113,7 +114,7 @@ const controller = ({ strapi: strapi2 }) => ({
113
114
  }
114
115
  try {
115
116
  const [contentTypeID, entryID] = uid.split("#");
116
- const entry = await strapi2.plugin("translationstudio").service("service").getEntryData(contentTypeID, entryID, locale);
117
+ const entry = await strapi2.plugin(APP_NAME$1).service("service").getEntryData(contentTypeID, entryID, locale);
117
118
  return entry;
118
119
  } catch (error) {
119
120
  return ctx.badRequest("Failed to get entry data", { error: error.message });
@@ -877,10 +878,12 @@ function prepareImportData(translatables, existingEntry, targetSchema) {
877
878
  }
878
879
  const jwt = require("jsonwebtoken");
879
880
  const crypto = require("crypto");
881
+ const TRANSLATIONTUDIO_URL = "https://cms-strapi-service-7866fdd79eab.herokuapp.com";
882
+ const APP_NAME = "translationstudio-strapi-extension";
880
883
  const service = ({ strapi: strapi2 }) => {
881
884
  const pluginStore = strapi2.store({
882
885
  type: "plugin",
883
- name: "translationstudio"
886
+ name: APP_NAME
884
887
  });
885
888
  return {
886
889
  // translationstudio Lizenz
@@ -912,7 +915,7 @@ const service = ({ strapi: strapi2 }) => {
912
915
  const secretKey = crypto.randomBytes(64).toString("hex");
913
916
  const token = jwt.sign(
914
917
  {
915
- app: "translationstudio",
918
+ app: APP_NAME,
916
919
  iat: Math.floor(Date.now() / 1e3)
917
920
  },
918
921
  secretKey,
@@ -927,7 +930,7 @@ const service = ({ strapi: strapi2 }) => {
927
930
  async getLanguageOptions() {
928
931
  const { license } = await this.getLicense();
929
932
  const response = await fetch(
930
- "https://cms-strapi-service-7866fdd79eab.herokuapp.com/mappings",
933
+ TRANSLATIONTUDIO_URL + "/mappings",
931
934
  {
932
935
  headers: { Authorization: `${license}` }
933
936
  }
@@ -979,7 +982,7 @@ const service = ({ strapi: strapi2 }) => {
979
982
  async requestTranslation(payload) {
980
983
  const { license } = await this.getLicense();
981
984
  const response = await fetch(
982
- "https://cms-strapi-service-7866fdd79eab.herokuapp.com/translate",
985
+ TRANSLATIONTUDIO_URL + "/translate",
983
986
  {
984
987
  method: "POST",
985
988
  headers: {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "license": "GPL-2.0-only",
5
5
  "author": "Duncan Leininger <duncan.leininger@idmedia.com>",
6
6
  "homepage": "https://translationstudio.tech",
7
- "version": "1.0.4",
7
+ "version": "1.0.6",
8
8
  "keywords": [
9
9
  "translationstudio",
10
10
  "strapi",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "strapi": {
69
69
  "kind": "plugin",
70
- "name": "translationstudio",
70
+ "name": "translationstudio-strapi-extension",
71
71
  "displayName": "translationstudio",
72
72
  "description": "translationstudio extension for strapi"
73
73
  }