@onivoro/isomorphic-common 22.0.5 → 24.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 (336) hide show
  1. package/README.md +393 -0
  2. package/dist/libs/isomorphic/axios/libs/isomorphic/axios/README.md +314 -0
  3. package/dist/libs/isomorphic/axios/libs/isomorphic/axios/package.json +10 -0
  4. package/dist/libs/isomorphic/common/libs/isomorphic/common/README.md +393 -0
  5. package/dist/libs/isomorphic/common/libs/isomorphic/common/package.json +10 -0
  6. package/dist/libs/server/common/libs/server/common/README.md +322 -0
  7. package/dist/libs/server/common/libs/server/common/package.json +12 -0
  8. package/jest.config.ts +11 -0
  9. package/package.json +8 -39
  10. package/project.json +23 -0
  11. package/{dist/cjs/index.d.ts → src/index.ts} +42 -5
  12. package/src/lib/constants/api-id-header.constant.ts +1 -0
  13. package/src/lib/constants/api-key-header.constant.ts +1 -0
  14. package/src/lib/constants/auth-cookie-name.constant.ts +2 -0
  15. package/src/lib/constants/millis-per-day.constant.ts +3 -0
  16. package/src/lib/constants/millis-per-hour.constant.ts +3 -0
  17. package/src/lib/constants/millis-per-minute.constant.ts +1 -0
  18. package/src/lib/constants/regexes.constant.ts +30 -0
  19. package/src/lib/functions/__snapshots__/chunk.function.spec.ts.snap +94 -0
  20. package/src/lib/functions/__snapshots__/split-date-range-into-days.function.spec.ts.snap +50 -0
  21. package/src/lib/functions/add-offset.function.spec.ts +12 -0
  22. package/src/lib/functions/add-offset.function.ts +14 -0
  23. package/src/lib/functions/arrange-act-assert.function.ts +23 -0
  24. package/src/lib/functions/camel-case.function.ts +30 -0
  25. package/src/lib/functions/chunk.function.spec.ts +20 -0
  26. package/src/lib/functions/chunk.function.ts +25 -0
  27. package/src/lib/functions/convert-object-to-literal.function.spec.ts +16 -0
  28. package/src/lib/functions/convert-object-to-literal.function.ts +10 -0
  29. package/src/lib/functions/format-usd.function.ts +4 -0
  30. package/src/lib/functions/from-boolean-string.function.ts +3 -0
  31. package/src/lib/functions/from-calendar-date.function.spec.ts +11 -0
  32. package/src/lib/functions/from-calendar-date.function.ts +5 -0
  33. package/src/lib/functions/from-csv-string.function.ts +3 -0
  34. package/src/lib/functions/get-date-last-month.function.ts +6 -0
  35. package/src/lib/functions/get-date-range-for-month.function copy.ts +8 -0
  36. package/src/lib/functions/get-date-range-for-month.function.ts +8 -0
  37. package/src/lib/functions/get-tag.function.ts +10 -0
  38. package/src/lib/functions/get-user-full-name.function.ts +5 -0
  39. package/src/lib/functions/is-symbol.function.ts +11 -0
  40. package/src/lib/functions/is-valid-date.function.ts +5 -0
  41. package/src/lib/functions/kebab-case.function.ts +5 -0
  42. package/src/lib/functions/map-entities-to-options.function.ts +11 -0
  43. package/src/lib/functions/map-enum-to-array-of-values.function copy.ts +3 -0
  44. package/src/lib/functions/map-enum-to-array-of-values.function.ts +3 -0
  45. package/src/lib/functions/map-enum-to-lookup-array.function.ts +6 -0
  46. package/src/lib/functions/map-enum-to-options.function copy.ts +7 -0
  47. package/src/lib/functions/map-enum-to-options.function.ts +7 -0
  48. package/src/lib/functions/mock-calls.function.ts +4 -0
  49. package/src/lib/functions/money.function.spec.ts +10 -0
  50. package/src/lib/functions/money.function.ts +22 -0
  51. package/src/lib/functions/parse-bool.function.ts +3 -0
  52. package/src/lib/functions/properties-to-array.function.ts +21 -0
  53. package/src/lib/functions/remove-alpha-chars.function.spec.ts +11 -0
  54. package/src/lib/functions/remove-alpha-chars.function.ts +9 -0
  55. package/src/lib/functions/remove-element-at-index.function copy.ts +9 -0
  56. package/src/lib/functions/remove-element-at-index.function.ts +9 -0
  57. package/src/lib/functions/round.function copy.ts +4 -0
  58. package/src/lib/functions/round.function.ts +4 -0
  59. package/src/lib/functions/sanitize-filename.function.ts +9 -0
  60. package/src/lib/functions/sleep.function.ts +3 -0
  61. package/{dist/esm/lib/functions/snake-case.function.js → src/lib/functions/snake-case.function.ts} +9 -6
  62. package/src/lib/functions/sort-by-created-at.function.ts +7 -0
  63. package/src/lib/functions/sort-by-full-name.function.ts +6 -0
  64. package/src/lib/functions/sort-by-id.function.ts +3 -0
  65. package/src/lib/functions/sort-by-name.function.ts +3 -0
  66. package/src/lib/functions/sort-numbers.function.ts +3 -0
  67. package/src/lib/functions/split-date-range-into-days.function.spec.ts +17 -0
  68. package/src/lib/functions/split-date-range-into-days.function.ts +26 -0
  69. package/src/lib/functions/subtract-offset.function.spec.ts +12 -0
  70. package/src/lib/functions/subtract-offset.function.ts +14 -0
  71. package/src/lib/functions/to-boolean-string.function.ts +3 -0
  72. package/src/lib/functions/to-calendar-date.function.ts +11 -0
  73. package/src/lib/functions/to-csv-string.function.ts +3 -0
  74. package/{dist/cjs/lib/functions/to-decimal-base.function.js → src/lib/functions/to-decimal-base.function.ts} +9 -7
  75. package/src/lib/functions/to-dollars-and-cents.function.spec.ts +7 -0
  76. package/src/lib/functions/to-dollars-and-cents.function.ts +17 -0
  77. package/{dist/cjs/lib/functions/to-string.function.js → src/lib/functions/to-string.function.ts} +6 -6
  78. package/src/lib/functions/to-unique-array.function.spec.ts +45 -0
  79. package/src/lib/functions/to-unique-array.function.ts +3 -0
  80. package/src/lib/functions/to-words.function.spec.ts +7 -0
  81. package/{dist/cjs/lib/functions/to-words.function.js → src/lib/functions/to-words.function.ts} +43 -26
  82. package/src/lib/functions/try-json-parse.spec.ts +37 -0
  83. package/src/lib/functions/try-json-parse.ts +11 -0
  84. package/src/lib/functions/try-json-stringify.spec.ts +44 -0
  85. package/src/lib/functions/try-json-stringify.ts +11 -0
  86. package/src/lib/functions/try-parse-date.function.spec.ts +12 -0
  87. package/src/lib/functions/try-parse-date.function.ts +17 -0
  88. package/src/lib/functions/unicode-words.const.ts +70 -0
  89. package/src/lib/functions/upper-first.function.spec.ts +16 -0
  90. package/src/lib/functions/upper-first.function.ts +10 -0
  91. package/src/lib/functions/use-date.function.ts +21 -0
  92. package/src/lib/functions/words.function.ts +38 -0
  93. package/src/lib/types/access-token.interface.ts +8 -0
  94. package/{dist/esm/lib/interfaces/axios-wrapped-nest-exception.interface.d.ts → src/lib/types/axios-wrapped-nest-exception.interface.ts} +1 -1
  95. package/src/lib/types/company.type.ts +18 -0
  96. package/src/lib/types/createable.type.ts +1 -0
  97. package/{dist/cjs/lib/interfaces/entity-provider.interface.d.ts → src/lib/types/entity-provider.interface.ts} +1 -1
  98. package/src/lib/types/keys-of.type copy.ts +1 -0
  99. package/src/lib/types/keys-of.type.ts +1 -0
  100. package/{dist/types/lib/interfaces/lookup.interface.d.ts → src/lib/types/lookup.interface copy.ts } +2 -2
  101. package/{dist/cjs/lib/interfaces/lookup.interface.d.ts → src/lib/types/lookup.interface.ts} +2 -2
  102. package/src/lib/types/nameable.type.ts +4 -0
  103. package/tsconfig.json +13 -0
  104. package/tsconfig.lib.json +8 -0
  105. package/tsconfig.spec.json +14 -0
  106. package/dist/cjs/index.js +0 -59
  107. package/dist/cjs/lib/constants/decimal-regex.constant.d.ts +0 -1
  108. package/dist/cjs/lib/constants/decimal-regex.constant.js +0 -4
  109. package/dist/cjs/lib/constants/millis-per-day.constant.d.ts +0 -1
  110. package/dist/cjs/lib/constants/millis-per-day.constant.js +0 -5
  111. package/dist/cjs/lib/constants/millis-per-hour.constant.d.ts +0 -1
  112. package/dist/cjs/lib/constants/millis-per-hour.constant.js +0 -5
  113. package/dist/cjs/lib/constants/millis-per-minute.constant.d.ts +0 -1
  114. package/dist/cjs/lib/constants/millis-per-minute.constant.js +0 -4
  115. package/dist/cjs/lib/functions/add-offset.function.d.ts +0 -1
  116. package/dist/cjs/lib/functions/add-offset.function.js +0 -13
  117. package/dist/cjs/lib/functions/camel-case.function.d.ts +0 -20
  118. package/dist/cjs/lib/functions/camel-case.function.js +0 -31
  119. package/dist/cjs/lib/functions/convert-object-to-literal.function.d.ts +0 -1
  120. package/dist/cjs/lib/functions/convert-object-to-literal.function.js +0 -9
  121. package/dist/cjs/lib/functions/format-usd.function.d.ts +0 -1
  122. package/dist/cjs/lib/functions/format-usd.function.js +0 -7
  123. package/dist/cjs/lib/functions/from-boolean-string.function.d.ts +0 -1
  124. package/dist/cjs/lib/functions/from-boolean-string.function.js +0 -6
  125. package/dist/cjs/lib/functions/from-calendar-date.function.d.ts +0 -1
  126. package/dist/cjs/lib/functions/from-calendar-date.function.js +0 -7
  127. package/dist/cjs/lib/functions/from-csv-string.function.d.ts +0 -1
  128. package/dist/cjs/lib/functions/from-csv-string.function.js +0 -6
  129. package/dist/cjs/lib/functions/get-date-range-for-month.function.d.ts +0 -4
  130. package/dist/cjs/lib/functions/get-date-range-for-month.function.js +0 -9
  131. package/dist/cjs/lib/functions/get-tag.function.d.ts +0 -1
  132. package/dist/cjs/lib/functions/get-tag.function.js +0 -11
  133. package/dist/cjs/lib/functions/is-symbol.function.d.ts +0 -1
  134. package/dist/cjs/lib/functions/is-symbol.function.js +0 -10
  135. package/dist/cjs/lib/functions/is-valid-date.function.d.ts +0 -1
  136. package/dist/cjs/lib/functions/is-valid-date.function.js +0 -7
  137. package/dist/cjs/lib/functions/kebab-case.function.d.ts +0 -1
  138. package/dist/cjs/lib/functions/kebab-case.function.js +0 -7
  139. package/dist/cjs/lib/functions/map-enum-to-array-of-values.function.d.ts +0 -1
  140. package/dist/cjs/lib/functions/map-enum-to-array-of-values.function.js +0 -6
  141. package/dist/cjs/lib/functions/map-enum-to-lookup-array.function.d.ts +0 -2
  142. package/dist/cjs/lib/functions/map-enum-to-lookup-array.function.js +0 -7
  143. package/dist/cjs/lib/functions/map-enum-to-options.function.d.ts +0 -4
  144. package/dist/cjs/lib/functions/map-enum-to-options.function.js +0 -9
  145. package/dist/cjs/lib/functions/money.function.d.ts +0 -1
  146. package/dist/cjs/lib/functions/money.function.js +0 -19
  147. package/dist/cjs/lib/functions/parse-bool.function.d.ts +0 -1
  148. package/dist/cjs/lib/functions/parse-bool.function.js +0 -6
  149. package/dist/cjs/lib/functions/properties-to-array.function.d.ts +0 -1
  150. package/dist/cjs/lib/functions/properties-to-array.function.js +0 -18
  151. package/dist/cjs/lib/functions/remove-alpha-chars.function.d.ts +0 -1
  152. package/dist/cjs/lib/functions/remove-alpha-chars.function.js +0 -10
  153. package/dist/cjs/lib/functions/remove-element-at-index.function.d.ts +0 -1
  154. package/dist/cjs/lib/functions/remove-element-at-index.function.js +0 -12
  155. package/dist/cjs/lib/functions/round.function.d.ts +0 -1
  156. package/dist/cjs/lib/functions/round.function.js +0 -7
  157. package/dist/cjs/lib/functions/sanitize-filename.function.d.ts +0 -1
  158. package/dist/cjs/lib/functions/sanitize-filename.function.js +0 -10
  159. package/dist/cjs/lib/functions/sleep.function.d.ts +0 -1
  160. package/dist/cjs/lib/functions/sleep.function.js +0 -6
  161. package/dist/cjs/lib/functions/snake-case.function.d.ts +0 -24
  162. package/dist/cjs/lib/functions/snake-case.function.js +0 -31
  163. package/dist/cjs/lib/functions/subtract-offset.function.d.ts +0 -1
  164. package/dist/cjs/lib/functions/subtract-offset.function.js +0 -13
  165. package/dist/cjs/lib/functions/to-boolean-string.function.d.ts +0 -1
  166. package/dist/cjs/lib/functions/to-boolean-string.function.js +0 -6
  167. package/dist/cjs/lib/functions/to-calendar-date.function.d.ts +0 -1
  168. package/dist/cjs/lib/functions/to-calendar-date.function.js +0 -11
  169. package/dist/cjs/lib/functions/to-csv-string.function.d.ts +0 -1
  170. package/dist/cjs/lib/functions/to-csv-string.function.js +0 -6
  171. package/dist/cjs/lib/functions/to-decimal-base.function.d.ts +0 -1
  172. package/dist/cjs/lib/functions/to-dollars-and-cents.function.d.ts +0 -1
  173. package/dist/cjs/lib/functions/to-dollars-and-cents.function.js +0 -16
  174. package/dist/cjs/lib/functions/to-string.function.d.ts +0 -1
  175. package/dist/cjs/lib/functions/to-unique-array.function.d.ts +0 -1
  176. package/dist/cjs/lib/functions/to-unique-array.function.js +0 -6
  177. package/dist/cjs/lib/functions/to-words.function.d.ts +0 -1
  178. package/dist/cjs/lib/functions/try-json-parse.d.ts +0 -1
  179. package/dist/cjs/lib/functions/try-json-parse.js +0 -14
  180. package/dist/cjs/lib/functions/try-json-stringify.d.ts +0 -1
  181. package/dist/cjs/lib/functions/try-json-stringify.js +0 -14
  182. package/dist/cjs/lib/functions/try-parse-date.function.d.ts +0 -1
  183. package/dist/cjs/lib/functions/try-parse-date.function.js +0 -16
  184. package/dist/cjs/lib/functions/unicode-words.const.d.ts +0 -8
  185. package/dist/cjs/lib/functions/unicode-words.const.js +0 -68
  186. package/dist/cjs/lib/functions/upper-first.function.d.ts +0 -1
  187. package/dist/cjs/lib/functions/upper-first.function.js +0 -12
  188. package/dist/cjs/lib/functions/words.function.d.ts +0 -17
  189. package/dist/cjs/lib/functions/words.function.js +0 -34
  190. package/dist/cjs/lib/interfaces/axios-wrapped-nest-exception.interface.d.ts +0 -5
  191. package/dist/cjs/lib/interfaces/axios-wrapped-nest-exception.interface.js +0 -2
  192. package/dist/cjs/lib/interfaces/entity-provider.interface.js +0 -2
  193. package/dist/cjs/lib/interfaces/keys-of.type.d.ts +0 -3
  194. package/dist/cjs/lib/interfaces/keys-of.type.js +0 -2
  195. package/dist/cjs/lib/interfaces/lookup.interface.js +0 -2
  196. package/dist/esm/index.d.ts +0 -43
  197. package/dist/esm/index.js +0 -59
  198. package/dist/esm/lib/constants/decimal-regex.constant.d.ts +0 -1
  199. package/dist/esm/lib/constants/decimal-regex.constant.js +0 -4
  200. package/dist/esm/lib/constants/millis-per-day.constant.d.ts +0 -1
  201. package/dist/esm/lib/constants/millis-per-day.constant.js +0 -5
  202. package/dist/esm/lib/constants/millis-per-hour.constant.d.ts +0 -1
  203. package/dist/esm/lib/constants/millis-per-hour.constant.js +0 -5
  204. package/dist/esm/lib/constants/millis-per-minute.constant.d.ts +0 -1
  205. package/dist/esm/lib/constants/millis-per-minute.constant.js +0 -4
  206. package/dist/esm/lib/functions/add-offset.function.d.ts +0 -1
  207. package/dist/esm/lib/functions/add-offset.function.js +0 -13
  208. package/dist/esm/lib/functions/camel-case.function.d.ts +0 -20
  209. package/dist/esm/lib/functions/camel-case.function.js +0 -31
  210. package/dist/esm/lib/functions/convert-object-to-literal.function.d.ts +0 -1
  211. package/dist/esm/lib/functions/convert-object-to-literal.function.js +0 -9
  212. package/dist/esm/lib/functions/format-usd.function.d.ts +0 -1
  213. package/dist/esm/lib/functions/format-usd.function.js +0 -7
  214. package/dist/esm/lib/functions/from-boolean-string.function.d.ts +0 -1
  215. package/dist/esm/lib/functions/from-boolean-string.function.js +0 -6
  216. package/dist/esm/lib/functions/from-calendar-date.function.d.ts +0 -1
  217. package/dist/esm/lib/functions/from-calendar-date.function.js +0 -7
  218. package/dist/esm/lib/functions/from-csv-string.function.d.ts +0 -1
  219. package/dist/esm/lib/functions/from-csv-string.function.js +0 -6
  220. package/dist/esm/lib/functions/get-date-range-for-month.function.d.ts +0 -4
  221. package/dist/esm/lib/functions/get-date-range-for-month.function.js +0 -9
  222. package/dist/esm/lib/functions/get-tag.function.d.ts +0 -1
  223. package/dist/esm/lib/functions/get-tag.function.js +0 -11
  224. package/dist/esm/lib/functions/is-symbol.function.d.ts +0 -1
  225. package/dist/esm/lib/functions/is-symbol.function.js +0 -10
  226. package/dist/esm/lib/functions/is-valid-date.function.d.ts +0 -1
  227. package/dist/esm/lib/functions/is-valid-date.function.js +0 -7
  228. package/dist/esm/lib/functions/kebab-case.function.d.ts +0 -1
  229. package/dist/esm/lib/functions/kebab-case.function.js +0 -7
  230. package/dist/esm/lib/functions/map-enum-to-array-of-values.function.d.ts +0 -1
  231. package/dist/esm/lib/functions/map-enum-to-array-of-values.function.js +0 -6
  232. package/dist/esm/lib/functions/map-enum-to-lookup-array.function.d.ts +0 -2
  233. package/dist/esm/lib/functions/map-enum-to-lookup-array.function.js +0 -7
  234. package/dist/esm/lib/functions/map-enum-to-options.function.d.ts +0 -4
  235. package/dist/esm/lib/functions/map-enum-to-options.function.js +0 -9
  236. package/dist/esm/lib/functions/money.function.d.ts +0 -1
  237. package/dist/esm/lib/functions/money.function.js +0 -19
  238. package/dist/esm/lib/functions/parse-bool.function.d.ts +0 -1
  239. package/dist/esm/lib/functions/parse-bool.function.js +0 -6
  240. package/dist/esm/lib/functions/properties-to-array.function.d.ts +0 -1
  241. package/dist/esm/lib/functions/properties-to-array.function.js +0 -18
  242. package/dist/esm/lib/functions/remove-alpha-chars.function.d.ts +0 -1
  243. package/dist/esm/lib/functions/remove-alpha-chars.function.js +0 -10
  244. package/dist/esm/lib/functions/remove-element-at-index.function.d.ts +0 -1
  245. package/dist/esm/lib/functions/remove-element-at-index.function.js +0 -12
  246. package/dist/esm/lib/functions/round.function.d.ts +0 -1
  247. package/dist/esm/lib/functions/round.function.js +0 -7
  248. package/dist/esm/lib/functions/sanitize-filename.function.d.ts +0 -1
  249. package/dist/esm/lib/functions/sanitize-filename.function.js +0 -10
  250. package/dist/esm/lib/functions/sleep.function.d.ts +0 -1
  251. package/dist/esm/lib/functions/sleep.function.js +0 -6
  252. package/dist/esm/lib/functions/snake-case.function.d.ts +0 -24
  253. package/dist/esm/lib/functions/subtract-offset.function.d.ts +0 -1
  254. package/dist/esm/lib/functions/subtract-offset.function.js +0 -13
  255. package/dist/esm/lib/functions/to-boolean-string.function.d.ts +0 -1
  256. package/dist/esm/lib/functions/to-boolean-string.function.js +0 -6
  257. package/dist/esm/lib/functions/to-calendar-date.function.d.ts +0 -1
  258. package/dist/esm/lib/functions/to-calendar-date.function.js +0 -11
  259. package/dist/esm/lib/functions/to-csv-string.function.d.ts +0 -1
  260. package/dist/esm/lib/functions/to-csv-string.function.js +0 -6
  261. package/dist/esm/lib/functions/to-decimal-base.function.d.ts +0 -1
  262. package/dist/esm/lib/functions/to-decimal-base.function.js +0 -21
  263. package/dist/esm/lib/functions/to-dollars-and-cents.function.d.ts +0 -1
  264. package/dist/esm/lib/functions/to-dollars-and-cents.function.js +0 -16
  265. package/dist/esm/lib/functions/to-string.function.d.ts +0 -1
  266. package/dist/esm/lib/functions/to-string.function.js +0 -25
  267. package/dist/esm/lib/functions/to-unique-array.function.d.ts +0 -1
  268. package/dist/esm/lib/functions/to-unique-array.function.js +0 -6
  269. package/dist/esm/lib/functions/to-words.function.d.ts +0 -1
  270. package/dist/esm/lib/functions/to-words.function.js +0 -91
  271. package/dist/esm/lib/functions/try-json-parse.d.ts +0 -1
  272. package/dist/esm/lib/functions/try-json-parse.js +0 -14
  273. package/dist/esm/lib/functions/try-json-stringify.d.ts +0 -1
  274. package/dist/esm/lib/functions/try-json-stringify.js +0 -14
  275. package/dist/esm/lib/functions/try-parse-date.function.d.ts +0 -1
  276. package/dist/esm/lib/functions/try-parse-date.function.js +0 -16
  277. package/dist/esm/lib/functions/unicode-words.const.d.ts +0 -8
  278. package/dist/esm/lib/functions/unicode-words.const.js +0 -68
  279. package/dist/esm/lib/functions/upper-first.function.d.ts +0 -1
  280. package/dist/esm/lib/functions/upper-first.function.js +0 -12
  281. package/dist/esm/lib/functions/words.function.d.ts +0 -17
  282. package/dist/esm/lib/functions/words.function.js +0 -34
  283. package/dist/esm/lib/interfaces/axios-wrapped-nest-exception.interface.js +0 -2
  284. package/dist/esm/lib/interfaces/entity-provider.interface.d.ts +0 -9
  285. package/dist/esm/lib/interfaces/entity-provider.interface.js +0 -2
  286. package/dist/esm/lib/interfaces/keys-of.type.d.ts +0 -3
  287. package/dist/esm/lib/interfaces/keys-of.type.js +0 -2
  288. package/dist/esm/lib/interfaces/lookup.interface.d.ts +0 -4
  289. package/dist/esm/lib/interfaces/lookup.interface.js +0 -2
  290. package/dist/types/index.d.ts +0 -43
  291. package/dist/types/lib/constants/decimal-regex.constant.d.ts +0 -1
  292. package/dist/types/lib/constants/millis-per-day.constant.d.ts +0 -1
  293. package/dist/types/lib/constants/millis-per-hour.constant.d.ts +0 -1
  294. package/dist/types/lib/constants/millis-per-minute.constant.d.ts +0 -1
  295. package/dist/types/lib/functions/add-offset.function.d.ts +0 -1
  296. package/dist/types/lib/functions/camel-case.function.d.ts +0 -20
  297. package/dist/types/lib/functions/convert-object-to-literal.function.d.ts +0 -1
  298. package/dist/types/lib/functions/format-usd.function.d.ts +0 -1
  299. package/dist/types/lib/functions/from-boolean-string.function.d.ts +0 -1
  300. package/dist/types/lib/functions/from-calendar-date.function.d.ts +0 -1
  301. package/dist/types/lib/functions/from-csv-string.function.d.ts +0 -1
  302. package/dist/types/lib/functions/get-date-range-for-month.function.d.ts +0 -4
  303. package/dist/types/lib/functions/get-tag.function.d.ts +0 -1
  304. package/dist/types/lib/functions/is-symbol.function.d.ts +0 -1
  305. package/dist/types/lib/functions/is-valid-date.function.d.ts +0 -1
  306. package/dist/types/lib/functions/kebab-case.function.d.ts +0 -1
  307. package/dist/types/lib/functions/map-enum-to-array-of-values.function.d.ts +0 -1
  308. package/dist/types/lib/functions/map-enum-to-lookup-array.function.d.ts +0 -2
  309. package/dist/types/lib/functions/map-enum-to-options.function.d.ts +0 -4
  310. package/dist/types/lib/functions/money.function.d.ts +0 -1
  311. package/dist/types/lib/functions/parse-bool.function.d.ts +0 -1
  312. package/dist/types/lib/functions/properties-to-array.function.d.ts +0 -1
  313. package/dist/types/lib/functions/remove-alpha-chars.function.d.ts +0 -1
  314. package/dist/types/lib/functions/remove-element-at-index.function.d.ts +0 -1
  315. package/dist/types/lib/functions/round.function.d.ts +0 -1
  316. package/dist/types/lib/functions/sanitize-filename.function.d.ts +0 -1
  317. package/dist/types/lib/functions/sleep.function.d.ts +0 -1
  318. package/dist/types/lib/functions/snake-case.function.d.ts +0 -24
  319. package/dist/types/lib/functions/subtract-offset.function.d.ts +0 -1
  320. package/dist/types/lib/functions/to-boolean-string.function.d.ts +0 -1
  321. package/dist/types/lib/functions/to-calendar-date.function.d.ts +0 -1
  322. package/dist/types/lib/functions/to-csv-string.function.d.ts +0 -1
  323. package/dist/types/lib/functions/to-decimal-base.function.d.ts +0 -1
  324. package/dist/types/lib/functions/to-dollars-and-cents.function.d.ts +0 -1
  325. package/dist/types/lib/functions/to-string.function.d.ts +0 -1
  326. package/dist/types/lib/functions/to-unique-array.function.d.ts +0 -1
  327. package/dist/types/lib/functions/to-words.function.d.ts +0 -1
  328. package/dist/types/lib/functions/try-json-parse.d.ts +0 -1
  329. package/dist/types/lib/functions/try-json-stringify.d.ts +0 -1
  330. package/dist/types/lib/functions/try-parse-date.function.d.ts +0 -1
  331. package/dist/types/lib/functions/unicode-words.const.d.ts +0 -8
  332. package/dist/types/lib/functions/upper-first.function.d.ts +0 -1
  333. package/dist/types/lib/functions/words.function.d.ts +0 -17
  334. package/dist/types/lib/interfaces/axios-wrapped-nest-exception.interface.d.ts +0 -5
  335. package/dist/types/lib/interfaces/entity-provider.interface.d.ts +0 -9
  336. package/dist/types/lib/interfaces/keys-of.type.d.ts +0 -3
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@onivoro/server-common",
3
+ "version": "23.0.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@onivoro/isomorphic-common": "23.0.0",
9
+ "@onivoro/server-b2b-orm": "23.0.0",
10
+ "tslib": "^2.3.0"
11
+ }
12
+ }
package/jest.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ displayName: 'lib-isomorphic-common',
4
+ preset: '../../../jest.preset.js',
5
+ testEnvironment: 'node',
6
+ transform: {
7
+ '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8
+ },
9
+ moduleFileExtensions: ['ts', 'js', 'html'],
10
+ coverageDirectory: '../../../coverage/libs/isomorphic/common',
11
+ };
package/package.json CHANGED
@@ -1,41 +1,10 @@
1
1
  {
2
- "name": "@onivoro/isomorphic-common",
3
- "version": "22.0.5",
4
- "repository": {
5
- "url": "git+https://github.com/onivoro/isomorphic-common.git"
6
- },
7
- "main": "dist/cjs/index.js",
8
- "module": "dist/esm/index.js",
9
- "types": "dist/types/index.d.ts",
10
- "files": [
11
- "dist/*"
12
- ],
13
- "scripts": {
14
- "onx": "onx",
15
- "build": "onx Build",
16
- "deploy": "onx Publish",
17
- "test": "onx Test",
18
- "update": "onx Update"
19
- },
20
- "exports": {
21
- ".": {
22
- "types": "./dist/types/index.d.ts",
23
- "require": "./dist/cjs/index.js",
24
- "import": "./dist/esm/index.js",
25
- "default": "./dist/esm/lib.js"
26
- }
27
- },
28
- "onx": {
29
- "platform": "isomorphic",
30
- "module": "commonjs"
31
- },
32
- "devDependencies": {
33
- "@onivoro/cli": "^22.0.8",
34
- "@types/jest": "*",
35
- "typescript": "*"
36
- },
37
- "engines": {
38
- "node": "22.10.0",
39
- "npm": "10.9.0"
40
- }
2
+ "name": "@onivoro/isomorphic-common",
3
+ "version": "24.0.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "tslib": "^2.3.0"
9
+ }
41
10
  }
