@intellegens/cornerstone-client 0.0.0-experimental-upgrade-20260302-1

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 (251) hide show
  1. package/README.md +256 -0
  2. package/demo/index.ts +29 -0
  3. package/demo/public_html/favicon.ico +0 -0
  4. package/demo/public_html/index.html +106 -0
  5. package/demo/public_html/websettings.json +3 -0
  6. package/dist/adapters/CollectionViewAdapter/index.d.ts +198 -0
  7. package/dist/adapters/CollectionViewAdapter/index.integration.test.d.ts +1 -0
  8. package/dist/adapters/CollectionViewAdapter/index.integration.test.js +163 -0
  9. package/dist/adapters/CollectionViewAdapter/index.js +381 -0
  10. package/dist/adapters/SearchAdapter/index.d.ts +55 -0
  11. package/dist/adapters/SearchAdapter/index.js +233 -0
  12. package/dist/adapters/index.d.ts +2 -0
  13. package/dist/adapters/index.js +2 -0
  14. package/dist/data/api/dto/PropertyPathDto.d.ts +4 -0
  15. package/dist/data/api/dto/PropertyPathDto.js +1 -0
  16. package/dist/data/api/dto/ReadOptionsDto.d.ts +8 -0
  17. package/dist/data/api/dto/ReadOptionsDto.js +1 -0
  18. package/dist/data/api/dto/ReadResultDto.d.ts +12 -0
  19. package/dist/data/api/dto/ReadResultDto.js +1 -0
  20. package/dist/data/api/dto/ReadResultMetadataDto.d.ts +8 -0
  21. package/dist/data/api/dto/ReadResultMetadataDto.js +1 -0
  22. package/dist/data/api/dto/crud/CrudMetadataDto.d.ts +4 -0
  23. package/dist/data/api/dto/crud/CrudMetadataDto.js +1 -0
  24. package/dist/data/api/dto/crud/index.d.ts +1 -0
  25. package/dist/data/api/dto/crud/index.js +1 -0
  26. package/dist/data/api/dto/index.d.ts +4 -0
  27. package/dist/data/api/dto/index.js +4 -0
  28. package/dist/data/api/dto/read/ReadMetadataDto.d.ts +8 -0
  29. package/dist/data/api/dto/read/ReadMetadataDto.js +1 -0
  30. package/dist/data/api/dto/read/ReadSelectedDefinitionDto.d.ts +18 -0
  31. package/dist/data/api/dto/read/ReadSelectedDefinitionDto.js +1 -0
  32. package/dist/data/api/dto/read/ReadSelectedNestedCollectionCriteriaDto.d.ts +22 -0
  33. package/dist/data/api/dto/read/ReadSelectedNestedCollectionCriteriaDto.js +1 -0
  34. package/dist/data/api/dto/read/ReadSelectedNestedCriteriaDto.d.ts +18 -0
  35. package/dist/data/api/dto/read/ReadSelectedNestedCriteriaDto.js +1 -0
  36. package/dist/data/api/dto/read/ReadSelectedOrderingDefinitionDto.d.ts +7 -0
  37. package/dist/data/api/dto/read/ReadSelectedOrderingDefinitionDto.js +1 -0
  38. package/dist/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +14 -0
  39. package/dist/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.js +1 -0
  40. package/dist/data/api/dto/read/ReadSelectedPaginationDefinitionDto.d.ts +13 -0
  41. package/dist/data/api/dto/read/ReadSelectedPaginationDefinitionDto.js +1 -0
  42. package/dist/data/api/dto/read/ReadSelectedSearchDefinitionBuilder.d.ts +167 -0
  43. package/dist/data/api/dto/read/ReadSelectedSearchDefinitionBuilder.js +267 -0
  44. package/dist/data/api/dto/read/ReadSelectedSearchDefinitionDto.d.ts +33 -0
  45. package/dist/data/api/dto/read/ReadSelectedSearchDefinitionDto.js +1 -0
  46. package/dist/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +114 -0
  47. package/dist/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.js +1 -0
  48. package/dist/data/api/dto/read/index.d.ts +10 -0
  49. package/dist/data/api/dto/read/index.js +10 -0
  50. package/dist/data/api/dto/response/ApiErrorDto.d.ts +17 -0
  51. package/dist/data/api/dto/response/ApiErrorDto.js +1 -0
  52. package/dist/data/api/dto/response/ApiErrorResponseDto.d.ts +11 -0
  53. package/dist/data/api/dto/response/ApiErrorResponseDto.js +1 -0
  54. package/dist/data/api/dto/response/ApiResponseDto.d.ts +3 -0
  55. package/dist/data/api/dto/response/ApiResponseDto.js +1 -0
  56. package/dist/data/api/dto/response/ApiSuccessResponseDto.d.ts +13 -0
  57. package/dist/data/api/dto/response/ApiSuccessResponseDto.js +1 -0
  58. package/dist/data/api/dto/response/EmptyMetadataDto.d.ts +4 -0
  59. package/dist/data/api/dto/response/EmptyMetadataDto.js +1 -0
  60. package/dist/data/api/dto/response/MetadataDto.d.ts +25 -0
  61. package/dist/data/api/dto/response/MetadataDto.js +1 -0
  62. package/dist/data/api/dto/response/index.d.ts +5 -0
  63. package/dist/data/api/dto/response/index.js +5 -0
  64. package/dist/data/api/enum/index.d.ts +2 -0
  65. package/dist/data/api/enum/index.js +2 -0
  66. package/dist/data/api/enum/read/ReadSelectedCollectionOperator.d.ts +16 -0
  67. package/dist/data/api/enum/read/ReadSelectedCollectionOperator.js +17 -0
  68. package/dist/data/api/enum/read/ReadSelectedComparisonOperator.d.ts +69 -0
  69. package/dist/data/api/enum/read/ReadSelectedComparisonOperator.js +76 -0
  70. package/dist/data/api/enum/read/ReadSelectedLogicalOperator.d.ts +15 -0
  71. package/dist/data/api/enum/read/ReadSelectedLogicalOperator.js +16 -0
  72. package/dist/data/api/enum/read/ReadSelectedOrderingDirection.d.ts +13 -0
  73. package/dist/data/api/enum/read/ReadSelectedOrderingDirection.js +14 -0
  74. package/dist/data/api/enum/read/ReadSelectedPropertyType.d.ts +66 -0
  75. package/dist/data/api/enum/read/ReadSelectedPropertyType.js +75 -0
  76. package/dist/data/api/enum/read/index.d.ts +5 -0
  77. package/dist/data/api/enum/read/index.js +5 -0
  78. package/dist/data/api/enum/response/ApiErrorCodes.d.ts +7 -0
  79. package/dist/data/api/enum/response/ApiErrorCodes.js +8 -0
  80. package/dist/data/api/enum/response/ErrorCode.d.ts +13 -0
  81. package/dist/data/api/enum/response/ErrorCode.js +14 -0
  82. package/dist/data/api/enum/response/index.d.ts +1 -0
  83. package/dist/data/api/enum/response/index.js +1 -0
  84. package/dist/data/api/index.d.ts +3 -0
  85. package/dist/data/api/index.js +3 -0
  86. package/dist/data/api/interface/ICommonIdentifiable.d.ts +7 -0
  87. package/dist/data/api/interface/ICommonIdentifiable.js +1 -0
  88. package/dist/data/api/interface/IConcurrencySafe.d.ts +9 -0
  89. package/dist/data/api/interface/IConcurrencySafe.js +2 -0
  90. package/dist/data/api/interface/IIdentifiable.d.ts +11 -0
  91. package/dist/data/api/interface/IIdentifiable.js +1 -0
  92. package/dist/data/api/interface/IIdentifiableSecondary.d.ts +9 -0
  93. package/dist/data/api/interface/IIdentifiableSecondary.js +1 -0
  94. package/dist/data/api/interface/index.d.ts +3 -0
  95. package/dist/data/api/interface/index.js +3 -0
  96. package/dist/data/auth/dto/ClaimDto.d.ts +4 -0
  97. package/dist/data/auth/dto/ClaimDto.js +1 -0
  98. package/dist/data/auth/dto/RegisterRequestDto.d.ts +4 -0
  99. package/dist/data/auth/dto/RegisterRequestDto.js +1 -0
  100. package/dist/data/auth/dto/RoleDto.d.ts +5 -0
  101. package/dist/data/auth/dto/RoleDto.js +1 -0
  102. package/dist/data/auth/dto/SignInRequestDto.d.ts +4 -0
  103. package/dist/data/auth/dto/SignInRequestDto.js +1 -0
  104. package/dist/data/auth/dto/TokensDto.d.ts +4 -0
  105. package/dist/data/auth/dto/TokensDto.js +1 -0
  106. package/dist/data/auth/dto/UserDto.d.ts +17 -0
  107. package/dist/data/auth/dto/UserDto.js +1 -0
  108. package/dist/data/auth/dto/UserInfoDto.d.ts +14 -0
  109. package/dist/data/auth/dto/UserInfoDto.js +1 -0
  110. package/dist/data/auth/dto/index.d.ts +5 -0
  111. package/dist/data/auth/dto/index.js +5 -0
  112. package/dist/data/auth/index.d.ts +2 -0
  113. package/dist/data/auth/index.js +2 -0
  114. package/dist/data/auth/policy.d.ts +52 -0
  115. package/dist/data/auth/policy.js +44 -0
  116. package/dist/data/index.d.ts +2 -0
  117. package/dist/data/index.js +2 -0
  118. package/dist/index.d.ts +4 -0
  119. package/dist/index.js +4 -0
  120. package/dist/services/api/ApiCrudControllerClient/index.d.ts +41 -0
  121. package/dist/services/api/ApiCrudControllerClient/index.integration.test.d.ts +1 -0
  122. package/dist/services/api/ApiCrudControllerClient/index.integration.test.js +34 -0
  123. package/dist/services/api/ApiCrudControllerClient/index.js +116 -0
  124. package/dist/services/api/ApiInitializationService/index.d.ts +106 -0
  125. package/dist/services/api/ApiInitializationService/index.js +208 -0
  126. package/dist/services/api/ApiReadControllerClient/index.d.ts +40 -0
  127. package/dist/services/api/ApiReadControllerClient/index.integration.test.d.ts +1 -0
  128. package/dist/services/api/ApiReadControllerClient/index.integration.test.js +59 -0
  129. package/dist/services/api/ApiReadControllerClient/index.js +111 -0
  130. package/dist/services/api/HttpService/FetchHttpService.d.ts +7 -0
  131. package/dist/services/api/HttpService/FetchHttpService.integration.test.d.ts +1 -0
  132. package/dist/services/api/HttpService/FetchHttpService.integration.test.js +52 -0
  133. package/dist/services/api/HttpService/FetchHttpService.js +29 -0
  134. package/dist/services/api/HttpService/HttpRequestConfig.d.ts +10 -0
  135. package/dist/services/api/HttpService/HttpRequestConfig.js +1 -0
  136. package/dist/services/api/HttpService/HttpResponse.d.ts +11 -0
  137. package/dist/services/api/HttpService/HttpResponse.js +3 -0
  138. package/dist/services/api/HttpService/IHttpService.d.ts +13 -0
  139. package/dist/services/api/HttpService/IHttpService.js +3 -0
  140. package/dist/services/api/HttpService/index.d.ts +9 -0
  141. package/dist/services/api/HttpService/index.js +10 -0
  142. package/dist/services/api/UserManagementControllerClient/index.d.ts +41 -0
  143. package/dist/services/api/UserManagementControllerClient/index.integration.test.d.ts +1 -0
  144. package/dist/services/api/UserManagementControllerClient/index.integration.test.js +60 -0
  145. package/dist/services/api/UserManagementControllerClient/index.js +117 -0
  146. package/dist/services/api/index.d.ts +5 -0
  147. package/dist/services/api/index.js +5 -0
  148. package/dist/services/auth/client/AuthService/index.d.ts +75 -0
  149. package/dist/services/auth/client/AuthService/index.js +200 -0
  150. package/dist/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +48 -0
  151. package/dist/services/auth/client/AuthorizationManagementControllerClient/index.integration.test.d.ts +1 -0
  152. package/dist/services/auth/client/AuthorizationManagementControllerClient/index.integration.test.js +89 -0
  153. package/dist/services/auth/client/AuthorizationManagementControllerClient/index.js +148 -0
  154. package/dist/services/auth/client/index.d.ts +2 -0
  155. package/dist/services/auth/client/index.js +2 -0
  156. package/dist/services/auth/index.d.ts +1 -0
  157. package/dist/services/auth/index.js +1 -0
  158. package/dist/services/index.d.ts +2 -0
  159. package/dist/services/index.js +2 -0
  160. package/dist/utils/authorization/index.d.ts +17 -0
  161. package/dist/utils/authorization/index.js +45 -0
  162. package/dist/utils/index.d.ts +2 -0
  163. package/dist/utils/index.js +2 -0
  164. package/dist/utils/result/index.d.ts +21 -0
  165. package/dist/utils/result/index.js +16 -0
  166. package/dist/utils/search/index.d.ts +34 -0
  167. package/dist/utils/search/index.js +106 -0
  168. package/package.json +45 -0
  169. package/src/adapters/CollectionViewAdapter/index.integration.test.ts +197 -0
  170. package/src/adapters/CollectionViewAdapter/index.ts +477 -0
  171. package/src/adapters/SearchAdapter/index.ts +302 -0
  172. package/src/adapters/index.ts +2 -0
  173. package/src/data/api/dto/PropertyPathDto.ts +4 -0
  174. package/src/data/api/dto/ReadOptionsDto.ts +8 -0
  175. package/src/data/api/dto/ReadResultDto.ts +13 -0
  176. package/src/data/api/dto/ReadResultMetadataDto.ts +8 -0
  177. package/src/data/api/dto/crud/CrudMetadataDto.ts +4 -0
  178. package/src/data/api/dto/crud/index.ts +1 -0
  179. package/src/data/api/dto/index.ts +4 -0
  180. package/src/data/api/dto/read/ReadMetadataDto.ts +8 -0
  181. package/src/data/api/dto/read/ReadSelectedDefinitionDto.ts +21 -0
  182. package/src/data/api/dto/read/ReadSelectedNestedCollectionCriteriaDto.ts +25 -0
  183. package/src/data/api/dto/read/ReadSelectedNestedCriteriaDto.ts +20 -0
  184. package/src/data/api/dto/read/ReadSelectedOrderingDefinitionDto.ts +8 -0
  185. package/src/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.ts +16 -0
  186. package/src/data/api/dto/read/ReadSelectedPaginationDefinitionDto.ts +13 -0
  187. package/src/data/api/dto/read/ReadSelectedSearchDefinitionBuilder.ts +348 -0
  188. package/src/data/api/dto/read/ReadSelectedSearchDefinitionDto.ts +43 -0
  189. package/src/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.ts +186 -0
  190. package/src/data/api/dto/read/index.ts +10 -0
  191. package/src/data/api/dto/response/ApiErrorDto.ts +21 -0
  192. package/src/data/api/dto/response/ApiErrorResponseDto.ts +13 -0
  193. package/src/data/api/dto/response/ApiResponseDto.ts +7 -0
  194. package/src/data/api/dto/response/ApiSuccessResponseDto.ts +13 -0
  195. package/src/data/api/dto/response/MetadataDto.ts +24 -0
  196. package/src/data/api/dto/response/index.ts +5 -0
  197. package/src/data/api/enum/index.ts +2 -0
  198. package/src/data/api/enum/read/ReadSelectedCollectionOperator.ts +17 -0
  199. package/src/data/api/enum/read/ReadSelectedComparisonOperator.ts +96 -0
  200. package/src/data/api/enum/read/ReadSelectedLogicalOperator.ts +16 -0
  201. package/src/data/api/enum/read/ReadSelectedOrderingDirection.ts +13 -0
  202. package/src/data/api/enum/read/ReadSelectedPropertyType.ts +96 -0
  203. package/src/data/api/enum/read/index.ts +5 -0
  204. package/src/data/api/enum/response/ErrorCode.ts +13 -0
  205. package/src/data/api/enum/response/index.ts +1 -0
  206. package/src/data/api/index.ts +3 -0
  207. package/src/data/api/interface/ICommonIdentifiable.ts +9 -0
  208. package/src/data/api/interface/IConcurrencySafe.ts +9 -0
  209. package/src/data/api/interface/IIdentifiable.ts +12 -0
  210. package/src/data/api/interface/IIdentifiableSecondary.ts +9 -0
  211. package/src/data/api/interface/index.ts +3 -0
  212. package/src/data/auth/dto/ClaimDto.ts +4 -0
  213. package/src/data/auth/dto/RegisterRequestDto.ts +4 -0
  214. package/src/data/auth/dto/RoleDto.ts +6 -0
  215. package/src/data/auth/dto/SignInRequestDto.ts +4 -0
  216. package/src/data/auth/dto/TokensDto.ts +4 -0
  217. package/src/data/auth/dto/UserDto.ts +18 -0
  218. package/src/data/auth/dto/UserInfoDto.ts +15 -0
  219. package/src/data/auth/dto/index.ts +5 -0
  220. package/src/data/auth/index.ts +2 -0
  221. package/src/data/auth/policy.ts +63 -0
  222. package/src/data/index.ts +2 -0
  223. package/src/index.ts +4 -0
  224. package/src/services/api/ApiCrudControllerClient/index.integration.test.ts +46 -0
  225. package/src/services/api/ApiCrudControllerClient/index.ts +135 -0
  226. package/src/services/api/ApiInitializationService/index.ts +254 -0
  227. package/src/services/api/ApiReadControllerClient/index.integration.test.ts +71 -0
  228. package/src/services/api/ApiReadControllerClient/index.ts +137 -0
  229. package/src/services/api/HttpService/FetchHttpService.integration.test.ts +65 -0
  230. package/src/services/api/HttpService/FetchHttpService.ts +34 -0
  231. package/src/services/api/HttpService/HttpRequestConfig.ts +10 -0
  232. package/src/services/api/HttpService/HttpResponse.ts +14 -0
  233. package/src/services/api/HttpService/IHttpService.ts +17 -0
  234. package/src/services/api/HttpService/README.md +106 -0
  235. package/src/services/api/HttpService/index.ts +12 -0
  236. package/src/services/api/UserManagementControllerClient/index.integration.test.ts +69 -0
  237. package/src/services/api/UserManagementControllerClient/index.ts +134 -0
  238. package/src/services/api/index.ts +5 -0
  239. package/src/services/auth/client/AuthService/index.ts +233 -0
  240. package/src/services/auth/client/AuthorizationManagementControllerClient/index.integration.test.ts +110 -0
  241. package/src/services/auth/client/AuthorizationManagementControllerClient/index.ts +165 -0
  242. package/src/services/auth/client/index.ts +2 -0
  243. package/src/services/auth/index.ts +1 -0
  244. package/src/services/index.ts +2 -0
  245. package/src/utils/authorization/index.ts +47 -0
  246. package/src/utils/index.ts +2 -0
  247. package/src/utils/result/index.ts +25 -0
  248. package/src/utils/search/index.ts +150 -0
  249. package/tsconfig.json +19 -0
  250. package/vitest-setup.ts +43 -0
  251. package/vitest.config.ts +59 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Represents the collection quantifier operators that can be used when searching collection properties.
