systemview 1.0.1 → 1.1.2

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 (264) hide show
  1. package/api/Connections.js +36 -0
  2. package/api/connections.txt +1 -0
  3. package/api/index.js +78 -0
  4. package/babel.config.js +12 -0
  5. package/cli/index.js +8 -3
  6. package/cli/launchApp.js +0 -0
  7. package/cli/runTest.js +0 -0
  8. package/cli/utils/cli.js +48 -0
  9. package/cli/utils/init.js +17 -0
  10. package/cli/utils/log.js +11 -0
  11. package/package.json +6 -3
  12. package/plugin/SystemViewModule.js +97 -0
  13. package/plugin/getAllTest.js +21 -0
  14. package/plugin/index.js +40 -0
  15. package/src/App.css +38 -0
  16. package/src/App.js +30 -0
  17. package/src/ServiceContext.js +9 -0
  18. package/src/assets/arrow.png +0 -0
  19. package/src/assets/check.svg +1 -0
  20. package/src/assets/clear.png +0 -0
  21. package/src/assets/edit.png +0 -0
  22. package/src/assets/error.svg +1 -0
  23. package/src/assets/eval-icon.svg +10 -0
  24. package/src/assets/expand-arrow.svg +41 -0
  25. package/src/assets/expand-button.svg +41 -0
  26. package/src/assets/fonts/FontsFree-Net-SFMono-Regular.ttf +0 -0
  27. package/src/assets/fonts/Malkor-Regular.ttf +0 -0
  28. package/src/assets/iconfinder-icon (1).svg +14 -0
  29. package/src/assets/iconfinder-icon.svg +14 -0
  30. package/src/assets/icons-save-60.png +0 -0
  31. package/src/assets/loading.gif +0 -0
  32. package/src/assets/missing-doc.png +0 -0
  33. package/src/assets/saved-doc.png +0 -0
  34. package/src/assets/sysly.png +0 -0
  35. package/src/assets/test-icon.svg +10 -0
  36. package/src/assets/test-missing.png +0 -0
  37. package/src/assets/test-saved.png +0 -0
  38. package/src/assets/x.svg +1 -0
  39. package/src/atoms/Button/Button.js +20 -0
  40. package/src/atoms/Button/Button.test.js +27 -0
  41. package/src/atoms/Button/__snapshots__/Button.test.js.snap +9 -0
  42. package/src/atoms/Button/styles.scss +35 -0
  43. package/src/atoms/Count/index.js +10 -0
  44. package/src/atoms/Count/styles.scss +25 -0
  45. package/src/atoms/DataTable/DataTable.js +27 -0
  46. package/src/atoms/DataTable/DataTable.test.js +55 -0
  47. package/src/atoms/DataTable/__snapshots__/DataTable.test.js.snap +36 -0
  48. package/src/atoms/DataTable/styles.scss +28 -0
  49. package/src/atoms/DescriptionBox/DescriptionBox.js +24 -0
  50. package/src/atoms/DescriptionBox/DescriptionBox.test.js +36 -0
  51. package/src/atoms/DescriptionBox/__snapshots__/DescriptionBox.test.js.snap +14 -0
  52. package/src/atoms/DescriptionBox/styles.scss +24 -0
  53. package/src/atoms/DescriptionText/DescriptionText.js +12 -0
  54. package/src/atoms/DescriptionText/DescriptionText.test.js +22 -0
  55. package/src/atoms/DescriptionText/styles.scss +10 -0
  56. package/src/atoms/DocsIcon/DocsIcon.js +20 -0
  57. package/src/atoms/DocsIcon/DocsIcon.test.js +23 -0
  58. package/src/atoms/DocsIcon/styles.scss +7 -0
  59. package/src/atoms/ExpandableIcon/ExpandableIcon.js +30 -0
  60. package/src/atoms/ExpandableIcon/ExpandableIcon.test.js +18 -0
  61. package/src/atoms/ExpandableIcon/styles.scss +5 -0
  62. package/src/atoms/JsonTextBox/JsonTextBox.js +61 -0
  63. package/src/atoms/JsonTextBox/JsonTextBox.test.js +0 -0
  64. package/src/atoms/JsonTextBox/styles.scss +41 -0
  65. package/src/atoms/Link/Link.js +17 -0
  66. package/src/atoms/Link/Link.test.js +33 -0
  67. package/src/atoms/Link/styles.scss +8 -0
  68. package/src/atoms/List/List.js +8 -0
  69. package/src/atoms/List/List.test.js +26 -0
  70. package/src/atoms/List/styles.scss +9 -0
  71. package/src/atoms/Markdown/Markdown.js +48 -0
  72. package/src/atoms/Markdown/styles.scss +414 -0
  73. package/src/atoms/RunTestIcon/index.js +41 -0
  74. package/src/atoms/RunTestIcon/styles.scss +16 -0
  75. package/src/atoms/SaveIcon/SaveIcon.js +6 -0
  76. package/src/atoms/SaveIcon/styles.scss +3 -0
  77. package/src/atoms/Selector/Selector.js +28 -0
  78. package/src/atoms/Selector/Selector.test.js +0 -0
  79. package/src/atoms/Selector/styles.scss +1 -0
  80. package/src/atoms/StatusIndicator/StatusIndicator.js +16 -0
  81. package/src/atoms/StatusIndicator/styles.scss +33 -0
  82. package/src/atoms/TestsIcon/TestsIcon.js +17 -0
  83. package/src/atoms/TestsIcon/TestsIcon.test.js +18 -0
  84. package/src/atoms/TestsIcon/styles.scss +0 -0
  85. package/src/atoms/Text/Text.js +8 -0
  86. package/src/atoms/Text/Text.test.js +21 -0
  87. package/src/atoms/Text/styles.scss +0 -0
  88. package/src/atoms/Textbox/Textbox.js +33 -0
  89. package/src/atoms/Textbox/Textbox.test.js +23 -0
  90. package/src/atoms/Textbox/styles.scss +14 -0
  91. package/src/atoms/Title/Title.js +12 -0
  92. package/src/atoms/Title/Title.test.js +0 -0
  93. package/src/atoms/Title/styles.scss +6 -0
  94. package/src/atoms/Toggle/Toggle.js +13 -0
  95. package/src/atoms/Toggle/Toggle.test.js +0 -0
  96. package/src/atoms/Toggle/styles.scss +62 -0
  97. package/src/atoms/TypeSelector/TypeSelector.js +28 -0
  98. package/src/atoms/TypeSelector/TypeSelector.test.js +0 -0
  99. package/src/atoms/TypeSelector/styles.scss +9 -0
  100. package/src/index.css +20 -0
  101. package/src/index.js +24 -0
  102. package/src/logo.svg +7 -0
  103. package/src/molecules/Args/Args.js +302 -0
  104. package/src/molecules/Args/Args.test.js +0 -0
  105. package/src/molecules/Args/styles.scss +166 -0
  106. package/src/molecules/AutoCompleteBox/AutoCompleteBox.js +101 -0
  107. package/src/molecules/AutoCompleteBox/AutoCompleteBox.test.js +0 -0
  108. package/src/molecules/AutoCompleteBox/styles.scss +35 -0
  109. package/src/molecules/DataTableForm/DataTableForm.js +167 -0
  110. package/src/molecules/DataTableForm/DataTableForm.test.js +0 -0
  111. package/src/molecules/DataTableForm/styles.scss +51 -0
  112. package/src/molecules/EditBox/EditBox.js +49 -0
  113. package/src/molecules/EditBox/EditBox.test.js +0 -0
  114. package/src/molecules/EditBox/styles.scss +38 -0
  115. package/src/molecules/ExpandableList/ExpandableList.js +26 -0
  116. package/src/molecules/ExpandableList/ExpandableList.test.js +33 -0
  117. package/src/molecules/ExpandableList/styles.scss +18 -0
  118. package/src/molecules/ExpandableSection/ExpandableSection.js +36 -0
  119. package/src/molecules/ExpandableSection/ExpandableSection.test.js +0 -0
  120. package/src/molecules/ExpandableSection/styles.scss +22 -0
  121. package/src/molecules/ServerModulesList/ServerModulesList.js +75 -0
  122. package/src/molecules/ServerModulesList/styles.scss +28 -0
  123. package/src/molecules/TargetSelector/TargetSelector.js +34 -0
  124. package/src/molecules/TargetSelector/TargetSelector.test.js +0 -0
  125. package/src/molecules/TargetSelector/styles.scss +0 -0
  126. package/src/molecules/TestCaption/TestCaption.js +26 -0
  127. package/src/molecules/TestCaption/TestCaption.test.js +0 -0
  128. package/src/molecules/TestCaption/styles.scss +40 -0
  129. package/src/molecules/TestSummary/index.js +212 -0
  130. package/src/molecules/TestSummary/styles.scss +83 -0
  131. package/src/molecules/TextWith2Links/TextWith2Links.js +10 -0
  132. package/src/molecules/TextWith2Links/styles.scss +0 -0
  133. package/src/molecules/ValidationInput/ValidationInput.js +64 -0
  134. package/src/molecules/ValidationInput/ValidationInput.test.js +0 -0
  135. package/src/molecules/ValidationInput/ValidationMessages.js +178 -0
  136. package/src/molecules/ValidationInput/ValidationOptions.js +113 -0
  137. package/src/molecules/ValidationInput/styles.scss +74 -0
  138. package/src/molecules/ValidationInput/validator.js +244 -0
  139. package/src/organisms/Documentation/Documentation.js +128 -0
  140. package/src/organisms/Documentation/Documentation.test.js +0 -0
  141. package/src/organisms/Documentation/styles.scss +22 -0
  142. package/src/organisms/MultiTestSection/MultiTestSection.js +85 -0
  143. package/src/organisms/MultiTestSection/MultiTestSection.test.js +0 -0
  144. package/src/organisms/MultiTestSection/styles.scss +22 -0
  145. package/src/organisms/SavedTests/SavedTests.js +209 -0
  146. package/src/organisms/SavedTests/SavedTests.test.js +0 -0
  147. package/src/organisms/SavedTests/styles.scss +76 -0
  148. package/src/organisms/SavedTests/transformTests.js +51 -0
  149. package/src/organisms/ScratchPad/ScratchPad.js +128 -0
  150. package/src/organisms/ScratchPad/ScratchPad.test.js +0 -0
  151. package/src/organisms/ScratchPad/styles.scss +100 -0
  152. package/src/organisms/SystemNavigator/SystemNavigator.js +148 -0
  153. package/src/organisms/SystemNavigator/SystemNavigator.test.js +24 -0
  154. package/src/organisms/SystemNavigator/styles.scss +38 -0
  155. package/src/organisms/TestContainer/TestContainer.js +72 -0
  156. package/src/organisms/TestContainer/TestContainer.test.js +0 -0
  157. package/src/organisms/TestContainer/styles.scss +20 -0
  158. package/src/organisms/TestPanel/AfterTest/AfterTest.js +16 -0
  159. package/src/organisms/TestPanel/AfterTest/AfterTest.test.js +0 -0
  160. package/src/organisms/TestPanel/AfterTest/styles.scss +0 -0
  161. package/src/organisms/TestPanel/BeforeTest/BeforeTest.js +16 -0
  162. package/src/organisms/TestPanel/BeforeTest/BeforeTest.test.js +0 -0
  163. package/src/organisms/TestPanel/BeforeTest/styles.scss +0 -0
  164. package/src/organisms/TestPanel/Evaluations.js +369 -0
  165. package/src/organisms/TestPanel/EventsTest/EventsTest.js +19 -0
  166. package/src/organisms/TestPanel/EventsTest/styles.scss +0 -0
  167. package/src/organisms/TestPanel/MainTest/MainTest.js +20 -0
  168. package/src/organisms/TestPanel/MainTest/MainTest.test.js +0 -0
  169. package/src/organisms/TestPanel/MainTest/styles.scss +143 -0
  170. package/src/organisms/TestPanel/TestPanel.js +170 -0
  171. package/src/organisms/TestPanel/TestPanel.test.js +0 -0
  172. package/src/organisms/TestPanel/components/Argument.class.js +94 -0
  173. package/src/organisms/TestPanel/components/FullTestController.js +78 -0
  174. package/src/organisms/TestPanel/components/Test.class.js +162 -0
  175. package/src/organisms/TestPanel/components/TestController.class.js +135 -0
  176. package/src/organisms/TestPanel/components/test-helpers.js +109 -0
  177. package/src/organisms/TestPanel/styles.scss +45 -0
  178. package/src/pages/SystemView/SystemView.js +68 -0
  179. package/src/pages/SystemView/styles.scss +81 -0
  180. package/src/reportWebVitals.js +13 -0
  181. package/src/sass/bootstrap/_alert.scss +51 -0
  182. package/src/sass/bootstrap/_badge.scss +47 -0
  183. package/src/sass/bootstrap/_breadcrumb.scss +38 -0
  184. package/src/sass/bootstrap/_button-group.scss +166 -0
  185. package/src/sass/bootstrap/_buttons.scss +143 -0
  186. package/src/sass/bootstrap/_card.scss +270 -0
  187. package/src/sass/bootstrap/_carousel.scss +191 -0
  188. package/src/sass/bootstrap/_close.scss +34 -0
  189. package/src/sass/bootstrap/_code.scss +56 -0
  190. package/src/sass/bootstrap/_custom-forms.scss +297 -0
  191. package/src/sass/bootstrap/_dropdown.scss +131 -0
  192. package/src/sass/bootstrap/_forms.scss +333 -0
  193. package/src/sass/bootstrap/_functions.scss +86 -0
  194. package/src/sass/bootstrap/_grid.scss +52 -0
  195. package/src/sass/bootstrap/_images.scss +42 -0
  196. package/src/sass/bootstrap/_input-group.scss +159 -0
  197. package/src/sass/bootstrap/_jumbotron.scss +16 -0
  198. package/src/sass/bootstrap/_list-group.scss +115 -0
  199. package/src/sass/bootstrap/_media.scss +8 -0
  200. package/src/sass/bootstrap/_mixins.scss +42 -0
  201. package/src/sass/bootstrap/_modal.scss +168 -0
  202. package/src/sass/bootstrap/_nav.scss +118 -0
  203. package/src/sass/bootstrap/_navbar.scss +311 -0
  204. package/src/sass/bootstrap/_pagination.scss +77 -0
  205. package/src/sass/bootstrap/_popover.scss +183 -0
  206. package/src/sass/bootstrap/_print.scss +124 -0
  207. package/src/sass/bootstrap/_progress.scss +33 -0
  208. package/src/sass/bootstrap/_reboot.scss +482 -0
  209. package/src/sass/bootstrap/_root.scss +19 -0
  210. package/src/sass/bootstrap/_tables.scss +180 -0
  211. package/src/sass/bootstrap/_tooltip.scss +115 -0
  212. package/src/sass/bootstrap/_transitions.scss +36 -0
  213. package/src/sass/bootstrap/_type.scss +125 -0
  214. package/src/sass/bootstrap/_utilities.scss +14 -0
  215. package/src/sass/bootstrap/_variables.scss +894 -0
  216. package/src/sass/bootstrap/bootstrap-grid.scss +32 -0
  217. package/src/sass/bootstrap/bootstrap-reboot.scss +12 -0
  218. package/src/sass/bootstrap/bootstrap.scss +42 -0
  219. package/src/sass/bootstrap/mixins/_alert.scss +13 -0
  220. package/src/sass/bootstrap/mixins/_background-variant.scss +21 -0
  221. package/src/sass/bootstrap/mixins/_badge.scss +12 -0
  222. package/src/sass/bootstrap/mixins/_border-radius.scss +35 -0
  223. package/src/sass/bootstrap/mixins/_box-shadow.scss +5 -0
  224. package/src/sass/bootstrap/mixins/_breakpoints.scss +123 -0
  225. package/src/sass/bootstrap/mixins/_buttons.scss +109 -0
  226. package/src/sass/bootstrap/mixins/_caret.scss +65 -0
  227. package/src/sass/bootstrap/mixins/_clearfix.scss +7 -0
  228. package/src/sass/bootstrap/mixins/_float.scss +11 -0
  229. package/src/sass/bootstrap/mixins/_forms.scss +137 -0
  230. package/src/sass/bootstrap/mixins/_gradients.scss +45 -0
  231. package/src/sass/bootstrap/mixins/_grid-framework.scss +67 -0
  232. package/src/sass/bootstrap/mixins/_grid.scss +52 -0
  233. package/src/sass/bootstrap/mixins/_hover.scss +39 -0
  234. package/src/sass/bootstrap/mixins/_image.scss +36 -0
  235. package/src/sass/bootstrap/mixins/_list-group.scss +21 -0
  236. package/src/sass/bootstrap/mixins/_lists.scss +7 -0
  237. package/src/sass/bootstrap/mixins/_nav-divider.scss +10 -0
  238. package/src/sass/bootstrap/mixins/_navbar-align.scss +10 -0
  239. package/src/sass/bootstrap/mixins/_pagination.scss +22 -0
  240. package/src/sass/bootstrap/mixins/_reset-text.scss +17 -0
  241. package/src/sass/bootstrap/mixins/_resize.scss +6 -0
  242. package/src/sass/bootstrap/mixins/_screen-reader.scss +35 -0
  243. package/src/sass/bootstrap/mixins/_size.scss +6 -0
  244. package/src/sass/bootstrap/mixins/_table-row.scss +30 -0
  245. package/src/sass/bootstrap/mixins/_text-emphasis.scss +14 -0
  246. package/src/sass/bootstrap/mixins/_text-hide.scss +9 -0
  247. package/src/sass/bootstrap/mixins/_text-truncate.scss +8 -0
  248. package/src/sass/bootstrap/mixins/_transition.scss +9 -0
  249. package/src/sass/bootstrap/mixins/_visibility.scss +7 -0
  250. package/src/sass/bootstrap/utilities/_align.scss +8 -0
  251. package/src/sass/bootstrap/utilities/_background.scss +19 -0
  252. package/src/sass/bootstrap/utilities/_borders.scss +59 -0
  253. package/src/sass/bootstrap/utilities/_clearfix.scss +3 -0
  254. package/src/sass/bootstrap/utilities/_display.scss +38 -0
  255. package/src/sass/bootstrap/utilities/_embed.scss +52 -0
  256. package/src/sass/bootstrap/utilities/_flex.scss +46 -0
  257. package/src/sass/bootstrap/utilities/_float.scss +9 -0
  258. package/src/sass/bootstrap/utilities/_position.scss +36 -0
  259. package/src/sass/bootstrap/utilities/_screenreaders.scss +11 -0
  260. package/src/sass/bootstrap/utilities/_sizing.scss +12 -0
  261. package/src/sass/bootstrap/utilities/_spacing.scss +51 -0
  262. package/src/sass/bootstrap/utilities/_text.scss +52 -0
  263. package/src/sass/bootstrap/utilities/_visibility.scss +11 -0
  264. package/src/setupTests.js +5 -0
