@shophost/rest-api 2.0.30 → 2.0.32

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 (352) hide show
  1. package/package.json +18 -13
  2. package/scripts/minify.mjs +123 -0
  3. package/src/app.js +1 -53
  4. package/src/core/auth/auth.schema.js +1 -41
  5. package/src/core/auth/auth.util.js +1 -44
  6. package/src/core/auth/better-auth.lib.js +1 -100
  7. package/src/core/auth/generate-password-hash.util.d.ts +0 -3
  8. package/src/core/auth/generate-password-hash.util.js +1 -30
  9. package/src/core/auth/headers.schema.js +1 -22
  10. package/src/core/auth/user.schema.js +1 -30
  11. package/src/core/db/__generated__/client/browser.d.ts +0 -128
  12. package/src/core/db/__generated__/client/browser.js +1 -18
  13. package/src/core/db/__generated__/client/client.d.ts +0 -143
  14. package/src/core/db/__generated__/client/client.js +1 -35
  15. package/src/core/db/__generated__/client/commonInputTypes.js +1 -11
  16. package/src/core/db/__generated__/client/enums.js +1 -200
  17. package/src/core/db/__generated__/client/internal/class.d.ts +0 -343
  18. package/src/core/db/__generated__/client/internal/class.js +1 -55
  19. package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +0 -234
  20. package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
  21. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.d.ts +0 -15
  22. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
  23. package/src/core/db/__generated__/client/models/Account.d.ts +0 -628
  24. package/src/core/db/__generated__/client/models/Account.js +1 -2
  25. package/src/core/db/__generated__/client/models/Address.d.ts +0 -701
  26. package/src/core/db/__generated__/client/models/Address.js +1 -2
  27. package/src/core/db/__generated__/client/models/Campaign.d.ts +0 -638
  28. package/src/core/db/__generated__/client/models/Campaign.js +1 -2
  29. package/src/core/db/__generated__/client/models/ClosingTimes.d.ts +0 -634
  30. package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
  31. package/src/core/db/__generated__/client/models/File.d.ts +0 -752
  32. package/src/core/db/__generated__/client/models/File.js +1 -2
  33. package/src/core/db/__generated__/client/models/Invitation.d.ts +0 -628
  34. package/src/core/db/__generated__/client/models/Invitation.js +1 -2
  35. package/src/core/db/__generated__/client/models/LegalEntity.d.ts +0 -652
  36. package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
  37. package/src/core/db/__generated__/client/models/Manufacturer.d.ts +0 -679
  38. package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
  39. package/src/core/db/__generated__/client/models/ManufacturerTranslation.d.ts +0 -628
  40. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
  41. package/src/core/db/__generated__/client/models/Member.d.ts +0 -628
  42. package/src/core/db/__generated__/client/models/Member.js +1 -2
  43. package/src/core/db/__generated__/client/models/Modifier.d.ts +0 -662
  44. package/src/core/db/__generated__/client/models/Modifier.js +1 -2
  45. package/src/core/db/__generated__/client/models/ModifierGroup.d.ts +0 -686
  46. package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
  47. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.d.ts +0 -628
  48. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
  49. package/src/core/db/__generated__/client/models/OpeningTimes.d.ts +0 -634
  50. package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
  51. package/src/core/db/__generated__/client/models/Order.d.ts +0 -700
  52. package/src/core/db/__generated__/client/models/Order.js +1 -2
  53. package/src/core/db/__generated__/client/models/OrderItem.d.ts +0 -686
  54. package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
  55. package/src/core/db/__generated__/client/models/OrderItemTranslation.d.ts +0 -628
  56. package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
  57. package/src/core/db/__generated__/client/models/Organization.d.ts +0 -811
  58. package/src/core/db/__generated__/client/models/Organization.js +1 -2
  59. package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +0 -676
  60. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
  61. package/src/core/db/__generated__/client/models/Payment.d.ts +0 -668
  62. package/src/core/db/__generated__/client/models/Payment.js +1 -2
  63. package/src/core/db/__generated__/client/models/PaymentSession.d.ts +0 -638
  64. package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
  65. package/src/core/db/__generated__/client/models/Product.d.ts +0 -746
  66. package/src/core/db/__generated__/client/models/Product.js +1 -2
  67. package/src/core/db/__generated__/client/models/ProductCategory.d.ts +0 -689
  68. package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
  69. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.d.ts +0 -628
  70. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
  71. package/src/core/db/__generated__/client/models/ProductSnapshot.d.ts +0 -664
  72. package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
  73. package/src/core/db/__generated__/client/models/ProductTranslation.d.ts +0 -628
  74. package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
  75. package/src/core/db/__generated__/client/models/Reservation.d.ts +0 -650
  76. package/src/core/db/__generated__/client/models/Reservation.js +1 -2
  77. package/src/core/db/__generated__/client/models/Session.d.ts +0 -628
  78. package/src/core/db/__generated__/client/models/Session.js +1 -2
  79. package/src/core/db/__generated__/client/models/ShippingMethod.d.ts +0 -679
  80. package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
  81. package/src/core/db/__generated__/client/models/ShippingZone.d.ts +0 -638
  82. package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
  83. package/src/core/db/__generated__/client/models/User.d.ts +0 -736
  84. package/src/core/db/__generated__/client/models/User.js +1 -2
  85. package/src/core/db/__generated__/client/models/Verification.d.ts +0 -592
  86. package/src/core/db/__generated__/client/models/Verification.js +1 -2
  87. package/src/core/db/__generated__/client/models.js +1 -2
  88. package/src/core/db/index.js +1 -2
  89. package/src/core/exceptions/http-exception.js +1 -9
  90. package/src/core/hono/hono.js +1 -123
  91. package/src/core/lib/prisma.d.ts +9 -1
  92. package/src/core/lib/prisma.js +1 -11
  93. package/src/core/logging/pino.js +1 -5
  94. package/src/core/notifications/email.service.d.ts +0 -15
  95. package/src/core/notifications/email.service.js +1 -116
  96. package/src/core/openapi/openapi.lib.js +1 -26
  97. package/src/core/types/google-maps.types.js +1 -2
  98. package/src/core/utils/currency.util.js +1 -11
  99. package/src/core/utils/env.util.js +1 -8
  100. package/src/core/utils/object.util.d.ts +0 -10
  101. package/src/core/utils/object.util.js +1 -39
  102. package/src/core/utils/translations.util.js +0 -2
  103. package/src/core/utils/zod.util.d.ts +0 -12
  104. package/src/core/utils/zod.util.js +1 -85
  105. package/src/db.js +1 -3
  106. package/src/features/access/access.handler.js +1 -91
  107. package/src/features/access/access.route.js +1 -220
  108. package/src/features/access/access.schema.js +1 -108
  109. package/src/features/access/access.service.js +1 -294
  110. package/src/features/cart/cart.handler.js +1 -17
  111. package/src/features/cart/cart.route.js +1 -32
  112. package/src/features/cart/cart.schema.js +1 -39
  113. package/src/features/cart/cart.service.d.ts +0 -7
  114. package/src/features/cart/cart.service.js +1 -97
  115. package/src/features/cart/cart.util.js +1 -76
  116. package/src/features/file/file.handler.js +1 -23
  117. package/src/features/file/file.route.js +1 -34
  118. package/src/features/file/file.schema.js +1 -77
  119. package/src/features/file/file.service.d.ts +0 -6
  120. package/src/features/file/file.service.js +1 -66
  121. package/src/features/health/health.handler.js +1 -10
  122. package/src/features/health/health.route.js +1 -25
  123. package/src/features/index.js +1 -16
  124. package/src/features/location/location.handler.js +1 -25
  125. package/src/features/location/location.route.js +1 -56
  126. package/src/features/location/location.schema.js +1 -50
  127. package/src/features/location/location.service.d.ts +0 -3
  128. package/src/features/location/location.service.js +1 -141
  129. package/src/features/manufacturer/manufacturer.handler.js +1 -53
  130. package/src/features/manufacturer/manufacturer.route.js +1 -97
  131. package/src/features/manufacturer/manufacturer.schema.js +1 -125
  132. package/src/features/manufacturer/manufacturer.service.d.ts +0 -19
  133. package/src/features/manufacturer/manufacturer.service.js +1 -190
  134. package/src/features/order/emails/order-confirmation.email.js +1 -229
  135. package/src/features/order/emails/order-notification.email.js +1 -229
  136. package/src/features/order/fulfilment.schema.js +1 -3
  137. package/src/features/order/order.handler.js +1 -54
  138. package/src/features/order/order.route.js +1 -111
  139. package/src/features/order/order.schema.js +1 -158
  140. package/src/features/order/order.service.d.ts +0 -15
  141. package/src/features/order/order.service.js +1 -306
  142. package/src/features/order/recipient.schema.js +1 -38
  143. package/src/features/organization/legal-entity.schema.js +1 -83
  144. package/src/features/organization/organization-configuration.schema.js +1 -115
  145. package/src/features/organization/organization.handler.js +1 -48
  146. package/src/features/organization/organization.route.js +1 -84
  147. package/src/features/organization/organization.schema.js +1 -64
  148. package/src/features/organization/organization.service.d.ts +0 -15
  149. package/src/features/organization/organization.service.js +1 -334
  150. package/src/features/payment/payment.handler.js +1 -16
  151. package/src/features/payment/payment.route.js +1 -22
  152. package/src/features/payment/payment.schema.js +1 -46
  153. package/src/features/payment/payment.service.js +1 -100
  154. package/src/features/payment/stripe.service.js +1 -164
  155. package/src/features/product/product-modifier.schema.js +1 -84
  156. package/src/features/product/product.handler.js +1 -87
  157. package/src/features/product/product.route.js +1 -179
  158. package/src/features/product/product.schema.js +1 -143
  159. package/src/features/product/product.service.d.ts +0 -25
  160. package/src/features/product/product.service.js +1 -440
  161. package/src/features/product-category/product-category.handler.js +1 -59
  162. package/src/features/product-category/product-category.route.js +1 -139
  163. package/src/features/product-category/product-category.schema.js +1 -86
  164. package/src/features/product-category/product-category.service.d.ts +0 -22
  165. package/src/features/product-category/product-category.service.js +1 -220
  166. package/src/features/reservation/emails/reservation-cancellation.email.js +1 -82
  167. package/src/features/reservation/emails/reservation-confirmation.email.js +1 -82
  168. package/src/features/reservation/emails/reservation-notification.email.js +1 -93
  169. package/src/features/reservation/reservation.handler.js +1 -65
  170. package/src/features/reservation/reservation.route.js +1 -167
  171. package/src/features/reservation/reservation.schema.js +1 -51
  172. package/src/features/reservation/reservation.service.d.ts +0 -18
  173. package/src/features/reservation/reservation.service.js +1 -231
  174. package/src/features/shipping/shipping.handler.js +1 -32
  175. package/src/features/shipping/shipping.route.js +1 -51
  176. package/src/features/shipping/shipping.service.d.ts +0 -7
  177. package/src/features/shipping/shipping.service.js +1 -96
  178. package/src/features/shipping-method/shipping-method.handler.js +1 -60
  179. package/src/features/shipping-method/shipping-method.route.js +1 -144
  180. package/src/features/shipping-method/shipping-method.schema.js +1 -48
  181. package/src/features/shipping-method/shipping-method.service.d.ts +0 -25
  182. package/src/features/shipping-method/shipping-method.service.js +1 -229
  183. package/src/features/shipping-method/shipping-zone.schema.js +1 -31
  184. package/src/features/webhook/webhook.handler.js +1 -50
  185. package/src/features/webhook/webhook.route.js +1 -33
  186. package/src/index.js +1 -6
  187. package/src/integrations/next.js +1 -82
  188. package/src/schemas/address.schema.d.ts +0 -8
  189. package/src/schemas/address.schema.js +1 -112
  190. package/src/schemas/currency.schema.d.ts +0 -42
  191. package/src/schemas/currency.schema.js +1 -118
  192. package/src/schemas/error.schema.js +1 -12
  193. package/src/schemas/index.js +1 -29
  194. package/src/schemas/locales.schema.js +1 -238
  195. package/src/schemas/number.schema.js +1 -29
  196. package/src/schemas/pagination.schema.js +1 -54
  197. package/src/schemas/params.schema.js +1 -20
  198. package/src/schemas/queries.schema.js +1 -6
  199. package/src/test/global-setup.d.ts +1 -0
  200. package/src/test/global-setup.js +1 -0
  201. package/src/test/integration/api-fixtures.d.ts +4 -16
  202. package/src/test/integration/api-fixtures.js +1 -225
  203. package/src/test/integration/seed.d.ts +81 -0
  204. package/src/test/integration/seed.js +1 -0
  205. package/src/test/integration/test-helpers.d.ts +107 -924
  206. package/src/test/integration/test-helpers.js +1 -1100
  207. package/src/test/setup-test-env.d.ts +1 -1
  208. package/src/test/setup-test-env.js +1 -29
  209. package/src/app.js.map +0 -1
  210. package/src/core/auth/auth.schema.js.map +0 -1
  211. package/src/core/auth/auth.util.js.map +0 -1
  212. package/src/core/auth/better-auth.lib.js.map +0 -1
  213. package/src/core/auth/generate-password-hash.util.js.map +0 -1
  214. package/src/core/auth/headers.schema.js.map +0 -1
  215. package/src/core/auth/user.schema.js.map +0 -1
  216. package/src/core/db/__generated__/client/browser.js.map +0 -1
  217. package/src/core/db/__generated__/client/client.js.map +0 -1
  218. package/src/core/db/__generated__/client/commonInputTypes.js.map +0 -1
  219. package/src/core/db/__generated__/client/enums.js.map +0 -1
  220. package/src/core/db/__generated__/client/internal/class.js.map +0 -1
  221. package/src/core/db/__generated__/client/internal/prismaNamespace.js.map +0 -1
  222. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js.map +0 -1
  223. package/src/core/db/__generated__/client/models/Account.js.map +0 -1
  224. package/src/core/db/__generated__/client/models/Address.js.map +0 -1
  225. package/src/core/db/__generated__/client/models/Campaign.js.map +0 -1
  226. package/src/core/db/__generated__/client/models/ClosingTimes.js.map +0 -1
  227. package/src/core/db/__generated__/client/models/File.js.map +0 -1
  228. package/src/core/db/__generated__/client/models/Invitation.js.map +0 -1
  229. package/src/core/db/__generated__/client/models/LegalEntity.js.map +0 -1
  230. package/src/core/db/__generated__/client/models/Manufacturer.js.map +0 -1
  231. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js.map +0 -1
  232. package/src/core/db/__generated__/client/models/Member.js.map +0 -1
  233. package/src/core/db/__generated__/client/models/Modifier.js.map +0 -1
  234. package/src/core/db/__generated__/client/models/ModifierGroup.js.map +0 -1
  235. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js.map +0 -1
  236. package/src/core/db/__generated__/client/models/OpeningTimes.js.map +0 -1
  237. package/src/core/db/__generated__/client/models/Order.js.map +0 -1
  238. package/src/core/db/__generated__/client/models/OrderItem.js.map +0 -1
  239. package/src/core/db/__generated__/client/models/OrderItemTranslation.js.map +0 -1
  240. package/src/core/db/__generated__/client/models/Organization.js.map +0 -1
  241. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js.map +0 -1
  242. package/src/core/db/__generated__/client/models/Payment.js.map +0 -1
  243. package/src/core/db/__generated__/client/models/PaymentSession.js.map +0 -1
  244. package/src/core/db/__generated__/client/models/Product.js.map +0 -1
  245. package/src/core/db/__generated__/client/models/ProductCategory.js.map +0 -1
  246. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js.map +0 -1
  247. package/src/core/db/__generated__/client/models/ProductSnapshot.js.map +0 -1
  248. package/src/core/db/__generated__/client/models/ProductTranslation.js.map +0 -1
  249. package/src/core/db/__generated__/client/models/Reservation.js.map +0 -1
  250. package/src/core/db/__generated__/client/models/Session.js.map +0 -1
  251. package/src/core/db/__generated__/client/models/ShippingMethod.js.map +0 -1
  252. package/src/core/db/__generated__/client/models/ShippingZone.js.map +0 -1
  253. package/src/core/db/__generated__/client/models/User.js.map +0 -1
  254. package/src/core/db/__generated__/client/models/Verification.js.map +0 -1
  255. package/src/core/db/__generated__/client/models.js.map +0 -1
  256. package/src/core/db/index.js.map +0 -1
  257. package/src/core/exceptions/http-exception.js.map +0 -1
  258. package/src/core/hono/hono.js.map +0 -1
  259. package/src/core/lib/prisma.js.map +0 -1
  260. package/src/core/logging/pino.js.map +0 -1
  261. package/src/core/notifications/email.service.js.map +0 -1
  262. package/src/core/openapi/openapi.lib.js.map +0 -1
  263. package/src/core/types/google-maps.types.js.map +0 -1
  264. package/src/core/utils/currency.util.js.map +0 -1
  265. package/src/core/utils/env.util.js.map +0 -1
  266. package/src/core/utils/object.util.js.map +0 -1
  267. package/src/core/utils/translations.util.js.map +0 -1
  268. package/src/core/utils/zod.util.js.map +0 -1
  269. package/src/db.js.map +0 -1
  270. package/src/features/access/access.handler.js.map +0 -1
  271. package/src/features/access/access.route.js.map +0 -1
  272. package/src/features/access/access.schema.js.map +0 -1
  273. package/src/features/access/access.service.js.map +0 -1
  274. package/src/features/cart/cart.handler.js.map +0 -1
  275. package/src/features/cart/cart.route.js.map +0 -1
  276. package/src/features/cart/cart.schema.js.map +0 -1
  277. package/src/features/cart/cart.service.js.map +0 -1
  278. package/src/features/cart/cart.util.js.map +0 -1
  279. package/src/features/file/file.handler.js.map +0 -1
  280. package/src/features/file/file.route.js.map +0 -1
  281. package/src/features/file/file.schema.js.map +0 -1
  282. package/src/features/file/file.service.js.map +0 -1
  283. package/src/features/health/health.handler.js.map +0 -1
  284. package/src/features/health/health.route.js.map +0 -1
  285. package/src/features/index.js.map +0 -1
  286. package/src/features/location/location.handler.js.map +0 -1
  287. package/src/features/location/location.route.js.map +0 -1
  288. package/src/features/location/location.schema.js.map +0 -1
  289. package/src/features/location/location.service.js.map +0 -1
  290. package/src/features/manufacturer/manufacturer.handler.js.map +0 -1
  291. package/src/features/manufacturer/manufacturer.route.js.map +0 -1
  292. package/src/features/manufacturer/manufacturer.schema.js.map +0 -1
  293. package/src/features/manufacturer/manufacturer.service.js.map +0 -1
  294. package/src/features/order/emails/order-confirmation.email.js.map +0 -1
  295. package/src/features/order/emails/order-notification.email.js.map +0 -1
  296. package/src/features/order/fulfilment.schema.js.map +0 -1
  297. package/src/features/order/order.handler.js.map +0 -1
  298. package/src/features/order/order.route.js.map +0 -1
  299. package/src/features/order/order.schema.js.map +0 -1
  300. package/src/features/order/order.service.js.map +0 -1
  301. package/src/features/order/recipient.schema.js.map +0 -1
  302. package/src/features/organization/legal-entity.schema.js.map +0 -1
  303. package/src/features/organization/organization-configuration.schema.js.map +0 -1
  304. package/src/features/organization/organization.handler.js.map +0 -1
  305. package/src/features/organization/organization.route.js.map +0 -1
  306. package/src/features/organization/organization.schema.js.map +0 -1
  307. package/src/features/organization/organization.service.js.map +0 -1
  308. package/src/features/payment/payment.handler.js.map +0 -1
  309. package/src/features/payment/payment.route.js.map +0 -1
  310. package/src/features/payment/payment.schema.js.map +0 -1
  311. package/src/features/payment/payment.service.js.map +0 -1
  312. package/src/features/payment/stripe.service.js.map +0 -1
  313. package/src/features/product/product-modifier.schema.js.map +0 -1
  314. package/src/features/product/product.handler.js.map +0 -1
  315. package/src/features/product/product.route.js.map +0 -1
  316. package/src/features/product/product.schema.js.map +0 -1
  317. package/src/features/product/product.service.js.map +0 -1
  318. package/src/features/product-category/product-category.handler.js.map +0 -1
  319. package/src/features/product-category/product-category.route.js.map +0 -1
  320. package/src/features/product-category/product-category.schema.js.map +0 -1
  321. package/src/features/product-category/product-category.service.js.map +0 -1
  322. package/src/features/reservation/emails/reservation-cancellation.email.js.map +0 -1
  323. package/src/features/reservation/emails/reservation-confirmation.email.js.map +0 -1
  324. package/src/features/reservation/emails/reservation-notification.email.js.map +0 -1
  325. package/src/features/reservation/reservation.handler.js.map +0 -1
  326. package/src/features/reservation/reservation.route.js.map +0 -1
  327. package/src/features/reservation/reservation.schema.js.map +0 -1
  328. package/src/features/reservation/reservation.service.js.map +0 -1
  329. package/src/features/shipping/shipping.handler.js.map +0 -1
  330. package/src/features/shipping/shipping.route.js.map +0 -1
  331. package/src/features/shipping/shipping.service.js.map +0 -1
  332. package/src/features/shipping-method/shipping-method.handler.js.map +0 -1
  333. package/src/features/shipping-method/shipping-method.route.js.map +0 -1
  334. package/src/features/shipping-method/shipping-method.schema.js.map +0 -1
  335. package/src/features/shipping-method/shipping-method.service.js.map +0 -1
  336. package/src/features/shipping-method/shipping-zone.schema.js.map +0 -1
  337. package/src/features/webhook/webhook.handler.js.map +0 -1
  338. package/src/features/webhook/webhook.route.js.map +0 -1
  339. package/src/index.js.map +0 -1
  340. package/src/integrations/next.js.map +0 -1
  341. package/src/schemas/address.schema.js.map +0 -1
  342. package/src/schemas/currency.schema.js.map +0 -1
  343. package/src/schemas/error.schema.js.map +0 -1
  344. package/src/schemas/index.js.map +0 -1
  345. package/src/schemas/locales.schema.js.map +0 -1
  346. package/src/schemas/number.schema.js.map +0 -1
  347. package/src/schemas/pagination.schema.js.map +0 -1
  348. package/src/schemas/params.schema.js.map +0 -1
  349. package/src/schemas/queries.schema.js.map +0 -1
  350. package/src/test/integration/api-fixtures.js.map +0 -1
  351. package/src/test/integration/test-helpers.js.map +0 -1
  352. package/src/test/setup-test-env.js.map +0 -1
