@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,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=Verification.js.map
1
+ export{};
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=models.js.map
1
+ export{};
@@ -1,2 +1 @@
1
- export * from "./__generated__/client/client";
2
- //# sourceMappingURL=index.js.map
1
+ export*from"./__generated__/client/client";
@@ -1,9 +1 @@
1
- class HttpException extends Error {
2
- constructor(status, message) {
3
- super(message);
4
- this.status = status;
5
- this.message = message;
6
- }
7
- }
8
- export { HttpException };
9
- //# sourceMappingURL=http-exception.js.map
1
+ class s extends Error{constructor(s,t){super(t),this.status=s,this.message=t}}export{s as HttpException};
@@ -1,123 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
3
- import { getReasonPhrase, StatusCodes } from "http-status-codes";
4
- import { HttpException } from "../exceptions/http-exception";
5
- const toOpenApiPath = (path) => {
6
- return path.replace(/:([A-Za-z0-9_]+)/g, "{$1}");
7
- };
8
- const buildResponse = (status, schema) => {
9
- const description = status === StatusCodes.NO_CONTENT
10
- ? "No Content"
11
- : getReasonPhrase(status);
12
- if (!schema || status === StatusCodes.NO_CONTENT) {
13
- return { description };
14
- }
15
- return {
16
- content: {
17
- "application/json": {
18
- schema,
19
- },
20
- },
21
- description,
22
- };
23
- };
24
- export const createApiRoute = ({ body, bodyRequired = true, description, headers, method, operationId, path, pathParams, query, responses, summary, tags, }) => {
25
- return createRoute({
26
- description,
27
- method: method.toLowerCase(),
28
- operationId,
29
- path: toOpenApiPath(path),
30
- request: Object.assign(Object.assign(Object.assign(Object.assign({}, (body
31
- ? {
32
- body: {
33
- content: {
34
- "application/json": {
35
- schema: body,
36
- },
37
- },
38
- required: bodyRequired,
39
- },
40
- }
41
- : {})), (headers ? { headers } : {})), (pathParams ? { params: pathParams } : {})), (query ? { query } : {})),
42
- responses: Object.fromEntries(Object.entries(responses).map(([status, schema]) => [
43
- Number(status),
44
- buildResponse(Number(status), schema),
45
- ])),
46
- summary,
47
- tags,
48
- });
49
- };
50
- export const createApiRouter = () => {
51
- return new OpenAPIHono({
52
- defaultHook: (result, c) => {
53
- if (result.success) {
54
- return;
55
- }
56
- return c.json({
57
- error: result.error.flatten(),
58
- message: "Validation Error",
59
- status: StatusCodes.BAD_REQUEST,
60
- }, StatusCodes.BAD_REQUEST);
61
- },
62
- });
63
- };
64
- export const createUnavailableAuth = () => ({
65
- getCurrentUser: () => __awaiter(void 0, void 0, void 0, function* () {
66
- throw new Error("Auth is not available for OpenAPI generation.");
67
- }),
68
- isGranted: () => __awaiter(void 0, void 0, void 0, function* () {
69
- throw new Error("Auth is not available for OpenAPI generation.");
70
- }),
71
- });
72
- export const attachAuthContext = (app, auth) => {
73
- app.use("*", (c, next) => __awaiter(void 0, void 0, void 0, function* () {
74
- c.set("auth", auth);
75
- Object.assign(c.req.raw, { auth });
76
- yield next();
77
- }));
78
- return app;
79
- };
80
- export const handleAppError = (error) => {
81
- var _a;
82
- if (error instanceof HttpException) {
83
- return new Response(JSON.stringify({
84
- message: error.message,
85
- status: error.status,
86
- }), {
87
- headers: {
88
- "content-type": "application/json",
89
- },
90
- status: error.status,
91
- });
92
- }
93
- const authStatus = typeof (error === null || error === void 0 ? void 0 : error.statusCode) === "number"
94
- ? error.statusCode
95
- : undefined;
96
- if (!authStatus || authStatus >= StatusCodes.INTERNAL_SERVER_ERROR) {
97
- console.error(error);
98
- }
99
- if (authStatus) {
100
- const message = ((_a = error === null || error === void 0 ? void 0 : error.body) === null || _a === void 0 ? void 0 : _a.message) ||
101
- (error === null || error === void 0 ? void 0 : error.message) ||
102
- getReasonPhrase(authStatus);
103
- return new Response(JSON.stringify({
104
- message,
105
- status: authStatus,
106
- }), {
107
- headers: {
108
- "content-type": "application/json",
109
- },
110
- status: authStatus,
111
- });
112
- }
113
- return new Response(JSON.stringify({
114
- message: "Internal Server Error",
115
- status: StatusCodes.INTERNAL_SERVER_ERROR,
116
- }), {
117
- headers: {
118
- "content-type": "application/json",
119
- },
120
- status: StatusCodes.INTERNAL_SERVER_ERROR,
121
- });
122
- };
123
- //# sourceMappingURL=hono.js.map
1
+ import{__awaiter as e}from"tslib";import{createRoute as t,OpenAPIHono as o}from"@hono/zod-openapi";import{getReasonPhrase as s,StatusCodes as r}from"http-status-codes";import{HttpException as n}from"../exceptions/http-exception";const a=e=>e.replace(/:([A-Za-z0-9_]+)/g,"{$1}"),i=(e,t)=>{const o=e===r.NO_CONTENT?"No Content":s(e);return t&&e!==r.NO_CONTENT?{content:{"application/json":{schema:t}},description:o}:{description:o}};export const createApiRoute=({body:e,bodyRequired:o=!0,description:s,headers:r,method:n,operationId:p,path:c,pathParams:u,query:d,responses:m,summary:l,tags:R})=>t({description:s,method:n.toLowerCase(),operationId:p,path:a(c),request:Object.assign(Object.assign(Object.assign(Object.assign({},e?{body:{content:{"application/json":{schema:e}},required:o}}:{}),r?{headers:r}:{}),u?{params:u}:{}),d?{query:d}:{}),responses:Object.fromEntries(Object.entries(m).map(([e,t])=>[Number(e),i(Number(e),t)])),summary:l,tags:R});export const createApiRouter=()=>new o({defaultHook:(e,t)=>{if(!e.success)return t.json({error:e.error.flatten(),message:"Validation Error",status:r.BAD_REQUEST},r.BAD_REQUEST)}});export const createUnavailableAuth=()=>({getCurrentUser:()=>e(void 0,void 0,void 0,function*(){throw new Error("Auth is not available for OpenAPI generation.")}),isGranted:()=>e(void 0,void 0,void 0,function*(){throw new Error("Auth is not available for OpenAPI generation.")})});export const attachAuthContext=(t,o)=>(t.use("*",(t,s)=>e(void 0,void 0,void 0,function*(){t.set("auth",o),Object.assign(t.req.raw,{auth:o}),yield s()})),t);export const handleAppError=e=>{var t;if(e instanceof n)return new Response(JSON.stringify({message:e.message,status:e.status}),{headers:{"content-type":"application/json"},status:e.status});const o="number"==typeof(null==e?void 0:e.statusCode)?e.statusCode:void 0;if((!o||o>=r.INTERNAL_SERVER_ERROR)&&console.error(e),o){const r=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.message)||(null==e?void 0:e.message)||s(o);return new Response(JSON.stringify({message:r,status:o}),{headers:{"content-type":"application/json"},status:o})}return new Response(JSON.stringify({message:"Internal Server Error",status:r.INTERNAL_SERVER_ERROR}),{headers:{"content-type":"application/json"},status:r.INTERNAL_SERVER_ERROR})};
@@ -2,7 +2,15 @@ import type { SqlDriverAdapterFactory } from "@prisma/client/runtime/client";
2
2
  import { Prisma } from "../db";
