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,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,26 +439,49 @@ 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
|
-
* @version
|
|
444
|
+
* @version 1.3.22
|
|
447
445
|
*
|
|
448
|
-
* @param {Object}
|
|
449
|
-
* @param {Object}
|
|
446
|
+
* @param {Object|Map} first
|
|
447
|
+
* @param {Object|Map} second
|
|
450
448
|
*
|
|
451
|
-
* @return {Object}
|
|
449
|
+
* @return {Object} The items in the first item that are not in the second
|
|
452
450
|
*/
|
|
453
451
|
Alchemy.setMethod(function getDifference(first, second) {
|
|
454
452
|
|
|
455
|
-
|
|
456
|
-
|
|
453
|
+
let first_is_map = first instanceof Map,
|
|
454
|
+
second_is_map = second instanceof Map,
|
|
455
|
+
first_keys,
|
|
456
|
+
result = {},
|
|
457
|
+
first_val,
|
|
458
|
+
key,
|
|
459
|
+
val;
|
|
460
|
+
|
|
461
|
+
if (first_is_map) {
|
|
462
|
+
first_keys = [...first.keys()];
|
|
463
|
+
} else {
|
|
464
|
+
first_keys = Object.keys(first);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
for (key of first_keys) {
|
|
457
468
|
|
|
458
|
-
|
|
469
|
+
if (second_is_map) {
|
|
470
|
+
val = second.get(key);
|
|
471
|
+
} else {
|
|
472
|
+
val = second[key];
|
|
473
|
+
}
|
|
459
474
|
|
|
460
475
|
// If the key in the first item doesn't show up in the second item,
|
|
461
476
|
// add it to the result
|
|
462
|
-
if (typeof
|
|
463
|
-
|
|
477
|
+
if (typeof val === 'undefined') {
|
|
478
|
+
if (first_is_map) {
|
|
479
|
+
first_val = first.get(key);
|
|
480
|
+
} else {
|
|
481
|
+
first_val = first[key];
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
result[key] = first_val;
|
|
464
485
|
}
|
|
465
486
|
}
|
|
466
487
|
|
|
@@ -470,24 +491,42 @@ Alchemy.setMethod(function getDifference(first, second) {
|
|
|
470
491
|
/**
|
|
471
492
|
* Return the shared items
|
|
472
493
|
*
|
|
473
|
-
* @author Jelle De Loecker
|
|
494
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
474
495
|
* @since 0.0.1
|
|
475
|
-
* @version
|
|
496
|
+
* @version 1.3.22
|
|
476
497
|
*
|
|
477
|
-
* @param {Object}
|
|
478
|
-
* @param {Object}
|
|
498
|
+
* @param {Object|Map} first
|
|
499
|
+
* @param {Object|Map} second
|
|
479
500
|
*
|
|
480
501
|
* @return {Object} The items in the second item that are also in the first
|
|
481
502
|
*/
|
|
482
503
|
Alchemy.setMethod(function getShared(first, second) {
|
|
483
504
|
|
|
484
|
-
|
|
485
|
-
|
|
505
|
+
let first_is_map = first instanceof Map,
|
|
506
|
+
second_is_map = second instanceof Map,
|
|
507
|
+
first_keys,
|
|
508
|
+
result = {},
|
|
509
|
+
key,
|
|
510
|
+
val;
|
|
486
511
|
|
|
487
|
-
|
|
512
|
+
if (first_is_map) {
|
|
513
|
+
first_keys = [...first.keys()];
|
|
514
|
+
} else {
|
|
515
|
+
first_keys = Object.keys(first);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
for (key of first_keys) {
|
|
519
|
+
|
|
520
|
+
if (second_is_map) {
|
|
521
|
+
val = second.get(key);
|
|
522
|
+
} else {
|
|
523
|
+
val = second[key];
|
|
524
|
+
}
|
|
488
525
|
|
|
489
|
-
|
|
490
|
-
|
|
526
|
+
// If the key in the first item doesn't show up in the second item,
|
|
527
|
+
// add it to the result
|
|
528
|
+
if (typeof val !== 'undefined') {
|
|
529
|
+
result[key] = val;
|
|
491
530
|
}
|
|
492
531
|
}
|
|
493
532
|
|
|
@@ -498,7 +537,7 @@ Alchemy.setMethod(function getShared(first, second) {
|
|
|
498
537
|
* Make JSON-Dry handle ObjectIDs when drying
|
|
499
538
|
* (Old class name)
|
|
500
539
|
*
|
|
501
|
-
* @author Jelle De Loecker
|
|
540
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
502
541
|
* @since 0.2.0
|
|
503
542
|
* @version 0.2.0
|
|
504
543
|
*/
|
|
@@ -510,7 +549,7 @@ JSON.registerDrier('ObjectID', function dryOI(holder, key, value) {
|
|
|
510
549
|
* Correctly un-dry ObjectIDs
|
|
511
550
|
* (Old class name)
|
|
512
551
|
*
|
|
513
|
-
* @author Jelle De Loecker
|
|
552
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
514
553
|
* @since 0.2.0
|
|
515
554
|
* @version 0.2.0
|
|
516
555
|
*/
|
|
@@ -521,7 +560,7 @@ JSON.registerUndrier('ObjectID', function undryOI(holder, key, value) {
|
|
|
521
560
|
/**
|
|
522
561
|
* Make JSON-Dry handle ObjectIds when drying
|
|
523
562
|
*
|
|
524
|
-
* @author Jelle De Loecker
|
|
563
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
525
564
|
* @since 1.3.16
|
|
526
565
|
* @version 1.3.16
|
|
527
566
|
*/
|
|
@@ -532,7 +571,7 @@ JSON.registerDrier('ObjectId', function dryOI(holder, key, value) {
|
|
|
532
571
|
/**
|
|
533
572
|
* Correctly un-dry ObjectIds
|
|
534
573
|
*
|
|
535
|
-
* @author Jelle De Loecker
|
|
574
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
536
575
|
* @since 1.3.16
|
|
537
576
|
* @version 1.3.16
|
|
538
577
|
*/
|
|
@@ -543,7 +582,7 @@ JSON.registerUndrier('ObjectId', function undryOI(holder, key, value) {
|
|
|
543
582
|
/**
|
|
544
583
|
* Monkey-patch checksum support to the ObjectId class
|
|
545
584
|
*
|
|
546
|
-
* @author Jelle De Loecker
|
|
585
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
547
586
|
* @since 1.3.16
|
|
548
587
|
* @version 1.3.16
|
|
549
588
|
*/
|
|
@@ -556,7 +595,7 @@ if (typeof mongo?.ObjectId == 'function') {
|
|
|
556
595
|
/**
|
|
557
596
|
* Create a new ObjectId
|
|
558
597
|
*
|
|
559
|
-
* @author Jelle De Loecker
|
|
598
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
560
599
|
* @since 1.3.16
|
|
561
600
|
* @version 1.3.16
|
|
562
601
|
*
|
|
@@ -573,14 +612,14 @@ Alchemy.setMethod(function ObjectId(object_id) {
|
|
|
573
612
|
*
|
|
574
613
|
* @deprecated Use Classes.Alchemy.Inode.File.getMimetype(path)
|
|
575
614
|
*
|
|
576
|
-
* @author Jelle De Loecker
|
|
615
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
577
616
|
* @since 0.2.0
|
|
578
617
|
* @version 1.3.0
|
|
579
618
|
*
|
|
580
|
-
* @param {
|
|
619
|
+
* @param {string} filepath A path to the file
|
|
581
620
|
* @param {Function} callback
|
|
582
621
|
*
|
|
583
|
-
* @return {Pledge<
|
|
622
|
+
* @return {Pledge<string>}
|
|
584
623
|
*/
|
|
585
624
|
Alchemy.setMethod(function getMimetype(filepath, callback) {
|
|
586
625
|
const pledge = Classes.Alchemy.Inode.File.getMimetype(filepath);
|
|
@@ -591,11 +630,11 @@ Alchemy.setMethod(function getMimetype(filepath, callback) {
|
|
|
591
630
|
/**
|
|
592
631
|
* Get a medhash
|
|
593
632
|
*
|
|
594
|
-
* @author Jelle De Loecker
|
|
633
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
595
634
|
* @since 1.0.7
|
|
596
635
|
* @version 1.0.7
|
|
597
636
|
*
|
|
598
|
-
* @param {
|
|
637
|
+
* @param {string} file_path A path to the file
|
|
599
638
|
* @param {Object} options
|
|
600
639
|
*/
|
|
601
640
|
Alchemy.setMethod(function getMedhash(file_path, options) {
|
|
@@ -735,11 +774,11 @@ Alchemy.setMethod(function getMedhash(file_path, options) {
|
|
|
735
774
|
/**
|
|
736
775
|
* Hash the given file_path using the given hash
|
|
737
776
|
*
|
|
738
|
-
* @author Jelle De Loecker
|
|
777
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
739
778
|
* @since 1.0.7
|
|
740
779
|
* @version 1.3.0
|
|
741
780
|
*
|
|
742
|
-
* @param {
|
|
781
|
+
* @param {string} file_path
|
|
743
782
|
* @param {Object} options
|
|
744
783
|
*/
|
|
745
784
|
Alchemy.setMethod(function hashFile(file_path, options) {
|
|
@@ -758,7 +797,7 @@ Alchemy.setMethod(function hashFile(file_path, options) {
|
|
|
758
797
|
};
|
|
759
798
|
}
|
|
760
799
|
|
|
761
|
-
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';
|
|
762
801
|
digest_type = options.digest_type || 'hex';
|
|
763
802
|
|
|
764
803
|
let checksum = crypto.createHash(hash_algorithm),
|
|
@@ -795,11 +834,11 @@ Alchemy.setMethod(function hashFile(file_path, options) {
|
|
|
795
834
|
/**
|
|
796
835
|
* Get file statistics
|
|
797
836
|
*
|
|
798
|
-
* @author Jelle De Loecker
|
|
837
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
799
838
|
* @since 1.0.7
|
|
800
839
|
* @version 1.0.7
|
|
801
840
|
*
|
|
802
|
-
* @param {
|
|
841
|
+
* @param {string} path Path to stat
|
|
803
842
|
* @param {Object} options
|
|
804
843
|
*
|
|
805
844
|
* @return {Pledge}
|
|
@@ -827,11 +866,11 @@ Alchemy.setMethod(function statPath(path, options) {
|
|
|
827
866
|
/**
|
|
828
867
|
* Get basic file information
|
|
829
868
|
*
|
|
830
|
-
* @author Jelle De Loecker
|
|
869
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
831
870
|
* @since 0.0.1
|
|
832
|
-
* @version 1.
|
|
871
|
+
* @version 1.4.0
|
|
833
872
|
*
|
|
834
|
-
* @param {
|
|
873
|
+
* @param {string} filePath A path to the file
|
|
835
874
|
* @param {Object} options
|
|
836
875
|
* @param {Function} callback
|
|
837
876
|
*/
|
|
@@ -850,7 +889,7 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
|
|
|
850
889
|
|
|
851
890
|
// Use sha1 as hashing default
|
|
852
891
|
if (typeof options.hash == 'undefined' || options.hash === true) {
|
|
853
|
-
options.hash = alchemy.settings.file_hash_algorithm || 'sha1';
|
|
892
|
+
options.hash = alchemy.settings.data_management.file_hash_algorithm || 'sha1';
|
|
854
893
|
}
|
|
855
894
|
|
|
856
895
|
// Get basic file information
|
|
@@ -865,11 +904,15 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
|
|
|
865
904
|
tasks.hash = this.hashFile(filePath, options.hash);
|
|
866
905
|
}
|
|
867
906
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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
|
+
}
|
|
873
916
|
|
|
874
917
|
// Get the extension
|
|
875
918
|
tasks.extension = function getExtension(next) {
|
|
@@ -929,12 +972,12 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
|
|
|
929
972
|
/**
|
|
930
973
|
* Move or copy a file
|
|
931
974
|
*
|
|
932
|
-
* @author Jelle De Loecker
|
|
975
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
933
976
|
* @since 0.0.1
|
|
934
977
|
* @version 1.0.5
|
|
935
978
|
*
|
|
936
|
-
* @param {
|
|
937
|
-
* @param {
|
|
979
|
+
* @param {string} source Origin path
|
|
980
|
+
* @param {string} target Target path
|
|
938
981
|
* @param {Function} cb
|
|
939
982
|
*/
|
|
940
983
|
function mcFile(type, source, target, cb) {
|
|
@@ -1008,12 +1051,12 @@ function mcFile(type, source, target, cb) {
|
|
|
1008
1051
|
/**
|
|
1009
1052
|
* Copy a file
|
|
1010
1053
|
*
|
|
1011
|
-
* @author Jelle De Loecker
|
|
1054
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1012
1055
|
* @since 0.0.1
|
|
1013
1056
|
* @version 0.4.0
|
|
1014
1057
|
*
|
|
1015
|
-
* @param {
|
|
1016
|
-
* @param {
|
|
1058
|
+
* @param {string} source Origin path
|
|
1059
|
+
* @param {string} target Target path
|
|
1017
1060
|
* @param {Function} cb
|
|
1018
1061
|
*/
|
|
1019
1062
|
Alchemy.setMethod(function copyFile(source, target, cb) {
|
|
@@ -1023,11 +1066,11 @@ Alchemy.setMethod(function copyFile(source, target, cb) {
|
|
|
1023
1066
|
/**
|
|
1024
1067
|
* Make an HTTP(S) request
|
|
1025
1068
|
*
|
|
1026
|
-
* @author Jelle De Loecker
|
|
1069
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1027
1070
|
* @since 0.2.0
|
|
1028
1071
|
* @version 1.1.0
|
|
1029
1072
|
*
|
|
1030
|
-
* @param {
|
|
1073
|
+
* @param {string} url The url
|
|
1031
1074
|
* @param {Object} options
|
|
1032
1075
|
* @param {Function} callback Callback
|
|
1033
1076
|
*
|
|
@@ -1061,11 +1104,11 @@ Alchemy.setMethod(function request(url, options, callback) {
|
|
|
1061
1104
|
/**
|
|
1062
1105
|
* Download a file
|
|
1063
1106
|
*
|
|
1064
|
-
* @author Jelle De Loecker
|
|
1107
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1065
1108
|
* @since 1.3.0
|
|
1066
1109
|
* @version 1.3.0
|
|
1067
1110
|
*
|
|
1068
|
-
* @param {
|
|
1111
|
+
* @param {string} url
|
|
1069
1112
|
*
|
|
1070
1113
|
* @return {Pledge<File>}
|
|
1071
1114
|
*/
|
|
@@ -1160,13 +1203,13 @@ Alchemy.setMethod(function download(url, options) {
|
|
|
1160
1203
|
/**
|
|
1161
1204
|
* Download a url to a temporary location
|
|
1162
1205
|
*
|
|
1163
|
-
* @author Jelle De Loecker
|
|
1206
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1164
1207
|
* @since 0.1.0
|
|
1165
1208
|
* @version 1.3.0
|
|
1166
1209
|
*
|
|
1167
1210
|
* @deprecated Use `download` instead
|
|
1168
1211
|
*
|
|
1169
|
-
* @param {
|
|
1212
|
+
* @param {string} url The url
|
|
1170
1213
|
* @param {Object} options
|
|
1171
1214
|
* @param {Function} callback Callback
|
|
1172
1215
|
*/
|
|
@@ -1185,12 +1228,12 @@ Alchemy.setMethod(function downloadFile(url, options, callback) {
|
|
|
1185
1228
|
/**
|
|
1186
1229
|
* Move a file
|
|
1187
1230
|
*
|
|
1188
|
-
* @author Jelle De Loecker
|
|
1231
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1189
1232
|
* @since 0.0.1
|
|
1190
1233
|
* @version 0.4.0
|
|
1191
1234
|
*
|
|
1192
|
-
* @param {
|
|
1193
|
-
* @param {
|
|
1235
|
+
* @param {string} source Origin path
|
|
1236
|
+
* @param {string} target Target path
|
|
1194
1237
|
* @param {Function} cb
|
|
1195
1238
|
*/
|
|
1196
1239
|
Alchemy.setMethod(function moveFile(source, target, cb) {
|
|
@@ -1200,15 +1243,15 @@ Alchemy.setMethod(function moveFile(source, target, cb) {
|
|
|
1200
1243
|
/**
|
|
1201
1244
|
* Return the first path that works
|
|
1202
1245
|
*
|
|
1203
|
-
* @author Jelle De Loecker
|
|
1246
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1204
1247
|
* @since 1.0.5
|
|
1205
1248
|
* @version 1.0.7
|
|
1206
1249
|
*
|
|
1207
|
-
* @param {
|
|
1208
|
-
* @param {
|
|
1250
|
+
* @param {string} name The name of the binary
|
|
1251
|
+
* @param {string} preferred_path The preferred path
|
|
1209
1252
|
* @param {Array} fallbacks Optional fallbacks
|
|
1210
1253
|
*
|
|
1211
|
-
* @return {
|
|
1254
|
+
* @return {string}
|
|
1212
1255
|
*/
|
|
1213
1256
|
Alchemy.setMethod(function findPathToBinarySync(name, preferred_path, fallbacks) {
|
|
1214
1257
|
|
|
@@ -1255,7 +1298,7 @@ var shown_list_warning = false;
|
|
|
1255
1298
|
/**
|
|
1256
1299
|
* Create a list, an array with extra methods
|
|
1257
1300
|
*
|
|
1258
|
-
* @author Jelle De Loecker
|
|
1301
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1259
1302
|
* @since 0.0.1
|
|
1260
1303
|
* @version 1.0.7
|
|
1261
1304
|
* @deprecated
|
|
@@ -1283,11 +1326,11 @@ function listToString() {
|
|
|
1283
1326
|
/**
|
|
1284
1327
|
* Get the current time in nanoseconds
|
|
1285
1328
|
*
|
|
1286
|
-
* @author Jelle De Loecker
|
|
1329
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1287
1330
|
* @since 0.0.1
|
|
1288
1331
|
* @version 0.4.0
|
|
1289
1332
|
*
|
|
1290
|
-
* @return {
|
|
1333
|
+
* @return {number}
|
|
1291
1334
|
*/
|
|
1292
1335
|
Alchemy.setMethod(function nanotime() {
|
|
1293
1336
|
var hrTime = process.hrtime();
|
|
@@ -1297,11 +1340,11 @@ Alchemy.setMethod(function nanotime() {
|
|
|
1297
1340
|
/**
|
|
1298
1341
|
* Start a very precise timer
|
|
1299
1342
|
*
|
|
1300
|
-
* @author Jelle De Loecker
|
|
1343
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1301
1344
|
* @since 0.0.1
|
|
1302
1345
|
* @version 0.4.0
|
|
1303
1346
|
*
|
|
1304
|
-
* @return {
|
|
1347
|
+
* @return {string} name
|
|
1305
1348
|
*/
|
|
1306
1349
|
Alchemy.setMethod(function time(name) {
|
|
1307
1350
|
|
|
@@ -1322,11 +1365,11 @@ Alchemy.setMethod(function time(name) {
|
|
|
1322
1365
|
* output the duration since the start to the console
|
|
1323
1366
|
* and return the duration too.
|
|
1324
1367
|
*
|
|
1325
|
-
* @author Jelle De Loecker
|
|
1368
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1326
1369
|
* @since 0.0.1
|
|
1327
1370
|
* @version 0.4.0
|
|
1328
1371
|
*
|
|
1329
|
-
* @return {
|
|
1372
|
+
* @return {string} name
|
|
1330
1373
|
*/
|
|
1331
1374
|
Alchemy.setMethod(function timeEnd(name, showNano, extra, iterated) {
|
|
1332
1375
|
|
|
@@ -1355,11 +1398,11 @@ Alchemy.setMethod(function timeEnd(name, showNano, extra, iterated) {
|
|
|
1355
1398
|
/**
|
|
1356
1399
|
* Get the total of all the registered durations for the given name
|
|
1357
1400
|
*
|
|
1358
|
-
* @author Jelle De Loecker
|
|
1401
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1359
1402
|
* @since 0.0.1
|
|
1360
1403
|
* @version 0.4.0
|
|
1361
1404
|
*
|
|
1362
|
-
* @return {
|
|
1405
|
+
* @return {string} name
|
|
1363
1406
|
*/
|
|
1364
1407
|
Alchemy.setMethod(function timeTotal(name, showNano) {
|
|
1365
1408
|
|
|
@@ -1380,11 +1423,11 @@ Alchemy.setMethod(function timeTotal(name, showNano) {
|
|
|
1380
1423
|
* (The value will be serialized once and then cached, so it should not change)
|
|
1381
1424
|
* Alias method for Hawkejs#exposeStatic()
|
|
1382
1425
|
*
|
|
1383
|
-
* @author Jelle De Loecker
|
|
1426
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1384
1427
|
* @since 1.1.0
|
|
1385
1428
|
* @version 1.1.0
|
|
1386
1429
|
*
|
|
1387
|
-
* @param {
|
|
1430
|
+
* @param {string} name
|
|
1388
1431
|
* @param {Object} value
|
|
1389
1432
|
*/
|
|
1390
1433
|
Alchemy.setMethod(function exposeStatic(name, value) {
|
|
@@ -1394,7 +1437,7 @@ Alchemy.setMethod(function exposeStatic(name, value) {
|
|
|
1394
1437
|
/**
|
|
1395
1438
|
* Expose the default static variables
|
|
1396
1439
|
*
|
|
1397
|
-
* @author Jelle De Loecker
|
|
1440
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1398
1441
|
* @since 1.1.0
|
|
1399
1442
|
* @version 1.3.1
|
|
1400
1443
|
*/
|
|
@@ -1415,12 +1458,12 @@ Alchemy.setMethod(function exposeDefaultStaticVariables() {
|
|
|
1415
1458
|
// Sort the models by their ancestor count
|
|
1416
1459
|
model_info.sortByPath(1, 'ancestors');
|
|
1417
1460
|
|
|
1418
|
-
model_code = `function inheritModel(
|
|
1419
|
-
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);
|
|
1420
1463
|
}\n`;
|
|
1421
1464
|
|
|
1422
1465
|
for (let info of model_info) {
|
|
1423
|
-
model_code += 'inheritModel(' + JSON.stringify(info.parent) + ', ' + JSON.stringify(info.
|
|
1466
|
+
model_code += 'inheritModel(' + JSON.stringify(info.parent) + ', ' + JSON.stringify(info.model_name) + ')\n';
|
|
1424
1467
|
}
|
|
1425
1468
|
|
|
1426
1469
|
// Expose the model configuration
|
|
@@ -1443,15 +1486,17 @@ Alchemy.setMethod(function exposeDefaultStaticVariables() {
|
|
|
1443
1486
|
// Expose prefixes
|
|
1444
1487
|
hawkejs.exposeStatic('prefixes', Prefix.all());
|
|
1445
1488
|
|
|
1489
|
+
const websockets = alchemy.settings.network.use_websockets;
|
|
1490
|
+
|
|
1446
1491
|
// Are websockets enabled?
|
|
1447
|
-
if (!
|
|
1492
|
+
if (!websockets || websockets == 'optional' || websockets == 'never') {
|
|
1448
1493
|
hawkejs.exposeStatic('enable_websockets', false);
|
|
1449
1494
|
} else {
|
|
1450
1495
|
hawkejs.exposeStatic('enable_websockets', true);
|
|
1451
1496
|
}
|
|
1452
1497
|
|
|
1453
1498
|
// Expose the layout settings
|
|
1454
|
-
hawkejs.exposeStatic('alchemy_layout', alchemy.settings.layout);
|
|
1499
|
+
hawkejs.exposeStatic('alchemy_layout', alchemy.settings.frontend.ui.layout);
|
|
1455
1500
|
|
|
1456
1501
|
let app_version = alchemy.package.version;
|
|
1457
1502
|
|
|
@@ -1472,7 +1517,7 @@ Alchemy.setMethod(function exposeDefaultStaticVariables() {
|
|
|
1472
1517
|
/**
|
|
1473
1518
|
* Regenerate exposed route data
|
|
1474
1519
|
*
|
|
1475
|
-
* @author Jelle De Loecker
|
|
1520
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1476
1521
|
* @since 1.3.0
|
|
1477
1522
|
* @version 1.3.0
|
|
1478
1523
|
*/
|
|
@@ -1495,7 +1540,7 @@ Alchemy.setMethod(function exposeRouteData() {
|
|
|
1495
1540
|
* Flush the exposed route data
|
|
1496
1541
|
* (Will only regenerate if default static variables haven't been generated yet)
|
|
1497
1542
|
*
|
|
1498
|
-
* @author Jelle De Loecker
|
|
1543
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1499
1544
|
* @since 1.3.0
|
|
1500
1545
|
* @version 1.3.0
|
|
1501
1546
|
*/
|
|
@@ -1511,11 +1556,11 @@ Alchemy.setMethod(function checkExposedRouteData() {
|
|
|
1511
1556
|
/**
|
|
1512
1557
|
* Read directory contents
|
|
1513
1558
|
*
|
|
1514
|
-
* @author Jelle De Loecker
|
|
1559
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1515
1560
|
* @since 1.1.0
|
|
1516
1561
|
* @version 1.1.0
|
|
1517
1562
|
*
|
|
1518
|
-
* @param {
|
|
1563
|
+
* @param {string} path
|
|
1519
1564
|
* @param {Object} options
|
|
1520
1565
|
*
|
|
1521
1566
|
* @return {Pledge}
|
|
@@ -1588,4 +1633,22 @@ Alchemy.setMethod(function readDir(path, options) {
|
|
|
1588
1633
|
});
|
|
1589
1634
|
|
|
1590
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;
|
|
1591
1654
|
});
|