@@ -0,0 +1,74 @@
1
+ .error-message {
2
+ padding: 4px 25px;
3
+ color: #ff5722;
4
+ word-break: break-word;
5
+ font-family: monospace;
6
+ &__message-container {
7
+ background: #ededed;
8
+ }
9
+ &__message {
10
+ padding: 6px 23px;
11
+ background: #ededed;
12
+ border-radius: 5px;
13
+ }
14
+ &__namespace {
15
+ color: #b136c6;
16
+ font-weight: 600;
17
+ }
18
+ &__expected {
19
+ color: #0b8b22;
20
+ font-weight: 700;
21
+ }
22
+ }
23
+
24
+ .validation-input {
25
+ margin: 3px 0;
26
+ display: flex;
27
+ &__input,
28
+ &__selector {
29
+ background: none;
30
+ border: none;
31
+ font-family: monospace;
32
+ font-size: 14px;
33
+ }
34
+ &__selector {
35
+ padding: 3px;
36
+ outline: none;
37
+ border-right: none;
38
+ appearance: none;
39
+ cursor: pointer;
40
+ font-weight: bold;
41
+ color: #009688;
42
+ text-indent: 5px;
43
+ &:hover {
44
+ background: #b3c1e8;
45
+ border-radius: 33px;
46
+ // color: #f1f1f1;
47
+ }
48
+ }
49
+
50
+ &__input {
51
+ padding: 4px;
52
+ outline: none;
53
+ color: #0d8065;
54
+ }
55
+ &__value {
56
+ &--boolean {
57
+ &--true {
58
+ color: #207844;
59
+ }
60
+ &--false {
61
+ color: #cf1515;
62
+ }
63
+ position: relative;
64
+ top: 7px;
65
+ font-weight: bold;
66
+ }
67
+ }
68
+ }
69
+ input:-webkit-autofill {
70
+ border: 3px solid blue;
71
+ }
72
+ input:autofill {
73
+ border: 3px solid blue;
74
+ }
@@ -0,0 +1,244 @@
1
+ import moment from "moment";
2
+ import {
3
+ arr,
4
+ obj,
5
+ parseIndex,
6
+ mapNamespace,
7
+ replaceLastIndex,
8
+ switchArrayIndices,
9
+ } from "../../organisms/TestPanel/components/test-helpers";
10
+
11
+ export function evaluate(value, namespace, savedEval = {}, shouldSave) {
12
+ const type = getType(value);
13
+ const validations = savedEval.validations || [];
14
+ const expected_type = savedEval.expected_type || type;
15
+ const save = shouldSave || !!savedEval.save;
16
+ const indexed = savedEval.indexed;
17
+ const errors = getErrors({ type, value, validations, expected_type });
18
+ return {
19
+ namespace,
20
+ expected_type,
21
+ validations,
22
+ save,
23
+ indexed,
24
+ type,
25
+ value,
26
+ errors,
27
+ };
28
+ }
29
+
30
+ export function validateResults() {
31
+ const { results, response_type, savedEvaluations, editMode } = this;
32
+ const savedEvalClone = [...savedEvaluations];
33
+ const shouldSave = !savedEvaluations.length;
34
+ const evaluations = [];
35
+ const errors = [];
36
+
37
+ function getSavedIndices(data, nsp) {
38
+ const randomIndex = () => {
39
+ // get all matching indices and rename them
40
+ // so they can be found later during getSavedEval
41
+ const index = arr(data).randomIndex();
42
+ const new_nsp = replaceLastIndex(nsp, index);
43
+ savedEvalClone.forEach((e) => {
44
+ if (!e.indexed) e.namespace = switchArrayIndices(e.namespace, new_nsp);
45
+ });
46
+ return index;
47
+ };
48
+ const savedIndices = savedEvalClone
49
+ .filter(({ namespace }) => {
50
+ return replaceLastIndex(namespace) === nsp;
51
+ })
52
+ .map((e) => {
53
+ if (e.indexed) {
54
+ return parseIndex(e.namespace);
55
+ } else {
56
+ return randomIndex();
57
+ }
58
+ });
59
+ return savedIndices.length ? savedIndices : [randomIndex()];
60
+ }
61
+ const getSavedEval = (nsp) => {
62
+ const i = savedEvalClone.findIndex(({ namespace }) => {
63
+ return replaceLastIndex(namespace) === replaceLastIndex(nsp);
64
+ });
65
+ return i > -1 ? savedEvalClone.splice(i, 1)[0] : {};
66
+ };
67
+ const addEvaluation = (evaluation) => {
68
+ evaluation.errors.forEach(
69
+ (e) => evaluation.save && errors.push({ ...e, namespace: evaluation.namespace })
70
+ );
71
+ evaluations.push(evaluation);
72
+ };
73
+
74
+ //evaluate based on the result only in edit mode
75
+ if (editMode)
76
+ (function recursiveEval(data, namespace) {
77
+ const evaluation = evaluate(data, namespace, getSavedEval(namespace), shouldSave);
78
+ addEvaluation(evaluation);
79
+ if (evaluation.type === "object") {
80
+ Object.getOwnPropertyNames(data).forEach((prop) => {
81
+ recursiveEval(data[prop], `${namespace}.${prop}`);
82
+ });
83
+ } else if (evaluation.type === "array") {
84
+ const indices = getSavedIndices(data, `${namespace}[0]`);
85
+ indices.forEach((index) => recursiveEval(data[index], `${namespace}[${index}]`));
86
+ }
87
+ })(results, response_type);
88
+
89
+ //evaluate based on the saved evaluations
90
+
91
+ // if (!editMode) {
92
+ const objParser = new obj({ [response_type]: results });
93
+ savedEvalClone.forEach(({ namespace, ...e }) => {
94
+ const value = objParser.valueAtNsp(namespace);
95
+ if (e.save) addEvaluation(evaluate(value, namespace, e));
96
+ });
97
+ // }
98
+
99
+ Object.assign(this, {
100
+ evaluations: evaluations.sort((e1, e2) => e1.namespace.localeCompare(e2.namespace)),
101
+ errors,
102
+ });
103
+ }
104
+
105
+ export function getErrors({ type, value, validations, expected_type }) {
106
+ if (type !== expected_type && expected_type !== "mixed")
107
+ return [{ name: "typeError", expected: expected_type, received: type }];
108
+
109
+ switch (type) {
110
+ case "number":
111
+ return validateNumber(value, validations);
112
+ case "date":
113
+ return validateDate(value, validations);
114
+ case "string":
115
+ return validateString(value, validations);
116
+ case "array":
117
+ return validateArray(value, validations);
118
+ case "boolean":
119
+ return validateBoolean(value, validations);
120
+ case "null":
121
+ case "undefined":
122
+ default:
123
+ return [];
124
+ }
125
+ }
126
+
127
+ export function getType(value) {
128
+ switch (true) {
129
+ case typeof value === "object":
130
+ if (!value) return "null";
131
+ else if (Array.isArray(value)) return "array";
132
+ else return "object";
133
+ case typeof value === "string":
134
+ if (moment(value).isValid()) return "date";
135
+ else return "string";
136
+ case typeof value === "number":
137
+ return "number";
138
+ case typeof value === "boolean":
139
+ return "boolean";
140
+ case typeof value === "undefined":
141
+ return "undefined";
142
+ default:
143
+ return "?";
144
+ }
145
+ }
146
+
147
+ export const defaultValue = (data_type) => {
148
+ switch (data_type) {
149
+ case "string":
150
+ return "";
151
+ case "number":
152
+ return 0;
153
+ case "date":
154
+ return moment().toJSON();
155
+ case "boolean":
156
+ return false;
157
+ case "array":
158
+ return [];
159
+ case "object":
160
+ return {};
161
+ case "null":
162
+ return null;
163
+ case "target":
164
+ return "";
165
+ case "undefined":
166
+ default:
167
+ return undefined;
168
+ }
169
+ };
170
+
171
+ const validateLength = (item, validations) =>
172
+ validations.reduce((errors, { name, value }) => {
173
+ if (name === "lengthEquals" && item.length !== value)
174
+ return errors.concat({ name, expected: value, received: item.length });
175
+ if (name === "maxLength" && item.length > value)
176
+ return errors.concat({ name, expected: value, received: item.length });
177
+ if (name === "minLength" && item.length < value)
178
+ return errors.concat({ name, expected: value, received: item.length });
179
+ return errors;
180
+ }, []);
181
+
182
+ const validateArray = (arr, validations) =>
183
+ validations.reduce((errors, { name, value }) => {
184
+ if (name === "includes" && !arr.includes(value))
185
+ return errors.concat({ name, expected: value, received: arr });
186
+ return errors;
187
+ }, validateLength(arr, validations));
188
+
189
+ const validateString = (str, validations) =>
190
+ validations.reduce((errors, { name, value }) => {
191
+ if (name === "strEquals" && str !== value)
192
+ return errors.concat({ name, expected: value, received: str });
193
+ //str.match() returns null when there is no match
194
+ if ((name === "isLike") & !str.match(new RegExp(value, "gi")))
195
+ return errors.concat({ name, expected: value, received: str });
196
+ if (
197
+ name === "isOneOf" &&
198
+ typeof value === "string" &&
199
+ !value
200
+ .split(",")
201
+ .map((v) => v.trim())
202
+ .includes(str)
203
+ )
204
+ return errors.concat({ name, expected: value, received: str });
205
+ return errors;
206
+ }, validateLength(str, validations));
207
+
208
+ const validateNumber = (num, validations) =>
209
+ validations.reduce((errors, { name, value }) => {
210
+ if (name === "numEquals" && num !== value)
211
+ return errors.concat({ name, expected: value, received: num });
212
+ if (name === "max" && num > value)
213
+ return errors.concat({ name, expected: value, received: num });
214
+ if (name === "min" && num < value)
215
+ return errors.concat({ name, expected: value, received: num });
216
+ if (
217
+ name === "isOneOf" &&
218
+ typeof value === "string" &&
219
+ !value
220
+ .split(",")
221
+ .map((v) => parseInt(v))
222
+ .includes(num)
223
+ )
224
+ return errors.concat({ name, expected: value, received: num });
225
+ return errors;
226
+ }, []);
227
+
228
+ const validateBoolean = (bool, validations) =>
229
+ validations.reduce((errors, { name, value }) => {
230
+ if (name === "boolEquals" && bool !== value)
231
+ return errors.concat({ name, expected: value, received: bool });
232
+ return errors;
233
+ }, []);
234
+
235
+ const validateDate = (datetime, validations) =>
236
+ validations.reduce((errors, { name, value }) => {
237
+ if (name === "dateEquals" && !moment(datetime).isSame(value))
238
+ return errors.concat({ name, expected: value, received: datetime });
239
+ if (name === "maxDate" && moment(datetime).isAfter(value))
240
+ return errors.concat({ name, expected: value, received: datetime });
241
+ if (name === "minDate" && moment(datetime).isBefore(value))
242
+ return errors.concat({ name, expected: value, received: datetime });
243
+ return errors;
244
+ }, []);
@@ -0,0 +1,128 @@
1
+ import React, { useState, useContext, useEffect } from "react";
2
+ import "./styles.scss";
3
+ import DescriptionBox from "../../atoms/DescriptionBox/DescriptionBox";
4
+ import EditBox from "../../molecules/EditBox/EditBox";
5
+ import Title from "../../atoms/Title/Title";
6
+ import Markdown from "../../atoms/Markdown/Markdown";
7
+ import ServiceContext from "../../ServiceContext";
8
+ import { Client } from "systemlynx";
9
+
10
+ export default function Documentation({
11
+ projectCode,
12
+ serviceId,
13
+ moduleName,
14
+ methodName,
15
+ }) {
16
+ const { connectedServices } = useContext(ServiceContext);
17
+
18
+ const service = connectedServices.find(
19
+ (service) => service.serviceId === serviceId && service.projectCode === projectCode
20
+ );
21
+ const { Plugin } = service ? Client.createService(service.system.connectionData) : {};
22
+
23
+ const [doc, setDocument] = useState({
24
+ documentation: "",
25
+ namespace: { serviceId, moduleName, methodName },
26
+ });
27
+
28
+ const fetchDocument = async (Plugin) => {
29
+ setDocument({
30
+ documentation: "",
31
+ namespace: { serviceId, moduleName, methodName },
32
+ });
33
+ try {
34
+ if (Plugin) {
35
+ const results = await Plugin.getDoc({
36
+ serviceId,
37
+ moduleName,
38
+ methodName,
39
+ });
40
+ setDocument(results);
41
+ }
42
+ } catch (error) {
43
+ console.error(error);
44
+ }
45
+ };
46
+
47
+ useEffect(() => {
48
+ fetchDocument(Plugin);
49
+ }, [methodName, moduleName, serviceId, Plugin]);
50
+
51
+ useEffect(() => {
52
+ // if (Plugin) Plugin.on(`reconnect`, fetchDocument.bind({}, Plugin));
53
+ }, [Plugin]);
54
+ return (
55
+ <section className="documentation">
56
+ <div className="documentation-view">
57
+ <div className="row">
58
+ <DocTitle
59
+ serviceId={serviceId}
60
+ moduleName={moduleName}
61
+ methodName={methodName}
62
+ />
63
+ </div>
64
+ <div className="row documentation-view__data-table">
65
+ <DocDescription doc={doc} setDocument={setDocument} Plugin={Plugin} />
66
+ </div>
67
+ </div>
68
+ </section>
69
+ );
70
+ }
71
+
72
+ const DocTitle = ({ serviceId, moduleName, methodName, variable_name = "..." }) => {
73
+ return (
74
+ <Title
75
+ style={{ marginBottom: "5px" }}
76
+ text={
77
+ <span className="documentation-view__title">
78
+ {methodName && moduleName && serviceId ? (
79
+ <>
80
+ {`${serviceId}.${moduleName}.${methodName}`}
81
+ <span className="documentation-view__parentheses">(</span>
82
+ <span className="documentation-view__parameter btn">{variable_name}</span>
83
+ <span className="documentation-view__parentheses">)</span>
84
+ </>
85
+ ) : moduleName && serviceId ? (
86
+ <>{`${serviceId}.${moduleName}`}</>
87
+ ) : (
88
+ serviceId && <>{`${serviceId}`}</>
89
+ )}
90
+ </span>
91
+ }
92
+ />
93
+ );
94
+ };
95
+
96
+ const DocDescription = ({ doc, setDocument, Plugin }) => {
97
+ const { serviceId, methodName, moduleName } = doc;
98
+ const [text, setText] = useState(doc.documentation);
99
+ const saveDocument = async (setFormDisplay) => {
100
+ if (Plugin) {
101
+ try {
102
+ const results = await Plugin.saveDoc({ ...doc, documentation: text });
103
+ setDocument(results);
104
+ setFormDisplay(false);
105
+ } catch (error) {
106
+ console.error(error);
107
+ }
108
+ }
109
+ };
110
+
111
+ const updateDoc = (documentation) => setText(documentation);
112
+ const cancel = () => setText(doc.documentation);
113
+
114
+ useEffect(() => {
115
+ setText(doc.documentation);
116
+ }, [doc]);
117
+ return (
118
+ <EditBox
119
+ mainObject={
120
+ <Markdown children={text || "Use markdown to create your documentation here"} />
121
+ }
122
+ hiddenForm={<DescriptionBox text={text || ""} setValue={updateDoc} />}
123
+ formSubmit={saveDocument}
124
+ stateChange={[serviceId, methodName, moduleName]}
125
+ onCancel={cancel}
126
+ />
127
+ );
128
+ };
@@ -0,0 +1,22 @@
1
+ .documentation-view {
2
+ padding-top: 2rem;
3
+ color: black;
4
+
5
+ &__parameter {
6
+ color: #3dceac;
7
+ font-weight: bold;
8
+ }
9
+
10
+ &__data-table {
11
+ margin-bottom: 30px;
12
+ }
13
+ &__title {
14
+ color: #454c69;
15
+ display: flex;
16
+ align-items: flex-start;
17
+ margin-left: 4px;
18
+ }
19
+ &__parentheses {
20
+ font-size: 26px;
21
+ }
22
+ }
@@ -0,0 +1,85 @@
1
+ import React, { useState } from "react";
2
+ import ExpandableSection from "../../molecules/ExpandableSection/ExpandableSection";
3
+ import TestCaption from "../../molecules/TestCaption/TestCaption";
4
+ import TestContainer from "../TestContainer/TestContainer";
5
+ import Argument from "../TestPanel/components/Argument.class";
6
+
7
+ import "./styles.scss";
8
+ import Count from "../../atoms/Count";
9
+
10
+ const MultiTestSection = ({
11
+ caption,
12
+ TestController,
13
+ TestSection,
14
+ dynamic,
15
+ namespace,
16
+ arg = {},
17
+ staticArguments,
18
+ }) => {
19
+ const className = "multi-test-section";
20
+ const [open, setOpen] = useState(false);
21
+
22
+ const toggleExpansion = () => {
23
+ setOpen((state) => !state);
24
+ };
25
+
26
+ const addTest = () => {
27
+ TestController.addTest(
28
+ namespace,
29
+ arg.name && [new Argument(arg.name, arg.FullTest, arg.input_type)]
30
+ );
31
+ TestSection.length === 1 && setOpen(true);
32
+ };
33
+ return (
34
+ <section className={className}>
35
+ <ExpandableSection
36
+ toggleExpansion={toggleExpansion}
37
+ open={open}
38
+ title={
39
+ <>
40
+ <TestCaption
41
+ caption={
42
+ <span>
43
+ {caption}{" "}
44
+ {TestSection.length > 0 && <Count count={TestSection.length} />}
45
+ </span>
46
+ }
47
+ />
48
+ <AddButton onClick={addTest} className={className} />
49
+ </>
50
+ }
51
+ title_color="#0d8065"
52
+ >
53
+ <div className={`${className}__test-data`}>
54
+ {TestSection.length > 0 ? (
55
+ TestSection.map((test, i) => (
56
+ <TestContainer
57
+ key={i}
58
+ TestController={TestController}
59
+ test={test}
60
+ testIndex={i}
61
+ title={`${i + 1}:`}
62
+ title_color={"#4b53b3"}
63
+ dynamic={dynamic}
64
+ open={true}
65
+ staticArguments={staticArguments}
66
+ multiTest
67
+ />
68
+ ))
69
+ ) : (
70
+ <span>no actions</span>
71
+ )}
72
+ </div>
73
+ </ExpandableSection>
74
+ </section>
75
+ );
76
+ };
77
+
78
+ const AddButton = ({ onClick, className }) => {
79
+ return (
80
+ <span className={`${className}__add-btn btn`} onClick={onClick}>
81
+ +
82
+ </span>
83
+ );
84
+ };
85
+ export default MultiTestSection;
@@ -0,0 +1,22 @@
1
+ .multi-test-section {
2
+ width: 100%;
3
+ &__test-data {
4
+ background: #dadada;
5
+ padding: 12px 15px;
6
+ width: 100%;
7
+ border-radius: 5px;
8
+ }
9
+ &__add-btn {
10
+ padding: 0px 4px;
11
+ border-radius: 21px;
12
+ font-weight: bold;
13
+ color: #5960b6;
14
+ font-size: 16px;
15
+ background: #cecee3;
16
+ font-family: monospace;
17
+ }
18
+ }
19
+
20
+ .react-json-view {
21
+ font-size: 14px;
22
+ }