@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,58 @@
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 { CommandWithRouteParams } from '../CommandWithRouteParams';
6
+ import { given } from '../../../given';
7
+
8
+ describe("when executing with route parameters", given(class {
9
+ command: CommandWithRouteParams;
10
+ fetchStub: sinon.SinonStub;
11
+
12
+ constructor() {
13
+ this.command = new CommandWithRouteParams();
14
+ this.command.setOrigin('http://localhost');
15
+ this.command.setApiBasePath('/api');
16
+ this.command.id = '123';
17
+ this.command.name = 'Test Item';
18
+ this.fetchStub = sinon.stub(globalThis, 'fetch');
19
+ }
20
+ }, context => {
21
+ const responseData = {
22
+ correlationId: '12345678-1234-1234-1234-123456789012',
23
+ isSuccess: true,
24
+ isAuthorized: true,
25
+ isValid: true,
26
+ hasExceptions: false,
27
+ validationResults: [],
28
+ exceptionMessages: [],
29
+ exceptionStackTrace: '',
30
+ response: {}
31
+ };
32
+
33
+ beforeEach(async () => {
34
+ context.fetchStub.resolves({
35
+ status: 200,
36
+ json: async () => responseData
37
+ });
38
+
39
+ await context.command.execute();
40
+ });
41
+
42
+ afterEach(() => {
43
+ context.fetchStub.restore();
44
+ });
45
+
46
+ it("should_replace_route_parameters_in_url", () => {
47
+ const call = context.fetchStub.getCall(0);
48
+ const url = call.args[0];
49
+ url.toString().should.contain('/api/items/123');
50
+ });
51
+
52
+ it("should_include_all_properties_in_body", () => {
53
+ const call = context.fetchStub.getCall(0);
54
+ const body = JSON.parse(call.args[1].body);
55
+ body.id.should.equal('123');
56
+ body.name.should.equal('Test Item');
57
+ });
58
+ }));
@@ -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 { a_command } from '../given/a_command';
5
+ import { given } from '../../../given';
6
+ import { CommandResult } from '../../CommandResult';
7
+
8
+ describe("when executing with successful response", given(a_command, context => {
9
+ let result: CommandResult<object>;
10
+ const responseData = {
11
+ correlationId: '12345678-1234-1234-1234-123456789012',
12
+ isSuccess: true,
13
+ isAuthorized: true,
14
+ isValid: true,
15
+ hasExceptions: false,
16
+ validationResults: [],
17
+ exceptionMessages: [],
18
+ exceptionStackTrace: '',
19
+ response: { data: 'test' }
20
+ };
21
+
22
+ beforeEach(async () => {
23
+ context.fetchStub.resolves({
24
+ status: 200,
25
+ json: async () => responseData
26
+ });
27
+
28
+ result = await context.command.execute();
29
+ });
30
+
31
+ afterEach(() => {
32
+ context.fetchStub.restore();
33
+ });
34
+
35
+ it("should_call_fetch_with_correct_url", () => context.fetchStub.calledOnce.should.be.true);
36
+
37
+ it("should_call_fetch_with_post_method", () => {
38
+ const call = context.fetchStub.getCall(0);
39
+ call.args[1].method.should.equal('POST');
40
+ });
41
+
42
+ it("should_call_fetch_with_json_headers", () => {
43
+ const call = context.fetchStub.getCall(0);
44
+ call.args[1].headers['Content-Type'].should.equal('application/json');
45
+ call.args[1].headers['Accept'].should.equal('application/json');
46
+ });
47
+
48
+ it("should_return_command_result", () => (result !== null && result !== undefined).should.be.true);
49
+
50
+ it("should_set_initial_values_from_current_values", () => context.command.hasChanges.should.be.false);
51
+ }));
@@ -0,0 +1,16 @@
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 property changed value that is different from initial value', () => {
7
+ const command = new SomeCommand();
8
+ command.setInitialValues({
9
+ someProperty: ''
10
+ });
11
+
12
+ command.someProperty = '42';
13
+ command.propertyChanged('someProperty');
14
+
15
+ it('should have changes', () => command.hasChanges.should.be.true);
16
+ });
@@ -0,0 +1,16 @@
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 property changed value that is same as initial value', () => {
7
+ const command = new SomeCommand();
8
+ command.setInitialValues({
9
+ someProperty: ''
10
+ });
11
+
12
+ command.someProperty = '';
13
+ command.propertyChanged('someProperty');
14
+
15
+ it('should have no changes', () => command.hasChanges.should.be.false);
16
+ });
@@ -0,0 +1,12 @@
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 property changes and initial value is undefined', () => {
7
+ const command = new SomeCommand();
8
+ command.someProperty = '42';
9
+ command.propertyChanged('someProperty');
10
+
11
+ it('should have changes', () => command.hasChanges.should.be.true);
12
+ });
@@ -0,0 +1,15 @@
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
+ describe('when property changes and there is a callback', () => {
8
+ const command = new SomeCommand();
9
+ const callback = sinon.stub();
10
+ command.onPropertyChanged(callback, command);
11
+
12
+ command.propertyChanged('someProperty');
13
+
14
+ it('should call the callback', () => callback.calledWith('someProperty').should.be.true);
15
+ });
@@ -0,0 +1,15 @@
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 property has changed and we revert', () => {
7
+ const command = new SomeCommand();
8
+ command.setInitialValues({
9
+ someProperty: ''
10
+ });
11
+ command.someProperty = '42';
12
+ command.revertChanges();
13
+
14
+ it('should not have any changes', () => command.hasChanges.should.be.false);
15
+ });
@@ -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 setting initial values after property changed', () => {
7
+ const command = new SomeCommand();
8
+ command.setInitialValues({
9
+ someProperty: ''
10
+ });
11
+ command.someProperty = '42';
12
+ command.propertyChanged('someProperty');
13
+
14
+ command.setInitialValuesFromCurrentValues();
15
+
16
+ it('should not have any changes', () => command.hasChanges.should.be.false);
17
+ });
@@ -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 validating 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.validate();
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 validation call'));
23
+ it("should_have_exception_messages", () => (result.exceptionMessages.length > 0).should.be.true);
24
+ }));
@@ -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 validating and validation endpoint 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.validate();
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,39 @@
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 validating does not update initial values", 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 = 'initial value';
22
+ context.command.setInitialValues({ someProperty: 'initial value' });
23
+ context.command.someProperty = 'changed value';
24
+ context.command.propertyChanged('someProperty');
25
+
26
+ context.fetchStub.resolves({
27
+ status: 200,
28
+ json: async () => responseData
29
+ });
30
+
31
+ await context.command.validate();
32
+ });
33
+
34
+ afterEach(() => {
35
+ context.fetchStub.restore();
36
+ });
37
+
38
+ it("should_still_have_changes_after_validation", () => context.command.hasChanges.should.be.true);
39
+ }));
@@ -0,0 +1,47 @@
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 validating with successful response", given(a_command, context => {
9
+ let result: CommandResult<object>;
10
+ const responseData = {
11
+ correlationId: '12345678-1234-1234-1234-123456789012',
12
+ isSuccess: true,
13
+ isAuthorized: true,
14
+ isValid: true,
15
+ hasExceptions: false,
16
+ validationResults: [],
17
+ exceptionMessages: [],
18
+ exceptionStackTrace: '',
19
+ response: {}
20
+ };
21
+
22
+ beforeEach(async () => {
23
+ context.fetchStub.resolves({
24
+ status: 200,
25
+ json: async () => responseData
26
+ });
27
+
28
+ result = await context.command.validate();
29
+ });
30
+
31
+ afterEach(() => {
32
+ context.fetchStub.restore();
33
+ });
34
+
35
+ it("should_call_fetch_with_validate_route", () => {
36
+ const call = context.fetchStub.getCall(0);
37
+ const url = call.args[0];
38
+ url.toString().should.contain('/validate');
39
+ });
40
+
41
+ it("should_call_fetch_with_post_method", () => {
42
+ const call = context.fetchStub.getCall(0);
43
+ call.args[1].method.should.equal('POST');
44
+ });
45
+
46
+ it("should_return_command_result", () => (result !== null && result !== undefined).should.be.true);
47
+ }));
@@ -0,0 +1,45 @@
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 validating with validation errors", given(a_command, context => {
9
+ let result: CommandResult<object>;
10
+ const responseData = {
11
+ correlationId: '12345678-1234-1234-1234-123456789012',
12
+ isSuccess: false,
13
+ isAuthorized: true,
14
+ isValid: false,
15
+ hasExceptions: false,
16
+ validationResults: [
17
+ {
18
+ severity: 1,
19
+ message: 'Field is required',
20
+ members: ['someProperty'],
21
+ state: {}
22
+ }
23
+ ],
24
+ exceptionMessages: [],
25
+ exceptionStackTrace: '',
26
+ response: {}
27
+ };
28
+
29
+ beforeEach(async () => {
30
+ context.fetchStub.resolves({
31
+ status: 200,
32
+ json: async () => responseData
33
+ });
34
+
35
+ result = await context.command.validate();
36
+ });
37
+
38
+ afterEach(() => {
39
+ context.fetchStub.restore();
40
+ });
41
+
42
+ it("should_return_invalid_result", () => result.isValid.should.be.false);
43
+ it("should_not_be_successful", () => result.isSuccess.should.be.false);
44
+ it("should_not_update_initial_values", () => context.command.hasChanges.should.be.false);
45
+ }));
@@ -0,0 +1,54 @@
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 { CommandResult } from '../../CommandResult';
5
+
6
+ describe('when chaining callbacks and result has exceptions', () => {
7
+ const result = new CommandResult({
8
+ correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
9
+ isSuccess: false,
10
+ isAuthorized: true,
11
+ isValid: true,
12
+ hasExceptions: true,
13
+ validationResults: [],
14
+ exceptionMessages: [
15
+ 'Something went wrong',
16
+ 'Something is not right'
17
+ ],
18
+ exceptionStackTrace: 'Some stack trace',
19
+ response: {}
20
+ }, Object, false);
21
+
22
+ let onSuccessCalled = false;
23
+ let onFailedCalled = false;
24
+ let receivedCommandResultOnFailed: CommandResult<object>;
25
+ let onUnauthorizedCalled = false;
26
+ let onValidationFailureCalled = false;
27
+ let onExceptionCalled = false;
28
+ let receivedMessages: string[] = [];
29
+ let receivedStackTrace: string = '';
30
+
31
+ result
32
+ .onSuccess(() => onSuccessCalled = true)
33
+ .onFailed((commandResult) => {
34
+ onFailedCalled = true;
35
+ receivedCommandResultOnFailed = commandResult;
36
+ })
37
+ .onUnauthorized(() => onUnauthorizedCalled = true)
38
+ .onValidationFailure(() => onValidationFailureCalled = true)
39
+ .onException((messages, stackTrace) => {
40
+ onExceptionCalled = true;
41
+ receivedMessages = messages;
42
+ receivedStackTrace = stackTrace;
43
+ });
44
+
45
+ it('should not call the on success callback', () => onSuccessCalled.should.be.false);
46
+ it('should forward the exception messages to the callback', () => receivedMessages.should.equal(result.exceptionMessages));
47
+ it('should forward the exception stack trace to the callback', () => receivedStackTrace.should.equal(result.exceptionStackTrace));
48
+ it('should call the on failed callback', () => onFailedCalled.should.be.true);
49
+ it('should forward the command result to the on failed callback', () => receivedCommandResultOnFailed.should.equal(result));
50
+ it('should not call the on unauthorized callback', () => onUnauthorizedCalled.should.be.false);
51
+ it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.false);
52
+ it('should call the on exception callback', () => onExceptionCalled.should.be.true);
53
+ });
54
+
@@ -0,0 +1,53 @@
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 { ValidationResult } from '../../../validation/ValidationResult';
5
+ import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity';
6
+ import { CommandResult } from '../../CommandResult';
7
+
8
+ describe('when chaining callbacks and result is invalid', () => {
9
+ const result = new CommandResult({
10
+ correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
11
+ isSuccess: false,
12
+ isAuthorized: true,
13
+ isValid: false,
14
+ hasExceptions: false,
15
+ validationResults: [
16
+ new ValidationResult(ValidationResultSeverity.Error, 'Something went wrong', ['someProperty'], 'Something went wrong'),
17
+ new ValidationResult(ValidationResultSeverity.Warning, 'Something is not right', ['someOtherProperty'], 'Something is not right')
18
+ ],
19
+ exceptionMessages: [],
20
+ exceptionStackTrace: '',
21
+ response: {}
22
+ }, Object, false);
23
+
24
+ let onSuccessCalled = false;
25
+ let onFailedCalled = false;
26
+ let receivedCommandResultOnFailed: CommandResult<object>;
27
+ let onUnauthorizedCalled = false;
28
+ let onValidationFailureCalled = false;
29
+ let onExceptionCalled = false;
30
+ let receivedValidationResults: ValidationResult[] = [];
31
+
32
+ result
33
+ .onSuccess(() => onSuccessCalled = true)
34
+ .onFailed((commandResult) => {
35
+ onFailedCalled = true;
36
+ receivedCommandResultOnFailed = commandResult;
37
+ })
38
+ .onUnauthorized(() => onUnauthorizedCalled = true)
39
+ .onValidationFailure(validationResults => {
40
+ onValidationFailureCalled = true;
41
+ receivedValidationResults = validationResults;
42
+ })
43
+ .onException(() => onExceptionCalled = true);
44
+
45
+ it('should not call the on success callback', () => onSuccessCalled.should.be.false);
46
+ it('should forward the validation results to the callback', () => receivedValidationResults.should.equal(result.validationResults));
47
+ it('should call the on failed callback', () => onFailedCalled.should.be.true);
48
+ it('should forward the command result to the on failed callback', () => receivedCommandResultOnFailed.should.equal(result));
49
+ it('should not call the on unauthorized callback', () => onUnauthorizedCalled.should.be.false);
50
+ it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.true);
51
+ it('should not call the on exception callback', () => onExceptionCalled.should.be.false);
52
+ });
53
+
@@ -0,0 +1,42 @@
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 { CommandResult } from '../../CommandResult';
5
+
6
+ describe('when chaining callbacks and result is successful', () => {
7
+ const result = new CommandResult<string>({
8
+ correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
9
+ isSuccess: true,
10
+ isAuthorized: true,
11
+ isValid: true,
12
+ hasExceptions: false,
13
+ validationResults: [],
14
+ exceptionMessages: [],
15
+ exceptionStackTrace: '',
16
+ response: 'The ultimate response'
17
+ }, Object, false);
18
+
19
+ let onSuccessCalled = false;
20
+ let onFailedCalled = false;
21
+ let onUnauthorizedCalled = false;
22
+ let onValidationFailureCalled = false;
23
+ let onExceptionCalled = false;
24
+ let receivedResponse: string | null = null;
25
+
26
+ result
27
+ .onSuccess(response => {
28
+ onSuccessCalled = true;
29
+ receivedResponse = response as string;
30
+ })
31
+ .onFailed(() => onFailedCalled = true)
32
+ .onUnauthorized(() => onUnauthorizedCalled = true)
33
+ .onValidationFailure(() => onValidationFailureCalled = true)
34
+ .onException(() => onExceptionCalled = true);
35
+
36
+ it('should call the on success callback', () => onSuccessCalled.should.be.true);
37
+ it('should pass the response to the callback', () => receivedResponse!.should.equal(result.response));
38
+ it('should not call the on failed callback', () => onFailedCalled.should.be.false);
39
+ it('should not call the on unauthorized callback', () => onUnauthorizedCalled.should.be.false);
40
+ it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.false);
41
+ it('should not call the on exception callback', () => onExceptionCalled.should.be.false);
42
+ });
@@ -0,0 +1,43 @@
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 { CommandResult } from '../../CommandResult';
5
+
6
+ describe('when chaining callbacks and result is unauthorized', () => {
7
+ const result = new CommandResult({
8
+ correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
9
+ isSuccess: false,
10
+ isAuthorized: false,
11
+ isValid: true,
12
+ hasExceptions: false,
13
+ validationResults: [],
14
+ exceptionMessages: [],
15
+ exceptionStackTrace: '',
16
+ response: {}
17
+ }, Object, false);
18
+
19
+ let onSuccessCalled = false;
20
+ let onFailedCalled = false;
21
+ let receivedCommandResultOnFailed: CommandResult<object>;
22
+ let onUnauthorizedCalled = false;
23
+ let onValidationFailureCalled = false;
24
+ let onExceptionCalled = false;
25
+
26
+ result
27
+ .onSuccess(() => onSuccessCalled = true)
28
+ .onFailed((commandResult) => {
29
+ onFailedCalled = true;
30
+ receivedCommandResultOnFailed = commandResult;
31
+ })
32
+ .onUnauthorized(() => onUnauthorizedCalled = true)
33
+ .onValidationFailure(() => onValidationFailureCalled = true)
34
+ .onException(() => onExceptionCalled = true);
35
+
36
+ it('should not the on success callback', () => onSuccessCalled.should.be.false);
37
+ it('should call the on failed callback', () => onFailedCalled.should.be.true);
38
+ it('should forward the command result to the on failed callback', () => receivedCommandResultOnFailed.should.equal(result));
39
+ it('should call the on unauthorized callback', () => onUnauthorizedCalled.should.be.true);
40
+ it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.false);
41
+ it('should not call the on exception callback', () => onExceptionCalled.should.be.false);
42
+ });
43
+
@@ -0,0 +1,9 @@
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
+ export * from './ICommand';
5
+ export * from './Command';
6
+ export * from './ICommandResult';
7
+ export * from './CommandResult';
8
+ export * from './CommandResults';
9
+ export * from './CommandValidator';
package/deepEqual.ts ADDED
@@ -0,0 +1,23 @@
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
+ export const deepEqual = (obj1, obj2) => {
5
+ if (obj1 === obj2) return true; // Same reference or primitive value
6
+
7
+ if (obj1 == null || obj2 == null || typeof obj1 !== "object" || typeof obj2 !== "object") {
8
+ return false; // Handle null, undefined, or different types
9
+ }
10
+
11
+ const keys1 = Object.keys(obj1);
12
+ const keys2 = Object.keys(obj2);
13
+
14
+ if (keys1.length !== keys2.length) {
15
+ return false; // Different number of keys
16
+ }
17
+
18
+ for (const key of keys1) {
19
+ if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) return false;
20
+ }
21
+
22
+ return true; // All keys and values match
23
+ };
@@ -0,0 +1,2 @@
1
+ export type GetHttpHeaders = () => HeadersInit;
2
+ //# sourceMappingURL=GetHttpHeaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetHttpHeaders.d.ts","sourceRoot":"","sources":["../../GetHttpHeaders.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,cAAc,GAAG,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface IGlobals {
2
+ microservice: string;
3
+ microserviceHttpHeader: string;
4
+ microserviceWSQueryArgument: string;
5
+ }
6
+ export declare const Globals: IGlobals;
7
+ //# sourceMappingURL=Globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Globals.d.ts","sourceRoot":"","sources":["../../Globals.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,QAAQ;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;CACvC;AAED,eAAO,MAAM,OAAO,EAAE,QAIrB,CAAC"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const Globals = {
4
+ microservice: '',
5
+ microserviceHttpHeader: 'x-cratis-microservice',
6
+ microserviceWSQueryArgument: 'x-cratis-microservice'
7
+ };
8
+
9
+ exports.Globals = Globals;
10
+ //# sourceMappingURL=Globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Globals.js","sources":["../../Globals.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport interface IGlobals {\n microservice: string;\n microserviceHttpHeader: string;\n microserviceWSQueryArgument: string;\n}\n\nexport const Globals: IGlobals = {\n microservice: '',\n microserviceHttpHeader: 'x-cratis-microservice',\n microserviceWSQueryArgument: 'x-cratis-microservice'\n};"],"names":[],"mappings":";;AASO,MAAM,OAAO,GAAa;AAC7B,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,sBAAsB,EAAE,uBAAuB;AAC/C,IAAA,2BAA2B,EAAE;;;;;"}