alchemymvc 1.3.21 → 1.4.0-alpha.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.
- package/LICENSE +1 -1
- package/README.md +3 -3
- package/lib/app/behaviour/publishable_behaviour.js +5 -5
- package/lib/app/behaviour/revision_behaviour.js +10 -10
- package/lib/app/behaviour/sluggable_behaviour.js +14 -14
- package/lib/app/conduit/electron_conduit.js +9 -9
- package/lib/app/conduit/http_conduit.js +13 -13
- package/lib/app/conduit/loopback_conduit.js +15 -15
- package/lib/app/conduit/socket_conduit.js +43 -43
- package/lib/app/config/routes.js +26 -0
- package/lib/app/controller/00-default_app_controller.js +21 -0
- package/lib/app/controller/alchemy_info_controller.js +12 -12
- package/lib/app/datasource/mongo_datasource.js +16 -16
- package/lib/app/element/00-default_app_element.js +19 -0
- package/lib/app/element/time_ago.js +5 -5
- package/lib/app/helper/00-default_app_helper.js +11 -0
- package/lib/app/helper/alchemy_helper.js +22 -22
- package/lib/app/helper/backed_map.js +1 -1
- package/lib/app/helper/breadcrumb.js +10 -10
- package/lib/app/helper/client_collection.js +3 -3
- package/lib/app/helper/cron.js +29 -29
- package/lib/app/helper/enum_values.js +6 -6
- package/lib/app/helper/pagination_helper.js +36 -36
- package/lib/app/helper/router_helper.js +35 -35
- package/lib/app/helper/socket_helper.js +57 -57
- package/lib/app/helper/syncable.js +84 -59
- package/lib/app/helper_component/paginate_component.js +9 -9
- package/lib/app/helper_controller/component.js +1 -1
- package/lib/app/helper_controller/conduit.js +31 -31
- package/lib/app/helper_controller/controller.js +54 -39
- package/lib/app/helper_datasource/00-nosql_datasource.js +624 -70
- package/lib/app/helper_datasource/05-fallback_datasource.js +10 -10
- package/lib/app/helper_datasource/idb_datasource.js +6 -6
- package/lib/app/helper_datasource/indexed_db.js +22 -22
- package/lib/app/helper_datasource/remote_datasource.js +5 -5
- package/lib/app/helper_error/http_error.js +4 -4
- package/lib/app/helper_error/model_error.js +2 -2
- package/lib/app/helper_error/validation_error.js +12 -12
- package/lib/app/helper_field/00-objectid_field.js +7 -7
- package/lib/app/helper_field/05-string_field.js +16 -12
- package/lib/app/helper_field/06-text_field.js +2 -4
- package/lib/app/helper_field/10-number_field.js +9 -12
- package/lib/app/helper_field/11-date_field.js +15 -15
- package/lib/app/helper_field/15-local_temporal_field.js +10 -10
- package/lib/app/helper_field/20-decimal_field.js +8 -9
- package/lib/app/helper_field/belongsto_field.js +1 -1
- package/lib/app/helper_field/big_int_field.js +8 -8
- package/lib/app/helper_field/boolean_field.js +9 -11
- package/lib/app/helper_field/datetime_field.js +3 -3
- package/lib/app/helper_field/enum_field.js +13 -8
- package/lib/app/helper_field/fixed_decimal_field.js +6 -7
- package/lib/app/helper_field/geopoint_field.js +9 -10
- package/lib/app/helper_field/habtm_field.js +3 -3
- package/lib/app/helper_field/hasoneparent_field.js +1 -1
- package/lib/app/helper_field/html_field.js +2 -4
- package/lib/app/helper_field/integer_field.js +8 -11
- package/lib/app/helper_field/local_date_field.js +5 -5
- package/lib/app/helper_field/local_date_time_field.js +5 -5
- package/lib/app/helper_field/local_time_field.js +5 -5
- package/lib/app/helper_field/mixed_field.js +5 -5
- package/lib/app/helper_field/object_field.js +8 -8
- package/lib/app/helper_field/password_field.js +3 -3
- package/lib/app/helper_field/regexp_field.js +7 -9
- package/lib/app/helper_field/schema_field.js +91 -88
- package/lib/app/helper_field/settings_field.js +92 -0
- package/lib/app/helper_field/time_field.js +6 -6
- package/lib/app/helper_field/url_field.js +2 -4
- package/lib/app/helper_model/00-base_criteria.js +662 -0
- package/lib/app/helper_model/05-criteria_expressions.js +605 -0
- package/lib/app/helper_model/10-model_criteria.js +1182 -0
- package/lib/app/helper_model/data_provider.js +2 -2
- package/lib/app/helper_model/document.js +103 -92
- package/lib/app/helper_model/document_list.js +14 -14
- package/lib/app/helper_model/field_config.js +11 -11
- package/lib/app/helper_model/field_set.js +17 -17
- package/lib/app/helper_model/model.js +203 -124
- package/lib/app/helper_model/remote_data_provider.js +2 -2
- package/lib/app/helper_validator/00_validator.js +16 -16
- package/lib/app/helper_validator/not_empty_validator.js +9 -9
- package/lib/app/model/00-default_app_model.js +18 -0
- package/lib/app/model/05-system_model.js +27 -0
- package/lib/app/model/{alchemy_migration_model.js → system_migration_model.js} +4 -4
- package/lib/app/model/system_setting_model.js +154 -0
- package/lib/app/model/{alchemy_task_history_model.js → system_task_history_model.js} +7 -7
- package/lib/app/model/{alchemy_task_model.js → system_task_model.js} +11 -11
- package/lib/bootstrap.js +22 -312
- package/lib/class/accumulator.js +5 -5
- package/lib/class/behaviour.js +5 -5
- package/lib/class/component.js +3 -3
- package/lib/class/conduit.js +203 -163
- package/lib/class/controller.js +42 -42
- package/lib/class/datasource.js +74 -79
- package/lib/class/document.js +74 -95
- package/lib/class/document_list.js +5 -5
- package/lib/class/element.js +17 -17
- package/lib/class/error.js +3 -3
- package/lib/class/field.js +169 -91
- package/lib/class/field_value.js +6 -6
- package/lib/class/helper.js +3 -3
- package/lib/class/inode.js +17 -17
- package/lib/class/inode_dir.js +12 -12
- package/lib/class/inode_file.js +50 -25
- package/lib/class/inode_list.js +4 -4
- package/lib/class/migration.js +4 -4
- package/lib/class/model.js +182 -168
- package/lib/class/path_definition.js +22 -22
- package/lib/class/path_evaluator.js +5 -5
- package/lib/class/path_param_definition.js +7 -7
- package/lib/class/plugin.js +312 -0
- package/lib/class/postponement.js +29 -29
- package/lib/class/reciprocal.js +8 -8
- package/lib/class/route.js +33 -33
- package/lib/class/router.js +73 -73
- package/lib/class/schema.js +21 -21
- package/lib/class/schema_client.js +73 -67
- package/lib/class/session.js +63 -29
- package/lib/class/session_scene.js +4 -4
- package/lib/class/sitemap.js +16 -16
- package/lib/class/task.js +39 -39
- package/lib/class/task_service.js +43 -47
- package/lib/{init → core}/alchemy.js +413 -374
- package/lib/{init/functions.js → core/alchemy_functions.js} +171 -108
- package/lib/core/alchemy_load_functions.js +715 -0
- package/lib/core/base.js +50 -62
- package/lib/core/client_alchemy.js +144 -152
- package/lib/core/client_base.js +39 -52
- package/lib/core/discovery.js +16 -18
- package/lib/core/middleware.js +54 -43
- package/lib/core/{routing.js → prefix.js} +14 -16
- package/lib/core/setting.js +1684 -0
- package/lib/core/stage.js +758 -0
- package/lib/scripts/create_constants.js +119 -0
- package/lib/{init/languages.js → scripts/create_languages.js} +5 -5
- package/lib/scripts/create_settings.js +449 -0
- package/lib/scripts/create_shared_constants.js +95 -0
- package/lib/scripts/create_stages.js +55 -0
- package/lib/scripts/init_alchemy.js +51 -0
- package/lib/{init/requirements.js → scripts/preload_modules.js} +15 -2
- package/lib/scripts/setup_devwatch.js +238 -0
- package/lib/stages/00-load_core.js +342 -0
- package/lib/stages/05-load_app.js +57 -0
- package/lib/stages/10-datasource.js +61 -0
- package/lib/stages/15-tasks.js +27 -0
- package/lib/stages/20-settings.js +68 -0
- package/lib/stages/50-routes.js +218 -0
- package/lib/stages/90-server.js +347 -0
- package/package.json +5 -7
- package/lib/app/helper_model/criteria.js +0 -2294
- package/lib/app/helper_model/db_query.js +0 -1488
- package/lib/app/routes.js +0 -11
- package/lib/core/socket.js +0 -171
- package/lib/init/constants.js +0 -158
- package/lib/init/devwatch.js +0 -238
- package/lib/init/load_functions.js +0 -973
- package/lib/stages.js +0 -513
package/lib/class/field_value.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @constructor
|
|
5
5
|
*
|
|
6
|
-
* @author Jelle De Loecker
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
7
|
* @since 1.1.0
|
|
8
8
|
* @version 1.1.0
|
|
9
9
|
*
|
|
10
10
|
* @param {Field} field The field definition
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {string} path The full path to the value (includes indexes)
|
|
12
12
|
* @param {*} value
|
|
13
13
|
*/
|
|
14
14
|
const FieldValue = Function.inherits(null, 'Alchemy', function FieldValue(field, path, value) {
|
|
@@ -22,7 +22,7 @@ const FieldValue = Function.inherits(null, 'Alchemy', function FieldValue(field,
|
|
|
22
22
|
/**
|
|
23
23
|
* Get the translated values, if possible
|
|
24
24
|
*
|
|
25
|
-
* @author Jelle De Loecker
|
|
25
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
26
26
|
* @since 1.1.0
|
|
27
27
|
* @version 1.1.4
|
|
28
28
|
*
|
|
@@ -61,7 +61,7 @@ FieldValue.setMethod(function getTranslatedValues() {
|
|
|
61
61
|
/**
|
|
62
62
|
* Get the array values, if possible
|
|
63
63
|
*
|
|
64
|
-
* @author Jelle De Loecker
|
|
64
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
65
65
|
* @since 1.1.0
|
|
66
66
|
* @version 1.1.0
|
|
67
67
|
*
|
|
@@ -131,7 +131,7 @@ FieldValue.setMethod(function unwind() {
|
|
|
131
131
|
/**
|
|
132
132
|
* Refine the values
|
|
133
133
|
*
|
|
134
|
-
* @author Jelle De Loecker
|
|
134
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
135
135
|
* @since 1.1.0
|
|
136
136
|
* @version 1.1.0
|
|
137
137
|
*
|
|
@@ -170,7 +170,7 @@ FieldValue.setMethod(function refine(fields) {
|
|
|
170
170
|
/**
|
|
171
171
|
* Get subfield values
|
|
172
172
|
*
|
|
173
|
-
* @author Jelle De Loecker
|
|
173
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
174
174
|
* @since 1.1.0
|
|
175
175
|
* @version 1.1.0
|
|
176
176
|
*
|
package/lib/class/helper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Custom alchemy helpers
|
|
3
3
|
*
|
|
4
|
-
* @author Jelle De Loecker
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
5
|
* @since 1.0.0
|
|
6
6
|
* @version 1.0.0
|
|
7
7
|
*
|
|
@@ -14,12 +14,12 @@ var Helper = Function.inherits('Hawkejs.Helper', 'Alchemy.Helper', function Help
|
|
|
14
14
|
/**
|
|
15
15
|
* Add an error to the given element
|
|
16
16
|
*
|
|
17
|
-
* @author Jelle De Loecker
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
18
|
* @since 1.1.0
|
|
19
19
|
* @version 1.1.0
|
|
20
20
|
*
|
|
21
21
|
* @param {Element} element
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {string} error
|
|
23
23
|
*/
|
|
24
24
|
Helper.setMethod(function markElementError(element, error) {
|
|
25
25
|
element.setAttribute('data-alchemy-error', error);
|
package/lib/class/inode.js
CHANGED
|
@@ -6,7 +6,7 @@ const libpath = alchemy.use('path'),
|
|
|
6
6
|
*
|
|
7
7
|
* @constructor
|
|
8
8
|
*
|
|
9
|
-
* @author Jelle De Loecker
|
|
9
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
10
10
|
* @since 1.1.0
|
|
11
11
|
* @version 1.1.0
|
|
12
12
|
*
|
|
@@ -29,11 +29,11 @@ var Inode = Function.inherits('Alchemy.Base', 'Alchemy.Inode', function Inode(pa
|
|
|
29
29
|
/**
|
|
30
30
|
* Get the correct Inode instance for the given path
|
|
31
31
|
*
|
|
32
|
-
* @author Jelle De Loecker
|
|
32
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
33
33
|
* @since 1.3.0
|
|
34
34
|
* @version 1.3.0
|
|
35
35
|
*
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {string} path
|
|
37
37
|
*
|
|
38
38
|
* @return {Pledge<Inode>}
|
|
39
39
|
*/
|
|
@@ -56,11 +56,11 @@ Inode.setStatic(function from(path) {
|
|
|
56
56
|
/**
|
|
57
57
|
* Process given path
|
|
58
58
|
*
|
|
59
|
-
* @author Jelle De Loecker
|
|
59
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
60
60
|
* @since 1.1.0
|
|
61
61
|
* @version 1.1.0
|
|
62
62
|
*
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {string|Array} full_path
|
|
64
64
|
*/
|
|
65
65
|
Inode.setStatic(function process(full_path, options, next) {
|
|
66
66
|
|
|
@@ -100,33 +100,33 @@ Inode.setStatic(function process(full_path, options, next) {
|
|
|
100
100
|
/**
|
|
101
101
|
* Things are not directories by default
|
|
102
102
|
*
|
|
103
|
-
* @author Jelle De Loecker
|
|
103
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
104
104
|
* @since 1.1.0
|
|
105
105
|
* @version 1.1.0
|
|
106
106
|
*
|
|
107
|
-
* @type {
|
|
107
|
+
* @type {boolean}
|
|
108
108
|
*/
|
|
109
109
|
Inode.setProperty('is_directory', false);
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Things are not files by default
|
|
113
113
|
*
|
|
114
|
-
* @author Jelle De Loecker
|
|
114
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
115
115
|
* @since 1.1.0
|
|
116
116
|
* @version 1.1.0
|
|
117
117
|
*
|
|
118
|
-
* @type {
|
|
118
|
+
* @type {boolean}
|
|
119
119
|
*/
|
|
120
120
|
Inode.setProperty('is_file', false);
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* The extension of this inode
|
|
124
124
|
*
|
|
125
|
-
* @author Jelle De Loecker
|
|
125
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
126
126
|
* @since 1.1.0
|
|
127
127
|
* @version 1.1.0
|
|
128
128
|
*
|
|
129
|
-
* @type {
|
|
129
|
+
* @type {string}
|
|
130
130
|
*/
|
|
131
131
|
Inode.setProperty(function extension() {
|
|
132
132
|
return libpath.extname(this.name);
|
|
@@ -135,11 +135,11 @@ Inode.setProperty(function extension() {
|
|
|
135
135
|
/**
|
|
136
136
|
* The basename of this inode
|
|
137
137
|
*
|
|
138
|
-
* @author Jelle De Loecker
|
|
138
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
139
139
|
* @since 1.1.0
|
|
140
140
|
* @version 1.1.0
|
|
141
141
|
*
|
|
142
|
-
* @type {
|
|
142
|
+
* @type {string}
|
|
143
143
|
*/
|
|
144
144
|
Inode.setProperty(function basename() {
|
|
145
145
|
return libpath.basename(this.name);
|
|
@@ -149,11 +149,11 @@ Inode.setProperty(function basename() {
|
|
|
149
149
|
* The rootname of this inode
|
|
150
150
|
* (basename without extension)
|
|
151
151
|
*
|
|
152
|
-
* @author Jelle De Loecker
|
|
152
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
153
153
|
* @since 1.1.0
|
|
154
154
|
* @version 1.1.0
|
|
155
155
|
*
|
|
156
|
-
* @type {
|
|
156
|
+
* @type {string}
|
|
157
157
|
*/
|
|
158
158
|
Inode.setProperty(function rootname() {
|
|
159
159
|
|
|
@@ -169,7 +169,7 @@ Inode.setProperty(function rootname() {
|
|
|
169
169
|
/**
|
|
170
170
|
* Get the stat object
|
|
171
171
|
*
|
|
172
|
-
* @author Jelle De Loecker
|
|
172
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
173
173
|
* @since 1.1.8
|
|
174
174
|
* @version 1.1.8
|
|
175
175
|
*
|
|
@@ -201,7 +201,7 @@ Inode.setMethod(function getStats(refresh) {
|
|
|
201
201
|
/**
|
|
202
202
|
* Does this inode still exist?
|
|
203
203
|
*
|
|
204
|
-
* @author Jelle De Loecker
|
|
204
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
205
205
|
* @since 1.1.8
|
|
206
206
|
* @version 1.1.8
|
|
207
207
|
*
|
package/lib/class/inode_dir.js
CHANGED
|
@@ -5,11 +5,11 @@ const libpath = alchemy.use('path');
|
|
|
5
5
|
*
|
|
6
6
|
* @constructor
|
|
7
7
|
*
|
|
8
|
-
* @author Jelle De Loecker
|
|
8
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
9
|
* @since 1.1.0
|
|
10
10
|
* @version 1.1.0
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {string} path Path to the directory
|
|
13
13
|
*/
|
|
14
14
|
var Directory = Function.inherits('Alchemy.Inode', function Directory(path) {
|
|
15
15
|
Directory.super.call(this, path);
|
|
@@ -21,18 +21,18 @@ var Directory = Function.inherits('Alchemy.Inode', function Directory(path) {
|
|
|
21
21
|
/**
|
|
22
22
|
* Directories are obviously directories
|
|
23
23
|
*
|
|
24
|
-
* @author Jelle De Loecker
|
|
24
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
25
25
|
* @since 1.1.0
|
|
26
26
|
* @version 1.1.0
|
|
27
27
|
*
|
|
28
|
-
* @type {
|
|
28
|
+
* @type {boolean}
|
|
29
29
|
*/
|
|
30
30
|
Directory.setProperty('is_directory', true);
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Load this directory's contents
|
|
34
34
|
*
|
|
35
|
-
* @author Jelle De Loecker
|
|
35
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
36
36
|
* @since 1.1.0
|
|
37
37
|
* @version 1.1.0
|
|
38
38
|
*
|
|
@@ -68,13 +68,13 @@ Directory.setMethod(async function loadContents(options) {
|
|
|
68
68
|
/**
|
|
69
69
|
* See if this directory contains any entries matching the given name
|
|
70
70
|
*
|
|
71
|
-
* @author Jelle De Loecker
|
|
71
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
72
72
|
* @since 1.1.0
|
|
73
73
|
* @version 1.1.0
|
|
74
74
|
*
|
|
75
|
-
* @param {
|
|
75
|
+
* @param {string|Regex} regex
|
|
76
76
|
*
|
|
77
|
-
* @return {
|
|
77
|
+
* @return {boolean}
|
|
78
78
|
*/
|
|
79
79
|
Directory.setMethod(function contains(regex) {
|
|
80
80
|
|
|
@@ -98,7 +98,7 @@ Directory.setMethod(function contains(regex) {
|
|
|
98
98
|
/**
|
|
99
99
|
* Iterator over the contents of this directory
|
|
100
100
|
*
|
|
101
|
-
* @author Jelle De Loecker
|
|
101
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
102
102
|
* @since 1.1.0
|
|
103
103
|
* @version 1.1.0
|
|
104
104
|
*/
|
|
@@ -114,7 +114,7 @@ Directory.setMethod(Symbol.iterator, function* iterate() {
|
|
|
114
114
|
/**
|
|
115
115
|
* Get a file from this directory, or its subdirectory
|
|
116
116
|
*
|
|
117
|
-
* @author Jelle De Loecker
|
|
117
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
118
118
|
* @since 1.1.8
|
|
119
119
|
* @version 1.1.8
|
|
120
120
|
*
|
|
@@ -165,7 +165,7 @@ Directory.setMethod(async function get(path) {
|
|
|
165
165
|
/**
|
|
166
166
|
* Return a list of all files
|
|
167
167
|
*
|
|
168
|
-
* @author Jelle De Loecker
|
|
168
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
169
169
|
* @since 1.1.8
|
|
170
170
|
* @version 1.1.8
|
|
171
171
|
*
|
|
@@ -191,7 +191,7 @@ Directory.setMethod(async function flatten() {
|
|
|
191
191
|
/**
|
|
192
192
|
* Add all files to the given list
|
|
193
193
|
*
|
|
194
|
-
* @author Jelle De Loecker
|
|
194
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
195
195
|
* @since 1.1.8
|
|
196
196
|
* @version 1.1.8
|
|
197
197
|
*
|
package/lib/class/inode_file.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const HASH = Symbol('hash'),
|
|
2
2
|
ALGORITHM = Symbol('algorithm'),
|
|
3
|
-
LIBMAGIC = alchemy.use('mmmagic'),
|
|
3
|
+
LIBMAGIC = alchemy.use('@picturae/mmmagic'),
|
|
4
4
|
LIBMIME = alchemy.use('mime'),
|
|
5
5
|
fs = alchemy.use('fs');
|
|
6
6
|
|
|
@@ -11,11 +11,11 @@ let Magic;
|
|
|
11
11
|
*
|
|
12
12
|
* @constructor
|
|
13
13
|
*
|
|
14
|
-
* @author Jelle De Loecker
|
|
14
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
15
15
|
* @since 1.1.0
|
|
16
16
|
* @version 1.1.0
|
|
17
17
|
*
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {string} path Path to the file
|
|
19
19
|
*/
|
|
20
20
|
var File = Function.inherits('Alchemy.Inode', function File(path) {
|
|
21
21
|
|
|
@@ -32,24 +32,24 @@ var File = Function.inherits('Alchemy.Inode', function File(path) {
|
|
|
32
32
|
/**
|
|
33
33
|
* Files are obviously files
|
|
34
34
|
*
|
|
35
|
-
* @author Jelle De Loecker
|
|
35
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
36
36
|
* @since 1.1.0
|
|
37
37
|
* @version 1.1.0
|
|
38
38
|
*
|
|
39
|
-
* @type {
|
|
39
|
+
* @type {boolean}
|
|
40
40
|
*/
|
|
41
41
|
File.setProperty('is_file', true);
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Detect the filetype of the given path
|
|
45
45
|
*
|
|
46
|
-
* @author Jelle De Loecker
|
|
46
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
47
47
|
* @since 1.3.0
|
|
48
48
|
* @version 1.3.0
|
|
49
49
|
*
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {string} path
|
|
51
51
|
*
|
|
52
|
-
* @return {Pledge<
|
|
52
|
+
* @return {Pledge<string>}
|
|
53
53
|
*/
|
|
54
54
|
File.setStatic(function getMimetype(path) {
|
|
55
55
|
|
|
@@ -82,14 +82,14 @@ File.setStatic(function getMimetype(path) {
|
|
|
82
82
|
/**
|
|
83
83
|
* Guess the mimetype from the path
|
|
84
84
|
*
|
|
85
|
-
* @author Jelle De Loecker
|
|
85
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
86
86
|
* @since 1.3.0
|
|
87
|
-
* @version 1.
|
|
87
|
+
* @version 1.4.0
|
|
88
88
|
*
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
89
|
+
* @param {string} path
|
|
90
|
+
* @param {string} fallback
|
|
91
91
|
*
|
|
92
|
-
* @return {
|
|
92
|
+
* @return {string}
|
|
93
93
|
*/
|
|
94
94
|
File.setStatic(function guessMimetypeFromPath(path, fallback) {
|
|
95
95
|
|
|
@@ -105,14 +105,14 @@ File.setStatic(function guessMimetypeFromPath(path, fallback) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
return result;
|
|
108
|
+
return result || fallback;
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Create a File instance from the given variable
|
|
113
113
|
* (From an untrusted source)
|
|
114
114
|
*
|
|
115
|
-
* @author Jelle De Loecker
|
|
115
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
116
116
|
* @since 1.3.0
|
|
117
117
|
* @version 1.3.0
|
|
118
118
|
*/
|
|
@@ -161,7 +161,7 @@ File.setStatic(function fromUntrusted(obj) {
|
|
|
161
161
|
/**
|
|
162
162
|
* Create a File instance from the given variable
|
|
163
163
|
*
|
|
164
|
-
* @author Jelle De Loecker
|
|
164
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
165
165
|
* @since 1.1.0
|
|
166
166
|
* @version 1.3.0
|
|
167
167
|
*/
|
|
@@ -224,11 +224,11 @@ File.setStatic(function from(obj) {
|
|
|
224
224
|
/**
|
|
225
225
|
* Get the mimetype of the file
|
|
226
226
|
*
|
|
227
|
-
* @author Jelle De Loecker
|
|
227
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
228
228
|
* @since 1.3.0
|
|
229
229
|
* @version 1.3.0
|
|
230
230
|
*
|
|
231
|
-
* @return {
|
|
231
|
+
* @return {string|Pledge<string>}
|
|
232
232
|
*/
|
|
233
233
|
File.setMethod(function getMimetype() {
|
|
234
234
|
|
|
@@ -253,17 +253,17 @@ File.setMethod(function getMimetype() {
|
|
|
253
253
|
/**
|
|
254
254
|
* Get the SHA1 hash of the file
|
|
255
255
|
*
|
|
256
|
-
* @author Jelle De Loecker
|
|
256
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
257
257
|
* @since 1.3.0
|
|
258
258
|
* @version 1.3.0
|
|
259
259
|
*
|
|
260
|
-
* @param {
|
|
260
|
+
* @param {string} algorithm
|
|
261
261
|
*
|
|
262
|
-
* @return {
|
|
262
|
+
* @return {string|Pledge<string>}
|
|
263
263
|
*/
|
|
264
264
|
File.setMethod(function getHash(algorithm) {
|
|
265
265
|
|
|
266
|
-
algorithm = algorithm || alchemy.settings.file_hash_algorithm;
|
|
266
|
+
algorithm = algorithm || alchemy.settings.data_management.file_hash_algorithm;
|
|
267
267
|
|
|
268
268
|
if (!this[HASH] || this[ALGORITHM] != algorithm) {
|
|
269
269
|
const options = {algorithm};
|
|
@@ -281,7 +281,7 @@ File.setMethod(function getHash(algorithm) {
|
|
|
281
281
|
/**
|
|
282
282
|
* Create a read stream
|
|
283
283
|
*
|
|
284
|
-
* @author Jelle De Loecker
|
|
284
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
285
285
|
* @since 1.3.0
|
|
286
286
|
* @version 1.3.0
|
|
287
287
|
*
|
|
@@ -294,7 +294,7 @@ File.setMethod(function createReadStream(options) {
|
|
|
294
294
|
/**
|
|
295
295
|
* Read and return the contents
|
|
296
296
|
*
|
|
297
|
-
* @author Jelle De Loecker
|
|
297
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
298
298
|
* @since 1.1.0
|
|
299
299
|
* @version 1.3.16
|
|
300
300
|
*/
|
|
@@ -327,7 +327,7 @@ File.setMethod(function read(options) {
|
|
|
327
327
|
/**
|
|
328
328
|
* Read and return the contents as a string
|
|
329
329
|
*
|
|
330
|
-
* @author Jelle De Loecker
|
|
330
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
331
331
|
* @since 1.1.0
|
|
332
332
|
* @version 1.1.0
|
|
333
333
|
*/
|
|
@@ -338,4 +338,29 @@ File.setMethod(function readString(encoding) {
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
return this.read({encoding: encoding});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Write the given data to the file
|
|
345
|
+
*
|
|
346
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
347
|
+
* @since 1.3.22
|
|
348
|
+
* @version 1.3.22
|
|
349
|
+
*/
|
|
350
|
+
File.setMethod(function overwrite(contents, options = {}) {
|
|
351
|
+
|
|
352
|
+
let pledge = new Pledge();
|
|
353
|
+
|
|
354
|
+
options.flag = 'w';
|
|
355
|
+
|
|
356
|
+
fs.writeFile(this.path, contents, options, function done(err) {
|
|
357
|
+
|
|
358
|
+
if (err) {
|
|
359
|
+
return pledge.reject(err);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
pledge.resolve();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
return pledge;
|
|
341
366
|
});
|
package/lib/class/inode_list.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @constructor
|
|
5
5
|
*
|
|
6
|
-
* @author Jelle De Loecker
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
7
|
* @since 1.1.0
|
|
8
8
|
* @version 1.1.0
|
|
9
9
|
*
|
|
@@ -16,7 +16,7 @@ var List = Function.inherits(['Alchemy.Base', 'Array'], 'Alchemy.Inode', functio
|
|
|
16
16
|
/**
|
|
17
17
|
* Return the length of the entries
|
|
18
18
|
*
|
|
19
|
-
* @author Jelle De Loecker
|
|
19
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
20
20
|
* @since 1.1.0
|
|
21
21
|
* @version 1.1.0
|
|
22
22
|
*/
|
|
@@ -27,7 +27,7 @@ List.setProperty(function length() {
|
|
|
27
27
|
/**
|
|
28
28
|
* Iterator method
|
|
29
29
|
*
|
|
30
|
-
* @author Jelle De Loecker
|
|
30
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
31
31
|
* @since 1.1.0
|
|
32
32
|
* @version 1.1.0
|
|
33
33
|
*/
|
|
@@ -43,7 +43,7 @@ List.setMethod(Symbol.iterator, function* iterate() {
|
|
|
43
43
|
/**
|
|
44
44
|
* Load the contents of directories?
|
|
45
45
|
*
|
|
46
|
-
* @author Jelle De Loecker
|
|
46
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
47
47
|
* @since 1.1.0
|
|
48
48
|
* @version 1.1.0
|
|
49
49
|
*
|
package/lib/class/migration.js
CHANGED
|
@@ -5,7 +5,7 @@ const libpath = alchemy.use('path');
|
|
|
5
5
|
*
|
|
6
6
|
* @constructor
|
|
7
7
|
*
|
|
8
|
-
* @author Jelle De Loecker
|
|
8
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
9
|
* @since 1.2.0
|
|
10
10
|
* @version 1.2.0
|
|
11
11
|
*/
|
|
@@ -18,13 +18,13 @@ const Migration = Function.inherits('Alchemy.Base', function Migration(document)
|
|
|
18
18
|
*
|
|
19
19
|
* @constructor
|
|
20
20
|
*
|
|
21
|
-
* @author Jelle De Loecker
|
|
21
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
22
22
|
* @since 1.2.0
|
|
23
23
|
* @version 1.2.0
|
|
24
24
|
*/
|
|
25
25
|
Migration.setStatic(async function start() {
|
|
26
26
|
|
|
27
|
-
const AlchemyMigration = Model.get('
|
|
27
|
+
const AlchemyMigration = Model.get('System.Migration');
|
|
28
28
|
|
|
29
29
|
console.log('Starting migration task...');
|
|
30
30
|
|
|
@@ -116,7 +116,7 @@ Migration.setStatic(async function start() {
|
|
|
116
116
|
*
|
|
117
117
|
* @constructor
|
|
118
118
|
*
|
|
119
|
-
* @author Jelle De Loecker
|
|
119
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
120
120
|
* @since 1.2.0
|
|
121
121
|
* @version 1.3.1
|
|
122
122
|
*/
|