@silexlabs/silex 3.0.0-alpha.41 → 3.0.0-alpha.43

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 (207) hide show
  1. package/.silex.js +2 -11
  2. package/dist/client/client/api.d.ts +83 -0
  3. package/dist/client/client/config.d.ts +3 -3
  4. package/dist/client/client/events.d.ts +12 -0
  5. package/dist/client/client/expose.d.ts +6 -0
  6. package/dist/client/client/grapesjs/LoginDialog.d.ts +3 -2
  7. package/dist/client/client/grapesjs/PublicationManager.d.ts +9 -3
  8. package/dist/client/client/grapesjs/PublicationUi.d.ts +9 -6
  9. package/dist/client/client/grapesjs/index.d.ts +4 -4
  10. package/dist/client/client/grapesjs/openImport.d.ts +5 -0
  11. package/dist/client/constants.d.ts +23 -14
  12. package/dist/client/css/admin.css +5 -0
  13. package/dist/client/js/main.js +90 -111
  14. package/dist/client/js/main.js.LICENSE.txt +0 -6
  15. package/dist/client/page.d.ts +1 -1
  16. package/dist/client/types.d.ts +125 -86
  17. package/dist/plugins/client/client/events.d.ts +12 -0
  18. package/dist/plugins/client/client/events.js +30 -0
  19. package/dist/plugins/client/client/events.js.map +1 -0
  20. package/dist/plugins/client/client/utils.d.ts +1 -0
  21. package/{src/ts/events.ts → dist/plugins/client/client/utils.js} +9 -3
  22. package/dist/plugins/client/client/utils.js.map +1 -0
  23. package/dist/plugins/client/constants.d.ts +30 -0
  24. package/dist/plugins/client/constants.js +47 -0
  25. package/dist/plugins/client/constants.js.map +1 -0
  26. package/dist/plugins/client/page.d.ts +2 -0
  27. package/dist/plugins/client/page.js +31 -0
  28. package/dist/plugins/client/page.js.map +1 -0
  29. package/dist/plugins/client/plugins/client/publicationRenderer.d.ts +2 -0
  30. package/dist/plugins/client/plugins/client/publicationRenderer.js +128 -0
  31. package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -0
  32. package/dist/plugins/client/plugins/client/template.d.ts +2 -0
  33. package/dist/plugins/client/plugins/client/template.js +186 -0
  34. package/dist/plugins/client/plugins/client/template.js.map +1 -0
  35. package/dist/plugins/client/server/config.d.ts +59 -0
  36. package/dist/plugins/client/server/config.js +178 -0
  37. package/dist/plugins/client/server/config.js.map +1 -0
  38. package/dist/plugins/client/server/connectors/FsHosting.d.ts +13 -0
  39. package/dist/plugins/client/server/connectors/FsHosting.js +51 -0
  40. package/dist/plugins/client/server/connectors/FsHosting.js.map +1 -0
  41. package/dist/plugins/client/server/connectors/FsStorage.d.ts +41 -0
  42. package/dist/plugins/client/server/connectors/FsStorage.js +220 -0
  43. package/dist/plugins/client/server/connectors/FsStorage.js.map +1 -0
  44. package/dist/plugins/client/server/connectors/connectors.d.ts +83 -0
  45. package/dist/plugins/client/server/connectors/connectors.js +91 -0
  46. package/dist/plugins/client/server/connectors/connectors.js.map +1 -0
  47. package/dist/plugins/client/server/events.d.ts +26 -0
  48. package/dist/plugins/client/server/events.js +12 -0
  49. package/dist/plugins/client/server/events.js.map +1 -0
  50. package/dist/plugins/client/server/jobs.js +67 -0
  51. package/dist/plugins/client/server/jobs.js.map +1 -0
  52. package/dist/plugins/client/server/utils/validation.js +34 -0
  53. package/dist/plugins/client/server/utils/validation.js.map +1 -0
  54. package/dist/plugins/client/types.d.ts +309 -0
  55. package/dist/plugins/client/types.js +49 -0
  56. package/dist/plugins/client/types.js.map +1 -0
  57. package/dist/plugins/server/constants.d.ts +30 -0
  58. package/dist/plugins/server/constants.js +50 -0
  59. package/dist/plugins/server/constants.js.map +1 -0
  60. package/dist/plugins/server/plugins/server/AuthPlugin.js.map +1 -0
  61. package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
  62. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +94 -0
  63. package/dist/plugins/server/plugins/server/FtpConnector.js +521 -0
  64. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
  65. package/dist/plugins/{HooksPlugin.d.ts → server/plugins/server/HooksPlugin.d.ts} +1 -1
  66. package/dist/plugins/{HooksPlugin.js → server/plugins/server/HooksPlugin.js} +8 -10
  67. package/dist/plugins/server/plugins/server/HooksPlugin.js.map +1 -0
  68. package/dist/plugins/server/plugins/server/PublicationOptimizer.d.ts +0 -0
  69. package/dist/plugins/server/plugins/server/PublicationOptimizer.js +14 -0
  70. package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +1 -0
  71. package/dist/plugins/{SslPlugin.js → server/plugins/server/SslPlugin.js} +8 -8
  72. package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
  73. package/dist/plugins/{StaticPlugin.js → server/plugins/server/StaticPlugin.js} +9 -4
  74. package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
  75. package/dist/plugins/server/server/config.d.ts +59 -0
  76. package/dist/plugins/server/server/config.js +182 -0
  77. package/dist/plugins/server/server/config.js.map +1 -0
  78. package/dist/plugins/server/server/connectors/FsHosting.d.ts +13 -0
  79. package/dist/plugins/server/server/connectors/FsHosting.js +55 -0
  80. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
  81. package/dist/plugins/server/server/connectors/FsStorage.d.ts +41 -0
  82. package/dist/{server/backends/FsBackend.js → plugins/server/server/connectors/FsStorage.js} +103 -125
  83. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
  84. package/dist/plugins/server/server/connectors/connectors.d.ts +83 -0
  85. package/dist/plugins/server/server/connectors/connectors.js +99 -0
  86. package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
  87. package/dist/plugins/server/server/events.d.ts +26 -0
  88. package/dist/plugins/server/server/events.js +15 -0
  89. package/dist/plugins/server/server/events.js.map +1 -0
  90. package/dist/plugins/server/server/jobs.d.ts +6 -0
  91. package/dist/plugins/server/server/jobs.js.map +1 -0
  92. package/dist/plugins/server/server/utils/validation.d.ts +7 -0
  93. package/dist/{server → plugins/server/server}/utils/validation.js +3 -2
  94. package/dist/plugins/server/server/utils/validation.js.map +1 -0
  95. package/dist/plugins/server/types.d.ts +309 -0
  96. package/dist/{types.js → plugins/server/types.js} +18 -7
  97. package/dist/plugins/server/types.js.map +1 -0
  98. package/dist/server/constants.js +30 -0
  99. package/dist/server/plugins/server/Cache.js +15 -0
  100. package/dist/server/server/api/api.js +20 -0
  101. package/dist/server/server/api/connectorApi.js +200 -0
  102. package/dist/server/server/api/publicationApi.js +116 -0
  103. package/dist/server/server/api/websiteApi.js +297 -0
  104. package/dist/server/{cli.js → server/cli.js} +6 -5
  105. package/dist/server/server/config.js +121 -0
  106. package/dist/server/server/connectors/FsHosting.js +37 -0
  107. package/dist/server/server/connectors/FsStorage.js +218 -0
  108. package/dist/server/server/connectors/connectors.js +65 -0
  109. package/dist/server/server/events.js +14 -0
  110. package/dist/server/{express.js → server/express.js} +4 -3
  111. package/dist/server/{index.js → server/index.js} +14 -7
  112. package/dist/server/server/jobs.js +47 -0
  113. package/dist/server/server/utils/validation.js +15 -0
  114. package/dist/server/types.js +19 -0
  115. package/package.json +26 -15
  116. package/src/css/grapesjs.scss +5 -0
  117. package/src/ts/client/api.ts +135 -0
  118. package/src/ts/client/config.ts +3 -3
  119. package/{dist/events.js → src/ts/client/events.ts} +13 -6
  120. package/src/ts/client/expose.ts +11 -0
  121. package/src/ts/client/grapesjs/LoginDialog.ts +33 -32
  122. package/src/ts/client/grapesjs/PublicationManager.ts +86 -112
  123. package/src/ts/client/grapesjs/PublicationUi.ts +43 -33
  124. package/src/ts/client/grapesjs/eleventy.ts +4 -1
  125. package/src/ts/client/grapesjs/index.ts +6 -19
  126. package/src/ts/client/grapesjs/openImport.ts +5 -0
  127. package/src/ts/client/grapesjs/storage.ts +18 -14
  128. package/src/ts/client/index.ts +21 -15
  129. package/src/ts/constants.ts +24 -14
  130. package/src/ts/page.ts +1 -1
  131. package/src/ts/plugins/client/publicationRenderer.ts +128 -0
  132. package/src/ts/plugins/client/template.ts +196 -0
  133. package/src/ts/plugins/server/FtpConnector.ts +602 -0
  134. package/src/ts/plugins/{HooksPlugin.ts → server/HooksPlugin.ts} +9 -12
  135. package/src/ts/plugins/server/PublicationOptimizer.ts +14 -0
  136. package/src/ts/plugins/{SslPlugin.ts → server/SslPlugin.ts} +8 -8
  137. package/src/ts/plugins/{StaticPlugin.ts → server/StaticPlugin.ts} +8 -4
  138. package/src/ts/server/api/api.ts +19 -0
  139. package/src/ts/server/api/connectorApi.ts +322 -0
  140. package/src/ts/server/api/publicationApi.ts +166 -0
  141. package/src/ts/server/api/websiteApi.ts +420 -0
  142. package/src/ts/server/cli.ts +7 -5
  143. package/src/ts/server/config.ts +107 -95
  144. package/src/ts/server/connectors/FsHosting.ts +60 -0
  145. package/src/ts/server/connectors/FsStorage.ts +247 -0
  146. package/src/ts/server/connectors/connectors.ts +173 -0
  147. package/src/ts/server/events.ts +20 -0
  148. package/src/ts/server/express.ts +4 -3
  149. package/src/ts/server/index.ts +19 -15
  150. package/src/ts/server/jobs.test.ts +1 -0
  151. package/src/ts/server/utils/BackwardCompat.ts +1 -1
  152. package/src/ts/server/utils/validation.ts +3 -2
  153. package/src/ts/types.ts +93 -61
  154. package/.silex/default/website.json +0 -1
  155. package/dist/client/client/grapesjs/eleventy.d.ts +0 -1
  156. package/dist/client/client/grapesjs/template.d.ts +0 -1
  157. package/dist/client/client/services.d.ts +0 -35
  158. package/dist/client/events.d.ts +0 -2
  159. package/dist/constants.d.ts +0 -21
  160. package/dist/constants.js +0 -41
  161. package/dist/constants.js.map +0 -1
  162. package/dist/events.d.ts +0 -2
  163. package/dist/events.js.map +0 -1
  164. package/dist/plugins/AuthPlugin.js.map +0 -1
  165. package/dist/plugins/Cache.js.map +0 -1
  166. package/dist/plugins/FtpBackend.d.ts +0 -92
  167. package/dist/plugins/FtpBackend.js +0 -604
  168. package/dist/plugins/FtpBackend.js.map +0 -1
  169. package/dist/plugins/HooksPlugin.js.map +0 -1
  170. package/dist/plugins/PublicationPlugin.d.ts +0 -17
  171. package/dist/plugins/PublicationPlugin.js +0 -170
  172. package/dist/plugins/PublicationPlugin.js.map +0 -1
  173. package/dist/plugins/SslPlugin.js.map +0 -1
  174. package/dist/plugins/StaticPlugin.js.map +0 -1
  175. package/dist/plugins/WebsitePlugin.d.ts +0 -14
  176. package/dist/plugins/WebsitePlugin.js +0 -302
  177. package/dist/plugins/WebsitePlugin.js.map +0 -1
  178. package/dist/server/backends/FsBackend.d.ts +0 -42
  179. package/dist/server/backends/FsBackend.js.map +0 -1
  180. package/dist/server/backends/index.d.ts +0 -95
  181. package/dist/server/backends/index.js +0 -255
  182. package/dist/server/backends/index.js.map +0 -1
  183. package/dist/server/config.d.ts +0 -58
  184. package/dist/server/config.js +0 -174
  185. package/dist/server/config.js.map +0 -1
  186. package/dist/server/jobs.js.map +0 -1
  187. package/dist/server/utils/validation.js.map +0 -1
  188. package/dist/types.d.ts +0 -270
  189. package/dist/types.js.map +0 -1
  190. package/src/ts/client/grapesjs/template.ts +0 -183
  191. package/src/ts/client/services.ts +0 -129
  192. package/src/ts/plugins/FtpBackend.ts +0 -689
  193. package/src/ts/plugins/PublicationPlugin.ts +0 -170
  194. package/src/ts/plugins/WebsitePlugin.ts +0 -318
  195. package/src/ts/server/backends/FsBackend.ts +0 -266
  196. package/src/ts/server/backends/index.ts +0 -309
  197. /package/dist/{server → plugins/client/server}/jobs.d.ts +0 -0
  198. /package/dist/{server → plugins/client/server}/utils/validation.d.ts +0 -0
  199. /package/dist/plugins/{AuthPlugin.d.ts → server/plugins/server/AuthPlugin.d.ts} +0 -0
  200. /package/dist/plugins/{AuthPlugin.js → server/plugins/server/AuthPlugin.js} +0 -0
  201. /package/dist/plugins/{Cache.d.ts → server/plugins/server/Cache.d.ts} +0 -0
  202. /package/dist/plugins/{Cache.js → server/plugins/server/Cache.js} +0 -0
  203. /package/dist/plugins/{SslPlugin.d.ts → server/plugins/server/SslPlugin.d.ts} +0 -0
  204. /package/dist/plugins/{StaticPlugin.d.ts → server/plugins/server/StaticPlugin.d.ts} +0 -0
  205. /package/dist/{server → plugins/server/server}/jobs.js +0 -0
  206. /package/src/ts/plugins/{AuthPlugin.ts → server/AuthPlugin.ts} +0 -0
  207. /package/src/ts/plugins/{Cache.ts → server/Cache.ts} +0 -0