package/project.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "lib-isomorphic-common",
3
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/isomorphic/common/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "@nx/js:tsc",
9
+ "outputs": ["{options.outputPath}"],
10
+ "options": {
11
+ "outputPath": "dist/libs/isomorphic/common",
12
+ "main": "libs/isomorphic/common/src/index.ts",
13
+ "tsConfig": "libs/isomorphic/common/tsconfig.lib.json",
14
+ "assets": [
15
+ "libs/isomorphic/common/README.md",
16
+ "libs/isomorphic/common/package.json"
17
+ ],
18
+ "declaration": true
19
+ }
20
+ }
21
+ },
22
+ "tags": []
23
+ }
@@ -1,7 +1,43 @@
1
- export * from './lib/constants/decimal-regex.constant';
1
+ export * from './lib/constants/api-id-header.constant';
2
+ export * from './lib/constants/api-key-header.constant';
3
+ export * from './lib/constants/auth-cookie-name.constant';
4
+ export * from './lib/constants/regexes.constant';
5
+
6
+ export * from './lib/functions/arrange-act-assert.function';
7
+ export * from './lib/functions/mock-calls.function';
8
+
9
+ export * from './lib/functions/chunk.function';
10
+ export * from './lib/functions/format-usd.function';
11
+ export * from './lib/functions/get-date-last-month.function';
12
+ export * from './lib/functions/get-date-range-for-month.function';
13
+ export * from './lib/functions/get-user-full-name.function';
14
+ export * from './lib/functions/is-valid-date.function';
15
+ export * from './lib/functions/map-entities-to-options.function';
16
+ export * from './lib/functions/map-enum-to-array-of-values.function';
17
+ export * from './lib/functions/map-enum-to-lookup-array.function';
18
+ export * from './lib/functions/map-enum-to-options.function';
19
+ export * from './lib/functions/remove-element-at-index.function';
20
+ export * from './lib/functions/round.function';
21
+ export * from './lib/functions/sort-by-created-at.function';
22
+ export * from './lib/functions/sort-by-full-name.function';
23
+ export * from './lib/functions/sort-by-id.function';
24
+ export * from './lib/functions/sort-by-name.function';
25
+ export * from './lib/functions/sort-numbers.function';
26
+ export * from './lib/functions/split-date-range-into-days.function';
27
+ export * from './lib/functions/use-date.function';
28
+
29
+ export * from './lib/types/access-token.interface';
30
+ export * from './lib/types/company.type';
31
+ export * from './lib/types/createable.type';
32
+ export * from './lib/types/keys-of.type';
33
+ export * from './lib/types/lookup.interface';
34
+ export * from './lib/types/nameable.type';
35
+
2
36
  export * from './lib/constants/millis-per-day.constant';
