@shophost/rest-api 2.0.32 → 2.0.34

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 (348) hide show
  1. package/package.json +13 -14
  2. package/src/app.js +53 -1
  3. package/src/app.js.map +1 -0
  4. package/src/core/auth/auth.schema.js +41 -1
  5. package/src/core/auth/auth.schema.js.map +1 -0
  6. package/src/core/auth/auth.util.js +44 -1
  7. package/src/core/auth/auth.util.js.map +1 -0
  8. package/src/core/auth/better-auth.lib.js +100 -1
  9. package/src/core/auth/better-auth.lib.js.map +1 -0
  10. package/src/core/auth/generate-password-hash.util.d.ts +3 -0
  11. package/src/core/auth/generate-password-hash.util.js +30 -1
  12. package/src/core/auth/generate-password-hash.util.js.map +1 -0
  13. package/src/core/auth/headers.schema.js +22 -1
  14. package/src/core/auth/headers.schema.js.map +1 -0
  15. package/src/core/auth/user.schema.js +30 -1
  16. package/src/core/auth/user.schema.js.map +1 -0
  17. package/src/core/db/__generated__/client/browser.d.ts +128 -0
  18. package/src/core/db/__generated__/client/browser.js +18 -1
  19. package/src/core/db/__generated__/client/browser.js.map +1 -0
  20. package/src/core/db/__generated__/client/client.d.ts +143 -0
  21. package/src/core/db/__generated__/client/client.js +35 -1
  22. package/src/core/db/__generated__/client/client.js.map +1 -0
  23. package/src/core/db/__generated__/client/commonInputTypes.js +11 -1
  24. package/src/core/db/__generated__/client/commonInputTypes.js.map +1 -0
  25. package/src/core/db/__generated__/client/enums.js +200 -1
  26. package/src/core/db/__generated__/client/enums.js.map +1 -0
  27. package/src/core/db/__generated__/client/internal/class.d.ts +343 -0
  28. package/src/core/db/__generated__/client/internal/class.js +55 -1
  29. package/src/core/db/__generated__/client/internal/class.js.map +1 -0
  30. package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +234 -0
  31. package/src/core/db/__generated__/client/internal/prismaNamespace.js +541 -1
  32. package/src/core/db/__generated__/client/internal/prismaNamespace.js.map +1 -0
  33. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.d.ts +15 -0
  34. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +512 -1
  35. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js.map +1 -0
  36. package/src/core/db/__generated__/client/models/Account.d.ts +633 -0
  37. package/src/core/db/__generated__/client/models/Account.js +2 -1
  38. package/src/core/db/__generated__/client/models/Account.js.map +1 -0
  39. package/src/core/db/__generated__/client/models/Address.d.ts +706 -0
  40. package/src/core/db/__generated__/client/models/Address.js +2 -1
  41. package/src/core/db/__generated__/client/models/Address.js.map +1 -0
  42. package/src/core/db/__generated__/client/models/Campaign.d.ts +643 -0
  43. package/src/core/db/__generated__/client/models/Campaign.js +2 -1
  44. package/src/core/db/__generated__/client/models/Campaign.js.map +1 -0
  45. package/src/core/db/__generated__/client/models/ClosingTimes.d.ts +639 -0
  46. package/src/core/db/__generated__/client/models/ClosingTimes.js +2 -1
  47. package/src/core/db/__generated__/client/models/ClosingTimes.js.map +1 -0
  48. package/src/core/db/__generated__/client/models/File.d.ts +757 -0
  49. package/src/core/db/__generated__/client/models/File.js +2 -1
  50. package/src/core/db/__generated__/client/models/File.js.map +1 -0
  51. package/src/core/db/__generated__/client/models/Invitation.d.ts +633 -0
  52. package/src/core/db/__generated__/client/models/Invitation.js +2 -1
  53. package/src/core/db/__generated__/client/models/Invitation.js.map +1 -0
  54. package/src/core/db/__generated__/client/models/LegalEntity.d.ts +657 -0
  55. package/src/core/db/__generated__/client/models/LegalEntity.js +2 -1
  56. package/src/core/db/__generated__/client/models/LegalEntity.js.map +1 -0
  57. package/src/core/db/__generated__/client/models/Manufacturer.d.ts +684 -0
  58. package/src/core/db/__generated__/client/models/Manufacturer.js +2 -1
  59. package/src/core/db/__generated__/client/models/Manufacturer.js.map +1 -0
  60. package/src/core/db/__generated__/client/models/ManufacturerTranslation.d.ts +633 -0
  61. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +2 -1
  62. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js.map +1 -0
  63. package/src/core/db/__generated__/client/models/Member.d.ts +633 -0
  64. package/src/core/db/__generated__/client/models/Member.js +2 -1
  65. package/src/core/db/__generated__/client/models/Member.js.map +1 -0
  66. package/src/core/db/__generated__/client/models/Modifier.d.ts +667 -0
  67. package/src/core/db/__generated__/client/models/Modifier.js +2 -1
  68. package/src/core/db/__generated__/client/models/Modifier.js.map +1 -0
  69. package/src/core/db/__generated__/client/models/ModifierGroup.d.ts +691 -0
  70. package/src/core/db/__generated__/client/models/ModifierGroup.js +2 -1
  71. package/src/core/db/__generated__/client/models/ModifierGroup.js.map +1 -0
  72. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.d.ts +633 -0
  73. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +2 -1
  74. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js.map +1 -0
  75. package/src/core/db/__generated__/client/models/OpeningTimes.d.ts +639 -0
  76. package/src/core/db/__generated__/client/models/OpeningTimes.js +2 -1
  77. package/src/core/db/__generated__/client/models/OpeningTimes.js.map +1 -0
  78. package/src/core/db/__generated__/client/models/Order.d.ts +705 -0
  79. package/src/core/db/__generated__/client/models/Order.js +2 -1
  80. package/src/core/db/__generated__/client/models/Order.js.map +1 -0
  81. package/src/core/db/__generated__/client/models/OrderItem.d.ts +691 -0
  82. package/src/core/db/__generated__/client/models/OrderItem.js +2 -1
  83. package/src/core/db/__generated__/client/models/OrderItem.js.map +1 -0
  84. package/src/core/db/__generated__/client/models/OrderItemTranslation.d.ts +633 -0
  85. package/src/core/db/__generated__/client/models/OrderItemTranslation.js +2 -1
  86. package/src/core/db/__generated__/client/models/OrderItemTranslation.js.map +1 -0
  87. package/src/core/db/__generated__/client/models/Organization.d.ts +816 -0
  88. package/src/core/db/__generated__/client/models/Organization.js +2 -1
  89. package/src/core/db/__generated__/client/models/Organization.js.map +1 -0
  90. package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +681 -0
  91. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +2 -1
  92. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js.map +1 -0
  93. package/src/core/db/__generated__/client/models/Payment.d.ts +673 -0
  94. package/src/core/db/__generated__/client/models/Payment.js +2 -1
  95. package/src/core/db/__generated__/client/models/Payment.js.map +1 -0
  96. package/src/core/db/__generated__/client/models/PaymentSession.d.ts +643 -0
  97. package/src/core/db/__generated__/client/models/PaymentSession.js +2 -1
  98. package/src/core/db/__generated__/client/models/PaymentSession.js.map +1 -0
  99. package/src/core/db/__generated__/client/models/Product.d.ts +751 -0
  100. package/src/core/db/__generated__/client/models/Product.js +2 -1
  101. package/src/core/db/__generated__/client/models/Product.js.map +1 -0
  102. package/src/core/db/__generated__/client/models/ProductCategory.d.ts +694 -0
  103. package/src/core/db/__generated__/client/models/ProductCategory.js +2 -1
  104. package/src/core/db/__generated__/client/models/ProductCategory.js.map +1 -0
  105. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.d.ts +633 -0
  106. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +2 -1
  107. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js.map +1 -0
  108. package/src/core/db/__generated__/client/models/ProductSnapshot.d.ts +669 -0
  109. package/src/core/db/__generated__/client/models/ProductSnapshot.js +2 -1
  110. package/src/core/db/__generated__/client/models/ProductSnapshot.js.map +1 -0
  111. package/src/core/db/__generated__/client/models/ProductTranslation.d.ts +633 -0
  112. package/src/core/db/__generated__/client/models/ProductTranslation.js +2 -1
  113. package/src/core/db/__generated__/client/models/ProductTranslation.js.map +1 -0
  114. package/src/core/db/__generated__/client/models/Reservation.d.ts +655 -0
  115. package/src/core/db/__generated__/client/models/Reservation.js +2 -1
  116. package/src/core/db/__generated__/client/models/Reservation.js.map +1 -0
  117. package/src/core/db/__generated__/client/models/Session.d.ts +633 -0
  118. package/src/core/db/__generated__/client/models/Session.js +2 -1
  119. package/src/core/db/__generated__/client/models/Session.js.map +1 -0
  120. package/src/core/db/__generated__/client/models/ShippingMethod.d.ts +684 -0
  121. package/src/core/db/__generated__/client/models/ShippingMethod.js +2 -1
  122. package/src/core/db/__generated__/client/models/ShippingMethod.js.map +1 -0
  123. package/src/core/db/__generated__/client/models/ShippingZone.d.ts +643 -0
  124. package/src/core/db/__generated__/client/models/ShippingZone.js +2 -1
  125. package/src/core/db/__generated__/client/models/ShippingZone.js.map +1 -0
  126. package/src/core/db/__generated__/client/models/User.d.ts +741 -0
  127. package/src/core/db/__generated__/client/models/User.js +2 -1
  128. package/src/core/db/__generated__/client/models/User.js.map +1 -0
  129. package/src/core/db/__generated__/client/models/Verification.d.ts +597 -0
  130. package/src/core/db/__generated__/client/models/Verification.js +2 -1
  131. package/src/core/db/__generated__/client/models/Verification.js.map +1 -0
  132. package/src/core/db/__generated__/client/models.js +2 -1
  133. package/src/core/db/__generated__/client/models.js.map +1 -0
  134. package/src/core/db/index.js +2 -1
  135. package/src/core/db/index.js.map +1 -0
  136. package/src/core/exceptions/http-exception.js +9 -1
  137. package/src/core/exceptions/http-exception.js.map +1 -0
  138. package/src/core/hono/hono.js +123 -1
  139. package/src/core/hono/hono.js.map +1 -0
  140. package/src/core/lib/prisma.js +11 -1
  141. package/src/core/lib/prisma.js.map +1 -0
  142. package/src/core/logging/pino.js +5 -1
  143. package/src/core/logging/pino.js.map +1 -0
  144. package/src/core/notifications/email.service.d.ts +15 -0
  145. package/src/core/notifications/email.service.js +116 -1
  146. package/src/core/notifications/email.service.js.map +1 -0
  147. package/src/core/openapi/openapi.lib.js +26 -1
  148. package/src/core/openapi/openapi.lib.js.map +1 -0
  149. package/src/core/types/google-maps.types.js +2 -1
  150. package/src/core/types/google-maps.types.js.map +1 -0
  151. package/src/core/utils/currency.util.js +11 -1
  152. package/src/core/utils/currency.util.js.map +1 -0
  153. package/src/core/utils/env.util.js +8 -1
  154. package/src/core/utils/env.util.js.map +1 -0
  155. package/src/core/utils/object.util.d.ts +10 -0
  156. package/src/core/utils/object.util.js +39 -1
  157. package/src/core/utils/object.util.js.map +1 -0
  158. package/src/core/utils/translations.util.js +2 -0
  159. package/src/core/utils/translations.util.js.map +1 -0
  160. package/src/core/utils/zod.util.d.ts +12 -0
  161. package/src/core/utils/zod.util.js +85 -1
  162. package/src/core/utils/zod.util.js.map +1 -0
  163. package/src/db.js +3 -1
  164. package/src/db.js.map +1 -0
  165. package/src/features/access/access.handler.js +91 -1
  166. package/src/features/access/access.handler.js.map +1 -0
  167. package/src/features/access/access.route.js +220 -1
  168. package/src/features/access/access.route.js.map +1 -0
  169. package/src/features/access/access.schema.js +108 -1
  170. package/src/features/access/access.schema.js.map +1 -0
  171. package/src/features/access/access.service.js +294 -1
  172. package/src/features/access/access.service.js.map +1 -0
  173. package/src/features/cart/cart.handler.js +17 -1
  174. package/src/features/cart/cart.handler.js.map +1 -0
  175. package/src/features/cart/cart.route.js +32 -1
  176. package/src/features/cart/cart.route.js.map +1 -0
  177. package/src/features/cart/cart.schema.js +39 -1
  178. package/src/features/cart/cart.schema.js.map +1 -0
  179. package/src/features/cart/cart.service.d.ts +7 -0
  180. package/src/features/cart/cart.service.js +97 -1
  181. package/src/features/cart/cart.service.js.map +1 -0
  182. package/src/features/cart/cart.util.js +76 -1
  183. package/src/features/cart/cart.util.js.map +1 -0
  184. package/src/features/file/file.handler.js +23 -1
  185. package/src/features/file/file.handler.js.map +1 -0
  186. package/src/features/file/file.route.js +34 -1
  187. package/src/features/file/file.route.js.map +1 -0
  188. package/src/features/file/file.schema.js +77 -1
  189. package/src/features/file/file.schema.js.map +1 -0
  190. package/src/features/file/file.service.d.ts +6 -0
  191. package/src/features/file/file.service.js +66 -1
  192. package/src/features/file/file.service.js.map +1 -0
  193. package/src/features/health/health.handler.js +10 -1
  194. package/src/features/health/health.handler.js.map +1 -0
  195. package/src/features/health/health.route.js +25 -1
  196. package/src/features/health/health.route.js.map +1 -0
  197. package/src/features/index.js +16 -1
  198. package/src/features/index.js.map +1 -0
  199. package/src/features/location/location.handler.js +25 -1
  200. package/src/features/location/location.handler.js.map +1 -0
  201. package/src/features/location/location.route.js +56 -1
  202. package/src/features/location/location.route.js.map +1 -0
  203. package/src/features/location/location.schema.js +50 -1
  204. package/src/features/location/location.schema.js.map +1 -0
  205. package/src/features/location/location.service.d.ts +3 -0
  206. package/src/features/location/location.service.js +141 -1
  207. package/src/features/location/location.service.js.map +1 -0
  208. package/src/features/manufacturer/manufacturer.handler.js +53 -1
  209. package/src/features/manufacturer/manufacturer.handler.js.map +1 -0
  210. package/src/features/manufacturer/manufacturer.route.js +97 -1
  211. package/src/features/manufacturer/manufacturer.route.js.map +1 -0
  212. package/src/features/manufacturer/manufacturer.schema.js +125 -1
  213. package/src/features/manufacturer/manufacturer.schema.js.map +1 -0
  214. package/src/features/manufacturer/manufacturer.service.d.ts +19 -0
  215. package/src/features/manufacturer/manufacturer.service.js +190 -1
  216. package/src/features/manufacturer/manufacturer.service.js.map +1 -0
  217. package/src/features/order/emails/order-confirmation.email.js +229 -1
  218. package/src/features/order/emails/order-confirmation.email.js.map +1 -0
  219. package/src/features/order/emails/order-notification.email.js +229 -1
  220. package/src/features/order/emails/order-notification.email.js.map +1 -0
  221. package/src/features/order/fulfilment.schema.js +3 -1
  222. package/src/features/order/fulfilment.schema.js.map +1 -0
  223. package/src/features/order/order.handler.js +54 -1
  224. package/src/features/order/order.handler.js.map +1 -0
  225. package/src/features/order/order.route.js +111 -1
  226. package/src/features/order/order.route.js.map +1 -0
  227. package/src/features/order/order.schema.js +158 -1
  228. package/src/features/order/order.schema.js.map +1 -0
  229. package/src/features/order/order.service.d.ts +15 -0
  230. package/src/features/order/order.service.js +306 -1
  231. package/src/features/order/order.service.js.map +1 -0
  232. package/src/features/order/recipient.schema.js +38 -1
  233. package/src/features/order/recipient.schema.js.map +1 -0
  234. package/src/features/organization/legal-entity.schema.js +83 -1
  235. package/src/features/organization/legal-entity.schema.js.map +1 -0
  236. package/src/features/organization/organization-configuration.schema.js +115 -1
  237. package/src/features/organization/organization-configuration.schema.js.map +1 -0
  238. package/src/features/organization/organization.handler.js +48 -1
  239. package/src/features/organization/organization.handler.js.map +1 -0
  240. package/src/features/organization/organization.route.js +84 -1
  241. package/src/features/organization/organization.route.js.map +1 -0
  242. package/src/features/organization/organization.schema.js +64 -1
  243. package/src/features/organization/organization.schema.js.map +1 -0
  244. package/src/features/organization/organization.service.d.ts +15 -0
  245. package/src/features/organization/organization.service.js +334 -1
  246. package/src/features/organization/organization.service.js.map +1 -0
  247. package/src/features/payment/payment.handler.js +16 -1
  248. package/src/features/payment/payment.handler.js.map +1 -0
  249. package/src/features/payment/payment.route.js +22 -1
  250. package/src/features/payment/payment.route.js.map +1 -0
  251. package/src/features/payment/payment.schema.js +46 -1
  252. package/src/features/payment/payment.schema.js.map +1 -0
  253. package/src/features/payment/payment.service.js +100 -1
  254. package/src/features/payment/payment.service.js.map +1 -0
  255. package/src/features/payment/stripe.service.js +164 -1
  256. package/src/features/payment/stripe.service.js.map +1 -0
  257. package/src/features/product/product-modifier.schema.js +84 -1
  258. package/src/features/product/product-modifier.schema.js.map +1 -0
  259. package/src/features/product/product.handler.js +87 -1
  260. package/src/features/product/product.handler.js.map +1 -0
  261. package/src/features/product/product.route.js +179 -1
  262. package/src/features/product/product.route.js.map +1 -0
  263. package/src/features/product/product.schema.js +143 -1
  264. package/src/features/product/product.schema.js.map +1 -0
  265. package/src/features/product/product.service.d.ts +25 -0
  266. package/src/features/product/product.service.js +440 -1
  267. package/src/features/product/product.service.js.map +1 -0
  268. package/src/features/product-category/product-category.handler.js +59 -1
  269. package/src/features/product-category/product-category.handler.js.map +1 -0
  270. package/src/features/product-category/product-category.route.js +139 -1
  271. package/src/features/product-category/product-category.route.js.map +1 -0
  272. package/src/features/product-category/product-category.schema.js +86 -1
  273. package/src/features/product-category/product-category.schema.js.map +1 -0
  274. package/src/features/product-category/product-category.service.d.ts +22 -0
  275. package/src/features/product-category/product-category.service.js +220 -1
  276. package/src/features/product-category/product-category.service.js.map +1 -0
  277. package/src/features/reservation/emails/reservation-cancellation.email.js +82 -1
  278. package/src/features/reservation/emails/reservation-cancellation.email.js.map +1 -0
  279. package/src/features/reservation/emails/reservation-confirmation.email.js +82 -1
  280. package/src/features/reservation/emails/reservation-confirmation.email.js.map +1 -0
  281. package/src/features/reservation/emails/reservation-notification.email.js +93 -1
  282. package/src/features/reservation/emails/reservation-notification.email.js.map +1 -0
  283. package/src/features/reservation/reservation.handler.js +65 -1
  284. package/src/features/reservation/reservation.handler.js.map +1 -0
  285. package/src/features/reservation/reservation.route.js +167 -1
  286. package/src/features/reservation/reservation.route.js.map +1 -0
  287. package/src/features/reservation/reservation.schema.js +51 -1
  288. package/src/features/reservation/reservation.schema.js.map +1 -0
  289. package/src/features/reservation/reservation.service.d.ts +18 -0
  290. package/src/features/reservation/reservation.service.js +231 -1
  291. package/src/features/reservation/reservation.service.js.map +1 -0
  292. package/src/features/shipping/shipping.handler.js +32 -1
  293. package/src/features/shipping/shipping.handler.js.map +1 -0
  294. package/src/features/shipping/shipping.route.js +51 -1
  295. package/src/features/shipping/shipping.route.js.map +1 -0
  296. package/src/features/shipping/shipping.service.d.ts +7 -0
  297. package/src/features/shipping/shipping.service.js +96 -1
  298. package/src/features/shipping/shipping.service.js.map +1 -0
  299. package/src/features/shipping-method/shipping-method.handler.js +60 -1
  300. package/src/features/shipping-method/shipping-method.handler.js.map +1 -0
  301. package/src/features/shipping-method/shipping-method.route.js +144 -1
  302. package/src/features/shipping-method/shipping-method.route.js.map +1 -0
  303. package/src/features/shipping-method/shipping-method.schema.js +48 -1
  304. package/src/features/shipping-method/shipping-method.schema.js.map +1 -0
  305. package/src/features/shipping-method/shipping-method.service.d.ts +25 -0
  306. package/src/features/shipping-method/shipping-method.service.js +229 -1
  307. package/src/features/shipping-method/shipping-method.service.js.map +1 -0
  308. package/src/features/shipping-method/shipping-zone.schema.js +31 -1
  309. package/src/features/shipping-method/shipping-zone.schema.js.map +1 -0
  310. package/src/features/webhook/webhook.handler.js +50 -1
  311. package/src/features/webhook/webhook.handler.js.map +1 -0
  312. package/src/features/webhook/webhook.route.js +33 -1
  313. package/src/features/webhook/webhook.route.js.map +1 -0
  314. package/src/index.js +6 -1
  315. package/src/index.js.map +1 -0
  316. package/src/integrations/next.js +82 -1
  317. package/src/integrations/next.js.map +1 -0
  318. package/src/schemas/address.schema.d.ts +8 -0
  319. package/src/schemas/address.schema.js +112 -1
  320. package/src/schemas/address.schema.js.map +1 -0
  321. package/src/schemas/currency.schema.d.ts +42 -0
  322. package/src/schemas/currency.schema.js +118 -1
  323. package/src/schemas/currency.schema.js.map +1 -0
  324. package/src/schemas/error.schema.js +12 -1
  325. package/src/schemas/error.schema.js.map +1 -0
  326. package/src/schemas/index.js +29 -1
  327. package/src/schemas/index.js.map +1 -0
  328. package/src/schemas/locales.schema.js +238 -1
  329. package/src/schemas/locales.schema.js.map +1 -0
  330. package/src/schemas/number.schema.js +29 -1
  331. package/src/schemas/number.schema.js.map +1 -0
  332. package/src/schemas/pagination.schema.js +54 -1
  333. package/src/schemas/pagination.schema.js.map +1 -0
  334. package/src/schemas/params.schema.js +20 -1
  335. package/src/schemas/params.schema.js.map +1 -0
  336. package/src/schemas/queries.schema.js +6 -1
  337. package/src/schemas/queries.schema.js.map +1 -0
  338. package/src/test/global-setup.js +37 -1
  339. package/src/test/global-setup.js.map +1 -0
  340. package/src/test/integration/api-fixtures.js +160 -1
  341. package/src/test/integration/api-fixtures.js.map +1 -0
  342. package/src/test/integration/seed.js +368 -1
  343. package/src/test/integration/seed.js.map +1 -0
  344. package/src/test/integration/test-helpers.js +154 -1
  345. package/src/test/integration/test-helpers.js.map +1 -0
  346. package/src/test/setup-test-env.js +7 -1
  347. package/src/test/setup-test-env.js.map +1 -0
  348. package/scripts/minify.mjs +0 -123
