@silexlabs/silex 3.0.0-alpha.41 → 3.0.0-alpha.42
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/.silex.js +2 -11
- package/dist/client/client/api.d.ts +83 -0
- package/dist/client/client/config.d.ts +3 -3
- package/dist/client/client/expose.d.ts +6 -0
- package/dist/client/client/grapesjs/LoginDialog.d.ts +3 -2
- package/dist/client/client/grapesjs/PublicationManager.d.ts +9 -3
- package/dist/client/client/grapesjs/PublicationUi.d.ts +9 -6
- package/dist/client/client/grapesjs/index.d.ts +4 -4
- package/dist/client/client/grapesjs/openImport.d.ts +5 -0
- package/dist/client/constants.d.ts +23 -14
- package/dist/client/events.d.ts +8 -0
- package/dist/client/js/main.js +90 -111
- package/dist/client/js/main.js.LICENSE.txt +0 -6
- package/dist/client/page.d.ts +1 -1
- package/dist/client/types.d.ts +125 -86
- package/dist/plugins/client/client/utils.d.ts +1 -0
- package/dist/{events.js → plugins/client/client/utils.js} +9 -6
- package/dist/plugins/client/client/utils.js.map +1 -0
- package/dist/plugins/client/events.d.ts +10 -0
- package/dist/plugins/client/events.js +27 -0
- package/dist/plugins/client/events.js.map +1 -0
- package/dist/plugins/client/plugins/client/template.d.ts +2 -0
- package/dist/plugins/client/plugins/client/template.js +186 -0
- package/dist/plugins/client/plugins/client/template.js.map +1 -0
- package/dist/plugins/server/constants.d.ts +30 -0
- package/dist/plugins/server/constants.js +50 -0
- package/dist/plugins/server/constants.js.map +1 -0
- package/dist/plugins/server/events.d.ts +10 -0
- package/dist/plugins/server/events.js +30 -0
- package/dist/plugins/server/events.js.map +1 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.js.map +1 -0
- package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
- package/dist/plugins/server/plugins/server/FtpConnector.d.ts +94 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js +521 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
- package/dist/plugins/{HooksPlugin.d.ts → server/plugins/server/HooksPlugin.d.ts} +1 -1
- package/dist/plugins/{HooksPlugin.js → server/plugins/server/HooksPlugin.js} +4 -6
- package/dist/plugins/server/plugins/server/HooksPlugin.js.map +1 -0
- package/dist/plugins/{SslPlugin.js → server/plugins/server/SslPlugin.js} +7 -7
- package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
- package/dist/plugins/{StaticPlugin.js → server/plugins/server/StaticPlugin.js} +8 -3
- package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
- package/dist/{server → plugins/server/server}/config.d.ts +13 -12
- package/dist/{server → plugins/server/server}/config.js +44 -34
- package/dist/plugins/server/server/config.js.map +1 -0
- package/dist/plugins/server/server/connectors/FsHosting.d.ts +13 -0
- package/dist/plugins/server/server/connectors/FsHosting.js +55 -0
- package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
- package/dist/plugins/server/server/connectors/FsStorage.d.ts +40 -0
- package/dist/{server/backends/FsBackend.js → plugins/server/server/connectors/FsStorage.js} +93 -125
- package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
- package/dist/plugins/server/server/connectors/connectors.d.ts +83 -0
- package/dist/plugins/server/server/connectors/connectors.js +98 -0
- package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
- package/dist/plugins/server/server/jobs.js.map +1 -0
- package/dist/{server → plugins/server/server}/utils/validation.js +3 -2
- package/dist/plugins/server/server/utils/validation.js.map +1 -0
- package/dist/plugins/server/types.d.ts +309 -0
- package/dist/{types.js → plugins/server/types.js} +18 -7
- package/dist/plugins/server/types.js.map +1 -0
- package/dist/server/constants.js +30 -0
- package/dist/server/events.js +13 -0
- package/dist/server/plugins/server/Cache.js +15 -0
- package/dist/server/server/api/api.js +20 -0
- package/dist/server/server/api/connectorApi.js +200 -0
- package/dist/server/server/api/publicationApi.js +116 -0
- package/dist/server/server/api/websiteApi.js +288 -0
- package/dist/server/{cli.js → server/cli.js} +2 -1
- package/dist/server/server/config.js +124 -0
- package/dist/server/server/connectors/FsHosting.js +37 -0
- package/dist/server/server/connectors/FsStorage.js +208 -0
- package/dist/server/server/connectors/connectors.js +65 -0
- package/dist/server/{express.js → server/express.js} +1 -0
- package/dist/server/{index.js → server/index.js} +6 -3
- package/dist/server/server/jobs.js +47 -0
- package/dist/server/server/utils/validation.js +15 -0
- package/dist/server/types.js +19 -0
- package/package.json +24 -14
- package/src/ts/client/api.ts +135 -0
- package/src/ts/client/config.ts +3 -3
- package/src/ts/client/expose.ts +11 -0
- package/src/ts/client/grapesjs/LoginDialog.ts +33 -32
- package/src/ts/client/grapesjs/PublicationManager.ts +86 -112
- package/src/ts/client/grapesjs/PublicationUi.ts +43 -33
- package/src/ts/client/grapesjs/eleventy.ts +4 -1
- package/src/ts/client/grapesjs/index.ts +6 -19
- package/src/ts/client/grapesjs/openImport.ts +5 -0
- package/src/ts/client/grapesjs/storage.ts +18 -14
- package/src/ts/client/index.ts +15 -10
- package/src/ts/constants.ts +24 -14
- package/src/ts/events.ts +8 -0
- package/src/ts/page.ts +1 -1
- package/src/ts/plugins/client/template.ts +196 -0
- package/src/ts/plugins/server/FtpConnector.ts +602 -0
- package/src/ts/plugins/{HooksPlugin.ts → server/HooksPlugin.ts} +2 -4
- package/src/ts/plugins/{SslPlugin.ts → server/SslPlugin.ts} +7 -7
- package/src/ts/plugins/{StaticPlugin.ts → server/StaticPlugin.ts} +7 -3
- package/src/ts/server/api/api.ts +19 -0
- package/src/ts/server/api/connectorApi.ts +322 -0
- package/src/ts/server/api/publicationApi.ts +179 -0
- package/src/ts/server/api/websiteApi.ts +397 -0
- package/src/ts/server/cli.ts +3 -1
- package/src/ts/server/config.ts +47 -36
- package/src/ts/server/connectors/FsHosting.ts +60 -0
- package/src/ts/server/connectors/FsStorage.ts +236 -0
- package/src/ts/server/connectors/connectors.ts +171 -0
- package/src/ts/server/express.ts +1 -0
- package/src/ts/server/index.ts +5 -5
- package/src/ts/server/jobs.test.ts +1 -0
- package/src/ts/server/utils/BackwardCompat.ts +1 -1
- package/src/ts/server/utils/validation.ts +3 -2
- package/src/ts/types.ts +93 -61
- package/dist/client/client/grapesjs/eleventy.d.ts +0 -1
- package/dist/client/client/grapesjs/template.d.ts +0 -1
- package/dist/client/client/services.d.ts +0 -35
- package/dist/constants.d.ts +0 -21
- package/dist/constants.js +0 -41
- package/dist/constants.js.map +0 -1
- package/dist/events.d.ts +0 -2
- package/dist/events.js.map +0 -1
- package/dist/plugins/AuthPlugin.js.map +0 -1
- package/dist/plugins/Cache.js.map +0 -1
- package/dist/plugins/FtpBackend.d.ts +0 -92
- package/dist/plugins/FtpBackend.js +0 -604
- package/dist/plugins/FtpBackend.js.map +0 -1
- package/dist/plugins/HooksPlugin.js.map +0 -1
- package/dist/plugins/PublicationPlugin.d.ts +0 -17
- package/dist/plugins/PublicationPlugin.js +0 -170
- package/dist/plugins/PublicationPlugin.js.map +0 -1
- package/dist/plugins/SslPlugin.js.map +0 -1
- package/dist/plugins/StaticPlugin.js.map +0 -1
- package/dist/plugins/WebsitePlugin.d.ts +0 -14
- package/dist/plugins/WebsitePlugin.js +0 -302
- package/dist/plugins/WebsitePlugin.js.map +0 -1
- package/dist/server/backends/FsBackend.d.ts +0 -42
- package/dist/server/backends/FsBackend.js.map +0 -1
- package/dist/server/backends/index.d.ts +0 -95
- package/dist/server/backends/index.js +0 -255
- package/dist/server/backends/index.js.map +0 -1
- package/dist/server/config.js.map +0 -1
- package/dist/server/jobs.js.map +0 -1
- package/dist/server/utils/validation.js.map +0 -1
- package/dist/types.d.ts +0 -270
- package/dist/types.js.map +0 -1
- package/src/ts/client/grapesjs/template.ts +0 -183
- package/src/ts/client/services.ts +0 -129
- package/src/ts/plugins/FtpBackend.ts +0 -689
- package/src/ts/plugins/PublicationPlugin.ts +0 -170
- package/src/ts/plugins/WebsitePlugin.ts +0 -318
- package/src/ts/server/backends/FsBackend.ts +0 -266
- package/src/ts/server/backends/index.ts +0 -309
- /package/dist/plugins/{AuthPlugin.d.ts → server/plugins/server/AuthPlugin.d.ts} +0 -0
- /package/dist/plugins/{AuthPlugin.js → server/plugins/server/AuthPlugin.js} +0 -0
- /package/dist/plugins/{Cache.d.ts → server/plugins/server/Cache.d.ts} +0 -0
- /package/dist/plugins/{Cache.js → server/plugins/server/Cache.js} +0 -0
- /package/dist/plugins/{SslPlugin.d.ts → server/plugins/server/SslPlugin.d.ts} +0 -0
- /package/dist/plugins/{StaticPlugin.d.ts → server/plugins/server/StaticPlugin.d.ts} +0 -0
- /package/dist/{server → plugins/server/server}/jobs.d.ts +0 -0
- /package/dist/{server → plugins/server/server}/jobs.js +0 -0
- /package/dist/{server → plugins/server/server}/utils/validation.d.ts +0 -0
- /package/src/ts/plugins/{AuthPlugin.ts → server/AuthPlugin.ts} +0 -0
- /package/src/ts/plugins/{Cache.ts → server/Cache.ts} +0 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
const basic_ftp_1 = require("basic-ftp");
|
|
20
|
+
const stream_1 = require("stream");
|
|
21
|
+
const connectors_1 = require("../../server/connectors/connectors");
|
|
22
|
+
const validation_1 = require("../../server/utils/validation");
|
|
23
|
+
const constants_1 = require("../../constants");
|
|
24
|
+
const types_1 = require("../../types");
|
|
25
|
+
const jobs_1 = require("../../server/jobs");
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
const os_1 = require("os");
|
|
28
|
+
const uuid_1 = require("uuid");
|
|
29
|
+
// **
|
|
30
|
+
// Utils methos
|
|
31
|
+
function formHtml(redirectTo, type, { host, user, pass, port, secure, storageRootPath, publicationPath, websiteUrl }, err = '') {
|
|
32
|
+
return `
|
|
33
|
+
${err && `<div class="error">${err || ''}</div>`}
|
|
34
|
+
<form method="POST" action="${redirectTo}">
|
|
35
|
+
<label for="host">Host</label>
|
|
36
|
+
<input placeholder="ftp.example.com" type="text" name="host" value="${host || ''}" />
|
|
37
|
+
<label for="user">User</label>
|
|
38
|
+
<input placeholder="user" type="text" name="user" value="${user || ''}" />
|
|
39
|
+
<label for="pass">Pass</label>
|
|
40
|
+
<input placeholder="****" type="password" name="pass" value="${pass || ''}" />
|
|
41
|
+
<label for="port">Port</label>
|
|
42
|
+
<input placeholder="21" type="number" name="port" value="${port || '21'}" />
|
|
43
|
+
<div class="checkbox-container">
|
|
44
|
+
<input class="checkbox" type="checkbox" name="secure" value="true" ${secure ? 'checked' : ''} />
|
|
45
|
+
<label for="secure">Secure</label>
|
|
46
|
+
</div>
|
|
47
|
+
${type === types_1.ConnectorType.STORAGE ? `
|
|
48
|
+
<details>
|
|
49
|
+
<summary>Storage options</summary>
|
|
50
|
+
<p>If you are not sure, don't change this</p>
|
|
51
|
+
<label for="storageRootPath">Root path where to store the website files</label>
|
|
52
|
+
<input placeholder="/silex/" type="text" name="storageRootPath" value="${storageRootPath || '/silex/'}" />
|
|
53
|
+
</details>
|
|
54
|
+
` : ''}
|
|
55
|
+
${type === types_1.ConnectorType.HOSTING ? `
|
|
56
|
+
<fieldset>
|
|
57
|
+
<legend>Publication options</legend>
|
|
58
|
+
<label for="publicationPath">Path where to publish</label>
|
|
59
|
+
<input placeholder="/public_html/" type="text" name="publicationPath" value="${publicationPath || ''}" />
|
|
60
|
+
<label for="websiteUrl">URL where to the site will be accessible</label>
|
|
61
|
+
<input placeholder="https://mysite.com/" type="text" name="websiteUrl" value="${websiteUrl || ''}" />
|
|
62
|
+
</fieldset>
|
|
63
|
+
` : ''}
|
|
64
|
+
<div class="button-container">
|
|
65
|
+
<button type="submit" class="primary-button">Login</button>
|
|
66
|
+
<button type="button" class="secondary-button">Cancel</button>
|
|
67
|
+
</div>
|
|
68
|
+
</form>
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
const formCss = `
|
|
72
|
+
/* Reset default form styles */
|
|
73
|
+
form {
|
|
74
|
+
margin: 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Center the form */
|
|
79
|
+
body {
|
|
80
|
+
display: flex;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
align-items: center;
|
|
83
|
+
height: 100vh;
|
|
84
|
+
background-color: #f5f5f5;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Style form container */
|
|
88
|
+
form {
|
|
89
|
+
width: 400px;
|
|
90
|
+
padding: 20px;
|
|
91
|
+
border-radius: 4px;
|
|
92
|
+
background-color: white;
|
|
93
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Style form labels */
|
|
97
|
+
label {
|
|
98
|
+
font-weight: bold;
|
|
99
|
+
margin-bottom: 5px;
|
|
100
|
+
color: #333;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Style form inputs */
|
|
104
|
+
input {
|
|
105
|
+
width: 100%;
|
|
106
|
+
padding: 8px;
|
|
107
|
+
margin-bottom: 10px;
|
|
108
|
+
border: 1px solid #ccc;
|
|
109
|
+
border-radius: 4px;
|
|
110
|
+
}
|
|
111
|
+
input.checkbox {
|
|
112
|
+
width: 20px;
|
|
113
|
+
height: 20px;
|
|
114
|
+
}
|
|
115
|
+
fieldset {
|
|
116
|
+
padding: 20px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Style form buttons */
|
|
120
|
+
.button-container {
|
|
121
|
+
display: flex;
|
|
122
|
+
justify-content: space-between;
|
|
123
|
+
margin-top: 20px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.primary-button,
|
|
127
|
+
.secondary-button {
|
|
128
|
+
width: 48%;
|
|
129
|
+
padding: 10px;
|
|
130
|
+
border: none;
|
|
131
|
+
border-radius: 4px;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
transition: background-color 0.3s ease;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.primary-button {
|
|
137
|
+
background-color: #4caf50;
|
|
138
|
+
color: white;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.secondary-button {
|
|
142
|
+
background-color: #e0e0e0;
|
|
143
|
+
color: #333;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.primary-button:hover,
|
|
147
|
+
.secondary-button:hover {
|
|
148
|
+
background-color: #388e3c;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* Style form checkbox */
|
|
152
|
+
.checkbox-container {
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
margin-bottom: 10px;
|
|
156
|
+
margin: 20px 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.checkbox-container label {
|
|
160
|
+
margin-left: 5px;
|
|
161
|
+
color: #333;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Style details and summary elements */
|
|
165
|
+
details {
|
|
166
|
+
margin-top: 20px;
|
|
167
|
+
color: #333;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
summary {
|
|
171
|
+
font-weight: bold;
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
details > p {
|
|
176
|
+
margin-top: 10px;
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
/**
|
|
180
|
+
* @class FtpConnector
|
|
181
|
+
* @implements {HostingConnector}
|
|
182
|
+
* @implements {StorageConnector}
|
|
183
|
+
*/
|
|
184
|
+
class FtpConnector {
|
|
185
|
+
connectorId = 'ftp';
|
|
186
|
+
displayName = 'Ftp';
|
|
187
|
+
icon = 'ftp';
|
|
188
|
+
options;
|
|
189
|
+
connectorType;
|
|
190
|
+
constructor(config, opts) {
|
|
191
|
+
this.options = {
|
|
192
|
+
path: '',
|
|
193
|
+
authorizeUrl: '/api/authorize/ftp/',
|
|
194
|
+
authorizePath: '/api/authorize/ftp/',
|
|
195
|
+
...opts,
|
|
196
|
+
};
|
|
197
|
+
this.connectorType = this.options.type;
|
|
198
|
+
}
|
|
199
|
+
// **
|
|
200
|
+
// Utils
|
|
201
|
+
sessionData(session) {
|
|
202
|
+
return session[this.options.type] ?? {};
|
|
203
|
+
}
|
|
204
|
+
rootPath(session) {
|
|
205
|
+
return this.connectorType === types_1.ConnectorType.STORAGE ?
|
|
206
|
+
(0, validation_1.requiredParam)(this.sessionData(session).storageRootPath, 'storage root path') :
|
|
207
|
+
(0, validation_1.requiredParam)(this.sessionData(session).publicationPath, 'publication path');
|
|
208
|
+
}
|
|
209
|
+
// **
|
|
210
|
+
// FTP methods
|
|
211
|
+
async write(ftp, path, content, progress) {
|
|
212
|
+
ftp.trackProgress(info => {
|
|
213
|
+
progress && progress(`Uploading ${info.bytes / 1000} KB}`);
|
|
214
|
+
});
|
|
215
|
+
progress && progress('Upload started');
|
|
216
|
+
await ftp.uploadFrom((0, connectors_1.contentToReadable)(content), path);
|
|
217
|
+
progress && progress('Upload complete');
|
|
218
|
+
return path;
|
|
219
|
+
}
|
|
220
|
+
async read(ftp, path) {
|
|
221
|
+
const stream = new stream_1.PassThrough();
|
|
222
|
+
await ftp.downloadTo(stream, path);
|
|
223
|
+
return stream;
|
|
224
|
+
}
|
|
225
|
+
async readdir(ftp, path) {
|
|
226
|
+
const list = await ftp.list(path);
|
|
227
|
+
return list.map((file) => ({
|
|
228
|
+
name: file.name,
|
|
229
|
+
isDir: file.isDirectory,
|
|
230
|
+
size: file.size,
|
|
231
|
+
createdAt: file.modifiedAt,
|
|
232
|
+
updatedAt: file.modifiedAt,
|
|
233
|
+
metaData: file,
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
async mkdir(ftp, path) {
|
|
237
|
+
return ftp.ensureDir(path);
|
|
238
|
+
}
|
|
239
|
+
async rmdir(ftp, path) {
|
|
240
|
+
return ftp.removeDir(path);
|
|
241
|
+
}
|
|
242
|
+
async unlink(ftp, path) {
|
|
243
|
+
return ftp.remove(path);
|
|
244
|
+
}
|
|
245
|
+
async getClient({ host, user, pass, port, secure }) {
|
|
246
|
+
const ftp = new basic_ftp_1.Client();
|
|
247
|
+
await ftp.access({
|
|
248
|
+
host,
|
|
249
|
+
port,
|
|
250
|
+
user,
|
|
251
|
+
password: pass,
|
|
252
|
+
secure,
|
|
253
|
+
});
|
|
254
|
+
ftp['test'] = (0, uuid_1.v4)();
|
|
255
|
+
return ftp;
|
|
256
|
+
}
|
|
257
|
+
closeClient(ftp) {
|
|
258
|
+
if (ftp && !ftp.closed) {
|
|
259
|
+
ftp.close();
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
console.warn('ftp already closed');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// **
|
|
266
|
+
// Connector interface
|
|
267
|
+
getOptions(formData) {
|
|
268
|
+
return {
|
|
269
|
+
// Storage
|
|
270
|
+
storageRootPath: formData['storageRootPath'],
|
|
271
|
+
// Hosting
|
|
272
|
+
publicationPath: formData['publicationPath'],
|
|
273
|
+
websiteUrl: formData['websiteUrl'],
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
async getOAuthUrl(session) { return null; }
|
|
277
|
+
async getLoginForm(session, redirectTo) {
|
|
278
|
+
const { host, user, pass, port, secure, publicationPath, storageRootPath, websiteUrl } = this.sessionData(session);
|
|
279
|
+
(0, validation_1.requiredParam)(os_1.type, 'connector type');
|
|
280
|
+
return `
|
|
281
|
+
<style>
|
|
282
|
+
${formCss}
|
|
283
|
+
</style>
|
|
284
|
+
${formHtml(redirectTo, this.connectorType, { host, user, pass, port, secure, publicationPath, storageRootPath, websiteUrl })}
|
|
285
|
+
`;
|
|
286
|
+
}
|
|
287
|
+
async getSettingsForm(session, redirectTo) { return null; }
|
|
288
|
+
async setToken(session, token) {
|
|
289
|
+
// Check all required params are present
|
|
290
|
+
const { host, user, pass, port, secure = false, publicationPath, storageRootPath, websiteUrl } = token;
|
|
291
|
+
(0, validation_1.requiredParam)(session, 'session');
|
|
292
|
+
(0, validation_1.requiredParam)(host, 'host');
|
|
293
|
+
(0, validation_1.requiredParam)(user, 'user');
|
|
294
|
+
(0, validation_1.requiredParam)(pass, 'pass');
|
|
295
|
+
(0, validation_1.requiredParam)(port, 'port');
|
|
296
|
+
// Check if the connection is valid
|
|
297
|
+
const ftp = await this.getClient({ host, user, pass, port, secure });
|
|
298
|
+
// Save the token
|
|
299
|
+
session[this.connectorType] = { host, user, pass, port, secure, publicationPath, storageRootPath, websiteUrl };
|
|
300
|
+
// Clean up
|
|
301
|
+
this.closeClient(ftp);
|
|
302
|
+
}
|
|
303
|
+
async logout(session) {
|
|
304
|
+
delete session[this.options.type];
|
|
305
|
+
}
|
|
306
|
+
async getUser(session) {
|
|
307
|
+
return {
|
|
308
|
+
name: this.sessionData(session).user,
|
|
309
|
+
picture: 'data://image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAA',
|
|
310
|
+
storage: await (0, connectors_1.toConnectorData)(session, this)
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async isLoggedIn(session) {
|
|
314
|
+
try {
|
|
315
|
+
if (!session[this.options.type]) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
319
|
+
this.closeClient(ftp);
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async setWebsiteMeta(session, id, data) {
|
|
327
|
+
const websiteId = (0, validation_1.requiredParam)(id, 'website id');
|
|
328
|
+
const path = (0, path_1.join)(this.rootPath(session), websiteId, constants_1.WEBSITE_META_DATA_FILE);
|
|
329
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
330
|
+
await this.write(ftp, path, JSON.stringify(data));
|
|
331
|
+
this.closeClient(ftp);
|
|
332
|
+
}
|
|
333
|
+
async getWebsiteMeta(session, id) {
|
|
334
|
+
try {
|
|
335
|
+
const websiteId = (0, validation_1.requiredParam)(id, 'website id');
|
|
336
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
337
|
+
// Get stats for the website folder
|
|
338
|
+
const folder = (0, path_1.join)(this.rootPath(session), websiteId);
|
|
339
|
+
const lastMod = await ftp.lastMod(folder);
|
|
340
|
+
// Read the meta data file to get the meta data set by the user
|
|
341
|
+
const path = (0, path_1.join)(this.rootPath(session), websiteId, constants_1.WEBSITE_META_DATA_FILE);
|
|
342
|
+
const readable = await this.read(ftp, path);
|
|
343
|
+
const meta = JSON.parse(await (0, connectors_1.contentToString)(readable));
|
|
344
|
+
this.closeClient(ftp);
|
|
345
|
+
// Return all meta
|
|
346
|
+
return {
|
|
347
|
+
websiteId,
|
|
348
|
+
//url: await this.getFileUrl(session, websiteId, WEBSITE_DATA_FILE_NAME),
|
|
349
|
+
createdAt: lastMod,
|
|
350
|
+
updatedAt: lastMod,
|
|
351
|
+
...meta,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
catch (err) {
|
|
355
|
+
console.error(err);
|
|
356
|
+
throw err;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// **
|
|
360
|
+
// Storage interface
|
|
361
|
+
/**
|
|
362
|
+
* Create necessary folders
|
|
363
|
+
* Assets and root folders
|
|
364
|
+
*/
|
|
365
|
+
async createWebsite(session) {
|
|
366
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
367
|
+
// Generate a random id
|
|
368
|
+
const id = (0, uuid_1.v4)();
|
|
369
|
+
// // create root folder
|
|
370
|
+
// const rootPath = join(this.storageRootPath(session), id)
|
|
371
|
+
// await this.mkdir(ftp, rootPath)
|
|
372
|
+
// create assets folder
|
|
373
|
+
const assetsPath = (0, path_1.join)(this.rootPath(session), id, '/assets');
|
|
374
|
+
await this.mkdir(ftp, assetsPath);
|
|
375
|
+
// create website data file
|
|
376
|
+
const websiteDataPath = (0, path_1.join)(this.rootPath(session), id, constants_1.WEBSITE_DATA_FILE);
|
|
377
|
+
await this.write(ftp, websiteDataPath, JSON.stringify(types_1.defaultWebsiteData));
|
|
378
|
+
// create website meta data file
|
|
379
|
+
const websiteMetaDataPath = (0, path_1.join)(this.rootPath(session), id, constants_1.WEBSITE_META_DATA_FILE);
|
|
380
|
+
await this.write(ftp, websiteMetaDataPath, JSON.stringify({}));
|
|
381
|
+
// Clean up
|
|
382
|
+
this.closeClient(ftp);
|
|
383
|
+
// All good
|
|
384
|
+
return id;
|
|
385
|
+
}
|
|
386
|
+
async listWebsites(session) {
|
|
387
|
+
const storageRootPath = this.rootPath(session);
|
|
388
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
389
|
+
const files = await this.readdir(ftp, storageRootPath);
|
|
390
|
+
const list = await Promise.all(files.map(async (file) => {
|
|
391
|
+
const websiteId = file.name;
|
|
392
|
+
const websiteMeta = await this.getWebsiteMeta(session, websiteId);
|
|
393
|
+
return websiteMeta;
|
|
394
|
+
}));
|
|
395
|
+
this.closeClient(ftp);
|
|
396
|
+
return list;
|
|
397
|
+
}
|
|
398
|
+
async readWebsite(session, websiteId) {
|
|
399
|
+
const storageRootPath = this.rootPath(session);
|
|
400
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
401
|
+
const websiteDataPath = (0, path_1.join)(storageRootPath, websiteId, constants_1.WEBSITE_DATA_FILE);
|
|
402
|
+
const data = await this.read(ftp, websiteDataPath);
|
|
403
|
+
this.closeClient(ftp);
|
|
404
|
+
return data;
|
|
405
|
+
}
|
|
406
|
+
async updateWebsite(session, websiteId, data) {
|
|
407
|
+
const storageRootPath = this.rootPath(session);
|
|
408
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
409
|
+
const websiteDataPath = (0, path_1.join)(storageRootPath, websiteId, constants_1.WEBSITE_DATA_FILE);
|
|
410
|
+
await this.write(ftp, websiteDataPath, JSON.stringify(data));
|
|
411
|
+
this.closeClient(ftp);
|
|
412
|
+
}
|
|
413
|
+
async deleteWebsite(session, websiteId) {
|
|
414
|
+
const storageRootPath = this.rootPath(session);
|
|
415
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
416
|
+
const websitePath = (0, path_1.join)(storageRootPath, websiteId);
|
|
417
|
+
await this.rmdir(ftp, websitePath);
|
|
418
|
+
this.closeClient(ftp);
|
|
419
|
+
}
|
|
420
|
+
async writeAssets(session, id, files, statusCbk) {
|
|
421
|
+
// Connect to FTP server
|
|
422
|
+
statusCbk && statusCbk({
|
|
423
|
+
message: 'Connecting to FTP server',
|
|
424
|
+
status: types_1.JobStatus.IN_PROGRESS,
|
|
425
|
+
});
|
|
426
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
427
|
+
const rootPath = this.rootPath(session);
|
|
428
|
+
// Make sure that root folder exists
|
|
429
|
+
statusCbk && statusCbk({
|
|
430
|
+
message: 'Making sure that root folder exists',
|
|
431
|
+
status: types_1.JobStatus.IN_PROGRESS,
|
|
432
|
+
});
|
|
433
|
+
await this.mkdir(ftp, rootPath);
|
|
434
|
+
// Write files
|
|
435
|
+
const paths = [];
|
|
436
|
+
let lastFile;
|
|
437
|
+
try {
|
|
438
|
+
// Sequentially write files
|
|
439
|
+
for (const file of files) {
|
|
440
|
+
statusCbk && statusCbk({
|
|
441
|
+
message: `Writing file ${file.path}`,
|
|
442
|
+
status: types_1.JobStatus.IN_PROGRESS,
|
|
443
|
+
});
|
|
444
|
+
const dstPath = (0, path_1.join)(this.options.path, rootPath, id, file.path);
|
|
445
|
+
lastFile = file;
|
|
446
|
+
const result = await this.write(ftp, dstPath, file.content, message => {
|
|
447
|
+
statusCbk && statusCbk({
|
|
448
|
+
message: `Writing file ${file.path.split('/').pop()} to ${dstPath.split('/').slice(0, -1).join('/')}: ${message}`,
|
|
449
|
+
status: types_1.JobStatus.IN_PROGRESS,
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
paths.push(result);
|
|
453
|
+
}
|
|
454
|
+
this.closeClient(ftp);
|
|
455
|
+
statusCbk && statusCbk({
|
|
456
|
+
message: `Finished writing ${paths.length} files to ${rootPath}`,
|
|
457
|
+
status: types_1.JobStatus.SUCCESS,
|
|
458
|
+
});
|
|
459
|
+
return paths;
|
|
460
|
+
}
|
|
461
|
+
catch (err) {
|
|
462
|
+
// Not sure why it never gets here
|
|
463
|
+
statusCbk && statusCbk({
|
|
464
|
+
message: `Error writing file ${lastFile?.path}: ${err.message}`,
|
|
465
|
+
status: types_1.JobStatus.ERROR,
|
|
466
|
+
});
|
|
467
|
+
this.closeClient(ftp);
|
|
468
|
+
return [];
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
async readAsset(session, id, path) {
|
|
472
|
+
if (!this.sessionData(session))
|
|
473
|
+
throw new Error('Not logged in');
|
|
474
|
+
const storageRootPath = this.rootPath(session);
|
|
475
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
476
|
+
const dirPath = (0, path_1.join)(this.options.path, storageRootPath, id, path);
|
|
477
|
+
const asset = this.read(ftp, dirPath);
|
|
478
|
+
this.closeClient(ftp);
|
|
479
|
+
return asset;
|
|
480
|
+
}
|
|
481
|
+
async deleteAssets(session, id, paths) {
|
|
482
|
+
const storageRootPath = this.rootPath(session);
|
|
483
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
484
|
+
await Promise.all(paths.map((path) => this.unlink(ftp, (0, path_1.join)(this.options.path, storageRootPath, id, path))));
|
|
485
|
+
this.closeClient(ftp);
|
|
486
|
+
}
|
|
487
|
+
// **
|
|
488
|
+
// Hosting interface
|
|
489
|
+
async getUrl(session, id) {
|
|
490
|
+
// FIXME: do not store websiteUrl in the session, but in the website data
|
|
491
|
+
console.warn('FIXME: do not store websiteUrl in the session, but in the website data');
|
|
492
|
+
return this.sessionData(session).websiteUrl ?? '';
|
|
493
|
+
}
|
|
494
|
+
async publish(session, id, files) {
|
|
495
|
+
const job = (0, jobs_1.startJob)(`Publishing to ${this.displayName}`);
|
|
496
|
+
job.logs = [[`Publishing to ${this.displayName}`]];
|
|
497
|
+
job.errors = [[]];
|
|
498
|
+
// Create folders
|
|
499
|
+
const rootPath = this.rootPath(session);
|
|
500
|
+
const ftp = await this.getClient(this.sessionData(session));
|
|
501
|
+
await this.mkdir(ftp, rootPath);
|
|
502
|
+
await this.mkdir(ftp, (0, path_1.join)(rootPath, 'assets'));
|
|
503
|
+
// Write files
|
|
504
|
+
this.writeAssets(session, '', files, async ({ status, message }) => {
|
|
505
|
+
// Update the job status
|
|
506
|
+
job.status = status;
|
|
507
|
+
job.message = message;
|
|
508
|
+
job.logs[0].push(message);
|
|
509
|
+
if (status === types_1.JobStatus.SUCCESS) {
|
|
510
|
+
(0, jobs_1.jobSuccess)(job.jobId, message);
|
|
511
|
+
}
|
|
512
|
+
else if (status === types_1.JobStatus.ERROR) {
|
|
513
|
+
job.errors[0].push(message);
|
|
514
|
+
(0, jobs_1.jobError)(job.jobId, message);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
return job;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
exports.default = FtpConnector;
|
|
521
|
+
//# sourceMappingURL=FtpConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FtpConnector.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/FtpConnector.ts"],"names":[],"mappings":";AAAA;;;;;;;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Default = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
23
|
+
const events_1 = require("../../events");
|
|
23
24
|
const rootPath = process.env.DATA_FOLDER;
|
|
24
25
|
// **********
|
|
25
26
|
throw new Error('TODO: implement hooks plugin');
|
|
26
|
-
const EVENT_ASSET_WRITE_END = 'silex:asset:write:end';
|
|
27
|
-
const EVENT_PUBLISH_END = 'silex:publish:end';
|
|
28
|
-
const EVENT_WRITE_END = 'silex:write:end';
|
|
29
27
|
function projectPath(projectId) { return `${rootPath}/${projectId}`; }
|
|
30
28
|
// **********
|
|
31
29
|
async function default_1(config, opts = {}) {
|
|
@@ -35,7 +33,7 @@ async function default_1(config, opts = {}) {
|
|
|
35
33
|
buildUrl: process.env.SILEX_HOOK_BUILD,
|
|
36
34
|
...opts
|
|
37
35
|
};
|
|
38
|
-
config.on(EVENT_WRITE_END, async ({ res, req, projectId, data }) => {
|
|
36
|
+
config.on(events_1.EVENT_WRITE_END, async ({ res, req, projectId, data }) => {
|
|
39
37
|
if (options.gitUrl) {
|
|
40
38
|
await hook(options.gitUrl, {
|
|
41
39
|
path: projectPath(projectId),
|
|
@@ -43,7 +41,7 @@ async function default_1(config, opts = {}) {
|
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
});
|
|
46
|
-
config.on(EVENT_ASSET_WRITE_END, async ({ res, req, projectId, uploadDir, form, data }) => {
|
|
44
|
+
config.on(events_1.EVENT_ASSET_WRITE_END, async ({ res, req, projectId, uploadDir, form, data }) => {
|
|
47
45
|
if (options.gitUrl) {
|
|
48
46
|
await hook(options.gitUrl, {
|
|
49
47
|
path: projectPath(projectId),
|
|
@@ -51,7 +49,7 @@ async function default_1(config, opts = {}) {
|
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
|
-
config.on(EVENT_PUBLISH_END, async ({ projectId, files, req, res }) => {
|
|
52
|
+
config.on(events_1.EVENT_PUBLISH_END, async ({ projectId, files, req, res }) => {
|
|
55
53
|
if (options.buildUrl) {
|
|
56
54
|
await hook(options.buildUrl);
|
|
57
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HooksPlugin.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/HooksPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;AAEH,4DAA8B;AAE9B,yCAAwF;AAOxF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAExC,aAAa;AACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;AAC/C,SAAS,WAAW,CAAC,SAAiB,IAAI,OAAO,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAA,CAAC,CAAC;AAC7E,aAAa;AAEE,KAAK,oBAAU,MAAoB,EAAE,OAAqB,EAAE;IACzE,wBAAwB;IACxB,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QAClC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACtC,GAAG,IAAI;KACR,CAAA;IACD,MAAM,CAAC,EAAE,CAAC,wBAAe,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;QACjE,IAAG,OAAO,CAAC,MAAM,EAAE;YACjB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;gBACzB,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC;gBAC5B,OAAO,EAAE,mBAAmB;aAC7B,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IACF,MAAM,CAAC,EAAE,CAAC,8BAAqB,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE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const express_force_ssl_1 = __importDefault(require("express-force-ssl"));
|
|
26
|
-
const events_1 = require("
|
|
26
|
+
const events_1 = require("../../events");
|
|
27
27
|
// interface SslOptions {
|
|
28
28
|
// forceHttps?: boolean
|
|
29
29
|
// trustXFPHeader?: boolean
|
|
@@ -47,18 +47,18 @@ async function default_1(config, opts = {}) {
|
|
|
47
47
|
// SSL
|
|
48
48
|
// force ssl if the env var SILEX_FORCE_HTTPS is set
|
|
49
49
|
if (options.forceHttps) {
|
|
50
|
-
console.log('> Force SSL option is enabled');
|
|
50
|
+
console.log('> [SslPlugin] Force SSL option is enabled');
|
|
51
51
|
app.set('forceSSLOptions', {
|
|
52
52
|
trustXFPHeader: !!options.trustXFPHeader,
|
|
53
53
|
});
|
|
54
54
|
router.use(express_force_ssl_1.default);
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
console.log('> Force SSL option is disabled, env var SILEX_FORCE_HTTPS not set');
|
|
57
|
+
console.log('> [SslPlugin] Force SSL option is disabled, env var SILEX_FORCE_HTTPS not set');
|
|
58
58
|
}
|
|
59
59
|
// SSL certificate
|
|
60
60
|
if (options.privateKey && options.certificate) {
|
|
61
|
-
console.log('> SSL certificate is enabled, found certificate:', options.certificate);
|
|
61
|
+
console.log('> [SslPlugin] SSL certificate is enabled, found certificate:', options.certificate);
|
|
62
62
|
try {
|
|
63
63
|
const privateKey = (0, fs_1.readFileSync)(options.privateKey).toString();
|
|
64
64
|
const certificate = (0, fs_1.readFileSync)(options.certificate).toString();
|
|
@@ -69,15 +69,15 @@ async function default_1(config, opts = {}) {
|
|
|
69
69
|
rejectUnauthorized: false,
|
|
70
70
|
};
|
|
71
71
|
(0, https_1.createServer)(sslServerOptions, this).listen(options.sslPort, () => {
|
|
72
|
-
console.log('
|
|
72
|
+
console.log('> [SslPlugin] Listening on port ', options.sslPort);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
catch (e) {
|
|
76
|
-
console.error('
|
|
76
|
+
console.error('> [SslPlugin] Load certificate failed.', e);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
console.log('>
|
|
80
|
+
console.log('> [SslPlugin] Certificate disabled, env vars SILEX_SSL_CERTIFICATE and SILEX_SSL_PRIVATE_KEY not set');
|
|
81
81
|
}
|
|
82
82
|
app.use(router);
|
|
83
83
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SslPlugin.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/SslPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;AAEH,sDAA6B;AAC7B,2BAAiC;AACjC,iCAAoC;AACpC,0EAAwC;AACxC,yCAAkD;AAElD,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,wBAAwB;AACxB,yBAAyB;AACzB,qBAAqB;AACrB,IAAI;AAEW,KAAK,oBAAU,MAAM,EAAE,IAAI,GAAG,EAAE;IAC7C,wBAAwB;IACxB,MAAM,OAAO,GAAG;QACd,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM;QACpD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC,KAAK,MAAM;QACzE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC9C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK;QACtC,GAAG,IAAI;KACR,CAAA;IAED,8BAA8B;IAC9B,MAAM,CAAC,EAAE,CAAC,4BAAmB,EAAE,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAA;QAE/B,MAAM;QACN,oDAAoD;QACpD,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;YACxD,GAAG,CA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