@shophost/rest-api 0.1.21 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (707) hide show
  1. package/README.md +8 -2
  2. package/global.d.ts +1 -1
  3. package/package.json +16 -16
  4. package/src/app.d.ts +16 -0
  5. package/src/app.js +46 -0
  6. package/src/app.js.map +1 -0
  7. package/src/client/__generated__/openapi.json +13633 -0
  8. package/src/client/generated/client/client.gen.d.ts +2 -0
  9. package/src/client/generated/client/client.gen.js +200 -0
  10. package/src/client/generated/client/client.gen.js.map +1 -0
  11. package/src/client/generated/client/index.d.ts +8 -0
  12. package/src/client/generated/client/index.js +7 -0
  13. package/src/client/generated/client/index.js.map +1 -0
  14. package/src/client/generated/client/types.gen.d.ts +117 -0
  15. package/src/client/generated/client/types.gen.js +3 -0
  16. package/src/client/generated/client/types.gen.js.map +1 -0
  17. package/src/client/generated/client/utils.gen.d.ts +33 -0
  18. package/src/client/generated/client/utils.gen.js +221 -0
  19. package/src/client/generated/client/utils.gen.js.map +1 -0
  20. package/src/client/generated/client.gen.d.ts +12 -0
  21. package/src/client/generated/client.gen.js +4 -0
  22. package/src/client/generated/client.gen.js.map +1 -0
  23. package/src/client/generated/core/auth.gen.d.ts +18 -0
  24. package/src/client/generated/core/auth.gen.js +16 -0
  25. package/src/client/generated/core/auth.gen.js.map +1 -0
  26. package/src/client/generated/core/bodySerializer.gen.d.ts +25 -0
  27. package/src/client/generated/core/bodySerializer.gen.js +58 -0
  28. package/src/client/generated/core/bodySerializer.gen.js.map +1 -0
  29. package/src/client/generated/core/params.gen.d.ts +43 -0
  30. package/src/client/generated/core/params.gen.js +101 -0
  31. package/src/client/generated/core/params.gen.js.map +1 -0
  32. package/src/client/generated/core/pathSerializer.gen.d.ts +33 -0
  33. package/src/client/generated/core/pathSerializer.gen.js +115 -0
  34. package/src/client/generated/core/pathSerializer.gen.js.map +1 -0
  35. package/src/client/generated/core/queryKeySerializer.gen.d.ts +18 -0
  36. package/src/client/generated/core/queryKeySerializer.gen.js +100 -0
  37. package/src/client/generated/core/queryKeySerializer.gen.js.map +1 -0
  38. package/src/client/generated/core/serverSentEvents.gen.d.ts +71 -0
  39. package/src/client/generated/core/serverSentEvents.gen.js +135 -0
  40. package/src/client/generated/core/serverSentEvents.gen.js.map +1 -0
  41. package/src/client/generated/core/types.gen.d.ts +78 -0
  42. package/src/client/generated/core/types.gen.js +3 -0
  43. package/src/client/generated/core/types.gen.js.map +1 -0
  44. package/src/client/generated/core/utils.gen.d.ts +19 -0
  45. package/src/client/generated/core/utils.gen.js +88 -0
  46. package/src/client/generated/core/utils.gen.js.map +1 -0
  47. package/src/client/generated/index.d.ts +2 -0
  48. package/src/client/generated/index.js +3 -0
  49. package/src/client/generated/index.js.map +1 -0
  50. package/src/client/generated/sdk.gen.d.ts +315 -0
  51. package/src/client/generated/sdk.gen.js +360 -0
  52. package/src/client/generated/sdk.gen.js.map +1 -0
  53. package/src/client/generated/types.gen.d.ts +5113 -0
  54. package/src/client/generated/types.gen.js +3 -0
  55. package/src/client/generated/types.gen.js.map +1 -0
  56. package/src/client/index.d.ts +112 -0
  57. package/src/client/index.js +147 -0
  58. package/src/client/index.js.map +1 -0
  59. package/src/core/auth/auth.schema.d.ts +11 -0
  60. package/src/{schemas → core/auth}/auth.schema.js +10 -8
  61. package/src/core/auth/auth.schema.js.map +1 -0
  62. package/src/{utils → core/auth}/auth.util.d.ts +1 -1
  63. package/src/core/auth/auth.util.js.map +1 -0
  64. package/src/{lib → core/auth}/better-auth.lib.d.ts +1 -1
  65. package/src/{lib → core/auth}/better-auth.lib.js +1 -1
  66. package/src/core/auth/better-auth.lib.js.map +1 -0
  67. package/src/core/auth/generate-password-hash.util.js.map +1 -0
  68. package/src/core/auth/headers.schema.d.ts +5 -0
  69. package/src/{schemas → core/auth}/headers.schema.js +10 -3
  70. package/src/core/auth/headers.schema.js.map +1 -0
  71. package/src/core/auth/user.schema.d.ts +10 -0
  72. package/src/{schemas → core/auth}/user.schema.js +1 -3
  73. package/src/core/auth/user.schema.js.map +1 -0
  74. package/src/core/db/__generated__/client/browser.d.ts +164 -0
  75. package/src/core/db/__generated__/client/browser.js +18 -0
  76. package/src/core/db/__generated__/client/browser.js.map +1 -0
  77. package/src/core/db/__generated__/client/client.d.ts +183 -0
  78. package/src/core/db/__generated__/client/client.js +35 -0
  79. package/src/core/db/__generated__/client/client.js.map +1 -0
  80. package/src/{db → core/db}/__generated__/client/commonInputTypes.d.ts +1 -6
  81. package/src/{db → core/db}/__generated__/client/commonInputTypes.js +2 -1
  82. package/src/core/db/__generated__/client/commonInputTypes.js.map +1 -0
  83. package/src/{db → core/db}/__generated__/client/enums.d.ts +0 -5
  84. package/src/{db → core/db}/__generated__/client/enums.js +2 -1
  85. package/src/core/db/__generated__/client/enums.js.map +1 -0
  86. package/src/{db → core/db}/__generated__/client/internal/class.d.ts +117 -60
  87. package/src/core/db/__generated__/client/internal/class.js +55 -0
  88. package/src/core/db/__generated__/client/internal/class.js.map +1 -0
  89. package/src/{db → core/db}/__generated__/client/internal/prismaNamespace.d.ts +62 -125
  90. package/src/{db → core/db}/__generated__/client/internal/prismaNamespace.js +13 -16
  91. package/src/core/db/__generated__/client/internal/prismaNamespace.js.map +1 -0
  92. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.d.ts +535 -0
  93. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +512 -0
  94. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js.map +1 -0
  95. package/src/{db → core/db}/__generated__/client/models/Account.d.ts +1 -6
  96. package/src/core/db/__generated__/client/models/Account.js.map +1 -0
  97. package/src/{db → core/db}/__generated__/client/models/Address.d.ts +1 -6
  98. package/src/core/db/__generated__/client/models/Address.js.map +1 -0
  99. package/src/{db → core/db}/__generated__/client/models/Campaign.d.ts +1 -6
  100. package/src/core/db/__generated__/client/models/Campaign.js.map +1 -0
  101. package/src/{db → core/db}/__generated__/client/models/ClosingTimes.d.ts +1 -6
  102. package/src/core/db/__generated__/client/models/ClosingTimes.js.map +1 -0
  103. package/src/{db → core/db}/__generated__/client/models/File.d.ts +1 -6
  104. package/src/core/db/__generated__/client/models/File.js.map +1 -0
  105. package/src/{db → core/db}/__generated__/client/models/Invitation.d.ts +1 -6
  106. package/src/core/db/__generated__/client/models/Invitation.js.map +1 -0
  107. package/src/{db → core/db}/__generated__/client/models/LegalEntity.d.ts +1 -6
  108. package/src/core/db/__generated__/client/models/LegalEntity.js.map +1 -0
  109. package/src/{db → core/db}/__generated__/client/models/Manufacturer.d.ts +1 -6
  110. package/src/core/db/__generated__/client/models/Manufacturer.js.map +1 -0
  111. package/src/{db → core/db}/__generated__/client/models/ManufacturerTranslation.d.ts +1 -6
  112. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js.map +1 -0
  113. package/src/{db → core/db}/__generated__/client/models/Member.d.ts +1 -6
  114. package/src/core/db/__generated__/client/models/Member.js.map +1 -0
  115. package/src/{db → core/db}/__generated__/client/models/Modifier.d.ts +1 -6
  116. package/src/core/db/__generated__/client/models/Modifier.js.map +1 -0
  117. package/src/{db → core/db}/__generated__/client/models/ModifierGroup.d.ts +1 -6
  118. package/src/core/db/__generated__/client/models/ModifierGroup.js.map +1 -0
  119. package/src/{db → core/db}/__generated__/client/models/ModifierGroupTranslation.d.ts +1 -6
  120. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js.map +1 -0
  121. package/src/{db → core/db}/__generated__/client/models/OpeningTimes.d.ts +1 -6
  122. package/src/core/db/__generated__/client/models/OpeningTimes.js.map +1 -0
  123. package/src/{db → core/db}/__generated__/client/models/Order.d.ts +1 -6
  124. package/src/core/db/__generated__/client/models/Order.js.map +1 -0
  125. package/src/{db → core/db}/__generated__/client/models/OrderItem.d.ts +1 -6
  126. package/src/core/db/__generated__/client/models/OrderItem.js.map +1 -0
  127. package/src/{db → core/db}/__generated__/client/models/OrderItemTranslation.d.ts +1 -6
  128. package/src/core/db/__generated__/client/models/OrderItemTranslation.js.map +1 -0
  129. package/src/{db → core/db}/__generated__/client/models/Organization.d.ts +1 -6
  130. package/src/core/db/__generated__/client/models/Organization.js.map +1 -0
  131. package/src/{db → core/db}/__generated__/client/models/OrganizationConfiguration.d.ts +1 -6
  132. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js.map +1 -0
  133. package/src/{db → core/db}/__generated__/client/models/Payment.d.ts +1 -6
  134. package/src/core/db/__generated__/client/models/Payment.js.map +1 -0
  135. package/src/{db → core/db}/__generated__/client/models/PaymentSession.d.ts +1 -6
  136. package/src/core/db/__generated__/client/models/PaymentSession.js.map +1 -0
  137. package/src/{db → core/db}/__generated__/client/models/Product.d.ts +1 -6
  138. package/src/core/db/__generated__/client/models/Product.js.map +1 -0
  139. package/src/{db → core/db}/__generated__/client/models/ProductCategory.d.ts +1 -6
  140. package/src/core/db/__generated__/client/models/ProductCategory.js.map +1 -0
  141. package/src/{db → core/db}/__generated__/client/models/ProductCategoryTranslation.d.ts +1 -6
  142. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js.map +1 -0
  143. package/src/{db → core/db}/__generated__/client/models/ProductSnapshot.d.ts +1 -6
  144. package/src/core/db/__generated__/client/models/ProductSnapshot.js.map +1 -0
  145. package/src/{db → core/db}/__generated__/client/models/ProductTranslation.d.ts +1 -6
  146. package/src/core/db/__generated__/client/models/ProductTranslation.js.map +1 -0
  147. package/src/{db → core/db}/__generated__/client/models/Reservation.d.ts +1 -6
  148. package/src/core/db/__generated__/client/models/Reservation.js.map +1 -0
  149. package/src/{db → core/db}/__generated__/client/models/Session.d.ts +1 -6
  150. package/src/core/db/__generated__/client/models/Session.js.map +1 -0
  151. package/src/{db → core/db}/__generated__/client/models/ShippingMethod.d.ts +1 -6
  152. package/src/core/db/__generated__/client/models/ShippingMethod.js.map +1 -0
  153. package/src/{db → core/db}/__generated__/client/models/ShippingZone.d.ts +1 -6
  154. package/src/core/db/__generated__/client/models/ShippingZone.js.map +1 -0
  155. package/src/{db → core/db}/__generated__/client/models/User.d.ts +1 -6
  156. package/src/core/db/__generated__/client/models/User.js.map +1 -0
  157. package/src/{db → core/db}/__generated__/client/models/Verification.d.ts +1 -6
  158. package/src/core/db/__generated__/client/models/Verification.js.map +1 -0
  159. package/src/{db → core/db}/__generated__/client/models.d.ts +0 -5
  160. package/src/core/db/__generated__/client/models.js.map +1 -0
  161. package/src/core/db/index.d.ts +1 -0
  162. package/src/core/db/index.js +2 -0
  163. package/src/core/db/index.js.map +1 -0
  164. package/src/core/exceptions/http-exception.js.map +1 -0
  165. package/src/core/hono/hono.d.ts +34 -0
  166. package/src/core/hono/hono.js +123 -0
  167. package/src/core/hono/hono.js.map +1 -0
  168. package/src/{lib → core/lib}/prisma.d.ts +333 -340
  169. package/src/core/lib/prisma.js.map +1 -0
  170. package/src/core/logging/pino.js.map +1 -0
  171. package/src/{services → core/notifications}/email.service.d.ts +1 -1
  172. package/src/{services → core/notifications}/email.service.js +5 -5
  173. package/src/core/notifications/email.service.js.map +1 -0
  174. package/src/core/openapi/openapi.lib.d.ts +13 -0
  175. package/src/core/openapi/openapi.lib.js +26 -0
  176. package/src/core/openapi/openapi.lib.js.map +1 -0
  177. package/src/core/types/google-maps.types.js.map +1 -0
  178. package/src/core/utils/currency.util.js.map +1 -0
  179. package/src/{utils → core/utils}/env.util.js +1 -1
  180. package/src/core/utils/env.util.js.map +1 -0
  181. package/src/core/utils/object.util.js.map +1 -0
  182. package/src/core/utils/translations.util.js.map +1 -0
  183. package/src/{utils → core/utils}/zod.util.d.ts +1 -1
  184. package/src/{utils → core/utils}/zod.util.js +1 -1
  185. package/src/core/utils/zod.util.js.map +1 -0
  186. package/src/features/cart/cart.handler.d.ts +2 -0
  187. package/src/features/cart/cart.handler.js +17 -0
  188. package/src/features/cart/cart.handler.js.map +1 -0
  189. package/src/features/cart/cart.route.d.ts +3 -0
  190. package/src/features/cart/cart.route.js +32 -0
  191. package/src/features/cart/cart.route.js.map +1 -0
  192. package/src/features/cart/cart.schema.d.ts +180 -0
  193. package/src/{schemas → features/cart}/cart.schema.js +2 -4
  194. package/src/features/cart/cart.schema.js.map +1 -0
  195. package/src/{services → features/cart}/cart.service.d.ts +6 -6
  196. package/src/{services → features/cart}/cart.service.js +2 -2
  197. package/src/features/cart/cart.service.js.map +1 -0
  198. package/src/{utils → features/cart}/cart.util.d.ts +3 -3
  199. package/src/features/cart/cart.util.js.map +1 -0
  200. package/src/features/file/file.handler.d.ts +2 -0
  201. package/src/features/file/file.handler.js +23 -0
  202. package/src/features/file/file.handler.js.map +1 -0
  203. package/src/features/file/file.route.d.ts +4 -0
  204. package/src/features/file/file.route.js +34 -0
  205. package/src/features/file/file.route.js.map +1 -0
  206. package/src/features/file/file.schema.d.ts +37 -0
  207. package/src/{schemas → features/file}/file.schema.js +1 -3
  208. package/src/features/file/file.schema.js.map +1 -0
  209. package/src/{services → features/file}/file.service.d.ts +4 -4
  210. package/src/{services → features/file}/file.service.js +2 -2
  211. package/src/features/file/file.service.js.map +1 -0
  212. package/src/features/health/health.handler.d.ts +1 -0
  213. package/src/features/health/health.handler.js +10 -0
  214. package/src/features/health/health.handler.js.map +1 -0
  215. package/src/features/health/health.route.d.ts +3 -0
  216. package/src/features/health/health.route.js +25 -0
  217. package/src/features/health/health.route.js.map +1 -0
  218. package/src/features/index.d.ts +14 -0
  219. package/src/features/index.js +15 -0
  220. package/src/features/index.js.map +1 -0
  221. package/src/features/location/location.handler.d.ts +7 -0
  222. package/src/features/location/location.handler.js +25 -0
  223. package/src/features/location/location.handler.js.map +1 -0
  224. package/src/features/location/location.route.d.ts +4 -0
  225. package/src/features/location/location.route.js +56 -0
  226. package/src/features/location/location.route.js.map +1 -0
  227. package/src/features/location/location.schema.d.ts +17 -0
  228. package/src/{schemas → features/location}/location.schema.js +1 -1
  229. package/src/features/location/location.schema.js.map +1 -0
  230. package/src/features/location/location.service.js.map +1 -0
  231. package/src/features/manufacturer/manufacturer.handler.d.ts +2 -0
  232. package/src/features/manufacturer/manufacturer.handler.js +53 -0
  233. package/src/features/manufacturer/manufacturer.handler.js.map +1 -0
  234. package/src/features/manufacturer/manufacturer.route.d.ts +7 -0
  235. package/src/features/manufacturer/manufacturer.route.js +97 -0
  236. package/src/features/manufacturer/manufacturer.route.js.map +1 -0
  237. package/src/features/manufacturer/manufacturer.schema.d.ts +66 -0
  238. package/src/{schemas → features/manufacturer}/manufacturer.schema.js +3 -5
  239. package/src/features/manufacturer/manufacturer.schema.js.map +1 -0
  240. package/src/{services → features/manufacturer}/manufacturer.service.d.ts +29 -29
  241. package/src/{services → features/manufacturer}/manufacturer.service.js +4 -4
  242. package/src/features/manufacturer/manufacturer.service.js.map +1 -0
  243. package/src/{emails/order-confirmation-email.d.ts → features/order/emails/order-confirmation.email.d.ts} +1 -1
  244. package/src/{emails/order-confirmation-email.js → features/order/emails/order-confirmation.email.js} +1 -1
  245. package/src/features/order/emails/order-confirmation.email.js.map +1 -0
  246. package/src/{emails/order-notification-email.d.ts → features/order/emails/order-notification.email.d.ts} +1 -1
  247. package/src/{emails/order-notification-email.js → features/order/emails/order-notification.email.js} +1 -1
  248. package/src/features/order/emails/order-notification.email.js.map +1 -0
  249. package/src/features/order/fulfilment.schema.d.ts +5 -0
  250. package/src/features/order/fulfilment.schema.js +3 -0
  251. package/src/features/order/fulfilment.schema.js.map +1 -0
  252. package/src/features/order/order.handler.d.ts +3 -0
  253. package/src/features/order/order.handler.js +54 -0
  254. package/src/features/order/order.handler.js.map +1 -0
  255. package/src/features/order/order.route.d.ts +7 -0
  256. package/src/features/order/order.route.js +111 -0
  257. package/src/features/order/order.route.js.map +1 -0
  258. package/src/features/order/order.schema.d.ts +697 -0
  259. package/src/{schemas → features/order}/order.schema.js +8 -10
  260. package/src/features/order/order.schema.js.map +1 -0
  261. package/src/{services → features/order}/order.service.d.ts +64 -64
  262. package/src/{services → features/order}/order.service.js +5 -5
  263. package/src/features/order/order.service.js.map +1 -0
  264. package/src/features/order/recipient.schema.d.ts +54 -0
  265. package/src/{schemas → features/order}/recipient.schema.js +2 -4
  266. package/src/features/order/recipient.schema.js.map +1 -0
  267. package/src/features/organization/legal-entity.schema.d.ts +56 -0
  268. package/src/{schemas → features/organization}/legal-entity.schema.js +2 -4
  269. package/src/features/organization/legal-entity.schema.js.map +1 -0
  270. package/src/features/organization/organization-configuration.schema.d.ts +601 -0
  271. package/src/{schemas → features/organization}/organization-configuration.schema.js +3 -5
  272. package/src/features/organization/organization-configuration.schema.js.map +1 -0
  273. package/src/features/organization/organization.handler.d.ts +2 -0
  274. package/src/features/organization/organization.handler.js +48 -0
  275. package/src/features/organization/organization.handler.js.map +1 -0
  276. package/src/features/organization/organization.route.d.ts +7 -0
  277. package/src/features/organization/organization.route.js +84 -0
  278. package/src/features/organization/organization.route.js.map +1 -0
  279. package/src/features/organization/organization.schema.d.ts +669 -0
  280. package/src/{schemas → features/organization}/organization.schema.js +4 -6
  281. package/src/features/organization/organization.schema.js.map +1 -0
  282. package/src/{services → features/organization}/organization.service.d.ts +19 -19
  283. package/src/{services → features/organization}/organization.service.js +8 -7
  284. package/src/features/organization/organization.service.js.map +1 -0
  285. package/src/features/payment/payment.handler.d.ts +3 -0
  286. package/src/features/payment/payment.handler.js +16 -0
  287. package/src/features/payment/payment.handler.js.map +1 -0
  288. package/src/features/payment/payment.route.d.ts +3 -0
  289. package/src/features/payment/payment.route.js +22 -0
  290. package/src/features/payment/payment.route.js.map +1 -0
  291. package/src/features/payment/payment.schema.d.ts +100 -0
  292. package/src/{schemas → features/payment}/payment.schema.js +2 -4
  293. package/src/{schemas → features/payment}/payment.schema.js.map +1 -1
  294. package/src/{services → features/payment}/payment.service.d.ts +4 -4
  295. package/src/{services → features/payment}/payment.service.js +1 -1
  296. package/src/features/payment/payment.service.js.map +1 -0
  297. package/src/{services → features/payment}/stripe.service.d.ts +3 -3
  298. package/src/{services → features/payment}/stripe.service.js +3 -3
  299. package/src/features/payment/stripe.service.js.map +1 -0
  300. package/src/features/product/product-modifier.schema.d.ts +621 -0
  301. package/src/{schemas → features/product}/product-modifier.schema.js +3 -5
  302. package/src/{schemas → features/product}/product-modifier.schema.js.map +1 -1
  303. package/src/features/product/product.handler.d.ts +2 -0
  304. package/src/features/product/product.handler.js +87 -0
  305. package/src/features/product/product.handler.js.map +1 -0
  306. package/src/features/product/product.route.d.ts +9 -0
  307. package/src/features/product/product.route.js +179 -0
  308. package/src/features/product/product.route.js.map +1 -0
  309. package/src/features/product/product.schema.d.ts +1316 -0
  310. package/src/{schemas → features/product}/product.schema.js +6 -8
  311. package/src/features/product/product.schema.js.map +1 -0
  312. package/src/{services → features/product}/product.service.d.ts +129 -129
  313. package/src/{services → features/product}/product.service.js +4 -4
  314. package/src/features/product/product.service.js.map +1 -0
  315. package/src/features/product-category/product-category.handler.d.ts +2 -0
  316. package/src/features/product-category/product-category.handler.js +59 -0
  317. package/src/features/product-category/product-category.handler.js.map +1 -0
  318. package/src/features/product-category/product-category.route.d.ts +8 -0
  319. package/src/features/product-category/product-category.route.js +139 -0
  320. package/src/features/product-category/product-category.route.js.map +1 -0
  321. package/src/features/product-category/product-category.schema.d.ts +72 -0
  322. package/src/{schemas → features/product-category}/product-category.schema.js +3 -5
  323. package/src/features/product-category/product-category.schema.js.map +1 -0
  324. package/src/{services → features/product-category}/product-category.service.d.ts +25 -25
  325. package/src/{services → features/product-category}/product-category.service.js +4 -4
  326. package/src/features/product-category/product-category.service.js.map +1 -0
  327. package/src/{emails/reservation-cancellation-email.d.ts → features/reservation/emails/reservation-cancellation.email.d.ts} +1 -1
  328. package/src/{emails/reservation-cancellation-email.js → features/reservation/emails/reservation-cancellation.email.js} +1 -1
  329. package/src/features/reservation/emails/reservation-cancellation.email.js.map +1 -0
  330. package/src/{emails/reservation-confirmation-email.d.ts → features/reservation/emails/reservation-confirmation.email.d.ts} +1 -1
  331. package/src/{emails/reservation-confirmation-email.js → features/reservation/emails/reservation-confirmation.email.js} +1 -1
  332. package/src/features/reservation/emails/reservation-confirmation.email.js.map +1 -0
  333. package/src/{emails/reservation-notification-email.d.ts → features/reservation/emails/reservation-notification.email.d.ts} +1 -1
  334. package/src/{emails/reservation-notification-email.js → features/reservation/emails/reservation-notification.email.js} +1 -1
  335. package/src/features/reservation/emails/reservation-notification.email.js.map +1 -0
  336. package/src/features/reservation/reservation.handler.d.ts +2 -0
  337. package/src/features/reservation/reservation.handler.js +65 -0
  338. package/src/features/reservation/reservation.handler.js.map +1 -0
  339. package/src/features/reservation/reservation.route.d.ts +8 -0
  340. package/src/features/reservation/reservation.route.js +167 -0
  341. package/src/features/reservation/reservation.route.js.map +1 -0
  342. package/src/features/reservation/reservation.schema.d.ts +22 -0
  343. package/src/{schemas → features/reservation}/reservation.schema.js +2 -4
  344. package/src/features/reservation/reservation.schema.js.map +1 -0
  345. package/src/{services → features/reservation}/reservation.service.d.ts +18 -18
  346. package/src/{services → features/reservation}/reservation.service.js +4 -4
  347. package/src/features/reservation/reservation.service.js.map +1 -0
  348. package/src/features/shipping/shipping.handler.d.ts +2 -0
  349. package/src/features/shipping/shipping.handler.js +32 -0
  350. package/src/features/shipping/shipping.handler.js.map +1 -0
  351. package/src/features/shipping/shipping.route.d.ts +5 -0
  352. package/src/features/shipping/shipping.route.js +51 -0
  353. package/src/features/shipping/shipping.route.js.map +1 -0
  354. package/src/{services → features/shipping}/shipping.service.d.ts +11 -11
  355. package/src/{services → features/shipping}/shipping.service.js +3 -3
  356. package/src/features/shipping/shipping.service.js.map +1 -0
  357. package/src/features/shipping-method/shipping-method.handler.d.ts +2 -0
  358. package/src/features/shipping-method/shipping-method.handler.js +60 -0
  359. package/src/features/shipping-method/shipping-method.handler.js.map +1 -0
  360. package/src/features/shipping-method/shipping-method.route.d.ts +8 -0
  361. package/src/features/shipping-method/shipping-method.route.js +144 -0
  362. package/src/features/shipping-method/shipping-method.route.js.map +1 -0
  363. package/src/features/shipping-method/shipping-method.schema.d.ts +77 -0
  364. package/src/{schemas → features/shipping-method}/shipping-method.schema.js +2 -4
  365. package/src/features/shipping-method/shipping-method.schema.js.map +1 -0
  366. package/src/{services → features/shipping-method}/shipping-method.service.d.ts +23 -23
  367. package/src/{services → features/shipping-method}/shipping-method.service.js +3 -3
  368. package/src/features/shipping-method/shipping-method.service.js.map +1 -0
  369. package/src/features/shipping-method/shipping-zone.schema.d.ts +10 -0
  370. package/src/{schemas → features/shipping-method}/shipping-zone.schema.js +2 -4
  371. package/src/features/shipping-method/shipping-zone.schema.js.map +1 -0
  372. package/src/features/webhook/webhook.handler.d.ts +4 -0
  373. package/src/features/webhook/webhook.handler.js +50 -0
  374. package/src/features/webhook/webhook.handler.js.map +1 -0
  375. package/src/features/webhook/webhook.route.d.ts +3 -0
  376. package/src/features/webhook/webhook.route.js +33 -0
  377. package/src/features/webhook/webhook.route.js.map +1 -0
  378. package/src/index.d.ts +4 -4
  379. package/src/index.js +4 -5
  380. package/src/index.js.map +1 -1
  381. package/src/integrations/next.d.ts +6 -5
  382. package/src/integrations/next.js +30 -51
  383. package/src/integrations/next.js.map +1 -1
  384. package/src/schemas/address.schema.d.ts +12 -153
  385. package/src/schemas/address.schema.js +1 -3
  386. package/src/schemas/address.schema.js.map +1 -1
  387. package/src/schemas/currency.schema.d.ts +36 -2
  388. package/src/schemas/currency.schema.js +1 -3
  389. package/src/schemas/currency.schema.js.map +1 -1
  390. package/src/schemas/error.schema.d.ts +2 -8
  391. package/src/schemas/error.schema.js +1 -3
  392. package/src/schemas/error.schema.js.map +1 -1
  393. package/src/schemas/index.d.ts +20 -20
  394. package/src/schemas/index.js +20 -20
  395. package/src/schemas/index.js.map +1 -1
  396. package/src/schemas/locales.schema.d.ts +116 -2
  397. package/src/schemas/locales.schema.js +1 -3
  398. package/src/schemas/locales.schema.js.map +1 -1
  399. package/src/schemas/number.schema.d.ts +3 -3
  400. package/src/schemas/number.schema.js +1 -1
  401. package/src/schemas/number.schema.js.map +1 -1
  402. package/src/schemas/pagination.schema.d.ts +121 -35
  403. package/src/schemas/pagination.schema.js +1 -1
  404. package/src/schemas/pagination.schema.js.map +1 -1
  405. package/src/schemas/params.schema.d.ts +3 -14
  406. package/src/schemas/params.schema.js +1 -3
  407. package/src/schemas/params.schema.js.map +1 -1
  408. package/src/schemas/queries.schema.d.ts +117 -7
  409. package/src/schemas/queries.schema.js +1 -3
  410. package/src/schemas/queries.schema.js.map +1 -1
  411. package/src/test/integration/api-fixtures.d.ts +159 -0
  412. package/src/test/integration/api-fixtures.js +225 -0
  413. package/src/test/integration/api-fixtures.js.map +1 -0
  414. package/src/test/integration/test-helpers.d.ts +961 -0
  415. package/src/test/integration/test-helpers.js +1100 -0
  416. package/src/test/integration/test-helpers.js.map +1 -0
  417. package/src/test/setup-test-env.d.ts +1 -0
  418. package/src/test/setup-test-env.js +29 -0
  419. package/src/test/setup-test-env.js.map +1 -0
  420. package/src/contract.d.ts +0 -3864
  421. package/src/contract.js +0 -6
  422. package/src/contract.js.map +0 -1
  423. package/src/contracts/cart.contract.d.ts +0 -407
  424. package/src/contracts/cart.contract.js +0 -29
  425. package/src/contracts/cart.contract.js.map +0 -1
  426. package/src/contracts/customers.contract.d.ts +0 -903
  427. package/src/contracts/customers.contract.js +0 -119
  428. package/src/contracts/customers.contract.js.map +0 -1
  429. package/src/contracts/files.contract.d.ts +0 -152
  430. package/src/contracts/files.contract.js +0 -29
  431. package/src/contracts/files.contract.js.map +0 -1
  432. package/src/contracts/health.contract.d.ts +0 -38
  433. package/src/contracts/health.contract.js +0 -25
  434. package/src/contracts/health.contract.js.map +0 -1
  435. package/src/contracts/index.d.ts +0 -15096
  436. package/src/contracts/index.js +0 -32
  437. package/src/contracts/index.js.map +0 -1
  438. package/src/contracts/location.contract.d.ts +0 -127
  439. package/src/contracts/location.contract.js +0 -40
  440. package/src/contracts/location.contract.js.map +0 -1
  441. package/src/contracts/manufacturers.contract.d.ts +0 -931
  442. package/src/contracts/manufacturers.contract.js +0 -85
  443. package/src/contracts/manufacturers.contract.js.map +0 -1
  444. package/src/contracts/orders.contract.d.ts +0 -3910
  445. package/src/contracts/orders.contract.js +0 -92
  446. package/src/contracts/orders.contract.js.map +0 -1
  447. package/src/contracts/organizations.contract.d.ts +0 -2234
  448. package/src/contracts/organizations.contract.js +0 -71
  449. package/src/contracts/organizations.contract.js.map +0 -1
  450. package/src/contracts/payment.contract.d.ts +0 -64
  451. package/src/contracts/payment.contract.js +0 -20
  452. package/src/contracts/payment.contract.js.map +0 -1
  453. package/src/contracts/product-categories.contract.d.ts +0 -1172
  454. package/src/contracts/product-categories.contract.js +0 -103
  455. package/src/contracts/product-categories.contract.js.map +0 -1
  456. package/src/contracts/products.contract.d.ts +0 -3748
  457. package/src/contracts/products.contract.js +0 -128
  458. package/src/contracts/products.contract.js.map +0 -1
  459. package/src/contracts/reservation.contract.d.ts +0 -675
  460. package/src/contracts/reservation.contract.js +0 -141
  461. package/src/contracts/reservation.contract.js.map +0 -1
  462. package/src/contracts/shipping-methods.contract.d.ts +0 -1276
  463. package/src/contracts/shipping-methods.contract.js +0 -118
  464. package/src/contracts/shipping-methods.contract.js.map +0 -1
  465. package/src/contracts/shipping.contract.d.ts +0 -306
  466. package/src/contracts/shipping.contract.js +0 -42
  467. package/src/contracts/shipping.contract.js.map +0 -1
  468. package/src/contracts/webhook.contract.d.ts +0 -66
  469. package/src/contracts/webhook.contract.js +0 -28
  470. package/src/contracts/webhook.contract.js.map +0 -1
  471. package/src/db/__generated__/client/client.d.ts +0 -385
  472. package/src/db/__generated__/client/client.js +0 -50
  473. package/src/db/__generated__/client/client.js.map +0 -1
  474. package/src/db/__generated__/client/commonInputTypes.js.map +0 -1
  475. package/src/db/__generated__/client/enums.js.map +0 -1
  476. package/src/db/__generated__/client/index.d.ts +0 -1
  477. package/src/db/__generated__/client/index.js +0 -5
  478. package/src/db/__generated__/client/index.js.map +0 -1
  479. package/src/db/__generated__/client/internal/class.js +0 -83
  480. package/src/db/__generated__/client/internal/class.js.map +0 -1
  481. package/src/db/__generated__/client/internal/prismaNamespace.js.map +0 -1
  482. package/src/db/__generated__/client/libquery_engine-darwin-arm64.dylib.node +0 -0
  483. package/src/db/__generated__/client/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
  484. package/src/db/__generated__/client/libquery_engine-rhel-openssl-3.0.x.so.node +0 -0
  485. package/src/db/__generated__/client/models/Account.js.map +0 -1
  486. package/src/db/__generated__/client/models/Address.js.map +0 -1
  487. package/src/db/__generated__/client/models/Campaign.js.map +0 -1
  488. package/src/db/__generated__/client/models/ClosingTimes.js.map +0 -1
  489. package/src/db/__generated__/client/models/File.js.map +0 -1
  490. package/src/db/__generated__/client/models/Invitation.js.map +0 -1
  491. package/src/db/__generated__/client/models/LegalEntity.js.map +0 -1
  492. package/src/db/__generated__/client/models/Manufacturer.js.map +0 -1
  493. package/src/db/__generated__/client/models/ManufacturerTranslation.js.map +0 -1
  494. package/src/db/__generated__/client/models/Member.js.map +0 -1
  495. package/src/db/__generated__/client/models/Modifier.js.map +0 -1
  496. package/src/db/__generated__/client/models/ModifierGroup.js.map +0 -1
  497. package/src/db/__generated__/client/models/ModifierGroupTranslation.js.map +0 -1
  498. package/src/db/__generated__/client/models/OpeningTimes.js.map +0 -1
  499. package/src/db/__generated__/client/models/Order.js.map +0 -1
  500. package/src/db/__generated__/client/models/OrderItem.js.map +0 -1
  501. package/src/db/__generated__/client/models/OrderItemTranslation.js.map +0 -1
  502. package/src/db/__generated__/client/models/Organization.js.map +0 -1
  503. package/src/db/__generated__/client/models/OrganizationConfiguration.js.map +0 -1
  504. package/src/db/__generated__/client/models/Payment.js.map +0 -1
  505. package/src/db/__generated__/client/models/PaymentSession.js.map +0 -1
  506. package/src/db/__generated__/client/models/Product.js.map +0 -1
  507. package/src/db/__generated__/client/models/ProductCategory.js.map +0 -1
  508. package/src/db/__generated__/client/models/ProductCategoryTranslation.js.map +0 -1
  509. package/src/db/__generated__/client/models/ProductSnapshot.js.map +0 -1
  510. package/src/db/__generated__/client/models/ProductTranslation.js.map +0 -1
  511. package/src/db/__generated__/client/models/Reservation.js.map +0 -1
  512. package/src/db/__generated__/client/models/Session.js.map +0 -1
  513. package/src/db/__generated__/client/models/ShippingMethod.js.map +0 -1
  514. package/src/db/__generated__/client/models/ShippingZone.js.map +0 -1
  515. package/src/db/__generated__/client/models/User.js.map +0 -1
  516. package/src/db/__generated__/client/models/Verification.js.map +0 -1
  517. package/src/db/__generated__/client/models.js.map +0 -1
  518. package/src/db/index.d.ts +0 -1
  519. package/src/db/index.js +0 -2
  520. package/src/db/index.js.map +0 -1
  521. package/src/emails/order-confirmation-email.js.map +0 -1
  522. package/src/emails/order-notification-email.js.map +0 -1
  523. package/src/emails/reservation-cancellation-email.js.map +0 -1
  524. package/src/emails/reservation-confirmation-email.js.map +0 -1
  525. package/src/emails/reservation-notification-email.js.map +0 -1
  526. package/src/exceptions/http-exception.js.map +0 -1
  527. package/src/handlers/webhook.handler.d.ts +0 -8
  528. package/src/handlers/webhook.handler.js +0 -36
  529. package/src/handlers/webhook.handler.js.map +0 -1
  530. package/src/lib/better-auth.lib.js.map +0 -1
  531. package/src/lib/openapi.lib.d.ts +0 -2
  532. package/src/lib/openapi.lib.js +0 -25
  533. package/src/lib/openapi.lib.js.map +0 -1
  534. package/src/lib/pino.js.map +0 -1
  535. package/src/lib/prisma.js.map +0 -1
  536. package/src/lib/stripe.d.ts +0 -2
  537. package/src/lib/stripe.js +0 -8
  538. package/src/lib/stripe.js.map +0 -1
  539. package/src/lib/ts-rest.d.ts +0 -2
  540. package/src/lib/ts-rest.js +0 -3
  541. package/src/lib/ts-rest.js.map +0 -1
  542. package/src/routers/cart.router.d.ts +0 -407
  543. package/src/routers/cart.router.js +0 -20
  544. package/src/routers/cart.router.js.map +0 -1
  545. package/src/routers/file.router.d.ts +0 -153
  546. package/src/routers/file.router.js +0 -28
  547. package/src/routers/file.router.js.map +0 -1
  548. package/src/routers/health.router.d.ts +0 -37
  549. package/src/routers/health.router.js +0 -17
  550. package/src/routers/health.router.js.map +0 -1
  551. package/src/routers/index.d.ts +0 -11
  552. package/src/routers/index.js +0 -12
  553. package/src/routers/index.js.map +0 -1
  554. package/src/routers/manufacturer.router.d.ts +0 -931
  555. package/src/routers/manufacturer.router.js +0 -58
  556. package/src/routers/manufacturer.router.js.map +0 -1
  557. package/src/routers/order.router.d.ts +0 -3911
  558. package/src/routers/order.router.js +0 -60
  559. package/src/routers/order.router.js.map +0 -1
  560. package/src/routers/organization.router.d.ts +0 -2234
  561. package/src/routers/organization.router.js +0 -55
  562. package/src/routers/organization.router.js.map +0 -1
  563. package/src/routers/payment.router.d.ts +0 -65
  564. package/src/routers/payment.router.js +0 -22
  565. package/src/routers/payment.router.js.map +0 -1
  566. package/src/routers/places.router.d.ts +0 -132
  567. package/src/routers/places.router.js +0 -31
  568. package/src/routers/places.router.js.map +0 -1
  569. package/src/routers/product-category.router.d.ts +0 -1172
  570. package/src/routers/product-category.router.js +0 -66
  571. package/src/routers/product-category.router.js.map +0 -1
  572. package/src/routers/product.router.d.ts +0 -3748
  573. package/src/routers/product.router.js +0 -94
  574. package/src/routers/product.router.js.map +0 -1
  575. package/src/routers/reservation.router.d.ts +0 -675
  576. package/src/routers/reservation.router.js +0 -71
  577. package/src/routers/reservation.router.js.map +0 -1
  578. package/src/routers/shipping-method.router.d.ts +0 -1276
  579. package/src/routers/shipping-method.router.js +0 -67
  580. package/src/routers/shipping-method.router.js.map +0 -1
  581. package/src/routers/shipping.router.d.ts +0 -307
  582. package/src/routers/shipping.router.js +0 -38
  583. package/src/routers/shipping.router.js.map +0 -1
  584. package/src/routers/webhook.router.d.ts +0 -65
  585. package/src/routers/webhook.router.js +0 -19
  586. package/src/routers/webhook.router.js.map +0 -1
  587. package/src/schemas/auth.schema.d.ts +0 -29
  588. package/src/schemas/auth.schema.js.map +0 -1
  589. package/src/schemas/cart.schema.d.ts +0 -315
  590. package/src/schemas/cart.schema.js.map +0 -1
  591. package/src/schemas/file.schema.d.ts +0 -115
  592. package/src/schemas/file.schema.js.map +0 -1
  593. package/src/schemas/fulfilment.schema.d.ts +0 -2
  594. package/src/schemas/fulfilment.schema.js +0 -5
  595. package/src/schemas/fulfilment.schema.js.map +0 -1
  596. package/src/schemas/headers.schema.d.ts +0 -11
  597. package/src/schemas/headers.schema.js.map +0 -1
  598. package/src/schemas/legal-entity.schema.d.ts +0 -212
  599. package/src/schemas/legal-entity.schema.js.map +0 -1
  600. package/src/schemas/location.schema.d.ts +0 -41
  601. package/src/schemas/location.schema.js.map +0 -1
  602. package/src/schemas/manufacturer.schema.d.ts +0 -287
  603. package/src/schemas/manufacturer.schema.js.map +0 -1
  604. package/src/schemas/order.schema.d.ts +0 -1046
  605. package/src/schemas/order.schema.js.map +0 -1
  606. package/src/schemas/organization-configuration.schema.d.ts +0 -287
  607. package/src/schemas/organization-configuration.schema.js.map +0 -1
  608. package/src/schemas/organization.schema.d.ts +0 -894
  609. package/src/schemas/organization.schema.js.map +0 -1
  610. package/src/schemas/payment.schema.d.ts +0 -54
  611. package/src/schemas/product-category.schema.d.ts +0 -352
  612. package/src/schemas/product-category.schema.js.map +0 -1
  613. package/src/schemas/product-modifier.schema.d.ts +0 -280
  614. package/src/schemas/product.schema.d.ts +0 -1287
  615. package/src/schemas/product.schema.js.map +0 -1
  616. package/src/schemas/recipient.schema.d.ts +0 -260
  617. package/src/schemas/recipient.schema.js.map +0 -1
  618. package/src/schemas/reservation.schema.d.ts +0 -61
  619. package/src/schemas/reservation.schema.js.map +0 -1
  620. package/src/schemas/shipping-method.schema.d.ts +0 -335
  621. package/src/schemas/shipping-method.schema.js.map +0 -1
  622. package/src/schemas/shipping-zone.schema.d.ts +0 -24
  623. package/src/schemas/shipping-zone.schema.js.map +0 -1
  624. package/src/schemas/user.schema.d.ts +0 -24
  625. package/src/schemas/user.schema.js.map +0 -1
  626. package/src/services/cart.service.js.map +0 -1
  627. package/src/services/email.service.js.map +0 -1
  628. package/src/services/file.service.js.map +0 -1
  629. package/src/services/location.service.js.map +0 -1
  630. package/src/services/manufacturer.service.js.map +0 -1
  631. package/src/services/order.service.js.map +0 -1
  632. package/src/services/organization.service.js.map +0 -1
  633. package/src/services/payment.service.js.map +0 -1
  634. package/src/services/product-category.service.js.map +0 -1
  635. package/src/services/product.service.js.map +0 -1
  636. package/src/services/reservation.service.js.map +0 -1
  637. package/src/services/shipping-method.service.js.map +0 -1
  638. package/src/services/shipping.service.js.map +0 -1
  639. package/src/services/stripe.service.js.map +0 -1
  640. package/src/types/google-maps.types.js.map +0 -1
  641. package/src/utils/auth.util.js.map +0 -1
  642. package/src/utils/cart.util.js.map +0 -1
  643. package/src/utils/client.util.d.ts +0 -3864
  644. package/src/utils/client.util.js +0 -6
  645. package/src/utils/client.util.js.map +0 -1
  646. package/src/utils/currency.util.js.map +0 -1
  647. package/src/utils/env.util.js.map +0 -1
  648. package/src/utils/error-handler.util.d.ts +0 -3
  649. package/src/utils/error-handler.util.js +0 -30
  650. package/src/utils/error-handler.util.js.map +0 -1
  651. package/src/utils/generate-password-hash.util.js.map +0 -1
  652. package/src/utils/object.util.js.map +0 -1
  653. package/src/utils/translations.util.js.map +0 -1
  654. package/src/utils/zod.util.js.map +0 -1
  655. /package/src/{utils → core/auth}/auth.util.js +0 -0
  656. /package/src/{utils → core/auth}/generate-password-hash.util.d.ts +0 -0
  657. /package/src/{utils → core/auth}/generate-password-hash.util.js +0 -0
  658. /package/src/{db → core/db}/__generated__/client/models/Account.js +0 -0
  659. /package/src/{db → core/db}/__generated__/client/models/Address.js +0 -0
  660. /package/src/{db → core/db}/__generated__/client/models/Campaign.js +0 -0
  661. /package/src/{db → core/db}/__generated__/client/models/ClosingTimes.js +0 -0
  662. /package/src/{db → core/db}/__generated__/client/models/File.js +0 -0
  663. /package/src/{db → core/db}/__generated__/client/models/Invitation.js +0 -0
  664. /package/src/{db → core/db}/__generated__/client/models/LegalEntity.js +0 -0
  665. /package/src/{db → core/db}/__generated__/client/models/Manufacturer.js +0 -0
  666. /package/src/{db → core/db}/__generated__/client/models/ManufacturerTranslation.js +0 -0
  667. /package/src/{db → core/db}/__generated__/client/models/Member.js +0 -0
  668. /package/src/{db → core/db}/__generated__/client/models/Modifier.js +0 -0
  669. /package/src/{db → core/db}/__generated__/client/models/ModifierGroup.js +0 -0
  670. /package/src/{db → core/db}/__generated__/client/models/ModifierGroupTranslation.js +0 -0
  671. /package/src/{db → core/db}/__generated__/client/models/OpeningTimes.js +0 -0
  672. /package/src/{db → core/db}/__generated__/client/models/Order.js +0 -0
  673. /package/src/{db → core/db}/__generated__/client/models/OrderItem.js +0 -0
  674. /package/src/{db → core/db}/__generated__/client/models/OrderItemTranslation.js +0 -0
  675. /package/src/{db → core/db}/__generated__/client/models/Organization.js +0 -0
  676. /package/src/{db → core/db}/__generated__/client/models/OrganizationConfiguration.js +0 -0
  677. /package/src/{db → core/db}/__generated__/client/models/Payment.js +0 -0
  678. /package/src/{db → core/db}/__generated__/client/models/PaymentSession.js +0 -0
  679. /package/src/{db → core/db}/__generated__/client/models/Product.js +0 -0
  680. /package/src/{db → core/db}/__generated__/client/models/ProductCategory.js +0 -0
  681. /package/src/{db → core/db}/__generated__/client/models/ProductCategoryTranslation.js +0 -0
  682. /package/src/{db → core/db}/__generated__/client/models/ProductSnapshot.js +0 -0
  683. /package/src/{db → core/db}/__generated__/client/models/ProductTranslation.js +0 -0
  684. /package/src/{db → core/db}/__generated__/client/models/Reservation.js +0 -0
  685. /package/src/{db → core/db}/__generated__/client/models/Session.js +0 -0
  686. /package/src/{db → core/db}/__generated__/client/models/ShippingMethod.js +0 -0
  687. /package/src/{db → core/db}/__generated__/client/models/ShippingZone.js +0 -0
  688. /package/src/{db → core/db}/__generated__/client/models/User.js +0 -0
  689. /package/src/{db → core/db}/__generated__/client/models/Verification.js +0 -0
  690. /package/src/{db → core/db}/__generated__/client/models.js +0 -0
  691. /package/src/{exceptions → core/exceptions}/http-exception.d.ts +0 -0
  692. /package/src/{exceptions → core/exceptions}/http-exception.js +0 -0
  693. /package/src/{lib → core/lib}/prisma.js +0 -0
  694. /package/src/{lib → core/logging}/pino.d.ts +0 -0
  695. /package/src/{lib → core/logging}/pino.js +0 -0
  696. /package/src/{types → core/types}/google-maps.types.d.ts +0 -0
  697. /package/src/{types → core/types}/google-maps.types.js +0 -0
  698. /package/src/{utils → core/utils}/currency.util.d.ts +0 -0
  699. /package/src/{utils → core/utils}/currency.util.js +0 -0
  700. /package/src/{utils → core/utils}/env.util.d.ts +0 -0
  701. /package/src/{utils → core/utils}/object.util.d.ts +0 -0
  702. /package/src/{utils → core/utils}/object.util.js +0 -0
  703. /package/src/{utils → core/utils}/translations.util.d.ts +0 -0
  704. /package/src/{utils → core/utils}/translations.util.js +0 -0
  705. /package/src/{utils → features/cart}/cart.util.js +0 -0
  706. /package/src/{services → features/location}/location.service.d.ts +0 -0
  707. /package/src/{services → features/location}/location.service.js +0 -0
