@cloudimage-strapi/content-plugin 1.0.2 → 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.
- package/README.md +7 -7
- package/dist/_chunks/App-BmZyLUWk.mjs +138 -0
- package/dist/_chunks/App-CRbNvJDt.js +138 -0
- package/dist/_chunks/en-DUVjg0jJ.js +16 -0
- package/dist/_chunks/en-r7lu9xMg.mjs +16 -0
- package/dist/_chunks/fr-DTrzyr9o.js +16 -0
- package/dist/_chunks/fr-Ge-jvwxL.mjs +16 -0
- package/dist/_chunks/index-4zkw0zS1.mjs +72 -0
- package/dist/_chunks/index-DfCnchyr.js +71 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/server/index.js +237 -0
- package/dist/server/index.mjs +238 -0
- package/package.json +69 -32
- package/LICENSE +0 -21
- package/admin/src/components/Initializer/index.js +0 -26
- package/admin/src/components/PluginIcon/index.js +0 -12
- package/admin/src/index.js +0 -63
- package/admin/src/pages/App/index.js +0 -25
- package/admin/src/pages/HomePage/index.js +0 -199
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/en.json +0 -1
- package/admin/src/translations/fr.json +0 -1
- package/admin/src/utils/axiosInstance.js +0 -40
- package/admin/src/utils/getTrad.js +0 -5
- package/server/bootstrap.js +0 -25
- package/server/config/index.js +0 -6
- package/server/content-types/index.js +0 -3
- package/server/controllers/index.js +0 -7
- package/server/controllers/scaleflex-cloudimage.js +0 -40
- package/server/destroy.js +0 -5
- package/server/index.js +0 -25
- package/server/middlewares/index.js +0 -3
- package/server/policies/index.js +0 -3
- package/server/register.js +0 -65
- package/server/routes/index.js +0 -56
- package/server/services/index.js +0 -7
- package/server/services/scaleflex-cloudimage.js +0 -172
- package/strapi-admin.js +0 -3
- 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 Scaleflex Filerobot';
|
|
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
|
-
});
|
package/strapi-admin.js
DELETED
package/strapi-server.js
DELETED