spice-js 2.5.3 → 2.5.7
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/build/bootstrap/database.js +1 -1
- package/build/bootstrap/event.js +4 -3
- package/build/bootstrap/map.js +36 -0
- package/build/bootstrap/tasks.js +8 -7
- package/build/docs/generator.js +9 -15
- package/build/events/Event.js +3 -5
- package/build/events/providers/EventDebugger.js +4 -6
- package/build/events/providers/SocketEventDriver.js +8 -19
- package/build/events/providers/SpiceEventDriver.js +5 -7
- package/build/index.js +44 -106
- package/build/loaders/index.js +16 -5
- package/build/mail/Mail.js +8 -11
- package/build/mail/providers/Debug.js +12 -9
- package/build/mail/providers/File.js +14 -11
- package/build/models/SpiceModel.js +28 -28
- package/build/storage/Storage.js +6 -5
- package/build/storage/providers/Debug.js +12 -9
- package/build/storage/providers/Local.js +8 -7
- package/build/utility/Crypt.js +1 -3
- package/build/utility/DataType.js +1 -3
- package/build/utility/MapType.js +1 -3
- package/build/utility/RestHelper.js +11 -10
- package/build/utility/Serializer.js +1 -3
- package/build/utility/index.js +1 -3
- package/build/val/Utility.js +3 -3
- package/gulpfile.js +29 -26
- package/package.json +2 -1
- package/src/bootstrap/event.js +3 -4
- package/src/bootstrap/map.js +18 -0
- package/src/events/providers/SocketEventDriver.js +4 -4
- package/src/events/providers/SpiceEventDriver.js +1 -1
- package/src/index.js +6 -0
- package/src/loaders/index.js +14 -4
- package/src/models/SpiceModel.js +26 -9
package/src/loaders/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
|
|
5
|
-
let ordered_modules = ["
|
|
5
|
+
let ordered_modules = ["map", "logger", "error", "database"];
|
|
6
|
+
let last_modules = ["views", "routes"];
|
|
6
7
|
export async function load() {
|
|
7
8
|
try {
|
|
8
9
|
/* console.log('loading from array')*/
|
|
@@ -10,14 +11,14 @@ export async function load() {
|
|
|
10
11
|
let bootstrap_path = path.resolve(
|
|
11
12
|
path.join(spice.module_root_path, "/bootstrap")
|
|
12
13
|
);
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
let app_bootstrap_path = path.resolve(
|
|
15
16
|
path.join(spice.root_path, "/bootstrap")
|
|
16
17
|
);
|
|
17
18
|
|
|
18
19
|
/* console.log('MODULE Bootstrap directory', bootstrap_path);
|
|
19
20
|
console.log('APP Bootstrap directory', app_bootstrap_path); */
|
|
20
|
-
|
|
21
|
+
console.log("Loading Ordered Files", ordered_modules);
|
|
21
22
|
for (let file of ordered_modules) {
|
|
22
23
|
let mod = require(path.join(bootstrap_path, file));
|
|
23
24
|
if (_.isFunction(mod)) {
|
|
@@ -33,7 +34,8 @@ export async function load() {
|
|
|
33
34
|
console.log("Loading:", file);
|
|
34
35
|
if (
|
|
35
36
|
file != "index.js" &&
|
|
36
|
-
!_.includes(ordered_modules, file.split(".")[0])
|
|
37
|
+
!_.includes(ordered_modules, file.split(".")[0]) &&
|
|
38
|
+
!_.includes(last_modules, file.split(".")[0])
|
|
37
39
|
) {
|
|
38
40
|
let mod = require(path.join(loadder_path, file.split(".")[0]));
|
|
39
41
|
if (_.isFunction(mod)) {
|
|
@@ -42,6 +44,14 @@ export async function load() {
|
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
47
|
+
|
|
48
|
+
for (let file of last_modules) {
|
|
49
|
+
let mod = require(path.join(bootstrap_path, file));
|
|
50
|
+
if (_.isFunction(mod)) {
|
|
51
|
+
await mod();
|
|
52
|
+
}
|
|
53
|
+
console.log("loaded", file);
|
|
54
|
+
}
|
|
45
55
|
} catch (e) {
|
|
46
56
|
console.log(e.stack);
|
|
47
57
|
}
|
package/src/models/SpiceModel.js
CHANGED
|
@@ -242,7 +242,10 @@ export default class SpiceModel {
|
|
|
242
242
|
return _.join(returnVal, "|");
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
getValidationRules(
|
|
245
|
+
getValidationRules(
|
|
246
|
+
method = "POST",
|
|
247
|
+
{ complete = false, pick = [], omit = [] } = {}
|
|
248
|
+
) {
|
|
246
249
|
let rules = {};
|
|
247
250
|
let filters = {};
|
|
248
251
|
let working_properties = this.props;
|
|
@@ -743,14 +746,17 @@ export default class SpiceModel {
|
|
|
743
746
|
case "string": {
|
|
744
747
|
this.addModifier({
|
|
745
748
|
when: properties[i].map.when || "read",
|
|
746
|
-
execute: async (data) =>
|
|
747
|
-
await this.mapToObject(
|
|
749
|
+
execute: async (data) => {
|
|
750
|
+
return await this.mapToObject(
|
|
748
751
|
data,
|
|
749
|
-
properties[i].map.reference
|
|
752
|
+
_.isString(properties[i].map.reference)
|
|
753
|
+
? spice.models[properties[i].map.reference]
|
|
754
|
+
: properties[i].map.reference,
|
|
750
755
|
i,
|
|
751
756
|
properties[i].map.destination || i,
|
|
752
757
|
properties[i]
|
|
753
|
-
)
|
|
758
|
+
);
|
|
759
|
+
},
|
|
754
760
|
});
|
|
755
761
|
break;
|
|
756
762
|
}
|
|
@@ -758,14 +764,25 @@ export default class SpiceModel {
|
|
|
758
764
|
case "array": {
|
|
759
765
|
this.addModifier({
|
|
760
766
|
when: properties[i].map.when || "read",
|
|
761
|
-
execute: async (data) =>
|
|
762
|
-
|
|
767
|
+
execute: async (data) => {
|
|
768
|
+
console.log(
|
|
769
|
+
_.isString(properties[i].map.reference),
|
|
770
|
+
_.isString(properties[i].map.reference)
|
|
771
|
+
? spice.models[properties[i].map.reference]
|
|
772
|
+
: properties[i].map.reference,
|
|
773
|
+
spice.models,
|
|
774
|
+
properties[i].map.reference
|
|
775
|
+
);
|
|
776
|
+
return await this.mapToObjectArray(
|
|
763
777
|
data,
|
|
764
|
-
properties[i].map.reference
|
|
778
|
+
_.isString(properties[i].map.reference)
|
|
779
|
+
? spice.models[properties[i].map.reference]
|
|
780
|
+
: properties[i].map.reference,
|
|
765
781
|
i,
|
|
766
782
|
properties[i].map.destination || i,
|
|
767
783
|
properties[i]
|
|
768
|
-
)
|
|
784
|
+
);
|
|
785
|
+
},
|
|
769
786
|
});
|
|
770
787
|
break;
|
|
771
788
|
}
|