@admin-layout/client 1.0.3-alpha.209 → 1.0.3-alpha.213

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.
@@ -1,10 +1,8 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import "reflect-metadata";
3
3
  /**
4
- *
5
4
  * An HOC that will render components using SLOT-FILL in case of
6
5
  * backendError else it will render the Component Passed
7
- *
8
6
  */
9
7
  interface ApplicationErrorHandlerCommonProps {
10
8
  plugins: Record<string, any>;
@@ -0,0 +1,10 @@
1
+ export declare type BACKEND_ERROR = '@platform/BACKEND_ERROR';
2
+ export declare const BACKEND_ERROR: BACKEND_ERROR;
3
+ export declare type DISMISS_APPLICATION_ERROR = '@platform/DISMISS_APPLICATION_ERROR';
4
+ export declare const DISMISS_APPLICATION_ERROR: DISMISS_APPLICATION_ERROR;
5
+ export declare type CLEAR_APPLICATION_ERRORS = '@platform/CLEAR_APPLICATION_ERRORS';
6
+ export declare const CLEAR_APPLICATION_ERRORS: CLEAR_APPLICATION_ERRORS;
7
+ export declare type RESTORE_APPLICATION_ERRORS = '@platform/RESTORE_APPLICATION_ERRORS';
8
+ export declare const RESTORE_APPLICATION_ERRORS: RESTORE_APPLICATION_ERRORS;
9
+ export declare type LOG_APPLICATION_ERROR = '@platform/LOG_APPLICATION_ERROR';
10
+ export declare const LOG_APPLICATION_ERROR: LOG_APPLICATION_ERROR;
@@ -1 +1,2 @@
1
1
  export * from './constants';
2
+ export * from './error';
@@ -0,0 +1 @@
1
+ export * from './link';
@@ -0,0 +1,13 @@
1
+ import { ApolloLink } from '@apollo/client';
2
+ import { interfaces } from 'inversify';
3
+ declare type IGetErrorLink = (container: interfaces.Container) => ApolloLink;
4
+ interface IErrorLink {
5
+ getErrorLink: IGetErrorLink;
6
+ }
7
+ export declare class ErrorLink implements IErrorLink {
8
+ idToken: string;
9
+ dispatchErrorAction(container: interfaces.Container, error: any): void;
10
+ getErrorLink(container: interfaces.Container): ApolloLink;
11
+ }
12
+ export declare const errorReduxLink: (container: interfaces.Container) => ApolloLink;
13
+ export {};
@@ -0,0 +1 @@
1
+ export * from './error-link';
package/lib/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './constants';
3
3
  export * from './redux';
4
4
  export * from './utils';
5
5
  export * from './components';
6
+ export * from './graphql';
package/lib/index.js CHANGED
@@ -146,8 +146,8 @@ const react_1 = __importDefault(__webpack_require__(/*! react */ "react"));
146
146
  const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
147
147
  __webpack_require__(/*! reflect-metadata */ "reflect-metadata");
148
148
  const components_1 = __webpack_require__(/*! @workbench-stack/components */ "@workbench-stack/components");
149
- const constants_1 = __webpack_require__(/*! ../constants/constants */ "./src/constants/constants.ts");
150
- const platform_client_1 = __webpack_require__(/*! @adminide-stack/platform-client */ "@adminide-stack/platform-client");
149
+ const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
150
+ const selectors_1 = __webpack_require__(/*! ../redux/selectors */ "./src/redux/selectors/index.ts");
151
151
  /**
152
152
  * ApplicationErrorSlot is needed for mobile. Since for mobile
153
153
  * we import Slot from @common-stack/react-mobile. The default
@@ -161,7 +161,7 @@ const platform_client_1 = __webpack_require__(/*! @adminide-stack/platform-clien
161
161
  const ApplicationErrorHandlerCommon = (FallbackComponent, ApplicationErrorSlot = undefined) => ({ plugins, children }) => {
162
162
  const applicationErrors = react_redux_1.useSelector((state) => state === null || state === void 0 ? void 0 : state.applicationErrors);
163
163
  const errors = applicationErrors.filter((error) => !!plugins.find((plugin) => plugin.name === (error === null || error === void 0 ? void 0 : error.pluginName)));
164
- const backendError = react_redux_1.useSelector(platform_client_1.backendErrorSelector);
164
+ const backendError = react_redux_1.useSelector(selectors_1.backendErrorSelector);
165
165
  const RenderApplicationErrorSlot = (props) => {
166
166
  return !!ApplicationErrorSlot ? react_1.default.createElement(ApplicationErrorSlot, Object.assign({}, props)) : react_1.default.createElement(components_1.Slot, Object.assign({}, props));
167
167
  };
@@ -338,6 +338,26 @@ exports.CHANGE_LANGUAGE = 'language/changeLanguage';
338
338
  exports.APPLICATION_ERROR_SLOT_FILL = "APPLICATION_ERROR_SLOT_FILL";
339
339
 
340
340
 
341
+ /***/ }),
342
+
343
+ /***/ "./src/constants/error.ts":
344
+ /*!********************************!*\
345
+ !*** ./src/constants/error.ts ***!
346
+ \********************************/
347
+ /*! no static exports found */
348
+ /***/ (function(module, exports, __webpack_require__) {
349
+
350
+ "use strict";
351
+
352
+ Object.defineProperty(exports, "__esModule", { value: true });
353
+ exports.LOG_APPLICATION_ERROR = exports.RESTORE_APPLICATION_ERRORS = exports.CLEAR_APPLICATION_ERRORS = exports.DISMISS_APPLICATION_ERROR = exports.BACKEND_ERROR = void 0;
354
+ exports.BACKEND_ERROR = '@platform/BACKEND_ERROR';
355
+ exports.DISMISS_APPLICATION_ERROR = '@platform/DISMISS_APPLICATION_ERROR';
356
+ exports.CLEAR_APPLICATION_ERRORS = '@platform/CLEAR_APPLICATION_ERRORS';
357
+ exports.RESTORE_APPLICATION_ERRORS = '@platform/RESTORE_APPLICATION_ERRORS';
358
+ exports.LOG_APPLICATION_ERROR = '@platform/LOG_APPLICATION_ERROR';
359
+
360
+
341
361
  /***/ }),
