cloudcms-server 3.3.1-beta.1 → 3.3.1-beta.10

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 (38) hide show
  1. package/.last_command +7 -0
  2. package/broadcast/providers/redis.js +32 -57
  3. package/clients/nrp.js +117 -0
  4. package/clients/redis.js +48 -0
  5. package/duster/helpers/sample/nyt.js +5 -7
  6. package/framework/controllers.js +0 -1
  7. package/index.js +23 -13
  8. package/insight/insight.js +6 -9
  9. package/locks/providers/redis.js +29 -58
  10. package/middleware/admin/admin.js +4 -4
  11. package/middleware/awareness/awareness.js +4 -1
  12. package/middleware/awareness/plugins/editorial.js +41 -66
  13. package/middleware/awareness/plugins/resources.js +74 -0
  14. package/middleware/awareness/providers/redis.js +263 -237
  15. package/middleware/cache/providers/redis.js +134 -92
  16. package/middleware/config/config.js +41 -2
  17. package/middleware/deployment/deployment.js +19 -22
  18. package/middleware/form/form.js +18 -33
  19. package/middleware/modules/modules.js +64 -11
  20. package/middleware/proxy/proxy.js +1 -2
  21. package/middleware/stores/engines/s3.js +0 -2
  22. package/middleware/stores/stores.js +50 -6
  23. package/middleware/themes/themes.js +49 -0
  24. package/middleware/virtual-config/virtual-config.js +35 -39
  25. package/notifications/notifications.js +75 -2
  26. package/package.json +18 -19
  27. package/server/index.js +105 -24
  28. package/server/standalone.js +2 -0
  29. package/util/auth.js +2 -7
  30. package/util/cloudcms.js +19 -34
  31. package/util/proxy-factory.js +17 -7
  32. package/util/redis.js +113 -0
  33. package/util/renditions.js +6 -12
  34. package/util/request.js +117 -0
  35. package/util/util.js +23 -36
  36. package/web/socket.io/socket.io.js +4240 -2
  37. package/web/cms/ice.js +0 -109
  38. package/web/cms/preview.js +0 -106
@@ -28,6 +28,7 @@ var log = function(text, level)
28
28
  * "cache" the root of the cache
29
29
  * "public" the web host root (this might be public_build too)
30
30
  * "templates" the templates storage location (for client-side templates)
31
+ * "themes" the themes storage location (for client-side themes)
31
32
  * "modules" the deployed modules storage location (for client-side modules)
32
33
  * "config" the configuration storage location for static config (for client-side config)
33
34
  *
@@ -45,7 +46,7 @@ exports = module.exports = function()
45
46
  var engineId = storeConfiguration[storeType];
46
47
 
47
48
  var engine = ENGINES[engineId];
48
-
49
+
49
50
  var engineType = process.configuration.storeEngines[engineId].type;
50
51
  var engineConfiguration = process.configuration.storeEngines[engineId].config;
51
52
 
@@ -208,6 +209,7 @@ exports = module.exports = function()
208
209
  // these will get overwritten in the binding methods below
209
210
  stores["config"] = buildStore("config", host, "config");
210
211
  stores["templates"] = buildStore("templates", host, "templates");
212
+ stores["themes"] = buildStore("themes", host, "themes");
211
213
 
212
214
  var bindWebStore = function(done) {
213
215
 
@@ -415,7 +417,7 @@ exports = module.exports = function()
415
417
  var moduleStoreType = moduleDescriptors[i].store;
416
418
  var modulePath = moduleDescriptors[i].path;
417
419
 
418
- // console.log("Config Store - Module Path: " + modulePath + ", type: " + moduleStoreType);
420
+ //console.log("Config Store - Module Path: " + modulePath + ", type: " + moduleStoreType);
419
421
 
420
422
  var storePath = path.join(modulePath, "config");
421
423
  if (moduleStoreType === "modules")
@@ -423,7 +425,7 @@ exports = module.exports = function()
423
425
  storePath = path.join("modules", storePath);
424
426
  }
425
427
 
426
- // console.log("Config Store - Module Store: " + storePath);
428
+ //console.log("Config Store - Module Store: " + storePath);
427
429
 
