@cratis/arc 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. package/GetHttpHeaders.ts +7 -0
  2. package/Globals.ts +14 -0
  3. package/ICanBeConfigured.ts +33 -0
  4. package/README.md +65 -0
  5. package/UrlHelpers.ts +71 -0
  6. package/commands/Command.ts +209 -0
  7. package/commands/CommandResult.ts +203 -0
  8. package/commands/CommandResults.ts +105 -0
  9. package/commands/CommandValidator.ts +17 -0
  10. package/commands/ICommand.ts +82 -0
  11. package/commands/ICommandResult.ts +60 -0
  12. package/commands/for_Command/CommandWithRouteParams.ts +34 -0
  13. package/commands/for_Command/SomeCommand.ts +34 -0
  14. package/commands/for_Command/given/a_command.ts +18 -0
  15. package/commands/for_Command/when_clearing_the_command.ts +17 -0
  16. package/commands/for_Command/when_executing/and_command_route_not_found.ts +26 -0
  17. package/commands/for_Command/when_executing/and_fetch_throws_exception.ts +24 -0
  18. package/commands/for_Command/when_executing/with_command_properties.ts +40 -0
  19. package/commands/for_Command/when_executing/with_custom_http_headers.ts +60 -0
  20. package/commands/for_Command/when_executing/with_microservice_header.ts +55 -0
  21. package/commands/for_Command/when_executing/with_origin_and_api_base_path.ts +51 -0
  22. package/commands/for_Command/when_executing/with_route_parameters.ts +58 -0
  23. package/commands/for_Command/when_executing/with_successful_response.ts +51 -0
  24. package/commands/for_Command/when_property_changed_value_that_is_different_from_initial_value.ts +16 -0
  25. package/commands/for_Command/when_property_changed_value_that_is_same_as_initial_value.ts +16 -0
  26. package/commands/for_Command/when_property_changes_and_initial_value_is_undefined.ts +12 -0
  27. package/commands/for_Command/when_property_changes_and_there_is_a_callback.ts +15 -0
  28. package/commands/for_Command/when_property_has_changed_and_we_revert.ts +15 -0
  29. package/commands/for_Command/when_setting_initial_values_after_property_changed.ts +17 -0
  30. package/commands/for_Command/when_validating/and_fetch_throws_exception.ts +24 -0
  31. package/commands/for_Command/when_validating/and_validation_endpoint_not_found.ts +26 -0
  32. package/commands/for_Command/when_validating/does_not_update_initial_values.ts +39 -0
  33. package/commands/for_Command/when_validating/with_successful_response.ts +47 -0
  34. package/commands/for_Command/when_validating/with_validation_errors.ts +45 -0
  35. package/commands/for_CommandResult/when_chaining_callbacks/and_result_has_exceptions.ts +54 -0
  36. package/commands/for_CommandResult/when_chaining_callbacks/and_result_is_invalid.ts +53 -0
  37. package/commands/for_CommandResult/when_chaining_callbacks/and_result_is_successful.ts +42 -0
  38. package/commands/for_CommandResult/when_chaining_callbacks/and_result_is_unauthorized.ts +43 -0
  39. package/commands/index.ts +9 -0
  40. package/deepEqual.ts +23 -0
  41. package/dist/cjs/GetHttpHeaders.d.ts +2 -0
  42. package/dist/cjs/GetHttpHeaders.d.ts.map +1 -0
  43. package/dist/cjs/Globals.d.ts +7 -0
  44. package/dist/cjs/Globals.d.ts.map +1 -0
  45. package/dist/cjs/Globals.js +10 -0
  46. package/dist/cjs/Globals.js.map +1 -0
  47. package/dist/cjs/ICanBeConfigured.d.ts +8 -0
  48. package/dist/cjs/ICanBeConfigured.d.ts.map +1 -0
  49. package/dist/cjs/UrlHelpers.d.ts +9 -0
  50. package/dist/cjs/UrlHelpers.d.ts.map +1 -0
  51. package/dist/cjs/UrlHelpers.js +43 -0
  52. package/dist/cjs/UrlHelpers.js.map +1 -0
  53. package/dist/cjs/commands/Command.d.ts +41 -0
  54. package/dist/cjs/commands/Command.d.ts.map +1 -0
  55. package/dist/cjs/commands/Command.js +151 -0
  56. package/dist/cjs/commands/Command.js.map +1 -0
  57. package/dist/cjs/commands/CommandResult.d.ts +48 -0
  58. package/dist/cjs/commands/CommandResult.d.ts.map +1 -0
  59. package/dist/cjs/commands/CommandResult.js +95 -0
  60. package/dist/cjs/commands/CommandResult.js.map +1 -0
  61. package/dist/cjs/commands/CommandResults.d.ts +23 -0
  62. package/dist/cjs/commands/CommandResults.d.ts.map +1 -0
  63. package/dist/cjs/commands/CommandResults.js +72 -0
  64. package/dist/cjs/commands/CommandResults.js.map +1 -0
  65. package/dist/cjs/commands/CommandValidator.d.ts +9 -0
  66. package/dist/cjs/commands/CommandValidator.d.ts.map +1 -0
  67. package/dist/cjs/commands/CommandValidator.js +10 -0
  68. package/dist/cjs/commands/CommandValidator.js.map +1 -0
  69. package/dist/cjs/commands/ICommand.d.ts +18 -0
  70. package/dist/cjs/commands/ICommand.d.ts.map +1 -0
  71. package/dist/cjs/commands/ICommandResult.d.ts +15 -0
  72. package/dist/cjs/commands/ICommandResult.d.ts.map +1 -0
  73. package/dist/cjs/commands/index.d.ts +7 -0
  74. package/dist/cjs/commands/index.d.ts.map +1 -0
  75. package/dist/cjs/commands/index.js +14 -0
  76. package/dist/cjs/commands/index.js.map +1 -0
  77. package/dist/cjs/deepEqual.d.ts +2 -0
  78. package/dist/cjs/deepEqual.d.ts.map +1 -0
  79. package/dist/cjs/deepEqual.js +22 -0
  80. package/dist/cjs/deepEqual.js.map +1 -0
  81. package/dist/cjs/given.d.ts +5 -0
  82. package/dist/cjs/given.d.ts.map +1 -0
  83. package/dist/cjs/identity/IIdentity.d.ts +8 -0
  84. package/dist/cjs/identity/IIdentity.d.ts.map +1 -0
  85. package/dist/cjs/identity/IIdentityProvider.d.ts +5 -0
  86. package/dist/cjs/identity/IIdentityProvider.d.ts.map +1 -0
  87. package/dist/cjs/identity/IIdentityProvider.js +7 -0
  88. package/dist/cjs/identity/IIdentityProvider.js.map +1 -0
  89. package/dist/cjs/identity/IdentityProvider.d.ts +14 -0
  90. package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -0
  91. package/dist/cjs/identity/IdentityProvider.js +63 -0
  92. package/dist/cjs/identity/IdentityProvider.js.map +1 -0
  93. package/dist/cjs/identity/IdentityProviderResult.d.ts +6 -0
  94. package/dist/cjs/identity/IdentityProviderResult.d.ts.map +1 -0
  95. package/dist/cjs/identity/index.d.ts +5 -0
  96. package/dist/cjs/identity/index.d.ts.map +1 -0
  97. package/dist/cjs/identity/index.js +10 -0
  98. package/dist/cjs/identity/index.js.map +1 -0
  99. package/dist/cjs/index.d.ts +12 -0
  100. package/dist/cjs/index.d.ts.map +1 -0
  101. package/dist/cjs/index.js +22 -0
  102. package/dist/cjs/index.js.map +1 -0
  103. package/dist/cjs/joinPaths.d.ts +2 -0
  104. package/dist/cjs/joinPaths.d.ts.map +1 -0
  105. package/dist/cjs/joinPaths.js +9 -0
  106. package/dist/cjs/joinPaths.js.map +1 -0
  107. package/dist/cjs/queries/IObservableQueryConnection.d.ts +6 -0
  108. package/dist/cjs/queries/IObservableQueryConnection.d.ts.map +1 -0
  109. package/dist/cjs/queries/IObservableQueryFor.d.ts +13 -0
  110. package/dist/cjs/queries/IObservableQueryFor.d.ts.map +1 -0
  111. package/dist/cjs/queries/IQuery.d.ts +10 -0
  112. package/dist/cjs/queries/IQuery.d.ts.map +1 -0
  113. package/dist/cjs/queries/IQueryFor.d.ts +12 -0
  114. package/dist/cjs/queries/IQueryFor.d.ts.map +1 -0
  115. package/dist/cjs/queries/IQueryProvider.d.ts +6 -0
  116. package/dist/cjs/queries/IQueryProvider.d.ts.map +1 -0
  117. package/dist/cjs/queries/IQueryProvider.js +7 -0
  118. package/dist/cjs/queries/IQueryProvider.js.map +1 -0
  119. package/dist/cjs/queries/IQueryResult.d.ts +15 -0
  120. package/dist/cjs/queries/IQueryResult.d.ts.map +1 -0
  121. package/dist/cjs/queries/NullObservableQueryConnection.d.ts +9 -0
  122. package/dist/cjs/queries/NullObservableQueryConnection.d.ts.map +1 -0
  123. package/dist/cjs/queries/NullObservableQueryConnection.js +18 -0
  124. package/dist/cjs/queries/NullObservableQueryConnection.js.map +1 -0
  125. package/dist/cjs/queries/ObservableQueryConnection.d.ts +14 -0
  126. package/dist/cjs/queries/ObservableQueryConnection.d.ts.map +1 -0
  127. package/dist/cjs/queries/ObservableQueryConnection.js +101 -0
  128. package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -0
  129. package/dist/cjs/queries/ObservableQueryFor.d.ts +37 -0
  130. package/dist/cjs/queries/ObservableQueryFor.d.ts.map +1 -0
  131. package/dist/cjs/queries/ObservableQueryFor.js +176 -0
  132. package/dist/cjs/queries/ObservableQueryFor.js.map +1 -0
  133. package/dist/cjs/queries/ObservableQuerySubscription.d.ts +7 -0
  134. package/dist/cjs/queries/ObservableQuerySubscription.d.ts.map +1 -0
  135. package/dist/cjs/queries/ObservableQuerySubscription.js +17 -0
  136. package/dist/cjs/queries/ObservableQuerySubscription.js.map +1 -0
  137. package/dist/cjs/queries/Paging.d.ts +8 -0
  138. package/dist/cjs/queries/Paging.d.ts.map +1 -0
  139. package/dist/cjs/queries/Paging.js +17 -0
  140. package/dist/cjs/queries/Paging.js.map +1 -0
  141. package/dist/cjs/queries/PagingInfo.d.ts +9 -0
  142. package/dist/cjs/queries/PagingInfo.d.ts.map +1 -0
  143. package/dist/cjs/queries/PagingInfo.js +18 -0
  144. package/dist/cjs/queries/PagingInfo.js.map +1 -0
  145. package/dist/cjs/queries/QueryFor.d.ts +30 -0
  146. package/dist/cjs/queries/QueryFor.d.ts.map +1 -0
  147. package/dist/cjs/queries/QueryFor.js +101 -0
  148. package/dist/cjs/queries/QueryFor.js.map +1 -0
  149. package/dist/cjs/queries/QueryProvider.d.ts +13 -0
  150. package/dist/cjs/queries/QueryProvider.d.ts.map +1 -0
  151. package/dist/cjs/queries/QueryProvider.js +25 -0
  152. package/dist/cjs/queries/QueryProvider.js.map +1 -0
  153. package/dist/cjs/queries/QueryResult.d.ts +44 -0
  154. package/dist/cjs/queries/QueryResult.d.ts.map +1 -0
  155. package/dist/cjs/queries/QueryResult.js +95 -0
  156. package/dist/cjs/queries/QueryResult.js.map +1 -0
  157. package/dist/cjs/queries/QueryResultWithState.d.ts +22 -0
  158. package/dist/cjs/queries/QueryResultWithState.d.ts.map +1 -0
  159. package/dist/cjs/queries/QueryResultWithState.js +46 -0
  160. package/dist/cjs/queries/QueryResultWithState.js.map +1 -0
  161. package/dist/cjs/queries/SortDirection.d.ts +6 -0
  162. package/dist/cjs/queries/SortDirection.d.ts.map +1 -0
  163. package/dist/cjs/queries/SortDirection.js +9 -0
  164. package/dist/cjs/queries/SortDirection.js.map +1 -0
  165. package/dist/cjs/queries/Sorting.d.ts +9 -0
  166. package/dist/cjs/queries/Sorting.d.ts.map +1 -0
  167. package/dist/cjs/queries/Sorting.js +19 -0
  168. package/dist/cjs/queries/Sorting.js.map +1 -0
  169. package/dist/cjs/queries/SortingActions.d.ts +10 -0
  170. package/dist/cjs/queries/SortingActions.d.ts.map +1 -0
  171. package/dist/cjs/queries/SortingActions.js +24 -0
  172. package/dist/cjs/queries/SortingActions.js.map +1 -0
  173. package/dist/cjs/queries/SortingActionsForObservableQuery.d.ts +10 -0
  174. package/dist/cjs/queries/SortingActionsForObservableQuery.d.ts.map +1 -0
  175. package/dist/cjs/queries/SortingActionsForObservableQuery.js +24 -0
  176. package/dist/cjs/queries/SortingActionsForObservableQuery.js.map +1 -0
  177. package/dist/cjs/queries/SortingActionsForQuery.d.ts +10 -0
  178. package/dist/cjs/queries/SortingActionsForQuery.d.ts.map +1 -0
  179. package/dist/cjs/queries/SortingActionsForQuery.js +24 -0
  180. package/dist/cjs/queries/SortingActionsForQuery.js.map +1 -0
  181. package/dist/cjs/queries/ValidateRequestArguments.d.ts +2 -0
  182. package/dist/cjs/queries/ValidateRequestArguments.d.ts.map +1 -0
  183. package/dist/cjs/queries/ValidateRequestArguments.js +29 -0
  184. package/dist/cjs/queries/ValidateRequestArguments.js.map +1 -0
  185. package/dist/cjs/queries/index.d.ts +19 -0
  186. package/dist/cjs/queries/index.d.ts.map +1 -0
  187. package/dist/cjs/queries/index.js +37 -0
  188. package/dist/cjs/queries/index.js.map +1 -0
  189. package/dist/cjs/reflection/IHaveParameters.d.ts +5 -0
  190. package/dist/cjs/reflection/IHaveParameters.d.ts.map +1 -0
  191. package/dist/cjs/reflection/ParameterDescriptor.d.ts +7 -0
  192. package/dist/cjs/reflection/ParameterDescriptor.d.ts.map +1 -0
  193. package/dist/cjs/reflection/ParameterDescriptor.js +13 -0
  194. package/dist/cjs/reflection/ParameterDescriptor.js.map +1 -0
  195. package/dist/cjs/reflection/ParametersHelper.d.ts +5 -0
  196. package/dist/cjs/reflection/ParametersHelper.d.ts.map +1 -0
  197. package/dist/cjs/reflection/ParametersHelper.js +17 -0
  198. package/dist/cjs/reflection/ParametersHelper.js.map +1 -0
  199. package/dist/cjs/reflection/PropertyDescriptor.d.ts +7 -0
  200. package/dist/cjs/reflection/PropertyDescriptor.d.ts.map +1 -0
  201. package/dist/cjs/reflection/PropertyDescriptor.js +13 -0
  202. package/dist/cjs/reflection/PropertyDescriptor.js.map +1 -0
  203. package/dist/cjs/reflection/index.d.ts +5 -0
  204. package/dist/cjs/reflection/index.d.ts.map +1 -0
  205. package/dist/cjs/reflection/index.js +12 -0
  206. package/dist/cjs/reflection/index.js.map +1 -0
  207. package/dist/cjs/validation/ValidationResult.d.ts +9 -0
  208. package/dist/cjs/validation/ValidationResult.d.ts.map +1 -0
  209. package/dist/cjs/validation/ValidationResult.js +17 -0
  210. package/dist/cjs/validation/ValidationResult.js.map +1 -0
  211. package/dist/cjs/validation/ValidationResultSeverity.d.ts +7 -0
  212. package/dist/cjs/validation/ValidationResultSeverity.d.ts.map +1 -0
  213. package/dist/cjs/validation/Validator.d.ts +4 -0
  214. package/dist/cjs/validation/Validator.d.ts.map +1 -0
  215. package/dist/cjs/validation/Validator.js +10 -0
  216. package/dist/cjs/validation/Validator.js.map +1 -0
  217. package/dist/cjs/validation/index.d.ts +3 -0
  218. package/dist/cjs/validation/index.d.ts.map +1 -0
  219. package/dist/cjs/validation/index.js +10 -0
  220. package/dist/cjs/validation/index.js.map +1 -0
  221. package/dist/esm/GetHttpHeaders.d.ts +2 -0
  222. package/dist/esm/GetHttpHeaders.d.ts.map +1 -0
  223. package/dist/esm/GetHttpHeaders.js +2 -0
  224. package/dist/esm/GetHttpHeaders.js.map +1 -0
  225. package/dist/esm/Globals.d.ts +7 -0
  226. package/dist/esm/Globals.d.ts.map +1 -0
  227. package/dist/esm/Globals.js +8 -0
  228. package/dist/esm/Globals.js.map +1 -0
  229. package/dist/esm/ICanBeConfigured.d.ts +8 -0
  230. package/dist/esm/ICanBeConfigured.d.ts.map +1 -0
  231. package/dist/esm/ICanBeConfigured.js +2 -0
  232. package/dist/esm/ICanBeConfigured.js.map +1 -0
  233. package/dist/esm/UrlHelpers.d.ts +9 -0
  234. package/dist/esm/UrlHelpers.d.ts.map +1 -0
  235. package/dist/esm/UrlHelpers.js +41 -0
  236. package/dist/esm/UrlHelpers.js.map +1 -0
  237. package/dist/esm/commands/Command.d.ts +41 -0
  238. package/dist/esm/commands/Command.d.ts.map +1 -0
  239. package/dist/esm/commands/Command.js +149 -0
  240. package/dist/esm/commands/Command.js.map +1 -0
  241. package/dist/esm/commands/CommandResult.d.ts +48 -0
  242. package/dist/esm/commands/CommandResult.d.ts.map +1 -0
  243. package/dist/esm/commands/CommandResult.js +93 -0
  244. package/dist/esm/commands/CommandResult.js.map +1 -0
  245. package/dist/esm/commands/CommandResults.d.ts +23 -0
  246. package/dist/esm/commands/CommandResults.d.ts.map +1 -0
  247. package/dist/esm/commands/CommandResults.js +70 -0
  248. package/dist/esm/commands/CommandResults.js.map +1 -0
  249. package/dist/esm/commands/CommandValidator.d.ts +9 -0
  250. package/dist/esm/commands/CommandValidator.d.ts.map +1 -0
  251. package/dist/esm/commands/CommandValidator.js +8 -0
  252. package/dist/esm/commands/CommandValidator.js.map +1 -0
  253. package/dist/esm/commands/ICommand.d.ts +18 -0
  254. package/dist/esm/commands/ICommand.d.ts.map +1 -0
  255. package/dist/esm/commands/ICommand.js +2 -0
  256. package/dist/esm/commands/ICommand.js.map +1 -0
  257. package/dist/esm/commands/ICommandResult.d.ts +15 -0
  258. package/dist/esm/commands/ICommandResult.d.ts.map +1 -0
  259. package/dist/esm/commands/ICommandResult.js +2 -0
  260. package/dist/esm/commands/ICommandResult.js.map +1 -0
  261. package/dist/esm/commands/index.d.ts +7 -0
  262. package/dist/esm/commands/index.d.ts.map +1 -0
  263. package/dist/esm/commands/index.js +5 -0
  264. package/dist/esm/commands/index.js.map +1 -0
  265. package/dist/esm/deepEqual.d.ts +2 -0
  266. package/dist/esm/deepEqual.d.ts.map +1 -0
  267. package/dist/esm/deepEqual.js +20 -0
  268. package/dist/esm/deepEqual.js.map +1 -0
  269. package/dist/esm/given.d.ts +5 -0
  270. package/dist/esm/given.d.ts.map +1 -0
  271. package/dist/esm/given.js +7 -0
  272. package/dist/esm/given.js.map +1 -0
  273. package/dist/esm/identity/IIdentity.d.ts +8 -0
  274. package/dist/esm/identity/IIdentity.d.ts.map +1 -0
  275. package/dist/esm/identity/IIdentity.js +2 -0
  276. package/dist/esm/identity/IIdentity.js.map +1 -0
  277. package/dist/esm/identity/IIdentityProvider.d.ts +5 -0
  278. package/dist/esm/identity/IIdentityProvider.d.ts.map +1 -0
  279. package/dist/esm/identity/IIdentityProvider.js +5 -0
  280. package/dist/esm/identity/IIdentityProvider.js.map +1 -0
  281. package/dist/esm/identity/IdentityProvider.d.ts +14 -0
  282. package/dist/esm/identity/IdentityProvider.d.ts.map +1 -0
  283. package/dist/esm/identity/IdentityProvider.js +61 -0
  284. package/dist/esm/identity/IdentityProvider.js.map +1 -0
  285. package/dist/esm/identity/IdentityProviderResult.d.ts +6 -0
  286. package/dist/esm/identity/IdentityProviderResult.d.ts.map +1 -0
  287. package/dist/esm/identity/IdentityProviderResult.js +2 -0
  288. package/dist/esm/identity/IdentityProviderResult.js.map +1 -0
  289. package/dist/esm/identity/index.d.ts +5 -0
  290. package/dist/esm/identity/index.d.ts.map +1 -0
  291. package/dist/esm/identity/index.js +3 -0
  292. package/dist/esm/identity/index.js.map +1 -0
  293. package/dist/esm/index.d.ts +12 -0
  294. package/dist/esm/index.d.ts.map +1 -0
  295. package/dist/esm/index.js +14 -0
  296. package/dist/esm/index.js.map +1 -0
  297. package/dist/esm/joinPaths.d.ts +2 -0
  298. package/dist/esm/joinPaths.d.ts.map +1 -0
  299. package/dist/esm/joinPaths.js +7 -0
  300. package/dist/esm/joinPaths.js.map +1 -0
  301. package/dist/esm/queries/IObservableQueryConnection.d.ts +6 -0
  302. package/dist/esm/queries/IObservableQueryConnection.d.ts.map +1 -0
  303. package/dist/esm/queries/IObservableQueryConnection.js +2 -0
  304. package/dist/esm/queries/IObservableQueryConnection.js.map +1 -0
  305. package/dist/esm/queries/IObservableQueryFor.d.ts +13 -0
  306. package/dist/esm/queries/IObservableQueryFor.d.ts.map +1 -0
  307. package/dist/esm/queries/IObservableQueryFor.js +2 -0
  308. package/dist/esm/queries/IObservableQueryFor.js.map +1 -0
  309. package/dist/esm/queries/IQuery.d.ts +10 -0
  310. package/dist/esm/queries/IQuery.d.ts.map +1 -0
  311. package/dist/esm/queries/IQuery.js +2 -0
  312. package/dist/esm/queries/IQuery.js.map +1 -0
  313. package/dist/esm/queries/IQueryFor.d.ts +12 -0
  314. package/dist/esm/queries/IQueryFor.d.ts.map +1 -0
  315. package/dist/esm/queries/IQueryFor.js +2 -0
  316. package/dist/esm/queries/IQueryFor.js.map +1 -0
  317. package/dist/esm/queries/IQueryProvider.d.ts +6 -0
  318. package/dist/esm/queries/IQueryProvider.d.ts.map +1 -0
  319. package/dist/esm/queries/IQueryProvider.js +5 -0
  320. package/dist/esm/queries/IQueryProvider.js.map +1 -0
  321. package/dist/esm/queries/IQueryResult.d.ts +15 -0
  322. package/dist/esm/queries/IQueryResult.d.ts.map +1 -0
  323. package/dist/esm/queries/IQueryResult.js +2 -0
  324. package/dist/esm/queries/IQueryResult.js.map +1 -0
  325. package/dist/esm/queries/NullObservableQueryConnection.d.ts +9 -0
  326. package/dist/esm/queries/NullObservableQueryConnection.d.ts.map +1 -0
  327. package/dist/esm/queries/NullObservableQueryConnection.js +16 -0
  328. package/dist/esm/queries/NullObservableQueryConnection.js.map +1 -0
  329. package/dist/esm/queries/ObservableQueryConnection.d.ts +14 -0
  330. package/dist/esm/queries/ObservableQueryConnection.d.ts.map +1 -0
  331. package/dist/esm/queries/ObservableQueryConnection.js +99 -0
  332. package/dist/esm/queries/ObservableQueryConnection.js.map +1 -0
  333. package/dist/esm/queries/ObservableQueryFor.d.ts +37 -0
  334. package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -0
  335. package/dist/esm/queries/ObservableQueryFor.js +174 -0
  336. package/dist/esm/queries/ObservableQueryFor.js.map +1 -0
  337. package/dist/esm/queries/ObservableQuerySubscription.d.ts +7 -0
  338. package/dist/esm/queries/ObservableQuerySubscription.d.ts.map +1 -0
  339. package/dist/esm/queries/ObservableQuerySubscription.js +15 -0
  340. package/dist/esm/queries/ObservableQuerySubscription.js.map +1 -0
  341. package/dist/esm/queries/Paging.d.ts +8 -0
  342. package/dist/esm/queries/Paging.d.ts.map +1 -0
  343. package/dist/esm/queries/Paging.js +15 -0
  344. package/dist/esm/queries/Paging.js.map +1 -0
  345. package/dist/esm/queries/PagingInfo.d.ts +9 -0
  346. package/dist/esm/queries/PagingInfo.d.ts.map +1 -0
  347. package/dist/esm/queries/PagingInfo.js +16 -0
  348. package/dist/esm/queries/PagingInfo.js.map +1 -0
  349. package/dist/esm/queries/QueryFor.d.ts +30 -0
  350. package/dist/esm/queries/QueryFor.d.ts.map +1 -0
  351. package/dist/esm/queries/QueryFor.js +99 -0
  352. package/dist/esm/queries/QueryFor.js.map +1 -0
  353. package/dist/esm/queries/QueryProvider.d.ts +13 -0
  354. package/dist/esm/queries/QueryProvider.d.ts.map +1 -0
  355. package/dist/esm/queries/QueryProvider.js +23 -0
  356. package/dist/esm/queries/QueryProvider.js.map +1 -0
  357. package/dist/esm/queries/QueryResult.d.ts +44 -0
  358. package/dist/esm/queries/QueryResult.d.ts.map +1 -0
  359. package/dist/esm/queries/QueryResult.js +93 -0
  360. package/dist/esm/queries/QueryResult.js.map +1 -0
  361. package/dist/esm/queries/QueryResultWithState.d.ts +22 -0
  362. package/dist/esm/queries/QueryResultWithState.d.ts.map +1 -0
  363. package/dist/esm/queries/QueryResultWithState.js +44 -0
  364. package/dist/esm/queries/QueryResultWithState.js.map +1 -0
  365. package/dist/esm/queries/SortDirection.d.ts +6 -0
  366. package/dist/esm/queries/SortDirection.d.ts.map +1 -0
  367. package/dist/esm/queries/SortDirection.js +9 -0
  368. package/dist/esm/queries/SortDirection.js.map +1 -0
  369. package/dist/esm/queries/Sorting.d.ts +9 -0
  370. package/dist/esm/queries/Sorting.d.ts.map +1 -0
  371. package/dist/esm/queries/Sorting.js +17 -0
  372. package/dist/esm/queries/Sorting.js.map +1 -0
  373. package/dist/esm/queries/SortingActions.d.ts +10 -0
  374. package/dist/esm/queries/SortingActions.d.ts.map +1 -0
  375. package/dist/esm/queries/SortingActions.js +22 -0
  376. package/dist/esm/queries/SortingActions.js.map +1 -0
  377. package/dist/esm/queries/SortingActionsForObservableQuery.d.ts +10 -0
  378. package/dist/esm/queries/SortingActionsForObservableQuery.d.ts.map +1 -0
  379. package/dist/esm/queries/SortingActionsForObservableQuery.js +22 -0
  380. package/dist/esm/queries/SortingActionsForObservableQuery.js.map +1 -0
  381. package/dist/esm/queries/SortingActionsForQuery.d.ts +10 -0
  382. package/dist/esm/queries/SortingActionsForQuery.d.ts.map +1 -0
  383. package/dist/esm/queries/SortingActionsForQuery.js +22 -0
  384. package/dist/esm/queries/SortingActionsForQuery.js.map +1 -0
  385. package/dist/esm/queries/ValidateRequestArguments.d.ts +2 -0
  386. package/dist/esm/queries/ValidateRequestArguments.d.ts.map +1 -0
  387. package/dist/esm/queries/ValidateRequestArguments.js +27 -0
  388. package/dist/esm/queries/ValidateRequestArguments.js.map +1 -0
  389. package/dist/esm/queries/index.d.ts +19 -0
  390. package/dist/esm/queries/index.d.ts.map +1 -0
  391. package/dist/esm/queries/index.js +15 -0
  392. package/dist/esm/queries/index.js.map +1 -0
  393. package/dist/esm/reflection/IHaveParameters.d.ts +5 -0
  394. package/dist/esm/reflection/IHaveParameters.d.ts.map +1 -0
  395. package/dist/esm/reflection/IHaveParameters.js +2 -0
  396. package/dist/esm/reflection/IHaveParameters.js.map +1 -0
  397. package/dist/esm/reflection/ParameterDescriptor.d.ts +7 -0
  398. package/dist/esm/reflection/ParameterDescriptor.d.ts.map +1 -0
  399. package/dist/esm/reflection/ParameterDescriptor.js +11 -0
  400. package/dist/esm/reflection/ParameterDescriptor.js.map +1 -0
  401. package/dist/esm/reflection/ParametersHelper.d.ts +5 -0
  402. package/dist/esm/reflection/ParametersHelper.d.ts.map +1 -0
  403. package/dist/esm/reflection/ParametersHelper.js +15 -0
  404. package/dist/esm/reflection/ParametersHelper.js.map +1 -0
  405. package/dist/esm/reflection/PropertyDescriptor.d.ts +7 -0
  406. package/dist/esm/reflection/PropertyDescriptor.d.ts.map +1 -0
  407. package/dist/esm/reflection/PropertyDescriptor.js +11 -0
  408. package/dist/esm/reflection/PropertyDescriptor.js.map +1 -0
  409. package/dist/esm/reflection/index.d.ts +5 -0
  410. package/dist/esm/reflection/index.d.ts.map +1 -0
  411. package/dist/esm/reflection/index.js +4 -0
  412. package/dist/esm/reflection/index.js.map +1 -0
  413. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  414. package/dist/esm/validation/ValidationResult.d.ts +9 -0
  415. package/dist/esm/validation/ValidationResult.d.ts.map +1 -0
  416. package/dist/esm/validation/ValidationResult.js +15 -0
  417. package/dist/esm/validation/ValidationResult.js.map +1 -0
  418. package/dist/esm/validation/ValidationResultSeverity.d.ts +7 -0
  419. package/dist/esm/validation/ValidationResultSeverity.d.ts.map +1 -0
  420. package/dist/esm/validation/ValidationResultSeverity.js +8 -0
  421. package/dist/esm/validation/ValidationResultSeverity.js.map +1 -0
  422. package/dist/esm/validation/Validator.d.ts +4 -0
  423. package/dist/esm/validation/Validator.d.ts.map +1 -0
  424. package/dist/esm/validation/Validator.js +8 -0
  425. package/dist/esm/validation/Validator.js.map +1 -0
  426. package/dist/esm/validation/index.d.ts +3 -0
  427. package/dist/esm/validation/index.d.ts.map +1 -0
  428. package/dist/esm/validation/index.js +3 -0
  429. package/dist/esm/validation/index.js.map +1 -0
  430. package/for_UrlHelpers/when_building_query_params/with_additional_parameters.ts +23 -0
  431. package/for_UrlHelpers/when_building_query_params/with_empty_parameters.ts +16 -0
  432. package/for_UrlHelpers/when_building_query_params/with_null_and_undefined_values.ts +22 -0
  433. package/for_UrlHelpers/when_building_query_params/with_unused_parameters_only.ts +21 -0
  434. package/for_UrlHelpers/when_creating_url_from/with_base_path_ending_with_slash.ts +32 -0
  435. package/for_UrlHelpers/when_creating_url_from/with_empty_origin.ts +45 -0
  436. package/for_UrlHelpers/when_creating_url_from/with_null_or_undefined_origin.ts +53 -0
  437. package/for_UrlHelpers/when_creating_url_from/with_relative_route.ts +32 -0
  438. package/for_UrlHelpers/when_creating_url_from/with_valid_parameters.ts +32 -0
  439. package/for_UrlHelpers/when_creating_url_from/without_document_object.ts +34 -0
  440. package/for_UrlHelpers/when_replacing_route_parameters/with_all_parameters_used_in_route.ts +21 -0
  441. package/for_UrlHelpers/when_replacing_route_parameters/with_no_parameters.ts +19 -0
  442. package/for_UrlHelpers/when_replacing_route_parameters/with_unused_parameters.ts +23 -0
  443. package/for_UrlHelpers/when_replacing_route_parameters/with_url_encoded_values.ts +20 -0
  444. package/given.ts +14 -0
  445. package/identity/IIdentity.ts +33 -0
  446. package/identity/IIdentityProvider.ts +16 -0
  447. package/identity/IdentityProvider.ts +85 -0
  448. package/identity/IdentityProviderResult.ts +8 -0
  449. package/identity/index.ts +7 -0
  450. package/index.ts +21 -0
  451. package/joinPaths.ts +7 -0
  452. package/package.json +70 -0
  453. package/queries/IObservableQueryConnection.ts +21 -0
  454. package/queries/IObservableQueryFor.ts +38 -0
  455. package/queries/IQuery.ts +31 -0
  456. package/queries/IQueryFor.ts +36 -0
  457. package/queries/IQueryProvider.ts +17 -0
  458. package/queries/IQueryResult.ts +60 -0
  459. package/queries/NullObservableQueryConnection.ts +29 -0
  460. package/queries/ObservableQueryConnection.ts +118 -0
  461. package/queries/ObservableQueryFor.ts +230 -0
  462. package/queries/ObservableQuerySubscription.ts +27 -0
  463. package/queries/Paging.ts +38 -0
  464. package/queries/PagingInfo.ts +43 -0
  465. package/queries/QueryFor.ts +138 -0
  466. package/queries/QueryProvider.ts +36 -0
  467. package/queries/QueryResult.ts +157 -0
  468. package/queries/QueryResultWithState.ts +95 -0
  469. package/queries/SortDirection.ts +22 -0
  470. package/queries/Sorting.ts +30 -0
  471. package/queries/SortingActions.ts +36 -0
  472. package/queries/SortingActionsForObservableQuery.ts +36 -0
  473. package/queries/SortingActionsForQuery.ts +36 -0
  474. package/queries/ValidateRequestArguments.ts +36 -0
  475. package/queries/for_ObservableQueryFor/given/TestQueries.ts +58 -0
  476. package/queries/for_ObservableQueryFor/given/an_observable_query_for.ts +16 -0
  477. package/queries/for_ObservableQueryFor/when_constructing.ts +32 -0
  478. package/queries/for_ObservableQueryFor/when_constructing_enumerable.ts +18 -0
  479. package/queries/for_ObservableQueryFor/when_disposing.ts +28 -0
  480. package/queries/for_ObservableQueryFor/when_performing/with_enumerable_query.ts +61 -0
  481. package/queries/for_ObservableQueryFor/when_performing/with_invalid_arguments.ts +22 -0
  482. package/queries/for_ObservableQueryFor/when_performing/with_paging.ts +55 -0
  483. package/queries/for_ObservableQueryFor/when_performing/with_parameter_descriptor_values.ts +68 -0
  484. package/queries/for_ObservableQueryFor/when_performing/with_partial_parameter_descriptor_values.ts +67 -0
  485. package/queries/for_ObservableQueryFor/when_performing/with_route_parameters_and_unused_parameters.ts +71 -0
  486. package/queries/for_ObservableQueryFor/when_performing/with_sorting.ts +56 -0
  487. package/queries/for_ObservableQueryFor/when_performing/with_valid_arguments.ts +79 -0
  488. package/queries/for_ObservableQueryFor/when_setting_api_base_path.ts +17 -0
  489. package/queries/for_ObservableQueryFor/when_setting_microservice.ts +17 -0
  490. package/queries/for_ObservableQueryFor/when_setting_origin.ts +17 -0
  491. package/queries/for_ObservableQueryFor/when_subscribing/with_enumerable_query.ts +34 -0
  492. package/queries/for_ObservableQueryFor/when_subscribing/with_invalid_arguments.ts +40 -0
  493. package/queries/for_ObservableQueryFor/when_subscribing/with_paging.ts +36 -0
  494. package/queries/for_ObservableQueryFor/when_subscribing/with_sorting.ts +37 -0
  495. package/queries/for_ObservableQueryFor/when_subscribing/with_valid_arguments.ts +35 -0
  496. package/queries/for_QueryFor/given/TestQueries.ts +72 -0
  497. package/queries/for_QueryFor/given/a_query_for.ts +18 -0
  498. package/queries/for_QueryFor/when_constructing.ts +31 -0
  499. package/queries/for_QueryFor/when_constructing_enumerable.ts +17 -0
  500. package/queries/for_QueryFor/when_performing/with_abort_controller.ts +71 -0
  501. package/queries/for_QueryFor/when_performing/with_enumerable_query.ts +62 -0
  502. package/queries/for_QueryFor/when_performing/with_fetch_error.ts +47 -0
  503. package/queries/for_QueryFor/when_performing/with_invalid_arguments.ts +29 -0
  504. package/queries/for_QueryFor/when_performing/with_json_parse_error.ts +45 -0
  505. package/queries/for_QueryFor/when_performing/with_paging.ts +62 -0
  506. package/queries/for_QueryFor/when_performing/with_parameter_descriptor_values.ts +68 -0
  507. package/queries/for_QueryFor/when_performing/with_partial_parameter_descriptor_values.ts +67 -0
  508. package/queries/for_QueryFor/when_performing/with_query_without_required_parameters.ts +58 -0
  509. package/queries/for_QueryFor/when_performing/with_route_parameters_and_unused_parameters.ts +71 -0
  510. package/queries/for_QueryFor/when_performing/with_sorting.ts +99 -0
  511. package/queries/for_QueryFor/when_performing/with_valid_arguments.ts +87 -0
  512. package/queries/for_QueryFor/when_setting_api_base_path.ts +19 -0
  513. package/queries/for_QueryFor/when_setting_microservice.ts +19 -0
  514. package/queries/for_QueryFor/when_setting_origin.ts +19 -0
  515. package/queries/for_QueryResult/when_asking_has_data/and_it_an_array_with_items.ts +27 -0
  516. package/queries/for_QueryResult/when_asking_has_data/and_it_is_defined_instance.ts +27 -0
  517. package/queries/for_QueryResult/when_asking_has_data/and_it_is_empty_array.ts +27 -0
  518. package/queries/for_QueryResult/when_asking_has_data/and_it_is_undefined.ts +27 -0
  519. package/queries/index.ts +21 -0
  520. package/reflection/IHaveParameters.ts +11 -0
  521. package/reflection/ParameterDescriptor.ts +17 -0
  522. package/reflection/ParametersHelper.ts +25 -0
  523. package/reflection/PropertyDescriptor.ts +17 -0
  524. package/reflection/index.ts +7 -0
  525. package/validation/ValidationResult.ts +16 -0
  526. package/validation/ValidationResultSeverity.ts +28 -0
  527. package/validation/Validator.ts +15 -0
  528. package/validation/index.ts +5 -0