342
362
 
343
363
  /***/ "./src/constants/index.ts":
@@ -361,6 +381,122 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
361
381
  };
362
382
  Object.defineProperty(exports, "__esModule", { value: true });
363
383
  __exportStar(__webpack_require__(/*! ./constants */ "./src/constants/constants.ts"), exports);
384
+ __exportStar(__webpack_require__(/*! ./error */ "./src/constants/error.ts"), exports);
385
+
386
+
387
+ /***/ }),
388
+
389
+ /***/ "./src/graphql/index.ts":
390
+ /*!******************************!*\
391
+ !*** ./src/graphql/index.ts ***!
392
+ \******************************/
393
+ /*! no static exports found */
394
+ /***/ (function(module, exports, __webpack_require__) {
395
+
396
+ "use strict";
397
+
398
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
399
+ if (k2 === undefined) k2 = k;
400
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
401
+ }) : (function(o, m, k, k2) {
402
+ if (k2 === undefined) k2 = k;
403
+ o[k2] = m[k];
404
+ }));
405
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
406
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
407
+ };
408
+ Object.defineProperty(exports, "__esModule", { value: true });
409
+ __exportStar(__webpack_require__(/*! ./link */ "./src/graphql/link/index.ts"), exports);
410
+
411
+
412
+ /***/ }),
413
+
414
+ /***/ "./src/graphql/link/error-link.ts":
415
+ /*!****************************************!*\
416
+ !*** ./src/graphql/link/error-link.ts ***!
417
+ \****************************************/
418
+ /*! no static exports found */
419
+ /***/ (function(module, exports, __webpack_require__) {
420
+
421
+ "use strict";
422
+
423
+ Object.defineProperty(exports, "__esModule", { value: true });
424
+ exports.errorReduxLink = exports.ErrorLink = void 0;
425
+ const error_1 = __webpack_require__(/*! @apollo/client/link/error */ "@apollo/client/link/error");
426
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
427
+ const serialize_error_1 = __webpack_require__(/*! serialize-error */ "serialize-error");
428
+ class ErrorLink {
429
+ dispatchErrorAction(container, error) {
430
+ var _a, _b;
431
+ const reduxStore = container.get('ReduxStore');
432
+ let action = {
433
+ type: (_a = error === null || error === void 0 ? void 0 : error.extensions) === null || _a === void 0 ? void 0 : _a.actionName,
434
+ payload: (_b = error === null || error === void 0 ? void 0 : error.extensions) === null || _b === void 0 ? void 0 : _b.payload
435
+ };
436
+ if (!(action === null || action === void 0 ? void 0 : action.type)) {
437
+ action = {
438
+ type: constants_1.LOG_APPLICATION_ERROR,
439
+ payload: {
440
+ type: constants_1.BACKEND_ERROR,
441
+ payload: serialize_error_1.serializeError(error)
442
+ }
443
+ };
444
+ }
445
+ reduxStore.dispatch(action);
446
+ }
447
+ getErrorLink(container) {
448
+ return error_1.onError(err => {
449
+ var _a, _b;
450
+ const { networkError, graphQLErrors, operation, forward } = err;
451
+ if (graphQLErrors === null || graphQLErrors === void 0 ? void 0 : graphQLErrors.length) {
452
+ graphQLErrors.forEach((error) => {
453
+ this.dispatchErrorAction(container, error);
454
+ });
455
+ }
456
+ if (networkError) {
457
+ const serverErrors = (_b = (_a = networkError) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.errors;
458
+ if (serverErrors === null || serverErrors === void 0 ? void 0 : serverErrors.length) {
459
+ serverErrors.map((error) => {
460
+ this.dispatchErrorAction(container, error);
461
+ });
462
+ }
463
+ else {
464
+ this.dispatchErrorAction(container, networkError);
465
+ }
466
+ }
467
+ });
468
+ }
469
+ }
470
+ exports.ErrorLink = ErrorLink;
471
+ const errorReduxLink = (container) => {
472
+ return new ErrorLink().getErrorLink(container);
473
+ };
474
+ exports.errorReduxLink = errorReduxLink;
475
+
476
+
477
+ /***/ }),
478
+
479
+ /***/ "./src/graphql/link/index.ts":
480
+ /*!***********************************!*\
481
+ !*** ./src/graphql/link/index.ts ***!
482
+ \***********************************/
483
+ /*! no static exports found */
484
+ /***/ (function(module, exports, __webpack_require__) {
485
+
486
+ "use strict";
487
+
488
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
489
+ if (k2 === undefined) k2 = k;
490
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
491
+ }) : (function(o, m, k, k2) {
492
+ if (k2 === undefined) k2 = k;
493
+ o[k2] = m[k];
494
+ }));
495
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
496
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
497
+ };
498
+ Object.defineProperty(exports, "__esModule", { value: true });
499
+ __exportStar(__webpack_require__(/*! ./error-link */ "./src/graphql/link/error-link.ts"), exports);
364
500
 
