cloudcms-server 3.3.1-beta.8 → 4.0.0-beta.1

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 (109) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/broadcast/broadcast.js +6 -3
  4. package/broadcast/providers/redis.js +24 -49
  5. package/clients/nrp.js +117 -0
  6. package/clients/redis.js +64 -0
  7. package/d1/index.js +629 -0
  8. package/d1/index.js.works +203 -0
  9. package/d1/package.json +86 -0
  10. package/d1/package.json.works +14 -0
  11. package/duster/helpers/sample/nyt.js +2 -1
  12. package/framework/controllers.js +4 -4
  13. package/index.js +26 -14
  14. package/insight/insight.js +1 -1
  15. package/launchpad/index.js +203 -11
  16. package/launchpad/launchers/cluster.js +103 -110
  17. package/launchpad/launchers/redis.js +70 -0
  18. package/launchpad/launchers/single.js +36 -22
  19. package/locks/locks.js +63 -9
  20. package/locks/providers/cluster.js +3 -1
  21. package/locks/providers/memory.js +10 -7
  22. package/locks/providers/redis.js +62 -82
  23. package/middleware/admin/admin.js +3 -3
  24. package/middleware/authentication/adapters/session.js +11 -8
  25. package/middleware/authentication/authentication.js +28 -16
  26. package/middleware/authentication/authenticators/default.js +5 -2
  27. package/middleware/authentication/authenticators/session.js +5 -2
  28. package/middleware/authentication/providers/saml.js +1 -1
  29. package/middleware/authorization/authorization.js +11 -8
  30. package/middleware/awareness/awareness.js +55 -31
  31. package/middleware/awareness/plugins/editorial.js +4 -4
  32. package/middleware/awareness/providers/abstract-async.js +107 -84
  33. package/middleware/awareness/providers/abstract.js +1 -1
  34. package/middleware/awareness/providers/memory.js +0 -14
  35. package/middleware/awareness/providers/redis.js +186 -279
  36. package/middleware/cache/cache.js +4 -2
  37. package/middleware/cache/providers/redis.js +127 -89
  38. package/middleware/cache/providers/shared-memory.js +3 -3
  39. package/middleware/cloudcms/cloudcms.js +22 -16
  40. package/middleware/form/form.js +3 -3
  41. package/middleware/modules/modules.js +63 -10
  42. package/middleware/proxy/proxy.js +8 -21
  43. package/middleware/stores/stores.js +48 -5
  44. package/middleware/themes/themes.js +49 -0
  45. package/middleware/virtual-config/virtual-config.js +11 -8
  46. package/middleware/wcm/wcm.js +4 -4
  47. package/notifications/notifications.js +27 -4
  48. package/package.json +30 -25
  49. package/server/index.js +508 -412
  50. package/server/standalone.js +9 -0
  51. package/temp/clusterlock/index.js +3 -3
  52. package/temp/clusterlock/package.json +1 -1
  53. package/temp/passport-saml/LICENSE +23 -0
  54. package/temp/passport-saml/README.md +406 -0
  55. package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
  56. package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
  57. package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
  58. package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
  59. package/temp/passport-saml/lib/node-saml/index.js +6 -0
  60. package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
  61. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
  62. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
  63. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
  64. package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
  65. package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
  66. package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
  67. package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
  68. package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
  69. package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
  70. package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
  71. package/temp/passport-saml/lib/node-saml/types.js +8 -0
  72. package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
  73. package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
  74. package/temp/passport-saml/lib/node-saml/utility.js +19 -0
  75. package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
  76. package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
  77. package/temp/passport-saml/lib/node-saml/xml.js +140 -0
  78. package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
  79. package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
  80. package/temp/passport-saml/lib/passport-saml/index.js +11 -0
  81. package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
  82. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
  83. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
  84. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
  85. package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
  86. package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
  87. package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
  88. package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
  89. package/temp/passport-saml/lib/passport-saml/types.js +11 -0
  90. package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
  91. package/temp/passport-saml/package.json +96 -0
  92. package/util/auth.js +6 -6
  93. package/util/cloudcms.js +85 -88
  94. package/util/proxy-factory.js +159 -268
  95. package/util/redis.js +113 -0
  96. package/util/renditions.js +12 -6
  97. package/util/request.js +48 -12
  98. package/util/util.js +16 -2
  99. package/launchpad/launchers/sticky-cluster.js +0 -43
  100. package/temp/memored/.jshintrc +0 -4
  101. package/temp/memored/README.md +0 -240
  102. package/temp/memored/demo/demo1.js +0 -37
  103. package/temp/memored/demo/demo2.js +0 -32
  104. package/temp/memored/gulpfile.js +0 -8
  105. package/temp/memored/index.js +0 -343
  106. package/temp/memored/package.json +0 -54
  107. package/temp/memored/spec/memored.spec.js +0 -265
  108. package/web/cms/ice.js +0 -109
  109. package/web/cms/preview.js +0 -106
