@sdflc/backend-helpers 1.0.133 → 1.0.134
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/BaseCore.js +23 -11
- package/build/esm/BaseCore.js +23 -11
- package/package.json +1 -1
package/build/BaseCore.js
CHANGED
|
@@ -743,7 +743,7 @@ class BaseCore {
|
|
|
743
743
|
action: async (args, opt) => {
|
|
744
744
|
const object = await this.beforeList(args, opt);
|
|
745
745
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
746
|
-
return object;
|
|
746
|
+
return object.toJS();
|
|
747
747
|
}
|
|
748
748
|
const items = await this.getGateway()?.list(object);
|
|
749
749
|
const result = await this.afterList(items, opt);
|
|
@@ -773,15 +773,20 @@ class BaseCore {
|
|
|
773
773
|
action: async (args, opt) => {
|
|
774
774
|
const args2use = await this.beforeGet(args, opt);
|
|
775
775
|
if ((0, api_helpers_1.isOpResult)(args2use)) {
|
|
776
|
-
return args2use;
|
|
776
|
+
return args2use.toJS();
|
|
777
777
|
}
|
|
778
778
|
if (args2use?.id == null) {
|
|
779
779
|
return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, '', []);
|
|
780
780
|
}
|
|
781
781
|
const item = await this.getGateway()?.get(args2use.id);
|
|
782
|
+
if (this.getGateway()?.getConfig()?.hasRemovedAt === true) {
|
|
783
|
+
if (!item || item.removedAt) {
|
|
784
|
+
return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, `${this.config.name} not found`, []);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
782
787
|
const result = await this.afterGet(item, opt);
|
|
783
788
|
if (!result) {
|
|
784
|
-
return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND,
|
|
789
|
+
return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, `${this.config.name} not found`, []);
|
|
785
790
|
}
|
|
786
791
|
return this.success([result]);
|
|
787
792
|
},
|
|
@@ -809,12 +814,19 @@ class BaseCore {
|
|
|
809
814
|
action: async (args, opt) => {
|
|
810
815
|
const args2use = await this.beforeGetMany(args, opt);
|
|
811
816
|
if ((0, api_helpers_1.isOpResult)(args2use)) {
|
|
812
|
-
return args2use;
|
|
817
|
+
return args2use.toJS();
|
|
813
818
|
}
|
|
814
819
|
if (!Array.isArray(args2use?.ids)) {
|
|
815
820
|
return this.failure(api_helpers_1.OP_RESULT_CODES.NOT_FOUND, 'Expected ids array but received invalid input', []);
|
|
816
821
|
}
|
|
817
822
|
const items = await this.getGateway()?.getMany(args2use.ids);
|
|
823
|
+
if (this.getGateway()?.getConfig()?.hasRemovedAt === true) {
|
|
824
|
+
items.forEach((item, index) => {
|
|
825
|
+
if (!item || item.removedAt) {
|
|
826
|
+
items[index] = null;
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
}
|
|
818
830
|
const result = await this.afterGetMany(items, opt);
|
|
819
831
|
return this.success(result);
|
|
820
832
|
},
|
|
@@ -861,7 +873,7 @@ class BaseCore {
|
|
|
861
873
|
}
|
|
862
874
|
const object = await this.beforeCreate(params, opt);
|
|
863
875
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
864
|
-
return object;
|
|
876
|
+
return object.toJS();
|
|
865
877
|
}
|
|
866
878
|
const items = await this.getGateway()?.create(object);
|
|
867
879
|
const result = await this.afterCreate(items, opt);
|
|
@@ -889,7 +901,7 @@ class BaseCore {
|
|
|
889
901
|
const { params } = args || {};
|
|
890
902
|
const objects = await this.beforeCreateMany(params, opt);
|
|
891
903
|
if ((0, api_helpers_1.isOpResult)(objects)) {
|
|
892
|
-
return objects;
|
|
904
|
+
return objects.toJS();
|
|
893
905
|
}
|
|
894
906
|
const items = await this.getGateway()?.create(objects);
|
|
895
907
|
const result = await this.afterCreateMany(items, opt);
|
|
@@ -920,7 +932,7 @@ class BaseCore {
|
|
|
920
932
|
const { where, params } = args || {};
|
|
921
933
|
const object = await this.beforeUpdate(params, opt);
|
|
922
934
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
923
|
-
return object;
|
|
935
|
+
return object.toJS();
|
|
924
936
|
}
|
|
925
937
|
const items = await this.getGateway()?.update(where, object);
|
|
926
938
|
const result = await this.afterUpdate(items, opt);
|
|
@@ -948,7 +960,7 @@ class BaseCore {
|
|
|
948
960
|
const { params } = args || {};
|
|
949
961
|
const object = await this.beforeUpdateMany(params, opt);
|
|
950
962
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
951
|
-
return object;
|
|
963
|
+
return object.toJS();
|
|
952
964
|
}
|
|
953
965
|
const items = await this.getGateway()?.updateMany(object);
|
|
954
966
|
const result = await this.afterUpdateMany(items, opt);
|
|
@@ -977,7 +989,7 @@ class BaseCore {
|
|
|
977
989
|
const { params } = args || {};
|
|
978
990
|
const object = await this.beforeSet(params, opt);
|
|
979
991
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
980
|
-
return object;
|
|
992
|
+
return object.toJS();
|
|
981
993
|
}
|
|
982
994
|
const items = await this.getGateway()?.set(object);
|
|
983
995
|
const result = await this.afterSet(items, opt);
|
|
@@ -1005,7 +1017,7 @@ class BaseCore {
|
|
|
1005
1017
|
const { where } = args || {};
|
|
1006
1018
|
const object = await this.beforeRemove(where, opt);
|
|
1007
1019
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
1008
|
-
return object;
|
|
1020
|
+
return object.toJS();
|
|
1009
1021
|
}
|
|
1010
1022
|
const items = await this.getGateway()?.remove(object);
|
|
1011
1023
|
const result = await this.afterRemove(items, opt);
|
|
@@ -1033,7 +1045,7 @@ class BaseCore {
|
|
|
1033
1045
|
const { where } = args || {};
|
|
1034
1046
|
const object = await this.beforeRemoveMany(where, opt);
|
|
1035
1047
|
if ((0, api_helpers_1.isOpResult)(object)) {
|
|
1036
|
-
return object;
|
|
1048
|
+
return object.toJS();
|
|
1037
1049
|
}
|
|
1038
1050
|
const items = await this.getGateway()?.remove(object);
|
|
1039
1051
|
const result = await this.afterRemoveMany(items, opt);
|
package/build/esm/BaseCore.js
CHANGED
|
@@ -737,7 +737,7 @@ class BaseCore {
|
|
|
737
737
|
action: async (args, opt) => {
|
|
738
738
|
const object = await this.beforeList(args, opt);
|
|
739
739
|
if (isOpResult(object)) {
|
|
740
|
-
return object;
|
|
740
|
+
return object.toJS();
|
|
741
741
|
}
|
|
742
742
|
const items = await this.getGateway()?.list(object);
|
|
743
743
|
const result = await this.afterList(items, opt);
|
|
@@ -767,15 +767,20 @@ class BaseCore {
|
|
|
767
767
|
action: async (args, opt) => {
|
|
768
768
|
const args2use = await this.beforeGet(args, opt);
|
|
769
769
|
if (isOpResult(args2use)) {
|
|
770
|
-
return args2use;
|
|
770
|
+
return args2use.toJS();
|
|
771
771
|
}
|
|
772
772
|
if (args2use?.id == null) {
|
|
773
773
|
return this.failure(OP_RESULT_CODES.NOT_FOUND, '', []);
|
|
774
774
|
}
|
|
775
775
|
const item = await this.getGateway()?.get(args2use.id);
|
|
776
|
+
if (this.getGateway()?.getConfig()?.hasRemovedAt === true) {
|
|
777
|
+
if (!item || item.removedAt) {
|
|
778
|
+
return this.failure(OP_RESULT_CODES.NOT_FOUND, `${this.config.name} not found`, []);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
776
781
|
const result = await this.afterGet(item, opt);
|
|
777
782
|
if (!result) {
|
|
778
|
-
return this.failure(OP_RESULT_CODES.NOT_FOUND,
|
|
783
|
+
return this.failure(OP_RESULT_CODES.NOT_FOUND, `${this.config.name} not found`, []);
|
|
779
784
|
}
|
|
780
785
|
return this.success([result]);
|
|
781
786
|
},
|
|
@@ -803,12 +808,19 @@ class BaseCore {
|
|
|
803
808
|
action: async (args, opt) => {
|
|
804
809
|
const args2use = await this.beforeGetMany(args, opt);
|
|
805
810
|
if (isOpResult(args2use)) {
|
|
806
|
-
return args2use;
|
|
811
|
+
return args2use.toJS();
|
|
807
812
|
}
|
|
808
813
|
if (!Array.isArray(args2use?.ids)) {
|
|
809
814
|
return this.failure(OP_RESULT_CODES.NOT_FOUND, 'Expected ids array but received invalid input', []);
|
|
810
815
|
}
|
|
811
816
|
const items = await this.getGateway()?.getMany(args2use.ids);
|
|
817
|
+
if (this.getGateway()?.getConfig()?.hasRemovedAt === true) {
|
|
818
|
+
items.forEach((item, index) => {
|
|
819
|
+
if (!item || item.removedAt) {
|
|
820
|
+
items[index] = null;
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
}
|
|
812
824
|
const result = await this.afterGetMany(items, opt);
|
|
813
825
|
return this.success(result);
|
|
814
826
|
},
|
|
@@ -855,7 +867,7 @@ class BaseCore {
|
|
|
855
867
|
}
|
|
856
868
|
const object = await this.beforeCreate(params, opt);
|
|
857
869
|
if (isOpResult(object)) {
|
|
858
|
-
return object;
|
|
870
|
+
return object.toJS();
|
|
859
871
|
}
|
|
860
872
|
const items = await this.getGateway()?.create(object);
|
|
861
873
|
const result = await this.afterCreate(items, opt);
|
|
@@ -883,7 +895,7 @@ class BaseCore {
|
|
|
883
895
|
const { params } = args || {};
|
|
884
896
|
const objects = await this.beforeCreateMany(params, opt);
|
|
885
897
|
if (isOpResult(objects)) {
|
|
886
|
-
return objects;
|
|
898
|
+
return objects.toJS();
|
|
887
899
|
}
|
|
888
900
|
const items = await this.getGateway()?.create(objects);
|
|
889
901
|
const result = await this.afterCreateMany(items, opt);
|
|
@@ -914,7 +926,7 @@ class BaseCore {
|
|
|
914
926
|
const { where, params } = args || {};
|
|
915
927
|
const object = await this.beforeUpdate(params, opt);
|
|
916
928
|
if (isOpResult(object)) {
|
|
917
|
-
return object;
|
|
929
|
+
return object.toJS();
|
|
918
930
|
}
|
|
919
931
|
const items = await this.getGateway()?.update(where, object);
|
|
920
932
|
const result = await this.afterUpdate(items, opt);
|
|
@@ -942,7 +954,7 @@ class BaseCore {
|
|
|
942
954
|
const { params } = args || {};
|
|
943
955
|
const object = await this.beforeUpdateMany(params, opt);
|
|
944
956
|
if (isOpResult(object)) {
|
|
945
|
-
return object;
|
|
957
|
+
return object.toJS();
|
|
946
958
|
}
|
|
947
959
|
const items = await this.getGateway()?.updateMany(object);
|
|
948
960
|
const result = await this.afterUpdateMany(items, opt);
|
|
@@ -971,7 +983,7 @@ class BaseCore {
|
|
|
971
983
|
const { params } = args || {};
|
|
972
984
|
const object = await this.beforeSet(params, opt);
|
|
973
985
|
if (isOpResult(object)) {
|
|
974
|
-
return object;
|
|
986
|
+
return object.toJS();
|
|
975
987
|
}
|
|
976
988
|
const items = await this.getGateway()?.set(object);
|
|
977
989
|
const result = await this.afterSet(items, opt);
|
|
@@ -999,7 +1011,7 @@ class BaseCore {
|
|
|
999
1011
|
const { where } = args || {};
|
|
1000
1012
|
const object = await this.beforeRemove(where, opt);
|
|
1001
1013
|
if (isOpResult(object)) {
|
|
1002
|
-
return object;
|
|
1014
|
+
return object.toJS();
|
|
1003
1015
|
}
|
|
1004
1016
|
const items = await this.getGateway()?.remove(object);
|
|
1005
1017
|
const result = await this.afterRemove(items, opt);
|
|
@@ -1027,7 +1039,7 @@ class BaseCore {
|
|
|
1027
1039
|
const { where } = args || {};
|
|
1028
1040
|
const object = await this.beforeRemoveMany(where, opt);
|
|
1029
1041
|
if (isOpResult(object)) {
|
|
1030
|
-
return object;
|
|
1042
|
+
return object.toJS();
|
|
1031
1043
|
}
|
|
1032
1044
|
const items = await this.getGateway()?.remove(object);
|
|
1033
1045
|
const result = await this.afterRemoveMany(items, opt);
|