@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.
Files changed (174) hide show
  1. package/coverage.json +4 -4
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.js +1277 -3684
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.modern.js +956 -2767
  6. package/dist/index.modern.js.map +1 -1
  7. package/package.json +4 -5
  8. package/readme.md +9 -57
  9. package/src/components/input-tags/inputTags.component.tsx +1 -1
  10. package/src/components/select/select.component.tsx +1 -1
  11. package/src/components/table/filters/sliderColumnFilter.component.tsx +2 -2
  12. package/src/index.ts +3 -2
  13. package/dist/stores/action/action.actions.d.ts +0 -9
  14. package/dist/stores/action/action.actions.spec.d.ts +0 -1
  15. package/dist/stores/action/action.constant.d.ts +0 -1
  16. package/dist/stores/action/action.reducers.d.ts +0 -7
  17. package/dist/stores/action/action.reducers.spec.d.ts +0 -1
  18. package/dist/stores/action/action.selectors.d.ts +0 -2
  19. package/dist/stores/action/action.selectors.spec.d.ts +0 -1
  20. package/dist/stores/action/index.d.ts +0 -4
  21. package/dist/stores/action-info/action-info.actions.d.ts +0 -5
  22. package/dist/stores/action-info/action-info.actions.spec.d.ts +0 -1
  23. package/dist/stores/action-info/action-info.constant.d.ts +0 -1
  24. package/dist/stores/action-info/action-info.reducers.d.ts +0 -7
  25. package/dist/stores/action-info/action-info.reducers.spec.d.ts +0 -1
  26. package/dist/stores/action-info/action-info.selectors.d.ts +0 -2
  27. package/dist/stores/action-info/action-info.selectors.spec.d.ts +0 -1
  28. package/dist/stores/action-info/index.d.ts +0 -4
  29. package/dist/stores/actions/actions.actions.d.ts +0 -5
  30. package/dist/stores/actions/actions.actions.spec.d.ts +0 -1
  31. package/dist/stores/actions/actions.constant.d.ts +0 -1
  32. package/dist/stores/actions/actions.reducers.d.ts +0 -8
  33. package/dist/stores/actions/actions.reducers.spec.d.ts +0 -1
  34. package/dist/stores/actions/actions.selectors.d.ts +0 -2
  35. package/dist/stores/actions/actions.selectors.spec.d.ts +0 -1
  36. package/dist/stores/actions/index.d.ts +0 -4
  37. package/dist/stores/auth/auth.actions.d.ts +0 -9
  38. package/dist/stores/auth/auth.constant.d.ts +0 -1
  39. package/dist/stores/auth/auth.reducers.d.ts +0 -16
  40. package/dist/stores/auth/auth.reducers.spec.d.ts +0 -1
  41. package/dist/stores/auth/auth.selectors.d.ts +0 -6
  42. package/dist/stores/auth/auth.selectors.spec.d.ts +0 -1
  43. package/dist/stores/auth/auth.utils.d.ts +0 -6
  44. package/dist/stores/auth/auth.utils.spec.d.ts +0 -1
  45. package/dist/stores/auth/getAccess.action.d.ts +0 -1
  46. package/dist/stores/auth/getAccess.action.spec.d.ts +0 -1
  47. package/dist/stores/auth/getProjectAccess.action.d.ts +0 -1
  48. package/dist/stores/auth/index.d.ts +0 -10
  49. package/dist/stores/auth/initAuth.action.d.ts +0 -1
  50. package/dist/stores/auth/initAuth.action.spec.d.ts +0 -1
  51. package/dist/stores/auth/logout.action.d.ts +0 -1
  52. package/dist/stores/auth/logout.action.spec.d.ts +0 -1
  53. package/dist/stores/auth/setUser.action.d.ts +0 -1
  54. package/dist/stores/auth/setUser.action.spec.d.ts +0 -1
  55. package/dist/stores/form/form.actions.d.ts +0 -10
  56. package/dist/stores/form/form.actions.spec.d.ts +0 -1
  57. package/dist/stores/form/form.reducers.d.ts +0 -9
  58. package/dist/stores/form/form.reducers.spec.d.ts +0 -1
  59. package/dist/stores/form/form.selectors.d.ts +0 -2
  60. package/dist/stores/form/form.selectors.spec.d.ts +0 -1
  61. package/dist/stores/form/index.d.ts +0 -3
  62. package/dist/stores/forms/forms.actions.d.ts +0 -9
  63. package/dist/stores/forms/forms.actions.spec.d.ts +0 -1
  64. package/dist/stores/forms/forms.reducers.d.ts +0 -16
  65. package/dist/stores/forms/forms.reducers.spec.d.ts +0 -1
  66. package/dist/stores/forms/forms.selectors.d.ts +0 -10
  67. package/dist/stores/forms/forms.selectors.spec.d.ts +0 -1
  68. package/dist/stores/forms/index.d.ts +0 -3
  69. package/dist/stores/index.d.ts +0 -10
  70. package/dist/stores/index.spec.d.ts +0 -1
  71. package/dist/stores/root/index.d.ts +0 -1
  72. package/dist/stores/root/root.selectors.d.ts +0 -5
  73. package/dist/stores/root/root.selectors.spec.d.ts +0 -1
  74. package/dist/stores/submission/index.d.ts +0 -3
  75. package/dist/stores/submission/submission.actions.d.ts +0 -10
  76. package/dist/stores/submission/submission.actions.spec.d.ts +0 -1
  77. package/dist/stores/submission/submission.reducers.d.ts +0 -11
  78. package/dist/stores/submission/submission.reducers.spec.d.ts +0 -1
  79. package/dist/stores/submission/submission.selectors.d.ts +0 -2
  80. package/dist/stores/submission/submission.selectors.spec.d.ts +0 -1
  81. package/dist/stores/submissions/index.d.ts +0 -3
  82. package/dist/stores/submissions/submissions.actions.d.ts +0 -6
  83. package/dist/stores/submissions/submissions.actions.spec.d.ts +0 -1
  84. package/dist/stores/submissions/submissions.reducers.d.ts +0 -17
  85. package/dist/stores/submissions/submissions.reducers.spec.d.ts +0 -1
  86. package/dist/stores/submissions/submissions.selectors.d.ts +0 -9
  87. package/dist/stores/submissions/submissions.selectors.spec.d.ts +0 -1
  88. package/dist/utils/clean.d.ts +0 -1
  89. package/dist/utils/clean.test.d.ts +0 -1
  90. package/dist/utils/mapRequestParams.d.ts +0 -9
  91. package/dist/utils/mapRequestParams.test.d.ts +0 -1
  92. package/dist/utils/url.d.ts +0 -3
  93. package/dist/utils/url.test.d.ts +0 -1
  94. package/src/stores/action/action.actions.spec.ts +0 -114
  95. package/src/stores/action/action.actions.ts +0 -82
  96. package/src/stores/action/action.constant.ts +0 -1
  97. package/src/stores/action/action.reducers.spec.ts +0 -91
  98. package/src/stores/action/action.reducers.ts +0 -54
  99. package/src/stores/action/action.selectors.spec.ts +0 -19
  100. package/src/stores/action/action.selectors.ts +0 -6
  101. package/src/stores/action/index.ts +0 -4
  102. package/src/stores/action-info/action-info.actions.spec.ts +0 -46
  103. package/src/stores/action-info/action-info.actions.ts +0 -32
  104. package/src/stores/action-info/action-info.constant.ts +0 -1
  105. package/src/stores/action-info/action-info.reducers.spec.ts +0 -60
  106. package/src/stores/action-info/action-info.reducers.ts +0 -44
  107. package/src/stores/action-info/action-info.selectors.spec.ts +0 -19
  108. package/src/stores/action-info/action-info.selectors.ts +0 -7
  109. package/src/stores/action-info/index.ts +0 -4
  110. package/src/stores/actions/actions.actions.spec.ts +0 -62
  111. package/src/stores/actions/actions.actions.ts +0 -34
  112. package/src/stores/actions/actions.constant.ts +0 -1
  113. package/src/stores/actions/actions.reducers.spec.ts +0 -62
  114. package/src/stores/actions/actions.reducers.ts +0 -48
  115. package/src/stores/actions/actions.selectors.spec.ts +0 -34
  116. package/src/stores/actions/actions.selectors.ts +0 -7
  117. package/src/stores/actions/index.ts +0 -4
  118. package/src/stores/auth/auth.actions.ts +0 -13
  119. package/src/stores/auth/auth.constant.ts +0 -1
  120. package/src/stores/auth/auth.reducers.spec.ts +0 -376
  121. package/src/stores/auth/auth.reducers.ts +0 -151
  122. package/src/stores/auth/auth.selectors.spec.ts +0 -47
  123. package/src/stores/auth/auth.selectors.ts +0 -14
  124. package/src/stores/auth/auth.utils.spec.ts +0 -29
  125. package/src/stores/auth/auth.utils.tsx +0 -37
  126. package/src/stores/auth/getAccess.action.spec.ts +0 -257
  127. package/src/stores/auth/getAccess.action.ts +0 -57
  128. package/src/stores/auth/getProjectAccess.action.ts +0 -25
  129. package/src/stores/auth/index.ts +0 -10
  130. package/src/stores/auth/initAuth.action.spec.ts +0 -56
  131. package/src/stores/auth/initAuth.action.ts +0 -29
  132. package/src/stores/auth/logout.action.spec.ts +0 -25
  133. package/src/stores/auth/logout.action.ts +0 -9
  134. package/src/stores/auth/setUser.action.spec.ts +0 -25
  135. package/src/stores/auth/setUser.action.ts +0 -9
  136. package/src/stores/form/form.actions.spec.ts +0 -203
  137. package/src/stores/form/form.actions.ts +0 -84
  138. package/src/stores/form/form.reducers.spec.ts +0 -78
  139. package/src/stores/form/form.reducers.ts +0 -59
  140. package/src/stores/form/form.selectors.spec.ts +0 -19
  141. package/src/stores/form/form.selectors.ts +0 -5
  142. package/src/stores/form/index.ts +0 -3
  143. package/src/stores/forms/forms.actions.spec.ts +0 -91
  144. package/src/stores/forms/forms.actions.ts +0 -44
  145. package/src/stores/forms/forms.reducers.spec.ts +0 -97
  146. package/src/stores/forms/forms.reducers.ts +0 -77
  147. package/src/stores/forms/forms.selectors.spec.ts +0 -39
  148. package/src/stores/forms/forms.selectors.ts +0 -6
  149. package/src/stores/forms/index.ts +0 -3
  150. package/src/stores/index.spec.ts +0 -125
  151. package/src/stores/index.ts +0 -33
  152. package/src/stores/root/index.ts +0 -1
  153. package/src/stores/root/root.selectors.spec.ts +0 -94
  154. package/src/stores/root/root.selectors.ts +0 -23
  155. package/src/stores/submission/index.ts +0 -3
  156. package/src/stores/submission/submission.actions.spec.ts +0 -214
  157. package/src/stores/submission/submission.actions.ts +0 -81
  158. package/src/stores/submission/submission.reducers.spec.ts +0 -96
  159. package/src/stores/submission/submission.reducers.ts +0 -70
  160. package/src/stores/submission/submission.selectors.spec.ts +0 -19
  161. package/src/stores/submission/submission.selectors.ts +0 -5
  162. package/src/stores/submissions/index.ts +0 -3
  163. package/src/stores/submissions/submissions.actions.spec.ts +0 -99
  164. package/src/stores/submissions/submissions.actions.ts +0 -38
  165. package/src/stores/submissions/submissions.reducers.spec.ts +0 -98
  166. package/src/stores/submissions/submissions.reducers.ts +0 -78
  167. package/src/stores/submissions/submissions.selectors.spec.ts +0 -39
  168. package/src/stores/submissions/submissions.selectors.ts +0 -6
  169. package/src/utils/clean.test.ts +0 -7
  170. package/src/utils/clean.ts +0 -12
  171. package/src/utils/mapRequestParams.test.ts +0 -81
  172. package/src/utils/mapRequestParams.ts +0 -36
  173. package/src/utils/url.test.ts +0 -31
  174. 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;
@@ -1,7 +0,0 @@
1
- import { clean } from "./clean";
2
-
3
- describe("clean", () => {
4
- it("should return cleaned object", () => {
5
- expect(clean({ test: undefined, test2: "" })).toEqual({ test2: "" });
6
- });
7
- });
@@ -1,12 +0,0 @@
1
- export function clean(obj: any = {}) {
2
- return Object.entries(obj).reduce((obj, [key, entry]) => {
3
- if (entry !== undefined) {
4
- return {
5
- ...obj,
6
- [key]: entry
7
- };
8
- }
9
-
10
- return obj;
11
- }, {});
12
- }
@@ -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
- }
@@ -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
- }