@react-pakistan/util-functions 1.25.90 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) hide show
  1. package/README.md +74 -315
  2. package/constants/api-methods.d.ts +3 -1
  3. package/constants/api-methods.js +1 -15
  4. package/constants/cache-time.d.ts +7 -5
  5. package/constants/cache-time.js +1 -8
  6. package/constants/countries-timezones.d.ts +4 -2
  7. package/constants/countries-timezones.js +1 -1411
  8. package/constants/currencies.d.ts +4 -2
  9. package/constants/currencies.js +1 -1076
  10. package/constants/dial-codes.d.ts +5 -3
  11. package/constants/dial-codes.js +1 -1216
  12. package/constants/layout-direction.d.ts +3 -1
  13. package/constants/layout-direction.js +1 -8
  14. package/constants/react-pakistan-meta.d.ts +4 -2
  15. package/constants/react-pakistan-meta.js +1 -35
  16. package/constants/react-pakistan.d.ts +5 -3
  17. package/constants/react-pakistan.js +12 -104
  18. package/constants/select-value-delimiter.d.ts +3 -1
  19. package/constants/select-value-delimiter.js +1 -13
  20. package/constants/social-media-colors.d.ts +3 -1
  21. package/constants/social-media-colors.js +1 -42
  22. package/constants/social-media-sizes.d.ts +6 -4
  23. package/constants/social-media-sizes.js +1 -327
  24. package/constants/user-roles.d.ts +3 -1
  25. package/constants/user-roles.js +1 -9
  26. package/edu-pilot-pro/types/academics.d.ts +2 -266
  27. package/edu-pilot-pro/types/academics.js +1 -9
  28. package/edu-pilot-pro/types/admission.d.ts +803 -10
  29. package/edu-pilot-pro/types/admission.js +1 -7
  30. package/edu-pilot-pro/types/communication.d.ts +2 -165
  31. package/edu-pilot-pro/types/communication.js +1 -8
  32. package/edu-pilot-pro/types/enums.d.ts +30 -28
  33. package/edu-pilot-pro/types/enums.js +1 -445
  34. package/edu-pilot-pro/types/finance.d.ts +2 -128
  35. package/edu-pilot-pro/types/finance.js +1 -8
  36. package/edu-pilot-pro/types/index.d.ts +2 -12
  37. package/edu-pilot-pro/types/index.js +1 -28
  38. package/edu-pilot-pro/types/user-management.d.ts +2 -236
  39. package/edu-pilot-pro/types/user-management.js +1 -8
  40. package/factory/generic-component-factory.d.ts +12 -9
  41. package/factory/generic-component-factory.js +1 -131
  42. package/factory/generic-module-factory.d.ts +14 -10
  43. package/factory/generic-module-factory.js +1 -190
  44. package/general/basic-get.d.ts +8 -1
  45. package/general/basic-get.js +1 -83
  46. package/general/basic-post.d.ts +8 -1
  47. package/general/basic-post.js +1 -70
  48. package/general/calculate-pages.d.ts +9 -1
  49. package/general/calculate-pages.js +1 -7
  50. package/general/camel-to-sentence-case.d.ts +3 -1
  51. package/general/camel-to-sentence-case.js +1 -20
  52. package/general/check-even-odd-length.d.ts +3 -1
  53. package/general/check-even-odd-length.js +1 -17
  54. package/general/clear-cache.d.ts +7 -2
  55. package/general/clear-cache.js +1 -12
  56. package/general/cnic-formatter.d.ts +16 -3
  57. package/general/cnic-formatter.js +1 -53
  58. package/general/convert-url-to-base64.d.ts +8 -6
  59. package/general/convert-url-to-base64.js +1 -231
  60. package/general/countries.d.ts +5 -3
  61. package/general/countries.js +1 -514
  62. package/general/create-date.d.ts +3 -1
  63. package/general/create-date.js +1 -22
  64. package/general/crypto.d.ts +4 -2
  65. package/general/crypto.js +1 -45
  66. package/general/currencies.d.ts +2 -0
  67. package/general/currencies.js +0 -1077
  68. package/general/delete-image-from-private-supabase.d.ts +10 -2
  69. package/general/delete-image-from-private-supabase.js +1 -66
  70. package/general/delete-image-from-public-supabase.d.ts +10 -2
  71. package/general/delete-image-from-public-supabase.js +1 -66
  72. package/general/download-from-url.d.ts +8 -1
  73. package/general/download-from-url.js +1 -82
  74. package/general/dynamic-page-limit.d.ts +9 -3
  75. package/general/dynamic-page-limit.js +1 -7
  76. package/general/enum-to-text.d.ts +8 -1
  77. package/general/enum-to-text.js +1 -11
  78. package/general/fetch-data.d.ts +16 -4
  79. package/general/fetch-data.js +1 -95
  80. package/general/fetch-supabase-image.d.ts +11 -2
  81. package/general/fetch-supabase-image.js +1 -67
  82. package/general/fetch-supabase-private-assets.d.ts +11 -2
  83. package/general/fetch-supabase-private-assets.js +1 -69
  84. package/general/format-date.d.ts +10 -2
  85. package/general/format-date.js +1 -49
  86. package/general/format-number.d.ts +12 -2
  87. package/general/format-number.js +1 -35
  88. package/general/format-phone-display.d.ts +9 -1
  89. package/general/format-phone-display.js +1 -32
  90. package/general/format-phone.d.ts +10 -2
  91. package/general/format-phone.js +1 -20
  92. package/general/format-pricing.d.ts +8 -1
  93. package/general/format-pricing.js +1 -23
  94. package/general/format-secs.d.ts +8 -1
  95. package/general/format-secs.js +1 -21
  96. package/general/format-time.d.ts +8 -2
  97. package/general/format-time.js +1 -38
  98. package/general/format-value.d.ts +8 -1
  99. package/general/format-value.js +1 -7
  100. package/general/full-month-range.d.ts +3 -2
  101. package/general/full-month-range.js +1 -24
  102. package/general/full-year-range.d.ts +3 -2
  103. package/general/full-year-range.js +1 -20
  104. package/general/generate-article-schema.d.ts +3 -2
  105. package/general/generate-article-schema.js +1 -100
  106. package/general/generate-blog-schema.d.ts +3 -2
  107. package/general/generate-blog-schema.js +1 -32
  108. package/general/generate-book-schema.d.ts +3 -2
  109. package/general/generate-book-schema.js +1 -109
  110. package/general/generate-breadcrumb-schema.d.ts +3 -2
  111. package/general/generate-breadcrumb-schema.js +1 -34
  112. package/general/generate-carousel-schema.d.ts +3 -2
  113. package/general/generate-carousel-schema.js +1 -172
  114. package/general/generate-course-schema.d.ts +3 -2
  115. package/general/generate-course-schema.js +1 -124
  116. package/general/generate-dataset-schema.d.ts +3 -2
  117. package/general/generate-dataset-schema.js +1 -156
  118. package/general/generate-discussion-forum-schema.d.ts +3 -2
  119. package/general/generate-discussion-forum-schema.js +1 -67
  120. package/general/generate-education-schema.d.ts +3 -2
  121. package/general/generate-education-schema.js +1 -137
  122. package/general/generate-employer-aggregate-rating-schema.d.ts +3 -2
  123. package/general/generate-employer-aggregate-rating-schema.js +1 -64
  124. package/general/generate-event-schema.d.ts +3 -2
  125. package/general/generate-event-schema.js +1 -214
  126. package/general/generate-faq-schema.d.ts +3 -2
  127. package/general/generate-faq-schema.js +1 -43
  128. package/general/generate-grid.d.ts +3 -2
  129. package/general/generate-grid.js +1 -55
  130. package/general/generate-image-metadata-schema.d.ts +3 -2
  131. package/general/generate-image-metadata-schema.js +1 -73
  132. package/general/generate-job-posting-schema.d.ts +3 -2
  133. package/general/generate-job-posting-schema.js +1 -120
  134. package/general/generate-local-business-schema.d.ts +3 -2
  135. package/general/generate-local-business-schema.js +1 -75
  136. package/general/generate-math-solver-schema.d.ts +3 -2
  137. package/general/generate-math-solver-schema.js +1 -83
  138. package/general/generate-movie-carousel-schema.d.ts +3 -2
  139. package/general/generate-movie-carousel-schema.js +1 -160
  140. package/general/generate-organization-schema.d.ts +3 -2
  141. package/general/generate-organization-schema.js +1 -39
  142. package/general/generate-profile-page-schema.d.ts +3 -2
  143. package/general/generate-profile-page-schema.js +1 -82
  144. package/general/generate-qa-page-schema.d.ts +3 -2
  145. package/general/generate-qa-page-schema.js +1 -67
  146. package/general/generate-recipe-schema.d.ts +3 -2
  147. package/general/generate-recipe-schema.js +1 -104
  148. package/general/generate-ref.d.ts +8 -2
  149. package/general/generate-ref.js +1 -12
  150. package/general/generate-review-snippet-schema.d.ts +3 -2
  151. package/general/generate-review-snippet-schema.js +1 -137
  152. package/general/generate-shopping-loyalty-program-schema.d.ts +3 -2
  153. package/general/generate-shopping-loyalty-program-schema.js +1 -59
  154. package/general/generate-shopping-merchant-listing-schema.d.ts +3 -2
  155. package/general/generate-shopping-merchant-listing-schema.js +1 -153
  156. package/general/generate-shopping-merchant-return-policy-schema.d.ts +3 -2
  157. package/general/generate-shopping-merchant-return-policy-schema.js +1 -68
  158. package/general/generate-shopping-merchant-shipping-policy-schema.d.ts +3 -2
  159. package/general/generate-shopping-merchant-shipping-policy-schema.js +1 -74
  160. package/general/generate-shopping-overview-schema.d.ts +3 -2
  161. package/general/generate-shopping-overview-schema.js +1 -157
  162. package/general/generate-shopping-product-snippet-schema.d.ts +3 -2
  163. package/general/generate-shopping-product-snippet-schema.js +1 -167
  164. package/general/generate-shopping-variants-schema.d.ts +3 -2
  165. package/general/generate-shopping-variants-schema.js +1 -143
  166. package/general/generate-software-app-schema.d.ts +3 -2
  167. package/general/generate-software-app-schema.js +1 -143
  168. package/general/generate-speakable-schema.d.ts +3 -2
  169. package/general/generate-speakable-schema.js +1 -139
  170. package/general/generate-subscription-schema.d.ts +3 -2
  171. package/general/generate-subscription-schema.js +1 -133
  172. package/general/generate-vacation-rental-schema.d.ts +3 -2
  173. package/general/generate-vacation-rental-schema.js +1 -135
  174. package/general/generate-video-schema.d.ts +3 -2
  175. package/general/generate-video-schema.js +1 -163
  176. package/general/generic-cache.d.ts +17 -15
  177. package/general/generic-cache.js +1 -659
  178. package/general/get-available-page-limit.d.ts +8 -2
  179. package/general/get-available-page-limit.js +1 -31
  180. package/general/get-calendar-current-month.d.ts +11 -3
  181. package/general/get-calendar-current-month.js +1 -31
  182. package/general/get-calendar-dates.d.ts +11 -3
  183. package/general/get-calendar-dates.js +1 -42
  184. package/general/get-calendar-next-month.d.ts +12 -3
  185. package/general/get-calendar-next-month.js +1 -32
  186. package/general/get-calendar-previous-month.d.ts +12 -3
  187. package/general/get-calendar-previous-month.js +1 -36
  188. package/general/get-current-year.d.ts +7 -1
  189. package/general/get-current-year.js +1 -5
  190. package/general/get-day-name.d.ts +5 -3
  191. package/general/get-day-name.js +1 -14
  192. package/general/get-dial-code.d.ts +8 -1
  193. package/general/get-dial-code.js +1 -8
  194. package/general/get-full-name.d.ts +9 -2
  195. package/general/get-full-name.js +1 -8
  196. package/general/get-href.d.ts +3 -1
  197. package/general/get-href.js +1 -13
  198. package/general/get-month-name.d.ts +5 -3
  199. package/general/get-month-name.js +1 -19
  200. package/general/get-month-number.d.ts +5 -3
  201. package/general/get-month-number.js +1 -29
  202. package/general/get-number-of-days-in-month.d.ts +9 -2
  203. package/general/get-number-of-days-in-month.js +1 -12
  204. package/general/get-pathname.d.ts +3 -1
  205. package/general/get-pathname.js +1 -16
  206. package/general/get-week-day.d.ts +8 -1
  207. package/general/get-week-day.js +1 -9
  208. package/general/image-url-to-base64.d.ts +3 -1
  209. package/general/image-url-to-base64.js +1 -80
  210. package/general/is-created-or-updated.d.ts +3 -1
  211. package/general/is-created-or-updated.js +1 -26
  212. package/general/is-next-button-disabled.d.ts +9 -1
  213. package/general/is-next-button-disabled.js +1 -5
  214. package/general/is-odd.d.ts +3 -1
  215. package/general/is-odd.js +1 -13
  216. package/general/is-previous-button-disabled.d.ts +8 -1
  217. package/general/is-previous-button-disabled.js +1 -7
  218. package/general/linear-gradients.d.ts +4 -2
  219. package/general/linear-gradients.js +1 -52
  220. package/general/multi-part-search.d.ts +10 -2
  221. package/general/multi-part-search.js +1 -16
  222. package/general/normalize-phone.d.ts +15 -2
  223. package/general/normalize-phone.js +1 -40
  224. package/general/parse-frontmatter.d.ts +11 -4
  225. package/general/parse-frontmatter.js +2 -35
  226. package/general/remove-data-image-prefix.d.ts +8 -1
  227. package/general/remove-data-image-prefix.js +1 -7
  228. package/general/repeat-times.d.ts +3 -1
  229. package/general/repeat-times.js +1 -21
  230. package/general/resolve-anchor-link.d.ts +3 -1
  231. package/general/resolve-anchor-link.js +1 -26
  232. package/general/resolve-current-date.d.ts +3 -1
  233. package/general/resolve-current-date.js +1 -22
  234. package/general/resolve-grid.d.ts +3 -1
  235. package/general/resolve-grid.js +1 -18
  236. package/general/resolve-initials.d.ts +3 -1
  237. package/general/resolve-initials.js +1 -17
  238. package/general/set-timezone.d.ts +11 -1
  239. package/general/set-timezone.js +1 -12
  240. package/general/slugify.d.ts +3 -1
  241. package/general/slugify.js +1 -24
  242. package/general/text-to-enum.d.ts +8 -1
  243. package/general/text-to-enum.js +1 -10
  244. package/general/text-to-sentence-case.d.ts +3 -1
  245. package/general/text-to-sentence-case.js +1 -16
  246. package/general/time-out.d.ts +3 -1
  247. package/general/time-out.js +1 -16
  248. package/general/time-zones.d.ts +3 -1
  249. package/general/time-zones.js +1 -437
  250. package/general/truncate-text.d.ts +3 -1
  251. package/general/truncate-text.js +1 -18
  252. package/general/type.d.ts +3 -1
  253. package/general/type.js +1 -2
  254. package/general/upload-blob-to-private-supabase.d.ts +14 -2
  255. package/general/upload-blob-to-private-supabase.js +1 -62
  256. package/general/upload-blob-to-public-supabase.d.ts +14 -2
  257. package/general/upload-blob-to-public-supabase.js +1 -62
  258. package/general/upload-image-to-private-supabase.d.ts +15 -3
  259. package/general/upload-image-to-private-supabase.js +1 -66
  260. package/general/upload-image-to-public-supabase.d.ts +15 -3
  261. package/general/upload-image-to-public-supabase.js +1 -66
  262. package/general/url-to-sentence-case.d.ts +3 -1
  263. package/general/url-to-sentence-case.js +1 -19
  264. package/general/validate-comment.d.ts +3 -1
  265. package/general/validate-comment.js +1 -21
  266. package/general/validate-email.d.ts +3 -1
  267. package/general/validate-email.js +1 -24
  268. package/general/validate-form.d.ts +12 -3
  269. package/general/validate-form.js +1 -29
  270. package/general/validate-name.d.ts +3 -1
  271. package/general/validate-name.js +1 -21
  272. package/hooks/use-change.d.ts +11 -2
  273. package/hooks/use-change.js +1 -23
  274. package/hooks/use-debounce.d.ts +10 -1
  275. package/hooks/use-debounce.js +1 -14
  276. package/hooks/use-fetch.d.ts +7 -5
  277. package/hooks/use-fetch.js +1 -239
  278. package/hooks/use-force-render.d.ts +6 -2
  279. package/hooks/use-force-render.js +1 -17
  280. package/hooks/use-ip-geo-location.d.ts +8 -1
  281. package/hooks/use-ip-geo-location.js +1 -79
  282. package/hooks/use-is-mobile.d.ts +8 -1
  283. package/hooks/use-is-mobile.js +1 -22
  284. package/hooks/use-module-entity-v2.d.ts +7 -4
  285. package/hooks/use-module-entity-v2.js +1 -188
  286. package/hooks/use-module-entity.d.ts +7 -4
  287. package/hooks/use-module-entity.js +1 -177
  288. package/hooks/use-phone-formatter.d.ts +10 -2
  289. package/hooks/use-phone-formatter.js +1 -23
  290. package/hooks/use-position.d.ts +6 -3
  291. package/hooks/use-position.js +1 -43
  292. package/hooks/use-rtl.d.ts +4 -2
  293. package/hooks/use-rtl.js +1 -84
  294. package/hooks/use-sticky.d.ts +3 -1
  295. package/hooks/use-sticky.js +1 -39
  296. package/hooks/use-toggle-state.d.ts +3 -2
  297. package/hooks/use-toggle-state.js +1 -26
  298. package/hooks/use-window-event-listener.d.ts +9 -1
  299. package/hooks/use-window-event-listener.js +1 -11
  300. package/hooks/with-seo.d.ts +11 -2
  301. package/hooks/with-seo.js +1 -37
  302. package/local-storage/get-storage-value.d.ts +5 -2
  303. package/local-storage/get-storage-value.js +1 -20
  304. package/local-storage/remove-storage-value.d.ts +3 -1
  305. package/local-storage/remove-storage-value.js +1 -14
  306. package/local-storage/set-storage-value.d.ts +3 -1
  307. package/local-storage/set-storage-value.js +1 -14
  308. package/local-storage/type.d.ts +3 -1
  309. package/local-storage/type.js +1 -2
  310. package/npm.d.d.ts +2 -0
  311. package/npm.d.js +0 -0
  312. package/package.json +20 -18
  313. package/storybook/generate-sitemap.d.ts +3 -1
  314. package/storybook/generate-sitemap.js +17 -26
  315. package/storybook/preview.d.ts +4 -2
  316. package/storybook/preview.js +1 -62
  317. package/storybook/react-design-story-script.d.ts +3 -1
  318. package/storybook/react-design-story-script.js +5 -27
  319. package/storybook/react-emoji-collection.d.ts +3 -1
  320. package/storybook/react-emoji-collection.js +10 -55
  321. package/storybook/react-emoji-story-script.d.ts +3 -1
  322. package/storybook/react-emoji-story-script.js +5 -31
  323. package/storybook/react-emoji-story-template.d.ts +3 -1
  324. package/storybook/react-emoji-story-template.js +45 -15
  325. package/storybook/react-icon-collection.d.ts +3 -1
  326. package/storybook/react-icon-collection.js +10 -42
  327. package/storybook/react-icon-story-script.d.ts +3 -1
  328. package/storybook/react-icon-story-script.js +5 -27
  329. package/storybook/react-icon-story-template.d.ts +3 -1
  330. package/storybook/react-icon-story-template.js +45 -14
  331. package/storybook/react-logo-collection.d.ts +3 -1
  332. package/storybook/react-logo-collection.js +10 -42
  333. package/storybook/react-logo-story-script.d.ts +3 -1
  334. package/storybook/react-logo-story-script.js +5 -27
  335. package/storybook/react-logo-story-template.d.ts +3 -1
  336. package/storybook/react-logo-story-template.js +45 -14
  337. package/storybook/react-pakistan-theme.d.ts +3 -1
  338. package/storybook/react-pakistan-theme.js +1 -31
  339. package/storybook/responsive-args.d.ts +11 -10
  340. package/storybook/responsive-args.js +1 -19
  341. package/storybook/responsive-component.d.ts +4 -2
  342. package/storybook/responsive-component.js +37 -23
  343. package/storybook/responsive-screens.d.ts +3 -1
  344. package/storybook/responsive-screens.js +1 -109
  345. package/storybook/theme.d.ts +17 -15
  346. package/storybook/theme.js +1 -1022
  347. package/api/stellar-solutions/app-user/index.d.ts +0 -51
  348. package/api/stellar-solutions/app-user/index.js +0 -210
  349. package/api/stellar-solutions/bank/index.d.ts +0 -59
  350. package/api/stellar-solutions/bank/index.js +0 -210
  351. package/api/stellar-solutions/branch/index.d.ts +0 -58
  352. package/api/stellar-solutions/branch/index.js +0 -220
  353. package/api/stellar-solutions/company/index.d.ts +0 -57
  354. package/api/stellar-solutions/company/index.js +0 -218
  355. package/api/stellar-solutions/company-report/index.d.ts +0 -15
  356. package/api/stellar-solutions/company-report/index.js +0 -74
  357. package/api/stellar-solutions/constants.d.ts +0 -19
  358. package/api/stellar-solutions/constants.js +0 -22
  359. package/api/stellar-solutions/contact/index.d.ts +0 -56
  360. package/api/stellar-solutions/contact/index.js +0 -217
  361. package/api/stellar-solutions/currency/index.d.ts +0 -55
  362. package/api/stellar-solutions/currency/index.js +0 -212
  363. package/api/stellar-solutions/customer/index.d.ts +0 -68
  364. package/api/stellar-solutions/customer/index.js +0 -249
  365. package/api/stellar-solutions/expense/index.d.ts +0 -58
  366. package/api/stellar-solutions/expense/index.js +0 -229
  367. package/api/stellar-solutions/expense-category/index.d.ts +0 -53
  368. package/api/stellar-solutions/expense-category/index.js +0 -214
  369. package/api/stellar-solutions/lead/index.d.ts +0 -51
  370. package/api/stellar-solutions/lead/index.js +0 -206
  371. package/api/stellar-solutions/menu-order/index.d.ts +0 -53
  372. package/api/stellar-solutions/menu-order/index.js +0 -202
  373. package/api/stellar-solutions/payment/index.d.ts +0 -65
  374. package/api/stellar-solutions/payment/index.js +0 -230
  375. package/api/stellar-solutions/payment-mode/index.d.ts +0 -53
  376. package/api/stellar-solutions/payment-mode/index.js +0 -191
  377. package/api/stellar-solutions/preference/index.d.ts +0 -25
  378. package/api/stellar-solutions/preference/index.js +0 -114
  379. package/api/stellar-solutions/product/index.d.ts +0 -64
  380. package/api/stellar-solutions/product/index.js +0 -235
  381. package/api/stellar-solutions/product-category/index.d.ts +0 -51
  382. package/api/stellar-solutions/product-category/index.js +0 -212
  383. package/api/stellar-solutions/profile/index.d.ts +0 -78
  384. package/api/stellar-solutions/profile/index.js +0 -234
  385. package/api/stellar-solutions/quote-invoice/index.d.ts +0 -97
  386. package/api/stellar-solutions/quote-invoice/index.js +0 -369
  387. package/api/stellar-solutions/quote-invoice-report/index.d.ts +0 -15
  388. package/api/stellar-solutions/quote-invoice-report/index.js +0 -74
  389. package/api/stellar-solutions/tax/index.d.ts +0 -55
  390. package/api/stellar-solutions/tax/index.js +0 -224
  391. package/api/stellar-solutions/types/common.d.ts +0 -24
  392. package/api/stellar-solutions/types/common.js +0 -22
  393. package/api/stellar-solutions/types/erp.d.ts +0 -302
  394. package/api/stellar-solutions/types/erp.js +0 -73
  395. package/api/stellar-solutions/types/index.d.ts +0 -3
  396. package/api/stellar-solutions/types/index.js +0 -19
  397. package/api/stellar-solutions/types/pos.d.ts +0 -176
  398. package/api/stellar-solutions/types/pos.js +0 -61
  399. package/constants/index.d.ts +0 -12
  400. package/constants/index.js +0 -28
  401. package/factory/index.d.ts +0 -2
  402. package/factory/index.js +0 -18
  403. package/general/index.d.ts +0 -95
  404. package/general/index.js +0 -111
  405. package/index.d.ts +0 -28
  406. package/index.js +0 -44
  407. package/local-storage/index.d.ts +0 -4
  408. package/local-storage/index.js +0 -20
  409. package/setupTests.d.ts +0 -1
  410. package/setupTests.js +0 -52
  411. package/storybook/index.d.ts +0 -17
  412. package/storybook/index.js +0 -33