3
+ *
4
+ * The `Any` operator matches if at least one element in the collection satisfies the criteria.
5
+ * The `All` operator matches if all elements in the collection satisfy the criteria.
6
+ */
7
+ export enum ReadSelectedCollectionOperator {
8
+ /**
9
+ * Matches if at least one element in the collection satisfies the criteria.
10
+ */
11
+ Any = 0,
12
+
13
+ /**
14
+ * Matches if all elements in the collection satisfy the criteria.
15
+ */
16
+ All = 1,
17
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Represents the basic comparison operators that can be used in a controller.
3
+ */
4
+ export enum ReadSelectedComparisonOperator {
5
+ //#region Any type
6
+
7
+ /**
8
+ * Represents the equal comparison operator.
9
+ */
10
+ Equal = 0,
11
+
12
+ /**
13
+ * Represents the not equal comparison operator.
14
+ */
15
+ NotEqual = 1,
16
+
17
+ /**
18
+ * Represents the is null comparison operator.
19
+ */
20
+ IsNull = 2,
21
+
22
+ /**
23
+ * Represents the is not null comparison operator.
24
+ */
25
+ IsNotNull = 3,
26
+
27
+ //#endregion
28
+
29
+ //#region Number
30
+
31
+ /**
32
+ * Represents the less than comparison operator.
33
+ */
34
+ LessThan = 100,
35
+
36
+ /**
37
+ * Represents the less than or equal comparison operator.
38
+ */
39
+ LessOrEqual = 101,
40
+
41
+ /**
42
+ * Represents the greater than comparison operator.
43
+ */
44
+ GreaterThan = 102,
45
+
46
+ /**
47
+ * Represents the greater than or equal comparison operator.
48
+ */
49
+ GreaterOrEqual = 103,
50
+
51
+ //#endregion
52
+
53
+ //#region String
54
+
55
+ /**
56
+ * Represents the contains comparison operator.
57
+ */
58
+ Contains = 200,
59
+
60
+ /**
61
+ * Represents the starts with comparison operator.
62
+ */
63
+ StartsWith = 201,
64
+
65
+ /**
66
+ * Represents the ends with comparison operator.
67
+ */
68
+ EndsWith = 202,
69
+
70
+ /**
71
+ * Represents the contains comparison operator (case-insensitive).
72
+ */
73
+ IContains = 203,
74
+
75
+ /**
76
+ * Represents the starts with comparison operator (case-insensitive).
77
+ */
78
+ IStartsWith = 204,
79
+
80
+ /**
81
+ * Represents the ends with comparison operator (case-insensitive).
82
+ */
83
+ IEndsWith = 205,
84
+
85
+ /**
86
+ * Represents the equal comparison operator (case-insensitive).
87
+ */
88
+ IEqual = 206,
89
+
90
+ /**
91
+ * Represents the not equal comparison operator (case-insensitive).
92
+ */
93
+ INotEqual = 207,
94
+
95
+ //#endregion
96
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Represents the logical operators that can be used in a controller.
3
+ * - The `And` operator combines multiple conditions, requiring all of them to be true.
4
+ * - The `Or` operator combines multiple conditions, requiring at least one of them to be true.
5
+ */
6
+ export enum ReadSelectedLogicalOperator {
7
+ /**
8
+ * Represents the logical AND operator.
9
+ */
10
+ And = 0,
11
+
12
+ /**
13
+ * Represents the logical OR operator.
14
+ */
15
+ Or = 1,
16
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Represents options for ordering directions
3
+ */
4
+ export enum ReadSelectedOrderingDirection {
5
+ /**
6
+ * Ascending ordering
7
+ */
8
+ Ascending = 0,
9
+ /**
10
+ * Descending ordering
11
+ */
12
+ Descending = 1,
13
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Represents the basic property types that can be used in a controller.
3
+ * - The ReadSelectedPropertyType enum defines the basic property types that can be used in a fetch controller. These types include boolean, integer, long, and string.
4
+ */
5
+ export enum ReadSelectedPropertyType {
6
+ //#region Boolean
7
+
8
+ /**
9
+ * Represents a boolean property type.
10
+ */
11
+ Bool = 0,
12
+
13
+ //#endregion
14
+
15
+ //#region Number
16
+
17
+ /**
18
+ * Represents an integer property type.
19
+ */
20
+ Int = 100,
21
+
22
+ /**
23
+ * Represents a short property type.
24
+ */
25
+ Short = 101,
26
+
27
+ /**
28
+ * Represents a long property type.
29
+ */
30
+ Long = 102,
31
+
32
+ /**
33
+ * Represents a decimal property type.
34
+ */
35
+ Decimal = 103,
36
+
37
+ /**
38
+ * Represents a double property type.
39
+ */
40
+ Double = 104,
41
+
42
+ /**
43
+ * Represents a float property type.
44
+ */
45
+ Float = 105,
46
+
47
+ //#endregion
48
+
49
+ //#region string
50
+
51
+ /**
52
+ * Represents a string property type.
53
+ */
54
+ String = 200,
55
+
56
+ /**
57
+ * Represents a Guid property type.
58
+ */
59
+ Guid = 201,
60
+
61
+ //#endregion
62
+
63
+ //#region Time
64
+
65
+ /**
66
+ * Represents a DateTime property type.
67
+ */
68
+ DateTime = 300,
69
+
70
+ /**
71
+ * Represents a DateTimeOffset property type.
72
+ */
73
+ DateTimeOffset = 301,
74
+
75
+ /**
76
+ * Represents a TimeSpan property type.
77
+ */
78
+ TimeSpan = 302,
79
+
80
+ /**
81
+ * Represents a DateOnly property type.
82
+ */
83
+ DateOnly = 303,
84
+
85
+ /**
86
+ * Represents a TimeOnly property type.
87
+ */
88
+ TimeOnly = 304,
89
+
90
+ //#endregion
91
+
92
+ /**
93
+ * Represents an Enum property type.
94
+ */
95
+ Enum = 400,
96
+ }
@@ -0,0 +1,5 @@
1
+ export * from './ReadSelectedCollectionOperator';
2
+ export * from './ReadSelectedComparisonOperator';
3
+ export * from './ReadSelectedLogicalOperator';
4
+ export * from './ReadSelectedOrderingDirection';
5
+ export * from './ReadSelectedPropertyType';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Represents available error codes to be returned as part of the ApiResponse object
3
+ */
4
+ export enum ErrorCode {
5
+ InternalServerError = 500,
6
+ NotFound = 404,
7
+ BadRequest = 400,
8
+ NotImplemented = 501,
9
+ Unauthorized = 401,
10
+ GatewayTimeout = 504,
11
+ ValidationFailed = 422,
12
+ UnknownError = 599,
13
+ }
@@ -0,0 +1 @@
1
+ export * from './ErrorCode';
@@ -0,0 +1,3 @@
1
+ export * from './interface';
2
+ export * from './dto';
3
+ export * from './enum';
@@ -0,0 +1,9 @@
1
+ import {IIdentifiable} from "@data";
2
+
3
+
4
+ export interface ICommonIdentifiable<TKey> extends IIdentifiable<TKey> {
5
+ /**
6
+ * Gets or sets the type of the entity.
7
+ */
8
+ type: string;
9
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Interface for entities that have row versioning
3
+ */
4
+ export interface IConcurrencySafe {
5
+ /**
6
+ * Row version
7
+ */
8
+ rowVersion: string;
9
+ };
@@ -0,0 +1,12 @@
1
+ import { IConcurrencySafe } from './IConcurrencySafe';
2
+
3
+ /**
4
+ * Interface for entities that have a Id property.
5
+ * Will be used as a primary key in the database.
6
+ */
7
+ export interface IIdentifiable<TKey> extends IConcurrencySafe {
8
+ /**
9
+ * Gets or sets the Id of the entity.
10
+ */
11
+ id: TKey;
12
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Interface for entities that have a secondary Id property.
3
+ */
4
+ export interface IIdentifiableSecondary<TKey> {
5
+ /**
6
+ * Gets or sets the secondary Id of the entity.
7
+ */
8
+ idSecondary: TKey;
9
+ }
@@ -0,0 +1,3 @@
1
+ export * from './IIdentifiable';
2
+ export * from './IIdentifiableSecondary';
3
+ export * from './IConcurrencySafe';
@@ -0,0 +1,4 @@
1
+ export type ClaimDto = {
2
+ type: string;
3
+ value: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ export type RegisterRequestDto = {
2
+ username: string;
3
+ password: string;
4
+ };
@@ -0,0 +1,6 @@
1
+ import { ClaimDto } from '@data';
2
+
3
+ export type RoleDto = {
4
+ name: string;
5
+ claims: ClaimDto[];
6
+ };
@@ -0,0 +1,4 @@
1
+ export type SignInRequestDto = {
2
+ username: string;
3
+ password: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ export type TokensDto = {
2
+ accessToken?: string;
3
+ refreshToken?: string;
4
+ };
@@ -0,0 +1,18 @@
1
+ import { ClaimDto } from '@data';
2
+ import { IIdentifiable } from '@data';
3
+
4
+ /**
5
+ * Represents a user with an identifier and email address.
6
+ *
7
+ * @template TKey The type of the user identifier.
8
+ *
9
+ * @param {TKey} id The unique identifier for the user.
10
+ * @param {string} email The email address associated with the user.
11
+ * @param {string[]} roles The roles associated with the user.
12
+ * @param {ClaimDto[]} claims The claims associated with the user.
13
+ */
14
+ export type UserDto<TKey> = IIdentifiable<TKey> & {
15
+ email: string;
16
+ roles: string[];
17
+ claims: ClaimDto[];
18
+ };
@@ -0,0 +1,15 @@
1
+ import { UserDto } from '@data';
2
+
3
+ /**
4
+ * Represents user information along with access token expiry.
5
+ *
6
+ * @template TKey The type of the user identifier.
7
+ * @template TUser The type of the user object, defaulting to `UserDto<TKey>`.
8
+ *
9
+ * @param {TUser} user The user object containing user details.
10
+ * @param {Date} accessTokenExpiry The date and time when the access token will expire.
11
+ */
12
+ export type UserInfoDto<TKey, TUser = UserDto<TKey>> = {
13
+ user: TUser;
14
+ accessTokenExpiry: Date;
15
+ };
@@ -0,0 +1,5 @@
1
+ export * from './ClaimDto';
2
+ export * from './UserDto';
3
+ export * from './UserInfoDto';
4
+ export * from './RoleDto';
5
+ export * from './RegisterRequestDto';
@@ -0,0 +1,2 @@
1
+ export * from './dto';
2
+ export * from './policy';
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Interface for policies that can be checked.
3
+ *
4
+ * @interface IPolicy<TParams extends unknown[]>
5
+ * @template TParams - The type of the parameters that will be passed to the policy check function.
6
+ */
7
+ export interface IPolicy<TParams extends unknown[]> {
8
+ /**
9
+ * Checks if the policy is valid for the given parameters.
10
+ *
11
+ * @param params - Parameters to pass to the policy check function.
12
+ * @return A promise that resolves if the policy is valid, rejects otherwise.
13
+ */
14
+ check(...params: TParams): Promise<boolean>;
15
+ }
16
+
17
+ /**
18
+ * Base class for policies. It implements the IPolicy interface.
19
+ *
20
+ * @class PolicyBase
21
+ * @template TParams - The type of the parameters that will be passed to the policy check function.
22
+ */
23
+ export class PolicyBase<TParams extends unknown[]> implements IPolicy<TParams> {
24
+ /**
25
+ * Checks if the policy is valid for the given parameters.
26
+ *
27
+ * @return A promise that resolves if the policy is valid, rejects otherwise.
28
+ * @throws {Error} Error if not implemented.
29
+ */
30
+ public async check(): Promise<boolean> {
31
+ throw new Error('Not implemented');
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Class for policies that can be checked.
37
+ *
38
+ * @class Policy
39
+ * @template TParams - The type of the parameters that will be passed to the policy check function.
40
+ */
41
+ export class Policy<TParams extends unknown[]> extends PolicyBase<TParams> {
42
+ private readonly _verificationFn: (...params: TParams) => Promise<boolean>;
43
+
44
+ /**
45
+ * Creates a new policy.
46
+ *
47
+ * @param verificationFn - The function that will be used to verify the policy.
48
+ */
49
+ constructor(verificationFn: (...params: TParams) => Promise<boolean>) {
50
+ super();
51
+ this._verificationFn = verificationFn;
52
+ }
53
+
54
+ /**
55
+ * Checks if the policy is valid for the given parameters.
56
+ *
57
+ * @param params - Parameters to pass to the policy check function.
58
+ * @return A promise that resolves if the policy is valid, rejects otherwise.
59
+ */
60
+ public async check(...params: TParams): Promise<boolean> {
61
+ return this._verificationFn(...params);
62
+ }
63
+ }
@@ -0,0 +1,2 @@
1
+ export * from './auth';
2
+ export * from './api';
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './services';
2
+ export * from './data';
3
+ export * from './adapters';
4
+ export * from './utils';
@@ -0,0 +1,46 @@
1
+ import { beforeEach, describe, expect, it } from 'vitest';
2
+ import { ApiCrudControllerClient } from '.';
3
+ import { FetchHttpService } from '../HttpService';
4
+
5
+ type VehicleSlimDto = { id: number; brand: string; model: string };
6
+
7
+ describe('ApiCrudControllerClient', () => {
8
+ let client: ApiCrudControllerClient<number, any, any, any, any>;
9
+ let fetchService: FetchHttpService;
10
+ const testId = 100;
11
+
12
+ beforeEach(() => {
13
+ fetchService = new FetchHttpService();
14
+ client = new ApiCrudControllerClient('/VehiclesSlim', fetchService);
15
+ });
16
+
17
+ it('should use injected HTTP service for create', async () => {
18
+ const newVehicle: VehicleSlimDto = { id: testId, brand: 'New Brand', model: 'New Model' };
19
+
20
+ const result = (await client.create(newVehicle)) as { ok: boolean; result: any };
21
+
22
+ expect(result.ok).toBe(true);
23
+ expect(result.result).toBeDefined();
24
+ expect(result.result.id).toBe(newVehicle.id);
25
+ expect(result.result.brand).toBe(newVehicle.brand);
26
+ expect(result.result.model).toBe(newVehicle.model);
27
+ });
28
+
29
+ it('should use injected HTTP service for update', async () => {
30
+ const updateVehicle: VehicleSlimDto = { id: testId, brand: 'Updated Brand', model: 'Updated Model' };
31
+
32
+ const result = (await client.update(testId, updateVehicle)) as { ok: boolean; result: any };
33
+
34
+ expect(result.ok).toBe(true);
35
+ expect(result.result).toBeDefined();
36
+ expect(result.result.id).toBe(updateVehicle.id);
37
+ expect(result.result.brand).toBe(updateVehicle.brand);
38
+ expect(result.result.model).toBe(updateVehicle.model);
39
+ });
40
+
41
+ it('should use injected HTTP service for delete', async () => {
42
+ const result = await client.delete(testId);
43
+
44
+ expect(result.ok).toBe(true);
45
+ });
46
+ });
@@ -0,0 +1,135 @@
1
+ import { apiInitializationService } from '../ApiInitializationService';
2
+ import { ApiErrorResponseDto, ApiResponseDto, ApiSuccessResponseDto, EmptyMetadataDto } from '../../../data/api/dto';
3
+ import { IIdentifiable } from '../../../data/api/interface';
4
+ import { IHttpService } from '../HttpService';
5
+ import { ApiReadControllerClient } from '../ApiReadControllerClient';
6
+ import { ErrorCode } from '@data';
7
+ import { fail, ok } from '@utils/result';
8
+
9
+ /**
10
+ * Generic API client for consuming any Cornerstone CrudController
11
+ *
12
+ * @export
13
+ * @class ApiCrudControllerClient
14
+ * @template TKey - Type of the entity key (e.g., number, string, GUID, etc.)
15
+ * @template TDto - Data Transfer Object representing the entity
16
+ */
17
+
18
+ export class ApiCrudControllerClient<
19
+ TKey,
20
+ TResultDto extends IIdentifiable<TKey>,
21
+ TSingleResultDto extends IIdentifiable<TKey>,
22
+ TInsertRequestDto,
23
+ TUpdateRequestDto,
24
+ > extends ApiReadControllerClient<TKey, TResultDto, TSingleResultDto> {
25
+ /**
26
+ * Constructor
27
+ * @param baseControllerPath Base path to API controller
28
+ * @param httpService HTTP service implementation to use for requests
29
+ */
30
+ constructor(baseControllerPath: string, httpService?: IHttpService) {
31
+ super(baseControllerPath, httpService);
32
+ }
33
+
34
+ /**
35
+ * Creates a new entity.
36
+ * @param dto - Insert request DTO
37
+ * @param {AbortSignal} [signal] - Optional cancellation signal
38
+ * @returns The created entity DTO
39
+ */
40
+ public async create(dto: TInsertRequestDto, signal?: AbortSignal): Promise<ApiResponseDto<TSingleResultDto, EmptyMetadataDto>> {
41
+ try {
42
+ const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/Create`);
43
+ const res = await this.httpService.request(url, {
44
+ method: 'POST',
45
+ headers: { 'Content-Type': 'application/json' },
46
+ body: JSON.stringify(dto),
47
+ credentials: 'include',
48
+ signal,
49
+ });
50
+ if (!res.ok) {
51
+ return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
52
+ }
53
+
54
+ return ok<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
55
+ } catch (err) {
56
+ console.error(err);
57
+
58
+ return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>({
59
+ error: {
60
+ code: ErrorCode.UnknownError,
61
+ message: 'Unknown error occurred while creating the record.',
62
+ metadata: {} as EmptyMetadataDto,
63
+ },
64
+ });
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Updates an existing entity.
70
+ * @param id - The ID of the entity to update
71
+ * @param dto - Update request DTO
72
+ * @param {AbortSignal} [signal] - Optional cancellation signal
73
+ * @returns The updated entity DTO
74
+ */
75
+ public async update(id: TKey, dto: TUpdateRequestDto, signal?: AbortSignal): Promise<ApiResponseDto<TSingleResultDto, EmptyMetadataDto>> {
76
+ try {
77
+ const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/Update?id=${encodeURIComponent(String(id))}`);
78
+ const res = await this.httpService.request(url, {
79
+ method: 'PUT',
80
+ headers: { 'Content-Type': 'application/json' },
81
+ body: JSON.stringify(dto),
82
+ credentials: 'include',
83
+ signal,
84
+ });
85
+
86
+ if (!res.ok) {
87
+ return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
88
+ }
89
+
90
+ return ok<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
91
+ } catch (err) {
92
+ console.error(err);
93
+
94
+ return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>({
95
+ error: {
96
+ code: ErrorCode.UnknownError,
97
+ message: `Unknown error occurred while updating the record with id ${id}`,
98
+ metadata: {} as EmptyMetadataDto,
99
+ },
100
+ });
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Deletes an entity by ID.
106
+ * @param id - The ID of the entity to delete
107
+ * @param {AbortSignal} [signal] - Optional cancellation signal
108
+ */
109
+ public async delete(id: TKey, signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>> {
110
+ try {
111
+ const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/Delete?id=${encodeURIComponent(String(id))}`);
112
+ const res = await this.httpService.request(url, {
113
+ method: 'DELETE',
114
+ credentials: 'include',
115
+ signal,
116
+ });
117
+
118
+ if (!res.ok) {
119
+ return fail<ApiSuccessResponseDto<undefined, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
120
+ }
121
+
122
+ return ok<ApiSuccessResponseDto<undefined, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
123
+ } catch (err) {
124
+ console.error(err);
125
+
126
+ return fail<ApiSuccessResponseDto<undefined, EmptyMetadataDto>, ApiErrorResponseDto>({
127
+ error: {
128
+ code: ErrorCode.UnknownError,
129
+ message: `Unknown error occurred while deleting the record with id ${id}`,
130
+ metadata: {} as EmptyMetadataDto,
131
+ },
132
+ });
133
+ }
134
+ }
135
+ }