alchemymvc 1.1.7 → 1.2.0

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 (39) hide show
  1. package/lib/app/behaviour/sluggable_behaviour.js +2 -4
  2. package/lib/app/conduit/http_conduit.js +173 -192
  3. package/lib/app/conduit/loopback_conduit.js +0 -0
  4. package/lib/app/conduit/socket_conduit.js +620 -620
  5. package/lib/app/datasource/mongo_datasource.js +75 -10
  6. package/lib/app/element/time_ago.js +0 -0
  7. package/lib/app/helper/socket_helper.js +613 -613
  8. package/lib/app/helper_datasource/00-nosql_datasource.js +73 -19
  9. package/lib/app/helper_datasource/remote_datasource.js +0 -0
  10. package/lib/app/helper_field/05-string_field.js +0 -0
  11. package/lib/app/helper_field/schema_field.js +7 -2
  12. package/lib/app/helper_model/criteria.js +76 -18
  13. package/lib/app/helper_model/field_config.js +24 -5
  14. package/lib/app/helper_model/model.js +65 -7
  15. package/lib/app/model/alchemy_migration_model.js +33 -0
  16. package/lib/bootstrap.js +9 -0
  17. package/lib/class/conduit.js +2474 -2412
  18. package/lib/class/datasource.js +8 -8
  19. package/lib/class/field.js +7 -1
  20. package/lib/class/inode.js +62 -0
  21. package/lib/class/inode_dir.js +115 -0
  22. package/lib/class/inode_file.js +112 -111
  23. package/lib/class/migration.js +138 -0
  24. package/lib/class/model.js +1765 -1772
  25. package/lib/class/reciprocal.js +8 -2
  26. package/lib/class/router.js +0 -0
  27. package/lib/class/schema.js +14 -12
  28. package/lib/core/base.js +37 -10
  29. package/lib/core/client_base.js +1 -9
  30. package/lib/core/middleware.js +4 -8
  31. package/lib/core/socket.js +159 -159
  32. package/lib/init/alchemy.js +1779 -1779
  33. package/lib/init/devwatch.js +1 -1
  34. package/lib/init/functions.js +2 -56
  35. package/lib/init/load_functions.js +8 -2
  36. package/lib/init/requirements.js +101 -96
  37. package/lib/stages.js +12 -0
  38. package/package.json +74 -76
  39. package/CHANGELOG.md +0 -445
@@ -100,7 +100,7 @@ if (alchemy.settings.kill_on_file_change) {
100
100
  }
101
101
 
102
102
  // Skip some big module folders by default
