@techextensor/tab-core-utility 2.1.5 → 2.1.7

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 (177) hide show
  1. package/.eslintrc.json +92 -0
  2. package/README.md +7 -0
  3. package/jest.config.ts +22 -0
  4. package/ng-package.json +7 -0
  5. package/package.json +18 -31
  6. package/project.json +42 -0
  7. package/{index.d.ts → src/index.ts} +77 -53
  8. package/src/lib/tab-core-utility/app/constants/api-constants.ts +33 -0
  9. package/src/lib/tab-core-utility/app/constants/common.ts +34 -0
  10. package/src/lib/tab-core-utility/app/constants/error-messages.ts +21 -0
  11. package/src/lib/tab-core-utility/app/constants/storage-constants.ts +17 -0
  12. package/src/lib/tab-core-utility/app/crud/tab-delete.service.ts +144 -0
  13. package/src/lib/tab-core-utility/app/crud/tab-get.service.ts +160 -0
  14. package/src/lib/tab-core-utility/app/crud/tab-insert.service.ts +75 -0
  15. package/src/lib/tab-core-utility/app/crud/tab-update.service.ts +105 -0
  16. package/src/lib/tab-core-utility/app/crud/tab-workflow.service.ts +39 -0
  17. package/src/lib/tab-core-utility/app/enums/controllers.enum.ts +24 -0
  18. package/src/lib/tab-core-utility/app/enums/dsq.enum.ts +46 -0
  19. package/src/lib/tab-core-utility/app/enums/permission.enum.ts +18 -0
  20. package/src/lib/tab-core-utility/app/enums/query.enum.ts +12 -0
  21. package/src/lib/tab-core-utility/app/enums/workflow.enum.ts +35 -0
  22. package/src/lib/tab-core-utility/app/helpers/common/app.helpers.ts +65 -0
  23. package/src/lib/tab-core-utility/app/helpers/common/dsq.helpers.ts +80 -0
  24. package/src/lib/tab-core-utility/app/helpers/common/req-res.helpers.ts +75 -0
  25. package/src/lib/tab-core-utility/app/helpers/common/where-clause.helpers.ts +262 -0
  26. package/src/lib/tab-core-utility/app/helpers/screen/forms.helpers.ts +33 -0
  27. package/src/lib/tab-core-utility/app/helpers/screen/grid-column-data.helpers.ts +88 -0
  28. package/src/lib/tab-core-utility/app/helpers/screen/grid.helpers.ts +113 -0
  29. package/src/lib/tab-core-utility/app/helpers/screen/media-upload.helpers.ts +74 -0
  30. package/src/lib/tab-core-utility/app/helpers/screen/plugin.helpers.ts +52 -0
  31. package/src/lib/tab-core-utility/app/helpers/screen/screen.helpers.ts +20 -0
  32. package/{lib/tab-core-utility/app/interfaces/auth.interface.d.ts → src/lib/tab-core-utility/app/interfaces/auth.interface.ts} +18 -15
  33. package/src/lib/tab-core-utility/app/interfaces/common-api.interface.ts +27 -0
  34. package/src/lib/tab-core-utility/app/interfaces/grid.interface.ts +118 -0
  35. package/src/lib/tab-core-utility/app/interfaces/orgInfo.interface.ts +34 -0
  36. package/src/lib/tab-core-utility/app/interfaces/schema.interface.ts +11 -0
  37. package/src/lib/tab-core-utility/app/interfaces/user.interface.ts +91 -0
  38. package/src/lib/tab-core-utility/app/models/api-query.class.ts +92 -0
  39. package/src/lib/tab-core-utility/app/models/app-object.class.ts +87 -0
  40. package/src/lib/tab-core-utility/app/models/common.class.ts +30 -0
  41. package/src/lib/tab-core-utility/app/models/data-source-queries.class.ts +114 -0
  42. package/src/lib/tab-core-utility/app/utils/filter.util.ts +78 -0
  43. package/src/lib/tab-core-utility/app/utils/form-builder.util.ts +31 -0
  44. package/src/lib/tab-core-utility/app/utils/json.util.ts +137 -0
  45. package/src/lib/tab-core-utility/app/utils/operators.util.ts +129 -0
  46. package/src/lib/tab-core-utility/app/utils/req-res.util.ts +189 -0
  47. package/src/lib/tab-core-utility/app/utils/tab-app.util.ts +131 -0
  48. package/src/lib/tab-core-utility/auth/auth.service.spec.ts +167 -0
  49. package/src/lib/tab-core-utility/auth/auth.service.ts +91 -0
  50. package/src/lib/tab-core-utility/auth/idb-storage.service.ts +77 -0
  51. package/src/lib/tab-core-utility/auth/local-storage.service.spec.ts +47 -0
  52. package/src/lib/tab-core-utility/auth/local-storage.service.ts +46 -0
  53. package/src/lib/tab-core-utility/auth/session-storage.service.spec.ts +47 -0
  54. package/src/lib/tab-core-utility/auth/session-storage.service.ts +46 -0
  55. package/src/lib/tab-core-utility/core/error-handler/error-handler-interceptor.service.ts +32 -0
  56. package/src/lib/tab-core-utility/core/error-handler/error-handler.store.spec.ts +16 -0
  57. package/src/lib/tab-core-utility/core/error-handler/error-handler.store.ts +26 -0
  58. package/src/lib/tab-core-utility/core/error-handler/models/error-handler.state.ts +9 -0
  59. package/src/lib/tab-core-utility/core/http-client/api-url.token.ts +4 -0
  60. package/src/lib/tab-core-utility/core/http-client/api.service.spec.ts +18 -0
  61. package/src/lib/tab-core-utility/core/http-client/api.service.ts +105 -0
  62. package/src/lib/tab-core-utility/core/util/auth.utils.ts +22 -0
  63. package/src/lib/tab-core-utility/store/auth.store.ts +54 -0
  64. package/src/lib/tab-core-utility/store/orginfo.store.ts +57 -0
  65. package/src/lib/tab-core-utility/store/schema.store.ts +85 -0
  66. package/src/test-setup.ts +8 -0
  67. package/tsconfig.json +29 -0
  68. package/tsconfig.lib.json +17 -0
  69. package/tsconfig.lib.prod.json +7 -0
  70. package/tsconfig.spec.json +16 -0
  71. package/esm2022/index.mjs +0 -64
  72. package/esm2022/lib/tab-core-utility/app/constants/api-constants.mjs +0 -33
  73. package/esm2022/lib/tab-core-utility/app/constants/common.mjs +0 -23
  74. package/esm2022/lib/tab-core-utility/app/constants/error-messages.mjs +0 -13
  75. package/esm2022/lib/tab-core-utility/app/constants/storage-constants.mjs +0 -15
  76. package/esm2022/lib/tab-core-utility/app/crud/tab-delete.service.mjs +0 -145
  77. package/esm2022/lib/tab-core-utility/app/crud/tab-get.service.mjs +0 -131
  78. package/esm2022/lib/tab-core-utility/app/crud/tab-insert.service.mjs +0 -77
  79. package/esm2022/lib/tab-core-utility/app/crud/tab-update.service.mjs +0 -105
  80. package/esm2022/lib/tab-core-utility/app/crud/tab-workflow.service.mjs +0 -43
  81. package/esm2022/lib/tab-core-utility/app/enums/controllers.enum.mjs +0 -26
  82. package/esm2022/lib/tab-core-utility/app/enums/dsq.enum.mjs +0 -48
  83. package/esm2022/lib/tab-core-utility/app/enums/permission.enum.mjs +0 -20
  84. package/esm2022/lib/tab-core-utility/app/enums/query.enum.mjs +0 -14
  85. package/esm2022/lib/tab-core-utility/app/enums/workflow.enum.mjs +0 -37
  86. package/esm2022/lib/tab-core-utility/app/helpers/common/app.helpers.mjs +0 -68
  87. package/esm2022/lib/tab-core-utility/app/helpers/common/dsq.helpers.mjs +0 -70
  88. package/esm2022/lib/tab-core-utility/app/helpers/common/req-res.helpers.mjs +0 -64
  89. package/esm2022/lib/tab-core-utility/app/helpers/common/where-clause.helpers.mjs +0 -208
  90. package/esm2022/lib/tab-core-utility/app/helpers/screen/forms.helpers.mjs +0 -38
  91. package/esm2022/lib/tab-core-utility/app/helpers/screen/grid-column-data.helpers.mjs +0 -78
  92. package/esm2022/lib/tab-core-utility/app/helpers/screen/grid.helpers.mjs +0 -112
  93. package/esm2022/lib/tab-core-utility/app/helpers/screen/media-upload.helpers.mjs +0 -77
  94. package/esm2022/lib/tab-core-utility/app/helpers/screen/plugin.helpers.mjs +0 -55
  95. package/esm2022/lib/tab-core-utility/app/helpers/screen/screen.helpers.mjs +0 -26
  96. package/esm2022/lib/tab-core-utility/app/interfaces/auth.interface.mjs +0 -2
  97. package/esm2022/lib/tab-core-utility/app/interfaces/common-api.interface.mjs +0 -2
  98. package/esm2022/lib/tab-core-utility/app/interfaces/grid.interface.mjs +0 -3
  99. package/esm2022/lib/tab-core-utility/app/interfaces/orgInfo.interface.mjs +0 -2
  100. package/esm2022/lib/tab-core-utility/app/interfaces/schema.interface.mjs +0 -2
  101. package/esm2022/lib/tab-core-utility/app/interfaces/user.interface.mjs +0 -2
  102. package/esm2022/lib/tab-core-utility/app/models/api-query.class.mjs +0 -47
  103. package/esm2022/lib/tab-core-utility/app/models/app-object.class.mjs +0 -30
  104. package/esm2022/lib/tab-core-utility/app/models/common.class.mjs +0 -12
  105. package/esm2022/lib/tab-core-utility/app/models/data-source-queries.class.mjs +0 -31
  106. package/esm2022/lib/tab-core-utility/app/utils/filter.util.mjs +0 -75
  107. package/esm2022/lib/tab-core-utility/app/utils/form-builder.util.mjs +0 -39
  108. package/esm2022/lib/tab-core-utility/app/utils/json.util.mjs +0 -138
  109. package/esm2022/lib/tab-core-utility/app/utils/operators.util.mjs +0 -129
  110. package/esm2022/lib/tab-core-utility/app/utils/req-res.util.mjs +0 -147
  111. package/esm2022/lib/tab-core-utility/app/utils/tab-app.util.mjs +0 -99
  112. package/esm2022/lib/tab-core-utility/auth/auth.service.mjs +0 -74
  113. package/esm2022/lib/tab-core-utility/auth/idb-storage.service.mjs +0 -69
  114. package/esm2022/lib/tab-core-utility/auth/local-storage.service.mjs +0 -52
  115. package/esm2022/lib/tab-core-utility/auth/session-storage.service.mjs +0 -52
  116. package/esm2022/lib/tab-core-utility/core/error-handler/error-handler-interceptor.service.mjs +0 -26
  117. package/esm2022/lib/tab-core-utility/core/error-handler/error-handler.store.mjs +0 -21
  118. package/esm2022/lib/tab-core-utility/core/error-handler/models/error-handler.state.mjs +0 -5
  119. package/esm2022/lib/tab-core-utility/core/http-client/api-url.token.mjs +0 -4
  120. package/esm2022/lib/tab-core-utility/core/http-client/api.service.mjs +0 -99
  121. package/esm2022/lib/tab-core-utility/core/util/auth.utils.mjs +0 -21
  122. package/esm2022/lib/tab-core-utility/store/auth.store.mjs +0 -43
  123. package/esm2022/lib/tab-core-utility/store/orginfo.store.mjs +0 -42
  124. package/esm2022/lib/tab-core-utility/store/schema.store.mjs +0 -68
  125. package/esm2022/techextensor-tab-core-utility.mjs +0 -5
  126. package/lib/tab-core-utility/app/constants/api-constants.d.ts +0 -30
  127. package/lib/tab-core-utility/app/constants/common.d.ts +0 -8
  128. package/lib/tab-core-utility/app/constants/error-messages.d.ts +0 -6
  129. package/lib/tab-core-utility/app/constants/storage-constants.d.ts +0 -14
  130. package/lib/tab-core-utility/app/crud/tab-delete.service.d.ts +0 -51
  131. package/lib/tab-core-utility/app/crud/tab-get.service.d.ts +0 -58
  132. package/lib/tab-core-utility/app/crud/tab-insert.service.d.ts +0 -37
  133. package/lib/tab-core-utility/app/crud/tab-update.service.d.ts +0 -14
  134. package/lib/tab-core-utility/app/crud/tab-workflow.service.d.ts +0 -20
  135. package/lib/tab-core-utility/app/enums/controllers.enum.d.ts +0 -24
  136. package/lib/tab-core-utility/app/enums/dsq.enum.d.ts +0 -42
  137. package/lib/tab-core-utility/app/enums/permission.enum.d.ts +0 -16
  138. package/lib/tab-core-utility/app/enums/query.enum.d.ts +0 -11
  139. package/lib/tab-core-utility/app/enums/workflow.enum.d.ts +0 -30
  140. package/lib/tab-core-utility/app/helpers/common/app.helpers.d.ts +0 -31
  141. package/lib/tab-core-utility/app/helpers/common/dsq.helpers.d.ts +0 -32
  142. package/lib/tab-core-utility/app/helpers/common/req-res.helpers.d.ts +0 -62
  143. package/lib/tab-core-utility/app/helpers/common/where-clause.helpers.d.ts +0 -82
  144. package/lib/tab-core-utility/app/helpers/screen/forms.helpers.d.ts +0 -11
  145. package/lib/tab-core-utility/app/helpers/screen/grid-column-data.helpers.d.ts +0 -33
  146. package/lib/tab-core-utility/app/helpers/screen/grid.helpers.d.ts +0 -63
  147. package/lib/tab-core-utility/app/helpers/screen/media-upload.helpers.d.ts +0 -38
  148. package/lib/tab-core-utility/app/helpers/screen/plugin.helpers.d.ts +0 -25
  149. package/lib/tab-core-utility/app/helpers/screen/screen.helpers.d.ts +0 -11
  150. package/lib/tab-core-utility/app/interfaces/common-api.interface.d.ts +0 -24
  151. package/lib/tab-core-utility/app/interfaces/grid.interface.d.ts +0 -110
  152. package/lib/tab-core-utility/app/interfaces/orgInfo.interface.d.ts +0 -31
  153. package/lib/tab-core-utility/app/interfaces/schema.interface.d.ts +0 -11
  154. package/lib/tab-core-utility/app/interfaces/user.interface.d.ts +0 -84
  155. package/lib/tab-core-utility/app/models/api-query.class.d.ts +0 -69
  156. package/lib/tab-core-utility/app/models/app-object.class.d.ts +0 -74
  157. package/lib/tab-core-utility/app/models/common.class.d.ts +0 -24
  158. package/lib/tab-core-utility/app/models/data-source-queries.class.d.ts +0 -95
  159. package/lib/tab-core-utility/app/utils/filter.util.d.ts +0 -30
  160. package/lib/tab-core-utility/app/utils/form-builder.util.d.ts +0 -13
  161. package/lib/tab-core-utility/app/utils/json.util.d.ts +0 -25
  162. package/lib/tab-core-utility/app/utils/operators.util.d.ts +0 -21
  163. package/lib/tab-core-utility/app/utils/req-res.util.d.ts +0 -61
  164. package/lib/tab-core-utility/app/utils/tab-app.util.d.ts +0 -48
  165. package/lib/tab-core-utility/auth/auth.service.d.ts +0 -53
  166. package/lib/tab-core-utility/auth/idb-storage.service.d.ts +0 -14
  167. package/lib/tab-core-utility/auth/local-storage.service.d.ts +0 -22
  168. package/lib/tab-core-utility/auth/session-storage.service.d.ts +0 -22
  169. package/lib/tab-core-utility/core/error-handler/error-handler-interceptor.service.d.ts +0 -3
  170. package/lib/tab-core-utility/core/error-handler/error-handler.store.d.ts +0 -10
  171. package/lib/tab-core-utility/core/error-handler/models/error-handler.state.d.ts +0 -5
  172. package/lib/tab-core-utility/core/http-client/api-url.token.d.ts +0 -3
  173. package/lib/tab-core-utility/core/http-client/api.service.d.ts +0 -65
  174. package/lib/tab-core-utility/core/util/auth.utils.d.ts +0 -9
  175. package/lib/tab-core-utility/store/auth.store.d.ts +0 -19
  176. package/lib/tab-core-utility/store/orginfo.store.d.ts +0 -22
  177. package/lib/tab-core-utility/store/schema.store.d.ts +0 -32
