@uxf/cms 11.81.0 → 11.83.0
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/deprecated/hoc/with-authenticate.d.ts +5 -3
- package/deprecated/hoc/with-authenticate.js +6 -9
- package/package.json +1 -4
- package/pages/content-builder/content-builder-page.d.ts +2 -1
- package/pages/content-builder/content-builder-page.js +16 -17
- package/pages/content-builder/types.d.ts +0 -2
- package/pages/invite-user-page/invite-user-page.d.ts +2 -1
- package/pages/invite-user-page/invite-user-page.js +2 -2
- package/deprecated/api/api-client.d.ts +0 -15
- package/deprecated/api/api-client.js +0 -86
- package/deprecated/redux/configure-store.d.ts +0 -3
- package/deprecated/redux/configure-store.js +0 -16
- package/deprecated/redux/entities/actions.d.ts +0 -30
- package/deprecated/redux/entities/actions.js +0 -15
- package/deprecated/redux/entities/index.d.ts +0 -2
- package/deprecated/redux/entities/index.js +0 -18
- package/deprecated/redux/entities/reducer.d.ts +0 -3
- package/deprecated/redux/entities/reducer.js +0 -36
- package/deprecated/redux/entities/selectors.d.ts +0 -10
- package/deprecated/redux/entities/selectors.js +0 -16
- package/deprecated/redux/index.d.ts +0 -3
- package/deprecated/redux/index.js +0 -22
- package/deprecated/redux/redux-helper.d.ts +0 -15
- package/deprecated/redux/redux-helper.js +0 -6
- package/deprecated/redux/types.d.ts +0 -7
- package/deprecated/redux/types.js +0 -2
- package/deprecated/redux/user/actions.d.ts +0 -19
- package/deprecated/redux/user/actions.js +0 -14
- package/deprecated/redux/user/index.d.ts +0 -2
- package/deprecated/redux/user/index.js +0 -18
- package/deprecated/redux/user/reducer.d.ts +0 -3
- package/deprecated/redux/user/reducer.js +0 -21
- package/deprecated/redux/user/selectors.d.ts +0 -3
- package/deprecated/redux/user/selectors.js +0 -5
- package/deprecated/redux/with-redux-store.d.ts +0 -1
- package/deprecated/redux/with-redux-store.js +0 -70
- package/deprecated/types/app.d.ts +0 -6
- package/deprecated/types/app.js +0 -2
- package/deprecated/types/form.d.ts +0 -25
- package/deprecated/types/form.js +0 -16
- package/pages/grid-page/get-initial-props-helper.d.ts +0 -4
- package/pages/grid-page/get-initial-props-helper.js +0 -20
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { NextComponentType } from "next";
|
|
2
|
-
import { IAppContext } from "../types/app";
|
|
1
|
+
import { NextComponentType, NextPageContext } from "next";
|
|
3
2
|
export interface IConfig {
|
|
4
3
|
allowedRoles?: string[];
|
|
5
4
|
}
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use restrictedPage instead
|
|
7
|
+
*/
|
|
8
|
+
export declare const withAuthenticate: <PROPS extends object, INITIAL_PROPS extends object>(config: IConfig) => (Component: any) => NextComponentType<NextPageContext, INITIAL_PROPS, PROPS>;
|
|
@@ -31,21 +31,18 @@ const react_1 = __importStar(require("react"));
|
|
|
31
31
|
const api_1 = require("../../api");
|
|
32
32
|
const config_1 = require("../../config");
|
|
33
33
|
const UnauthorizedError_1 = require("../../errors/UnauthorizedError");
|
|
34
|
-
const user_1 = require("../redux/user");
|
|
35
34
|
const cms_authorizator_1 = __importDefault(require("../security/cms-authorizator"));
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use restrictedPage instead
|
|
37
|
+
*/
|
|
37
38
|
const withAuthenticate = (config) => (Component) => {
|
|
38
39
|
var _a;
|
|
39
40
|
// eslint-disable-next-line import/no-named-as-default-member
|
|
40
41
|
return (_a = class extends react_1.Component {
|
|
41
42
|
static async getInitialProps(ctx) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
}
|
|
43
|
+
const user = config_1.container.has("api.getLoggedUser")
|
|
44
|
+
? await config_1.container.get("api.getLoggedUser")(ctx)
|
|
45
|
+
: await (0, api_1.getLoggedUser)(ctx);
|
|
49
46
|
if (config.allowedRoles && !cms_authorizator_1.default.isGranted(config.allowedRoles, user.roles)) {
|
|
50
47
|
throw new UnauthorizedError_1.UnauthorizedError();
|
|
51
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/cms",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.83.0",
|
|
4
4
|
"description": "UXF Cms",
|
|
5
5
|
"author": "UXFans <dev@uxf.cz>",
|
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/cms#readme",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"@dnd-kit/sortable": "8.0.0",
|
|
30
30
|
"@dnd-kit/utilities": "3.2.2",
|
|
31
31
|
"@floating-ui/react": "0.26.28",
|
|
32
|
-
"@redux-devtools/extension": "3.3.0",
|
|
33
32
|
"@uxf/core": "11.80.4",
|
|
34
33
|
"@uxf/core-react": "11.80.4",
|
|
35
34
|
"@uxf/data-grid": "11.80.6",
|
|
@@ -42,8 +41,6 @@
|
|
|
42
41
|
"es6-error": "4.1.1",
|
|
43
42
|
"qs": "6.13.0",
|
|
44
43
|
"react-hook-form": "7.53.0",
|
|
45
|
-
"react-redux": "8.1.3",
|
|
46
|
-
"redux": "4.2.1",
|
|
47
44
|
"swr": "2.3.3"
|
|
48
45
|
},
|
|
49
46
|
"peerDependencies": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { Content, ContentBuilderConfig } from "./types";
|
|
2
3
|
/** @deprecated use ContentBuilder from @uxf/cms/content-builder */
|
|
3
|
-
export declare const ContentBuilderPage: <T extends Content<string, any>>(config: ContentBuilderConfig<T>) =>
|
|
4
|
+
export declare const ContentBuilderPage: <T extends Content<string, any>>(config: ContentBuilderConfig<T>) => (props: any) => React.JSX.Element;
|
|
@@ -24,22 +24,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ContentBuilderPage = void 0;
|
|
27
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
27
28
|
const router_1 = require("@uxf/router");
|
|
29
|
+
const router_2 = require("next/router");
|
|
28
30
|
const react_1 = __importStar(require("react"));
|
|
29
31
|
const api_1 = require("../../api");
|
|
30
32
|
const config_1 = require("../../config");
|
|
31
|
-
const
|
|
33
|
+
const restricted_page_1 = require("../../security/restricted-page");
|
|
32
34
|
const form_1 = require("./components/form");
|
|
33
35
|
const mapper_1 = require("./mapper");
|
|
34
36
|
const DefaultLayout = (props) => react_1.default.createElement("div", { ...props });
|
|
35
|
-
const defaultInitialValues = async (
|
|
36
|
-
const contentId = ctx.query.id ? (0, router_1.queryParamToNumber)(ctx.query.id) : null;
|
|
37
|
+
const defaultInitialValues = async (id) => {
|
|
37
38
|
const date = new Date();
|
|
38
39
|
date.setHours(0);
|
|
39
40
|
date.setMinutes(0);
|
|
40
41
|
date.setMilliseconds(0);
|
|
41
|
-
return
|
|
42
|
-
? await (0, api_1.contentGet)(
|
|
42
|
+
return id
|
|
43
|
+
? await (0, api_1.contentGet)(null, id).then((r) => (0, mapper_1.mapResponseToFormData)(r.data))
|
|
43
44
|
: {
|
|
44
45
|
name: "",
|
|
45
46
|
type: null,
|
|
@@ -90,18 +91,16 @@ const ContentBuilderPageComponent = (props) => {
|
|
|
90
91
|
ContentBuilderPageComponent.displayName = "ContentBuilderComponent";
|
|
91
92
|
/** @deprecated use ContentBuilder from @uxf/cms/content-builder */
|
|
92
93
|
const ContentBuilderPage = (config) => {
|
|
93
|
-
const Page = (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
initialValues: typeof initialValues === "function" ? await initialValues(ctx) : initialValues,
|
|
103
|
-
};
|
|
94
|
+
const Page = () => {
|
|
95
|
+
var _a;
|
|
96
|
+
const router = (0, router_2.useRouter)();
|
|
97
|
+
const id = (_a = (0, router_1.queryParamToNumber)(router.query.id)) !== null && _a !== void 0 ? _a : null;
|
|
98
|
+
const [initialValues, setInitialValues] = (0, react_1.useState)(null);
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
100
|
+
defaultInitialValues(id).then((r) => setInitialValues(r));
|
|
101
|
+
}, [id]);
|
|
102
|
+
return ((0, is_not_nil_1.isNotNil)(initialValues) && (react_1.default.createElement(ContentBuilderPageComponent, { config: config, id: id, initialValues: initialValues, key: id })));
|
|
104
103
|
};
|
|
105
|
-
return (0,
|
|
104
|
+
return (0, restricted_page_1.restrictedPage)(Page, { allowedRole: config.allowedRoles || ["ROLE_ROOT"] });
|
|
106
105
|
};
|
|
107
106
|
exports.ContentBuilderPage = ContentBuilderPage;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FileResponse } from "@uxf/core/types";
|
|
2
2
|
import { SelectProps } from "@uxf/form/select";
|
|
3
3
|
import { ComboboxValue } from "@uxf/ui/combobox";
|
|
4
|
-
import { NextPageContext } from "next";
|
|
5
4
|
import { FC, PropsWithChildren, ReactNode } from "react";
|
|
6
5
|
import { Control, ControllerRenderProps } from "react-hook-form";
|
|
7
6
|
import { ContentResponse, ContentTagResponse } from "../../api";
|
|
@@ -72,7 +71,6 @@ export interface ContentBuilderConfig<Contents extends Content<string, any>> {
|
|
|
72
71
|
contentComponents: ContentComponent<any>[];
|
|
73
72
|
onSubmit?: (contentId: number | null, values: RootContent<Contents>) => Promise<ContentResponse>;
|
|
74
73
|
onSubmitSuccess?: (contentId: number | null, values: RootContent<Contents>, response: ContentResponse) => Promise<void>;
|
|
75
|
-
initialValues?: RootContent<Contents> | ((ctx: NextPageContext) => Promise<RootContent<Contents>>);
|
|
76
74
|
allowedRoles?: string[];
|
|
77
75
|
ui: {
|
|
78
76
|
Layout?: FC<PropsWithChildren>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { InviteUserPageConfig } from "./types";
|
|
2
|
-
export declare const InviteUserPage: (config: InviteUserPageConfig) =>
|
|
3
|
+
export declare const InviteUserPage: (config: InviteUserPageConfig) => (props: any) => React.JSX.Element;
|
|
@@ -26,8 +26,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.InviteUserPage = void 0;
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
|
-
const with_authenticate_1 = require("../../deprecated/hoc/with-authenticate");
|
|
30
29
|
const invite_user_form_1 = require("../../forms/invite-user-form");
|
|
30
|
+
const restricted_page_1 = require("../../security/restricted-page");
|
|
31
31
|
const INITIAL_VALUES = {
|
|
32
32
|
name: "",
|
|
33
33
|
surname: "",
|
|
@@ -52,6 +52,6 @@ const InviteUserPage = (config) => {
|
|
|
52
52
|
children: Content,
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
|
-
return (0,
|
|
55
|
+
return (0, restricted_page_1.restrictedPage)(Component, { allowedRole: config.allowedRoles || ["ROLE_ROOT"] });
|
|
56
56
|
};
|
|
57
57
|
exports.InviteUserPage = InviteUserPage;
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,30 +0,0 @@
|
|
|
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>;
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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);
|
|
@@ -1,36 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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; } });
|
|
@@ -1,15 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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>;
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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);
|
|
@@ -1,21 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const withReduxStore: (App: any) => any;
|
|
@@ -1,70 +0,0 @@
|
|
|
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;
|
package/deprecated/types/app.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface FieldSchema {
|
|
2
|
-
name: string;
|
|
3
|
-
type: string;
|
|
4
|
-
label: string;
|
|
5
|
-
required: boolean;
|
|
6
|
-
readOnly: boolean;
|
|
7
|
-
editable: boolean;
|
|
8
|
-
fields: FieldSchema[] | null;
|
|
9
|
-
autocompleteName?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface EntityFormSchema {
|
|
12
|
-
fields: FieldSchema[];
|
|
13
|
-
}
|
|
14
|
-
export declare enum FormTypes {
|
|
15
|
-
TEXT = "text",
|
|
16
|
-
BOOLEAN = "boolean",
|
|
17
|
-
DATE = "date",
|
|
18
|
-
DATETIME = "datetime",
|
|
19
|
-
MANY_TO_MANY = "manyToMany",
|
|
20
|
-
MANY_TO_ONE = "manyToOne",
|
|
21
|
-
ONE_TO_MANY = "oneToMany",
|
|
22
|
-
ONE_TO_ONE = "oneToOne",
|
|
23
|
-
ONE_TO_ONE_FIELDSET = "oneToOneFieldset",
|
|
24
|
-
EMBEDDED = "embedded"
|
|
25
|
-
}
|
package/deprecated/types/form.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormTypes = void 0;
|
|
4
|
-
var FormTypes;
|
|
5
|
-
(function (FormTypes) {
|
|
6
|
-
FormTypes["TEXT"] = "text";
|
|
7
|
-
FormTypes["BOOLEAN"] = "boolean";
|
|
8
|
-
FormTypes["DATE"] = "date";
|
|
9
|
-
FormTypes["DATETIME"] = "datetime";
|
|
10
|
-
FormTypes["MANY_TO_MANY"] = "manyToMany";
|
|
11
|
-
FormTypes["MANY_TO_ONE"] = "manyToOne";
|
|
12
|
-
FormTypes["ONE_TO_MANY"] = "oneToMany";
|
|
13
|
-
FormTypes["ONE_TO_ONE"] = "oneToOne";
|
|
14
|
-
FormTypes["ONE_TO_ONE_FIELDSET"] = "oneToOneFieldset";
|
|
15
|
-
FormTypes["EMBEDDED"] = "embedded";
|
|
16
|
-
})(FormTypes || (exports.FormTypes = FormTypes = {}));
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Schema } from "@uxf/data-grid";
|
|
2
|
-
import { EntityMetaSchema } from "../../api";
|
|
3
|
-
export declare function loadEntityMetaSchema(ctx: any, entityAlias: string): Promise<EntityMetaSchema>;
|
|
4
|
-
export declare function loadEntityGridSchema(ctx: any, entityAlias: string): Promise<Schema<any>>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadEntityMetaSchema = loadEntityMetaSchema;
|
|
4
|
-
exports.loadEntityGridSchema = loadEntityGridSchema;
|
|
5
|
-
const api_1 = require("../../api");
|
|
6
|
-
const entities_1 = require("../../deprecated/redux/entities");
|
|
7
|
-
async function loadEntityMetaSchema(ctx, entityAlias) {
|
|
8
|
-
const { reduxStore: { getState, dispatch }, } = ctx;
|
|
9
|
-
if (!(0, entities_1.metaSchemaExistsSelector)(getState())) {
|
|
10
|
-
dispatch((0, entities_1.onSetEntityMetaSchemas)((await (0, api_1.getEntityMetaSchemas)(ctx)).data));
|
|
11
|
-
}
|
|
12
|
-
return (0, entities_1.metaSchemaSelector)(entityAlias)(getState());
|
|
13
|
-
}
|
|
14
|
-
async function loadEntityGridSchema(ctx, entityAlias) {
|
|
15
|
-
const { reduxStore: { getState, dispatch }, } = ctx;
|
|
16
|
-
if (!(0, entities_1.gridSchemaExistsSelector)(entityAlias)(getState())) {
|
|
17
|
-
dispatch((0, entities_1.onSetGridSchema)(entityAlias, (await (0, api_1.dataGridSchemaGet)(ctx, entityAlias)).data));
|
|
18
|
-
}
|
|
19
|
-
return (0, entities_1.gridSchemaSelector)(entityAlias)(getState());
|
|
20
|
-
}
|