@stancer/stancer 1.0.1 → 1.1.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 (371) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/dist/address/api-endpoint.d.ts +20 -0
  3. package/dist/address/api-endpoint.d.ts.map +1 -0
  4. package/dist/address/api-endpoint.js +28 -0
  5. package/dist/address/api-endpoint.js.map +1 -0
  6. package/dist/address/model.d.ts +35 -0
  7. package/dist/address/model.d.ts.map +1 -0
  8. package/dist/address/model.js +63 -0
  9. package/dist/address/model.js.map +1 -0
  10. package/dist/address/repository.d.ts +7 -0
  11. package/dist/address/repository.d.ts.map +1 -0
  12. package/dist/address/repository.js +14 -0
  13. package/dist/address/repository.js.map +1 -0
  14. package/dist/address/validator.d.ts +4 -0
  15. package/dist/address/validator.d.ts.map +1 -0
  16. package/dist/address/validator.js +32 -0
  17. package/dist/address/validator.js.map +1 -0
  18. package/dist/api-endpoint/abstract-api-endpoint.d.ts +46 -0
  19. package/dist/api-endpoint/abstract-api-endpoint.d.ts.map +1 -0
  20. package/dist/api-endpoint/abstract-api-endpoint.js +220 -0
  21. package/dist/api-endpoint/abstract-api-endpoint.js.map +1 -0
  22. package/dist/api-endpoint/configuration.d.ts +34 -0
  23. package/dist/api-endpoint/configuration.d.ts.map +1 -0
  24. package/dist/api-endpoint/configuration.js +99 -0
  25. package/dist/api-endpoint/configuration.js.map +1 -0
  26. package/dist/api-endpoint/http/fetch-http-client.d.ts +3 -0
  27. package/dist/api-endpoint/http/fetch-http-client.d.ts.map +1 -0
  28. package/dist/api-endpoint/http/fetch-http-client.js +34 -0
  29. package/dist/api-endpoint/http/fetch-http-client.js.map +1 -0
  30. package/dist/api-endpoint/http/http.d.ts +18 -0
  31. package/dist/api-endpoint/http/http.d.ts.map +1 -0
  32. package/dist/api-endpoint/http/http.js +47 -0
  33. package/dist/api-endpoint/http/http.js.map +1 -0
  34. package/dist/api-endpoint/http/index.d.ts +3 -0
  35. package/dist/api-endpoint/http/index.d.ts.map +1 -0
  36. package/dist/api-endpoint/http/index.js +3 -0
  37. package/dist/api-endpoint/http/index.js.map +1 -0
  38. package/dist/api-endpoint/version.d.ts +5 -0
  39. package/dist/api-endpoint/version.d.ts.map +1 -0
  40. package/dist/api-endpoint/version.js +6 -0
  41. package/dist/api-endpoint/version.js.map +1 -0
  42. package/dist/card/api-endpoint.d.ts +28 -0
  43. package/dist/card/api-endpoint.d.ts.map +1 -0
  44. package/dist/card/api-endpoint.js +37 -0
  45. package/dist/card/api-endpoint.js.map +1 -0
  46. package/dist/card/enum/funding.d.ts +3 -0
  47. package/dist/card/enum/funding.d.ts.map +1 -0
  48. package/dist/card/enum/funding.js +10 -0
  49. package/dist/card/enum/funding.js.map +1 -0
  50. package/dist/card/enum/nature.d.ts +3 -0
  51. package/dist/card/enum/nature.d.ts.map +1 -0
  52. package/dist/card/enum/nature.js +6 -0
  53. package/dist/card/enum/nature.js.map +1 -0
  54. package/dist/card/enum/network.d.ts +5 -0
  55. package/dist/card/enum/network.d.ts.map +1 -0
  56. package/dist/card/enum/network.js +12 -0
  57. package/dist/card/enum/network.js.map +1 -0
  58. package/dist/card/model.d.ts +55 -0
  59. package/dist/card/model.d.ts.map +1 -0
  60. package/dist/card/model.js +90 -0
  61. package/dist/card/model.js.map +1 -0
  62. package/dist/card/repository.d.ts +7 -0
  63. package/dist/card/repository.d.ts.map +1 -0
  64. package/dist/card/repository.js +10 -0
  65. package/dist/card/repository.js.map +1 -0
  66. package/dist/card/validator.d.ts +8 -0
  67. package/dist/card/validator.d.ts.map +1 -0
  68. package/dist/card/validator.js +71 -0
  69. package/dist/card/validator.js.map +1 -0
  70. package/dist/core/abstract-model.d.ts +51 -0
  71. package/dist/core/abstract-model.d.ts.map +1 -0
  72. package/dist/core/abstract-model.js +93 -0
  73. package/dist/core/abstract-model.js.map +1 -0
  74. package/dist/core/abstract-repository.d.ts +86 -0
  75. package/dist/core/abstract-repository.d.ts.map +1 -0
  76. package/dist/core/abstract-repository.js +97 -0
  77. package/dist/core/abstract-repository.js.map +1 -0
  78. package/dist/core/common/branded-type.d.ts +6 -0
  79. package/dist/core/common/branded-type.d.ts.map +1 -0
  80. package/dist/core/common/branded-type.js +9 -0
  81. package/dist/core/common/branded-type.js.map +1 -0
  82. package/dist/core/common/handler/date-handler.d.ts +5 -0
  83. package/dist/core/common/handler/date-handler.d.ts.map +1 -0
  84. package/dist/core/common/handler/date-handler.js +23 -0
  85. package/dist/core/common/handler/date-handler.js.map +1 -0
  86. package/dist/core/common/handler/enum-handler.d.ts +3 -0
  87. package/dist/core/common/handler/enum-handler.d.ts.map +1 -0
  88. package/dist/core/common/handler/enum-handler.js +14 -0
  89. package/dist/core/common/handler/enum-handler.js.map +1 -0
  90. package/dist/core/common/handler/handler.d.ts +24 -0
  91. package/dist/core/common/handler/handler.d.ts.map +1 -0
  92. package/dist/core/common/handler/handler.js +33 -0
  93. package/dist/core/common/handler/handler.js.map +1 -0
  94. package/dist/core/common/handler/id-handler.d.ts +4 -0
  95. package/dist/core/common/handler/id-handler.d.ts.map +1 -0
  96. package/dist/core/common/handler/id-handler.js +21 -0
  97. package/dist/core/common/handler/id-handler.js.map +1 -0
  98. package/dist/core/common/handler/metadata-handler.d.ts +18 -0
  99. package/dist/core/common/handler/metadata-handler.d.ts.map +1 -0
  100. package/dist/core/common/handler/metadata-handler.js +19 -0
  101. package/dist/core/common/handler/metadata-handler.js.map +1 -0
  102. package/dist/core/common/id-validator.d.ts +10 -0
  103. package/dist/core/common/id-validator.d.ts.map +1 -0
  104. package/dist/core/common/id-validator.js +17 -0
  105. package/dist/core/common/id-validator.js.map +1 -0
  106. package/dist/core/common/mutation-tracked-object.d.ts +8 -0
  107. package/dist/core/common/mutation-tracked-object.d.ts.map +1 -0
  108. package/dist/core/common/mutation-tracked-object.js +38 -0
  109. package/dist/core/common/mutation-tracked-object.js.map +1 -0
  110. package/dist/core/endpoint-interface.d.ts +38 -0
  111. package/dist/core/endpoint-interface.d.ts.map +1 -0
  112. package/dist/core/endpoint-interface.js +2 -0
  113. package/dist/core/endpoint-interface.js.map +1 -0
  114. package/dist/core/error/base-error.d.ts +3 -0
  115. package/dist/core/error/base-error.d.ts.map +1 -0
  116. package/dist/core/error/base-error.js +3 -0
  117. package/dist/core/error/base-error.js.map +1 -0
  118. package/dist/core/error/endpoint/api/api-conflict-error.d.ts +5 -0
  119. package/dist/core/error/endpoint/api/api-conflict-error.d.ts.map +1 -0
  120. package/dist/core/error/endpoint/api/api-conflict-error.js +7 -0
  121. package/dist/core/error/endpoint/api/api-conflict-error.js.map +1 -0
  122. package/dist/core/error/endpoint/api/api-error.d.ts +6 -0
  123. package/dist/core/error/endpoint/api/api-error.d.ts.map +1 -0
  124. package/dist/core/error/endpoint/api/api-error.js +9 -0
  125. package/dist/core/error/endpoint/api/api-error.js.map +1 -0
  126. package/dist/core/error/endpoint/api/api-not-found-error.d.ts +5 -0
  127. package/dist/core/error/endpoint/api/api-not-found-error.d.ts.map +1 -0
  128. package/dist/core/error/endpoint/api/api-not-found-error.js +7 -0
  129. package/dist/core/error/endpoint/api/api-not-found-error.js.map +1 -0
  130. package/dist/core/error/endpoint/api/api-unauthorized-error.d.ts +5 -0
  131. package/dist/core/error/endpoint/api/api-unauthorized-error.d.ts.map +1 -0
  132. package/dist/core/error/endpoint/api/api-unauthorized-error.js +7 -0
  133. package/dist/core/error/endpoint/api/api-unauthorized-error.js.map +1 -0
  134. package/dist/core/error/endpoint/api/api-unknown-error.d.ts +5 -0
  135. package/dist/core/error/endpoint/api/api-unknown-error.d.ts.map +1 -0
  136. package/dist/core/error/endpoint/api/api-unknown-error.js +7 -0
  137. package/dist/core/error/endpoint/api/api-unknown-error.js.map +1 -0
  138. package/dist/core/error/endpoint/api/api-validation-error.d.ts +11 -0
  139. package/dist/core/error/endpoint/api/api-validation-error.d.ts.map +1 -0
  140. package/dist/core/error/endpoint/api/api-validation-error.js +9 -0
  141. package/dist/core/error/endpoint/api/api-validation-error.js.map +1 -0
  142. package/dist/core/error/endpoint/api/index.d.ts +7 -0
  143. package/dist/core/error/endpoint/api/index.d.ts.map +1 -0
  144. package/dist/core/error/endpoint/api/index.js +7 -0
  145. package/dist/core/error/endpoint/api/index.js.map +1 -0
  146. package/dist/core/error/endpoint/route-inaccessible-error.d.ts +5 -0
  147. package/dist/core/error/endpoint/route-inaccessible-error.d.ts.map +1 -0
  148. package/dist/core/error/endpoint/route-inaccessible-error.js +8 -0
  149. package/dist/core/error/endpoint/route-inaccessible-error.js.map +1 -0
  150. package/dist/core/error/unpopulated-error.d.ts +4 -0
  151. package/dist/core/error/unpopulated-error.d.ts.map +1 -0
  152. package/dist/core/error/unpopulated-error.js +4 -0
  153. package/dist/core/error/unpopulated-error.js.map +1 -0
  154. package/dist/core/error/unsendable-error.d.ts +4 -0
  155. package/dist/core/error/unsendable-error.d.ts.map +1 -0
  156. package/dist/core/error/unsendable-error.js +4 -0
  157. package/dist/core/error/unsendable-error.js.map +1 -0
  158. package/dist/core/error/validation-error.d.ts +4 -0
  159. package/dist/core/error/validation-error.d.ts.map +1 -0
  160. package/dist/core/error/validation-error.js +4 -0
  161. package/dist/core/error/validation-error.js.map +1 -0
  162. package/dist/core/validator.d.ts +63 -0
  163. package/dist/core/validator.d.ts.map +1 -0
  164. package/dist/core/validator.js +73 -0
  165. package/dist/core/validator.js.map +1 -0
  166. package/dist/customer/api-endpoint.d.ts +21 -0
  167. package/dist/customer/api-endpoint.d.ts.map +1 -0
  168. package/dist/customer/api-endpoint.js +27 -0
  169. package/dist/customer/api-endpoint.js.map +1 -0
  170. package/dist/customer/model.d.ts +39 -0
  171. package/dist/customer/model.d.ts.map +1 -0
  172. package/dist/customer/model.js +73 -0
  173. package/dist/customer/model.js.map +1 -0
  174. package/dist/customer/repository.d.ts +7 -0
  175. package/dist/customer/repository.d.ts.map +1 -0
  176. package/dist/customer/repository.js +10 -0
  177. package/dist/customer/repository.js.map +1 -0
  178. package/dist/customer/validator.d.ts +4 -0
  179. package/dist/customer/validator.d.ts.map +1 -0
  180. package/dist/customer/validator.js +23 -0
  181. package/dist/customer/validator.js.map +1 -0
  182. package/dist/event/model.d.ts +20 -0
  183. package/dist/event/model.d.ts.map +1 -0
  184. package/dist/event/model.js +30 -0
  185. package/dist/event/model.js.map +1 -0
  186. package/dist/payment/api-endpoint.d.ts +51 -0
  187. package/dist/payment/api-endpoint.d.ts.map +1 -0
  188. package/dist/payment/api-endpoint.js +110 -0
  189. package/dist/payment/api-endpoint.js.map +1 -0
  190. package/dist/payment/enum/currency.d.ts +3 -0
  191. package/dist/payment/enum/currency.d.ts.map +1 -0
  192. package/dist/payment/enum/currency.js +13 -0
  193. package/dist/payment/enum/currency.js.map +1 -0
  194. package/dist/payment/enum/method.d.ts +3 -0
  195. package/dist/payment/enum/method.d.ts.map +1 -0
  196. package/dist/payment/enum/method.js +2 -0
  197. package/dist/payment/enum/method.js.map +1 -0
  198. package/dist/payment/enum/status.d.ts +4 -0
  199. package/dist/payment/enum/status.d.ts.map +1 -0
  200. package/dist/payment/enum/status.js +19 -0
  201. package/dist/payment/enum/status.js.map +1 -0
  202. package/dist/payment/model.d.ts +135 -0
  203. package/dist/payment/model.d.ts.map +1 -0
  204. package/dist/payment/model.js +232 -0
  205. package/dist/payment/model.js.map +1 -0
  206. package/dist/payment/repository.d.ts +17 -0
  207. package/dist/payment/repository.d.ts.map +1 -0
  208. package/dist/payment/repository.js +56 -0
  209. package/dist/payment/repository.js.map +1 -0
  210. package/dist/payment/validator.d.ts +16 -0
  211. package/dist/payment/validator.d.ts.map +1 -0
  212. package/dist/payment/validator.js +81 -0
  213. package/dist/payment/validator.js.map +1 -0
  214. package/dist/payment-intent/api-endpoint.d.ts +63 -0
  215. package/dist/payment-intent/api-endpoint.d.ts.map +1 -0
  216. package/dist/payment-intent/api-endpoint.js +95 -0
  217. package/dist/payment-intent/api-endpoint.js.map +1 -0
  218. package/dist/payment-intent/enum/status.d.ts +5 -0
  219. package/dist/payment-intent/enum/status.d.ts.map +1 -0
  220. package/dist/payment-intent/enum/status.js +20 -0
  221. package/dist/payment-intent/enum/status.js.map +1 -0
  222. package/dist/payment-intent/enum/threeds.d.ts +3 -0
  223. package/dist/payment-intent/enum/threeds.d.ts.map +1 -0
  224. package/dist/payment-intent/enum/threeds.js +2 -0
  225. package/dist/payment-intent/enum/threeds.js.map +1 -0
  226. package/dist/payment-intent/model.d.ts +91 -0
  227. package/dist/payment-intent/model.d.ts.map +1 -0
  228. package/dist/payment-intent/model.js +183 -0
  229. package/dist/payment-intent/model.js.map +1 -0
  230. package/dist/payment-intent/repository.d.ts +13 -0
  231. package/dist/payment-intent/repository.d.ts.map +1 -0
  232. package/dist/payment-intent/repository.js +65 -0
  233. package/dist/payment-intent/repository.js.map +1 -0
  234. package/dist/payment-intent/validator.d.ts +4 -0
  235. package/dist/payment-intent/validator.d.ts.map +1 -0
  236. package/dist/payment-intent/validator.js +38 -0
  237. package/dist/payment-intent/validator.js.map +1 -0
  238. package/dist/payout/model.d.ts +7 -0
  239. package/dist/payout/model.d.ts.map +1 -0
  240. package/dist/payout/model.js +6 -0
  241. package/dist/payout/model.js.map +1 -0
  242. package/dist/refund/api-endpoint.d.ts +22 -0
  243. package/dist/refund/api-endpoint.d.ts.map +1 -0
  244. package/dist/refund/api-endpoint.js +32 -0
  245. package/dist/refund/api-endpoint.js.map +1 -0
  246. package/dist/refund/enum/refund-status.d.ts +3 -0
  247. package/dist/refund/enum/refund-status.d.ts.map +1 -0
  248. package/dist/refund/enum/refund-status.js +10 -0
  249. package/dist/refund/enum/refund-status.js.map +1 -0
  250. package/dist/refund/model.d.ts +38 -0
  251. package/dist/refund/model.d.ts.map +1 -0
  252. package/dist/refund/model.js +51 -0
  253. package/dist/refund/model.js.map +1 -0
  254. package/dist/refund/repository.d.ts +7 -0
  255. package/dist/refund/repository.d.ts.map +1 -0
  256. package/dist/refund/repository.js +10 -0
  257. package/dist/refund/repository.js.map +1 -0
  258. package/dist/refund/validator.d.ts +4 -0
  259. package/dist/refund/validator.d.ts.map +1 -0
  260. package/dist/refund/validator.js +41 -0
  261. package/dist/refund/validator.js.map +1 -0
  262. package/dist/sepa/api-endpoint.d.ts +19 -0
  263. package/dist/sepa/api-endpoint.d.ts.map +1 -0
  264. package/dist/sepa/api-endpoint.js +25 -0
  265. package/dist/sepa/api-endpoint.js.map +1 -0
  266. package/dist/sepa/model.d.ts +32 -0
  267. package/dist/sepa/model.d.ts.map +1 -0
  268. package/dist/sepa/model.js +53 -0
  269. package/dist/sepa/model.js.map +1 -0
  270. package/dist/sepa/repository.d.ts +7 -0
  271. package/dist/sepa/repository.d.ts.map +1 -0
  272. package/dist/sepa/repository.js +10 -0
  273. package/dist/sepa/repository.js.map +1 -0
  274. package/dist/sepa/validator.d.ts +8 -0
  275. package/dist/sepa/validator.d.ts.map +1 -0
  276. package/dist/sepa/validator.js +47 -0
  277. package/dist/sepa/validator.js.map +1 -0
  278. package/dist/webhook/api-endpoint.d.ts +16 -0
  279. package/dist/webhook/api-endpoint.d.ts.map +1 -0
  280. package/dist/webhook/api-endpoint.js +33 -0
  281. package/dist/webhook/api-endpoint.js.map +1 -0
  282. package/dist/webhook/model.d.ts +35 -0
  283. package/dist/webhook/model.d.ts.map +1 -0
  284. package/dist/webhook/model.js +110 -0
  285. package/dist/webhook/model.js.map +1 -0
  286. package/dist/webhook/repository.d.ts +7 -0
  287. package/dist/webhook/repository.d.ts.map +1 -0
  288. package/dist/webhook/repository.js +10 -0
  289. package/dist/webhook/repository.js.map +1 -0
  290. package/dist/webhook/validator.d.ts +4 -0
  291. package/dist/webhook/validator.d.ts.map +1 -0
  292. package/dist/webhook/validator.js +16 -0
  293. package/dist/webhook/validator.js.map +1 -0
  294. package/package.json +4 -2
  295. package/src/api-endpoint/http/fetch-http-client.ts +8 -1
  296. package/src/core/common/handler/metadata-handler.ts +19 -0
  297. package/src/event/model.ts +42 -0
  298. package/src/payment-intent/api-endpoint.ts +2 -1
  299. package/src/payment-intent/model.ts +8 -3
  300. package/src/webhook/api-endpoint.ts +36 -0
  301. package/src/webhook/model.ts +140 -0
  302. package/src/webhook/repository.ts +14 -0
  303. package/src/webhook/validator.ts +18 -0
  304. package/.editorconfig +0 -14
  305. package/.gitlab-ci.yml +0 -159
  306. package/.prettierignore +0 -3
  307. package/eslint.config.js +0 -14
  308. package/pnpm-workspace.yaml +0 -19
  309. package/prettier.config.js +0 -3
  310. package/test/fixtures/endpoint.stub.ts +0 -22
  311. package/test/fixtures/list-endpoint.stub.ts +0 -33
  312. package/test/fixtures/list-model.stub.ts +0 -24
  313. package/test/fixtures/model.stub.ts +0 -12
  314. package/test/functional/address.test.ts +0 -126
  315. package/test/functional/card.test.ts +0 -175
  316. package/test/functional/customer.test.ts +0 -174
  317. package/test/functional/payment-intent.test.ts +0 -215
  318. package/test/functional/payment.test.ts +0 -206
  319. package/test/functional/refund.test.ts +0 -112
  320. package/test/functional/sepa.test.ts +0 -136
  321. package/test/integration/stub-integration.test.ts +0 -88
  322. package/test/stub/stub-endpoint.ts +0 -42
  323. package/test/stub/stub-model.ts +0 -82
  324. package/test/stub/stub-repository.ts +0 -11
  325. package/test/test-helper.ts +0 -133
  326. package/test/unit/address/api-endpoint.test.ts +0 -134
  327. package/test/unit/address/fixtures.ts +0 -60
  328. package/test/unit/address/model.test.ts +0 -75
  329. package/test/unit/address/repository.test.ts +0 -148
  330. package/test/unit/address/validator.test.ts +0 -49
  331. package/test/unit/api-endpoint/http/fetch-http-client.test.ts +0 -44
  332. package/test/unit/api-endpoint/http/http.test.ts +0 -152
  333. package/test/unit/card/api-endpoint.test.ts +0 -170
  334. package/test/unit/card/card-helper.ts +0 -116
  335. package/test/unit/card/fixtures.ts +0 -87
  336. package/test/unit/card/model.test.ts +0 -167
  337. package/test/unit/card/repository.test.ts +0 -146
  338. package/test/unit/card/validator.test.ts +0 -96
  339. package/test/unit/core/common/mutation-tracked-object.test.ts +0 -24
  340. package/test/unit/customer/api-endpoint.test.ts +0 -143
  341. package/test/unit/customer/fixtures.ts +0 -73
  342. package/test/unit/customer/model.test.ts +0 -90
  343. package/test/unit/customer/repository.test.ts +0 -148
  344. package/test/unit/customer/validator.test.ts +0 -62
  345. package/test/unit/payment/api-endpoint.test.ts +0 -188
  346. package/test/unit/payment/fixtures.ts +0 -116
  347. package/test/unit/payment/model.test.ts +0 -240
  348. package/test/unit/payment/repository.test.ts +0 -270
  349. package/test/unit/payment/validator.test.ts +0 -137
  350. package/test/unit/payment-intent/api-endpoint.test.ts +0 -142
  351. package/test/unit/payment-intent/fixtures.ts +0 -94
  352. package/test/unit/payment-intent/model.test.ts +0 -157
  353. package/test/unit/payment-intent/repository.test.ts +0 -263
  354. package/test/unit/payment-intent/validator.test.ts +0 -136
  355. package/test/unit/refund/api-endpoint.test.ts +0 -129
  356. package/test/unit/refund/fixtures.ts +0 -58
  357. package/test/unit/refund/model.test.ts +0 -89
  358. package/test/unit/refund/repository.test.ts +0 -157
  359. package/test/unit/refund/validator.test.ts +0 -89
  360. package/test/unit/sepa/api-endpoint.test.ts +0 -170
  361. package/test/unit/sepa/fixture.ts +0 -62
  362. package/test/unit/sepa/model.test.ts +0 -86
  363. package/test/unit/sepa/repository.test.ts +0 -149
  364. package/test/unit/sepa/sepa-helper.ts +0 -71
  365. package/test/unit/sepa/validator.test.ts +0 -58
  366. package/test/unit/stub/stub-endpoint.test.ts +0 -236
  367. package/test/unit/stub/stub-list-endpoint.test.ts +0 -86
  368. package/test/unit/stub/stub-model.test.ts +0 -111
  369. package/test/unit/stub/stub-repository.test.ts +0 -144
  370. package/tsconfig.json +0 -50
  371. package/vitest.config.ts +0 -20
