@cyberskill/shared 2.28.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) 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.test.unit.d.ts +1 -0
  4. package/dist/config/config.type.js +1 -0
  5. package/dist/config/config.type.js.map +1 -0
  6. package/dist/config/config.type.test.unit.d.ts +1 -0
  7. package/dist/config/config.util.js +25 -33
  8. package/dist/config/config.util.js.map +1 -0
  9. package/dist/config/env/env.constant.js +1 -0
  10. package/dist/config/env/env.constant.js.map +1 -0
  11. package/dist/config/env/env.util.js +1 -0
  12. package/dist/config/env/env.util.js.map +1 -0
  13. package/dist/config/env/index.js +1 -0
  14. package/dist/config/env/index.js.map +1 -0
  15. package/dist/config/eslint/index.d.ts +4 -0
  16. package/dist/config/eslint/index.js +5 -12
  17. package/dist/config/eslint/index.js.map +1 -0
  18. package/dist/config/graphql-codegen/graphql-codegen.util.js +29 -33
  19. package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -0
  20. package/dist/config/graphql-codegen/index.js +1 -0
  21. package/dist/config/graphql-codegen/index.js.map +1 -0
  22. package/dist/config/index.js +1 -0
  23. package/dist/config/index.js.map +1 -0
  24. package/dist/config/lint-staged/index.js +1 -0
  25. package/dist/config/lint-staged/index.js.map +1 -0
  26. package/dist/config/storybook/index.js +1 -0
  27. package/dist/config/storybook/index.js.map +1 -0
  28. package/dist/config/storybook/storybook.main.js +1 -0
  29. package/dist/config/storybook/storybook.main.js.map +1 -0
  30. package/dist/config/storybook/storybook.preview.js +11 -13
  31. package/dist/config/storybook/storybook.preview.js.map +1 -0
  32. package/dist/config/vitest/index.js +1 -0
  33. package/dist/config/vitest/index.js.map +1 -0
  34. package/dist/config/vitest/vitest.e2e.js +2 -1
  35. package/dist/config/vitest/vitest.e2e.js.map +1 -0
  36. package/dist/config/vitest/vitest.unit.js +20 -8
  37. package/dist/config/vitest/vitest.unit.js.map +1 -0
  38. package/dist/constant/common.js +2 -1
  39. package/dist/constant/common.js.map +1 -0
  40. package/dist/constant/constant.test.unit.d.ts +1 -0
  41. package/dist/constant/index.js +1 -0
  42. package/dist/constant/index.js.map +1 -0
  43. package/dist/constant/response-status.js +1 -0
  44. package/dist/constant/response-status.js.map +1 -0
  45. package/dist/node/apollo-server/apollo-server.util.js +22 -48
  46. package/dist/node/apollo-server/apollo-server.util.js.map +1 -0
  47. package/dist/node/apollo-server/index.js +1 -0
  48. package/dist/node/apollo-server/index.js.map +1 -0
  49. package/dist/node/cli/index.js +110 -165
  50. package/dist/node/cli/index.js.map +1 -0
  51. package/dist/node/command/command.test.unit.d.ts +1 -0
  52. package/dist/node/command/command.type.js +1 -0
  53. package/dist/node/command/command.type.js.map +1 -0
  54. package/dist/node/command/command.util.js +142 -169
  55. package/dist/node/command/command.util.js.map +1 -0
  56. package/dist/node/command/index.js +1 -0
  57. package/dist/node/command/index.js.map +1 -0
  58. package/dist/node/express/express.type.d.ts +4 -0
  59. package/dist/node/express/express.util.js +56 -71
  60. package/dist/node/express/express.util.js.map +1 -0
  61. package/dist/node/express/index.js +1 -0
  62. package/dist/node/express/index.js.map +1 -0
  63. package/dist/node/fs/fs.test.unit.d.ts +1 -0
  64. package/dist/node/fs/fs.util.js +46 -60
  65. package/dist/node/fs/fs.util.js.map +1 -0
  66. package/dist/node/fs/index.js +1 -0
  67. package/dist/node/fs/index.js.map +1 -0
  68. package/dist/node/log/index.js +1 -0
  69. package/dist/node/log/index.js.map +1 -0
  70. package/dist/node/log/log.test.unit.d.ts +1 -0
  71. package/dist/node/log/log.type.js +1 -0
  72. package/dist/node/log/log.type.js.map +1 -0
  73. package/dist/node/log/log.util.js +30 -30
  74. package/dist/node/log/log.util.js.map +1 -0
  75. package/dist/node/mongo/index.d.ts +2 -0
  76. package/dist/node/mongo/index.js +21 -12
  77. package/dist/node/mongo/index.js.map +1 -0
  78. package/dist/node/mongo/mongo.constant.js +1 -0
  79. package/dist/node/mongo/mongo.constant.js.map +1 -0
  80. package/dist/node/mongo/mongo.controller.d.ts +5 -315
  81. package/dist/node/mongo/mongo.controller.mongoose.d.ts +234 -0
  82. package/dist/node/mongo/mongo.controller.mongoose.js +468 -0
  83. package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -0
  84. package/dist/node/mongo/mongo.controller.native.d.ts +84 -0
  85. package/dist/node/mongo/mongo.controller.native.js +214 -0
  86. package/dist/node/mongo/mongo.controller.native.js.map +1 -0
  87. package/dist/node/mongo/mongo.dynamic-populate.d.ts +61 -0
  88. package/dist/node/mongo/mongo.dynamic-populate.js +197 -0
  89. package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -0
  90. package/dist/node/mongo/mongo.populate.d.ts +15 -0
  91. package/dist/node/mongo/mongo.populate.js +269 -0
  92. package/dist/node/mongo/mongo.populate.js.map +1 -0
  93. package/dist/node/mongo/mongo.type.js +1 -0
  94. package/dist/node/mongo/mongo.type.js.map +1 -0
  95. package/dist/node/mongo/mongo.util.d.ts +52 -0
  96. package/dist/node/mongo/mongo.util.js +111 -409
  97. package/dist/node/mongo/mongo.util.js.map +1 -0
  98. package/dist/node/package/index.js +1 -0
  99. package/dist/node/package/index.js.map +1 -0
  100. package/dist/node/package/package.test.unit.d.ts +1 -0
  101. package/dist/node/package/package.type.js +1 -0
  102. package/dist/node/package/package.type.js.map +1 -0
  103. package/dist/node/package/package.util.js +197 -226
  104. package/dist/node/package/package.util.js.map +1 -0
  105. package/dist/node/path/index.js +27 -25
  106. package/dist/node/path/index.js.map +1 -0
  107. package/dist/node/path/path.constant.d.ts +2 -0
  108. package/dist/node/path/path.constant.js +131 -150
  109. package/dist/node/path/path.constant.js.map +1 -0
  110. package/dist/node/path/path.util.js +1 -0
  111. package/dist/node/path/path.util.js.map +1 -0
  112. package/dist/node/storage/index.js +1 -0
  113. package/dist/node/storage/index.js.map +1 -0
  114. package/dist/node/storage/storage.constant.js +1 -0
  115. package/dist/node/storage/storage.constant.js.map +1 -0
  116. package/dist/node/storage/storage.util.js +111 -158
  117. package/dist/node/storage/storage.util.js.map +1 -0
  118. package/dist/node/upload/index.js +1 -0
  119. package/dist/node/upload/index.js.map +1 -0
  120. package/dist/node/upload/upload.constant.js +1 -0
  121. package/dist/node/upload/upload.constant.js.map +1 -0
  122. package/dist/node/upload/upload.type.js +1 -0
  123. package/dist/node/upload/upload.type.js.map +1 -0
  124. package/dist/node/upload/upload.util.js +120 -150
  125. package/dist/node/upload/upload.util.js.map +1 -0
  126. package/dist/node/ws/index.d.ts +1 -1
  127. package/dist/node/ws/index.js +2 -1
  128. package/dist/node/ws/index.js.map +1 -0
  129. package/dist/node/ws/ws.util.js +46 -0
  130. package/dist/node/ws/ws.util.js.map +1 -0
  131. package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_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.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.js +1 -0
  132. 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.js.map +1 -0
  133. package/dist/react/apollo-client/apollo-client.component.js +5 -4
  134. package/dist/react/apollo-client/apollo-client.component.js.map +1 -0
  135. package/dist/react/apollo-client/apollo-client.constant.js +1 -0
  136. package/dist/react/apollo-client/apollo-client.constant.js.map +1 -0
  137. package/dist/react/apollo-client/apollo-client.context.js +1 -0
  138. package/dist/react/apollo-client/apollo-client.context.js.map +1 -0
  139. package/dist/react/apollo-client/apollo-client.module.scss.js +1 -0
  140. package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -0
  141. package/dist/react/apollo-client/apollo-client.util.js +52 -58
  142. package/dist/react/apollo-client/apollo-client.util.js.map +1 -0
  143. package/dist/react/apollo-client/index.js +1 -0
  144. package/dist/react/apollo-client/index.js.map +1 -0
  145. package/dist/react/apollo-client/links/index.js +1 -0
  146. package/dist/react/apollo-client/links/index.js.map +1 -0
  147. package/dist/react/apollo-client/links/upload.js +72 -74
  148. package/dist/react/apollo-client/links/upload.js.map +1 -0
  149. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -0
  150. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -0
  151. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +1 -0
  152. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -0
  153. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +12 -18
  154. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -0
  155. package/dist/react/apollo-client-nextjs/index.js +1 -0
  156. package/dist/react/apollo-client-nextjs/index.js.map +1 -0
  157. package/dist/react/apollo-error/apollo-error.component.js +62 -23
  158. package/dist/react/apollo-error/apollo-error.component.js.map +1 -0
  159. package/dist/react/apollo-error/apollo-error.context.js +1 -0
  160. package/dist/react/apollo-error/apollo-error.context.js.map +1 -0
  161. package/dist/react/apollo-error/apollo-error.hook.js +1 -0
  162. package/dist/react/apollo-error/apollo-error.hook.js.map +1 -0
  163. package/dist/react/apollo-error/apollo-error.module.scss.js +7 -6
  164. package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -0
  165. package/dist/react/apollo-error/apollo-error.provider.js +1 -0
  166. package/dist/react/apollo-error/apollo-error.provider.js.map +1 -0
  167. package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
  168. package/dist/react/apollo-error/apollo-error.util.js +7 -6
  169. package/dist/react/apollo-error/apollo-error.util.js.map +1 -0
  170. package/dist/react/apollo-error/index.js +1 -0
  171. package/dist/react/apollo-error/index.js.map +1 -0
  172. package/dist/react/i18next/i18next.hook.js +1 -0
  173. package/dist/react/i18next/i18next.hook.js.map +1 -0
  174. package/dist/react/i18next/i18next.util.js +1 -0
  175. package/dist/react/i18next/i18next.util.js.map +1 -0
  176. package/dist/react/i18next/index.js +1 -0
  177. package/dist/react/i18next/index.js.map +1 -0
  178. package/dist/react/loading/index.js +1 -0
  179. package/dist/react/loading/index.js.map +1 -0
  180. package/dist/react/loading/loading.component.js +31 -46
  181. package/dist/react/loading/loading.component.js.map +1 -0
  182. package/dist/react/loading/loading.context.js +1 -0
  183. package/dist/react/loading/loading.context.js.map +1 -0
  184. package/dist/react/loading/loading.hook.js +1 -0
  185. package/dist/react/loading/loading.hook.js.map +1 -0
  186. package/dist/react/loading/loading.module.scss.js +1 -0
  187. package/dist/react/loading/loading.module.scss.js.map +1 -0
  188. package/dist/react/loading/loading.provider.js +1 -0
  189. package/dist/react/loading/loading.provider.js.map +1 -0
  190. package/dist/react/log/index.js +1 -0
  191. package/dist/react/log/index.js.map +1 -0
  192. package/dist/react/log/log.util.js +5 -4
  193. package/dist/react/log/log.util.js.map +1 -0
  194. package/dist/react/next-intl/index.js +1 -0
  195. package/dist/react/next-intl/index.js.map +1 -0
  196. package/dist/react/next-intl/next-intl.constant.js +1 -0
  197. package/dist/react/next-intl/next-intl.constant.js.map +1 -0
  198. package/dist/react/next-intl/next-intl.context.js +1 -0
  199. package/dist/react/next-intl/next-intl.context.js.map +1 -0
  200. package/dist/react/next-intl/next-intl.hoc.js +14 -22
  201. package/dist/react/next-intl/next-intl.hoc.js.map +1 -0
  202. package/dist/react/next-intl/next-intl.hook.js +1 -0
  203. package/dist/react/next-intl/next-intl.hook.js.map +1 -0
  204. package/dist/react/next-intl/next-intl.provider.js +8 -7
  205. package/dist/react/next-intl/next-intl.provider.js.map +1 -0
  206. package/dist/react/storage/index.js +1 -0
  207. package/dist/react/storage/index.js.map +1 -0
  208. package/dist/react/storage/storage.hook.js +44 -59
  209. package/dist/react/storage/storage.hook.js.map +1 -0
  210. package/dist/react/storage/storage.test.unit.d.ts +1 -0
  211. package/dist/react/storage/storage.util.js +29 -53
  212. package/dist/react/storage/storage.util.js.map +1 -0
  213. package/dist/react/toast/index.js +1 -0
  214. package/dist/react/toast/index.js.map +1 -0
  215. package/dist/react/userback/index.js +1 -0
  216. package/dist/react/userback/index.js.map +1 -0
  217. package/dist/react/userback/userback.component.js +19 -42
  218. package/dist/react/userback/userback.component.js.map +1 -0
  219. package/dist/style.css +1 -1
  220. package/dist/typescript/common.type.js +1 -0
  221. package/dist/typescript/common.type.js.map +1 -0
  222. package/dist/typescript/index.js +1 -0
  223. package/dist/typescript/index.js.map +1 -0
  224. package/dist/typescript/typescript.test.unit.d.ts +1 -0
  225. package/dist/util/common/common.util.d.ts +2 -0
  226. package/dist/util/common/common.util.js +30 -37
  227. package/dist/util/common/common.util.js.map +1 -0
  228. package/dist/util/common/index.js +1 -0
  229. package/dist/util/common/index.js.map +1 -0
  230. package/dist/util/index.js +11 -9
  231. package/dist/util/index.js.map +1 -0
  232. package/dist/util/object/index.js +1 -0
  233. package/dist/util/object/index.js.map +1 -0
  234. package/dist/util/object/object.util.js +73 -76
  235. package/dist/util/object/object.util.js.map +1 -0
  236. package/dist/util/serializer/index.js +1 -0
  237. package/dist/util/serializer/index.js.map +1 -0
  238. package/dist/util/serializer/serializer.util.js +1 -0
  239. package/dist/util/serializer/serializer.util.js.map +1 -0
  240. package/dist/util/string/index.js +5 -3
  241. package/dist/util/string/index.js.map +1 -0
  242. package/dist/util/string/string.util.d.ts +12 -0
  243. package/dist/util/string/string.util.js +64 -44
  244. package/dist/util/string/string.util.js.map +1 -0
  245. package/dist/util/validate/index.js +1 -0
  246. package/dist/util/validate/index.js.map +1 -0
  247. package/dist/util/validate/validate.util.js +1 -0
  248. package/dist/util/validate/validate.util.js.map +1 -0
  249. package/package.json +76 -96
  250. package/public/tsconfig.base.json +7 -3
  251. package/README.md +0 -470
  252. package/dist/config/commitlint/index.cjs +0 -1
  253. package/dist/config/config.type.cjs +0 -1
  254. package/dist/config/config.util.cjs +0 -1
  255. package/dist/config/env/env.constant.cjs +0 -1
  256. package/dist/config/env/env.util.cjs +0 -1
  257. package/dist/config/env/index.cjs +0 -1
  258. package/dist/config/eslint/index.cjs +0 -1
  259. package/dist/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
  260. package/dist/config/graphql-codegen/index.cjs +0 -1
  261. package/dist/config/index.cjs +0 -1
  262. package/dist/config/lint-staged/index.cjs +0 -1
  263. package/dist/config/storybook/index.cjs +0 -1
  264. package/dist/config/storybook/storybook.main.cjs +0 -1
  265. package/dist/config/storybook/storybook.preview.cjs +0 -1
  266. package/dist/config/vitest/index.cjs +0 -1
  267. package/dist/config/vitest/vitest.e2e.cjs +0 -1
  268. package/dist/config/vitest/vitest.unit.cjs +0 -1
  269. package/dist/constant/common.cjs +0 -1
  270. package/dist/constant/index.cjs +0 -1
  271. package/dist/constant/response-status.cjs +0 -1
  272. package/dist/node/apollo-server/apollo-server.util.cjs +0 -1
  273. package/dist/node/apollo-server/index.cjs +0 -1
  274. package/dist/node/cli/index.cjs +0 -3
  275. package/dist/node/command/command.type.cjs +0 -1
  276. package/dist/node/command/command.util.cjs +0 -2
  277. package/dist/node/command/index.cjs +0 -1
  278. package/dist/node/express/express.util.cjs +0 -1
  279. package/dist/node/express/index.cjs +0 -1
  280. package/dist/node/fs/fs.util.cjs +0 -4
  281. package/dist/node/fs/index.cjs +0 -1
  282. package/dist/node/log/index.cjs +0 -1
  283. package/dist/node/log/log.type.cjs +0 -1
  284. package/dist/node/log/log.util.cjs +0 -1
  285. package/dist/node/mongo/index.cjs +0 -1
  286. package/dist/node/mongo/mongo.constant.cjs +0 -1
  287. package/dist/node/mongo/mongo.controller.cjs +0 -1
  288. package/dist/node/mongo/mongo.controller.js +0 -956
  289. package/dist/node/mongo/mongo.type.cjs +0 -1
  290. package/dist/node/mongo/mongo.util.cjs +0 -2
  291. package/dist/node/package/index.cjs +0 -1
  292. package/dist/node/package/package.type.cjs +0 -1
  293. package/dist/node/package/package.util.cjs +0 -1
  294. package/dist/node/path/index.cjs +0 -1
  295. package/dist/node/path/path.constant.cjs +0 -1
  296. package/dist/node/path/path.util.cjs +0 -1
  297. package/dist/node/storage/index.cjs +0 -1
  298. package/dist/node/storage/storage.constant.cjs +0 -1
  299. package/dist/node/storage/storage.util.cjs +0 -1
  300. package/dist/node/upload/index.cjs +0 -1
  301. package/dist/node/upload/upload.constant.cjs +0 -1
  302. package/dist/node/upload/upload.type.cjs +0 -1
  303. package/dist/node/upload/upload.util.cjs +0 -1
  304. package/dist/node/ws/index.cjs +0 -1
  305. package/dist/node/ws/ts.util.cjs +0 -1
  306. package/dist/node/ws/ts.util.js +0 -68
  307. package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.0_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
  308. package/dist/react/apollo-client/apollo-client.component.cjs +0 -1
  309. package/dist/react/apollo-client/apollo-client.constant.cjs +0 -1
  310. package/dist/react/apollo-client/apollo-client.context.cjs +0 -1
  311. package/dist/react/apollo-client/apollo-client.module.scss.cjs +0 -1
  312. package/dist/react/apollo-client/apollo-client.util.cjs +0 -1
  313. package/dist/react/apollo-client/index.cjs +0 -1
  314. package/dist/react/apollo-client/links/index.cjs +0 -1
  315. package/dist/react/apollo-client/links/upload.cjs +0 -1
  316. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
  317. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
  318. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
  319. package/dist/react/apollo-client-nextjs/index.cjs +0 -1
  320. package/dist/react/apollo-error/apollo-error.component.cjs +0 -1
  321. package/dist/react/apollo-error/apollo-error.context.cjs +0 -1
  322. package/dist/react/apollo-error/apollo-error.hook.cjs +0 -1
  323. package/dist/react/apollo-error/apollo-error.module.scss.cjs +0 -1
  324. package/dist/react/apollo-error/apollo-error.provider.cjs +0 -1
  325. package/dist/react/apollo-error/apollo-error.util.cjs +0 -1
  326. package/dist/react/apollo-error/index.cjs +0 -1
  327. package/dist/react/i18next/i18next.hook.cjs +0 -1
  328. package/dist/react/i18next/i18next.util.cjs +0 -1
  329. package/dist/react/i18next/index.cjs +0 -1
  330. package/dist/react/loading/index.cjs +0 -1
  331. package/dist/react/loading/loading.component.cjs +0 -6
  332. package/dist/react/loading/loading.context.cjs +0 -1
  333. package/dist/react/loading/loading.hook.cjs +0 -1
  334. package/dist/react/loading/loading.module.scss.cjs +0 -1
  335. package/dist/react/loading/loading.provider.cjs +0 -1
  336. package/dist/react/log/index.cjs +0 -1
  337. package/dist/react/log/log.util.cjs +0 -1
  338. package/dist/react/next-intl/index.cjs +0 -1
  339. package/dist/react/next-intl/next-intl.constant.cjs +0 -1
  340. package/dist/react/next-intl/next-intl.context.cjs +0 -1
  341. package/dist/react/next-intl/next-intl.hoc.cjs +0 -1
  342. package/dist/react/next-intl/next-intl.hook.cjs +0 -1
  343. package/dist/react/next-intl/next-intl.provider.cjs +0 -1
  344. package/dist/react/storage/index.cjs +0 -1
  345. package/dist/react/storage/storage.hook.cjs +0 -1
  346. package/dist/react/storage/storage.util.cjs +0 -1
  347. package/dist/react/toast/index.cjs +0 -1
  348. package/dist/react/userback/index.cjs +0 -1
  349. package/dist/react/userback/userback.component.cjs +0 -1
  350. package/dist/typescript/common.type.cjs +0 -1
  351. package/dist/typescript/index.cjs +0 -1
  352. package/dist/util/common/common.util.cjs +0 -1
  353. package/dist/util/common/index.cjs +0 -1
  354. package/dist/util/index.cjs +0 -1
  355. package/dist/util/object/index.cjs +0 -1
  356. package/dist/util/object/object.util.cjs +0 -1
  357. package/dist/util/serializer/index.cjs +0 -1
  358. package/dist/util/serializer/serializer.util.cjs +0 -1
  359. package/dist/util/string/index.cjs +0 -1
  360. package/dist/util/string/string.util.cjs +0 -1
  361. package/dist/util/validate/index.cjs +0 -1
  362. package/dist/util/validate/validate.util.cjs +0 -1
  363. /package/dist/node/ws/{ts.util.d.ts → ws.util.d.ts} +0 -0