@@ -1,191 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.deletePaymentMode = exports.updatePaymentMode = exports.unitPaymentModeById = exports.listPaymentMode = void 0;
49
- var multi_part_search_1 = require("../../../general/multi-part-search");
50
- /**
51
- * Retrieves a paginated list of payment modes
52
- * @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
53
- * @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
54
- */
55
- var listPaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
56
- var include, orderBy, idSearchQuery, labelSearchQuery, where, _c, count, items;
57
- var _d;
58
- var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includePayments, includePayments = _f === void 0 ? false : _f, _g = _b.includePreference, includePreference = _g === void 0 ? false : _g, _h = _b.orderByColumn, orderByColumn = _h === void 0 ? 'createdAt' : _h, _j = _b.orderByDirection, orderByDirection = _j === void 0 ? 'desc' : _j, _k = _b.pageLimit, pageLimit = _k === void 0 ? Number(process.env.NEXT_PUBLIC_PAGE_LIMIT_PAYMENT_MODE) : _k, prisma = _b.prisma, _l = _b.searchQuery, searchQuery = _l === void 0 ? '' : _l;
59
- return __generator(this, function (_m) {
60
- switch (_m.label) {
61
- case 0:
62
- if (!currentPage || currentPage < 1) {
63
- throw new Error('Valid current page is required');
64
- }
65
- if (!pageLimit || pageLimit < 1) {
66
- throw new Error('Valid page limit is required');
67
- }
68
- include = {
69
- payments: includePayments,
70
- preference: includePreference,
71
- };
72
- orderBy = (_d = {},
73
- _d[orderByColumn] = orderByDirection,
74
- _d);
75
- idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
76
- columnName: 'id',
77
- fullText: searchQuery,
78
- });
79
- labelSearchQuery = (0, multi_part_search_1.multiPartSearch)({
80
- columnName: 'label',
81
- fullText: searchQuery,
82
- });
83
- where = {
84
- OR: __spreadArray(__spreadArray([], idSearchQuery, true), labelSearchQuery, true),
85
- };
86
- return [4 /*yield*/, prisma.$transaction([
87
- prisma.paymentMode.count({
88
- where: where,
89
- }),
90
- prisma.paymentMode.findMany({
91
- include: include,
92
- orderBy: orderBy,
93
- skip: (currentPage - 1) * pageLimit,
94
- take: pageLimit,
95
- where: where,
96
- }),
97
- ])];
98
- case 1:
99
- _c = _m.sent(), count = _c[0], items = _c[1];
100
- return [2 /*return*/, [count, items]];
101
- }
102
- });
103
- }); };
104
- exports.listPaymentMode = listPaymentMode;
105
- /**
106
- * Retrieves a single payment mode by its ID
107
- * @param {UnitPaymentModeByIdArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
108
- * @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
109
- */
110
- var unitPaymentModeById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
111
- var include, where, paymentMode;
112
- var id = _b.id, _c = _b.includePayments, includePayments = _c === void 0 ? false : _c, _d = _b.includePreference, includePreference = _d === void 0 ? false : _d, prisma = _b.prisma;
113
- return __generator(this, function (_e) {
114
- switch (_e.label) {
115
- case 0:
116
- if (!id) {
117
- throw new Error('Payment mode ID is required');
118
- }
119
- include = {
120
- payments: includePayments,
121
- preference: includePreference,
122
- };
123
- where = { id: id };
124
- return [4 /*yield*/, prisma.paymentMode.findUnique({
125
- include: include,
126
- where: where,
127
- })];
128
- case 1:
129
- paymentMode = _e.sent();
130
- return [2 /*return*/, paymentMode];
131
- }
132
- });
133
- }); };
134
- exports.unitPaymentModeById = unitPaymentModeById;
135
- /**
136
- * Updates a payment mode's enabled status
137
- * @param {UpdatePaymentModeArgs} args - Object containing prisma client, payment mode ID, enabled status, and optional query parameters
138
- * @returns {Promise<PaymentModeBE>} Updated payment mode
139
- */
140
- var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
141
- var where, paymentMode;
142
- var enabled = _b.enabled, isDefault = _b.isDefault, id = _b.id, prisma = _b.prisma;
143
- return __generator(this, function (_c) {
144
- switch (_c.label) {
145
- case 0:
146
- if (!id) {
147
- throw new Error('Payment mode ID is required');
148
- }
149
- if (typeof enabled !== 'boolean') {
150
- throw new Error('Enabled status must be a boolean');
151
- }
152
- where = { id: id };
153
- return [4 /*yield*/, prisma.paymentMode.update({
154
- data: {
155
- enabled: enabled,
156
- isDefault: isDefault,
157
- },
158
- where: where,
159
- })];
160
- case 1:
161
- paymentMode = _c.sent();
162
- return [2 /*return*/, paymentMode];
163
- }
164
- });
165
- }); };
166
- exports.updatePaymentMode = updatePaymentMode;
167
- /**
168
- * Deletes a payment mode by ID
169
- * @param {DeletePaymentModeArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
170
- * @returns {Promise<PaymentModeBE>} Deleted payment mode
171
- */
172
- var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
173
- var where, paymentMode;
174
- var id = _b.id, prisma = _b.prisma;
175
- return __generator(this, function (_c) {
176
- switch (_c.label) {
177
- case 0:
178
- if (!id) {
179
- throw new Error('Payment mode ID is required');
180
- }
181
- where = { id: id };
182
- return [4 /*yield*/, prisma.paymentMode.delete({
183
- where: where,
184
- })];
185
- case 1:
186
- paymentMode = _c.sent();
187
- return [2 /*return*/, paymentMode];
188
- }
189
- });
190
- }); };
191
- exports.deletePaymentMode = deletePaymentMode;
@@ -1,25 +0,0 @@
1
- import { PreferenceBE } from '../types';
2
- type PrismaClient = any;
3
- export interface ListPreferencesArgs {
4
- orderByColumn?: string;
5
- orderByDirection?: 'asc' | 'desc';
6
- prisma: PrismaClient;
7
- }
8
- export interface PostPreferenceArgs {
9
- id: string;
10
- onboarding: boolean;
11
- prisma: PrismaClient;
12
- }
13
- /**
14
- * Retrieves all preferences
15
- * @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
16
- * @returns {Promise<Array<PreferenceBE>>} Array of preferences
17
- */
18
- export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }: ListPreferencesArgs) => Promise<Array<PreferenceBE>>;
19
- /**
20
- * Updates a preference using upsert
21
- * @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
22
- * @returns {Promise<PreferenceBE>} Updated preference
23
- */
24
- export declare const updatePreference: ({ id, onboarding, prisma, }: PostPreferenceArgs) => Promise<PreferenceBE>;
25
- export {};
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.updatePreference = exports.listPreference = void 0;
51
- /**
52
- * Retrieves all preferences
53
- * @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
54
- * @returns {Promise<Array<PreferenceBE>>} Array of preferences
55
- */
56
- var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
- var include, orderBy, where, _c, count, items;
58
- var _d;
59
- var _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, prisma = _b.prisma;
60
- return __generator(this, function (_g) {
61
- switch (_g.label) {
62
- case 0:
63
- include = {};
64
- orderBy = (_d = {},
65
- _d[orderByColumn] = orderByDirection,
66
- _d);
67
- where = {};
68
- return [4 /*yield*/, prisma.preference.findMany({
69
- include: include,
70
- orderBy: orderBy,
71
- where: where,
72
- })];
73
- case 1:
74
- _c = _g.sent(), count = _c[0], items = _c[1];
75
- return [2 /*return*/, [count, items]];
76
- }
77
- });
78
- }); };
79
- exports.listPreference = listPreference;
80
- /**
81
- * Updates a preference using upsert
82
- * @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
83
- * @returns {Promise<PreferenceBE>} Updated preference
84
- */
85
- var updatePreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
86
- var preferenceData, where, preference;
87
- var id = _b.id, onboarding = _b.onboarding, prisma = _b.prisma;
88
- return __generator(this, function (_c) {
89
- switch (_c.label) {
90
- case 0:
91
- if (!id) {
92
- throw new Error('Preference ID is required');
93
- }
94
- if (typeof onboarding !== 'boolean') {
95
- throw new Error('Onboarding status must be a boolean');
96
- }
97
- preferenceData = {
98
- onboarding: onboarding,
99
- };
100
- where = {
101
- id: id,
102
- };
103
- return [4 /*yield*/, prisma.preference.upsert({
104
- create: __assign({ id: id }, preferenceData),
105
- update: preferenceData,
106
- where: where,
107
- })];
108
- case 1:
109
- preference = _c.sent();
110
- return [2 /*return*/, preference];
111
- }
112
- });
113
- }); };
114
- exports.updatePreference = updatePreference;
@@ -1,64 +0,0 @@
1
- import { ProductBE } from '../types';
2
- type PrismaClient = any;
3
- export interface ListProductArgs {
4
- buyPrice?: number;
5
- currentPage?: number;
6
- includeProductCategory?: boolean;
7
- includeQuotesInvoices?: boolean;
8
- orderByColumn?: string;
9
- orderByDirection?: 'asc' | 'desc';
10
- pageLimit?: number;
11
- prisma: PrismaClient;
12
- productCategoryId?: string;
13
- salePrice?: number;
14
- searchQuery?: string;
15
- }
16
- export interface UnitProductByIdArgs {
17
- id: string;
18
- prisma: PrismaClient;
19
- includeProductCategory?: boolean;
20
- includeQuotesInvoices?: boolean;
21
- }
22
- export interface UpdateProductArgs {
23
- buyPrice: string;
24
- currency: string;
25
- description?: string;
26
- id: string;
27
- images?: string[];
28
- include?: any;
29
- name: string;
30
- prisma: PrismaClient;
31
- productCategoryId: string;
32
- quantity: string;
33
- ref?: string;
34
- salePrice: string;
35
- }
36
- export interface DeleteProductArgs {
37
- id: string;
38
- prisma: PrismaClient;
39
- }
40
- /**
41
- * Retrieves a paginated list of products
42
- * @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
43
- * @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
44
- */
45
- export declare const listProduct: ({ buyPrice, currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, productCategoryId, salePrice, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
46
- /**
47
- * Retrieves a single product by its ID
48
- * @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
49
- * @returns {Promise<ProductBE | null>} Product or null if not found
50
- */
51
- export declare const unitProductById: ({ id, includeProductCategory, includeQuotesInvoices, prisma, }: UnitProductByIdArgs) => Promise<ProductBE | null>;
52
- /**
53
- * Creates or updates a product
54
- * @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
55
- * @returns {Promise<ProductBE>} Created or updated product
56
- */
57
- export declare const updateProduct: ({ buyPrice, currency, description, id, images, name, prisma, productCategoryId, quantity, ref, salePrice, }: UpdateProductArgs) => Promise<ProductBE>;
58
- /**
59
- * Deletes a product by ID
60
- * @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
61
- * @returns {Promise<ProductBE>} Deleted product
62
- */
63
- export declare const deleteProduct: ({ id, prisma, }: DeleteProductArgs) => Promise<ProductBE>;
64
- export {};
@@ -1,235 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
57
- };
58
- Object.defineProperty(exports, "__esModule", { value: true });
59
- exports.deleteProduct = exports.updateProduct = exports.unitProductById = exports.listProduct = void 0;
60
- var multi_part_search_1 = require("../../../general/multi-part-search");
61
- /**
62
- * Retrieves a paginated list of products
63
- * @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
64
- * @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
65
- */
66
- var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
67
- var include, orderBy, idSearchQuery, nameSearchQuery, refSearchQuery, where, _c, count, items;
68
- var _d;
69
- var _e = _b.buyPrice, buyPrice = _e === void 0 ? 0 : _e, _f = _b.currentPage, currentPage = _f === void 0 ? 1 : _f, _g = _b.includeProductCategory, includeProductCategory = _g === void 0 ? false : _g, _h = _b.includeQuotesInvoices, includeQuotesInvoices = _h === void 0 ? false : _h, _j = _b.orderByColumn, orderByColumn = _j === void 0 ? 'createdAt' : _j, _k = _b.orderByDirection, orderByDirection = _k === void 0 ? 'desc' : _k, _l = _b.pageLimit, pageLimit = _l === void 0 ? 5 : _l, prisma = _b.prisma, _m = _b.productCategoryId, productCategoryId = _m === void 0 ? '' : _m, _o = _b.salePrice, salePrice = _o === void 0 ? 0 : _o, _p = _b.searchQuery, searchQuery = _p === void 0 ? '' : _p;
70
- return __generator(this, function (_q) {
71
- switch (_q.label) {
72
- case 0:
73
- if (!currentPage || currentPage < 1) {
74
- throw new Error('Valid current page is required');
75
- }
76
- if (!pageLimit || pageLimit < 1) {
77
- throw new Error('Valid page limit is required');
78
- }
79
- include = {
80
- productCategory: includeProductCategory,
81
- quotesInvoices: includeQuotesInvoices,
82
- };
83
- orderBy = (_d = {},
84
- _d[orderByColumn] = orderByDirection,
85
- _d);
86
- idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
87
- columnName: 'id',
88
- fullText: searchQuery,
89
- });
90
- nameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
91
- columnName: 'name',
92
- fullText: searchQuery,
93
- });
94
- refSearchQuery = (0, multi_part_search_1.multiPartSearch)({
95
- columnName: 'ref',
96
- fullText: searchQuery,
97
- });
98
- where = {
99
- productCategoryId: productCategoryId || undefined,
100
- buyPrice: {
101
- lte: buyPrice || undefined,
102
- gte: buyPrice || undefined,
103
- },
104
- salePrice: {
105
- lte: salePrice || undefined,
106
- gte: salePrice || undefined,
107
- },
108
- OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), refSearchQuery, true),
109
- };
110
- return [4 /*yield*/, prisma.$transaction([
111
- prisma.product.count({
112
- where: where,
113
- }),
114
- prisma.product.findMany({
115
- include: include,
116
- orderBy: orderBy,
117
- skip: (currentPage - 1) * pageLimit,
118
- take: pageLimit,
119
- where: where,
120
- }),
121
- ])];
122
- case 1:
123
- _c = _q.sent(), count = _c[0], items = _c[1];
124
- return [2 /*return*/, [count, items]];
125
- }
126
- });
127
- }); };
128
- exports.listProduct = listProduct;
129
- /**
130
- * Retrieves a single product by its ID
131
- * @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
132
- * @returns {Promise<ProductBE | null>} Product or null if not found
133
- */
134
- var unitProductById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
135
- var include, where, product;
136
- var id = _b.id, _c = _b.includeProductCategory, includeProductCategory = _c === void 0 ? false : _c, _d = _b.includeQuotesInvoices, includeQuotesInvoices = _d === void 0 ? false : _d, prisma = _b.prisma;
137
- return __generator(this, function (_e) {
138
- switch (_e.label) {
139
- case 0:
140
- if (!id) {
141
- throw new Error('Product ID is required');
142
- }
143
- include = {
144
- productCategory: includeProductCategory,
145
- quotesInvoices: includeQuotesInvoices,
146
- };
147
- where = {
148
- id: id,
149
- };
150
- return [4 /*yield*/, prisma.product.findUnique({
151
- include: include,
152
- where: where,
153
- })];
154
- case 1:
155
- product = _e.sent();
156
- return [2 /*return*/, product];
157
- }
158
- });
159
- }); };
160
- exports.unitProductById = unitProductById;
161
- /**
162
- * Creates or updates a product
163
- * @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
164
- * @returns {Promise<ProductBE>} Created or updated product
165
- */
166
- var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
167
- var productData, where, product;
168
- var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, images = _b.images, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
169
- return __generator(this, function (_c) {
170
- switch (_c.label) {
171
- case 0:
172
- if (!id) {
173
- throw new Error('Product ID is required');
174
- }
175
- if (!buyPrice ||
176
- !currency ||
177
- !name ||
178
- !productCategoryId ||
179
- !quantity ||
180
- !salePrice) {
181
- throw new Error('Buy price, currency, name, product category ID, quantity, and sale price are required');
182
- }
183
- productData = {
184
- buyPrice: buyPrice,
185
- currency: currency,
186
- description: description || null,
187
- images: images || null,
188
- name: name,
189
- productCategoryId: productCategoryId,
190
- quantity: quantity,
191
- ref: ref || null,
192
- salePrice: salePrice,
193
- };
194
- where = {
195
- id: id,
196
- };
197
- return [4 /*yield*/, prisma.product.upsert({
198
- create: __assign({ id: id }, productData),
199
- update: productData,
200
- where: where,
201
- })];
202
- case 1:
203
- product = _c.sent();
204
- return [2 /*return*/, product];
205
- }
206
- });
207
- }); };
208
- exports.updateProduct = updateProduct;
209
- /**
210
- * Deletes a product by ID
211
- * @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
212
- * @returns {Promise<ProductBE>} Deleted product
213
- */
214
- var deleteProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
215
- var where, product;
216
- var id = _b.id, prisma = _b.prisma;
217
- return __generator(this, function (_c) {
218
- switch (_c.label) {
219
- case 0:
220
- if (!id) {
221
- throw new Error('Product ID is required');
222
- }
223
- where = {
224
- id: id,
225
- };
226
- return [4 /*yield*/, prisma.product.delete({
227
- where: where,
228
- })];
229
- case 1:
230
- product = _c.sent();
231
- return [2 /*return*/, product];
232
- }
233
- });
234
- }); };
235
- exports.deleteProduct = deleteProduct;