@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,393 @@
1
+ # @onivoro/isomorphic-common
2
+
3
+ Common utilities, functions, types, and constants shared between browser and server environments. This comprehensive library provides essential building blocks for TypeScript applications with a focus on type safety, reliability, and consistent behavior across different runtime environments.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @onivoro/isomorphic-common
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **Isomorphic Design**: Works identically in browser and Node.js environments
14
+ - **String Manipulation**: Case conversion, formatting, and validation utilities
15
+ - **Array Operations**: Chunking, sorting, deduplication, and transformation functions
16
+ - **Date/Time Utilities**: Calendar operations, offset calculations, and formatting
17
+ - **Financial Functions**: Currency formatting, money calculations, and validation
18
+ - **Type Utilities**: Advanced TypeScript type helpers and interfaces
19
+ - **Validation Functions**: Data validation and parsing utilities
20
+ - **Testing Helpers**: Mock functions and test arrangement utilities
21
+ - **Constants**: Common values, regex patterns, and configuration constants
22
+
23
+ ## Quick Start
24
+
25
+ ### String Operations
26
+
27
+ ```typescript
28
+ import {
29
+ camelCase,
30
+ kebabCase,
31
+ snakeCase,
32
+ upperFirst,
33
+ sanitizeFilename,
34
+ formatUsd
35
+ } from '@onivoro/isomorphic-common';
36
+
37
+ // Case conversions
38
+ camelCase('hello world'); // 'helloWorld'
39
+ kebabCase('Hello World'); // 'hello-world'
40
+ snakeCase('Hello World'); // 'hello_world'
41
+ upperFirst('hello'); // 'Hello'
42
+
43
+ // File operations
44
+ sanitizeFilename('My File/Name?.txt'); // 'My File Name .txt'
45
+
46
+ // Currency formatting
47
+ formatUsd(1234.56); // '$1,234.56'
48
+ formatUsd('1234.56'); // '$1,234.56'
49
+ ```
50
+
51
+ ### Array Manipulation
52
+
53
+ ```typescript
54
+ import {
55
+ chunk,
56
+ toUniqueArray,
57
+ removeElementAtIndex,
58
+ sortByName,
59
+ sortById,
60
+ sortNumbers
61
+ } from '@onivoro/isomorphic-common';
62
+
63
+ // Chunking arrays
64
+ chunk([1, 2, 3, 4, 5, 6], 3); // [[1, 2], [3, 4], [5, 6]]
65
+
66
+ // Remove duplicates
67
+ toUniqueArray([1, 2, 2, 3, 3, 4]); // [1, 2, 3, 4]
68
+
69
+ // Remove element by index
70
+ removeElementAtIndex(['a', 'b', 'c'], 1); // ['a', 'c']
71
+
72
+ // Sorting utilities
73
+ sortByName([{name: 'Bob'}, {name: 'Alice'}]); // [{name: 'Alice'}, {name: 'Bob'}]
74
+ sortById([{id: 3}, {id: 1}, {id: 2}]); // [{id: 1}, {id: 2}, {id: 3}]
75
+ sortNumbers([3, 1, 4, 1, 5]); // [1, 1, 3, 4, 5]
76
+ ```
77
+
78
+ ### Date and Time Operations
79
+
80
+ ```typescript
81
+ import {
82
+ addOffset,
83
+ subtractOffset,
84
+ getDateRangeForMonth,
85
+ splitDateRangeIntoDays,
86
+ isValidDate,
87
+ tryParseDate,
88
+ toCalendarDate,
89
+ fromCalendarDate
90
+ } from '@onivoro/isomorphic-common';
91
+
92
+ // Date offset calculations
93
+ const date = new Date('2023-01-15');
94
+ addOffset(date, 7); // Add 7 days
95
+ subtractOffset(date, 2); // Subtract 2 days
96
+
97
+ // Monthly date ranges
98
+ getDateRangeForMonth(2023, 0); // January 2023 range
99
+
100
+ // Date validation
101
+ isValidDate(new Date('2023-01-15')); // true
102
+ isValidDate(new Date('invalid')); // false
103
+
104
+ // Safe date parsing
105
+ tryParseDate('2023-01-15'); // Date object or null
106
+ ```
107
+
108
+ ### Financial and Money Operations
109
+
110
+ ```typescript
111
+ import {
112
+ money,
113
+ toDollarsAndCents,
114
+ round,
115
+ formatUsd
116
+ } from '@onivoro/isomorphic-common';
117
+
118
+ // Money calculations (in cents)
119
+ const price = money(19.99); // 1999 cents
120
+ const tax = money(price * 0.08); // Calculate tax
121
+ const total = price + tax;
122
+
123
+ // Convert back to dollars
124
+ toDollarsAndCents(total); // { dollars: 21, cents: 59 }
125
+
126
+ // Rounding
127
+ round(19.999, 2); // 20.00
128
+ round(19.994, 2); // 19.99
129
+
130
+ // Currency display
131
+ formatUsd(total / 100); // '$21.59'
132
+ ```
133
+
134
+ ## Usage Examples
135
+
136
+ ### Data Transformation
137
+
138
+ ```typescript
139
+ import {
140
+ mapEnumToOptions,
141
+ mapEntitiesToOptions,
142
+ convertObjectToLiteral,
143
+ propertiestoArray
144
+ } from '@onivoro/isomorphic-common';
145
+
146
+ enum Status {
147
+ ACTIVE = 'active',
148
+ INACTIVE = 'inactive',
149
+ PENDING = 'pending'
150
+ }
151
+
152
+ // Convert enum to dropdown options
153
+ const statusOptions = mapEnumToOptions(Status);
154
+ // [{ label: 'Active', value: 'active' }, ...]
155
+
156
+ // Convert entities to options
157
+ const users = [{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }];
158
+ const userOptions = mapEntitiesToOptions(users, 'name', 'id');
159
+ // [{ label: 'John', value: 1 }, { label: 'Jane', value: 2 }]
160
+ ```
161
+
162
+ ### Boolean and String Parsing
163
+
164
+ ```typescript
165
+ import {
166
+ parseBool,
167
+ fromBooleanString,
168
+ toBooleanString,
169
+ fromCsvString,
170
+ toCsvString
171
+ } from '@onivoro/isomorphic-common';
172
+
173
+ // Boolean parsing
174
+ parseBool('true'); // true
175
+ parseBool('1'); // true
176
+ parseBool('yes'); // true
177
+ parseBool('false'); // false
178
+
179
+ // CSV operations
180
+ const items = fromCsvString('apple,banana,cherry');
181
+ // ['apple', 'banana', 'cherry']
182
+
183
+ toCsvString(['apple', 'banana', 'cherry']);
184
+ // 'apple,banana,cherry'
185
+ ```
186
+
187
+ ### Testing Utilities
188
+
189
+ ```typescript
190
+ import {
191
+ arrangeActAssert,
192
+ mockCalls
193
+ } from '@onivoro/isomorphic-common';
194
+
195
+ // Test structure helper
196
+ const testCase = arrangeActAssert({
197
+ arrange: () => ({ input: 'test data' }),
198
+ act: (arranged) => processData(arranged.input),
199
+ assert: (result) => expect(result).toBeTruthy()
200
+ });
201
+
202
+ // Mock function calls tracking
203
+ const mockTracker = mockCalls();
204
+ mockTracker.track('functionName', ['arg1', 'arg2']);
205
+ mockTracker.getCalls('functionName'); // [['arg1', 'arg2']]
206
+ ```
207
+
208
+ ## API Reference
209
+
210
+ ### String Functions
211
+
212
+ #### Case Conversion
213
+ - `camelCase(string)` - Convert to camelCase
214
+ - `kebabCase(string)` - Convert to kebab-case
215
+ - `snakeCase(string)` - Convert to snake_case
216
+ - `upperFirst(string)` - Capitalize first letter
217
+
218
+ #### String Utilities
219
+ - `sanitizeFilename(filename)` - Remove invalid filename characters
220
+ - `removeAlphaChars(string)` - Remove alphabetic characters
221
+ - `words(string)` - Split string into words array
222
+ - `toString(value)` - Convert value to string safely
223
+
224
+ ### Array Functions
225
+
226
+ #### Array Manipulation
227
+ - `chunk<T>(array, numDivisions)` - Split array into chunks
228
+ - `toUniqueArray<T>(array)` - Remove duplicate elements
229
+ - `removeElementAtIndex<T>(array, index)` - Remove element by index
230
+
231
+ #### Sorting Functions
232
+ - `sortByName<T>(array)` - Sort objects by name property
233
+ - `sortById<T>(array)` - Sort objects by id property
234
+ - `sortByFullName<T>(array)` - Sort objects by full name
235
+ - `sortByCreatedAt<T>(array)` - Sort objects by creation date
236
+ - `sortNumbers(array)` - Sort numeric array
237
+
238
+ ### Date/Time Functions
239
+
240
+ #### Date Operations
241
+ - `addOffset(date, days)` - Add days to date
242
+ - `subtractOffset(date, days)` - Subtract days from date
243
+ - `getDateRangeForMonth(year, month)` - Get month's date range
244
+ - `getDateLastMonth()` - Get previous month's date
245
+ - `splitDateRangeIntoDays(start, end)` - Split range into daily intervals
246
+
247
+ #### Date Utilities
248
+ - `isValidDate(date)` - Check if date is valid
249
+ - `tryParseDate(string)` - Safely parse date string
250
+ - `toCalendarDate(date)` - Convert to calendar format
251
+ - `fromCalendarDate(string)` - Parse calendar date string
252
+ - `useDate(date)` - React hook for date handling
253
+
254
+ #### Time Constants
255
+ - `MILLIS_PER_MINUTE` - Milliseconds in a minute
256
+ - `MILLIS_PER_HOUR` - Milliseconds in an hour
257
+ - `MILLIS_PER_DAY` - Milliseconds in a day
258
+
259
+ ### Financial Functions
260
+
261
+ #### Money Operations
262
+ - `money(amount)` - Convert dollars to cents
263
+ - `toDollarsAndCents(cents)` - Convert cents to dollars/cents object
264
+ - `formatUsd(amount)` - Format as USD currency
265
+ - `round(number, precision)` - Round to decimal places
266
+
267
+ ### Type Utilities
268
+
269
+ #### Interfaces
270
+ - `ILookup<T>` - Key-value lookup interface
271
+ - `IAccessToken` - Access token structure
272
+ - `IEntityProvider<T>` - Entity provider interface
273
+
274
+ #### Type Helpers
275
+ - `KeysOf<T>` - Extract keys of type T
276
+ - `Createable<T>` - Type for creatable entities
277
+ - `Nameable` - Type for entities with name property
278
+ - `Company` - Company type definition
279
+
280
+ ### Data Transformation
281
+
282
+ #### Enum Utilities
283
+ - `mapEnumToOptions(enum)` - Convert enum to option array
284
+ - `mapEnumToArrayOfValues(enum)` - Convert enum to value array
285
+ - `mapEnumToLookupArray(enum)` - Convert enum to lookup array
286
+
287
+ #### Object Utilities
288
+ - `convertObjectToLiteral(object)` - Convert to literal object
289
+ - `propertiesToArray(object)` - Convert properties to array
290
+ - `mapEntitiesToOptions(entities, labelKey, valueKey)` - Convert entities to options
291
+
292
+ ### Validation Functions
293
+
294
+ #### Data Validation
295
+ - `parseBool(value)` - Parse boolean from various formats
296
+ - `isSymbol(value)` - Check if value is symbol
297
+ - `tryJsonParse(string)` - Safely parse JSON
298
+ - `tryJsonStringify(object)` - Safely stringify JSON
299
+
300
+ #### String Validation
301
+ - `fromBooleanString(string)` - Convert string to boolean
302
+ - `toBooleanString(boolean)` - Convert boolean to string
303
+ - `fromCsvString(string)` - Parse CSV string
304
+ - `toCsvString(array)` - Convert array to CSV
305
+
306
+ ### Utility Functions
307
+
308
+ #### General Utilities
309
+ - `sleep(milliseconds)` - Async sleep function
310
+ - `getTag(value)` - Get object type tag
311
+ - `getUserFullName(user)` - Get user's full name
312
+ - `toDecimalBase(number, base)` - Convert to decimal base
313
+
314
+ #### Testing Helpers
315
+ - `arrangeActAssert(config)` - Structure test cases
316
+ - `mockCalls()` - Track mock function calls
317
+
318
+ ### Constants
319
+
320
+ #### Headers and Authentication
321
+ - `API_ID_HEADER` - API ID header constant
322
+ - `API_KEY_HEADER` - API key header constant
323
+ - `AUTH_COOKIE_NAME` - Authentication cookie name
324
+
325
+ #### Regular Expressions
326
+ - `REGEXES` - Common regex patterns object
327
+
328
+ ## Advanced Usage
329
+
330
+ ### Custom Type Guards
331
+
332
+ ```typescript
333
+ import { isSymbol, isValidDate } from '@onivoro/isomorphic-common';
334
+
335
+ function processValue(value: unknown) {
336
+ if (isSymbol(value)) {
337
+ return value.toString();
338
+ }
339
+
340
+ if (value instanceof Date && isValidDate(value)) {
341
+ return value.toISOString();
342
+ }
343
+
344
+ return String(value);
345
+ }
346
+ ```
347
+
348
+ ### Complex Data Transformations
349
+
350
+ ```typescript
351
+ import {
352
+ chunk,
353
+ mapEntitiesToOptions,
354
+ sortByName,
355
+ toUniqueArray
356
+ } from '@onivoro/isomorphic-common';
357
+
358
+ function processUserData(users: User[]) {
359
+ return chunk(
360
+ toUniqueArray(
361
+ sortByName(users)
362
+ ),
363
+ 10 // Process in batches of 10
364
+ ).map(batch =>
365
+ mapEntitiesToOptions(batch, 'fullName', 'id')
366
+ );
367
+ }
368
+ ```
369
+
370
+ ### Date Range Operations
371
+
372
+ ```typescript
373
+ import {
374
+ getDateRangeForMonth,
375
+ splitDateRangeIntoDays,
376
+ addOffset,
377
+ subtractOffset
378
+ } from '@onivoro/isomorphic-common';
379
+
380
+ function getMonthlyReportDates(year: number, month: number) {
381
+ const { start, end } = getDateRangeForMonth(year, month);
382
+
383
+ // Add buffer days
384
+ const reportStart = subtractOffset(start, 1);
385
+ const reportEnd = addOffset(end, 1);
386
+
387
+ return splitDateRangeIntoDays(reportStart, reportEnd);
388
+ }
389
+ ```
390
+
391
+ ## License
392
+
393
+ MIT
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@onivoro/isomorphic-common",
3
+ "version": "23.0.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "tslib": "^2.3.0"
9
+ }
10
+ }
@@ -0,0 +1,322 @@
1
+ # @onivoro/server-common
2
+
3
+ A comprehensive collection of common server utilities, DTOs, decorators, pipes, and functions for building robust NestJS applications. This library provides foundational components used across enterprise-scale server applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @onivoro/server-common
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **NestJS Module**: Ready-to-import server common module
14
+ - **Error Handling**: Advanced error filters for TypeORM and general exceptions
15
+ - **API Decorators**: OpenAPI documentation decorators and response formatters
16
+ - **DTOs**: Common data transfer objects for typical API operations
17
+ - **Validation Pipes**: Custom pipes for data parsing and validation
18
+ - **Utility Functions**: Helper functions for API creation, encoding, file operations, and more
19
+ - **Environment Management**: Environment variable handling and configuration
20
+ - **Application Bootstrap**: Functions for creating and configuring API applications
21
+
22
+ ## Quick Start
23
+
24
+ ### Import the Module
25
+
26
+ ```typescript
27
+ import { ServerCommonModule } from '@onivoro/server-common';
28
+
29
+ @Module({
30
+ imports: [ServerCommonModule],
31
+ // ...
32
+ })
33
+ export class AppModule {}
34
+ ```
35
+
36
+ ### Using API Configuration
37
+
38
+ ```typescript
39
+ import { createApiApp, configureApiApp } from '@onivoro/server-common';
40
+
41
+ async function bootstrap() {
42
+ const app = await createApiApp(AppModule);
43
+ await configureApiApp(app, {
44
+ port: 3000,
45
+ title: 'My API',
46
+ version: '1.0.0'
47
+ });
48
+ }
49
+ ```
50
+
51
+ ### Environment Configuration
52
+
53
+ ```typescript
54
+ import { EnvironmentClass } from '@onivoro/server-common';
55
+
56
+ @EnvironmentClass()
57
+ export class AppConfig {
58
+ @EnvironmentVariable('DATABASE_URL')
59
+ databaseUrl: string;
60
+
61
+ @EnvironmentVariable('PORT', '3000')
62
+ port: number;
63
+ }
64
+ ```
65
+
66
+ ## Configuration
67
+
68
+ The library provides several configuration utilities:
69
+
70
+ ### Environment Variables
71
+
72
+ ```typescript
73
+ import { loadDotEnvForKey } from '@onivoro/server-common';
74
+
75
+ // Load environment variables for a specific key
76
+ loadDotEnvForKey('development');
77
+ ```
78
+
79
+ ### Version Management
80
+
81
+ ```typescript
82
+ import { getPackageVersion, VERSION_PROVIDER_TOKEN } from '@onivoro/server-common';
83
+
84
+ // Get version from package.json
85
+ const version = getPackageVersion();
86
+
87
+ // Use as provider
88
+ @Module({
89
+ providers: [
90
+ {
91
+ provide: VERSION_PROVIDER_TOKEN,
92
+ useValue: getPackageVersion()
93
+ }
94
+ ]
95
+ })
96
+ export class AppModule {}
97
+ ```
98
+
99
+ ## Usage Examples
100
+
101
+ ### Error Handling
102
+
103
+ ```typescript
104
+ import { ErrorFilter, TypeormErrorFilter } from '@onivoro/server-common';
105
+
106
+ @UseFilters(new ErrorFilter(), new TypeormErrorFilter())
107
+ @Controller('api')
108
+ export class ApiController {
109
+ // Your controller methods
110
+ }
111
+ ```
112
+
113
+ ### API Documentation Decorators
114
+
115
+ ```typescript
116
+ import {
117
+ DefaultApiController,
118
+ ApiResponsePaged,
119
+ ApiQueryPagedParams
120
+ } from '@onivoro/server-common';
121
+
122
+ @DefaultApiController('users')
123
+ export class UsersController {
124
+ @Get()
125
+ @ApiQueryPagedParams()
126
+ @ApiResponsePaged(UserDto)
127
+ async findAll(@QueryPagedParams() params: PageParams) {
128
+ // Implementation
129
+ }
130
+ }
131
+ ```
132
+
133
+ ### Common DTOs
134
+
135
+ ```typescript
136
+ import {
137
+ PagedResponseDto,
138
+ SuccessDto,
139
+ HealthDto,
140
+ EmailDto
141
+ } from '@onivoro/server-common';
142
+
143
+ @Get('health')
144
+ async getHealth(): Promise<HealthDto> {
145
+ return { status: 'ok', timestamp: new Date() };
146
+ }
147
+
148
+ @Post('send-email')
149
+ async sendEmail(@Body() emailDto: EmailDto): Promise<SuccessDto> {
150
+ // Send email logic
151
+ return { success: true };
152
+ }
153
+ ```
154
+
155
+ ### Validation Pipes
156
+
157
+ ```typescript
158
+ import {
159
+ ParseDateOptionalPipe,
160
+ ParseUuidOptionalPipe,
161
+ ZodValidationPipe
162
+ } from '@onivoro/server-common';
163
+
164
+ @Get('events')
165
+ async getEvents(
166
+ @Query('date', ParseDateOptionalPipe) date?: Date,
167
+ @Query('userId', ParseUuidOptionalPipe) userId?: string
168
+ ) {
169
+ // Implementation
170
+ }
171
+ ```
172
+
173
+ ### Utility Functions
174
+
175
+ ```typescript
176
+ import {
177
+ generateUniqueCode,
178
+ getRandomString,
179
+ encode,
180
+ decode,
181
+ shell,
182
+ tryCatch
183
+ } from '@onivoro/server-common';
184
+
185
+ // Generate unique codes
186
+ const code = generateUniqueCode(8);
187
+
188
+ // Random string generation
189
+ const randomStr = getRandomString(16);
190
+
191
+ // Encoding/decoding
192
+ const encoded = encode('sensitive data');
193
+ const decoded = decode(encoded);
194
+
195
+ // Shell command execution
196
+ const result = await shell('ls -la');
197
+
198
+ // Safe function execution
199
+ const [error, result] = await tryCatch(async () => {
200
+ return await someAsyncOperation();
201
+ });
202
+ ```
203
+
204
+ ### File Operations
205
+
206
+ ```typescript
207
+ import {
208
+ readFileAsJson,
209
+ saveFileAsJson,
210
+ parsePackageJson
211
+ } from '@onivoro/server-common';
212
+
213
+ // Read JSON file
214
+ const config = await readFileAsJson('./config.json');
215
+
216
+ // Save JSON file
217
+ await saveFileAsJson('./output.json', { data: 'example' });
218
+
219
+ // Parse package.json
220
+ const packageInfo = parsePackageJson('./package.json');
221
+ ```
222
+
223
+ ### Application Metadata
224
+
225
+ ```typescript
226
+ import { generateAppMetadata } from '@onivoro/server-common';
227
+
228
+ const metadata = generateAppMetadata({
229
+ name: 'My API',
230
+ version: '1.0.0',
231
+ description: 'Example API'
232
+ });
233
+ ```
234
+
235
+ ## API Reference
236
+
237
+ ### Core Functions
238
+
239
+ - **createApiApp(module)**: Create NestJS application
240
+ - **configureApiApp(app, options)**: Configure API with OpenAPI, CORS, etc.
241
+ - **moduleFactory(module, options)**: Create dynamic modules
242
+ - **initOpenapi(app, config)**: Initialize OpenAPI documentation
243
+
244
+ ### Utility Functions
245
+
246
+ - **encode(data)**: Encode sensitive data
247
+ - **decode(data)**: Decode sensitive data
248
+ - **generateUniqueCode(length)**: Generate unique alphanumeric codes
249
+ - **getRandomString(length)**: Generate random strings
250
+ - **shell(command)**: Execute shell commands
251
+ - **tryCatch(fn)**: Safe async function execution
252
+
253
+ ### File Operations
254
+
255
+ - **readFileAsJson(path)**: Read and parse JSON files
256
+ - **saveFileAsJson(path, data)**: Save data as JSON file
257
+ - **parsePackageJson(path)**: Parse package.json files
258
+
259
+ ### Environment
260
+
261
+ - **loadDotEnvForKey(key)**: Load environment variables
262
+ - **getPackageVersion()**: Get current package version
263
+ - **isPortInUse(port)**: Check if port is available
264
+
265
+ ### Memory and Performance
266
+
267
+ - **getMemoryStats()**: Get Node.js memory statistics
268
+
269
+ ## DTOs
270
+
271
+ ### Common DTOs
272
+
273
+ - **SuccessDto**: Standard success response
274
+ - **HealthDto**: Health check response
275
+ - **EmailDto**: Email data transfer object
276
+ - **PagedResponseDto**: Paginated response wrapper
277
+ - **LookupDto**: Key-value lookup objects
278
+
279
+ ### Request DTOs
280
+
281
+ - **BodyDto**: Generic request body
282
+ - **UserIdDto**: User ID parameter
283
+ - **ValueDto/ValuesDto**: Generic value containers
284
+
285
+ ## Decorators
286
+
287
+ ### API Documentation
288
+
289
+ - **@DefaultApiController**: Standard API controller decorator
290
+ - **@ApiResponsePaged**: Paginated response documentation
291
+ - **@ApiQueryPagedParams**: Paginated query parameters
292
+ - **@ApiBodyUnspecified**: Unspecified request body
293
+ - **@ApiResponseUnspecified**: Unspecified response
294
+
295
+ ### Environment
296
+
297
+ - **@EnvironmentClass**: Mark classes for environment variable injection
298
+
299
+ ### Query Parameters
300
+
301
+ - **@QueryPagedParams**: Extract pagination parameters
302
+
303
+ ## Error Handling
304
+
305
+ The library provides comprehensive error handling:
306
+
307
+ - **ErrorFilter**: General application error filter
308
+ - **TypeormErrorFilter**: Database-specific error handling
309
+ - **Structured Error Responses**: Consistent error response format
310
+
311
+ ## Best Practices
312
+
313
+ 1. **Use Type Safety**: Leverage TypeScript for all DTOs and interfaces
314
+ 2. **Environment Configuration**: Use `@EnvironmentClass` for configuration
315
+ 3. **Error Handling**: Apply error filters at the controller level
316
+ 4. **API Documentation**: Use provided decorators for OpenAPI documentation
317
+ 5. **Validation**: Use custom pipes for input validation
318
+ 6. **Pagination**: Use provided pagination utilities for list endpoints
319
+
320
+ ## License
321
+
322
+ This library is part of the Onivoro monorepo ecosystem.