@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,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
|
+
}
|
|
@@ -16,19 +16,30 @@
|
|
|
16
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.JobStatus = exports.
|
|
19
|
+
exports.JobStatus = exports.ConnectorType = exports.Unit = exports.defaultWebsiteData = void 0;
|
|
20
|
+
// **
|
|
21
|
+
// Website API
|
|
22
|
+
exports.defaultWebsiteData = {
|
|
23
|
+
//pages: [],
|
|
24
|
+
//assets: [],
|
|
25
|
+
//styles: [],
|
|
26
|
+
//settings: {},
|
|
27
|
+
//fonts: [],
|
|
28
|
+
//symbols: [],
|
|
29
|
+
//publication: {},
|
|
30
|
+
};
|
|
20
31
|
var Unit;
|
|
21
32
|
(function (Unit) {
|
|
22
33
|
Unit["PX"] = "px";
|
|
23
34
|
})(Unit || (exports.Unit = Unit = {}));
|
|
24
35
|
/**
|
|
25
|
-
* Enum to express if the
|
|
36
|
+
* Enum to express if the connector is a storage or a hosting
|
|
26
37
|
*/
|
|
27
|
-
var
|
|
28
|
-
(function (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})(
|
|
38
|
+
var ConnectorType;
|
|
39
|
+
(function (ConnectorType) {
|
|
40
|
+
ConnectorType["STORAGE"] = "STORAGE";
|
|
41
|
+
ConnectorType["HOSTING"] = "HOSTING";
|
|
42
|
+
})(ConnectorType || (exports.ConnectorType = ConnectorType = {}));
|
|
32
43
|
/**
|
|
33
44
|
* Enum to express if the job is in progress or finished or errored
|
|
34
45
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAkEH,KAAK;AACL,cAAc;AACD,QAAA,kBAAkB,GAAgB;AAC7C,YAAY;AACZ,aAAa;AACb,aAAa;AACb,eAAe;AACf,YAAY;AACZ,cAAc;AACd,kBAAkB;CACJ,CAAA;AAyDhB,IAAY,IAEX;AAFD,WAAY,IAAI;IACd,iBAAS,CAAA;AACX,CAAC,EAFW,IAAI,oBAAJ,IAAI,QAEf;AAoDD;;GAEG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAqDD;;GAEG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,gCAAmB,CAAA;IACnB,4BAAe,CAAA;AACjB,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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;
|
|
4
|
+
exports.WEBSITE_DATA_FILE = 'website.json';
|
|
5
|
+
exports.WEBSITE_META_DATA_FILE = 'meta.json';
|
|
6
|
+
exports.DEFAULT_WEBSITE_ID = 'default';
|
|
7
|
+
exports.DEFAULT_CONNECTOR_ID = '';
|
|
8
|
+
exports.DEFAULT_LANGUAGE = 'en';
|
|
9
|
+
exports.CLIENT_CONFIG_FILE_NAME = 'silex.js';
|
|
10
|
+
exports.API_PATH = '/api';
|
|
11
|
+
exports.API_CONNECTOR_PATH = '/connector';
|
|
12
|
+
exports.API_CONNECTOR_USER = '/user';
|
|
13
|
+
exports.API_CONNECTOR_LIST = '/';
|
|
14
|
+
exports.API_CONNECTOR_LOGOUT = '/logout';
|
|
15
|
+
exports.API_CONNECTOR_LOGIN = '/login';
|
|
16
|
+
exports.API_CONNECTOR_SETTINGS = '/settings';
|
|
17
|
+
exports.API_CONNECTOR_LOGIN_CALLBACK = '/login/callback';
|
|
18
|
+
exports.API_PUBLICATION_PATH = '/publication';
|
|
19
|
+
exports.API_PUBLICATION_PUBLISH = '/';
|
|
20
|
+
exports.API_PUBLICATION_STATUS = '/publication/status';
|
|
21
|
+
exports.API_WEBSITE_PATH = '/website';
|
|
22
|
+
exports.API_WEBSITE_READ = '/';
|
|
23
|
+
exports.API_WEBSITE_WRITE = '/';
|
|
24
|
+
exports.API_WEBSITE_CREATE = '/';
|
|
25
|
+
exports.API_WEBSITE_DELETE = '/';
|
|
26
|
+
exports.API_WEBSITE_LIST = '/';
|
|
27
|
+
exports.API_WEBSITE_ASSETS_READ = 'assets/:path';
|
|
28
|
+
exports.API_WEBSITE_ASSETS_WRITE = 'assets';
|
|
29
|
+
exports.API_WEBSITE_META_READ = '/meta';
|
|
30
|
+
exports.API_WEBSITE_META_WRITE = '/meta';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVENT_WRITE_END = exports.EVENT_ASSET_WRITE_END = exports.EVENT_PUBLISH_LOGIN_END = exports.EVENT_PUBLISH_LOGIN_START = exports.EVENT_PUBLISH_ERROR = exports.EVENT_PUBLISH_END = exports.EVENT_PUBLISH_DATA = exports.EVENT_PUBLISH_START = exports.EVENT_STARTUP_END = exports.EVENT_STARTUP_START = void 0;
|
|
4
|
+
exports.EVENT_STARTUP_START = 'silex:startup:start';
|
|
5
|
+
exports.EVENT_STARTUP_END = 'silex:startup:end';
|
|
6
|
+
exports.EVENT_PUBLISH_START = 'silex:publish:start';
|
|
7
|
+
exports.EVENT_PUBLISH_DATA = 'silex:publish:data';
|
|
8
|
+
exports.EVENT_PUBLISH_END = 'silex:publish:end';
|
|
9
|
+
exports.EVENT_PUBLISH_ERROR = 'silex:publish:error';
|
|
10
|
+
exports.EVENT_PUBLISH_LOGIN_START = 'silex:publish:login:start';
|
|
11
|
+
exports.EVENT_PUBLISH_LOGIN_END = 'silex:publish:login:end';
|
|
12
|
+
exports.EVENT_ASSET_WRITE_END = 'silex:asset:write:end';
|
|
13
|
+
exports.EVENT_WRITE_END = 'silex:write:end';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withCache = exports.noCache = void 0;
|
|
4
|
+
function noCache(req, res, next) {
|
|
5
|
+
res.header('Cache-Control', 'private,no-cache,no-store,must-revalidate,proxy-revalidate');
|
|
6
|
+
res.header('Expires', '-1');
|
|
7
|
+
res.header('Pragma', 'no-cache');
|
|
8
|
+
next();
|
|
9
|
+
}
|
|
10
|
+
exports.noCache = noCache;
|
|
11
|
+
function withCache(req, res, next) {
|
|
12
|
+
res.header('Cache-Control', 'public,max-age=86400,immutable');
|
|
13
|
+
next();
|
|
14
|
+
}
|
|
15
|
+
exports.withCache = withCache;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const express_1 = require("express");
|
|
7
|
+
const Cache_1 = require("../../plugins/server/Cache");
|
|
8
|
+
const connectorApi_1 = __importDefault(require("./connectorApi"));
|
|
9
|
+
const websiteApi_1 = __importDefault(require("./websiteApi"));
|
|
10
|
+
const publicationApi_1 = __importDefault(require("./publicationApi"));
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
function default_1(config) {
|
|
13
|
+
const router = (0, express_1.Router)();
|
|
14
|
+
router.use(Cache_1.noCache);
|
|
15
|
+
router.use(constants_1.API_CONNECTOR_PATH, (0, connectorApi_1.default)(config));
|
|
16
|
+
router.use(constants_1.API_WEBSITE_PATH, (0, websiteApi_1.default)(config));
|
|
17
|
+
router.use(constants_1.API_PUBLICATION_PATH, (0, publicationApi_1.default)(config));
|
|
18
|
+
return router;
|
|
19
|
+
}
|
|
20
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const express_1 = require("express");
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const validation_1 = require("../utils/validation");
|
|
6
|
+
const connectors_1 = require("../connectors/connectors");
|
|
7
|
+
function default_1(config) {
|
|
8
|
+
const router = (0, express_1.Router)();
|
|
9
|
+
router.get(constants_1.API_CONNECTOR_USER, routeUser);
|
|
10
|
+
router.get(constants_1.API_CONNECTOR_LIST, routeListConnectors);
|
|
11
|
+
router.get(constants_1.API_CONNECTOR_LOGIN, routeLogin);
|
|
12
|
+
router.post(constants_1.API_CONNECTOR_LOGIN_CALLBACK, routeLoginSuccess);
|
|
13
|
+
router.get(constants_1.API_CONNECTOR_LOGIN_CALLBACK, routeLoginSuccess);
|
|
14
|
+
router.post(constants_1.API_CONNECTOR_LOGOUT, routeLogout);
|
|
15
|
+
return router;
|
|
16
|
+
}
|
|
17
|
+
exports.default = default_1;
|
|
18
|
+
async function routeUser(req, res) {
|
|
19
|
+
try {
|
|
20
|
+
const config = (0, validation_1.requiredParam)(req.app.get('config'), 'Config object on express js APP');
|
|
21
|
+
const session = (0, validation_1.requiredParam)(req['session'], 'Session object');
|
|
22
|
+
const query = req.query;
|
|
23
|
+
const type = (0, connectors_1.toConnectorEnum)((0, validation_1.requiredParam)(query.type, 'Connector type'));
|
|
24
|
+
const connector = await (0, connectors_1.getConnector)(config, session, type, query.connectorId);
|
|
25
|
+
if (!connector) {
|
|
26
|
+
res
|
|
27
|
+
.status(500)
|
|
28
|
+
.json({
|
|
29
|
+
error: true,
|
|
30
|
+
message: `Connector not found: ${type} ${query.connectorId}`,
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!await connector.isLoggedIn(session)) {
|
|
35
|
+
res
|
|
36
|
+
.status(401)
|
|
37
|
+
.json({
|
|
38
|
+
error: true,
|
|
39
|
+
message: 'Not logged in',
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const user = await connector.getUser(session);
|
|
44
|
+
res.json(user);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Error in the login status request', error);
|
|
48
|
+
res.status(error?.code ?? 500).json({
|
|
49
|
+
error: true,
|
|
50
|
+
message: error.message,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function routeListConnectors(req, res) {
|
|
55
|
+
try {
|
|
56
|
+
const config = (0, validation_1.requiredParam)(req.app.get('config'), 'Config object on express js APP');
|
|
57
|
+
const session = (0, validation_1.requiredParam)(req['session'], 'Session object');
|
|
58
|
+
const query = req.query;
|
|
59
|
+
const type = (0, connectors_1.toConnectorEnum)((0, validation_1.requiredParam)(query.type, 'Connector type'));
|
|
60
|
+
const connectors = config.getConnectors(type);
|
|
61
|
+
try {
|
|
62
|
+
const list = await Promise.all(connectors.map(async (connector) => (0, connectors_1.toConnectorData)(session, connector)));
|
|
63
|
+
res.json(list);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('Error while listing connectors', error);
|
|
67
|
+
res.status(error?.code ?? 500).json({
|
|
68
|
+
error: true,
|
|
69
|
+
message: 'Error while listing connectors: ' + error.message,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error('Error in the list connectors request', error);
|
|
75
|
+
res.status(error?.code ?? 400).json({
|
|
76
|
+
error: true,
|
|
77
|
+
message: 'Error in the list connectors request: ' + error.message,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function routeLogin(req, res) {
|
|
82
|
+
try {
|
|
83
|
+
const query = req.query;
|
|
84
|
+
const connectorId = (0, validation_1.requiredParam)(query.connectorId, 'Connector id');
|
|
85
|
+
const config = (0, validation_1.requiredParam)(req.app.get('config'), 'Config object on express js APP');
|
|
86
|
+
const type = (0, connectors_1.toConnectorEnum)((0, validation_1.requiredParam)(query.type, 'Connector type'));
|
|
87
|
+
const connector = await (0, connectors_1.getConnector)(config, req['session'], type, connectorId);
|
|
88
|
+
const session = (0, validation_1.requiredParam)(req['session'], 'Session object');
|
|
89
|
+
if (!connector)
|
|
90
|
+
throw new Error(`Connector not found ${connectorId} ${type}`);
|
|
91
|
+
if (await connector.isLoggedIn(session)) {
|
|
92
|
+
res.redirect(`${constants_1.API_PATH}${constants_1.API_CONNECTOR_PATH}${constants_1.API_CONNECTOR_LOGIN_CALLBACK}?connectorId=${connectorId}&type=${type}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const oauthUrl = await connector.getOAuthUrl(session);
|
|
96
|
+
if (oauthUrl) {
|
|
97
|
+
res.redirect(oauthUrl);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const redirectTo = await connector.getSettingsForm(session, '') ?
|
|
101
|
+
`${constants_1.API_PATH}${constants_1.API_CONNECTOR_PATH}${constants_1.API_CONNECTOR_SETTINGS}?connectorId=${connectorId}&type=${type}` :
|
|
102
|
+
`${constants_1.API_PATH}${constants_1.API_CONNECTOR_PATH}${constants_1.API_CONNECTOR_LOGIN_CALLBACK}?connectorId=${connectorId}&type=${type}`;
|
|
103
|
+
res.send(await connector.getLoginForm(session, redirectTo));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error('Error in the login request', error);
|
|
108
|
+
res.status(error?.code ?? 400).json({
|
|
109
|
+
error: true,
|
|
110
|
+
message: 'Error in the login request: ' + error.message,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function routeLoginSuccess(req, res) {
|
|
115
|
+
try {
|
|
116
|
+
const query = req.query;
|
|
117
|
+
if (query.error)
|
|
118
|
+
throw new Error(query.error);
|
|
119
|
+
const body = req.body;
|
|
120
|
+
const session = (0, validation_1.requiredParam)(req['session'], 'Session object');
|
|
121
|
+
const connectorId = (0, validation_1.requiredParam)(query.connectorId, 'Connector id');
|
|
122
|
+
const config = (0, validation_1.requiredParam)(req.app.get('config'), 'Config object on express js APP');
|
|
123
|
+
const type = (0, connectors_1.toConnectorEnum)((0, validation_1.requiredParam)(query.type, 'Connector type'));
|
|
124
|
+
const connector = await (0, connectors_1.getConnector)(config, req['session'], type, connectorId);
|
|
125
|
+
if (!connector)
|
|
126
|
+
throw new Error('Connector not found ' + connectorId);
|
|
127
|
+
await connector.setToken(session, {
|
|
128
|
+
...query,
|
|
129
|
+
...body,
|
|
130
|
+
});
|
|
131
|
+
res.send(getEndAuthHtml('Logged in', false, connectorId, connector.getOptions(body)));
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
res
|
|
135
|
+
.status(error?.code ?? 500)
|
|
136
|
+
.send(getEndAuthHtml(error.message, true));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function routeLogout(req, res) {
|
|
140
|
+
try {
|
|
141
|
+
const query = req.query;
|
|
142
|
+
const session = (0, validation_1.requiredParam)(req['session'], 'Session object');
|
|
143
|
+
const config = (0, validation_1.requiredParam)(req.app.get('config'), 'Config object on express js APP');
|
|
144
|
+
const type = (0, connectors_1.toConnectorEnum)((0, validation_1.requiredParam)(query.type, 'Connector type'));
|
|
145
|
+
const connectorId = query.connectorId;
|
|
146
|
+
const connector = await (0, connectors_1.getConnector)(config, session, type, connectorId);
|
|
147
|
+
if (!connector)
|
|
148
|
+
throw new Error(`Connector not found ${connectorId} ${type}`);
|
|
149
|
+
try {
|
|
150
|
+
await connector.logout(session);
|
|
151
|
+
res.json({
|
|
152
|
+
error: false,
|
|
153
|
+
message: 'OK',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
console.error('Error while logging out', error);
|
|
158
|
+
res.status(error?.code ?? 500).json({
|
|
159
|
+
error: true,
|
|
160
|
+
message: 'Error while logging out: ' + error.message,
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error('Error in the logout request', error);
|
|
167
|
+
res.status(error?.code ?? 400).json({
|
|
168
|
+
error: true,
|
|
169
|
+
message: 'Error in the logout request: ' + error.message,
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function getEndAuthHtml(message, error, connectorId, options) {
|
|
175
|
+
const data = {
|
|
176
|
+
type: 'login',
|
|
177
|
+
error,
|
|
178
|
+
message,
|
|
179
|
+
connectorId,
|
|
180
|
+
options,
|
|
181
|
+
};
|
|
182
|
+
return `
|
|
183
|
+
<html>
|
|
184
|
+
<head>
|
|
185
|
+
<script>
|
|
186
|
+
if(window.opener) {
|
|
187
|
+
window.opener.postMessage(${JSON.stringify(data)}, '*')
|
|
188
|
+
window.close()
|
|
189
|
+
} else {
|
|
190
|
+
window.location.href = '/'
|
|
191
|
+
}
|
|
192
|
+
</script>
|
|
193
|
+
</head>
|
|
194
|
+
<body>
|
|
195
|
+
<p>${message}</p>
|
|
196
|
+
<p>Close this window or <a href="/">go back to /</a></p>
|
|
197
|
+
</body>
|
|
198
|
+
</html>
|
|
199
|
+
`;
|
|
200
|
+
}
|