alchemymvc 1.3.22 → 1.4.0-alpha.2
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 +96 -59
- 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 +27 -18
- 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 +62 -62
- 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 +6 -6
- 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 +201 -123
- 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 +152 -150
- 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 +26 -26
- package/lib/class/inode_list.js +4 -4
- package/lib/class/migration.js +4 -4
- package/lib/class/model.js +146 -165
- 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 +105 -82
- 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 +411 -373
- package/lib/{init/functions.js → core/alchemy_functions.js} +113 -91
- 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 +27 -50
- 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 -979
- package/lib/stages.js +0 -515
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
let mkdirp = alchemy.use('mkdirp')?.mkdirp,
|
|
4
2
|
ncp = alchemy.use('ncp').ncp,
|
|
5
3
|
fs = alchemy.use('fs'),
|
|
@@ -27,7 +25,7 @@ spawnQueue.start();
|
|
|
27
25
|
/**
|
|
28
26
|
* Attach a conduit to a certain instance
|
|
29
27
|
*
|
|
30
|
-
* @author Jelle De Loecker
|
|
28
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
31
29
|
* @since 0.2.0
|
|
32
30
|
* @version 0.2.0
|
|
33
31
|
*
|
|
@@ -40,15 +38,15 @@ Informer.setMethod(function attachConduit(conduit) {
|
|
|
40
38
|
/**
|
|
41
39
|
* Get a model, attach a conduit if possible
|
|
42
40
|
*
|
|
43
|
-
* @author Jelle De Loecker
|
|
41
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
44
42
|
* @since 0.3.0
|
|
45
43
|
* @version 1.1.8
|
|
46
44
|
*
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
45
|
+
* @param {string} name The name of the model to get
|
|
46
|
+
* @param {boolean} init Initialize the class [true]
|
|
47
|
+
* @param {Object} options
|
|
50
48
|
*
|
|
51
|
-
* @return
|
|
49
|
+
* @return {Model}
|
|
52
50
|
*/
|
|
53
51
|
Informer.setMethod(function getModel(name, init, options) {
|
|
54
52
|
return Blast.Classes.Alchemy.Base.prototype.getModel.apply(this, arguments);
|
|
@@ -57,11 +55,11 @@ Informer.setMethod(function getModel(name, init, options) {
|
|
|
57
55
|
/**
|
|
58
56
|
* Create a debug entry
|
|
59
57
|
*
|
|
60
|
-
* @author Jelle De Loecker
|
|
58
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
61
59
|
* @since 0.2.0
|
|
62
60
|
* @version 0.2.0
|
|
63
61
|
*
|
|
64
|
-
* @param
|
|
62
|
+
* @param {number} verbosity
|
|
65
63
|
*/
|
|
66
64
|
Informer.setMethod(function debug(verbosity) {
|
|
67
65
|
|
|
@@ -91,7 +89,7 @@ Informer.setMethod(function debug(verbosity) {
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
// Do nothing if debugging is off and verbosity is too high
|
|
94
|
-
if (!alchemy.settings.debug && options.verbosity > log.ERROR) {
|
|
92
|
+
if (!alchemy.settings.debugging.debug && options.verbosity > log.ERROR) {
|
|
95
93
|
return;
|
|
96
94
|
}
|
|
97
95
|
|
|
@@ -148,7 +146,7 @@ Informer.setMethod(function debug(verbosity) {
|
|
|
148
146
|
return item;
|
|
149
147
|
}
|
|
150
148
|
|
|
151
|
-
if (!duplicate && alchemy.settings.debug && options.data && options.data.args) {
|
|
149
|
+
if (!duplicate && alchemy.settings.debugging.debug && options.data && options.data.args) {
|
|
152
150
|
if (typeof options.level != 'number') {
|
|
153
151
|
options.level = 1;
|
|
154
152
|
}
|
|
@@ -162,11 +160,11 @@ Informer.setMethod(function debug(verbosity) {
|
|
|
162
160
|
/**
|
|
163
161
|
* Create a debug mark
|
|
164
162
|
*
|
|
165
|
-
* @author Jelle De Loecker
|
|
163
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
166
164
|
* @since 0.2.0
|
|
167
165
|
* @version 0.2.0
|
|
168
166
|
*
|
|
169
|
-
* @param
|
|
167
|
+
* @param {string} message
|
|
170
168
|
*/
|
|
171
169
|
Informer.setMethod(function debugMark(message) {
|
|
172
170
|
if (this._debugObject) {
|
|
@@ -331,12 +329,12 @@ Debugger.setMethod(function stop(message) {
|
|
|
331
329
|
/**
|
|
332
330
|
* Schedule a function in a low priority queue
|
|
333
331
|
*
|
|
334
|
-
* @author Jelle De Loecker
|
|
332
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
335
333
|
* @since 0.0.1
|
|
336
334
|
* @version 0.4.0
|
|
337
335
|
*
|
|
338
336
|
* @param {Function} fnc
|
|
339
|
-
* @param {
|
|
337
|
+
* @param {number} wait How long to wait before executing
|
|
340
338
|
*/
|
|
341
339
|
Alchemy.setMethod(function lowPriority(fnc, wait) {
|
|
342
340
|
|
|
@@ -399,13 +397,13 @@ var _duplicateCheck = {};
|
|
|
399
397
|
/**
|
|
400
398
|
* Copy a directory
|
|
401
399
|
*
|
|
402
|
-
* @author Jelle De Loecker
|
|
400
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
403
401
|
* @since 0.0.1
|
|
404
402
|
* @version 0.4.0
|
|
405
403
|
*
|
|
406
|
-
* @param
|
|
407
|
-
* @param
|
|
408
|
-
* @param
|
|
404
|
+
* @param {string} source The source path
|
|
405
|
+
* @param {string} target The target path
|
|
406
|
+
* @param {Function} callback The function to call when done
|
|
409
407
|
*/
|
|
410
408
|
Alchemy.setMethod(function copyDir(source, target, callback) {
|
|
411
409
|
|
|
@@ -418,14 +416,14 @@ Alchemy.setMethod(function copyDir(source, target, callback) {
|
|
|
418
416
|
/**
|
|
419
417
|
* Create a directory
|
|
420
418
|
*
|
|
421
|
-
* @author Jelle De Loecker
|
|
419
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
422
420
|
* @since 0.0.1
|
|
423
421
|
* @version 1.1.0
|
|
424
422
|
*
|
|
425
|
-
* @param
|
|
426
|
-
* @param
|
|
423
|
+
* @param {string} target The target path
|
|
424
|
+
* @param {Function} callback The function to call when done
|
|
427
425
|
*
|
|
428
|
-
* @return
|
|
426
|
+
* @return {Promise}
|
|
429
427
|
*/
|
|
430
428
|
Alchemy.setMethod(function createDir(target, callback) {
|
|
431
429
|
|
|
@@ -441,7 +439,7 @@ Alchemy.setMethod(function createDir(target, callback) {
|
|
|
441
439
|
/**
|
|
442
440
|
* Return the key:items of the first object that are no longer in the second
|
|
443
441
|
*
|
|
444
|
-
* @author Jelle De Loecker
|
|
442
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
445
443
|
* @since 0.0.1
|
|
446
444
|
* @version 1.3.22
|
|
447
445
|
*
|
|
@@ -493,7 +491,7 @@ Alchemy.setMethod(function getDifference(first, second) {
|
|
|
493
491
|
/**
|
|
494
492
|
* Return the shared items
|
|
495
493
|
*
|
|
496
|
-
* @author Jelle De Loecker
|
|
494
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
497
495
|
* @since 0.0.1
|
|
498
496
|
* @version 1.3.22
|
|
499
497
|
*
|
|
@@ -539,7 +537,7 @@ Alchemy.setMethod(function getShared(first, second) {
|
|
|
539
537
|
* Make JSON-Dry handle ObjectIDs when drying
|
|
540
538
|
* (Old class name)
|
|
541
539
|
*
|
|
542
|
-
* @author Jelle De Loecker
|
|
540
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
543
541
|
* @since 0.2.0
|
|
544
542
|
* @version 0.2.0
|
|
545
543
|
*/
|
|
@@ -551,7 +549,7 @@ JSON.registerDrier('ObjectID', function dryOI(holder, key, value) {
|
|
|
551
549
|
* Correctly un-dry ObjectIDs
|
|
552
550
|
* (Old class name)
|
|
553
551
|
*
|
|
554
|
-
* @author Jelle De Loecker
|
|
552
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
555
553
|
* @since 0.2.0
|
|
556
554
|
* @version 0.2.0
|
|
557
555
|
*/
|
|
@@ -562,7 +560,7 @@ JSON.registerUndrier('ObjectID', function undryOI(holder, key, value) {
|
|
|
562
560
|
/**
|
|
563
561
|
* Make JSON-Dry handle ObjectIds when drying
|
|
564
562
|
*
|
|
565
|
-
* @author Jelle De Loecker
|
|
563
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
566
564
|
* @since 1.3.16
|
|
567
565
|
* @version 1.3.16
|
|
568
566
|
*/
|
|
@@ -573,7 +571,7 @@ JSON.registerDrier('ObjectId', function dryOI(holder, key, value) {
|
|
|
573
571
|
/**
|
|
574
572
|
* Correctly un-dry ObjectIds
|
|
575
573
|
*
|
|
576
|
-
* @author Jelle De Loecker
|
|
574
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
577
575
|
* @since 1.3.16
|
|
578
576
|
* @version 1.3.16
|
|
579
577
|
*/
|
|
@@ -584,7 +582,7 @@ JSON.registerUndrier('ObjectId', function undryOI(holder, key, value) {
|
|
|
584
582
|
/**
|
|
585
583
|
* Monkey-patch checksum support to the ObjectId class
|
|
586
584
|
*
|
|
587
|
-
* @author Jelle De Loecker
|
|
585
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
588
586
|
* @since 1.3.16
|
|
589
587
|
* @version 1.3.16
|
|
590
588
|
*/
|
|
@@ -597,7 +595,7 @@ if (typeof mongo?.ObjectId == 'function') {
|
|
|
597
595
|
/**
|
|
598
596
|
* Create a new ObjectId
|
|
599
597
|
*
|
|
600
|
-
* @author Jelle De Loecker
|
|
598
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
601
599
|
* @since 1.3.16
|
|
602
600
|
* @version 1.3.16
|
|
603
601
|
*
|
|
@@ -614,14 +612,14 @@ Alchemy.setMethod(function ObjectId(object_id) {
|
|
|
614
612
|
*
|
|
615
613
|
* @deprecated Use Classes.Alchemy.Inode.File.getMimetype(path)
|
|
616
614
|
*
|
|
617
|
-
* @author Jelle De Loecker
|
|
615
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
618
616
|
* @since 0.2.0
|
|
619
617
|
* @version 1.3.0
|
|
620
618
|
*
|
|
621
|
-
* @param {
|
|
619
|
+
* @param {string} filepath A path to the file
|
|
622
620
|
* @param {Function} callback
|
|
623
621
|
*
|
|
624
|
-
* @return {Pledge<
|
|
622
|
+
* @return {Pledge<string>}
|
|
625
623
|
*/
|
|
626
624
|
Alchemy.setMethod(function getMimetype(filepath, callback) {
|
|
627
625
|
const pledge = Classes.Alchemy.Inode.File.getMimetype(filepath);
|
|
@@ -632,11 +630,11 @@ Alchemy.setMethod(function getMimetype(filepath, callback) {
|
|
|
632
630
|
/**
|
|
633
631
|
* Get a medhash
|
|
634
632
|
*
|
|
635
|
-
* @author Jelle De Loecker
|
|
633
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
636
634
|
* @since 1.0.7
|
|
637
635
|
* @version 1.0.7
|
|
638
636
|
*
|
|
639
|
-
* @param {
|
|
637
|
+
* @param {string} file_path A path to the file
|
|
640
638
|
* @param {Object} options
|
|
641
639
|
*/
|
|
642
640
|
Alchemy.setMethod(function getMedhash(file_path, options) {
|
|
@@ -776,11 +774,11 @@ Alchemy.setMethod(function getMedhash(file_path, options) {
|
|
|
776
774
|
/**
|
|
777
775
|
* Hash the given file_path using the given hash
|
|
778
776
|
*
|
|
779
|
-
* @author Jelle De Loecker
|
|
777
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
780
778
|
* @since 1.0.7
|
|
781
779
|
* @version 1.3.0
|
|
782
780
|
*
|
|
783
|
-
* @param {
|
|
781
|
+
* @param {string} file_path
|
|
784
782
|
* @param {Object} options
|
|
785
783
|
*/
|
|
786
784
|
Alchemy.setMethod(function hashFile(file_path, options) {
|
|
@@ -799,7 +797,7 @@ Alchemy.setMethod(function hashFile(file_path, options) {
|
|
|
799
797
|
};
|
|
800
798
|
}
|
|
801
799
|
|
|
802
|
-
hash_algorithm = options.algorithm || options.type || alchemy.settings.file_hash_algorithm || 'sha1';
|
|
800
|
+
hash_algorithm = options.algorithm || options.type || alchemy.settings.data_management.file_hash_algorithm || 'sha1';
|
|
803
801
|
digest_type = options.digest_type || 'hex';
|
|
804
802
|
|
|
805
803
|
let checksum = crypto.createHash(hash_algorithm),
|
|
@@ -836,11 +834,11 @@ Alchemy.setMethod(function hashFile(file_path, options) {
|
|
|
836
834
|
/**
|
|
837
835
|
* Get file statistics
|
|
838
836
|
*
|
|
839
|
-
* @author Jelle De Loecker
|
|
837
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
840
838
|
* @since 1.0.7
|
|
841
839
|
* @version 1.0.7
|
|
842
840
|
*
|
|
843
|
-
* @param {
|
|
841
|
+
* @param {string} path Path to stat
|
|
844
842
|
* @param {Object} options
|
|
845
843
|
*
|
|
846
844
|
* @return {Pledge}
|
|
@@ -868,11 +866,11 @@ Alchemy.setMethod(function statPath(path, options) {
|
|
|
868
866
|
/**
|
|
869
867
|
* Get basic file information
|
|
870
868
|
*
|
|
871
|
-
* @author Jelle De Loecker
|
|
869
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
872
870
|
* @since 0.0.1
|
|
873
|
-
* @version 1.
|
|
871
|
+
* @version 1.4.0
|
|
874
872
|
*
|
|
875
|
-
* @param {
|
|
873
|
+
* @param {string} filePath A path to the file
|
|
876
874
|
* @param {Object} options
|
|
877
875
|
* @param {Function} callback
|
|
878
876
|
*/
|
|
@@ -891,7 +889,7 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
|
|
|
891
889
|
|
|
892
890
|
// Use sha1 as hashing default
|
|
893
891
|
if (typeof options.hash == 'undefined' || options.hash === true) {
|
|
894
|
-
options.hash = alchemy.settings.file_hash_algorithm || 'sha1';
|
|
892
|
+
options.hash = alchemy.settings.data_management.file_hash_algorithm || 'sha1';
|
|
895
893
|
}
|
|
896
894
|
|
|
897
895
|
// Get basic file information
|
|
@@ -906,11 +904,15 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
|
|
|
906
904
|
tasks.hash = this.hashFile(filePath, options.hash);
|
|
907
905
|
}
|
|
908
906
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
907
|
+
if (options.filename) {
|
|
908
|
+
tasks.filename = options.filename;
|
|
909
|
+
} else {
|
|
910
|
+
// Get the filename
|
|
911
|
+
tasks.filename = next => {
|
|
912
|
+
let pieces = filePath.split('/');
|
|
913
|
+
next(null, pieces[pieces.length-1]);
|
|
914
|
+
};
|
|
915
|
+
}
|
|
914
916
|
|
|
915
917
|
// Get the extension
|
|
916
918
|
tasks.extension = function getExtension(next) {
|
|
@@ -970,12 +972,12 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
|
|
|
970
972
|
/**
|
|
971
973
|
* Move or copy a file
|
|
972
974
|
*
|
|
973
|
-
* @author Jelle De Loecker
|
|
975
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
974
976
|
* @since 0.0.1
|
|
975
977
|
* @version 1.0.5
|
|
976
978
|
*
|
|
977
|
-
* @param {
|
|
978
|
-
* @param {
|
|
979
|
+
* @param {string} source Origin path
|
|
980
|
+
* @param {string} target Target path
|
|
979
981
|
* @param {Function} cb
|
|
980
982
|
*/
|
|
981
983
|
function mcFile(type, source, target, cb) {
|
|
@@ -1049,12 +1051,12 @@ function mcFile(type, source, target, cb) {
|
|
|
1049
1051
|
/**
|
|
1050
1052
|
* Copy a file
|
|
1051
1053
|
*
|
|
1052
|
-
* @author Jelle De Loecker
|
|
1054
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1053
1055
|
* @since 0.0.1
|
|
1054
1056
|
* @version 0.4.0
|
|
1055
1057
|
*
|
|
1056
|
-
* @param {
|
|
1057
|
-
* @param {
|
|
1058
|
+
* @param {string} source Origin path
|
|
1059
|
+
* @param {string} target Target path
|
|
1058
1060
|
* @param {Function} cb
|
|
1059
1061
|
*/
|
|
1060
1062
|
Alchemy.setMethod(function copyFile(source, target, cb) {
|
|
@@ -1064,11 +1066,11 @@ Alchemy.setMethod(function copyFile(source, target, cb) {
|
|
|
1064
1066
|
/**
|
|
1065
1067
|
* Make an HTTP(S) request
|
|
1066
1068
|
*
|
|
1067
|
-
* @author Jelle De Loecker
|
|
1069
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1068
1070
|
* @since 0.2.0
|
|
1069
1071
|
* @version 1.1.0
|
|
1070
1072
|
*
|
|
1071
|
-
* @param {
|
|
1073
|
+
* @param {string} url The url
|
|
1072
1074
|
* @param {Object} options
|
|
1073
1075
|
* @param {Function} callback Callback
|
|
1074
1076
|
*
|
|
@@ -1102,11 +1104,11 @@ Alchemy.setMethod(function request(url, options, callback) {
|
|
|
1102
1104
|
/**
|
|
1103
1105
|
* Download a file
|
|
1104
1106
|
*
|
|
1105
|
-
* @author Jelle De Loecker
|
|
1107
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1106
1108
|
* @since 1.3.0
|
|
1107
1109
|
* @version 1.3.0
|
|
1108
1110
|
*
|
|
1109
|
-
* @param {
|
|
1111
|
+
* @param {string} url
|
|
1110
1112
|
*
|
|
1111
1113
|
* @return {Pledge<File>}
|
|
1112
1114
|
*/
|
|
@@ -1201,13 +1203,13 @@ Alchemy.setMethod(function download(url, options) {
|
|
|
1201
1203
|
/**
|
|
1202
1204
|
* Download a url to a temporary location
|
|
1203
1205
|
*
|
|
1204
|
-
* @author Jelle De Loecker
|
|
1206
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1205
1207
|
* @since 0.1.0
|
|
1206
1208
|
* @version 1.3.0
|
|
1207
1209
|
*
|
|
1208
1210
|
* @deprecated Use `download` instead
|
|
1209
1211
|
*
|
|
1210
|
-
* @param {
|
|
1212
|
+
* @param {string} url The url
|
|
1211
1213
|
* @param {Object} options
|
|
1212
1214
|
* @param {Function} callback Callback
|
|
1213
1215
|
*/
|
|
@@ -1226,12 +1228,12 @@ Alchemy.setMethod(function downloadFile(url, options, callback) {
|
|
|
1226
1228
|
/**
|
|
1227
1229
|
* Move a file
|
|
1228
1230
|
*
|
|
1229
|
-
* @author Jelle De Loecker
|
|
1231
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1230
1232
|
* @since 0.0.1
|
|
1231
1233
|
* @version 0.4.0
|
|
1232
1234
|
*
|
|
1233
|
-
* @param {
|
|
1234
|
-
* @param {
|
|
1235
|
+
* @param {string} source Origin path
|
|
1236
|
+
* @param {string} target Target path
|
|
1235
1237
|
* @param {Function} cb
|
|
1236
1238
|
*/
|
|
1237
1239
|
Alchemy.setMethod(function moveFile(source, target, cb) {
|
|
@@ -1241,15 +1243,15 @@ Alchemy.setMethod(function moveFile(source, target, cb) {
|
|
|
1241
1243
|
/**
|
|
1242
1244
|
* Return the first path that works
|
|
1243
1245
|
*
|
|
1244
|
-
* @author Jelle De Loecker
|
|
1246
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1245
1247
|
* @since 1.0.5
|
|
1246
1248
|
* @version 1.0.7
|
|
1247
1249
|
*
|
|
1248
|
-
* @param {
|
|
1249
|
-
* @param {
|
|
1250
|
+
* @param {string} name The name of the binary
|
|
1251
|
+
* @param {string} preferred_path The preferred path
|
|
1250
1252
|
* @param {Array} fallbacks Optional fallbacks
|
|
1251
1253
|
*
|
|
1252
|
-
* @return {
|
|
1254
|
+
* @return {string}
|
|
1253
1255
|
*/
|
|
1254
1256
|
Alchemy.setMethod(function findPathToBinarySync(name, preferred_path, fallbacks) {
|
|
1255
1257
|
|
|
@@ -1296,7 +1298,7 @@ var shown_list_warning = false;
|
|
|
1296
1298
|
/**
|
|
1297
1299
|
* Create a list, an array with extra methods
|
|
1298
1300
|
*
|
|
1299
|
-
* @author Jelle De Loecker
|
|
1301
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1300
1302
|
* @since 0.0.1
|
|
1301
1303
|
* @version 1.0.7
|
|
1302
1304
|
* @deprecated
|
|
@@ -1324,11 +1326,11 @@ function listToString() {
|
|
|
1324
1326
|
/**
|
|
1325
1327
|
* Get the current time in nanoseconds
|
|
1326
1328
|
*
|
|
1327
|
-
* @author Jelle De Loecker
|
|
1329
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1328
1330
|
* @since 0.0.1
|
|
1329
1331
|
* @version 0.4.0
|
|
1330
1332
|
*
|
|
1331
|
-
* @return {
|
|
1333
|
+
* @return {number}
|
|
1332
1334
|
*/
|
|
1333
1335
|
Alchemy.setMethod(function nanotime() {
|
|
1334
1336
|
var hrTime = process.hrtime();
|
|
@@ -1338,11 +1340,11 @@ Alchemy.setMethod(function nanotime() {
|
|
|
1338
1340
|
/**
|
|
1339
1341
|
* Start a very precise timer
|
|
1340
1342
|
*
|
|
1341
|
-
* @author Jelle De Loecker
|
|
1343
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1342
1344
|
* @since 0.0.1
|
|
1343
1345
|
* @version 0.4.0
|
|
1344
1346
|
*
|
|
1345
|
-
* @return {
|
|
1347
|
+
* @return {string} name
|
|
1346
1348
|
*/
|
|
1347
1349
|
Alchemy.setMethod(function time(name) {
|
|
1348
1350
|
|
|
@@ -1363,11 +1365,11 @@ Alchemy.setMethod(function time(name) {
|
|
|
1363
1365
|
* output the duration since the start to the console
|
|
1364
1366
|
* and return the duration too.
|
|
1365
1367
|
*
|
|
1366
|
-
* @author Jelle De Loecker
|
|
1368
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1367
1369
|
* @since 0.0.1
|
|
1368
1370
|
* @version 0.4.0
|
|
1369
1371
|
*
|
|
1370
|
-
* @return {
|
|
1372
|
+
* @return {string} name
|
|
1371
1373
|
*/
|
|
1372
1374
|
Alchemy.setMethod(function timeEnd(name, showNano, extra, iterated) {
|
|
1373
1375
|
|
|
@@ -1396,11 +1398,11 @@ Alchemy.setMethod(function timeEnd(name, showNano, extra, iterated) {
|
|
|
1396
1398
|
/**
|
|
1397
1399
|
* Get the total of all the registered durations for the given name
|
|
1398
1400
|
*
|
|
1399
|
-
* @author Jelle De Loecker
|
|
1401
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1400
1402
|
* @since 0.0.1
|
|
1401
1403
|
* @version 0.4.0
|
|
1402
1404
|
*
|
|
1403
|
-
* @return {
|
|
1405
|
+
* @return {string} name
|
|
1404
1406
|
*/
|
|
1405
1407
|
Alchemy.setMethod(function timeTotal(name, showNano) {
|
|
1406
1408
|
|
|
@@ -1421,11 +1423,11 @@ Alchemy.setMethod(function timeTotal(name, showNano) {
|
|
|
1421
1423
|
* (The value will be serialized once and then cached, so it should not change)
|
|
1422
1424
|
* Alias method for Hawkejs#exposeStatic()
|
|
1423
1425
|
*
|
|
1424
|
-
* @author Jelle De Loecker
|
|
1426
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1425
1427
|
* @since 1.1.0
|
|
1426
1428
|
* @version 1.1.0
|
|
1427
1429
|
*
|
|
1428
|
-
* @param {
|
|
1430
|
+
* @param {string} name
|
|
1429
1431
|
* @param {Object} value
|
|
1430
1432
|
*/
|
|
1431
1433
|
Alchemy.setMethod(function exposeStatic(name, value) {
|
|
@@ -1435,7 +1437,7 @@ Alchemy.setMethod(function exposeStatic(name, value) {
|
|
|
1435
1437
|
/**
|
|
1436
1438
|
* Expose the default static variables
|
|
1437
1439
|
*
|
|
1438
|
-
* @author Jelle De Loecker
|
|
1440
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1439
1441
|
* @since 1.1.0
|
|
1440
1442
|
* @version 1.3.1
|
|
1441
1443
|
*/
|
|
@@ -1456,12 +1458,12 @@ Alchemy.setMethod(function exposeDefaultStaticVariables() {
|
|
|
1456
1458
|
// Sort the models by their ancestor count
|
|
1457
1459
|
model_info.sortByPath(1, 'ancestors');
|
|
1458
1460
|
|
|
1459
|
-
model_code = `function inheritModel(
|
|
1460
|
-
return Classes.Hawkejs.Model.getClass(
|
|
1461
|
+
model_code = `function inheritModel(parent_model_name, child_model_name) {
|
|
1462
|
+
return Classes.Hawkejs.Model.getClass(child_model_name, true, parent_model_name);
|
|
1461
1463
|
}\n`;
|
|
1462
1464
|
|
|
1463
1465
|
for (let info of model_info) {
|
|
1464
|
-
model_code += 'inheritModel(' + JSON.stringify(info.parent) + ', ' + JSON.stringify(info.
|
|
1466
|
+
model_code += 'inheritModel(' + JSON.stringify(info.parent) + ', ' + JSON.stringify(info.model_name) + ')\n';
|
|
1465
1467
|
}
|
|
1466
1468
|
|
|
1467
1469
|
// Expose the model configuration
|
|
@@ -1484,15 +1486,17 @@ Alchemy.setMethod(function exposeDefaultStaticVariables() {
|
|
|
1484
1486
|
// Expose prefixes
|
|
1485
1487
|
hawkejs.exposeStatic('prefixes', Prefix.all());
|
|
1486
1488
|
|
|
1489
|
+
const websockets = alchemy.settings.network.use_websockets;
|
|
1490
|
+
|
|
1487
1491
|
// Are websockets enabled?
|
|
1488
|
-
if (!
|
|
1492
|
+
if (!websockets || websockets == 'optional' || websockets == 'never') {
|
|
1489
1493
|
hawkejs.exposeStatic('enable_websockets', false);
|
|
1490
1494
|
} else {
|
|
1491
1495
|
hawkejs.exposeStatic('enable_websockets', true);
|
|
1492
1496
|
}
|
|
1493
1497
|
|
|
1494
1498
|
// Expose the layout settings
|
|
1495
|
-
hawkejs.exposeStatic('alchemy_layout', alchemy.settings.layout);
|
|
1499
|
+
hawkejs.exposeStatic('alchemy_layout', alchemy.settings.frontend.ui.layout);
|
|
1496
1500
|
|
|
1497
1501
|
let app_version = alchemy.package.version;
|
|
1498
1502
|
|
|
@@ -1513,7 +1517,7 @@ Alchemy.setMethod(function exposeDefaultStaticVariables() {
|
|
|
1513
1517
|
/**
|
|
1514
1518
|
* Regenerate exposed route data
|
|
1515
1519
|
*
|
|
1516
|
-
* @author Jelle De Loecker
|
|
1520
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1517
1521
|
* @since 1.3.0
|
|
1518
1522
|
* @version 1.3.0
|
|
1519
1523
|
*/
|
|
@@ -1536,7 +1540,7 @@ Alchemy.setMethod(function exposeRouteData() {
|
|
|
1536
1540
|
* Flush the exposed route data
|
|
1537
1541
|
* (Will only regenerate if default static variables haven't been generated yet)
|
|
1538
1542
|
*
|
|
1539
|
-
* @author Jelle De Loecker
|
|
1543
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1540
1544
|
* @since 1.3.0
|
|
1541
1545
|
* @version 1.3.0
|
|
1542
1546
|
*/
|
|
@@ -1552,11 +1556,11 @@ Alchemy.setMethod(function checkExposedRouteData() {
|
|
|
1552
1556
|
/**
|
|
1553
1557
|
* Read directory contents
|
|
1554
1558
|
*
|
|
1555
|
-
* @author Jelle De Loecker
|
|
1559
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1556
1560
|
* @since 1.1.0
|
|
1557
1561
|
* @version 1.1.0
|
|
1558
1562
|
*
|
|
1559
|
-
* @param {
|
|
1563
|
+
* @param {string} path
|
|
1560
1564
|
* @param {Object} options
|
|
1561
1565
|
*
|
|
1562
1566
|
* @return {Pledge}
|
|
@@ -1629,4 +1633,22 @@ Alchemy.setMethod(function readDir(path, options) {
|
|
|
1629
1633
|
});
|
|
1630
1634
|
|
|
1631
1635
|
return pledge;
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* Connect to another alchemy instance
|
|
1640
|
+
*
|
|
1641
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1642
|
+
* @since 0.1.0
|
|
1643
|
+
* @version 0.4.0
|
|
1644
|
+
*/
|
|
1645
|
+
Alchemy.setMethod(function callServer(address, data, callback) {
|
|
1646
|
+
|
|
1647
|
+
var server = new Classes.ClientSocket();
|
|
1648
|
+
|
|
1649
|
+
server.reconnect = false;
|
|
1650
|
+
|
|
1651
|
+
server.connect(address, data, callback);
|
|
1652
|
+
|
|
1653
|
+
return server;
|
|
1632
1654
|
});
|