package/util/request.js CHANGED
@@ -1,7 +1,9 @@
1
1
  var axios = require("axios");
2
2
 
3
- var http = require("http");
4
- var https = require("https");
3
+ // var http = require("http");
4
+ // var https = require("https");
5
+ //
6
+ // var FormData = require("form-data");
5
7
 
6
8
  /**
7
9
  * Incoming config:
@@ -30,30 +32,64 @@ module.exports = function(config, callback)
30
32
  var requestConfig = {};
31
33
  requestConfig.url = config.uri || config.url;
32
34
  requestConfig.method = config.method || "get";
35
+ requestConfig.headers = {};
33
36
 
37
+ if (!config) {
38
+ config = {};
39
+ }
34
40
  if (!config.headers) {
35
41
  config.headers = {};
36
42
  }
37
-
38
- if (config.headers) {
39
- requestConfig.headers = config.headers;
43
+ for (var k in config.headers)
44
+ {
45
+ var v = config.headers[k];
46
+ if (v)
47
+ {
48
+ requestConfig.headers[k.trim().toLowerCase()] = v;
49
+ }
40
50
  }
41
-
51
+ // support for FormData headers
52
+ // copy form data headers
53
+ if (config.data && config.data.getHeaders)
54
+ {
55
+ var formDataHeaders = config.data.getHeaders();
56
+ for (var k in formDataHeaders)
57
+ {
58
+ var v = formDataHeaders[k];
59
+ requestConfig.headers[k] = v;
60
+ }
61
+ }
62
+
42
63
  if (config.qs) {
43
64
  requestConfig.params = config.qs;
44
65
  }
45
66
 
46
67
  if (config.json) {
47
68
  requestConfig.data = config.json;
48
- requestConfig.headers["content-type"] = "application/json";
69
+
70
+ if (!requestConfig.headers["content-type"]) {
71
+ requestConfig.headers["content-type"] = "application/json";
72
+ }
49
73
  }
50
74
 
51
- if (config.data) {
75
+ if (config.data)
76
+ {
52
77
  requestConfig.data = config.data;
53
-
54
- if (requestConfig.data !== null && typeof requestConfig.data === 'object')
78
+
79
+ if (!requestConfig.headers["content-type"])
55
80
  {
56
- requestConfig.headers["content-type"] = "application/json";
81
+ if (!requestConfig.data)
82
+ {
83
+ if (requestConfig.data.getHeaders)
84
+ {
85
+ // assume this is a FormData and skip
86
+ }
87
+ else if (typeof(requestConfig.data) === "object")
88
+ {
89
+ // send as json
90
+ requestConfig.headers["content-type"] = "application/json";
91
+ }
92
+ }
57
93
  }
58
94
  }
59
95
 
@@ -72,7 +108,7 @@ module.exports = function(config, callback)
72
108
  requestConfig.httpAgent = http.globalAgent;
73
109
  }
74
110
  */
