@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,174 +1,144 @@
1
1
  import { Buffer as w } from "node:buffer";
2
2
  import { Transform as C } from "node:stream";
3
3
  import { ReadableStream as D } from "node:stream/web";
4
- import { DEFAULT_UPLOAD_CONFIG as R, BYTES_PER_MB as h } from "./upload.constant.js";
5
- import { E_UploadType as p } from "./upload.type.js";
6
- import { dirname as x } from "../path/path.util.js";
7
- import { pathExistsSync as z, mkdirSync as A, createWriteStream as F } from "../fs/fs.util.js";
8
- import { RESPONSE_STATUS as u } from "../../constant/response-status.js";
9
- var P = Object.defineProperty, S = Object.getOwnPropertySymbols, T = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable, v = (t, r, e) => r in t ? P(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e, _ = (t, r) => {
10
- for (var e in r || (r = {}))
11
- T.call(r, e) && v(t, e, r[e]);
12
- if (S)
13
- for (var e of S(r))
14
- L.call(r, e) && v(t, e, r[e]);
15
- return t;
16
- }, E = (t, r, e) => new Promise((i, a) => {
17
- var s = (l) => {
18
- try {
19
- n(e.next(l));
20
- } catch (c) {
21
- a(c);
22
- }
23
- }, o = (l) => {
24
- try {
25
- n(e.throw(l));
26
- } catch (c) {
27
- a(c);
28
- }
29
- }, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(s, o);
30
- n((e = e.apply(t, r)).next());
31
- });
32
- function B(t) {
33
- return E(this, null, function* () {
34
- return new Promise((r, e) => {
35
- let i = 0;
36
- t.on("data", (a) => {
37
- i += a.length;
38
- }), t.on("end", () => r(i)), t.on("error", e);
39
- });
4
+ import { DEFAULT_UPLOAD_CONFIG as y, BYTES_PER_MB as R } from "./upload.constant.js";
5
+ import { E_UploadType as E } from "./upload.type.js";
6
+ import { dirname as O } from "../path/path.util.js";
7
+ import { pathExistsSync as x, mkdirSync as z, createWriteStream as v } from "../fs/fs.util.js";
8
+ import { RESPONSE_STATUS as c } from "../../constant/response-status.js";
9
+ async function A(i) {
10
+ return new Promise((o, t) => {
11
+ let e = 0;
12
+ i.on("data", (n) => {
13
+ e += n.length;
14
+ }), i.on("end", () => o(e)), i.on("error", t);
40
15
  });
41
16
  }
42
- function g(t, r, e) {
43
- return E(this, null, function* () {
44
- const i = yield (yield r).file, a = i.createReadStream(), s = yield B(a), o = e != null ? e : O(), n = U(
45
- { filename: i.filename, fileSize: s },
46
- o,
47
- t
48
- );
49
- return n.isValid ? {
50
- success: !0,
51
- result: i,
52
- message: "File validated successfully"
53
- } : {
54
- success: !1,
55
- message: n.error || "File validation failed",
56
- code: u.BAD_REQUEST.CODE
57
- };
58
- });
17
+ async function S(i, o, t) {
18
+ const e = await (await o).file, n = e.createReadStream(), s = await A(n), r = t ?? g(), a = T(
19
+ { filename: e.filename, fileSize: s },
20
+ r,
21
+ i
22
+ );
23
+ return a.isValid ? {
24
+ success: !0,
25
+ result: e,
26
+ message: "File validated successfully"
27
+ } : {
28
+ success: !1,
29
+ message: a.error || "File validation failed",
30
+ code: c.BAD_REQUEST.CODE
31
+ };
59
32
  }
60
- function G(t, r, e) {
61
- return E(this, null, function* () {
62
- const a = (e != null ? e : O())[t], s = yield g(t, r, e);
63
- if (!s.success)
64
- return s;
65
- const { createReadStream: o } = s.result;
66
- let n = a.sizeLimit;
67
- const l = new C({
68
- transform(f, d, y) {
69
- n -= f.length, n < 0 ? y(new Error(`File size exceeds limit of ${a.sizeLimit / h}MB`)) : y(null, f);
33
+ async function h(i, o, t) {
34
+ const n = (t ?? g())[i], s = await S(i, o, t);
35
+ if (!s.success)
36
+ return s;
37
+ const { createReadStream: r } = s.result;
38
+ let a = n.sizeLimit;
39
+ const f = new C({
40
+ transform(l, d, p) {
41
+ a -= l.length, a < 0 ? p(new Error(`File size exceeds limit of ${n.sizeLimit / R}MB`)) : p(null, l);
42
+ }
43
+ }), u = r().pipe(f);
44
+ return {
45
+ success: !0,
46
+ result: new D({
47
+ start(l) {
48
+ u.on("data", (d) => {
49
+ l.enqueue(typeof d == "string" ? w.from(d) : d);
50
+ }), u.on("end", () => l.close()), u.on("error", (d) => l.error(d));
70
51
  }
71
- }), m = o().pipe(l);
72
- return {
73
- success: !0,
74
- result: new D({
75
- start(f) {
76
- m.on("data", (d) => {
77
- f.enqueue(typeof d == "string" ? w.from(d) : d);
78
- }), m.on("end", () => f.close()), m.on("error", (d) => f.error(d));
79
- }
80
- })
81
- };
82
- });
52
+ })
53
+ };
83
54
  }
84
- function I(t, r) {
85
- const e = t.lastIndexOf(".");
86
- if (e === -1)
55
+ function F(i, o) {
56
+ const t = i.lastIndexOf(".");
57
+ if (t === -1)
87
58
  return !1;
88
- const i = t.substring(e + 1).toLowerCase();
89
- return r.includes(i);
59
+ const e = i.substring(t + 1).toLowerCase();
60
+ return o.includes(e);
90
61
  }
91
- function U(t, r, e) {
92
- const { filename: i, fileSize: a } = t, s = r[e], { allowedExtensions: o, sizeLimit: n } = s;
93
- if (!I(i, o))
62
+ function T(i, o, t) {
63
+ const { filename: e, fileSize: n } = i, s = o[t], { allowedExtensions: r, sizeLimit: a } = s;
64
+ if (!F(e, r))
94
65
  return {
95
66
  isValid: !1,
96
- error: `File extension not allowed for ${e.toLowerCase()} files. Allowed extensions: ${o.join(", ")}`
67
+ error: `File extension not allowed for ${t.toLowerCase()} files. Allowed extensions: ${r.join(", ")}`
97
68
  };
98
- if (a !== void 0 && a > n) {
99
- const l = Math.round(n / 1048576);
69
+ if (n !== void 0 && n > a) {
70
+ const f = Math.round(a / 1048576);
100
71
  return {
101
72
  isValid: !1,
102
- error: `File size exceeds limit for ${e.toLowerCase()} files. Maximum size: ${l}MB`
73
+ error: `File size exceeds limit for ${t.toLowerCase()} files. Maximum size: ${f}MB`
103
74
  };
104
75
  }
105
76
  return { isValid: !0 };
106
77
  }
107
- function O(t) {
108
- return _(_({}, R), t);
78
+ function g(i) {
79
+ return { ...y, ...i };
109
80
  }
110
- function W(t) {
111
- return E(this, null, function* () {
112
- const { path: r, file: e, config: i, type: a } = t;
113
- if (!r || typeof r != "string")
114
- return {
115
- success: !1,
116
- message: "Invalid path provided",
117
- code: u.BAD_REQUEST.CODE
118
- };
119
- if (!e || typeof e != "object")
120
- return {
121
- success: !1,
122
- message: "Invalid file provided",
123
- code: u.BAD_REQUEST.CODE
124
- };
125
- if (i) {
126
- const s = [p.IMAGE, p.VIDEO, p.DOCUMENT, p.OTHER];
127
- for (const o of s) {
128
- if (!i[o] || !Array.isArray(i[o].allowedExtensions) || i[o].allowedExtensions.length === 0)
129
- return {
130
- success: !1,
131
- message: `Invalid config for ${o.toLowerCase()} files`,
132
- code: u.BAD_REQUEST.CODE
133
- };
134
- if (typeof i[o].sizeLimit != "number" || i[o].sizeLimit <= 0)
135
- return {
136
- success: !1,
137
- message: `Invalid size limit for ${o.toLowerCase()} files`,
138
- code: u.BAD_REQUEST.CODE
139
- };
140
- }
141
- }
142
- try {
143
- const s = yield g(a, yield e, i);
144
- if (!s.success)
145
- return s;
146
- const { createReadStream: o } = s.result, n = x(r);
147
- z(n) || A(n, { recursive: !0 });
148
- const l = o(), c = F(r);
149
- return l.pipe(c), yield new Promise((m, f) => {
150
- c.on("finish", () => m()), c.on("error", f), l.on("error", f);
151
- }), {
152
- success: !0,
153
- result: r,
154
- message: "File uploaded successfully",
155
- code: u.OK.CODE
156
- };
157
- } catch (s) {
158
- return {
159
- success: !1,
160
- message: s instanceof Error ? s.message : "File upload failed",
161
- code: u.INTERNAL_SERVER_ERROR.CODE
162
- };
81
+ async function N(i) {
82
+ const { path: o, file: t, config: e, type: n } = i;
83
+ if (!o || typeof o != "string")
84
+ return {
85
+ success: !1,
86
+ message: "Invalid path provided",
87
+ code: c.BAD_REQUEST.CODE
88
+ };
89
+ if (!t || typeof t != "object")
90
+ return {
91
+ success: !1,
92
+ message: "Invalid file provided",
93
+ code: c.BAD_REQUEST.CODE
94
+ };
95
+ if (e) {
96
+ const s = [E.IMAGE, E.VIDEO, E.DOCUMENT, E.OTHER];
97
+ for (const r of s) {
98
+ if (!e[r] || !Array.isArray(e[r].allowedExtensions) || e[r].allowedExtensions.length === 0)
99
+ return {
100
+ success: !1,
101
+ message: `Invalid config for ${r.toLowerCase()} files`,
102
+ code: c.BAD_REQUEST.CODE
103
+ };
104
+ if (typeof e[r].sizeLimit != "number" || e[r].sizeLimit <= 0)
105
+ return {
106
+ success: !1,
107
+ message: `Invalid size limit for ${r.toLowerCase()} files`,
108
+ code: c.BAD_REQUEST.CODE
109
+ };
163
110
  }
164
- });
111
+ }
112
+ try {
113
+ const s = await S(n, await t, e);
114
+ if (!s.success)
115
+ return s;
116
+ const { createReadStream: r } = s.result, a = O(o);
117
+ x(a) || z(a, { recursive: !0 });
118
+ const f = r(), m = v(o);
119
+ return f.pipe(m), await new Promise((u, l) => {
120
+ m.on("finish", () => u()), m.on("error", l), f.on("error", l);
121
+ }), {
122
+ success: !0,
123
+ result: o,
124
+ message: "File uploaded successfully",
125
+ code: c.OK.CODE
126
+ };
127
+ } catch (s) {
128
+ return {
129
+ success: !1,
130
+ message: s instanceof Error ? s.message : "File upload failed",
131
+ code: c.INTERNAL_SERVER_ERROR.CODE
132
+ };
133
+ }
165
134
  }
166
135
  export {
167
- O as createUploadConfig,
168
- g as getAndValidateFile,
169
- B as getFileSizeFromStream,
170
- G as getFileWebStream,
171
- W as upload,
172
- I as validateFileExtension,
173
- U as validateUpload
136
+ g as createUploadConfig,
137
+ S as getAndValidateFile,
138
+ A as getFileSizeFromStream,
139
+ h as getFileWebStream,
140
+ N as upload,
141
+ F as validateFileExtension,
142
+ T as validateUpload
174
143
  };
144
+ //# sourceMappingURL=upload.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.util.js","sources":["../../../src/node/upload/upload.util.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { Transform } from 'node:stream';\nimport { ReadableStream } from 'node:stream/web';\n\nimport type { I_Return } from '#typescript/index.js';\n\nimport { RESPONSE_STATUS } from '#constant/index.js';\n\nimport type { I_UploadConfig, I_UploadFile, I_UploadFileData, I_UploadOptions, I_UploadTypeConfig, I_UploadValidationConfig } from './upload.type.js';\n\nimport { createWriteStream, mkdirSync, pathExistsSync } from '../fs/index.js';\nimport { dirname } from '../path/index.js';\nimport { BYTES_PER_MB, DEFAULT_UPLOAD_CONFIG } from './upload.constant.js';\nimport { E_UploadType } from './upload.type.js';\n\n/**\n * Calculates the size of a file from a readable stream.\n * This function reads through the entire stream to determine the total byte size\n * by accumulating the length of each data chunk.\n *\n * @param stream - The readable stream to calculate the size for.\n * @returns A promise that resolves to the total size of the stream in bytes.\n */\nexport async function getFileSizeFromStream(stream: NodeJS.ReadableStream): Promise<number> {\n return new Promise((resolve, reject) => {\n let size = 0;\n stream.on('data', (chunk) => {\n size += chunk.length;\n });\n stream.on('end', () => resolve(size));\n stream.on('error', reject);\n });\n}\n\n/**\n * Extracts and validates file data from an upload file.\n * This function processes upload files by:\n * - Extracting file metadata and creating a readable stream\n * - Calculating the file size from the stream\n * - Validating file size and extension against upload configuration\n * - Returning a standardized response with success status and error codes\n * - Providing validated file data for further processing\n *\n * @param type - The type of upload being processed (IMAGE, VIDEO, DOCUMENT, OTHER).\n * @param file - The upload file object containing file metadata and stream creation method.\n * @param config - Optional upload configuration. If not provided, uses default configuration.\n * @returns A promise that resolves to a standardized response containing validated file data or error information.\n */\nexport async function getAndValidateFile(type: E_UploadType, file: I_UploadFile, config?: I_UploadConfig): Promise<I_Return<I_UploadFileData>> {\n const fileData = await (await file).file;\n const stream = fileData.createReadStream();\n const fileSize = await getFileSizeFromStream(stream);\n const uploadConfig = config ?? createUploadConfig();\n\n const validationResult = validateUpload(\n { filename: fileData.filename, fileSize },\n uploadConfig,\n type,\n );\n\n if (!validationResult.isValid) {\n return {\n success: false,\n message: validationResult.error || 'File validation failed',\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n\n return {\n success: true,\n result: fileData,\n message: 'File validated successfully',\n };\n}\n\n/**\n * Creates a validated web-readable stream from an upload file with size validation.\n * This function processes file uploads for web environments by:\n * - Validating file data using getAndValidateFile function\n * - Creating a size validation transform stream to monitor upload progress\n * - Returning a web-compatible ReadableStream with real-time validation\n * - Providing standardized error responses for validation failures\n * - Wrapping the stream in a standardized response format\n *\n * @param type - The type of upload being processed (IMAGE, VIDEO, DOCUMENT, OTHER).\n * @param file - The upload file object containing file metadata and stream creation method.\n * @param config - Optional upload configuration. If not provided, uses default configuration.\n * @returns A promise that resolves to a standardized response containing either a web ReadableStream or error information.\n */\nexport async function getFileWebStream(type: E_UploadType, file: I_UploadFile, config?: I_UploadConfig): Promise<I_Return<ReadableStream<Uint8Array>>> {\n const uploadConfig = config ?? createUploadConfig();\n const typeConfig = uploadConfig[type];\n\n const fileData = await getAndValidateFile(type, file, config);\n\n if (!fileData.success) {\n return fileData;\n }\n\n const { createReadStream } = fileData.result;\n\n let remainingBytes = typeConfig.sizeLimit;\n\n const sizeValidationStream = new Transform({\n transform(chunk: Buffer, _enc: BufferEncoding, cb) {\n remainingBytes -= chunk.length;\n\n if (remainingBytes < 0) {\n cb(new Error(`File size exceeds limit of ${typeConfig.sizeLimit / BYTES_PER_MB}MB`));\n }\n else {\n cb(null, chunk);\n }\n },\n });\n const originalStream = createReadStream();\n const validatedStream = originalStream.pipe(sizeValidationStream);\n\n return {\n success: true,\n result: new ReadableStream<Uint8Array>({\n start(controller) {\n validatedStream.on('data', (chunk: Buffer | string) => {\n controller.enqueue(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);\n });\n validatedStream.on('end', () => controller.close());\n validatedStream.on('error', (err: unknown) => controller.error(err));\n },\n }),\n };\n}\n\n/**\n * Validates if a file has an allowed extension.\n * This function extracts the file extension from the filename and checks if it's\n * included in the list of allowed extensions (case-insensitive comparison).\n *\n * @param filename - The filename to check for valid extension.\n * @param allowedExtensions - An array of allowed file extensions (without dots).\n * @returns True if the file extension is allowed, false otherwise.\n */\nexport function validateFileExtension(filename: string, allowedExtensions: string[]): boolean {\n const lastDotIndex = filename.lastIndexOf('.');\n\n if (lastDotIndex === -1) {\n return false;\n }\n\n const extension = filename.substring(lastDotIndex + 1).toLowerCase();\n\n return allowedExtensions.includes(extension);\n}\n\n/**\n * Validates an upload against the specified configuration.\n * This function performs comprehensive validation including:\n * - File extension validation against allowed extensions\n * - File size validation against size limits\n * - Returns detailed error messages for validation failures\n *\n * @param config - The validation configuration including filename and optional file size.\n * @param uploadConfig - The upload configuration containing allowed extensions and size limits.\n * @param uploadType - The type of upload being validated.\n * @returns An object indicating validation success and optional error message.\n */\nexport function validateUpload(\n config: I_UploadValidationConfig,\n uploadConfig: I_UploadConfig,\n uploadType: E_UploadType,\n): { isValid: boolean; error?: string } {\n const { filename, fileSize } = config;\n const typeConfig: I_UploadTypeConfig = uploadConfig[uploadType];\n\n const { allowedExtensions, sizeLimit } = typeConfig;\n\n if (!validateFileExtension(filename, allowedExtensions)) {\n return {\n isValid: false,\n error: `File extension not allowed for ${uploadType.toLowerCase()} files. Allowed extensions: ${allowedExtensions.join(', ')}`,\n };\n }\n\n if (fileSize !== undefined && fileSize > sizeLimit) {\n const maxSizeMB = Math.round(sizeLimit / (1024 * 1024));\n\n return {\n isValid: false,\n error: `File size exceeds limit for ${uploadType.toLowerCase()} files. Maximum size: ${maxSizeMB}MB`,\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Creates a default upload configuration with predefined settings for different file types.\n * This function provides sensible defaults for image, video, document, and other file types,\n * including allowed extensions and size limits. The configuration can be customized with overrides.\n *\n * @param overrides - Optional configuration overrides to merge with the default configuration.\n * @returns A complete upload configuration object with defaults and any provided overrides.\n */\nexport function createUploadConfig(overrides?: Partial<I_UploadConfig>): I_UploadConfig {\n return { ...DEFAULT_UPLOAD_CONFIG, ...overrides };\n}\n\n/**\n * Uploads a file with comprehensive validation and error handling.\n * This function processes file uploads with the following features:\n * - Input validation for path and file parameters\n * - Configuration validation for all upload types\n * - File validation using getAndValidateFile function\n * - Automatic directory creation\n * - Stream-based file writing\n * - Comprehensive error handling with standardized response codes\n *\n * @param options - Upload configuration including file, path, type, and optional validation config.\n * @returns A promise that resolves to a standardized response with success status, message, file path, and response codes.\n */\nexport async function upload(options: I_UploadOptions): Promise<I_Return<string>> {\n const { path, file, config, type } = options;\n\n if (!path || typeof path !== 'string') {\n return {\n success: false,\n message: 'Invalid path provided',\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n\n if (!file || typeof file !== 'object') {\n return {\n success: false,\n message: 'Invalid file provided',\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n\n if (config) {\n const requiredTypes = [E_UploadType.IMAGE, E_UploadType.VIDEO, E_UploadType.DOCUMENT, E_UploadType.OTHER];\n\n for (const requiredType of requiredTypes) {\n if (!config[requiredType] || !Array.isArray(config[requiredType].allowedExtensions) || config[requiredType].allowedExtensions.length === 0) {\n return {\n success: false,\n message: `Invalid config for ${requiredType.toLowerCase()} files`,\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n if (typeof config[requiredType].sizeLimit !== 'number' || config[requiredType].sizeLimit <= 0) {\n return {\n success: false,\n message: `Invalid size limit for ${requiredType.toLowerCase()} files`,\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n }\n }\n\n try {\n const fileData = await getAndValidateFile(type, await file, config);\n\n if (!fileData.success) {\n return fileData;\n }\n\n const { createReadStream } = fileData.result;\n\n const dir = dirname(path);\n\n if (!pathExistsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n const writeStream = createReadStream();\n const out = createWriteStream(path);\n writeStream.pipe(out);\n\n await new Promise<void>((resolve, reject) => {\n out.on('finish', () => resolve());\n out.on('error', reject);\n writeStream.on('error', reject);\n });\n\n return {\n success: true,\n result: path,\n message: 'File uploaded successfully',\n code: RESPONSE_STATUS.OK.CODE,\n };\n }\n catch (error) {\n return {\n success: false,\n message: error instanceof Error ? error.message : 'File upload failed',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n}\n"],"names":["getFileSizeFromStream","stream","resolve","reject","size","chunk","getAndValidateFile","type","file","config","fileData","fileSize","uploadConfig","createUploadConfig","validationResult","validateUpload","RESPONSE_STATUS","getFileWebStream","typeConfig","createReadStream","remainingBytes","sizeValidationStream","Transform","_enc","cb","BYTES_PER_MB","validatedStream","ReadableStream","controller","Buffer","err","validateFileExtension","filename","allowedExtensions","lastDotIndex","extension","uploadType","sizeLimit","maxSizeMB","overrides","DEFAULT_UPLOAD_CONFIG","upload","options","path","requiredTypes","E_UploadType","requiredType","dir","dirname","pathExistsSync","mkdirSync","writeStream","out","createWriteStream","error"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- export * from './ts.util.js';
1
+ export * from './ws.util.js';
2
2
  export * from './ws.type.js';
@@ -1,5 +1,6 @@
1
- import { createWSServer as t, initGraphQLWS as S } from "./ts.util.js";
1
+ import { createWSServer as t, initGraphQLWS as S } from "./ws.util.js";
2
2
  export {
3
3
  t as createWSServer,
4
4
  S as initGraphQLWS
5
5
  };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,46 @@
1
+ import { useServer as p } from "graphql-ws/use/ws";
2
+ import { WebSocketServer as u } from "ws";
3
+ function f(c) {
4
+ const { server: o, path: a, sessionParser: n } = c;
5
+ if (n) {
6
+ const r = new u({ noServer: !0 });
7
+ return o.on("upgrade", (e, t, s) => {
8
+ try {
9
+ if (new URL(e.url || "", "http://localhost").pathname !== a)
10
+ return;
11
+ n(e, {}, () => {
12
+ r.handleUpgrade(e, t, s, (i) => {
13
+ r.emit("connection", i, e);
14
+ });
15
+ });
16
+ } catch {
17
+ t.destroy();
18
+ }
19
+ }), r;
20
+ }
21
+ return new u({ server: o, path: a });
22
+ }
23
+ function S(c) {
24
+ const { schema: o, server: a, context: n, onConnect: r } = c;
25
+ return p(
26
+ {
27
+ schema: o,
28
+ context: async (e) => {
29
+ const t = e.extra.request, s = n ? await n(t) : {};
30
+ return { req: t, ...s };
31
+ },
32
+ onConnect: async (e) => {
33
+ if (r) {
34
+ const t = e.extra.request;
35
+ await r(t);
36
+ }
37
+ }
38
+ },
39
+ a
40
+ );
41
+ }
42
+ export {
43
+ f as createWSServer,
44
+ S as initGraphQLWS
45
+ };
46
+ //# sourceMappingURL=ws.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.util.js","sources":["../../../src/node/ws/ws.util.ts"],"sourcesContent":["import type { Request, Response } from 'express';\nimport type { Buffer } from 'node:buffer';\nimport type { IncomingMessage } from 'node:http';\nimport type { Duplex } from 'node:stream';\n\nimport { useServer as createGraphQLWSServer } from 'graphql-ws/use/ws';\nimport { WebSocketServer } from 'ws';\n\nimport type { I_GraphqlWSOptions, I_WSOptions } from './ws.type.js';\n\n/**\n * Creates a WebSocket server with the specified configuration.\n * This function creates a WebSocket server instance that can be attached to an HTTP server\n * and configured with a specific path for WebSocket connections.\n *\n * @param options - Configuration options including the HTTP server instance and WebSocket path.\n * @returns A configured WebSocket server instance ready to handle connections.\n */\nexport function createWSServer(options: I_WSOptions): WebSocketServer {\n const { server, path, sessionParser } = options;\n\n if (sessionParser) {\n const wss = new WebSocketServer({ noServer: true });\n\n server.on('upgrade', (req: IncomingMessage, socket: Duplex, head: Buffer) => {\n try {\n const url = new URL(req.url || '', 'http://localhost');\n if (url.pathname !== path)\n return;\n\n sessionParser(req as Request, {} as Response, () => {\n wss.handleUpgrade(req, socket, head, (ws) => {\n wss.emit('connection', ws, req);\n });\n });\n }\n catch {\n socket.destroy();\n }\n });\n\n return wss;\n }\n\n return new WebSocketServer({ server, path });\n}\n\n/**\n * Initializes GraphQL WebSocket server with schema and WebSocket server.\n * This function sets up GraphQL subscriptions over WebSocket by creating a GraphQL WebSocket server\n * that can handle GraphQL operations including queries, mutations, and subscriptions.\n *\n * @param options - Configuration options including the GraphQL schema and WebSocket server instance.\n * @returns A configured GraphQL WebSocket server ready to handle GraphQL operations over WebSocket.\n */\nexport function initGraphQLWS(options: I_GraphqlWSOptions) {\n const { schema, server, context: makeExtraContext, onConnect } = options;\n\n return createGraphQLWSServer(\n {\n schema,\n context: async (ctx) => {\n const req = ctx.extra.request as IncomingMessage & { session?: any; user?: any };\n\n const extra = makeExtraContext ? await makeExtraContext(req) : {};\n return { req, ...extra };\n },\n onConnect: async (ctx) => {\n if (onConnect) {\n const req = ctx.extra.request as IncomingMessage & { session?: any; user?: any };\n await onConnect(req);\n }\n },\n },\n server,\n );\n}\n"],"names":["createWSServer","options","server","path","sessionParser","wss","WebSocketServer","req","socket","head","ws","initGraphQLWS","schema","makeExtraContext","onConnect","createGraphQLWSServer","ctx","extra"],"mappings":";;AAkBO,SAASA,EAAeC,GAAuC;AAClE,QAAM,EAAE,QAAAC,GAAQ,MAAAC,GAAM,eAAAC,EAAA,IAAkBH;AAExC,MAAIG,GAAe;AACf,UAAMC,IAAM,IAAIC,EAAgB,EAAE,UAAU,IAAM;AAElD,WAAAJ,EAAO,GAAG,WAAW,CAACK,GAAsBC,GAAgBC,MAAiB;AACzE,UAAI;AAEA,YADY,IAAI,IAAIF,EAAI,OAAO,IAAI,kBAAkB,EAC7C,aAAaJ;AACjB;AAEJ,QAAAC,EAAcG,GAAgB,CAAA,GAAgB,MAAM;AAChD,UAAAF,EAAI,cAAcE,GAAKC,GAAQC,GAAM,CAACC,MAAO;AACzC,YAAAL,EAAI,KAAK,cAAcK,GAAIH,CAAG;AAAA,UAClC,CAAC;AAAA,QACL,CAAC;AAAA,MACL,QACM;AACF,QAAAC,EAAO,QAAA;AAAA,MACX;AAAA,IACJ,CAAC,GAEMH;AAAA,EACX;AAEA,SAAO,IAAIC,EAAgB,EAAE,QAAAJ,GAAQ,MAAAC,GAAM;AAC/C;AAUO,SAASQ,EAAcV,GAA6B;AACvD,QAAM,EAAE,QAAAW,GAAQ,QAAAV,GAAQ,SAASW,GAAkB,WAAAC,MAAcb;AAEjE,SAAOc;AAAAA,IACH;AAAA,MACI,QAAAH;AAAA,MACA,SAAS,OAAOI,MAAQ;AACpB,cAAMT,IAAMS,EAAI,MAAM,SAEhBC,IAAQJ,IAAmB,MAAMA,EAAiBN,CAAG,IAAI,CAAA;AAC/D,eAAO,EAAE,KAAAA,GAAK,GAAGU,EAAA;AAAA,MACrB;AAAA,MACA,WAAW,OAAOD,MAAQ;AACtB,YAAIF,GAAW;AACX,gBAAMP,IAAMS,EAAI,MAAM;AACtB,gBAAMF,EAAUP,CAAG;AAAA,QACvB;AAAA,MACJ;AAAA,IAAA;AAAA,IAEJL;AAAA,EAAA;AAER;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sources":["../../../../../../../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"],"sourcesContent":["export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.BOqNVLsY.js';\nexport { mergeConfig } from 'vite';\nexport { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';\nimport 'node:os';\nimport './chunks/env.D4Lgay0q.js';\nimport 'std-env';\n\nfunction defineConfig(config) {\n\treturn config;\n}\nfunction defineProject(config) {\n\treturn config;\n}\n\nexport { defineConfig, defineProject };\n"],"names":["defineConfig","config"],"mappings":"AAOA,SAASA,EAAaC,GAAQ;AAC7B,SAAOA;AACR;","x_google_ignoreList":[0]}
@@ -6,13 +6,14 @@ import { getClient as p } from "./apollo-client.util.js";
6
6
  import { ApolloErrorProvider as a } from "../apollo-error/apollo-error.provider.js";
7
7
  import { ApolloErrorComponent as c } from "../apollo-error/apollo-error.component.js";
8
8
  import { Toaster as f } from "react-hot-toast";
9
- function g({ options: r, children: l, onError: o }) {
9
+ function g({ options: o, children: l, onError: r }) {
10
10
  const t = i(
11
- () => p(r != null ? r : {}),
12
- [r]
11
+ () => p(o ?? {}),
12
+ [o]
13
13
  );
14
- return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(a, { onError: o }, /* @__PURE__ */ e.createElement(n, { client: t }, /* @__PURE__ */ e.createElement(m, { client: t }, l)), !o && /* @__PURE__ */ e.createElement(c, null)), /* @__PURE__ */ e.createElement(f, { position: "top-right" }));
14
+ return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(a, { onError: r }, /* @__PURE__ */ e.createElement(n, { client: t }, /* @__PURE__ */ e.createElement(m, { client: t }, l)), !r && /* @__PURE__ */ e.createElement(c, null)), /* @__PURE__ */ e.createElement(f, { position: "top-right" }));
15
15
  }
16
16
  export {
17
17
  g as ApolloProvider
18
18
  };
19
+ //# sourceMappingURL=apollo-client.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apollo-client.component.js","sources":["../../../src/react/apollo-client/apollo-client.component.tsx"],"sourcesContent":["import { ApolloProvider as ApolloProviderDefault } from '@apollo/client/react';\nimport * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_ApolloProviderProps } from './apollo-client.type.js';\n\nimport { ApolloErrorComponent, ApolloErrorProvider } from '../apollo-error/index.js';\nimport { Toaster } from '../toast/index.js';\nimport { ApolloClientProvider } from './apollo-client.context.js';\nimport { getClient } from './apollo-client.util.js';\n\n/**\n * Apollo Provider component that wraps the application with Apollo Client context.\n * This component provides the Apollo Client instance to all child components,\n * enabling GraphQL operations throughout the component tree. It includes\n * error handling and toast integration for a complete GraphQL experience.\n *\n * Features:\n * - Apollo Client context provision\n * - Error boundary integration\n * - Toast notification support\n * - Automatic error handling\n * - Development and production optimizations\n *\n * @param props - Component props containing options, children, and optional error override.\n * @param props.options - Apollo Client configuration options.\n * @param props.children - React children that will have access to Apollo Client context.\n * @param props.onError - Optional callback to override the default modal/toast error handling.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloProvider({ options, children, onError }: I_ApolloProviderProps) {\n const client = useMemo(\n () => getClient(options ?? {}),\n [options],\n );\n\n return (\n <>\n <ApolloErrorProvider onError={onError}>\n <ApolloClientProvider client={client}>\n <ApolloProviderDefault client={client}>{children}</ApolloProviderDefault>\n </ApolloClientProvider>\n {!onError && <ApolloErrorComponent />}\n </ApolloErrorProvider>\n <Toaster position=\"top-right\" />\n </>\n );\n}\n"],"names":["ApolloProvider","options","children","onError","client","useMemo","getClient","React","ApolloErrorProvider","ApolloClientProvider","ApolloProviderDefault","ApolloErrorComponent","Toaster"],"mappings":";;;;;;;;AA8BO,SAASA,EAAe,EAAE,SAAAC,GAAS,UAAAC,GAAU,SAAAC,KAAkC;AAClF,QAAMC,IAASC;AAAA,IACX,MAAMC,EAAUL,KAAW,EAAE;AAAA,IAC7B,CAACA,CAAO;AAAA,EAAA;AAGZ,SACI,gBAAAM,EAAA,cAAAA,EAAA,UAAA,sCACKC,GAAA,EAAoB,SAAAL,EAAA,mCAChBM,GAAA,EAAqB,QAAAL,EAAA,GAClB,gBAAAG,EAAA,cAACG,GAAA,EAAsB,QAAAN,EAAA,GAAiBF,CAAS,CACrD,GACC,CAACC,KAAW,gBAAAI,EAAA,cAACI,GAAA,IAAqB,CACvC,GACA,gBAAAJ,EAAA,cAACK,GAAA,EAAQ,UAAS,YAAA,CAAY,CAClC;AAER;"}
@@ -2,3 +2,4 @@ const o = "/graphql";
2
2
  export {
3
3
  o as GRAPHQL_URI_DEFAULT
4
4
  };
5
+ //# sourceMappingURL=apollo-client.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apollo-client.constant.js","sources":["../../../src/react/apollo-client/apollo-client.constant.ts"],"sourcesContent":["/**\n * Default GraphQL endpoint URI for Apollo Client configuration.\n * This constant provides the standard GraphQL endpoint path that is commonly used\n * in web applications for GraphQL API communication.\n */\nexport const GRAPHQL_URI_DEFAULT = '/graphql';\n"],"names":["GRAPHQL_URI_DEFAULT"],"mappings":"AAKO,MAAMA,IAAsB;"}
@@ -11,3 +11,4 @@ export {
11
11
  l as ApolloClientContext,
12
12
  i as ApolloClientProvider
13
13
  };
14
+ //# sourceMappingURL=apollo-client.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apollo-client.context.js","sources":["../../../src/react/apollo-client/apollo-client.context.tsx"],"sourcesContent":["import type { ApolloClient } from '@apollo/client';\n\nimport * as React from 'react';\nimport { createContext } from 'react';\n\n/**\n * React context for providing Apollo Client instance to child components.\n * This context allows components to access the Apollo Client instance without\n * prop drilling, enabling direct access to client methods and cache operations.\n */\nconst ApolloClientContext = createContext<ApolloClient | null>(null);\n\n/**\n * Provider component that makes Apollo Client available to the component tree.\n * This component wraps the Apollo Client instance in a React context, allowing\n * any child component to access the client using the useApolloClient hook.\n *\n * @param props - Component props containing client and children.\n * @param props.client - The Apollo Client instance to provide to the component tree.\n * @param props.children - React children that will have access to the Apollo Client context.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloClientProvider({\n client,\n children,\n}: {\n client: ApolloClient;\n children: React.ReactNode;\n}) {\n return (\n <ApolloClientContext value={client}>\n {children}\n </ApolloClientContext>\n );\n}\n\nexport { ApolloClientContext };\n"],"names":["React","createContext","ApolloClientContext","ApolloClientProvider","client","children"],"mappings":"AAUA,YAAAA,OAAA;AAAA,SAAA,iBAAAC,SAAA;AAAA,MAAMC,IAAsBD,EAAmC,IAAI;AAY5D,SAASE,EAAqB;AAAA,EACjC,QAAAC;AAAA,EACA,UAAAC;AACJ,GAGG;AACC,SACI,gBAAAL,EAAA,cAACE,GAAA,EAAoB,OAAOE,EAAA,GACvBC,CACL;AAER;"}
@@ -5,3 +5,4 @@ const r = {
5
5
  export {
6
6
  r as default
7
7
  };
8
+ //# sourceMappingURL=apollo-client.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apollo-client.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,84 +1,78 @@
1
- import { ApolloClient as y, InMemoryCache as h, CombinedGraphQLErrors as g, CombinedProtocolErrors as E, ServerError as v } from "@apollo/client/core";
2
- import { ApolloLink as m } from "@apollo/client/link";
3
- import { ErrorLink as _ } from "@apollo/client/link/error";
4
- import { RemoveTypenameFromVariablesLink as O } from "@apollo/client/link/remove-typename";
5
- import { GraphQLWsLink as P } from "@apollo/client/link/subscriptions";
6
- import { OperationTypeNode as b } from "graphql";
7
- import { createClient as C } from "graphql-ws";
1
+ import { ApolloClient as d, InMemoryCache as w, CombinedGraphQLErrors as h, CombinedProtocolErrors as E, ServerError as g } from "@apollo/client/core";
2
+ import { ApolloLink as a } from "@apollo/client/link";
3
+ import { ErrorLink as C } from "@apollo/client/link/error";
4
+ import { RemoveTypenameFromVariablesLink as y } from "@apollo/client/link/remove-typename";
5
+ import { GraphQLWsLink as N } from "@apollo/client/link/subscriptions";
6
+ import { OperationTypeNode as $ } from "graphql";
7
+ import { createClient as b } from "graphql-ws";
8
8
  import * as p from "react";
9
- import { tap as N } from "rxjs";
10
- import { GRAPHQL_URI_DEFAULT as f } from "./apollo-client.constant.js";
11
- import c from "./apollo-client.module.scss.js";
12
- import { createUploadLink as $ } from "./links/upload.js";
13
- import { hasCustomApolloErrorHandler as A, showGlobalApolloError as u } from "../apollo-error/apollo-error.util.js";
9
+ import { tap as A } from "rxjs";
10
+ import { GRAPHQL_URI_DEFAULT as c } from "./apollo-client.constant.js";
11
+ import f from "./apollo-client.module.scss.js";
12
+ import { createUploadLink as T } from "./links/upload.js";
13
+ import { hasCustomApolloErrorHandler as U, showGlobalApolloError as u } from "../apollo-error/apollo-error.util.js";
14
14
  import { log as s } from "../log/log.util.js";
15
- import { toast as d } from "react-hot-toast";
16
- var S = Object.defineProperty, w = Object.getOwnPropertySymbols, T = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, L = (r, e, o) => e in r ? S(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o, I = (r, e) => {
17
- for (var o in e || (e = {}))
18
- T.call(e, o) && L(r, o, e[o]);
19
- if (w)
20
- for (var o of w(e))
21
- U.call(e, o) && L(r, o, e[o]);
22
- return r;
23
- };
24
- const R = new m((r, e) => (r.setContext({ start: /* @__PURE__ */ new Date() }), e(r).pipe(
25
- N(() => {
26
- const o = (/* @__PURE__ */ new Date()).getTime() - r.getContext().start;
27
- s.info(`Operation ${r.operationName} took ${o}ms to complete`);
15
+ import { toast as L } from "react-hot-toast";
16
+ const R = new a((o, e) => (o.setContext({ start: /* @__PURE__ */ new Date() }), e(o).pipe(
17
+ A(() => {
18
+ const t = (/* @__PURE__ */ new Date()).getTime() - o.getContext().start;
19
+ s.info(`Operation ${o.operationName} took ${t}ms to complete`);
28
20
  })
29
- ))), G = new _(({ error: r, operation: e }) => {
30
- const o = (e == null ? void 0 : e.operationName) || "Unknown";
31
- let t = "";
32
- g.is(r) ? r.errors.forEach(({ message: n, locations: i, path: l }, a) => {
33
- a === 0 && (t = n), s.error(
34
- `[GraphQL error] ${o}: ${n}, Location: ${JSON.stringify(i, null, 4)}, Path: ${l}`
21
+ ))), S = new C(({ error: o, operation: e }) => {
22
+ const t = e?.operationName || "Unknown";
23
+ let i = "";
24
+ h.is(o) ? o.errors.forEach(({ message: r, locations: n, path: l }, m) => {
25
+ m === 0 && (i = r), s.error(
26
+ `[GraphQL error] ${t}: ${r}, Location: ${JSON.stringify(n, null, 4)}, Path: ${l}`
35
27
  );
36
- }) : E.is(r) ? r.errors.forEach(({ message: n, extensions: i }, l) => {
37
- l === 0 && (t = n), s.error(
38
- `[Protocol error]: ${n}, Extensions: ${JSON.stringify(i, null, 4)}`
28
+ }) : E.is(o) ? o.errors.forEach(({ message: r, extensions: n }, l) => {
29
+ l === 0 && (i = r), s.error(
30
+ `[Protocol error]: ${r}, Extensions: ${JSON.stringify(n, null, 4)}`
39
31
  );
40
- }) : v.is(r) ? (t = r.message, s.error(`[Server error]: ${r.message}`)) : (t = r.message, s.error(`[Network error]: ${r.message}`)), r && t && typeof window != "undefined" && (A() ? u(r) : d.error((n) => /* @__PURE__ */ p.createElement("div", { className: c["error-container"] }, t, /* @__PURE__ */ p.createElement(
32
+ }) : g.is(o) ? (i = o.message, s.error(`[Server error]: ${o.message}`)) : (i = o.message, s.error(`[Network error]: ${o.message}`)), o && i && typeof window < "u" && (U() ? u(o) : L.error((r) => /* @__PURE__ */ p.createElement("div", { className: f["error-container"] }, i, /* @__PURE__ */ p.createElement(
41
33
  "button",
42
34
  {
43
35
  type: "button",
44
- className: c["error-details-button"],
36
+ className: f["error-details-button"],
45
37
  onClick: () => {
46
- u(r), d.dismiss(n.id);
38
+ u(o), L.dismiss(r.id);
47
39
  }
48
40
  },
49
41
  "Error Details"
50
42
  ))));
51
43
  });
52
- function Q(r) {
53
- const { uri: e, wsUrl: o, customLinks: t } = r, n = new O();
54
- e || s.warn(`[Apollo] No GraphQL URI provided — using "${f}" as default`);
55
- const i = $({
56
- uri: e != null ? e : f,
44
+ function v(o) {
45
+ const { uri: e, wsUrl: t, customLinks: i } = o, r = new y();
46
+ e || s.warn(`[Apollo] No GraphQL URI provided — using "${c}" as default`);
47
+ const n = T({
48
+ uri: e ?? c,
57
49
  credentials: "include",
58
50
  headers: {
59
51
  "apollo-require-preflight": "true"
60
52
  }
61
- }), l = o ? new P(C({ url: o })) : m.empty(), a = o ? m.split(
62
- ({ operationType: k }) => k === b.SUBSCRIPTION,
53
+ }), l = t ? new N(b({ url: t })) : a.empty(), m = t ? a.split(
54
+ ({ operationType: k }) => k === $.SUBSCRIPTION,
63
55
  l,
64
- i
65
- ) : i;
66
- return o && a === i && s.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
56
+ n
57
+ ) : n;
58
+ return t && m === n && s.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
67
59
  R,
68
- G,
69
- n,
70
- ...t != null ? t : [],
71
- a
60
+ S,
61
+ r,
62
+ ...i ?? [],
63
+ m
72
64
  ];
73
65
  }
74
- function Y(r) {
75
- const e = m.from(Q(r));
76
- return new y(I({
66
+ function B(o) {
67
+ const e = a.from(v(o));
68
+ return new d({
77
69
  link: e,
78
- cache: new h()
79
- }, r));
70
+ cache: new w(),
71
+ ...o
72
+ });
80
73
  }
81
74
  export {
82
- Q as createApolloLinks,
83
- Y as getClient
75
+ v as createApolloLinks,
76
+ B as getClient
84
77
  };
78
+ //# sourceMappingURL=apollo-client.util.js.map