@@ -1,103 +1,99 @@
1
- var A = Object.defineProperty, m = Object.defineProperties, d = Object.getOwnPropertyDescriptors, f = Object.getOwnPropertySymbols, v = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable, u = (e, r, n) => r in e ? A(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, y = (e, r) => {
2
- for (var n in r || (r = {}))
3
- v.call(r, n) && u(e, n, r[n]);
4
- if (f)
5
- for (var n of f(r))
6
- w.call(r, n) && u(e, n, r[n]);
7
- return e;
8
- }, p = (e, r) => m(e, d(r));
9
- function P(e) {
1
+ function p(e) {
10
2
  try {
11
3
  return JSON.parse(e), !0;
12
- } catch (r) {
4
+ } catch {
13
5
  return !1;
14
6
  }
15
7
  }
16
- function _(e, r) {
8
+ function A(e, t) {
17
9
  let n = e;
18
- const o = r.length;
19
- for (let t = 0; t < o; t++) {
20
- const s = r[t];
21
- if (s !== void 0 && n && typeof n == "object" && s in n)
10
+ const o = t.length;
11
+ for (let r = 0; r < o; r++) {
12
+ if (n == null || typeof n != "object")
13
+ return;
14
+ const s = t[r];
15
+ if (s !== void 0 && s in n)
22
16
  n = n[s];
23
17
  else
24
18
  return;
25
19
  }
26
20
  return n;
27
21
  }
28
- function g(e, r, n, o) {
29
- if (o >= r.length)
22
+ function f(e, t, n, o) {
23
+ if (o >= t.length)
30
24
  return e;
31
- const t = r[o];
32
- if (o === r.length - 1)
33
- return p(y({}, e), {
34
- [t]: n
35
- });
36
- const s = e[t];
37
- return p(y({}, e), {
38
- [t]: g(
25
+ const r = t[o];
26
+ if (o === t.length - 1)
27
+ return {
28
+ ...e,
29
+ [r]: n
30
+ };
31
+ const s = e[r];
32
+ return {
33
+ ...e,
34
+ [r]: f(
39
35
  typeof s == "object" && s !== null ? s : {},
40
- r,
36
+ t,
41
37
  n,
42
38
  o + 1
43
39
  )
44
- });
40
+ };
45
41
  }
46
- function b(e, r, n) {
47
- return r.length === 0 ? e : g(e, r, n, 0);
42
+ function g(e, t, n) {
43
+ return t.length === 0 ? e : f(e, t, n, 0);
48
44
  }
49
- function O(e) {
45
+ function u(e) {
50
46
  if (e === null || typeof e != "object")
51
47
  return e;
52
48
  if (Array.isArray(e))
53
- return e.map((o) => O(o));
49
+ return e.map((o) => u(o));
54
50
  if (e instanceof Date)
55
51
  return new Date(e.getTime());
56
52
  if (e instanceof RegExp)
57
53
  return new RegExp(e.source, e.flags);
58
- const r = Object.getPrototypeOf(e);
59
- if (r !== Object.prototype && r !== null)
54
+ const t = Object.getPrototypeOf(e);
55
+ if (t !== Object.prototype && t !== null)
60
56
  return e;
61
57
  const n = {};
62
58
  for (const o in e)
63
- Object.prototype.hasOwnProperty.call(e, o) && (n[o] = O(e[o]));
59
+ Object.prototype.hasOwnProperty.call(e, o) && (n[o] = u(e[o]));
64
60
  return n;
65
61
  }
66
- function h(...e) {
62
+ function y(...e) {
67
63
  if (e.length === 0)
68
64
  return {};
69
- const r = e.filter((t) => t != null);
70
- if (r.length === 0)
65
+ const t = e.filter((r) => r != null);
66
+ if (t.length === 0)
71
67
  return {};
72
- if (r.length === 1)
73
- return r[0];
74
- if (r.every(Array.isArray))
75
- return [].concat(...r);
76
- if (r.every((t) => typeof t == "object" && t !== null && !Array.isArray(t))) {
77
- const t = {};
78
- for (const s of r) {
79
- const l = s;
80
- for (const a in l)
81
- if (Object.prototype.hasOwnProperty.call(l, a)) {
82
- const i = l[a];
83
- if (Object.prototype.hasOwnProperty.call(t, a)) {
84
- const c = t[a];
85
- typeof i == "object" && i !== null && typeof c == "object" && c !== null ? Array.isArray(i) && Array.isArray(c) ? t[a] = c.concat(i) : !Array.isArray(i) && !Array.isArray(c) ? t[a] = h(
68
+ if (t.length === 1)
69
+ return t[0];
70
+ if (t.every(Array.isArray))
71
+ return [].concat(...t);
72
+ if (t.every((r) => typeof r == "object" && r !== null && !Array.isArray(r))) {
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(
86
82
  c,
87
- i
88
- ) : t[a] = i : t[a] = i;
83
+ a
84
+ ) : r[l] = a : r[l] = a;
89
85
  } else
90
- t[a] = i;
86
+ r[l] = a;
91
87
  }
92
88
  }
93
- return t;
89
+ return r;
94
90
  }
95
- if (r.every((t) => typeof t != "object" || t === null))
91
+ if (t.every((r) => typeof r != "object" || r === null))
96
92
  throw new Error(
97
93
  "deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
98
94
  );
99
- const n = r.some(Array.isArray), o = r.some(
100
- (t) => typeof t == "object" && t !== null && !Array.isArray(t)
95
+ const n = t.some(Array.isArray), o = t.some(
96
+ (r) => typeof r == "object" && r !== null && !Array.isArray(r)
101
97
  );
102
98
  throw n && o ? new Error(
103
99
  "deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
@@ -105,34 +101,35 @@ function h(...e) {
105
101
  "deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
106
102
  );
107
103
  }
108
- function j(e) {
104
+ function h(e) {
109
105
  if (!e || typeof e != "object")
110
106
  return e;
111
- const r = {};
112
- function n(o, t) {
107
+ const t = {};
108
+ function n(o, r) {
113
109
  for (const s in o) {
114
110
  if (!Object.prototype.hasOwnProperty.call(o, s))
115
111
  continue;
116
- const l = o[s], a = t ? `${t}.${s}` : s;
117
- if (l && typeof l == "object" && !Array.isArray(l)) {
118
- let i = !1;
119
- for (const c in l)
120
- if (Object.prototype.hasOwnProperty.call(l, c) && c.startsWith("$")) {
121
- i = !0;
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;
122
118
  break;
123
119
  }
124
- i ? r[a] = l : n(l, a);
120
+ a ? t[l] = i : n(i, l);
125
121
  } else
126
- r[a] = l;
122
+ t[l] = i;
127
123
  }
128
124
  }
129
- return n(e, ""), r;
125
+ return n(e, ""), t;
130
126
  }
131
127
  export {
132
- O as deepClone,
133
- h as deepMerge,
134
- _ as getNestedValue,
135
- P as isJSON,
136
- j as normalizeMongoFilter,
137
- b as setNestedValue
128
+ u as deepClone,
129
+ y as deepMerge,
130
+ A as getNestedValue,
131
+ p as isJSON,
132
+ h as normalizeMongoFilter,
133
+ g as setNestedValue
138
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\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.prototype.hasOwnProperty.call(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 ([] as unknown[]).concat(...validArgs) 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.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n if (Object.prototype.hasOwnProperty.call(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.concat(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.prototype.hasOwnProperty.call(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.prototype.hasOwnProperty.call(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;AAEA,SAASI,EAAwBN,GAAQC,GAA2BM,GAAgBC,GAAkB;AAClG,MAAIA,KAASP,EAAK;AACd,WAAOD;AAEX,QAAMS,IAAOR,EAAKO,CAAK;AAEvB,MAAIA,MA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I;AAAA,IACN;AAAA,EAAA,IAKF,IAAI;AAAA,IACN;AAAA,EAAA;AAER;AAuBO,SAASC,EAAwDC,GAAc;AAClF,MAAI,CAACA,KAAU,OAAOA,KAAW;AAC7B,WAAOA;AAGX,QAAMC,IAAsC,CAAA;AAK5C,WAASC,EAAQvB,GAAkCwB,GAAgB;AAC/D,eAAWrB,KAAOH,GAAS;AACvB,UAAI,CAAC,OAAO,UAAU,eAAe,KAAKA,GAASG,CAAG;AAClD;AAEJ,YAAME,IAAQL,EAAQG,CAAG,GACnBsB,IAASD,IAAS,GAAGA,CAAM,IAAIrB,CAAG,KAAKA;AAE7C,UAAIE,KAAS,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK,GAAG;AAE7D,YAAIqB,IAAmB;AACvB,mBAAWC,KAAUtB;AACjB,cAAI,OAAO,UAAU,eAAe,KAAKA,GAAOsB,CAAM,KAAKA,EAAO,WAAW,GAAG,GAAG;AAC/E,YAAAD,IAAmB;AACnB;AAAA,UACJ;AAGJ,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":";"}
@@ -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: Array.from(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: Array.from(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,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A,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;"}
@@ -1,8 +1,10 @@
1
- import { generateRandomPassword as t, generateShortId as a, generateSlug as g, getFileName as n, substringBetween as o } from "./string.util.js";
1
+ import { generateRandomPassword as t, generateRandomString as n, generateShortId as a, generateSlug as g, getFileName as o, substringBetween as d } from "./string.util.js";
2
2
  export {
3
3
  t as generateRandomPassword,
4
+ n as generateRandomString,
4
5
  a as generateShortId,
5
6
  g as generateSlug,
6
- n as getFileName,
7
- o as substringBetween
7
+ o as getFileName,
8
+ d as substringBetween
8
9
  };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -28,8 +28,20 @@ export declare function generateShortId(uuid: string, length?: number): string;
28
28
  *
29
29
  * @param length - The desired length of the password (default: 8 characters).
30
30
  * @returns A randomly generated password string with the specified length.
31
+ * @throws {RangeError} If `length` is not a non-negative safe integer.
31
32
  */
32
33
  export declare function generateRandomPassword(length?: number): string;
34
+ /**
35
+ * Generates a random string of a given length using a secure random number generator.
36
+ * This function is a cryptographically secure alternative to Math.random().toString(36).
37
+ *
38
+ * @param length - The desired length of the string (default: 8 characters).
39
+ * @param charset - The characters to use (default: lowercase alphanumeric).
40
+ * @returns A randomly generated string.
41
+ * @throws {RangeError} If `length` is not a non-negative safe integer.
42
+ * @throws {RangeError} If `charset` is empty or exceeds 2^32 characters.
43
+ */
44
+ export declare function generateRandomString(length?: number, charset?: string): string;
33
45
  /**
34
46
  * Get the file name from a URL.
35
47
  * This function extracts the file name from a URL, optionally including or excluding
@@ -1,50 +1,70 @@
1
1
  import { removeAccent as c } from "../common/common.util.js";
2
- function l(t, r) {
3
- let e = t.trim();
4
- return e = c(e), (r == null ? void 0 : r.lower) !== !1 && (e = e.toLowerCase()), e = e.replace(/[^a-z0-9\s-]/gi, " "), e = e.replace(/[\s-]+/g, "-"), e = e.replace(/^-+|-+$/g, ""), e;
5
- }
6
- function a(t, r) {
7
- const e = (n) => l(n != null ? n : "", r);
8
- if (typeof t == "object" && t !== null) {
9
- const n = {};
10
- for (const [o, s] of Object.entries(t))
11
- n[o] = e(s);
12
- return n;
2
+ function u(e, n) {
3
+ let t = e.trim();
4
+ return t = c(t), n?.lower !== !1 && (t = t.toLowerCase()), t = t.replace(/[^a-z0-9\s-]/gi, " "), t = t.replace(/[\s-]+/g, "-"), t = t.replace(/^-+|-+$/g, ""), t;
5
+ }
6
+ function m(e, n) {
7
+ const t = (r) => u(r ?? "", n);
8
+ if (typeof e == "object" && e !== null) {
9
+ const r = {};
10
+ for (const [o, i] of Object.entries(e))
11
+ r[o] = t(i);
12
+ return r;
13
+ }
14
+ return t(e);
15
+ }
16
+ function h(e, n = 4) {
17
+ let t = 2166136261;
18
+ for (let o = 0; o < e.length; o++)
19
+ t ^= e.charCodeAt(o), t = Math.imul(t, 16777619);
20
+ const r = (t >>> 0).toString(16).padStart(8, "0");
21
+ return n > 8 ? e.replace(/-/g, "").slice(0, n) : r.slice(0, n);
22
+ }
23
+ function f(e, n) {
24
+ const t = Math.floor(4294967296 / n.length) * n.length, r = [], o = 16384;
25
+ for (; r.length < e; ) {
26
+ const i = e - r.length, l = i > o ? o : i, s = new Uint32Array(l);
27
+ crypto.getRandomValues(s);
28
+ for (const a of s) {
29
+ if (r.length >= e)
30
+ break;
31
+ a < t && r.push(n[a % n.length]);
32
+ }
13
33
  }
14
- return e(t);
15
- }
16
- function f(t, r = 4) {
17
- let e = 2166136261;
18
- for (let o = 0; o < t.length; o++)
19
- e ^= t.charCodeAt(o), e = Math.imul(e, 16777619);
20
- const n = (e >>> 0).toString(16).padStart(8, "0");
21
- return r > 8 ? t.replace(/-/g, "").slice(0, r) : n.slice(0, r);
22
- }
23
- function u(t = 8) {
24
- const r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";
25
- return Array.from({ length: t }, () => {
26
- const e = Math.floor(Math.random() * r.length);
27
- return r.charAt(e);
28
- }).join("");
29
- }
30
- function g(t = "", r = !1) {
31
- const e = t.split(/[?#]/)[0] || "", n = e.substring(e.lastIndexOf("/") + 1);
32
- if (r)
33
- return n;
34
- const o = n.lastIndexOf(".");
35
- return o > 0 ? n.slice(0, o) : n;
36
- }
37
- function d(t, r, e) {
38
- const n = t.indexOf(r);
39
- if (n === -1)
34
+ return r.join("");
35
+ }
36
+ function d(e = 8) {
37
+ if (!Number.isSafeInteger(e) || e < 0)
38
+ throw new RangeError("length must be a non-negative safe integer");
39
+ return f(e, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?");
40
+ }
41
+ function w(e = 8, n = "abcdefghijklmnopqrstuvwxyz0123456789") {
42
+ if (!Number.isSafeInteger(e) || e < 0)
43
+ throw new RangeError("length must be a non-negative safe integer");
44
+ if (n.length === 0 || n.length > 2 ** 32)
45
+ throw new RangeError("charset.length must be between 1 and 2^32");
46
+ return f(e, n);
47
+ }
48
+ function b(e = "", n = !1) {
49
+ const t = e.split(/[?#]/)[0] || "", r = t.substring(t.lastIndexOf("/") + 1);
50
+ if (n)
51
+ return r;
52
+ const o = r.lastIndexOf(".");
53
+ return o > 0 ? r.slice(0, o) : r;
54
+ }
55
+ function p(e, n, t) {
56
+ const r = e.indexOf(n);
57
+ if (r === -1)
40
58
  return "";
41
- const o = n + r.length, s = t.indexOf(e, o);
42
- return s === -1 ? "" : t.slice(o, s);
59
+ const o = r + n.length, i = e.indexOf(t, o);
60
+ return i === -1 ? "" : e.slice(o, i);
43
61
  }
44
62
  export {
45
- u as generateRandomPassword,
46
- f as generateShortId,
47
- a as generateSlug,
48
- g as getFileName,
49
- d as substringBetween
63
+ d as generateRandomPassword,
64
+ w as generateRandomString,
65
+ h as generateShortId,
66
+ m as generateSlug,
67
+ b as getFileName,
68
+ p as substringBetween
50
69
  };
70
+ //# sourceMappingURL=string.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.util.js","sources":["../../../src/util/string/string.util.ts"],"sourcesContent":["import type { T_Object } from '#typescript/index.js';\n\nimport type { I_SlugifyOptions } from './string.type.js';\n\nimport { removeAccent } from '../common/common.util.js';\n\n/**\n * Generates a slug from a string.\n * The slug is a URL-friendly version of the string, removing special characters\n * and converting spaces to hyphens.\n *\n * @param input - The string to be slugified.\n * @param options - Options for slugification.\n * @returns The slugified string.\n */\nfunction slugify(input: string, options?: I_SlugifyOptions): string {\n let slug = input.trim();\n\n // 1. Remove accents\n slug = removeAccent(slug);\n\n // 2. To lower case if requested (default true)\n if (options?.lower !== false) {\n slug = slug.toLowerCase();\n }\n\n // 3. Replace invalid characters with space (keeping alphanumeric, hyphens, and spaces)\n slug = slug.replace(/[^a-z0-9\\s-]/gi, ' ');\n\n // 4. Replace multiple spaces or hyphens with a single hyphen\n slug = slug.replace(/[\\s-]+/g, '-');\n\n // 5. Remove leading/trailing hyphens\n slug = slug.replace(/^-+|-+$/g, '');\n\n return slug;\n}\n\n/**\n * Generates a slug from a string or an object containing strings.\n * The slug is a URL-friendly version of the string, removing special characters\n * and converting spaces to hyphens. This function can handle both single strings\n * and objects with string values.\n *\n * @param input - The string or object to be slugified.\n * @param options - Options for slugification including replacement character, case sensitivity, locale, etc.\n * @returns The slugified string or object with the same structure as the input.\n */\nexport function generateSlug<T = string>(\n input: T,\n options?: I_SlugifyOptions,\n): T {\n const slugifyWithOptions = (value: string) =>\n slugify(value ?? '', options);\n\n if (typeof input === 'object' && input !== null) {\n const result: T_Object = {};\n\n for (const [key, value] of Object.entries(input)) {\n result[key] = slugifyWithOptions(value as string);\n }\n\n return result as T;\n }\n\n return slugifyWithOptions(input as string) as T;\n}\n\n/**\n * Generates a short ID from a UUID.\n * The ID is a substring of the UUID, providing a shorter identifier.\n * Note: This is NOT cryptographically secure and collisions are possible,\n * but suitable for display purposes where uniqueness is handled elsewhere.\n *\n * @param uuid - The UUID to be converted to a short ID.\n * @param length - The desired length of the short ID (default: 4 characters).\n * @returns A short ID string of the specified length derived from the UUID.\n */\nexport function generateShortId(uuid: string, length = 4): string {\n // Simple hash function (FNV-1a variant) to generate a hex string from the UUID\n let hash = 0x811C9DC5;\n for (let i = 0; i < uuid.length; i++) {\n hash ^= uuid.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193);\n }\n // Convert to unsigned 32-bit integer hex string\n const hex = (hash >>> 0).toString(16).padStart(8, '0');\n\n // If we need more than 8 chars, we can just append part of the original UUID (stripped of dashes)\n // or use a different strategy. For short IDs (usually < 8), the hash is fine.\n // If length > 8, we fallback to just slicing the clean UUID.\n if (length > 8) {\n return uuid.replace(/-/g, '').slice(0, length);\n }\n\n return hex.slice(0, length);\n}\n\n/**\n * Internal helper that fills `length` characters from `charset` using\n * rejection-sampling over `crypto.getRandomValues` to avoid modulo bias.\n * Random values are requested in bounded chunks to keep allocations small.\n *\n * @param length - Number of characters to generate.\n * @param charset - The pool of characters to draw from.\n * @returns A randomly generated string of the requested length.\n */\nfunction generateRandomFromCharset(length: number, charset: string): string {\n const limit = Math.floor(2 ** 32 / charset.length) * charset.length;\n const result: string[] = [];\n const MAX_UINT32_VALUES_PER_CALL = 16384;\n\n while (result.length < length) {\n const remaining = length - result.length;\n const chunkSize = remaining > MAX_UINT32_VALUES_PER_CALL ? MAX_UINT32_VALUES_PER_CALL : remaining;\n const values = new Uint32Array(chunkSize);\n crypto.getRandomValues(values);\n\n for (const value of values) {\n if (result.length >= length) {\n break;\n }\n if (value < limit) {\n result.push(charset[value % charset.length] as string);\n }\n }\n }\n\n return result.join('');\n}\n\n/**\n * Generates a random password of a given length.\n * The password contains a mix of letters (both cases), numbers, and special characters\n * to ensure complexity and security.\n *\n * @param length - The desired length of the password (default: 8 characters).\n * @returns A randomly generated password string with the specified length.\n * @throws {RangeError} If `length` is not a non-negative safe integer.\n */\nexport function generateRandomPassword(length = 8): string {\n if (!Number.isSafeInteger(length) || length < 0) {\n throw new RangeError('length must be a non-negative safe integer');\n }\n\n const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?';\n\n return generateRandomFromCharset(length, charset);\n}\n\n/**\n * Generates a random string of a given length using a secure random number generator.\n * This function is a cryptographically secure alternative to Math.random().toString(36).\n *\n * @param length - The desired length of the string (default: 8 characters).\n * @param charset - The characters to use (default: lowercase alphanumeric).\n * @returns A randomly generated string.\n * @throws {RangeError} If `length` is not a non-negative safe integer.\n * @throws {RangeError} If `charset` is empty or exceeds 2^32 characters.\n */\nexport function generateRandomString(\n length = 8,\n charset = 'abcdefghijklmnopqrstuvwxyz0123456789',\n): string {\n if (!Number.isSafeInteger(length) || length < 0) {\n throw new RangeError('length must be a non-negative safe integer');\n }\n\n if (charset.length === 0 || charset.length > 2 ** 32) {\n throw new RangeError('charset.length must be between 1 and 2^32');\n }\n\n return generateRandomFromCharset(length, charset);\n}\n\n/**\n * Get the file name from a URL.\n * This function extracts the file name from a URL, optionally including or excluding\n * the file extension. It handles URLs with query parameters and fragments.\n *\n * @param url - The URL to extract the file name from (default: empty string).\n * @param getExtension - Whether to include the file extension in the result (default: false).\n * @returns The file name extracted from the URL, with or without the extension.\n */\nexport function getFileName(url = '', getExtension = false): string {\n const withoutQuery = url.split(/[?#]/)[0] || '';\n const fileName = withoutQuery.substring(withoutQuery.lastIndexOf('/') + 1);\n\n if (getExtension) {\n return fileName;\n }\n\n const dotIndex = fileName.lastIndexOf('.');\n\n return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;\n}\n\n/**\n * Extracts a substring between two strings.\n * This function finds the first occurrence of the starting string, then finds the first\n * occurrence of the ending string after the starting string, and returns the content between them.\n *\n * @param s - The original string to search within.\n * @param a - The starting string that marks the beginning of the desired substring.\n * @param b - The ending string that marks the end of the desired substring.\n * @returns The substring between the two specified strings, or an empty string if either string is not found.\n */\nexport function substringBetween(s: string, a: string, b: string): string {\n const start = s.indexOf(a);\n\n if (start === -1) {\n return '';\n }\n\n const from = start + a.length;\n const end = s.indexOf(b, from);\n\n if (end === -1) {\n return '';\n }\n\n return s.slice(from, end);\n}\n"],"names":["removeAccent","slugify","input","options","slug","generateSlug","slugifyWithOptions","value","result","key","generateShortId","uuid","length","hash","i","hex","generateRandomFromCharset","charset","limit","MAX_UINT32_VALUES_PER_CALL","remaining","chunkSize","values","generateRandomPassword","generateRandomString","getFileName","url","getExtension","withoutQuery","fileName","dotIndex","substringBetween","s","a","b","start","from","end"],"mappings":"AAeA,SAAA,gBAAAA,SAAA;AAAA,SAASC,EAAQC,GAAeC,GAAoC;AAChE,MAAIC,IAAOF,EAAM,KAAA;AAGjB,SAAAE,IAAOJ,EAAaI,CAAI,GAGpBD,GAAS,UAAU,OACnBC,IAAOA,EAAK,YAAA,IAIhBA,IAAOA,EAAK,QAAQ,kBAAkB,GAAG,GAGzCA,IAAOA,EAAK,QAAQ,WAAW,GAAG,GAGlCA,IAAOA,EAAK,QAAQ,YAAY,EAAE,GAE3BA;AACX;AAYO,SAASC,EACZH,GACAC,GACC;AACD,QAAMG,IAAqB,CAACC,MACxBN,EAAQM,KAAS,IAAIJ,CAAO;AAEhC,MAAI,OAAOD,KAAU,YAAYA,MAAU,MAAM;AAC7C,UAAMM,IAAmB,CAAA;AAEzB,eAAW,CAACC,GAAKF,CAAK,KAAK,OAAO,QAAQL,CAAK;AAC3C,MAAAM,EAAOC,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AM,IAAI,WAAW,4CAA4C;AAGrE,MAAIK,EAAQ,WAAW,KAAKA,EAAQ,SAAS,KAAK;AAC9C,UAAM,IAAI,WAAW,2CAA2C;AAGpE,SAAOD,EAA0BJ,GAAQK,CAAO;AACpD;AAWO,SAASQ,EAAYC,IAAM,IAAIC,IAAe,IAAe;AAChE,QAAMC,IAAeF,EAAI,MAAM,MAAM,EAAE,CAAC,KAAK,IACvCG,IAAWD,EAAa,UAAUA,EAAa,YAAY,GAAG,IAAI,CAAC;AAEzE,MAAID;AACA,WAAOE;AAGX,QAAMC,IAAWD,EAAS,YAAY,GAAG;AAEzC,SAAOC,IAAW,IAAID,EAAS,MAAM,GAAGC,CAAQ,IAAID;AACxD;AAYO,SAASE,EAAiBC,GAAWC,GAAWC,GAAmB;AACtE,QAAMC,IAAQH,EAAE,QAAQC,CAAC;AAEzB,MAAIE,MAAU;AACV,WAAO;AAGX,QAAMC,IAAOD,IAAQF,EAAE,QACjBI,IAAML,EAAE,QAAQE,GAAGE,CAAI;AAE7B,SAAIC,MAAQ,KACD,KAGJL,EAAE,MAAMI,GAAMC,CAAG;AAC5B;"}
@@ -2,3 +2,4 @@ import { validate as o } from "./validate.util.js";
2
2
  export {
3
3
  o as validate
4
4
  };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -37,3 +37,4 @@ const e = {
37
37
  export {
38
38
  e as validate
39
39
  };
40
+ //# sourceMappingURL=validate.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.util.js","sources":["../../../src/util/validate/validate.util.ts"],"sourcesContent":["/**\n * A collection of validation utility functions for common data validation tasks.\n * This object provides methods to validate various data types and formats.\n */\nexport const validate = {\n /**\n * Checks if a value is empty.\n * This function provides comprehensive empty checking for different data types:\n * - For strings, it checks if the string is empty or contains only whitespace.\n * - For arrays, it checks if the array has no elements.\n * - For objects, it checks if the object has no own properties.\n * - For Maps and Sets, it checks if they are empty.\n * - For WeakMaps and WeakSets, it returns true (as they are not enumerable).\n * - For ArrayBuffer views, it checks if the byte length is 0.\n * - For Dates, it returns false.\n * - For null and undefined, it returns true.\n * - For all other types, it returns false.\n *\n * @param value - The value to check for emptiness.\n * @returns True if the value is empty, false otherwise.\n */\n isEmpty(value: unknown): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n\n if (typeof value === 'string') {\n return value.trim().length === 0;\n }\n\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (typeof value === 'object') {\n if (value instanceof Date) {\n return false;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (value instanceof WeakMap || value instanceof WeakSet) {\n return true;\n }\n\n if (ArrayBuffer.isView(value)) {\n return value.byteLength === 0;\n }\n\n return Object.keys(value).length === 0;\n }\n\n return false;\n },\n /**\n * Checks if a string is a valid IP address (IPv4 or IPv6).\n * This function validates IP addresses according to standard formats:\n * - IPv4: Four octets separated by dots, each between 0–255.\n * - IPv6: Eight groups of four hex digits, possibly compressed with `::`.\n *\n * @param ip - The IP address string to validate.\n * @returns True if the IP is valid IPv4 or IPv6, false otherwise.\n */\n isValidIP(ip: string): boolean {\n const ipv4Parts = ip.split('.');\n\n if (ipv4Parts.length === 4 && ipv4Parts.every(octet =>\n /^\\d+$/.test(octet)\n && Number(octet) >= 0\n && Number(octet) <= 255,\n )) {\n return true;\n }\n\n const ipv6Regex = /^(?:(?:[a-f\\d]{1,4}:){7}(?:[a-f\\d]{1,4}|:)|(?:[a-f\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-f\\d]{1,4}|:)|(?:[a-f\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[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