3
37
  export * from './lib/constants/millis-per-hour.constant';
4
38
  export * from './lib/constants/millis-per-minute.constant';
39
+ export * from './lib/constants/regexes.constant';
40
+
5
41
  export * from './lib/functions/add-offset.function';
6
42
  export * from './lib/functions/camel-case.function';
7
43
  export * from './lib/functions/convert-object-to-literal.function';
@@ -37,7 +73,8 @@ export * from './lib/functions/try-parse-date.function';
37
73
  export * from './lib/functions/unicode-words.const';
38
74
  export * from './lib/functions/upper-first.function';
39
75
  export * from './lib/functions/words.function';
40
- export * from './lib/interfaces/axios-wrapped-nest-exception.interface';
41
- export * from './lib/interfaces/entity-provider.interface';
42
- export * from './lib/interfaces/keys-of.type';
43
- export * from './lib/interfaces/lookup.interface';
76
+
77
+ export * from './lib/types/axios-wrapped-nest-exception.interface';
78
+ export * from './lib/types/entity-provider.interface';
79
+ export * from './lib/types/keys-of.type';
80
+ export * from './lib/types/lookup.interface';
@@ -0,0 +1 @@
1
+ export const apiIdHeader = 'x-api-id';
@@ -0,0 +1 @@
1
+ export const apiKeyHeader = 'x-api-key';
@@ -0,0 +1,2 @@
1
+ // TODO: REMOVE THIS BAD PATTERN OF HAVING LOWER LEVEL LIBS AWARE OF HIGHER ORDER LIBS/APPS
2
+ export const authCookieName = 'token';
@@ -0,0 +1,3 @@
1
+ import { MILLIS_PER_HOUR } from "./millis-per-hour.constant";
2
+
3
+ export const MILLIS_PER_DAY = MILLIS_PER_HOUR * 24;
@@ -0,0 +1,3 @@
1
+ import { MILLIS_PER_MINUTE } from "./millis-per-minute.constant";
2
+
3
+ export const MILLIS_PER_HOUR = MILLIS_PER_MINUTE * 60;
@@ -0,0 +1 @@
1
+ export const MILLIS_PER_MINUTE = 1000 * 60;
@@ -0,0 +1,30 @@
1
+ export const oneOrMoreSpaces = /\s{1,}/g;
2
+ export const multipleSpaces = /\s{2,}/g;
3
+ export const comma = /,/g;
4
+ export const dashesLettersNumbers = /^([a-z]|-|\d)*$/i;
5
+ export const dashesLettersNumbersSpaces = /^([a-z]|-|\s|\d)*$/i;
6
+ export const zip = /^\d{5}$/;
7
+ export const phone = /^\d{3}-\d{3}-\d{4}$/;
8
+ export const phonePlusOne = /^\+1\d{10}$/;
9
+ export const code = /^\d{6}$/;
10
+ export const url = /(https?:\/\/|https?:\/\/).*\..+/;
11
+ export const protocol = /https?:\/\/|https?:\/\//;
12
+ export const firstSpaceLast = /[a-z]+\s[a-z]+([a-z]|')+[a-z]+/i;
13
+ export const passwordNumber = /\d/;
14
+ export const passwordUpper = /[A-Z]/;
15
+ export const passwordLower = /[a-z]/;
16
+ export const passwordSpecial = /\^|\$|\*|\.|\?|-|!|@|#|%|>|<|:|;|_|~|\+|=/;
17
+ export const ssn = /^\d{3}-\d{2}-\d{4}$/;
18
+ export const numeric = /^(\d|\.)*$/;
19
+ export const duns = /^\d{9}$/;
20
+ export const lastFourSocial = /^\d{4}$/;
21
+ export const ein = /^\d{2}-\d{7}$/;
22
+ export const stateShort = /^[A-Z]{2}$/;
23
+ export const email = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
24
+ export const domain = /^(?!:\/\/)([a-zA-Z0-9-_]{1,63}\.)+[a-zA-Z]{2,63}$/;
25
+ export const emailDomain = /^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
26
+ export const v4 = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
27
+ export const dateIso8601 = /^\d{4}-\d{1,2}-\d{1,2}$/;
28
+ export const dateIso8601WithTime = /^\d{4}-\d{1,2}-\d{1,2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
29
+ export const decimalRegex = /(\d|\.)/g;
30
+ export const slashR = /\r/g;
@@ -0,0 +1,94 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`chunk given 1, returns an array of arrays 1`] = `
4
+ [
5
+ [
6
+ "one",
7
+ "two",
8
+ "three",
9
+ "four",
10
+ "five",
11
+ "six",
12
+ "seven",
13
+ "eight",
14
+ ],
15
+ ]
16
+ `;
17
+
18
+ exports[`chunk given 2, returns an array of arrays 1`] = `
19
+ [
20
+ [
21
+ "one",
22
+ "two",
23
+ "three",
24
+ "four",
25
+ ],
26
+ [
27
+ "five",
28
+ "six",
29
+ "seven",
30
+ "eight",
31
+ ],
32
+ ]
33
+ `;
34
+
35
+ exports[`chunk given 3, returns an array of arrays 1`] = `
36
+ [
37
+ [
38
+ "one",
39
+ "two",
40
+ "three",
41
+ ],
42
+ [
43
+ "four",
44
+ "five",
45
+ "six",
46
+ ],
47
+ [
48
+ "seven",
49
+ "eight",
50
+ ],
51
+ ]
52
+ `;
53
+
54
+ exports[`chunk given 4, returns an array of arrays 1`] = `
55
+ [
56
+ [
57
+ "one",
58
+ "two",
59
+ ],
60
+ [
61
+ "three",
62
+ "four",
63
+ ],
64
+ [
65
+ "five",
66
+ "six",
67
+ ],
68
+ [
69
+ "seven",
70
+ "eight",
71
+ ],
72
+ ]
73
+ `;
74
+
75
+ exports[`chunk given 5, returns an array of arrays 1`] = `
76
+ [
77
+ [
78
+ "one",
79
+ "two",
80
+ ],
81
+ [
82
+ "three",
83
+ "four",
84
+ ],
85
+ [
86
+ "five",
87
+ "six",
88
+ ],
89
+ [
90
+ "seven",
91
+ "eight",
92
+ ],
93
+ ]
94
+ `;
@@ -0,0 +1,50 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`splitDateRangeIntoDays given {"from":"","to":""}, returns an array of days 1`] = `[]`;
4
+
5
+ exports[`splitDateRangeIntoDays given {"from":"2024-01-01","to":"2024-01-01"}, returns an array of days 1`] = `
6
+ [
7
+ "2024-01-01",
8
+ ]
9
+ `;
10
+
11
+ exports[`splitDateRangeIntoDays given {"from":"2024-01-01","to":"2024-02-01"}, returns an array of days 1`] = `
12
+ [
13
+ "2024-01-01",
14
+ "2024-01-02",
15
+ "2024-01-03",
16
+ "2024-01-04",
17
+ "2024-01-05",
18
+ "2024-01-06",
19
+ "2024-01-07",
20
+ "2024-01-08",
21
+ "2024-01-09",
22
+ "2024-01-10",
23
+ "2024-01-11",
24
+ "2024-01-12",
25
+ "2024-01-13",
26
+ "2024-01-14",
27
+ "2024-01-15",
28
+ "2024-01-16",
29
+ "2024-01-17",
30
+ "2024-01-18",
31
+ "2024-01-19",
32
+ "2024-01-20",
33
+ "2024-01-21",
34
+ "2024-01-22",
35
+ "2024-01-23",
36
+ "2024-01-24",
37
+ "2024-01-25",
38
+ "2024-01-26",
39
+ "2024-01-27",
40
+ "2024-01-28",
41
+ "2024-01-29",
42
+ "2024-01-30",
43
+ "2024-01-31",
44
+ "2024-02-01",
45
+ ]
46
+ `;
47
+
48
+ exports[`splitDateRangeIntoDays given {"from":"2025-01-01","to":""}, returns an array of days 1`] = `[]`;
49
+
50
+ exports[`splitDateRangeIntoDays given {"from":"asdf","to":"2345"}, returns an array of days 1`] = `[]`;
@@ -0,0 +1,12 @@
1
+ import { addOffset } from './add-offset.function';
2
+
3
+ describe('addOffset', () => {
4
+ describe('GIVEN input is partial or full ISO8601', () => {
5
+ it.each([
6
+ '2023-12-23',
7
+ '2023-12-23T00:00:00.000',
8
+ ])('%j', (input) => {
9
+ expect(addOffset(input)).toMatchSnapshot();
10
+ });
11
+ });
12
+ });
@@ -0,0 +1,14 @@
1
+ import { MILLIS_PER_MINUTE } from '../constants/millis-per-minute.constant';
2
+ import { tryParseDate } from './try-parse-date.function';
3
+
4
+ export function addOffset(input: string | Date | undefined | null): Date | undefined {
5
+ const parsed = tryParseDate(input);
6
+
7
+ if(!parsed) {
8
+ return;
9
+ }
10
+
11
+ const offset = (parsed).getTimezoneOffset();
12
+
13
+ return new Date(parsed.valueOf() + offset * MILLIS_PER_MINUTE);
14
+ }
@@ -0,0 +1,23 @@
1
+ // YOU MUST AWAIT THIS FUNCTION WHEN INVOKING IT!!!
2
+
3
+ // TODO: PUT THIS IN A TEST-ONLY LIBRARY => LIBS/ISO/JEST
4
+
5
+ export async function arrangeActAssert<TArrangeOutput, TActOutput>({ arrange, act, assert }: { arrange: () => TArrangeOutput, act: (_: TArrangeOutput) => TActOutput, assert: (_: TArrangeOutput & { result: TActOutput }) => any }) {
6
+ const arrangeOutput = arrange();
7
+
8
+ const actInput = isPromise(arrangeOutput) ? await arrangeOutput : arrangeOutput;
9
+
10
+ const actOutput = act(actInput);
11
+
12
+ const assertInput = isPromise(actOutput) ? await actOutput : actOutput;
13
+
14
+ const assertOutput = assert({ ...actInput, result: assertInput });
15
+
16
+ const returnValue = isPromise(assertOutput) ? await assertOutput : assertOutput;
17
+
18
+ return returnValue;
19
+ }
20
+
21
+ function isPromise(value: any) {
22
+ return (typeof value?.then) === 'function';
23
+ }
@@ -0,0 +1,30 @@
1
+ // https://github.com/lodash/lodash/blob/main/src/camelCase.ts
2
+
3
+ import { toString } from './to-string.function';
4
+ import { upperFirst } from './upper-first.function';
5
+ import { words } from './words.function';
6
+
7
+ /**
8
+ * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
9
+ *
10
+ * @since 3.0.0
11
+ * @category String
12
+ * @param {string} [string=''] The string to convert.
13
+ * @returns {string} Returns the camel cased string.
14
+ * @see lowerCase, kebabCase, snakeCase, startCase, upperCase, upperFirst
15
+ * @example
16
+ *
17
+ * camelCase('Foo Bar')
18
+ * // => 'fooBar'
19
+ *
20
+ * camelCase('--foo-bar--')
21
+ * // => 'fooBar'
22
+ *
23
+ * camelCase('__FOO_BAR__')
24
+ * // => 'fooBar'
25
+ */
26
+ export const camelCase = (string: string): string =>
27
+ (words(toString(string).replace(/['\u2019]/g, '')) as string[]).reduce((result: string, word: string, index: number) => {
28
+ word = word.toLowerCase();
29
+ return result + (index ? upperFirst(word) : word);
30
+ }, '');
@@ -0,0 +1,20 @@
1
+ import { chunk } from './chunk.function';
2
+ import { arrangeActAssert } from '../functions/arrange-act-assert.function';
3
+
4
+ const array = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'];
5
+
6
+ describe('chunk', () => {
7
+ it.each([
8
+ [1],
9
+ [2],
10
+ [3],
11
+ [4],
12
+ [5],
13
+ ])('given %j, returns an array of arrays', async (_) => await arrangeActAssert({
14
+ arrange: () => ({ subject: chunk }),
15
+ act: ({ subject }) => subject(array, _),
16
+ assert: ({ result }) => {
17
+ expect(result).toMatchSnapshot();
18
+ }
19
+ }));
20
+ });
@@ -0,0 +1,25 @@
1
+ export function chunk<T>(array: T[], numDivisions: number): T[][] {
2
+ if (numDivisions <= 0) {
3
+ throw new Error('Number of divisions must be greater than or equal to 0');
4
+ }
5
+
6
+ if (array.length === 0) {
7
+ return [];
8
+ }
9
+
10
+ const result: T[][] = [];
11
+ const chunkSize = Math.ceil(array.length / numDivisions);
12
+
13
+ for (let i = 0; i < array.length; i += chunkSize) {
14
+ result.push(array.slice(i, i + chunkSize));
15
+ }
16
+
17
+ while (result.length > numDivisions) {
18
+ const lastChunk = result.pop();
19
+ if (lastChunk) {
20
+ result[result.length - 1].push(...lastChunk);
21
+ }
22
+ }
23
+
24
+ return result;
25
+ }
@@ -0,0 +1,16 @@
1
+ import { convertObjectToLiteral } from './convert-object-to-literal.function';
2
+
3
+ const qty = 337;
4
+ const price = 100;
5
+ const product = 'flux-capacitor';
6
+
7
+ describe('convertObjectToLiteral', () => {
8
+ it.each([[(k, v) => `${k}=${v}`, ' AND ', { qty, price, product }]])(
9
+ 'converts an object to a string',
10
+ (literalFn, delimiter, obj) => {
11
+ expect(
12
+ convertObjectToLiteral(literalFn, delimiter, obj)
13
+ ).toMatchSnapshot();
14
+ }
15
+ );
16
+ });
@@ -0,0 +1,10 @@
1
+ export function convertObjectToLiteral(
2
+ literalFn: (k: string, v: any) => string,
3
+ delimiter: string,
4
+ keyValuePairs: Record<string, any>
5
+ ) {
6
+ return Object.entries(keyValuePairs)
7
+ .filter(([, v]) => !!v || v === 0 || v === false)
8
+ .map(([k, v]) => literalFn(k, v?.toString?.()))
9
+ .join(delimiter);
10
+ }
@@ -0,0 +1,4 @@
1
+ export function formatUsd(rawAmount?: number | string) {
2
+ const amount = Number(rawAmount) || 0;
3
+ return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amount);
4
+ }
@@ -0,0 +1,3 @@
1
+ export function fromBooleanString(value?: string) {
2
+ return value === 'true';
3
+ }
@@ -0,0 +1,11 @@
1
+ import { fromCalendarDate } from './from-calendar-date.function';
2
+
3
+ describe('fromCalendarDate', () => {
4
+ describe('GIVEN input is partial or full ISO8601', () => {
5
+ it.each([
6
+ '2023-12-23',
7
+ ])('%j', (input) => {
8
+ expect(fromCalendarDate(input)).toMatchSnapshot();
9
+ });
10
+ });
11
+ });
@@ -0,0 +1,5 @@
1
+ import { addOffset } from "./add-offset.function";
2
+
3
+ export function fromCalendarDate(input: string | Date | undefined | null): Date | null {
4
+ return addOffset(input) || null;
5
+ }
@@ -0,0 +1,3 @@
1
+ export function fromCsvString(value?: string) {
2
+ return value ? value.split(',').map((v) => v.trim()) : [];
3
+ }
@@ -0,0 +1,6 @@
1
+ import { MILLIS_PER_DAY } from "../constants/millis-per-day.constant";
2
+
3
+ export function getDateLastMonth() {
4
+ const days = new Date().getUTCDate() + 1;
5
+ return new Date(Date.now() - (MILLIS_PER_DAY * days));
6
+ }
@@ -0,0 +1,8 @@
1
+ import { MILLIS_PER_DAY } from "../constants/millis-per-day.constant";
2
+
3
+ export function getDateRangeForMonth(year: number, month: number) {
4
+ const startDate = new Date(+Date.UTC(year, month + -1, 0) + MILLIS_PER_DAY);
5
+ const endDate = new Date(+Date.UTC(year, month + 0, 0) + MILLIS_PER_DAY);
6
+
7
+ return { startDate, endDate };
8
+ }
@@ -0,0 +1,8 @@
1
+ import { MILLIS_PER_DAY } from "../constants/millis-per-day.constant";
2
+
3
+ export function getDateRangeForMonth(year: number, month: number) {
4
+ const startDate = new Date(+Date.UTC(year, month + -1, 0) + MILLIS_PER_DAY);
5
+ const endDate = new Date(+Date.UTC(year, month + 0, 0) + MILLIS_PER_DAY);
6
+
7
+ return { startDate, endDate };
8
+ }
@@ -0,0 +1,10 @@
1
+ // https://github.com/lodash/lodash/blob/main/src/.internal/getTag.ts
2
+
3
+ const toString = Object.prototype.toString
4
+
5
+ export function getTag(value: any): string {
6
+ if (value == null) {
7
+ return value === undefined ? '[object Undefined]' : '[object Null]'
8
+ }
9
+ return toString.call(value)
10
+ }
@@ -0,0 +1,5 @@
1
+ import { TNameable } from "../types/nameable.type";
2
+
3
+ export function getUserFullName(user: TNameable | undefined): string {
4
+ return `${user?.firstName} ${user?.lastName}`;
5
+ }
@@ -0,0 +1,11 @@
1
+ // https://github.com/lodash/lodash/blob/main/src/isSymbol.ts
2
+
3
+ import { getTag } from './get-tag.function';
4
+
5
+ export function isSymbol(value: any): boolean {
6
+ const type = typeof value;
7
+ return (
8
+ type === 'symbol' ||
9
+ (type === 'object' && value != null && getTag(value) === '[object Symbol]')
10
+ );
11
+ }
@@ -0,0 +1,5 @@
1
+ export function isValidDate(dateString: string | Date) {
2
+ const date = new Date(dateString);
3
+
4
+ return (date instanceof Date && !isNaN(date.getTime())) ? date : undefined;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { snakeCase } from "./snake-case.function";
2
+
3
+ export function kebabCase(string: string) {
4
+ return snakeCase(string).replace(/_/g, '-');
5
+ }
@@ -0,0 +1,11 @@
1
+ export function mapEntitiesToOptions<TEntity extends { name?: string, id: string }>(
2
+ entities: Record<string, TEntity>,
3
+ ids: string[],
4
+ includeBlank = true,
5
+ ) {
6
+ const entityArray = ids?.length ? (ids?.map((value => ({ value, display: entities[value].name || entities[value].id })))) : [];
7
+
8
+ return includeBlank
9
+ ? [{ display: '', value: '' }, ...entityArray]
10
+ : entityArray;
11
+ }
@@ -0,0 +1,3 @@
1
+ export function mapEnumToArrayOfValues(enumeration: any): any {
2
+ return Object.entries(enumeration).map(([key, value]) => value) as string[];
3
+ }
@@ -0,0 +1,3 @@
1
+ export function mapEnumToArrayOfValues(enumeration: any): any {
2
+ return Object.entries(enumeration).map(([key, value]) => value) as string[];
3
+ }