@cloudimage-strapi/content-plugin 1.0.4 → 1.0.5

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 (40) hide show
  1. package/README.md +2 -2
  2. package/dist/_chunks/App-BmZyLUWk.mjs +138 -0
  3. package/dist/_chunks/App-CRbNvJDt.js +138 -0
  4. package/dist/_chunks/en-DUVjg0jJ.js +16 -0
  5. package/dist/_chunks/en-r7lu9xMg.mjs +16 -0
  6. package/dist/_chunks/fr-DTrzyr9o.js +16 -0
  7. package/dist/_chunks/fr-Ge-jvwxL.mjs +16 -0
  8. package/dist/_chunks/index-4zkw0zS1.mjs +72 -0
  9. package/dist/_chunks/index-DfCnchyr.js +71 -0
  10. package/dist/admin/index.js +3 -0
  11. package/dist/admin/index.mjs +4 -0
  12. package/dist/server/index.js +237 -0
  13. package/dist/server/index.mjs +238 -0
  14. package/package.json +57 -75
  15. package/LICENSE +0 -21
  16. package/admin/src/components/Initializer/index.js +0 -26
  17. package/admin/src/components/PluginIcon/index.js +0 -11
  18. package/admin/src/index.js +0 -63
  19. package/admin/src/pages/App/index.js +0 -25
  20. package/admin/src/pages/HomePage/index.js +0 -199
  21. package/admin/src/pluginId.js +0 -5
  22. package/admin/src/translations/en.json +0 -1
  23. package/admin/src/translations/fr.json +0 -1
  24. package/admin/src/utils/axiosInstance.js +0 -40
  25. package/admin/src/utils/getTrad.js +0 -5
  26. package/server/bootstrap.js +0 -25
  27. package/server/config/index.js +0 -6
  28. package/server/content-types/index.js +0 -3
  29. package/server/controllers/cloudimage-by-scaleflex.js +0 -40
  30. package/server/controllers/index.js +0 -7
  31. package/server/destroy.js +0 -5
  32. package/server/index.js +0 -25
  33. package/server/middlewares/index.js +0 -3
  34. package/server/policies/index.js +0 -3
  35. package/server/register.js +0 -65
  36. package/server/routes/index.js +0 -56
  37. package/server/services/cloudimage-by-scaleflex.js +0 -172
  38. package/server/services/index.js +0 -7
  39. package/strapi-admin.js +0 -3
  40. package/strapi-server.js +0 -3
@@ -1,172 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const fetch = require("node-fetch");
6
-
7
- module.exports = ({ strapi }) => ({
8
- getWelcomeMessage() {
9
- return 'Thank you for using Cloudimage by Scaleflex';
10
- },
11
- getPluginStore() {
12
- return strapi.store({
13
- environment: strapi.config.environment,
14
- type: 'plugin',
15
- name: 'cloudimage',
16
- });
17
- },
18
- async getConfig() {
19
- const pluginStore = this.getPluginStore();
20
-
21
- let config = {
22
- domain: '',
23
- isV7: ''
24
- }
25
-
26
- const storedConfig = await pluginStore.get({key: 'options'})
27
- if (storedConfig) {
28
- config = storedConfig;
29
- }
30
-
31
- return config
32
- },
33
- async updateConfig(ctx) {
34
- const pluginStore = this.getPluginStore();
35
-
36
- await pluginStore.set({
37
- key: 'options',
38
- value: ctx.request.body
39
- });
40
-
41
- const config = await pluginStore.get({key: 'options'});
42
-
43
- return config;
44
- },
45
- async checkV7(ctx) {
46
- let domain = ctx.request.query.domain;
47
-
48
- let response = {};
49
- let responseV7 = {};
50
-
51
- try
52
- {
53
- response = await fetch(`https://${domain}/http://sample.li/blank.png`);
54
- responseV7 = await fetch(`https://${domain}/v7/http://sample.li/blank.png`);
55
- }
56
- catch (error)
57
- {
58
- console.error(error);
59
-
60
- return {domainExists: false};
61
- }
62
-
63
- let isValid = response.status === 200 && !response.headers.get('x-hexa-missingbehavior');
64
- let isV7Valid = responseV7.status === 200 && !responseV7.headers.get('x-hexa-missingbehavior');
65
-
66
- if (isValid && !isV7Valid)
67
- {
68
- return {isSuccess: true, domainExists: true, isV7: false};
69
- }
70
- else if (!isValid && isV7Valid)
71
- {
72
- return {isSuccess: true, domainExists: true, isV7: true};
73
- }
74
- else
75
- {
76
- return {isSuccess: false, domainExists: true};
77
- }
78
- },
79
- async countUpdate(ctx) {
80
- let pluginStore = this.getPluginStore();
81
- let pluginConfig = await pluginStore.get({key: 'options'});
82
- let domain = pluginConfig.domain;
83
-
84
- let media = await strapi.entityService.findMany('plugin::upload.file', {
85
- populate: {category: true},
86
- filters: { // https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/entity-service/filter.html#and
87
- $and: [
88
- {
89
- url: { $notContains: domain, },
90
- },
91
- {
92
- mime: { $contains: 'image', },
93
- },
94
- {
95
- provider: { $notContains: 'filerobot', },
96
- },
97
- ],
98
- },
99
- });
100
-
101
- return media.length;
102
- },
103
- async updateMedia(ctx) {
104
- let baseUrl = strapi.config.get('server.url');
105
- let pluginStore = this.getPluginStore();
106
- let pluginConfig = await pluginStore.get({key: 'options'});
107
- let domain = pluginConfig.domain;
108
- let isV7 = pluginConfig.isV7;
109
-
110
- let media = await strapi.entityService.findMany('plugin::upload.file', {
111
- populate: {category: true},
112
- filters: {
113
- $and: [
114
- {
115
- url: { $notContains: domain, },
116
- },
117
- {
118
- mime: { $contains: 'image', },
119
- },
120
- {
121
- provider: { $notContains: 'filerobot', },
122
- },
123
- ],
124
- },
125
- });
126
-
127
- return Promise.all(media.map((item, index) => {
128
- let prepUrl = '';
129
-
130
- if (/^https?:\/\//.test(item.url))
131
- {
132
- prepUrl = item.url.replace(/^https?:\/\//, '');
133
- }
134
- else
135
- {
136
- prepUrl = `${baseUrl}${item.url}`.replace(/^https?:\/\//, '');
137
- }
138
-
139
- let ciUrl = `https://${pluginConfig.domain}${pluginConfig.isV7 ? '/v7' : ''}/${prepUrl}`;
140
-
141
- return strapi.entityService.update('plugin::upload.file', item.id, {
142
- data: {
143
- url: ciUrl,
144
- formats: null
145
- },
146
- })
147
- .then(function(result) {
148
- return {success: true, result: result};
149
- })
150
- .catch(function(error) {
151
- return {success: false, error: error.message};
152
- });
153
- }))
154
- .then(function(results) {
155
- let successCount = 0;
156
-
157
- results.forEach((result, index) => {
158
- if (result.success)
159
- {
160
- successCount++;
161
- }
162
- });
163
-
164
- return {response: `${successCount} / ${results.length}`};
165
- })
166
- .catch(function(error) {
167
- console.dir(error.message);
168
-
169
- return {response: false};
170
- });
171
- },
172
- });
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- const scaleflexCloudimage = require('./cloudimage-by-scaleflex');
4
-
5
- module.exports = {
6
- scaleflexCloudimage,
7
- };
package/strapi-admin.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = require('./admin/src').default;
package/strapi-server.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = require('./server');