@@ -0,0 +1,1100 @@
1
+ import { __awaiter } from "tslib";
2
+ import { randomUUID } from "node:crypto";
3
+ import { PrismaNeon } from "@prisma/adapter-neon";
4
+ import { buildApiApp } from "../../app";
5
+ import { HttpException } from "../../core/exceptions/http-exception";
6
+ import { createPrismaClient, } from "../../core/lib/prisma";
7
+ const GOOGLE_MAPS_TEST_KEY = "test-google-maps-key";
8
+ const getOrganizationIdFromPath = (path) => {
9
+ var _a;
10
+ const match = path.match(/^\/organizations\/([^/]+)/);
11
+ return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : null;
12
+ };
13
+ const toAuthUser = (user) => ({
14
+ id: user.id,
15
+ email: user.email,
16
+ firstname: user.firstname,
17
+ lastname: user.lastname,
18
+ image: user.image,
19
+ name: user.name,
20
+ });
21
+ export const createIntegrationPrismaClient = () => {
22
+ const adapter = new PrismaNeon({
23
+ connectionString: process.env.POSTGRES_PRISMA_URL,
24
+ });
25
+ return createPrismaClient({
26
+ adapter,
27
+ log: ["warn", "error"],
28
+ });
29
+ };
30
+ export const createTestUser = (prisma_1, ...args_1) => __awaiter(void 0, [prisma_1, ...args_1], void 0, function* (prisma, overrides = {}) {
31
+ var _a, _b, _c, _d;
32
+ const id = randomUUID();
33
+ const firstname = (_a = overrides.firstname) !== null && _a !== void 0 ? _a : "Integration";
34
+ const lastname = (_b = overrides.lastname) !== null && _b !== void 0 ? _b : "Tester";
35
+ const name = (_c = overrides.name) !== null && _c !== void 0 ? _c : `${firstname} ${lastname}`;
36
+ return prisma.user.create({
37
+ data: {
38
+ id,
39
+ email: (_d = overrides.email) !== null && _d !== void 0 ? _d : `integration-${id}@shophost.test`,
40
+ emailVerified: false,
41
+ firstname,
42
+ image: null,
43
+ lastname,
44
+ name,
45
+ createdAt: new Date(),
46
+ updatedAt: new Date(),
47
+ },
48
+ });
49
+ });
50
+ const ensureMembership = (prisma, organizationId, userId) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const existingMembership = yield prisma.member.findFirst({
52
+ where: {
53
+ organizationId,
54
+ userId,
55
+ },
56
+ select: {
57
+ id: true,
58
+ },
59
+ });
60
+ if (existingMembership) {
61
+ return existingMembership;
62
+ }
63
+ return prisma.member.create({
64
+ data: {
65
+ organizationId,
66
+ role: "owner",
67
+ userId,
68
+ },
69
+ select: {
70
+ id: true,
71
+ },
72
+ });
73
+ });
74
+ const ensureSeededUser = (prisma, fixtureKey) => __awaiter(void 0, void 0, void 0, function* () {
75
+ const now = new Date();
76
+ const email = `fixture.${fixtureKey}@shophost.test`;
77
+ const displayName = fixtureKey
78
+ .split("-")
79
+ .map((value) => value.charAt(0).toUpperCase() + value.slice(1))
80
+ .join(" ");
81
+ return prisma.user.upsert({
82
+ where: {
83
+ email,
84
+ },
85
+ update: {
86
+ emailVerified: false,
87
+ firstname: "Fixture",
88
+ image: null,
89
+ lastname: displayName,
90
+ name: `Fixture ${displayName}`,
91
+ updatedAt: now,
92
+ },
93
+ create: {
94
+ id: randomUUID(),
95
+ email,
96
+ emailVerified: false,
97
+ firstname: "Fixture",
98
+ image: null,
99
+ lastname: displayName,
100
+ name: `Fixture ${displayName}`,
101
+ createdAt: now,
102
+ updatedAt: now,
103
+ },
104
+ });
105
+ });
106
+ const ensureSeededOrganization = (prisma, fixtureKey, variant, userId) => __awaiter(void 0, void 0, void 0, function* () {
107
+ const slug = `it-${fixtureKey}-${variant}`;
108
+ const name = `Integration ${fixtureKey} ${variant}`;
109
+ const addressData = variant === "primary"
110
+ ? {
111
+ addressLineOne: "123 Main Street",
112
+ addressLineTwo: "Suite 10",
113
+ city: "New York",
114
+ country: "US",
115
+ doorNumber: "10A",
116
+ latitude: 40.7128,
117
+ longitude: -74.006,
118
+ zipCode: "10001",
119
+ }
120
+ : {
121
+ addressLineOne: "500 Lake Shore Drive",
122
+ addressLineTwo: "Floor 4",
123
+ city: "Chicago",
124
+ country: "US",
125
+ doorNumber: "4B",
126
+ latitude: 41.8781,
127
+ longitude: -87.6298,
128
+ zipCode: "60601",
129
+ };
130
+ const existingOrganization = yield prisma.organization.findUnique({
131
+ where: {
132
+ slug,
133
+ },
134
+ select: {
135
+ addressId: true,
136
+ configurationId: true,
137
+ id: true,
138
+ slug: true,
139
+ },
140
+ });
141
+ if (existingOrganization) {
142
+ yield prisma.address.update({
143
+ where: {
144
+ id: existingOrganization.addressId,
145
+ },
146
+ data: Object.assign(Object.assign({}, addressData), { deletedAt: null, deletedBy: null, updatedBy: userId }),
147
+ });
148
+ yield prisma.organizationConfiguration.update({
149
+ where: {
150
+ id: existingOrganization.configurationId,
151
+ },
152
+ data: {
153
+ countriesShipping: ["US"],
154
+ defaultCurrency: "USD",
155
+ defaultLocale: "en",
156
+ enableHostCheckout: true,
157
+ enableHostTracking: true,
158
+ hostname: `${slug}.shophost.test`,
159
+ isAcceptingOrders: true,
160
+ supportedLocales: ["en", "pl"],
161
+ updatedBy: userId,
162
+ },
163
+ });
164
+ yield prisma.organization.update({
165
+ where: {
166
+ id: existingOrganization.id,
167
+ },
168
+ data: {
169
+ deletedAt: null,
170
+ deletedBy: null,
171
+ email: `${slug}@shophost.test`,
172
+ name,
173
+ phone: "+15550001111",
174
+ slug,
175
+ updatedBy: userId,
176
+ },
177
+ });
178
+ yield ensureMembership(prisma, existingOrganization.id, userId);
179
+ return Object.assign(Object.assign({}, existingOrganization), { slug });
180
+ }
181
+ const address = yield prisma.address.create({
182
+ data: Object.assign(Object.assign({}, addressData), { createdBy: userId, isDefault: false }),
183
+ select: {
184
+ id: true,
185
+ },
186
+ });
187
+ const configuration = yield prisma.organizationConfiguration.create({
188
+ data: {
189
+ countriesShipping: ["US"],
190
+ defaultCurrency: "USD",
191
+ defaultLocale: "en",
192
+ enableHostCheckout: true,
193
+ enableHostTracking: true,
194
+ hostname: `${slug}.shophost.test`,
195
+ isAcceptingOrders: true,
196
+ supportedLocales: ["en", "pl"],
197
+ createdBy: userId,
198
+ updatedBy: userId,
199
+ },
200
+ select: {
201
+ id: true,
202
+ },
203
+ });
204
+ const organization = yield prisma.organization.create({
205
+ data: {
206
+ addressId: address.id,
207
+ configurationId: configuration.id,
208
+ createdBy: userId,
209
+ email: `${slug}@shophost.test`,
210
+ name,
211
+ phone: "+15550001111",
212
+ slug,
213
+ },
214
+ select: {
215
+ addressId: true,
216
+ configurationId: true,
217
+ id: true,
218
+ slug: true,
219
+ },
220
+ });
221
+ yield ensureMembership(prisma, organization.id, userId);
222
+ return Object.assign(Object.assign({}, organization), { slug });
223
+ });
224
+ const deleteOrganizationResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
225
+ const [productCategories, manufacturers, products, modifierGroups, shippingMethods, orders,] = yield Promise.all([
226
+ prisma.productCategory.findMany({
227
+ where: {
228
+ organizationId,
229
+ },
230
+ select: {
231
+ id: true,
232
+ },
233
+ }),
234
+ prisma.manufacturer.findMany({
235
+ where: {
236
+ organizationId,
237
+ },
238
+ select: {
239
+ id: true,
240
+ },
241
+ }),
242
+ prisma.product.findMany({
243
+ where: {
244
+ organizationId,
245
+ },
246
+ select: {
247
+ id: true,
248
+ },
249
+ }),
250
+ prisma.modifierGroup.findMany({
251
+ where: {
252
+ products: {
253
+ some: {
254
+ organizationId,
255
+ },
256
+ },
257
+ },
258
+ select: {
259
+ id: true,
260
+ },
261
+ }),
262
+ prisma.shippingMethod.findMany({
263
+ where: {
264
+ organizationId,
265
+ },
266
+ select: {
267
+ id: true,
268
+ },
269
+ }),
270
+ prisma.order.findMany({
271
+ where: {
272
+ organizationId,
273
+ },
274
+ select: {
275
+ id: true,
276
+ paymentId: true,
277
+ shippingAddressId: true,
278
+ },
279
+ }),
280
+ ]);
281
+ const productCategoryIds = productCategories.map(({ id }) => id);
282
+ const manufacturerIds = manufacturers.map(({ id }) => id);
283
+ const productIds = products.map(({ id }) => id);
284
+ const modifierGroupIds = modifierGroups.map(({ id }) => id);
285
+ const shippingMethodIds = shippingMethods.map(({ id }) => id);
286
+ const orderIds = orders.map(({ id }) => id);
287
+ const paymentIds = orders
288
+ .map(({ paymentId }) => paymentId)
289
+ .filter((paymentId) => Boolean(paymentId));
290
+ const orderShippingAddressIds = orders
291
+ .map(({ shippingAddressId }) => shippingAddressId)
292
+ .filter((shippingAddressId) => Boolean(shippingAddressId));
293
+ if (orderIds.length > 0) {
294
+ yield prisma.orderItemTranslation.deleteMany({
295
+ where: {
296
+ orderItem: {
297
+ orderId: {
298
+ in: orderIds,
299
+ },
300
+ },
301
+ },
302
+ });
303
+ yield prisma.orderItem.deleteMany({
304
+ where: {
305
+ orderId: {
306
+ in: orderIds,
307
+ },
308
+ },
309
+ });
310
+ }
311
+ yield prisma.order.deleteMany({
312
+ where: {
313
+ organizationId,
314
+ },
315
+ });
316
+ if (paymentIds.length > 0) {
317
+ yield prisma.paymentSession.deleteMany({
318
+ where: {
319
+ paymentId: {
320
+ in: paymentIds,
321
+ },
322
+ },
323
+ });
324
+ yield prisma.payment.deleteMany({
325
+ where: {
326
+ id: {
327
+ in: paymentIds,
328
+ },
329
+ },
330
+ });
331
+ }
332
+ if (orderShippingAddressIds.length > 0) {
333
+ yield prisma.address.deleteMany({
334
+ where: {
335
+ id: {
336
+ in: orderShippingAddressIds,
337
+ },
338
+ },
339
+ });
340
+ }
341
+ yield prisma.reservation.deleteMany({
342
+ where: {
343
+ organizationId,
344
+ },
345
+ });
346
+ if (shippingMethodIds.length > 0) {
347
+ yield prisma.shippingZone.deleteMany({
348
+ where: {
349
+ shippingMethodId: {
350
+ in: shippingMethodIds,
351
+ },
352
+ },
353
+ });
354
+ }
355
+ yield prisma.shippingMethod.deleteMany({
356
+ where: {
357
+ organizationId,
358
+ },
359
+ });
360
+ yield prisma.product.updateMany({
361
+ where: {
362
+ organizationId,
363
+ },
364
+ data: {
365
+ latestSnapshotId: null,
366
+ },
367
+ });
368
+ if (productIds.length > 0) {
369
+ yield prisma.productSnapshot.deleteMany({
370
+ where: {
371
+ productId: {
372
+ in: productIds,
373
+ },
374
+ },
375
+ });
376
+ yield prisma.productTranslation.deleteMany({
377
+ where: {
378
+ productId: {
379
+ in: productIds,
380
+ },
381
+ },
382
+ });
383
+ }
384
+ yield prisma.product.deleteMany({
385
+ where: {
386
+ organizationId,
387
+ },
388
+ });
389
+ if (modifierGroupIds.length > 0) {
390
+ yield prisma.modifier.deleteMany({
391
+ where: {
392
+ modifierGroupId: {
393
+ in: modifierGroupIds,
394
+ },
395
+ },
396
+ });
397
+ yield prisma.modifierGroupTranslation.deleteMany({
398
+ where: {
399
+ modifierGroupId: {
400
+ in: modifierGroupIds,
401
+ },
402
+ },
403
+ });
404
+ yield prisma.modifierGroup.deleteMany({
405
+ where: {
406
+ id: {
407
+ in: modifierGroupIds,
408
+ },
409
+ },
410
+ });
411
+ }
412
+ if (productCategoryIds.length > 0) {
413
+ yield prisma.productCategoryTranslation.deleteMany({
414
+ where: {
415
+ productCategoryId: {
416
+ in: productCategoryIds,
417
+ },
418
+ },
419
+ });
420
+ }
421
+ yield prisma.productCategory.deleteMany({
422
+ where: {
423
+ organizationId,
424
+ },
425
+ });
426
+ if (manufacturerIds.length > 0) {
427
+ yield prisma.manufacturerTranslation.deleteMany({
428
+ where: {
429
+ manufacturerId: {
430
+ in: manufacturerIds,
431
+ },
432
+ },
433
+ });
434
+ }
435
+ yield prisma.manufacturer.deleteMany({
436
+ where: {
437
+ organizationId,
438
+ },
439
+ });
440
+ });
441
+ export const resetManufacturerResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
442
+ const manufacturers = yield prisma.manufacturer.findMany({
443
+ where: {
444
+ organizationId,
445
+ },
446
+ select: {
447
+ id: true,
448
+ },
449
+ });
450
+ const manufacturerIds = manufacturers.map(({ id }) => id);
451
+ if (manufacturerIds.length > 0) {
452
+ yield prisma.manufacturerTranslation.deleteMany({
453
+ where: {
454
+ manufacturerId: {
455
+ in: manufacturerIds,
456
+ },
457
+ },
458
+ });
459
+ }
460
+ yield prisma.manufacturer.deleteMany({
461
+ where: {
462
+ organizationId,
463
+ },
464
+ });
465
+ });
466
+ export const resetProductCategoryResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
467
+ const productCategories = yield prisma.productCategory.findMany({
468
+ where: {
469
+ organizationId,
470
+ },
471
+ select: {
472
+ id: true,
473
+ },
474
+ });
475
+ const productCategoryIds = productCategories.map(({ id }) => id);
476
+ if (productCategoryIds.length > 0) {
477
+ yield prisma.productCategoryTranslation.deleteMany({
478
+ where: {
479
+ productCategoryId: {
480
+ in: productCategoryIds,
481
+ },
482
+ },
483
+ });
484
+ }
485
+ yield prisma.productCategory.deleteMany({
486
+ where: {
487
+ organizationId,
488
+ },
489
+ });
490
+ });
491
+ export const resetProductResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
492
+ const [products, modifierGroups] = yield Promise.all([
493
+ prisma.product.findMany({
494
+ where: {
495
+ organizationId,
496
+ },
497
+ select: {
498
+ id: true,
499
+ },
500
+ }),
501
+ prisma.modifierGroup.findMany({
502
+ where: {
503
+ products: {
504
+ some: {
505
+ organizationId,
506
+ },
507
+ },
508
+ },
509
+ select: {
510
+ id: true,
511
+ },
512
+ }),
513
+ ]);
514
+ const productIds = products.map(({ id }) => id);
515
+ const modifierGroupIds = modifierGroups.map(({ id }) => id);
516
+ yield prisma.product.updateMany({
517
+ where: {
518
+ organizationId,
519
+ },
520
+ data: {
521
+ latestSnapshotId: null,
522
+ },
523
+ });
524
+ if (productIds.length > 0) {
525
+ yield prisma.productSnapshot.deleteMany({
526
+ where: {
527
+ productId: {
528
+ in: productIds,
529
+ },
530
+ },
531
+ });
532
+ yield prisma.productTranslation.deleteMany({
533
+ where: {
534
+ productId: {
535
+ in: productIds,
536
+ },
537
+ },
538
+ });
539
+ }
540
+ yield prisma.product.deleteMany({
541
+ where: {
542
+ organizationId,
543
+ },
544
+ });
545
+ if (modifierGroupIds.length > 0) {
546
+ yield prisma.modifier.deleteMany({
547
+ where: {
548
+ modifierGroupId: {
549
+ in: modifierGroupIds,
550
+ },
551
+ },
552
+ });
553
+ yield prisma.modifierGroupTranslation.deleteMany({
554
+ where: {
555
+ modifierGroupId: {
556
+ in: modifierGroupIds,
557
+ },
558
+ },
559
+ });
560
+ yield prisma.modifierGroup.deleteMany({
561
+ where: {
562
+ id: {
563
+ in: modifierGroupIds,
564
+ },
565
+ },
566
+ });
567
+ }
568
+ });
569
+ export const resetOrganizationResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
570
+ yield prisma.$transaction((tx) => __awaiter(void 0, void 0, void 0, function* () {
571
+ yield deleteOrganizationResources(tx, organizationId);
572
+ }));
573
+ });
574
+ export const hardDeleteOrganization = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
575
+ const organization = yield prisma.organization.findUnique({
576
+ where: {
577
+ id: organizationId,
578
+ },
579
+ select: {
580
+ addressId: true,
581
+ configurationId: true,
582
+ },
583
+ });
584
+ if (!organization) {
585
+ return;
586
+ }
587
+ const configuration = yield prisma.organizationConfiguration.findUnique({
588
+ where: {
589
+ id: organization.configurationId,
590
+ },
591
+ select: {
592
+ closingTimesId: true,
593
+ openingTimesId: true,
594
+ },
595
+ });
596
+ yield prisma.$transaction((tx) => __awaiter(void 0, void 0, void 0, function* () {
597
+ yield deleteOrganizationResources(tx, organizationId);
598
+ yield tx.organization.deleteMany({
599
+ where: {
600
+ id: organizationId,
601
+ },
602
+ });
603
+ yield tx.organizationConfiguration.deleteMany({
604
+ where: {
605
+ id: organization.configurationId,
606
+ },
607
+ });
608
+ if (configuration === null || configuration === void 0 ? void 0 : configuration.openingTimesId) {
609
+ yield tx.openingTimes.deleteMany({
610
+ where: {
611
+ id: configuration.openingTimesId,
612
+ },
613
+ });
614
+ }
615
+ if (configuration === null || configuration === void 0 ? void 0 : configuration.closingTimesId) {
616
+ yield tx.closingTimes.deleteMany({
617
+ where: {
618
+ id: configuration.closingTimesId,
619
+ },
620
+ });
621
+ }
622
+ yield tx.address.deleteMany({
623
+ where: {
624
+ id: organization.addressId,
625
+ },
626
+ });
627
+ }));
628
+ });
629
+ const deleteUserShippingAddresses = (prisma, userId) => __awaiter(void 0, void 0, void 0, function* () {
630
+ const shippingAddresses = yield prisma.address.findMany({
631
+ where: {
632
+ users: {
633
+ some: {
634
+ id: userId,
635
+ },
636
+ },
637
+ },
638
+ select: {
639
+ id: true,
640
+ },
641
+ });
642
+ if (shippingAddresses.length === 0) {
643
+ return;
644
+ }
645
+ yield prisma.address.deleteMany({
646
+ where: {
647
+ id: {
648
+ in: shippingAddresses.map(({ id }) => id),
649
+ },
650
+ },
651
+ });
652
+ });
653
+ export const resetUserShippingAddresses = deleteUserShippingAddresses;
654
+ export const resetFileResources = (prisma, userId) => __awaiter(void 0, void 0, void 0, function* () {
655
+ yield prisma.file.deleteMany({
656
+ where: {
657
+ createdBy: userId,
658
+ },
659
+ });
660
+ });
661
+ export const resetReservationResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
662
+ yield prisma.reservation.deleteMany({
663
+ where: {
664
+ organizationId,
665
+ },
666
+ });
667
+ });
668
+ export const resetShippingMethodResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
669
+ const shippingMethods = yield prisma.shippingMethod.findMany({
670
+ where: {
671
+ organizationId,
672
+ },
673
+ select: {
674
+ id: true,
675
+ },
676
+ });
677
+ const shippingMethodIds = shippingMethods.map(({ id }) => id);
678
+ if (shippingMethodIds.length > 0) {
679
+ yield prisma.shippingZone.deleteMany({
680
+ where: {
681
+ shippingMethodId: {
682
+ in: shippingMethodIds,
683
+ },
684
+ },
685
+ });
686
+ }
687
+ yield prisma.shippingMethod.deleteMany({
688
+ where: {
689
+ organizationId,
690
+ },
691
+ });
692
+ });
693
+ export const resetOrderResources = (prisma, organizationId) => __awaiter(void 0, void 0, void 0, function* () {
694
+ const orders = yield prisma.order.findMany({
695
+ where: {
696
+ organizationId,
697
+ },
698
+ select: {
699
+ id: true,
700
+ paymentId: true,
701
+ shippingAddressId: true,
702
+ },
703
+ });
704
+ const orderIds = orders.map(({ id }) => id);
705
+ const paymentIds = orders
706
+ .map(({ paymentId }) => paymentId)
707
+ .filter((paymentId) => Boolean(paymentId));
708
+ const orderShippingAddressIds = orders
709
+ .map(({ shippingAddressId }) => shippingAddressId)
710
+ .filter((shippingAddressId) => Boolean(shippingAddressId));
711
+ if (orderIds.length > 0) {
712
+ yield prisma.orderItemTranslation.deleteMany({
713
+ where: {
714
+ orderItem: {
715
+ orderId: {
716
+ in: orderIds,
717
+ },
718
+ },
719
+ },
720
+ });
721
+ yield prisma.orderItem.deleteMany({
722
+ where: {
723
+ orderId: {
724
+ in: orderIds,
725
+ },
726
+ },
727
+ });
728
+ }
729
+ yield prisma.order.deleteMany({
730
+ where: {
731
+ organizationId,
732
+ },
733
+ });
734
+ if (paymentIds.length > 0) {
735
+ yield prisma.paymentSession.deleteMany({
736
+ where: {
737
+ paymentId: {
738
+ in: paymentIds,
739
+ },
740
+ },
741
+ });
742
+ yield prisma.payment.deleteMany({
743
+ where: {
744
+ id: {
745
+ in: paymentIds,
746
+ },
747
+ },
748
+ });
749
+ }
750
+ if (orderShippingAddressIds.length > 0) {
751
+ yield prisma.address.deleteMany({
752
+ where: {
753
+ id: {
754
+ in: orderShippingAddressIds,
755
+ },
756
+ },
757
+ });
758
+ }
759
+ });
760
+ const seedShippingAddress = (prisma, fixtureKey, userId) => __awaiter(void 0, void 0, void 0, function* () {
761
+ const shippingAddress = yield prisma.address.create({
762
+ data: {
763
+ firstname: "Fixture",
764
+ lastname: "Recipient",
765
+ phone: "+15550009999",
766
+ addressLineOne: "500 Market Street",
767
+ addressLineTwo: `Suite ${fixtureKey}`,
768
+ city: "New York",
769
+ country: "US",
770
+ createdBy: userId,
771
+ deliveryInstructions: "Leave at reception",
772
+ doorNumber: "10A",
773
+ isDefault: true,
774
+ latitude: 40.713,
775
+ longitude: -74.0055,
776
+ placeId: `fixture-shipping-${fixtureKey}`,
777
+ users: {
778
+ connect: {
779
+ id: userId,
780
+ },
781
+ },
782
+ zipCode: "10001",
783
+ },
784
+ select: {
785
+ id: true,
786
+ },
787
+ });
788
+ return shippingAddress;
789
+ });
790
+ const seedCatalog = (prisma, fixtureKey, organizationId, suffix, userId) => __awaiter(void 0, void 0, void 0, function* () {
791
+ const manufacturer = yield prisma.manufacturer.create({
792
+ data: {
793
+ createdBy: userId,
794
+ name: `Fixture Manufacturer ${fixtureKey} ${suffix}`,
795
+ organizationId,
796
+ translations: {
797
+ create: [
798
+ {
799
+ about: `About fixture manufacturer ${suffix} in English`,
800
+ createdBy: userId,
801
+ locale: "en",
802
+ },
803
+ {
804
+ about: `O producencie testowym ${suffix} po polsku`,
805
+ createdBy: userId,
806
+ locale: "pl",
807
+ },
808
+ ],
809
+ },
810
+ },
811
+ select: {
812
+ id: true,
813
+ },
814
+ });
815
+ const category = yield prisma.productCategory.create({
816
+ data: {
817
+ createdBy: userId,
818
+ organizationId,
819
+ slug: `fixture-category-${fixtureKey}-${suffix}`,
820
+ translations: {
821
+ create: [
822
+ {
823
+ createdBy: userId,
824
+ description: `Fixture category ${suffix} in English`,
825
+ locale: "en",
826
+ title: `Fixture Category ${suffix}`,
827
+ },
828
+ {
829
+ createdBy: userId,
830
+ description: `Kategoria testowa ${suffix} po polsku`,
831
+ locale: "pl",
832
+ title: `Kategoria Testowa ${suffix}`,
833
+ },
834
+ ],
835
+ },
836
+ },
837
+ select: {
838
+ id: true,
839
+ },
840
+ });
841
+ const product = yield prisma.product.create({
842
+ data: {
843
+ basePrice: 24.99,
844
+ categories: {
845
+ connect: {
846
+ id: category.id,
847
+ },
848
+ },
849
+ createdBy: userId,
850
+ currency: "USD",
851
+ discountedBasePrice: 19.99,
852
+ manufacturerId: manufacturer.id,
853
+ metadata: {
854
+ fixtureKey,
855
+ suffix,
856
+ },
857
+ modifierGroups: {
858
+ create: [],
859
+ },
860
+ organizationId,
861
+ sku: `fixture-sku-${fixtureKey}-${suffix}`,
862
+ slug: `fixture-product-${fixtureKey}-${suffix}`,
863
+ tags: [],
864
+ translations: {
865
+ create: [
866
+ {
867
+ createdBy: userId,
868
+ description: `Fixture product ${suffix} in English`,
869
+ locale: "en",
870
+ title: `Fixture Product ${suffix}`,
871
+ },
872
+ {
873
+ createdBy: userId,
874
+ description: `Produkt testowy ${suffix} po polsku`,
875
+ locale: "pl",
876
+ title: `Produkt Testowy ${suffix}`,
877
+ },
878
+ ],
879
+ },
880
+ },
881
+ select: {
882
+ id: true,
883
+ },
884
+ });
885
+ const snapshot = yield prisma.productSnapshot.create({
886
+ data: {
887
+ createdBy: userId,
888
+ data: {
889
+ id: product.id,
890
+ sku: `fixture-sku-${fixtureKey}-${suffix}`,
891
+ title: `Fixture Product ${suffix}`,
892
+ },
893
+ productId: product.id,
894
+ },
895
+ select: {
896
+ id: true,
897
+ },
898
+ });
899
+ yield prisma.product.update({
900
+ where: {
901
+ id: product.id,
902
+ },
903
+ data: {
904
+ latestSnapshotId: snapshot.id,
905
+ },
906
+ });
907
+ return {
908
+ categoryId: category.id,
909
+ manufacturerId: manufacturer.id,
910
+ productId: product.id,
911
+ productSnapshotId: snapshot.id,
912
+ };
913
+ });
914
+ const seedShippingMethod = (prisma, fixtureKey, organizationId, suffix, userId) => __awaiter(void 0, void 0, void 0, function* () {
915
+ const shippingMethod = yield prisma.shippingMethod.create({
916
+ data: {
917
+ createdBy: userId,
918
+ organizationId,
919
+ providerName: `Fixture Provider ${suffix}`,
920
+ requireDateOfDelivery: false,
921
+ shippingZones: {
922
+ create: [
923
+ {
924
+ distanceUpto: 10,
925
+ eta: "30-45 min",
926
+ minimumOrderAmount: 0,
927
+ price: 4.99,
928
+ title: `Fixture Zone ${suffix}`,
929
+ },
930
+ ],
931
+ },
932
+ title: `Fixture Shipping ${fixtureKey} ${suffix}`,
933
+ },
934
+ select: {
935
+ id: true,
936
+ },
937
+ });
938
+ return shippingMethod;
939
+ });
940
+ const seedFixtureGraph = (prisma, fixtureKey, userId, options, organizations) => __awaiter(void 0, void 0, void 0, function* () {
941
+ const fixture = {
942
+ primaryOrganization: organizations.primaryOrganization,
943
+ secondaryOrganization: organizations.secondaryOrganization,
944
+ };
945
+ if (options.includeDefaultShippingAddress) {
946
+ fixture.defaultShippingAddress = yield seedShippingAddress(prisma, fixtureKey, userId);
947
+ }
948
+ if (options.includePrimaryCatalog) {
949
+ fixture.primaryCatalog = yield seedCatalog(prisma, fixtureKey, organizations.primaryOrganization.id, "primary", userId);
950
+ }
951
+ if (options.includeSecondaryCatalog) {
952
+ fixture.secondaryCatalog = yield seedCatalog(prisma, fixtureKey, organizations.secondaryOrganization.id, "secondary", userId);
953
+ }
954
+ if (options.includePrimaryShippingMethod) {
955
+ fixture.primaryShippingMethod = yield seedShippingMethod(prisma, fixtureKey, organizations.primaryOrganization.id, "primary", userId);
956
+ }
957
+ if (options.includeSecondaryShippingMethod) {
958
+ fixture.secondaryShippingMethod = yield seedShippingMethod(prisma, fixtureKey, organizations.secondaryOrganization.id, "secondary", userId);
959
+ }
960
+ return fixture;
961
+ });
962
+ export const ensureSeededTestFixture = (prisma_1, fixtureKey_1, ...args_1) => __awaiter(void 0, [prisma_1, fixtureKey_1, ...args_1], void 0, function* (prisma, fixtureKey, graph = {}) {
963
+ const dbUser = yield ensureSeededUser(prisma, fixtureKey);
964
+ const authUser = toAuthUser(dbUser);
965
+ const primaryOrganization = yield ensureSeededOrganization(prisma, fixtureKey, "primary", dbUser.id);
966
+ const secondaryOrganization = yield ensureSeededOrganization(prisma, fixtureKey, "secondary", dbUser.id);
967
+ yield resetOrganizationResources(prisma, primaryOrganization.id);
968
+ yield resetOrganizationResources(prisma, secondaryOrganization.id);
969
+ yield deleteUserShippingAddresses(prisma, dbUser.id);
970
+ const fixture = yield seedFixtureGraph(prisma, fixtureKey, dbUser.id, graph, {
971
+ primaryOrganization,
972
+ secondaryOrganization,
973
+ });
974
+ return {
975
+ authUser,
976
+ dbUser,
977
+ fixture,
978
+ };
979
+ });
980
+ export const createSeededApiContext = (prisma, context, appOptions = {}) => {
981
+ return {
982
+ app: createAuthenticatedApiApp(prisma, context.authUser, appOptions),
983
+ authUser: context.authUser,
984
+ dbUser: context.dbUser,
985
+ fixture: context.fixture,
986
+ };
987
+ };
988
+ export const createSeededTestContext = (prisma_1, fixtureKey_1, ...args_1) => __awaiter(void 0, [prisma_1, fixtureKey_1, ...args_1], void 0, function* (prisma, fixtureKey, options = {}) {
989
+ const seededFixture = yield ensureSeededTestFixture(prisma, fixtureKey, options.graph);
990
+ const appContext = createSeededApiContext(prisma, seededFixture, options.appOptions);
991
+ return Object.assign(Object.assign({}, appContext), { cleanup: () => __awaiter(void 0, void 0, void 0, function* () {
992
+ yield resetOrganizationResources(prisma, seededFixture.fixture.primaryOrganization.id);
993
+ yield resetOrganizationResources(prisma, seededFixture.fixture.secondaryOrganization.id);
994
+ yield deleteUserShippingAddresses(prisma, seededFixture.dbUser.id);
995
+ }) });
996
+ });
997
+ export const cleanupTestUser = (prisma, userId) => __awaiter(void 0, void 0, void 0, function* () {
998
+ const [memberships, shippingAddresses] = yield Promise.all([
999
+ prisma.member.findMany({
1000
+ where: {
1001
+ userId,
1002
+ },
1003
+ select: {
1004
+ organizationId: true,
1005
+ },
1006
+ }),
1007
+ prisma.address.findMany({
1008
+ where: {
1009
+ users: {
1010
+ some: {
1011
+ id: userId,
1012
+ },
1013
+ },
1014
+ },
1015
+ select: {
1016
+ id: true,
1017
+ },
1018
+ }),
1019
+ ]);
1020
+ const organizationIds = [
1021
+ ...new Set(memberships.map(({ organizationId }) => organizationId)),
1022
+ ];
1023
+ const shippingAddressIds = shippingAddresses.map(({ id }) => id);
1024
+ for (const organizationId of organizationIds) {
1025
+ yield hardDeleteOrganization(prisma, organizationId);
1026
+ }
1027
+ yield prisma.$transaction((tx) => __awaiter(void 0, void 0, void 0, function* () {
1028
+ yield tx.session.deleteMany({
1029
+ where: {
1030
+ userId,
1031
+ },
1032
+ });
1033
+ yield tx.account.deleteMany({
1034
+ where: {
1035
+ userId,
1036
+ },
1037
+ });
1038
+ yield tx.invitation.deleteMany({
1039
+ where: {
1040
+ inviterId: userId,
1041
+ },
1042
+ });
1043
+ yield tx.member.deleteMany({
1044
+ where: {
1045
+ userId,
1046
+ },
1047
+ });
1048
+ yield tx.user.deleteMany({
1049
+ where: {
1050
+ id: userId,
1051
+ },
1052
+ });
1053
+ if (shippingAddressIds.length > 0) {
1054
+ yield tx.address.deleteMany({
1055
+ where: {
1056
+ id: {
1057
+ in: shippingAddressIds,
1058
+ },
1059
+ },
1060
+ });
1061
+ }
1062
+ }));
1063
+ });
1064
+ export const createAuthenticatedApiApp = (prisma, authUser, options = {}) => {
1065
+ return buildApiApp(Object.assign(Object.assign({}, options), { maps: Object.assign({ google: {
1066
+ key: GOOGLE_MAPS_TEST_KEY,
1067
+ } }, options.maps), prisma, resolveAuth: (_request, path) => ({
1068
+ getCurrentUser: () => __awaiter(void 0, void 0, void 0, function* () { return authUser; }),
1069
+ isGranted: () => __awaiter(void 0, void 0, void 0, function* () {
1070
+ const organizationId = getOrganizationIdFromPath(path);
1071
+ if (!organizationId) {
1072
+ return authUser;
1073
+ }
1074
+ const membership = yield prisma.member.findFirst({
1075
+ where: {
1076
+ organizationId,
1077
+ userId: authUser.id,
1078
+ },
1079
+ });
1080
+ if (!membership) {
1081
+ throw new HttpException(403, "Forbidden");
1082
+ }
1083
+ return authUser;
1084
+ }),
1085
+ }) }));
1086
+ };
1087
+ export const createAuthenticatedTestContext = (prisma_1, ...args_1) => __awaiter(void 0, [prisma_1, ...args_1], void 0, function* (prisma, options = {}) {
1088
+ const dbUser = yield createTestUser(prisma);
1089
+ const authUser = toAuthUser(dbUser);
1090
+ const app = createAuthenticatedApiApp(prisma, authUser, options);
1091
+ return {
1092
+ app,
1093
+ authUser,
1094
+ dbUser,
1095
+ cleanup: () => __awaiter(void 0, void 0, void 0, function* () {
1096
+ yield cleanupTestUser(prisma, dbUser.id);
1097
+ }),
1098
+ };
1099
+ });
1100
+ //# sourceMappingURL=test-helpers.js.map