428
430
  var configStore = buildStore(moduleStoreType, host, storePath);
429
431
  configStores.push(configStore);
@@ -472,6 +474,7 @@ exports = module.exports = function()
472
474
  var bindingStores = [];
473
475
  for (var i = 0; i < allocatedStores.length; i++) {
474
476
  bindingStores.push(allocatedStores[i]);
477
+ //console.log("a2: " + allocatedStores[i]);
475
478
  }
476
479
  bindingStores.push(stores.templates);
477
480
 
@@ -481,7 +484,43 @@ exports = module.exports = function()
481
484
  callback();
482
485
  });
483
486
  };
484
-
487
+
488
+ var bindThemeStores = function(moduleDescriptors, callback)
489
+ {
490
+ // all theme stores
491
+ var themeStores = [];
492
+ for (var i = 0; i < moduleDescriptors.length; i++)
493
+ {
494
+ var moduleStoreType = moduleDescriptors[i].store;
495
+ var modulePath = moduleDescriptors[i].path;
496
+
497
+ var storePath = path.join(modulePath, "themes");
498
+ if (moduleStoreType === "modules")
499
+ {
500
+ storePath = path.join("modules", storePath);
501
+ }
502
+
503
+ var themeStore = buildStore(moduleStoreType, host, storePath);
504
+ themeStores.push(themeStore);
505
+ }
506
+
507
+ // trim back and only keep stores that are allocated
508
+ retainAllocatedStores(themeStores, function(err, allocatedStores) {
509
+
510
+ // all stores to be bound in
511
+ var bindingStores = [];
512
+ for (var i = 0; i < allocatedStores.length; i++) {
513
+ bindingStores.push(allocatedStores[i]);
514
+ }
515
+ bindingStores.push(stores.themes);
516
+
517
+ // bind into a multi-store
518
+ stores["themes"] = require("./multistore")(bindingStores);
519
+
520
+ callback();
521
+ });
522
+ };
523
+
485
524
  process.cache.read("module-descriptors-" + host, function(err, moduleDescriptors) {
486
525
 
487
526
  moduleDescriptors = null;
@@ -494,7 +533,9 @@ exports = module.exports = function()
494
533
 
495
534
  bindConfigStores(moduleDescriptors, function () {
496
535
  bindTemplateStores(moduleDescriptors, function() {
497
- done();
536
+ bindThemeStores(moduleDescriptors, function() {
537
+ done();
538
+ });
498
539
  });
499
540
  });
500
541
 
@@ -504,7 +545,9 @@ exports = module.exports = function()
504
545
  {
505
546
  bindConfigStores(moduleDescriptors, function() {
506
547
  bindTemplateStores(moduleDescriptors, function() {
507
- done();
548
+ bindThemeStores(moduleDescriptors, function() {
549
+ done();
550
+ });
508
551
  });
509
552
  });
510
553
  }
@@ -565,6 +608,7 @@ exports = module.exports = function()
565
608
  req.contentStore = stores["content"];
566
609
  req.webStore = stores["web"];
567
610
  req.templatesStore = stores["templates"];
611
+ req.themesStore = stores["themes"];
568
612
  req.modulesStore = stores["modules"];
569
613
 
570
614
  // sort the module descriptors by id
@@ -0,0 +1,49 @@
1
+ var path = require('path');
2
+ var util = require("../../util/util");
3
+
4
+ exports = module.exports = function()
5
+ {
6
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
+ //
8
+ // RESULTING OBJECT
9
+ //
10
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////
11
+
12
+ var r = {};
13
+
14
+ /**
15
+ * Retrieves themes for the application.
16
+ *
17
+ * @return {Function}
18
+ */
19
+ r.handler = function()
20
+ {
21
+ return util.createHandler("themes", function(req, res, next, stores, cache, configuration) {
22
+
23
+ var themeStore = stores.themes;
24
+
25
+ var handled = false;
26
+
27
+ if (req.method.toLowerCase() === "get") {
28
+
29
+ if (req.url.indexOf("/_themes") === 0)
30
+ {
31
+ var filePath = req.path.substring(8);
32
+
33
+ themeStore.sendFile(res, filePath, null, function(err) {
34
+ next(err);
35
+ });
36
+
37
+ handled = true;
38
+ }
39
+ }
40
+
41
+ if (!handled)
42
+ {
43
+ next();
44
+ }
45
+ });
46
+ };
47
+
48
+ return r;
49
+ }();
@@ -83,7 +83,7 @@ exports = module.exports = function()
83
83
 
84
84
  var URL = configuration.virtualDriver.baseURL;
85
85
  if (!URL) {
86
- URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT);
86
+ URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH);
87
87
  }
