@temboplus/frontend-core 0.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 (261) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +72 -0
  3. package/esm/_dnt.test_shims.d.ts.map +1 -0
  4. package/esm/deps/deno.land/std@0.217.0/assert/_constants.d.ts.map +1 -0
  5. package/esm/deps/deno.land/std@0.217.0/assert/_diff.d.ts.map +1 -0
  6. package/esm/deps/deno.land/std@0.217.0/assert/_format.d.ts.map +1 -0
  7. package/esm/deps/deno.land/std@0.217.0/assert/assert.d.ts.map +1 -0
  8. package/esm/deps/deno.land/std@0.217.0/assert/assert_almost_equals.d.ts.map +1 -0
  9. package/esm/deps/deno.land/std@0.217.0/assert/assert_array_includes.d.ts.map +1 -0
  10. package/esm/deps/deno.land/std@0.217.0/assert/assert_equals.d.ts.map +1 -0
  11. package/esm/deps/deno.land/std@0.217.0/assert/assert_exists.d.ts.map +1 -0
  12. package/esm/deps/deno.land/std@0.217.0/assert/assert_false.d.ts.map +1 -0
  13. package/esm/deps/deno.land/std@0.217.0/assert/assert_greater.d.ts.map +1 -0
  14. package/esm/deps/deno.land/std@0.217.0/assert/assert_greater_or_equal.d.ts.map +1 -0
  15. package/esm/deps/deno.land/std@0.217.0/assert/assert_instance_of.d.ts.map +1 -0
  16. package/esm/deps/deno.land/std@0.217.0/assert/assert_is_error.d.ts.map +1 -0
  17. package/esm/deps/deno.land/std@0.217.0/assert/assert_less.d.ts.map +1 -0
  18. package/esm/deps/deno.land/std@0.217.0/assert/assert_less_or_equal.d.ts.map +1 -0
  19. package/esm/deps/deno.land/std@0.217.0/assert/assert_match.d.ts.map +1 -0
  20. package/esm/deps/deno.land/std@0.217.0/assert/assert_not_equals.d.ts.map +1 -0
  21. package/esm/deps/deno.land/std@0.217.0/assert/assert_not_instance_of.d.ts.map +1 -0
  22. package/esm/deps/deno.land/std@0.217.0/assert/assert_not_match.d.ts.map +1 -0
  23. package/esm/deps/deno.land/std@0.217.0/assert/assert_not_strict_equals.d.ts.map +1 -0
  24. package/esm/deps/deno.land/std@0.217.0/assert/assert_object_match.d.ts.map +1 -0
  25. package/esm/deps/deno.land/std@0.217.0/assert/assert_rejects.d.ts.map +1 -0
  26. package/esm/deps/deno.land/std@0.217.0/assert/assert_strict_equals.d.ts.map +1 -0
  27. package/esm/deps/deno.land/std@0.217.0/assert/assert_string_includes.d.ts.map +1 -0
  28. package/esm/deps/deno.land/std@0.217.0/assert/assert_throws.d.ts.map +1 -0
  29. package/esm/deps/deno.land/std@0.217.0/assert/assertion_error.d.ts.map +1 -0
  30. package/esm/deps/deno.land/std@0.217.0/assert/equal.d.ts.map +1 -0
  31. package/esm/deps/deno.land/std@0.217.0/assert/fail.d.ts.map +1 -0
  32. package/esm/deps/deno.land/std@0.217.0/assert/mod.d.ts.map +1 -0
  33. package/esm/deps/deno.land/std@0.217.0/assert/unimplemented.d.ts.map +1 -0
  34. package/esm/deps/deno.land/std@0.217.0/assert/unreachable.d.ts.map +1 -0
  35. package/esm/deps/deno.land/std@0.217.0/fmt/colors.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
  37. package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
  38. package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
  40. package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
  41. package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
  43. package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
  44. package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
  46. package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
  49. package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
  50. package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
  52. package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
  53. package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
  55. package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
  56. package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
  58. package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
  60. package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
  61. package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
  62. package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
  64. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  65. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  68. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  69. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  70. package/esm/mod.d.ts +3 -0
  71. package/esm/mod.d.ts.map +1 -0
  72. package/esm/mod.js +2 -0
  73. package/esm/package.json +3 -0
  74. package/esm/src/models/amount/amount.d.ts +55 -0
  75. package/esm/src/models/amount/amount.d.ts.map +1 -0
  76. package/esm/src/models/amount/amount.js +229 -0
  77. package/esm/src/models/amount/amount.test.d.ts.map +1 -0
  78. package/esm/src/models/amount/antd_validator.d.ts +40 -0
  79. package/esm/src/models/amount/antd_validator.d.ts.map +1 -0
  80. package/esm/src/models/amount/antd_validator.js +58 -0
  81. package/esm/src/models/amount/antd_validator.test.d.ts.map +1 -0
  82. package/esm/src/models/amount/index.d.ts +3 -0
  83. package/esm/src/models/amount/index.d.ts.map +1 -0
  84. package/esm/src/models/amount/index.js +2 -0
  85. package/esm/src/models/bank/antd_validator.d.ts +11 -0
  86. package/esm/src/models/bank/antd_validator.d.ts.map +1 -0
  87. package/esm/src/models/bank/antd_validator.js +26 -0
  88. package/esm/src/models/bank/antd_validator.test.d.ts.map +1 -0
  89. package/esm/src/models/bank/bank.d.ts +125 -0
  90. package/esm/src/models/bank/bank.d.ts.map +1 -0
  91. package/esm/src/models/bank/bank.js +229 -0
  92. package/esm/src/models/bank/bank.test.d.ts.map +1 -0
  93. package/esm/src/models/bank/banks.d.ts +7 -0
  94. package/esm/src/models/bank/banks.d.ts.map +1 -0
  95. package/esm/src/models/bank/banks.js +197 -0
  96. package/esm/src/models/bank/index.d.ts +4 -0
  97. package/esm/src/models/bank/index.d.ts.map +1 -0
  98. package/esm/src/models/bank/index.js +3 -0
  99. package/esm/src/models/bank/utils.d.ts +25 -0
  100. package/esm/src/models/bank/utils.d.ts.map +1 -0
  101. package/esm/src/models/bank/utils.js +35 -0
  102. package/esm/src/models/index.d.ts +4 -0
  103. package/esm/src/models/index.d.ts.map +1 -0
  104. package/esm/src/models/index.js +3 -0
  105. package/esm/src/models/phone_number/antd_validator.d.ts +77 -0
  106. package/esm/src/models/phone_number/antd_validator.d.ts.map +1 -0
  107. package/esm/src/models/phone_number/antd_validator.js +90 -0
  108. package/esm/src/models/phone_number/antdvalidator.test.d.ts.map +1 -0
  109. package/esm/src/models/phone_number/index.d.ts +4 -0
  110. package/esm/src/models/phone_number/index.d.ts.map +1 -0
  111. package/esm/src/models/phone_number/index.js +3 -0
  112. package/esm/src/models/phone_number/phone_number.d.ts +117 -0
  113. package/esm/src/models/phone_number/phone_number.d.ts.map +1 -0
  114. package/esm/src/models/phone_number/phone_number.js +231 -0
  115. package/esm/src/models/phone_number/phone_number.test.d.ts.map +1 -0
  116. package/esm/src/models/phone_number/telecom.d.ts +25 -0
  117. package/esm/src/models/phone_number/telecom.d.ts.map +1 -0
  118. package/esm/src/models/phone_number/telecom.js +44 -0
  119. package/esm/src/utils/id.d.ts +12 -0
  120. package/esm/src/utils/id.d.ts.map +1 -0
  121. package/esm/src/utils/id.js +19 -0
  122. package/esm/src/utils/index.d.ts +4 -0
  123. package/esm/src/utils/index.d.ts.map +1 -0
  124. package/esm/src/utils/index.js +3 -0
  125. package/esm/src/utils/text.d.ts +32 -0
  126. package/esm/src/utils/text.d.ts.map +1 -0
  127. package/esm/src/utils/text.js +68 -0
  128. package/esm/src/utils/text.test.d.ts.map +1 -0
  129. package/esm/src/utils/time.d.ts +21 -0
  130. package/esm/src/utils/time.d.ts.map +1 -0
  131. package/esm/src/utils/time.js +34 -0
  132. package/package.json +35 -0
  133. package/script/_dnt.test_shims.d.ts.map +1 -0
  134. package/script/deps/deno.land/std@0.217.0/assert/_constants.d.ts.map +1 -0
  135. package/script/deps/deno.land/std@0.217.0/assert/_diff.d.ts.map +1 -0
  136. package/script/deps/deno.land/std@0.217.0/assert/_format.d.ts.map +1 -0
  137. package/script/deps/deno.land/std@0.217.0/assert/assert.d.ts.map +1 -0
  138. package/script/deps/deno.land/std@0.217.0/assert/assert_almost_equals.d.ts.map +1 -0
  139. package/script/deps/deno.land/std@0.217.0/assert/assert_array_includes.d.ts.map +1 -0
  140. package/script/deps/deno.land/std@0.217.0/assert/assert_equals.d.ts.map +1 -0
  141. package/script/deps/deno.land/std@0.217.0/assert/assert_exists.d.ts.map +1 -0
  142. package/script/deps/deno.land/std@0.217.0/assert/assert_false.d.ts.map +1 -0
  143. package/script/deps/deno.land/std@0.217.0/assert/assert_greater.d.ts.map +1 -0
  144. package/script/deps/deno.land/std@0.217.0/assert/assert_greater_or_equal.d.ts.map +1 -0
  145. package/script/deps/deno.land/std@0.217.0/assert/assert_instance_of.d.ts.map +1 -0
  146. package/script/deps/deno.land/std@0.217.0/assert/assert_is_error.d.ts.map +1 -0
  147. package/script/deps/deno.land/std@0.217.0/assert/assert_less.d.ts.map +1 -0
  148. package/script/deps/deno.land/std@0.217.0/assert/assert_less_or_equal.d.ts.map +1 -0
  149. package/script/deps/deno.land/std@0.217.0/assert/assert_match.d.ts.map +1 -0
  150. package/script/deps/deno.land/std@0.217.0/assert/assert_not_equals.d.ts.map +1 -0
  151. package/script/deps/deno.land/std@0.217.0/assert/assert_not_instance_of.d.ts.map +1 -0
  152. package/script/deps/deno.land/std@0.217.0/assert/assert_not_match.d.ts.map +1 -0
  153. package/script/deps/deno.land/std@0.217.0/assert/assert_not_strict_equals.d.ts.map +1 -0
  154. package/script/deps/deno.land/std@0.217.0/assert/assert_object_match.d.ts.map +1 -0
  155. package/script/deps/deno.land/std@0.217.0/assert/assert_rejects.d.ts.map +1 -0
  156. package/script/deps/deno.land/std@0.217.0/assert/assert_strict_equals.d.ts.map +1 -0
  157. package/script/deps/deno.land/std@0.217.0/assert/assert_string_includes.d.ts.map +1 -0
  158. package/script/deps/deno.land/std@0.217.0/assert/assert_throws.d.ts.map +1 -0
  159. package/script/deps/deno.land/std@0.217.0/assert/assertion_error.d.ts.map +1 -0
  160. package/script/deps/deno.land/std@0.217.0/assert/equal.d.ts.map +1 -0
  161. package/script/deps/deno.land/std@0.217.0/assert/fail.d.ts.map +1 -0
  162. package/script/deps/deno.land/std@0.217.0/assert/mod.d.ts.map +1 -0
  163. package/script/deps/deno.land/std@0.217.0/assert/unimplemented.d.ts.map +1 -0
  164. package/script/deps/deno.land/std@0.217.0/assert/unreachable.d.ts.map +1 -0
  165. package/script/deps/deno.land/std@0.217.0/fmt/colors.d.ts.map +1 -0
  166. package/script/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
  167. package/script/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
  168. package/script/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
  169. package/script/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
  170. package/script/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
  171. package/script/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
  172. package/script/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
  173. package/script/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
  174. package/script/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
  175. package/script/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
  176. package/script/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
  177. package/script/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
  178. package/script/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
  179. package/script/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
  180. package/script/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
  181. package/script/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
  182. package/script/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
  183. package/script/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
  184. package/script/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
  185. package/script/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
  186. package/script/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
  187. package/script/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
  188. package/script/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
  189. package/script/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
  190. package/script/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
  191. package/script/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
  192. package/script/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
  193. package/script/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
  194. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  195. package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  196. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  197. package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  198. package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  199. package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  200. package/script/mod.d.ts +3 -0
  201. package/script/mod.d.ts.map +1 -0
  202. package/script/mod.js +18 -0
  203. package/script/package.json +3 -0
  204. package/script/src/models/amount/amount.d.ts +55 -0
  205. package/script/src/models/amount/amount.d.ts.map +1 -0
  206. package/script/src/models/amount/amount.js +233 -0
  207. package/script/src/models/amount/amount.test.d.ts.map +1 -0
  208. package/script/src/models/amount/antd_validator.d.ts +40 -0
  209. package/script/src/models/amount/antd_validator.d.ts.map +1 -0
  210. package/script/src/models/amount/antd_validator.js +62 -0
  211. package/script/src/models/amount/antd_validator.test.d.ts.map +1 -0
  212. package/script/src/models/amount/index.d.ts +3 -0
  213. package/script/src/models/amount/index.d.ts.map +1 -0
  214. package/script/src/models/amount/index.js +18 -0
  215. package/script/src/models/bank/antd_validator.d.ts +11 -0
  216. package/script/src/models/bank/antd_validator.d.ts.map +1 -0
  217. package/script/src/models/bank/antd_validator.js +30 -0
  218. package/script/src/models/bank/antd_validator.test.d.ts.map +1 -0
  219. package/script/src/models/bank/bank.d.ts +125 -0
  220. package/script/src/models/bank/bank.d.ts.map +1 -0
  221. package/script/src/models/bank/bank.js +236 -0
  222. package/script/src/models/bank/bank.test.d.ts.map +1 -0
  223. package/script/src/models/bank/banks.d.ts +7 -0
  224. package/script/src/models/bank/banks.d.ts.map +1 -0
  225. package/script/src/models/bank/banks.js +199 -0
  226. package/script/src/models/bank/index.d.ts +4 -0
  227. package/script/src/models/bank/index.d.ts.map +1 -0
  228. package/script/src/models/bank/index.js +19 -0
  229. package/script/src/models/bank/utils.d.ts +25 -0
  230. package/script/src/models/bank/utils.d.ts.map +1 -0
  231. package/script/src/models/bank/utils.js +41 -0
  232. package/script/src/models/index.d.ts +4 -0
  233. package/script/src/models/index.d.ts.map +1 -0
  234. package/script/src/models/index.js +19 -0
  235. package/script/src/models/phone_number/antd_validator.d.ts +77 -0
  236. package/script/src/models/phone_number/antd_validator.d.ts.map +1 -0
  237. package/script/src/models/phone_number/antd_validator.js +94 -0
  238. package/script/src/models/phone_number/antdvalidator.test.d.ts.map +1 -0
  239. package/script/src/models/phone_number/index.d.ts +4 -0
  240. package/script/src/models/phone_number/index.d.ts.map +1 -0
  241. package/script/src/models/phone_number/index.js +19 -0
  242. package/script/src/models/phone_number/phone_number.d.ts +117 -0
  243. package/script/src/models/phone_number/phone_number.d.ts.map +1 -0
  244. package/script/src/models/phone_number/phone_number.js +235 -0
  245. package/script/src/models/phone_number/phone_number.test.d.ts.map +1 -0
  246. package/script/src/models/phone_number/telecom.d.ts +25 -0
  247. package/script/src/models/phone_number/telecom.d.ts.map +1 -0
  248. package/script/src/models/phone_number/telecom.js +47 -0
  249. package/script/src/utils/id.d.ts +12 -0
  250. package/script/src/utils/id.d.ts.map +1 -0
  251. package/script/src/utils/id.js +23 -0
  252. package/script/src/utils/index.d.ts +4 -0
  253. package/script/src/utils/index.d.ts.map +1 -0
  254. package/script/src/utils/index.js +19 -0
  255. package/script/src/utils/text.d.ts +32 -0
  256. package/script/src/utils/text.d.ts.map +1 -0
  257. package/script/src/utils/text.js +75 -0
  258. package/script/src/utils/text.test.d.ts.map +1 -0
  259. package/script/src/utils/time.d.ts +21 -0
  260. package/script/src/utils/time.d.ts.map +1 -0
  261. package/script/src/utils/time.js +39 -0
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PHONENUMBER_VALIDATOR = exports.TZ_PHONE_NUMBER_REGEX = void 0;
4
+ const phone_number_js_1 = require("./phone_number.js");
5
+ /**
6
+ * Validates a Tanzanian phone number according to specified format rules.
7
+ * This validator is designed for Ant Design Form components and performs the following validations:
8
+ * 1. Required field validation (if specified in rules)
9
+ * 2. Format validation for valid Tanzanian phone numbers using TZ_PHONE_NUMBER_REGEX
10
+ *
11
+ * The validator accepts phone numbers in the following formats:
12
+ * Format 1: With prefix
13
+ * - Starting with 255, 0, or +255
14
+ * - Followed by valid operator codes:
15
+ * • Vodacom: 74, 75, 76, 78, 79
16
+ * • Tigo: 65, 67, 71
17
+ * • Airtel: 68, 69, 77
18
+ * • Halotel: 61, 62
19
+ * - Followed by 7 digits
20
+ *
21
+ * Format 2: Without prefix
22
+ * - Starting directly with operator code (listed above)
23
+ * - Followed by 7 digits
24
+ *
25
+ * @param {RuleObject} rule - Ant Design rule object containing validation rules
26
+ * @param {string | null | undefined} value - The phone number to validate
27
+ * @returns {Promise<void>} Resolves if validation passes, rejects with Error if validation fails
28
+ * @throws {Error} Throws an error with a descriptive message for validation failures:
29
+ * - "Phone number is required." - When field is required but empty/null/undefined
30
+ * - "Invalid phone number format." - When value doesn't match expected TZ phone number format
31
+ *
32
+ * @example
33
+ * // Usage in Ant Design form rules:
34
+ * const rules = [
35
+ * {
36
+ * required: true,
37
+ * validator: PHONENUMBER_VALIDATOR
38
+ * }
39
+ * ];
40
+ *
41
+ * // Valid inputs:
42
+ * // "+255742345678" -> International format with plus (Vodacom)
43
+ * // "255652345678" -> International format without plus (Tigo)
44
+ * // "0712345678" -> Local format with leading zero (Tigo)
45
+ * // "652345678" -> Local format without prefix (Tigo)
46
+ *
47
+ * // Invalid inputs:
48
+ * // "+255722345678" -> Invalid operator code (72)
49
+ * // "652345" -> Too short
50
+ * // "6523456789" -> Too long
51
+ * // "abc65234567" -> Non-numeric characters
52
+ * // "" -> Empty when required
53
+ * // undefined -> Missing when required
54
+ * // null -> Null when required
55
+ *
56
+ * @notes
57
+ * The validator uses TZ_PHONE_NUMBER_REGEX which matches:
58
+ * ^(?:255|0|\+255)(74|75|76|78|79|68|69|71|65|67|77|62|61)\d{7}$|^(?:74|75|76|78|79|68|69|71|65|67|77|62|61)\d{7}$
59
+ *
60
+ * This breaks down to:
61
+ * ^ -> Start of string
62
+ * (?:255|0|\+255) -> Country code group: 255, 0, or +255
63
+ * ( -> Start operator code group
64
+ * 74|75|76|78|79 -> Vodacom prefixes
65
+ * |68|69|71 -> Tigo prefixes
66
+ * |65|67|77 -> Airtel prefixes
67
+ * |62|61 -> Halotel prefixes
68
+ * ) -> End operator code group
69
+ * \d{7} -> Exactly 7 digits
70
+ * $ -> End of string
71
+ * | -> OR
72
+ * ^ -> Start of string (alternative format)
73
+ * (same operator codes as above)
74
+ * \d{7} -> Exactly 7 digits
75
+ * $ -> End of string
76
+ */
77
+ exports.TZ_PHONE_NUMBER_REGEX = /^(?:255|0|\+255)(74|75|76|78|79|68|69|71|65|67|77|62|61)\d{7}$|^(?:74|75|76|78|79|68|69|71|65|67|77|62|61)\d{7}$/;
78
+ const PHONENUMBER_VALIDATOR = (rule, value) => {
79
+ const phoneString = value?.toString().trim();
80
+ // If field is empty/undefined/null
81
+ if (!phoneString) {
82
+ // Only throw if the field is required
83
+ if (rule.required) {
84
+ return Promise.reject(new Error("Phone number is required."));
85
+ }
86
+ // If field is not required and empty, validation passes
87
+ return Promise.resolve(undefined);
88
+ }
89
+ const phone = phone_number_js_1.PhoneNumber.from(phoneString);
90
+ if (phone)
91
+ return Promise.resolve(phone);
92
+ return Promise.reject(new Error("Invalid phone number format."));
93
+ };
94
+ exports.PHONENUMBER_VALIDATOR = PHONENUMBER_VALIDATOR;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"antdvalidator.test.d.ts","sourceRoot":"","sources":["../../../../src/src/models/phone_number/antdvalidator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from "./antd_validator.js";
2
+ export * from "./phone_number.js";
3
+ export * from "./telecom.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/phone_number/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./antd_validator.js"), exports);
18
+ __exportStar(require("./phone_number.js"), exports);
19
+ __exportStar(require("./telecom.js"), exports);
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview
3
+ *
4
+ * # Tanzania Phone Number Management System
5
+ *
6
+ * ## Problem Statement
7
+ * Tanzania's phone number system requires specific validation and formatting rules:
8
+ *
9
+ * 1. Phone numbers can be entered in multiple formats:
10
+ * - International format: "+255712345678"
11
+ * - Local format with country code: "255712345678"
12
+ * - Local format with leading zero: "0712345678"
13
+ * - Compact format: "712345678"
14
+ *
15
+ * 2. Valid numbers must:
16
+ * - Have exactly 9 digits after removing prefixes
17
+ * - Start with a valid telecom provider prefix
18
+ * - Contain only numeric characters
19
+ *
20
+ * 3. Each telecom provider has specific prefixes:
21
+ * - Vodacom: 71, 74, 75, etc.
22
+ * - Airtel: 68, 69, etc.
23
+ * - Tigo: 65, 67, etc.
24
+ *
25
+ * ## Solution
26
+ * The PhoneNumber class provides:
27
+ * 1. Parsing and validation of different input formats
28
+ * 2. Standardized storage in compact format
29
+ * 3. Formatting options for display and API use
30
+ * 4. Telecom provider identification
31
+ */
32
+ import { type Telecom } from "./telecom.js";
33
+ /**
34
+ * Enumeration for various mobile number formats.
35
+ * @enum {string}
36
+ */
37
+ export declare enum MobileNumberFormat {
38
+ s255 = "255",// Mobile numbers prefixed with 255
39
+ sp255 = "+255",// Mobile numbers prefixed with +255
40
+ s0 = "0",// Mobile numbers prefixed with 0
41
+ none = ""
42
+ }
43
+ /**
44
+ * Represents a TZ phone number
45
+ */
46
+ export declare class PhoneNumber {
47
+ /**
48
+ * Stores the phone number in a compact format excluding country code and the initial '0'.
49
+ */
50
+ compactNumber: string;
51
+ /**
52
+ * Constructs a new `PhoneNumber` instance.
53
+ *
54
+ * @param compactNumber - The phone number in a compact format (e.g., "712345678").
55
+ */
56
+ constructor(compactNumber: string);
57
+ /**
58
+ * Formats the compact phone number with the specified `MobileNumberFormat`.
59
+ *
60
+ * @param format - The desired phone number format (e.g., `+255` or `255`).
61
+ * @returns The phone number formatted as a string.
62
+ */
63
+ getNumberWithFormat(format: MobileNumberFormat): string;
64
+ /**
65
+ * Returns the formatted label of the phone number using the `s255` format.
66
+ *
67
+ * @returns The phone number label in `255` format.
68
+ */
69
+ get label(): string;
70
+ /**
71
+ * Derives the telecom details associated with the phone number by checking its prefix.
72
+ *
73
+ * @returns The `Telecom` object that matches the phone number prefix.
74
+ */
75
+ get telecom(): Telecom;
76
+ /**
77
+ * Creates a `PhoneNumber` instance from a given string.
78
+ *
79
+ * @param s - The input phone number string in various formats (e.g., "+255712345678", "0712345678").
80
+ * @returns A `PhoneNumber` instance if valid, otherwise `undefined`.
81
+ */
82
+ static from(s: string): PhoneNumber | undefined;
83
+ /**
84
+ * Checks if a string can be constructed into a valid phone number object.
85
+ * @param {string | undefined} input - The string to validate as a phone number.
86
+ * @returns {boolean} - Returns true if the input can be constructed into a valid phone number object,
87
+ * false if the input is undefined, empty, or cannot be parsed.
88
+ */
89
+ static canConstruct(input?: string | null): boolean;
90
+ /**
91
+ * Checks if an unknown value contains valid data to construct a PhoneNumber instance.
92
+ * Validates the structural integrity of the phone number object.
93
+ *
94
+ * @param {unknown} obj - The value to validate.
95
+ * @returns {obj is PhoneNumber} Type predicate indicating if the value has a valid phone number structure.
96
+ *
97
+ * @example
98
+ * const maybePhone = JSON.parse(someData);
99
+ * if (PhoneNumber.is(maybePhone)) {
100
+ * // maybePhone is typed as PhoneNumber
101
+ * console.log(maybePhone.label);
102
+ * }
103
+ *
104
+ * @remarks
105
+ * Validates:
106
+ * - Has required compactNumber property
107
+ * - compactNumber is a 9-digit string
108
+ * - Prefix matches a valid telecom provider
109
+ */
110
+ static is(obj: unknown): obj is PhoneNumber;
111
+ /**
112
+ * Checks the validity of the phone number data
113
+ * @returns true if the phone number information is available and valid
114
+ */
115
+ validate(): boolean;
116
+ }
117
+ //# sourceMappingURL=phone_number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone_number.d.ts","sourceRoot":"","sources":["../../../../src/src/models/phone_number/phone_number.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,cAAc,CAAC;AAE5D;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,IAAI,QAAQ,CAAE,mCAAmC;IACjD,KAAK,SAAS,CAAE,oCAAoC;IACpD,EAAE,MAAM,CAAE,iCAAiC;IAC3C,IAAI,KAAK;CACV;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;gBACS,aAAa,EAAE,MAAM;IAIjC;;;;;OAKG;IACH,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM;IAIvD;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,OAAO,CAMrB;IAED;;;;;OAKG;WACW,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAqCtD;;;;;OAKG;WACW,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAW1D;;;;;;;;;;;;;;;;;;;OAmBG;WACW,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW;IAYlD;;;OAGG;IACI,QAAQ,IAAI,OAAO;CAO3B"}
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview
4
+ *
5
+ * # Tanzania Phone Number Management System
6
+ *
7
+ * ## Problem Statement
8
+ * Tanzania's phone number system requires specific validation and formatting rules:
9
+ *
10
+ * 1. Phone numbers can be entered in multiple formats:
11
+ * - International format: "+255712345678"
12
+ * - Local format with country code: "255712345678"
13
+ * - Local format with leading zero: "0712345678"
14
+ * - Compact format: "712345678"
15
+ *
16
+ * 2. Valid numbers must:
17
+ * - Have exactly 9 digits after removing prefixes
18
+ * - Start with a valid telecom provider prefix
19
+ * - Contain only numeric characters
20
+ *
21
+ * 3. Each telecom provider has specific prefixes:
22
+ * - Vodacom: 71, 74, 75, etc.
23
+ * - Airtel: 68, 69, etc.
24
+ * - Tigo: 65, 67, etc.
25
+ *
26
+ * ## Solution
27
+ * The PhoneNumber class provides:
28
+ * 1. Parsing and validation of different input formats
29
+ * 2. Standardized storage in compact format
30
+ * 3. Formatting options for display and API use
31
+ * 4. Telecom provider identification
32
+ */
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.PhoneNumber = exports.MobileNumberFormat = void 0;
35
+ const telecom_js_1 = require("./telecom.js");
36
+ /**
37
+ * Enumeration for various mobile number formats.
38
+ * @enum {string}
39
+ */
40
+ var MobileNumberFormat;
41
+ (function (MobileNumberFormat) {
42
+ MobileNumberFormat["s255"] = "255";
43
+ MobileNumberFormat["sp255"] = "+255";
44
+ MobileNumberFormat["s0"] = "0";
45
+ MobileNumberFormat["none"] = "";
46
+ })(MobileNumberFormat || (exports.MobileNumberFormat = MobileNumberFormat = {}));
47
+ /**
48
+ * Represents a TZ phone number
49
+ */
50
+ class PhoneNumber {
51
+ /**
52
+ * Constructs a new `PhoneNumber` instance.
53
+ *
54
+ * @param compactNumber - The phone number in a compact format (e.g., "712345678").
55
+ */
56
+ constructor(compactNumber) {
57
+ /**
58
+ * Stores the phone number in a compact format excluding country code and the initial '0'.
59
+ */
60
+ Object.defineProperty(this, "compactNumber", {
61
+ enumerable: true,
62
+ configurable: true,
63
+ writable: true,
64
+ value: void 0
65
+ });
66
+ this.compactNumber = compactNumber;
67
+ }
68
+ /**
69
+ * Formats the compact phone number with the specified `MobileNumberFormat`.
70
+ *
71
+ * @param format - The desired phone number format (e.g., `+255` or `255`).
72
+ * @returns The phone number formatted as a string.
73
+ */
74
+ getNumberWithFormat(format) {
75
+ return `${format}${this.compactNumber}`;
76
+ }
77
+ /**
78
+ * Returns the formatted label of the phone number using the `s255` format.
79
+ *
80
+ * @returns The phone number label in `255` format.
81
+ */
82
+ get label() {
83
+ return this.getNumberWithFormat(MobileNumberFormat.s255);
84
+ }
85
+ /**
86
+ * Derives the telecom details associated with the phone number by checking its prefix.
87
+ *
88
+ * @returns The `Telecom` object that matches the phone number prefix.
89
+ */
90
+ get telecom() {
91
+ const id = this.compactNumber.substring(0, 2);
92
+ const result = Object.values(telecom_js_1.telecomDetails).find((e) => e.prefixes.includes(id));
93
+ return result;
94
+ }
95
+ /**
96
+ * Creates a `PhoneNumber` instance from a given string.
97
+ *
98
+ * @param s - The input phone number string in various formats (e.g., "+255712345678", "0712345678").
99
+ * @returns A `PhoneNumber` instance if valid, otherwise `undefined`.
100
+ */
101
+ static from(s) {
102
+ try {
103
+ const number = removeSpaces(s.trim());
104
+ if (number.length === 0)
105
+ return;
106
+ const isOnlyDigits = isOnlyDigitsOrPlus(number);
107
+ if (!isOnlyDigits)
108
+ return;
109
+ let compactNumber;
110
+ // Extract the compact number by removing country or local dialing prefixes.
111
+ if (number.startsWith("+255")) {
112
+ compactNumber = number.substring(4);
113
+ }
114
+ else if (number.startsWith("255")) {
115
+ compactNumber = number.substring(3);
116
+ }
117
+ else if (number.startsWith("0")) {
118
+ compactNumber = number.substring(1);
119
+ }
120
+ else {
121
+ compactNumber = number;
122
+ }
123
+ // Validate that the compact number length is correct.
124
+ if (compactNumber.length !== 9)
125
+ return;
126
+ // Check if the compact number matches any telecom provider prefix.
127
+ const id = compactNumber.substring(0, 2);
128
+ const telecom = Object.values(telecom_js_1.telecomDetails).find((e) => e.prefixes.includes(id));
129
+ if (!telecom)
130
+ return;
131
+ return new PhoneNumber(compactNumber);
132
+ }
133
+ catch (_) {
134
+ return;
135
+ }
136
+ }
137
+ /**
138
+ * Checks if a string can be constructed into a valid phone number object.
139
+ * @param {string | undefined} input - The string to validate as a phone number.
140
+ * @returns {boolean} - Returns true if the input can be constructed into a valid phone number object,
141
+ * false if the input is undefined, empty, or cannot be parsed.
142
+ */
143
+ static canConstruct(input) {
144
+ if (!input || typeof input !== "string")
145
+ return false;
146
+ const text = removeSpaces(input.trim());
147
+ if (text.length === 0)
148
+ return false;
149
+ const phone = PhoneNumber.from(text);
150
+ return phone !== undefined;
151
+ }
152
+ /**
153
+ * Checks if an unknown value contains valid data to construct a PhoneNumber instance.
154
+ * Validates the structural integrity of the phone number object.
155
+ *
156
+ * @param {unknown} obj - The value to validate.
157
+ * @returns {obj is PhoneNumber} Type predicate indicating if the value has a valid phone number structure.
158
+ *
159
+ * @example
160
+ * const maybePhone = JSON.parse(someData);
161
+ * if (PhoneNumber.is(maybePhone)) {
162
+ * // maybePhone is typed as PhoneNumber
163
+ * console.log(maybePhone.label);
164
+ * }
165
+ *
166
+ * @remarks
167
+ * Validates:
168
+ * - Has required compactNumber property
169
+ * - compactNumber is a 9-digit string
170
+ * - Prefix matches a valid telecom provider
171
+ */
172
+ static is(obj) {
173
+ if (!obj || typeof obj !== "object")
174
+ return false;
175
+ const maybePhone = obj;
176
+ // Check if compactNumber exists and is string
177
+ if (typeof maybePhone.compactNumber !== "string")
178
+ return false;
179
+ const compactNumber = maybePhone.compactNumber;
180
+ return PhoneNumber.canConstruct(compactNumber);
181
+ }
182
+ /**
183
+ * Checks the validity of the phone number data
184
+ * @returns true if the phone number information is available and valid
185
+ */
186
+ validate() {
187
+ try {
188
+ return PhoneNumber.canConstruct(this.compactNumber);
189
+ }
190
+ catch (_) {
191
+ return false;
192
+ }
193
+ }
194
+ }
195
+ exports.PhoneNumber = PhoneNumber;
196
+ /**
197
+ * Removes all whitespace characters from the given string.
198
+ *
199
+ * This function replaces all occurrences of spaces, tabs, and other
200
+ * whitespace characters (including multiple spaces) in the input string
201
+ * with an empty string, effectively removing them.
202
+ *
203
+ * @param {string} input - The input string from which spaces should be removed.
204
+ * @returns {string} A new string with all whitespace characters removed.
205
+ *
206
+ * @example
207
+ * removeSpaces(" Hello World "); // Returns: "HelloWorld"
208
+ * removeSpaces("NoSpacesHere"); // Returns: "NoSpacesHere"
209
+ * removeSpaces(" "); // Returns: ""
210
+ */
211
+ function removeSpaces(input) {
212
+ return input.replace(/\s+/g, "");
213
+ }
214
+ /**
215
+ * Checks if a given string contains only digits or a `+` prefix followed by digits.
216
+ *
217
+ * This function validates that the input string:
218
+ * - Can optionally start with a `+` sign.
219
+ * - Must have one or more digits after the optional `+`.
220
+ * - Does not contain any other characters besides digits and the `+` prefix.
221
+ *
222
+ * @param {string} input - The input string to validate.
223
+ * @returns {boolean} `true` if the string contains only digits or a `+` prefix followed by digits; otherwise, `false`.
224
+ *
225
+ * @example
226
+ * isOnlyDigitsOrPlus("12345"); // Returns: true
227
+ * isOnlyDigitsOrPlus("+12345"); // Returns: true
228
+ * isOnlyDigitsOrPlus("123a45"); // Returns: false
229
+ * isOnlyDigitsOrPlus("+"); // Returns: false
230
+ * isOnlyDigitsOrPlus(""); // Returns: false
231
+ */
232
+ function isOnlyDigitsOrPlus(input) {
233
+ const digitWithPlusRegex = /^\+?\d+$/;
234
+ return digitWithPlusRegex.test(input);
235
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone_number.test.d.ts","sourceRoot":"","sources":["../../../../src/src/models/phone_number/phone_number.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Enumeration for telecom identifiers.
3
+ * @enum {string}
4
+ */
5
+ export declare enum TelecomID {
6
+ vodacom = "vodacom",
7
+ airtel = "airtel",
8
+ tigo = "tigo",
9
+ halotel = "halotel"
10
+ }
11
+ /**
12
+ * Interface representing a telecom provider.
13
+ */
14
+ export interface Telecom {
15
+ id: TelecomID;
16
+ prefixes: string[];
17
+ label: string;
18
+ company: string;
19
+ color: string;
20
+ }
21
+ /**
22
+ * Details for each telecom provider including prefixes and branding information.
23
+ */
24
+ export declare const telecomDetails: Record<TelecomID, Telecom>;
25
+ //# sourceMappingURL=telecom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telecom.d.ts","sourceRoot":"","sources":["../../../../src/src/models/phone_number/telecom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,SAAS;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,SAAS,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CA6BrD,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.telecomDetails = exports.TelecomID = void 0;
4
+ /**
5
+ * Enumeration for telecom identifiers.
6
+ * @enum {string}
7
+ */
8
+ var TelecomID;
9
+ (function (TelecomID) {
10
+ TelecomID["vodacom"] = "vodacom";
11
+ TelecomID["airtel"] = "airtel";
12
+ TelecomID["tigo"] = "tigo";
13
+ TelecomID["halotel"] = "halotel";
14
+ })(TelecomID || (exports.TelecomID = TelecomID = {}));
15
+ /**
16
+ * Details for each telecom provider including prefixes and branding information.
17
+ */
18
+ exports.telecomDetails = {
19
+ vodacom: {
20
+ id: TelecomID.vodacom,
21
+ prefixes: ["74", "75", "76"],
22
+ label: "Vodacom",
23
+ company: "M-Pesa",
24
+ color: "red",
25
+ },
26
+ airtel: {
27
+ id: TelecomID.airtel,
28
+ prefixes: ["78", "79", "68", "69"],
29
+ label: "Airtel",
30
+ company: "Airtel-Money",
31
+ color: "volcano",
32
+ },
33
+ tigo: {
34
+ id: TelecomID.tigo,
35
+ prefixes: ["71", "65", "67", "77"],
36
+ label: "Tigo",
37
+ company: "Tigo-Pesa",
38
+ color: "blue",
39
+ },
40
+ halotel: {
41
+ id: TelecomID.halotel,
42
+ prefixes: ["62", "61"],
43
+ label: "Halotel",
44
+ company: "Halo-Pesa",
45
+ color: "orange",
46
+ },
47
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generates a unique UUID (version 4).
3
+ * @returns {string} - A randomly generated UUID string.
4
+ */
5
+ export declare function generateUniqueUUID(): string;
6
+ /**
7
+ * Generates a UUID (version 5) based on the input string and a predefined namespace.
8
+ * @param {string} data - The input string to generate the UUID from.
9
+ * @returns {string} - A UUID string generated from the input string.
10
+ */
11
+ export declare function generateUuidBasedOn(data: string): string;
12
+ //# sourceMappingURL=id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../../src/src/utils/id.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAKD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateUniqueUUID = generateUniqueUUID;
4
+ exports.generateUuidBasedOn = generateUuidBasedOn;
5
+ const uuid_1 = require("uuid");
6
+ const uuid_2 = require("uuid");
7
+ /**
8
+ * Generates a unique UUID (version 4).
9
+ * @returns {string} - A randomly generated UUID string.
10
+ */
11
+ function generateUniqueUUID() {
12
+ return (0, uuid_1.v4)();
13
+ }
14
+ // Predefined namespace
15
+ const NAMESPACE = uuid_2.v5.DNS;
16
+ /**
17
+ * Generates a UUID (version 5) based on the input string and a predefined namespace.
18
+ * @param {string} data - The input string to generate the UUID from.
19
+ * @returns {string} - A UUID string generated from the input string.
20
+ */
21
+ function generateUuidBasedOn(data) {
22
+ return (0, uuid_2.v5)(data, NAMESPACE);
23
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./id.js";
2
+ export * from "./time.js";
3
+ export * from "./text.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./id.js"), exports);
18
+ __exportStar(require("./time.js"), exports);
19
+ __exportStar(require("./text.js"), exports);
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Capitalizes the first letter of a string and converts the rest of the string to lowercase.
3
+ * @param {string} str - The input string.
4
+ * @returns {string} - The formatted string with the first letter capitalized.
5
+ */
6
+ export declare function capitalizeFirstLetter(str: string): string;
7
+ /**
8
+ * Combines a first name and a last name into a full name.
9
+ * @param {string} firstName - The first name.
10
+ * @param {string} lastName - The last name.
11
+ * @returns {string} - The full name formatted as "FirstName LastName".
12
+ */
13
+ export declare function getFullName(firstName: string, lastName: string): string;
14
+ /**
15
+ * Generates a URL-friendly slug from a given text.
16
+ * @param {string} text - The input string.
17
+ * @returns {string} - The generated slug with lowercase alphanumeric characters and hyphens.
18
+ */
19
+ export declare function generateSlug(text: string): string;
20
+ /**
21
+ * Abbreviates a full name into a first name and the initial of the last name.
22
+ * @param {string} fullName - The input full name.
23
+ * @returns {string} - The abbreviated name in the format "FirstName L.".
24
+ */
25
+ export declare function abbreviateName(fullName: string): string;
26
+ /**
27
+ * Extracts the initials from a full name.
28
+ * @param {string} fullName - The input full name.
29
+ * @returns {string} - The initials in uppercase format.
30
+ */
31
+ export declare function getInitialsFrom(fullName: string): string;
32
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/src/utils/text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASzD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOjD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAcxD"}