@tsed/react-formio 1.14.1 → 2.0.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/coverage.json +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1277 -3684
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +956 -2767
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -5
- package/readme.md +9 -57
- package/src/components/input-tags/inputTags.component.tsx +1 -1
- package/src/components/select/select.component.tsx +1 -1
- package/src/components/table/filters/sliderColumnFilter.component.tsx +2 -2
- package/src/index.ts +3 -2
- package/dist/stores/action/action.actions.d.ts +0 -9
- package/dist/stores/action/action.actions.spec.d.ts +0 -1
- package/dist/stores/action/action.constant.d.ts +0 -1
- package/dist/stores/action/action.reducers.d.ts +0 -7
- package/dist/stores/action/action.reducers.spec.d.ts +0 -1
- package/dist/stores/action/action.selectors.d.ts +0 -2
- package/dist/stores/action/action.selectors.spec.d.ts +0 -1
- package/dist/stores/action/index.d.ts +0 -4
- package/dist/stores/action-info/action-info.actions.d.ts +0 -5
- package/dist/stores/action-info/action-info.actions.spec.d.ts +0 -1
- package/dist/stores/action-info/action-info.constant.d.ts +0 -1
- package/dist/stores/action-info/action-info.reducers.d.ts +0 -7
- package/dist/stores/action-info/action-info.reducers.spec.d.ts +0 -1
- package/dist/stores/action-info/action-info.selectors.d.ts +0 -2
- package/dist/stores/action-info/action-info.selectors.spec.d.ts +0 -1
- package/dist/stores/action-info/index.d.ts +0 -4
- package/dist/stores/actions/actions.actions.d.ts +0 -5
- package/dist/stores/actions/actions.actions.spec.d.ts +0 -1
- package/dist/stores/actions/actions.constant.d.ts +0 -1
- package/dist/stores/actions/actions.reducers.d.ts +0 -8
- package/dist/stores/actions/actions.reducers.spec.d.ts +0 -1
- package/dist/stores/actions/actions.selectors.d.ts +0 -2
- package/dist/stores/actions/actions.selectors.spec.d.ts +0 -1
- package/dist/stores/actions/index.d.ts +0 -4
- package/dist/stores/auth/auth.actions.d.ts +0 -9
- package/dist/stores/auth/auth.constant.d.ts +0 -1
- package/dist/stores/auth/auth.reducers.d.ts +0 -16
- package/dist/stores/auth/auth.reducers.spec.d.ts +0 -1
- package/dist/stores/auth/auth.selectors.d.ts +0 -6
- package/dist/stores/auth/auth.selectors.spec.d.ts +0 -1
- package/dist/stores/auth/auth.utils.d.ts +0 -6
- package/dist/stores/auth/auth.utils.spec.d.ts +0 -1
- package/dist/stores/auth/getAccess.action.d.ts +0 -1
- package/dist/stores/auth/getAccess.action.spec.d.ts +0 -1
- package/dist/stores/auth/getProjectAccess.action.d.ts +0 -1
- package/dist/stores/auth/index.d.ts +0 -10
- package/dist/stores/auth/initAuth.action.d.ts +0 -1
- package/dist/stores/auth/initAuth.action.spec.d.ts +0 -1
- package/dist/stores/auth/logout.action.d.ts +0 -1
- package/dist/stores/auth/logout.action.spec.d.ts +0 -1
- package/dist/stores/auth/setUser.action.d.ts +0 -1
- package/dist/stores/auth/setUser.action.spec.d.ts +0 -1
- package/dist/stores/form/form.actions.d.ts +0 -10
- package/dist/stores/form/form.actions.spec.d.ts +0 -1
- package/dist/stores/form/form.reducers.d.ts +0 -9
- package/dist/stores/form/form.reducers.spec.d.ts +0 -1
- package/dist/stores/form/form.selectors.d.ts +0 -2
- package/dist/stores/form/form.selectors.spec.d.ts +0 -1
- package/dist/stores/form/index.d.ts +0 -3
- package/dist/stores/forms/forms.actions.d.ts +0 -9
- package/dist/stores/forms/forms.actions.spec.d.ts +0 -1
- package/dist/stores/forms/forms.reducers.d.ts +0 -16
- package/dist/stores/forms/forms.reducers.spec.d.ts +0 -1
- package/dist/stores/forms/forms.selectors.d.ts +0 -10
- package/dist/stores/forms/forms.selectors.spec.d.ts +0 -1
- package/dist/stores/forms/index.d.ts +0 -3
- package/dist/stores/index.d.ts +0 -10
- package/dist/stores/index.spec.d.ts +0 -1
- package/dist/stores/root/index.d.ts +0 -1
- package/dist/stores/root/root.selectors.d.ts +0 -5
- package/dist/stores/root/root.selectors.spec.d.ts +0 -1
- package/dist/stores/submission/index.d.ts +0 -3
- package/dist/stores/submission/submission.actions.d.ts +0 -10
- package/dist/stores/submission/submission.actions.spec.d.ts +0 -1
- package/dist/stores/submission/submission.reducers.d.ts +0 -11
- package/dist/stores/submission/submission.reducers.spec.d.ts +0 -1
- package/dist/stores/submission/submission.selectors.d.ts +0 -2
- package/dist/stores/submission/submission.selectors.spec.d.ts +0 -1
- package/dist/stores/submissions/index.d.ts +0 -3
- package/dist/stores/submissions/submissions.actions.d.ts +0 -6
- package/dist/stores/submissions/submissions.actions.spec.d.ts +0 -1
- package/dist/stores/submissions/submissions.reducers.d.ts +0 -17
- package/dist/stores/submissions/submissions.reducers.spec.d.ts +0 -1
- package/dist/stores/submissions/submissions.selectors.d.ts +0 -9
- package/dist/stores/submissions/submissions.selectors.spec.d.ts +0 -1
- package/dist/utils/clean.d.ts +0 -1
- package/dist/utils/clean.test.d.ts +0 -1
- package/dist/utils/mapRequestParams.d.ts +0 -9
- package/dist/utils/mapRequestParams.test.d.ts +0 -1
- package/dist/utils/url.d.ts +0 -3
- package/dist/utils/url.test.d.ts +0 -1
- package/src/stores/action/action.actions.spec.ts +0 -114
- package/src/stores/action/action.actions.ts +0 -82
- package/src/stores/action/action.constant.ts +0 -1
- package/src/stores/action/action.reducers.spec.ts +0 -91
- package/src/stores/action/action.reducers.ts +0 -54
- package/src/stores/action/action.selectors.spec.ts +0 -19
- package/src/stores/action/action.selectors.ts +0 -6
- package/src/stores/action/index.ts +0 -4
- package/src/stores/action-info/action-info.actions.spec.ts +0 -46
- package/src/stores/action-info/action-info.actions.ts +0 -32
- package/src/stores/action-info/action-info.constant.ts +0 -1
- package/src/stores/action-info/action-info.reducers.spec.ts +0 -60
- package/src/stores/action-info/action-info.reducers.ts +0 -44
- package/src/stores/action-info/action-info.selectors.spec.ts +0 -19
- package/src/stores/action-info/action-info.selectors.ts +0 -7
- package/src/stores/action-info/index.ts +0 -4
- package/src/stores/actions/actions.actions.spec.ts +0 -62
- package/src/stores/actions/actions.actions.ts +0 -34
- package/src/stores/actions/actions.constant.ts +0 -1
- package/src/stores/actions/actions.reducers.spec.ts +0 -62
- package/src/stores/actions/actions.reducers.ts +0 -48
- package/src/stores/actions/actions.selectors.spec.ts +0 -34
- package/src/stores/actions/actions.selectors.ts +0 -7
- package/src/stores/actions/index.ts +0 -4
- package/src/stores/auth/auth.actions.ts +0 -13
- package/src/stores/auth/auth.constant.ts +0 -1
- package/src/stores/auth/auth.reducers.spec.ts +0 -376
- package/src/stores/auth/auth.reducers.ts +0 -151
- package/src/stores/auth/auth.selectors.spec.ts +0 -47
- package/src/stores/auth/auth.selectors.ts +0 -14
- package/src/stores/auth/auth.utils.spec.ts +0 -29
- package/src/stores/auth/auth.utils.tsx +0 -37
- package/src/stores/auth/getAccess.action.spec.ts +0 -257
- package/src/stores/auth/getAccess.action.ts +0 -57
- package/src/stores/auth/getProjectAccess.action.ts +0 -25
- package/src/stores/auth/index.ts +0 -10
- package/src/stores/auth/initAuth.action.spec.ts +0 -56
- package/src/stores/auth/initAuth.action.ts +0 -29
- package/src/stores/auth/logout.action.spec.ts +0 -25
- package/src/stores/auth/logout.action.ts +0 -9
- package/src/stores/auth/setUser.action.spec.ts +0 -25
- package/src/stores/auth/setUser.action.ts +0 -9
- package/src/stores/form/form.actions.spec.ts +0 -203
- package/src/stores/form/form.actions.ts +0 -84
- package/src/stores/form/form.reducers.spec.ts +0 -78
- package/src/stores/form/form.reducers.ts +0 -59
- package/src/stores/form/form.selectors.spec.ts +0 -19
- package/src/stores/form/form.selectors.ts +0 -5
- package/src/stores/form/index.ts +0 -3
- package/src/stores/forms/forms.actions.spec.ts +0 -91
- package/src/stores/forms/forms.actions.ts +0 -44
- package/src/stores/forms/forms.reducers.spec.ts +0 -97
- package/src/stores/forms/forms.reducers.ts +0 -77
- package/src/stores/forms/forms.selectors.spec.ts +0 -39
- package/src/stores/forms/forms.selectors.ts +0 -6
- package/src/stores/forms/index.ts +0 -3
- package/src/stores/index.spec.ts +0 -125
- package/src/stores/index.ts +0 -33
- package/src/stores/root/index.ts +0 -1
- package/src/stores/root/root.selectors.spec.ts +0 -94
- package/src/stores/root/root.selectors.ts +0 -23
- package/src/stores/submission/index.ts +0 -3
- package/src/stores/submission/submission.actions.spec.ts +0 -214
- package/src/stores/submission/submission.actions.ts +0 -81
- package/src/stores/submission/submission.reducers.spec.ts +0 -96
- package/src/stores/submission/submission.reducers.ts +0 -70
- package/src/stores/submission/submission.selectors.spec.ts +0 -19
- package/src/stores/submission/submission.selectors.ts +0 -5
- package/src/stores/submissions/index.ts +0 -3
- package/src/stores/submissions/submissions.actions.spec.ts +0 -99
- package/src/stores/submissions/submissions.actions.ts +0 -38
- package/src/stores/submissions/submissions.reducers.spec.ts +0 -98
- package/src/stores/submissions/submissions.reducers.ts +0 -78
- package/src/stores/submissions/submissions.selectors.spec.ts +0 -39
- package/src/stores/submissions/submissions.selectors.ts +0 -6
- package/src/utils/clean.test.ts +0 -7
- package/src/utils/clean.ts +0 -12
- package/src/utils/mapRequestParams.test.ts +0 -81
- package/src/utils/mapRequestParams.ts +0 -36
- package/src/utils/url.test.ts +0 -31
- package/src/utils/url.ts +0 -23
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { failSubmissions, receiveSubmissions, requestSubmissions, resetSubmissions } from "./submissions.actions";
|
|
2
|
-
import { submissionsReducer } from "./submissions.reducers";
|
|
3
|
-
|
|
4
|
-
describe("Submissions reducers", () => {
|
|
5
|
-
it("should return state (resetSubmissions)", () => {
|
|
6
|
-
const reducer = submissionsReducer("name");
|
|
7
|
-
const state: any = {};
|
|
8
|
-
const payload = {};
|
|
9
|
-
|
|
10
|
-
expect(reducer.$emit(resetSubmissions.toString(), state, payload)).toEqual({
|
|
11
|
-
error: null,
|
|
12
|
-
data: [],
|
|
13
|
-
name: "name",
|
|
14
|
-
isActive: false,
|
|
15
|
-
formId: "",
|
|
16
|
-
parameters: {
|
|
17
|
-
pageCount: 0,
|
|
18
|
-
pageIndex: 0,
|
|
19
|
-
pageSize: 10,
|
|
20
|
-
query: {},
|
|
21
|
-
select: "",
|
|
22
|
-
sortBy: []
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
it("should return state (requestSubmissions)", () => {
|
|
27
|
-
const reducer = submissionsReducer("name");
|
|
28
|
-
const state: any = {};
|
|
29
|
-
const payload: any = {
|
|
30
|
-
parameters: {
|
|
31
|
-
pageSize: 10,
|
|
32
|
-
pageIndex: 1,
|
|
33
|
-
sortBy: [],
|
|
34
|
-
filters: [],
|
|
35
|
-
filterId: "id",
|
|
36
|
-
select: "select"
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
expect(reducer.$emit(requestSubmissions.toString(), state, payload)).toEqual({
|
|
41
|
-
error: null,
|
|
42
|
-
formId: undefined,
|
|
43
|
-
name: "name",
|
|
44
|
-
parameters: {
|
|
45
|
-
filterId: "id",
|
|
46
|
-
filters: [],
|
|
47
|
-
pageIndex: 1,
|
|
48
|
-
pageSize: 10,
|
|
49
|
-
select: "select",
|
|
50
|
-
sortBy: []
|
|
51
|
-
},
|
|
52
|
-
data: [],
|
|
53
|
-
isActive: true
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it("should return state (receiveSubmissions)", () => {
|
|
57
|
-
const reducer = submissionsReducer("name");
|
|
58
|
-
const state: any = {
|
|
59
|
-
parameters: {
|
|
60
|
-
pageSize: 10
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const payload = {
|
|
64
|
-
submissions: [{ _id: "id" }] as any,
|
|
65
|
-
url: "url",
|
|
66
|
-
success: "success"
|
|
67
|
-
};
|
|
68
|
-
payload.submissions.serverCount = 100;
|
|
69
|
-
|
|
70
|
-
expect(reducer.$emit(receiveSubmissions.toString(), state, payload)).toEqual({
|
|
71
|
-
name: "name",
|
|
72
|
-
data: [
|
|
73
|
-
{
|
|
74
|
-
_id: "id"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
isActive: false,
|
|
78
|
-
parameters: {
|
|
79
|
-
pageCount: 10,
|
|
80
|
-
pageSize: 10,
|
|
81
|
-
totalLength: 100
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
it("should return state (failSubmissions)", () => {
|
|
86
|
-
const reducer = submissionsReducer("name");
|
|
87
|
-
const state: any = {};
|
|
88
|
-
const payload = {
|
|
89
|
-
error: new Error("message")
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
expect(reducer.$emit(failSubmissions.toString(), state, payload)).toEqual({
|
|
93
|
-
name: "name",
|
|
94
|
-
error: payload.error,
|
|
95
|
-
isActive: false
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { createReducer } from "@tsed/redux-utils";
|
|
2
|
-
|
|
3
|
-
import { Submission } from "../../interfaces/Submission";
|
|
4
|
-
import { failSubmissions, receiveSubmissions, requestSubmissions, resetSubmissions } from "./submissions.actions";
|
|
5
|
-
|
|
6
|
-
export interface SubmissionsState {
|
|
7
|
-
error: null | Error;
|
|
8
|
-
formId: string;
|
|
9
|
-
isActive: boolean;
|
|
10
|
-
parameters: {
|
|
11
|
-
pageSize: number;
|
|
12
|
-
pageIndex: number;
|
|
13
|
-
pageCount: number;
|
|
14
|
-
query: any;
|
|
15
|
-
select: any;
|
|
16
|
-
sortBy: any[];
|
|
17
|
-
};
|
|
18
|
-
data: Submission[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createInitialState({ pageIndex = 0, pageSize = 10, query = {}, select = "", sortBy = [] }: any = {}): SubmissionsState {
|
|
22
|
-
return {
|
|
23
|
-
error: null,
|
|
24
|
-
formId: "",
|
|
25
|
-
isActive: false,
|
|
26
|
-
parameters: {
|
|
27
|
-
pageSize,
|
|
28
|
-
pageIndex,
|
|
29
|
-
pageCount: 0,
|
|
30
|
-
query,
|
|
31
|
-
select,
|
|
32
|
-
sortBy
|
|
33
|
-
},
|
|
34
|
-
data: []
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const submissionsReducer = createReducer<SubmissionsState>({}, createInitialState)
|
|
39
|
-
.on(resetSubmissions, (_: any, _2: any, reset: any) => {
|
|
40
|
-
return reset();
|
|
41
|
-
})
|
|
42
|
-
.on(requestSubmissions, (state: any, { parameters, formId }: any) => {
|
|
43
|
-
return {
|
|
44
|
-
...state,
|
|
45
|
-
formId,
|
|
46
|
-
parameters: {
|
|
47
|
-
...state.parameters,
|
|
48
|
-
...parameters
|
|
49
|
-
},
|
|
50
|
-
error: null,
|
|
51
|
-
data: [],
|
|
52
|
-
isActive: true
|
|
53
|
-
};
|
|
54
|
-
})
|
|
55
|
-
.on(receiveSubmissions, (state: SubmissionsState, { submissions }: any) => {
|
|
56
|
-
const total = submissions.serverCount;
|
|
57
|
-
const pageCount = Math.ceil(total / (state.parameters.pageSize || 10));
|
|
58
|
-
|
|
59
|
-
delete submissions.serverCount;
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
...state,
|
|
63
|
-
data: submissions,
|
|
64
|
-
isActive: false,
|
|
65
|
-
parameters: {
|
|
66
|
-
...state.parameters,
|
|
67
|
-
pageCount,
|
|
68
|
-
totalLength: total
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
})
|
|
72
|
-
.on(failSubmissions, (state: any, { error }: any) => {
|
|
73
|
-
return {
|
|
74
|
-
...state,
|
|
75
|
-
error,
|
|
76
|
-
isActive: false
|
|
77
|
-
};
|
|
78
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { selectSubmissions, selectSubmissionsParameters } from "./submissions.selectors";
|
|
2
|
-
|
|
3
|
-
describe("Submissions Selectors", () => {
|
|
4
|
-
describe("selectSubmissions()", () => {
|
|
5
|
-
it("should return data", () => {
|
|
6
|
-
expect(
|
|
7
|
-
selectSubmissions("submissions", {
|
|
8
|
-
submissions: {
|
|
9
|
-
data: [
|
|
10
|
-
{
|
|
11
|
-
id: "id"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
).toEqual([
|
|
17
|
-
{
|
|
18
|
-
id: "id"
|
|
19
|
-
}
|
|
20
|
-
]);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe("selectSubmissionsParameters()", () => {
|
|
24
|
-
it("should return data", () => {
|
|
25
|
-
expect(
|
|
26
|
-
selectSubmissionsParameters("submissions", {
|
|
27
|
-
submissions: {
|
|
28
|
-
parameters: {},
|
|
29
|
-
data: [
|
|
30
|
-
{
|
|
31
|
-
id: "id"
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
).toEqual({});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { selectRoot } from "../root";
|
|
2
|
-
import { SubmissionsState } from "./submissions.reducers";
|
|
3
|
-
|
|
4
|
-
export const selectSubmissions = (name: string, state: any) => selectRoot<SubmissionsState>(name, state).data;
|
|
5
|
-
|
|
6
|
-
export const selectSubmissionsParameters = (name: string, state: any) => selectRoot<SubmissionsState>(name, state).parameters;
|
package/src/utils/clean.test.ts
DELETED
package/src/utils/clean.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { mapRequestParams } from "./mapRequestParams";
|
|
2
|
-
|
|
3
|
-
describe("mapRequestParams", () => {
|
|
4
|
-
it("should map request params to call formio API (1)", () => {
|
|
5
|
-
const result = mapRequestParams({
|
|
6
|
-
query: {
|
|
7
|
-
type: "form",
|
|
8
|
-
tags: "survey"
|
|
9
|
-
},
|
|
10
|
-
select: ["id", "components"],
|
|
11
|
-
filters: [
|
|
12
|
-
{
|
|
13
|
-
id: "data.name",
|
|
14
|
-
value: "value"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: "data.id",
|
|
18
|
-
value: "value2"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
sortBy: [
|
|
22
|
-
{
|
|
23
|
-
id: "data.id",
|
|
24
|
-
desc: true
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(result).toEqual({
|
|
30
|
-
"data.name__regex": "/value/gi",
|
|
31
|
-
"data.id__regex": "/value2/gi",
|
|
32
|
-
select: "id,components",
|
|
33
|
-
skip: 0,
|
|
34
|
-
limit: 10,
|
|
35
|
-
sort: "-data.id",
|
|
36
|
-
tags: "survey",
|
|
37
|
-
type: "form"
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
it("should map request params to call formio API (2)", () => {
|
|
41
|
-
const result = mapRequestParams({
|
|
42
|
-
pageSize: 20,
|
|
43
|
-
pageIndex: 3,
|
|
44
|
-
query: {
|
|
45
|
-
type: "form",
|
|
46
|
-
tags: "survey"
|
|
47
|
-
},
|
|
48
|
-
select: "id,components",
|
|
49
|
-
filters: [
|
|
50
|
-
{
|
|
51
|
-
id: "data.name",
|
|
52
|
-
value: "value"
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
sortBy: [
|
|
56
|
-
{
|
|
57
|
-
id: "data.id",
|
|
58
|
-
desc: false
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
expect(result).toEqual({
|
|
64
|
-
"data.name__regex": "/value/gi",
|
|
65
|
-
limit: 20,
|
|
66
|
-
select: "id,components",
|
|
67
|
-
skip: 60,
|
|
68
|
-
sort: "data.id",
|
|
69
|
-
tags: "survey",
|
|
70
|
-
type: "form"
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
it("should map request params to call formio API (3)", () => {
|
|
74
|
-
const result = mapRequestParams({});
|
|
75
|
-
|
|
76
|
-
expect(result).toEqual({
|
|
77
|
-
limit: 10,
|
|
78
|
-
skip: 0
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { QueryOptions } from "../interfaces/QueryOptions";
|
|
2
|
-
import { clean } from "./clean";
|
|
3
|
-
|
|
4
|
-
export interface RequestParamsOptions extends QueryOptions {
|
|
5
|
-
select: string | string[];
|
|
6
|
-
query: {
|
|
7
|
-
[key: string]: string;
|
|
8
|
-
};
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function mapRequestParams({ query, pageSize = 10, pageIndex = 0, select, filters, sortBy }: Partial<RequestParamsOptions>) {
|
|
13
|
-
const requestParams: any = {
|
|
14
|
-
...clean(query),
|
|
15
|
-
limit: pageSize,
|
|
16
|
-
skip: pageIndex * pageSize
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
if (select && select.length) {
|
|
20
|
-
requestParams.select = Array.isArray(select) ? select.join(",") : select;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (filters && filters.length) {
|
|
24
|
-
filters.forEach((filter) => {
|
|
25
|
-
if (filter.value) {
|
|
26
|
-
requestParams[`${filter.id}__regex`] = new RegExp(filter.value, "gi").toString();
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (sortBy && sortBy.length) {
|
|
32
|
-
requestParams.sort = (sortBy[0].desc ? "-" : "") + sortBy[0].id;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return requestParams;
|
|
36
|
-
}
|
package/src/utils/url.test.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { getFormUrl, getSubmissionUrl } from "./url";
|
|
2
|
-
|
|
3
|
-
describe("getUrl", () => {
|
|
4
|
-
describe("getFormUrl()", () => {
|
|
5
|
-
it("should return the url from mongo id", () => {
|
|
6
|
-
expect(getFormUrl("5e455268aed853649e834c4a")).toEqual("https://api.form.io/form/5e455268aed853649e834c4a");
|
|
7
|
-
});
|
|
8
|
-
it("should return the url from alias", () => {
|
|
9
|
-
expect(getFormUrl("admin")).toEqual("https://api.form.io/admin");
|
|
10
|
-
});
|
|
11
|
-
it("should return the url from alias (__)", () => {
|
|
12
|
-
expect(getFormUrl("admin__login")).toEqual("https://api.form.io/admin/login");
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe("getSubmissionUrl()", () => {
|
|
16
|
-
it("should return the url from mongo id", () => {
|
|
17
|
-
expect(getSubmissionUrl("5e455268aed853649e834c4a", "5e455268aed853649e834c42")).toEqual(
|
|
18
|
-
"https://api.form.io/form/5e455268aed853649e834c4a/submission/5e455268aed853649e834c42"
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
it("should return the url from alias", () => {
|
|
22
|
-
expect(getSubmissionUrl("admin", "5e455268aed853649e834c42")).toEqual(
|
|
23
|
-
"https://api.form.io/admin/submission/5e455268aed853649e834c42"
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should return the url without submissionId", () => {
|
|
28
|
-
expect(getSubmissionUrl("admin")).toEqual("https://api.form.io/admin/submission");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
package/src/utils/url.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Formio, Utils } from "formiojs";
|
|
2
|
-
|
|
3
|
-
export function getFormUrl(formId: string): string {
|
|
4
|
-
const url = [Formio.getProjectUrl()];
|
|
5
|
-
|
|
6
|
-
if (Utils.isMongoId(formId)) {
|
|
7
|
-
url.push("form");
|
|
8
|
-
} else if (formId.includes("__")) {
|
|
9
|
-
formId = formId.replace(/__/gi, "/");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
url.push(formId);
|
|
13
|
-
|
|
14
|
-
return url.join("/");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getActionUrl(formId: string, actionId?: string): string {
|
|
18
|
-
return [getFormUrl(formId), "action", actionId].filter(Boolean).join("/");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getSubmissionUrl(formId: string, submissionId?: string): string {
|
|
22
|
-
return [getFormUrl(formId), "submission", submissionId].filter(Boolean).join("/");
|
|
23
|
-
}
|