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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Path definition parser
|
|
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.3.0
|
|
7
7
|
*/
|
|
@@ -46,7 +46,7 @@ const PathDefinition = Function.inherits('Alchemy.Base', function PathDefinition
|
|
|
46
46
|
/**
|
|
47
47
|
* The main path matching regexp utility
|
|
48
48
|
*
|
|
49
|
-
* @author Jelle De Loecker
|
|
49
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
50
50
|
* @since 1.0.0
|
|
51
51
|
* @version 1.1.0
|
|
52
52
|
*/
|
|
@@ -66,7 +66,7 @@ PathDefinition.setStatic('path_regexp', RegExp([
|
|
|
66
66
|
/**
|
|
67
67
|
* Type definition testers
|
|
68
68
|
*
|
|
69
|
-
* @author Jelle De Loecker
|
|
69
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
70
70
|
* @since 1.0.0
|
|
71
71
|
* @version 1.0.0
|
|
72
72
|
*/
|
|
@@ -75,8 +75,8 @@ PathDefinition.setStatic('typedefs', {});
|
|
|
75
75
|
/**
|
|
76
76
|
* Register a type (like ObjectId or Number)
|
|
77
77
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
78
|
+
* @param {string} name
|
|
79
|
+
* @param {Function} fnc
|
|
80
80
|
*/
|
|
81
81
|
PathDefinition.setStatic(function registerType(name, fnc) {
|
|
82
82
|
|
|
@@ -91,9 +91,9 @@ PathDefinition.setStatic(function registerType(name, fnc) {
|
|
|
91
91
|
/**
|
|
92
92
|
* Escape a regular expression string.
|
|
93
93
|
*
|
|
94
|
-
* @param
|
|
94
|
+
* @param {string} group
|
|
95
95
|
*
|
|
96
|
-
* @return
|
|
96
|
+
* @return {string}
|
|
97
97
|
*/
|
|
98
98
|
PathDefinition.setStatic(function escapeGroup(group) {
|
|
99
99
|
return group.replace(/([=!:$/()])/g, '\\$1')
|
|
@@ -102,9 +102,9 @@ PathDefinition.setStatic(function escapeGroup(group) {
|
|
|
102
102
|
/**
|
|
103
103
|
* Escape the capturing group by escaping special characters and meaning.
|
|
104
104
|
*
|
|
105
|
-
* @param
|
|
105
|
+
* @param {string} str
|
|
106
106
|
*
|
|
107
|
-
* @return
|
|
107
|
+
* @return {string}
|
|
108
108
|
*/
|
|
109
109
|
PathDefinition.setStatic(function escapeString(str) {
|
|
110
110
|
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1')
|
|
@@ -114,7 +114,7 @@ PathDefinition.setStatic(function escapeString(str) {
|
|
|
114
114
|
/**
|
|
115
115
|
* Does this path use any type class checks?
|
|
116
116
|
*
|
|
117
|
-
* @author Jelle De Loecker
|
|
117
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
118
118
|
* @since 1.3.0
|
|
119
119
|
* @version 1.3.0
|
|
120
120
|
*/
|
|
@@ -141,7 +141,7 @@ PathDefinition.enforceProperty(function uses_type_class_checks(new_value) {
|
|
|
141
141
|
/**
|
|
142
142
|
* Get the complete section identifier
|
|
143
143
|
*
|
|
144
|
-
* @author Jelle De Loecker
|
|
144
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
145
145
|
* @since 1.0.0
|
|
146
146
|
* @version 1.1.0
|
|
147
147
|
*/
|
|
@@ -260,7 +260,7 @@ PathDefinition.setMethod(function parse(str, options) {
|
|
|
260
260
|
/**
|
|
261
261
|
* Convert tokens to regular expression
|
|
262
262
|
*
|
|
263
|
-
* @author Jelle De Loecker
|
|
263
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
264
264
|
* @since 1.0.0
|
|
265
265
|
* @version 1.0.0
|
|
266
266
|
*
|
|
@@ -352,12 +352,12 @@ PathDefinition.setMethod(function tokensToRegexp(tokens, keys, options) {
|
|
|
352
352
|
/**
|
|
353
353
|
* Get parameters object
|
|
354
354
|
*
|
|
355
|
-
* @author Jelle De Loecker
|
|
355
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
356
356
|
* @since 1.0.0
|
|
357
357
|
* @version 1.1.0
|
|
358
358
|
*
|
|
359
359
|
* @param {Array} values
|
|
360
|
-
* @param {
|
|
360
|
+
* @param {string} info_type
|
|
361
361
|
*
|
|
362
362
|
* @return {Object}
|
|
363
363
|
*/
|
|
@@ -397,11 +397,11 @@ PathDefinition.setMethod(function getParametersObject(values, info_type) {
|
|
|
397
397
|
/**
|
|
398
398
|
* Test the given string
|
|
399
399
|
*
|
|
400
|
-
* @author Jelle De Loecker
|
|
400
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
401
401
|
* @since 1.0.0
|
|
402
402
|
* @version 1.3.0
|
|
403
403
|
*
|
|
404
|
-
* @param {
|
|
404
|
+
* @param {string} path
|
|
405
405
|
*
|
|
406
406
|
* @return {Array|Pledge}
|
|
407
407
|
*/
|
|
@@ -480,13 +480,13 @@ PathDefinition.setMethod(function test(path, conduit) {
|
|
|
480
480
|
/**
|
|
481
481
|
* Make sure it's a valid ObjectId string
|
|
482
482
|
*
|
|
483
|
-
* @author Jelle De Loecker
|
|
483
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
484
484
|
* @since 1.0.0
|
|
485
485
|
* @version 1.0.0
|
|
486
486
|
*
|
|
487
|
-
* @param {
|
|
487
|
+
* @param {string} value
|
|
488
488
|
*
|
|
489
|
-
* @return {
|
|
489
|
+
* @return {string}
|
|
490
490
|
*/
|
|
491
491
|
PathDefinition.registerType(function ObjectId(value) {
|
|
492
492
|
if (value.isObjectId()) {
|
|
@@ -497,13 +497,13 @@ PathDefinition.registerType(function ObjectId(value) {
|
|
|
497
497
|
/**
|
|
498
498
|
* Make sure it's a number
|
|
499
499
|
*
|
|
500
|
-
* @author Jelle De Loecker
|
|
500
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
501
501
|
* @since 1.0.0
|
|
502
502
|
* @version 1.0.0
|
|
503
503
|
*
|
|
504
|
-
* @param {
|
|
504
|
+
* @param {string} value
|
|
505
505
|
*
|
|
506
|
-
* @return {
|
|
506
|
+
* @return {number}
|
|
507
507
|
*/
|
|
508
508
|
PathDefinition.registerType(function Number(value) {
|
|
509
509
|
if (Classes.Number.isNumeric(value)) {
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
6
|
*
|
|
7
|
-
* @author Jelle De Loecker
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
8
|
* @since 1.1.0
|
|
9
9
|
* @version 1.3.20
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {string} path
|
|
12
12
|
*/
|
|
13
13
|
const PathEvaluator = Function.inherits(null, 'Alchemy', function PathEvaluator(path) {
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ const PathEvaluator = Function.inherits(null, 'Alchemy', function PathEvaluator(
|
|
|
26
26
|
/**
|
|
27
27
|
* Undry the value
|
|
28
28
|
*
|
|
29
|
-
* @author Jelle De Loecker
|
|
29
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
30
30
|
* @since 1.1.0
|
|
31
31
|
* @version 1.1.0
|
|
32
32
|
*/
|
|
@@ -37,7 +37,7 @@ PathEvaluator.setStatic(function unDry(value) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Create a dry object
|
|
39
39
|
*
|
|
40
|
-
* @author Jelle De Loecker
|
|
40
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
41
41
|
* @since 1.1.0
|
|
42
42
|
* @version 1.1.0
|
|
43
43
|
*/
|
|
@@ -52,7 +52,7 @@ PathEvaluator.setMethod(function toDry() {
|
|
|
52
52
|
/**
|
|
53
53
|
* Get the actual value
|
|
54
54
|
*
|
|
55
|
-
* @author Jelle De Loecker
|
|
55
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
56
56
|
* @since 1.1.0
|
|
57
57
|
* @version 1.3.20
|
|
58
58
|
*/
|
|
@@ -3,7 +3,7 @@ const PathDefinition = Classes.Alchemy.PathDefinition;
|
|
|
3
3
|
/**
|
|
4
4
|
* Path param definition
|
|
5
5
|
*
|
|
6
|
-
* @author Jelle De Loecker
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
7
|
* @since 1.3.0
|
|
8
8
|
* @version 1.3.7
|
|
9
9
|
*/
|
|
@@ -51,7 +51,7 @@ const PathParamDefinition = Function.inherits('Alchemy.Base', function PathParam
|
|
|
51
51
|
/**
|
|
52
52
|
* Create path param definitions
|
|
53
53
|
*
|
|
54
|
-
* @author Jelle De Loecker
|
|
54
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
55
55
|
* @since 1.3.0
|
|
56
56
|
* @version 1.3.0
|
|
57
57
|
*
|
|
@@ -85,7 +85,7 @@ PathParamDefinition.setStatic(function from(input) {
|
|
|
85
85
|
/**
|
|
86
86
|
* Get the model constructor
|
|
87
87
|
*
|
|
88
|
-
* @author Jelle De Loecker
|
|
88
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
89
89
|
* @since 1.3.7
|
|
90
90
|
* @version 1.3.7
|
|
91
91
|
*/
|
|
@@ -109,7 +109,7 @@ PathParamDefinition.enforceProperty(function model_constructor(new_value) {
|
|
|
109
109
|
/**
|
|
110
110
|
* Parse the type definition
|
|
111
111
|
*
|
|
112
|
-
* @author Jelle De Loecker
|
|
112
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
113
113
|
* @since 1.3.0
|
|
114
114
|
* @version 1.3.12
|
|
115
115
|
*/
|
|
@@ -172,11 +172,11 @@ PathParamDefinition.setMethod(function parseTypeDefinition() {
|
|
|
172
172
|
/**
|
|
173
173
|
* Check the value
|
|
174
174
|
*
|
|
175
|
-
* @author Jelle De Loecker
|
|
175
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
176
176
|
* @since 1.3.0
|
|
177
177
|
* @version 1.3.0
|
|
178
178
|
*
|
|
179
|
-
* @param {
|
|
179
|
+
* @param {boolean|Pledge<boolean>}
|
|
180
180
|
*/
|
|
181
181
|
PathParamDefinition.setMethod(function castValueToType(value, conduit) {
|
|
182
182
|
|
|
@@ -199,7 +199,7 @@ PathParamDefinition.setMethod(function castValueToType(value, conduit) {
|
|
|
199
199
|
/**
|
|
200
200
|
* Parse an original path value
|
|
201
201
|
*
|
|
202
|
-
* @author Jelle De Loecker
|
|
202
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
203
203
|
* @since 1.3.0
|
|
204
204
|
* @version 1.3.0
|
|
205
205
|
*
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
const PLUGINS_STAGE = STAGES.getStage('load_app').getStage('plugins'),
|
|
2
|
+
libpath = require('path'),
|
|
3
|
+
libfs = require('fs'),
|
|
4
|
+
FLAGS = Symbol('flags');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Plugin class:
|
|
8
|
+
* Represents a plugin that can be used by Alchemy
|
|
9
|
+
*
|
|
10
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
11
|
+
* @since 1.4.0
|
|
12
|
+
* @version 1.4.0
|
|
13
|
+
*
|
|
14
|
+
* @param {string} name The name of the plugin
|
|
15
|
+
* @param {string} path The path of the plugin
|
|
16
|
+
* @param {Object} default_settings
|
|
17
|
+
*/
|
|
18
|
+
const Plugin = Function.inherits('Alchemy.Base', function Plugin(name, path, default_settings) {
|
|
19
|
+
|
|
20
|
+
// The name of the plugin
|
|
21
|
+
this.name = name;
|
|
22
|
+
|
|
23
|
+
// The path of the plugin
|
|
24
|
+
this.path = path;
|
|
25
|
+
|
|
26
|
+
// The hard-coded default settings
|
|
27
|
+
this.default_settings = default_settings;
|
|
28
|
+
|
|
29
|
+
// Flags
|
|
30
|
+
this[FLAGS] = {
|
|
31
|
+
attempted_bootstrap : false,
|
|
32
|
+
preloaded : false,
|
|
33
|
+
created_settings : false,
|
|
34
|
+
started : false,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Preload the plugin
|
|
40
|
+
* (Bootstrap & settings)
|
|
41
|
+
*
|
|
42
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
43
|
+
* @since 1.4.0
|
|
44
|
+
* @version 1.4.0
|
|
45
|
+
*
|
|
46
|
+
* @return {boolean}
|
|
47
|
+
*/
|
|
48
|
+
Plugin.setMethod(function doPreload() {
|
|
49
|
+
|
|
50
|
+
if (this[FLAGS].preloaded) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Create settings from the `config/settings.js` file
|
|
55
|
+
this.loadSettingDefinitions();
|
|
56
|
+
|
|
57
|
+
// Load the bootstrap file
|
|
58
|
+
this.loadBootstrap();
|
|
59
|
+
|
|
60
|
+
PLUGINS_STAGE.addPostTask(() => {
|
|
61
|
+
return this.startPlugin();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Do the rest of the plugin loading
|
|
67
|
+
*
|
|
68
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
69
|
+
* @since 1.4.0
|
|
70
|
+
* @version 1.4.0
|
|
71
|
+
*
|
|
72
|
+
* @return {boolean}
|
|
73
|
+
*/
|
|
74
|
+
Plugin.setMethod(async function startPlugin() {
|
|
75
|
+
|
|
76
|
+
if (this[FLAGS].started) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this[FLAGS].started = true;
|
|
81
|
+
|
|
82
|
+
await alchemy.useAppPath(this.path, {plugin: this});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create the setting definitions
|
|
87
|
+
*
|
|
88
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
89
|
+
* @since 1.4.0
|
|
90
|
+
* @version 1.4.0
|
|
91
|
+
*
|
|
92
|
+
* @return {boolean}
|
|
93
|
+
*/
|
|
94
|
+
Plugin.setMethod(function loadSettingDefinitions() {
|
|
95
|
+
|
|
96
|
+
if (this[FLAGS].created_settings) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this[FLAGS].created_settings = true;
|
|
101
|
+
|
|
102
|
+
let settings_path = libpath.resolve(this.path, 'config', 'settings.js');
|
|
103
|
+
|
|
104
|
+
// See if the file exists
|
|
105
|
+
if (!libfs.existsSync(settings_path)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Get/create this plugin's group definition
|
|
110
|
+
let group = this.getSettingsGroup();
|
|
111
|
+
|
|
112
|
+
// Get any already-existing settings
|
|
113
|
+
let parent = alchemy.system_settings.get('plugins');
|
|
114
|
+
let existing = parent.get(this.name);
|
|
115
|
+
|
|
116
|
+
if (existing) {
|
|
117
|
+
// Remove the existing settings.
|
|
118
|
+
// They are not linked properly anyway.
|
|
119
|
+
parent.remove(this.name);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Require the settings.js file now
|
|
123
|
+
this.useFile(settings_path, {client: false});
|
|
124
|
+
|
|
125
|
+
// Create the new group settings with default values
|
|
126
|
+
let default_group = group.generateValue();
|
|
127
|
+
|
|
128
|
+
if (this.default_settings) {
|
|
129
|
+
default_group.setDefaultValue(this.default_settings);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (existing) {
|
|
133
|
+
default_group.setValueSilently(existing);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
parent.injectSubGroupValue(this.name, default_group);
|
|
137
|
+
|
|
138
|
+
return true;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Load the bootstrap file
|
|
143
|
+
*
|
|
144
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
145
|
+
* @since 1.4.0
|
|
146
|
+
* @version 1.4.0
|
|
147
|
+
*
|
|
148
|
+
* @return {boolean}
|
|
149
|
+
*/
|
|
150
|
+
Plugin.setMethod(function loadBootstrap() {
|
|
151
|
+
|
|
152
|
+
if (this[FLAGS].attempted_bootstrap) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
this[FLAGS].attempted_bootstrap = true;
|
|
157
|
+
|
|
158
|
+
let bootstrap_path = libpath.resolve(this.path, 'bootstrap.js');
|
|
159
|
+
|
|
160
|
+
// See if the file exists
|
|
161
|
+
if (!libfs.existsSync(bootstrap_path)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Require the bootstrap.js file now
|
|
166
|
+
this.useFile(bootstrap_path, {client: false});
|
|
167
|
+
|
|
168
|
+
if (this.default_settings) {
|
|
169
|
+
let settings_group = this.getSettingsGroup();
|
|
170
|
+
settings_group.setDefaultValue(this.default_settings);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return true;
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Use an entire path
|
|
178
|
+
*
|
|
179
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
180
|
+
* @since 1.4.0
|
|
181
|
+
* @version 1.4.0
|
|
182
|
+
*
|
|
183
|
+
* @param {string} path
|
|
184
|
+
* @param {Object} options
|
|
185
|
+
*/
|
|
186
|
+
Plugin.setMethod(function usePath(path, options) {
|
|
187
|
+
|
|
188
|
+
if (!options) {
|
|
189
|
+
options = {};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
options.plugin = this;
|
|
193
|
+
|
|
194
|
+
return alchemy.usePath(path, options);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Require a file of this plugin
|
|
199
|
+
*
|
|
200
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
201
|
+
* @since 1.4.0
|
|
202
|
+
* @version 1.4.0
|
|
203
|
+
*
|
|
204
|
+
* @param {string} path
|
|
205
|
+
* @param {Object} options
|
|
206
|
+
*
|
|
207
|
+
* @return {Mixed}
|
|
208
|
+
*/
|
|
209
|
+
Plugin.setMethod(function useOnce(path, options) {
|
|
210
|
+
return this.useFile(path, options);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Require a file of this plugin
|
|
215
|
+
*
|
|
216
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
217
|
+
* @since 1.4.0
|
|
218
|
+
* @version 1.4.0
|
|
219
|
+
*
|
|
220
|
+
* @param {string} path
|
|
221
|
+
* @param {Object} options
|
|
222
|
+
*
|
|
223
|
+
* @return {Mixed}
|
|
224
|
+
*/
|
|
225
|
+
Plugin.setMethod(function useFile(path, options) {
|
|
226
|
+
|
|
227
|
+
if (!options) {
|
|
228
|
+
options = {};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
options.plugin = this;
|
|
232
|
+
|
|
233
|
+
if (!options.arguments) {
|
|
234
|
+
|
|
235
|
+
let argument_configuration = {
|
|
236
|
+
values : [
|
|
237
|
+
Blast,
|
|
238
|
+
Blast.Classes,
|
|
239
|
+
Blast.Types,
|
|
240
|
+
Blast.Collection,
|
|
241
|
+
Blast.Bound,
|
|
242
|
+
Blast.Bound.Object,
|
|
243
|
+
Blast.Collection.Function,
|
|
244
|
+
this,
|
|
245
|
+
],
|
|
246
|
+
names : [
|
|
247
|
+
'Blast',
|
|
248
|
+
'Classes',
|
|
249
|
+
'Types',
|
|
250
|
+
'Collection',
|
|
251
|
+
'Bound',
|
|
252
|
+
'Obj',
|
|
253
|
+
'Fn',
|
|
254
|
+
'Plugin',
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
options.arguments = argument_configuration;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (typeof path == 'string' && path[0] != '/') {
|
|
262
|
+
path = libpath.resolve(this.path, path);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return alchemy.useOnce(path, options);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Get this plugin's settings group
|
|
270
|
+
*
|
|
271
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
272
|
+
* @since 1.4.0
|
|
273
|
+
* @version 1.4.0
|
|
274
|
+
*
|
|
275
|
+
* @return {Alchemy.Setting.Group}
|
|
276
|
+
*/
|
|
277
|
+
Plugin.setMethod(function getSettingsGroup() {
|
|
278
|
+
|
|
279
|
+
let group = Classes.Alchemy.Setting.PLUGINS.get(this.name);
|
|
280
|
+
|
|
281
|
+
if (!group) {
|
|
282
|
+
group = Classes.Alchemy.Setting.PLUGINS.createGroup(this.name);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return group;
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Add a route
|
|
290
|
+
*
|
|
291
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
292
|
+
* @since 1.4.0
|
|
293
|
+
* @version 1.4.0
|
|
294
|
+
*
|
|
295
|
+
* @return {Alchemy.Router.Route}
|
|
296
|
+
*/
|
|
297
|
+
Plugin.setMethod(function addRoute(config) {
|
|
298
|
+
return Router.add(config);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Custom Janeway representation (right side)
|
|
303
|
+
*
|
|
304
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
305
|
+
* @since 1.4.0
|
|
306
|
+
* @version 1.4.0
|
|
307
|
+
*
|
|
308
|
+
* @return {String}
|
|
309
|
+
*/
|
|
310
|
+
Plugin.setMethod(Symbol.for('janeway_arg_right'), function janewayInstanceInfo() {
|
|
311
|
+
return this.name;
|
|
312
|
+
});
|