88
88
  URL += "/virtual/driver/config";
89
89
  var requestConfig = {
@@ -91,53 +91,49 @@ exports = module.exports = function()
91
91
  "qs": qs
92
92
  };
93
93
 
94
- util.retryGitanaRequest(logMethod, gitana, requestConfig, 2, function(err, response, body) {
94
+ util.retryGitanaRequest(logMethod, gitana, requestConfig, 2, function(err, response, json) {
95
95
 
96
- if (response && response.statusCode === 200 && body)
96
+ if (response && response.status === 200 && json)
97
97
  {
98
- var config = JSON.parse(body).config;
98
+ var config = json.config;
99
99
  if (!config)
100
100
  {
101
101
  // nothing found
102
- callback();
102
+ return callback();
103
103
  }
104
- else
105
- {
106
- // make sure we update baseURL
107
- config.baseURL = configuration.virtualDriver.baseURL;
108
104
 
109
- // hand back
110
- callback(null, config);
111
- }
105
+ // make sure we update baseURL
106
+ config.baseURL = configuration.virtualDriver.baseURL;
107
+
108
+ // hand back
109
+ return callback(null, config);
112
110
  }
113
- else
111
+
112
+ logMethod("Load virtual driver config failed");
113
+ if (response && response.status)
114
114
  {
115
- logMethod("Load virtual driver config failed");
116
- if (response && response.statusCode)
117
- {
118
- logMethod("Response status code: " + response.statusCode);
119
- }
120
- if (err) {
121
- logMethod("Err: " + JSON.stringify(err));
122
- }
123
- if (body) {
124
- logMethod("Body: " + body);
125
- }
126
- var message = body;
127
- if (!message) {
128
- message = "Unable to load virtual driver configuration";
129
- }
115
+ logMethod("Response status code: " + response.status);
116
+ }
117
+ if (err) {
118
+ logMethod("Err: " + JSON.stringify(err));
119
+ }
120
+ if (json) {
121
+ logMethod("Body: " + json);
122
+ }
123
+ var message = json;
124
+ if (!message) {
125
+ message = "Unable to load virtual driver configuration";
126
+ }
130
127
 
131
- // force disconnect of virtual driver so that it has to log in again
132
- // this prevents the attempt to use the refresh token
133
- disconnectVirtualDriver();
128
+ // force disconnect of virtual driver so that it has to log in again
129
+ // this prevents the attempt to use the refresh token
130
+ disconnectVirtualDriver();
134
131
 
135
- // fire callback
136
- callback({
137
- "message": message,
138
- "err": err
139
- });
140
- }
132
+ // fire callback
133
+ return callback({
134
+ "message": message,
135
+ "err": err
136
+ });
141
137
  });
142
138
  });
143
139
  }
@@ -217,7 +213,7 @@ exports = module.exports = function()
217
213
  }
218
214
  if (!gitanaJson.baseURL)
219
215
  {
220
- gitanaJson.baseURL = util.cleanupURL(util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT));
216
+ gitanaJson.baseURL = util.cleanupURL(util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
221
217
  }
222
218
 
223
219
  // mark as retrieved from virtual driver
@@ -340,7 +336,7 @@ exports = module.exports = function()
340
336
  // defaults
341
337
  if (!configuration.baseURL)
342
338
  {
343
- configuration.baseURL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT);
339
+ configuration.baseURL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH);
344
340
  }