@@ -0,0 +1,105 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Guid } from '@cratis/fundamentals';
5
+ import { ValidationResult } from '../validation/ValidationResult';
6
+ import { Command } from './Command';
7
+ import { CommandResult } from './CommandResult';
8
+ import { ICommandResult } from './ICommandResult';
9
+
10
+ type GetSpecificState = (commandResult: CommandResult) => boolean;
11
+
12
+
13
+ export class CommandResults implements ICommandResult {
14
+ constructor(private readonly _commandResultsPerCommand: Map<Command, CommandResult>) {
15
+ }
16
+
17
+ /** @inheritdoc */
18
+ readonly correlationId: Guid = Guid.empty;
19
+
20
+ /** @inheritdoc */
21
+ get isSuccess(): boolean {
22
+ return this.isAnyFalse(_ => _.isSuccess);
23
+ }
24
+
25
+ /** @inheritdoc */
26
+ get isAuthorized(): boolean {
27
+ return this.isAnyFalse(_ => _.isAuthorized);
28
+ }
29
+
30
+ /** @inheritdoc */
31
+ get isValid(): boolean {
32
+ return this.isAnyFalse(_ => _.isValid);
33
+ }
34
+
35
+ /** @inheritdoc */
36
+ get hasExceptions(): boolean {
37
+ return this.isAnyTrue(_ => _.hasExceptions);
38
+ }
39
+
40
+ /** @inheritdoc */
41
+ get validationResults(): ValidationResult[] {
42
+ const errors: ValidationResult[] = [];
43
+
44
+ for (const result of this._commandResultsPerCommand.values()) {
45
+ result.validationResults.forEach(_ => errors.push(_));
46
+ }
47
+
48
+ return errors;
49
+ }
50
+
51
+ /** @inheritdoc */
52
+ get exceptionMessages(): string[] {
53
+ const messages: string[] = [];
54
+
55
+ for (const result of this._commandResultsPerCommand.values()) {
56
+ result.exceptionMessages.forEach(_ => messages.push(_));
57
+ }
58
+
59
+ return messages;
60
+ }
61
+
62
+ /** @inheritdoc */
63
+ get authorizationFailureReason(): string {
64
+ const reasons: string[] = [];
65
+
66
+ for (const result of this._commandResultsPerCommand.values()) {
67
+ if (result.authorizationFailureReason) {
68
+ reasons.push(result.authorizationFailureReason);
69
+ }
70
+ }
71
+
72
+ return reasons.join('; ');
73
+ }
74
+
75
+ /** @inheritdoc */
76
+ get exceptionStackTrace(): string {
77
+ let stackTraces = '';
78
+
79
+ for (const result of this._commandResultsPerCommand.values()) {
80
+ stackTraces = stackTraces + '\n' + result.exceptionStackTrace;
81
+ }
82
+
83
+ return stackTraces;
84
+
85
+ }
86
+
87
+
88
+ isAnyFalse(callback: GetSpecificState) {
89
+ for (const result of this._commandResultsPerCommand.values()) {
90
+ if (!callback(result)) {
91
+ return false;
92
+ }
93
+ }
94
+ return true;
95
+ }
96
+
97
+ isAnyTrue(callback: GetSpecificState) {
98
+ for (const result of this._commandResultsPerCommand.values()) {
99
+ if (callback(result)) {
100
+ return true;
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+ }
@@ -0,0 +1,17 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Validator } from '../validation/Validator';
5
+
6
+ export type CommandPropertyValidators = { [key: string]: Validator; };
7
+
8
+ /**
9
+ * Represents the command validator
10
+ */
11
+ export abstract class CommandValidator {
12
+ abstract readonly properties: CommandPropertyValidators;
13
+
14
+ get isValid() {
15
+ return true;
16
+ }
17
+ }
@@ -0,0 +1,82 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { ICanBeConfigured } from '../ICanBeConfigured';
5
+ import { CommandResult } from './CommandResult';
6
+ import { PropertyDescriptor } from '../reflection/PropertyDescriptor';
7
+
8
+ /**
9
+ * Callback for when a property changes.
10
+ */
11
+ export type PropertyChanged = (property: string) => void;
12
+
13
+ /**
14
+ * Defines the base of a command.
15
+ */
16
+ export interface ICommand<TCommandContent = object, TCommandResponse = object> extends ICanBeConfigured {
17
+ /**
18
+ * Gets the route information for the command.
19
+ */
20
+ readonly route: string;
21
+
22
+ /**
23
+ * Gets the property descriptors for the command.
24
+ */
25
+ readonly propertyDescriptors: PropertyDescriptor[];
26
+
27
+ /**
28
+ * Execute the {@link ICommand}.
29
+ * @param [args] Optional arguments for the command route - depends on whether or not the command needs arguments.
30
+ * @returns {CommandResult} for the execution.
31
+ */
32
+ execute(): Promise<CommandResult<TCommandResponse>>;
33
+
34
+ /**
35
+ * Validate the {@link ICommand} without executing it.
36
+ * @returns {CommandResult} for the validation containing authorization and validation status.
37
+ * @remarks
38
+ * This method performs authorization and validation checks on the server without executing the command handler.
39
+ * Use this for pre-flight validation to provide early feedback to users.
40
+ */
41
+ validate(): Promise<CommandResult<TCommandResponse>>;
42
+
43
+ /**
44
+ * Clear the command properties and reset them to their default values. This will also clear the initial values.
45
+ * This is used when the command is not needed anymore and should be cleared.
46
+ */
47
+ clear(): void;
48
+
49
+ /**
50
+ * Set the initial values for the command. This is used for tracking if there are changes to a command or not.
51
+ * @param {*} values Values to set.
52
+ */
53
+ setInitialValues(values: TCommandContent): void;
54
+
55
+ /**
56
+ * Set the initial values for the command to be the current value of the properties.
57
+ */
58
+ setInitialValuesFromCurrentValues(): void;
59
+
60
+ /**
61
+ * Revert any changes on the command.
62
+ */
63
+ revertChanges(): void;
64
+
65
+ /**
66
+ * Gets whether or not there are changes to any properties.
67
+ */
68
+ readonly hasChanges: boolean;
69
+
70
+ /**
71
+ * Notify about a property that has had its value changed.
72
+ * @param {string} property Name of property that changes.
73
+ */
74
+ propertyChanged(property: string): void;
75
+
76
+ /**
77
+ * Register callback that gets called when a property changes.
78
+ * @param {PropertyChanged} callback Callback to register.
79
+ * @param {*} thisArg The this arg to use when calling.
80
+ */
81
+ onPropertyChanged(callback: PropertyChanged, thisArg: object): void;
82
+ }
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Guid } from '@cratis/fundamentals';
5
+ import { ValidationResult } from '../validation/ValidationResult';
6
+
7
+ /**
8
+ * Defines the result from executing commands.
9
+ */
10
+ export interface ICommandResult<TResponse = object> {
11
+ /**
12
+ * Gets the correlation identifier associated with the executed command.
13
+ */
14
+ readonly correlationId: Guid;
15
+
16
+ /**
17
+ * Gets whether or not the command executed successfully.
18
+ */
19
+ readonly isSuccess: boolean;
20
+
21
+ /**
22
+ * Gets whether or not the command was authorized to execute.
23
+ */
24
+ readonly isAuthorized: boolean;
25
+
26
+ /**
27
+ * Gets whether or not the command is valid.
28
+ */
29
+ readonly isValid: boolean;
30
+
31
+ /**
32
+ * Gets whether or not there are any exceptions that occurred.
33
+ */
34
+ readonly hasExceptions: boolean;
35
+
36
+ /**
37
+ * Gets any validation errors. If this collection is empty, there are errors.
38
+ */
39
+ readonly validationResults: ValidationResult[];
40
+
41
+ /**
42
+ * Gets any exception messages that might have occurred.
43
+ */
44
+ readonly exceptionMessages: string[];
45
+
46
+ /**
47
+ * Gets the reason for authorization failure, if any.
48
+ */
49
+ readonly authorizationFailureReason: string;
50
+
51
+ /**
52
+ * Gets the stack trace if there was an exception.
53
+ */
54
+ readonly exceptionStackTrace: string;
55
+
56
+ /**
57
+ * Gets the response from the command, if any.
58
+ */
59
+ readonly response?: TResponse;
60
+ }
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Command } from '../Command';
5
+ import { CommandValidator } from '../CommandValidator';
6
+ import { PropertyDescriptor } from '../../reflection/PropertyDescriptor';
7
+
8
+ export interface ICommandWithRouteParams {
9
+ id: string;
10
+ name: string;
11
+ }
12
+
13
+ export class CommandWithRouteParams extends Command<ICommandWithRouteParams> implements ICommandWithRouteParams {
14
+ validation!: CommandValidator;
15
+ route = '/api/items/{id}';
16
+ propertyDescriptors: PropertyDescriptor[] = [
17
+ new PropertyDescriptor('id', String),
18
+ new PropertyDescriptor('name', String)
19
+ ];
20
+
21
+ constructor() {
22
+ super(Object, false);
23
+ }
24
+
25
+ get requestParameters(): string[] {
26
+ return ['id'];
27
+ }
28
+ get properties(): string[] {
29
+ return ['id', 'name'];
30
+ }
31
+
32
+ id!: string;
33
+ name!: string;
34
+ }
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Command } from '../Command';
5
+ import { CommandValidator } from '../CommandValidator';
6
+ import { PropertyDescriptor } from '../../reflection/PropertyDescriptor';
7
+
8
+ export interface ISomeCommand {
9
+ someProperty: string;
10
+ }
11
+
12
+ export class SomeCommand extends Command<ISomeCommand> implements ISomeCommand {
13
+ validation!: CommandValidator;
14
+ route = '';
15
+ propertyDescriptors: PropertyDescriptor[] = [
16
+ new PropertyDescriptor('someProperty', String)
17
+ ];
18
+
19
+ constructor() {
20
+ super(Object, false);
21
+ }
22
+
23
+ get requestParameters(): string[] {
24
+ return [];
25
+ }
26
+ get properties(): string[] {
27
+ return [
28
+ 'someProperty'
29
+ ];
30
+ }
31
+
32
+ someProperty!: string;
33
+ }
34
+
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import sinon from 'sinon';
5
+ import { SomeCommand } from '../SomeCommand';
6
+
7
+ export class a_command {
8
+ command: SomeCommand;
9
+ fetchStub: sinon.SinonStub;
10
+
11
+ constructor() {
12
+ this.command = new SomeCommand();
13
+ this.command.route = '/test-route';
14
+ this.command.setOrigin('http://localhost');
15
+ this.command.setApiBasePath('/api');
16
+ this.fetchStub = sinon.stub(globalThis, 'fetch');
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { SomeCommand } from './SomeCommand';
5
+
6
+ describe('when clearing the command', () => {
7
+ const command = new SomeCommand();
8
+ command.setInitialValues({
9
+ someProperty: ''
10
+ });
11
+ command.someProperty = '42';
12
+ command.propertyChanged('someProperty');
13
+ command.clear();
14
+
15
+ it('should not have any changes', () => command.hasChanges.should.be.false);
16
+ it('should clear the property', () => (command.someProperty === undefined).should.be.true);
17
+ });
@@ -0,0 +1,26 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { a_command } from '../given/a_command';
5
+ import { given } from '../../../given';
6
+ import { CommandResult } from '../../CommandResult';
7
+
8
+ describe("when executing and command route not found", given(a_command, context => {
9
+ let result: CommandResult<object>;
10
+
11
+ beforeEach(async () => {
12
+ context.fetchStub.resolves({
13
+ status: 404,
14
+ json: async () => ({})
15
+ });
16
+
17
+ result = await context.command.execute();
18
+ });
19
+
20
+ afterEach(() => {
21
+ context.fetchStub.restore();
22
+ });
23
+
24
+ it("should_return_failed_result", () => result.isSuccess.should.be.false);
25
+ it("should_have_exception_messages", () => (result.exceptionMessages.length > 0).should.be.true);
26
+ }));
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { a_command } from '../given/a_command';
5
+ import { given } from '../../../given';
6
+ import { CommandResult } from '../../CommandResult';
7
+
8
+ describe("when executing and fetch throws exception", given(a_command, context => {
9
+ let result: CommandResult<object>;
10
+
11
+ beforeEach(async () => {
12
+ context.fetchStub.rejects(new Error('Network error'));
13
+
14
+ result = await context.command.execute();
15
+ });
16
+
17
+ afterEach(() => {
18
+ context.fetchStub.restore();
19
+ });
20
+
21
+ it("should_return_failed_result", () => result.isSuccess.should.be.false);
22
+ it("should_include_error_message", () => result.exceptionMessages[0].should.contain('Error during server call'));
23
+ it("should_have_exception_messages", () => (result.exceptionMessages.length > 0).should.be.true);
24
+ }));
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { a_command } from '../given/a_command';
5
+ import { given } from '../../../given';
6
+
7
+ describe("when executing with command properties", given(a_command, context => {
8
+ const responseData = {
9
+ correlationId: '12345678-1234-1234-1234-123456789012',
10
+ isSuccess: true,
11
+ isAuthorized: true,
12
+ isValid: true,
13
+ hasExceptions: false,
14
+ validationResults: [],
15
+ exceptionMessages: [],
16
+ exceptionStackTrace: '',
17
+ response: {}
18
+ };
19
+
20
+ beforeEach(async () => {
21
+ context.command.someProperty = 'test value';
22
+
23
+ context.fetchStub.resolves({
24
+ status: 200,
25
+ json: async () => responseData
26
+ });
27
+
28
+ await context.command.execute();
29
+ });
30
+
31
+ afterEach(() => {
32
+ context.fetchStub.restore();
33
+ });
34
+
35
+ it("should_include_command_properties_in_body", () => {
36
+ const call = context.fetchStub.getCall(0);
37
+ const body = JSON.parse(call.args[1].body);
38
+ body.someProperty.should.equal('test value');
39
+ });
40
+ }));
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import sinon from 'sinon';
5
+ import { SomeCommand } from '../SomeCommand';
6
+ import { given } from '../../../given';
7
+
8
+ describe("when executing with custom http headers", given(class {
9
+ command: SomeCommand;
10
+ fetchStub: sinon.SinonStub;
11
+
12
+ constructor() {
13
+ this.command = new SomeCommand();
14
+ this.command.route = '/test-route';
15
+ this.command.setOrigin('http://localhost');
16
+ this.command.setApiBasePath('/api');
17
+ this.command.setHttpHeadersCallback(() => ({
18
+ 'X-Custom-Header': 'custom-value',
19
+ 'Authorization': 'Bearer token123'
20
+ }));
21
+ this.fetchStub = sinon.stub(globalThis, 'fetch');
22
+ }
23
+ }, context => {
24
+ const responseData = {
25
+ correlationId: '12345678-1234-1234-1234-123456789012',
26
+ isSuccess: true,
27
+ isAuthorized: true,
28
+ isValid: true,
29
+ hasExceptions: false,
30
+ validationResults: [],
31
+ exceptionMessages: [],
32
+ exceptionStackTrace: '',
33
+ response: {}
34
+ };
35
+
36
+ beforeEach(async () => {
37
+ context.fetchStub.resolves({
38
+ status: 200,
39
+ json: async () => responseData
40
+ });
41
+
42
+ await context.command.execute();
43
+ });
44
+
45
+ afterEach(() => {
46
+ context.fetchStub.restore();
47
+ });
48
+
49
+ it("should_include_custom_headers", () => {
50
+ const call = context.fetchStub.getCall(0);
51
+ call.args[1].headers['X-Custom-Header'].should.equal('custom-value');
52
+ call.args[1].headers['Authorization'].should.equal('Bearer token123');
53
+ });
54
+
55
+ it("should_include_default_headers", () => {
56
+ const call = context.fetchStub.getCall(0);
57
+ call.args[1].headers['Content-Type'].should.equal('application/json');
58
+ call.args[1].headers['Accept'].should.equal('application/json');
59
+ });
60
+ }));
@@ -0,0 +1,55 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import sinon from 'sinon';
5
+ import { SomeCommand } from '../SomeCommand';
6
+ import { given } from '../../../given';
7
+ import { Globals } from '../../../Globals';
8
+
9
+ describe("when executing with microservice header", given(class {
10
+ command: SomeCommand;
11
+ fetchStub: sinon.SinonStub;
12
+ originalMicroserviceHeader: string;
13
+
14
+ constructor() {
15
+ this.command = new SomeCommand();
16
+ this.command.route = '/test-route';
17
+ this.command.setOrigin('http://localhost');
18
+ this.command.setApiBasePath('/api');
19
+ this.command.setMicroservice('my-microservice');
20
+ this.fetchStub = sinon.stub(globalThis, 'fetch');
21
+ this.originalMicroserviceHeader = Globals.microserviceHttpHeader;
22
+ Globals.microserviceHttpHeader = 'X-Microservice-Id';
23
+ }
24
+ }, context => {
25
+ const responseData = {
26
+ correlationId: '12345678-1234-1234-1234-123456789012',
27
+ isSuccess: true,
28
+ isAuthorized: true,
29
+ isValid: true,
30
+ hasExceptions: false,
31
+ validationResults: [],
32
+ exceptionMessages: [],
33
+ exceptionStackTrace: '',
34
+ response: {}
35
+ };
36
+
37
+ beforeEach(async () => {
38
+ context.fetchStub.resolves({
39
+ status: 200,
40
+ json: async () => responseData
41
+ });
42
+
43
+ await context.command.execute();
44
+ });
45
+
46
+ afterEach(() => {
47
+ context.fetchStub.restore();
48
+ Globals.microserviceHttpHeader = context.originalMicroserviceHeader;
49
+ });
50
+
51
+ it("should_include_microservice_header", () => {
52
+ const call = context.fetchStub.getCall(0);
53
+ call.args[1].headers['X-Microservice-Id'].should.equal('my-microservice');
54
+ });
55
+ }));
@@ -0,0 +1,51 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import sinon from 'sinon';
5
+ import { SomeCommand } from '../SomeCommand';
6
+ import { given } from '../../../given';
7
+
8
+ describe("when executing with origin and api base path", given(class {
9
+ command: SomeCommand;
10
+ fetchStub: sinon.SinonStub;
11
+
12
+ constructor() {
13
+ this.command = new SomeCommand();
14
+ this.command.route = '/items';
15
+ this.command.setOrigin('https://api.example.com');
16
+ this.command.setApiBasePath('/api/v1');
17
+ this.fetchStub = sinon.stub(globalThis, 'fetch');
18
+ }
19
+ }, context => {
20
+ const responseData = {
21
+ correlationId: '12345678-1234-1234-1234-123456789012',
22
+ isSuccess: true,
23
+ isAuthorized: true,
24
+ isValid: true,
25
+ hasExceptions: false,
26
+ validationResults: [],
27
+ exceptionMessages: [],
28
+ exceptionStackTrace: '',
29
+ response: {}
30
+ };
31
+
32
+ beforeEach(async () => {
33
+ context.fetchStub.resolves({
34
+ status: 200,
35
+ json: async () => responseData
36
+ });
37
+
38
+ await context.command.execute();
39
+ });
40
+
41
+ afterEach(() => {
42
+ context.fetchStub.restore();
43
+ });
44
+
45
+ it("should_construct_url_with_origin_and_base_path", () => {
46
+ const call = context.fetchStub.getCall(0);
47
+ const url = call.args[0];
48
+ url.toString().should.contain('https://api.example.com');
49
+ url.toString().should.contain('/api/v1/items');
50
+ });
51
+ }));