cloudcms-server 4.0.0-beta.2 → 4.0.0-beta.21

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 (78) hide show
  1. package/README.md +0 -5
  2. package/cloudcms-server.iml +1 -0
  3. package/index.js +58 -32
  4. package/middleware/authentication/authentication.js +40 -12
  5. package/middleware/authentication/providers/saml.js +8 -4
  6. package/middleware/awareness/awareness.js +8 -7
  7. package/middleware/awareness/plugins/api_event.js +105 -0
  8. package/middleware/awareness/plugins/editorial.js +54 -3
  9. package/middleware/awareness/plugins/resources.js +13 -5
  10. package/middleware/config/adapter.js +0 -44
  11. package/middleware/deployment/deployment.js +22 -24
  12. package/middleware/driver/driver.js +24 -1
  13. package/middleware/driver-config/driver-config.js +0 -6
  14. package/middleware/modules/modules.js +11 -5
  15. package/middleware/perf/perf.js +3 -2
  16. package/middleware/registration/registration.js +0 -5
  17. package/middleware/stores/engines/empty.js +0 -4
  18. package/middleware/stores/engines/fs-caching-adapter.js +0 -5
  19. package/middleware/stores/engines/fs.js +0 -9
  20. package/middleware/stores/engines/s3.js +0 -5
  21. package/middleware/stores/engines/s3fs.js +0 -5
  22. package/middleware/stores/multistore.js +0 -29
  23. package/middleware/stores/store.js +0 -10
  24. package/middleware/stores/stores.js +2 -2
  25. package/middleware/virtual-config/virtual-config.js +253 -206
  26. package/middleware/virtual-files/virtual-files.js +0 -3
  27. package/middleware/welcome/welcome.js +0 -3
  28. package/notifications/notifications.js +72 -10
  29. package/notifications/providers/kafka.js +182 -0
  30. package/notifications/providers/stomp.js +4 -0
  31. package/package.json +40 -56
  32. package/server/index.js +216 -123
  33. package/server/standalone.js +1 -6
  34. package/util/auth.js +10 -4
  35. package/util/cloudcms.js +77 -35
  36. package/util/loaders.js +113 -0
  37. package/util/proxy-factory.js +143 -168
  38. package/util/request.js +6 -2
  39. package/util/workqueue.js +111 -0
  40. package/.last_command +0 -7
  41. package/duster/helpers/core/cloudcms/associations.js +0 -34
  42. package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
  43. package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
  44. package/duster/helpers/core/cloudcms/beta/params.js +0 -33
  45. package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
  46. package/duster/helpers/core/cloudcms/content.js +0 -34
  47. package/duster/helpers/core/cloudcms/expand.js +0 -38
  48. package/duster/helpers/core/cloudcms/form.js +0 -34
  49. package/duster/helpers/core/cloudcms/query.js +0 -34
  50. package/duster/helpers/core/cloudcms/queryOne.js +0 -34
  51. package/duster/helpers/core/cloudcms/relatives.js +0 -34
  52. package/duster/helpers/core/cloudcms/search.js +0 -34
  53. package/duster/helpers/core/cloudcms/searchOne.js +0 -34
  54. package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
  55. package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
  56. package/duster/helpers/core/dev/debug.js +0 -42
  57. package/duster/helpers/core/dom/block.js +0 -49
  58. package/duster/helpers/core/dom/include.js +0 -38
  59. package/duster/helpers/core/dom/layout.js +0 -49
  60. package/duster/helpers/core/dom/link.js +0 -81
  61. package/duster/helpers/core/dom/resource.js +0 -77
  62. package/duster/helpers/core/engine.js +0 -1580
  63. package/duster/helpers/core/ice/value.js +0 -65
  64. package/duster/helpers/core/index.js +0 -49
  65. package/duster/helpers/core/operators/if.js +0 -64
  66. package/duster/helpers/core/operators/iter.js +0 -45
  67. package/duster/helpers/core/operators/iterate.js +0 -129
  68. package/duster/helpers/sample/nyt.js +0 -114
  69. package/duster/index.js +0 -319
  70. package/duster/support.js +0 -436
  71. package/duster/tracker.js +0 -262
  72. package/middleware/authentication/providers/cas.js +0 -73
  73. package/middleware/authentication/providers/facebook.js +0 -120
  74. package/middleware/authentication/providers/github.js +0 -88
  75. package/middleware/authentication/providers/linkedin.js +0 -112
  76. package/middleware/authentication/providers/twitter.js +0 -120
  77. package/middleware/server-tags/server-tags.js +0 -113
  78. package/middleware/wcm/wcm.js +0 -1437