@@ -1,97 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { createApiRoute } from "../../core/hono/hono";
3
- import { ErrorSchema, HeaderSchema, OrganizationParams, OrganizationWithIdParams, PaginationMetaSchema, PaginationQuerySchema, } from "../../schemas";
4
- import { GetResourceQuerySchema } from "../../schemas/queries.schema";
5
- import { CreateManufacturerSchema, LocalizedManufacturerSchema, ManufacturerSchema, UpdateManufacturerSchema, } from "./manufacturer.schema";
6
- const getManufacturersRoute = createApiRoute({
7
- description: "Fetches a paginated list of manufacturers for a specific organization",
8
- headers: HeaderSchema,
9
- method: "GET",
10
- operationId: "getManufacturers",
11
- path: "/:organizationId/manufacturers",
12
- pathParams: OrganizationParams,
13
- query: PaginationQuerySchema,
14
- responses: {
15
- 200: z.object({
16
- list: z.array(z.union([ManufacturerSchema, LocalizedManufacturerSchema])),
17
- meta: PaginationMetaSchema,
18
- }),
19
- 400: ErrorSchema,
20
- 401: ErrorSchema,
21
- },
22
- summary: "Get Manufacturers",
23
- tags: ["Manufacturer"],
24
- });
25
- const createManufacturerRoute = createApiRoute({
26
- body: CreateManufacturerSchema,
27
- description: "Creates a new manufacturer for a specific organization",
28
- headers: HeaderSchema,
29
- method: "POST",
30
- operationId: "createManufacturer",
31
- path: "/:organizationId/manufacturers",
32
- pathParams: OrganizationParams,
33
- responses: {
34
- 201: ManufacturerSchema,
35
- 400: ErrorSchema,
36
- 401: ErrorSchema,
37
- 404: ErrorSchema,
38
- },
39
- summary: "Create Manufacturer",
40
- tags: ["Manufacturer"],
41
- });
42
- const getManufacturerRoute = createApiRoute({
43
- headers: HeaderSchema,
44
- method: "GET",
45
- operationId: "getManufacturer",
46
- path: "/:organizationId/manufacturers/:id",
47
- pathParams: OrganizationWithIdParams,
48
- query: GetResourceQuerySchema,
49
- responses: {
50
- 200: z.union([ManufacturerSchema, LocalizedManufacturerSchema]),
51
- 401: ErrorSchema,
52
- 404: ErrorSchema,
53
- },
54
- summary: "Get Manufacturer",
55
- tags: ["Manufacturer"],
56
- });
57
- const updateManufacturerRoute = createApiRoute({
58
- body: UpdateManufacturerSchema,
59
- description: "Updates an existing manufacturer",
60
- headers: HeaderSchema,
61
- method: "PUT",
62
- operationId: "updateManufacturer",
63
- path: "/:organizationId/manufacturers/:id",
64
- pathParams: OrganizationWithIdParams,
65
- responses: {
66
- 200: ManufacturerSchema,
67
- 400: ErrorSchema,
68
- 401: ErrorSchema,
69
- 404: ErrorSchema,
70
- },
71
- summary: "Update Manufacturer",
72
- tags: ["Manufacturer"],
73
- });
74
- const deleteManufacturerRoute = createApiRoute({
75
- description: "Soft deletes a manufacturer",
76
- headers: HeaderSchema,
77
- method: "DELETE",
78
- operationId: "deleteManufacturer",
79
- path: "/:organizationId/manufacturers/:id",
80
- pathParams: OrganizationWithIdParams,
81
- responses: {
82
- 204: null,
83
- 400: ErrorSchema,
84
- 401: ErrorSchema,
85
- 404: ErrorSchema,
86
- },
87
- summary: "Delete Manufacturer",
88
- tags: ["Manufacturer"],
89
- });
90
- export const manufacturerRoute = {
91
- getManufacturers: getManufacturersRoute,
92
- createManufacturer: createManufacturerRoute,
93
- getManufacturer: getManufacturerRoute,
94
- updateManufacturer: updateManufacturerRoute,
95
- deleteManufacturer: deleteManufacturerRoute,
96
- };
97
- //# sourceMappingURL=manufacturer.route.js.map
1
+ import{z as a}from"@hono/zod-openapi";import{createApiRoute as r}from"../../core/hono/hono";import{ErrorSchema as e,HeaderSchema as t,OrganizationParams as u,OrganizationWithIdParams as n,PaginationMetaSchema as o,PaginationQuerySchema as s}from"../../schemas";import{GetResourceQuerySchema as c}from"../../schemas/queries.schema";import{CreateManufacturerSchema as i,LocalizedManufacturerSchema as m,ManufacturerSchema as f,UpdateManufacturerSchema as p}from"./manufacturer.schema";const d=r({description:"Fetches a paginated list of manufacturers for a specific organization",headers:t,method:"GET",operationId:"getManufacturers",path:"/:organizationId/manufacturers",pathParams:u,query:s,responses:{200:a.object({list:a.array(a.union([f,m])),meta:o}),400:e,401:e},summary:"Get Manufacturers",tags:["Manufacturer"]}),h=r({body:i,description:"Creates a new manufacturer for a specific organization",headers:t,method:"POST",operationId:"createManufacturer",path:"/:organizationId/manufacturers",pathParams:u,responses:{201:f,400:e,401:e,404:e},summary:"Create Manufacturer",tags:["Manufacturer"]}),M=r({headers:t,method:"GET",operationId:"getManufacturer",path:"/:organizationId/manufacturers/:id",pathParams:n,query:c,responses:{200:a.union([f,m]),401:e,404:e},summary:"Get Manufacturer",tags:["Manufacturer"]}),g=r({body:p,description:"Updates an existing manufacturer",headers:t,method:"PUT",operationId:"updateManufacturer",path:"/:organizationId/manufacturers/:id",pathParams:n,responses:{200:f,400:e,401:e,404:e},summary:"Update Manufacturer",tags:["Manufacturer"]}),y=r({description:"Soft deletes a manufacturer",headers:t,method:"DELETE",operationId:"deleteManufacturer",path:"/:organizationId/manufacturers/:id",pathParams:n,responses:{204:null,400:e,401:e,404:e},summary:"Delete Manufacturer",tags:["Manufacturer"]});export const manufacturerRoute={getManufacturers:d,createManufacturer:h,getManufacturer:M,updateManufacturer:g,deleteManufacturer:y};
@@ -1,125 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { validateRequiredForDefaultLocale } from "../../core/utils/zod.util";
3
- import { FileSchema } from "../file/file.schema";
4
- export const ManufacturerSchema = z
5
- .object({
6
- id: z.string().openapi({
7
- example: "clf9876543210abcdef",
8
- description: "ID of the manufacturer",
9
- }),
10
- name: z.string().openapi({
11
- example: "Tech Innovators Inc.",
12
- description: "Name of the manufacturer",
13
- }),
14
- logo: FileSchema.nullable()
15
- .optional()
16
- .openapi({ description: "Logo of the manufacturer" }),
17
- createdAt: z.date(),
18
- translations: z
19
- .array(z.object({
20
- locale: z.string().min(1, "Locale is required").openapi({
21
- example: "en-US",
22
- description: "Locale code for the translation",
23
- }),
24
- about: z
25
- .string()
26
- .max(6000, "Maximum character limit is 6000")
27
- .nullable()
28
- .optional()
29
- .openapi({
30
- example: "Tech Innovators Inc. is a technology company.",
31
- description: "Description about the manufacturer in the specified locale",
32
- }),
33
- }))
34
- .optional()
35
- .openapi({
36
- description: "List of translations for the manufacturer",
37
- }),
38
- })
39
- .openapi("Manufacturer");
40
- export const LocalizedManufacturerSchema = ManufacturerSchema.omit({
41
- translations: true,
42
- })
43
- .extend({
44
- about: z.string().nullable().optional().default(""),
45
- })
46
- .openapi("LocalizedManufacturer");
47
- export const CreateManufacturerSchema = z
48
- .object({
49
- name: z.string().min(1, "Name is required").openapi({
50
- example: "Apple Inc.",
51
- description: "Name of the manufacturer",
52
- }),
53
- defaultLocale: z.string().min(1, "Default locale is required").openapi({
54
- example: "en-US",
55
- description: "The default locale for the manufacturer",
56
- }),
57
- logo: FileSchema.nullable().optional().openapi({
58
- description: "Logo of the manufacturer",
59
- }),
60
- translations: z
61
- .array(z.object({
62
- locale: z.string().min(1, "Locale is required").openapi({
63
- example: "en-US",
64
- description: "Locale code for the translation",
65
- }),
66
- about: z
67
- .string()
68
- .max(6000, "Maximum character limit is 6000")
69
- .nullable()
70
- .optional()
71
- .openapi({
72
- example: "Apple Inc. is a multinational technology company.",
73
- description: "Description about the manufacturer in the specified locale",
74
- }),
75
- }))
76
- .min(1, "Translations are required")
77
- .openapi({
78
- description: "List of translations for the manufacturer",
79
- }),
80
- logoId: z.string().optional().openapi({
81
- example: "clf9876543210abcdef",
82
- description: "ID reference to the manufacturer's logo file",
83
- }),
84
- })
85
- .superRefine(validateRequiredForDefaultLocale("about"))
86
- .openapi("CreateManufacturer");
87
- export const UpdateManufacturerSchema = z
88
- .object({
89
- name: z.string().min(1, "Name is required").optional().openapi({
90
- example: "Apple Inc. Updated",
91
- description: "Name of the manufacturer",
92
- }),
93
- logo: FileSchema.nullable().optional().openapi({
94
- description: "Logo of the manufacturer",
95
- }),
96
- defaultLocale: z.string().min(1, "Default locale is required").openapi({
97
- description: "The default locale for the manufacturer",
98
- }),
99
- logoId: z.string().nullable().optional().openapi({
100
- example: "clf9876543210abcdef",
101
- description: "ID reference to the manufacturer's logo file",
102
- }),
103
- translations: z
104
- .array(z.object({
105
- locale: z.string().min(1, "Locale is required").openapi({
106
- example: "en-US",
107
- description: "Locale code for the translation",
108
- }),
109
- about: z
110
- .string()
111
- .max(6000, "Maximum character limit is 6000")
112
- .nullable()
113
- .optional()
114
- .openapi({
115
- example: "Apple Inc. is a multinational technology company.",
116
- description: "Description about the manufacturer in the specified locale",
117
- }),
118
- }))
119
- .optional()
120
- .openapi({
121
- description: "List of translations for the manufacturer",
122
- }),
123
- })
124
- .openapi("UpdateManufacturer");
125
- //# sourceMappingURL=manufacturer.schema.js.map
1
+ import{z as e}from"@hono/zod-openapi";import{validateRequiredForDefaultLocale as a}from"../../core/utils/zod.util";import{FileSchema as o}from"../file/file.schema";export const ManufacturerSchema=e.object({id:e.string().openapi({example:"clf9876543210abcdef",description:"ID of the manufacturer"}),name:e.string().openapi({example:"Tech Innovators Inc.",description:"Name of the manufacturer"}),logo:o.nullable().optional().openapi({description:"Logo of the manufacturer"}),createdAt:e.date(),translations:e.array(e.object({locale:e.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:e.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Tech Innovators Inc. is a technology company.",description:"Description about the manufacturer in the specified locale"})})).optional().openapi({description:"List of translations for the manufacturer"})}).openapi("Manufacturer");export const LocalizedManufacturerSchema=ManufacturerSchema.omit({translations:!0}).extend({about:e.string().nullable().optional().default("")}).openapi("LocalizedManufacturer");export const CreateManufacturerSchema=e.object({name:e.string().min(1,"Name is required").openapi({example:"Apple Inc.",description:"Name of the manufacturer"}),defaultLocale:e.string().min(1,"Default locale is required").openapi({example:"en-US",description:"The default locale for the manufacturer"}),logo:o.nullable().optional().openapi({description:"Logo of the manufacturer"}),translations:e.array(e.object({locale:e.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:e.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Apple Inc. is a multinational technology company.",description:"Description about the manufacturer in the specified locale"})})).min(1,"Translations are required").openapi({description:"List of translations for the manufacturer"}),logoId:e.string().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the manufacturer's logo file"})}).superRefine(a("about")).openapi("CreateManufacturer");export const UpdateManufacturerSchema=e.object({name:e.string().min(1,"Name is required").optional().openapi({example:"Apple Inc. Updated",description:"Name of the manufacturer"}),logo:o.nullable().optional().openapi({description:"Logo of the manufacturer"}),defaultLocale:e.string().min(1,"Default locale is required").openapi({description:"The default locale for the manufacturer"}),logoId:e.string().nullable().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the manufacturer's logo file"}),translations:e.array(e.object({locale:e.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:e.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Apple Inc. is a multinational technology company.",description:"Description about the manufacturer in the specified locale"})})).optional().openapi({description:"List of translations for the manufacturer"})}).openapi("UpdateManufacturer");
@@ -4,14 +4,7 @@ import { CreateManufacturerSchema, UpdateManufacturerSchema } from "../../schema
4
4
  declare class ManufacturerService {
5
5
  private readonly prisma;
6
6
  constructor(prisma: PrismaClientType);
7
- /**
8
- * Find a manufacturer by ID and organization ID
9
- * @throws HttpException with 404 status if manufacturer is not found
10
- */
11
7
  private findManufacturer;
12
- /**
13
- * Create a new manufacturer
14
- */
15
8
  createManufacturer(organizationId: string, userId: string, body: z.infer<typeof CreateManufacturerSchema>): Promise<{
16
9
  id: string;
17
10
  name: string;
@@ -28,9 +21,6 @@ declare class ManufacturerService {
28
21
  about?: string | null | undefined;
29
22
  }[] | undefined;
30
23
  }>;
31
- /**
32
- * Get a manufacturer by ID
33
- */
34
24
  getManufacturer(organizationId: string, id: string, query: {
35
25
  locale?: string | null;
36
26
  }): Promise<{
@@ -61,9 +51,6 @@ declare class ManufacturerService {
61
51
  filename: string;
62
52
  } | null | undefined;
63
53
  }>;
64
- /**
65
- * Get a paginated list of manufacturers
66
- */
67
54
  getManufacturers(organizationId: string, query: {
68
55
  page?: number;
69
56
  limit?: number;
@@ -119,9 +106,6 @@ declare class ManufacturerService {
119
106
  } | null | undefined;
120
107
  }[];
121
108
  }>;
122
- /**
123
- * Update a manufacturer
124
- */
125
109
  updateManufacturer(organizationId: string, id: string, userId: string, body: z.infer<typeof UpdateManufacturerSchema>): Promise<{
126
110
  id: string;
127
111
  name: string;
@@ -138,9 +122,6 @@ declare class ManufacturerService {
138
122
  about?: string | null | undefined;
139
123
  }[] | undefined;
140
124
  }>;
141
- /**
142
- * Delete a manufacturer (soft delete)
143
- */
144
125
  deleteManufacturer(organizationId: string, id: string, userId: string): Promise<void>;
145
126
  }