365
501
 
366
502
  /***/ }),
@@ -390,6 +526,7 @@ __exportStar(__webpack_require__(/*! ./constants */ "./src/constants/index.ts"),
390
526
  __exportStar(__webpack_require__(/*! ./redux */ "./src/redux/index.ts"), exports);
391
527
  __exportStar(__webpack_require__(/*! ./utils */ "./src/utils/index.ts"), exports);
392
528
  __exportStar(__webpack_require__(/*! ./components */ "./src/components/index.tsx"), exports);
529
+ __exportStar(__webpack_require__(/*! ./graphql */ "./src/graphql/index.ts"), exports);
393
530
 
394
531
 
395
532
  /***/ }),
@@ -406,6 +543,20 @@ __exportStar(__webpack_require__(/*! ./components */ "./src/components/index.tsx
406
543
  Object.defineProperty(exports, "__esModule", { value: true });
407
544
 
408
545
 
546
+ /***/ }),
547
+
548
+ /***/ "./src/interfaces/error-state.ts":
549
+ /*!***************************************!*\
550
+ !*** ./src/interfaces/error-state.ts ***!
551
+ \***************************************/
552
+ /*! no static exports found */
553
+ /***/ (function(module, exports, __webpack_require__) {
554
+
555
+ "use strict";
556
+
557
+ Object.defineProperty(exports, "__esModule", { value: true });
558
+
559
+
409
560
  /***/ }),
410
561
 
411
562
  /***/ "./src/interfaces/generated/generated-models.ts":
@@ -668,6 +819,7 @@ __exportStar(__webpack_require__(/*! ./generated */ "./src/interfaces/generated/
668
819
  __exportStar(__webpack_require__(/*! ./default-settings */ "./src/interfaces/default-settings.ts"), exports);
669
820
  __exportStar(__webpack_require__(/*! ./pure-settings */ "./src/interfaces/pure-settings.ts"), exports);
670
821
  __exportStar(__webpack_require__(/*! ./typings */ "./src/interfaces/typings.ts"), exports);
822
+ __exportStar(__webpack_require__(/*! ./error-state */ "./src/interfaces/error-state.ts"), exports);
671
823
 
672
824
 
673
825
  /***/ }),
@@ -698,6 +850,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
698
850
  Object.defineProperty(exports, "__esModule", { value: true });
