alchemymvc 1.2.1 → 1.2.4
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/lib/app/helper_component/paginate_component.js +43 -98
- package/lib/app/helper_controller/conduit.js +11 -9
- package/lib/app/helper_datasource/00-nosql_datasource.js +5 -1
- package/lib/app/helper_field/05-string_field.js +1 -3
- package/lib/app/helper_field/belongsto_field.js +1 -20
- package/lib/app/{field → helper_field}/password_field.js +10 -8
- package/lib/app/helper_field/schema_field.js +20 -12
- package/lib/app/helper_model/criteria.js +42 -15
- package/lib/app/helper_model/data_provider.js +92 -0
- package/lib/app/helper_model/document.js +42 -4
- package/lib/app/helper_model/document_list.js +25 -2
- package/lib/app/helper_model/field_config.js +104 -3
- package/lib/app/helper_model/field_set.js +27 -1
- package/lib/app/helper_model/model.js +19 -3
- package/lib/app/helper_model/remote_data_provider.js +35 -0
- package/lib/bootstrap.js +16 -0
- package/lib/class/document.js +55 -13
- package/lib/class/document_list.js +33 -1
- package/lib/class/element.js +17 -3
- package/lib/class/field.js +7 -2
- package/lib/class/model.js +10 -14
- package/lib/class/schema.js +13 -4
- package/lib/class/schema_client.js +31 -0
- package/lib/core/base.js +54 -8
- package/lib/core/client_alchemy.js +27 -0
- package/lib/core/client_base.js +13 -3
- package/lib/init/alchemy.js +38 -8
- package/lib/init/functions.js +1 -1
- package/lib/init/load_functions.js +8 -3
- package/lib/init/requirements.js +1 -1
- package/package.json +3 -3
package/lib/class/schema.js
CHANGED
|
@@ -287,7 +287,7 @@ Schema.setMethod(function getAssociationArguments(locality, alias, modelName, op
|
|
|
287
287
|
*
|
|
288
288
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
289
289
|
* @since 0.2.0
|
|
290
|
-
* @version 1.
|
|
290
|
+
* @version 1.2.4
|
|
291
291
|
*
|
|
292
292
|
* @param {String} alias
|
|
293
293
|
* @param {String} modelname
|
|
@@ -369,13 +369,21 @@ Schema.setMethod(function addAssociation(type, alias, modelName, options) {
|
|
|
369
369
|
if (locality == 'internal') {
|
|
370
370
|
|
|
371
371
|
if (!this.getField(options.localKey)) {
|
|
372
|
-
|
|
372
|
+
let field_options = Object.assign({}, args);
|
|
373
|
+
|
|
374
|
+
if (options && options.field_options) {
|
|
375
|
+
Object.assign(field_options, options.field_options);
|
|
376
|
+
field_options.field_options = undefined;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
this.addField(options.localKey, type, field_options);
|
|
373
380
|
|
|
374
381
|
if (constructor) {
|
|
375
382
|
doc_class.setFieldGetter(options.localKey);
|
|
376
383
|
}
|
|
377
384
|
|
|
378
|
-
|
|
385
|
+
// Also set is_private fields on the server-side client_doc!
|
|
386
|
+
if (client_doc) {
|
|
379
387
|
client_doc.setFieldGetter(options.localKey, null, null, false);
|
|
380
388
|
}
|
|
381
389
|
}
|
|
@@ -389,7 +397,8 @@ Schema.setMethod(function addAssociation(type, alias, modelName, options) {
|
|
|
389
397
|
if (constructor) {
|
|
390
398
|
doc_class.setAliasGetter(alias);
|
|
391
399
|
|
|
392
|
-
|
|
400
|
+
// Also set is_private fields on the server-side client_doc!
|
|
401
|
+
if (client_doc) {
|
|
393
402
|
client_doc.setAliasGetter(alias);
|
|
394
403
|
}
|
|
395
404
|
}
|
|
@@ -414,6 +414,37 @@ Schema.setMethod(function toHawkejs(wm) {
|
|
|
414
414
|
return result;
|
|
415
415
|
});
|
|
416
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Get all the private fields
|
|
419
|
+
*
|
|
420
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
421
|
+
* @since 1.2.4
|
|
422
|
+
* @version 1.2.4
|
|
423
|
+
*
|
|
424
|
+
* @return {Array}
|
|
425
|
+
*/
|
|
426
|
+
Schema.setMethod(function getPrivateFields() {
|
|
427
|
+
|
|
428
|
+
let result = [],
|
|
429
|
+
field,
|
|
430
|
+
i;
|
|
431
|
+
|
|
432
|
+
// Get the sorted fields
|
|
433
|
+
let fields = this.getSorted(false);
|
|
434
|
+
|
|
435
|
+
for (i = 0; i < fields.length; i++) {
|
|
436
|
+
field = fields[i];
|
|
437
|
+
|
|
438
|
+
if (field.is_private) {
|
|
439
|
+
field = Object.create(field);
|
|
440
|
+
field.schema = null;
|
|
441
|
+
result.push(field);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return result;
|
|
446
|
+
});
|
|
447
|
+
|
|
417
448
|
/**
|
|
418
449
|
* Add a field to this schema
|
|
419
450
|
*
|
package/lib/core/base.js
CHANGED
|
@@ -345,7 +345,7 @@ Base.setStatic('starts_new_group', false);
|
|
|
345
345
|
*
|
|
346
346
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
347
347
|
* @since 1.1.8
|
|
348
|
-
* @version 1.
|
|
348
|
+
* @version 1.2.4
|
|
349
349
|
*
|
|
350
350
|
* @type {Conduit}
|
|
351
351
|
*/
|
|
@@ -355,16 +355,20 @@ Base.setProperty(function conduit() {
|
|
|
355
355
|
return this[CONDUIT];
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
let renderer
|
|
358
|
+
let renderer,
|
|
359
359
|
result;
|
|
360
|
+
|
|
361
|
+
if (Blast.isBrowser || !(this instanceof Classes.Alchemy.Controller)) {
|
|
362
|
+
renderer = this.renderer || this.view || this.hawkejs_view;
|
|
363
|
+
}
|
|
360
364
|
|
|
361
|
-
if (renderer
|
|
365
|
+
if (renderer?.conduit) {
|
|
362
366
|
result = renderer.conduit;
|
|
363
|
-
} else if (renderer
|
|
367
|
+
} else if (renderer?.root_renderer?.conduit) {
|
|
364
368
|
result = renderer.root_renderer.conduit;
|
|
365
369
|
}
|
|
366
370
|
|
|
367
|
-
if (!conduit && renderer
|
|
371
|
+
if (!conduit && renderer?.server_var) {
|
|
368
372
|
result = renderer.server_var('conduit');
|
|
369
373
|
}
|
|
370
374
|
|
|
@@ -416,19 +420,28 @@ Base.setMethod(function getClassPathAfter(after) {
|
|
|
416
420
|
/**
|
|
417
421
|
* Call a method if it exists or do the callback
|
|
418
422
|
*
|
|
419
|
-
* @author Jelle De Loecker <jelle@
|
|
423
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
420
424
|
* @since 1.0.0
|
|
421
|
-
* @version 1.
|
|
425
|
+
* @version 1.2.2
|
|
422
426
|
*/
|
|
423
427
|
Base.setMethod(function callOrNext(name, args, next) {
|
|
424
428
|
|
|
429
|
+
if (arguments.length == 2 && typeof args == 'function') {
|
|
430
|
+
next = args;
|
|
431
|
+
args = [];
|
|
432
|
+
}
|
|
433
|
+
|
|
425
434
|
if (typeof this[name] == 'function') {
|
|
426
435
|
|
|
427
436
|
if (next) {
|
|
428
437
|
args.push(next);
|
|
429
438
|
}
|
|
430
439
|
|
|
431
|
-
|
|
440
|
+
try {
|
|
441
|
+
this[name].apply(this, args);
|
|
442
|
+
} catch (err) {
|
|
443
|
+
next(err);
|
|
444
|
+
}
|
|
432
445
|
} else if (next) {
|
|
433
446
|
next();
|
|
434
447
|
|
|
@@ -439,6 +452,39 @@ Base.setMethod(function callOrNext(name, args, next) {
|
|
|
439
452
|
|
|
440
453
|
// PROTOBLAST START CUT
|
|
441
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Get the client implementation of this class
|
|
457
|
+
*
|
|
458
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
459
|
+
* @since 1.2.4
|
|
460
|
+
* @version 1.2.4
|
|
461
|
+
*
|
|
462
|
+
* @return {Function}
|
|
463
|
+
*/
|
|
464
|
+
Base.setStatic(function getClientClass() {
|
|
465
|
+
|
|
466
|
+
if (!this.namespace) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// It's already a client-side class!
|
|
471
|
+
if (this.namespace.indexOf('.Client.')) {
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Add the Client part of the namespace
|
|
476
|
+
let namespace = this.namespace.replace('.Alchemy.', '.Alchemy.Client.');
|
|
477
|
+
|
|
478
|
+
// Get the actual namespace object
|
|
479
|
+
namespace = Function.getNamespace(namespace);
|
|
480
|
+
|
|
481
|
+
if (!namespace) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return namespace[this.name];
|
|
486
|
+
});
|
|
487
|
+
|
|
442
488
|
/**
|
|
443
489
|
* Attach a conduit to a certain instance
|
|
444
490
|
*
|
|
@@ -24,6 +24,17 @@ var Alchemy = Function.inherits('Alchemy.Client.Base', function Alchemy() {
|
|
|
24
24
|
this.sent_subscriptions = [];
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* A reference to the main hawkejs instance
|
|
29
|
+
*
|
|
30
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
31
|
+
* @since 1.2.3
|
|
32
|
+
* @version 1.2.3
|
|
33
|
+
*/
|
|
34
|
+
Alchemy.setProperty(function hawkejs() {
|
|
35
|
+
return window.hawkejs;
|
|
36
|
+
});
|
|
37
|
+
|
|
27
38
|
/**
|
|
28
39
|
* Called in the onScene static method of the Alchemy helper
|
|
29
40
|
*
|
|
@@ -1080,4 +1091,20 @@ Alchemy.setMethod(function syncDataWithServer() {
|
|
|
1080
1091
|
Alchemy.setMethod(function createSchema(parent) {
|
|
1081
1092
|
let schema = new Classes.Alchemy.Client.Schema(parent);
|
|
1082
1093
|
return schema;
|
|
1094
|
+
});
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Get a client-side model
|
|
1098
|
+
*
|
|
1099
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1100
|
+
* @since 1.2.4
|
|
1101
|
+
* @version 1.2.4
|
|
1102
|
+
*
|
|
1103
|
+
* @param {String} name
|
|
1104
|
+
* @param {Object} options
|
|
1105
|
+
*
|
|
1106
|
+
* @return {Model}
|
|
1107
|
+
*/
|
|
1108
|
+
Alchemy.setMethod(function getClientModel(name, init, options) {
|
|
1109
|
+
return Classes.Alchemy.Client.Base.prototype.getModel.call(this, name, init, options);
|
|
1083
1110
|
});
|
package/lib/core/client_base.js
CHANGED
|
@@ -233,7 +233,7 @@ ClientBase.setStatic(function mapEventToMethod(event_name, method_name) {
|
|
|
233
233
|
*
|
|
234
234
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
235
235
|
* @since 1.0.0
|
|
236
|
-
* @version 1.
|
|
236
|
+
* @version 1.2.4
|
|
237
237
|
*
|
|
238
238
|
* @param {String} name
|
|
239
239
|
* @param {Object} options
|
|
@@ -255,9 +255,19 @@ ClientBase.setMethod(function getModel(name, init, options) {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
if (Blast.isBrowser) {
|
|
258
|
-
|
|
258
|
+
|
|
259
|
+
if (name == '') {
|
|
260
|
+
constructor = Hawkejs.Model;
|
|
261
|
+
} else {
|
|
262
|
+
constructor = Hawkejs.Model.getClass(name, false);
|
|
263
|
+
}
|
|
259
264
|
} else {
|
|
260
|
-
|
|
265
|
+
|
|
266
|
+
if (name == '') {
|
|
267
|
+
constructor = Blast.Classes.Hawkejs.Model;
|
|
268
|
+
} else {
|
|
269
|
+
constructor = Blast.Classes.Hawkejs.Model.getClass(name);
|
|
270
|
+
}
|
|
261
271
|
}
|
|
262
272
|
|
|
263
273
|
if (!constructor) {
|
package/lib/init/alchemy.js
CHANGED
|
@@ -751,7 +751,6 @@ Alchemy.setMethod(function use(module_name, register_as, options) {
|
|
|
751
751
|
return module;
|
|
752
752
|
});
|
|
753
753
|
|
|
754
|
-
|
|
755
754
|
/**
|
|
756
755
|
* Look for a module by traversing the filesystem
|
|
757
756
|
*
|
|
@@ -878,7 +877,7 @@ Alchemy.setMethod(function searchModule(startPath, moduleName, recurse) {
|
|
|
878
877
|
*
|
|
879
878
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
880
879
|
* @since 0.0.1
|
|
881
|
-
* @version 1.
|
|
880
|
+
* @version 1.2.2
|
|
882
881
|
*
|
|
883
882
|
* @param {String} moduleName
|
|
884
883
|
* @param {Object} options
|
|
@@ -949,20 +948,26 @@ Alchemy.setMethod(function findModule(moduleName, options) {
|
|
|
949
948
|
// If the module_path was found, actually require the module
|
|
950
949
|
if (module_path) {
|
|
951
950
|
|
|
952
|
-
// Modules are required by default
|
|
953
|
-
if (options.require) {
|
|
954
|
-
module = require(module_path);
|
|
955
|
-
}
|
|
956
|
-
|
|
957
951
|
// Get the package.json file
|
|
958
952
|
if (~module_path.indexOf(libpath.sep)) {
|
|
959
953
|
internal = false;
|
|
960
954
|
|
|
955
|
+
let last_piece = moduleName.split(libpath.sep).last(),
|
|
956
|
+
package_path;
|
|
957
|
+
|
|
961
958
|
let module_dir = libpath.dirname(module_path);
|
|
962
959
|
result.module_dir = module_dir;
|
|
963
960
|
|
|
961
|
+
// If the path doesn't end with the module name, look for it
|
|
962
|
+
if (!module_path.endsWith(last_piece)) {
|
|
963
|
+
package_path = module_path.beforeLast(last_piece) + last_piece;
|
|
964
|
+
package_path = libpath.resolve(package_path, 'package.json');
|
|
965
|
+
} else {
|
|
966
|
+
package_path = libpath.resolve(module_dir, 'package.json');
|
|
967
|
+
}
|
|
968
|
+
|
|
964
969
|
try {
|
|
965
|
-
package_json = require(
|
|
970
|
+
package_json = require(package_path);
|
|
966
971
|
} catch (err) {
|
|
967
972
|
package_json = false;
|
|
968
973
|
}
|
|
@@ -972,6 +977,15 @@ Alchemy.setMethod(function findModule(moduleName, options) {
|
|
|
972
977
|
version: process.versions.node
|
|
973
978
|
};
|
|
974
979
|
}
|
|
980
|
+
|
|
981
|
+
// Modules are required by default
|
|
982
|
+
if (options.require) {
|
|
983
|
+
if (package_json && package_json.type == 'module' && !(package_json.main && package_json.module)) {
|
|
984
|
+
module = doImport(module_path)
|
|
985
|
+
} else {
|
|
986
|
+
module = require(module_path);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
975
989
|
}
|
|
976
990
|
|
|
977
991
|
if (!options.require || module) {
|
|
@@ -1735,6 +1749,22 @@ Alchemy.setMethod(function createSchema(parent) {
|
|
|
1735
1749
|
return schema;
|
|
1736
1750
|
});
|
|
1737
1751
|
|
|
1752
|
+
/**
|
|
1753
|
+
* Get a client-side model
|
|
1754
|
+
*
|
|
1755
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1756
|
+
* @since 1.2.4
|
|
1757
|
+
* @version 1.2.4
|
|
1758
|
+
*
|
|
1759
|
+
* @param {String} name
|
|
1760
|
+
* @param {Object} options
|
|
1761
|
+
*
|
|
1762
|
+
* @return {Model}
|
|
1763
|
+
*/
|
|
1764
|
+
Alchemy.setMethod(function getClientModel(name, init, options) {
|
|
1765
|
+
return Classes.Alchemy.Client.Base.prototype.getModel.call(this, name, init, options);
|
|
1766
|
+
});
|
|
1767
|
+
|
|
1738
1768
|
/**
|
|
1739
1769
|
* The alchemy global, where everything will be stored
|
|
1740
1770
|
*
|
package/lib/init/functions.js
CHANGED
|
@@ -1082,7 +1082,7 @@ Alchemy.setMethod(function downloadFile(url, options, callback) {
|
|
|
1082
1082
|
file = fs.createWriteStream(filepath);
|
|
1083
1083
|
|
|
1084
1084
|
if (res.statusCode == 404) {
|
|
1085
|
-
err = new Error('Path does not exist');
|
|
1085
|
+
err = new Error('Path "' + url + '" does not exist');
|
|
1086
1086
|
err.number = 404;
|
|
1087
1087
|
|
|
1088
1088
|
return callback(err);
|
|
@@ -813,7 +813,7 @@ Alchemy.setMethod(function startPlugins(names) {
|
|
|
813
813
|
*
|
|
814
814
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
815
815
|
* @since 0.0.1
|
|
816
|
-
* @version 1.
|
|
816
|
+
* @version 1.2.2
|
|
817
817
|
*
|
|
818
818
|
* @param {String|Array} names
|
|
819
819
|
* @param {Boolean} attempt_require
|
|
@@ -844,8 +844,13 @@ Alchemy.setMethod(function requirePlugin(names, attempt_require) {
|
|
|
844
844
|
temp = alchemy.usePlugin(name);
|
|
845
845
|
|
|
846
846
|
if (temp) {
|
|
847
|
-
|
|
848
|
-
|
|
847
|
+
let plugin_stage = alchemy.sputnik.get('plugins');
|
|
848
|
+
|
|
849
|
+
if (!plugin_stage || plugin_stage.started) {
|
|
850
|
+
// If the plugin stage has already started,
|
|
851
|
+
// manually start this plugin now
|
|
852
|
+
alchemy.startPlugins(name);
|
|
853
|
+
}
|
|
849
854
|
continue;
|
|
850
855
|
}
|
|
851
856
|
}
|
package/lib/init/requirements.js
CHANGED
|
@@ -50,7 +50,7 @@ alchemy.use('less', 'less');
|
|
|
50
50
|
* @link https://npmjs.org/package/hawkejs
|
|
51
51
|
*/
|
|
52
52
|
alchemy.use('hawkejs', 'hawkejs');
|
|
53
|
-
alchemy.hawkejs =
|
|
53
|
+
alchemy.hawkejs = Classes.Hawkejs.Hawkejs.getInstance();
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* The function to detect when everything is too busy
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemymvc",
|
|
3
3
|
"description": "MVC framework for Node.js",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"author": "Jelle De Loecker <jelle@elevenways.be>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"alchemy",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"chokidar" : "~3.5.3",
|
|
23
23
|
"formidable" : "~1.2.2",
|
|
24
24
|
"graceful-fs" : "~4.2.9",
|
|
25
|
-
"hawkejs" : "~2.2.
|
|
25
|
+
"hawkejs" : "~2.2.10",
|
|
26
26
|
"jsondiffpatch" : "~0.4.1",
|
|
27
27
|
"mime" : "~3.0.0",
|
|
28
28
|
"minimist" : "~1.2.5",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"mongodb" : "~3.6.6",
|
|
32
32
|
"ncp" : "~2.0.0",
|
|
33
33
|
"postcss" : "~8.4.6",
|
|
34
|
-
"protoblast" : "~0.7.
|
|
34
|
+
"protoblast" : "~0.7.21",
|
|
35
35
|
"semver" : "~7.3.5",
|
|
36
36
|
"socket.io" : "~2.4.0",
|
|
37
37
|
"@11ways/socket.io-stream" : "~0.9.2",
|