75
-
111
+
76
112
  axios.request(requestConfig).then(function(response) {
77
113
  callback(null, response, response.data);
78
114
  }, function(error) {
package/util/util.js CHANGED
@@ -603,7 +603,7 @@ var executeFunction = exports.executeFunction = function(identifier, fn, afterFn
603
603
  // take out a lock to ensure that the first thread to pass through here is the only one
604
604
  // and gets to run by itself on the cluster
605
605
  var exclusiveLockKey = "exclusiveLock-" + identifier;
606
- process.locks.lock(exclusiveLockKey, function (releaseLockFn) {
606
+ process.locks.lock(exclusiveLockKey, function (err, releaseLockFn) {
607
607
 
608
608
  var firstRunCacheKey = "firstRun-" + identifier;
609
609
  process.cache.read(firstRunCacheKey, function(err, value) {
@@ -1777,10 +1777,11 @@ var zip = exports.zip = function(directoryPath, writableStream)
1777
1777
  * @param {string} protocol
1778
1778
  * @param {string} host
1779
1779
  * @param [number|string] port
1780
+ * @param {string} path
1780
1781
  *
1781
1782
  * @type {Function}
1782
1783
  */
1783
- var asURL = exports.asURL = function(protocol, host, port)
1784
+ var asURL = exports.asURL = function(protocol, host, port, path)
1784
1785
  {
1785
1786
  // protocol lower case
1786
1787
  protocol = protocol.toLowerCase();
@@ -1806,6 +1807,19 @@ var asURL = exports.asURL = function(protocol, host, port)
1806
1807
  }
1807
1808
  }
1808
1809
 
1810
+ // include url "path" if defined
1811
+ if (path) {
1812
+ path = '/' + path;
1813
+ path = path.replace(/\/+/g, '/'); // ensure no extra '/' characters
1814
+ if (path.endsWith('/')) {
1815
+ // remove trailing '/' character
1816
+ path = path.substring(0, path.length - 1);
1817
+ }
1818
+ if (path) {
1819
+ url += path;
1820
+ }
1821
+ }
1822
+
1809
1823
  return url;
1810
1824
  };
1811
1825
 
@@ -1,43 +0,0 @@
1
- var clusterlock = require("../../temp/clusterlock");
2
-
3
- // use sticky-session library
4
- var sticky = require('sticky-session');
5
-
6
- module.exports = function(options) {
7
-
8
- var factoryCallback = options.factory;
9
- var reportCallback = options.report;
10
- if (!reportCallback)
11
- {
12
- reportCallback = function () {
13
- };
14
- }
15
- var completionCallback = options.complete;
16
- if (!completionCallback)
17
- {
18
- completionCallback = function () {
19
- };
20
- }
21
-
22
- factoryCallback(function (server) {
23
-
24
- if (!sticky.listen(server, server._listenPort))
25
- {
26
- // master code
27
-
28
- // start up cluster locks
29
- clusterlock.setup();
30
-
31
- // wait 5 seconds, then fire callbacks
32
- setTimeout(function () {
33
- reportCallback();
34
- completionCallback();
35
- }, 5000);
36
- }
37
- else
38
- {
39
- // worker code
40
- }
41
-
42
- });
43
- };
@@ -1,4 +0,0 @@
1
- {
2
- "node": true,
3
- "unused": true
4
- }
@@ -1,240 +0,0 @@
1
- # Memored
2
-
3
- Memored implements an in-memory shared cache to use in nodejs applications which uses [cluster](http://nodejs.org/api/cluster.html) module.
4
-
5
- Let's say you want your application to take advantage of multi-core CPUs using nodejs cluster module; you will be able to run several _isolated_ processes which shared nothing but a communication channel with parent process.
6
- If you need a fast volatile cache, common solutions would create an in-memory map for every process you run, so you end up with the same data stored several times in your machine RAM.
7
-
8
- Memored uses communication channel between master process and its workers to use a unique in-memory storage, reducing the amount of memory your application would use.
9
-
10
- ## Getting Started
11
- Install this module with _npm_:
12
- ```javascript
13
- npm install memored
14
- ```
15
-
16
- Store and read values is straightforward:
17
- ```javascript
18
- var cluster = require('cluster'),
19
- memored = require('memored');
20
-
21
- if (cluster.isMaster) {
22
- cluster.fork();
23
- } else {
24
- var han = {
25
- firstname: 'Han',
26
- lastname: 'Solo'
27
- },
28
- luke = {
29
- firstname: 'Luke',
30
- lastname: 'Skywalker'
31
- };
32
-
33
- // Store and read
34
- memored.store('character1', han, function() {
35
- console.log('Value stored!');
36
-
37
- memored.read('character1', function(err, value) {
38
- console.log('Read value:', value);
39
- });
40
- });
41
-
42
- // You can also set a ttl (milliseconds)
43
- memored.store('character2', luke, 1000, function(err, expirationTime) {
44
- console.log('Value stored until:', new Date(expirationTime));
45
-
46
- setTimeout(function() {
47
- memored.read('character2', function(err, value) {
48
- console.log('Value is gone?', value === undefined);
49
-
50
- process.exit();
51
- });
52
- }, 1050);
53
- });
54
- }
55
- ```
56
-
57
- ## Invalidation management
58
- By default, _memored_ will evict cache entries (stored with _ttl_) passively. This is, when you read an expired entry, you will get no value on return and _memored_ will delete the value from its internal cache.
59
-
60
- You can also configure _memored_ to actively evict expired entries every N milliseconds. For this to work, you need to pass the attribute *purgeInterval* to the *setup* function.
61
- This will trigger an internal function which looks for expired entries and deletes them from its internal cache.
62
-
63
- Example:
64
- ```javascript
65
- var cluster = require('cluster'),
66
- async = require('async'),
67
- memored = require('memored');
68
-
69
- if (cluster.isMaster) {
70
-
71
- cluster.fork();
72
- memored.setup({ purgeInterval: 500});
73
-
74
- } else {
75
-
76
- async.series({
77
- storeValue: function(next) {
78
- memored.store('key1', 'My simple string value', 100, next);
79
- },
80
- readCacheSize: function(next) {
81
- memored.size(function(err, size) {
82
- console.log('Current size is 1?', size === 1);
83
- next();
84
- });
85
- },
86
- wait: function(next) {
87
- setTimeout(next, 600);
88
- },
89
- readCacheSizeAgain: function(next) {
90
- memored.size(function(err, size) {
91
- console.log('Current size is 0?', size === 0);
92
- next();
93
- });
94
- }
95
- }, process.exit);
96
- }
97
- ```
98
-
99
- ## API
100
- Documentation for every module function:
101
-
102
-
103
- ### setup(options)
104
-
105
- This function is used to configure _memored_.
106
-
107
- **Arguments**:
108
-
109
- - **purgeInterval** {Number} (optional): Configures and triggers _memored_ expired entries auto deletion. Value expressed in milliseconds. _It's only used when called this method from the master process of your application_.
110
- - **logger** {Object} (optional): In you want _memored_ to log something, you must provide an object implementing *log* and *warn* functions.
111
-
112
- **Example**:
113
- ```javascript
114
- memored.setup({
115
- purgeInterval: 15000,
116
- logger: console
117
- });
118
- ```
119
-
120
- ### store(key, value, [ttl], callback)
121
-
122
- This function stores a value in the cache.
123
- _It is intended to be called from a worker process_.
124
-
125
- **Arguments**:
126
-
127
- - **key** {String} (required): Key used to lookup the entry
128
- - **value** {Mixed} (required): Whatever you want to store
129
- - **ttl** {Number} (optional): Time to live for this value in the cache (milliseconds)
130
- - **callback** {Function} (optional): Function to be call on store completion. Callback arguments:
131
- - _err_ {Error}: Optional error
132
- - _expirationTime_ {Number}: The timestamp of the moment when this entry will expire. If _ttl_ is not used, this value will be undefined.
133
-
134
- **Examples**:
135
- ```javascript
136
- memored.store('key1', {firstname: 'Han', lastname: 'Solo'}, function() {
137
- console.log('Value stored!');
138
- });
139
-
140
- memored.store('key2', ['a', 'b', 'c'], 15000, function(err, expirationTime) {
141
- console.log('This value will expire on:', new Date(expirationTime));
142
- });
143
- ```
144
-
145
- ### read(key, callback)
146
-
147
- This function reads a value from the cache.
148
- _It is intended to be called from a worker process_.
149
-
150
- **Arguments**:
151
-
152
- - **key** {String} (required): Key used to lookup the entry
153
- - **callback** {Function} (required): Function to be called on read completion. Callback arguments:
154
- - _err_ {Error}: Optional error
155
- - _value_ {Mixed}: Contents of the cached entry. If the value is not found or is expired, it will be undefined.
156
-
157
- **Example**:
158
- ```javascript
159
- memored.read('key1', function(err, value) {
160
- console.log('Key1 value:', value);
161
- });
162
-
163
- memored.read('key1', function(err, value, expirationTime) {
164
- console.log('Key1 value:', value);
165
- console.log('Key1 expiration time:', new Date(expirationTime));
166
- });
167
-
168
- memored.read('unknownKey', function(err, value) {
169
- console.log('No data read?', value === undefined);
170
- });
171
- ```
172
-
173
- ### remove(key, callback)
174
-
175
- This function removes an entry from the cache.
176
- _It is intended to be called from a worker process_.
177
-
178
- **Arguments**:
179
-
180
- - **key** {String} (required): Key used to lookup the entry
181
- - **callback** {Function} (optional): Function to be called on read completion.
182
-
183
- **Example**:
184
- ```javascript
185
- memored.remove('key1', function() {
186
- console.log('Key removed from the cache.');
187
- });
188
- ```
189
-
190
- ### clean(callback)
191
-
192
- This function removes all the entries from the cache.
193
- _It is intended to be called from a worker process_.
194
-
195
- **Arguments**:
196
-
197
- - **callback** {Function} (optional): Function to be called on read completion.
198
-
199
- **Example**:
200
- ```javascript
201
- memored.clean(function() {
202
- console.log('All cache entries have been deleted.');
203
- });
204
- ```
205
-
206
- ### size(callback)
207
-
208
- This function returns the number of entries in the cache.
209
-
210
- **Arguments**:
211
-
212
- - **callback** {Function} (required): Function to be called on size calculation is complete. Callback arguments:
213
- - _err_ {Error}: Optional error
214
- - _size_ {Number}: The number of entries in the cache.
215
-
216
- **Example**:
217
-
218
- ```javascript
219
- memored.size(function(err, size) {
220
- console.log('Cache size:', size);
221
- });
222
- ```
223
-
224
- ### version
225
-
226
- This is an attribute wich provides module's version number
227
-
228
-
229
- # Final note
230
- All the callbacks first parameter is an optional error object. Actually, this param will never be an error because there is no expected error in the internal code. There's no function call that can possible throw an expected error that this module would deal with.
231
- The existence of this param is to follow the *convention* about libraries callbacks in nodejs. As everybody expects this first callback parameter to be an optional one, I decided to include it.
232
-
233
- - [Nodeguide](http://nodeguide.com/style.html#callbacks)
234
- - [Nodejitsu](http://docs.nodejitsu.com/articles/errors/what-are-the-error-conventions)
235
- - [GoSquared](https://engineering.gosquared.com/node-js-error-handling-callbacks-vs-promises)
236
-
237
-
238
- ## License
239
- Copyright (c) 2014 PaquitoSoft
240
- Licensed under the MIT license.
@@ -1,37 +0,0 @@
1
- var cluster = require('cluster'),
2
- memored = require('../index');
3
-
4
- if (cluster.isMaster) {
5
- cluster.fork();
6
- } else {
7
- var han = {
8
- firstname: 'Han',
9
- lastname: 'Solo'
10
- },
11
- luke = {
12
- firstname: 'Luke',
13
- lastname: 'Skywalker'
14
- };
15
-
16
- // Store and read
17
- memored.store('character1', han, function() {
18
- console.log('Value stored!');
19
-
20
- memored.read('character1', function(err, value) {
21
- console.log('Read value:', value);
22
- });
23
- });
24
-
25
- // You can also set a ttl (milliseconds)
26
- memored.store('character2', luke, 1000, function(err, expirationTime) {
27
- console.log('Value stored until:', new Date(expirationTime));
28
-
29
- setTimeout(function() {
30
- memored.read('character2', function(err, value) {
31
- console.log('Value is gone?', value === undefined);
32
-
33
- process.exit();
34
- });
35
- }, 1050);
36
- });
37
- }
@@ -1,32 +0,0 @@
1
- var cluster = require('cluster'),
2
- async = require('async'),
3
- memored = require('../index');
4
-
5
- if (cluster.isMaster) {
6
-
7
- cluster.fork();
8
- memored.setup({ purgeInterval: 500});
9
-
10
- } else {
11
-
12
- async.series({
13
- storeValue: function(next) {
14
- memored.store('key1', 'My simple string value', 100, next);
15
- },
16
- readCacheSize: function(next) {
17
- memored.size(function(err, size) {
18
- console.log('Current size is 1?', size === 1);
19
- next();
20
- });
21
- },
22
- wait: function(next) {
23
- setTimeout(next, 600);
24
- },
25
- readCacheSizeAgain: function(next) {
26
- memored.size(function(err, size) {
27
- console.log('Current size is 0?', size === 0);
28
- next();
29
- });
30
- }
31
- }, process.exit);
32
- }
@@ -1,8 +0,0 @@
1
- var gulp = require('gulp'),
2
- mocha = require('gulp-mocha')/*,
3
- plumber = require('gulp-plumber')*/;
4
-
5
- gulp.task('default', function() {
6
- return gulp.src('spec/*.spec.js', {read: true})
7
- .pipe(mocha({ui: 'bdd', reporter: 'spec'}));
8
- });