699
851
 
700
852
 
853
+ /***/ }),
854
+
855
+ /***/ "./src/redux/actions/error-actions.ts":
856
+ /*!********************************************!*\
857
+ !*** ./src/redux/actions/error-actions.ts ***!
858
+ \********************************************/
859
+ /*! no static exports found */
860
+ /***/ (function(module, exports, __webpack_require__) {
861
+
862
+ "use strict";
863
+
864
+ Object.defineProperty(exports, "__esModule", { value: true });
865
+ exports.restoreApplicationError = exports.dismissApplicationError = exports.setApplicationError = void 0;
866
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
867
+ const setApplicationError = (payload) => {
868
+ return ({
869
+ type: constants_1.LOG_APPLICATION_ERROR,
870
+ payload,
871
+ });
872
+ };
873
+ exports.setApplicationError = setApplicationError;
874
+ function dismissApplicationError(dismissByType) {
875
+ return {
876
+ type: constants_1.DISMISS_APPLICATION_ERROR,
877
+ payload: {
878
+ dismissByType
879
+ }
880
+ };
881
+ }
882
+ exports.dismissApplicationError = dismissApplicationError;
883
+ const restoreApplicationError = (payload) => {
884
+ return ({
885
+ type: constants_1.RESTORE_APPLICATION_ERRORS,
886
+ payload,
887
+ });
888
+ };
889
+ exports.restoreApplicationError = restoreApplicationError;
890
+
891
+
892
+ /***/ }),
893
+
894
+ /***/ "./src/redux/actions/index.ts":
895
+ /*!************************************!*\
896
+ !*** ./src/redux/actions/index.ts ***!
897
+ \************************************/
898
+ /*! no static exports found */
899
+ /***/ (function(module, exports, __webpack_require__) {
900
+
901
+ "use strict";
902
+
903
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
904
+ if (k2 === undefined) k2 = k;
905
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
906
+ }) : (function(o, m, k, k2) {
907
+ if (k2 === undefined) k2 = k;
908
+ o[k2] = m[k];
909
+ }));
910
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
911
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
912
+ };
913
+ Object.defineProperty(exports, "__esModule", { value: true });
914
+ // export * from './settings-action';
915
+ __exportStar(__webpack_require__(/*! ./error-actions */ "./src/redux/actions/error-actions.ts"), exports);
916
+
917
+
701
918
  /***/ }),
702
919
 
703
920
  /***/ "./src/redux/index.ts":
@@ -720,8 +937,99 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
720
937
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
721
938
  };
722
939
  Object.defineProperty(exports, "__esModule", { value: true });
723
- // export * from './actions';
940
+ __exportStar(__webpack_require__(/*! ./actions */ "./src/redux/actions/index.ts"), exports);
724
941
  __exportStar(__webpack_require__(/*! ./settings */ "./src/redux/settings.ts"), exports);