@@ -0,0 +1,309 @@
1
+ /**
2
+ * @fileoverview define types for Silex client and server
3
+ */
4
+ export interface PublicationSettings {
5
+ connector?: ConnectorData;
6
+ options?: ConnectorOptions;
7
+ url?: string;
8
+ autoHomePage?: boolean;
9
+ }
10
+ export interface WebsiteFile {
11
+ html: string;
12
+ css: string;
13
+ htmlPath: string;
14
+ cssPath: string;
15
+ }
16
+ export type ApiError = {
17
+ message: string;
18
+ };
19
+ export type ApiPublicationPublishBody = WebsiteData;
20
+ export type ApiPublicationPublishQuery = {
21
+ websiteId: WebsiteId;
22
+ hostingId: ConnectorId;
23
+ storageId: ConnectorId;
24
+ options: ConnectorOptions;
25
+ };
26
+ export type ApiPublicationPublishResponse = {
27
+ url: string;
28
+ job: PublicationJobData;
29
+ };
30
+ export type ApiPublicationStatusQuery = {
31
+ jobId: JobId;
32
+ };
33
+ export type ApiPublicationStatusResponse = PublicationJobData;
34
+ export type ApiWebsiteReadQuery = {
35
+ websiteId: WebsiteId;
36
+ connectorId?: ConnectorId;
37
+ };
38
+ export type ApiWebsiteReadResponse = WebsiteData;
39
+ export type ApiWebsiteListQuery = {
40
+ connectorId?: ConnectorId;
41
+ };
42
+ export type ApiWebsiteListResponse = WebsiteMeta[];
43
+ export type ApiWebsiteWriteQuery = {
44
+ websiteId: WebsiteId;
45
+ connectorId?: ConnectorId;
46
+ };
47
+ export type ApiWebsiteWriteBody = WebsiteData;
48
+ export type ApiWebsiteWriteResponse = {
49
+ message: string;
50
+ };
51
+ export type ApiWebsiteCreateQuery = {
52
+ connectorId?: ConnectorId;
53
+ };
54
+ export type ApiWebsiteCreateBody = WebsiteMetaFileContent;
55
+ export type ApiWebsiteCreateResponse = {
56
+ message: string;
57
+ };
58
+ export type ApiWebsiteDeleteQuery = {
59
+ websiteId: WebsiteId;
60
+ connectorId?: ConnectorId;
61
+ };
62
+ export type ApiWebsiteMetaReadQuery = {
63
+ websiteId: WebsiteId;
64
+ connectorId?: ConnectorId;
65
+ };
66
+ export type ApiWebsiteMetaReadResponse = WebsiteMetaFileContent;
67
+ export type ApiWebsiteMetaWriteQuery = {
68
+ websiteId: WebsiteId;
69
+ connectorId?: ConnectorId;
70
+ };
71
+ export type ApiWebsiteMetaWriteBody = WebsiteMetaFileContent;
72
+ export type ApiWebsiteMetaWriteResponse = {
73
+ message: string;
74
+ };
75
+ export type ApiWebsiteAssetsReadQuery = {
76
+ websiteId: WebsiteId;
77
+ connectorId?: ConnectorId;
78
+ };
79
+ export type ApiWebsiteAssetsReadParams = {
80
+ path: string;
81
+ };
82
+ export type ApiWebsiteAssetsReadResponse = string;
83
+ export type ApiWebsiteAssetsWriteQuery = {
84
+ websiteId: WebsiteId;
85
+ connectorId?: ConnectorId;
86
+ };
87
+ export type ApiWebsiteAssetsWriteBody = ClientSideFile[];
88
+ export type ApiWebsiteAssetsWriteResponse = {
89
+ data: string[];
90
+ };
91
+ export type ApiConnectorListQuery = {
92
+ type: ConnectorType;
93
+ };
94
+ export type ApiConnectorListResponse = ConnectorData[];
95
+ export type ApiConnectorLoginQuery = {
96
+ connectorId: ConnectorId;
97
+ type: ConnectorType;
98
+ };
99
+ export type ApiConnectorLoggedInPostMessage = {
100
+ type: string;
101
+ error: boolean;
102
+ message: string;
103
+ connectorId: ConnectorId;
104
+ options: ConnectorOptions;
105
+ };
106
+ export type ApiConnectorLoginCbkQuery = {
107
+ connectorId?: ConnectorId;
108
+ type: ConnectorType;
109
+ error?: string;
110
+ };
111
+ export type ApiConnectorLoginCbkBody = object;
112
+ export type ApiConnectorSettingsQuery = {
113
+ connectorId?: ConnectorId;
114
+ type: ConnectorType;
115
+ };
116
+ export type ApiConnectorSettingsResponse = string;
117
+ export type ApiConnectorSettingsPostQuery = {
118
+ connectorId?: ConnectorId;
119
+ type: ConnectorType;
120
+ };
121
+ export type ApiConnectorSettingsPostBody = ConnectorUserSettings;
122
+ export type ApiConnectorSettingsPostResponse = {
123
+ message: string;
124
+ };
125
+ export type ApiConnectorLogoutQuery = {
126
+ connectorId?: ConnectorId;
127
+ type: ConnectorType;
128
+ };
129
+ export type ApiConnectorUserQuery = {
130
+ connectorId?: ConnectorId;
131
+ type: ConnectorType;
132
+ };
133
+ export type ApiConnectorUserResponse = ConnectorUser;
134
+ export declare const defaultWebsiteData: WebsiteData;
135
+ export interface WebsiteData {
136
+ pages: Page[];
137
+ assets: Asset[];
138
+ styles: Style[];
139
+ settings: WebsiteSettings;
140
+ fonts: Font[];
141
+ symbols: symbol[];
142
+ publication: PublicationSettings;
143
+ }
144
+ export interface PublicationData extends WebsiteData {
145
+ files?: WebsiteFile[];
146
+ }
147
+ export interface WebsiteSettings {
148
+ description?: string;
149
+ title?: string;
150
+ lang?: string;
151
+ head?: string;
152
+ favicon?: string;
153
+ 'og:title'?: string;
154
+ 'og:description'?: string;
155
+ 'og:image'?: string;
156
+ }
157
+ export interface Font {
158
+ name: string;
159
+ value: string;
160
+ variants: string[];
161
+ }
162
+ export interface Page {
163
+ name?: string;
164
+ id: string;
165
+ type?: string;
166
+ frames: Frame[];
167
+ settings?: WebsiteSettings;
168
+ cssExt?: string;
169
+ htmlExt?: string;
170
+ slug?: string;
171
+ }
172
+ export interface Frame {
173
+ component: {
174
+ type: string;
175
+ stylable: string[];
176
+ };
177
+ components: Component[];
178
+ }
179
+ export interface Component {
180
+ type: string;
181
+ content?: string;
182
+ attributes: {
183
+ [key: string]: string;
184
+ };
185
+ conponents: Component[];
186
+ }
187
+ export declare enum Unit {
188
+ PX = "px"
189
+ }
190
+ export interface Asset {
191
+ type: string;
192
+ src: string;
193
+ unitDim: Unit;
194
+ height: number;
195
+ width: number;
196
+ name: string;
197
+ path?: string;
198
+ }
199
+ export interface Style {
200
+ selectors: Selector[];
201
+ style: {
202
+ [key: string]: string;
203
+ };
204
+ }
205
+ export type Selector = string | {
206
+ name: string;
207
+ type: number;
208
+ };
209
+ /**
210
+ * Type for a connector id
211
+ */
212
+ export type ConnectorId = string;
213
+ export type ConnectorOptions = object;
214
+ /**
215
+ * Type for a client side file
216
+ * @see connector/File
217
+ */
218
+ export interface ClientSideFile {
219
+ path: string;
220
+ content: string;
221
+ }
222
+ /**
223
+ * Type for file listing
224
+ */
225
+ export interface FileMeta {
226
+ name: string;
227
+ isDir: boolean;
228
+ size: number;
229
+ createdAt: Date;
230
+ updatedAt: Date;
231
+ metadata?: object;
232
+ }
233
+ /**
234
+ * Enum to express if the connector is a storage or a hosting
235
+ */
236
+ export declare enum ConnectorType {
237
+ STORAGE = "STORAGE",
238
+ HOSTING = "HOSTING"
239
+ }
240
+ /**
241
+ * Type for a website id
242
+ */
243
+ export type WebsiteId = string;
244
+ /**
245
+ * Back end data shared with the front end
246
+ */
247
+ export interface ConnectorData {
248
+ connectorId: ConnectorId;
249
+ type: ConnectorType;
250
+ displayName: string;
251
+ icon: string;
252
+ disableLogout: boolean;
253
+ isLoggedIn: boolean;
254
+ oauthUrl: string | null;
255
+ }
256
+ /**
257
+ * User settings for a connector and for a given website
258
+ */
259
+ export type ConnectorUserSettings = {
260
+ [websiteId: string]: object;
261
+ };
262
+ /**
263
+ * Back end data shared with the front end
264
+ */
265
+ export interface ConnectorUser {
266
+ name: string;
267
+ email?: string;
268
+ picture?: string;
269
+ storage: ConnectorData;
270
+ }
271
+ export interface WebsiteMetaFileContent {
272
+ name: string;
273
+ imageUrl?: string;
274
+ connectorUserSettings: ConnectorUserSettings;
275
+ }
276
+ /**
277
+ * Back end data sent to the front end
278
+ * Meta data can be the root path of the websites, or the bucket name, etc.
279
+ */
280
+ export interface WebsiteMeta extends WebsiteMetaFileContent {
281
+ websiteId: WebsiteId;
282
+ createdAt: Date;
283
+ updatedAt: Date;
284
+ }
285
+ /**
286
+ * Enum to express if the job is in progress or finished or errored
287
+ */
288
+ export declare enum JobStatus {
289
+ IN_PROGRESS = "IN_PROGRESS",
290
+ SUCCESS = "SUCCESS",
291
+ ERROR = "ERROR"
292
+ }
293
+ /**
294
+ * Id used to track the progress of a publication
295
+ */
296
+ export type JobId = string;
297
+ /**
298
+ * Data structure which is sent to the client to display the progress of a job
299
+ */
300
+ export interface JobData {
301
+ jobId: JobId;
302
+ status: JobStatus;
303
+ message: string;
304
+ _timeout?: ReturnType<typeof setTimeout>;
305
+ }
306
+ export interface PublicationJobData extends JobData {
307
+ logs: string[][];
308
+ errors: string[][];
309
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+ // **
18
+ // Website API
19
+ export const defaultWebsiteData = {
20
+ //pages: [],
21
+ //assets: [],
22
+ //styles: [],
23
+ //settings: {},
24
+ //fonts: [],
25
+ //symbols: [],
26
+ //publication: {},
27
+ };
28
+ export var Unit;
29
+ (function (Unit) {
30
+ Unit["PX"] = "px";
31
+ })(Unit || (Unit = {}));
32
+ /**
33
+ * Enum to express if the connector is a storage or a hosting
34
+ */
35
+ export var ConnectorType;
36
+ (function (ConnectorType) {
37
+ ConnectorType["STORAGE"] = "STORAGE";
38
+ ConnectorType["HOSTING"] = "HOSTING";
39
+ })(ConnectorType || (ConnectorType = {}));
40
+ /**
41
+ * Enum to express if the job is in progress or finished or errored
42
+ */
43
+ export var JobStatus;
44
+ (function (JobStatus) {
45
+ JobStatus["IN_PROGRESS"] = "IN_PROGRESS";
46
+ JobStatus["SUCCESS"] = "SUCCESS";
47
+ JobStatus["ERROR"] = "ERROR";
48
+ })(JobStatus || (JobStatus = {}));
49
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAkEH,KAAK;AACL,cAAc;AACd,MAAM,CAAC,MAAM,kBAAkB,GAAgB;AAC7C,YAAY;AACZ,aAAa;AACb,aAAa;AACb,eAAe;AACf,YAAY;AACZ,cAAc;AACd,kBAAkB;CACJ,CAAA;AAyDhB,MAAM,CAAN,IAAY,IAEX;AAFD,WAAY,IAAI;IACd,iBAAS,CAAA;AACX,CAAC,EAFW,IAAI,KAAJ,IAAI,QAEf;AAoDD;;GAEG;AACH,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAqDD;;GAEG;AACH,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,gCAAmB,CAAA;IACnB,4BAAe,CAAA;AACjB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview define constants for Silex client and server
3
+ */
4
+ export declare const WEBSITE_DATA_FILE = "website.json";
5
+ export declare const WEBSITE_META_DATA_FILE = "meta.json";
6
+ export declare const DEFAULT_WEBSITE_ID = "default";
7
+ export declare const DEFAULT_CONNECTOR_ID = "";
8
+ export declare const DEFAULT_LANGUAGE = "en";
9
+ export declare const CLIENT_CONFIG_FILE_NAME = "silex.js";
10
+ export declare const API_PATH = "/api";
11
+ export declare const API_CONNECTOR_PATH = "/connector";
12
+ export declare const API_CONNECTOR_USER = "/user";
13
+ export declare const API_CONNECTOR_LIST = "/";
14
+ export declare const API_CONNECTOR_LOGOUT = "/logout";
15
+ export declare const API_CONNECTOR_LOGIN = "/login";
16
+ export declare const API_CONNECTOR_SETTINGS = "/settings";
17
+ export declare const API_CONNECTOR_LOGIN_CALLBACK = "/login/callback";
18
+ export declare const API_PUBLICATION_PATH = "/publication";
19
+ export declare const API_PUBLICATION_PUBLISH = "/";
20
+ export declare const API_PUBLICATION_STATUS = "/publication/status";
21
+ export declare const API_WEBSITE_PATH = "/website";
22
+ export declare const API_WEBSITE_READ = "/";
23
+ export declare const API_WEBSITE_WRITE = "/";
24
+ export declare const API_WEBSITE_CREATE = "/";
25
+ export declare const API_WEBSITE_DELETE = "/";
26
+ export declare const API_WEBSITE_LIST = "/";
27
+ export declare const API_WEBSITE_ASSETS_READ = "assets/:path";
28
+ export declare const API_WEBSITE_ASSETS_WRITE = "assets";
29
+ export declare const API_WEBSITE_META_READ = "/meta";
30
+ export declare const API_WEBSITE_META_WRITE = "/meta";
@@ -0,0 +1,50 @@
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
+ exports.API_WEBSITE_META_WRITE = exports.API_WEBSITE_META_READ = exports.API_WEBSITE_ASSETS_WRITE = exports.API_WEBSITE_ASSETS_READ = exports.API_WEBSITE_LIST = exports.API_WEBSITE_DELETE = exports.API_WEBSITE_CREATE = exports.API_WEBSITE_WRITE = exports.API_WEBSITE_READ = exports.API_WEBSITE_PATH = exports.API_PUBLICATION_STATUS = exports.API_PUBLICATION_PUBLISH = exports.API_PUBLICATION_PATH = exports.API_CONNECTOR_LOGIN_CALLBACK = exports.API_CONNECTOR_SETTINGS = exports.API_CONNECTOR_LOGIN = exports.API_CONNECTOR_LOGOUT = exports.API_CONNECTOR_LIST = exports.API_CONNECTOR_USER = exports.API_CONNECTOR_PATH = exports.API_PATH = exports.CLIENT_CONFIG_FILE_NAME = exports.DEFAULT_LANGUAGE = exports.DEFAULT_CONNECTOR_ID = exports.DEFAULT_WEBSITE_ID = exports.WEBSITE_META_DATA_FILE = exports.WEBSITE_DATA_FILE = void 0;
20
+ /**
21
+ * @fileoverview define constants for Silex client and server
22
+ */
23
+ exports.WEBSITE_DATA_FILE = 'website.json';
24
+ exports.WEBSITE_META_DATA_FILE = 'meta.json';
25
+ exports.DEFAULT_WEBSITE_ID = 'default';
26
+ exports.DEFAULT_CONNECTOR_ID = '';
27
+ exports.DEFAULT_LANGUAGE = 'en';
28
+ exports.CLIENT_CONFIG_FILE_NAME = 'silex.js';
29
+ exports.API_PATH = '/api';
30
+ exports.API_CONNECTOR_PATH = '/connector';
31
+ exports.API_CONNECTOR_USER = '/user';
32
+ exports.API_CONNECTOR_LIST = '/';
33
+ exports.API_CONNECTOR_LOGOUT = '/logout';
34
+ exports.API_CONNECTOR_LOGIN = '/login';
35
+ exports.API_CONNECTOR_SETTINGS = '/settings';
36
+ exports.API_CONNECTOR_LOGIN_CALLBACK = '/login/callback';
37
+ exports.API_PUBLICATION_PATH = '/publication';
38
+ exports.API_PUBLICATION_PUBLISH = '/';
39
+ exports.API_PUBLICATION_STATUS = '/publication/status';
40
+ exports.API_WEBSITE_PATH = '/website';
41
+ exports.API_WEBSITE_READ = '/';
42
+ exports.API_WEBSITE_WRITE = '/';
43
+ exports.API_WEBSITE_CREATE = '/';
44
+ exports.API_WEBSITE_DELETE = '/';
45
+ exports.API_WEBSITE_LIST = '/';
46
+ exports.API_WEBSITE_ASSETS_READ = 'assets/:path';
47
+ exports.API_WEBSITE_ASSETS_WRITE = 'assets';
48
+ exports.API_WEBSITE_META_READ = '/meta';
49
+ exports.API_WEBSITE_META_WRITE = '/meta';
50
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/ts/constants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;GAEG;AAEU,QAAA,iBAAiB,GAAG,cAAc,CAAA;AAClC,QAAA,sBAAsB,GAAG,WAAW,CAAA;AAEpC,QAAA,kBAAkB,GAAG,SAAS,CAAA;AAC9B,QAAA,oBAAoB,GAAG,EAAE,CAAA;AACzB,QAAA,gBAAgB,GAAG,IAAI,CAAA;AACvB,QAAA,uBAAuB,GAAG,UAAU,CAAA;AAEpC,QAAA,QAAQ,GAAG,MAAM,CAAA;AAEjB,QAAA,kBAAkB,GAAG,YAAY,CAAA;AACjC,QAAA,kBAAkB,GAAG,OAAO,CAAA;AAC5B,QAAA,kBAAkB,GAAG,GAAG,CAAA;AACxB,QAAA,oBAAoB,GAAG,SAAS,CAAA;AAChC,QAAA,mBAAmB,GAAG,QAAQ,CAAA;AAC9B,QAAA,sBAAsB,GAAG,WAAW,CAAA;AACpC,QAAA,4BAA4B,GAAG,iBAAiB,CAAA;AAEhD,QAAA,oBAAoB,GAAG,cAAc,CAAA;AACrC,QAAA,uBAAuB,GAAG,GAAG,CAAA;AAC7B,QAAA,sBAAsB,GAAG,qBAAqB,CAAA;AAE9C,QAAA,gBAAgB,GAAG,UAAU,CAAA;AAC7B,QAAA,gBAAgB,GAAG,GAAG,CAAA;AACtB,QAAA,iBAAiB,GAAG,GAAG,CAAA;AACvB,QAAA,kBAAkB,GAAG,GAAG,CAAA;AACxB,QAAA,kBAAkB,GAAG,GAAG,CAAA;AACxB,QAAA,gBAAgB,GAAG,GAAG,CAAA;AACtB,QAAA,uBAAuB,GAAG,cAAc,CAAA;AACxC,QAAA,wBAAwB,GAAG,QAAQ,CAAA;AACnC,QAAA,qBAAqB,GAAG,OAAO,CAAA;AAC/B,QAAA,sBAAsB,GAAG,OAAO,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthPlugin.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/AuthPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAKY,KAAK,oBAAU,MAAM,EAAE,IAAI,GAAG,EAAE;IAC/C,iDAAiD;IACjD,qCAAqC;IACrC,uFAAuF;IACvF,aAAa;IACb,4DAA4D;IAC5D,yDAAyD;IACzD,6CAA6C;IAC7C,mDAAmD;IACnD,gBAAgB;IAChB,sBAAsB;IACtB,wGAAwG;IACxG,wDAAwD;IACxD,SAAS;IACT,QAAQ;IACR,qBAAqB;IACrB,MAAM;AACN,CAAC;AAjBD,4BAiBC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/Cache.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,SAAgB,OAAO,CAAE,GAAG,EAAE,GAAG,EAAE,IAAI;IACrC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,4DAA4D,CAAC,CAAA;IACzF,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IAC3B,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IAChC,IAAI,EAAE,CAAA;AACR,CAAC;AALD,0BAKC;AAED,SAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI;IACtC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,gCAAgC,CAAC,CAAA,CAAC,MAAM;IACpE,IAAI,EAAE,CAAA;AACR,CAAC;AAHD,8BAGC"}
@@ -0,0 +1,94 @@
1
+ /// <reference types="node" />
2
+ import { Client } from 'basic-ftp';
3
+ import { Readable } from 'stream';
4
+ import { ConnectorFile, ConnectorFileContent, StatusCallback, StorageConnector } from '../../server/connectors/connectors';
5
+ import { ConnectorType, ConnectorUser, WebsiteMeta, FileMeta, JobData, WebsiteId, WebsiteMetaFileContent, WebsiteData, ConnectorOptions } from '../../types';
6
+ import { ServerConfig } from '../../server/config';
7
+ /**
8
+ * @fileoverview FTP connector for Silex
9
+ * This is a connector for Silex, which allows to store the website on a FTP server
10
+ * and to publish the website on a FTP server
11
+ * FIXME: As a hosting connector, this connector should only store the password in the session and the rest in the website data
12
+ * to prevent publishing a site on the wrong server + multiple sites on 1 server
13
+ * FIXME: Allow reuse of FTP session between calls
14
+ */
15
+ export interface FtpSessionData {
16
+ host: string;
17
+ user: string;
18
+ pass: string;
19
+ port: number;
20
+ secure: boolean;
21
+ storageRootPath?: string;
22
+ publicationPath?: string;
23
+ websiteUrl?: string;
24
+ }
25
+ export interface FtpSession {
26
+ [ConnectorType.STORAGE]?: FtpSessionData;
27
+ [ConnectorType.HOSTING]?: FtpSessionData;
28
+ }
29
+ interface FtpOptions {
30
+ type: ConnectorType;
31
+ path?: string;
32
+ authorizeUrl?: string;
33
+ authorizePath?: string;
34
+ }
35
+ interface FtpOptionsWithDefaults {
36
+ type: ConnectorType;
37
+ path: string;
38
+ authorizeUrl: string;
39
+ authorizePath: string;
40
+ }
41
+ /**
42
+ * @class FtpConnector
43
+ * @implements {HostingConnector}
44
+ * @implements {StorageConnector}
45
+ */
46
+ export default class FtpConnector implements StorageConnector<FtpSession> {
47
+ connectorId: string;
48
+ displayName: string;
49
+ icon: string;
50
+ options: FtpOptionsWithDefaults;
51
+ connectorType: ConnectorType;
52
+ constructor(config: ServerConfig, opts: FtpOptions);
53
+ sessionData(session: FtpSession): FtpSessionData;
54
+ rootPath(session: FtpSession): string;
55
+ write(ftp: Client, path: string, content: ConnectorFileContent, progress?: (message: string) => void): Promise<string>;
56
+ read(ftp: Client, path: string): Promise<Readable>;
57
+ readdir(ftp: Client, path: string): Promise<FileMeta[]>;
58
+ mkdir(ftp: Client, path: string): Promise<void>;
59
+ rmdir(ftp: Client, path: string): Promise<void>;
60
+ unlink(ftp: Client, path: string): Promise<import("basic-ftp").FTPResponse>;
61
+ getClient({ host, user, pass, port, secure }: {
62
+ host: any;
63
+ user: any;
64
+ pass: any;
65
+ port: any;
66
+ secure: any;
67
+ }): Promise<Client>;
68
+ closeClient(ftp: Client): void;
69
+ getOptions(formData: object): ConnectorOptions;
70
+ getOAuthUrl(session: FtpSession): Promise<string | null>;
71
+ getLoginForm(session: FtpSession, redirectTo: string): Promise<string | null>;
72
+ getSettingsForm(session: FtpSession, redirectTo: string): Promise<string | null>;
73
+ setToken(session: FtpSession, token: object): Promise<void>;
74
+ logout(session: FtpSession): Promise<void>;
75
+ getUser(session: FtpSession): Promise<ConnectorUser>;
76
+ isLoggedIn(session: FtpSession): Promise<boolean>;
77
+ setWebsiteMeta(session: FtpSession, id: string, data: WebsiteMetaFileContent): Promise<void>;
78
+ getWebsiteMeta(session: FtpSession, id: WebsiteId): Promise<WebsiteMeta>;
79
+ /**
80
+ * Create necessary folders
81
+ * Assets and root folders
82
+ */
83
+ createWebsite(session: FtpSession): Promise<WebsiteId>;
84
+ listWebsites(session: FtpSession): Promise<WebsiteMeta[]>;
85
+ readWebsite(session: FtpSession, websiteId: string): Promise<WebsiteData | Readable>;
86
+ updateWebsite(session: FtpSession, websiteId: string, data: WebsiteData): Promise<void>;
87
+ deleteWebsite(session: FtpSession, websiteId: string): Promise<void>;
88
+ writeAssets(session: any, id: WebsiteId, files: ConnectorFile[], statusCbk?: StatusCallback): Promise<string[]>;
89
+ readAsset(session: FtpSession, id: string, path: string): Promise<ConnectorFileContent>;
90
+ deleteAssets(session: FtpSession, id: WebsiteId, paths: string[]): Promise<void>;
91
+ getUrl(session: FtpSession, id: WebsiteId): Promise<string>;
92
+ publish(session: FtpSession, id: string, files: ConnectorFile[]): Promise<JobData>;
93
+ }
94
+ export {};