345
341
  if (!configuration.key) {
346
342
  configuration.key = "virtual";
@@ -76,6 +76,7 @@ var handleNotificationMessages = function(items, callback) {
76
76
  return function(done) {
77
77
 
78
78
  //logFn("WORKING ON ITEM: " + i + ", item: " + JSON.stringify(item, null, " "));
79
+ console.log("WORKING ON ITEM: " + i + ", item: " + JSON.stringify(item, null, " "));
79
80
 
80
81
  var operation = item.operation;
81
82
 
@@ -178,6 +179,44 @@ var handleNotificationMessages = function(items, callback) {
178
179
  "paths": paths
179
180
  }, z_done);
180
181
  }
182
+ else if (type === "theme")
183
+ {
184
+ var platformId = obj.platformId;
185
+ var applicationId = obj.applicationId;
186
+ var themeId = obj.themeId;
187
+ var themeKey = obj.themeKey;
188
+
189
+ // broadcast the "invalidate_theme" event
190
+ process.broadcast.publish("invalidate_theme", {
191
+ "host": host,
192
+ "platformId": platformId,
193
+ "applicationId": applicationId,
194
+ "themeId": themeId,
195
+ "themeKey": themeKey
196
+ }, z_done);
197
+ }
198
+ else if (type === "themeAssignment")
199
+ {
200
+ var platformId = obj.platformId;
201
+ var applicationId = obj.applicationId;
202
+ var projectId = obj.projectId;
203
+ var domainId = obj.domainId;
204
+ var principalId = obj.principalId;
205
+ var themeId = obj.themeId;
206
+ var operation = obj.operation;
207
+
208
+ // broadcast the "invalidate_theme_assignment" event
209
+ process.broadcast.publish("invalidate_theme_assignment", {
210
+ "host": host,
211
+ "platformId": platformId,
212
+ "applicationId": applicationId,
213
+ "projectId": projectId,
214
+ "domainId": domainId,
215
+ "principalId": principalId,
216
+ "themeId": themeId,
217
+ "operation": operation
218
+ }, z_done);
219
+ }
181
220
  else if (type === "tenant")
182
221
  {
183
222
  //var ref = obj.ref;
@@ -493,6 +532,40 @@ var handleNotificationMessages = function(items, callback) {
493
532
  return done(err);
494
533
  });
495
534
  }
535
+ else if (operation === "deployments_synced")
536
+ {
537
+ var deploymentKey = item.deploymentKey;
538
+ var applicationId = item.applicationId;
539
+ // var scope = item.scope;
540
+
541
+ var host = determineHost(item);
542
+
543
+ var deployments = item.deployments;
544
+ if (deployments && deployments.length > 0)
545
+ {
546
+ for (var i = 0; i < deployments.length; i++)
547
+ {
548
+ var deployment = deployments[i];
549
+
550
+ var message = {
551
+ "applicationId": applicationId,
552
+ "deploymentKey": deploymentKey,
553
+ // "scope": scope,
554
+ "host": host,
555
+ "deployment": deployment
556
+ };
557
+
558
+ // broadcast event
559
+ process.broadcast.publish("deployment_synced", message, function(err) {
560
+ if (err) {
561
+ logInfo("published deployment_synced message. err:" + err + "\nmessage: " + JSON.stringify(message,null,2));
562
+ }
563
+ return done(err);
564
+ });
565
+
566
+ }
567
+ }
568
+ }
496
569
  else
