@uxf/cms 11.74.0 → 11.74.1
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/api/index.d.ts +165 -0
- package/api/index.js +100 -0
- package/api/swr.d.ts +76 -0
- package/api/swr.js +43 -0
- package/config/container.d.ts +29 -0
- package/config/container.js +24 -0
- package/config/index.d.ts +2 -0
- package/config/index.js +6 -0
- package/content-builder/content-builder-body.d.ts +6 -0
- package/content-builder/content-builder-body.js +10 -0
- package/content-builder/content-builder-header.d.ts +7 -0
- package/content-builder/content-builder-header.js +15 -0
- package/content-builder/content-builder-root.d.ts +11 -0
- package/content-builder/content-builder-root.js +13 -0
- package/content-builder/content-builder-sidebar.d.ts +7 -0
- package/content-builder/content-builder-sidebar.js +12 -0
- package/content-builder/content-builder.d.ts +14 -0
- package/content-builder/content-builder.js +57 -0
- package/content-builder/forms/content-builder-basic-form.d.ts +10 -0
- package/content-builder/forms/content-builder-basic-form.js +49 -0
- package/content-builder/forms/content-builder-seo-form.d.ts +10 -0
- package/content-builder/forms/content-builder-seo-form.js +22 -0
- package/content-builder/index.d.ts +4 -0
- package/content-builder/index.js +20 -0
- package/content-builder/map-content-response-to-form-data.d.ts +3 -0
- package/content-builder/map-content-response-to-form-data.js +44 -0
- package/content-builder/map-form-data-to-content-request.d.ts +2 -0
- package/content-builder/map-form-data-to-content-request.js +28 -0
- package/content-builder/translations.d.ts +127 -0
- package/content-builder/translations.js +128 -0
- package/content-builder/types.d.ts +186 -0
- package/content-builder/types.js +2 -0
- package/content-builder/use-content-builder-form-api.d.ts +3 -0
- package/content-builder/use-content-builder-form-api.js +7 -0
- package/context/cms-provider.d.ts +7 -0
- package/context/cms-provider.js +18 -0
- package/deprecated/api/api-client.d.ts +15 -0
- package/deprecated/api/api-client.js +86 -0
- package/deprecated/hoc/with-authenticate.d.ts +6 -0
- package/deprecated/hoc/with-authenticate.js +61 -0
- package/deprecated/redux/configure-store.d.ts +3 -0
- package/deprecated/redux/configure-store.js +16 -0
- package/deprecated/redux/entities/actions.d.ts +30 -0
- package/deprecated/redux/entities/actions.js +15 -0
- package/deprecated/redux/entities/index.d.ts +2 -0
- package/deprecated/redux/entities/index.js +18 -0
- package/deprecated/redux/entities/reducer.d.ts +3 -0
- package/deprecated/redux/entities/reducer.js +36 -0
- package/deprecated/redux/entities/selectors.d.ts +10 -0
- package/deprecated/redux/entities/selectors.js +16 -0
- package/deprecated/redux/index.d.ts +3 -0
- package/deprecated/redux/index.js +22 -0
- package/deprecated/redux/redux-helper.d.ts +15 -0
- package/deprecated/redux/redux-helper.js +6 -0
- package/deprecated/redux/types.d.ts +7 -0
- package/deprecated/redux/types.js +2 -0
- package/deprecated/redux/user/actions.d.ts +19 -0
- package/deprecated/redux/user/actions.js +14 -0
- package/deprecated/redux/user/index.d.ts +2 -0
- package/deprecated/redux/user/index.js +18 -0
- package/deprecated/redux/user/reducer.d.ts +3 -0
- package/deprecated/redux/user/reducer.js +21 -0
- package/deprecated/redux/user/selectors.d.ts +3 -0
- package/deprecated/redux/user/selectors.js +5 -0
- package/deprecated/redux/with-redux-store.d.ts +1 -0
- package/deprecated/redux/with-redux-store.js +70 -0
- package/deprecated/security/cms-authorizator.d.ts +3 -0
- package/deprecated/security/cms-authorizator.js +8 -0
- package/deprecated/types/app.d.ts +6 -0
- package/deprecated/types/app.js +2 -0
- package/deprecated/types/form.d.ts +25 -0
- package/deprecated/types/form.js +16 -0
- package/errors/BadRequestError.d.ts +18 -0
- package/errors/BadRequestError.js +14 -0
- package/errors/ForbiddenError.d.ts +4 -0
- package/errors/ForbiddenError.js +13 -0
- package/errors/NetworkError.d.ts +4 -0
- package/errors/NetworkError.js +13 -0
- package/errors/UnauthorizedError.d.ts +4 -0
- package/errors/UnauthorizedError.js +13 -0
- package/errors/ValidationError.d.ts +7 -0
- package/errors/ValidationError.js +17 -0
- package/form-renderer/field/content-dynamic.d.ts +8 -0
- package/form-renderer/field/content-dynamic.js +15 -0
- package/form-renderer/field/content.d.ts +5 -0
- package/form-renderer/field/content.js +38 -0
- package/forms/change-password-form/change-password-form.d.ts +3 -0
- package/forms/change-password-form/change-password-form.js +31 -0
- package/forms/change-password-form/index.d.ts +2 -0
- package/forms/change-password-form/index.js +18 -0
- package/forms/change-password-form/translations.d.ts +35 -0
- package/forms/change-password-form/translations.js +36 -0
- package/forms/change-password-form/types.d.ts +13 -0
- package/forms/change-password-form/types.js +2 -0
- package/forms/components/wysiwyg-input/index.d.ts +1 -0
- package/forms/components/wysiwyg-input/index.js +17 -0
- package/forms/components/wysiwyg-input/wysiwyg-input.d.ts +26 -0
- package/forms/components/wysiwyg-input/wysiwyg-input.js +83 -0
- package/forms/forgotten-password-form/forgotten-password-form.d.ts +3 -0
- package/forms/forgotten-password-form/forgotten-password-form.js +52 -0
- package/forms/forgotten-password-form/index.d.ts +2 -0
- package/forms/forgotten-password-form/index.js +18 -0
- package/forms/forgotten-password-form/translations.d.ts +17 -0
- package/forms/forgotten-password-form/translations.js +18 -0
- package/forms/forgotten-password-form/types.d.ts +10 -0
- package/forms/forgotten-password-form/types.js +2 -0
- package/forms/invite-user-form/index.d.ts +2 -0
- package/forms/invite-user-form/index.js +18 -0
- package/forms/invite-user-form/invite-user-form.d.ts +3 -0
- package/forms/invite-user-form/invite-user-form.js +33 -0
- package/forms/invite-user-form/translations.d.ts +35 -0
- package/forms/invite-user-form/translations.js +36 -0
- package/forms/invite-user-form/types.d.ts +15 -0
- package/forms/invite-user-form/types.js +2 -0
- package/forms/login-form/index.d.ts +2 -0
- package/forms/login-form/index.js +18 -0
- package/forms/login-form/login-form.d.ts +3 -0
- package/forms/login-form/login-form.js +51 -0
- package/forms/login-form/translations.d.ts +23 -0
- package/forms/login-form/translations.js +24 -0
- package/forms/login-form/types.d.ts +11 -0
- package/forms/login-form/types.js +2 -0
- package/forms/renew-password-form/index.d.ts +2 -0
- package/forms/renew-password-form/index.js +18 -0
- package/forms/renew-password-form/renew-password-form.d.ts +3 -0
- package/forms/renew-password-form/renew-password-form.js +53 -0
- package/forms/renew-password-form/translations.d.ts +29 -0
- package/forms/renew-password-form/translations.js +30 -0
- package/forms/renew-password-form/types.d.ts +11 -0
- package/forms/renew-password-form/types.js +2 -0
- package/lib/api/create-axios-instance.d.ts +6 -0
- package/lib/api/create-axios-instance.js +17 -0
- package/lib/api/create-axios-request.d.ts +3 -0
- package/lib/api/create-axios-request.js +39 -0
- package/lib/api/create-use-axios-request.d.ts +5 -0
- package/lib/api/create-use-axios-request.js +35 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +19 -0
- package/lib/api/types.d.ts +18 -0
- package/lib/api/types.js +2 -0
- package/lib/layout/breadcrumbs.d.ts +9 -0
- package/lib/layout/breadcrumbs.js +21 -0
- package/lib/layout/index.d.ts +3 -0
- package/lib/layout/index.js +19 -0
- package/lib/layout/layout-container.d.ts +3 -0
- package/lib/layout/layout-container.js +22 -0
- package/lib/layout/layout.d.ts +3 -0
- package/lib/layout/layout.js +47 -0
- package/lib/layout/sidebar.d.ts +3 -0
- package/lib/layout/sidebar.js +77 -0
- package/lib/layout/styles.d.ts +1 -0
- package/lib/layout/styles.js +4 -0
- package/lib/layout/types.d.ts +36 -0
- package/lib/layout/types.js +2 -0
- package/lib/login-layout/index.d.ts +2 -0
- package/lib/login-layout/index.js +18 -0
- package/lib/login-layout/login-layout.d.ts +3 -0
- package/lib/login-layout/login-layout.js +19 -0
- package/lib/login-layout/types.d.ts +9 -0
- package/lib/login-layout/types.js +2 -0
- package/lib/menu/active-item-resolver.d.ts +7 -0
- package/lib/menu/active-item-resolver.js +42 -0
- package/lib/menu/factory.d.ts +10 -0
- package/lib/menu/factory.js +40 -0
- package/lib/menu/index.d.ts +5 -0
- package/lib/menu/index.js +21 -0
- package/lib/menu/mobile-bar.d.ts +8 -0
- package/lib/menu/mobile-bar.js +54 -0
- package/lib/menu/model.d.ts +56 -0
- package/lib/menu/model.js +112 -0
- package/lib/menu/types.d.ts +5 -0
- package/lib/menu/types.js +2 -0
- package/lib/menu/ui/list-item/index.d.ts +2 -0
- package/lib/menu/ui/list-item/index.js +18 -0
- package/lib/menu/ui/list-item/list-item.d.ts +3 -0
- package/lib/menu/ui/list-item/list-item.js +37 -0
- package/lib/menu/ui/list-item/types.d.ts +19 -0
- package/lib/menu/ui/list-item/types.js +2 -0
- package/lib/menu/ui/menu-custom-item.d.ts +6 -0
- package/lib/menu/ui/menu-custom-item.js +17 -0
- package/lib/menu/ui/menu-item.d.ts +6 -0
- package/lib/menu/ui/menu-item.js +55 -0
- package/lib/menu/ui/menu-super-section-item.d.ts +6 -0
- package/lib/menu/ui/menu-super-section-item.js +40 -0
- package/lib/menu/ui/menu.d.ts +6 -0
- package/lib/menu/ui/menu.js +37 -0
- package/lib/menu/ui/sub-menu/sub-menu-item.d.ts +7 -0
- package/lib/menu/ui/sub-menu/sub-menu-item.js +23 -0
- package/lib/menu/ui/sub-menu/sub-menu-mobile.d.ts +8 -0
- package/lib/menu/ui/sub-menu/sub-menu-mobile.js +48 -0
- package/lib/menu/ui/sub-menu/sub-menu.d.ts +7 -0
- package/lib/menu/ui/sub-menu/sub-menu.js +46 -0
- package/lib/menu/ui/sub-menu/use-sub-menu.d.ts +49 -0
- package/lib/menu/ui/sub-menu/use-sub-menu.js +45 -0
- package/lib/menu/ui/translations.d.ts +17 -0
- package/lib/menu/ui/translations.js +18 -0
- package/lib/menu/ui/user-menu.d.ts +6 -0
- package/lib/menu/ui/user-menu.js +55 -0
- package/package.json +6 -6
- package/pages/content-builder/components/form-content.d.ts +12 -0
- package/pages/content-builder/components/form-content.js +64 -0
- package/pages/content-builder/components/form-root-fields.d.ts +16 -0
- package/pages/content-builder/components/form-root-fields.js +62 -0
- package/pages/content-builder/components/form.d.ts +12 -0
- package/pages/content-builder/components/form.js +83 -0
- package/pages/content-builder/components/header.d.ts +6 -0
- package/pages/content-builder/components/header.js +18 -0
- package/pages/content-builder/constants.d.ts +6 -0
- package/pages/content-builder/constants.js +10 -0
- package/pages/content-builder/content/feature-section.d.ts +17 -0
- package/pages/content-builder/content/feature-section.js +62 -0
- package/pages/content-builder/content/gallery.d.ts +9 -0
- package/pages/content-builder/content/gallery.js +29 -0
- package/pages/content-builder/content/hero-section.d.ts +12 -0
- package/pages/content-builder/content/hero-section.js +35 -0
- package/pages/content-builder/content/people.d.ts +17 -0
- package/pages/content-builder/content/people.js +61 -0
- package/pages/content-builder/content/wysiwyg.d.ts +15 -0
- package/pages/content-builder/content/wysiwyg.js +32 -0
- package/pages/content-builder/content-builder-page.d.ts +3 -0
- package/pages/content-builder/content-builder-page.js +107 -0
- package/pages/content-builder/content-field.d.ts +10 -0
- package/pages/content-builder/content-field.js +62 -0
- package/pages/content-builder/content-header.d.ts +3 -0
- package/pages/content-builder/content-header.js +55 -0
- package/pages/content-builder/context/details-visibility-context.d.ts +4 -0
- package/pages/content-builder/context/details-visibility-context.js +58 -0
- package/pages/content-builder/hooks/use-sortable.d.ts +15 -0
- package/pages/content-builder/hooks/use-sortable.js +57 -0
- package/pages/content-builder/index.d.ts +5 -0
- package/pages/content-builder/index.js +21 -0
- package/pages/content-builder/mapper.d.ts +4 -0
- package/pages/content-builder/mapper.js +69 -0
- package/pages/content-builder/types.d.ts +94 -0
- package/pages/content-builder/types.js +2 -0
- package/pages/forgotten-password-page/forgotten-password-page.d.ts +5 -0
- package/pages/forgotten-password-page/forgotten-password-page.js +49 -0
- package/pages/forgotten-password-page/index.d.ts +2 -0
- package/pages/forgotten-password-page/index.js +18 -0
- package/pages/forgotten-password-page/types.d.ts +11 -0
- package/pages/forgotten-password-page/types.js +2 -0
- package/pages/grid-page/get-initial-props-helper.d.ts +4 -0
- package/pages/grid-page/get-initial-props-helper.js +20 -0
- package/pages/grid-page/grid-page.d.ts +6 -0
- package/pages/grid-page/grid-page.js +161 -0
- package/pages/grid-page/index.d.ts +1 -0
- package/pages/grid-page/index.js +5 -0
- package/pages/grid-page/types.d.ts +65 -0
- package/pages/grid-page/types.js +2 -0
- package/pages/grid-page/use-hidden-columns.d.ts +4 -0
- package/pages/grid-page/use-hidden-columns.js +17 -0
- package/pages/invite-user-page/index.d.ts +2 -0
- package/pages/invite-user-page/index.js +18 -0
- package/pages/invite-user-page/invite-user-page.d.ts +2 -0
- package/pages/invite-user-page/invite-user-page.js +57 -0
- package/pages/invite-user-page/types.d.ts +12 -0
- package/pages/invite-user-page/types.js +2 -0
- package/pages/login-page/index.d.ts +2 -0
- package/pages/login-page/index.js +18 -0
- package/pages/login-page/login-page.d.ts +5 -0
- package/pages/login-page/login-page.js +80 -0
- package/pages/login-page/types.d.ts +21 -0
- package/pages/login-page/types.js +2 -0
- package/pages/renew-password-page/index.d.ts +2 -0
- package/pages/renew-password-page/index.js +18 -0
- package/pages/renew-password-page/renew-password-page.d.ts +9 -0
- package/pages/renew-password-page/renew-password-page.js +53 -0
- package/pages/renew-password-page/types.d.ts +14 -0
- package/pages/renew-password-page/types.js +2 -0
- package/pages/translations.d.ts +93 -0
- package/pages/translations.js +94 -0
- package/security/restricted-page.d.ts +10 -0
- package/security/restricted-page.js +40 -0
- package/security/translations.d.ts +29 -0
- package/security/translations.js +30 -0
- package/security/use-logged-user.d.ts +5 -0
- package/security/use-logged-user.js +17 -0
- package/ui/avatar/avatar.d.ts +11 -0
- package/ui/avatar/avatar.js +47 -0
- package/ui/avatar/get-avatar-user-letters.d.ts +1 -0
- package/ui/avatar/get-avatar-user-letters.js +18 -0
- package/ui/avatar/index.d.ts +3 -0
- package/ui/avatar/index.js +5 -0
- package/ui/avatar/theme.d.ts +11 -0
- package/ui/avatar/theme.js +2 -0
- package/ui/copy-to-clipboard/copy-to-clipboard.d.ts +3 -0
- package/ui/copy-to-clipboard/copy-to-clipboard.js +47 -0
- package/ui/copy-to-clipboard/index.d.ts +2 -0
- package/ui/copy-to-clipboard/index.js +18 -0
- package/ui/copy-to-clipboard/translations.d.ts +17 -0
- package/ui/copy-to-clipboard/translations.js +18 -0
- package/ui/copy-to-clipboard/types.d.ts +7 -0
- package/ui/copy-to-clipboard/types.js +2 -0
- package/ui/copy-to-clipboard-button/copy-to-clipboard-button.d.ts +3 -0
- package/ui/copy-to-clipboard-button/copy-to-clipboard-button.js +48 -0
- package/ui/copy-to-clipboard-button/index.d.ts +2 -0
- package/ui/copy-to-clipboard-button/index.js +18 -0
- package/ui/copy-to-clipboard-button/translations.d.ts +17 -0
- package/ui/copy-to-clipboard-button/translations.js +18 -0
- package/ui/copy-to-clipboard-button/types.d.ts +6 -0
- package/ui/copy-to-clipboard-button/types.js +2 -0
- package/ui/index.d.ts +1 -0
- package/ui/index.js +6 -0
- package/ui/tw-tokens/tw-box-shadow.d.ts +12 -0
- package/ui/tw-tokens/tw-box-shadow.js +15 -0
- package/ui/tw-tokens/tw-colors.d.ts +475 -0
- package/ui/tw-tokens/tw-colors.js +474 -0
- package/ui/tw-tokens/tw-containers.d.ts +8 -0
- package/ui/tw-tokens/tw-containers.js +5 -0
- package/ui/tw-tokens/tw-font-size.d.ts +55 -0
- package/ui/tw-tokens/tw-font-size.js +32 -0
- package/ui/tw-tokens/tw-font-weight.d.ts +12 -0
- package/ui/tw-tokens/tw-font-weight.js +15 -0
- package/ui/tw-tokens/tw-line-height.d.ts +17 -0
- package/ui/tw-tokens/tw-line-height.js +20 -0
- package/ui/tw-tokens/tw-screens.d.ts +8 -0
- package/ui/tw-tokens/tw-screens.js +5 -0
- package/ui/tw-tokens/tw-spacing.d.ts +39 -0
- package/ui/tw-tokens/tw-spacing.js +42 -0
- package/ui/tw-tokens/tw-z-index.d.ts +21 -0
- package/ui/tw-tokens/tw-z-index.js +24 -0
- package/ui/widget/index.d.ts +2 -0
- package/ui/widget/index.js +18 -0
- package/ui/widget/types.d.ts +6 -0
- package/ui/widget/types.js +2 -0
- package/ui/widget/widget.d.ts +3 -0
- package/ui/widget/widget.js +15 -0
- package/utils/remove-confirm-handler.d.ts +1 -0
- package/utils/remove-confirm-handler.js +31 -0
- package/utils/translations.d.ts +23 -0
- package/utils/translations.js +24 -0
- package/utils/use-viewport-height.d.ts +3 -0
- package/utils/use-viewport-height.js +28 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.CmsProvider = CmsProvider;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const swr_1 = require("swr");
|
9
|
+
const fetcher = (input) => fetch(input).then((res) => res.json());
|
10
|
+
function CmsProvider(props) {
|
11
|
+
var _a, _b, _c, _d;
|
12
|
+
const swrConfig = {
|
13
|
+
...props.swrConfig,
|
14
|
+
provider: (_b = (_a = props.swrConfig) === null || _a === void 0 ? void 0 : _a.provider) !== null && _b !== void 0 ? _b : (() => new Map()),
|
15
|
+
fetcher: (_d = (_c = props.swrConfig) === null || _c === void 0 ? void 0 : _c.fetcher) !== null && _d !== void 0 ? _d : fetcher,
|
16
|
+
};
|
17
|
+
return react_1.default.createElement(swr_1.SWRConfig, { value: swrConfig }, props.children);
|
18
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
2
|
+
import { NextPageContext } from "next";
|
3
|
+
export type ContextType = NextPageContext | null;
|
4
|
+
/** @deprecated */
|
5
|
+
export default class ApiClient {
|
6
|
+
private client;
|
7
|
+
constructor(basePath?: string, baseUrl?: string);
|
8
|
+
private request;
|
9
|
+
get<RESPONSE = any>(ctx: ContextType, url: string, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RESPONSE, any>>;
|
10
|
+
delete<RESPONSE = any>(ctx: ContextType, url: string, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RESPONSE, any>>;
|
11
|
+
head<RESPONSE = any>(ctx: ContextType, url: string, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RESPONSE, any>>;
|
12
|
+
post<REQUEST extends object = Record<string, any>, RESPONSE = any>(ctx: ContextType, url: string, data: REQUEST, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RESPONSE, any>>;
|
13
|
+
put<REQUEST extends object = Record<string, any>, RESPONSE = any>(ctx: ContextType, url: string, data: REQUEST, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RESPONSE, any>>;
|
14
|
+
patch<REQUEST extends object = Record<string, any>, RESPONSE = any>(ctx: ContextType, url: string, data: REQUEST, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RESPONSE, any>>;
|
15
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
7
|
+
const ForbiddenError_1 = require("../../errors/ForbiddenError");
|
8
|
+
const NetworkError_1 = require("../../errors/NetworkError");
|
9
|
+
const UnauthorizedError_1 = require("../../errors/UnauthorizedError");
|
10
|
+
const getClient = (options = {}) => {
|
11
|
+
const client = axios_1.default.create(options);
|
12
|
+
// Add a request interceptor
|
13
|
+
client.interceptors.request.use((requestConfig) => requestConfig, (requestError) => {
|
14
|
+
// eslint-disable-next-line no-console
|
15
|
+
console.error(requestError);
|
16
|
+
return Promise.reject(requestError);
|
17
|
+
});
|
18
|
+
// Add a response interceptor
|
19
|
+
client.interceptors.response.use((response) => response, (error) => {
|
20
|
+
if (error.response && error.response.status >= 500) {
|
21
|
+
// eslint-disable-next-line no-console
|
22
|
+
console.error(error);
|
23
|
+
}
|
24
|
+
return Promise.reject(error);
|
25
|
+
});
|
26
|
+
return client;
|
27
|
+
};
|
28
|
+
const addCookiesToHeader = (ctx, headers = {}) => {
|
29
|
+
var _a;
|
30
|
+
return ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.req) === null || _a === void 0 ? void 0 : _a.headers.cookie) ? { ...headers, cookie: ctx.req.headers.cookie } : headers;
|
31
|
+
};
|
32
|
+
const handleError = (error) => {
|
33
|
+
if (error.response) {
|
34
|
+
if (error.response.status === 401) {
|
35
|
+
throw new UnauthorizedError_1.UnauthorizedError();
|
36
|
+
}
|
37
|
+
else if (error.response.status === 403) {
|
38
|
+
throw new ForbiddenError_1.ForbiddenError();
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
throw error;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
else if (error.request) {
|
45
|
+
throw new NetworkError_1.NetworkError();
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
throw error;
|
49
|
+
}
|
50
|
+
};
|
51
|
+
/** @deprecated */
|
52
|
+
class ApiClient {
|
53
|
+
constructor(basePath = "", baseUrl = "") {
|
54
|
+
this.client = getClient({
|
55
|
+
baseURL: `${baseUrl}${basePath}`,
|
56
|
+
});
|
57
|
+
}
|
58
|
+
request(ctx, config) {
|
59
|
+
return this.client
|
60
|
+
.request({
|
61
|
+
...config,
|
62
|
+
headers: addCookiesToHeader(ctx, config.headers),
|
63
|
+
})
|
64
|
+
.then((response) => Promise.resolve(response))
|
65
|
+
.catch((error) => handleError(error));
|
66
|
+
}
|
67
|
+
get(ctx, url, config = {}) {
|
68
|
+
return this.request(ctx, { ...config, url, method: "GET" });
|
69
|
+
}
|
70
|
+
delete(ctx, url, config = {}) {
|
71
|
+
return this.request(ctx, { ...config, url, method: "DELETE" });
|
72
|
+
}
|
73
|
+
head(ctx, url, config = {}) {
|
74
|
+
return this.request(ctx, { ...config, url, method: "HEAD" });
|
75
|
+
}
|
76
|
+
post(ctx, url, data, config = {}) {
|
77
|
+
return this.request(ctx, { ...config, url, method: "POST", data });
|
78
|
+
}
|
79
|
+
put(ctx, url, data, config = {}) {
|
80
|
+
return this.request(ctx, { ...config, url, method: "PUT", data });
|
81
|
+
}
|
82
|
+
patch(ctx, url, data, config = {}) {
|
83
|
+
return this.request(ctx, { ...config, url, method: "PATCH", data });
|
84
|
+
}
|
85
|
+
}
|
86
|
+
exports.default = ApiClient;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { NextComponentType } from "next";
|
2
|
+
import { IAppContext } from "../types/app";
|
3
|
+
export interface IConfig {
|
4
|
+
allowedRoles?: string[];
|
5
|
+
}
|
6
|
+
export declare const withAuthenticate: <PROPS extends object, INITIAL_PROPS extends object>(config: IConfig) => (Component: any) => NextComponentType<IAppContext, INITIAL_PROPS, PROPS>;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.withAuthenticate = void 0;
|
30
|
+
const react_1 = __importStar(require("react"));
|
31
|
+
const api_1 = require("../../api");
|
32
|
+
const config_1 = require("../../config");
|
33
|
+
const UnauthorizedError_1 = require("../../errors/UnauthorizedError");
|
34
|
+
const user_1 = require("../redux/user");
|
35
|
+
const cms_authorizator_1 = __importDefault(require("../security/cms-authorizator"));
|
36
|
+
// TODO component any
|
37
|
+
const withAuthenticate = (config) => (Component) => {
|
38
|
+
var _a;
|
39
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
40
|
+
return (_a = class extends react_1.Component {
|
41
|
+
static async getInitialProps(ctx) {
|
42
|
+
let user = ctx.reduxStore.getState().user.user;
|
43
|
+
if (!user) {
|
44
|
+
user = config_1.container.has("api.getLoggedUser")
|
45
|
+
? await config_1.container.get("api.getLoggedUser")(ctx)
|
46
|
+
: await (0, api_1.getLoggedUser)(ctx);
|
47
|
+
ctx.reduxStore.dispatch((0, user_1.onUserPersist)(user));
|
48
|
+
}
|
49
|
+
if (config.allowedRoles && !cms_authorizator_1.default.isGranted(config.allowedRoles, user.roles)) {
|
50
|
+
throw new UnauthorizedError_1.UnauthorizedError();
|
51
|
+
}
|
52
|
+
return typeof Component.getInitialProps === "function" ? await Component.getInitialProps(ctx) : {};
|
53
|
+
}
|
54
|
+
render() {
|
55
|
+
return react_1.default.createElement(Component, { ...this.props });
|
56
|
+
}
|
57
|
+
},
|
58
|
+
_a.displayName = "withAuthenticateHOC",
|
59
|
+
_a);
|
60
|
+
}; // TODO!
|
61
|
+
exports.withAuthenticate = withAuthenticate;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.initializeStore = void 0;
|
7
|
+
const extension_1 = require("@redux-devtools/extension");
|
8
|
+
const redux_1 = require("redux");
|
9
|
+
const reducer_1 = __importDefault(require("../redux/entities/reducer"));
|
10
|
+
const reducer_2 = __importDefault(require("../redux/user/reducer"));
|
11
|
+
// TODO: create root reducer to have possibility reset store on logout...
|
12
|
+
const initializeStore = (initialState = {}) => (0, redux_1.createStore)((0, redux_1.combineReducers)({
|
13
|
+
entities: reducer_1.default,
|
14
|
+
user: reducer_2.default,
|
15
|
+
}), initialState, (0, extension_1.composeWithDevTools)((0, redux_1.applyMiddleware)()));
|
16
|
+
exports.initializeStore = initializeStore;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Schema } from "@uxf/data-grid";
|
2
|
+
import { EntityMetaSchema } from "../../../api";
|
3
|
+
import { EntityFormSchema } from "../../types/form";
|
4
|
+
import { ActionsUnion } from "../redux-helper";
|
5
|
+
export interface IState {
|
6
|
+
meta: Record<string, EntityMetaSchema>;
|
7
|
+
form: Record<string, EntityFormSchema>;
|
8
|
+
grid: Record<string, Schema<any>>;
|
9
|
+
}
|
10
|
+
export declare const onSetEntityMetaSchemas: (meta: Record<string, EntityMetaSchema>) => import("../redux-helper").IPayloadAction<"entities/SET_META_SCHEMAS", Record<string, EntityMetaSchema>>;
|
11
|
+
export declare const onSetFormSchema: (entityAlias: string, form: EntityFormSchema) => import("../redux-helper").IPayloadAction<"entities/SET_FORM_SCHEMA", {
|
12
|
+
entityAlias: string;
|
13
|
+
form: EntityFormSchema;
|
14
|
+
}>;
|
15
|
+
export declare const onSetGridSchema: (entityAlias: string, grid: Schema<any>) => import("../redux-helper").IPayloadAction<"entities/SET_GRID_SCHEMA", {
|
16
|
+
entityAlias: string;
|
17
|
+
grid: Schema<any>;
|
18
|
+
}>;
|
19
|
+
export declare const Actions: {
|
20
|
+
onSetEntityMetaSchemas: (meta: Record<string, EntityMetaSchema>) => import("../redux-helper").IPayloadAction<"entities/SET_META_SCHEMAS", Record<string, EntityMetaSchema>>;
|
21
|
+
onSetFormSchema: (entityAlias: string, form: EntityFormSchema) => import("../redux-helper").IPayloadAction<"entities/SET_FORM_SCHEMA", {
|
22
|
+
entityAlias: string;
|
23
|
+
form: EntityFormSchema;
|
24
|
+
}>;
|
25
|
+
onSetGridSchema: (entityAlias: string, grid: Schema<any>) => import("../redux-helper").IPayloadAction<"entities/SET_GRID_SCHEMA", {
|
26
|
+
entityAlias: string;
|
27
|
+
grid: Schema<any>;
|
28
|
+
}>;
|
29
|
+
};
|
30
|
+
export type ActionTypes = ActionsUnion<typeof Actions>;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Actions = exports.onSetGridSchema = exports.onSetFormSchema = exports.onSetEntityMetaSchemas = void 0;
|
4
|
+
const redux_helper_1 = require("../redux-helper");
|
5
|
+
const onSetEntityMetaSchemas = (meta) => (0, redux_helper_1.createAction)("entities/SET_META_SCHEMAS", meta);
|
6
|
+
exports.onSetEntityMetaSchemas = onSetEntityMetaSchemas;
|
7
|
+
const onSetFormSchema = (entityAlias, form) => (0, redux_helper_1.createAction)("entities/SET_FORM_SCHEMA", { entityAlias, form });
|
8
|
+
exports.onSetFormSchema = onSetFormSchema;
|
9
|
+
const onSetGridSchema = (entityAlias, grid) => (0, redux_helper_1.createAction)("entities/SET_GRID_SCHEMA", { entityAlias, grid });
|
10
|
+
exports.onSetGridSchema = onSetGridSchema;
|
11
|
+
exports.Actions = {
|
12
|
+
onSetEntityMetaSchemas: exports.onSetEntityMetaSchemas,
|
13
|
+
onSetFormSchema: exports.onSetFormSchema,
|
14
|
+
onSetGridSchema: exports.onSetGridSchema,
|
15
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./actions"), exports);
|
18
|
+
__exportStar(require("./selectors"), exports);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const initialState = {
|
4
|
+
meta: {},
|
5
|
+
form: {},
|
6
|
+
grid: {},
|
7
|
+
};
|
8
|
+
const entitiesReducer = (state = initialState, action) => {
|
9
|
+
// tslint:disable-next-line:no-small-switch
|
10
|
+
switch (action.type) {
|
11
|
+
case "entities/SET_META_SCHEMAS":
|
12
|
+
return {
|
13
|
+
...state,
|
14
|
+
meta: action.payload,
|
15
|
+
};
|
16
|
+
case "entities/SET_FORM_SCHEMA":
|
17
|
+
return {
|
18
|
+
...state,
|
19
|
+
form: {
|
20
|
+
...state.form,
|
21
|
+
[action.payload.entityAlias]: action.payload.form,
|
22
|
+
},
|
23
|
+
};
|
24
|
+
case "entities/SET_GRID_SCHEMA":
|
25
|
+
return {
|
26
|
+
...state,
|
27
|
+
grid: {
|
28
|
+
...state.grid,
|
29
|
+
[action.payload.entityAlias]: action.payload.grid,
|
30
|
+
},
|
31
|
+
};
|
32
|
+
default:
|
33
|
+
return state;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
exports.default = entitiesReducer;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Schema } from "@uxf/data-grid";
|
2
|
+
import { EntityMetaSchema } from "../../../api";
|
3
|
+
import { EntityFormSchema } from "../../types/form";
|
4
|
+
import { IReduxState } from "../types";
|
5
|
+
export declare const metaSchemaExistsSelector: (state: IReduxState) => boolean;
|
6
|
+
export declare const metaSchemaSelector: (entityAlias: string) => (state: IReduxState) => EntityMetaSchema;
|
7
|
+
export declare const gridSchemaExistsSelector: (entityAlias: string) => (state: IReduxState) => boolean;
|
8
|
+
export declare const gridSchemaSelector: (entityAlias: string) => (state: IReduxState) => Schema<any>;
|
9
|
+
export declare const formSchemaExistsSelector: (entityAlias: string) => (state: IReduxState) => boolean;
|
10
|
+
export declare const formSchemaSelector: (entityAlias: string) => (state: IReduxState) => EntityFormSchema;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.formSchemaSelector = exports.formSchemaExistsSelector = exports.gridSchemaSelector = exports.gridSchemaExistsSelector = exports.metaSchemaSelector = exports.metaSchemaExistsSelector = void 0;
|
4
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
5
|
+
const metaSchemaExistsSelector = (state) => Object.keys(state.entities.meta).length > 0;
|
6
|
+
exports.metaSchemaExistsSelector = metaSchemaExistsSelector;
|
7
|
+
const metaSchemaSelector = (entityAlias) => (state) => state.entities.meta[entityAlias];
|
8
|
+
exports.metaSchemaSelector = metaSchemaSelector;
|
9
|
+
const gridSchemaExistsSelector = (entityAlias) => (state) => (0, is_not_nil_1.isNotNil)(state.entities.grid[entityAlias]);
|
10
|
+
exports.gridSchemaExistsSelector = gridSchemaExistsSelector;
|
11
|
+
const gridSchemaSelector = (entityAlias) => (state) => state.entities.grid[entityAlias];
|
12
|
+
exports.gridSchemaSelector = gridSchemaSelector;
|
13
|
+
const formSchemaExistsSelector = (entityAlias) => (state) => (0, is_not_nil_1.isNotNil)(state.entities.form[entityAlias]);
|
14
|
+
exports.formSchemaExistsSelector = formSchemaExistsSelector;
|
15
|
+
const formSchemaSelector = (entityAlias) => (state) => state.entities.form[entityAlias];
|
16
|
+
exports.formSchemaSelector = formSchemaSelector;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
exports.withReduxStore = exports.useSelector = void 0;
|
18
|
+
var react_redux_1 = require("react-redux");
|
19
|
+
Object.defineProperty(exports, "useSelector", { enumerable: true, get: function () { return react_redux_1.useSelector; } });
|
20
|
+
__exportStar(require("./types"), exports);
|
21
|
+
var with_redux_store_1 = require("./with-redux-store");
|
22
|
+
Object.defineProperty(exports, "withReduxStore", { enumerable: true, get: function () { return with_redux_store_1.withReduxStore; } });
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Action as ReduxAction } from "redux";
|
2
|
+
export interface IAction<T extends string> extends ReduxAction {
|
3
|
+
type: T;
|
4
|
+
}
|
5
|
+
export interface IPayloadAction<T extends string, P> extends IAction<T> {
|
6
|
+
payload: P;
|
7
|
+
}
|
8
|
+
export declare function createAction<T extends string>(type: T): IAction<T>;
|
9
|
+
export declare function createAction<T extends string, P>(type: T, payload: P): IPayloadAction<T, P>;
|
10
|
+
type FunctionType = (...args: any[]) => any;
|
11
|
+
interface IActionCreatorsMapObject {
|
12
|
+
[actionCreator: string]: FunctionType;
|
13
|
+
}
|
14
|
+
export type ActionsUnion<A extends IActionCreatorsMapObject> = ReturnType<A[keyof A]>;
|
15
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ActionTypes as EntitiesActionTypes, IState as IEntitiesState } from "../redux/entities/actions";
|
2
|
+
import { IState as IUserState, ActionTypes as UserActionTypes } from "../redux/user/actions";
|
3
|
+
export interface IReduxState {
|
4
|
+
entities: IEntitiesState;
|
5
|
+
user: IUserState;
|
6
|
+
}
|
7
|
+
export type ActionTypes = EntitiesActionTypes | UserActionTypes;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import UserResponse from "../../../api";
|
2
|
+
import { ActionsUnion } from "../redux-helper";
|
3
|
+
export declare const USER_LOGOUT = "user/LOGOUT";
|
4
|
+
export declare const USER_PERSIST = "user/PERSIST";
|
5
|
+
export declare const onUserPersist: (user: UserResponse) => import("../redux-helper").IPayloadAction<"user/PERSIST", {
|
6
|
+
user: UserResponse;
|
7
|
+
}>;
|
8
|
+
export declare const onUserLogout: () => import("../redux-helper").IAction<"user/LOGOUT">;
|
9
|
+
export interface IState {
|
10
|
+
user?: UserResponse;
|
11
|
+
loginLoading?: boolean;
|
12
|
+
}
|
13
|
+
export declare const Actions: {
|
14
|
+
onUserPersist: (user: UserResponse) => import("../redux-helper").IPayloadAction<"user/PERSIST", {
|
15
|
+
user: UserResponse;
|
16
|
+
}>;
|
17
|
+
onUserLogout: () => import("../redux-helper").IAction<"user/LOGOUT">;
|
18
|
+
};
|
19
|
+
export type ActionTypes = ActionsUnion<typeof Actions>;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Actions = exports.onUserLogout = exports.onUserPersist = exports.USER_PERSIST = exports.USER_LOGOUT = void 0;
|
4
|
+
const redux_helper_1 = require("../redux-helper");
|
5
|
+
exports.USER_LOGOUT = "user/LOGOUT";
|
6
|
+
exports.USER_PERSIST = "user/PERSIST";
|
7
|
+
const onUserPersist = (user) => (0, redux_helper_1.createAction)(exports.USER_PERSIST, { user });
|
8
|
+
exports.onUserPersist = onUserPersist;
|
9
|
+
const onUserLogout = () => (0, redux_helper_1.createAction)(exports.USER_LOGOUT);
|
10
|
+
exports.onUserLogout = onUserLogout;
|
11
|
+
exports.Actions = {
|
12
|
+
onUserPersist: exports.onUserPersist,
|
13
|
+
onUserLogout: exports.onUserLogout,
|
14
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./actions"), exports);
|
18
|
+
__exportStar(require("./selectors"), exports);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const initialState = {};
|
4
|
+
const reducer = (state = initialState, action) => {
|
5
|
+
switch (action.type) {
|
6
|
+
case "user/LOGOUT":
|
7
|
+
return {
|
8
|
+
...state,
|
9
|
+
loginLoading: undefined,
|
10
|
+
user: undefined,
|
11
|
+
};
|
12
|
+
case "user/PERSIST":
|
13
|
+
return {
|
14
|
+
...state,
|
15
|
+
...action.payload,
|
16
|
+
};
|
17
|
+
default:
|
18
|
+
return state;
|
19
|
+
}
|
20
|
+
};
|
21
|
+
exports.default = reducer;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const withReduxStore: (App: any) => any;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
exports.withReduxStore = void 0;
|
27
|
+
const react_1 = __importStar(require("react"));
|
28
|
+
const react_redux_1 = require("react-redux");
|
29
|
+
const configure_store_1 = require("./configure-store");
|
30
|
+
const isServer = typeof window === "undefined";
|
31
|
+
const __NEXT_REDUX_STORE__ = "__NEXT_REDUX_STORE__";
|
32
|
+
const getOrCreateStore = (initialState = {}) => {
|
33
|
+
// Always make a new store if server, otherwise state is shared between requests
|
34
|
+
if (isServer) {
|
35
|
+
return (0, configure_store_1.initializeStore)(initialState);
|
36
|
+
}
|
37
|
+
// Create store if unavailable on the client and set it on the window object
|
38
|
+
if (!window[__NEXT_REDUX_STORE__]) {
|
39
|
+
window[__NEXT_REDUX_STORE__] = (0, configure_store_1.initializeStore)(initialState);
|
40
|
+
}
|
41
|
+
return window[__NEXT_REDUX_STORE__];
|
42
|
+
};
|
43
|
+
const withReduxStore = (App) => {
|
44
|
+
return class AppWithRedux extends react_1.Component {
|
45
|
+
static async getInitialProps(appContext) {
|
46
|
+
// Get or Create the store with `undefined` as initialState
|
47
|
+
// This allows you to set a custom default initialState
|
48
|
+
const reduxStore = getOrCreateStore();
|
49
|
+
// Provide the store to getInitialProps of pages
|
50
|
+
appContext.ctx.reduxStore = reduxStore;
|
51
|
+
let appProps = {};
|
52
|
+
if (typeof App.getInitialProps === "function") {
|
53
|
+
appProps = await App.getInitialProps(appContext);
|
54
|
+
}
|
55
|
+
return {
|
56
|
+
...appProps,
|
57
|
+
initialReduxState: reduxStore.getState(),
|
58
|
+
};
|
59
|
+
}
|
60
|
+
constructor(props) {
|
61
|
+
super(props);
|
62
|
+
this.reduxStore = getOrCreateStore(props.initialReduxState);
|
63
|
+
}
|
64
|
+
render() {
|
65
|
+
return (react_1.default.createElement(react_redux_1.Provider, { store: this.reduxStore },
|
66
|
+
react_1.default.createElement(App, { ...this.props })));
|
67
|
+
}
|
68
|
+
};
|
69
|
+
};
|
70
|
+
exports.withReduxStore = withReduxStore;
|