spice-js 2.5.31 → 2.5.33

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/index.js CHANGED
@@ -135,7 +135,8 @@ class Spice {
135
135
  formLimit: "1gb",
136
136
  multipart: true,
137
137
  formidable: {
138
- uploadDir: "./storage/uploads"
138
+ uploadDir: "./storage/uploads",
139
+ maxFileSize: 1024 * 1024 * 1024
139
140
  }
140
141
  }));
141
142
  app.use(convert(Validate()));
@@ -796,11 +796,21 @@ class SpiceModel {
796
796
  data = Array.of(data);
797
797
  }
798
798
 
799
+ function log() {
800
+ if (source_property === "entity") {
801
+ for (var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++) {
802
+ message[_key] = arguments[_key];
803
+ }
804
+
805
+ console.log(message);
806
+ }
807
+ }
808
+
799
809
  var classes = _.isArray(Class) ? Class : [Class];
800
810
  var ids = [];
801
811
 
802
812
  _.each(data, result => {
803
- if (_.isString(result[source_property])) {
813
+ if (_.isString(result[source_property]) && result[source_property] != "") {
804
814
  ids = _.union(ids, [result[source_property]]);
805
815
  }
806
816
  });
@@ -816,7 +826,11 @@ class SpiceModel {
816
826
  })));
817
827
 
818
828
  data = _.map(data, result => {
819
- result[store_property] = _.find(ug, g => g.id === result[source_property]) || {};
829
+ var result_found = _.find(ug, g => {
830
+ return g.id == result[source_property];
831
+ }) || {};
832
+ log(result[source_property], result_found.id);
833
+ result[store_property] = result_found;
820
834
  return result;
821
835
  });
822
836
  return original_is_array ? data : data[0];
@@ -846,7 +860,7 @@ class SpiceModel {
846
860
  value = [result[source_property]];
847
861
  }
848
862
 
849
- var items = _.filter(value, obj => _.isString(obj));
863
+ var items = _.filter(value, obj => _.isString(obj) && obj != "");
850
864
 
851
865
  ids = _.union(ids, items);
852
866
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.5.31",
3
+ "version": "2.5.33",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -23,12 +23,9 @@ module.exports = async function () {
23
23
  if (task.enabled) {
24
24
  await addTask(task);
25
25
  }
26
-
27
26
  });
28
27
  }
29
-
30
28
  resolve({})
31
-
32
29
  } catch (e) {
33
30
  reject(e);
34
31
  }
package/src/index.js CHANGED
@@ -65,6 +65,7 @@ export default class Spice {
65
65
  multipart: true,
66
66
  formidable: {
67
67
  uploadDir: "./storage/uploads",
68
+ maxFileSize: 1024 * 1024 * 1024, // 1GB
68
69
  },
69
70
  })
70
71
  );
@@ -117,8 +117,8 @@ export default class SpiceModel {
117
117
  this[i] = _.isBoolean(args.args[i])
118
118
  ? args.args[i]
119
119
  : args.args[i] == "true" ||
120
- args.args[i] == 1 ||
121
- args.args[i] == "True";
120
+ args.args[i] == 1 ||
121
+ args.args[i] == "True";
122
122
  break;
123
123
  }
124
124
  case Date:
@@ -175,17 +175,19 @@ export default class SpiceModel {
175
175
  }
176
176
 
177
177
  async propsToBeRemoved(data) {
178
-
179
178
  if (!_.isArray(data)) {
180
- data = Array.of(data)
179
+ data = Array.of(data);
181
180
  }
182
181
 
183
182
  if (this[_ctx]) {
184
- let returned = await new this[_ctx].state.process_fields().process(this[_ctx], data, this.type);
183
+ let returned = await new this[_ctx].state.process_fields().process(
184
+ this[_ctx],
185
+ data,
186
+ this.type
187
+ );
185
188
  return returned;
186
-
187
189
  }
188
- return []
190
+ return [];
189
191
  }
190
192
 
191
193
  createValidationString({ property_name, props, operation, complete }) {
@@ -705,11 +707,20 @@ export default class SpiceModel {
705
707
  data = Array.of(data);
706
708
  }
707
709
 
710
+ function log(...message) {
711
+ if (source_property === "entity") {
712
+ console.log(message);
713
+ }
714
+ }
715
+
708
716
  let classes = _.isArray(Class) ? Class : [Class];
709
717
 
710
718
  let ids = [];
711
719
  _.each(data, (result) => {
712
- if (_.isString(result[source_property])) {
720
+ if (
721
+ _.isString(result[source_property]) &&
722
+ result[source_property] != ""
723
+ ) {
713
724
  ids = _.union(ids, [result[source_property]]);
714
725
  }
715
726
  });
@@ -730,8 +741,12 @@ export default class SpiceModel {
730
741
  );
731
742
 
732
743
  data = _.map(data, (result) => {
733
- result[store_property] =
734
- _.find(ug, (g) => g.id === result[source_property]) || {};
744
+ let result_found =
745
+ _.find(ug, (g) => {
746
+ return g.id == result[source_property];
747
+ }) || {};
748
+ log(result[source_property], result_found.id);
749
+ result[store_property] = result_found;
735
750
  return result;
736
751
  });
737
752
  return original_is_array ? data : data[0];
@@ -760,7 +775,7 @@ export default class SpiceModel {
760
775
  value = [result[source_property]];
761
776
  }
762
777
 
763
- let items = _.filter(value, (obj) => _.isString(obj));
778
+ let items = _.filter(value, (obj) => _.isString(obj) && obj != "");
764
779
  ids = _.union(ids, items);
765
780
  });
766
781
 
@@ -871,11 +886,11 @@ export default class SpiceModel {
871
886
  async do_serialize(data, type, old_data, args, path_to_be_removed) {
872
887
  try {
873
888
  // run serializers
874
-
875
- if(!path_to_be_removed){
876
- path_to_be_removed =[]
889
+
890
+ if (!path_to_be_removed) {
891
+ path_to_be_removed = [];
877
892
  }
878
-
893
+
879
894
  if (this.shouldSerializerRun(args, type)) {
880
895
  for (let i of this[_serializers][type]["modifiers"]) {
881
896
  try {
@@ -902,9 +917,9 @@ export default class SpiceModel {
902
917
  ) {
903
918
  defaults[i] = _.isFunction(this.props[i].defaults[type])
904
919
  ? this.props[i].defaults[type]({
905
- old_data: data,
906
- new_data: old_data,
907
- })
920
+ old_data: data,
921
+ new_data: old_data,
922
+ })
908
923
  : this.props[i].defaults[type];
909
924
  }
910
925
  }
@@ -915,7 +930,6 @@ export default class SpiceModel {
915
930
 
916
931
  // apply cleaners
917
932
  if (type == "read") {
918
-
919
933
  let props_to_clean = ["deleted", "type", ...path_to_be_removed];
920
934
  for (let i in this.props) {
921
935
  if (this.props[i].hide) {