@@ -1,111 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { StancerValidationError } from '#error/validation-error.js';
4
- import { IdStub, StubData, StubModel, StubValidator } from '#test/stub/stub-model.js';
5
- import { randomNumber, randomString } from '#test/test-helper.js';
6
-
7
- describe('stub model', () => {
8
- describe('constructor', () => {
9
- it('should be created without anything', () => {
10
- const stub = new StubModel(StubValidator);
11
- expect(stub.id).toBeUndefined();
12
- expect(stub._data).toEqual({});
13
- });
14
-
15
- it('should be created with good ID', () => {
16
- const id = 'stub_' + randomString(24, 24);
17
- const stub = new StubModel(StubValidator, id);
18
- expect(stub.id).toEqual(id);
19
- expect(stub._data).toEqual({ id: id });
20
- expect(stub._data.getMutations()).toStrictEqual({ id });
21
- });
22
-
23
- it("shouldn't be created with bad ID", () => {
24
- const id = randomString(22, 24);
25
- expect(() => new StubModel(StubValidator, id)).toThrow();
26
- });
27
-
28
- it("shouldn't accept custom bad data", () => {
29
- const data: Partial<StubData> = {
30
- id: randomString(24, 25) as IdStub,
31
- default: randomString(12, 25),
32
- };
33
- expect(() => new StubModel(StubValidator, data)).toThrow();
34
- });
35
-
36
- it('should accept custom good data', () => {
37
- const id = ('stub_' + randomString(24)) as IdStub;
38
- const defaultValue = randomString(28, 32);
39
- const data: Partial<StubData> = {
40
- id,
41
- default: defaultValue,
42
- };
43
- const stub = new StubModel(StubValidator, data);
44
- expect(stub._data).toEqual(data);
45
- });
46
- });
47
-
48
- describe('Id setter', () => {
49
- it('should accept good Id', () => {
50
- const id = 'stub_' + randomString(24, 24);
51
- const stub = new StubModel(StubValidator, id);
52
- expect(stub._data.id).toStrictEqual(id);
53
- expect(stub.id).toStrictEqual(id);
54
- });
55
-
56
- it('should refuse bad ID', () => {
57
- const falseId = randomString(12, 24);
58
- expect(() => new StubModel(StubValidator, falseId)).toThrow(StancerValidationError);
59
- });
60
- });
61
-
62
- describe('default setter', () => {
63
- it('should accept good string length', () => {
64
- const stub = new StubModel(StubValidator);
65
- const defaultValue = randomString(1, 63);
66
- stub.setDefault(defaultValue);
67
- expect(stub.default).toBe(defaultValue);
68
- });
69
-
70
- it("shouldn't accept bad value", () => {
71
- const stub = new StubModel(StubValidator);
72
- //We want to hard prevent bad typing
73
- expect(() => stub.setDefault(12)).toThrow();
74
- expect(() => stub.setDefault(randomString(65, 100))).toThrow();
75
- });
76
- });
77
-
78
- describe('DefaultNumber setter', () => {
79
- it('should accept good number', () => {
80
- const stub = new StubModel(StubValidator);
81
- const defaultNumber = randomNumber(1, 263);
82
- stub.setDefaultNumber(defaultNumber);
83
- expect(stub.defaultNumber).toBe(defaultNumber);
84
- });
85
-
86
- it("shouldn't accept bad value", () => {
87
- const stub = new StubModel(StubValidator);
88
- const defaultNumber = randomNumber(265, 30000);
89
- expect(() => stub.setDefaultNumber(defaultNumber)).toThrow();
90
- expect(() => stub.setDefaultNumber('string')).toThrow();
91
- });
92
- });
93
-
94
- describe('boolean property', () => {
95
- it('should accept boolean', () => {
96
- const stub = new StubModel(StubValidator);
97
- const boolValue = true;
98
- stub.setUngettable(boolValue);
99
- expect(stub._data.ungettable).toBe(boolValue);
100
- stub.setAllAuthorized(boolValue);
101
- expect(stub.allAuthorized).toBe(boolValue);
102
- });
103
-
104
- it('should have gettable property', () => {
105
- const stub = new StubModel(StubValidator);
106
- // direct accession to _data is not validated
107
- stub._data.unmodifiable = true;
108
- expect(stub.unmodifiable).toBe(true);
109
- });
110
- });
111
- });
@@ -1,144 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
-
3
- import { AbstractRepository } from '#core/abstract-repository.js';
4
- import { IdValue } from '#core/common/branded-type.js';
5
- import { StancerError } from '#error/base-error.js';
6
- import { StancerRouteInaccessibleError } from '#error/endpoint/route-inaccessible-error.js';
7
- import ListModelFixtures from '#test/fixtures/list-model.stub.js';
8
- import ModelFixtures from '#test/fixtures/model.stub.js';
9
- import { StubEndpoint } from '#test/stub/stub-endpoint.js';
10
- import { IdStub, StubModel, StubValidator } from '#test/stub/stub-model.js';
11
- import { StubRepository } from '#test/stub/stub-repository.js';
12
- import { randomNumber, randomString } from '#test/test-helper.js';
13
-
14
- const stancerErrorID = 'stub_unidentifiedError' + randomString(7);
15
- const stancerRouteInaccessibleId = 'stub_StancerRouteInnacessible';
16
- const dataHasBeenSentId = 'stub_DataHasBeenSent' + randomString(9);
17
- const dataUnmodified = 'stub_unmodifiedData' + randomString(10);
18
- class MockApiEndpoint {
19
- constructor() {}
20
- list() {
21
- async function* listGenerator() {
22
- yield* ListModelFixtures;
23
- }
24
- return listGenerator();
25
- }
26
- delete() {
27
- return ModelFixtures;
28
- }
29
- send(id: IdValue, data: Record<string, unknown>) {
30
- if (id) {
31
- if (id === stancerErrorID) {
32
- throw new StancerError();
33
- }
34
- if (id === stancerRouteInaccessibleId) {
35
- throw new StancerRouteInaccessibleError('PATCH', 'stub');
36
- }
37
- if (id === dataUnmodified) {
38
- return;
39
- }
40
- }
41
- return { ...data, id: dataHasBeenSentId };
42
- }
43
- get() {
44
- return ModelFixtures;
45
- }
46
- }
47
- it('can be instanciated', () => {
48
- const instance = new StubRepository();
49
- expect(instance).toBeInstanceOf(StubRepository);
50
- expect(instance).toBeInstanceOf(AbstractRepository);
51
- expect(instance.endpoint).toBeInstanceOf(StubEndpoint);
52
- expect(instance.validator).toBe(StubValidator);
53
- expect(instance.staticModel).toBe(StubModel);
54
- });
55
-
56
- describe('repository', () => {
57
- const mockRepo = new MockApiEndpoint() as unknown as StubEndpoint; // I lie, for convenience sake
58
- const repository = new StubRepository(mockRepo);
59
-
60
- describe('create', () => {
61
- it("doesn't accept bad data", async () => {
62
- const badID = randomString(30, 56);
63
- await expect(async () => await repository.create(badID)).rejects.toThrow();
64
- const badID2 = randomNumber(1, 12);
65
- await expect(async () => await repository.create(badID2)).rejects.toThrow();
66
- const badData = { default: randomNumber(1, 12) };
67
- await expect(async () => await repository.create(badData)).rejects.toThrow();
68
- });
69
-
70
- it('accept good data', async () => {
71
- const id = 'stub_' + randomString(24);
72
- const model = await repository.create(id);
73
- expect(model).toBeInstanceOf(StubModel);
74
- });
75
- });
76
-
77
- it('delete', async () => {
78
- const modelWithoutId = await repository.create(ModelFixtures);
79
- await expect(() => repository.delete(modelWithoutId)).rejects.toThrow();
80
-
81
- const model = await repository.create({ ...ModelFixtures, id: ('stub_' + randomString(24)) as IdStub });
82
- await expect((await repository.delete(model))._data).toStrictEqual(ModelFixtures);
83
- });
84
-
85
- describe('send', () => {
86
- it('should return model', async () => {
87
- const model = await repository.create(ModelFixtures);
88
- const sentModel = await repository.send(model);
89
- expect(sentModel).toStrictEqual(model);
90
- expect(sentModel._data.id).toEqual(dataHasBeenSentId);
91
- });
92
-
93
- it('should throw on inprecise error', async () => {
94
- const model = await repository.create({ ...ModelFixtures, id: stancerErrorID as IdStub });
95
- await expect(() => repository.send(model)).rejects.toThrow(StancerError);
96
- });
97
-
98
- it('should return error on StancerRouteInacessibleError', async () => {
99
- const model = await repository.create({ ...ModelFixtures, id: stancerRouteInaccessibleId as IdStub });
100
- await expect(async () => await repository.send(model)).rejects.toThrow(StancerRouteInaccessibleError);
101
- });
102
-
103
- it('should return unmodified model when no new Data', async () => {
104
- const model = await repository.create({ ...ModelFixtures, id: dataUnmodified as IdStub });
105
- const sentModel = await repository.send(model);
106
- expect(model).toStrictEqual(sentModel);
107
- expect(sentModel._data.id).toEqual(dataUnmodified);
108
- });
109
- });
110
-
111
- describe('populate', () => {
112
- it('should not modify model if no Id', async () => {
113
- const getEndpoint = vi.spyOn(mockRepo, 'get');
114
- const model = await repository.create(ModelFixtures);
115
- expect(model).toBeInstanceOf(StubModel);
116
- expect(getEndpoint).toHaveBeenCalledTimes(0);
117
- });
118
-
119
- it('should get model if only id', async () => {
120
- const getEndpoint = vi.spyOn(mockRepo, 'get');
121
- const model = await repository.create(('stub_' + randomString(24)) as IdStub);
122
- expect(model).toBeInstanceOf(StubModel);
123
- expect(getEndpoint).toHaveBeenCalledTimes(1);
124
- });
125
- });
126
-
127
- describe('list', async () => {
128
- it('return correct model one by one', async () => {
129
- const listStub = repository.list();
130
- const item1 = await listStub.next();
131
- expect(item1.done).toBeFalsy();
132
- expect(item1.value).toHaveProperty('id');
133
- expect(item1.value).toBeInstanceOf(StubModel);
134
-
135
- const item2 = await listStub.next();
136
- expect(item2.done).toBeFalsy();
137
- expect(item2.value).toHaveProperty('id');
138
- expect(item2.value).toBeInstanceOf(StubModel);
139
-
140
- const item3 = await listStub.next();
141
- expect(item3.done).toBeTruthy();
142
- });
143
- });
144
- });
package/tsconfig.json DELETED
@@ -1,50 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "declarationMap": true,
5
- "esModuleInterop": true,
6
- "exactOptionalPropertyTypes": true,
7
- "isolatedModules": true,
8
- "lib": [
9
- "ESNext"
10
- ],
11
- "module": "NodeNext",
12
- "moduleDetection": "force",
13
- "noFallthroughCasesInSwitch": true,
14
- "noImplicitOverride": true,
15
- "noImplicitReturns": true,
16
- "noPropertyAccessFromIndexSignature": true,
17
- "noUncheckedIndexedAccess": true,
18
- "noUncheckedSideEffectImports": true,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "outDir": "./dist",
22
- "paths": {
23
- "#api/*": [
24
- "./src/api-endpoint/*"
25
- ],
26
- "#error/*": [
27
- "./src/core/error/*"
28
- ],
29
- "#core/*": [
30
- "./src/core/*"
31
- ],
32
- "#test/*": [
33
- "./test/*"
34
- ]
35
- },
36
- "resolveJsonModule": true,
37
- "rootDir": "./src",
38
- "skipLibCheck": true,
39
- "sourceMap": true,
40
- "strict": true,
41
- "target": "ESNext",
42
- "types": [
43
- "node"
44
- ],
45
- "verbatimModuleSyntax": true
46
- },
47
- "include": [
48
- "./src/"
49
- ]
50
- }
package/vitest.config.ts DELETED
@@ -1,20 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- coverage: {
6
- enabled: true,
7
- exclude: [
8
- '**/dist',
9
- '**/*.config.ts',
10
- '**/*.ignore.ts',
11
- '**/*.js',
12
- ],
13
- provider: 'v8',
14
- reporter: ['cobertura', 'html', 'text'],
15
- reportsDirectory: 'reports/',
16
- },
17
- outputFile: 'reports/junit.xml',
18
- reporters: ['default', 'junit'],
19
- },
20
- });