497
570
  {
498
571
  logInfo("Unknown notification item: " + JSON.stringify(item));
@@ -586,7 +659,7 @@ module.exports = function()
586
659
  var r = {};
587
660
 
588
661
  r.start = function(callback) {
589
-
662
+
590
663
  var config = process.configuration;
591
664
  if (!config["notifications"])
592
665
  {
@@ -613,7 +686,7 @@ module.exports = function()
613
686
  notifications.enabled = true;
614
687
  }
615
688
  }
616
-
689
+
617
690
  if (notifications.enabled)
618
691
  {
619
692
  if (process.env.CLOUDCMS_NOTIFICATIONS_TYPE)
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "3.3.1-beta.1",
9
+ "version": "3.3.1-beta.10",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
@@ -16,8 +16,9 @@
16
16
  "agentkeepalive": "^4.1.3",
17
17
  "alpaca": "^1.5.27",
18
18
  "archiver": "^5.1.0",
19
- "async": "^3.2.0",
20
- "aws-sdk": "^2.798.0",
19
+ "async": "^3.2.3",
20
+ "aws-sdk": "^2.807.0",
21
+ "axios": "^0.21.0",
21
22
  "basic-auth": "^2.0.1",
22
23
  "body-parser": "^1.19.0",
23
24
  "bytes": "^3.1.0",
@@ -25,31 +26,32 @@
25
26
  "clone": "^2.1.2",
26
27
  "connect-flash": "^0.1.1",
27
28
  "connect-multiparty": "^2.2.0",
28
- "connect-redis": "^5.0.0",
29
+ "connect-redis": "^6.1.3",
29
30
  "consolidate": "^0.16.0",
30
31
  "cookie-parser": "^1.4.5",
31
32
  "debug": "^4.3.1",
32
- "dustjs-helpers": "^1.7.4",
33
- "dustjs-linkedin": "^2.7.5",
33
+ "dustjs-helpers": "^1.6.3",
34
+ "dustjs-linkedin": "^3.0.1",
34
35
  "errorhandler": "^1.5.1",
35
36
  "express": "^4.17.1",
36
37
  "express-session": "^1.17.1",
37
38
  "express-useragent": "^1.0.15",
38
39
  "extend-with-super": "^2.0.0",
39
- "gitana": "^1.0.318",
40
+ "form-data": "^2.3.3",
41
+ "gitana": "^1.0.322",
40
42
  "handlebars": "^4.7.6",
41
43
  "hbs": "^4.1.1",
44
+ "helmet": "^4.6.0",
42
45
  "http-proxy": "^1.18.1",
43
46
  "json5": "^2.1.3",
44
47
  "jsonwebtoken": "^8.5.1",
45
48
  "klaw": "^3.0.0",
46
49
  "lru-cache": "^6.0.0",
47
- "marked": "^1.2.5",
50
+ "marked": "^4.0.14",
48
51
  "memorystore": "^1.6.4",
49
52
  "mime": "^2.4.6",
50
53
  "moment": "^2.29.1",
51
54
  "morgan": "^1.10.0",
52
- "node-redis-pubsub": "^4.0.0",
53
55
  "object-hash": "^2.0.3",
54
56
  "object-merge": "^2.5.1",
55
57
  "on-headers": "^1.0.2",
@@ -61,36 +63,33 @@
61
63
  "passport-linkedin": "^1.0.0",
62
64
  "passport-local": "^1.0.0",
63
65
  "passport-oauth": "^1.0.0",
64
- "passport-saml": "^2.0.2",
65
- "passport-twitter": "^1.0.4",
66
+ "passport-saml": "^3.2.1",
67
+ "passport-twitter": "^0.1.5",
66
68
  "pkginfo": "^0.4.1",
67
69
  "q": "^1.5.1",
68
70
  "random-js": "^2.1.0",
69
71
  "recursive-readdir": "^2.2.2",
70
- "redis": "^3.0.2",
72
+ "redis": "^4.0.6",
71
73
  "redislock": "^1.3.0",
72
- "request": "^2.88.0",
73
74
  "request-param": "^1.0.1",
74
75
  "response-time": "^2.3.2",
75
76
  "rwlock": "^5.0.0",
76
- "semver": "^7.3.2",
77
+ "semver": "^7.3.4",
77
78
  "serve-favicon": "^2.5.0",
78
79
  "session-file-store": "^1.5.0",
79
80
  "sha1": "^1.1.1",
80
- "socket.io": "3.0.3",
81
+ "socket.io": "^4.4.1",
81
82
  "ssl-root-cas": "^1.3.1",
82
83
  "sticky-session": "^1.1.2",
83
84
  "stomp-client": "^0.9.0",
84
85
  "targz": "^1.0.1",
85
86
  "temp": "^0.9.4",
86
87
  "toobusy-js": "^0.5.1",
87
- "uuid": "^8.3.1",
88
+ "uuid": "^8.3.2",
88
89
  "vm2": "^3.9.2",
89
- "watch": "^1.0.2",
90
+ "watch": "^0.13.0",
90
91
  "winston": "^3.3.3"
91
92
  },
92
- "devDependencies": {},
93
- "optionalDependencies": {},
94
93
  "contributors": [
95
94
  {
96
95
  "name": "Michael Uzquiano",