monorise 2.0.0-dev.2 → 2.0.0-dev.3
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/dist/cli/cli.js +1 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +85 -14
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/react/actions/core.action.d.ts +24 -70
- package/dist/react/actions/core.action.d.ts.map +1 -1
- package/dist/react/index.d.ts +47 -138
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +32 -19
- package/dist/react/index.js.map +1 -1
- package/dist/react/types/api.type.d.ts +12 -0
- package/dist/react/types/api.type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -446,6 +446,18 @@ var removeFromSearchResults = (state, entityType, entityId) => {
|
|
|
446
446
|
|
|
447
447
|
// actions/core.action.ts
|
|
448
448
|
var EMPTY_MAP = /* @__PURE__ */ new Map();
|
|
449
|
+
var toRequestError = (err) => {
|
|
450
|
+
var _a;
|
|
451
|
+
const error = err instanceof Error ? err : new Error("Unknown error occurred");
|
|
452
|
+
const response = err == null ? void 0 : err.response;
|
|
453
|
+
if (response) {
|
|
454
|
+
if (typeof response.status === "number") error.status = response.status;
|
|
455
|
+
error.data = response.data;
|
|
456
|
+
const code = (_a = response.data) == null ? void 0 : _a.code;
|
|
457
|
+
if (typeof code === "string") error.code = code;
|
|
458
|
+
}
|
|
459
|
+
return error;
|
|
460
|
+
};
|
|
449
461
|
var defaultOnError = (error) => {
|
|
450
462
|
if (!(error instanceof Error) && error.status >= 500) {
|
|
451
463
|
throw error;
|
|
@@ -510,7 +522,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
510
522
|
`mr/entity/list/${entityType}`
|
|
511
523
|
);
|
|
512
524
|
} catch (err) {
|
|
513
|
-
const error2 = err
|
|
525
|
+
const error2 = toRequestError(err);
|
|
514
526
|
return { error: error2 };
|
|
515
527
|
}
|
|
516
528
|
};
|
|
@@ -553,7 +565,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
553
565
|
`mr/entity/list-more/${entityType}`
|
|
554
566
|
);
|
|
555
567
|
} catch (err) {
|
|
556
|
-
const error2 = err
|
|
568
|
+
const error2 = toRequestError(err);
|
|
557
569
|
return { error: error2 };
|
|
558
570
|
}
|
|
559
571
|
};
|
|
@@ -582,7 +594,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
582
594
|
})
|
|
583
595
|
);
|
|
584
596
|
} catch (err) {
|
|
585
|
-
const error = err
|
|
597
|
+
const error = toRequestError(err);
|
|
586
598
|
return { error };
|
|
587
599
|
}
|
|
588
600
|
};
|
|
@@ -646,7 +658,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
646
658
|
);
|
|
647
659
|
return { data };
|
|
648
660
|
} catch (err) {
|
|
649
|
-
const error2 = err
|
|
661
|
+
const error2 = toRequestError(err);
|
|
650
662
|
return { error: error2 };
|
|
651
663
|
}
|
|
652
664
|
};
|
|
@@ -685,7 +697,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
685
697
|
);
|
|
686
698
|
return { data: entity };
|
|
687
699
|
} catch (err) {
|
|
688
|
-
const error2 = err
|
|
700
|
+
const error2 = toRequestError(err);
|
|
689
701
|
return { error: error2 };
|
|
690
702
|
}
|
|
691
703
|
};
|
|
@@ -730,7 +742,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
730
742
|
);
|
|
731
743
|
return { data: entity };
|
|
732
744
|
} catch (err) {
|
|
733
|
-
const error2 = err
|
|
745
|
+
const error2 = toRequestError(err);
|
|
734
746
|
return { error: error2 };
|
|
735
747
|
}
|
|
736
748
|
};
|
|
@@ -828,7 +840,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
828
840
|
);
|
|
829
841
|
return { data };
|
|
830
842
|
} catch (err) {
|
|
831
|
-
const error = err
|
|
843
|
+
const error = toRequestError(err);
|
|
832
844
|
onError == null ? void 0 : onError(error);
|
|
833
845
|
return { error };
|
|
834
846
|
}
|
|
@@ -853,7 +865,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
853
865
|
);
|
|
854
866
|
return { data };
|
|
855
867
|
} catch (err) {
|
|
856
|
-
const error = err
|
|
868
|
+
const error = toRequestError(err);
|
|
857
869
|
onError(error);
|
|
858
870
|
return { error };
|
|
859
871
|
}
|
|
@@ -971,7 +983,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
971
983
|
);
|
|
972
984
|
return { data };
|
|
973
985
|
} catch (err) {
|
|
974
|
-
const error = err
|
|
986
|
+
const error = toRequestError(err);
|
|
975
987
|
onError(error);
|
|
976
988
|
return { error };
|
|
977
989
|
}
|
|
@@ -1006,7 +1018,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1006
1018
|
if (((_b = err == null ? void 0 : err.response) == null ? void 0 : _b.status) === 409) {
|
|
1007
1019
|
await getEntity2(entityType, id, { forceFetch: true });
|
|
1008
1020
|
}
|
|
1009
|
-
const error = err
|
|
1021
|
+
const error = toRequestError(err);
|
|
1010
1022
|
onError(error);
|
|
1011
1023
|
return { error };
|
|
1012
1024
|
}
|
|
@@ -1027,7 +1039,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1027
1039
|
);
|
|
1028
1040
|
return { data: { entityId: id } };
|
|
1029
1041
|
} catch (err) {
|
|
1030
|
-
const error = err
|
|
1042
|
+
const error = toRequestError(err);
|
|
1031
1043
|
onError(error);
|
|
1032
1044
|
return { error };
|
|
1033
1045
|
}
|
|
@@ -1181,7 +1193,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1181
1193
|
clearError2(callRequestKey);
|
|
1182
1194
|
}
|
|
1183
1195
|
}
|
|
1184
|
-
const error = err
|
|
1196
|
+
const error = toRequestError(err);
|
|
1185
1197
|
onError(error);
|
|
1186
1198
|
return { error };
|
|
1187
1199
|
}
|
|
@@ -1263,7 +1275,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1263
1275
|
);
|
|
1264
1276
|
return { data };
|
|
1265
1277
|
} catch (err) {
|
|
1266
|
-
const error2 = err
|
|
1278
|
+
const error2 = toRequestError(err);
|
|
1267
1279
|
return { error: error2 };
|
|
1268
1280
|
}
|
|
1269
1281
|
};
|
|
@@ -1307,7 +1319,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1307
1319
|
));
|
|
1308
1320
|
} catch (err) {
|
|
1309
1321
|
if (!opts.defaultMutualData) {
|
|
1310
|
-
const error2 = err
|
|
1322
|
+
const error2 = toRequestError(err);
|
|
1311
1323
|
return { error: error2 };
|
|
1312
1324
|
}
|
|
1313
1325
|
hasRequestFailed = true;
|
|
@@ -1392,7 +1404,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1392
1404
|
);
|
|
1393
1405
|
return { data: mutual };
|
|
1394
1406
|
} catch (err) {
|
|
1395
|
-
const error = err
|
|
1407
|
+
const error = toRequestError(err);
|
|
1396
1408
|
onError(error);
|
|
1397
1409
|
return { error };
|
|
1398
1410
|
}
|
|
@@ -1530,7 +1542,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1530
1542
|
);
|
|
1531
1543
|
return { data: mutual };
|
|
1532
1544
|
} catch (err) {
|
|
1533
|
-
const error = err
|
|
1545
|
+
const error = toRequestError(err);
|
|
1534
1546
|
onError(error);
|
|
1535
1547
|
return { error };
|
|
1536
1548
|
}
|
|
@@ -1562,7 +1574,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1562
1574
|
);
|
|
1563
1575
|
return { data };
|
|
1564
1576
|
} catch (err) {
|
|
1565
|
-
const error = err
|
|
1577
|
+
const error = toRequestError(err);
|
|
1566
1578
|
onError(error);
|
|
1567
1579
|
return { error };
|
|
1568
1580
|
}
|
|
@@ -2146,11 +2158,12 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2146
2158
|
const requestKey = getTagRequestKey("list", entityType, tagName, params);
|
|
2147
2159
|
const isLoading = useLoadStore2(requestKey);
|
|
2148
2160
|
const error = useErrorStore2(requestKey);
|
|
2161
|
+
const paramsReady = !!params && Object.keys(params).length > 0 && Object.values(params).every((value) => value !== void 0);
|
|
2149
2162
|
useEffect2(() => {
|
|
2150
|
-
if (entityType && tagName &&
|
|
2163
|
+
if (entityType && tagName && paramsReady) {
|
|
2151
2164
|
listEntitiesByTag(entityType, tagName, opts);
|
|
2152
2165
|
}
|
|
2153
|
-
}, [entityType, opts, tagName,
|
|
2166
|
+
}, [entityType, opts, tagName, paramsReady, opts == null ? void 0 : opts.forceFetch]);
|
|
2154
2167
|
return {
|
|
2155
2168
|
entities,
|
|
2156
2169
|
entitiesMap: dataMap,
|