942
+ __exportStar(__webpack_require__(/*! ./reducers */ "./src/redux/reducers/index.ts"), exports);
943
+
944
+
945
+ /***/ }),
946
+
947
+ /***/ "./src/redux/reducers/error.ts":
948
+ /*!*************************************!*\
949
+ !*** ./src/redux/reducers/error.ts ***!
950
+ \*************************************/
951
+ /*! no static exports found */
952
+ /***/ (function(module, exports, __webpack_require__) {
953
+
954
+ "use strict";
955
+
956
+ Object.defineProperty(exports, "__esModule", { value: true });
957
+ exports.applicationErrors = exports.initialErrorsState = void 0;
958
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
959
+ exports.initialErrorsState = [];
960
+ function applicationErrors(errorState = exports.initialErrorsState, action) {
961
+ switch (action === null || action === void 0 ? void 0 : action.type) {
962
+ case constants_1.LOG_APPLICATION_ERROR: {
963
+ const { type: errorType, payload, pluginName, displayable = true } = (action === null || action === void 0 ? void 0 : action.payload) || {};
964
+ const nextState = [...errorState];
965
+ nextState.push({
966
+ type: errorType,
967
+ displayable,
968
+ payload,
969
+ pluginName,
970
+ date: new Date(Date.now()).toUTCString(),
971
+ });
972
+ return nextState;
973
+ }
974
+ case constants_1.DISMISS_APPLICATION_ERROR: {
975
+ const { dismissByType } = action === null || action === void 0 ? void 0 : action.payload;
976
+ let nextState = [...errorState];
977
+ nextState = nextState.filter(({ type }) => dismissByType !== type);
978
+ return nextState;
979
+ }
980
+ case constants_1.CLEAR_APPLICATION_ERRORS: {
981
+ return [];
982
+ }
983
+ case constants_1.RESTORE_APPLICATION_ERRORS:
984
+ return action.payload;
985
+ default:
986
+ return errorState;
987
+ }
988
+ }
989
+ exports.applicationErrors = applicationErrors;
990
+
991
+
992
+ /***/ }),
993
+
994
+ /***/ "./src/redux/reducers/index.ts":
995
+ /*!*************************************!*\
996
+ !*** ./src/redux/reducers/index.ts ***!
997
+ \*************************************/
998
+ /*! no static exports found */
999
+ /***/ (function(module, exports, __webpack_require__) {
1000
+
1001
+ "use strict";
1002
+
1003
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1004
+ if (k2 === undefined) k2 = k;
1005
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1006
+ }) : (function(o, m, k, k2) {
1007
+ if (k2 === undefined) k2 = k;
1008
+ o[k2] = m[k];
1009
+ }));
1010
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1011
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1012
+ };
1013
+ Object.defineProperty(exports, "__esModule", { value: true });
1014
+ __exportStar(__webpack_require__(/*! ./error */ "./src/redux/reducers/error.ts"), exports);
1015
+
1016
+
1017
+ /***/ }),
1018
+
1019
+ /***/ "./src/redux/selectors/index.ts":
1020
+ /*!**************************************!*\
1021
+ !*** ./src/redux/selectors/index.ts ***!
1022
+ \**************************************/
1023
+ /*! no static exports found */
1024
+ /***/ (function(module, exports, __webpack_require__) {
1025
+
1026
+ "use strict";
1027
+
1028
+ Object.defineProperty(exports, "__esModule", { value: true });
1029
+ exports.backendErrorSelector = void 0;
1030
+ const reselect_1 = __webpack_require__(/*! reselect */ "reselect");
1031
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
1032
+ exports.backendErrorSelector = reselect_1.createSelector((state) => state.applicationErrors, (applicationErrors) => applicationErrors.find((error) => error.type === constants_1.BACKEND_ERROR));
725
1033
 
726
1034
 
727
1035
  /***/ }),
@@ -829,25 +1137,25 @@ exports.getMenuSeparation = getMenuSeparation;
829
1137
 
830
1138
  /***/ }),
831
1139
 
832
- /***/ "@adminide-stack/platform-client":
833
- /*!**************************************************!*\
834
- !*** external "@adminide-stack/platform-client" ***!
835
- \**************************************************/
1140
+ /***/ "@apollo/client":
1141
+ /*!*********************************!*\
1142
+ !*** external "@apollo/client" ***!
1143
+ \*********************************/
836
1144
  /*! no static exports found */
837
1145
  /***/ (function(module, exports) {
838
1146
 
839
- module.exports = require("@adminide-stack/platform-client");
1147
+ module.exports = require("@apollo/client");
840
1148
 
841
1149
  /***/ }),
842
1150
 
843
- /***/ "@apollo/client":
844
- /*!*********************************!*\
845
- !*** external "@apollo/client" ***!
846
- \*********************************/
1151
+ /***/ "@apollo/client/link/error":
1152
+ /*!********************************************!*\
1153
+ !*** external "@apollo/client/link/error" ***!
1154
+ \********************************************/
847
1155
  /*! no static exports found */
848
1156
  /***/ (function(module, exports) {
849
1157
 
850
- module.exports = require("@apollo/client");
1158
+ module.exports = require("@apollo/client/link/error");
851
1159
 
852
1160
  /***/ }),
853
1161
 
@@ -915,6 +1223,28 @@ module.exports = require("react-redux");
915
1223
 
916
1224
  module.exports = require("reflect-metadata");
917
1225
 
1226
+ /***/ }),
1227
+
1228
+ /***/ "reselect":
1229
+ /*!***************************!*\
1230
+ !*** external "reselect" ***!
1231
+ \***************************/
1232
+ /*! no static exports found */
1233
+ /***/ (function(module, exports) {
1234
+
1235
+ module.exports = require("reselect");
1236
+
1237
+ /***/ }),
1238
+
1239
+ /***/ "serialize-error":
1240
+ /*!**********************************!*\
1241
+ !*** external "serialize-error" ***!
1242
+ \**********************************/
1243
+ /*! no static exports found */
1244
+ /***/ (function(module, exports) {
1245
+
1246
+ module.exports = require("serialize-error");
1247
+
918
1248
  /***/ })
919
1249
 
920
1250
  /******/ });