package/duster/index.js DELETED
@@ -1,319 +0,0 @@
1
- var path = require('path');
2
- var fs = require('fs');
3
- var http = require('http');
4
-
5
- var util = require("../util/util");
6
-
7
- var dust = require("dustjs-linkedin");
8
- require("dustjs-helpers");
9
-
10
- // we always set dust cache to false
11
- // this is because dust cache is file path dependent (could collide across tenants)s
12
- dust.config.cache = false;
13
-
14
- // instead we manage our own template cache
15
- var TEMPLATE_CACHE = {};
16
-
17
- if (process.env.CLOUDCMS_APPSERVER_MODE === "production") {
18
- dust.debugLevel = "INFO";
19
- } else {
20
- dust.debugLevel = "DEBUG";
21
- dust.config.cache = false;
22
- }
23
-
24
- if (process.env.CLOUDCMS_APPSERVER_MODE !== "production") {
25
- dust.config.whitespace = true;
26
- }
27
-
28
- if (process.env.DUST_DEBUG_LEVEL) {
29
- dust.debugLevel = (process.env.DUST_DEBUG_LEVEL + "").toUpperCase();
30
- }
31
-
32
- /**
33
- * Override Dust's isThenable() function so that Gitana driver chainable objects aren't included.
34
- *
35
- * @param elem
36
- * @returns {*|boolean}
37
- */
38
- dust.isThenable = function(elem) {
39
- return elem &&
40
- typeof elem === 'object' &&
41
- typeof elem.then === 'function' && !elem.objectType;
42
- };
43
-
44
- /**
45
- * Override Dust's onLoad() function so that templates are loaded from the store.
46
- * The cache key is also determined to include the appId.
47
- *
48
- * @param templatePath
49
- * @param options
50
- * @param callback
51
- */
52
- var loadTemplate = dust.onLoad = function(templatePath, options, callback)
53
- {
54
- //var log = options.log;
55
-
56
- // `templateName` is the name of the template requested by dust.render / dust.stream
57
- // or via a partial include, like {> "hello-world" /}
58
- // `options` can be set as part of a Context. They will be explored later
59
- // `callback` is a Node-like callback that takes (err, data)
60
-
61
- var store = options.store;
62
-
63
- store.existsFile(templatePath, function(exists) {
64
-
65
- if (!exists) {
66
- return callback({
67
- "message": "Dust cannot find file: " + templatePath
68
- });
69
- }
70
-
71
- store.readFile(templatePath, function(err, data) {
72
-
73
- if (err) {
74
- return callback(err);
75
- }
76
-
77
- callback(null, "" + data);
78
- });
79
- });
80
- };
81
-
82
- /**
83
- * Provides a convenience interface into the Dust subsystem that Cloud CMS uses to process in-page tags.
84
- */
85
- var exports = module.exports;
86
-
87
- exports.getDust = function()
88
- {
89
- return dust;
90
- };
91
-
92
- var populateContext = function(req, context, model, templateFilePath)
93
- {
94
- if (model)
95
- {
96
- for (var k in model)
97
- {
98
- context[k] = model[k];
99
- }
100
- }
101
-
102
- // assume no user information
103
-
104
- // if we have a req.user, add this in
105
- if (req.user)
106
- {
107
- context.user = req.user;
108
- context.userId = req.user.id;
109
- context.userName = req.user.name;
110
- }
111
-
112
- // populate request information
113
- var qs = {};
114
- if (req.query)
115
- {
116
- for (var name in req.query)
117
- {
118
- var value = req.query[name];
119
- if (value)
120
- {
121
- qs[name] = value;
122
- }
123
- }
124
- }
125
- if (!context.request) {
126
- context.request = {};
127
- }
128
- context.request.uri = req.originalUrl;
129
- context.request.path = req.path;
130
- context.request.qs = qs;
131
-
132
- context.gitana = req.gitana;
133
- context.templateFilePaths = [templateFilePath];
134
- context.req = req;
135
- context.messages = {};
136
-
137
- // populate any flash messages
138
- if (req.flash)
139
- {
140
- var info = req.flash("info");
141
- if (info)
142
- {
143
- context.messages.info = info;
144
- }
145
- }
146
-
147
- if (req.helpers)
148
- {
149
- context.helpers = req.helpers;
150
- }
151
-
152
- // push base tracker instance for tracking dependencies
153
- // TODO: add user information?
154
- context["__tracker"] = {
155
- "requires": {},
156
- "produces": {}
157
- };
158
-
159
- // TODO: add user information?
160
- // this isn't clear... not all pages in a user authenticated web site will require per-user page caching...
161
- // if we were to do it, we'd do it manually like this
162
- //context["__tracker"]["requires"]["userId"] = [req.userId];
163
-
164
- // used to generate fragment IDs
165
- context["fragmentIdGenerator"] = function(url) {
166
- var counter = 0;
167
- return function() {
168
- return util.hashSignature("fragment-" + url + "-" + (++counter));
169
- };
170
- }(req.url);
171
- };
172
-
173
- exports.invalidateCacheForApp = function(applicationId)
174
- {
175
- console.log("Invalidating dust cache for application: " + applicationId);
176
-
177
- var prefix = applicationId + ":";
178
-
179
- var badKeys = [];
180
- for (var k in TEMPLATE_CACHE)
181
- {
182
- if (k.indexOf(prefix) === 0) {
183
- badKeys.push(k);
184
- }
185
- }
186
- for (var i = 0; i < badKeys.length; i++)
187
- {
188
- console.log("Removing dust cache key: " + badKeys[i]);
189
- delete TEMPLATE_CACHE[badKeys[i]];
190
- }
191
- };
192
-
193
- exports.execute = function(req, store, filePath, model, callback)
194
- {
195
- if (typeof(model) === "function")
196
- {
197
- callback = model;
198
- model = {};
199
- }
200
-
201
- ensureInit(store);
202
-
203
- var templatePath = filePath.split(path.sep).join("/");
204
-
205
- // build context
206
- var contextObject = {};
207
- populateContext(req, contextObject, model, templatePath);
208
- var context = dust.context(contextObject, {
209
- "req": req,
210
- "store": store,
211
- "log": dust.log,
212
- "dust": dust
213
- });
214
-
215
- // hold on to this instance so that we can get at it once we're done
216
- var tracker = context.get("__tracker");
217
-
218
- var executeTemplate = function(template, templatePath, context, callback)
219
- {
220
- // execute template
221
- var t1 = new Date().getTime();
222
- dust.render(template, context, function(err, out) {
223
- var t2 = new Date().getTime();
224
-
225
- if (err)
226
- {
227
- req.log("An error was caught while rendering dust template: " + templatePath + ", error: " + JSON.stringify(err, null, " "));
228
- }
229
-
230
- // clean up - help out the garbage collector
231
- context.req = null;
232
- context.gitana = null;
233
- context.user = null;
234
-
235
- var dependencies = {
236
- "requires": tracker.requires,
237
- "produces": tracker.produces
238
- };
239
-
240
- var stats = {
241
- "dustExecutionTime": (t2 - t1)
242
- };
243
-
244
- // callback with dependencies
245
- callback(err, out, dependencies, stats);
246
- });
247
- };
248
-
249
- // does the template exist in the cache?
250
- var templateCacheKey = store.id + "_" + templatePath;
251
- var template = TEMPLATE_CACHE[templateCacheKey];
252
- if (template)
253
- {
254
- //console.log("FOUND IN TEMPLATE CACHE: " + templatePath);
255
- return executeTemplate(template, templatePath, context, callback);
256
- }
257
-
258
- // load and compile template by hand
259
- // we do this by hand in case it has a bug in it - we don't want it crashing the entire node process
260
- loadTemplate(templatePath, {
261
- "store": store
262
- }, function(err, text) {
263
-
264
- if (err) {
265
- return callback(err);
266
- }
267
-
268
- // compile and store into dust.cache
269
- try {
270
- //console.log("WRITE TO TEMPLATE CACHE: " + templatePath);
271
- template = dust.loadSource(dust.compile(text));
272
- TEMPLATE_CACHE[templateCacheKey] = template;
273
- } catch (e) {
274
- delete TEMPLATE_CACHE[templateCacheKey];
275
- return callback(e);
276
- }
277
-
278
- // proceed
279
- executeTemplate(template, templatePath, context, callback);
280
- });
281
- };
282
-
283
- /**
284
- * Init function that runs on the first call to duster.execute().
285
- * This ensures that templates are being watched properly.
286
- */
287
- var _init = false;
288
- var ensureInit = function(store)
289
- {
290
- if (_init)
291
- {
292
- return;
293
- }
294
-
295
- _init = true;
296
-
297
- if (process.env.CLOUDCMS_APPSERVER_MODE !== "production")
298
- {
299
- // watch everything in web store
300
- store.watchDirectory("/", function (f, curr, prev) {
301
-
302
- console.log("Template changes detected - invalidating dust cache");
303
- var badKeys = [];
304
- for (var k in TEMPLATE_CACHE)
305
- {
306
- if (k.indexOf(store.id) === 0)
307
- {
308
- badKeys.push(k);
309
- }
310
- }
311
- for (var i = 0; i < badKeys.length; i++)
312
- {
313
- console.log("Invalidating watched key: " + badKeys[i]);
314
- delete TEMPLATE_CACHE[badKeys[i]];
315
- }
316
-
317
- });
318
- }
319
- };