146
127
  export { ManufacturerService };
@@ -1,190 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { z } from "@hono/zod-openapi";
3
- import { HttpException } from "../../core/exceptions/http-exception";
4
- import { flattenTranslationData } from "../../core/utils/zod.util";
5
- import { LocalizedManufacturerSchema, ManufacturerSchema, PaginationMetaSchema, } from "../../schemas";
6
- class ManufacturerService {
7
- constructor(prisma) {
8
- this.prisma = prisma;
9
- }
10
- /**
11
- * Find a manufacturer by ID and organization ID
12
- * @throws HttpException with 404 status if manufacturer is not found
13
- */
14
- findManufacturer(id, organizationId, options) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const manufacturer = yield this.prisma.manufacturer.findUnique({
17
- where: {
18
- id,
19
- organizationId,
20
- deletedAt: null,
21
- },
22
- include: options === null || options === void 0 ? void 0 : options.include,
23
- });
24
- if (!manufacturer) {
25
- throw new HttpException(404, "Manufacturer not found");
26
- }
27
- return manufacturer;
28
- });
29
- }
30
- /**
31
- * Create a new manufacturer
32
- */
33
- createManufacturer(organizationId, userId, body) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- // Create new manufacturer
36
- const manufacturer = yield this.prisma.manufacturer.create({
37
- data: {
38
- name: body.name,
39
- organizationId,
40
- createdBy: userId,
41
- logoId: body.logoId,
42
- translations: {
43
- create: body.translations,
44
- },
45
- },
46
- include: {
47
- translations: true,
48
- logo: true,
49
- },
50
- });
51
- return ManufacturerSchema.parse(manufacturer);
52
- });
53
- }
54
- /**
55
- * Get a manufacturer by ID
56
- */
57
- getManufacturer(organizationId, id, query) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- // Extract locale from query parameter
60
- const { locale } = query;
61
- const manufacturer = yield this.findManufacturer(id, organizationId, {
62
- include: {
63
- logo: true,
64
- translations: locale
65
- ? {
66
- where: { locale },
67
- }
68
- : true,
69
- },
70
- });
71
- if (!locale) {
72
- return ManufacturerSchema.parse(manufacturer);
73
- }
74
- // If locale is provided, flatten the translations data and use LocalizedManufacturerSchema
75
- return LocalizedManufacturerSchema.parse(flattenTranslationData(manufacturer));
76
- });
77
- }
78
- /**
79
- * Get a paginated list of manufacturers
80
- */
81
- getManufacturers(organizationId, query) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const { page = 1, limit = 10, search, locale } = query;
84
- // Fetch manufacturers with pagination
85
- const [list, meta] = yield this.prisma.manufacturer
86
- .paginate({
87
- orderBy: {
88
- createdAt: "desc",
89
- },
90
- where: Object.assign({ organizationId, deletedAt: null }, (search && {
91
- name: {
92
- contains: search,
93
- mode: "insensitive",
94
- },
95
- })),
96
- include: {
97
- logo: true,
98
- translations: locale
99
- ? {
100
- where: { locale },
101
- }
102
- : true,
103
- },
104
- })
105
- .withPages({
106
- page,
107
- limit,
108
- });
109
- if (!locale) {
110
- // Return standard response with ManufacturerSchema
111
- return z
112
- .object({
113
- meta: PaginationMetaSchema,
114
- list: z.array(ManufacturerSchema),
115
- })
116
- .parse({
117
- meta,
118
- list,
119
- });
120
- }
121
- // Process the list for localization
122
- const localizedList = list.map((item) => flattenTranslationData(item));
123
- // Return localized response with LocalizedManufacturerSchema
124
- return z
125
- .object({
126
- meta: PaginationMetaSchema,
127
- list: z.array(LocalizedManufacturerSchema),
128
- })
129
- .parse({
130
- meta,
131
- list: localizedList,
132
- });
133
- });
134
- }
135
- /**
136
- * Update a manufacturer
137
- */
138
- updateManufacturer(organizationId, id, userId, body) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- // Fetch manufacturer by id
141
- yield this.findManufacturer(id, organizationId);
142
- // Update manufacturer
143
- const updatedManufacturer = yield this.prisma.manufacturer.update({
144
- where: {
145
- id,
146
- organizationId,
147
- deletedAt: null,
148
- },
149
- data: {
150
- updatedBy: userId,
151
- name: body.name,
152
- translations: {
153
- deleteMany: {},
154
- create: body.translations || [],
155
- },
156
- logoId: body.logoId,
157
- },
158
- include: {
159
- logo: true,
160
- translations: true,
161
- },
162
- });
163
- return ManufacturerSchema.parse(updatedManufacturer);
164
- });
165
- }
166
- /**
167
- * Delete a manufacturer (soft delete)
168
- */
169
- deleteManufacturer(organizationId, id, userId) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- // Fetch manufacturer by id
172
- yield this.findManufacturer(id, organizationId);
173
- // Soft delete manufacturer
174
- yield this.prisma.manufacturer.update({
175
- where: {
176
- id,
177
- organizationId,
178
- deletedAt: null,
179
- },
180
- data: {
181
- deletedAt: new Date(),
182
- deletedBy: userId,
183
- },
184
- });
185
- return;
186
- });
187
- }
188
- }
189
- export { ManufacturerService };
190
- //# sourceMappingURL=manufacturer.service.js.map
1
+ import{__awaiter as e}from"tslib";import{z as t}from"@hono/zod-openapi";import{HttpException as a}from"../../core/exceptions/http-exception";import{flattenTranslationData as r}from"../../core/utils/zod.util";import{LocalizedManufacturerSchema as i,ManufacturerSchema as n,PaginationMetaSchema as o}from"../../schemas";class d{constructor(e){this.prisma=e}findManufacturer(t,r,i){return e(this,void 0,void 0,function*(){const e=yield this.prisma.manufacturer.findUnique({where:{id:t,organizationId:r,deletedAt:null},include:null==i?void 0:i.include});if(!e)throw new a(404,"Manufacturer not found");return e})}createManufacturer(t,a,r){return e(this,void 0,void 0,function*(){const e=yield this.prisma.manufacturer.create({data:{name:r.name,organizationId:t,createdBy:a,logoId:r.logoId,translations:{create:r.translations}},include:{translations:!0,logo:!0}});return n.parse(e)})}getManufacturer(t,a,o){return e(this,void 0,void 0,function*(){const{locale:e}=o,d=yield this.findManufacturer(a,t,{include:{logo:!0,translations:!e||{where:{locale:e}}}});return e?i.parse(r(d)):n.parse(d)})}getManufacturers(a,d){return e(this,void 0,void 0,function*(){const{page:e=1,limit:s=10,search:u,locale:l}=d,[c,m]=yield this.prisma.manufacturer.paginate({orderBy:{createdAt:"desc"},where:Object.assign({organizationId:a,deletedAt:null},u&&{name:{contains:u,mode:"insensitive"}}),include:{logo:!0,translations:!l||{where:{locale:l}}}}).withPages({page:e,limit:s});if(!l)return t.object({meta:o,list:t.array(n)}).parse({meta:m,list:c});const f=c.map(e=>r(e));return t.object({meta:o,list:t.array(i)}).parse({meta:m,list:f})})}updateManufacturer(t,a,r,i){return e(this,void 0,void 0,function*(){yield this.findManufacturer(a,t);const e=yield this.prisma.manufacturer.update({where:{id:a,organizationId:t,deletedAt:null},data:{updatedBy:r,name:i.name,translations:{deleteMany:{},create:i.translations||[]},logoId:i.logoId},include:{logo:!0,translations:!0}});return n.parse(e)})}deleteManufacturer(t,a,r){return e(this,void 0,void 0,function*(){yield this.findManufacturer(a,t),yield this.prisma.manufacturer.update({where:{id:a,organizationId:t,deletedAt:null},data:{deletedAt:new Date,deletedBy:r}})})}}export{d as ManufacturerService};