@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
@@ -23,7 +23,7 @@ const express_1 = __importDefault(require("express"));
23
23
  const fs_1 = require("fs");
24
24
  const https_1 = require("https");
25
25
  const express_force_ssl_1 = __importDefault(require("express-force-ssl"));
26
- const events_1 = require("../events");
26
+ const events_1 = require("../../server/events");
27
27
  // interface SslOptions {
28
28
  // forceHttps?: boolean
29
29
  // trustXFPHeader?: boolean
@@ -42,23 +42,23 @@ async function default_1(config, opts = {}) {
42
42
  ...opts,
43
43
  };
44
44
  // Add routes on silex startup
45
- config.on(events_1.EVENT_STARTUP_START, ({ app }) => {
45
+ config.on(events_1.ServerEvent.STARTUP_START, ({ app }) => {
46
46
  const router = express_1.default.Router();
47
47
  // SSL
48
48
  // force ssl if the env var SILEX_FORCE_HTTPS is set
49
49
  if (options.forceHttps) {
50
- console.log('> Force SSL option is enabled');
50
+ console.log('> [SslPlugin] Force SSL option is enabled');
51
51
  app.set('forceSSLOptions', {
52
52
  trustXFPHeader: !!options.trustXFPHeader,
53
53
  });
54
54
  router.use(express_force_ssl_1.default);
55
55
  }
56
56
  else {
57
- console.log('> Force SSL option is disabled, env var SILEX_FORCE_HTTPS not set');
57
+ console.log('> [SslPlugin] Force SSL option is disabled, env var SILEX_FORCE_HTTPS not set');
58
58
  }
59
59
  // SSL certificate
60
60
  if (options.privateKey && options.certificate) {
61
- console.log('> SSL certificate is enabled, found certificate:', options.certificate);
61
+ console.log('> [SslPlugin] SSL certificate is enabled, found certificate:', options.certificate);
62
62
  try {
63
63
  const privateKey = (0, fs_1.readFileSync)(options.privateKey).toString();
64
64
  const certificate = (0, fs_1.readFileSync)(options.certificate).toString();
@@ -69,15 +69,15 @@ async function default_1(config, opts = {}) {
69
69
  rejectUnauthorized: false,
70
70
  };
71
71
  (0, https_1.createServer)(sslServerOptions, this).listen(options.sslPort, () => {
72
- console.log('SSL: listening on port ', options.sslPort);
72
+ console.log('> [SslPlugin] Listening on port ', options.sslPort);
73
73
  });
74
74
  }
75
75
  catch (e) {
76
- console.error('SSL: load certificate failed.', e);
76
+ console.error('> [SslPlugin] Load certificate failed.', e);
77
77
  }
78
78
  }
79
79
  else {
80
- console.log('> SSL certificate disabled, env vars SILEX_SSL_CERTIFICATE and SILEX_SSL_PRIVATE_KEY not set');
80
+ console.log('> [SslPlugin] Certificate disabled, env vars SILEX_SSL_CERTIFICATE and SILEX_SSL_PRIVATE_KEY not set');
81
81
  }
82
82
  app.use(router);
83
83
  });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SslPlugin.js","sourceRoot":"","sources":["../../../../../src/ts/plugins/server/SslPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;AAEH,sDAA6B;AAC7B,2BAAiC;AACjC,iCAAoC;AACpC,0EAAwC;AACxC,gDAAiD;AAEjD,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,wBAAwB;AACxB,yBAAyB;AACzB,qBAAqB;AACrB,IAAI;AAEW,KAAK,oBAAU,MAAM,EAAE,IAAI,GAAG,EAAE;IAC7C,wBAAwB;IACxB,MAAM,OAAO,GAAG;QACd,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM;QACpD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC,KAAK,MAAM;QACzE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC9C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK;QACtC,GAAG,IAAI;KACR,CAAA;IAED,8BAA8B;IAC9B,MAAM,CAAC,EAAE,CAAC,oBAAW,CAAC,aAAa,EAAE,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE;QAC7C,MAAM,MAAM,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAA;QAE/B,MAAM;QACN,oDAAoD;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jB,CAAC,CAAC,CAAA;AACJ,CAAC;AApDD,4BAoDC"}
@@ -23,23 +23,27 @@ const express_1 = __importDefault(require("express"));
23
23
  const node_modules_path_1 = __importDefault(require("node_modules-path"));
24
24
  const serve_static_1 = __importDefault(require("serve-static"));
25
25
  const Cache_1 = require("./Cache");
26
- const events_1 = require("../events");
26
+ const path_1 = require("path");
27
+ const events_1 = require("../../server/events");
27
28
  async function default_1(config, opts = {}) {
28
29
  // Options with defaults
29
30
  const options = {
30
31
  routes: [
31
32
  {
32
33
  route: '/',
33
- path: 'public',
34
+ path: (0, path_1.join)(__dirname, '../../../../..', 'public'),
34
35
  }, {
35
36
  route: '/css/',
36
37
  path: (0, node_modules_path_1.default)('@fortawesome/fontawesome-free') + '/@fortawesome/fontawesome-free/css/',
37
38
  }, {
38
39
  route: '/webfonts/',
39
40
  path: (0, node_modules_path_1.default)('@fortawesome/fontawesome-free') + '/@fortawesome/fontawesome-free/webfonts/',
41
+ }, {
42
+ route: '/node_modules/',
43
+ path: (0, node_modules_path_1.default)(),
40
44
  }, {
41
45
  route: '/',
42
- path: 'dist/client',
46
+ path: (0, path_1.join)(__dirname, '../../../../..', 'dist', 'client'),
43
47
  },
44
48
  ]
45
49
  // add project route for source maps
@@ -49,7 +53,7 @@ async function default_1(config, opts = {}) {
49
53
  }] : []),
50
54
  ...opts,
51
55
  };
52
- config.on(events_1.EVENT_STARTUP_START, ({ app }) => {
56
+ config.on(events_1.ServerEvent.STARTUP_START, ({ app }) => {
53
57
  const router = express_1.default.Router();
54
58
  options.routes
55
59
  .forEach(folder => {
@@ -57,6 +61,7 @@ async function default_1(config, opts = {}) {
57
61
  throw new Error('The config for static module has no `route` attribute');
58
62
  if (!folder.path)
59
63
  throw new Error('The config for static module has no `path` attribute');
64
+ console.info(`> [StaticPlugin] Serving static files from ${folder.path} on ${folder.route}`);
60
65
  router.use(folder.route, (0, serve_static_1.default)(folder.path));
61
66
  });
62
67
  app.use(Cache_1.withCache, router);
@@ -0,0 +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AC,MAAM,CAAC,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK;gBAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;YAC3F,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;YACzF,OAAO,CAAC,IAAI,CAAC,8CAA8C,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;YAC5F,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAA,sBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QACJ,GAAG,CAAC,GAAG,CAAC,iBAAS,EAAG,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC;AAxCD,4BAwCC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @fileoverview This is where the default config is defined. Also use this object as an event emitter to listen to Silex events
3
+ * The values can be overriden with env vars or before passing the config to Silex
4
+ */
5
+ /**
6
+ * @class default config for Silex server
7
+ */
8
+ import { Config, Plugin } from '@silexlabs/silex-plugins';
9
+ import { Application } from 'express';
10
+ import { HostingConnector, StorageConnector } from './connectors/connectors';
11
+ import { Connector } from './connectors/connectors';
12
+ import { ConnectorType } from '../types';
13
+ /**
14
+ * Config types definitions
15
+ */
16
+ export declare class ServerConfig extends Config {
17
+ expressOptions: {
18
+ jsonLimit: string;
19
+ textLimit: string;
20
+ urlencodedLimit: string;
21
+ sessionName: string;
22
+ sessionSecret: string;
23
+ cors: string;
24
+ };
25
+ port: string;
26
+ debug: boolean;
27
+ url: string;
28
+ userConfigPath: Plugin | undefined;
29
+ configFilePath: Plugin;
30
+ getConnectors(type?: ConnectorType | string | null): Connector[];
31
+ private storageConnectors;
32
+ addStorageConnector(storage: StorageConnector | StorageConnector[]): void;
33
+ setStorageConnectors(storageConnectors: StorageConnector[]): void;
34
+ getStorageConnectors(): StorageConnector[];
35
+ private hostingConnectors;
36
+ addHostingConnector(hosting: HostingConnector | HostingConnector[]): void;
37
+ setHostingConnectors(hostings: HostingConnector[]): void;
38
+ getHostingConnectors(): HostingConnector[];
39
+ /**
40
+ * Add routes to serve the client config file
41
+ */
42
+ addRoutes(app: Application): Promise<void>;
43
+ /**
44
+ * Load config files
45
+ * This is the main config file and the user config file
46
+ */
47
+ loadConfigFiles(): Promise<void>;
48
+ /**
49
+ * Load user config file
50
+ * This is the config file passed as env var CONFIG
51
+ */
52
+ loadUserConfig(): Promise<void>;
53
+ /**
54
+ * Load .silex.js in the root folder
55
+ * This is the main config file
56
+ */
57
+ loadSilexConfig(): Promise<void>;
58
+ initDefaultConnectors(): Promise<void>;
59
+ }
@@ -0,0 +1,182 @@
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.ServerConfig = void 0;
20
+ /**
21
+ * @fileoverview This is where the default config is defined. Also use this object as an event emitter to listen to Silex events
22
+ * The values can be overriden with env vars or before passing the config to Silex
23
+ */
24
+ /**
25
+ * @class default config for Silex server
26
+ */
27
+ const silex_plugins_1 = require("@silexlabs/silex-plugins");
28
+ const path_1 = require("path");
29
+ const constants_1 = require("../constants");
30
+ const promises_1 = require("fs/promises");
31
+ const connectors_1 = require("./connectors/connectors");
32
+ const FsStorage_1 = require("./connectors/FsStorage");
33
+ const types_1 = require("../types");
34
+ const FsHosting_1 = require("./connectors/FsHosting");
35
+ /**
36
+ * Config types definitions
37
+ */
38
+ class ServerConfig extends silex_plugins_1.Config {
39
+ expressOptions = {
40
+ jsonLimit: process.env.SILEX_EXPRESS_JSON_LIMIT,
41
+ textLimit: process.env.SILEX_EXPRESS_TEXT_LIMIT,
42
+ urlencodedLimit: process.env.SILEX_EXPRESS_URLENCODED_LIMIT,
43
+ sessionName: process.env.SILEX_SESSION_NAME,
44
+ sessionSecret: process.env.SILEX_SESSION_SECRET,
45
+ cors: process.env.SILEX_CORS_URL,
46
+ };
47
+ port = process.env.SILEX_PORT;
48
+ debug = process.env.SILEX_DEBUG === 'true';
49
+ url = `${process.env.SILEX_PROTOCOL}://${process.env.SILEX_HOST}:${process.env.SILEX_PORT}`;
50
+ userConfigPath = process.env.SILEX_CONFIG;
51
+ configFilePath = (0, path_1.resolve)(__dirname, '../../../.silex.js');
52
+ // All connectors or just the storage or hosting connectors
53
+ getConnectors(type = null) {
54
+ // All connectors including storage and hosting connectors
55
+ if (!type) {
56
+ // Concat storage and hosting connectors
57
+ const allConnectors = this.getStorageConnectors().concat(this.getHostingConnectors());
58
+ // Remove duplicates (if a connector is both a storage and a hosting connector)
59
+ return [...new Set(allConnectors)];
60
+ }
61
+ // Convert to enum in case it is a string
62
+ const connectorType = (0, connectors_1.toConnectorEnum)(type.toString());
63
+ // Only one type of connector
64
+ switch (connectorType) {
65
+ case types_1.ConnectorType.HOSTING: return this.getHostingConnectors();
66
+ case types_1.ConnectorType.STORAGE: return this.getStorageConnectors();
67
+ default: throw new Error(`Unknown connector type ${type}`);
68
+ }
69
+ }
70
+ // Storage connectors to store the website data and assets
71
+ storageConnectors = [];
72
+ addStorageConnector(storage) {
73
+ this.setStorageConnectors(this.storageConnectors.concat(storage));
74
+ }
75
+ setStorageConnectors(storageConnectors) {
76
+ this.storageConnectors = storageConnectors;
77
+ }
78
+ getStorageConnectors() {
79
+ return this.storageConnectors;
80
+ }
81
+ // Hosting connectors to publish the website online
82
+ hostingConnectors = [];
83
+ addHostingConnector(hosting) {
84
+ this.setHostingConnectors(this.hostingConnectors.concat(hosting));
85
+ }
86
+ setHostingConnectors(hostings) {
87
+ this.hostingConnectors = hostings;
88
+ }
89
+ getHostingConnectors() { return this.hostingConnectors; }
90
+ /**
91
+ * Add routes to serve the client config file
92
+ */
93
+ async addRoutes(app) {
94
+ const path = process.env.SILEX_CLIENT_CONFIG;
95
+ if (path) {
96
+ console.log(`> Serving client side config ${path} at ${constants_1.CLIENT_CONFIG_FILE_NAME}`);
97
+ try {
98
+ // Load the client config file
99
+ let clientConfig = (await (0, promises_1.readFile)(path)).toString();
100
+ // Serve the config file
101
+ app.get(`/${constants_1.CLIENT_CONFIG_FILE_NAME}`, async (req, res) => {
102
+ // Reload each time in debug mode
103
+ if (this.debug) {
104
+ console.log('[Debug mode] Reloading config file', path);
105
+ clientConfig = (await (0, promises_1.readFile)(path)).toString();
106
+ }
107
+ // Send the config file
108
+ res
109
+ .contentType('application/javascript')
110
+ .send(clientConfig);
111
+ });
112
+ }
113
+ catch (e) {
114
+ console.error(`Error loading client config file ${path}`, e);
115
+ throw new Error(`Error loading client config file ${path}: ${e.message}`);
116
+ }
117
+ }
118
+ }
119
+ /**
120
+ * Load config files
121
+ * This is the main config file and the user config file
122
+ */
123
+ async loadConfigFiles() {
124
+ // Load the user config file
125
+ await this.loadUserConfig();
126
+ // Load the main config file
127
+ await this.loadSilexConfig();
128
+ }
129
+ /**
130
+ * Load user config file
131
+ * This is the config file passed as env var CONFIG
132
+ */
133
+ async loadUserConfig() {
134
+ if (this.userConfigPath) {
135
+ console.log('> Loading user config', this.userConfigPath);
136
+ try {
137
+ // Initiate the process with the config file which is just another plugin
138
+ await this.addPlugin(this.userConfigPath, {});
139
+ }
140
+ catch (e) {
141
+ throw new Error(`User config file ${this.userConfigPath} error: ${e.message}`);
142
+ }
143
+ }
144
+ }
145
+ /**
146
+ * Load .silex.js in the root folder
147
+ * This is the main config file
148
+ */
149
+ async loadSilexConfig() {
150
+ console.log('> Loading config', this.configFilePath);
151
+ try {
152
+ // Initiate the process with the config file which is just another plugin
153
+ await this.addPlugin(this.configFilePath, {});
154
+ }
155
+ catch (e) {
156
+ console.log(e.requireStack[0]);
157
+ // Check if the error is about the config file not found and not another module not found in the config file
158
+ if (e.code === 'MODULE_NOT_FOUND' && (!e.requireStack || !e.requireStack.find(path => path === this.configFilePath))) {
159
+ console.info('> /!\\ Config file not found', this.configFilePath);
160
+ }
161
+ else {
162
+ throw new Error(`Error in config file ${this.configFilePath}: ${e.message}`);
163
+ }
164
+ }
165
+ }
166
+ async initDefaultConnectors() {
167
+ // Add default storage connectors
168
+ if (!this.storageConnectors.length) {
169
+ this.addStorageConnector(new FsStorage_1.FsStorage(null, {
170
+ path: process.env.SILEX_FS_ROOT,
171
+ }));
172
+ }
173
+ // Add default hosting connectors
174
+ if (!this.hostingConnectors.length) {
175
+ this.addHostingConnector(new FsHosting_1.FsHosting(null, {
176
+ path: process.env.SILEX_FS_ROOT,
177
+ }));
178
+ }
179
+ }
180
+ }
181
+ exports.ServerConfig = ServerConfig;
182
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/ts/server/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;GAGG;AAEH;;GAEG;AAEH,4DAAyD;AACzD,+BAA8B;AAC9B,4CAAsD;AAEtD,0CAAsC;AACtC,wDAA6F;AAC7F,sDAAkD;AAElD,oCAAwC;AACxC,sDAAkD;AAElD;;GAEG;AACH,MAAa,YAAa,SAAQ,sBAAM;IAC/B,cAAc,GAAG;QACtB,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;QAC/C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;QAC/C,eAAe,EAAE,OAAO,CAAC,GA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AAC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;SAC9C;QAAC,OAAM,CAAC,EAAE;YACT,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;YAC9B,4GAA4G;YAC5G,IAAG,CAAC,CAAC,IAAI,KAAK,kBAAkB,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE;gBACnH,OAAO,CAAC,IAAI,CAAC,8BAA8B,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;aAClE;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,cAAc,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;aAC7E;SACF;IACH,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,iCAAiC;QACjC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,mBAAmB,CAAC,IAAI,qBAAS,CAAC,IAAI,EAAE;gBAC3C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;aAChC,CAAC,CAAC,CAAA;SACJ;QACD,iCAAiC;QACjC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,mBAAmB,CAAC,IAAI,qBAAS,CAAC,IAAI,EAAE;gBAC3C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;aAChC,CAAC,CAAC,CAAA;SACJ;IACH,CAAC;CACF;AArJD,oCAqJC"}
@@ -0,0 +1,13 @@
1
+ import { ConnectorFile, HostingConnector, ConnectorSession } from './connectors';
2
+ import { FsStorage } from './FsStorage';
3
+ import { ConnectorType, JobData, WebsiteId } from '../../types';
4
+ type FsSession = ConnectorSession;
5
+ export declare class FsHosting extends FsStorage implements HostingConnector<FsSession> {
6
+ connectorId: string;
7
+ displayName: string;
8
+ icon: string;
9
+ connectorType: ConnectorType;
10
+ publish(session: FsSession, id: WebsiteId, files: ConnectorFile[]): Promise<JobData>;
11
+ getUrl(session: FsSession, id: WebsiteId): Promise<string>;
12
+ }
13
+ export {};
@@ -0,0 +1,55 @@
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.FsHosting = void 0;
20
+ const path_1 = require("path");
21
+ const jobs_1 = require("../jobs");
22
+ const FsStorage_1 = require("./FsStorage");
23
+ const types_1 = require("../../types");
24
+ class FsHosting extends FsStorage_1.FsStorage {
25
+ connectorId = 'fs-hosting';
26
+ displayName = 'File system hosting';
27
+ icon = 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%202L6%2022%2018%2022%2018%207%2012%202%206%202Z%22%3E%3C%2Fpath%3E%3Cpath%20d%3D%22M18%202L12%202%2012%208%2018%208%2018%202Z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E';
28
+ connectorType = types_1.ConnectorType.HOSTING;
29
+ async publish(session, id, files) {
30
+ const job = (0, jobs_1.startJob)(`Publishing to ${this.displayName}`);
31
+ job.logs = [[`Publishing to ${this.displayName}`]];
32
+ job.errors = [[]];
33
+ this.writeAssets(session, id, files, async ({ status, message }) => {
34
+ // Update the job status
35
+ job.status = status;
36
+ job.message = message;
37
+ job.logs[0].push(message);
38
+ if (status === types_1.JobStatus.SUCCESS) {
39
+ (0, jobs_1.jobSuccess)(job.jobId, message);
40
+ }
41
+ else if (status === types_1.JobStatus.ERROR) {
42
+ job.errors[0].push(message);
43
+ (0, jobs_1.jobError)(job.jobId, message);
44
+ }
45
+ });
46
+ return job;
47
+ }
48
+ async getUrl(session, id) {
49
+ const filePath = (0, path_1.join)(this.options.path, id, 'index.html');
50
+ const fileUrl = new URL(filePath, 'file://');
51
+ return fileUrl.toString();
52
+ }
53
+ }
54
+ exports.FsHosting = FsHosting;
55
+ //# sourceMappingURL=FsHosting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsHosting.js","sourceRoot":"","sources":["../../../../../src/ts/server/connectors/FsHosting.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,+BAA2B;AAC3B,kCAAwD;AACxD,2CAAuC;AACvC,uCAA8F;AAQ9F,MAAa,SAAU,SAAQ,qBAAS;IACtC,WAAW,GAAG,YAAY,CAAA;IAC1B,WAAW,GAAG,qBAAqB,CAAA;IACnC,IAAI,GAAG,+aAA+a,CAAA;IACtb,aAAa,GAAG,qBAAa,CAAC,OAAO,CAAA;IAErC,KAAK,CAAC,OAAO,CAAC,OAAkB,EAAE,EAAa,EAAE,KAAsB;QACrE,MAAM,GAAG,GAAG,IAAA,eAAQ,EAAC,iBAAiB,IAAI,CAAC,WAAW,EAAE,CAAuB,CAAA;QAC/E,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,iBAAiB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;QAClD,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAA;QACjB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,EAAE;YAC/D,wBAAwB;YACxB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;YACnB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAA;YACrB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACzB,IAAG,MAAM,KAAK,iBAAS,CAAC,OAAO,EAAE;gBAC/B,IAAA,iBAAU,EAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;aAC/B;iBAAM,IAAG,MAAM,KAAK,iBAAS,CAAC,KAAK,EAAE;gBACpC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBAC3B,IAAA,eAAQ,EAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;aAC7B;QACH,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAkB,EAAE,EAAa;QAC5C,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,YAAY,CAAC,CAAA;QAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC5C,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;IAC3B,CAAC;CACF;AA9BD,8BA8BC"}
@@ -0,0 +1,41 @@
1
+ import { ConnectorFile, StorageConnector, StatusCallback, ConnectorSession, ConnectorFileContent } from './connectors';
2
+ import { ConnectorUser, WebsiteMeta, WebsiteId, ConnectorType, WebsiteMetaFileContent, WebsiteData, ConnectorOptions } from '../../types';
3
+ import { ServerConfig } from '../config';
4
+ type FsSession = ConnectorSession;
5
+ interface FsOptions {
6
+ path?: string;
7
+ }
8
+ export declare class FsStorage implements StorageConnector<FsSession> {
9
+ connectorId: string;
10
+ displayName: string;
11
+ icon: string;
12
+ disableLogout: boolean;
13
+ options: {
14
+ path: string;
15
+ };
16
+ connectorType: ConnectorType;
17
+ constructor(config: ServerConfig | null, opts: FsOptions);
18
+ initFs(): Promise<void>;
19
+ updateStatus(filesStatuses: any, status: any, statusCbk: any): void;
20
+ initStatus(files: any): any;
21
+ getOptions(formData: object): ConnectorOptions;
22
+ getOAuthUrl(session: object): Promise<string | null>;
23
+ getLoginForm(session: object, redirectTo: string): Promise<string | null>;
24
+ getSettingsForm(session: object, redirectTo: string): Promise<string | null>;
25
+ isLoggedIn(session: FsSession): Promise<boolean>;
26
+ setToken(session: FsSession, query: object): Promise<void>;
27
+ logout(session: FsSession): Promise<void>;
28
+ getUser(session: FsSession): Promise<ConnectorUser>;
29
+ setWebsiteMeta(session: any, id: string, data: WebsiteMetaFileContent): Promise<void>;
30
+ getWebsiteMeta(session: FsSession, id: WebsiteId): Promise<WebsiteMeta>;
31
+ createWebsite(session: FsSession, meta: WebsiteMetaFileContent): Promise<WebsiteId>;
32
+ readWebsite(session: FsSession, websiteId: WebsiteId): Promise<WebsiteData>;
33
+ updateWebsite(session: FsSession, websiteId: WebsiteId, data: WebsiteData): Promise<void>;
34
+ deleteWebsite(session: FsSession, websiteId: WebsiteId): Promise<void>;
35
+ listWebsites(session: any): Promise<WebsiteMeta[]>;
36
+ getAsset(session: FsSession, id: WebsiteId, path: string): Promise<ConnectorFile>;
37
+ writeAssets(session: FsSession, id: WebsiteId, files: ConnectorFile[], statusCbk?: StatusCallback): Promise<string[]>;
38
+ deleteAssets(session: FsSession, id: WebsiteId, paths: string[]): Promise<void>;
39
+ readAsset(session: object, websiteId: string, fileName: string): Promise<ConnectorFileContent>;
40
+ }
41
+ export {};