3
3
  export type CreatePrismaClientOptions = {
4
4
  adapter: SqlDriverAdapterFactory;
5
- } & Omit<Prisma.PrismaClientOptions, "adapter" | "accelerateUrl">;
5
+ errorFormat?: Prisma.ErrorFormat;
6
+ log?: (Prisma.LogLevel | Prisma.LogDefinition)[];
7
+ transactionOptions?: {
8
+ maxWait?: number;
9
+ timeout?: number;
10
+ isolationLevel?: Prisma.TransactionIsolationLevel;
11
+ };
12
+ omit?: Prisma.GlobalOmitConfig;
13
+ };
6
14
  export declare const createPrismaClient: (options: CreatePrismaClientOptions) => import("@prisma/client/runtime/client").DynamicClientExtensionThis<Prisma.TypeMap<import("@prisma/client/runtime/client").InternalArgs & {
7
15
  result: {};
8
16
  model: {
@@ -1,11 +1 @@
1
- import { pagination } from "prisma-extension-pagination";
2
- import { PrismaClient } from "../db";
3
- export const createPrismaClient = (options) => {
4
- return new PrismaClient(options).$extends(pagination({
5
- pages: {
6
- limit: 15,
7
- includePageCount: true,
8
- },
9
- }));
10
- };
11
- //# sourceMappingURL=prisma.js.map
1
+ import{pagination as e}from"prisma-extension-pagination";import{PrismaClient as i}from"../db";export const createPrismaClient=t=>new i(t).$extends(e({pages:{limit:15,includePageCount:!0}}));
@@ -1,5 +1 @@
1
- import pino from "pino";
2
- export const logger = pino({
3
- timestamp: pino.stdTimeFunctions.isoTime,
4
- });
5
- //# sourceMappingURL=pino.js.map
1
+ import o from"pino";export const logger=o({timestamp:o.stdTimeFunctions.isoTime});
@@ -7,26 +7,11 @@ interface ReservationWithRelations extends Reservation {
7
7
  declare class EmailService {
8
8
  private resend;
9
9
  constructor(apiKey: string);
10
- /**
11
- * Sends an email
12
- */
13
10
  sendEmail(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<void>;
14
- /**
15
- * Sends an order confirmation email
16
- */
17
11
  sendOrderConfirmationEmail(user: User, organization: Organization, order: Order): Promise<void>;
18
- /**
19
- * Sends an order confirmation email
20
- */
21
12
  sendOrderNotificationEmail(user: User, member: User, organization: Organization, order: Order): Promise<void>;
22
13
  sendReservationConfirmationEmail(reservation: ReservationWithRelations): Promise<void>;
23
- /**
24
- * Sends a reservation cancellation email
25
- */
26
14
  sendReservationCancellationEmail(reservation: ReservationWithRelations): Promise<void>;
27
- /**
28
- * Sends a reservation notification email to an organization member
29
- */
30
15
  sendReservationNotificationEmail(member: User, reservation: ReservationWithRelations): Promise<void>;
31
16
  }
32
17
  export { EmailService };
@@ -1,116 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { Resend } from "resend";
3
- import { OrderConfirmationEmail } from "../../features/order/emails/order-confirmation.email";
4
- import OrderNotificationEmail from "../../features/order/emails/order-notification.email";
5
- import { ReservationCancellationEmail } from "../../features/reservation/emails/reservation-cancellation.email";
6
- import { ReservationConfirmationEmail } from "../../features/reservation/emails/reservation-confirmation.email";
7
- import ReservationNotificationEmail from "../../features/reservation/emails/reservation-notification.email";
8
- class EmailService {
9
- constructor(apiKey) {
10
- this.resend = new Resend(apiKey);
11
- }
12
- /**
13
- * Sends an email
14
- */
15
- sendEmail(payload, options) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const { data, error } = yield this.resend.emails.send(payload);
18
- });
19
- }
20
- /**
21
- * Sends an order confirmation email
22
- */
23
- sendOrderConfirmationEmail(user, organization, order) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- console.log(`Sending order confirmation email to ${user.email}`);
26
- yield this.sendEmail({
27
- from: `${organization.name} <info@shophost.io>`,
28
- to: [user.email],
29
- subject: `Order Confirmation - Order #${order.referenceId} | ${organization.name}`,
30
- react: OrderConfirmationEmail({
31
- user,
32
- organization,
33
- order,
34
- }),
35
- });
36
- });
37
- }
38
- /**
39
- * Sends an order confirmation email
40
- */
41
- sendOrderNotificationEmail(user, member, organization, order) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- console.log(`Sending order notification email to ${member.email}`);
44
- yield this.sendEmail({
45
- from: `${organization.name} <info@shophost.io>`,
46
- to: [member.email],
47
- subject: `You have received a new order | ${organization.name}`,
48
- react: OrderNotificationEmail({
49
- user,
50
- organization,
51
- order,
52
- }),
53
- });
54
- });
55
- }
56
- sendReservationConfirmationEmail(reservation) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const user = reservation.user;
59
- const organization = reservation.organization;
60
- console.log(`Sending reservation confirmation email to ${user.email}`);
61
- yield this.sendEmail({
62
- from: `${organization.name} <info@shophost.io>`,
63
- to: [user.email],
64
- subject: `Reservation Confirmation - ${organization.name}`,
65
- react: ReservationConfirmationEmail({
66
- user,
67
- organization,
68
- reservation,
69
- }),
70
- });
71
- });
72
- }
73
- /**
74
- * Sends a reservation cancellation email
75
- */
76
- sendReservationCancellationEmail(reservation) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- const user = reservation.user;
79
- const organization = reservation.organization;
80
- console.log(`Sending reservation cancellation email to ${user.email}`);
81
- yield this.sendEmail({
82
- from: `${organization.name} <info@shophost.io>`,
83
- to: [user.email],
84
- subject: `Reservation Cancelled - ${organization.name}`,
85
- react: ReservationCancellationEmail({
86
- user,
87
- organization,
88
- reservation,
89
- }),
90
- });
91
- });
92
- }
93
- /**
94
- * Sends a reservation notification email to an organization member
95
- */
96
- sendReservationNotificationEmail(member, reservation) {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const user = reservation.user;
99
- const organization = reservation.organization;
100
- console.log(`Sending reservation notification email to ${member.email}`);
101
- yield this.sendEmail({
102
- from: `${organization.name} <info@shophost.io>`,
103
- to: [member.email],
104
- subject: `New Reservation Request | ${organization.name}`,
105
- react: ReservationNotificationEmail({
106
- user,
107
- member,
108
- organization,
109
- reservation,
110
- }),
111
- });
112
- });
113
- }
114
- }
115
- export { EmailService };
116
- //# sourceMappingURL=email.service.js.map
1
+ import{__awaiter as e}from"tslib";import{Resend as i}from"resend";import{OrderConfirmationEmail as o}from"../../features/order/emails/order-confirmation.email";import n from"../../features/order/emails/order-notification.email";import{ReservationCancellationEmail as r}from"../../features/reservation/emails/reservation-cancellation.email";import{ReservationConfirmationEmail as t}from"../../features/reservation/emails/reservation-confirmation.email";import a from"../../features/reservation/emails/reservation-notification.email";class s{constructor(e){this.resend=new i(e)}sendEmail(i,o){return e(this,void 0,void 0,function*(){const{data:e,error:o}=yield this.resend.emails.send(i)})}sendOrderConfirmationEmail(i,n,r){return e(this,void 0,void 0,function*(){console.log(`Sending order confirmation email to ${i.email}`),yield this.sendEmail({from:`${n.name} <info@shophost.io>`,to:[i.email],subject:`Order Confirmation - Order #${r.referenceId} | ${n.name}`,react:o({user:i,organization:n,order:r})})})}sendOrderNotificationEmail(i,o,r,t){return e(this,void 0,void 0,function*(){console.log(`Sending order notification email to ${o.email}`),yield this.sendEmail({from:`${r.name} <info@shophost.io>`,to:[o.email],subject:`You have received a new order | ${r.name}`,react:n({user:i,organization:r,order:t})})})}sendReservationConfirmationEmail(i){return e(this,void 0,void 0,function*(){const e=i.user,o=i.organization;console.log(`Sending reservation confirmation email to ${e.email}`),yield this.sendEmail({from:`${o.name} <info@shophost.io>`,to:[e.email],subject:`Reservation Confirmation - ${o.name}`,react:t({user:e,organization:o,reservation:i})})})}sendReservationCancellationEmail(i){return e(this,void 0,void 0,function*(){const e=i.user,o=i.organization;console.log(`Sending reservation cancellation email to ${e.email}`),yield this.sendEmail({from:`${o.name} <info@shophost.io>`,to:[e.email],subject:`Reservation Cancelled - ${o.name}`,react:r({user:e,organization:o,reservation:i})})})}sendReservationNotificationEmail(i,o){return e(this,void 0,void 0,function*(){const e=o.user,n=o.organization;console.log(`Sending reservation notification email to ${i.email}`),yield this.sendEmail({from:`${n.name} <info@shophost.io>`,to:[i.email],subject:`New Reservation Request | ${n.name}`,react:a({user:e,member:i,organization:n,reservation:o})})})}}export{s as EmailService};
@@ -1,26 +1 @@
1
- import { buildApiApp } from "../../app";
2
- export const defaultOpenApiDocument = {
3
- info: {
4
- description: "API for Shophost Organization API",
5
- title: "Shophost API",
6
- version: "1.0",
7
- },
8
- openapi: "3.1.0",
9
- servers: [
10
- {
11
- description: "Local",
12
- url: "http://localhost:3001/api",
13
- },
14
- {
15
- description: "Production",
16
- url: "https://api.shophost.io/api",
17
- },
18
- ],
19
- };
20
- export const generateOpenApiSpec = (apiDoc = defaultOpenApiDocument, buildApiAppOptions = {}) => {
21
- const app = buildApiApp(buildApiAppOptions);
22
- return app.getOpenAPI31Document(apiDoc, {
23
- unionPreferredType: "oneOf",
24
- });
25
- };
26
- //# sourceMappingURL=openapi.lib.js.map
1
+ import{buildApiApp as o}from"../../app";export const defaultOpenApiDocument={info:{description:"API for Shophost Organization API",title:"Shophost API",version:"1.0"},openapi:"3.1.0",servers:[{description:"Local",url:"http://localhost:3001/api"},{description:"Production",url:"https://api.shophost.io/api"}]};export const generateOpenApiSpec=(e=defaultOpenApiDocument,p={})=>o(p).getOpenAPI31Document(e,{unionPreferredType:"oneOf"});
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=google-maps.types.js.map
1
+ export{};
@@ -1,11 +1 @@
1
- export const formatCurrencyAmount = (amount, currency = "USD", locale = "en-US") => {
2
- // Stripe amounts are in the smallest currency unit (e.g., cents for USD)
3
- const amountInMainUnit = amount / 100;
4
- return new Intl.NumberFormat(locale, {
5
- style: "currency",
6
- currency: currency,
7
- minimumFractionDigits: 2,
8
- maximumFractionDigits: 2,
9
- }).format(amountInMainUnit);
10
- };
11
- //# sourceMappingURL=currency.util.js.map
1
+ export const formatCurrencyAmount=(r,t="USD",n="en-US")=>{const m=r/100;return new Intl.NumberFormat(n,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(m)};
@@ -1,8 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- export function requireEnv(type, key) {
3
- if (type === "string") {
4
- return z.string().min(1, `${key} is required`).parse(process.env[key]);
5
- }
6
- return z.coerce.number().min(1, `${key} is required`).parse(process.env[key]);
7
- }
8
- //# sourceMappingURL=env.util.js.map
1
+ import{z as r}from"@hono/zod-openapi";export function requireEnv(e,n){return"string"===e?r.string().min(1,`${n} is required`).parse(process.env[n]):r.coerce.number().min(1,`${n} is required`).parse(process.env[n])}
@@ -1,11 +1 @@
1
- /**
2
- * A standalone implementation of Lodash's `_.get` in TypeScript.
3
- *
4
- * @param object The object to query.
5
- * @param path The path to get. Can be:
6
- * - a string in dot/bracket notation, e.g. "a.b[0].c"
7
- * - an array of string/number keys, e.g. ["a", "b", 0, "c"].
8
- * @param defaultValue The value returned if the resolved value is undefined.
9
- * @returns The resolved value, or defaultValue if it's undefined.
10
- */
11
1
  export declare const get: <T extends object, R = unknown>(object: T | null | undefined, path: string | Array<string | number>, defaultValue?: R) => R | unknown;
@@ -1,39 +1 @@
1
- /**
2
- * A standalone implementation of Lodash's `_.get` in TypeScript.
3
- *
4
- * @param object The object to query.
5
- * @param path The path to get. Can be:
6
- * - a string in dot/bracket notation, e.g. "a.b[0].c"
7
- * - an array of string/number keys, e.g. ["a", "b", 0, "c"].
8
- * @param defaultValue The value returned if the resolved value is undefined.
9
- * @returns The resolved value, or defaultValue if it's undefined.
10
- */
11
- export const get = (object, path, defaultValue) => {
12
- // If the object is null or undefined, return the defaultValue right away.
13
- if (object == null) {
14
- return defaultValue;
15
- }
16
- // Convert path into an array if it's not already.
17
- // This regex handles bracket-notation -> dot-notation, e.g. "a[0].b" -> "a.0.b".
18
- // Then we split on '.' to create an array of keys.
19
- const pathArray = Array.isArray(path)
20
- ? path
21
- : path
22
- .replace(/\[(\d+)\]/g, ".$1")
23
- .split(".")
24
- // filter out empty strings (e.g., if path had a leading or trailing dot)
25
- .filter(Boolean);
26
- // Start traversing
27
- let result = object;
28
- for (let i = 0; i < pathArray.length; i++) {
29
- const key = pathArray[i];
30
- // If the current value is null/undefined or doesn't have the key, return defaultValue.
31
- if (result == null || !(key in result)) {
32
- return defaultValue;
33
- }
34
- result = result[key];
35
- }
36
- // If we finally get `undefined`, return defaultValue, else the resolved value
37
- return result === undefined ? defaultValue : result;
38
- };
39
- //# sourceMappingURL=object.util.js.map
1
+ export const get=(r,t,e)=>{if(null==r)return e;const l=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=r;for(let r=0;r<l.length;r++){const t=l[r];if(null==n||!(t in n))return e;n=n[t]}return void 0===n?e:n};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=translations.util.js.map
@@ -1,15 +1,3 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- /**
3
- * A helper function that, given an array of field names,
4
- * ensures that each of these fields is present and non-empty
5
- * in the translation that matches the `defaultLocale`.
6
- */
7
2
  export declare const validateRequiredForDefaultLocale: (...requiredFields: string[]) => (data: any, ctx: z.RefinementCtx) => void;
8
- /**
9
- * Recursively processes an object and extracts values from 'translations' arrays.
10
- * If a field called 'translations' is found and it's an array with at least one object,
11
- * the values from that object are added to the parent object.
12
- * @param data The object to process
13
- * @returns A new object with translations extracted
14
- */
15
3
  export declare const flattenTranslationData: (data: any) => any;
@@ -1,85 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- /**
3
- * A helper function that, given an array of field names,
4
- * ensures that each of these fields is present and non-empty
5
- * in the translation that matches the `defaultLocale`.
6
- */
7
- export const validateRequiredForDefaultLocale = (...requiredFields) => (data, ctx) => {
8
- const { translations, defaultLocale } = data;
9
- // Find the index of the translation that matches the defaultLocale
10
- const defaultTranslationIndex = translations.findIndex((t) => t.locale === defaultLocale);
11
- // If there's no translation for the default locale, add an error
12
- if (defaultTranslationIndex === -1) {
13
- ctx.addIssue({
14
- code: z.ZodIssueCode.custom,
15
- message: "Missing translation for the default locale",
16
- path: ["translations"],
17
- });
18
- return;
19
- }
20
- // For each required field, check if it's present and non-empty
21
- requiredFields.forEach((fieldName) => {
22
- const fieldValue = translations[defaultTranslationIndex][fieldName];
23
- // Depending on your exact needs, this could be a more nuanced check,
24
- // e.g., for non-empty arrays, numeric values, etc.
25
- // Here, we assume "non-empty string" is the requirement.
26
- if (typeof fieldValue !== "string" || !fieldValue.trim()) {
27
- ctx.addIssue({
28
- code: z.ZodIssueCode.custom,
29
- message: `This field is required`,
30
- path: ["translations", defaultTranslationIndex, fieldName],
31
- });
32
- }
33
- });
34
- };
35
- /**
36
- * Recursively processes an object and extracts values from 'translations' arrays.
37
- * If a field called 'translations' is found and it's an array with at least one object,
38
- * the values from that object are added to the parent object.
39
- * @param data The object to process
40
- * @returns A new object with translations extracted
41
- */
42
- export const flattenTranslationData = (data) => {
43
- // If data is null, undefined, or not an object, return it as is
44
- if (data === null ||
45
- data === undefined ||
46
- typeof data !== "object" ||
47
- data instanceof Date) {
48
- return data;
49
- }
50
- // If data is an array, process each item recursively
51
- if (Array.isArray(data)) {
52
- return data.map((item) => flattenTranslationData(item));
53
- }
54
- // Create a new object to hold the result
55
- const result = {};
56
- // Process each property in the object
57
- for (const [key, value] of Object.entries(data)) {
58
- if (key === "translations" && Array.isArray(value) && value.length > 0) {
59
- // If we found a translations array with at least one object,
60
- // merge its properties into the result object
61
- const translationObj = value[0];
62
- if (translationObj && typeof translationObj === "object") {
63
- // Copy all properties from the first translation object to the result
64
- // except for the 'id' field
65
- for (const [translationKey, translationValue] of Object.entries(translationObj)) {
66
- if (translationKey !== "id") {
67
- result[translationKey] = translationValue;
68
- }
69
- }
70
- }
71
- }
72
- else if (typeof value === "object" &&
73
- value !== null &&
74
- !(value instanceof Date)) {
75
- // Recursively process nested objects
76
- result[key] = flattenTranslationData(value);
77
- }
78
- else {
79
- // Copy primitive values and dates as is
80
- result[key] = value;
81
- }
82
- }
83
- return result;
84
- };
85
- //# sourceMappingURL=zod.util.js.map
1
+ import{z as t}from"@hono/zod-openapi";export const validateRequiredForDefaultLocale=(...e)=>(o,a)=>{const{translations:s,defaultLocale:n}=o,r=s.findIndex(t=>t.locale===n);-1!==r?e.forEach(e=>{const o=s[r][e];"string"==typeof o&&o.trim()||a.addIssue({code:t.ZodIssueCode.custom,message:"This field is required",path:["translations",r,e]})}):a.addIssue({code:t.ZodIssueCode.custom,message:"Missing translation for the default locale",path:["translations"]})};export const flattenTranslationData=t=>{if(null==t||"object"!=typeof t||t instanceof Date)return t;if(Array.isArray(t))return t.map(t=>flattenTranslationData(t));const e={};for(const[o,a]of Object.entries(t))if("translations"===o&&Array.isArray(a)&&a.length>0){const t=a[0];if(t&&"object"==typeof t)for(const[o,a]of Object.entries(t))"id"!==o&&(e[o]=a)}else"object"!=typeof a||null===a||a instanceof Date?e[o]=a:e[o]=flattenTranslationData(a);return e};
package/src/db.js CHANGED
@@ -1,3 +1 @@
1
- export * from "./core/db";
2
- export { createPrismaClient, } from "./core/lib/prisma";
3
- //# sourceMappingURL=db.js.map
1
+ export*from"./core/db";export{createPrismaClient}from"./core/lib/prisma";