103
- if (path.endsWith('/less') || path.endsWith('/caniuse-lite') || path.endsWith('/bcrypt') || path.endsWith('/node-sass') || path.endsWith('/mmmagic') || path.endsWith('/node-gyp') || path.endsWith('/lodash')) {
103
+ if (path.endsWith('/less') || path.endsWith('/caniuse-lite') || path.endsWith('/bcrypt') || path.endsWith('/sass') || path.endsWith('/mmmagic') || path.endsWith('/node-gyp') || path.endsWith('/lodash')) {
104
104
  seen_map.set(_path, true);
105
105
  return true;
106
106
  }
@@ -41,7 +41,7 @@ Informer.setMethod(function attachConduit(conduit) {
41
41
  *
42
42
  * @author Jelle De Loecker <jelle@develry.be>
43
43
  * @since 0.3.0
44
- * @version 1.1.0
44
+ * @version 1.1.8
45
45
  *
46
46
  * @param {String} name The name of the model to get
47
47
  * @param {Boolean} init Initialize the class [true]
@@ -50,61 +50,7 @@ Informer.setMethod(function attachConduit(conduit) {
50
50
  * @return {Model}
51
51
  */
52
52
  Informer.setMethod(function getModel(name, init, options) {
53
-
54
- var instance;
55
-
56
- if (typeof init != 'boolean') {
57
- options = init;
58
- init = true;
59
- }
60
-
61
- if (!init) {
62
- return Model.get(name, false);
63
- }
64
-
65
- if (!options) {
66
- options = {};
67
- }
68
-
69
- let conduit = this.conduit;
70
-
71
- if (!conduit) {
72
- if (this.view && this.view.conduit) {
73
- conduit = this.view.conduit;
74
- } else if (this.view && this.view.root_renderer && this.view.root_renderer.conduit) {
75
- conduit = this.view.root_renderer.conduit;
76
- }
77
- }
78
-
79
- if (options.cache !== false) {
80
- if (!this._modelInstances) {
81
- this._modelInstances = {};
82
- } else {
83
- instance = this._modelInstances[name];
84
- }
85
-
86
- // If an instance already exists on this item,
87
- // and it has the same conduit (or none), return that
88
- if (instance && (instance.conduit == conduit)) {
89
- return instance;
90
- }
91
- }
92
-
93
- instance = Model.get(name, options);
94
-
95
- if (conduit) {
96
- instance.attachConduit(conduit);
97
- }
98
-
99
- if (this._debugObject) {
100
- instance._debugObject = this._debugObject;
101
- }
102
-
103
- if (options.cache !== false) {
104
- this._modelInstances[name] = instance;
105
- }
106
-
107
- return instance;
53
+ return Blast.Classes.Alchemy.Base.prototype.getModel.apply(this, arguments);
108
54
  });
109
55
 
110
56
  /**
@@ -166,7 +166,7 @@ Alchemy.setProperty('default_use_path_options', {
166
166
  *
167
167
  * @author Jelle De Loecker <jelle@develry.be>
168
168
  * @since 0.0.1
169
- * @version 1.0.3
169
+ * @version 1.2.0
170
170
  *
171
171
  * @param {String} dir_path
172
172
  * @param {Object} options
@@ -255,7 +255,8 @@ Alchemy.setMethod(function _usePath(dir_path, options) {
255
255
  parent_path : dir_path,
256
256
  name : file_name,
257
257
  path : file_path,
258
- stat : file_stat
258
+ stat : file_stat,
259
+ local_path : file_path.slice(PATH_APP.length),
259
260
  });
260
261
 
261
262
  continue;
@@ -273,6 +274,11 @@ Alchemy.setMethod(function _usePath(dir_path, options) {
273
274
  for (i = 0; i < directories.length; i++) {
274
275
  entry = directories[i];
275
276
 
277
+ // Don't load migrations
278
+ if (entry.local_path == '/migrations') {
279
+ continue;
280
+ }
281
+
276
282
  // Do not include subfolders of the "config" directory
277
283
  // if it's a modular load
278
284
  if (options.modularParent && /\/config$/.exec(entry.parent_path)) {
@@ -1,97 +1,102 @@
1
- 'use strict';
2
-
3
- /**
4
- * The basic http module, used to create the server.
5
- *
6
- * @link http://nodejs.org/api/http.html
7
- */
8
- alchemy.use('http', 'http');
9
-
10
- /**
11
- * This module contains utilities for handling and transforming file paths.
12
- * Almost all these methods perform only string transformations.
13
- * The file system is not consulted to check whether paths are valid.
14
- *
15
- * @link http://nodejs.org/api/path.html
16
- */
17
- alchemy.use('path', 'path');
18
-
19
- /**
20
- * File I/O is provided by simple wrappers around standard POSIX functions.
21
- *
22
- * @link http://nodejs.org/api/fs.html
23
- */
24
- alchemy.use('graceful-fs', 'fs');
25
-
26
- /**
27
- * Usefull utilities.
28
- *
29
- * @link http://nodejs.org/api/util.html
30
- */
31
- alchemy.use('util', 'util');
32
-
33
- /**
34
- * The native mongodb library
35
- *
36
- * @link https://npmjs.org/package/mongodb
37
- */
38
- alchemy.use('mongodb', 'mongodb');
39
-
40
- /**
41
- * The LESS interpreter.
42
- *
43
- * @link https://npmjs.org/package/less
44
- */
45
- alchemy.use('less', 'less');
46
-
47
- /**
48
- * Hawkejs view engine
49
- *
50
- * @link https://npmjs.org/package/hawkejs
51
- */
52
- alchemy.use('hawkejs', 'hawkejs');
53
- alchemy.hawkejs = new Classes.Hawkejs.Hawkejs;
54
-
55
- /**
56
- * The function to detect when everything is too busy
57
- */
58
- alchemy.toobusy = alchemy.use('toobusy-js', 'toobusy');
59
-
60
- // If the config is a number, use that as the lag threshold
61
- if (typeof alchemy.settings.toobusy === 'number') {
62
- alchemy.toobusy.maxLag(alchemy.settings.toobusy);
63
- }
64
-
65
- /**
66
- * Load Sputnik, the stage-based launcher
67
- */
68
- alchemy.sputnik = new (alchemy.use('sputnik', 'sputnik'))();
69
-
70
- /**
71
- * Real-time apps made cross-browser & easy with a WebSocket-like API.
72
- *
73
- * @link https://npmjs.org/package/socket.io
74
- */
75
- alchemy.use('socket.io', 'io');
76
-
77
- /**
78
- * Recursively mkdir, like `mkdir -p`.
79
- * This is a requirement fetched from express
80
- *
81
- * @link https://npmjs.org/package/mkdirp
82
- */
83
- alchemy.use('mkdirp', 'mkdirp');
84
-
85
- /**
86
- * Base useragent library
87
- *
88
- * @link https://npmjs.org/package/useragent
89
- */
90
- alchemy.use('useragent');
91
-
92
- /**
93
- * Enable the `satisfies` method in the `useragent` library
94
- *
95
- * @link https://www.npmjs.com/package/useragent#adding-more-features-to-the-useragent
96
- */
1
+ 'use strict';
2
+
3
+ /**
4
+ * The basic http module, used to create the server.
5
+ *
6
+ * @link http://nodejs.org/api/http.html
7
+ */
8
+ alchemy.use('http', 'http');
9
+
10
+ /**
11
+ * This module contains utilities for handling and transforming file paths.
12
+ * Almost all these methods perform only string transformations.
13
+ * The file system is not consulted to check whether paths are valid.
14
+ *
15
+ * @link http://nodejs.org/api/path.html
16
+ */
17
+ alchemy.use('path', 'path');
18
+
19
+ /**
20
+ * File I/O is provided by simple wrappers around standard POSIX functions.
21
+ *
22
+ * @link http://nodejs.org/api/fs.html
23
+ */
24
+ alchemy.use('graceful-fs', 'fs');
25
+
26
+ /**
27
+ * Usefull utilities.
28
+ *
29
+ * @link http://nodejs.org/api/util.html
30
+ */
31
+ alchemy.use('util', 'util');
32
+
33
+ /**
34
+ * The native mongodb library
35
+ *
36
+ * @link https://npmjs.org/package/mongodb
37
+ */
38
+ alchemy.use('mongodb', 'mongodb');
39
+
40
+ /**
41
+ * The LESS interpreter.
42
+ *
43
+ * @link https://npmjs.org/package/less
44
+ */
45
+ alchemy.use('less', 'less');
46
+
47
+ /**
48
+ * Hawkejs view engine
49
+ *
50
+ * @link https://npmjs.org/package/hawkejs
51
+ */
52
+ alchemy.use('hawkejs', 'hawkejs');
53
+ alchemy.hawkejs = new Classes.Hawkejs.Hawkejs;
54
+
55
+ /**
56
+ * The function to detect when everything is too busy
57
+ */
58
+ alchemy.toobusy = alchemy.use('toobusy-js', 'toobusy');
59
+
60
+ // If the config is a number, use that as the lag threshold
61
+ if (typeof alchemy.settings.toobusy === 'number') {
62
+ alchemy.toobusy.maxLag(alchemy.settings.toobusy);
63
+ }
64
+
65
+ /**
66
+ * Load Sputnik, the stage-based launcher
67
+ */
68
+ alchemy.sputnik = new (alchemy.use('sputnik', 'sputnik'))();
69
+
70
+ /**
71
+ * Real-time apps made cross-browser & easy with a WebSocket-like API.
72
+ *
73
+ * @link https://npmjs.org/package/socket.io
74
+ */
75
+ alchemy.use('socket.io', 'io');
76
+
77
+ /**
78
+ * Allow streams over a socket.io connection
79
+ */
80
+ alchemy.use('@11ways/socket.io-stream', 'socket.io-stream');
81
+
82
+ /**
83
+ * Recursively mkdir, like `mkdir -p`.
84
+ * This is a requirement fetched from express
85
+ *
86
+ * @link https://npmjs.org/package/mkdirp
87
+ */
88
+ alchemy.use('mkdirp', 'mkdirp');
89
+
90
+ /**
91
+ * Base useragent library
92
+ *
93
+ * @link https://npmjs.org/package/useragent
94
+ */
95
+ alchemy.use('useragent');
96
+
97
+ /**
98
+ * Enable the `satisfies` method in the `useragent` library
99
+ *
100
+ * @link https://www.npmjs.com/package/useragent#adding-more-features-to-the-useragent
101
+ */
97
102
  require('useragent/features');
package/lib/stages.js CHANGED
@@ -225,6 +225,18 @@ alchemy.sputnik.add(function hawkejs_setup() {
225
225
  }
226
226
  });
227
227
 
228
+ // Serve the static file with exposed variables
229
+ Router.use('/hawkejs/static.js', function getHawkejs(req, res, next) {
230
+ alchemy.hawkejs.getStaticExposedPath((err, path) => {
231
+
232
+ if (err) {
233
+ return req.conduit.error(err);
234
+ }
235
+
236
+ req.conduit.serveFile(path);
237
+ });
238
+ });
239
+
228
240
  // Serve multiple template files
229
241
  Router.use('/hawkejs/templates', function onGetTemplates(req, res) {
230
242
 
package/package.json CHANGED
@@ -1,76 +1,74 @@
1
- {
2
- "name": "alchemymvc",
3
- "description": "MVC framework for Node.js",
4
- "version": "1.1.7",
5
- "author": "Jelle De Loecker <jelle@elevenways.be>",
6
- "keywords": [
7
- "alchemy",
8
- "alchemymvc",
9
- "mvc"
10
- ],
11
- "repository": {
12
- "type": "git",
13
- "url": "git://github.com/11ways/alchemy.git"
14
- },
15
- "dependencies": {
16
- "ansi-256-colors" : "~1.1.0",
17
- "autoprefixer" : "~10.2.5",
18
- "bcrypt" : "~5.0.1",
19
- "body" : "~5.1.0",
20
- "body-parser" : "~1.19.0",
21
- "bson" : "~4.3.0",
22
- "chokidar" : "~3.5.1",
23
- "formidable" : "~1.2.2",
24
- "graceful-fs" : "~4.2.6",
25
- "hawkejs" : "~2.1.4",
26
- "jsondiffpatch" : "~0.4.1",
27
- "mime" : "~2.5.2",
28
- "minimist" : "~1.2.5",
29
- "mkdirp" : "~1.0.4",
30
- "mmmagic" : "~0.5.3",
31
- "mollusc" : "~2.0.0",
32
- "mongodb" : "~3.6.6",
33
- "ncp" : "~2.0.0",
34
- "postcss" : "~8.2.13",
35
- "protoblast" : "~0.7.8",
36
- "semver" : "~7.3.5",
37
- "socket.io" : "~2.3.0",
38
- "socket.io-stream" : "~0.9.1",
39
- "sputnik" : "~0.1.0",
40
- "temp" : "~0.9.4",
41
- "terser" : "~5.7.0",
42
- "toobusy-js" : "~0.5.1",
43
- "useragent" : "~2.3.0"
44
- },
45
- "files": [
46
- "lib/",
47
- "index.js"
48
- ],
49
- "optionalDependencies": {
50
- "janeway" : "~0.3.5",
51
- "less" : "~4.1.1",
52
- "node-sass" : "~5.0.0",
53
- "nodent-compiler" : "~3.2.13",
54
- "socket.io-client" : "~2.3.0"
55
- },
56
- "devDependencies": {
57
- "codecov" : "~3.8.1",
58
- "istanbul-lib-instrument" : "~4.0.3",
59
- "nyc" : "^15.1.0",
60
- "mocha" : "~8.3.2",
61
- "mongo-unit" : "~2.0.1",
62
- "puppeteer" : "~9.0.0",
63
- "source-map" : "~0.7.3"
64
- },
65
- "scripts": {
66
- "test" : "mocha --exit --reporter spec --bail --timeout 50000 --file test/00-init.js",
67
- "appveyor" : "mocha --exit --reporter spec --bail --timeout 20000 --file test/00-init.js",
68
- "coverage" : "nyc --reporter=text --reporter=lcov mocha --exit --timeout 200000 --bail --file test/00-init.js",
69
- "report-coverage" : "nyc report --reporter=lcov && cat ./coverage/lcov.info | codecov"
70
- },
71
- "main": "lib/bootstrap.js",
72
- "license": "MIT",
73
- "engines": {
74
- "node": ">=10.21.0"
75
- }
76
- }
1
+ {
2
+ "name": "alchemymvc",
3
+ "description": "MVC framework for Node.js",
4
+ "version": "1.2.0",
5
+ "author": "Jelle De Loecker <jelle@elevenways.be>",
6
+ "keywords": [
7
+ "alchemy",
8
+ "alchemymvc",
9
+ "mvc"
10
+ ],
11
+ "repository": {
12
+ "type" : "git",
13
+ "url" : "git://github.com/11ways/alchemy.git"
14
+ },
15
+ "dependencies": {
16
+ "ansi-256-colors" : "~1.1.0",
17
+ "autoprefixer" : "~10.4.2",
18
+ "bcrypt" : "~5.0.1",
19
+ "body" : "~5.1.0",
20
+ "body-parser" : "~1.19.2",
21
+ "bson" : "~4.6.1",
22
+ "chokidar" : "~3.5.3",
23
+ "formidable" : "~1.2.2",
24
+ "graceful-fs" : "~4.2.9",
25
+ "hawkejs" : "~2.2.0",
26
+ "jsondiffpatch" : "~0.4.1",
27
+ "mime" : "~3.0.0",
28
+ "minimist" : "~1.2.5",
29
+ "mkdirp" : "~1.0.4",
30
+ "mmmagic" : "~0.5.3",
31
+ "mongodb" : "~3.6.6",
32
+ "ncp" : "~2.0.0",
33
+ "postcss" : "~8.4.6",
34
+ "protoblast" : "~0.7.10",
35
+ "semver" : "~7.3.5",
36
+ "socket.io" : "~2.4.0",
37
+ "@11ways/socket.io-stream" : "~0.9.2",
38
+ "sputnik" : "~0.1.0",
39
+ "terser" : "~5.10.0",
40
+ "toobusy-js" : "~0.5.1",
41
+ "useragent" : "~2.3.0"
42
+ },
43
+ "files": [
44
+ "lib/",
45
+ "index.js"
46
+ ],
47
+ "optionalDependencies": {
48
+ "janeway" : "~0.3.5",
49
+ "less" : "~4.1.1",
50
+ "sass" : "~1.49.8",
51
+ "nodent-compiler" : "~3.2.13",
52
+ "socket.io-client" : "~2.4.0"
53
+ },
54
+ "devDependencies": {
55
+ "codecov" : "~3.8.1",
56
+ "istanbul-lib-instrument" : "~4.0.3",
57
+ "mocha" : "~8.3.2",
58
+ "mongo-unit" : "~2.0.1",
59
+ "nyc" : "^15.1.0",
60
+ "puppeteer" : "~9.0.0",
61
+ "source-map" : "~0.7.3"
62
+ },
63
+ "scripts": {
64
+ "appveyor" : "mocha --exit --reporter spec --bail --timeout 20000 --file test/00-init.js",
65
+ "coverage" : "nyc --reporter=text --reporter=lcov mocha --exit --timeout 200000 --bail --file test/00-init.js",
66
+ "report-coverage" : "nyc report --reporter=lcov && cat ./coverage/lcov.info | codecov",
67
+ "test" : "mocha --exit --reporter spec --bail --timeout 50000 --file test/00-init.js"
68
+ },
69
+ "main": "lib/bootstrap.js",
70
+ "license": "MIT",
71
+ "engines": {
72
+ "node" : ">=10.21.0"
73
+ }
74
+ }