@shophost/rest-api 2.0.30 → 2.0.31

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 +110 -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,225 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { randomUUID } from "node:crypto";
3
- import { vi } from "vitest";
4
- import { LocationService } from "../../features/location/location.service";
5
- export const requestJson = (context, path, options) => __awaiter(void 0, void 0, void 0, function* () {
6
- return context.app.request(path, {
7
- method: options.method,
8
- headers: options.body === undefined
9
- ? undefined
10
- : {
11
- "content-type": "application/json",
12
- },
13
- body: options.body === undefined ? undefined : JSON.stringify(options.body),
14
- });
15
- });
16
- export const mockPlaceDetails = () => {
17
- return vi.spyOn(LocationService.prototype, "getPlaceDetails").mockResolvedValue({
18
- addressLineOne: "123 Main Street",
19
- city: "New York",
20
- country: "US",
21
- latitude: 40.7128,
22
- longitude: -74.006,
23
- zipCode: "10001",
24
- });
25
- };
26
- export const buildOrganizationPayload = (suffix = randomUUID()) => ({
27
- name: `Integration Org ${suffix}`,
28
- phone: "+15550001111",
29
- email: `org-${suffix}@shophost.test`,
30
- address: {
31
- addressLineOne: "123 Main Street",
32
- addressLineTwo: "Suite 10",
33
- city: "New York",
34
- country: "US",
35
- doorNumber: "10A",
36
- placeId: `place-${suffix}`,
37
- zipCode: "10001",
38
- },
39
- });
40
- export const createOrganization = (context_1, ...args_1) => __awaiter(void 0, [context_1, ...args_1], void 0, function* (context, suffix = randomUUID()) {
41
- const response = yield requestJson(context, "/organizations", {
42
- method: "POST",
43
- body: buildOrganizationPayload(suffix),
44
- });
45
- return response;
46
- });
47
- export const buildManufacturerPayload = (suffix = randomUUID()) => ({
48
- name: `Manufacturer ${suffix}`,
49
- defaultLocale: "en",
50
- translations: [
51
- {
52
- locale: "en",
53
- about: `About ${suffix} in English`,
54
- },
55
- {
56
- locale: "pl",
57
- about: `O producencie ${suffix} po polsku`,
58
- },
59
- ],
60
- });
61
- export const createManufacturer = (context_1, organizationId_1, ...args_1) => __awaiter(void 0, [context_1, organizationId_1, ...args_1], void 0, function* (context, organizationId, suffix = randomUUID()) {
62
- const response = yield requestJson(context, `/${organizationId}/manufacturers`, {
63
- method: "POST",
64
- body: buildManufacturerPayload(suffix),
65
- });
66
- return response;
67
- });
68
- export const buildProductCategoryPayload = (suffix = randomUUID()) => ({
69
- slug: `category-${suffix}`,
70
- defaultLocale: "en",
71
- translations: [
72
- {
73
- locale: "en",
74
- title: `Category ${suffix}`,
75
- description: `Description for ${suffix} in English`,
76
- },
77
- {
78
- locale: "pl",
79
- title: `Kategoria ${suffix}`,
80
- description: `Opis ${suffix} po polsku`,
81
- },
82
- ],
83
- });
84
- export const createProductCategory = (context_1, organizationId_1, ...args_1) => __awaiter(void 0, [context_1, organizationId_1, ...args_1], void 0, function* (context, organizationId, suffix = randomUUID()) {
85
- const response = yield requestJson(context, `/${organizationId}/product-categories`, {
86
- method: "POST",
87
- body: buildProductCategoryPayload(suffix),
88
- });
89
- return response;
90
- });
91
- export const buildProductPayload = ({ categoryIds = [], manufacturerId = null, modifierGroups = [
92
- {
93
- defaultLocale: "en",
94
- selectMin: 0,
95
- selectMax: 1,
96
- translations: [
97
- {
98
- locale: "en",
99
- title: "Size",
100
- },
101
- {
102
- locale: "pl",
103
- title: "Rozmiar",
104
- },
105
- ],
106
- modifiers: [
107
- {
108
- title: "Large",
109
- price: 2.5,
110
- },
111
- ],
112
- },
113
- ], suffix = randomUUID(), } = {}) => ({
114
- slug: `product-${suffix}`,
115
- sku: `sku-${suffix}`,
116
- basePrice: 24.99,
117
- discountedBasePrice: 19.99,
118
- currency: "USD",
119
- defaultLocale: "en",
120
- manufacturerId,
121
- categories: categoryIds,
122
- modifierGroups,
123
- translations: [
124
- {
125
- locale: "en",
126
- title: `Product ${suffix}`,
127
- description: `Description for ${suffix} in English`,
128
- },
129
- {
130
- locale: "pl",
131
- title: `Produkt ${suffix}`,
132
- description: `Opis ${suffix} po polsku`,
133
- },
134
- ],
135
- metadata: {
136
- origin: "integration-test",
137
- skuSuffix: suffix,
138
- },
139
- });
140
- export const createProduct = (context_1, organizationId_1, ...args_1) => __awaiter(void 0, [context_1, organizationId_1, ...args_1], void 0, function* (context, organizationId, options = {}) {
141
- const response = yield requestJson(context, `/${organizationId}/products`, {
142
- method: "POST",
143
- body: buildProductPayload(options),
144
- });
145
- return response;
146
- });
147
- export const buildShippingAddressPayload = (suffix = randomUUID()) => ({
148
- firstname: "Integration",
149
- lastname: "Tester",
150
- phone: "+15550009999",
151
- addressLineOne: "500 Market Street",
152
- addressLineTwo: `Suite ${suffix}`,
153
- doorNumber: "10A",
154
- city: "New York",
155
- country: "US",
156
- zipCode: "10001",
157
- placeId: `shipping-${suffix}`,
158
- deliveryInstructions: "Leave at reception",
159
- });
160
- export const createShippingAddress = (context_1, ...args_1) => __awaiter(void 0, [context_1, ...args_1], void 0, function* (context, suffix = randomUUID()) {
161
- const response = yield requestJson(context, "/shipping", {
162
- method: "POST",
163
- body: buildShippingAddressPayload(suffix),
164
- });
165
- return response;
166
- });
167
- export const buildShippingMethodPayload = (suffix = randomUUID()) => ({
168
- title: `Shipping ${suffix}`,
169
- providerName: `Provider ${suffix}`,
170
- requireDateOfDelivery: false,
171
- shippingZones: [
172
- {
173
- title: `Zone ${suffix}`,
174
- distanceUpto: 10,
175
- price: 4.99,
176
- minimumOrderAmount: 0,
177
- eta: "30-45 min",
178
- },
179
- ],
180
- });
181
- export const createShippingMethod = (context_1, organizationId_1, ...args_1) => __awaiter(void 0, [context_1, organizationId_1, ...args_1], void 0, function* (context, organizationId, suffix = randomUUID()) {
182
- const response = yield requestJson(context, `/${organizationId}/shipping-methods`, {
183
- method: "POST",
184
- body: buildShippingMethodPayload(suffix),
185
- });
186
- return response;
187
- });
188
- export const buildReservationPayload = (suffix = randomUUID()) => ({
189
- firstname: "Reservation",
190
- lastname: `Guest ${suffix}`,
191
- guests: 4,
192
- phone: "+15550002222",
193
- date: "2030-01-01T18:30:00.000Z",
194
- });
195
- export const createReservation = (context_1, organizationId_1, ...args_1) => __awaiter(void 0, [context_1, organizationId_1, ...args_1], void 0, function* (context, organizationId, suffix = randomUUID()) {
196
- const response = yield requestJson(context, `/${organizationId}/reservations`, {
197
- method: "POST",
198
- body: buildReservationPayload(suffix),
199
- });
200
- return response;
201
- });
202
- export const buildOrderPayload = ({ checkoutBaseUrl = "https://example.com", productId, shippingMethodId, }) => ({
203
- items: [
204
- {
205
- productId,
206
- quantity: 2,
207
- modifierGroups: [],
208
- },
209
- ],
210
- fulfilmentMethod: shippingMethodId ? "delivery" : "pickup",
211
- shippingMethodId,
212
- payment: {
213
- provider: "stripe",
214
- method: "card",
215
- },
216
- checkoutBaseUrl,
217
- });
218
- export const createOrder = (context, organizationId, payload) => __awaiter(void 0, void 0, void 0, function* () {
219
- const response = yield requestJson(context, `/${organizationId}/orders`, {
220
- method: "POST",
221
- body: buildOrderPayload(payload),
222
- });
223
- return response;
224
- });
225
- //# sourceMappingURL=api-fixtures.js.map
1
+ import{__awaiter as e}from"tslib";import{randomUUID as t}from"node:crypto";import{vi as o}from"vitest";import{LocationService as i}from"../../features/location/location.service";export const requestJson=(t,o,i)=>e(void 0,void 0,void 0,function*(){return t.app.request(o,{method:i.method,headers:void 0===i.body?void 0:{"content-type":"application/json"},body:void 0===i.body?void 0:JSON.stringify(i.body)})});export const mockPlaceDetails=()=>o.spyOn(i.prototype,"getPlaceDetails").mockResolvedValue({addressLineOne:"123 Main Street",city:"New York",country:"US",latitude:40.7128,longitude:-74.006,zipCode:"10001"});export const buildOrganizationPayload=(e=t())=>({name:`Integration Org ${e}`,phone:"+15550001111",email:`org-${e}@shophost.test`,address:{addressLineOne:"123 Main Street",addressLineTwo:"Suite 10",city:"New York",country:"US",doorNumber:"10A",placeId:`place-${e}`,zipCode:"10001"}});export const buildManufacturerPayload=(e=t())=>({name:`Manufacturer ${e}`,defaultLocale:"en",translations:[{locale:"en",about:`About ${e} in English`},{locale:"pl",about:`O producencie ${e} po polsku`}]});export const buildProductCategoryPayload=(e=t())=>({slug:`category-${e}`,defaultLocale:"en",translations:[{locale:"en",title:`Category ${e}`,description:`Description for ${e} in English`},{locale:"pl",title:`Kategoria ${e}`,description:`Opis ${e} po polsku`}]});export const buildProductPayload=({categoryIds:e=[],manufacturerId:o=null,modifierGroups:i=[{defaultLocale:"en",selectMin:0,selectMax:1,translations:[{locale:"en",title:"Size"},{locale:"pl",title:"Rozmiar"}],modifiers:[{title:"Large",price:2.5}]}],suffix:r=t()}={})=>({slug:`product-${r}`,sku:`sku-${r}`,basePrice:24.99,discountedBasePrice:19.99,currency:"USD",defaultLocale:"en",manufacturerId:o,categories:e,modifierGroups:i,translations:[{locale:"en",title:`Product ${r}`,description:`Description for ${r} in English`},{locale:"pl",title:`Produkt ${r}`,description:`Opis ${r} po polsku`}],metadata:{origin:"integration-test",skuSuffix:r}});export const buildShippingAddressPayload=(e=t())=>({firstname:"Integration",lastname:"Tester",phone:"+15550009999",addressLineOne:"500 Market Street",addressLineTwo:`Suite ${e}`,doorNumber:"10A",city:"New York",country:"US",zipCode:"10001",placeId:`shipping-${e}`,deliveryInstructions:"Leave at reception"});export const buildShippingMethodPayload=(e=t())=>({title:`Shipping ${e}`,providerName:`Provider ${e}`,requireDateOfDelivery:!1,shippingZones:[{title:`Zone ${e}`,distanceUpto:10,price:4.99,minimumOrderAmount:0,eta:"30-45 min"}]});export const buildReservationPayload=(e=t())=>({firstname:"Reservation",lastname:`Guest ${e}`,guests:4,phone:"+15550002222",date:"2030-01-01T18:30:00.000Z"});export const buildOrderPayload=({checkoutBaseUrl:e="https://example.com",productId:t,shippingMethodId:o})=>({items:[{productId:t,quantity:2,modifierGroups:[]}],fulfilmentMethod:o?"delivery":"pickup",shippingMethodId:o,payment:{provider:"stripe",method:"card"},checkoutBaseUrl:e});
@@ -0,0 +1,81 @@
1
+ import type { PrismaClientType } from "../../core/lib/prisma";
2
+ export declare const SEED: {
3
+ readonly users: {
4
+ readonly owner: {
5
+ readonly id: "test-owner-user-00000001";
6
+ readonly email: "owner@shophost.test";
7
+ readonly firstname: "Test";
8
+ readonly lastname: "Owner";
9
+ readonly name: "Test Owner";
10
+ readonly image: null;
11
+ };
12
+ readonly outsider: {
13
+ readonly id: "test-outsider-user-00002";
14
+ readonly email: "outsider@shophost.test";
15
+ readonly firstname: "Test";
16
+ readonly lastname: "Outsider";
17
+ readonly name: "Test Outsider";
18
+ readonly image: null;
19
+ };
20
+ };
21
+ readonly organizations: {
22
+ readonly primary: {
23
+ readonly id: "cseedorgprimary000001";
24
+ readonly slug: "test-primary";
25
+ readonly name: "Test Primary Organization";
26
+ readonly email: "primary@shophost.test";
27
+ readonly phone: "+15550001111";
28
+ readonly addressId: "cseedaddrorgprim00001";
29
+ readonly configurationId: "cseedcfgprimary000001";
30
+ };
31
+ readonly secondary: {
32
+ readonly id: "cseedorgsecondary0001";
33
+ readonly slug: "test-secondary";
34
+ readonly name: "Test Secondary Organization";
35
+ readonly email: "secondary@shophost.test";
36
+ readonly phone: "+15550002222";
37
+ readonly addressId: "cseedaddrorgsec000001";
38
+ readonly configurationId: "cseedcfgsecondary0001";
39
+ };
40
+ };
41
+ readonly memberships: {
42
+ readonly ownerPrimary: {
43
+ readonly id: "cseedmbrownerprim0001";
44
+ };
45
+ readonly ownerSecondary: {
46
+ readonly id: "cseedmbrownersec00001";
47
+ };
48
+ };
49
+ readonly catalog: {
50
+ readonly primary: {
51
+ readonly categoryId: "cseedcatprimary000001";
52
+ readonly manufacturerId: "cseedmfgprimary000001";
53
+ readonly productId: "cseedprdprimary000001";
54
+ readonly productSnapshotId: "cseedsnpprimary000001";
55
+ };
56
+ readonly secondary: {
57
+ readonly categoryId: "cseedcatsecondary0001";
58
+ readonly manufacturerId: "cseedmfgsecondary0001";
59
+ readonly productId: "cseedprdsecondary0001";
60
+ readonly productSnapshotId: "cseedsnpsecondary0001";
61
+ };
62
+ };
63
+ readonly shipping: {
64
+ readonly primary: {
65
+ readonly methodId: "cseedshpprimary000001";
66
+ readonly zoneId: "cseedzneprimary000001";
67
+ };
68
+ readonly secondary: {
69
+ readonly methodId: "cseedshpsecondary0001";
70
+ readonly zoneId: "cseedznrsecondary0001";
71
+ };
72
+ };
73
+ readonly addresses: {
74
+ readonly defaultShipping: {
75
+ readonly id: "cseedaddrshipping0001";
76
+ };
77
+ };
78
+ };
79
+ export declare const seedDatabase: (prisma: PrismaClientType) => Promise<void>;
80
+ export declare const TABLES: string[];
81
+ export declare const resetToSeed: (prisma: PrismaClientType) => Promise<void>;
@@ -0,0 +1 @@
1
+ import{__awaiter as e}from"tslib";export const SEED={users:{owner:{id:"test-owner-user-00000001",email:"owner@shophost.test",firstname:"Test",lastname:"Owner",name:"Test Owner",image:null},outsider:{id:"test-outsider-user-00002",email:"outsider@shophost.test",firstname:"Test",lastname:"Outsider",name:"Test Outsider",image:null}},organizations:{primary:{id:"cseedorgprimary000001",slug:"test-primary",name:"Test Primary Organization",email:"primary@shophost.test",phone:"+15550001111",addressId:"cseedaddrorgprim00001",configurationId:"cseedcfgprimary000001"},secondary:{id:"cseedorgsecondary0001",slug:"test-secondary",name:"Test Secondary Organization",email:"secondary@shophost.test",phone:"+15550002222",addressId:"cseedaddrorgsec000001",configurationId:"cseedcfgsecondary0001"}},memberships:{ownerPrimary:{id:"cseedmbrownerprim0001"},ownerSecondary:{id:"cseedmbrownersec00001"}},catalog:{primary:{categoryId:"cseedcatprimary000001",manufacturerId:"cseedmfgprimary000001",productId:"cseedprdprimary000001",productSnapshotId:"cseedsnpprimary000001"},secondary:{categoryId:"cseedcatsecondary0001",manufacturerId:"cseedmfgsecondary0001",productId:"cseedprdsecondary0001",productSnapshotId:"cseedsnpsecondary0001"}},shipping:{primary:{methodId:"cseedshpprimary000001",zoneId:"cseedzneprimary000001"},secondary:{methodId:"cseedshpsecondary0001",zoneId:"cseedznrsecondary0001"}},addresses:{defaultShipping:{id:"cseedaddrshipping0001"}}};const a=new Date,r=SEED.users.owner.id;export const seedDatabase=t=>e(void 0,void 0,void 0,function*(){yield t.user.createMany({data:[{id:SEED.users.owner.id,email:SEED.users.owner.email,emailVerified:!1,firstname:SEED.users.owner.firstname,lastname:SEED.users.owner.lastname,name:SEED.users.owner.name,image:null,createdAt:a,updatedAt:a},{id:SEED.users.outsider.id,email:SEED.users.outsider.email,emailVerified:!1,firstname:SEED.users.outsider.firstname,lastname:SEED.users.outsider.lastname,name:SEED.users.outsider.name,image:null,createdAt:a,updatedAt:a}]}),yield t.address.createMany({data:[{id:SEED.organizations.primary.addressId,addressLineOne:"123 Main Street",addressLineTwo:"Suite 10",city:"New York",country:"US",doorNumber:"10A",latitude:40.7128,longitude:-74.006,zipCode:"10001",isDefault:!1,createdBy:r},{id:SEED.organizations.secondary.addressId,addressLineOne:"500 Lake Shore Drive",addressLineTwo:"Floor 4",city:"Chicago",country:"US",doorNumber:"4B",latitude:41.8781,longitude:-87.6298,zipCode:"60601",isDefault:!1,createdBy:r},{id:SEED.addresses.defaultShipping.id,firstname:"Test",lastname:"Owner",phone:"+15550009999",addressLineOne:"500 Market Street",addressLineTwo:"Suite A",city:"New York",country:"US",doorNumber:"10A",latitude:40.713,longitude:-74.0055,zipCode:"10001",placeId:"seed-shipping-address",deliveryInstructions:"Leave at reception",isDefault:!0,createdBy:r}]}),yield t.user.update({where:{id:r},data:{shippingAddresses:{connect:{id:SEED.addresses.defaultShipping.id}}}}),yield t.organizationConfiguration.createMany({data:[{id:SEED.organizations.primary.configurationId,countriesShipping:["US"],defaultCurrency:"USD",defaultLocale:"en",enableHostCheckout:!0,enableHostTracking:!0,hostname:"test-primary.shophost.test",isAcceptingOrders:!0,supportedLocales:["en","pl"],createdBy:r,updatedBy:r},{id:SEED.organizations.secondary.configurationId,countriesShipping:["US"],defaultCurrency:"USD",defaultLocale:"en",enableHostCheckout:!0,enableHostTracking:!0,hostname:"test-secondary.shophost.test",isAcceptingOrders:!0,supportedLocales:["en","pl"],createdBy:r,updatedBy:r}]}),yield t.organization.createMany({data:[{id:SEED.organizations.primary.id,name:SEED.organizations.primary.name,slug:SEED.organizations.primary.slug,email:SEED.organizations.primary.email,phone:SEED.organizations.primary.phone,addressId:SEED.organizations.primary.addressId,configurationId:SEED.organizations.primary.configurationId,createdBy:r},{id:SEED.organizations.secondary.id,name:SEED.organizations.secondary.name,slug:SEED.organizations.secondary.slug,email:SEED.organizations.secondary.email,phone:SEED.organizations.secondary.phone,addressId:SEED.organizations.secondary.addressId,configurationId:SEED.organizations.secondary.configurationId,createdBy:r}]}),yield t.member.createMany({data:[{id:SEED.memberships.ownerPrimary.id,organizationId:SEED.organizations.primary.id,userId:r,role:"owner"},{id:SEED.memberships.ownerSecondary.id,organizationId:SEED.organizations.secondary.id,userId:r,role:"owner"}]});for(const[e,d]of Object.entries(SEED.catalog)){const i=SEED.organizations[e].id;yield t.manufacturer.create({data:{id:d.manufacturerId,name:`Seed Manufacturer ${e}`,organizationId:i,createdBy:r,translations:{create:[{locale:"en",about:`About seed manufacturer ${e}`,createdBy:r},{locale:"pl",about:`O producencie ${e}`,createdBy:r}]}}}),yield t.productCategory.create({data:{id:d.categoryId,slug:`seed-category-${e}`,organizationId:i,createdBy:r,translations:{create:[{locale:"en",title:`Seed Category ${e}`,description:`Seed category ${e} in English`,createdBy:r},{locale:"pl",title:`Kategoria ${e}`,description:`Kategoria ${e} po polsku`,createdBy:r}]}}}),yield t.product.create({data:{id:d.productId,slug:`seed-product-${e}`,sku:`seed-sku-${e}`,basePrice:24.99,discountedBasePrice:19.99,currency:"USD",organizationId:i,manufacturerId:d.manufacturerId,tags:[],metadata:{seed:"true",variant:e},publishedAt:a,createdBy:r,categories:{connect:{id:d.categoryId}},translations:{create:[{locale:"en",title:`Seed Product ${e}`,description:`Seed product ${e} in English`,createdBy:r},{locale:"pl",title:`Produkt ${e}`,description:`Produkt ${e} po polsku`,createdBy:r}]}}}),yield t.productSnapshot.create({data:{id:d.productSnapshotId,productId:d.productId,data:{id:d.productId,sku:`seed-sku-${e}`,title:`Seed Product ${e}`},createdBy:r}}),yield t.product.update({where:{id:d.productId},data:{latestSnapshotId:d.productSnapshotId}});const o=SEED.shipping[e];yield t.shippingMethod.create({data:{id:o.methodId,title:`Seed Shipping ${e}`,providerName:`Seed Provider ${e}`,requireDateOfDelivery:!1,organizationId:i,createdBy:r,shippingZones:{create:{id:o.zoneId,title:`Seed Zone ${e}`,distanceUpto:10,price:4.99,minimumOrderAmount:0,eta:"30-45 min"}}}})}});export const TABLES=["OrderItemTranslation","OrderItem","Order","PaymentSession","Payment","Reservation","Campaign","ShippingZone","ShippingMethod","ProductSnapshot","ProductTranslation","Modifier","ModifierGroupTranslation","ModifierGroup","Product","ProductCategoryTranslation","ProductCategory","ManufacturerTranslation","Manufacturer","File","Invitation","Member","Organization","OrganizationConfiguration","OpeningTimes","ClosingTimes","LegalEntity","Address","Session","Account","Verification","User"];export const resetToSeed=a=>e(void 0,void 0,void 0,function*(){const e=TABLES.map(e=>`"${e}"`).join(", ");yield a.$executeRawUnsafe(`TRUNCATE TABLE ${e} CASCADE`),yield seedDatabase(a)});