@@ -1 +1,60 @@
1
- import{__awaiter as i}from"tslib";import{createApiRouter as e}from"../../core/hono/hono";import{shippingMethodRoute as o}from"./shipping-method.route";import{ShippingMethodService as n}from"./shipping-method.service";export const buildShippingMethodHandler=t=>{const d=e();return d.openapi(o.createShippingMethod,e=>i(void 0,void 0,void 0,function*(){const i=e.get("auth"),o=e.req.valid("param"),d=e.req.valid("json"),a=yield i.isGranted("create"),r=new n(t),p=yield r.createShippingMethod(o.organizationId,a.id,d);return e.json(p,201)})),d.openapi(o.getShippingMethod,e=>i(void 0,void 0,void 0,function*(){const i=e.get("auth"),o=e.req.valid("param");yield i.isGranted("read");const d=new n(t),a=yield d.getShippingMethod(o.organizationId,o.id);return e.json(a,200)})),d.openapi(o.accessEligibility,e=>i(void 0,void 0,void 0,function*(){const i=e.get("auth"),o=e.req.valid("param"),d=yield i.getCurrentUser(),a=new n(t),r=yield a.accessEligibility(d,o.organizationId);return e.json(r,200)})),d.openapi(o.getShippingMethods,e=>i(void 0,void 0,void 0,function*(){const i=e.get("auth"),o=e.req.valid("param"),d=e.req.valid("query");yield i.isGranted("read");const a=new n(t),r=yield a.getShippingMethods(o.organizationId,Object.assign({},d));return e.json(r,200)})),d.openapi(o.updateShippingMethod,e=>i(void 0,void 0,void 0,function*(){const i=e.get("auth"),o=e.req.valid("param"),d=e.req.valid("json"),a=yield i.isGranted("update"),r=new n(t),p=yield r.updateShippingMethod(o.organizationId,o.id,a.id,d);return e.json(p,200)})),d.openapi(o.deleteShippingMethod,e=>i(void 0,void 0,void 0,function*(){const i=e.get("auth"),o=e.req.valid("param"),d=yield i.isGranted("delete"),a=new n(t);return yield a.deleteShippingMethod(o.organizationId,o.id,d.id),e.body(null,204)})),d};
1
+ import { __awaiter } from "tslib";
2
+ import { createApiRouter } from "../../core/hono/hono";
3
+ import { shippingMethodRoute } from "./shipping-method.route";
4
+ import { ShippingMethodService } from "./shipping-method.service";
5
+ export const buildShippingMethodHandler = (prisma) => {
6
+ const app = createApiRouter();
7
+ app.openapi(shippingMethodRoute.createShippingMethod, (c) => __awaiter(void 0, void 0, void 0, function* () {
8
+ const auth = c.get("auth");
9
+ const params = c.req.valid("param");
10
+ const body = c.req.valid("json");
11
+ const user = yield auth.isGranted("create");
12
+ const service = new ShippingMethodService(prisma);
13
+ const shippingMethod = yield service.createShippingMethod(params.organizationId, user.id, body);
14
+ return c.json(shippingMethod, 201);
15
+ }));
16
+ app.openapi(shippingMethodRoute.getShippingMethod, (c) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const auth = c.get("auth");
18
+ const params = c.req.valid("param");
19
+ yield auth.isGranted("read");
20
+ const service = new ShippingMethodService(prisma);
21
+ const shippingMethod = yield service.getShippingMethod(params.organizationId, params.id);
22
+ return c.json(shippingMethod, 200);
23
+ }));
24
+ app.openapi(shippingMethodRoute.accessEligibility, (c) => __awaiter(void 0, void 0, void 0, function* () {
25
+ const auth = c.get("auth");
26
+ const params = c.req.valid("param");
27
+ const user = yield auth.getCurrentUser();
28
+ const service = new ShippingMethodService(prisma);
29
+ const shippingMethods = yield service.accessEligibility(user, params.organizationId);
30
+ return c.json(shippingMethods, 200);
31
+ }));
32
+ app.openapi(shippingMethodRoute.getShippingMethods, (c) => __awaiter(void 0, void 0, void 0, function* () {
33
+ const auth = c.get("auth");
34
+ const params = c.req.valid("param");
35
+ const query = c.req.valid("query");
36
+ yield auth.isGranted("read");
37
+ const service = new ShippingMethodService(prisma);
38
+ const result = yield service.getShippingMethods(params.organizationId, Object.assign({}, query));
39
+ return c.json(result, 200);
40
+ }));
41
+ app.openapi(shippingMethodRoute.updateShippingMethod, (c) => __awaiter(void 0, void 0, void 0, function* () {
42
+ const auth = c.get("auth");
43
+ const params = c.req.valid("param");
44
+ const body = c.req.valid("json");
45
+ const user = yield auth.isGranted("update");
46
+ const service = new ShippingMethodService(prisma);
47
+ const updatedShippingMethod = yield service.updateShippingMethod(params.organizationId, params.id, user.id, body);
48
+ return c.json(updatedShippingMethod, 200);
49
+ }));
50
+ app.openapi(shippingMethodRoute.deleteShippingMethod, (c) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const auth = c.get("auth");
52
+ const params = c.req.valid("param");
53
+ const user = yield auth.isGranted("delete");
54
+ const service = new ShippingMethodService(prisma);
55
+ yield service.deleteShippingMethod(params.organizationId, params.id, user.id);
56
+ return c.body(null, 204);
57
+ }));
58
+ return app;
59
+ };
60
+ //# sourceMappingURL=shipping-method.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-method.handler.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/shipping-method/shipping-method.handler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAAwB,EAAE,EAAE;IACrE,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;IAE9B,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,CAAO,CAAM,EAAE,EAAE;QACrE,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE5C,MAAM,OAAO,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,oBAAoB,CACvD,MAAM,CAAC,cAAc,EACrB,IAAI,CAAC,EAAE,EACP,IAAI,CACL,CAAC;QAEF,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC,CAAA,CAAC,CAAC;IAEH,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,CA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,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE5C,MAAM,OAAO,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,OAAO,CAAC,oBAAoB,CAChC,MAAM,CAAC,cAAc,EACrB,MAAM,CAAC,EAAE,EACT,IAAI,CAAC,EAAE,CACR,CAAC;QAEF,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC,CAAA,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -1 +1,144 @@
1
- import{z as i}from"@hono/zod-openapi";import{createApiRoute as e}from"../../core/hono/hono";import{CreateShippingMethodSchema as t,ErrorSchema as o,HeaderSchema as a,OrganizationParams as p,OrganizationWithIdParams as n,PaginationMetaSchema as h,PaginationQuerySchema as s,ShippingMethodSchema as d,UpdateShippingMethodSchema as r}from"../../schemas";const g=i.object({id:i.string().openapi({description:"ID of the shipping method",example:"clf9876543210abcdef",param:{in:"path",name:"id"}}),organizationId:i.string().openapi({description:"ID of the organization",example:"cju0z9k4z0000l1qg5z1z1z1z",param:{in:"path",name:"organizationId"}})}),m=e({headers:a,method:"GET",operationId:"getShippingMethod",path:"/:organizationId/shipping-methods/:id",pathParams:n,responses:{200:d,401:o,404:o},summary:"Get Shipping Method",tags:["ShippingMethod"]}),z=e({description:"Fetches a list of published shipping methods a user can use",headers:a,method:"GET",operationId:"accessEligibility",path:"/:organizationId/shipping-methods/access/eligibility",pathParams:p,responses:{200:i.array(d)},summary:"Get Eligible Shipping Methods",tags:["ShippingMethod"]}),c=e({description:"Fetches a paginated list of shipping methods for an organization",headers:a,method:"GET",operationId:"getShippingMethods",path:"/:organizationId/shipping-methods",pathParams:i.object({organizationId:i.string().openapi({description:"ID of the organization",example:"cju0z9k4z0000l1qg5z1z1z1z",param:{in:"path",name:"organizationId"}})}),query:s,responses:{200:i.object({list:i.array(d),meta:h}),400:o,401:o},summary:"Get Shipping Methods",tags:["ShippingMethod"]}),l=e({body:t,description:"Creates a new shipping method for an organization",headers:a,method:"POST",operationId:"createShippingMethod",path:"/:organizationId/shipping-methods",pathParams:i.object({organizationId:i.string().openapi({description:"ID of the organization",example:"cju0z9k4z0000l1qg5z1z1z1z",param:{in:"path",name:"organizationId"}})}),responses:{201:d,400:o,401:o,404:o},summary:"Create Shipping Method",tags:["ShippingMethod"]}),S=e({body:r,description:"Updates an existing shipping method",headers:a,method:"PUT",operationId:"updateShippingMethod",path:"/:organizationId/shipping-methods/:id",pathParams:g,responses:{200:d,400:o,401:o,404:o},summary:"Update Shipping Method",tags:["ShippingMethod"]}),M=e({description:"Soft deletes a shipping method",headers:a,method:"DELETE",operationId:"deleteShippingMethod",path:"/:organizationId/shipping-methods/:id",pathParams:g,responses:{204:null,400:o,401:o,404:o},summary:"Delete Shipping Method",tags:["ShippingMethod"]});export const shippingMethodRoute={getShippingMethod:m,accessEligibility:z,getShippingMethods:c,createShippingMethod:l,updateShippingMethod:S,deleteShippingMethod:M};
1
+ import { z } from "@hono/zod-openapi";
2
+ import { createApiRoute } from "../../core/hono/hono";
3
+ import { CreateShippingMethodSchema, ErrorSchema, HeaderSchema, OrganizationParams, OrganizationWithIdParams, PaginationMetaSchema, PaginationQuerySchema, ShippingMethodSchema, UpdateShippingMethodSchema, } from "../../schemas";
4
+ const shippingMethodPathParams = z.object({
5
+ id: z.string().openapi({
6
+ description: "ID of the shipping method",
7
+ example: "clf9876543210abcdef",
8
+ param: {
9
+ in: "path",
10
+ name: "id",
11
+ },
12
+ }),
13
+ organizationId: z.string().openapi({
14
+ description: "ID of the organization",
15
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
16
+ param: {
17
+ in: "path",
18
+ name: "organizationId",
19
+ },
20
+ }),
21
+ });
22
+ const getShippingMethodRoute = createApiRoute({
23
+ headers: HeaderSchema,
24
+ method: "GET",
25
+ operationId: "getShippingMethod",
26
+ path: "/:organizationId/shipping-methods/:id",
27
+ pathParams: OrganizationWithIdParams,
28
+ responses: {
29
+ 200: ShippingMethodSchema,
30
+ 401: ErrorSchema,
31
+ 404: ErrorSchema,
32
+ },
33
+ summary: "Get Shipping Method",
34
+ tags: ["ShippingMethod"],
35
+ });
36
+ const accessEligibilityRoute = createApiRoute({
37
+ description: "Fetches a list of published shipping methods a user can use",
38
+ headers: HeaderSchema,
39
+ method: "GET",
40
+ operationId: "accessEligibility",
41
+ path: "/:organizationId/shipping-methods/access/eligibility",
42
+ pathParams: OrganizationParams,
43
+ responses: {
44
+ 200: z.array(ShippingMethodSchema),
45
+ },
46
+ summary: "Get Eligible Shipping Methods",
47
+ tags: ["ShippingMethod"],
48
+ });
49
+ const getShippingMethodsRoute = createApiRoute({
50
+ description: "Fetches a paginated list of shipping methods for an organization",
51
+ headers: HeaderSchema,
52
+ method: "GET",
53
+ operationId: "getShippingMethods",
54
+ path: "/:organizationId/shipping-methods",
55
+ pathParams: z.object({
56
+ organizationId: z.string().openapi({
57
+ description: "ID of the organization",
58
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
59
+ param: {
60
+ in: "path",
61
+ name: "organizationId",
62
+ },
63
+ }),
64
+ }),
65
+ query: PaginationQuerySchema,
66
+ responses: {
67
+ 200: z.object({
68
+ list: z.array(ShippingMethodSchema),
69
+ meta: PaginationMetaSchema,
70
+ }),
71
+ 400: ErrorSchema,
72
+ 401: ErrorSchema,
73
+ },
74
+ summary: "Get Shipping Methods",
75
+ tags: ["ShippingMethod"],
76
+ });
77
+ const createShippingMethodRoute = createApiRoute({
78
+ body: CreateShippingMethodSchema,
79
+ description: "Creates a new shipping method for an organization",
80
+ headers: HeaderSchema,
81
+ method: "POST",
82
+ operationId: "createShippingMethod",
83
+ path: "/:organizationId/shipping-methods",
84
+ pathParams: z.object({
85
+ organizationId: z.string().openapi({
86
+ description: "ID of the organization",
87
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
88
+ param: {
89
+ in: "path",
90
+ name: "organizationId",
91
+ },
92
+ }),
93
+ }),
94
+ responses: {
95
+ 201: ShippingMethodSchema,
96
+ 400: ErrorSchema,
97
+ 401: ErrorSchema,
98
+ 404: ErrorSchema,
99
+ },
100
+ summary: "Create Shipping Method",
101
+ tags: ["ShippingMethod"],
102
+ });
103
+ const updateShippingMethodRoute = createApiRoute({
104
+ body: UpdateShippingMethodSchema,
105
+ description: "Updates an existing shipping method",
106
+ headers: HeaderSchema,
107
+ method: "PUT",
108
+ operationId: "updateShippingMethod",
109
+ path: "/:organizationId/shipping-methods/:id",
110
+ pathParams: shippingMethodPathParams,
111
+ responses: {
112
+ 200: ShippingMethodSchema,
113
+ 400: ErrorSchema,
114
+ 401: ErrorSchema,
115
+ 404: ErrorSchema,
116
+ },
117
+ summary: "Update Shipping Method",
118
+ tags: ["ShippingMethod"],
119
+ });
120
+ const deleteShippingMethodRoute = createApiRoute({
121
+ description: "Soft deletes a shipping method",
122
+ headers: HeaderSchema,
123
+ method: "DELETE",
124
+ operationId: "deleteShippingMethod",
125
+ path: "/:organizationId/shipping-methods/:id",
126
+ pathParams: shippingMethodPathParams,
127
+ responses: {
128
+ 204: null,
129
+ 400: ErrorSchema,
130
+ 401: ErrorSchema,
131
+ 404: ErrorSchema,
132
+ },
133
+ summary: "Delete Shipping Method",
134
+ tags: ["ShippingMethod"],
135
+ });
136
+ export const shippingMethodRoute = {
137
+ getShippingMethod: getShippingMethodRoute,
138
+ accessEligibility: accessEligibilityRoute,
139
+ getShippingMethods: getShippingMethodsRoute,
140
+ createShippingMethod: createShippingMethodRoute,
141
+ updateShippingMethod: updateShippingMethodRoute,
142
+ deleteShippingMethod: deleteShippingMethodRoute,
143
+ };
144
+ //# sourceMappingURL=shipping-method.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-method.route.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/shipping-method/shipping-method.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,0BAA0B,EAC1B,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAEvB,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACrB,WAAW,EAAE,2BAA2B;QACxC,OAAO,EAAE,qBAAqB;QAC9B,KAAK,EAAE;YACL,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,IAAI;SACX;KACF,CAAC;IACF,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACjC,WAAW,EAAE,wBAAwB;QACrC,OAAO,EAAE,2BAA2B;QACpC,KAAK,EAAE;YACL,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,gBAAgB;SACvB;KACF,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,cAAc,CAAC;IAC5C,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,mBAAmB;IAChC,IAAI,EAAE,uCAAuC;IAC7C,UAAU,EAAE,wBAAwB;IACpC,SAAS,EAAE;QACT,GAAG,EAAE,oBAAoB;QACzB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;KACjB;IACD,OAAO,EAAE,qBAAqB;IAC9B,IAAI,EAAE,CAAC,gBAAgB,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,cAAc,CAAC;IAC5C,WAAW,EAAE,6DAA6D;IAC1E,OAAO,E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,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,iBAAiB,EAAE,sBAAsB;IACzC,iBAAiB,EAAE,sBAAsB;IACzC,kBAAkB,EAAE,uBAAuB;IAC3C,oBAAoB,EAAE,yBAAyB;IAC/C,oBAAoB,EAAE,yBAAyB;IAC/C,oBAAoB,EAAE,yBAAyB;CAChD,CAAC"}
@@ -1 +1,48 @@
1
- import{z as e}from"@hono/zod-openapi";import{FileSchema as i}from"../file/file.schema";import{ShippingZoneSchema as p}from"./shipping-zone.schema";export const ShippingMethodSchema=e.object({id:e.string().openapi({example:"clf9876543210abcdef",description:"ID of the shipping method"}),title:e.string().min(1,"Title is required").openapi({example:"Standard Shipping",description:"Title of the shipping method"}),providerName:e.string().min(1,"Provider name is required").openapi({example:"FedEx",description:"Name of the shipping provider"}),providerLogo:i.nullable().optional().openapi({description:"Logo of the shipping provider"}),requireDateOfDelivery:e.coerce.boolean().optional().openapi({example:!0,description:"Whether the delivery time should be selected"}),shippingZones:e.array(p).openapi({description:"List of shipping zones for this shipping method"}),eligibleShippingZone:p.optional(),createdAt:e.date(),updatedAt:e.date()}).openapi("ShippingMethod");export const CreateShippingMethodSchema=ShippingMethodSchema.pick({title:!0,providerName:!0,providerLogo:!0,requireDateOfDelivery:!0,shippingZones:!0}).extend({providerLogoId:e.string().cuid().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the provider logo file"})}).openapi("CreateShippingMethod");export const UpdateShippingMethodSchema=CreateShippingMethodSchema.partial().openapi("UpdateShippingMethod");
1
+ import { z } from "@hono/zod-openapi";
2
+ import { FileSchema } from "../file/file.schema";
3
+ import { ShippingZoneSchema } from "./shipping-zone.schema";
4
+ export const ShippingMethodSchema = z
5
+ .object({
6
+ id: z.string().openapi({
7
+ example: "clf9876543210abcdef",
8
+ description: "ID of the shipping method",
9
+ }),
10
+ title: z.string().min(1, "Title is required").openapi({
11
+ example: "Standard Shipping",
12
+ description: "Title of the shipping method",
13
+ }),
14
+ providerName: z.string().min(1, "Provider name is required").openapi({
15
+ example: "FedEx",
16
+ description: "Name of the shipping provider",
17
+ }),
18
+ providerLogo: FileSchema.nullable().optional().openapi({
19
+ description: "Logo of the shipping provider",
20
+ }),
21
+ requireDateOfDelivery: z.coerce.boolean().optional().openapi({
22
+ example: true,
23
+ description: "Whether the delivery time should be selected",
24
+ }),
25
+ shippingZones: z.array(ShippingZoneSchema).openapi({
26
+ description: "List of shipping zones for this shipping method",
27
+ }),
28
+ eligibleShippingZone: ShippingZoneSchema.optional(),
29
+ createdAt: z.date(),
30
+ updatedAt: z.date(),
31
+ })
32
+ .openapi("ShippingMethod");
33
+ export const CreateShippingMethodSchema = ShippingMethodSchema.pick({
34
+ title: true,
35
+ providerName: true,
36
+ providerLogo: true,
37
+ requireDateOfDelivery: true,
38
+ shippingZones: true,
39
+ })
40
+ .extend({
41
+ providerLogoId: z.string().cuid().optional().openapi({
42
+ example: "clf9876543210abcdef",
43
+ description: "ID reference to the provider logo file",
44
+ }),
45
+ })
46
+ .openapi("CreateShippingMethod");
47
+ export const UpdateShippingMethodSchema = CreateShippingMethodSchema.partial().openapi("UpdateShippingMethod");
48
+ //# sourceMappingURL=shipping-method.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-method.schema.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/shipping-method/shipping-method.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,qBAAqB;QAC9B,WAAW,EAAE,2BAA2B;KACzC,CAAC;IACF,KAAK,EAA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;QAC9B,WAAW,EAAE,wCAAwC;KACtD,CAAC;CACH,CAAC;KACD,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,0BAA0B,GACrC,0BAA0B,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC"}
@@ -4,8 +4,18 @@ import { CreateShippingMethodSchema, UpdateShippingMethodSchema, User } from "..
4
4
  declare class ShippingMethodService {
5
5
  private readonly prisma;
6
6
  constructor(prisma: PrismaClientType);
7
+ /**
8
+ * Find a shipping method by ID and organization ID
9
+ * @throws HttpException with 404 status if shipping method is not found
10
+ */
7
11
  private findShippingMethod;
12
+ /**
13
+ * Find the distance between two coordinates
14
+ */
8
15
  private findDistanceBetweenCoordinates;
16
+ /**
17
+ * Get a list of eligible shipping methods for a user
18
+ */
9
19
  accessEligibility(user: User, organizationId: string): Promise<{
10
20
  id: string;
11
21
  title: string;
@@ -37,6 +47,9 @@ declare class ShippingMethodService {
37
47
  id?: string | undefined;
38
48
  } | undefined;
39
49
  }[]>;
50
+ /**
51
+ * Create a new shipping method
52
+ */
40
53
  createShippingMethod(organizationId: string, userId: string, body: z.infer<typeof CreateShippingMethodSchema>): Promise<{
41
54
  id: string;
42
55
  title: string;
@@ -68,6 +81,9 @@ declare class ShippingMethodService {
68
81
  id?: string | undefined;
69
82
  } | undefined;
70
83
  }>;
84
+ /**
85
+ * Get a shipping method by ID
86
+ */
71
87
  getShippingMethod(organizationId: string, id: string): Promise<{
72
88
  id: string;
73
89
  title: string;
@@ -99,6 +115,9 @@ declare class ShippingMethodService {
99
115
  id?: string | undefined;
100
116
  } | undefined;
101
117
  }>;
118
+ /**
119
+ * Get a paginated list of shipping methods
120
+ */
102
121
  getShippingMethods(organizationId: string, query: {
103
122
  page?: number;
104
123
  limit?: number;
@@ -145,6 +164,9 @@ declare class ShippingMethodService {
145
164
  } | undefined;
146
165
  }[];
147
166
  }>;
167
+ /**
168
+ * Update a shipping method
169
+ */
148
170
  updateShippingMethod(organizationId: string, id: string, userId: string, body: z.infer<typeof UpdateShippingMethodSchema>): Promise<{
149
171
  id: string;
150
172
  title: string;
@@ -176,6 +198,9 @@ declare class ShippingMethodService {
176
198
  id?: string | undefined;
177
199
  } | undefined;
178
200
  }>;
201
+ /**
202
+ * Delete a shipping method (soft delete)
203
+ */
179
204
  deleteShippingMethod(organizationId: string, id: string, userId: string): Promise<void>;
180
205
  }
181
206
  export { ShippingMethodService };
@@ -1 +1,229 @@
1
- import{__awaiter as i}from"tslib";import{z as e}from"@hono/zod-openapi";import{HttpException as t}from"../../core/exceptions/http-exception";import{PaginationMetaSchema as n,ShippingMethodSchema as o}from"../../schemas";class d{constructor(i){this.prisma=i}findShippingMethod(e,n,o){return i(this,void 0,void 0,function*(){const i=yield this.prisma.shippingMethod.findUnique({where:{id:e,organizationId:n},include:null==o?void 0:o.include});if(!i)throw new t(404,"Shipping method not found");return i})}findDistanceBetweenCoordinates(i,e){const t=i=>i*(Math.PI/180),n=t(e.latitude-i.latitude),o=t(e.longitude-i.longitude),d=t(i.latitude),r=t(e.latitude),s=Math.sin(n/2)*Math.sin(n/2)+Math.cos(d)*Math.cos(r)*Math.sin(o/2)*Math.sin(o/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371}accessEligibility(e,n){return i(this,void 0,void 0,function*(){const i=yield this.prisma.organization.findUnique({where:{id:n},include:{address:!0}});if(!i)throw new t(404,"Organization not found");const d=yield this.prisma.address.findFirst({where:{users:{some:{id:e.id}},isDefault:!0}});if(!d)throw new t(404,"User shipping address not found");return(yield this.prisma.shippingMethod.findMany({where:{organizationId:n},include:{shippingZones:!0}})).map(e=>{const t=this.findDistanceBetweenCoordinates({latitude:i.address.latitude,longitude:i.address.longitude},{latitude:d.latitude,longitude:d.longitude}),n=e.shippingZones.find(({distanceUpto:i})=>t<=i);return o.parse(Object.assign(Object.assign({},e),{eligibleShippingZone:n}))})})}createShippingMethod(e,t,n){return i(this,void 0,void 0,function*(){const i=yield this.prisma.shippingMethod.create({data:{title:n.title,providerName:n.providerName,providerLogoId:n.providerLogoId,requireDateOfDelivery:n.requireDateOfDelivery,organizationId:e,shippingZones:{create:n.shippingZones},createdBy:t},include:{shippingZones:!0,providerLogo:!0}});return o.parse(i)})}getShippingMethod(e,t){return i(this,void 0,void 0,function*(){const i=yield this.findShippingMethod(t,e,{include:{providerLogo:!0,shippingZones:!0}});return o.parse(i)})}getShippingMethods(t,d){return i(this,void 0,void 0,function*(){const{page:i=1,limit:r=10,search:s}=d,[a,p]=yield this.prisma.shippingMethod.paginate({orderBy:{createdAt:"desc"},where:Object.assign({organizationId:t},s&&{title:{contains:s,mode:"insensitive"}}),include:{shippingZones:!0,providerLogo:!0}}).withPages({page:i,limit:r});return e.object({meta:n,list:e.array(o)}).parse({meta:p,list:a})})}updateShippingMethod(e,t,n,d){return i(this,void 0,void 0,function*(){yield this.findShippingMethod(t,e);const i=yield this.prisma.shippingMethod.update({where:{id:t,organizationId:e},data:{title:d.title,providerName:d.providerName,providerLogoId:d.providerLogoId,requireDateOfDelivery:d.requireDateOfDelivery,shippingZones:{deleteMany:{},create:d.shippingZones},updatedBy:n},include:{providerLogo:!0,shippingZones:!0}});return o.parse(i)})}deleteShippingMethod(e,t,n){return i(this,void 0,void 0,function*(){yield this.findShippingMethod(t,e),yield this.prisma.shippingMethod.update({where:{id:t,organizationId:e},data:{archivedAt:new Date,archivedBy:n}})})}}export{d as ShippingMethodService};
1
+ import { __awaiter } from "tslib";
2
+ import { z } from "@hono/zod-openapi";
3
+ import { HttpException } from "../../core/exceptions/http-exception";
4
+ import { PaginationMetaSchema, ShippingMethodSchema, } from "../../schemas";
5
+ class ShippingMethodService {
6
+ constructor(prisma) {
7
+ this.prisma = prisma;
8
+ }
9
+ /**
10
+ * Find a shipping method by ID and organization ID
11
+ * @throws HttpException with 404 status if shipping method is not found
12
+ */
13
+ findShippingMethod(id, organizationId, options) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const shippingMethod = yield this.prisma.shippingMethod.findUnique({
16
+ where: {
17
+ id,
18
+ organizationId,
19
+ },
20
+ include: options === null || options === void 0 ? void 0 : options.include,
21
+ });
22
+ if (!shippingMethod) {
23
+ throw new HttpException(404, "Shipping method not found");
24
+ }
25
+ return shippingMethod;
26
+ });
27
+ }
28
+ /**
29
+ * Find the distance between two coordinates
30
+ */
31
+ findDistanceBetweenCoordinates(from, to) {
32
+ // Helper function to convert degrees to radians
33
+ const toRadians = (degrees) => degrees * (Math.PI / 180);
34
+ // Earth's radius in kilometers
35
+ const earthRadiusKm = 6371;
36
+ // Convert latitude and longitude differences to radians
37
+ const dLat = toRadians(to.latitude - from.latitude);
38
+ const dLon = toRadians(to.longitude - from.longitude);
39
+ // Convert starting coordinates to radians
40
+ const lat1 = toRadians(from.latitude);
41
+ const lat2 = toRadians(to.latitude);
42
+ // Haversine formula
43
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
44
+ Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
45
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
46
+ // Calculate the distance
47
+ const distance = earthRadiusKm * c;
48
+ return distance;
49
+ }
50
+ /**
51
+ * Get a list of eligible shipping methods for a user
52
+ */
53
+ accessEligibility(user, organizationId) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const organization = yield this.prisma.organization.findUnique({
56
+ where: {
57
+ id: organizationId,
58
+ },
59
+ include: {
60
+ address: true,
61
+ },
62
+ });
63
+ if (!organization) {
64
+ throw new HttpException(404, "Organization not found");
65
+ }
66
+ const userShippingAddress = yield this.prisma.address.findFirst({
67
+ where: {
68
+ users: {
69
+ some: { id: user.id },
70
+ },
71
+ isDefault: true,
72
+ },
73
+ });
74
+ if (!userShippingAddress) {
75
+ throw new HttpException(404, "User shipping address not found");
76
+ }
77
+ const shippingMethods = yield this.prisma.shippingMethod.findMany({
78
+ where: {
79
+ organizationId,
80
+ },
81
+ include: {
82
+ shippingZones: true,
83
+ },
84
+ });
85
+ return shippingMethods.map((shippingMethod) => {
86
+ const distance = this.findDistanceBetweenCoordinates({
87
+ latitude: organization.address.latitude,
88
+ longitude: organization.address.longitude,
89
+ }, {
90
+ latitude: userShippingAddress.latitude,
91
+ longitude: userShippingAddress.longitude,
92
+ });
93
+ const eligibleShippingZone = shippingMethod.shippingZones.find(({ distanceUpto }) => {
94
+ return distance <= distanceUpto;
95
+ });
96
+ return ShippingMethodSchema.parse(Object.assign(Object.assign({}, shippingMethod), { eligibleShippingZone }));
97
+ });
98
+ });
99
+ }
100
+ /**
101
+ * Create a new shipping method
102
+ */
103
+ createShippingMethod(organizationId, userId, body) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ const shippingMethod = yield this.prisma.shippingMethod.create({
106
+ data: {
107
+ title: body.title,
108
+ providerName: body.providerName,
109
+ providerLogoId: body.providerLogoId,
110
+ requireDateOfDelivery: body.requireDateOfDelivery,
111
+ organizationId,
112
+ shippingZones: {
113
+ create: body.shippingZones,
114
+ },
115
+ createdBy: userId,
116
+ },
117
+ include: {
118
+ shippingZones: true,
119
+ providerLogo: true,
120
+ },
121
+ });
122
+ return ShippingMethodSchema.parse(shippingMethod);
123
+ });
124
+ }
125
+ /**
126
+ * Get a shipping method by ID
127
+ */
128
+ getShippingMethod(organizationId, id) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const shippingMethod = yield this.findShippingMethod(id, organizationId, {
131
+ include: {
132
+ providerLogo: true,
133
+ shippingZones: true,
134
+ },
135
+ });
136
+ return ShippingMethodSchema.parse(shippingMethod);
137
+ });
138
+ }
139
+ /**
140
+ * Get a paginated list of shipping methods
141
+ */
142
+ getShippingMethods(organizationId, query) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ const { page = 1, limit = 10, search } = query;
145
+ const [list, meta] = yield this.prisma.shippingMethod
146
+ .paginate({
147
+ orderBy: {
148
+ createdAt: "desc",
149
+ },
150
+ where: Object.assign({ organizationId }, (search && {
151
+ title: {
152
+ contains: search,
153
+ mode: "insensitive",
154
+ },
155
+ })),
156
+ include: {
157
+ shippingZones: true,
158
+ providerLogo: true,
159
+ },
160
+ })
161
+ .withPages({
162
+ page,
163
+ limit,
164
+ });
165
+ return z
166
+ .object({
167
+ meta: PaginationMetaSchema,
168
+ list: z.array(ShippingMethodSchema),
169
+ })
170
+ .parse({
171
+ meta,
172
+ list,
173
+ });
174
+ });
175
+ }
176
+ /**
177
+ * Update a shipping method
178
+ */
179
+ updateShippingMethod(organizationId, id, userId, body) {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ // Ensure the shipping method exists
182
+ yield this.findShippingMethod(id, organizationId);
183
+ const updatedShippingMethod = yield this.prisma.shippingMethod.update({
184
+ where: {
185
+ id,
186
+ organizationId,
187
+ },
188
+ data: {
189
+ title: body.title,
190
+ providerName: body.providerName,
191
+ providerLogoId: body.providerLogoId,
192
+ requireDateOfDelivery: body.requireDateOfDelivery,
193
+ shippingZones: {
194
+ deleteMany: {},
195
+ create: body.shippingZones,
196
+ },
197
+ updatedBy: userId,
198
+ },
199
+ include: {
200
+ providerLogo: true,
201
+ shippingZones: true,
202
+ },
203
+ });
204
+ return ShippingMethodSchema.parse(updatedShippingMethod);
205
+ });
206
+ }
207
+ /**
208
+ * Delete a shipping method (soft delete)
209
+ */
210
+ deleteShippingMethod(organizationId, id, userId) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ // Ensure the shipping method exists
213
+ yield this.findShippingMethod(id, organizationId);
214
+ yield this.prisma.shippingMethod.update({
215
+ where: {
216
+ id,
217
+ organizationId,
218
+ },
219
+ data: {
220
+ archivedAt: new Date(),
221
+ archivedBy: userId,
222
+ },
223
+ });
224
+ return;
225
+ });
226
+ }
227
+ }
228
+ export { ShippingMethodService };
229
+ //# sourceMappingURL=shipping-method.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-method.service.js","sourceRoot":"","sources":["../../../../../../packages/rest-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E;oBACtB,UAAU,EAAE,MAAM;iBACnB;aACF,CAAC,CAAC;YAEH,OAAO;QACT,CAAC;KAAA;CACF;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1 +1,31 @@
1
- import{z as i}from"@hono/zod-openapi";import{optionalNumber as e,requiredNumber as p}from"../../schemas/number.schema";export const ShippingZoneSchema=i.object({id:i.string().optional().openapi({example:"clf9876543210abcdef",description:"ID of the shipping zone"}),title:i.string().min(1,"Title is required").openapi({example:"Zone 1",description:"Title of the shipping zone"}),distanceUpto:p.openapi({example:10,description:"Ending distance for the shipping zone"}),price:p.openapi({example:5.99,description:"Price for shipping in this zone"}),minimumOrderAmount:e.openapi({example:50,description:"Minimum order amount for this shipping zone"}),eta:i.string().min(1,"ETA is required").openapi({example:"2-3 days",description:"Estimated time of arrival for this shipping zone"})}).openapi("ShippingZone");
1
+ import { z } from "@hono/zod-openapi";
2
+ import { optionalNumber, requiredNumber } from "../../schemas/number.schema";
3
+ export const ShippingZoneSchema = z
4
+ .object({
5
+ id: z.string().optional().openapi({
6
+ example: "clf9876543210abcdef",
7
+ description: "ID of the shipping zone",
8
+ }),
9
+ title: z.string().min(1, "Title is required").openapi({
10
+ example: "Zone 1",
11
+ description: "Title of the shipping zone",
12
+ }),
13
+ distanceUpto: requiredNumber.openapi({
14
+ example: 10,
15
+ description: "Ending distance for the shipping zone",
16
+ }),
17
+ price: requiredNumber.openapi({
18
+ example: 5.99,
19
+ description: "Price for shipping in this zone",
20
+ }),
21
+ minimumOrderAmount: optionalNumber.openapi({
22
+ example: 50,
23
+ description: "Minimum order amount for this shipping zone",
24
+ }),
25
+ eta: z.string().min(1, "ETA is required").openapi({
26
+ example: "2-3 days",
27
+ description: "Estimated time of arrival for this shipping zone",
28
+ }),
29
+ })
30
+ .openapi("ShippingZone");
31
+ //# sourceMappingURL=shipping-zone.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-zone.schema.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/shipping-method/shipping-zone.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;QAChC,OAAO,EAAE,qBAAqB;QAC9B,WAAW,EAAE,yBAAyB;KACvC,CAAC;IACF,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,OAAO,CAAC;QACpD,OAAO,EAAE,QAAQ;QACjB,WAAW,EAAE,4BAA4B;KAC1C,CAAC;IACF,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC;QACnC,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,uCAAuC;KACrD,CAAC;IACF,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC;QAC5B,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,iCAAiC;KAC/C,CAAC;IACF,kBAAkB,EAAE,cAAc,CAAC,OAAO,CAAC;QACzC,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,6CAA6C;KAC3D,CAAC;IACF,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC;QAChD,OAAO,EAAE,UAAU;QACnB,WAAW,EAAE,kDAAkD;KAChE,CAAC;CACH,CAAC;KACD,OAAO,CAAC,cAAc,CAAC,CAAC"}