@cyberskill/shared 3.0.0 → 3.2.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 (360) hide show
  1. package/dist/config/commitlint/index.js +1 -0
  2. package/dist/config/commitlint/index.js.map +1 -0
  3. package/dist/config/config.type.js +1 -0
  4. package/dist/config/config.type.js.map +1 -0
  5. package/dist/config/config.util.js +4 -2
  6. package/dist/config/config.util.js.map +1 -0
  7. package/dist/config/env/env.constant.js +1 -0
  8. package/dist/config/env/env.constant.js.map +1 -0
  9. package/dist/config/env/env.util.js +1 -0
  10. package/dist/config/env/env.util.js.map +1 -0
  11. package/dist/config/env/index.js +1 -0
  12. package/dist/config/env/index.js.map +1 -0
  13. package/dist/config/eslint/index.js +1 -0
  14. package/dist/config/eslint/index.js.map +1 -0
  15. package/dist/config/graphql-codegen/graphql-codegen.util.js +1 -0
  16. package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -0
  17. package/dist/config/graphql-codegen/index.js +1 -0
  18. package/dist/config/graphql-codegen/index.js.map +1 -0
  19. package/dist/config/index.js +1 -0
  20. package/dist/config/index.js.map +1 -0
  21. package/dist/config/lint-staged/index.js +1 -0
  22. package/dist/config/lint-staged/index.js.map +1 -0
  23. package/dist/config/storybook/index.js +1 -0
  24. package/dist/config/storybook/index.js.map +1 -0
  25. package/dist/config/storybook/storybook.main.js +1 -0
  26. package/dist/config/storybook/storybook.main.js.map +1 -0
  27. package/dist/config/storybook/storybook.preview.d.ts +1 -1
  28. package/dist/config/storybook/storybook.preview.js +6 -4
  29. package/dist/config/storybook/storybook.preview.js.map +1 -0
  30. package/dist/config/vitest/index.js +1 -0
  31. package/dist/config/vitest/index.js.map +1 -0
  32. package/dist/config/vitest/vitest.e2e.d.ts +2 -0
  33. package/dist/config/vitest/vitest.e2e.js +12 -18
  34. package/dist/config/vitest/vitest.e2e.js.map +1 -0
  35. package/dist/config/vitest/vitest.unit.d.ts +2 -0
  36. package/dist/config/vitest/vitest.unit.js +8 -5
  37. package/dist/config/vitest/vitest.unit.js.map +1 -0
  38. package/dist/constant/common.js +1 -0
  39. package/dist/constant/common.js.map +1 -0
  40. package/dist/constant/index.js +1 -0
  41. package/dist/constant/index.js.map +1 -0
  42. package/dist/constant/response-status.js +1 -0
  43. package/dist/constant/response-status.js.map +1 -0
  44. package/dist/node/apollo-server/apollo-server.util.js +1 -0
  45. package/dist/node/apollo-server/apollo-server.util.js.map +1 -0
  46. package/dist/node/apollo-server/index.js +1 -0
  47. package/dist/node/apollo-server/index.js.map +1 -0
  48. package/dist/node/cli/index.js +56 -45
  49. package/dist/node/cli/index.js.map +1 -0
  50. package/dist/node/command/command.type.js +1 -0
  51. package/dist/node/command/command.type.js.map +1 -0
  52. package/dist/node/command/command.util.js +107 -99
  53. package/dist/node/command/command.util.js.map +1 -0
  54. package/dist/node/command/index.js +1 -0
  55. package/dist/node/command/index.js.map +1 -0
  56. package/dist/node/express/express.type.d.ts +4 -0
  57. package/dist/node/express/express.util.js +49 -31
  58. package/dist/node/express/express.util.js.map +1 -0
  59. package/dist/node/express/index.js +1 -0
  60. package/dist/node/express/index.js.map +1 -0
  61. package/dist/node/fs/fs.util.js +1 -0
  62. package/dist/node/fs/fs.util.js.map +1 -0
  63. package/dist/node/fs/index.js +1 -0
  64. package/dist/node/fs/index.js.map +1 -0
  65. package/dist/node/log/index.js +1 -0
  66. package/dist/node/log/index.js.map +1 -0
  67. package/dist/node/log/log.type.js +1 -0
  68. package/dist/node/log/log.type.js.map +1 -0
  69. package/dist/node/log/log.util.js +1 -0
  70. package/dist/node/log/log.util.js.map +1 -0
  71. package/dist/node/mongo/index.d.ts +2 -0
  72. package/dist/node/mongo/index.js +21 -12
  73. package/dist/node/mongo/index.js.map +1 -0
  74. package/dist/node/mongo/mongo.constant.js +1 -0
  75. package/dist/node/mongo/mongo.constant.js.map +1 -0
  76. package/dist/node/mongo/mongo.controller.d.ts +5 -315
  77. package/dist/node/mongo/mongo.controller.mongoose.d.ts +234 -0
  78. package/dist/node/mongo/mongo.controller.mongoose.js +468 -0
  79. package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -0
  80. package/dist/node/mongo/mongo.controller.native.d.ts +84 -0
  81. package/dist/node/mongo/mongo.controller.native.js +214 -0
  82. package/dist/node/mongo/mongo.controller.native.js.map +1 -0
  83. package/dist/node/mongo/mongo.dynamic-populate.d.ts +61 -0
  84. package/dist/node/mongo/mongo.dynamic-populate.js +197 -0
  85. package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -0
  86. package/dist/node/mongo/mongo.populate.d.ts +15 -0
  87. package/dist/node/mongo/mongo.populate.js +269 -0
  88. package/dist/node/mongo/mongo.populate.js.map +1 -0
  89. package/dist/node/mongo/mongo.type.js +1 -0
  90. package/dist/node/mongo/mongo.type.js.map +1 -0
  91. package/dist/node/mongo/mongo.util.d.ts +52 -0
  92. package/dist/node/mongo/mongo.util.js +106 -363
  93. package/dist/node/mongo/mongo.util.js.map +1 -0
  94. package/dist/node/package/index.js +1 -0
  95. package/dist/node/package/index.js.map +1 -0
  96. package/dist/node/package/package.type.js +1 -0
  97. package/dist/node/package/package.type.js.map +1 -0
  98. package/dist/node/package/package.util.js +20 -20
  99. package/dist/node/package/package.util.js.map +1 -0
  100. package/dist/node/path/index.js +1 -0
  101. package/dist/node/path/index.js.map +1 -0
  102. package/dist/node/path/path.constant.js +10 -9
  103. package/dist/node/path/path.constant.js.map +1 -0
  104. package/dist/node/path/path.util.js +1 -0
  105. package/dist/node/path/path.util.js.map +1 -0
  106. package/dist/node/storage/index.js +1 -0
  107. package/dist/node/storage/index.js.map +1 -0
  108. package/dist/node/storage/storage.constant.js +1 -0
  109. package/dist/node/storage/storage.constant.js.map +1 -0
  110. package/dist/node/storage/storage.util.js +1 -0
  111. package/dist/node/storage/storage.util.js.map +1 -0
  112. package/dist/node/upload/index.js +1 -0
  113. package/dist/node/upload/index.js.map +1 -0
  114. package/dist/node/upload/upload.constant.js +1 -0
  115. package/dist/node/upload/upload.constant.js.map +1 -0
  116. package/dist/node/upload/upload.type.js +1 -0
  117. package/dist/node/upload/upload.type.js.map +1 -0
  118. package/dist/node/upload/upload.util.js +1 -0
  119. package/dist/node/upload/upload.util.js.map +1 -0
  120. package/dist/node/ws/index.d.ts +1 -1
  121. package/dist/node/ws/index.js +2 -1
  122. package/dist/node/ws/index.js.map +1 -0
  123. package/dist/node/ws/{ts.util.js → ws.util.js} +1 -0
  124. package/dist/node/ws/ws.util.js.map +1 -0
  125. package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +1 -0
  126. package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js.map +1 -0
  127. package/dist/react/apollo-client/apollo-client.component.js +1 -0
  128. package/dist/react/apollo-client/apollo-client.component.js.map +1 -0
  129. package/dist/react/apollo-client/apollo-client.constant.js +1 -0
  130. package/dist/react/apollo-client/apollo-client.constant.js.map +1 -0
  131. package/dist/react/apollo-client/apollo-client.context.js +1 -0
  132. package/dist/react/apollo-client/apollo-client.context.js.map +1 -0
  133. package/dist/react/apollo-client/apollo-client.module.scss.js +1 -0
  134. package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -0
  135. package/dist/react/apollo-client/apollo-client.util.js +14 -13
  136. package/dist/react/apollo-client/apollo-client.util.js.map +1 -0
  137. package/dist/react/apollo-client/index.js +1 -0
  138. package/dist/react/apollo-client/index.js.map +1 -0
  139. package/dist/react/apollo-client/links/index.js +1 -0
  140. package/dist/react/apollo-client/links/index.js.map +1 -0
  141. package/dist/react/apollo-client/links/upload.js +1 -0
  142. package/dist/react/apollo-client/links/upload.js.map +1 -0
  143. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -0
  144. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -0
  145. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +1 -0
  146. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -0
  147. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +1 -0
  148. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -0
  149. package/dist/react/apollo-client-nextjs/index.js +1 -0
  150. package/dist/react/apollo-client-nextjs/index.js.map +1 -0
  151. package/dist/react/apollo-error/apollo-error.component.js +23 -21
  152. package/dist/react/apollo-error/apollo-error.component.js.map +1 -0
  153. package/dist/react/apollo-error/apollo-error.context.js +1 -0
  154. package/dist/react/apollo-error/apollo-error.context.js.map +1 -0
  155. package/dist/react/apollo-error/apollo-error.hook.js +1 -0
  156. package/dist/react/apollo-error/apollo-error.hook.js.map +1 -0
  157. package/dist/react/apollo-error/apollo-error.module.scss.js +1 -0
  158. package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -0
  159. package/dist/react/apollo-error/apollo-error.provider.js +1 -0
  160. package/dist/react/apollo-error/apollo-error.provider.js.map +1 -0
  161. package/dist/react/apollo-error/apollo-error.util.js +1 -0
  162. package/dist/react/apollo-error/apollo-error.util.js.map +1 -0
  163. package/dist/react/apollo-error/index.js +1 -0
  164. package/dist/react/apollo-error/index.js.map +1 -0
  165. package/dist/react/i18next/i18next.hook.js +1 -0
  166. package/dist/react/i18next/i18next.hook.js.map +1 -0
  167. package/dist/react/i18next/i18next.util.js +1 -0
  168. package/dist/react/i18next/i18next.util.js.map +1 -0
  169. package/dist/react/i18next/index.js +1 -0
  170. package/dist/react/i18next/index.js.map +1 -0
  171. package/dist/react/loading/index.js +1 -0
  172. package/dist/react/loading/index.js.map +1 -0
  173. package/dist/react/loading/loading.component.js +1 -0
  174. package/dist/react/loading/loading.component.js.map +1 -0
  175. package/dist/react/loading/loading.context.js +1 -0
  176. package/dist/react/loading/loading.context.js.map +1 -0
  177. package/dist/react/loading/loading.hook.js +1 -0
  178. package/dist/react/loading/loading.hook.js.map +1 -0
  179. package/dist/react/loading/loading.module.scss.js +1 -0
  180. package/dist/react/loading/loading.module.scss.js.map +1 -0
  181. package/dist/react/loading/loading.provider.js +1 -0
  182. package/dist/react/loading/loading.provider.js.map +1 -0
  183. package/dist/react/log/index.js +1 -0
  184. package/dist/react/log/index.js.map +1 -0
  185. package/dist/react/log/log.util.js +1 -0
  186. package/dist/react/log/log.util.js.map +1 -0
  187. package/dist/react/next-intl/index.js +1 -0
  188. package/dist/react/next-intl/index.js.map +1 -0
  189. package/dist/react/next-intl/next-intl.constant.js +1 -0
  190. package/dist/react/next-intl/next-intl.constant.js.map +1 -0
  191. package/dist/react/next-intl/next-intl.context.js +1 -0
  192. package/dist/react/next-intl/next-intl.context.js.map +1 -0
  193. package/dist/react/next-intl/next-intl.hoc.js +1 -0
  194. package/dist/react/next-intl/next-intl.hoc.js.map +1 -0
  195. package/dist/react/next-intl/next-intl.hook.js +1 -0
  196. package/dist/react/next-intl/next-intl.hook.js.map +1 -0
  197. package/dist/react/next-intl/next-intl.provider.js +1 -0
  198. package/dist/react/next-intl/next-intl.provider.js.map +1 -0
  199. package/dist/react/storage/index.js +1 -0
  200. package/dist/react/storage/index.js.map +1 -0
  201. package/dist/react/storage/storage.hook.js +1 -0
  202. package/dist/react/storage/storage.hook.js.map +1 -0
  203. package/dist/react/storage/storage.util.js +1 -0
  204. package/dist/react/storage/storage.util.js.map +1 -0
  205. package/dist/react/toast/index.js +1 -0
  206. package/dist/react/toast/index.js.map +1 -0
  207. package/dist/react/userback/index.js +1 -0
  208. package/dist/react/userback/index.js.map +1 -0
  209. package/dist/react/userback/userback.component.js +1 -0
  210. package/dist/react/userback/userback.component.js.map +1 -0
  211. package/dist/typescript/common.type.js +1 -0
  212. package/dist/typescript/common.type.js.map +1 -0
  213. package/dist/typescript/index.js +1 -0
  214. package/dist/typescript/index.js.map +1 -0
  215. package/dist/util/common/common.util.js +27 -25
  216. package/dist/util/common/common.util.js.map +1 -0
  217. package/dist/util/common/index.js +1 -0
  218. package/dist/util/common/index.js.map +1 -0
  219. package/dist/util/index.js +1 -0
  220. package/dist/util/index.js.map +1 -0
  221. package/dist/util/object/index.js +1 -0
  222. package/dist/util/object/index.js.map +1 -0
  223. package/dist/util/object/object.util.js +50 -49
  224. package/dist/util/object/object.util.js.map +1 -0
  225. package/dist/util/serializer/index.js +1 -0
  226. package/dist/util/serializer/index.js.map +1 -0
  227. package/dist/util/serializer/serializer.util.js +13 -12
  228. package/dist/util/serializer/serializer.util.js.map +1 -0
  229. package/dist/util/string/index.js +1 -0
  230. package/dist/util/string/index.js.map +1 -0
  231. package/dist/util/string/string.util.js +30 -28
  232. package/dist/util/string/string.util.js.map +1 -0
  233. package/dist/util/validate/index.js +1 -0
  234. package/dist/util/validate/index.js.map +1 -0
  235. package/dist/util/validate/validate.util.d.ts +0 -4
  236. package/dist/util/validate/validate.util.js +4 -3
  237. package/dist/util/validate/validate.util.js.map +1 -0
  238. package/package.json +68 -95
  239. package/public/tsconfig.base.json +1 -1
  240. package/dist/config/commitlint/index.cjs +0 -1
  241. package/dist/config/config.type.cjs +0 -1
  242. package/dist/config/config.util.cjs +0 -1
  243. package/dist/config/env/env.constant.cjs +0 -1
  244. package/dist/config/env/env.util.cjs +0 -1
  245. package/dist/config/env/index.cjs +0 -1
  246. package/dist/config/eslint/index.cjs +0 -1
  247. package/dist/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
  248. package/dist/config/graphql-codegen/index.cjs +0 -1
  249. package/dist/config/index.cjs +0 -1
  250. package/dist/config/lint-staged/index.cjs +0 -1
  251. package/dist/config/storybook/index.cjs +0 -1
  252. package/dist/config/storybook/storybook.main.cjs +0 -1
  253. package/dist/config/storybook/storybook.preview.cjs +0 -1
  254. package/dist/config/vitest/index.cjs +0 -1
  255. package/dist/config/vitest/vitest.e2e.cjs +0 -1
  256. package/dist/config/vitest/vitest.unit.cjs +0 -1
  257. package/dist/constant/common.cjs +0 -1
  258. package/dist/constant/index.cjs +0 -1
  259. package/dist/constant/response-status.cjs +0 -1
  260. package/dist/node/apollo-server/apollo-server.util.cjs +0 -1
  261. package/dist/node/apollo-server/index.cjs +0 -1
  262. package/dist/node/cli/index.cjs +0 -3
  263. package/dist/node/command/command.type.cjs +0 -1
  264. package/dist/node/command/command.util.cjs +0 -2
  265. package/dist/node/command/index.cjs +0 -1
  266. package/dist/node/express/express.util.cjs +0 -1
  267. package/dist/node/express/index.cjs +0 -1
  268. package/dist/node/fs/fs.util.cjs +0 -4
  269. package/dist/node/fs/index.cjs +0 -1
  270. package/dist/node/log/index.cjs +0 -1
  271. package/dist/node/log/log.type.cjs +0 -1
  272. package/dist/node/log/log.util.cjs +0 -1
  273. package/dist/node/mongo/index.cjs +0 -1
  274. package/dist/node/mongo/mongo.constant.cjs +0 -1
  275. package/dist/node/mongo/mongo.controller.cjs +0 -1
  276. package/dist/node/mongo/mongo.controller.js +0 -858
  277. package/dist/node/mongo/mongo.controller.test.unit.d.ts +0 -1
  278. package/dist/node/mongo/mongo.type.cjs +0 -1
  279. package/dist/node/mongo/mongo.util.cjs +0 -2
  280. package/dist/node/mongo/mongo.util.test.unit.d.ts +0 -1
  281. package/dist/node/package/index.cjs +0 -1
  282. package/dist/node/package/package.type.cjs +0 -1
  283. package/dist/node/package/package.util.cjs +0 -1
  284. package/dist/node/path/index.cjs +0 -1
  285. package/dist/node/path/path.constant.cjs +0 -1
  286. package/dist/node/path/path.test.unit.d.ts +0 -1
  287. package/dist/node/path/path.util.cjs +0 -1
  288. package/dist/node/storage/index.cjs +0 -1
  289. package/dist/node/storage/storage.constant.cjs +0 -1
  290. package/dist/node/storage/storage.util.cjs +0 -1
  291. package/dist/node/upload/index.cjs +0 -1
  292. package/dist/node/upload/upload.constant.cjs +0 -1
  293. package/dist/node/upload/upload.type.cjs +0 -1
  294. package/dist/node/upload/upload.util.cjs +0 -1
  295. package/dist/node/ws/index.cjs +0 -1
  296. package/dist/node/ws/ts.util.cjs +0 -1
  297. package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs +0 -1
  298. package/dist/react/apollo-client/apollo-client.component.cjs +0 -1
  299. package/dist/react/apollo-client/apollo-client.constant.cjs +0 -1
  300. package/dist/react/apollo-client/apollo-client.context.cjs +0 -1
  301. package/dist/react/apollo-client/apollo-client.module.scss.cjs +0 -1
  302. package/dist/react/apollo-client/apollo-client.util.cjs +0 -1
  303. package/dist/react/apollo-client/index.cjs +0 -1
  304. package/dist/react/apollo-client/links/index.cjs +0 -1
  305. package/dist/react/apollo-client/links/upload.cjs +0 -1
  306. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
  307. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
  308. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
  309. package/dist/react/apollo-client-nextjs/index.cjs +0 -1
  310. package/dist/react/apollo-error/apollo-error.component.cjs +0 -1
  311. package/dist/react/apollo-error/apollo-error.context.cjs +0 -1
  312. package/dist/react/apollo-error/apollo-error.hook.cjs +0 -1
  313. package/dist/react/apollo-error/apollo-error.module.scss.cjs +0 -1
  314. package/dist/react/apollo-error/apollo-error.provider.cjs +0 -1
  315. package/dist/react/apollo-error/apollo-error.test.unit.d.ts +0 -1
  316. package/dist/react/apollo-error/apollo-error.util.cjs +0 -1
  317. package/dist/react/apollo-error/index.cjs +0 -1
  318. package/dist/react/i18next/i18next.hook.cjs +0 -1
  319. package/dist/react/i18next/i18next.util.cjs +0 -1
  320. package/dist/react/i18next/index.cjs +0 -1
  321. package/dist/react/loading/index.cjs +0 -1
  322. package/dist/react/loading/loading.component.cjs +0 -6
  323. package/dist/react/loading/loading.context.cjs +0 -1
  324. package/dist/react/loading/loading.hook.cjs +0 -1
  325. package/dist/react/loading/loading.module.scss.cjs +0 -1
  326. package/dist/react/loading/loading.provider.cjs +0 -1
  327. package/dist/react/loading/loading.test.unit.d.ts +0 -1
  328. package/dist/react/log/index.cjs +0 -1
  329. package/dist/react/log/log.util.cjs +0 -1
  330. package/dist/react/next-intl/index.cjs +0 -1
  331. package/dist/react/next-intl/next-intl.constant.cjs +0 -1
  332. package/dist/react/next-intl/next-intl.context.cjs +0 -1
  333. package/dist/react/next-intl/next-intl.hoc.cjs +0 -1
  334. package/dist/react/next-intl/next-intl.hook.cjs +0 -1
  335. package/dist/react/next-intl/next-intl.provider.cjs +0 -1
  336. package/dist/react/storage/index.cjs +0 -1
  337. package/dist/react/storage/storage.hook.cjs +0 -1
  338. package/dist/react/storage/storage.util.cjs +0 -1
  339. package/dist/react/toast/index.cjs +0 -1
  340. package/dist/react/userback/index.cjs +0 -1
  341. package/dist/react/userback/userback.component.cjs +0 -1
  342. package/dist/typescript/common.type.cjs +0 -1
  343. package/dist/typescript/index.cjs +0 -1
  344. package/dist/util/common/common.test.unit.d.ts +0 -1
  345. package/dist/util/common/common.util.cjs +0 -1
  346. package/dist/util/common/index.cjs +0 -1
  347. package/dist/util/index.cjs +0 -1
  348. package/dist/util/object/index.cjs +0 -1
  349. package/dist/util/object/object.test.unit.d.ts +0 -1
  350. package/dist/util/object/object.util.cjs +0 -1
  351. package/dist/util/serializer/index.cjs +0 -1
  352. package/dist/util/serializer/serializer.test.unit.d.ts +0 -1
  353. package/dist/util/serializer/serializer.util.cjs +0 -1
  354. package/dist/util/string/index.cjs +0 -1
  355. package/dist/util/string/string.test.unit.d.ts +0 -1
  356. package/dist/util/string/string.util.cjs +0 -1
  357. package/dist/util/validate/index.cjs +0 -1
  358. package/dist/util/validate/validate.test.unit.d.ts +0 -1
  359. package/dist/util/validate/validate.util.cjs +0 -1
  360. /package/dist/node/ws/{ts.util.d.ts → ws.util.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.hoc.js","sources":["../../../src/react/next-intl/next-intl.hoc.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\nimport { NextIntlClientProvider } from 'next-intl';\nimport * as React from 'react';\n\nimport type { I_Children } from '#typescript/index.js';\n\nimport type { I_NextIntlLanguage, T_NextIntlMessageList } from './next-intl.type.js';\n\nimport { log } from '../log/index.js';\nimport { NEXT_INTL_DEFAULT_LANGUAGE } from './next-intl.constant.js';\nimport { useNextIntl } from './next-intl.hook.js';\n\n/**\n * Higher-Order Component (HOC) that wraps components with Next.js internationalization support.\n * This HOC provides internationalization capabilities to React components by wrapping them\n * with the NextIntlClientProvider. It automatically handles language detection, message\n * loading, and timezone configuration based on the current language settings.\n *\n * Features:\n * - Automatic language detection and message loading\n * - Timezone configuration based on language settings\n * - Fallback to default language when messages are missing\n * - Warning logging for missing message configurations\n * - Proper display name preservation for debugging\n *\n * @param Component - The React component to wrap with internationalization support.\n * @returns A new component with internationalization capabilities and additional props for languages and messages.\n */\nexport function withNextIntl<T extends I_Children>(Component: ComponentType<T>) {\n const PageWithI18n = (props: T & { languages: I_NextIntlLanguage[]; messages: T_NextIntlMessageList }) => {\n const { currentLanguage } = useNextIntl();\n const { messages, languages } = props;\n const defaultLang = 'en';\n\n const defaultMessages = messages[currentLanguage?.value || defaultLang];\n const timeZone = languages.find(lang => lang.value === currentLanguage?.value)?.timezone ?? NEXT_INTL_DEFAULT_LANGUAGE.timezone;\n\n if (!messages) {\n log.warn(`Missing messages for language: ${currentLanguage?.value || defaultLang}`);\n return null;\n }\n\n return (\n <NextIntlClientProvider\n locale={currentLanguage?.value || defaultLang}\n messages={defaultMessages || null}\n timeZone={timeZone}\n >\n <Component {...(props as T)} />\n </NextIntlClientProvider>\n );\n };\n\n PageWithI18n.displayName = `withNextIntl(${Component.displayName || Component.name || 'Component'})`;\n\n return PageWithI18n;\n}\n"],"names":["withNextIntl","Component","PageWithI18n","props","currentLanguage","useNextIntl","messages","languages","defaultLang","defaultMessages","timeZone","lang","NEXT_INTL_DEFAULT_LANGUAGE","React","NextIntlClientProvider","log"],"mappings":";;;;;AA6BO,SAASA,EAAmCC,GAA6B;AAC5E,QAAMC,IAAe,CAACC,MAAoF;AACtG,UAAM,EAAE,iBAAAC,EAAA,IAAoBC,EAAA,GACtB,EAAE,UAAAC,GAAU,WAAAC,EAAA,IAAcJ,GAC1BK,IAAc,MAEdC,IAAkBH,EAASF,GAAiB,SAASI,CAAW,GAChEE,IAAWH,EAAU,KAAK,CAAAI,MAAQA,EAAK,UAAUP,GAAiB,KAAK,GAAG,YAAYQ,EAA2B;AAEvH,WAAKN,IAMD,gBAAAO,EAAA;AAAA,MAACC;AAAA,MAAA;AAAA,QACG,QAAQV,GAAiB,SAASI;AAAA,QAClC,UAAUC,KAAmB;AAAA,QAC7B,UAAAC;AAAA,MAAA;AAAA,MAEA,gBAAAG,EAAA,cAACZ,GAAA,EAAW,GAAIE,EAAA,CAAa;AAAA,IAAA,KAVjCY,EAAI,KAAK,kCAAkCX,GAAiB,SAASI,CAAW,EAAE,GAC3E;AAAA,EAYf;AAEA,SAAAN,EAAa,cAAc,gBAAgBD,EAAU,eAAeA,EAAU,QAAQ,WAAW,KAE1FC;AACX;"}
@@ -12,3 +12,4 @@ export {
12
12
  u as useNextIntl,
13
13
  x as useTranslateNextIntl
14
14
  };
15
+ //# sourceMappingURL=next-intl.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.hook.js","sources":["../../../src/react/next-intl/next-intl.hook.tsx"],"sourcesContent":["import { useTranslations } from 'next-intl';\nimport { use } from 'react';\n\nimport type { I_NextIntlContext } from './next-intl.type.js';\n\nimport { NextIntlContext } from './next-intl.context.js';\n\n/**\n * React hook that provides access to Next.js internationalization context.\n * This hook retrieves the Next.js internationalization context which contains\n * language information and language switching functionality. It provides a\n * convenient way to access internationalization features within components.\n *\n * The hook will throw an error if used outside of a NextIntlProvider,\n * ensuring proper context usage and providing clear error messages for debugging.\n *\n * @returns The Next.js internationalization context containing language state and control methods.\n * @throws {Error} When used outside of a NextIntlProvider context.\n */\nexport function useNextIntl(): I_NextIntlContext {\n const context = use(NextIntlContext);\n\n if (!context) {\n throw new Error('useNextIntl must be used within a NextIntlProvider');\n }\n\n return context;\n}\n\n/**\n * React hook that provides Next.js translation functionality.\n * This hook is a wrapper around next-intl's useTranslations hook,\n * providing access to translation functions and current locale information.\n * It enables internationalization features including text translation,\n * locale switching, and pluralization support for Next.js applications.\n *\n * @returns The useTranslations hook result with translation functions and locale information.\n */\nexport const useTranslateNextIntl: typeof useTranslations = useTranslations;\n"],"names":["useTranslations","use","NextIntlContext","useNextIntl","context","useTranslateNextIntl"],"mappings":"AAmBO,SAAA,mBAAAA,SAAA;AAAA,SAAA,OAAAC,SAAA;AAAA,SAAA,mBAAAC,SAAA;AAAA,SAASC,IAAiC;AAC7C,QAAMC,IAAUH,EAAIC,CAAe;AAEnC,MAAI,CAACE;AACD,UAAM,IAAI,MAAM,oDAAoD;AAGxE,SAAOA;AACX;AAWO,MAAMC,IAA+CL;"}
@@ -22,3 +22,4 @@ function I({
22
22
  export {
23
23
  I as NextIntlProvider
24
24
  };
25
+ //# sourceMappingURL=next-intl.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-intl.provider.js","sources":["../../../src/react/next-intl/next-intl.provider.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_Children } from '#typescript/index.js';\n\nimport type { I_NextIntlLanguage, I_NextIntlProviderProps } from './next-intl.type.js';\n\nimport { useStorage } from '../storage/index.js';\nimport { NEXT_INTL_DEFAULT_LANGUAGE } from './next-intl.constant.js';\nimport { NextIntlContext } from './next-intl.context.js';\nimport { withNextIntl } from './next-intl.hoc.js';\n\n/**\n * Base component that serves as a wrapper for the withNextIntl HOC.\n * This component is used internally by the NextIntlProvider to create\n * the language wrapper component with internationalization capabilities.\n *\n * @param props - Component props containing children.\n * @param props.children - React children to be wrapped with internationalization support.\n * @returns A React component that passes through its children.\n */\nfunction LanguageWrapperBase({ children }: I_Children) {\n return <>{children}</>;\n}\n\nconst LanguageWrapper = withNextIntl(LanguageWrapperBase);\n\n/**\n * Provider component that manages Next.js internationalization state and provides i18n context.\n * This component sets up a complete internationalization system for Next.js applications,\n * including language management, message loading, and persistent language preferences.\n * It integrates with the storage system to remember user language choices and provides\n * a comprehensive i18n context to all child components.\n *\n * Features:\n * - Language state management with persistence\n * - Automatic language detection and fallback\n * - Message loading and caching\n * - Timezone configuration per language\n * - Integration with Next.js internationalization\n * - Memoized context value for performance optimization\n *\n * @param props - Component props containing children, languages, and messages.\n * @param props.children - React children that will have access to the internationalization context.\n * @param props.languages - Array of supported languages with their configurations.\n * @param props.messages - Object containing translation messages for each supported language.\n * @returns A React component that provides internationalization context to its children.\n */\nexport function NextIntlProvider({\n children,\n languages,\n messages,\n}: I_NextIntlProviderProps) {\n const { value, set } = useStorage<I_NextIntlLanguage>('lang', languages[0]);\n\n const contextValue = useMemo(\n () => ({ languages, currentLanguage: value ?? NEXT_INTL_DEFAULT_LANGUAGE, setCurrentLanguage: set }),\n [languages, set, value],\n );\n\n return (\n <NextIntlContext value={contextValue}>\n <LanguageWrapper languages={languages} messages={messages}>\n {children}\n </LanguageWrapper>\n </NextIntlContext>\n );\n}\n"],"names":["React","useMemo","NEXT_INTL_DEFAULT_LANGUAGE","NextIntlContext","withNextIntl","useStorage","LanguageWrapperBase","children","LanguageWrapper","NextIntlProvider","languages","messages","value","set","contextValue"],"mappings":"AAqBA,YAAAA,OAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,SAAA,8BAAAC,SAAA;AAAA,SAAA,mBAAAC,SAAA;AAAA,SAAA,gBAAAC,SAAA;AAAA,SAAA,cAAAC,SAAA;AAAA,SAASC,EAAoB,EAAE,UAAAC,KAAwB;AACnD,2DAAUA,CAAS;AACvB;AAEA,MAAMC,IAAkBJ,EAAaE,CAAmB;AAuBjD,SAASG,EAAiB;AAAA,EAC7B,UAAAF;AAAA,EACA,WAAAG;AAAA,EACA,UAAAC;AACJ,GAA4B;AACxB,QAAM,EAAE,OAAAC,GAAO,KAAAC,EAAA,IAAQR,EAA+B,QAAQK,EAAU,CAAC,CAAC,GAEpEI,IAAeb;AAAA,IACjB,OAAO,EAAE,WAAAS,GAAW,iBAAiBE,KAASV,GAA4B,oBAAoBW;IAC9F,CAACH,GAAWG,GAAKD,CAAK;AAAA,EAAA;AAG1B,SACI,gBAAAZ,EAAA,cAACG,KAAgB,OAAOW,EAAA,mCACnBN,GAAA,EAAgB,WAAAE,GAAsB,UAAAC,EAAA,GAClCJ,CACL,CACJ;AAER;"}
@@ -4,3 +4,4 @@ export {
4
4
  a as storage,
5
5
  e as useStorage
6
6
  };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -57,3 +57,4 @@ function S(e, o, a = w) {
57
57
  export {
58
58
  S as useStorage
59
59
  };
60
+ //# sourceMappingURL=storage.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.hook.js","sources":["../../../src/react/storage/storage.hook.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport type { I_Serializer } from '#util/serializer/index.js';\n\nimport { serializer as defaultSerializer } from '#util/serializer/index.js';\n\nimport { catchError } from '../log/index.js';\nimport { storage } from './storage.util.js';\n\n/**\n * React hook that provides persistent storage functionality with automatic serialization.\n * This hook manages state that persists across browser sessions using localForage,\n * with automatic serialization/deserialization of complex data types. It provides\n * a React-friendly interface for storage operations with proper error handling.\n *\n * Features:\n * - Automatic data serialization and deserialization\n * - Persistent storage across browser sessions\n * - Initial value handling and fallback\n * - Error handling with graceful degradation\n * - Automatic storage synchronization\n * - Support for complex data types via custom serializers\n *\n * @param key - The unique storage key for the data.\n * @param initialValue - Optional initial value to use if no stored value exists.\n * @param serializer - Optional custom serializer for complex data types (defaults to JSON serializer).\n * @returns An object containing the current value, set function, and remove function.\n */\nexport function useStorage<T>(\n key: string,\n initialValue?: T,\n serializer: I_Serializer<T> = defaultSerializer as I_Serializer<T>,\n) {\n const [value, setValue] = useState<T | undefined>(initialValue);\n const [isLoaded, setIsLoaded] = useState(false);\n\n useEffect(() => {\n let isMounted = true;\n\n const loadValue = async () => {\n try {\n const valueFound = await storage.get<string>(key);\n\n if (isMounted) {\n if (valueFound !== null) {\n const parsedValue = serializer.deserialize(valueFound);\n setValue(parsedValue);\n }\n else if (initialValue !== undefined) {\n const serialized = serializer.serialize(initialValue);\n await storage.set(key, serialized);\n setValue(initialValue);\n }\n else {\n setValue(undefined);\n }\n }\n }\n catch (error) {\n catchError(error);\n\n if (isMounted) {\n setValue(initialValue);\n }\n }\n finally {\n if (isMounted)\n setIsLoaded(true);\n }\n };\n\n loadValue();\n\n return () => {\n isMounted = false;\n setIsLoaded(false);\n };\n }, [key, initialValue, serializer]);\n\n useEffect(() => {\n if (!isLoaded)\n return;\n\n const saveValue = async () => {\n try {\n if (value !== undefined) {\n const serialized = serializer.serialize(value);\n await storage.set(key, serialized);\n }\n }\n catch (error) {\n catchError(error);\n }\n };\n\n saveValue();\n }, [value, key, serializer, isLoaded]);\n\n const set = useCallback(\n (newValue: T | ((val: T | undefined) => T)) => {\n setValue((prev) => {\n if (typeof newValue === 'function') {\n return (newValue as (val: T | undefined) => T)(prev);\n }\n return newValue;\n });\n },\n [],\n );\n\n const remove = useCallback(async () => {\n try {\n await storage.remove(key);\n setValue(undefined);\n }\n catch (error) {\n catchError(error);\n }\n }, [key]);\n\n return { value, set, remove };\n}\n"],"names":["useStorage","key","initialValue","serializer","defaultSerializer","value","setValue","useState","isLoaded","setIsLoaded","useEffect","isMounted","valueFound","storage","parsedValue","serialized","error","catchError","set","useCallback","newValue","prev","remove"],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S,CAACe,MACF,OAAOD,KAAa,aACZA,EAAuCC,CAAI,IAEhDD,CACV;AAAA,IACL;AAAA,IACA,CAAA;AAAA,EAAC,GAGCE,IAASH,EAAY,YAAY;AACnC,QAAI;AACA,YAAMN,EAAQ,OAAOZ,CAAG,GACxBK,EAAS,MAAS;AAAA,IACtB,SACOU,GAAO;AACV,MAAAC,EAAWD,CAAK;AAAA,IACpB;AAAA,EACJ,GAAG,CAACf,CAAG,CAAC;AAER,SAAO,EAAE,OAAAI,GAAO,KAAAa,GAAK,QAAAI,EAAA;AACzB;"}
@@ -66,3 +66,4 @@ const s = {
66
66
  export {
67
67
  s as storage
68
68
  };
69
+ //# sourceMappingURL=storage.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.util.js","sources":["../../../src/react/storage/storage.util.ts"],"sourcesContent":["import localForage from 'localforage';\n\nimport { catchError } from '../log/index.js';\n\n/**\n * Browser storage utility object using localForage for cross-browser compatibility.\n * This object provides a unified interface for browser storage operations using localForage,\n * which automatically chooses the best available storage method (IndexedDB, WebSQL, or localStorage)\n * based on browser capabilities. It includes comprehensive error handling and type safety.\n */\nexport const storage = {\n /**\n * Retrieves a value from browser storage by key.\n * This method fetches data that was previously stored using the set method.\n * Returns null if the key doesn't exist or if an error occurs during retrieval.\n *\n * @param key - The unique identifier for the stored value.\n * @returns A promise that resolves to the stored value or null if not found.\n */\n async get<T = unknown>(key: string): Promise<T | null> {\n try {\n return await localForage.getItem<T>(key);\n }\n catch (error) {\n return catchError(error, { returnValue: null });\n }\n },\n /**\n * Stores a value in browser storage with a unique key.\n * This method saves data that can be retrieved later using the get method.\n * The data is automatically handled by localForage which chooses the optimal\n * storage method for the browser environment.\n *\n * @param key - The unique identifier for the value to store.\n * @param value - The data to store (will be automatically handled by localForage).\n * @returns A promise that resolves when the storage operation is complete.\n */\n async set<T = unknown>(key: string, value: T): Promise<void> {\n try {\n await localForage.setItem(key, value);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Removes a value from browser storage by key.\n * This method permanently deletes the stored data associated with the specified key.\n * If the key doesn't exist, the operation completes successfully without error.\n *\n * @param key - The unique identifier of the value to remove.\n * @returns A promise that resolves when the removal operation is complete.\n */\n async remove(key: string): Promise<void> {\n try {\n await localForage.removeItem(key);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Retrieves all storage keys.\n * This method returns an array of all keys that currently have stored values.\n * Returns an empty array if no keys exist or if an error occurs during retrieval.\n *\n * @returns A promise that resolves to an array of storage keys.\n */\n async keys(): Promise<string[]> {\n try {\n const keys = await localForage.keys();\n\n return keys ?? [];\n }\n catch (error) {\n return catchError(error, { returnValue: [] });\n }\n },\n};\n"],"names":["localForage","catchError","storage","key","error","value"],"mappings":"AAUO,OAAAA,OAAA;AAAA,SAAA,cAAAC,SAAA;AAAA,MAAMC,IAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnB,MAAM,IAAiBC,GAAgC;AACnD,QAAI;AACA,aAAO,MAAMH,EAAY,QAAWG,CAAG;AAAA,IAC3C,SACOC,GAAO;AACV,aAAOH,EAAWG,GAAO,EAAE,aAAa,MAAM;AAAA,IAClD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,IAAiBD,GAAaE,GAAyB;AACzD,QAAI;AACA,YAAML,EAAY,QAAQG,GAAKE,CAAK;AAAA,IACxC,SACOD,GAAO;AACV,MAAAH,EAAWG,CAAK;AAAA,IACpB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OAAOD,GAA4B;AACrC,QAAI;AACA,YAAMH,EAAY,WAAWG,CAAG;AAAA,IACpC,SACOC,GAAO;AACV,MAAAH,EAAWG,CAAK;AAAA,IACpB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAA0B;AAC5B,QAAI;AAGA,aAFa,MAAMJ,EAAY,KAAA,KAEhB,CAAA;AAAA,IACnB,SACOI,GAAO;AACV,aAAOH,EAAWG,GAAO,EAAE,aAAa,CAAA,GAAI;AAAA,IAChD;AAAA,EACJ;AACJ;"}
@@ -3,3 +3,4 @@ export {
3
3
  r as Toaster,
4
4
  a as toast
5
5
  };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -2,3 +2,4 @@ import { Userback as o } from "./userback.component.js";
2
2
  export {
3
3
  o as Userback
4
4
  };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -25,3 +25,4 @@ function d({ token: r, options: n }) {
25
25
  export {
26
26
  d as Userback
27
27
  };
28
+ //# sourceMappingURL=userback.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userback.component.js","sources":["../../../src/react/userback/userback.component.tsx"],"sourcesContent":["import UserbackWidget from '@userback/widget';\nimport { useEffect } from 'react';\n\nimport type { I_UserBackProps } from './userback.type.js';\n\n/**\n * Userback feedback widget component for collecting user feedback.\n * This component integrates the Userback feedback widget into React applications,\n * providing a customizable feedback collection interface for users to submit\n * bug reports, feature requests, and general feedback.\n *\n * Features:\n * - Userback widget integration\n * - Customizable feedback collection\n * - Automatic widget initialization\n * - Token-based configuration\n * - Responsive design support\n *\n * @param props - Component props containing token and options.\n * @param props.token - The Userback token for widget authentication.\n * @param props.options - Optional configuration options for the Userback widget.\n * @returns A React component that renders the Userback feedback widget.\n */\nexport function Userback({ token, options }: I_UserBackProps) {\n useEffect(() => {\n if (!token) {\n return;\n }\n\n let observer: MutationObserver;\n\n const loadUserback = async () => {\n const { hide, ...rest } = options || {};\n\n await UserbackWidget(token, rest);\n\n if (hide && hide.length > 0) {\n hide.forEach((selector: string) => {\n document.querySelectorAll(selector).forEach(el => el.remove());\n });\n }\n\n observer = new MutationObserver(() => {\n if (hide && hide.length > 0) {\n hide.forEach((selector: string) => {\n document.querySelectorAll(selector).forEach(el => el.remove());\n });\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n };\n\n loadUserback();\n\n return () => {\n observer?.disconnect();\n };\n }, [token, options]);\n\n return null;\n}\n"],"names":["UserbackWidget","useEffect","Userback","token","options","observer","hide","rest","selector","el"],"mappings":"AAuBO,OAAAA,OAAA;AAAA,SAAA,aAAAC,SAAA;AAAA,SAASC,EAAS,EAAE,OAAAC,GAAO,SAAAC,KAA4B;AAC1D,SAAAH,EAAU,MAAM;AACZ,QAAI,CAACE;AACD;AAGJ,QAAIE;AA2BJ,YAzBqB,YAAY;AAC7B,YAAM,EAAE,MAAAC,GAAM,GAAGC,EAAA,IAASH,KAAW,CAAA;AAErC,YAAMJ,EAAeG,GAAOI,CAAI,GAE5BD,KAAQA,EAAK,SAAS,KACtBA,EAAK,QAAQ,CAACE,MAAqB;AAC/B,iBAAS,iBAAiBA,CAAQ,EAAE,QAAQ,CAAAC,MAAMA,EAAG,QAAQ;AAAA,MACjE,CAAC,GAGLJ,IAAW,IAAI,iBAAiB,MAAM;AAClC,QAAIC,KAAQA,EAAK,SAAS,KACtBA,EAAK,QAAQ,CAACE,MAAqB;AAC/B,mBAAS,iBAAiBA,CAAQ,EAAE,QAAQ,CAAAC,MAAMA,EAAG,QAAQ;AAAA,QACjE,CAAC;AAAA,MAET,CAAC,GAEDJ,EAAS,QAAQ,SAAS,MAAM;AAAA,QAC5B,WAAW;AAAA,QACX,SAAS;AAAA,MAAA,CACZ;AAAA,IACL,GAEA,GAEO,MAAM;AACT,MAAAA,GAAU,WAAA;AAAA,IACd;AAAA,EACJ,GAAG,CAACF,GAAOC,CAAO,CAAC,GAEZ;AACX;"}
@@ -2,3 +2,4 @@ var p = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "stagi
2
2
  export {
3
3
  p as E_Environment
4
4
  };
5
+ //# sourceMappingURL=common.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.type.js","sources":["../../src/typescript/common.type.ts"],"sourcesContent":["import type consola from 'consola';\n\n/**\n * Generic object type with string keys and values of type T (defaults to unknown).\n */\nexport type T_Object<T = unknown> = Record<string, T>;\n\n/**\n * Logging interface for browser and Node.js environments, compatible with consola.\n */\nexport interface I_Log {\n silent: typeof consola['silent'];\n level: typeof consola['level'];\n fatal: typeof consola['fatal'];\n error: typeof consola['error'];\n warn: typeof consola['warn'];\n log: typeof consola['log'];\n info: typeof consola['info'];\n success: typeof consola['success'];\n ready: typeof consola['ready'];\n start: typeof consola['start'];\n box: typeof consola['box'];\n debug: typeof consola['debug'];\n trace: typeof consola['trace'];\n verbose: typeof consola['verbose'];\n}\n\n/**\n * Base interface for return types with common properties.\n */\nexport interface I_ReturnBase {\n success: boolean;\n message?: string;\n code?: number | string;\n}\n\n/**\n * Success return type with result data.\n * @template T - The main result type\n * @template E - Additional properties to merge with the result (defaults to unknown)\n */\nexport interface I_ReturnSuccess<T, E = unknown> extends I_ReturnBase {\n success: true;\n result: T & E;\n}\n\n/**\n * Failure return type with error information.\n */\nexport interface I_ReturnFailure extends I_ReturnBase {\n success: false;\n message: string;\n code: number | string;\n}\n\n/**\n * Discriminated union type for function return values.\n * Provides type-safe handling of success and failure cases.\n *\n * @template T - The success result type (defaults to void)\n * @template E - Additional properties to merge with the result (defaults to unknown)\n *\n * @example\n * ```typescript\n * function fetchUser(id: string): I_Return<User> {\n * try {\n * const user = await getUser(id);\n * return { success: true, result: user };\n * } catch (error) {\n * return { success: false, message: error.message, code: 'USER_NOT_FOUND' };\n * }\n * }\n * ```\n */\nexport type I_Return<T = void, E = unknown> = I_ReturnSuccess<T, E> | I_ReturnFailure;\n\nexport enum E_Environment {\n PRODUCTION = 'production',\n STAGING = 'staging',\n DEVELOPMENT = 'development',\n}\n"],"names":["E_Environment"],"mappings":"AA4EO,IAAKA,sBAAAA,OACRA,EAAA,aAAa,cACbA,EAAA,UAAU,WACVA,EAAA,cAAc,eAHNA,IAAAA,KAAA,CAAA,CAAA;"}
@@ -2,3 +2,4 @@ import { E_Environment as r } from "./common.type.js";
2
2
  export {
3
3
  r as E_Environment
4
4
  };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,4 +1,4 @@
1
- import { E_Environment as r } from "../../typescript/common.type.js";
1
+ import { E_Environment as o } from "../../typescript/common.type.js";
2
2
  const p = {
3
3
  a: ["à", "á", "ạ", "ả", "ã", "â", "ầ", "ấ", "ậ", "ẩ", "ẫ", "ă", "ằ", "ắ", "ặ", "ẳ", "ẵ"],
4
4
  e: ["è", "é", "ẹ", "ẻ", "ẽ", "ê", "ề", "ế", "ệ", "ể", "ễ"],
@@ -7,46 +7,48 @@ const p = {
7
7
  u: ["ù", "ú", "ụ", "ủ", "ũ", "ư", "ừ", "ứ", "ự", "ử", "ữ"],
8
8
  y: ["ỳ", "ý", "ỵ", "ỷ", "ỹ"],
9
9
  d: ["đ"]
10
- }, s = Object.entries(p).reduce(
11
- (e, [n, t]) => (e[n.toUpperCase()] = t.map((o) => o.toUpperCase()), e),
10
+ }, a = Object.entries(p).reduce(
11
+ (e, [n, t]) => (e[n.toUpperCase()] = t.map((r) => r.toUpperCase()), e),
12
12
  {}
13
- ), u = { ...p, ...s }, a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
13
+ ), u = { ...p, ...a }, s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
14
14
  Object.entries(u).forEach(([e, n]) => {
15
15
  const t = `(${[e, ...n].join("|")})`;
16
- [e, ...n].forEach((o) => {
17
- a.set(o, t), i.add(o);
16
+ [e, ...n].forEach((r) => {
17
+ s.set(r, t), i.add(r);
18
18
  });
19
19
  });
20
- const O = Array.from(i).join(""), D = new RegExp(`[${O}]`, "g");
21
- function N(e) {
22
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
20
+ const O = [...i].join(""), D = new RegExp(`[${O}]`, "g"), N = /[.*+?^${}()|[\]\\]/g;
21
+ function M(e) {
22
+ return e.replace(N, "\\$&");
23
23
  }
24
24
  function m(e) {
25
- return e = N(e), e.replace(D, (n) => a.get(n) || n);
25
+ return e = M(e), e.replace(D, (n) => s.get(n) || n);
26
26
  }
27
- function M(e) {
28
- return e.normalize("NFD").replace(/\p{Diacritic}/gu, "");
27
+ const f = /\p{Diacritic}/gu;
28
+ function P(e) {
29
+ return e.normalize("NFD").replace(f, "");
29
30
  }
30
- function T(e, n) {
31
+ function R(e, n) {
31
32
  if (!n)
32
- return Array.from(new Set(e));
33
- const t = /* @__PURE__ */ new Set(), o = [];
33
+ return [...new Set(e)];
34
+ const t = /* @__PURE__ */ new Set(), r = [];
34
35
  for (const c of e) {
35
36
  const E = n(c);
36
- t.has(E) || (t.add(E), o.push(c));
37
+ t.has(E) || (t.add(E), r.push(c));
37
38
  }
38
- return o;
39
+ return r;
39
40
  }
40
- function g(e) {
41
- const { NODE_ENV: n = r.DEVELOPMENT, NODE_ENV_MODE: t = r.DEVELOPMENT } = e, o = n === r.DEVELOPMENT && t === r.DEVELOPMENT, c = n === r.PRODUCTION && t === r.STAGING, E = n === r.PRODUCTION && t === r.PRODUCTION;
42
- if (n === r.PRODUCTION && t === r.DEVELOPMENT)
41
+ function _(e) {
42
+ const { NODE_ENV: n = o.DEVELOPMENT, NODE_ENV_MODE: t = o.DEVELOPMENT } = e, r = n === o.DEVELOPMENT && t === o.DEVELOPMENT, c = n === o.PRODUCTION && t === o.STAGING, E = n === o.PRODUCTION && t === o.PRODUCTION;
43
+ if (n === o.PRODUCTION && t === o.DEVELOPMENT)
43
44
  throw new Error("NODE_ENV_MODE must be set to staging or production in production environment");
44
- return { IS_DEV: o, IS_STAG: c, IS_PROD: E };
45
+ return { IS_DEV: r, IS_STAG: c, IS_PROD: E };
45
46
  }
46
47
  export {
47
- N as escapeRegExp,
48
- g as mapEnvironment,
48
+ M as escapeRegExp,
49
+ _ as mapEnvironment,
49
50
  m as regexSearchMapper,
50
- M as removeAccent,
51
- T as uniqueArray
51
+ P as removeAccent,
52
+ R as uniqueArray
52
53
  };
54
+ //# sourceMappingURL=common.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.util.js","sources":["../../../src/util/common/common.util.ts"],"sourcesContent":["import { E_Environment } from '#typescript/index.js';\n\nimport type { I_EnvFlags, I_NodeEnvInput } from './common.type.js';\n\nconst charMap: Record<string, string[]> = {\n a: ['à', 'á', 'ạ', 'ả', 'ã', 'â', 'ầ', 'ấ', 'ậ', 'ẩ', 'ẫ', 'ă', 'ằ', 'ắ', 'ặ', 'ẳ', 'ẵ'],\n e: ['è', 'é', 'ẹ', 'ẻ', 'ẽ', 'ê', 'ề', 'ế', 'ệ', 'ể', 'ễ'],\n i: ['ì', 'í', 'ị', 'ỉ', 'ĩ'],\n o: ['ò', 'ó', 'ọ', 'ỏ', 'õ', 'ô', 'ồ', 'ố', 'ộ', 'ổ', 'ỗ', 'ơ', 'ờ', 'ớ', 'ợ', 'ở', 'ỡ'],\n u: ['ù', 'ú', 'ụ', 'ủ', 'ũ', 'ư', 'ừ', 'ứ', 'ự', 'ử', 'ữ'],\n y: ['ỳ', 'ý', 'ỵ', 'ỷ', 'ỹ'],\n d: ['đ'],\n};\n\nconst upperCharMap: Record<string, string[]> = Object.entries(charMap).reduce(\n (map, [key, value]) => {\n map[key.toUpperCase()] = value.map(char => char.toUpperCase());\n return map;\n },\n {} as Record<string, string[]>,\n);\n\nconst combinedMap = { ...charMap, ...upperCharMap };\n\n// Pre-compute replacement map and search regex for better performance\n// This avoids rebuilding regexes and maps on every function call\nconst replacementMap = new Map<string, string>();\nconst charsToMatch = new Set<string>();\n\nObject.entries(combinedMap).forEach(([baseChar, variations]) => {\n // The replacement pattern is the same for the base char and all its variations\n // Example: 'a', 'à', 'á'... all map to '(a|à|á...)'\n const replacement = `(${[baseChar, ...variations].join('|')})`;\n\n [baseChar, ...variations].forEach((char) => {\n replacementMap.set(char, replacement);\n charsToMatch.add(char);\n });\n});\n\n// Construct a single regex that matches any character in our map\nconst patternString = [...charsToMatch].join('');\n// We use a character class regex: [abc...]\n// eslint-disable-next-line regexp/no-empty-character-class -- regex is built dynamically from precomputed charMap\nconst searchRegex = new RegExp(`[${patternString}]`, 'g');\n\nconst RE_ESCAPE_REGEXP = /[.*+?^${}()|[\\]\\\\]/g;\n\n/**\n * Escapes special characters in a string for use in a regular expression.\n * This function escapes characters that have special meaning in regex (e.g., ., *, +, ?, etc.)\n * so they are treated as literal characters.\n *\n * @param str - The string to escape.\n * @returns The escaped string safe for use in a RegExp.\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(RE_ESCAPE_REGEXP, '\\\\$&');\n}\n\n/**\n * Convert a string to a regex pattern that matches the string and its accented variations.\n * This function normalizes the input string and creates a regex pattern that can match\n * both the original characters and their accented equivalents.\n *\n * Optimization: Uses pre-computed regex and map to perform replacement in a single pass (O(N)),\n * instead of iterating through all character groups (O(K*N)).\n * Removed unnecessary NFD normalization which improves performance and fixes\n * matching against NFC target strings.\n *\n * @param str - The string to convert to a regex pattern.\n * @returns The regex pattern as a string that matches the original string and its accented variations.\n */\nexport function regexSearchMapper(str: string) {\n str = escapeRegExp(str);\n return str.replace(searchRegex, match => replacementMap.get(match) || match);\n}\n\nconst RE_DIACRITIC = /\\p{Diacritic}/gu;\n\n/**\n * Remove accents from a string.\n * This function normalizes the string using NFD normalization and removes all diacritical marks.\n *\n * @param str - The string to remove accents from.\n * @returns The string without any accents or diacritical marks.\n */\nexport function removeAccent(str: string) {\n return str.normalize('NFD').replace(RE_DIACRITIC, '');\n}\n\n/**\n * Remove duplicates from an array based on a key function.\n * This function can remove duplicates either by comparing values directly (when no keyFn is provided)\n * or by using a custom key function to determine uniqueness.\n *\n * @param arr - The array to remove duplicates from.\n * @param keyFn - Optional function that returns a unique key for each item in the array.\n * @returns A new array with duplicates removed, maintaining the original order.\n */\nexport function uniqueArray<T>(\n arr: T[],\n keyFn?: (item: T) => string | number,\n): T[] {\n if (!keyFn) {\n return [...new Set(arr)];\n }\n\n const seen = new Set<string | number>();\n const result: T[] = [];\n\n for (const item of arr) {\n const key = keyFn(item);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(item);\n }\n }\n\n return result;\n}\n\n/**\n * Map environment variables to boolean flags indicating the current environment.\n * This function takes NODE_ENV and NODE_ENV_MODE variables and returns flags\n * indicating whether the current environment is development, staging, or production.\n *\n * @param env - The environment variables object containing NODE_ENV and NODE_ENV_MODE.\n * @returns An object containing boolean flags for the environment (IS_DEV, IS_STAG, IS_PROD).\n * @throws {Error} When NODE_ENV is production but NODE_ENV_MODE is development.\n */\nexport function mapEnvironment(env: I_NodeEnvInput): I_EnvFlags {\n const { NODE_ENV = E_Environment.DEVELOPMENT, NODE_ENV_MODE = E_Environment.DEVELOPMENT } = env;\n\n const IS_DEV = NODE_ENV === E_Environment.DEVELOPMENT && NODE_ENV_MODE === E_Environment.DEVELOPMENT;\n const IS_STAG = NODE_ENV === E_Environment.PRODUCTION && NODE_ENV_MODE === E_Environment.STAGING;\n const IS_PROD = NODE_ENV === E_Environment.PRODUCTION && NODE_ENV_MODE === E_Environment.PRODUCTION;\n\n if (NODE_ENV === E_Environment.PRODUCTION && NODE_ENV_MODE === E_Environment.DEVELOPMENT) {\n throw new Error('NODE_ENV_MODE must be set to staging or production in production environment');\n }\n\n return { IS_DEV, IS_STAG, IS_PROD };\n}\n"],"names":["E_Environment","charMap","upperCharMap","map","key","value","char","combinedMap","replacementMap","charsToMatch","baseChar","variations","replacement","patternString","searchRegex","RE_ESCAPE_REGEXP","escapeRegExp","str","regexSearchMapper","match","RE_DIACRITIC","removeAccent","uniqueArray","arr","keyFn","seen","result","item","mapEnvironment","env","NODE_ENV","NODE_ENV_MODE","IS_DEV","IS_STAG","IS_PROD"],"mappings":"AAIA,SAAA,iBA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index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -24,3 +24,4 @@ export {
24
24
  x as uniqueArray,
25
25
  z as validate
26
26
  };
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -7,3 +7,4 @@ export {
7
7
  s as normalizeMongoFilter,
8
8
  a as setNestedValue
9
9
  };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,52 +1,52 @@
1
- function p(e) {
1
+ function A(e) {
2
2
  try {
3
3
  return JSON.parse(e), !0;
4
4
  } catch {
5
5
  return !1;
6
6
  }
7
7
  }
8
- function A(e, t) {
8
+ function p(e, t) {
9
9
  let n = e;
10
- const o = t.length;
11
- for (let r = 0; r < o; r++) {
10
+ const s = t.length;
11
+ for (let r = 0; r < s; r++) {
12
12
  if (n == null || typeof n != "object")
13
13
  return;
14
- const s = t[r];
15
- if (s !== void 0 && s in n)
16
- n = n[s];
14
+ const o = t[r];
15
+ if (o !== void 0 && o in n)
16
+ n = n[o];
17
17
  else
18
18
  return;
19
19
  }
20
20
  return n;
21
21
  }
22
- function f(e, t, n, o) {
23
- if (o >= t.length)
22
+ function c(e, t, n, s) {
23
+ if (s >= t.length)
24
24
  return e;
25
- const r = t[o];
26
- if (o === t.length - 1)
25
+ const r = t[s];
26
+ if (s === t.length - 1)
27
27
  return {
28
28
  ...e,
29
29
  [r]: n
30
30
  };
31
- const s = e[r];
31
+ const o = e[r];
32
32
  return {
33
33
  ...e,
34
- [r]: f(
35
- typeof s == "object" && s !== null ? s : {},
34
+ [r]: c(
35
+ typeof o == "object" && o !== null ? o : {},
36
36
  t,
37
37
  n,
38
- o + 1
38
+ s + 1
39
39
  )
40
40
  };
41
41
  }
42
42
  function g(e, t, n) {
43
- return t.length === 0 ? e : f(e, t, n, 0);
43
+ return t.length === 0 ? e : c(e, t, n, 0);
44
44
  }
45
- function u(e) {
45
+ function f(e) {
46
46
  if (e === null || typeof e != "object")
47
47
  return e;
48
48
  if (Array.isArray(e))
49
- return e.map((o) => u(o));
49
+ return e.map((s) => f(s));
50
50
  if (e instanceof Date)
51
51
  return new Date(e.getTime());
52
52
  if (e instanceof RegExp)
@@ -55,8 +55,8 @@ function u(e) {
55
55
  if (t !== Object.prototype && t !== null)
56
56
  return e;
57
57
  const n = {};
58
- for (const o in e)
59
- Object.prototype.hasOwnProperty.call(e, o) && (n[o] = u(e[o]));
58
+ for (const s in e)
59
+ Object.hasOwn(e, s) && (n[s] = f(e[s]));
60
60
  return n;
61
61
  }
62
62
  function y(...e) {
@@ -68,22 +68,22 @@ function y(...e) {
68
68
  if (t.length === 1)
69
69
  return t[0];
70
70
  if (t.every(Array.isArray))
71
- return [].concat(...t);
71
+ return t.flat();
72
72
  if (t.every((r) => typeof r == "object" && r !== null && !Array.isArray(r))) {
73
73
  const r = {};
74
- for (const s of t) {
75
- const i = s;
76
- for (const l in i)
77
- if (Object.prototype.hasOwnProperty.call(i, l)) {
78
- const a = i[l];
79
- if (Object.prototype.hasOwnProperty.call(r, l)) {
80
- const c = r[l];
81
- typeof a == "object" && a !== null && typeof c == "object" && c !== null ? Array.isArray(a) && Array.isArray(c) ? r[l] = c.concat(a) : !Array.isArray(a) && !Array.isArray(c) ? r[l] = y(
82
- c,
83
- a
84
- ) : r[l] = a : r[l] = a;
74
+ for (const o of t) {
75
+ const l = o;
76
+ for (const i in l)
77
+ if (Object.hasOwn(l, i)) {
78
+ const u = l[i];
79
+ if (Object.hasOwn(r, i)) {
80
+ const a = r[i];
81
+ typeof u == "object" && u !== null && typeof a == "object" && a !== null ? Array.isArray(u) && Array.isArray(a) ? r[i] = [...a, ...u] : !Array.isArray(u) && !Array.isArray(a) ? r[i] = y(
82
+ a,
83
+ u
84
+ ) : r[i] = u : r[i] = u;
85
85
  } else
86
- r[l] = a;
86
+ r[i] = u;
87
87
  }
88
88
  }
89
89
  return r;
@@ -92,10 +92,10 @@ function y(...e) {
92
92
  throw new Error(
93
93
  "deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
94
94
  );
95
- const n = t.some(Array.isArray), o = t.some(
95
+ const n = t.some(Array.isArray), s = t.some(
96
96
  (r) => typeof r == "object" && r !== null && !Array.isArray(r)
97
97
  );
98
- throw n && o ? new Error(
98
+ throw n && s ? new Error(
99
99
  "deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
100
100
  ) : new Error(
101
101
  "deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
@@ -105,30 +105,31 @@ function h(e) {
105
105
  if (!e || typeof e != "object")
106
106
  return e;
107
107
  const t = {};
108
- function n(o, r) {
109
- for (const s in o) {
110
- if (!Object.prototype.hasOwnProperty.call(o, s))
108
+ function n(s, r) {
109
+ for (const o in s) {
110
+ if (!Object.hasOwn(s, o))
111
111
  continue;
112
- const i = o[s], l = r ? `${r}.${s}` : s;
113
- if (i && typeof i == "object" && !Array.isArray(i)) {
114
- let a = !1;
115
- for (const c in i)
116
- if (Object.prototype.hasOwnProperty.call(i, c) && c.startsWith("$")) {
117
- a = !0;
112
+ const l = s[o], i = r ? `${r}.${o}` : o;
113
+ if (l && typeof l == "object" && !Array.isArray(l)) {
114
+ let u = !1;
115
+ for (const a in l)
116
+ if (Object.hasOwn(l, a) && a.startsWith("$")) {
117
+ u = !0;
118
118
  break;
119
119
  }
120
- a ? t[l] = i : n(i, l);
120
+ u ? t[i] = l : n(l, i);
121
121
  } else
122
- t[l] = i;
122
+ t[i] = l;
123
123
  }
124
124
  }
125
125
  return n(e, ""), t;
126
126
  }
127
127
  export {
128
- u as deepClone,
128
+ f as deepClone,
129
129
  y as deepMerge,
130
- A as getNestedValue,
131
- p as isJSON,
130
+ p as getNestedValue,
131
+ A as isJSON,
132
132
  h as normalizeMongoFilter,
133
133
  g as setNestedValue
134
134
  };
135
+ //# sourceMappingURL=object.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.util.js","sources":["../../../src/util/object/object.util.ts"],"sourcesContent":["/**\n * Check if a string is a valid JSON string.\n * This function attempts to parse the string as JSON and returns true if successful,\n * false if the string is not valid JSON.\n *\n * @param str - The string to check for valid JSON format.\n * @returns True if the string is a valid JSON string, false otherwise.\n */\nexport function isJSON(str: string): boolean {\n try {\n JSON.parse(str);\n return true;\n }\n catch {\n return false;\n }\n}\n\n/**\n * Gets a nested value from an object using a path array.\n * This function traverses the object following the provided path and returns\n * the value at the specified location, or undefined if the path doesn't exist.\n *\n * @param obj - The object to get the value from.\n * @param path - An array of keys representing the path to the desired value.\n * @returns The value at the specified path, or undefined if the path doesn't exist.\n */\nexport function getNestedValue<T>(obj: T, path: (string | number)[]): unknown {\n // Optimization: Loop is faster than reduce and allows early exit\n let current: unknown = obj;\n const len = path.length;\n\n for (let i = 0; i < len; i++) {\n // Optimization: Early return if current value is null/undefined or not an object\n // This avoids unnecessary key lookups and type checks\n if (current == null || typeof current !== 'object') {\n return undefined;\n }\n\n const key = path[i];\n\n if (key !== undefined && key in (current as Record<string | number, unknown>)) {\n current = (current as Record<string | number, unknown>)[key];\n }\n else {\n return undefined;\n }\n }\n\n return current;\n}\n\n/**\n *\n */\nfunction setNestedValueHelper<T>(obj: T, path: (string | number)[], value: unknown, index: number): T {\n if (index >= path.length)\n return obj;\n\n const head = path[index];\n\n if (index === path.length - 1) {\n return {\n ...(obj as Record<string | number, unknown>),\n [head as string | number]: value,\n } as T;\n }\n\n const current = (obj as Record<string | number, unknown>)[head as string | number];\n\n return {\n ...(obj as Record<string | number, unknown>),\n [head as string | number | symbol]: setNestedValueHelper(\n typeof current === 'object' && current !== null\n ? (current as object)\n : {},\n path,\n value,\n index + 1,\n ),\n } as T;\n}\n\n/**\n * Sets a nested value in an object using a path array.\n * This function creates the path if it doesn't exist and sets the value at the specified location.\n * The function returns a new object with the updated value, maintaining immutability.\n *\n * @param obj - The object to set the value in.\n * @param path - An array of keys representing the path to the desired location.\n * @param value - The value to set at the specified path.\n * @returns A new object with the updated value at the specified path.\n */\nexport function setNestedValue<T>(obj: T, path: (string | number)[], value: unknown): T {\n if (path.length === 0)\n return obj;\n\n return setNestedValueHelper(obj, path, value, 0);\n}\n\n/**\n * Deep clones an object or array.\n * This function creates a deep copy of the input, recursively cloning objects and arrays.\n * Primitive values, dates, and other non-plain objects are returned as is (or cloned if supported).\n * Note: This implementation focuses on plain objects and arrays. For complex types like Map/Set/Buffer/ObjectId,\n * it returns the reference or handles them according to specific logic.\n *\n * @param obj - The object to clone.\n * @returns A deep copy of the object.\n */\nexport function deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => deepClone(item)) as unknown as T;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as unknown as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as unknown as T;\n }\n\n // Handle Mongoose ObjectId and other custom classes by returning reference\n // structuredClone would fail here. We assume if it's not a plain object, we keep the reference\n // unless we want to implement specific cloning logic for every type.\n // However, we want to clone POJOs (Plain Old JavaScript Objects).\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n return obj;\n }\n\n const result = {} as Record<string, unknown>;\n for (const key in obj) {\n if (Object.hasOwn(obj, key)) {\n result[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n }\n\n return result as T;\n}\n\n/**\n * Deep merges multiple objects into a single object.\n * @param args - The objects to merge. Can be empty, in which case returns an empty object.\n * @returns The merged object.\n */\nexport function deepMerge<T = Record<string, unknown>>(\n ...args: (object | null | undefined)[]\n): T;\n\n/**\n * Deep merges multiple arrays into a single array.\n * @param args - The arrays to merge. Can be empty, in which case returns an empty array.\n * @returns The merged array.\n */\nexport function deepMerge<T = unknown[]>(\n ...args: (unknown[] | null | undefined)[]\n): T;\n\n/**\n * Implementation of deepMerge function.\n * @param args - The objects or arrays to merge.\n * @returns The merged result.\n */\nexport function deepMerge<T = Record<string, unknown> | unknown[]>(\n ...args: (object | unknown[] | null | undefined)[]\n): T {\n // Handle empty arguments\n if (args.length === 0) {\n return {} as T;\n }\n\n // Filter out null/undefined and convert to empty objects/arrays\n const validArgs = args.filter((arg): arg is object => arg !== null && arg !== undefined);\n\n // If no valid arguments after filtering, return empty object/array\n if (validArgs.length === 0) {\n return {} as T;\n }\n\n // If only one argument, return it directly\n if (validArgs.length === 1) {\n return validArgs[0] as T;\n }\n\n // Check if all arguments are arrays\n if (validArgs.every(Array.isArray)) {\n return (validArgs as unknown[][]).flat() as T;\n }\n\n // Check if all arguments are objects (but not arrays)\n if (validArgs.every(arg => typeof arg === 'object' && arg !== null && !Array.isArray(arg))) {\n const result = {} as Record<string, unknown>;\n\n for (const arg of validArgs) {\n const obj = arg as Record<string, unknown>;\n for (const key in obj) {\n if (Object.hasOwn(obj, key)) {\n const value = obj[key];\n if (Object.hasOwn(result, key)) {\n const existingValue = result[key];\n if (\n typeof value === 'object' && value !== null\n && typeof existingValue === 'object' && existingValue !== null\n ) {\n if (Array.isArray(value) && Array.isArray(existingValue)) {\n result[key] = [...existingValue, ...value];\n }\n else if (!Array.isArray(value) && !Array.isArray(existingValue)) {\n result[key] = deepMerge(\n existingValue as Record<string, unknown>,\n value as Record<string, unknown>,\n );\n }\n else {\n // One is array, other is object (shouldn't happen with strict types but possible)\n // Overwrite\n result[key] = value;\n }\n }\n else {\n result[key] = value;\n }\n }\n else {\n result[key] = value;\n }\n }\n }\n }\n return result as T;\n }\n\n // Check if all arguments are primitive values\n if (validArgs.every(arg => typeof arg !== 'object' || arg === null)) {\n throw new Error(\n 'deepMerge: Cannot merge primitive values. All arguments must be objects or arrays.',\n );\n }\n\n // Mixed types error\n const hasArrays = validArgs.some(Array.isArray);\n const hasObjects = validArgs.some(arg =>\n typeof arg === 'object' && arg !== null && !Array.isArray(arg),\n );\n\n if (hasArrays && hasObjects) {\n throw new Error(\n 'deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects.',\n );\n }\n\n // Fallback for unexpected cases\n throw new Error(\n 'deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type.',\n );\n}\n\n/**\n * Normalizes MongoDB filters to support both dot notation strings and nested objects.\n * This function converts nested object filters to dot notation format while preserving\n * MongoDB operators to ensure consistent behavior across different filter input formats.\n *\n * @param filter - The filter object to normalize.\n * @returns A normalized filter object with nested objects converted to dot notation,\n * while preserving MongoDB operators as nested objects.\n *\n * @example\n * ```typescript\n * // Both of these will work the same way:\n * normalizeMongoFilter({ \"location.countryId\": \"240\" })\n * normalizeMongoFilter({ location: { countryId: \"240\" } })\n * // Both return: { \"location.countryId\": \"240\" }\n *\n * // MongoDB operators are preserved:\n * normalizeMongoFilter({ id: { $in: [\"240\", \"59\"] } })\n * // Returns: { id: { $in: [\"240\", \"59\"] } }\n * ```\n */\nexport function normalizeMongoFilter<T extends Record<string, unknown>>(filter: T): T {\n if (!filter || typeof filter !== 'object') {\n return filter;\n }\n\n const normalized: Record<string, unknown> = {};\n\n /**\n *\n */\n function flatten(current: Record<string, unknown>, prefix: string) {\n for (const key in current) {\n if (!Object.hasOwn(current, key))\n continue;\n\n const value = current[key];\n const newKey = prefix ? `${prefix}.${key}` : key;\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n // Check for Mongo operator\n let hasMongoOperator = false;\n for (const subKey in value as Record<string, unknown>) {\n if (Object.hasOwn(value, subKey) && subKey.startsWith('$')) {\n hasMongoOperator = true;\n break;\n }\n }\n\n if (hasMongoOperator) {\n normalized[newKey] = value;\n }\n else {\n flatten(value as Record<string, unknown>, newKey);\n }\n }\n else {\n normalized[newKey] = value;\n }\n }\n }\n\n flatten(filter, '');\n\n return normalized as T;\n}\n"],"names":["isJSON","str","getNestedValue","obj","path","current","len","i","key","setNestedValueHelper","value","index","head","setNestedValue","deepClone","item","proto","result","deepMerge","args","validArgs","arg","existingValue","hasArrays","hasObjects","normalizeMongoFilter","filter","normalized","flatten","prefix","newKey","hasMongoOperator","subKey"],"mappings":"AAQO,SAASA,EAAOC,GAAsB;AACzC,MAAI;AACA,gBAAK,MAAMA,CAAG,GACP;AAAA,EACX,QACM;AACF,WAAO;AAAA,EACX;AACJ;AAWO,SAASC,EAAkBC,GAAQC,GAAoC;AAE1E,MAAIC,IAAmBF;AACvB,QAAMG,IAAMF,EAAK;AAEjB,WAASG,IAAI,GAAGA,IAAID,GAAKC,KAAK;AAG1B,QAAIF,KAAW,QAAQ,OAAOA,KAAY;AACtC;AAGJ,UAAMG,IAAMJ,EAAKG,CAAC;AAElB,QAAIC,MAAQ,UAAaA,KAAQH;AAC7B,MAAAA,IAAWA,EAA6CG,CAAG;AAAA;AAG3D;AAAA,EAER;AAEA,SAAOH;AACX;AAKA,SAASI,EAAwBN,GAAQC,GAA2BM,GAAgBC,GAAkB;AAClG,MAAIA,KAASP,EAAK;AACd,WAAOD;AAEX,QAAMS,IAAOR,EAAKO,CAAK;AAEvB,MAAIA,MAAUP,EAAK,SAAS;AACxB,WAAO;AAAA,MACH,GAAID;AAAA,MACJ,CAACS,CAAuB,GAAGF;AAAA,IAAA;AAInC,QAAML,IAAWF,EAAyCS,CAAuB;AAEjF,SAAO;AAAA,IACH,GAAIT;AAAA,IACJ,CAACS,CAAgC,GAAGH;AAAA,MAChC,OAAOJ,KAAY,YAAYA,MAAY,OACpCA,IACD,CAAA;AAAA,MACND;AAAA,MACAM;AAAA,MACAC,IAAQ;AAAA,IAAA;AAAA,EACZ;AAER;AAYO,SAASE,EAAkBV,GAAQC,GAA2BM,GAAmB;AACpF,SAAIN,EAAK,WAAW,IACTD,IAEJM,EAAqBN,GAAKC,GAAMM,GAAO,CAAC;AACnD;AAYO,SAASI,EAAaX,GAAW;AACpC,MAAIA,MAAQ,QAAQ,OAAOA,KAAQ;AAC/B,WAAOA;AAGX,MAAI,MAAM,QAAQA,CAAG;AACjB,WAAOA,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QAAIA,IACAJ,EAAWG,CAAM,IAAIpB,IAGrBkB,EAAQlB,GAAkCoB,CAAM;AAAA,MAExD;AAEI,QAAAH,EAAWG,CAAM,IAAIpB;AAAA,IAE7B;AAAA,EACJ;AAEA,SAAAkB,EAAQF,GAAQ,EAAE,GAEXC;AACX;"}
@@ -2,3 +2,4 @@ import { serializer as i } from "./serializer.util.js";
2
2
  export {
3
3
  i as serializer
4
4
  };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,4 +1,4 @@
1
- const n = {
1
+ const s = {
2
2
  Date: {
3
3
  is: (e) => e instanceof Date,
4
4
  serialize: (e) => ({ __type: "Date", value: e.toISOString() }),
@@ -6,12 +6,12 @@ const n = {
6
6
  },
7
7
  Map: {
8
8
  is: (e) => e instanceof Map,
9
- serialize: (e) => ({ __type: "Map", value: Array.from(e.entries()) }),
9
+ serialize: (e) => ({ __type: "Map", value: [...e.entries()] }),
10
10
  deserialize: (e) => new Map(e)
11
11
  },
12
12
  Set: {
13
13
  is: (e) => e instanceof Set,
14
- serialize: (e) => ({ __type: "Set", value: Array.from(e) }),
14
+ serialize: (e) => ({ __type: "Set", value: [...e] }),
15
15
  deserialize: (e) => new Set(e)
16
16
  },
17
17
  RegExp: {
@@ -21,8 +21,8 @@ const n = {
21
21
  value: { source: e.source, flags: e.flags }
22
22
  }),
23
23
  deserialize: (e) => {
24
- const { source: r, flags: t } = e;
25
- return new RegExp(r, t);
24
+ const { source: n, flags: t } = e;
25
+ return new RegExp(n, t);
26
26
  }
27
27
  },
28
28
  BigInt: {
@@ -41,12 +41,12 @@ const n = {
41
41
  * @returns The serialized JSON string that can be safely stored or transmitted.
42
42
  */
43
43
  serialize(e) {
44
- return JSON.stringify(e, function(r, t) {
45
- const i = this[r];
44
+ return JSON.stringify(e, function(n, t) {
45
+ const i = this[n];
46
46
  if (i instanceof Date)
47
- return n.Date.serialize(i);
48
- for (const o of Object.keys(n)) {
49
- const a = n[o];
47
+ return s.Date.serialize(i);
48
+ for (const o of Object.keys(s)) {
49
+ const a = s[o];
50
50
  if (a.is(t))
51
51
  return a.serialize(t);
52
52
  }
@@ -63,9 +63,9 @@ const n = {
63
63
  * @returns The deserialized value with all special types reconstructed.
64
64
  */
65
65
  deserialize(e) {
66
- return JSON.parse(e, (r, t) => {
66
+ return JSON.parse(e, (n, t) => {
67
67
  if (t && typeof t == "object" && "__type" in t && typeof t.__type == "string") {
68
- const s = t.__type, i = n[s];
68
+ const r = t.__type, i = s[r];
69
69
  if (i)
70
70
  return i.deserialize(t.value);
71
71
  }
@@ -76,3 +76,4 @@ const n = {
76
76
  export {
77
77
  p as serializer
78
78
  };
79
+ //# sourceMappingURL=serializer.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.util.js","sources":["../../../src/util/serializer/serializer.util.ts"],"sourcesContent":["import type {\n I_Serializer,\n I_SerializerTypeWrapper,\n I_SerializerValueMap,\n T_SerializerKnownTypes,\n} from './serializer.type.js';\n\n/**\n * Interface for handling serialization and deserialization of specific types.\n * Each handler provides methods to check if a value is of the specific type,\n * serialize it to a format that can be JSON stringified, and deserialize it back.\n */\ninterface I_Handler<T extends T_SerializerKnownTypes> {\n /** Checks if a value is of the specific type */\n is: (value: unknown) => value is I_SerializerValueMap[T];\n /** Serializes a value of the specific type to a format that can be JSON stringified */\n serialize: (value: I_SerializerValueMap[T]) => I_SerializerTypeWrapper<T>;\n /** Deserializes a value back to the specific type */\n deserialize: (value: unknown) => I_SerializerValueMap[T];\n}\n\n/**\n * Type handlers for different JavaScript types that cannot be directly serialized to JSON.\n * Each handler provides methods to serialize and deserialize specific types like Date, Map, Set, etc.\n */\nconst typeHandlers: {\n [K in T_SerializerKnownTypes]: I_Handler<K>;\n} = {\n Date: {\n is: (v): v is Date => v instanceof Date,\n serialize: v => ({ __type: 'Date', value: v.toISOString() }),\n deserialize: v => new Date(v as string),\n },\n Map: {\n is: (v): v is Map<unknown, unknown> => v instanceof Map,\n serialize: v => ({ __type: 'Map', value: [...v.entries()] }),\n deserialize: v => new Map(v as [unknown, unknown][]),\n },\n Set: {\n is: (v): v is Set<unknown> => v instanceof Set,\n serialize: v => ({ __type: 'Set', value: [...v] }),\n deserialize: v => new Set(v as unknown[]),\n },\n RegExp: {\n is: (v): v is RegExp => v instanceof RegExp,\n serialize: v => ({\n __type: 'RegExp',\n value: { source: v.source, flags: v.flags },\n }),\n deserialize: (v) => {\n const { source, flags } = v as { source: string; flags: string };\n return new RegExp(source, flags);\n },\n },\n BigInt: {\n is: (v): v is bigint => typeof v === 'bigint',\n serialize: v => ({ __type: 'BigInt', value: v.toString() }),\n deserialize: v => BigInt(v as string),\n },\n};\n\n/**\n * A serializer that can handle complex JavaScript types that cannot be directly JSON stringified.\n * This serializer extends JSON.stringify and JSON.parse to handle types like Date, Map, Set, RegExp, and BigInt.\n *\n * The serializer works by:\n * 1. During serialization: Wrapping special types with type information before JSON stringification\n * 2. During deserialization: Detecting wrapped types and reconstructing them to their original form\n */\nexport const serializer: I_Serializer<unknown> = {\n /**\n * Serializes a value to a JSON string.\n * If the value is of a known type (Date, Map, Set, RegExp, BigInt),\n * it will be serialized using the corresponding handler.\n * Otherwise, it will be serialized as is.\n *\n * @param value - The value to serialize to a JSON string.\n * @returns The serialized JSON string that can be safely stored or transmitted.\n */\n serialize(value) {\n return JSON.stringify(value, function (_key, val) {\n // eslint-disable-next-line ts/no-this-alias\n const context = this;\n const originalValue = context[_key];\n\n if (originalValue instanceof Date) {\n return typeHandlers.Date.serialize(originalValue);\n }\n\n for (const type of Object.keys(typeHandlers) as T_SerializerKnownTypes[]) {\n const handler = typeHandlers[type];\n\n if (handler.is(val)) {\n return (handler as I_Handler<typeof type>).serialize(val);\n }\n }\n\n return val;\n });\n },\n /**\n * Deserializes a JSON string to its original value.\n * If the value is of a known type (Date, Map, Set, RegExp, BigInt),\n * it will be deserialized using the corresponding handler.\n * Otherwise, it will be deserialized as is.\n *\n * @param json - The JSON string to deserialize back to its original form.\n * @returns The deserialized value with all special types reconstructed.\n */\n deserialize(json) {\n return JSON.parse(json, (_key, val) => {\n if (\n val\n && typeof val === 'object'\n && '__type' in val\n && typeof val.__type === 'string'\n ) {\n const type = val.__type as T_SerializerKnownTypes;\n const handler = typeHandlers[type];\n\n if (handler) {\n return handler.deserialize(val.value);\n }\n }\n return val;\n });\n },\n};\n"],"names":["typeHandlers","v","source","flags","serializer","value","_key","val","originalValue","type","handler","json"],"mappings":"AAyBA,MAAMA,IAEF;AAAA,EACA,MAAM;AAAA,IACF,IAAI,CAACC,MAAiBA,aAAa;AAAA,IACnC,WAAW,QAAM,EAAE,QAAQ,QAAQ,OAAOA,EAAE;IAC5C,aAAa,CAAAA,MAAK,IAAI,KAAKA,CAAW;AAAA,EAAA;AAAA,EAE1C,KAAK;AAAA,IACD,IAAI,CAACA,MAAkCA,aAAa;AAAA,IACpD,WAAW,CAAAA,OAAM,EAAE,QAAQ,OAAO,OAAO,CAAC,GAAGA,EAAE,QAAA,CAAS;IACxD,aAAa,CAAAA,MAAK,IAAI,IAAIA,CAAyB;AAAA,EAAA;AAAA,EAEvD,KAAK;AAAA,IACD,IAAI,CAACA,MAAyBA,aAAa;AAAA,IAC3C,WAAW,QAAM,EAAE,QAAQ,OAAO,OAAO,CAAC,GAAGA,CAAC;IAC9C,aAAa,CAAAA,MAAK,IAAI,IAAIA,CAAc;AAAA,EAAA;AAAA,EAE5C,QAAQ;AAAA,IACJ,IAAI,CAACA,MAAmBA,aAAa;AAAA,IACrC,WAAW,CAAAA,OAAM;AAAA,MACb,QAAQ;AAAA,MACR,OAAO,EAAE,QAAQA,EAAE,QAAQ,OAAOA,EAAE,MAAA;AAAA,IAAM;AAAA,IAE9C,aAAa,CAACA,MAAM;AAChB,YAAM,EAAE,QAAAC,GAAQ,OAAAC,EAAA,IAAUF;AAC1B,aAAO,IAAI,OAAOC,GAAQC,CAAK;AAAA,IACnC;AAAA,EAAA;AAAA,EAEJ,QAAQ;AAAA,IACJ,IAAI,CAACF,MAAmB,OAAOA,KAAM;AAAA,IACrC,WAAW,QAAM,EAAE,QAAQ,UAAU,OAAOA,EAAE;IAC9C,aAAa,CAAAA,MAAK,OAAOA,CAAW;AAAA,EAAA;AAE5C,GAUaG,IAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU7C,UAAUC,GAAO;AACb,WAAO,KAAK,UAAUA,GAAO,SAAUC,GAAMC,GAAK;AAG9C,YAAMC,IADU,KACcF,CAAI;AAElC,UAAIE,aAAyB;AACzB,eAAOR,EAAa,KAAK,UAAUQ,CAAa;AAGpD,iBAAWC,KAAQ,OAAO,KAAKT,CAAY,GAA+B;AACtE,cAAMU,IAAUV,EAAaS,CAAI;AAEjC,YAAIC,EAAQ,GAAGH,CAAG;AACd,iBAAQG,EAAmC,UAAUH,CAAG;AAAA,MAEhE;AAEA,aAAOA;AAAA,IACX,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,YAAYI,GAAM;AACd,WAAO,KAAK,MAAMA,GAAM,CAACL,GAAMC,MAAQ;AACnC,UACIA,KACG,OAAOA,KAAQ,YACf,YAAYA,KACZ,OAAOA,EAAI,UAAW,UAC3B;AACE,cAAME,IAAOF,EAAI,QACXG,IAAUV,EAAaS,CAAI;AAEjC,YAAIC;AACA,iBAAOA,EAAQ,YAAYH,EAAI,KAAK;AAAA,MAE5C;AACA,aAAOA;AAAA,IACX,CAAC;AAAA,EACL;AACJ;"}
@@ -7,3 +7,4 @@ export {
7
7
  o as getFileName,
8
8
  d as substringBetween
9
9
  };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}