@@ -0,0 +1,78 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Returns the filter value type as a string.
4
+ * @param type The filter value type.
5
+ * @returns The filter value type as a string.
6
+ */
7
+ export function getFilterValueTypeInString(type: number): string {
8
+ switch (type) {
9
+ case 1:
10
+ return 'Literal';
11
+ case 2:
12
+ return 'Parameter';
13
+ case 3:
14
+ return 'Property';
15
+ case 4:
16
+ return 'Global';
17
+ default:
18
+ return '';
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Returns the conjunction clause name based on the type.
24
+ * @param type The conjunction clause type.
25
+ * @returns The conjunction clause name.
26
+ */
27
+ export function getConjuctionClauseName(type: number): string {
28
+ return type === 1 ? 'and' : 'or';
29
+ }
30
+
31
+ /**
32
+ * Returns the conjunction clause value based on the type.
33
+ * @param type The conjunction clause name.
34
+ * @returns The conjunction clause value.
35
+ */
36
+ export function getConjuctionClause(type: string): number {
37
+ return type === 'and' ? 1 : 2;
38
+ }
39
+
40
+ /**
41
+ * Returns the filter type based on the element.
42
+ * @param element The filter element.
43
+ * @returns The filter type.
44
+ */
45
+ export function getFilterType(element: any): string {
46
+ switch (element.ValueType) {
47
+ case 1:
48
+ return element.Value;
49
+ case 2:
50
+ return '@' + element.Value;
51
+ case 3:
52
+ return '((' + element.Value + '))';
53
+ case 4:
54
+ return '[[' + element.Value + ']]';
55
+ default:
56
+ return '';
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Returns the filter value type as an integer.
62
+ * @param type The filter value type.
63
+ * @returns The filter value type as an integer.
64
+ */
65
+ export function getFilterValueTypeInInt(type: string): string {
66
+ switch (type) {
67
+ case 'Literal':
68
+ return '1';
69
+ case 'Parameter':
70
+ return '2';
71
+ case 'Property':
72
+ return '3';
73
+ case 'Global':
74
+ return '4';
75
+ default:
76
+ return '0';
77
+ }
78
+ }
@@ -0,0 +1,31 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Returns the form builder type based on the data type.
4
+ * @param dataType The data type.
5
+ * @returns The form builder type.
6
+ */
7
+ export function getFormBuilderType(dataType: number): string {
8
+ if ([1, 7, 13].includes(dataType)) return 'textfield';
9
+ else if ([2, 3, 4].includes(dataType)) return 'number';
10
+ else if ([5, 6].includes(dataType)) return 'datetime';
11
+ else return 'textfield';
12
+ }
13
+
14
+ /**
15
+ * Returns the field type based on the data type and whether it's a lookup.
16
+ * @param dataType The data type.
17
+ * @param isLookup Indicates if it's a lookup field.
18
+ * @returns The field type.
19
+ */
20
+ export function getFieldsType(dataType: number, isLookup: any): string {
21
+ if (isLookup && dataType !== 6) return 'string';
22
+ if ([1, 2, 16].includes(dataType)) return 'number';
23
+ else if (dataType === 3) return 'boolean';
24
+ else if (
25
+ [4, ...Array.from({ length: 9 }, (_, i) => i + 7)].includes(dataType)
26
+ )
27
+ return 'string';
28
+ else if (dataType === 5) return 'Date';
29
+ else if (dataType === 6) return 'date';
30
+ else return 'string';
31
+ }
@@ -0,0 +1,137 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /* eslint-disable no-prototype-builtins */
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+
5
+ /**
6
+ * Validates if a string is a valid JSON.
7
+ * @param str The string to validate.
8
+ * @returns True if the string is a valid JSON, false otherwise.
9
+ */
10
+ export function validateJSON(str: string): boolean {
11
+ try {
12
+ const json = JSON.parse(str);
13
+ return Object.prototype.toString.call(json).slice(8, -1) === 'Object';
14
+ } catch (e) {
15
+ return false;
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Creates dynamic data based on the input object
21
+ * @param obj The input object to create dynamic data from
22
+ * @returns The formatted array
23
+ */
24
+ export function createDynamicData(obj: any) {
25
+ return formatArray(obj);
26
+ }
27
+
28
+ /**
29
+ * Formats the input object into a new array with AppFieldID and Value pairs
30
+ * @param input The input object to be formatted
31
+ * @returns The formatted array with AppFieldID and Value pairs
32
+ */
33
+ function formatArray(input: any) {
34
+ if (input !== null) {
35
+ const newObj = Object.keys(input).map((key) => {
36
+ let Value: any = '';
37
+ if (Array.isArray(input[key])) {
38
+ if (key === 'Child_Relationship') {
39
+ Value = handleChildRelationship(input[key]);
40
+ } else {
41
+ Value = handleObject(input[key]);
42
+ }
43
+ } else if (typeof input[key] === 'object') {
44
+ Value = handleObject(input[key]);
45
+ } else {
46
+ Value = input[key];
47
+ }
48
+ return { AppFieldID: key, Value };
49
+ });
50
+ return newObj;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * Handles the Child_Relationship key in the input object
57
+ * @param child The value of the Child_Relationship key
58
+ * @returns The JSON stringified value if not null, empty, or 'null'; otherwise null
59
+ */
60
+ function handleChildRelationship(child: any) {
61
+ if (child !== null && child !== '' && child !== 'null') {
62
+ return JSON.stringify(child);
63
+ } else {
64
+ return null;
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Handles object keys in the input object based on specific cases
70
+ * @param obj The object to be handled
71
+ * @returns The JSON stringified value based on specific cases or recursively formats the object
72
+ */
73
+ function handleObject(obj: any) {
74
+ if (obj === null) {
75
+ return null;
76
+ }
77
+ switch (Object.keys(obj)[0]) {
78
+ case 'Container':
79
+ case 'Setting_Value':
80
+ case 'Child_Relationship':
81
+ case 'ScreenConfiguration':
82
+ case 'AppObjectConfiguration':
83
+ case 'SchemaConfig':
84
+ case 'Criteria':
85
+ case 'ApplyCriteria':
86
+ case 'SLASetting':
87
+ return JSON.stringify(obj);
88
+ default:
89
+ return formatArray(obj);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Removes blank values from the input object
95
+ * @param dataObj The input object to remove blank values from
96
+ */
97
+ export function removeBlankValue(dataObj: any) {
98
+ Object.keys(dataObj).forEach((key) => {
99
+ if (Array.isArray(dataObj[key])) {
100
+ dataObj[key].forEach((item: { Value: any }, i: any) => {
101
+ if (isValueBlank(item.Value)) {
102
+ dataObj[key].splice(i, 1);
103
+ } else {
104
+ removeBlankValue(item);
105
+ }
106
+ });
107
+ if (dataObj[key].length === 0) {
108
+ delete dataObj[key];
109
+ }
110
+ } else if (dataObj[key] && typeof dataObj[key] === 'object') {
111
+ removeBlankValue(dataObj[key]);
112
+ if (Object.keys(dataObj[key]).length === 0) {
113
+ delete dataObj[key];
114
+ }
115
+ } else if (key === 'Value' && isValueBlank(dataObj[key])) {
116
+ delete dataObj[key];
117
+ }
118
+ });
119
+ }
120
+
121
+ /**
122
+ * Removes blank array keys from the input object
123
+ * @param dataObj The input object to remove blank array keys from
124
+ */
125
+ export function removeBlankArrayKeys(dataObj: any) {
126
+ dataObj.forEach((element: any, i: any) => {
127
+ if (element && element.hasOwnProperty('Value')) {
128
+ if (typeof element.Value === 'object' && element.Value.length == 0) {
129
+ dataObj.splice(i, 1);
130
+ }
131
+ }
132
+ });
133
+ }
134
+
135
+ function isValueBlank(value: any): boolean {
136
+ return value === null || value === '';
137
+ }
@@ -0,0 +1,129 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Converts a relational operator value to a number.
4
+ * @param dataType The relational operator value as a string.
5
+ * @returns The relational operator value as a number.
6
+ */
7
+ export function getRelationalOperatorValueToNumber(dataType: string): number {
8
+ const operatorsMap: Record<string, number> = {
9
+ greaterthan: 1,
10
+ lessthan: 2,
11
+ equal: 3,
12
+ in: 4,
13
+ notin: 5,
14
+ isnull: 6,
15
+ isnotnull: 7,
16
+ notequal: 8,
17
+ greaterthanorequal: 9,
18
+ lessthanorequal: 10,
19
+ contains: 11,
20
+ notcontains: 12,
21
+ startswith: 13,
22
+ notstartswith: 14,
23
+ endswith: 15,
24
+ notendswith: 16,
25
+ between: 17,
26
+ notbetween: 18,
27
+ splitcontains: 19,
28
+ notsplitcontains: 20,
29
+ };
30
+ return operatorsMap[dataType] || 0;
31
+ }
32
+
33
+ /**
34
+ * Converts a relational operator value to a string.
35
+ * @param dataType The relational operator value as a number.
36
+ * @returns The relational operator value as a string.
37
+ */
38
+ export function getRelationalOperatorValueToString(dataType: number): string {
39
+ const operatorsMap: Record<number, string> = {
40
+ 1: 'greaterthan',
41
+ 2: 'lessthan',
42
+ 3: 'equal',
43
+ 4: 'in',
44
+ 5: 'notin',
45
+ 6: 'isnull',
46
+ 7: 'isnotnull',
47
+ 8: 'notequal',
48
+ 9: 'greaterthanorequal',
49
+ 10: 'lessthanorequal',
50
+ 11: 'contains',
51
+ 12: 'notcontains',
52
+ 13: 'startswith',
53
+ 14: 'notstartswith',
54
+ 15: 'endswith',
55
+ 16: 'notendswith',
56
+ 17: 'between',
57
+ 18: 'notbetween',
58
+ 19: 'splitcontains',
59
+ 20: 'notsplitcontains',
60
+ };
61
+ return operatorsMap[dataType] || '';
62
+ }
63
+
64
+ /**
65
+ * Returns a list of operators for the query builder based on the data type.
66
+ * @param dataType The data type.
67
+ * @returns A list of operators.
68
+ */
69
+ export function getOperatorListForQueryBuilder(
70
+ dataType: any
71
+ ): { value: string; key: string }[] {
72
+ let operators: { value: string; key: string }[] = [];
73
+ if (dataType === 'string') {
74
+ operators = [
75
+ { value: 'equal', key: 'Equal To' },
76
+ { value: 'in', key: 'IN' },
77
+ { value: 'notin', key: 'NOT IN' },
78
+ { value: 'isnull', key: 'Is NULL' },
79
+ { value: 'isnotnull', key: 'Is Not NULL' },
80
+ { value: 'notequal', key: 'Not Equal To' },
81
+ { value: 'contains', key: 'Contains' },
82
+ { value: 'notcontains', key: 'Not Contains' },
83
+ { value: 'startswith', key: 'Starts With' },
84
+ { value: 'notstartswith', key: 'Not Starts With' },
85
+ { value: 'endswith', key: 'Ends With' },
86
+ { value: 'notendswith', key: 'Not Ends With' },
87
+ { value: 'splitcontains', key: 'SplitContains' },
88
+ { value: 'notsplitcontains', key: 'Not SplitContains' },
89
+ ];
90
+ } else if (dataType === 'number') {
91
+ operators = [
92
+ { value: 'greaterthan', key: 'Greater Than' },
93
+ { value: 'lessthan', key: 'Less Than' },
94
+ { value: 'equal', key: 'Equal To' },
95
+ { value: 'isnull', key: 'Is NULL' },
96
+ { value: 'isnotnull', key: 'Is Not NULL' },
97
+ { value: 'notequal', key: 'Not Equal To' },
98
+ { value: 'greaterthanorequal', key: 'Greater Than OR Equal To' },
99
+ { value: 'lessthanorequal', key: 'Less Than OR Equal To' },
100
+ ];
101
+ } else if (dataType === 'Date' || dataType === 'date') {
102
+ operators = [
103
+ { value: 'greaterthan', key: 'Greater Than' },
104
+ { value: 'lessthan', key: 'Less Than' },
105
+ { value: 'equal', key: 'Equal To' },
106
+ { value: 'isnull', key: 'Is NULL' },
107
+ { value: 'isnotnull', key: 'Is Not NULL' },
108
+ { value: 'notequal', key: 'Not Equal To' },
109
+ { value: 'greaterthanorequal', key: 'Greater Than OR Equal To' },
110
+ { value: 'lessthanorequal', key: 'Less Than OR Equal To' },
111
+ { value: 'contains', key: 'Contains' },
112
+ { value: 'notcontains', key: 'Not Contains' },
113
+ { value: 'startswith', key: 'Starts With' },
114
+ { value: 'notstartswith', key: 'Not Starts With' },
115
+ { value: 'endswith', key: 'Ends With' },
116
+ { value: 'notendswith', key: 'Not Ends With' },
117
+ ];
118
+ } else if (dataType === 'boolean') {
119
+ operators = [
120
+ { value: 'equal', key: 'Equal To' },
121
+ { value: 'isnull', key: 'Is NULL' },
122
+ { value: 'isnotnull', key: 'Is Not NULL' },
123
+ { value: 'notequal', key: 'Not Equal To' },
124
+ { value: 'contains', key: 'Contains' },
125
+ { value: 'notcontains', key: 'Not Contains' },
126
+ ];
127
+ }
128
+ return operators;
129
+ }
@@ -0,0 +1,189 @@
1
+ /* eslint-disable no-prototype-builtins */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { HttpHeaders } from '@angular/common/http';
4
+ import { Common } from '../constants/common';
5
+ import { AppObject } from '../models/app-object.class';
6
+ import {
7
+ getAppObject,
8
+ getDsqIdfromSelectedAppObjectDSQArray,
9
+ } from './tab-app.util';
10
+ import { AppFields } from '../models/data-source-queries.class';
11
+ import { API } from '../constants/api-constants';
12
+ import { getFormBuilderType } from './form-builder.util';
13
+ import { StorageConstants } from '../constants/storage-constants';
14
+ // import { inject } from '@angular/core';
15
+ import { SessionStorageService } from '../../auth/session-storage.service';
16
+ import { API_URL } from '../../core/http-client/api-url.token';
17
+
18
+ // const sessionStorageService = inject(SessionStorageService);
19
+ const sessionStorageService = new SessionStorageService();
20
+
21
+ /**
22
+ * Delete a key from the response object
23
+ *
24
+ * @param response - The response object
25
+ * @param key - The key to be deleted
26
+ * @returns any - The updated response object
27
+ */
28
+ export function deleteKeyFromResponse(response: any, key: string) {
29
+ delete response[key];
30
+ return response;
31
+ }
32
+
33
+ /**
34
+ * Remove the primary key from the response object
35
+ *
36
+ * @param response - The response object
37
+ * @param field - The field to be removed as primary key
38
+ * @returns any - The updated response object
39
+ */
40
+ export function removePrimaryKey(response: any, field: string) {
41
+ if (field) {
42
+ deleteKeyFromResponse(response, field);
43
+ }
44
+ return response;
45
+ }
46
+
47
+ /**
48
+ * Remove multiple primary keys from the response object
49
+ *
50
+ * @param response - The response object
51
+ * @param fields - The array of fields to be removed as primary keys
52
+ * @returns any - The updated response object
53
+ */
54
+ export function removeMultiplePrimaryKey(response: any, fields: any) {
55
+ fields.forEach((element: any) => {
56
+ delete response[element.FieldName];
57
+ });
58
+ return response;
59
+ }
60
+
61
+ /**
62
+ * Get the HttpHeaders for API requests
63
+ *
64
+ * @returns HttpHeaders | null - The HttpHeaders object or null
65
+ */
66
+ export function getHeaders() {
67
+ const token = sessionStorageService.getSessionStorage(StorageConstants.token);
68
+ const staticToken = sessionStorageService.getSessionStorage(StorageConstants.staticToken);
69
+
70
+ if (!token && staticToken) {
71
+ // Token is empty but staticToken is not
72
+ return new HttpHeaders({
73
+ 'Content-Type': 'application/json',
74
+ Authorization: staticToken,
75
+ ApplicationCode: Common.applicationCode,
76
+ });
77
+ } else if (token) {
78
+ // Token is not empty
79
+ return new HttpHeaders({
80
+ 'Content-Type': 'application/json',
81
+ Authorization: token,
82
+ ApplicationCode: Common.applicationCode,
83
+ });
84
+ }
85
+ // Handle the case when both tokens are empty
86
+ return null;
87
+ }
88
+
89
+ /**
90
+ * Get the primary key fields from the AppObject
91
+ *
92
+ * @param appObject - The AppObject
93
+ * @returns AppFields[] | null - The array of primary key fields or null
94
+ */
95
+
96
+ export function getPrimaryKeyFields(appObject: AppObject) {
97
+ if (appObject.Fields.length) {
98
+ return appObject.Fields.filter((field) => field.IsPrimaryKey);
99
+ }
100
+ return null;
101
+ }
102
+
103
+ /**
104
+ * Get the edit record ID from the response object
105
+ *
106
+ * @param response - The response object
107
+ * @param fieldName - The field name for the edit record ID
108
+ * @returns any - The edit record ID
109
+ */
110
+ export function getEditRecordId(response: any, fieldName: any) {
111
+ let recordId = null;
112
+ if (fieldName) {
113
+ recordId = response[fieldName] || null;
114
+ } else {
115
+ recordId = response.Id || response.ID || null;
116
+ }
117
+ return recordId;
118
+ }
119
+
120
+ /**
121
+ * Generate the fields schema based on the AppFields
122
+ *
123
+ * @param fields - The AppFields object
124
+ * @returns any - The generated fields schema
125
+ */
126
+ export function generateFieldsSchema(fields: AppFields) {
127
+ let schema = {};
128
+ if (fields.hasOwnProperty('LookUpDetails')) {
129
+ const selectedAppObject: AppObject = getAppObject(
130
+ fields.LookUpDetails.LookupObject
131
+ );
132
+ const dsqID = getDsqIdfromSelectedAppObjectDSQArray(
133
+ selectedAppObject?.DataSourceQueries,
134
+ fields.LookUpDetails.LookupObject,
135
+ 'List'
136
+ );
137
+ schema = {
138
+ label: fields.DisplayName,
139
+ type: 'select',
140
+ key: fields.SystemDBFieldName,
141
+ input: true,
142
+ dataSrc: 'url',
143
+ valueProperty: fields.LookUpDetails.LookupField,
144
+ template: `<span>{{ item.${fields.LookUpDetails.DisplayField} }}</span>`,
145
+ selectValues: 'Result',
146
+ data: {
147
+ url: `${API_URL}${API.getListFromDsq}${dsqID}`,// API.getListFromDsq + dsqID,
148
+ headers: [
149
+ {
150
+ "key": "Applicationcode",
151
+ "value": sessionStorageService.getSessionStorage(StorageConstants.applicationCode)
152
+ },
153
+ {
154
+ "key": "Authorization",
155
+ "value": sessionStorageService.getSessionStorage(StorageConstants.token)
156
+ }
157
+ ],
158
+ },
159
+
160
+ };
161
+ } else {
162
+ schema = {
163
+ label: fields.DisplayName,
164
+ type: getFormBuilderType(fields.FieldType.DataType),
165
+ key: fields.SystemDBFieldName,
166
+ input: true,
167
+ };
168
+ }
169
+ return schema;
170
+ }
171
+
172
+ /**
173
+ * Get the HttpHeaders for form data requests
174
+ *
175
+ * @returns HttpHeaders | null - The HttpHeaders object or null
176
+ */
177
+ export function getFormDataHeaders() {
178
+ const isToken = sessionStorageService.getSessionStorage(
179
+ StorageConstants.token
180
+ );
181
+ if (isToken) {
182
+ return new HttpHeaders({
183
+ Accept: '*/*',
184
+ Authorization: isToken,
185
+ ApplicationCode: Common.applicationCode,
186
+ });
187
+ }
188
+ return null;
189
+ }
@@ -0,0 +1,131 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import { Common } from '../constants/common';
4
+ import { AppObject } from '../models/app-object.class';
5
+ import { deleteKeyFromResponse } from './req-res.util';
6
+
7
+ /** Get the DataSourceQuery ID from the selected AppObject's DataSourceQuery array
8
+ * @param dsqList - The list of DataSourceQueries
9
+ * @param table - The table name
10
+ * @param like - The like string
11
+ * @returns string - The ID of the DataSourceQuery
12
+ */
13
+
14
+ export function getDsqIdfromSelectedAppObjectDSQArray(
15
+ dsqList: any,
16
+ table: string,
17
+ like: string
18
+ ) {
19
+ if (dsqList) {
20
+ const matchName = like + '_' + table;
21
+ const result = dsqList.find((d: any) => d.QueryName === matchName);
22
+ return result?.ID;
23
+ }
24
+ }
25
+
26
+ /** Get the AppObject based on the provided ID
27
+ * @param id - The ID of the AppObject
28
+ * @returns AppObject | null - The found AppObject or null
29
+ */
30
+
31
+ export function getAppObject(id: string) {
32
+ const tabData: any | null = Common.tabJson;
33
+ return (
34
+ tabData?.AppObjects.find((t: any) => t.ID === id?.toLowerCase()) || null
35
+ );
36
+ }
37
+
38
+ /**
39
+ * Get the AppObject from the DataSourceQuery ID
40
+ * @param dsqId - The DataSourceQuery ID
41
+ * @returns AppObject | null - The found AppObject or null
42
+ */
43
+
44
+ export function getAppObjectFromDataSourceQueryID(dsqId: string) {
45
+ const tabData: any = Common.tabJson;
46
+ if (!dsqId || !tabData) {
47
+ return null;
48
+ }
49
+
50
+ for (const appObject of tabData.AppObjects) {
51
+ const dsq = appObject.DataSourceQueries.find(
52
+ (l: any) => l.ID === dsqId?.toLowerCase()
53
+ );
54
+ if (dsq) {
55
+ return appObject;
56
+ }
57
+ }
58
+
59
+ return null;
60
+ }
61
+
62
+ /**
63
+ * Get the DataSourceQuery ID from the QueryName and table
64
+ * @param table - The table name
65
+ * @param dsq - The DataSourceQuery name
66
+ * @returns any - The found DataSourceQuery
67
+ */
68
+ export function getDsqIDFromQueryName(table: string, dsq: string) {
69
+ const appObjectList = getAppObjectFromSystemDBTableName(table);
70
+ return appObjectList?.DataSourceQueries.find((d: any) => d.QueryName === dsq);
71
+ }
72
+
73
+ /**
74
+ * Get the Data from the DataSourceQuery ID
75
+ *
76
+ * @param dsqId - The DataSourceQuery ID
77
+ * @returns any - The found Data
78
+ */
79
+
80
+ export function getDataFromDataSourceQueryID(dsqId: string) {
81
+ const tabData: any = Common.tabJson;
82
+ if (!tabData) {
83
+ return null;
84
+ }
85
+
86
+ for (const appObject of tabData.AppObjects) {
87
+ const DSQ = appObject.DataSourceQueries.find(
88
+ (l: any) => l.ID === dsqId?.toLowerCase()
89
+ );
90
+ if (DSQ) {
91
+ return DSQ;
92
+ }
93
+ }
94
+
95
+ return null;
96
+ }
97
+
98
+ /**
99
+ * Synchronize AppObject fields with the response
100
+ *
101
+ * @param response - The response object
102
+ * @param appObject - The AppObject
103
+ * @returns any - The synchronized response object
104
+ */
105
+ export function syncAppObjectFields(response: any, appObject: AppObject) {
106
+ for (const key in response) {
107
+ const foundObj = appObject.Fields.find((f: any) => f.FieldName === key);
108
+ const chilData = appObject.ChildRelationShips?.map(
109
+ (x) => x.childDetails.LookupObject
110
+ );
111
+ if (!foundObj && !(chilData && chilData.some((x) => x.includes(key)))) {
112
+ deleteKeyFromResponse(response, key);
113
+ }
114
+ }
115
+ return response;
116
+ }
117
+
118
+ /**
119
+ * Get the AppObject based on the SystemDBTableName
120
+ *
121
+ * @param tableName - The SystemDBTableName
122
+ * @returns AppObject | null - The found AppObject or null
123
+ */
124
+ export function getAppObjectFromSystemDBTableName(tableName: string) {
125
+ const tabData: any = Common.tabJson;
126
+ return (
127
+ tabData?.AppObjects.find(
128
+ (t: { SystemDBTableName: string }) => t.SystemDBTableName === tableName
129
+ ) || null
130
+ );
131
+ }