alchemymvc 1.2.5 → 1.2.7
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.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/lib/app/assets/scripts/.gitkeep +0 -0
- package/lib/app/assets/stylesheets/alchemy-info.less +0 -0
- package/lib/app/behaviour/publishable_behaviour.js +0 -0
- package/lib/app/behaviour/revision_behaviour.js +0 -0
- package/lib/app/behaviour/sluggable_behaviour.js +0 -0
- package/lib/app/component/.gitkeep +0 -0
- package/lib/app/conduit/electron_conduit.js +0 -0
- package/lib/app/conduit/http_conduit.js +173 -173
- package/lib/app/conduit/loopback_conduit.js +2 -3
- package/lib/app/conduit/socket_conduit.js +620 -620
- package/lib/app/controller/alchemy_info_controller.js +0 -0
- package/lib/app/datasource/mongo_datasource.js +0 -0
- package/lib/app/element/time_ago.js +2 -4
- package/lib/app/helper/alchemy_helper.js +22 -11
- package/lib/app/helper/client_collection.js +0 -0
- package/lib/app/helper/pagination_helper.js +0 -0
- package/lib/app/helper/router_helper.js +20 -7
- package/lib/app/helper/socket_helper.js +613 -613
- package/lib/app/helper_component/paginate_component.js +0 -0
- package/lib/app/helper_controller/component.js +0 -0
- package/lib/app/helper_controller/conduit.js +0 -0
- package/lib/app/helper_controller/controller.js +0 -0
- package/lib/app/helper_datasource/00-nosql_datasource.js +0 -0
- package/lib/app/helper_datasource/05-fallback_datasource.js +0 -0
- package/lib/app/helper_datasource/idb_datasource.js +0 -0
- package/lib/app/helper_datasource/indexed_db.js +0 -0
- package/lib/app/helper_field/00-objectid_field.js +0 -0
- package/lib/app/helper_field/06-text_field.js +0 -0
- package/lib/app/helper_field/10-number_field.js +0 -0
- package/lib/app/helper_field/boolean_field.js +0 -0
- package/lib/app/helper_field/date_field.js +0 -0
- package/lib/app/helper_field/datetime_field.js +0 -0
- package/lib/app/helper_field/enum_field.js +0 -0
- package/lib/app/helper_field/geopoint_field.js +0 -0
- package/lib/app/helper_field/habtm_field.js +0 -0
- package/lib/app/helper_field/hasoneparent_field.js +0 -0
- package/lib/app/helper_field/html_field.js +0 -0
- package/lib/app/helper_field/integer_field.js +0 -0
- package/lib/app/helper_field/object_field.js +0 -0
- package/lib/app/helper_field/regexp_field.js +0 -0
- package/lib/app/helper_field/schema_field.js +23 -2
- package/lib/app/helper_field/time_field.js +0 -0
- package/lib/app/helper_field/url_field.js +0 -0
- package/lib/app/helper_model/criteria.js +21 -3
- package/lib/app/helper_model/db_query.js +0 -0
- package/lib/app/helper_model/document_list.js +0 -0
- package/lib/app/helper_model/field_config.js +2 -2
- package/lib/app/helper_model/model.js +72 -5
- package/lib/app/model/alchemy_task_model.js +0 -0
- package/lib/app/routes.js +0 -0
- package/lib/app/view/alchemy/info.ejs +0 -0
- package/lib/app/view/error/unknown.ejs +0 -0
- package/lib/app/view/paginate/navlist.ejs +0 -0
- package/lib/bootstrap.js +0 -0
- package/lib/class/behaviour.js +0 -0
- package/lib/class/component.js +0 -0
- package/lib/class/conduit.js +2572 -2552
- package/lib/class/controller.js +4 -1
- package/lib/class/document.js +18 -4
- package/lib/class/document_list.js +0 -0
- package/lib/class/helper.js +0 -0
- package/lib/class/inode.js +0 -0
- package/lib/class/inode_dir.js +0 -0
- package/lib/class/inode_file.js +136 -112
- package/lib/class/inode_list.js +0 -0
- package/lib/class/model.js +1740 -1769
- package/lib/class/path_definition.js +0 -0
- package/lib/class/route.js +0 -0
- package/lib/class/router.js +6 -3
- package/lib/class/session.js +0 -0
- package/lib/class/task.js +0 -0
- package/lib/core/base.js +41 -18
- package/lib/core/client_alchemy.js +48 -2
- package/lib/core/discovery.js +0 -0
- package/lib/core/middleware.js +6 -4
- package/lib/core/routing.js +0 -0
- package/lib/core/socket.js +159 -159
- package/lib/init/alchemy.js +1848 -1823
- package/lib/init/constants.js +0 -0
- package/lib/init/functions.js +8 -4
- package/lib/init/load_functions.js +0 -0
- package/lib/init/requirements.js +101 -101
- package/lib/stages.js +10 -2
- package/package.json +74 -74
package/lib/class/controller.js
CHANGED
|
@@ -407,7 +407,7 @@ Controller.setMethod(function update(name, value) {
|
|
|
407
407
|
*
|
|
408
408
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
409
409
|
* @since 1.0.0
|
|
410
|
-
* @version 1.
|
|
410
|
+
* @version 1.2.6
|
|
411
411
|
*/
|
|
412
412
|
Controller.setAction(async function readDatasource(conduit) {
|
|
413
413
|
|
|
@@ -449,6 +449,9 @@ Controller.setAction(async function readDatasource(conduit) {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
model.removePrivateFields(items);
|
|
452
|
+
|
|
453
|
+
// @TODO: Is this still necesary?
|
|
454
|
+
// When would the records need translation so late?
|
|
452
455
|
model.translateItems(items, criteria, Function.thrower);
|
|
453
456
|
|
|
454
457
|
conduit.end({
|
package/lib/class/document.js
CHANGED
|
@@ -300,7 +300,7 @@ Document.setProperty(function $model() {
|
|
|
300
300
|
*
|
|
301
301
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
302
302
|
* @since 0.3.3
|
|
303
|
-
* @version 1.
|
|
303
|
+
* @version 1.2.7
|
|
304
304
|
*/
|
|
305
305
|
Document.setProperty(function conduit() {
|
|
306
306
|
if (this.$conduit) {
|
|
@@ -314,6 +314,10 @@ Document.setProperty(function conduit() {
|
|
|
314
314
|
}
|
|
315
315
|
}, function setConduit(conduit) {
|
|
316
316
|
this.$conduit = conduit;
|
|
317
|
+
|
|
318
|
+
if (this.$options.model) {
|
|
319
|
+
this.$options.model.conduit = conduit;
|
|
320
|
+
}
|
|
317
321
|
});
|
|
318
322
|
|
|
319
323
|
/**
|
|
@@ -384,9 +388,9 @@ Document.setMethod(function toDry() {
|
|
|
384
388
|
/**
|
|
385
389
|
* Simplify the object for Hawkejs
|
|
386
390
|
*
|
|
387
|
-
* @author Jelle De Loecker
|
|
391
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
388
392
|
* @since 0.2.0
|
|
389
|
-
* @version 1.2.
|
|
393
|
+
* @version 1.2.7
|
|
390
394
|
*
|
|
391
395
|
* @param {WeakMap} wm
|
|
392
396
|
*
|
|
@@ -410,7 +414,7 @@ Document.setMethod(function toHawkejs(wm) {
|
|
|
410
414
|
record = JSON.clone(this.$record, 'toHawkejs', wm);
|
|
411
415
|
|
|
412
416
|
// Sometimes we get an EMPTY $record value,
|
|
413
|
-
// this is probably because it's already in the process of being
|
|
417
|
+
// this is probably because it's already in the process of being cloned
|
|
414
418
|
if (!Object.isEmpty(record)) {
|
|
415
419
|
// Get clean options
|
|
416
420
|
let options = JSON.clone(this.getCleanOptions(), 'toHawkejs', wm);
|
|
@@ -425,6 +429,16 @@ Document.setMethod(function toHawkejs(wm) {
|
|
|
425
429
|
result.$_hold = JSON.clone(this.$_hold, 'toHawkejs', wm);
|
|
426
430
|
}
|
|
427
431
|
|
|
432
|
+
const conduit = this.conduit;
|
|
433
|
+
|
|
434
|
+
if (conduit) {
|
|
435
|
+
result.conduit = conduit;
|
|
436
|
+
|
|
437
|
+
if (result.$options?.model) {
|
|
438
|
+
result.$options.model.conduit = conduit;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
428
442
|
return result;
|
|
429
443
|
});
|
|
430
444
|
|
|
File without changes
|
package/lib/class/helper.js
CHANGED
|
File without changes
|
package/lib/class/inode.js
CHANGED
|
File without changes
|
package/lib/class/inode_dir.js
CHANGED
|
File without changes
|
package/lib/class/inode_file.js
CHANGED
|
@@ -1,113 +1,137 @@
|
|
|
1
|
-
const fs = alchemy.use('fs');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The File class
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
*
|
|
8
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
|
-
* @since 1.1.0
|
|
10
|
-
* @version 1.1.0
|
|
11
|
-
*
|
|
12
|
-
* @param {String} path Path to the file
|
|
13
|
-
*/
|
|
14
|
-
var File = Function.inherits('Alchemy.Inode', function File(path) {
|
|
15
|
-
|
|
16
|
-
if (typeof path == 'object') {
|
|
17
|
-
return File.from(path);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
this.type = null;
|
|
21
|
-
this.hash = null;
|
|
22
|
-
|
|
23
|
-
File.super.call(this, path);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Files are obviously files
|
|
28
|
-
*
|
|
29
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
30
|
-
* @since 1.1.0
|
|
31
|
-
* @version 1.1.0
|
|
32
|
-
*
|
|
33
|
-
* @type {Boolean}
|
|
34
|
-
*/
|
|
35
|
-
File.setProperty('is_file', true);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create a File instance from the given variable
|
|
39
|
-
*
|
|
40
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
41
|
-
* @since 1.1.0
|
|
42
|
-
* @version 1.2.
|
|
43
|
-
*/
|
|
44
|
-
File.setStatic(function from(obj) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
const fs = alchemy.use('fs');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The File class
|
|
5
|
+
*
|
|
6
|
+
* @constructor
|
|
7
|
+
*
|
|
8
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
|
+
* @since 1.1.0
|
|
10
|
+
* @version 1.1.0
|
|
11
|
+
*
|
|
12
|
+
* @param {String} path Path to the file
|
|
13
|
+
*/
|
|
14
|
+
var File = Function.inherits('Alchemy.Inode', function File(path) {
|
|
15
|
+
|
|
16
|
+
if (typeof path == 'object') {
|
|
17
|
+
return File.from(path);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.type = null;
|
|
21
|
+
this.hash = null;
|
|
22
|
+
|
|
23
|
+
File.super.call(this, path);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Files are obviously files
|
|
28
|
+
*
|
|
29
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
30
|
+
* @since 1.1.0
|
|
31
|
+
* @version 1.1.0
|
|
32
|
+
*
|
|
33
|
+
* @type {Boolean}
|
|
34
|
+
*/
|
|
35
|
+
File.setProperty('is_file', true);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a File instance from the given variable
|
|
39
|
+
*
|
|
40
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
41
|
+
* @since 1.1.0
|
|
42
|
+
* @version 1.2.7
|
|
43
|
+
*/
|
|
44
|
+
File.setStatic(function from(obj) {
|
|
45
|
+
|
|
46
|
+
if (!obj) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let path,
|
|
51
|
+
name,
|
|
52
|
+
type,
|
|
53
|
+
hash,
|
|
54
|
+
size;
|
|
55
|
+
|
|
56
|
+
if (typeof obj == 'string') {
|
|
57
|
+
path = obj;
|
|
58
|
+
} else if (obj.originalFilename) {
|
|
59
|
+
// Formidable 2.0
|
|
60
|
+
path = obj.filepath;
|
|
61
|
+
name = obj.originalFilename;
|
|
62
|
+
type = obj.mimetype;
|
|
63
|
+
hash = obj.hash;
|
|
64
|
+
size = obj.size;
|
|
65
|
+
} else {
|
|
66
|
+
path = obj.path;
|
|
67
|
+
name = obj.name;
|
|
68
|
+
type = obj.type;
|
|
69
|
+
hash = obj.hash;
|
|
70
|
+
size = obj.size;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let file = new File(path);
|
|
74
|
+
|
|
75
|
+
if (size != null) {
|
|
76
|
+
file.stat = {size};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (name != null) {
|
|
80
|
+
file.name = name;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (type != null) {
|
|
84
|
+
file.type = type;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (hash != null) {
|
|
88
|
+
file.hash = hash;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return file;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Read and return the contents
|
|
96
|
+
*
|
|
97
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
98
|
+
* @since 1.1.0
|
|
99
|
+
* @version 1.1.8
|
|
100
|
+
*/
|
|
101
|
+
File.setMethod(function read(options) {
|
|
102
|
+
|
|
103
|
+
let pledge = new Pledge();
|
|
104
|
+
|
|
105
|
+
if (!options) {
|
|
106
|
+
options = {flag: 'r'};
|
|
107
|
+
} else if (!options.flag) {
|
|
108
|
+
options.flag = 'r';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
fs.readFile(this.path, options, function done(err, data) {
|
|
112
|
+
|
|
113
|
+
if (err) {
|
|
114
|
+
return pledge.reject(err);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
pledge.resolve(data);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return pledge;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Read and return the contents as a string
|
|
125
|
+
*
|
|
126
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
127
|
+
* @since 1.1.0
|
|
128
|
+
* @version 1.1.0
|
|
129
|
+
*/
|
|
130
|
+
File.setMethod(function readString(encoding) {
|
|
131
|
+
|
|
132
|
+
if (!encoding) {
|
|
133
|
+
encoding = 'utf8';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return this.read({encoding: encoding});
|
|
113
137
|
});
|
package/lib/class/inode_list.js
CHANGED
|
File without changes
|