@silexlabs/silex 3.0.0-alpha.100
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/.env.default +19 -0
- package/.silex.js +37 -0
- package/LICENSE +661 -0
- package/README.md +96 -0
- package/dist/client/client/api.d.ts +85 -0
- package/dist/client/client/assetUrl.d.ts +51 -0
- package/dist/client/client/config.d.ts +58 -0
- package/dist/client/client/events.d.ts +14 -0
- package/dist/client/client/expose.d.ts +8 -0
- package/dist/client/client/grapesjs/LoginDialog.d.ts +15 -0
- package/dist/client/client/grapesjs/PublicationManager.d.ts +72 -0
- package/dist/client/client/grapesjs/PublicationUi.d.ts +62 -0
- package/dist/client/client/grapesjs/blocks.d.ts +1 -0
- package/dist/client/client/grapesjs/breadcrumbs.d.ts +1 -0
- package/dist/client/client/grapesjs/footer.d.ts +2 -0
- package/dist/client/client/grapesjs/index.d.ts +5 -0
- package/dist/client/client/grapesjs/internal-links.d.ts +1 -0
- package/dist/client/client/grapesjs/new-page-dialog.d.ts +2 -0
- package/dist/client/client/grapesjs/openImport.d.ts +9 -0
- package/dist/client/client/grapesjs/page-panel.d.ts +3 -0
- package/dist/client/client/grapesjs/project-bar.d.ts +1 -0
- package/dist/client/client/grapesjs/rich-text.d.ts +1 -0
- package/dist/client/client/grapesjs/semantic.d.ts +1 -0
- package/dist/client/client/grapesjs/settings.d.ts +2 -0
- package/dist/client/client/grapesjs/storage.d.ts +1 -0
- package/dist/client/client/grapesjs/symbolDialogs.d.ts +3 -0
- package/dist/client/client/index.d.ts +5 -0
- package/dist/client/client/publication-transformers.d.ts +41 -0
- package/dist/client/client/utils.d.ts +2 -0
- package/dist/client/constants.d.ts +29 -0
- package/dist/client/css/admin.css +4491 -0
- package/dist/client/index.html +9 -0
- package/dist/client/js/main.js +321 -0
- package/dist/client/js/main.js.LICENSE.txt +24 -0
- package/dist/client/page.d.ts +2 -0
- package/dist/client/types.d.ts +334 -0
- package/dist/plugins/client/client/api.d.ts +85 -0
- package/dist/plugins/client/client/api.js +114 -0
- package/dist/plugins/client/client/api.js.map +1 -0
- package/dist/plugins/client/client/assetUrl.d.ts +51 -0
- package/dist/plugins/client/client/assetUrl.js +224 -0
- package/dist/plugins/client/client/assetUrl.js.map +1 -0
- package/dist/plugins/client/client/config.d.ts +58 -0
- package/dist/plugins/client/client/config.js +90 -0
- package/dist/plugins/client/client/config.js.map +1 -0
- package/dist/plugins/client/client/events.d.ts +14 -0
- package/dist/plugins/client/client/events.js +34 -0
- package/dist/plugins/client/client/events.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.js +195 -0
- package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +72 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js +356 -0
- package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +62 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.js +336 -0
- package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/blocks.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/blocks.js +37 -0
- package/dist/plugins/client/client/grapesjs/blocks.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/breadcrumbs.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/breadcrumbs.js +75 -0
- package/dist/plugins/client/client/grapesjs/breadcrumbs.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/footer.d.ts +2 -0
- package/dist/plugins/client/client/grapesjs/footer.js +28 -0
- package/dist/plugins/client/client/grapesjs/footer.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/index.d.ts +5 -0
- package/dist/plugins/client/client/grapesjs/index.js +313 -0
- package/dist/plugins/client/client/grapesjs/index.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/internal-links.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/internal-links.js +219 -0
- package/dist/plugins/client/client/grapesjs/internal-links.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +2 -0
- package/dist/plugins/client/client/grapesjs/new-page-dialog.js +83 -0
- package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/openImport.d.ts +9 -0
- package/dist/plugins/client/client/grapesjs/openImport.js +74 -0
- package/dist/plugins/client/client/grapesjs/openImport.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/page-panel.d.ts +3 -0
- package/dist/plugins/client/client/grapesjs/page-panel.js +113 -0
- package/dist/plugins/client/client/grapesjs/page-panel.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/project-bar.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/project-bar.js +104 -0
- package/dist/plugins/client/client/grapesjs/project-bar.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/rich-text.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/rich-text.js +31 -0
- package/dist/plugins/client/client/grapesjs/rich-text.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/semantic.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/semantic.js +110 -0
- package/dist/plugins/client/client/grapesjs/semantic.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/settings.d.ts +2 -0
- package/dist/plugins/client/client/grapesjs/settings.js +198 -0
- package/dist/plugins/client/client/grapesjs/settings.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/storage.d.ts +1 -0
- package/dist/plugins/client/client/grapesjs/storage.js +126 -0
- package/dist/plugins/client/client/grapesjs/storage.js.map +1 -0
- package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +3 -0
- package/dist/plugins/client/client/grapesjs/symbolDialogs.js +36 -0
- package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +1 -0
- package/dist/plugins/client/client/publication-transformers.d.ts +41 -0
- package/dist/plugins/client/client/publication-transformers.js +238 -0
- package/dist/plugins/client/client/publication-transformers.js.map +1 -0
- package/dist/plugins/client/client/utils.d.ts +2 -0
- package/dist/plugins/client/client/utils.js +25 -0
- package/dist/plugins/client/client/utils.js.map +1 -0
- package/dist/plugins/client/constants.d.ts +29 -0
- package/dist/plugins/client/constants.js +46 -0
- package/dist/plugins/client/constants.js.map +1 -0
- package/dist/plugins/client/page.d.ts +2 -0
- package/dist/plugins/client/page.js +31 -0
- package/dist/plugins/client/page.js.map +1 -0
- package/dist/plugins/client/plugins/client/11ty.d.ts +17 -0
- package/dist/plugins/client/plugins/client/11ty.js +86 -0
- package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.d.ts +2 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.js +170 -0
- package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -0
- package/dist/plugins/client/plugins/client/template.d.ts +2 -0
- package/dist/plugins/client/plugins/client/template.js +183 -0
- package/dist/plugins/client/plugins/client/template.js.map +1 -0
- package/dist/plugins/client/plugins/client/website-info.d.ts +1 -0
- package/dist/plugins/client/plugins/client/website-info.js +72 -0
- package/dist/plugins/client/plugins/client/website-info.js.map +1 -0
- package/dist/plugins/client/types.d.ts +334 -0
- package/dist/plugins/client/types.js +74 -0
- package/dist/plugins/client/types.js.map +1 -0
- package/dist/plugins/server/constants.d.ts +29 -0
- package/dist/plugins/server/constants.js +49 -0
- package/dist/plugins/server/constants.js.map +1 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.d.ts +1 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.js +40 -0
- package/dist/plugins/server/plugins/server/AuthPlugin.js.map +1 -0
- package/dist/plugins/server/plugins/server/Cache.d.ts +2 -0
- package/dist/plugins/server/plugins/server/Cache.js +32 -0
- package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
- package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +29 -0
- package/dist/plugins/server/plugins/server/DownloadConnector.js +129 -0
- package/dist/plugins/server/plugins/server/DownloadConnector.js.map +1 -0
- package/dist/plugins/server/plugins/server/FtpConnector.d.ts +86 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js +526 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +87 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.js +564 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -0
- package/dist/plugins/server/plugins/server/PublicationOptimizer.d.ts +0 -0
- package/dist/plugins/server/plugins/server/PublicationOptimizer.js +14 -0
- package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +1 -0
- package/dist/plugins/server/plugins/server/SslPlugin.d.ts +1 -0
- package/dist/plugins/server/plugins/server/SslPlugin.js +86 -0
- package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
- package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +1 -0
- package/dist/plugins/server/plugins/server/StaticPlugin.js +78 -0
- package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
- package/dist/plugins/server/server/config.d.ts +59 -0
- package/dist/plugins/server/server/config.js +181 -0
- 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 +54 -0
- package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
- package/dist/plugins/server/server/connectors/FsStorage.d.ts +43 -0
- package/dist/plugins/server/server/connectors/FsStorage.js +257 -0
- package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
- package/dist/plugins/server/server/connectors/connectors.d.ts +87 -0
- package/dist/plugins/server/server/connectors/connectors.js +127 -0
- package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
- package/dist/plugins/server/server/events.d.ts +26 -0
- package/dist/plugins/server/server/events.js +31 -0
- package/dist/plugins/server/server/events.js.map +1 -0
- package/dist/plugins/server/server/jobs.d.ts +12 -0
- package/dist/plugins/server/server/jobs.js +77 -0
- package/dist/plugins/server/server/jobs.js.map +1 -0
- package/dist/plugins/server/server/utils/validation.d.ts +7 -0
- package/dist/plugins/server/server/utils/validation.js +38 -0
- package/dist/plugins/server/server/utils/validation.js.map +1 -0
- package/dist/plugins/server/types.d.ts +334 -0
- package/dist/plugins/server/types.js +78 -0
- package/dist/plugins/server/types.js.map +1 -0
- package/dist/server/constants.js +29 -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 +216 -0
- package/dist/server/server/api/publicationApi.js +108 -0
- package/dist/server/server/api/websiteApi.js +296 -0
- package/dist/server/server/cli.js +68 -0
- package/dist/server/server/config.js +120 -0
- package/dist/server/server/connectors/FsHosting.js +35 -0
- package/dist/server/server/connectors/FsStorage.js +225 -0
- package/dist/server/server/connectors/connectors.js +89 -0
- package/dist/server/server/events.js +14 -0
- package/dist/server/server/expose.js +27 -0
- package/dist/server/server/express.js +47 -0
- package/dist/server/server/index.js +90 -0
- package/dist/server/server/jobs.js +48 -0
- package/dist/server/server/utils/validation.js +15 -0
- package/dist/server/types.js +34 -0
- package/package.json +209 -0
- package/public/assets/container.png +0 -0
- package/public/assets/favicon.png +0 -0
- package/public/assets/logo-silex-small.png +0 -0
- package/public/robots.txt +2 -0
- package/public/silex.js +24 -0
- package/src/css/_mixins.scss +8 -0
- package/src/css/_variables.scss +33 -0
- package/src/css/dialog.scss +41 -0
- package/src/css/footer.scss +12 -0
- package/src/css/grapesjs-light.scss +180 -0
- package/src/css/grapesjs.scss +152 -0
- package/src/css/index.scss +32 -0
- package/src/css/light.scss +7 -0
- package/src/css/loader.scss +12 -0
- package/src/css/page-panel.scss +65 -0
- package/src/css/project-bar.scss +102 -0
- package/src/css/silex.scss +189 -0
- package/src/css/website-info.scss +14 -0
- package/src/html/debug.pug +8 -0
- package/src/html/index.pug +39 -0
- package/src/html/templates/includes.pug +1 -0
- package/src/html/templates/workspace.pug +2 -0
- package/src/ts/client/api.ts +144 -0
- package/src/ts/client/assetUrl.test.ts +125 -0
- package/src/ts/client/assetUrl.ts +235 -0
- package/src/ts/client/config.ts +105 -0
- package/src/ts/client/events.ts +34 -0
- package/src/ts/client/expose.ts +30 -0
- package/src/ts/client/grapesjs/LoginDialog.ts +204 -0
- package/src/ts/client/grapesjs/PublicationManager.ts +370 -0
- package/src/ts/client/grapesjs/PublicationUi.ts +342 -0
- package/src/ts/client/grapesjs/blocks.ts +37 -0
- package/src/ts/client/grapesjs/breadcrumbs.ts +79 -0
- package/src/ts/client/grapesjs/eleventy.ts +47 -0
- package/src/ts/client/grapesjs/footer.ts +27 -0
- package/src/ts/client/grapesjs/index.ts +335 -0
- package/src/ts/client/grapesjs/internal-links.test.ts +105 -0
- package/src/ts/client/grapesjs/internal-links.ts +225 -0
- package/src/ts/client/grapesjs/new-page-dialog.ts +90 -0
- package/src/ts/client/grapesjs/openImport.ts +81 -0
- package/src/ts/client/grapesjs/page-panel.ts +118 -0
- package/src/ts/client/grapesjs/project-bar.ts +107 -0
- package/src/ts/client/grapesjs/rich-text.ts +33 -0
- package/src/ts/client/grapesjs/semantic.ts +114 -0
- package/src/ts/client/grapesjs/settings.ts +208 -0
- package/src/ts/client/grapesjs/storage.ts +121 -0
- package/src/ts/client/grapesjs/symbolDialogs.ts +38 -0
- package/src/ts/client/index.ts +98 -0
- package/src/ts/client/publication-transformers.test.ts +199 -0
- package/src/ts/client/publication-transformers.ts +263 -0
- package/src/ts/client/utils.ts +28 -0
- package/src/ts/constants.ts +52 -0
- package/src/ts/externs.ts +18 -0
- package/src/ts/page.ts +31 -0
- package/src/ts/plugins/client/11ty.ts +104 -0
- package/src/ts/plugins/client/publicationRenderer.ts +174 -0
- package/src/ts/plugins/client/template.ts +192 -0
- package/src/ts/plugins/client/website-info.ts +84 -0
- package/src/ts/plugins/server/AuthPlugin.ts +38 -0
- package/src/ts/plugins/server/Cache.ts +28 -0
- package/src/ts/plugins/server/DownloadConnector.ts +148 -0
- package/src/ts/plugins/server/FtpConnector.test.ts +82 -0
- package/src/ts/plugins/server/FtpConnector.ts +609 -0
- package/src/ts/plugins/server/GitlabConnector.ts +644 -0
- package/src/ts/plugins/server/PublicationOptimizer.ts +14 -0
- package/src/ts/plugins/server/SslPlugin.ts +84 -0
- package/src/ts/plugins/server/StaticPlugin.ts +79 -0
- package/src/ts/server/api/api.ts +19 -0
- package/src/ts/server/api/connectorApi.ts +345 -0
- package/src/ts/server/api/publicationApi.ts +159 -0
- package/src/ts/server/api/websiteApi.ts +432 -0
- package/src/ts/server/cli.ts +65 -0
- package/src/ts/server/config.ts +189 -0
- package/src/ts/server/connectors/FsHosting.ts +60 -0
- package/src/ts/server/connectors/FsStorage.test.ts +51 -0
- package/src/ts/server/connectors/FsStorage.ts +261 -0
- package/src/ts/server/connectors/connectors.ts +203 -0
- package/src/ts/server/events.ts +37 -0
- package/src/ts/server/expose.ts +19 -0
- package/src/ts/server/express.ts +70 -0
- package/src/ts/server/index.ts +100 -0
- package/src/ts/server/jobs.test.ts +75 -0
- package/src/ts/server/jobs.ts +87 -0
- package/src/ts/server/utils/BackwardCompat.ts +552 -0
- package/src/ts/server/utils/validation.ts +34 -0
- package/src/ts/types.ts +339 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* jQuery JavaScript Library v3.7.0
|
|
3
|
+
* https://jquery.com/
|
|
4
|
+
*
|
|
5
|
+
* Copyright OpenJS Foundation and other contributors
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
* https://jquery.org/license
|
|
8
|
+
*
|
|
9
|
+
* Date: 2023-05-11T18:29Z
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*! @silexlabs/grapesjs-loading - 1.0.8 */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2017 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @license
|
|
22
|
+
* Copyright 2021 Google LLC
|
|
23
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
24
|
+
*/
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview define types for Silex client and server
|
|
3
|
+
*/
|
|
4
|
+
export interface PublicationSettings {
|
|
5
|
+
connector?: ConnectorData;
|
|
6
|
+
options?: ConnectorOptions;
|
|
7
|
+
}
|
|
8
|
+
export interface WebsiteFile {
|
|
9
|
+
html: string;
|
|
10
|
+
css: string;
|
|
11
|
+
htmlPath: string;
|
|
12
|
+
cssPath: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class ApiError extends Error {
|
|
15
|
+
readonly httpStatusCode: number;
|
|
16
|
+
constructor(message: string, httpStatusCode: number);
|
|
17
|
+
}
|
|
18
|
+
export type ApiResponseError = {
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
export type ApiPublicationPublishBody = WebsiteData;
|
|
22
|
+
export type ApiPublicationPublishQuery = {
|
|
23
|
+
websiteId: WebsiteId;
|
|
24
|
+
hostingId: ConnectorId;
|
|
25
|
+
storageId: ConnectorId;
|
|
26
|
+
options: ConnectorOptions;
|
|
27
|
+
};
|
|
28
|
+
export type ApiPublicationPublishResponse = {
|
|
29
|
+
url: string;
|
|
30
|
+
job: PublicationJobData;
|
|
31
|
+
};
|
|
32
|
+
export type ApiPublicationStatusQuery = {
|
|
33
|
+
jobId: JobId;
|
|
34
|
+
};
|
|
35
|
+
export type ApiPublicationStatusResponse = PublicationJobData;
|
|
36
|
+
export type ApiWebsiteReadQuery = {
|
|
37
|
+
websiteId: WebsiteId;
|
|
38
|
+
connectorId?: ConnectorId;
|
|
39
|
+
};
|
|
40
|
+
export type ApiWebsiteReadResponse = WebsiteData;
|
|
41
|
+
export type ApiWebsiteListQuery = {
|
|
42
|
+
connectorId?: ConnectorId;
|
|
43
|
+
};
|
|
44
|
+
export type ApiWebsiteListResponse = WebsiteMeta[];
|
|
45
|
+
export type ApiWebsiteWriteQuery = {
|
|
46
|
+
websiteId: WebsiteId;
|
|
47
|
+
connectorId?: ConnectorId;
|
|
48
|
+
};
|
|
49
|
+
export type ApiWebsiteWriteBody = WebsiteData;
|
|
50
|
+
export type ApiWebsiteWriteResponse = {
|
|
51
|
+
message: string;
|
|
52
|
+
};
|
|
53
|
+
export type ApiWebsiteCreateQuery = {
|
|
54
|
+
connectorId?: ConnectorId;
|
|
55
|
+
};
|
|
56
|
+
export type ApiWebsiteCreateBody = WebsiteMetaFileContent;
|
|
57
|
+
export type ApiWebsiteCreateResponse = {
|
|
58
|
+
message: string;
|
|
59
|
+
};
|
|
60
|
+
export type ApiWebsiteDeleteQuery = {
|
|
61
|
+
websiteId: WebsiteId;
|
|
62
|
+
connectorId?: ConnectorId;
|
|
63
|
+
};
|
|
64
|
+
export type ApiWebsiteMetaReadQuery = {
|
|
65
|
+
websiteId: WebsiteId;
|
|
66
|
+
connectorId?: ConnectorId;
|
|
67
|
+
};
|
|
68
|
+
export type ApiWebsiteMetaReadResponse = WebsiteMeta;
|
|
69
|
+
export type ApiWebsiteMetaWriteQuery = {
|
|
70
|
+
websiteId: WebsiteId;
|
|
71
|
+
connectorId?: ConnectorId;
|
|
72
|
+
};
|
|
73
|
+
export type ApiWebsiteMetaWriteBody = WebsiteMetaFileContent;
|
|
74
|
+
export type ApiWebsiteMetaWriteResponse = {
|
|
75
|
+
message: string;
|
|
76
|
+
};
|
|
77
|
+
export type ApiWebsiteAssetsReadQuery = {
|
|
78
|
+
websiteId: WebsiteId;
|
|
79
|
+
connectorId?: ConnectorId;
|
|
80
|
+
};
|
|
81
|
+
export type ApiWebsiteAssetsReadParams = {
|
|
82
|
+
path: string;
|
|
83
|
+
};
|
|
84
|
+
export type ApiWebsiteAssetsReadResponse = string;
|
|
85
|
+
export type ApiWebsiteAssetsWriteQuery = {
|
|
86
|
+
websiteId: WebsiteId;
|
|
87
|
+
connectorId?: ConnectorId;
|
|
88
|
+
};
|
|
89
|
+
export type ApiWebsiteAssetsWriteBody = ClientSideFile[];
|
|
90
|
+
export type ApiWebsiteAssetsWriteResponse = {
|
|
91
|
+
data: string[];
|
|
92
|
+
};
|
|
93
|
+
export type ApiConnectorListQuery = {
|
|
94
|
+
type: ConnectorType;
|
|
95
|
+
};
|
|
96
|
+
export type ApiConnectorListResponse = ConnectorData[];
|
|
97
|
+
export type ApiConnectorLoginQuery = {
|
|
98
|
+
connectorId: ConnectorId;
|
|
99
|
+
type: ConnectorType;
|
|
100
|
+
};
|
|
101
|
+
export type ApiConnectorLoggedInPostMessage = {
|
|
102
|
+
type: string;
|
|
103
|
+
error: boolean;
|
|
104
|
+
message: string;
|
|
105
|
+
connectorId: ConnectorId;
|
|
106
|
+
options: ConnectorOptions;
|
|
107
|
+
};
|
|
108
|
+
export type ApiConnectorLoginCbkQuery = {
|
|
109
|
+
connectorId?: ConnectorId;
|
|
110
|
+
type: ConnectorType;
|
|
111
|
+
error?: string;
|
|
112
|
+
};
|
|
113
|
+
export type ApiConnectorLoginCbkBody = object;
|
|
114
|
+
export type ApiConnectorSettingsQuery = {
|
|
115
|
+
connectorId?: ConnectorId;
|
|
116
|
+
type: ConnectorType;
|
|
117
|
+
};
|
|
118
|
+
export type ApiConnectorSettingsResponse = string;
|
|
119
|
+
export type ApiConnectorSettingsPostQuery = {
|
|
120
|
+
connectorId?: ConnectorId;
|
|
121
|
+
type: ConnectorType;
|
|
122
|
+
};
|
|
123
|
+
export type ApiConnectorSettingsPostBody = ConnectorUserSettings;
|
|
124
|
+
export type ApiConnectorSettingsPostResponse = {
|
|
125
|
+
message: string;
|
|
126
|
+
};
|
|
127
|
+
export type ApiConnectorLogoutQuery = {
|
|
128
|
+
connectorId?: ConnectorId;
|
|
129
|
+
type: ConnectorType;
|
|
130
|
+
};
|
|
131
|
+
export type ApiConnectorUserQuery = {
|
|
132
|
+
connectorId?: ConnectorId;
|
|
133
|
+
type: ConnectorType;
|
|
134
|
+
};
|
|
135
|
+
export type ApiConnectorUserResponse = ConnectorUser;
|
|
136
|
+
export declare const defaultWebsiteData: WebsiteData;
|
|
137
|
+
export interface Component {
|
|
138
|
+
type: string;
|
|
139
|
+
content?: string;
|
|
140
|
+
attributes: {
|
|
141
|
+
[key: string]: string;
|
|
142
|
+
};
|
|
143
|
+
components: Component[];
|
|
144
|
+
}
|
|
145
|
+
export interface Page {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
slug: string;
|
|
149
|
+
settings: WebsiteSettings;
|
|
150
|
+
frames: {
|
|
151
|
+
component: Component;
|
|
152
|
+
}[];
|
|
153
|
+
}
|
|
154
|
+
export interface WebsiteData {
|
|
155
|
+
pages: Page[];
|
|
156
|
+
assets: Asset[];
|
|
157
|
+
styles: Style[];
|
|
158
|
+
settings: WebsiteSettings;
|
|
159
|
+
fonts: Font[];
|
|
160
|
+
symbols: symbol[];
|
|
161
|
+
publication: PublicationSettings;
|
|
162
|
+
}
|
|
163
|
+
export interface PublicationData extends WebsiteData {
|
|
164
|
+
files?: ClientSideFile[];
|
|
165
|
+
}
|
|
166
|
+
export interface WebsiteSettings {
|
|
167
|
+
description?: string;
|
|
168
|
+
title?: string;
|
|
169
|
+
lang?: string;
|
|
170
|
+
head?: string;
|
|
171
|
+
favicon?: string;
|
|
172
|
+
'og:title'?: string;
|
|
173
|
+
'og:description'?: string;
|
|
174
|
+
'og:image'?: string;
|
|
175
|
+
}
|
|
176
|
+
export interface Font {
|
|
177
|
+
name: string;
|
|
178
|
+
value: string;
|
|
179
|
+
variants: string[];
|
|
180
|
+
}
|
|
181
|
+
export declare enum Unit {
|
|
182
|
+
PX = "px"
|
|
183
|
+
}
|
|
184
|
+
export interface Asset {
|
|
185
|
+
type: string;
|
|
186
|
+
src: string;
|
|
187
|
+
unitDim: Unit;
|
|
188
|
+
height: number;
|
|
189
|
+
width: number;
|
|
190
|
+
name: string;
|
|
191
|
+
path?: string;
|
|
192
|
+
}
|
|
193
|
+
export interface Style {
|
|
194
|
+
selectors: Selector[];
|
|
195
|
+
style: {
|
|
196
|
+
[key: string]: string;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export type Selector = string | {
|
|
200
|
+
name: string;
|
|
201
|
+
type: number;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Type for a connector id
|
|
205
|
+
*/
|
|
206
|
+
export type ConnectorId = string;
|
|
207
|
+
export type ConnectorOptions = {
|
|
208
|
+
websiteUrl?: string;
|
|
209
|
+
[key: string]: any;
|
|
210
|
+
};
|
|
211
|
+
export declare enum ClientSideFileType {
|
|
212
|
+
HTML = "html",
|
|
213
|
+
ASSET = "asset",
|
|
214
|
+
CSS = "css"
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Type for a client side file when the content is not available, used to handle file names and paths and urls
|
|
218
|
+
*/
|
|
219
|
+
export interface ClientSideFileWithPermalink {
|
|
220
|
+
path: string;
|
|
221
|
+
permalink: string;
|
|
222
|
+
type: ClientSideFileType;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Type for a client side file when the content is available as a string
|
|
226
|
+
*/
|
|
227
|
+
export interface ClientSideFileWithContent {
|
|
228
|
+
path: string;
|
|
229
|
+
content: string;
|
|
230
|
+
type: ClientSideFileType;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Type for a client side file when the content is in the connector
|
|
234
|
+
*/
|
|
235
|
+
export interface ClientSideFileWithSrc {
|
|
236
|
+
path: string;
|
|
237
|
+
src: string;
|
|
238
|
+
type: ClientSideFileType;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Type for a client side file
|
|
242
|
+
* @see connector/File
|
|
243
|
+
*/
|
|
244
|
+
export type ClientSideFile = ClientSideFileWithContent | ClientSideFileWithSrc;
|
|
245
|
+
/**
|
|
246
|
+
* Type for file listing
|
|
247
|
+
*/
|
|
248
|
+
export interface FileMeta {
|
|
249
|
+
name: string;
|
|
250
|
+
isDir: boolean;
|
|
251
|
+
size: number;
|
|
252
|
+
createdAt: Date;
|
|
253
|
+
updatedAt: Date;
|
|
254
|
+
metadata?: object;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Enum to express if the connector is a storage or a hosting
|
|
258
|
+
*/
|
|
259
|
+
export declare enum ConnectorType {
|
|
260
|
+
STORAGE = "STORAGE",
|
|
261
|
+
HOSTING = "HOSTING"
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Type for a website id
|
|
265
|
+
*/
|
|
266
|
+
export type WebsiteId = string;
|
|
267
|
+
/**
|
|
268
|
+
* Back end data shared with the front end
|
|
269
|
+
*/
|
|
270
|
+
export interface ConnectorData {
|
|
271
|
+
connectorId: ConnectorId;
|
|
272
|
+
type: ConnectorType;
|
|
273
|
+
displayName: string;
|
|
274
|
+
icon: string;
|
|
275
|
+
disableLogout: boolean;
|
|
276
|
+
isLoggedIn: boolean;
|
|
277
|
+
oauthUrl: string | null;
|
|
278
|
+
color: string;
|
|
279
|
+
background: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* User settings for a connector and for a given website
|
|
283
|
+
*/
|
|
284
|
+
export type ConnectorUserSettings = {
|
|
285
|
+
[websiteId: string]: object;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Back end data shared with the front end
|
|
289
|
+
*/
|
|
290
|
+
export interface ConnectorUser {
|
|
291
|
+
name: string;
|
|
292
|
+
email?: string;
|
|
293
|
+
picture?: string;
|
|
294
|
+
storage: ConnectorData;
|
|
295
|
+
}
|
|
296
|
+
export interface WebsiteMetaFileContent {
|
|
297
|
+
name: string;
|
|
298
|
+
imageUrl?: string;
|
|
299
|
+
connectorUserSettings: ConnectorUserSettings;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Back end data sent to the front end
|
|
303
|
+
* Meta data can be the root path of the websites, or the bucket name, etc.
|
|
304
|
+
*/
|
|
305
|
+
export interface WebsiteMeta extends WebsiteMetaFileContent {
|
|
306
|
+
websiteId: WebsiteId;
|
|
307
|
+
createdAt: Date;
|
|
308
|
+
updatedAt: Date;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Enum to express if the job is in progress or finished or errored
|
|
312
|
+
*/
|
|
313
|
+
export declare enum JobStatus {
|
|
314
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
315
|
+
SUCCESS = "SUCCESS",
|
|
316
|
+
ERROR = "ERROR"
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Id used to track the progress of a publication
|
|
320
|
+
*/
|
|
321
|
+
export type JobId = string;
|
|
322
|
+
/**
|
|
323
|
+
* Data structure which is sent to the client to display the progress of a job
|
|
324
|
+
*/
|
|
325
|
+
export interface JobData {
|
|
326
|
+
jobId: JobId;
|
|
327
|
+
status: JobStatus;
|
|
328
|
+
message: string;
|
|
329
|
+
_timeout?: ReturnType<typeof setTimeout>;
|
|
330
|
+
}
|
|
331
|
+
export interface PublicationJobData extends JobData {
|
|
332
|
+
logs: string[][];
|
|
333
|
+
errors: string[][];
|
|
334
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ConnectorId, JobId, PublicationJobData, WebsiteId, ConnectorData, ConnectorType, WebsiteData, ClientSideFile, PublicationData, ConnectorUser, WebsiteMeta, WebsiteMetaFileContent, ConnectorOptions } from '../types';
|
|
2
|
+
export declare enum ApiRoute {
|
|
3
|
+
PUBLICATION_PUBLISH = "/api/publication/",
|
|
4
|
+
PUBLICATION_STATUS = "/api/publication/publication/status",
|
|
5
|
+
CONNECTOR_USER = "/api/connector/user",
|
|
6
|
+
CONNECTOR_LOGOUT = "/api/connector/logout",
|
|
7
|
+
CONNECTOR_LIST = "/api/connector/",
|
|
8
|
+
WEBSITE_READ = "/api/website/",
|
|
9
|
+
WEBSITE_WRITE = "/api/website/",
|
|
10
|
+
WEBSITE_DELETE = "/api/website/",
|
|
11
|
+
WEBSITE_CREATE = "/api/website/",
|
|
12
|
+
WEBSITE_LIST = "/api/website/",
|
|
13
|
+
WEBSITE_ASSETS_READ = "/api/website/assets",
|
|
14
|
+
WEBSITE_ASSETS_WRITE = "/api/website/assets",
|
|
15
|
+
WEBSITE_META_READ = "/api/website/meta",
|
|
16
|
+
WEBSITE_META_WRITE = "/api/website/meta"
|
|
17
|
+
}
|
|
18
|
+
export declare function setServerUrl(url: string): void;
|
|
19
|
+
export declare function getServerUrl(): string;
|
|
20
|
+
export declare function getUser({ type, connectorId }: {
|
|
21
|
+
type: ConnectorType;
|
|
22
|
+
connectorId?: ConnectorId;
|
|
23
|
+
}): Promise<ConnectorUser>;
|
|
24
|
+
export declare function logout({ type, connectorId }: {
|
|
25
|
+
type: ConnectorType;
|
|
26
|
+
connectorId?: ConnectorId;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
export declare function publish({ websiteId, hostingId, storageId, data, options }: {
|
|
29
|
+
websiteId: WebsiteId;
|
|
30
|
+
hostingId: ConnectorId;
|
|
31
|
+
storageId: ConnectorId;
|
|
32
|
+
data: PublicationData;
|
|
33
|
+
options: ConnectorOptions;
|
|
34
|
+
}): Promise<[url: string, job: PublicationJobData]>;
|
|
35
|
+
export declare function publicationStatus({ jobId }: {
|
|
36
|
+
jobId: JobId;
|
|
37
|
+
}): Promise<PublicationJobData>;
|
|
38
|
+
export declare function connectorList({ type }: {
|
|
39
|
+
type: ConnectorType;
|
|
40
|
+
}): Promise<ConnectorData[]>;
|
|
41
|
+
export declare function websiteList({ connectorId }: {
|
|
42
|
+
connectorId?: ConnectorId;
|
|
43
|
+
}): Promise<WebsiteMeta[]>;
|
|
44
|
+
export declare function websiteLoad({ websiteId, connectorId }: {
|
|
45
|
+
websiteId: WebsiteId;
|
|
46
|
+
connectorId?: ConnectorId;
|
|
47
|
+
}): Promise<WebsiteData>;
|
|
48
|
+
export declare function websiteSave({ websiteId, data, connectorId }: {
|
|
49
|
+
websiteId: WebsiteId;
|
|
50
|
+
data: WebsiteData;
|
|
51
|
+
connectorId?: ConnectorId;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
export declare function websiteDelete({ websiteId, connectorId }: {
|
|
54
|
+
websiteId: WebsiteId;
|
|
55
|
+
connectorId?: ConnectorId;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
export declare function websiteCreate({ websiteId, data, connectorId }: {
|
|
58
|
+
websiteId: WebsiteId;
|
|
59
|
+
data: WebsiteMetaFileContent;
|
|
60
|
+
connectorId?: ConnectorId;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
export declare function websiteMetaWrite({ websiteId, data, connectorId }: {
|
|
63
|
+
websiteId: WebsiteId;
|
|
64
|
+
data: WebsiteMetaFileContent;
|
|
65
|
+
connectorId?: ConnectorId;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
export declare function websiteMetaRead({ websiteId, connectorId }: {
|
|
68
|
+
websiteId: WebsiteId;
|
|
69
|
+
connectorId?: ConnectorId;
|
|
70
|
+
}): Promise<WebsiteMeta>;
|
|
71
|
+
export declare function websiteAssetsLoad({ path, websiteId, connectorId }: {
|
|
72
|
+
path: string;
|
|
73
|
+
websiteId: WebsiteId;
|
|
74
|
+
connectorId: ConnectorId;
|
|
75
|
+
}): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Not used directly, grapesjs handles the upload
|
|
78
|
+
* @see assetManager in src/ts/client/grapesjs/index.ts
|
|
79
|
+
*/
|
|
80
|
+
export declare function websiteAssetsSave({ websiteId, connectorId, files }: {
|
|
81
|
+
websiteId: WebsiteId;
|
|
82
|
+
connectorId: ConnectorId;
|
|
83
|
+
files: ClientSideFile[];
|
|
84
|
+
}): Promise<string[]>;
|
|
85
|
+
export declare function api<ReqQuery, ReqBody, ResBody>(route: ApiRoute | string, method: string, query?: ReqQuery, payload?: ReqBody): Promise<ResBody>;
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
import { API_CONNECTOR_LIST, API_CONNECTOR_USER, API_CONNECTOR_LOGOUT, API_CONNECTOR_PATH, API_PATH, API_PUBLICATION_PATH, API_PUBLICATION_PUBLISH, API_PUBLICATION_STATUS, API_WEBSITE_ASSET_READ, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_DELETE, API_WEBSITE_LIST, API_WEBSITE_PATH, API_WEBSITE_READ, API_WEBSITE_WRITE, API_WEBSITE_META_READ, API_WEBSITE_META_WRITE, API_WEBSITE_CREATE } from '../constants';
|
|
18
|
+
import { ApiError } from '../types';
|
|
19
|
+
export var ApiRoute;
|
|
20
|
+
(function (ApiRoute) {
|
|
21
|
+
ApiRoute["PUBLICATION_PUBLISH"] = "/api/publication/";
|
|
22
|
+
ApiRoute["PUBLICATION_STATUS"] = "/api/publication/publication/status";
|
|
23
|
+
ApiRoute["CONNECTOR_USER"] = "/api/connector/user";
|
|
24
|
+
ApiRoute["CONNECTOR_LOGOUT"] = "/api/connector/logout";
|
|
25
|
+
ApiRoute["CONNECTOR_LIST"] = "/api/connector/";
|
|
26
|
+
ApiRoute["WEBSITE_READ"] = "/api/website/";
|
|
27
|
+
ApiRoute["WEBSITE_WRITE"] = "/api/website/";
|
|
28
|
+
ApiRoute["WEBSITE_DELETE"] = "/api/website/";
|
|
29
|
+
ApiRoute["WEBSITE_CREATE"] = "/api/website/";
|
|
30
|
+
ApiRoute["WEBSITE_LIST"] = "/api/website/";
|
|
31
|
+
ApiRoute["WEBSITE_ASSETS_READ"] = "/api/website/assets";
|
|
32
|
+
ApiRoute["WEBSITE_ASSETS_WRITE"] = "/api/website/assets";
|
|
33
|
+
ApiRoute["WEBSITE_META_READ"] = "/api/website/meta";
|
|
34
|
+
ApiRoute["WEBSITE_META_WRITE"] = "/api/website/meta";
|
|
35
|
+
})(ApiRoute || (ApiRoute = {}));
|
|
36
|
+
// Root URL of Silex server, should we use config.rootUrl ?
|
|
37
|
+
let serverUrl = window.location.origin + window.location.pathname.replace(/\/$/, '');
|
|
38
|
+
export function setServerUrl(url) {
|
|
39
|
+
serverUrl = url;
|
|
40
|
+
}
|
|
41
|
+
export function getServerUrl() {
|
|
42
|
+
return serverUrl;
|
|
43
|
+
}
|
|
44
|
+
export async function getUser({ type, connectorId }) {
|
|
45
|
+
return api(ApiRoute.CONNECTOR_USER, 'GET', {
|
|
46
|
+
type,
|
|
47
|
+
connectorId,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export async function logout({ type, connectorId }) {
|
|
51
|
+
return api(ApiRoute.CONNECTOR_LOGOUT, 'POST', { connectorId, type });
|
|
52
|
+
}
|
|
53
|
+
export async function publish({ websiteId, hostingId, storageId, data, options }) {
|
|
54
|
+
const { url, job } = await api(ApiRoute.PUBLICATION_PUBLISH, 'POST', { websiteId, hostingId, storageId, options }, data);
|
|
55
|
+
return [url, job];
|
|
56
|
+
}
|
|
57
|
+
export async function publicationStatus({ jobId }) {
|
|
58
|
+
return api(ApiRoute.PUBLICATION_STATUS, 'GET', { jobId });
|
|
59
|
+
}
|
|
60
|
+
export async function connectorList({ type }) {
|
|
61
|
+
const list = await api(ApiRoute.CONNECTOR_LIST, 'GET', { type });
|
|
62
|
+
return list;
|
|
63
|
+
}
|
|
64
|
+
export async function websiteList({ connectorId }) {
|
|
65
|
+
return api(ApiRoute.WEBSITE_LIST, 'GET', { connectorId });
|
|
66
|
+
}
|
|
67
|
+
export async function websiteLoad({ websiteId, connectorId }) {
|
|
68
|
+
return api(ApiRoute.WEBSITE_READ, 'GET', { websiteId, connectorId: connectorId });
|
|
69
|
+
}
|
|
70
|
+
export async function websiteSave({ websiteId, data, connectorId }) {
|
|
71
|
+
const { message } = await api(ApiRoute.WEBSITE_WRITE, 'POST', { websiteId, connectorId: connectorId }, data);
|
|
72
|
+
}
|
|
73
|
+
export async function websiteDelete({ websiteId, connectorId }) {
|
|
74
|
+
await api(ApiRoute.WEBSITE_DELETE, 'DELETE', { websiteId, connectorId: connectorId });
|
|
75
|
+
}
|
|
76
|
+
export async function websiteCreate({ websiteId, data, connectorId }) {
|
|
77
|
+
await api(ApiRoute.WEBSITE_CREATE, 'PUT', { connectorId: connectorId }, data);
|
|
78
|
+
}
|
|
79
|
+
export async function websiteMetaWrite({ websiteId, data, connectorId }) {
|
|
80
|
+
await api(ApiRoute.WEBSITE_META_WRITE, 'POST', { websiteId, connectorId: connectorId }, data);
|
|
81
|
+
}
|
|
82
|
+
export async function websiteMetaRead({ websiteId, connectorId }) {
|
|
83
|
+
return api(ApiRoute.WEBSITE_META_WRITE, 'GET', { websiteId, connectorId });
|
|
84
|
+
}
|
|
85
|
+
export async function websiteAssetsLoad({ path, websiteId, connectorId }) {
|
|
86
|
+
return api(`${ApiRoute.WEBSITE_ASSETS_READ}/${path}`, 'GET', { websiteId, connectorId: connectorId });
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Not used directly, grapesjs handles the upload
|
|
90
|
+
* @see assetManager in src/ts/client/grapesjs/index.ts
|
|
91
|
+
*/
|
|
92
|
+
export async function websiteAssetsSave({ websiteId, connectorId, files }) {
|
|
93
|
+
const { data } = await api(ApiRoute.WEBSITE_ASSETS_WRITE, 'POST', { websiteId, connectorId: connectorId }, files);
|
|
94
|
+
return data;
|
|
95
|
+
}
|
|
96
|
+
export async function api(route, method, query, payload) {
|
|
97
|
+
const url = `${serverUrl}${route.toString()}?${new URLSearchParams(Object.entries(query)
|
|
98
|
+
.filter(([key, value]) => !!value)
|
|
99
|
+
.map(([key, value]) => [key, typeof value === 'string' ? value : JSON.stringify(value)])).toString()}`;
|
|
100
|
+
const response = await fetch(url, {
|
|
101
|
+
method,
|
|
102
|
+
headers: {
|
|
103
|
+
'Content-Type': 'application/json',
|
|
104
|
+
},
|
|
105
|
+
body: payload && JSON.stringify(payload),
|
|
106
|
+
credentials: 'include', // sends the cookies with the request
|
|
107
|
+
});
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
const json = await response.json();
|
|
110
|
+
throw new ApiError(json.message, response.status);
|
|
111
|
+
}
|
|
112
|
+
return response.json();
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/ts/client/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAClZ,OAAO,EAA0+B,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE3gC,MAAM,CAAN,IAAY,QAeX;AAfD,WAAY,QAAQ;IAClB,qDAA+E,CAAA;IAC/E,sEAA6E,CAAA;IAC7E,kDAAmE,CAAA;IACnE,sDAAuE,CAAA;IACvE,8CAAmE,CAAA;IACnE,0CAA6D,CAAA;IA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,EAAE,KAAgB,EAAE,OAAiB;IACjI,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAE,IACzC,IAAI,eAAe,CACjB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAC3F,CAAC,QAAQ,EAAE,EAAE,CAAA;IAChB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM;QACN,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QACxC,WAAW,EAAE,SAAS,EAAE,qCAAqC;KAC9D,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;KAClD;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Asset, ClientSideFileType, ConnectorId, Page, Style, WebsiteId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Function to convert a path from it stored version to the displayed version
|
|
4
|
+
* Stored version is like `/assets/image.webp`
|
|
5
|
+
* Grapesjs version is like `/api/website/assets/image.webp?websiteId=47868975&connectorId=gitlab`
|
|
6
|
+
* Exported for unit tests
|
|
7
|
+
*/
|
|
8
|
+
export declare function storedToDisplayed(path: string, websiteId: WebsiteId, storageId: ConnectorId): string;
|
|
9
|
+
/**
|
|
10
|
+
* Function to convert a path from the one we give to grapesjs to the stored version
|
|
11
|
+
* Grapesjs version is like `/api/website/assets/image.webp?websiteId=47868975&connectorId=gitlab`
|
|
12
|
+
* Stored version is like `/assets/image.webp`
|
|
13
|
+
* @param path the path to convert
|
|
14
|
+
* @returns the converted path
|
|
15
|
+
* Exported for unit tests
|
|
16
|
+
*/
|
|
17
|
+
export declare function displayedToStored(path: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Publication transformer to convert the asset URL during publication
|
|
20
|
+
*/
|
|
21
|
+
export declare const assetsPublicationTransformer: {
|
|
22
|
+
transformPath(path: string, type: ClientSideFileType): string;
|
|
23
|
+
transformPermalink(path: string, type: ClientSideFileType): string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Update asset URL to use the current storage connector and website ID
|
|
27
|
+
* Assets URLs are stored in the project data in the form `/assets/image.webp`
|
|
28
|
+
* This function adds the API path and the connectorId and websiteId like so: `/api/website/assets/image.webp?websiteId=47868975&connectorId=gitlab`
|
|
29
|
+
*/
|
|
30
|
+
export declare function addTempDataToAssetUrl(assets: Asset[], websiteId: WebsiteId, storageId: ConnectorId): Asset[];
|
|
31
|
+
/**
|
|
32
|
+
* Remove the temporary data from the asset URL
|
|
33
|
+
* Remove the API path and the connectorId and websiteId like so: `/assets/image.webp`
|
|
34
|
+
*/
|
|
35
|
+
export declare function removeTempDataFromAssetUrl(assets: Asset[]): Asset[];
|
|
36
|
+
/**
|
|
37
|
+
* Add temp data to pages
|
|
38
|
+
*/
|
|
39
|
+
export declare function addTempDataToPages(pages: Page[], websiteId: WebsiteId, storageId: ConnectorId): Page[];
|
|
40
|
+
/**
|
|
41
|
+
* Remove temp data from asset URL in the components
|
|
42
|
+
*/
|
|
43
|
+
export declare function removeTempDataFromPages(pages: Page[]): Page[];
|
|
44
|
+
/**
|
|
45
|
+
* Add data to stylesheets
|
|
46
|
+
*/
|
|
47
|
+
export declare function addTempDataToStyles(styles: Style[], websiteId: WebsiteId, storageId: ConnectorId): Style[];
|
|
48
|
+
/**
|
|
49
|
+
* Remove temp data from stylesheets
|
|
50
|
+
*/
|
|
51
|
+
export declare function removeTempDataFromStyles(styles: Style[]): Style[];
|